PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.17
Yatra – Travel Booking & Tour Operator Software v3.0.17
3.0.17 3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 All 85 releases
yatra / assets / dist / js / Settings-NDffCp8Q.js

Settings-NDffCp8Q.js in Yatra – Travel Booking & Tour Operator Software 3.0.17, at assets/dist/js/Settings-NDffCp8Q.js

9,104 lines 464.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { r as reactExports, j as jsxRuntimeExports, ax as Plus, aO as Trash2, bc as GripVertical, aL as ArrowUp, aM as ArrowDown, bb as Lock, n as Star, aR as Eye, by as EyeOff, aV as Pen, bd as ChevronUp, y as ChevronDown, R as RotateCcw, v as useQueryClient, u as useQuery, a6 as React, w as useMutation, bO as Building2, bP as Palette, q as Calendar, bQ as ClipboardList, bR as SlidersHorizontal, at as DollarSign, bS as Percent, U as Users, bT as Receipt, b2 as Globe, bU as Plug, T as TrendingUp, av as Shield, E as Loader2, aW as Save, l as Settings$1, m as BarChart3, X as ExternalLink, O as RefreshCw, ay as X, aT as Image, aG as Info, d as Mail, aw as CheckCircle, b9 as XCircle, aB as Check, aA as AlertCircle, z as ChevronRight } from "./react-vendor-CithbthY.js";
2 import { a as apiClient, A as API_ENDPOINTS, _ as __, I as Input, s as sprintf, u as useToast, S as SearchableSelect, m as getCurrencyOptions, b as apiService } from "./index-Dec_weLB.js";
3 import { r as unwrapApiPayload, C as Card, f as CardHeader, g as CardTitle, B as Button, d as CardContent, s as Label, S as Select, k as ConfirmationDialog, t as useTripTargets, M as Modal, v as describeTargets, n as MultiSelect, w as decodeTargets, x as encodeTargets, y as hasTargets, u as usePermissions, P as PageHeader, z as ConditionalRender, E as CardFooter, F as PremiumUpgradeDialog, o as prepareWordPressMediaFrameOpen, G as buildYatraAccountViewUrl, J as navigateMenu, K as saveSettings, N as buildYatraListingPublicUrl, m as isWordPressPlainPermalink, O as postInsertBookingShortcode, Q as postFlushRewriteRules, U as fetchBookingPageShortcodeStatus, q as fetchSettings, V as fetchPaymentGatewayDefinitions, W as fetchWordPressPages } from "../../admin/dist/js/app.js";
4 import { P as ProBadge, a as ProFeature } from "./ProFeature-DE6oH70S.js";
5 async function fetchUsageTrackingStatus() {
6 return unwrapApiPayload(
7 await apiClient.get(API_ENDPOINTS.USAGE_TRACKING_STATUS)
8 );
9 }
10 async function postUsageTrackingSettings(enabled) {
11 return unwrapApiPayload(
12 await apiClient.post(API_ENDPOINTS.USAGE_TRACKING_SETTINGS, { enabled })
13 );
14 }
15 async function postUsageTrackingSend(options) {
16 const body = {};
17 if (options == null ? void 0 : options.force) {
18 body.force = true;
19 }
20 return apiClient.post(API_ENDPOINTS.USAGE_TRACKING_SEND, body);
21 }
22 const withOrder = (fields) => fields.map((field, i) => ({ ...field, order: i + 1 }));
23 const BookingFormFieldsEditor = ({
24 formType,
25 fields,
26 onChange,
27 fieldTypes,
28 widthOptions,
29 appliesToOptions,
30 headerExtra
31 }) => {
32 const [editingField, setEditingField] = reactExports.useState(null);
33 const [fieldIdDraft, setFieldIdDraft] = reactExports.useState(null);
34 reactExports.useEffect(() => {
35 setFieldIdDraft(null);
36 }, [editingField]);
37 const [showAddField, setShowAddField] = reactExports.useState(false);
38 const [newField, setNewField] = reactExports.useState({
39 id: "",
40 type: "text",
41 label: "",
42 placeholder: "",
43 required: false,
44 enabled: true,
45 width: "full",
46 options: [],
47 applies_to: "all"
48 });
49 const [deleteConfirm, setDeleteConfirm] = reactExports.useState({
50 isOpen: false,
51 fieldId: null,
52 fieldLabel: ""
53 });
54 const [draggedFieldId, setDraggedFieldId] = reactExports.useState(null);
55 const [dragOverFieldId, setDragOverFieldId] = reactExports.useState(null);
56 const generateIdFromLabel = (label) => {
57 return label.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "");
58 };
59 const sanitizeId = (id) => {
60 return id.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "");
61 };
62 const handleNewFieldLabelChange = (label) => {
63 const autoId = generateIdFromLabel(label);
64 setNewField((prev) => ({
65 ...prev,
66 label,
67 // Only auto-generate ID if it hasn't been manually edited
68 id: prev.id === "" || prev.id === generateIdFromLabel(prev.label || "") ? autoId : prev.id
69 }));
70 };
71 const updateField = (fieldId, updates) => {
72 onChange(
73 fields.map(
74 (field) => field.id === fieldId ? { ...field, ...updates } : field
75 )
76 );
77 };
78 const toggleFieldEnabled = (fieldId) => {
79 const field = fields.find((f) => f.id === fieldId);
80 if (field && !field.locked) {
81 updateField(fieldId, { enabled: !field.enabled });
82 }
83 };
84 const toggleFieldRequired = (fieldId) => {
85 const field = fields.find((f) => f.id === fieldId);
86 if (field) {
87 updateField(fieldId, { required: !field.required });
88 }
89 };
90 const moveField = (fieldId, direction) => {
91 const next = [...fields];
92 const index = next.findIndex((f) => f.id === fieldId);
93 if (direction === "up" && index > 0) {
94 [next[index - 1], next[index]] = [next[index], next[index - 1]];
95 } else if (direction === "down" && index < next.length - 1) {
96 [next[index], next[index + 1]] = [next[index + 1], next[index]];
97 }
98 onChange(withOrder(next));
99 };
100 const handleDragStart = (e, fieldId) => {
101 setDraggedFieldId(fieldId);
102 e.dataTransfer.effectAllowed = "move";
103 };
104 const handleDragOver = (e, fieldId) => {
105 e.preventDefault();
106 e.dataTransfer.dropEffect = "move";
107 if (fieldId !== draggedFieldId) {
108 setDragOverFieldId(fieldId);
109 }
110 };
111 const handleDragLeave = () => {
112 setDragOverFieldId(null);
113 };
114 const handleDrop = (e, targetFieldId) => {
115 e.preventDefault();
116 if (!draggedFieldId || draggedFieldId === targetFieldId) {
117 setDraggedFieldId(null);
118 setDragOverFieldId(null);
119 return;
120 }
121 const next = [...fields];
122 const draggedIndex = next.findIndex((f) => f.id === draggedFieldId);
123 const targetIndex = next.findIndex((f) => f.id === targetFieldId);
124 if (draggedIndex !== -1 && targetIndex !== -1) {
125 const [draggedField] = next.splice(draggedIndex, 1);
126 next.splice(targetIndex, 0, draggedField);
127 onChange(withOrder(next));
128 }
129 setDraggedFieldId(null);
130 setDragOverFieldId(null);
131 };
132 const handleDragEnd = () => {
133 setDraggedFieldId(null);
134 setDragOverFieldId(null);
135 };
136 const deleteField = (fieldId) => {
137 onChange(withOrder(fields.filter((f) => f.id !== fieldId)));
138 setDeleteConfirm({ isOpen: false, fieldId: null, fieldLabel: "" });
139 };
140 const addNewField = () => {
141 const isTextBlock = newField.type === "text_block";
142 let fieldId;
143 if (isTextBlock) {
144 if (!newField.content || !newField.content.trim()) return;
145 let n = 1;
146 while (fields.some((f) => f.id === `text_block_${n}`)) n++;
147 fieldId = `text_block_${n}`;
148 } else {
149 if (!newField.label || !newField.id) return;
150 fieldId = sanitizeId(newField.id);
151 }
152 if (fields.some((f) => f.id === fieldId)) {
153 window.alert(
154 "A field with this ID already exists. Please use a different ID."
155 );
156 return;
157 }
158 const newFieldConfig = {
159 id: fieldId,
160 type: newField.type || "text",
161 label: newField.label || "",
162 placeholder: newField.placeholder || "",
163 required: newField.required || false,
164 enabled: true,
165 order: fields.length + 1,
166 width: newField.width || "full",
167 // Per-traveler targeting only applies to the Traveler section.
168 ...formType === "traveler_form" ? { applies_to: newField.applies_to || "all" } : {},
169 // Phone fields carry the country-code toggle (default on).
170 ...newField.type === "tel" ? { show_country_code: newField.show_country_code !== false } : {}
171 };
172 if (newField.type === "select" && newField.options && newField.options.length > 0) {
173 newFieldConfig.options = newField.options.filter(
174 (opt) => opt.value && opt.label
175 );
176 }
177 if (isTextBlock) {
178 newFieldConfig.content = newField.content || "";
179 newFieldConfig.required = false;
180 }
181 onChange([...fields, newFieldConfig]);
182 setNewField({
183 id: "",
184 type: "text",
185 label: "",
186 placeholder: "",
187 required: false,
188 enabled: true,
189 width: "full",
190 options: [],
191 content: ""
192 });
193 setShowAddField(false);
194 };
195 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
197 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row flex-wrap items-center justify-between gap-2 w-full", children: [
198 /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Form Fields", "yatra") }),
199 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
200 headerExtra,
201 /* @__PURE__ */ jsxRuntimeExports.jsxs(
202 Button,
203 {
204 variant: "outline",
205 size: "sm",
206 onClick: () => setShowAddField(!showAddField),
207 className: "flex items-center gap-2",
208 "data-testid": "add-field-toggle",
209 children: [
210 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }),
211 __("Add Field", "yatra")
212 ]
213 }
214 )
215 ] })
216 ] }) }),
217 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [
218 showAddField && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800 mb-4", children: [
219 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "font-medium text-sm mb-3", children: __("Add New Field", "yatra") }),
220 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-5 gap-3", children: [
221 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
222 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Field Type", "yatra") }),
223 /* @__PURE__ */ jsxRuntimeExports.jsx(
224 Select,
225 {
226 value: newField.type || "text",
227 onChange: (e) => setNewField((prev) => ({
228 ...prev,
229 type: e.target.value
230 })),
231 className: "mt-1",
232 children: fieldTypes.map((type) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: type.value, children: type.label }, type.value))
233 }
234 )
235 ] }),
236 newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
237 /* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [
238 __("Label", "yatra"),
239 " *"
240 ] }),
241 /* @__PURE__ */ jsxRuntimeExports.jsx(
242 Input,
243 {
244 value: newField.label || "",
245 onChange: (e) => handleNewFieldLabelChange(e.target.value),
246 placeholder: "Field label",
247 className: "mt-1"
248 }
249 )
250 ] }),
251 newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
252 /* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [
253 __("Field ID", "yatra"),
254 " *"
255 ] }),
256 /* @__PURE__ */ jsxRuntimeExports.jsx(
257 Input,
258 {
259 value: newField.id || "",
260 onChange: (e) => setNewField((prev) => ({
261 ...prev,
262 id: sanitizeId(e.target.value)
263 })),
264 placeholder: "field_id",
265 className: "mt-1 font-mono text-xs"
266 }
267 ),
268 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __("Lowercase, no spaces", "yatra") })
269 ] }),
270 newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
271 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Placeholder", "yatra") }),
272 /* @__PURE__ */ jsxRuntimeExports.jsx(
273 Input,
274 {
275 value: newField.placeholder || "",
276 onChange: (e) => setNewField((prev) => ({
277 ...prev,
278 placeholder: e.target.value
279 })),
280 placeholder: "Placeholder text",
281 className: "mt-1"
282 }
283 )
284 ] }),
285 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
286 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Width", "yatra") }),
287 /* @__PURE__ */ jsxRuntimeExports.jsx(
288 Select,
289 {
290 value: newField.width || "full",
291 onChange: (e) => setNewField((prev) => ({
292 ...prev,
293 width: e.target.value
294 })),
295 className: "mt-1",
296 children: widthOptions.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: w.value, children: w.label }, w.value))
297 }
298 )
299 ] }),
300 formType === "traveler_form" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
301 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Applies to", "yatra") }),
302 /* @__PURE__ */ jsxRuntimeExports.jsx(
303 Select,
304 {
305 value: newField.applies_to || "all",
306 onChange: (e) => setNewField((prev) => ({
307 ...prev,
308 applies_to: e.target.value
309 })),
310 className: "mt-1",
311 children: appliesToOptions.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: a.value, children: a.label }, a.value))
312 }
313 )
314 ] })
315 ] }),
316 newField.type === "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3", children: [
317 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Content", "yatra") }),
318 /* @__PURE__ */ jsxRuntimeExports.jsx(
319 "textarea",
320 {
321 value: newField.content || "",
322 onChange: (e) => setNewField((prev) => ({
323 ...prev,
324 content: e.target.value
325 })),
326 rows: 4,
327 placeholder: __(
328 "Text shown to customers between fields. Basic HTML (bold, links, lists) is allowed.",
329 "yatra"
330 ),
331 className: "mt-1 w-full rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 py-2 text-sm"
332 }
333 ),
334 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __(
335 "Display only — this is not an input and is not submitted by the customer.",
336 "yatra"
337 ) })
338 ] }),
339 newField.type === "select" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-100 dark:border-blue-900", children: [
340 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
341 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Dropdown Options", "yatra") }),
342 /* @__PURE__ */ jsxRuntimeExports.jsxs(
343 Button,
344 {
345 type: "button",
346 variant: "ghost",
347 size: "sm",
348 onClick: () => {
349 const currentOptions = newField.options || [];
350 setNewField((prev) => ({
351 ...prev,
352 options: [
353 ...currentOptions,
354 { value: "", label: "" }
355 ]
356 }));
357 },
358 className: "h-6 text-xs",
359 children: [
360 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-3 h-3 mr-1" }),
361 __("Add Option", "yatra")
362 ]
363 }
364 )
365 ] }),
366 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
367 (newField.options || []).map((option, optIndex) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
368 /* @__PURE__ */ jsxRuntimeExports.jsx(
369 Input,
370 {
371 value: option.value,
372 onChange: (e) => {
373 const newOptions = [...newField.options || []];
374 newOptions[optIndex] = {
375 ...newOptions[optIndex],
376 value: e.target.value
377 };
378 setNewField((prev) => ({
379 ...prev,
380 options: newOptions
381 }));
382 },
383 placeholder: "Value (e.g., option1)",
384 className: "text-xs flex-1"
385 }
386 ),
387 /* @__PURE__ */ jsxRuntimeExports.jsx(
388 Input,
389 {
390 value: option.label,
391 onChange: (e) => {
392 const newOptions = [...newField.options || []];
393 newOptions[optIndex] = {
394 ...newOptions[optIndex],
395 label: e.target.value
396 };
397 setNewField((prev) => ({
398 ...prev,
399 options: newOptions
400 }));
401 },
402 placeholder: "Label (e.g., Option 1)",
403 className: "text-xs flex-1"
404 }
405 ),
406 /* @__PURE__ */ jsxRuntimeExports.jsx(
407 "button",
408 {
409 type: "button",
410 onClick: () => {
411 const newOptions = (newField.options || []).filter(
412 (_, i) => i !== optIndex
413 );
414 setNewField((prev) => ({
415 ...prev,
416 options: newOptions
417 }));
418 },
419 className: "p-1 text-gray-400 hover:text-red-500",
420 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-3 h-3" })
421 }
422 )
423 ] }, optIndex)),
424 (!newField.options || newField.options.length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 italic", children: __(
425 'Click "Add Option" to add dropdown choices.',
426 "yatra"
427 ) })
428 ] })
429 ] }),
430 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 mt-3", children: [
431 newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
432 /* @__PURE__ */ jsxRuntimeExports.jsx(
433 "input",
434 {
435 type: "checkbox",
436 checked: newField.required || false,
437 onChange: (e) => setNewField((prev) => ({
438 ...prev,
439 required: e.target.checked
440 })),
441 className: "w-4 h-4 rounded border-gray-300 text-blue-600"
442 }
443 ),
444 __("Required", "yatra")
445 ] }),
446 newField.type === "tel" && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
447 /* @__PURE__ */ jsxRuntimeExports.jsx(
448 "input",
449 {
450 type: "checkbox",
451 checked: newField.show_country_code !== false,
452 onChange: (e) => setNewField((prev) => ({
453 ...prev,
454 show_country_code: e.target.checked
455 })),
456 className: "w-4 h-4 rounded border-gray-300 text-blue-600"
457 }
458 ),
459 __("Show country code", "yatra")
460 ] }),
461 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1" }),
462 /* @__PURE__ */ jsxRuntimeExports.jsx(
463 Button,
464 {
465 variant: "ghost",
466 size: "sm",
467 onClick: () => setShowAddField(false),
468 children: __("Cancel", "yatra")
469 }
470 ),
471 /* @__PURE__ */ jsxRuntimeExports.jsx(
472 Button,
473 {
474 size: "sm",
475 onClick: addNewField,
476 disabled: newField.type === "text_block" ? !newField.content || !newField.content.trim() : !newField.id || !newField.label,
477 children: __("Add Field", "yatra")
478 }
479 )
480 ] })
481 ] }),
482 (fields == null ? void 0 : fields.length) === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __(
483 'No fields configured. Click "Add Field" to get started.',
484 "yatra"
485 ) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: fields == null ? void 0 : fields.map((field, index) => {
486 var _a, _b;
487 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
488 "div",
489 {
490 draggable: true,
491 onDragStart: (e) => handleDragStart(e, field.id),
492 onDragOver: (e) => handleDragOver(e, field.id),
493 onDragLeave: handleDragLeave,
494 onDrop: (e) => handleDrop(e, field.id),
495 onDragEnd: handleDragEnd,
496 className: `flex items-center gap-3 p-3 rounded-lg border transition-all cursor-grab active:cursor-grabbing ${draggedFieldId === field.id ? "opacity-50 border-dashed" : ""} ${dragOverFieldId === field.id ? "border-blue-500 bg-blue-50 dark:bg-blue-900/20" : ""} ${field.enabled ? "bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700" : "bg-gray-50 dark:bg-gray-900 border-gray-100 dark:border-gray-800 opacity-60"}`,
497 children: [
498 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
499 /* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { className: "w-4 h-4 text-gray-400" }),
500 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-0.5", children: [
501 /* @__PURE__ */ jsxRuntimeExports.jsx(
502 "button",
503 {
504 type: "button",
505 onClick: () => moveField(field.id, "up"),
506 disabled: index === 0,
507 className: "p-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-30 disabled:cursor-not-allowed",
508 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowUp, { className: "w-3 h-3" })
509 }
510 ),
511 /* @__PURE__ */ jsxRuntimeExports.jsx(
512 "button",
513 {
514 type: "button",
515 onClick: () => moveField(field.id, "down"),
516 disabled: index === fields.length - 1,
517 className: "p-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-30 disabled:cursor-not-allowed",
518 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowDown, { className: "w-3 h-3" })
519 }
520 )
521 ] })
522 ] }),
523 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-w-0", children: editingField === field.id ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
524 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
525 field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
526 /* @__PURE__ */ jsxRuntimeExports.jsx(
527 Input,
528 {
529 value: field.label,
530 onChange: (e) => updateField(field.id, {
531 label: e.target.value
532 }),
533 placeholder: "Label",
534 className: "text-sm"
535 }
536 ),
537 /* @__PURE__ */ jsxRuntimeExports.jsx(
538 Input,
539 {
540 value: field.placeholder,
541 onChange: (e) => updateField(field.id, {
542 placeholder: e.target.value
543 }),
544 placeholder: "Placeholder",
545 className: "text-sm"
546 }
547 )
548 ] }),
549 /* @__PURE__ */ jsxRuntimeExports.jsx(
550 Select,
551 {
552 value: field.type,
553 onChange: (e) => !field.locked && updateField(field.id, {
554 type: e.target.value
555 }),
556 disabled: field.locked,
557 title: field.locked ? "Locked fields cannot change type" : void 0,
558 className: "text-sm",
559 children: fieldTypes.map((type) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: type.value, children: type.label }, type.value))
560 }
561 ),
562 /* @__PURE__ */ jsxRuntimeExports.jsx(
563 Select,
564 {
565 value: field.width,
566 onChange: (e) => updateField(field.id, {
567 width: e.target.value
568 }),
569 className: "text-sm",
570 children: widthOptions.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: w.value, children: w.label }, w.value))
571 }
572 ),
573 formType === "traveler_form" && /* @__PURE__ */ jsxRuntimeExports.jsx(
574 Select,
575 {
576 value: field.applies_to || "all",
577 onChange: (e) => updateField(field.id, {
578 applies_to: e.target.value
579 }),
580 className: "text-sm",
581 title: __(
582 "Which travelers see this field",
583 "yatra"
584 ),
585 children: appliesToOptions.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: a.value, children: a.label }, a.value))
586 }
587 ),
588 field.type === "tel" && /* @__PURE__ */ jsxRuntimeExports.jsxs(
589 "label",
590 {
591 className: "flex items-center gap-2 text-sm whitespace-nowrap px-1",
592 title: __(
593 "Show the international country flag + dial code selector on this phone field",
594 "yatra"
595 ),
596 children: [
597 /* @__PURE__ */ jsxRuntimeExports.jsx(
598 "input",
599 {
600 type: "checkbox",
601 checked: field.show_country_code !== false,
602 onChange: (e) => updateField(field.id, {
603 show_country_code: e.target.checked
604 }),
605 className: "w-4 h-4 rounded border-gray-300 text-blue-600"
606 }
607 ),
608 __("Show country code", "yatra")
609 ]
610 }
611 )
612 ] }),
613 field.type === "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
614 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Content", "yatra") }),
615 /* @__PURE__ */ jsxRuntimeExports.jsx(
616 "textarea",
617 {
618 value: field.content || "",
619 onChange: (e) => updateField(field.id, {
620 content: e.target.value
621 }),
622 rows: 4,
623 placeholder: __(
624 "Text shown to customers between fields. Basic HTML (bold, links, lists) is allowed.",
625 "yatra"
626 ),
627 className: "mt-1 w-full rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 py-2 text-sm"
628 }
629 ),
630 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __(
631 "Display only — this is not an input and is not submitted by the customer.",
632 "yatra"
633 ) })
634 ] }),
635 field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-2 bg-gray-50 dark:bg-gray-900 rounded", children: [
636 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs text-gray-500 whitespace-nowrap", children: __("Field ID:", "yatra") }),
637 /* @__PURE__ */ jsxRuntimeExports.jsx(
638 Input,
639 {
640 value: fieldIdDraft !== null ? fieldIdDraft : field.id,
641 onChange: (e) => {
642 if (!field.locked) {
643 setFieldIdDraft(sanitizeId(e.target.value));
644 }
645 },
646 onBlur: () => {
647 if (fieldIdDraft === null) return;
648 const next = fieldIdDraft;
649 setFieldIdDraft(null);
650 if (!field.locked && next !== "" && next !== field.id) {
651 updateField(field.id, { id: next });
652 setEditingField(
653 (cur) => cur === field.id ? next : cur
654 );
655 }
656 },
657 onKeyDown: (e) => {
658 if (e.key === "Enter") {
659 e.preventDefault();
660 e.currentTarget.blur();
661 }
662 },
663 placeholder: "field_id",
664 className: "text-sm font-mono flex-1 max-w-xs",
665 disabled: field.locked,
666 title: field.locked ? "Locked fields cannot change ID" : "Field ID (lowercase, no spaces)"
667 }
668 ),
669 field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-amber-600", children: __("(locked)", "yatra") })
670 ] }),
671 field.type === "select" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700", children: [
672 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
673 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Dropdown Options", "yatra") }),
674 /* @__PURE__ */ jsxRuntimeExports.jsxs(
675 Button,
676 {
677 type: "button",
678 variant: "ghost",
679 size: "sm",
680 onClick: () => {
681 const newOptions = [
682 ...field.options || [],
683 { value: "", label: "" }
684 ];
685 updateField(field.id, {
686 options: newOptions
687 });
688 },
689 className: "h-6 text-xs",
690 children: [
691 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-3 h-3 mr-1" }),
692 __("Add Option", "yatra")
693 ]
694 }
695 )
696 ] }),
697 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
698 (field.options || []).map((option, optIndex) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
699 "div",
700 {
701 className: "flex items-center gap-2",
702 children: [
703 /* @__PURE__ */ jsxRuntimeExports.jsx(
704 Input,
705 {
706 value: option.value,
707 onChange: (e) => {
708 const newOptions = [
709 ...field.options || []
710 ];
711 newOptions[optIndex] = {
712 ...newOptions[optIndex],
713 value: e.target.value
714 };
715 updateField(field.id, {
716 options: newOptions
717 });
718 },
719 placeholder: "Value (e.g., spouse)",
720 className: "text-xs flex-1"
721 }
722 ),
723 /* @__PURE__ */ jsxRuntimeExports.jsx(
724 Input,
725 {
726 value: option.label,
727 onChange: (e) => {
728 const newOptions = [
729 ...field.options || []
730 ];
731 newOptions[optIndex] = {
732 ...newOptions[optIndex],
733 label: e.target.value
734 };
735 updateField(field.id, {
736 options: newOptions
737 });
738 },
739 placeholder: "Label (e.g., Spouse/Partner)",
740 className: "text-xs flex-1"
741 }
742 ),
743 /* @__PURE__ */ jsxRuntimeExports.jsx(
744 "button",
745 {
746 type: "button",
747 onClick: () => {
748 const newOptions = (field.options || []).filter((_, i) => i !== optIndex);
749 updateField(field.id, {
750 options: newOptions
751 });
752 },
753 className: "p-1 text-gray-400 hover:text-red-500",
754 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-3 h-3" })
755 }
756 )
757 ]
758 },
759 optIndex
760 )),
761 (!field.options || field.options.length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 italic", children: __(
762 'No options. Click "Add Option" to add dropdown choices.',
763 "yatra"
764 ) })
765 ] })
766 ] })
767 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
768 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-sm", children: field.type === "text_block" ? __("Text Block", "yatra") : field.label }),
769 field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-xs text-gray-500 dark:text-gray-400 px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 rounded font-mono", children: field.id }),
770 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500 px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded", children: ((_a = fieldTypes.find((t) => t.value === field.type)) == null ? void 0 : _a.label) || field.type }),
771 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: ((_b = widthOptions.find((w) => w.value === field.width)) == null ? void 0 : _b.label) || "Full" }),
772 field.type === "text_block" && field.content && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-500 dark:text-gray-400 italic truncate max-w-[16rem]", children: [
773 '"',
774 field.content.replace(/<[^>]*>/g, "").slice(0, 60),
775 '"'
776 ] }),
777 field.type === "select" && field.options && field.options.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-blue-500 dark:text-blue-400", children: [
778 "(",
779 field.options.length,
780 " ",
781 field.options.length === 1 ? "option" : "options",
782 ")"
783 ] }),
784 field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500 font-medium", children: __("Required", "yatra") }),
785 formType === "traveler_form" && field.applies_to === "lead" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs px-1.5 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400 font-medium", children: __("Lead only", "yatra") }),
786 field.locked && /* @__PURE__ */ jsxRuntimeExports.jsxs(
787 "span",
788 {
789 className: "inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 px-1.5 py-0.5 bg-amber-50 dark:bg-amber-900/20 rounded",
790 title: "This field is protected and cannot be deleted",
791 children: [
792 /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "w-3 h-3" }),
793 "Locked"
794 ]
795 }
796 )
797 ] }) }),
798 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
799 field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsx(
800 "button",
801 {
802 type: "button",
803 onClick: () => !field.locked && toggleFieldRequired(field.id),
804 disabled: field.locked,
805 className: `p-1.5 rounded ${field.locked ? "cursor-not-allowed opacity-50" : ""} ${field.required ? "text-red-500 bg-red-50 dark:bg-red-900/20" : "text-gray-400 hover:text-gray-600"}`,
806 title: field.locked ? "This field is required and cannot be changed" : field.required ? "Make optional" : "Make required",
807 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
808 Star,
809 {
810 className: "w-4 h-4",
811 fill: field.required ? "currentColor" : "none"
812 }
813 )
814 }
815 ),
816 !field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx(
817 "button",
818 {
819 type: "button",
820 onClick: () => toggleFieldEnabled(field.id),
821 className: `p-1.5 rounded ${field.enabled ? "text-green-500" : "text-gray-400"}`,
822 title: field.enabled ? "Disable field" : "Enable field",
823 children: field.enabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "w-4 h-4" })
824 }
825 ),
826 /* @__PURE__ */ jsxRuntimeExports.jsx(
827 "button",
828 {
829 type: "button",
830 onClick: () => setEditingField(
831 editingField === field.id ? null : field.id
832 ),
833 className: "p-1.5 rounded text-gray-400 hover:text-blue-500",
834 title: "Edit field",
835 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pen, { className: "w-4 h-4" })
836 }
837 ),
838 !field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx(
839 "button",
840 {
841 type: "button",
842 onClick: () => setDeleteConfirm({
843 isOpen: true,
844 fieldId: field.id,
845 fieldLabel: field.label
846 }),
847 className: "p-1.5 rounded text-gray-400 hover:text-red-500",
848 title: "Delete field",
849 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" })
850 }
851 )
852 ] })
853 ]
854 },
855 field.id
856 );
857 }) })
858 ] })
859 ] }),
860 /* @__PURE__ */ jsxRuntimeExports.jsx(
861 ConfirmationDialog,
862 {
863 isOpen: deleteConfirm.isOpen,
864 onClose: () => setDeleteConfirm({ isOpen: false, fieldId: null, fieldLabel: "" }),
865 onConfirm: () => {
866 if (deleteConfirm.fieldId) {
867 deleteField(deleteConfirm.fieldId);
868 }
869 },
870 title: __("Delete Field", "yatra"),
871 message: `Are you sure you want to delete the field "${deleteConfirm.fieldLabel}"? This action cannot be undone.`,
872 confirmText: __("Delete", "yatra"),
873 cancelText: __("Cancel", "yatra"),
874 variant: "danger"
875 }
876 )
877 ] });
878 };
879 const clone = (v) => JSON.parse(JSON.stringify(v));
880 const reorder = (fields) => fields.map((f, i) => ({ ...f, order: i + 1 }));
881 const newConditionFrom = (section) => ({
882 id: `condition_${Date.now().toString(36)}`,
883 targets: {},
884 title: section.title || "",
885 description: section.description || "",
886 fields: clone(section.fields || [])
887 });
888 const BookingFormConditionsModal = ({
889 isOpen,
890 onClose,
891 formType,
892 formLabel,
893 section,
894 onSave,
895 fieldTypes,
896 widthOptions,
897 appliesToOptions
898 }) => {
899 const [draft, setDraft] = reactExports.useState([]);
900 const [collapsed, setCollapsed] = reactExports.useState(/* @__PURE__ */ new Set());
901 const [addFromGlobal, setAddFromGlobal] = reactExports.useState(null);
902 const [error, setError] = reactExports.useState(null);
903 const { options: targetOptions } = useTripTargets(isOpen);
904 reactExports.useEffect(() => {
905 if (!isOpen) return;
906 setDraft(clone(section.conditions || []));
907 setCollapsed(/* @__PURE__ */ new Set());
908 setAddFromGlobal(null);
909 setError(null);
910 }, [isOpen, section.conditions]);
911 const globalFields = section.fields || [];
912 const update = (ci, patch) => setDraft((d) => d.map((c, i) => i === ci ? { ...c, ...patch } : c));
913 const moveCondition = (ci, delta) => setDraft((d) => {
914 const next = [...d];
915 const to = ci + delta;
916 if (to < 0 || to >= next.length) return next;
917 [next[ci], next[to]] = [next[to], next[ci]];
918 return next;
919 });
920 const toggleCollapsed = (ci) => setCollapsed((s) => {
921 const n = new Set(s);
922 if (n.has(ci)) n.delete(ci);
923 else n.add(ci);
924 return n;
925 });
926 const addCondition = () => {
927 setDraft((d) => [...d, newConditionFrom(section)]);
928 setCollapsed(new Set(draft.map((_, i) => i)));
929 };
930 const done = () => {
931 const bad = draft.findIndex((c) => !hasTargets(c.targets));
932 if (bad >= 0) {
933 setError(
934 sprintf(
935 __(
936 "Condition %d needs at least one trip, category or trip type.",
937 "yatra"
938 ),
939 bad + 1
940 )
941 );
942 setCollapsed((s) => {
943 const n = new Set(s);
944 n.delete(bad);
945 return n;
946 });
947 return;
948 }
949 onSave(draft);
950 onClose();
951 };
952 const typeLabel = (t) => {
953 var _a;
954 return ((_a = fieldTypes.find((x) => x.value === t)) == null ? void 0 : _a.label) || t;
955 };
956 const renderCondition = (c, ci) => {
957 const isCollapsed = collapsed.has(ci);
958 const missingFromGlobal = globalFields.filter(
959 (g) => !c.fields.some((f) => f.id === g.id)
960 );
961 const enabledCount = c.fields.filter((f) => f.enabled !== false).length;
962 const where = describeTargets(c.targets, targetOptions);
963 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
964 "div",
965 {
966 className: "rounded-lg border border-gray-200 dark:border-gray-700 border-l-4 border-l-purple-500 overflow-hidden",
967 "data-testid": `condition-${ci}`,
968 children: [
969 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800/60 border-b border-gray-200 dark:border-gray-700", children: [
970 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[11px] font-mono font-semibold px-1.5 py-0.5 rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300", children: sprintf(__("COND %d", "yatra"), ci + 1) }),
971 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-semibold", children: where || __("Choose where this applies", "yatra") }),
972 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: sprintf(
973 __("→ “%1$s” · %2$d fields", "yatra"),
974 c.title,
975 enabledCount
976 ) }),
977 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1" }),
978 /* @__PURE__ */ jsxRuntimeExports.jsx(
979 "button",
980 {
981 type: "button",
982 className: "p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-30",
983 disabled: ci === 0,
984 onClick: () => moveCondition(ci, -1),
985 title: __("Higher priority", "yatra"),
986 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronUp, { className: "w-4 h-4" })
987 }
988 ),
989 /* @__PURE__ */ jsxRuntimeExports.jsx(
990 "button",
991 {
992 type: "button",
993 className: "p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-30",
994 disabled: ci === draft.length - 1,
995 onClick: () => moveCondition(ci, 1),
996 title: __("Lower priority", "yatra"),
997 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" })
998 }
999 ),
1000 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1001 Button,
1002 {
1003 type: "button",
1004 variant: "ghost",
1005 size: "sm",
1006 onClick: () => {
1007 const fresh = newConditionFrom(section);
1008 update(ci, {
1009 title: fresh.title,
1010 description: fresh.description,
1011 fields: fresh.fields
1012 });
1013 },
1014 title: __(
1015 "Replace this condition's form with a fresh copy of the global form",
1016 "yatra"
1017 ),
1018 children: [
1019 /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCcw, { className: "w-3 h-3 mr-1" }),
1020 __("Reset to global form", "yatra")
1021 ]
1022 }
1023 ),
1024 /* @__PURE__ */ jsxRuntimeExports.jsx(
1025 Button,
1026 {
1027 type: "button",
1028 variant: "ghost",
1029 size: "sm",
1030 className: "text-red-600",
1031 onClick: () => setDraft((d) => d.filter((_, i) => i !== ci)),
1032 children: __("Remove", "yatra")
1033 }
1034 ),
1035 /* @__PURE__ */ jsxRuntimeExports.jsx(
1036 Button,
1037 {
1038 type: "button",
1039 variant: "ghost",
1040 size: "sm",
1041 onClick: () => toggleCollapsed(ci),
1042 children: isCollapsed ? __("Expand", "yatra") : __("Collapse", "yatra")
1043 }
1044 )
1045 ] }),
1046 !isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 space-y-4", children: [
1047 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1048 /* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [
1049 __("Use this form on", "yatra"),
1050 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 font-normal text-gray-400", children: __(
1051 "trips, categories or trip types — any match applies",
1052 "yatra"
1053 ) })
1054 ] }),
1055 /* @__PURE__ */ jsxRuntimeExports.jsx(
1056 MultiSelect,
1057 {
1058 value: encodeTargets(c.targets),
1059 onChange: (vals) => update(ci, { targets: decodeTargets(vals) }),
1060 options: targetOptions,
1061 placeholder: __(
1062 "Search trips, categories, trip types…",
1063 "yatra"
1064 ),
1065 className: "mt-1"
1066 }
1067 ),
1068 !hasTargets(c.targets) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-600 mt-1", children: __(
1069 "Pick at least one trip, category or trip type.",
1070 "yatra"
1071 ) })
1072 ] }),
1073 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-200 dark:border-gray-700", children: [
1074 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-3 py-2 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between", children: [
1075 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-semibold", children: __("Form Section Settings", "yatra") }),
1076 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: __("for these trips", "yatra") })
1077 ] }),
1078 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 grid grid-cols-1 md:grid-cols-2 gap-3", children: [
1079 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1080 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Section Title", "yatra") }),
1081 /* @__PURE__ */ jsxRuntimeExports.jsx(
1082 Input,
1083 {
1084 value: c.title,
1085 onChange: (e) => update(ci, { title: e.target.value }),
1086 className: "mt-1 text-sm",
1087 "data-testid": `condition-${ci}-title`
1088 }
1089 )
1090 ] }),
1091 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1092 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Section Description", "yatra") }),
1093 /* @__PURE__ */ jsxRuntimeExports.jsx(
1094 Input,
1095 {
1096 value: c.description,
1097 onChange: (e) => update(ci, { description: e.target.value }),
1098 className: "mt-1 text-sm"
1099 }
1100 )
1101 ] })
1102 ] })
1103 ] }),
1104 /* @__PURE__ */ jsxRuntimeExports.jsx(
1105 BookingFormFieldsEditor,
1106 {
1107 formType,
1108 fields: c.fields,
1109 onChange: (fields) => update(ci, { fields }),
1110 fieldTypes,
1111 widthOptions,
1112 appliesToOptions,
1113 headerExtra: addFromGlobal === ci ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
1114 Select,
1115 {
1116 autoFocus: true,
1117 className: "text-sm h-9 w-56",
1118 value: "",
1119 onChange: (e) => {
1120 const g = globalFields.find(
1121 (f) => f.id === e.target.value
1122 );
1123 if (g) {
1124 update(ci, {
1125 fields: reorder([...c.fields, clone(g)])
1126 });
1127 }
1128 setAddFromGlobal(null);
1129 },
1130 onBlur: () => setAddFromGlobal(null),
1131 "data-testid": "add-from-global-select",
1132 children: [
1133 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: __("Pick a global field…", "yatra") }),
1134 missingFromGlobal.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: g.id, children: [
1135 g.type === "text_block" ? __("Text Block", "yatra") : g.label,
1136 " ",
1137 "(",
1138 typeLabel(g.type),
1139 ")"
1140 ] }, g.id))
1141 ]
1142 }
1143 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
1144 Button,
1145 {
1146 type: "button",
1147 size: "sm",
1148 variant: "outline",
1149 disabled: missingFromGlobal.length === 0,
1150 onClick: () => setAddFromGlobal(ci),
1151 title: missingFromGlobal.length === 0 ? __(
1152 "Every global field is already in this condition",
1153 "yatra"
1154 ) : void 0,
1155 "data-testid": "add-from-global",
1156 children: __("Add from global form", "yatra")
1157 }
1158 )
1159 }
1160 )
1161 ] })
1162 ]
1163 },
1164 c.id
1165 );
1166 };
1167 return /* @__PURE__ */ jsxRuntimeExports.jsx(
1168 Modal,
1169 {
1170 isOpen,
1171 onClose,
1172 size: "xl",
1173 title: sprintf(__("Conditions — %s", "yatra"), formLabel),
1174 description: __(
1175 "Give some trips their own version of this form. Each condition is a full copy of the form builder — change the section title, add or remove fields, reorder, edit labels, required, widths and options — and applies only to the trips it names.",
1176 "yatra"
1177 ),
1178 footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3 w-full", children: [
1179 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: __(
1180 "Conditions are saved with Save Settings, like every other form change.",
1181 "yatra"
1182 ) }),
1183 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
1184 error && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-600", children: error }),
1185 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: __("Cancel", "yatra") }),
1186 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", onClick: done, "data-testid": "conditions-done", children: __("Done", "yatra") })
1187 ] })
1188 ] }),
1189 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", "data-testid": "conditions-modal", children: [
1190 draft.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: __(
1191 "No conditions yet — every trip uses the global form. Add one to give some trips their own version.",
1192 "yatra"
1193 ) }),
1194 draft.map(renderCondition),
1195 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1196 "button",
1197 {
1198 type: "button",
1199 className: "w-full flex items-center justify-center gap-2 p-3 rounded-lg border border-dashed border-gray-300 dark:border-gray-600 text-sm text-gray-500 hover:border-purple-500 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/10",
1200 onClick: addCondition,
1201 "data-testid": "add-condition",
1202 children: [
1203 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }),
1204 __("Add condition", "yatra"),
1205 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: __("— starts as a copy of the global form", "yatra") })
1206 ]
1207 }
1208 ),
1209 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 rounded-lg bg-gray-50 dark:bg-gray-800/60 text-sm", children: [
1210 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold", children: __("All other trips", "yatra") }),
1211 " ",
1212 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __(
1213 "Trips that match no condition use the global form behind this popup — the behaviour before conditions existed.",
1214 "yatra"
1215 ) })
1216 ] })
1217 ] })
1218 }
1219 );
1220 };
1221 const MultipleTaxesEditor = React.memo(
1222 ({
1223 taxes,
1224 onChange
1225 }) => {
1226 const removeTax = (index) => {
1227 onChange(taxes.filter((_, i) => i !== index));
1228 };
1229 const updateTax = (index, field, value) => {
1230 const updated = [...taxes];
1231 if (field === "rate") {
1232 updated[index].rate = parseFloat(value) || 0;
1233 } else {
1234 updated[index].name = value;
1235 }
1236 onChange(updated);
1237 };
1238 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: taxes.filter((tax) => tax.name && tax.name.trim() !== "").map((tax, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1239 "div",
1240 {
1241 className: "relative p-4 border rounded-lg bg-gray-50 dark:bg-gray-800 w-full",
1242 children: [
1243 /* @__PURE__ */ jsxRuntimeExports.jsx(
1244 Button,
1245 {
1246 type: "button",
1247 variant: "outline",
1248 size: "sm",
1249 onClick: () => removeTax(index),
1250 className: "absolute top-3 right-3 text-red-600 hover:text-red-700 p-2",
1251 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" })
1252 }
1253 ),
1254 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 pr-12", children: [
1255 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1256 Input,
1257 {
1258 value: tax.name,
1259 onChange: (e) => updateTax(index, "name", e.target.value),
1260 placeholder: __("Tax name (e.g., VAT, GST)", "yatra"),
1261 className: "w-full"
1262 }
1263 ) }),
1264 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
1265 /* @__PURE__ */ jsxRuntimeExports.jsx(
1266 Input,
1267 {
1268 type: "number",
1269 value: tax.rate,
1270 onChange: (e) => updateTax(index, "rate", e.target.value),
1271 min: "0",
1272 max: "100",
1273 step: "0.01",
1274 placeholder: __("Rate", "yatra"),
1275 className: "w-full"
1276 }
1277 ),
1278 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" })
1279 ] }) })
1280 ] })
1281 ]
1282 },
1283 index
1284 )) }) });
1285 }
1286 );
1287 const FormField = React.memo(
1288 ({
1289 id,
1290 label,
1291 description,
1292 required = false,
1293 actionButton,
1294 children
1295 }) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1296 /* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: id, className: "flex items-center gap-1.5", children: [
1297 label,
1298 required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
1299 ] }),
1300 description && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 flex items-start gap-1.5", children: [
1301 /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-3.5 h-3.5 mt-0.5 flex-shrink-0" }),
1302 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "min-w-0 leading-relaxed", children: description })
1303 ] }),
1304 actionButton ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
1305 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children }),
1306 actionButton
1307 ] }) : children
1308 ] })
1309 );
1310 FormField.displayName = "FormField";
1311 const GoogleCalendarIntegrationSection = ({ formData, setFormData }) => {
1312 const yatraAdmin = window.yatraAdmin || {};
1313 const gcSettings = yatraAdmin.googleCalendar || {};
1314 const siteUrl = yatraAdmin.siteUrl || "";
1315 const gcDashboardUrl = `${yatraAdmin.adminUrl || "admin.php"}?page=yatra&subpage=google-calendar`;
1316 const [clientId, setClientId] = reactExports.useState(
1317 formData.google_calendar_client_id || gcSettings.client_id || ""
1318 );
1319 const [clientSecret, setClientSecret] = reactExports.useState(
1320 formData.google_calendar_client_secret || gcSettings.client_secret || ""
1321 );
1322 const [calendarId, setCalendarId] = reactExports.useState(
1323 formData.google_calendar_calendar_id || gcSettings.calendar_id || ""
1324 );
1325 const [calendarName, setCalendarName] = reactExports.useState(
1326 formData.google_calendar_calendar_name || gcSettings.calendar_name || ""
1327 );
1328 const [connected, setConnected] = reactExports.useState(
1329 formData.google_calendar_connected || gcSettings.connected || false
1330 );
1331 const [connecting, setConnecting] = reactExports.useState(false);
1332 const [syncing, setSyncing] = reactExports.useState(false);
1333 const [savingCalendar, setSavingCalendar] = reactExports.useState(false);
1334 const { showToast } = useToast();
1335 const redirectUri = yatraAdmin.googleCalendarRedirectUri || gcSettings.redirect_uri || `${siteUrl}/wp-json/yatra/v1/google-calendar/callback`;
1336 const lastSync = formData.google_calendar_last_sync || gcSettings.last_sync || null;
1337 const syncSettingsToFormData = () => {
1338 const allSettings = {
1339 google_calendar_client_id: clientId,
1340 google_calendar_client_secret: clientSecret,
1341 google_calendar_enabled: true,
1342 // Enable by default when settings are provided
1343 // Persist the target calendar through the MAIN page Save too (the option
1344 // name matches what the sync path reads), so the user's natural action —
1345 // clicking the page's Save button — keeps the chosen calendar.
1346 google_calendar_calendar_id: calendarId,
1347 google_calendar_calendar_name: calendarName
1348 };
1349 setFormData((prev) => {
1350 if (!prev) return prev;
1351 return {
1352 ...prev,
1353 ...allSettings
1354 };
1355 });
1356 };
1357 reactExports.useEffect(() => {
1358 syncSettingsToFormData();
1359 }, [clientId, clientSecret, calendarId, calendarName]);
1360 const handleConnect = async () => {
1361 var _a;
1362 setConnecting(true);
1363 try {
1364 const response = await apiClient.post("/google-calendar/connect");
1365 if ((_a = response.data) == null ? void 0 : _a.auth_url) {
1366 window.open(response.data.auth_url, "_blank");
1367 }
1368 } catch (error) {
1369 console.error("Failed to connect:", error);
1370 } finally {
1371 setConnecting(false);
1372 }
1373 };
1374 const handleDisconnect = async () => {
1375 if (!confirm(
1376 __(
1377 "Are you sure you want to disconnect from Google Calendar?",
1378 "yatra"
1379 )
1380 )) {
1381 return;
1382 }
1383 try {
1384 await apiClient.post("/google-calendar/disconnect");
1385 setConnected(false);
1386 setCalendarId("");
1387 setCalendarName("");
1388 showToast(__("Disconnected from Google Calendar.", "yatra"), "success");
1389 } catch (error) {
1390 showToast(
1391 __("Failed to disconnect. Please try again.", "yatra"),
1392 "error"
1393 );
1394 }
1395 };
1396 const handleSync = async () => {
1397 setSyncing(true);
1398 try {
1399 const res = await apiClient.post("/google-calendar/sync-all");
1400 if (res && res.success === false) {
1401 showToast(
1402 res.message || __("Failed to sync bookings.", "yatra"),
1403 "error"
1404 );
1405 } else {
1406 showToast(
1407 res && res.message || __("Bookings synced to Google Calendar.", "yatra"),
1408 "success"
1409 );
1410 }
1411 } catch (error) {
1412 showToast(
1413 __("Failed to sync bookings. Please try again.", "yatra"),
1414 "error"
1415 );
1416 } finally {
1417 setSyncing(false);
1418 }
1419 };
1420 const handleSaveCalendar = async () => {
1421 setSavingCalendar(true);
1422 try {
1423 await apiClient.post("/google-calendar/settings", {
1424 calendar_id: calendarId.trim(),
1425 calendar_name: calendarName.trim()
1426 });
1427 showToast(__("Calendar settings saved.", "yatra"), "success");
1428 } catch (error) {
1429 showToast(
1430 __("Failed to save calendar settings. Please try again.", "yatra"),
1431 "error"
1432 );
1433 } finally {
1434 setSavingCalendar(false);
1435 }
1436 };
1437 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
1438 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
1439 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [
1440 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-5 h-5 text-blue-500" }),
1441 __("Google Calendar Settings", "yatra")
1442 ] }),
1443 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-2", children: connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [
1444 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
1445 __("Connected", "yatra")
1446 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [
1447 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
1448 __("Not Connected", "yatra")
1449 ] }) })
1450 ] }),
1451 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [
1452 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __(
1453 "Connect your Google Calendar to automatically sync bookings and departures. Events will be created for each booking with trip details, traveler information, and departure dates.",
1454 "yatra"
1455 ) }),
1456 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1457 /* @__PURE__ */ jsxRuntimeExports.jsx(
1458 FormField,
1459 {
1460 id: "gc_client_id",
1461 label: __("Client ID", "yatra"),
1462 description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1463 __("Create an OAuth client in", "yatra"),
1464 " ",
1465 /* @__PURE__ */ jsxRuntimeExports.jsx(
1466 "a",
1467 {
1468 href: "https://console.cloud.google.com/apis/credentials",
1469 target: "_blank",
1470 rel: "noopener noreferrer",
1471 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline",
1472 children: __("Google Cloud Credentials", "yatra")
1473 }
1474 ),
1475 __(", then paste the OAuth 2.0 Client ID here.", "yatra"),
1476 " ",
1477 __("Example:", "yatra"),
1478 " ",
1479 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "font-mono", children: "123...apps.googleusercontent.com" })
1480 ] }),
1481 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1482 Input,
1483 {
1484 id: "gc_client_id",
1485 value: clientId,
1486 onChange: (e) => setClientId(e.target.value),
1487 placeholder: "123456789-xxxxx.apps.googleusercontent.com"
1488 }
1489 )
1490 }
1491 ),
1492 /* @__PURE__ */ jsxRuntimeExports.jsx(
1493 FormField,
1494 {
1495 id: "gc_client_secret",
1496 label: __("Client Secret", "yatra"),
1497 description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1498 __(
1499 "Copy the Client Secret from the same OAuth client in",
1500 "yatra"
1501 ),
1502 " ",
1503 /* @__PURE__ */ jsxRuntimeExports.jsx(
1504 "a",
1505 {
1506 href: "https://console.cloud.google.com/apis/credentials",
1507 target: "_blank",
1508 rel: "noopener noreferrer",
1509 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline",
1510 children: __("Google Cloud Credentials", "yatra")
1511 }
1512 ),
1513 __(".", "yatra"),
1514 " ",
1515 __("Keep this private.", "yatra")
1516 ] }),
1517 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1518 Input,
1519 {
1520 id: "gc_client_secret",
1521 type: "password",
1522 value: clientSecret,
1523 onChange: (e) => setClientSecret(e.target.value),
1524 placeholder: "GOCSPX-xxxxxxxxxxxxxxxxxx"
1525 }
1526 )
1527 }
1528 )
1529 ] }),
1530 /* @__PURE__ */ jsxRuntimeExports.jsx(
1531 FormField,
1532 {
1533 id: "gc_redirect_uri",
1534 label: __("Redirect URI (OAuth Callback URL)", "yatra"),
1535 description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1536 __(
1537 'Add this to your OAuth client under "Authorized redirect URIs" in',
1538 "yatra"
1539 ),
1540 " ",
1541 /* @__PURE__ */ jsxRuntimeExports.jsx(
1542 "a",
1543 {
1544 href: "https://console.cloud.google.com/apis/credentials",
1545 target: "_blank",
1546 rel: "noopener noreferrer",
1547 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline",
1548 children: __("Google Cloud Credentials", "yatra")
1549 }
1550 ),
1551 __(".", "yatra"),
1552 " ",
1553 __("Make sure the", "yatra"),
1554 " ",
1555 /* @__PURE__ */ jsxRuntimeExports.jsx(
1556 "a",
1557 {
1558 href: "https://console.cloud.google.com/apis/library/calendar-json.googleapis.com",
1559 target: "_blank",
1560 rel: "noopener noreferrer",
1561 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline",
1562 children: __("Google Calendar API", "yatra")
1563 }
1564 ),
1565 " ",
1566 __("is enabled.", "yatra")
1567 ] }),
1568 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
1569 /* @__PURE__ */ jsxRuntimeExports.jsx(
1570 Input,
1571 {
1572 id: "gc_redirect_uri",
1573 value: redirectUri,
1574 readOnly: true,
1575 className: "bg-gray-50 dark:bg-gray-900 font-mono text-sm"
1576 }
1577 ),
1578 /* @__PURE__ */ jsxRuntimeExports.jsx(
1579 Button,
1580 {
1581 variant: "outline",
1582 size: "sm",
1583 onClick: () => navigator.clipboard.writeText(redirectUri),
1584 children: __("Copy", "yatra")
1585 }
1586 )
1587 ] })
1588 }
1589 ),
1590 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md", children: [
1591 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [
1592 /* @__PURE__ */ jsxRuntimeExports.jsx(Shield, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }),
1593 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0 leading-relaxed", children: [
1594 __(
1595 "OAuth scopes required (add these on the Google OAuth consent screen):",
1596 "yatra"
1597 ),
1598 " ",
1599 /* @__PURE__ */ jsxRuntimeExports.jsx(
1600 "a",
1601 {
1602 href: "https://console.cloud.google.com/apis/credentials/consent",
1603 target: "_blank",
1604 rel: "noopener noreferrer",
1605 className: "text-amber-900 dark:text-amber-200 underline",
1606 children: __("OAuth Consent Screen", "yatra")
1607 }
1608 )
1609 ] })
1610 ] }),
1611 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 space-y-1", children: [
1612 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [
1613 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }),
1614 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-[11px] bg-amber-100 dark:bg-amber-900/40 px-1 py-0.5 rounded", children: "https://www.googleapis.com/auth/calendar" })
1615 ] }),
1616 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [
1617 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }),
1618 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-[11px] bg-amber-100 dark:bg-amber-900/40 px-1 py-0.5 rounded", children: "https://www.googleapis.com/auth/calendar.events" })
1619 ] })
1620 ] })
1621 ] }),
1622 connected && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md space-y-4", children: [
1623 /* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "font-medium text-sm text-green-800 dark:text-green-400 flex items-center gap-2", children: [
1624 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
1625 __("Connected Calendar", "yatra")
1626 ] }),
1627 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 md:items-end", children: [
1628 /* @__PURE__ */ jsxRuntimeExports.jsx(
1629 FormField,
1630 {
1631 id: "gc_calendar_id",
1632 label: __("Calendar ID", "yatra"),
1633 description: __(
1634 'The ID of the Google Calendar to sync events to. Use "primary" for your main calendar, or enter a specific calendar ID.',
1635 "yatra"
1636 ),
1637 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1638 Input,
1639 {
1640 id: "gc_calendar_id",
1641 value: calendarId,
1642 onChange: (e) => setCalendarId(e.target.value),
1643 placeholder: "primary"
1644 }
1645 )
1646 }
1647 ),
1648 /* @__PURE__ */ jsxRuntimeExports.jsx(
1649 FormField,
1650 {
1651 id: "gc_calendar_name",
1652 label: __("Calendar Name", "yatra"),
1653 description: __(
1654 "A friendly name for this calendar connection (for your reference only).",
1655 "yatra"
1656 ),
1657 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1658 Input,
1659 {
1660 id: "gc_calendar_name",
1661 value: calendarName,
1662 onChange: (e) => setCalendarName(e.target.value),
1663 placeholder: __("My Booking Calendar", "yatra")
1664 }
1665 )
1666 }
1667 )
1668 ] }),
1669 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between pt-2 border-t border-green-200 dark:border-green-800", children: [
1670 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-green-700 dark:text-green-400", children: lastSync ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1671 __("Last sync:", "yatra"),
1672 " ",
1673 new Date(lastSync).toLocaleString()
1674 ] }) : __("Never synced", "yatra") }),
1675 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
1676 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1677 "a",
1678 {
1679 href: gcDashboardUrl,
1680 className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md border border-green-300 dark:border-green-700 text-green-800 dark:text-green-300 hover:bg-green-100 dark:hover:bg-green-900/40",
1681 children: [
1682 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4" }),
1683 __("Open dashboard", "yatra")
1684 ]
1685 }
1686 ),
1687 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1688 Button,
1689 {
1690 size: "sm",
1691 onClick: handleSaveCalendar,
1692 disabled: savingCalendar,
1693 className: "flex items-center gap-2",
1694 children: [
1695 savingCalendar ? /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
1696 __("Save Calendar", "yatra")
1697 ]
1698 }
1699 ),
1700 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1701 Button,
1702 {
1703 variant: "outline",
1704 size: "sm",
1705 onClick: handleSync,
1706 disabled: syncing,
1707 className: "flex items-center gap-2",
1708 children: [
1709 /* @__PURE__ */ jsxRuntimeExports.jsx(
1710 RefreshCw,
1711 {
1712 className: `w-4 h-4 ${syncing ? "animate-spin" : ""}`
1713 }
1714 ),
1715 __("Sync Now", "yatra")
1716 ]
1717 }
1718 )
1719 ] })
1720 ] })
1721 ] }),
1722 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap justify-between items-center gap-3 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
1723 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-3", children: [
1724 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1725 "a",
1726 {
1727 href: gcDashboardUrl,
1728 className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm font-medium",
1729 children: [
1730 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3.5 h-3.5" }),
1731 __("Open Google Calendar dashboard", "yatra")
1732 ]
1733 }
1734 ),
1735 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1736 "a",
1737 {
1738 href: "https://console.cloud.google.com/apis/credentials",
1739 target: "_blank",
1740 rel: "noopener noreferrer",
1741 className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm",
1742 children: [
1743 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
1744 __("Credentials", "yatra")
1745 ]
1746 }
1747 ),
1748 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1749 "a",
1750 {
1751 href: "https://console.cloud.google.com/apis/library/calendar-json.googleapis.com",
1752 target: "_blank",
1753 rel: "noopener noreferrer",
1754 className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm",
1755 children: [
1756 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
1757 __("Calendar API", "yatra")
1758 ]
1759 }
1760 ),
1761 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1762 "a",
1763 {
1764 href: "https://console.cloud.google.com/apis/credentials/consent",
1765 target: "_blank",
1766 rel: "noopener noreferrer",
1767 className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm",
1768 children: [
1769 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
1770 __("OAuth Consent", "yatra")
1771 ]
1772 }
1773 )
1774 ] }),
1775 connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
1776 Button,
1777 {
1778 variant: "destructive",
1779 onClick: handleDisconnect,
1780 className: "flex items-center gap-2",
1781 children: [
1782 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
1783 __("Disconnect", "yatra")
1784 ]
1785 }
1786 ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
1787 Button,
1788 {
1789 onClick: handleConnect,
1790 disabled: connecting || !clientId || !clientSecret,
1791 className: "flex items-center gap-2",
1792 children: [
1793 connecting ? /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4" }),
1794 __("Connect to Google Calendar", "yatra")
1795 ]
1796 }
1797 )
1798 ] })
1799 ] })
1800 ] }) });
1801 };
1802 const getInitialFormSubTab = () => {
1803 if (typeof window !== "undefined") {
1804 const saved = localStorage.getItem("yatra_settings_booking_form_subtab");
1805 if (saved && ["contact_form", "emergency_contact_form", "traveler_form"].includes(
1806 saved
1807 )) {
1808 return saved;
1809 }
1810 }
1811 return "contact_form";
1812 };
1813 const BookingFormBuilder = ({
1814 formData,
1815 setFormData
1816 }) => {
1817 var _a, _b, _c, _d, _e, _f, _g, _h;
1818 const [activeFormTab, setActiveFormTab] = reactExports.useState(getInitialFormSubTab);
1819 const { data: modulesData } = useQuery({
1820 queryKey: ["modules", "raw-envelope"],
1821 queryFn: async () => {
1822 const response = await apiService.getModules();
1823 return response;
1824 },
1825 staleTime: 3e4
1826 // Cache for 30 seconds
1827 });
1828 const isDynamicFormFieldEnabled = React.useMemo(() => {
1829 var _a2;
1830 if (modulesData == null ? void 0 : modulesData.data) {
1831 const module = modulesData.data.find(
1832 (m) => m.slug === "dynamic_form_field"
1833 );
1834 return (module == null ? void 0 : module.enabled) === true && (module == null ? void 0 : module.is_available) === true;
1835 }
1836 return !!((_a2 = window.yatraAdmin) == null ? void 0 : _a2.dynamicFormFieldEnabled);
1837 }, [modulesData]);
1838 const conditionsSupported = isDynamicFormFieldEnabled && !!((_a = window.yatraAdmin) == null ? void 0 : _a.bookingFormConditionsEnabled);
1839 const [conditionsOpen, setConditionsOpen] = reactExports.useState(false);
1840 const hasAnyConditions = React.useMemo(() => {
1841 const cfg = formData == null ? void 0 : formData.booking_form_config;
1842 return !!cfg && Object.values(cfg).some(
1843 (s) => Array.isArray(s == null ? void 0 : s.conditions) && s.conditions.length > 0
1844 );
1845 }, [formData == null ? void 0 : formData.booking_form_config]);
1846 const { options: conditionTargetOptions } = useTripTargets(
1847 conditionsSupported && hasAnyConditions
1848 );
1849 const handleSubTabChange = (tab) => {
1850 setActiveFormTab(tab);
1851 if (typeof window !== "undefined") {
1852 localStorage.setItem("yatra_settings_booking_form_subtab", tab);
1853 }
1854 };
1855 const appliesToOptions = [
1856 { value: "all", label: __("All travelers", "yatra") },
1857 { value: "lead", label: __("Lead traveler only", "yatra") }
1858 ];
1859 const formTabs = [
1860 {
1861 id: "contact_form",
1862 label: __("Contact Form", "yatra"),
1863 description: "Lead traveler contact details"
1864 },
1865 {
1866 id: "emergency_contact_form",
1867 label: __("Emergency Contact", "yatra"),
1868 description: "Emergency contact information"
1869 },
1870 {
1871 id: "traveler_form",
1872 label: __("Traveler Form", "yatra"),
1873 description: "Individual traveler details"
1874 }
1875 ];
1876 const fieldTypes = [
1877 { value: "text", label: __("Text", "yatra") },
1878 { value: "email", label: __("Email", "yatra") },
1879 { value: "tel", label: __("Phone", "yatra") },
1880 { value: "date", label: __("Date", "yatra") },
1881 { value: "select", label: __("Dropdown", "yatra") },
1882 { value: "country", label: __("Country Selector", "yatra") },
1883 { value: "textarea", label: __("Text Area", "yatra") },
1884 { value: "number", label: __("Number", "yatra") },
1885 { value: "checkbox", label: __("Checkbox", "yatra") },
1886 { value: "text_block", label: __("Text Block (display only)", "yatra") }
1887 ];
1888 const widthOptions = [
1889 { value: "full", label: "Full Width" },
1890 { value: "half", label: "Half Width" },
1891 { value: "third", label: "One Third" }
1892 ];
1893 const getCurrentFormConfig = () => {
1894 var _a2;
1895 return ((_a2 = formData == null ? void 0 : formData.booking_form_config) == null ? void 0 : _a2[activeFormTab]) || {
1896 title: "",
1897 description: "",
1898 enabled: true,
1899 fields: []
1900 };
1901 };
1902 const bookingFormCapturesEmail = (() => {
1903 const cfg = formData == null ? void 0 : formData.booking_form_config;
1904 if (!cfg) return true;
1905 const sectionHasEnabledEmail = (section) => {
1906 if (!section || section.enabled === false) return false;
1907 return (section.fields || []).some(
1908 (f) => (f.type === "email" || f.id === "email") && f.enabled !== false
1909 );
1910 };
1911 return sectionHasEnabledEmail(cfg.contact_form) || sectionHasEnabledEmail(cfg.traveler_form);
1912 })();
1913 const updateFormConfig = (updates) => {
1914 setFormData((prev) => {
1915 if (!prev) return prev;
1916 return {
1917 ...prev,
1918 booking_form_config: {
1919 ...prev.booking_form_config,
1920 [activeFormTab]: {
1921 ...prev.booking_form_config[activeFormTab],
1922 ...updates
1923 }
1924 }
1925 };
1926 });
1927 };
1928 const currentConfig = getCurrentFormConfig();
1929 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1930 ProFeature,
1931 {
1932 title: __("Dynamic Form Field", "yatra"),
1933 description: __(
1934 "customize your booking forms with drag-and-drop field builder",
1935 "yatra"
1936 ),
1937 moduleName: "Dynamic Form Field",
1938 pricingUrl: "https://wpyatra.com/pricing?module=dynamic-form-field",
1939 isProActive: (_b = window.yatraAdmin) == null ? void 0 : _b.isPro,
1940 isModuleEnabled: isDynamicFormFieldEnabled,
1941 children: [
1942 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "flex gap-4", "aria-label": "Form Types", children: formTabs.map((tab) => /* @__PURE__ */ jsxRuntimeExports.jsx(
1943 "button",
1944 {
1945 onClick: () => handleSubTabChange(tab.id),
1946 className: `pb-3 px-1 border-b-2 font-medium text-sm transition-colors ${activeFormTab === tab.id ? "border-blue-500 text-blue-600 dark:text-blue-400" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`,
1947 children: tab.label
1948 },
1949 tab.id
1950 )) }) }),
1951 !bookingFormCapturesEmail && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 p-3 rounded-md border border-red-300 bg-red-50 dark:border-red-700 dark:bg-red-900/20 text-sm text-red-800 dark:text-red-300", children: [
1952 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold", children: "⚠" }),
1953 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: __(
1954 "No form is set to collect an email address. An email is required for booking confirmation, the customer account and the voucher. Please enable an email field on the Contact or Traveler form — otherwise customers can't complete checkout.",
1955 "yatra"
1956 ) })
1957 ] }),
1958 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
1959 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
1960 /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Form Section Settings", "yatra") }),
1961 conditionsSupported && /* @__PURE__ */ jsxRuntimeExports.jsxs(
1962 Button,
1963 {
1964 type: "button",
1965 variant: "outline",
1966 size: "sm",
1967 onClick: () => setConditionsOpen(true),
1968 className: "border-purple-300 text-purple-700 hover:bg-purple-50 dark:border-purple-700 dark:text-purple-300 dark:hover:bg-purple-900/20",
1969 title: __(
1970 "Give some trips their own version of this form",
1971 "yatra"
1972 ),
1973 "data-testid": "open-conditions",
1974 children: [
1975 /* @__PURE__ */ jsxRuntimeExports.jsx(SlidersHorizontal, { className: "w-4 h-4 mr-1.5" }),
1976 __("Conditions", "yatra"),
1977 (((_c = currentConfig.conditions) == null ? void 0 : _c.length) ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-1.5 text-[11px] px-1.5 py-0.5 rounded-full bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300 font-semibold", children: (_d = currentConfig.conditions) == null ? void 0 : _d.length })
1978 ]
1979 }
1980 )
1981 ] }) }),
1982 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [
1983 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
1984 /* @__PURE__ */ jsxRuntimeExports.jsx(
1985 "input",
1986 {
1987 type: "checkbox",
1988 id: "form_section_enabled",
1989 checked: currentConfig.enabled !== false,
1990 onChange: (e) => updateFormConfig({ enabled: e.target.checked }),
1991 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
1992 }
1993 ),
1994 /* @__PURE__ */ jsxRuntimeExports.jsx(
1995 Label,
1996 {
1997 htmlFor: "form_section_enabled",
1998 className: "font-medium cursor-pointer",
1999 children: __("Enable this form section", "yatra")
2000 }
2001 )
2002 ] }),
2003 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2004 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2005 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "form_title", children: __("Section Title", "yatra") }),
2006 /* @__PURE__ */ jsxRuntimeExports.jsx(
2007 Input,
2008 {
2009 id: "form_title",
2010 value: currentConfig.title || "",
2011 onChange: (e) => updateFormConfig({ title: e.target.value }),
2012 placeholder: "Enter section title",
2013 className: "mt-1"
2014 }
2015 )
2016 ] }),
2017 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2018 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "form_description", children: __("Section Description", "yatra") }),
2019 /* @__PURE__ */ jsxRuntimeExports.jsx(
2020 Input,
2021 {
2022 id: "form_description",
2023 value: currentConfig.description || "",
2024 onChange: (e) => updateFormConfig({ description: e.target.value }),
2025 placeholder: "Enter description",
2026 className: "mt-1"
2027 }
2028 )
2029 ] })
2030 ] }),
2031 conditionsSupported && (((_e = currentConfig.conditions) == null ? void 0 : _e.length) ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", "data-testid": "conditions-summary", children: [
2032 (_f = currentConfig.conditions) == null ? void 0 : _f.map((c, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2033 "div",
2034 {
2035 className: "flex flex-wrap items-center gap-2 px-3 py-2 rounded-md border border-dashed border-gray-300 dark:border-gray-600 text-sm",
2036 children: [
2037 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __("On", "yatra") }),
2038 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: describeTargets(c.targets, conditionTargetOptions) || __("(no trips selected)", "yatra") }),
2039 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: sprintf(
2040 __("→ “%1$s” · %2$d fields", "yatra"),
2041 c.title,
2042 c.fields.filter((f) => f.enabled !== false).length
2043 ) }),
2044 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1" }),
2045 /* @__PURE__ */ jsxRuntimeExports.jsx(
2046 Button,
2047 {
2048 type: "button",
2049 variant: "ghost",
2050 size: "sm",
2051 onClick: () => setConditionsOpen(true),
2052 children: __("Edit", "yatra")
2053 }
2054 )
2055 ]
2056 },
2057 c.id || i
2058 )),
2059 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2 px-3 py-2 rounded-md bg-gray-50 dark:bg-gray-800 text-sm", children: [
2060 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: __("All other trips", "yatra") }),
2061 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __("use this form (below)", "yatra") })
2062 ] })
2063 ] })
2064 ] })
2065 ] }),
2066 conditionsSupported && /* @__PURE__ */ jsxRuntimeExports.jsx(
2067 BookingFormConditionsModal,
2068 {
2069 isOpen: conditionsOpen,
2070 onClose: () => setConditionsOpen(false),
2071 formType: activeFormTab,
2072 formLabel: ((_g = formTabs.find((t) => t.id === activeFormTab)) == null ? void 0 : _g.label) || "",
2073 section: currentConfig,
2074 onSave: (conditions) => updateFormConfig({
2075 conditions: conditions.length > 0 ? conditions : void 0
2076 }),
2077 fieldTypes,
2078 widthOptions,
2079 appliesToOptions
2080 }
2081 ),
2082 /* @__PURE__ */ jsxRuntimeExports.jsx(
2083 BookingFormFieldsEditor,
2084 {
2085 formType: activeFormTab,
2086 fields: currentConfig.fields,
2087 onChange: (fields) => updateFormConfig({ fields }),
2088 fieldTypes,
2089 widthOptions,
2090 appliesToOptions
2091 }
2092 ),
2093 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
2094 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Preview", "yatra") }) }),
2095 /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-800 rounded-lg", children: [
2096 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-semibold text-lg mb-1", children: currentConfig.title || "Form Section" }),
2097 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-4", children: currentConfig.description }),
2098 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-4", children: (_h = currentConfig.fields) == null ? void 0 : _h.filter((f) => f.enabled).map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2099 "div",
2100 {
2101 className: field.width === "full" ? "col-span-2" : field.width === "third" ? "col-span-1" : "col-span-1",
2102 children: field.type === "text_block" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-form-text-block text-sm text-gray-600 dark:text-gray-300 whitespace-pre-line", children: (field.content || "").replace(/<[^>]*>/g, "") }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2103 /* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-sm", children: [
2104 field.label,
2105 field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" })
2106 ] }),
2107 field.type === "select" || field.type === "country" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { disabled: true, className: "mt-1 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("option", { children: field.placeholder || "Select..." }) }) : field.type === "textarea" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2108 "textarea",
2109 {
2110 disabled: true,
2111 placeholder: field.placeholder,
2112 className: "mt-1 w-full px-3 py-2 border border-gray-300 rounded-md bg-white dark:bg-gray-700 text-sm",
2113 rows: 2
2114 }
2115 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
2116 Input,
2117 {
2118 disabled: true,
2119 type: field.type,
2120 placeholder: field.placeholder,
2121 className: "mt-1"
2122 }
2123 )
2124 ] })
2125 },
2126 field.id
2127 )) })
2128 ] }) })
2129 ] })
2130 ]
2131 }
2132 ) });
2133 };
2134 const Settings = () => {
2135 var _a, _b;
2136 const queryClient = useQueryClient();
2137 const { can } = usePermissions();
2138 const { showToast } = useToast();
2139 const getInitialActiveSection = () => {
2140 const VALID_SECTIONS = [
2141 "general",
2142 "design",
2143 "booking",
2144 "booking_form",
2145 "payment",
2146 "trip",
2147 "customer",
2148 "review",
2149 "tax",
2150 "currency",
2151 "integration",
2152 "permalink",
2153 "seo",
2154 "advanced",
2155 "uninstall"
2156 ];
2157 if (typeof window !== "undefined") {
2158 const fromUrl = new URLSearchParams(window.location.search).get(
2159 "section"
2160 );
2161 if (fromUrl && VALID_SECTIONS.includes(fromUrl)) {
2162 return fromUrl;
2163 }
2164 const saved = localStorage.getItem("yatra_settings_active_section");
2165 if (saved === "email" || saved === "notification") {
2166 return "general";
2167 }
2168 if (saved && [
2169 "general",
2170 "design",
2171 "booking",
2172 "booking_form",
2173 "payment",
2174 "trip",
2175 "customer",
2176 "review",
2177 "tax",
2178 "currency",
2179 "integration",
2180 "permalink",
2181 "seo",
2182 "advanced",
2183 "uninstall"
2184 ].includes(saved)) {
2185 return saved;
2186 }
2187 }
2188 return "general";
2189 };
2190 const [activeSection, setActiveSection] = reactExports.useState(
2191 getInitialActiveSection()
2192 );
2193 const [viewingSection, setViewingSection] = reactExports.useState(
2194 getInitialActiveSection()
2195 );
2196 const [isSaving, setIsSaving] = reactExports.useState(false);
2197 const [expandedGateways, setExpandedGateways] = reactExports.useState({});
2198 const [gatewayOrder, setGatewayOrder] = reactExports.useState([]);
2199 const [draggedGateway, setDraggedGateway] = reactExports.useState(null);
2200 const [usageStatus, setUsageStatus] = reactExports.useState(
2201 null
2202 );
2203 const [usageBusy, setUsageBusy] = reactExports.useState(false);
2204 const [usageLoading, setUsageLoading] = reactExports.useState(false);
2205 const [usageError, setUsageError] = reactExports.useState("");
2206 reactExports.useEffect(() => {
2207 setViewingSection(activeSection);
2208 }, [activeSection]);
2209 const {
2210 data: settings,
2211 isLoading,
2212 error
2213 } = useQuery({
2214 queryKey: ["settings"],
2215 queryFn: async () => {
2216 try {
2217 return await fetchSettings();
2218 } catch (error2) {
2219 console.error("Error fetching settings:", error2);
2220 showToast(
2221 (error2 == null ? void 0 : error2.message) || __("Failed to load settings", "yatra"),
2222 "error"
2223 );
2224 throw error2;
2225 }
2226 },
2227 enabled: can("yatra_manage_settings")
2228 // Avoid overwriting in-progress edits due to background refetches
2229 });
2230 const { data: gatewayDefinitions } = useQuery({
2231 queryKey: ["payment-gateways-definitions"],
2232 queryFn: async () => {
2233 try {
2234 const response = await fetchPaymentGatewayDefinitions();
2235 return response.gateways || {};
2236 } catch (error2) {
2237 console.error("Failed to load gateway definitions:", error2);
2238 return {};
2239 }
2240 },
2241 enabled: can("yatra_manage_settings"),
2242 staleTime: Infinity
2243 });
2244 reactExports.useEffect(() => {
2245 if (viewingSection !== "advanced" || !can("yatra_manage_settings")) {
2246 return;
2247 }
2248 let cancelled = false;
2249 setUsageLoading(true);
2250 setUsageError("");
2251 (async () => {
2252 var _a2;
2253 try {
2254 const s = await fetchUsageTrackingStatus();
2255 if (!cancelled) {
2256 setUsageStatus(s);
2257 }
2258 } catch (e) {
2259 if (!cancelled) {
2260 setUsageStatus(null);
2261 const status = ((_a2 = e == null ? void 0 : e.response) == null ? void 0 : _a2.status) != null ? ` (HTTP ${e.response.status})` : "";
2262 const msg = (typeof (e == null ? void 0 : e.message) === "string" && e.message.trim() !== "" ? e.message : __("Failed to load usage tracking status", "yatra")) + status;
2263 setUsageError(msg);
2264 }
2265 } finally {
2266 setUsageLoading(false);
2267 }
2268 })();
2269 return () => {
2270 cancelled = true;
2271 };
2272 }, [viewingSection, can]);
2273 const defaultSettings = reactExports.useMemo(
2274 () => ({
2275 company_name: "Yatra Travel Agency",
2276 company_email: "[email protected]",
2277 company_phone: "+1-234-567-8900",
2278 company_address: "123 Travel Street",
2279 company_city: "Kathmandu",
2280 company_state: "Bagmati",
2281 company_country: "Nepal",
2282 company_zip: "44600",
2283 company_website: "https://wpyatra.com",
2284 company_logo: "",
2285 timezone: "Asia/Kathmandu",
2286 date_format: "Y-m-d",
2287 time_format: "H:i",
2288 frontend_primary_color: "#3b82f6",
2289 frontend_container_max_width: "",
2290 frontend_listing_card_layout: "standard",
2291 // Search & Listing — defaults match current behaviour (all fields shown,
2292 // mobile filters expanded) so existing sites are unchanged.
2293 search_show_keyword: true,
2294 search_show_destination: true,
2295 search_show_activities: true,
2296 search_show_duration: true,
2297 search_show_budget: true,
2298 search_show_date: false,
2299 collapse_filters_on_mobile: false,
2300 booking_confirmation: true,
2301 auto_confirm_bookings: false,
2302 auto_confirm_mode: "online",
2303 require_login: false,
2304 allow_guest_checkout: true,
2305 require_guest_email_verification: false,
2306 booking_expiry_hours: 24,
2307 booking_reminder_days: 3,
2308 allow_waitlist: true,
2309 waitlist_auto_confirm: false,
2310 date_picker_as_dropdown: false,
2311 currency: "USD",
2312 payment_test_mode: true,
2313 payment_gateways: ["pay_later"],
2314 payment_methods: ["credit_card", "paypal", "bank_transfer"],
2315 partial_payment: true,
2316 partial_payment_percentage: 30,
2317 deposit_required: true,
2318 deposit_percentage: 20,
2319 auto_confirm_pay_later: true,
2320 enable_scheduled_payments: false,
2321 scheduled_payment_type: "single",
2322 scheduled_payment_days: 15,
2323 scheduled_payment_installments: 1,
2324 discount_stacking_mode: "both",
2325 scheduled_payment_interval: 30,
2326 scheduled_payment_reminder_days: 3,
2327 balance_anchor: "booking",
2328 balance_due_days: 14,
2329 gateway_configs: {
2330 stripe: {
2331 enabled: true,
2332 title: "Stripe",
2333 description: "Accept credit and debit cards",
2334 api_key: "",
2335 api_secret: "",
2336 webhook_secret: ""
2337 },
2338 paypal: {
2339 enabled: true,
2340 title: "PayPal",
2341 description: "Accept PayPal payments",
2342 client_id: "",
2343 client_secret: ""
2344 },
2345 razorpay: {
2346 enabled: false,
2347 title: "Razorpay",
2348 description: "Accept payments via Razorpay",
2349 api_key: "",
2350 api_secret: ""
2351 },
2352 square: {
2353 enabled: false,
2354 title: "Square",
2355 description: "Accept payments via Square",
2356 api_key: "",
2357 api_secret: ""
2358 },
2359 authorize_net: {
2360 enabled: false,
2361 title: "Authorize.net",
2362 description: "Accept payments via Authorize.net",
2363 api_key: "",
2364 api_secret: ""
2365 },
2366 bank_transfer: {
2367 enabled: false,
2368 title: "Bank Transfer",
2369 description: "Accept manual bank transfer payments",
2370 api_key: "",
2371 // Used for bank account name
2372 api_secret: "",
2373 // Used for bank account number
2374 public_key: "",
2375 // Used for bank name
2376 private_key: ""
2377 // Used for routing/SWIFT code
2378 },
2379 esewa: {
2380 enabled: false,
2381 title: "eSewa",
2382 description: "Accept payments via eSewa (Nepal)",
2383 api_key: "",
2384 api_secret: ""
2385 },
2386 khalti: {
2387 enabled: false,
2388 title: "Khalti",
2389 description: "Accept payments via Khalti (Nepal)",
2390 api_key: "",
2391 api_secret: ""
2392 },
2393 pay_later: {
2394 enabled: false,
2395 title: "Book Now, Pay Later",
2396 description: "Allow customers to reserve now and pay before the trip",
2397 api_key: "",
2398 // Used for payment deadline days
2399 api_secret: ""
2400 // Used for auto-cancel days
2401 }
2402 },
2403 gateway_order: [
2404 "pay_later",
2405 "stripe",
2406 "paypal",
2407 "razorpay",
2408 "square",
2409 "authorize_net",
2410 "bank_transfer",
2411 "esewa",
2412 "khalti"
2413 ],
2414 admin_email: "[email protected]",
2415 from_email: "[email protected]",
2416 from_name: "Yatra Travel",
2417 email_template_booking: true,
2418 email_template_confirmation: true,
2419 email_template_cancellation: true,
2420 email_template_reminder: true,
2421 email_template_admin_new_booking: true,
2422 email_template_admin_payment: true,
2423 email_template_admin_cancellation: true,
2424 email_template_trip_consent: true,
2425 email_template_customer_verification: true,
2426 email_template_guest_verification: true,
2427 email_template_booking_completed: true,
2428 email_template_booking_expired_customer: true,
2429 email_template_admin_booking_expired: true,
2430 email_template_scheduled_payment_reminder: true,
2431 email_template_scheduled_payment_succeeded: true,
2432 email_template_scheduled_payment_failed: true,
2433 email_template_admin_scheduled_payment_failed: true,
2434 email_template_enquiry_received: true,
2435 email_template_enquiry_admin: true,
2436 email_template_enquiry_response: true,
2437 email_template_review_request: false,
2438 email_template_abandoned_booking_recovery_first: true,
2439 email_template_abandoned_booking_recovery_second: true,
2440 email_template_abandoned_booking_recovery_final: true,
2441 smtp_enabled: false,
2442 smtp_host: "smtp.gmail.com",
2443 smtp_port: 587,
2444 smtp_username: "",
2445 smtp_password: "",
2446 smtp_encryption: "tls",
2447 email_tpl_booking_subject: "",
2448 email_tpl_booking_body: "",
2449 email_tpl_payment_subject: "",
2450 email_tpl_payment_body: "",
2451 email_tpl_cancellation_subject: "",
2452 email_tpl_cancellation_body: "",
2453 email_tpl_reminder_subject: "",
2454 email_tpl_reminder_body: "",
2455 email_tpl_admin_booking_subject: "",
2456 email_tpl_admin_booking_body: "",
2457 email_tpl_admin_payment_subject: "",
2458 email_tpl_admin_payment_body: "",
2459 email_tpl_admin_cancellation_subject: "",
2460 email_tpl_admin_cancellation_body: "",
2461 email_tpl_trip_consent_subject: "",
2462 email_tpl_trip_consent_body: "",
2463 email_tpl_customer_verification_subject: "",
2464 email_tpl_customer_verification_body: "",
2465 email_tpl_guest_verification_subject: "",
2466 email_tpl_guest_verification_body: "",
2467 email_tpl_booking_completed_subject: "",
2468 email_tpl_booking_completed_body: "",
2469 email_tpl_booking_expired_customer_subject: "",
2470 email_tpl_booking_expired_customer_body: "",
2471 email_tpl_admin_booking_expired_subject: "",
2472 email_tpl_admin_booking_expired_body: "",
2473 email_tpl_scheduled_payment_reminder_subject: "",
2474 email_tpl_scheduled_payment_reminder_body: "",
2475 email_tpl_scheduled_payment_succeeded_subject: "",
2476 email_tpl_scheduled_payment_succeeded_body: "",
2477 email_tpl_scheduled_payment_failed_subject: "",
2478 email_tpl_scheduled_payment_failed_body: "",
2479 email_tpl_admin_scheduled_payment_failed_subject: "",
2480 email_tpl_admin_scheduled_payment_failed_body: "",
2481 email_tpl_enquiry_received_subject: "",
2482 email_tpl_enquiry_received_body: "",
2483 email_tpl_enquiry_admin_subject: "",
2484 email_tpl_enquiry_admin_body: "",
2485 email_tpl_enquiry_response_subject: "",
2486 email_tpl_enquiry_response_body: "",
2487 email_tpl_review_request_subject: "",
2488 email_tpl_review_request_body: "",
2489 email_tpl_abandoned_booking_recovery_first_subject: "",
2490 email_tpl_abandoned_booking_recovery_first_body: "",
2491 email_tpl_abandoned_booking_recovery_second_subject: "",
2492 email_tpl_abandoned_booking_recovery_second_body: "",
2493 email_tpl_abandoned_booking_recovery_final_subject: "",
2494 email_tpl_abandoned_booking_recovery_final_body: "",
2495 customer_registration: true,
2496 customer_fields: ["name", "email", "phone", "address"],
2497 require_email_verification: false,
2498 customer_account_page: "/my-account",
2499 allow_customer_reviews: true,
2500 customer_dashboard_enabled: true,
2501 enable_reviews: true,
2502 require_booking: true,
2503 auto_approve_reviews: false,
2504 review_moderation: true,
2505 min_rating: 1,
2506 allow_anonymous_reviews: false,
2507 review_reminder_days: 3,
2508 review_reminder_max_age_days: 14,
2509 enable_tax: true,
2510 tax_name: __("Tax", "yatra"),
2511 tax_rate: 10,
2512 tax_inclusive: false,
2513 vat_number: "",
2514 tax_by_country: false,
2515 tax_rates: {},
2516 multiple_taxes_enabled: false,
2517 multiple_taxes: [],
2518 multiple_taxes_by_country: {},
2519 default_currency: "USD",
2520 multi_currency: false,
2521 currency_position: "left",
2522 currency_decimals: 2,
2523 thousand_separator: ",",
2524 decimal_separator: ".",
2525 sms_notifications: false,
2526 sms_provider: "twilio",
2527 sms_api_key: "",
2528 google_analytics: "",
2529 facebook_pixel: "",
2530 recaptcha_enabled: false,
2531 recaptcha_site_key: "",
2532 recaptcha_secret_key: "",
2533 recaptcha_score_threshold: 0.5,
2534 recaptcha_protect_enquiry: false,
2535 recaptcha_protect_booking: false,
2536 recaptcha_protect_registration: false,
2537 trip_base: "trip",
2538 destination_base: "destination",
2539 activity_base: "activity",
2540 trip_category_base: "trip-category",
2541 booking_base: "book",
2542 enable_wishlist: false,
2543 show_sold_out: true,
2544 availability_horizon_months: 12,
2545 use_booking_page: false,
2546 booking_page_id: 0,
2547 terms_page_id: 0,
2548 privacy_policy_page_id: 0,
2549 debug_mode: false,
2550 enable_logging: false,
2551 delete_data_on_uninstall: false,
2552 cache_enabled: true,
2553 api_key: "",
2554 api_rate_limit: 100,
2555 session_timeout: 3600,
2556 // Booking Form Builder
2557 booking_form_config: {
2558 contact_form: {
2559 title: "Lead Traveler / Contact Information",
2560 description: "Primary contact person for this booking",
2561 enabled: true,
2562 fields: [
2563 {
2564 id: "first_name",
2565 type: "text",
2566 label: "First Name",
2567 placeholder: "Enter first name",
2568 required: true,
2569 enabled: true,
2570 order: 1,
2571 width: "half",
2572 locked: true
2573 },
2574 {
2575 id: "last_name",
2576 type: "text",
2577 label: "Last Name",
2578 placeholder: "Enter last name",
2579 required: true,
2580 enabled: true,
2581 order: 2,
2582 width: "half",
2583 locked: true
2584 },
2585 {
2586 id: "email",
2587 type: "email",
2588 label: "Email Address",
2589 placeholder: "[email protected]",
2590 required: true,
2591 enabled: true,
2592 order: 3,
2593 width: "half",
2594 locked: true
2595 },
2596 {
2597 id: "phone",
2598 type: "tel",
2599 label: "Phone Number",
2600 placeholder: "+1 234 567 8900",
2601 required: true,
2602 enabled: true,
2603 order: 4,
2604 width: "half",
2605 locked: true
2606 },
2607 {
2608 id: "country",
2609 type: "country",
2610 label: "Country",
2611 placeholder: "Select Country",
2612 required: true,
2613 enabled: true,
2614 order: 5,
2615 width: "half",
2616 locked: true
2617 },
2618 {
2619 id: "nationality",
2620 type: "country",
2621 label: "Nationality",
2622 placeholder: "Select Nationality",
2623 required: false,
2624 enabled: true,
2625 order: 6,
2626 width: "half"
2627 },
2628 {
2629 id: "address",
2630 type: "text",
2631 label: "Address",
2632 placeholder: "Street address (optional)",
2633 required: false,
2634 enabled: true,
2635 order: 7,
2636 width: "full"
2637 }
2638 ]
2639 },
2640 emergency_contact_form: {
2641 title: "Emergency Contact",
2642 description: "Person to contact in case of emergency",
2643 enabled: true,
2644 fields: [
2645 {
2646 id: "name",
2647 type: "text",
2648 label: "Contact Name",
2649 placeholder: "Full name",
2650 required: true,
2651 enabled: true,
2652 order: 1,
2653 width: "half"
2654 },
2655 {
2656 id: "phone",
2657 type: "tel",
2658 label: "Contact Phone",
2659 placeholder: "+1 234 567 8900",
2660 required: true,
2661 enabled: true,
2662 order: 2,
2663 width: "half"
2664 },
2665 {
2666 id: "relationship",
2667 type: "select",
2668 label: "Relationship",
2669 placeholder: "Select Relationship",
2670 required: false,
2671 enabled: true,
2672 order: 3,
2673 width: "full",
2674 options: [
2675 { value: "spouse", label: "Spouse/Partner" },
2676 { value: "parent", label: "Parent" },
2677 { value: "sibling", label: "Sibling" },
2678 { value: "child", label: "Child" },
2679 { value: "friend", label: "Friend" },
2680 { value: "other", label: "Other" }
2681 ]
2682 }
2683 ]
2684 },
2685 traveler_form: {
2686 title: "Traveler Information",
2687 description: "Please provide details for each traveler",
2688 enabled: true,
2689 fields: [
2690 {
2691 id: "first_name",
2692 type: "text",
2693 label: "First Name",
2694 placeholder: "Legal first name",
2695 required: true,
2696 enabled: true,
2697 order: 1,
2698 width: "half"
2699 },
2700 {
2701 id: "last_name",
2702 type: "text",
2703 label: "Last Name",
2704 placeholder: "Legal last name",
2705 required: true,
2706 enabled: true,
2707 order: 2,
2708 width: "half"
2709 },
2710 {
2711 id: "date_of_birth",
2712 type: "date",
2713 label: "Date of Birth",
2714 placeholder: "",
2715 required: true,
2716 enabled: true,
2717 order: 3,
2718 width: "half"
2719 },
2720 {
2721 id: "gender",
2722 type: "select",
2723 label: "Gender",
2724 placeholder: "Select Gender",
2725 required: true,
2726 enabled: true,
2727 order: 4,
2728 width: "half",
2729 options: [
2730 { value: "male", label: "Male" },
2731 { value: "female", label: "Female" },
2732 { value: "other", label: "Other" }
2733 ]
2734 },
2735 {
2736 id: "nationality",
2737 type: "country",
2738 label: "Nationality",
2739 placeholder: "Select Nationality",
2740 required: true,
2741 enabled: true,
2742 order: 5,
2743 width: "full"
2744 },
2745 {
2746 id: "dietary",
2747 type: "select",
2748 label: "Dietary Requirements",
2749 placeholder: "Select",
2750 required: false,
2751 enabled: true,
2752 order: 6,
2753 width: "half",
2754 section: "dietary_medical",
2755 options: [
2756 { value: "none", label: "No special requirements" },
2757 { value: "vegetarian", label: "Vegetarian" },
2758 { value: "vegan", label: "Vegan" },
2759 { value: "halal", label: "Halal" },
2760 { value: "kosher", label: "Kosher" },
2761 { value: "gluten_free", label: "Gluten Free" },
2762 { value: "lactose_free", label: "Lactose Free" },
2763 { value: "other", label: "Other (specify in notes)" }
2764 ]
2765 },
2766 {
2767 id: "medical",
2768 type: "text",
2769 label: "Medical Conditions / Allergies",
2770 placeholder: "Any allergies or conditions",
2771 required: false,
2772 enabled: true,
2773 order: 7,
2774 width: "half",
2775 section: "dietary_medical"
2776 }
2777 ]
2778 }
2779 },
2780 // SEO Settings
2781 seo_trip_meta_title: "",
2782 seo_trip_meta_description: "",
2783 seo_trip_meta_keywords: "",
2784 seo_trip_meta_image: 0,
2785 enable_sitemap: true,
2786 sitemap_types: ["archive", "trip", "destination", "activity", "category"],
2787 sitemap_noindex_excluded: false
2788 }),
2789 []
2790 );
2791 const [formData, setFormData] = reactExports.useState(null);
2792 const isInitializedRef = React.useRef(false);
2793 const [mailchimpConnectionStatus, setMailchimpConnectionStatus] = reactExports.useState(null);
2794 const [mailchimpLists, setMailchimpLists] = reactExports.useState([]);
2795 const [mailchimpMergeFields, setMailchimpMergeFields] = reactExports.useState([]);
2796 const [showApiKey, setShowApiKey] = reactExports.useState(false);
2797 const [validatingApiKey, setValidatingApiKey] = reactExports.useState(false);
2798 const [showFacebookToken, setShowFacebookToken] = reactExports.useState(false);
2799 const [showGa4ApiSecret, setShowGa4ApiSecret] = reactExports.useState(false);
2800 const [seoImageUrl, setSeoImageUrl] = reactExports.useState("");
2801 const [seoImageLoading, setSeoImageLoading] = reactExports.useState(false);
2802 const [seoImageError, setSeoImageError] = reactExports.useState("");
2803 const [newTaxName, setNewTaxName] = reactExports.useState("");
2804 const [newTaxRate, setNewTaxRate] = reactExports.useState("");
2805 const [showPremiumDialog, setShowPremiumDialog] = reactExports.useState(false);
2806 const [selectedPremiumGateway, setSelectedPremiumGateway] = reactExports.useState("");
2807 const [validatingPixel, setValidatingPixel] = reactExports.useState(false);
2808 const [validatingToken, setValidatingToken] = reactExports.useState(false);
2809 const [validatingMeasurementId, setValidatingMeasurementId] = reactExports.useState(false);
2810 const [validatingApiSecret, setValidatingApiSecret] = reactExports.useState(false);
2811 const validateMailchimpApiKey = async () => {
2812 var _a2, _b2;
2813 if (!(formData == null ? void 0 : formData.mailchimp_api_key)) return;
2814 setValidatingApiKey(true);
2815 try {
2816 const response = await apiClient.post("/mailchimp/test", {
2817 api_key: formData.mailchimp_api_key
2818 });
2819 if (response.success) {
2820 const updatedMailchimpData = {
2821 ...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {},
2822 connectionStatus: {
2823 connected: true,
2824 error: null
2825 }
2826 };
2827 if (window.yatraAdmin) {
2828 window.yatraAdmin.mailchimp = updatedMailchimpData;
2829 }
2830 setMailchimpConnectionStatus({
2831 connected: true,
2832 error: void 0
2833 });
2834 await loadMailchimpLists();
2835 }
2836 } catch (error2) {
2837 const updatedMailchimpData = {
2838 ...((_b2 = window.yatraAdmin) == null ? void 0 : _b2.mailchimp) || {},
2839 connectionStatus: {
2840 connected: false,
2841 error: error2.message || __("Invalid API key", "yatra")
2842 }
2843 };
2844 if (window.yatraAdmin) {
2845 window.yatraAdmin.mailchimp = updatedMailchimpData;
2846 }
2847 setMailchimpConnectionStatus({
2848 connected: false,
2849 error: error2.message || __("Invalid API key", "yatra")
2850 });
2851 console.error("API key validation failed:", error2);
2852 } finally {
2853 setValidatingApiKey(false);
2854 }
2855 };
2856 const loadMailchimpLists = async () => {
2857 var _a2;
2858 try {
2859 const response = await apiClient.get("/mailchimp/lists");
2860 if (response.success && response.data) {
2861 setMailchimpLists(response.data);
2862 const updatedMailchimpData = {
2863 ...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {},
2864 availableLists: response.data
2865 };
2866 if (window.yatraAdmin) {
2867 window.yatraAdmin.mailchimp = updatedMailchimpData;
2868 }
2869 }
2870 } catch (error2) {
2871 console.error("Error loading Mailchimp lists:", error2);
2872 setMailchimpLists([]);
2873 }
2874 };
2875 const loadMailchimpMergeFields = async (listId) => {
2876 var _a2;
2877 if (!listId) {
2878 setMailchimpMergeFields([]);
2879 return;
2880 }
2881 try {
2882 const response = await apiClient.get(
2883 `/mailchimp/lists/${listId}/merge-fields`
2884 );
2885 if (response.success && response.data) {
2886 setMailchimpMergeFields(response.data);
2887 const updatedMailchimpData = {
2888 ...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {},
2889 mergeFields: response.data
2890 };
2891 if (window.yatraAdmin) {
2892 window.yatraAdmin.mailchimp = updatedMailchimpData;
2893 }
2894 }
2895 } catch (error2) {
2896 console.error("Error loading Mailchimp merge fields:", error2);
2897 setMailchimpMergeFields([]);
2898 }
2899 };
2900 React.useEffect(() => {
2901 if ((formData == null ? void 0 : formData.mailchimp_list_id) && (mailchimpConnectionStatus == null ? void 0 : mailchimpConnectionStatus.connected)) {
2902 loadMailchimpMergeFields(formData.mailchimp_list_id);
2903 }
2904 }, [formData == null ? void 0 : formData.mailchimp_list_id, mailchimpConnectionStatus == null ? void 0 : mailchimpConnectionStatus.connected]);
2905 React.useEffect(() => {
2906 var _a2, _b2;
2907 if ((_b2 = (_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) == null ? void 0 : _b2.connectionStatus) {
2908 setMailchimpConnectionStatus(
2909 window.yatraAdmin.mailchimp.connectionStatus
2910 );
2911 }
2912 }, []);
2913 const validateMeasurementId = async () => {
2914 if (!(formData == null ? void 0 : formData.ga4_measurement_id)) return;
2915 setValidatingMeasurementId(true);
2916 try {
2917 const raw = await apiService.validateGoogleAnalyticsMeasurementId(
2918 formData.ga4_measurement_id
2919 );
2920 if (raw == null ? void 0 : raw.success) {
2921 showToast(
2922 __("Measurement ID validated successfully!", "yatra"),
2923 "success"
2924 );
2925 } else {
2926 showToast(
2927 (raw == null ? void 0 : raw.message) || __("Measurement ID validation failed.", "yatra"),
2928 "error"
2929 );
2930 }
2931 } catch (error2) {
2932 showToast(
2933 error2.message || __("Failed to validate Measurement ID.", "yatra"),
2934 "error"
2935 );
2936 } finally {
2937 setValidatingMeasurementId(false);
2938 }
2939 };
2940 const validateApiSecret = async () => {
2941 if (!(formData == null ? void 0 : formData.ga4_measurement_id) || !(formData == null ? void 0 : formData.ga4_api_secret)) return;
2942 setValidatingApiSecret(true);
2943 try {
2944 const raw = await apiService.validateGoogleAnalyticsApiSecret(
2945 formData.ga4_measurement_id,
2946 formData.ga4_api_secret
2947 );
2948 if (raw == null ? void 0 : raw.success) {
2949 showToast(__("API Secret validated successfully!", "yatra"), "success");
2950 } else {
2951 showToast(
2952 (raw == null ? void 0 : raw.message) || __("API Secret validation failed.", "yatra"),
2953 "error"
2954 );
2955 }
2956 } catch (error2) {
2957 showToast(
2958 error2.message || __("Failed to validate API Secret.", "yatra"),
2959 "error"
2960 );
2961 } finally {
2962 setValidatingApiSecret(false);
2963 }
2964 };
2965 const validateFacebookPixel = async () => {
2966 var _a2, _b2, _c, _d, _e, _f;
2967 if (!(formData == null ? void 0 : formData.facebook_pixel_id)) return;
2968 setValidatingPixel(true);
2969 try {
2970 const response = await apiClient.post("/facebook-pixel/test", {
2971 pixel_id: formData.facebook_pixel_id
2972 });
2973 if (response.success) {
2974 const updatedFacebookPixelData = {
2975 ...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.facebookPixel) || {},
2976 connectionStatus: {
2977 ...((_c = (_b2 = window.yatraAdmin) == null ? void 0 : _b2.facebookPixel) == null ? void 0 : _c.connectionStatus) || {},
2978 pixelConnected: true,
2979 pixelError: null
2980 }
2981 };
2982 if (window.yatraAdmin) {
2983 window.yatraAdmin.facebookPixel = updatedFacebookPixelData;
2984 }
2985 }
2986 } catch (error2) {
2987 const updatedFacebookPixelData = {
2988 ...((_d = window.yatraAdmin) == null ? void 0 : _d.facebookPixel) || {},
2989 connectionStatus: {
2990 ...((_f = (_e = window.yatraAdmin) == null ? void 0 : _e.facebookPixel) == null ? void 0 : _f.connectionStatus) || {},
2991 pixelConnected: false,
2992 pixelError: error2.message || __("Invalid Pixel ID", "yatra")
2993 }
2994 };
2995 if (window.yatraAdmin) {
2996 window.yatraAdmin.facebookPixel = updatedFacebookPixelData;
2997 }
2998 console.error("Pixel validation failed:", error2);
2999 } finally {
3000 setValidatingPixel(false);
3001 }
3002 };
3003 const validateFacebookToken = async () => {
3004 var _a2, _b2, _c, _d, _e, _f;
3005 if (!(formData == null ? void 0 : formData.facebook_access_token)) return;
3006 setValidatingToken(true);
3007 try {
3008 const response = await apiClient.post("/facebook-pixel/test-token", {
3009 access_token: formData.facebook_access_token
3010 });
3011 if (response.success) {
3012 const updatedFacebookPixelData = {
3013 ...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.facebookPixel) || {},
3014 connectionStatus: {
3015 ...((_c = (_b2 = window.yatraAdmin) == null ? void 0 : _b2.facebookPixel) == null ? void 0 : _c.connectionStatus) || {},
3016 tokenConnected: true,
3017 tokenError: null
3018 }
3019 };
3020 if (window.yatraAdmin) {
3021 window.yatraAdmin.facebookPixel = updatedFacebookPixelData;
3022 }
3023 }
3024 } catch (error2) {
3025 const updatedFacebookPixelData = {
3026 ...((_d = window.yatraAdmin) == null ? void 0 : _d.facebookPixel) || {},
3027 connectionStatus: {
3028 ...((_f = (_e = window.yatraAdmin) == null ? void 0 : _e.facebookPixel) == null ? void 0 : _f.connectionStatus) || {},
3029 tokenConnected: false,
3030 tokenError: error2.message || __("Invalid access token", "yatra")
3031 }
3032 };
3033 if (window.yatraAdmin) {
3034 window.yatraAdmin.facebookPixel = updatedFacebookPixelData;
3035 }
3036 console.error("Access token validation failed:", error2);
3037 } finally {
3038 setValidatingToken(false);
3039 }
3040 };
3041 React.useEffect(() => {
3042 if (isInitializedRef.current) return;
3043 if (settings) {
3044 const mergedSettings = {
3045 ...defaultSettings,
3046 ...settings,
3047 // Ensure gateway_configs from defaults are merged with any saved configs
3048 gateway_configs: {
3049 ...defaultSettings.gateway_configs,
3050 ...settings.gateway_configs || {}
3051 }
3052 };
3053 setFormData(mergedSettings);
3054 isInitializedRef.current = true;
3055 } else if (!isLoading && !settings) {
3056 setFormData(defaultSettings);
3057 isInitializedRef.current = true;
3058 }
3059 }, [settings, isLoading]);
3060 React.useEffect(() => {
3061 let isMounted = true;
3062 const controller = new AbortController();
3063 const fetchSeoImageUrl = async () => {
3064 var _a2;
3065 const imageId = formData == null ? void 0 : formData.seo_trip_meta_image;
3066 if (!imageId || imageId <= 0) {
3067 if (isMounted) {
3068 setSeoImageUrl("");
3069 setSeoImageLoading(false);
3070 setSeoImageError("");
3071 }
3072 return;
3073 }
3074 if (isMounted) {
3075 setSeoImageLoading(true);
3076 setSeoImageError("");
3077 }
3078 try {
3079 const siteUrl = ((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || "";
3080 const response = await fetch(
3081 `${siteUrl}/wp-json/wp/v2/media/${imageId}`,
3082 {
3083 signal: controller.signal,
3084 headers: {
3085 Accept: "application/json"
3086 }
3087 }
3088 );
3089 if (!isMounted) return;
3090 if (response.ok) {
3091 const mediaData = await response.json();
3092 const imageUrl = mediaData == null ? void 0 : mediaData.source_url;
3093 if (imageUrl && typeof imageUrl === "string") {
3094 setSeoImageUrl(imageUrl);
3095 setSeoImageError("");
3096 } else {
3097 setSeoImageUrl("");
3098 setSeoImageError("Image not found");
3099 }
3100 } else {
3101 setSeoImageUrl("");
3102 setSeoImageError(`Failed to load image (${response.status})`);
3103 }
3104 } catch (error2) {
3105 if (isMounted) {
3106 console.error("Error fetching SEO image:", error2);
3107 setSeoImageUrl("");
3108 setSeoImageError(
3109 error2 instanceof Error ? error2.message : "Unknown error"
3110 );
3111 }
3112 } finally {
3113 if (isMounted) {
3114 setSeoImageLoading(false);
3115 }
3116 }
3117 };
3118 fetchSeoImageUrl();
3119 return () => {
3120 isMounted = false;
3121 controller.abort();
3122 };
3123 }, [formData == null ? void 0 : formData.seo_trip_meta_image]);
3124 const gatewayOrderInitialized = React.useRef(false);
3125 React.useEffect(() => {
3126 if (gatewayOrderInitialized.current) return;
3127 if (!gatewayDefinitions || Object.keys(gatewayDefinitions).length === 0) {
3128 return;
3129 }
3130 if (settings === void 0) return;
3131 const allGateways = Object.keys(gatewayDefinitions);
3132 const savedOrder = settings == null ? void 0 : settings.gateway_order;
3133 if (Array.isArray(savedOrder) && savedOrder.length > 0) {
3134 const validSavedOrder = savedOrder.filter(
3135 (id) => allGateways.includes(id)
3136 );
3137 const newGateways = allGateways.filter(
3138 (id) => !validSavedOrder.includes(id)
3139 );
3140 setGatewayOrder([...validSavedOrder, ...newGateways]);
3141 } else {
3142 setGatewayOrder(allGateways);
3143 }
3144 gatewayOrderInitialized.current = true;
3145 }, [gatewayDefinitions, settings]);
3146 const handleFieldChange = React.useCallback(
3147 (e) => {
3148 const field = e.target.name || e.target.id;
3149 let value;
3150 if (e.target.type === "checkbox") {
3151 value = e.target.checked;
3152 } else if (e.target.type === "number") {
3153 const raw = e.target.value;
3154 if (raw === "") {
3155 value = "";
3156 } else {
3157 const numValue = parseFloat(raw);
3158 value = isNaN(numValue) ? 0 : numValue;
3159 }
3160 } else {
3161 value = e.target.value;
3162 }
3163 setFormData((prev) => {
3164 if (!prev) return prev;
3165 return { ...prev, [field]: value };
3166 });
3167 },
3168 []
3169 );
3170 const timeZoneSelectOptions = reactExports.useMemo(() => {
3171 var _a2;
3172 const ya = window.yatraAdmin || {};
3173 const raw = ya.timeZoneIdentifiers;
3174 let ids = [];
3175 if (Array.isArray(raw) && raw.length > 0 && raw.every((x) => typeof x === "string")) {
3176 ids = raw;
3177 } else {
3178 ids = [
3179 "UTC",
3180 "America/New_York",
3181 "America/Los_Angeles",
3182 "Europe/London",
3183 "Europe/Paris",
3184 "Asia/Dubai",
3185 "Asia/Kolkata",
3186 "Asia/Kathmandu",
3187 "Australia/Sydney"
3188 ];
3189 }
3190 const set = new Set(ids);
3191 const wpTz = typeof ya.wordPressTimezone === "string" ? ya.wordPressTimezone.trim() : "";
3192 if (wpTz) {
3193 set.add(wpTz);
3194 }
3195 const current = (_a2 = formData == null ? void 0 : formData.timezone) == null ? void 0 : _a2.trim();
3196 if (current) {
3197 set.add(current);
3198 }
3199 return Array.from(set).sort((a, b) => a.localeCompare(b)).map((z) => ({ value: z, label: z }));
3200 }, [formData == null ? void 0 : formData.timezone]);
3201 const handleGatewayConfigChange = React.useCallback(
3202 (gateway, field, value) => {
3203 setFormData((prev) => {
3204 if (!prev) return prev;
3205 const configs = { ...prev.gateway_configs || {} };
3206 const existingConfig = configs[gateway] || {
3207 enabled: false,
3208 title: gateway,
3209 description: ""
3210 };
3211 configs[gateway] = { ...existingConfig, [field]: value };
3212 return { ...prev, gateway_configs: configs };
3213 });
3214 if (field === "enabled" && value === true) {
3215 setExpandedGateways((prev) => ({ ...prev, [gateway]: true }));
3216 }
3217 if (field === "enabled" && value === false) {
3218 setExpandedGateways((prev) => ({ ...prev, [gateway]: false }));
3219 }
3220 },
3221 []
3222 );
3223 const toggleGatewayExpanded = (gateway) => {
3224 setExpandedGateways((prev) => ({ ...prev, [gateway]: !prev[gateway] }));
3225 };
3226 const moveGatewayUp = (gatewayId) => {
3227 setGatewayOrder((prev) => {
3228 const index = prev.indexOf(gatewayId);
3229 if (index <= 0) return prev;
3230 const newOrder = [...prev];
3231 [newOrder[index - 1], newOrder[index]] = [
3232 newOrder[index],
3233 newOrder[index - 1]
3234 ];
3235 setFormData(
3236 (current) => current ? { ...current, gateway_order: newOrder } : current
3237 );
3238 return newOrder;
3239 });
3240 };
3241 const moveGatewayDown = (gatewayId) => {
3242 setGatewayOrder((prev) => {
3243 const index = prev.indexOf(gatewayId);
3244 if (index < 0 || index >= prev.length - 1) return prev;
3245 const newOrder = [...prev];
3246 [newOrder[index], newOrder[index + 1]] = [
3247 newOrder[index + 1],
3248 newOrder[index]
3249 ];
3250 setFormData(
3251 (current) => current ? { ...current, gateway_order: newOrder } : current
3252 );
3253 return newOrder;
3254 });
3255 };
3256 const handleDragStart = (e, gatewayId) => {
3257 setDraggedGateway(gatewayId);
3258 e.dataTransfer.effectAllowed = "move";
3259 };
3260 const handleDragOver = (e) => {
3261 e.preventDefault();
3262 e.dataTransfer.dropEffect = "move";
3263 };
3264 const handleDrop = (e, targetGatewayId) => {
3265 e.preventDefault();
3266 if (!draggedGateway || draggedGateway === targetGatewayId) {
3267 setDraggedGateway(null);
3268 return;
3269 }
3270 setGatewayOrder((prev) => {
3271 const dragIndex = prev.indexOf(draggedGateway);
3272 const dropIndex = prev.indexOf(targetGatewayId);
3273 if (dragIndex < 0 || dropIndex < 0) return prev;
3274 const newOrder = [...prev];
3275 newOrder.splice(dragIndex, 1);
3276 newOrder.splice(dropIndex, 0, draggedGateway);
3277 setFormData(
3278 (current) => current ? { ...current, gateway_order: newOrder } : current
3279 );
3280 return newOrder;
3281 });
3282 setDraggedGateway(null);
3283 };
3284 const handleDragEnd = () => {
3285 setDraggedGateway(null);
3286 };
3287 const saveMutation = useMutation({
3288 mutationFn: async (data) => {
3289 try {
3290 await saveSettings(data);
3291 return data;
3292 } catch (error2) {
3293 showToast(
3294 (error2 == null ? void 0 : error2.message) || __("Failed to save settings", "yatra"),
3295 "error"
3296 );
3297 throw error2;
3298 }
3299 },
3300 onSuccess: (savedData) => {
3301 queryClient.setQueryData(["settings"], savedData);
3302 showToast(__("Settings saved successfully", "yatra"), "success");
3303 setIsSaving(false);
3304 setFormData(savedData);
3305 isInitializedRef.current = true;
3306 },
3307 onError: (error2) => {
3308 setIsSaving(false);
3309 const errorMessage = (error2 == null ? void 0 : error2.message) || __("Error saving settings", "yatra");
3310 showToast(errorMessage, "error");
3311 }
3312 });
3313 const flushRewriteRulesMutation = useMutation({
3314 mutationFn: async () => {
3315 return await postFlushRewriteRules();
3316 },
3317 onSuccess: () => {
3318 showToast(__("Rewrite rules flushed successfully", "yatra"), "success");
3319 },
3320 onError: (error2) => {
3321 showToast(
3322 (error2 == null ? void 0 : error2.message) || __("Failed to flush rewrite rules", "yatra"),
3323 "error"
3324 );
3325 }
3326 });
3327 const { data: pagesData } = useQuery({
3328 queryKey: ["wordpress-pages"],
3329 queryFn: async () => {
3330 const response = await fetchWordPressPages();
3331 return response;
3332 },
3333 // Used by multiple sections (Booking page, Legal pages, etc.), so keep it available
3334 // whenever the user can manage Yatra settings.
3335 enabled: can("yatra_manage_settings")
3336 });
3337 const checkShortcodeMutation = useMutation({
3338 mutationFn: async (pageId) => {
3339 const response = await fetchBookingPageShortcodeStatus(pageId);
3340 return response;
3341 }
3342 });
3343 const insertShortcodeMutation = useMutation({
3344 mutationFn: async (pageId) => {
3345 return await postInsertBookingShortcode(pageId);
3346 },
3347 onSuccess: () => {
3348 showToast(__("Shortcode added successfully", "yatra"), "success");
3349 queryClient.invalidateQueries({ queryKey: ["wordpress-pages"] });
3350 },
3351 onError: (error2) => {
3352 showToast(
3353 (error2 == null ? void 0 : error2.message) || __("Failed to add shortcode", "yatra"),
3354 "error"
3355 );
3356 }
3357 });
3358 const [showShortcodeDialog, setShowShortcodeDialog] = reactExports.useState(false);
3359 const [selectedPageForShortcode, setSelectedPageForShortcode] = reactExports.useState(null);
3360 const [isCheckingShortcode, setIsCheckingShortcode] = reactExports.useState(false);
3361 const handleBookingPageChange = async (pageId) => {
3362 if (pageId === 0) {
3363 handleFieldChange({
3364 target: { name: "booking_page_id", value: 0 }
3365 });
3366 handleFieldChange({
3367 target: { name: "use_booking_page", value: false }
3368 });
3369 return;
3370 }
3371 const page = pagesData == null ? void 0 : pagesData.find((p) => p.id === pageId);
3372 if (!page) return;
3373 setIsCheckingShortcode(true);
3374 try {
3375 const result = await checkShortcodeMutation.mutateAsync(pageId);
3376 if (result.has_shortcode) {
3377 handleFieldChange({
3378 target: { name: "booking_page_id", value: pageId }
3379 });
3380 handleFieldChange({
3381 target: { name: "use_booking_page", value: true }
3382 });
3383 showToast(__("Booking page selected successfully", "yatra"), "success");
3384 } else {
3385 setSelectedPageForShortcode({ id: pageId, title: page.title });
3386 setShowShortcodeDialog(true);
3387 }
3388 } catch (error2) {
3389 showToast((error2 == null ? void 0 : error2.message) || __("Failed to check page", "yatra"), "error");
3390 } finally {
3391 setIsCheckingShortcode(false);
3392 }
3393 };
3394 const handleConfirmInsertShortcode = async () => {
3395 if (!selectedPageForShortcode) return;
3396 try {
3397 await insertShortcodeMutation.mutateAsync(selectedPageForShortcode.id);
3398 handleFieldChange({
3399 target: { name: "booking_page_id", value: selectedPageForShortcode.id }
3400 });
3401 handleFieldChange({
3402 target: { name: "use_booking_page", value: true }
3403 });
3404 setShowShortcodeDialog(false);
3405 setSelectedPageForShortcode(null);
3406 } catch (error2) {
3407 }
3408 };
3409 const handleSave = () => {
3410 if (formData) {
3411 setIsSaving(true);
3412 let updatedFormData = { ...formData };
3413 saveMutation.mutate(updatedFormData, {
3414 onSuccess: () => {
3415 setActiveSection(viewingSection);
3416 if (typeof window !== "undefined") {
3417 localStorage.setItem(
3418 "yatra_settings_active_section",
3419 viewingSection
3420 );
3421 }
3422 },
3423 onSettled: () => {
3424 setIsSaving(false);
3425 }
3426 });
3427 }
3428 };
3429 const settingsSections = [
3430 {
3431 id: "general",
3432 label: __("General", "yatra"),
3433 icon: Building2
3434 },
3435 {
3436 id: "design",
3437 label: __("Design", "yatra"),
3438 icon: Palette
3439 },
3440 {
3441 id: "booking",
3442 label: __("Booking", "yatra"),
3443 icon: Calendar
3444 },
3445 {
3446 id: "booking_form",
3447 label: __("Booking Form", "yatra"),
3448 icon: ClipboardList
3449 },
3450 {
3451 id: "search",
3452 label: __("Search & Listing", "yatra"),
3453 icon: SlidersHorizontal
3454 },
3455 {
3456 id: "payment",
3457 label: __("Payment", "yatra"),
3458 icon: DollarSign
3459 },
3460 // Pricing tab — visible on every Pro install so the Discount
3461 // Stacking control is *discoverable*. The setting itself only
3462 // takes effect when BOTH Advanced Discount and Dynamic Pricing
3463 // are enabled; the case "pricing" render gives a clear status
3464 // banner + disables the dropdown when prerequisites are missing.
3465 //
3466 // Truthy check (not `=== true`) because some WP installs end up
3467 // with `isPro` serialized as `1` instead of `true` through the
3468 // PHP→JSON→JS pipeline. Free installs serialize false (or omit
3469 // the key), which stays falsy and correctly hides the tab.
3470 ...((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.isPro) ? [
3471 {
3472 id: "pricing",
3473 label: __("Pricing", "yatra"),
3474 icon: Percent
3475 }
3476 ] : [],
3477 {
3478 id: "customer",
3479 label: __("Customer", "yatra"),
3480 icon: Users
3481 },
3482 {
3483 id: "review",
3484 label: __("Review", "yatra"),
3485 icon: Star
3486 },
3487 { id: "tax", label: __("Tax", "yatra"), icon: Receipt },
3488 {
3489 id: "currency",
3490 label: __("Currency", "yatra"),
3491 icon: Globe
3492 },
3493 {
3494 id: "integration",
3495 label: __("Integration", "yatra"),
3496 icon: Plug
3497 },
3498 {
3499 id: "permalink",
3500 label: __("Permalink", "yatra"),
3501 icon: Globe
3502 },
3503 {
3504 id: "seo",
3505 label: __("SEO", "yatra"),
3506 icon: TrendingUp
3507 },
3508 {
3509 id: "advanced",
3510 label: __("Advanced", "yatra"),
3511 icon: Shield
3512 },
3513 {
3514 id: "uninstall",
3515 label: __("Uninstall", "yatra"),
3516 icon: Trash2
3517 }
3518 ];
3519 const SectionDivider = ({ title }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-4 mt-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: title }) });
3520 const renderSettingsContent = () => {
3521 var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __2, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia;
3522 if (!formData) return null;
3523 switch (viewingSection) {
3524 case "general":
3525 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
3526 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
3527 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Company Information", "yatra") }),
3528 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
3529 /* @__PURE__ */ jsxRuntimeExports.jsx(
3530 FormField,
3531 {
3532 id: "company_name",
3533 label: __("Company Name", "yatra"),
3534 description: __(
3535 "Your travel agency or company name",
3536 "yatra"
3537 ),
3538 required: true,
3539 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3540 Input,
3541 {
3542 id: "company_name",
3543 name: "company_name",
3544 value: formData.company_name || "",
3545 onChange: handleFieldChange,
3546 placeholder: __("Enter company name", "yatra")
3547 }
3548 )
3549 }
3550 ),
3551 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
3552 /* @__PURE__ */ jsxRuntimeExports.jsx(
3553 FormField,
3554 {
3555 id: "company_email",
3556 label: __("Company Email", "yatra"),
3557 description: __("Primary contact email address", "yatra"),
3558 required: true,
3559 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3560 Input,
3561 {
3562 id: "company_email",
3563 name: "company_email",
3564 type: "email",
3565 value: formData.company_email || "",
3566 onChange: handleFieldChange,
3567 placeholder: __("[email protected]", "yatra")
3568 }
3569 )
3570 }
3571 ),
3572 /* @__PURE__ */ jsxRuntimeExports.jsx(
3573 FormField,
3574 {
3575 id: "company_phone",
3576 label: __("Company Phone", "yatra"),
3577 description: __("Primary contact phone number", "yatra"),
3578 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3579 Input,
3580 {
3581 id: "company_phone",
3582 name: "company_phone",
3583 value: formData.company_phone || "",
3584 onChange: handleFieldChange,
3585 placeholder: __("+1-234-567-8900", "yatra")
3586 }
3587 )
3588 }
3589 )
3590 ] }),
3591 /* @__PURE__ */ jsxRuntimeExports.jsx(
3592 FormField,
3593 {
3594 id: "company_address",
3595 label: __("Street Address", "yatra"),
3596 description: __("Street address of your company", "yatra"),
3597 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3598 Input,
3599 {
3600 id: "company_address",
3601 name: "company_address",
3602 value: formData.company_address || "",
3603 onChange: handleFieldChange,
3604 placeholder: __("123 Main Street", "yatra")
3605 }
3606 )
3607 }
3608 ),
3609 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
3610 /* @__PURE__ */ jsxRuntimeExports.jsx(FormField, { id: "company_city", label: __("City", "yatra"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3611 Input,
3612 {
3613 id: "company_city",
3614 name: "company_city",
3615 value: formData.company_city || "",
3616 onChange: handleFieldChange,
3617 placeholder: __("City", "yatra")
3618 }
3619 ) }),
3620 /* @__PURE__ */ jsxRuntimeExports.jsx(
3621 FormField,
3622 {
3623 id: "company_state",
3624 label: __("State/Province", "yatra"),
3625 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3626 Input,
3627 {
3628 id: "company_state",
3629 name: "company_state",
3630 value: formData.company_state || "",
3631 onChange: handleFieldChange,
3632 placeholder: __("State or Province", "yatra")
3633 }
3634 )
3635 }
3636 )
3637 ] }),
3638 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
3639 /* @__PURE__ */ jsxRuntimeExports.jsx(
3640 FormField,
3641 {
3642 id: "company_country",
3643 label: __("Country", "yatra"),
3644 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3645 Input,
3646 {
3647 id: "company_country",
3648 name: "company_country",
3649 value: formData.company_country || "",
3650 onChange: handleFieldChange,
3651 placeholder: __("Country", "yatra")
3652 }
3653 )
3654 }
3655 ),
3656 /* @__PURE__ */ jsxRuntimeExports.jsx(
3657 FormField,
3658 {
3659 id: "company_zip",
3660 label: __("ZIP/Postal Code", "yatra"),
3661 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3662 Input,
3663 {
3664 id: "company_zip",
3665 value: formData.company_zip,
3666 name: "company_zip",
3667 onChange: handleFieldChange,
3668 placeholder: __("ZIP Code", "yatra")
3669 }
3670 )
3671 }
3672 )
3673 ] }),
3674 /* @__PURE__ */ jsxRuntimeExports.jsx(
3675 FormField,
3676 {
3677 id: "company_website",
3678 label: __("Website URL", "yatra"),
3679 description: __("Your company website address", "yatra"),
3680 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3681 Input,
3682 {
3683 id: "company_website",
3684 type: "url",
3685 value: formData.company_website,
3686 name: "company_website",
3687 onChange: handleFieldChange,
3688 placeholder: __("https://example.com", "yatra")
3689 }
3690 )
3691 }
3692 )
3693 ] })
3694 ] }),
3695 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Regional Settings", "yatra") }),
3696 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
3697 /* @__PURE__ */ jsxRuntimeExports.jsx(
3698 FormField,
3699 {
3700 id: "timezone",
3701 label: __("Timezone", "yatra"),
3702 description: __(
3703 "Used for booking logic, emails, and date display. Search the full IANA list (same identifiers PHP uses).",
3704 "yatra"
3705 ),
3706 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
3707 ((_a2 = window.yatraAdmin) == null ? void 0 : _a2.wordPressTimezone) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
3708 Button,
3709 {
3710 type: "button",
3711 variant: "outline",
3712 size: "sm",
3713 className: "w-full sm:w-auto",
3714 onClick: () => handleFieldChange({
3715 target: {
3716 name: "timezone",
3717 id: "timezone",
3718 value: String(
3719 window.yatraAdmin.wordPressTimezone
3720 ),
3721 type: "select-one"
3722 }
3723 }),
3724 children: [
3725 __("Use WordPress site timezone", "yatra"),
3726 ": ",
3727 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-mono text-xs", children: window.yatraAdmin.wordPressTimezone })
3728 ]
3729 }
3730 ) : null,
3731 /* @__PURE__ */ jsxRuntimeExports.jsx(
3732 SearchableSelect,
3733 {
3734 value: formData.timezone,
3735 onChange: (val) => handleFieldChange({
3736 target: {
3737 name: "timezone",
3738 id: "timezone",
3739 value: val,
3740 type: "select-one"
3741 }
3742 }),
3743 options: timeZoneSelectOptions,
3744 searchPlaceholder: __(
3745 "Search by city, region, or code…",
3746 "yatra"
3747 ),
3748 placeholder: __("Select timezone…", "yatra"),
3749 showValueId: false
3750 }
3751 )
3752 ] })
3753 }
3754 ),
3755 /* @__PURE__ */ jsxRuntimeExports.jsx(
3756 FormField,
3757 {
3758 id: "date_format",
3759 label: __("Date Format", "yatra"),
3760 description: __("How dates are displayed", "yatra"),
3761 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3762 Select,
3763 {
3764 id: "date_format",
3765 value: formData.date_format,
3766 name: "date_format",
3767 onChange: handleFieldChange,
3768 children: [
3769 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y-m-d", children: [
3770 (/* @__PURE__ */ new Date()).toLocaleDateString("en-CA"),
3771 " (YYYY-MM-DD)"
3772 ] }),
3773 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y/m/d", children: [
3774 `${(/* @__PURE__ */ new Date()).getFullYear()}/${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}`,
3775 " ",
3776 "(YYYY/MM/DD)"
3777 ] }),
3778 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "m/d/Y", children: [
3779 `${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}/${(/* @__PURE__ */ new Date()).getFullYear()}`,
3780 " ",
3781 "(MM/DD/YYYY)"
3782 ] }),
3783 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d/m/Y", children: [
3784 `${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${(/* @__PURE__ */ new Date()).getFullYear()}`,
3785 " ",
3786 "(DD/MM/YYYY)"
3787 ] }),
3788 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d-m-Y", children: [
3789 `${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}-${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getFullYear()}`,
3790 " ",
3791 "(DD-MM-YYYY)"
3792 ] }),
3793 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d.m.Y", children: [
3794 `${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}.${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}.${(/* @__PURE__ */ new Date()).getFullYear()}`,
3795 " ",
3796 "(DD.MM.YYYY)"
3797 ] }),
3798 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "M j, Y", children: [
3799 (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
3800 month: "short",
3801 day: "numeric",
3802 year: "numeric"
3803 }),
3804 " ",
3805 "(Mon D, YYYY)"
3806 ] }),
3807 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "F j, Y", children: [
3808 (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
3809 month: "long",
3810 day: "numeric",
3811 year: "numeric"
3812 }),
3813 " ",
3814 "(Month D, YYYY)"
3815 ] }),
3816 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "j M Y", children: [
3817 `${(/* @__PURE__ */ new Date()).getDate()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "short" })} ${(/* @__PURE__ */ new Date()).getFullYear()}`,
3818 " ",
3819 "(D Mon YYYY)"
3820 ] }),
3821 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "j F Y", children: [
3822 `${(/* @__PURE__ */ new Date()).getDate()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "long" })} ${(/* @__PURE__ */ new Date()).getFullYear()}`,
3823 " ",
3824 "(D Month YYYY)"
3825 ] }),
3826 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y M j", children: [
3827 `${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "short" })} ${(/* @__PURE__ */ new Date()).getDate()}`,
3828 " ",
3829 "(YYYY Mon D)"
3830 ] }),
3831 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y F j", children: [
3832 `${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "long" })} ${(/* @__PURE__ */ new Date()).getDate()}`,
3833 " ",
3834 "(YYYY Month D)"
3835 ] }),
3836 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "l, F j, Y", children: [
3837 (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
3838 weekday: "long",
3839 month: "long",
3840 day: "numeric",
3841 year: "numeric"
3842 }),
3843 " ",
3844 "(Day, Month D, YYYY)"
3845 ] }),
3846 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "D, M j, Y", children: [
3847 (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
3848 weekday: "short",
3849 month: "short",
3850 day: "numeric",
3851 year: "numeric"
3852 }),
3853 " ",
3854 "(Day, Mon D, YYYY)"
3855 ] })
3856 ]
3857 }
3858 )
3859 }
3860 ),
3861 /* @__PURE__ */ jsxRuntimeExports.jsx(
3862 FormField,
3863 {
3864 id: "time_format",
3865 label: __("Time Format", "yatra"),
3866 description: __("12-hour or 24-hour format", "yatra"),
3867 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3868 Select,
3869 {
3870 id: "time_format",
3871 value: formData.time_format,
3872 name: "time_format",
3873 onChange: handleFieldChange,
3874 children: [
3875 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "H:i", children: "24 Hour (14:30)" }),
3876 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "h:i A", children: "12 Hour (2:30 PM)" })
3877 ]
3878 }
3879 )
3880 }
3881 )
3882 ] }) })
3883 ] });
3884 case "design":
3885 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
3886 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __(
3887 "Control how Yatra looks on the public site (trip pages, booking, listings, and shortcodes). These options complement your WordPress theme.",
3888 "yatra"
3889 ) }),
3890 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
3891 /* @__PURE__ */ jsxRuntimeExports.jsx(
3892 FormField,
3893 {
3894 id: "frontend_primary_color",
3895 label: __("Primary brand color", "yatra"),
3896 description: __(
3897 "Buttons, links, and highlights. Default is the standard Yatra blue; choose a hex color that matches your brand or theme accent.",
3898 "yatra"
3899 ),
3900 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
3901 /* @__PURE__ */ jsxRuntimeExports.jsx(
3902 "input",
3903 {
3904 type: "color",
3905 id: "frontend_primary_color_picker",
3906 "aria-label": __("Pick primary color", "yatra"),
3907 className: "h-10 w-14 cursor-pointer rounded border border-gray-300 bg-white p-0.5 dark:border-gray-600",
3908 value: /^#[0-9A-Fa-f]{6}$/.test(
3909 (formData.frontend_primary_color || "").trim()
3910 ) ? (formData.frontend_primary_color || "").trim() : "#3b82f6",
3911 onChange: (e) => handleFieldChange({
3912 target: {
3913 name: "frontend_primary_color",
3914 id: "frontend_primary_color",
3915 value: e.target.value,
3916 type: "text"
3917 }
3918 })
3919 }
3920 ),
3921 /* @__PURE__ */ jsxRuntimeExports.jsx(
3922 Input,
3923 {
3924 id: "frontend_primary_color",
3925 name: "frontend_primary_color",
3926 className: "max-w-[10rem] font-mono text-sm",
3927 value: formData.frontend_primary_color || "",
3928 onChange: handleFieldChange,
3929 placeholder: "#3b82f6",
3930 spellCheck: false
3931 }
3932 ),
3933 /* @__PURE__ */ jsxRuntimeExports.jsx(
3934 Button,
3935 {
3936 type: "button",
3937 variant: "outline",
3938 size: "sm",
3939 onClick: () => handleFieldChange({
3940 target: {
3941 name: "frontend_primary_color",
3942 id: "frontend_primary_color",
3943 value: "#3b82f6",
3944 type: "text"
3945 }
3946 }),
3947 children: __("Reset to default", "yatra")
3948 }
3949 )
3950 ] })
3951 }
3952 ),
3953 /* @__PURE__ */ jsxRuntimeExports.jsx(
3954 FormField,
3955 {
3956 id: "frontend_container_max_width",
3957 label: __("Container max width", "yatra"),
3958 description: __(
3959 "Optional. CSS width for trip listings, booking flow, and shortcode layouts (e.g. 1200px, 72rem, min(100%,80rem)). Leave empty to use your block theme layout (theme.json) or theme content width.",
3960 "yatra"
3961 ),
3962 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3963 Input,
3964 {
3965 id: "frontend_container_max_width",
3966 name: "frontend_container_max_width",
3967 className: "max-w-md font-mono text-sm",
3968 value: formData.frontend_container_max_width || "",
3969 onChange: handleFieldChange,
3970 placeholder: "1200px",
3971 spellCheck: false,
3972 autoComplete: "off"
3973 }
3974 )
3975 }
3976 ),
3977 /* @__PURE__ */ jsxRuntimeExports.jsx(
3978 FormField,
3979 {
3980 id: "frontend_listing_card_layout",
3981 label: __("Listing card layout", "yatra"),
3982 description: __(
3983 "How trip cards appear in listings and search results. Compact shows a dense card — image, title, price and a View Details button only — so several trips fit per screen. Ideal for phones. Existing sites keep the Standard card.",
3984 "yatra"
3985 ),
3986 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3987 "div",
3988 {
3989 role: "radiogroup",
3990 "aria-label": __("Listing card layout", "yatra"),
3991 className: "grid grid-cols-1 sm:grid-cols-3 gap-3 max-w-2xl",
3992 children: [
3993 {
3994 value: "standard",
3995 label: __("Standard", "yatra"),
3996 sub: __("Full card (default)", "yatra"),
3997 svg: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3998 "svg",
3999 {
4000 viewBox: "0 0 160 100",
4001 className: "w-full h-full",
4002 fill: "none",
4003 children: [
4004 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "46", y: "6", width: "68", height: "88", rx: "6", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }),
4005 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "12", width: "56", height: "30", rx: "3", fill: "#60a5fa" }),
4006 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "49", width: "44", height: "5", rx: "2.5", fill: "#94a3b8" }),
4007 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "59", width: "34", height: "3", rx: "1.5", fill: "#cbd5e1" }),
4008 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "66", width: "50", height: "3", rx: "1.5", fill: "#e2e8f0" }),
4009 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "73", width: "50", height: "3", rx: "1.5", fill: "#e2e8f0" }),
4010 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "82", width: "18", height: "6", rx: "2", fill: "#475569" }),
4011 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "86", y: "81", width: "22", height: "8", rx: "3", fill: "#3b82f6" })
4012 ]
4013 }
4014 )
4015 },
4016 {
4017 value: "compact_mobile",
4018 label: __("Compact — mobile", "yatra"),
4019 sub: __("Dense on phones · desktop unchanged", "yatra"),
4020 svg: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4021 "svg",
4022 {
4023 viewBox: "0 0 160 100",
4024 className: "w-full h-full",
4025 fill: "none",
4026 children: [
4027 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "50", y: "4", width: "60", height: "92", rx: "9", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }),
4028 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "72", y: "8", width: "16", height: "3", rx: "1.5", fill: "#e2e8f0" }),
4029 [0, 26, 52].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [
4030 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "56", y: "16", width: "48", height: "22", rx: "3", fill: "#f1f5f9" }),
4031 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "59", y: "19", width: "16", height: "16", rx: "2", fill: "#60a5fa" }),
4032 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "21", width: "20", height: "3", rx: "1.5", fill: "#94a3b8" }),
4033 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "27", width: "12", height: "2.5", rx: "1.25", fill: "#cbd5e1" }),
4034 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "32", width: "9", height: "3", rx: "1.5", fill: "#475569" }),
4035 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "93", y: "31.5", width: "6", height: "4", rx: "1.5", fill: "#3b82f6" })
4036 ] }, dy))
4037 ]
4038 }
4039 )
4040 },
4041 {
4042 value: "compact_all",
4043 label: __("Compact — everywhere", "yatra"),
4044 sub: __("Dense on mobile & desktop", "yatra"),
4045 svg: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4046 "svg",
4047 {
4048 viewBox: "0 0 160 100",
4049 className: "w-full h-full",
4050 fill: "none",
4051 children: [
4052 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "10", y: "12", width: "98", height: "58", rx: "4", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }),
4053 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "51", y: "70", width: "16", height: "8", fill: "#cbd5e1" }),
4054 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "39", y: "78", width: "40", height: "4", rx: "2", fill: "#cbd5e1" }),
4055 [0, 24].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [
4056 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "16", y: "18", width: "86", height: "20", rx: "3", fill: "#f1f5f9" }),
4057 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "19", y: "21", width: "14", height: "14", rx: "2", fill: "#60a5fa" }),
4058 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "37", y: "23", width: "34", height: "3", rx: "1.5", fill: "#94a3b8" }),
4059 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "37", y: "29", width: "20", height: "2.5", rx: "1.25", fill: "#cbd5e1" }),
4060 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "86", y: "27", width: "12", height: "6", rx: "2", fill: "#3b82f6" })
4061 ] }, dy)),
4062 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "120", y: "26", width: "30", height: "62", rx: "5", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }),
4063 [0, 18, 36].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [
4064 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "124", y: "32", width: "22", height: "14", rx: "2", fill: "#f1f5f9" }),
4065 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "126", y: "34", width: "10", height: "10", rx: "1.5", fill: "#60a5fa" }),
4066 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "138", y: "36", width: "7", height: "2", rx: "1", fill: "#94a3b8" }),
4067 /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "138", y: "40", width: "5", height: "2", rx: "1", fill: "#cbd5e1" })
4068 ] }, dy))
4069 ]
4070 }
4071 )
4072 }
4073 ].map((opt) => {
4074 const selected = (formData.frontend_listing_card_layout || "standard") === opt.value;
4075 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4076 "button",
4077 {
4078 type: "button",
4079 role: "radio",
4080 "aria-checked": selected,
4081 onClick: () => handleFieldChange({
4082 target: {
4083 name: "frontend_listing_card_layout",
4084 id: "frontend_listing_card_layout",
4085 value: opt.value,
4086 type: "text"
4087 }
4088 }),
4089 className: `relative rounded-lg border-2 p-2.5 text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 ${selected ? "border-blue-600 ring-1 ring-blue-600 bg-blue-50/60 dark:bg-blue-900/20" : "border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,
4090 children: [
4091 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "aspect-[8/5] w-full overflow-hidden rounded-md bg-gray-50 dark:bg-gray-800/60", children: opt.svg }),
4092 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-sm font-medium text-gray-900 dark:text-white", children: opt.label }),
4093 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: opt.sub }),
4094 selected && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute top-2 right-2 inline-flex h-5 w-5 items-center justify-center rounded-full bg-blue-600 text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.7 5.3a1 1 0 010 1.4l-7 7a1 1 0 01-1.4 0l-3-3a1 1 0 011.4-1.4L9 11.6l6.3-6.3a1 1 0 011.4 0z" }) }) })
4095 ]
4096 },
4097 opt.value
4098 );
4099 })
4100 }
4101 )
4102 }
4103 )
4104 ] })
4105 ] });
4106 case "booking_form":
4107 return /* @__PURE__ */ jsxRuntimeExports.jsx(BookingFormBuilder, { formData, setFormData });
4108 case "payment":
4109 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4110 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
4111 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4112 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: [
4113 __("Flexible Payments", "yatra"),
4114 /* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_b2 = window.yatraAdmin) == null ? void 0 : _b2.isPro })
4115 ] }),
4116 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-4", children: __(
4117 "Enable deposit and partial payment options for bookings. Allow customers to pay a percentage upfront and the rest later.",
4118 "yatra"
4119 ) }),
4120 /* @__PURE__ */ jsxRuntimeExports.jsx(
4121 ProFeature,
4122 {
4123 title: __("Flexible Payments", "yatra"),
4124 description: __(
4125 "offer deposit and partial payment options to your customers",
4126 "yatra"
4127 ),
4128 moduleName: "Flexible Payments",
4129 pricingUrl: "https://wpyatra.com/pricing?module=flexible-payments",
4130 isProActive: (_c = window.yatraAdmin) == null ? void 0 : _c.isPro,
4131 isModuleEnabled: (_d = window.yatraAdmin) == null ? void 0 : _d.flexiblePaymentsEnabled,
4132 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
4133 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
4134 /* @__PURE__ */ jsxRuntimeExports.jsx(
4135 "input",
4136 {
4137 type: "checkbox",
4138 id: "partial_payment",
4139 checked: formData.partial_payment,
4140 name: "partial_payment",
4141 onChange: handleFieldChange,
4142 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4143 }
4144 ),
4145 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
4146 /* @__PURE__ */ jsxRuntimeExports.jsx(
4147 Label,
4148 {
4149 htmlFor: "partial_payment",
4150 className: "font-medium cursor-pointer",
4151 children: __("Enable Partial Payment", "yatra")
4152 }
4153 ),
4154 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
4155 "Allow customers to pay a portion now and the rest later",
4156 "yatra"
4157 ) })
4158 ] })
4159 ] }),
4160 formData.partial_payment && /* @__PURE__ */ jsxRuntimeExports.jsx(
4161 FormField,
4162 {
4163 id: "partial_payment_percentage",
4164 label: __("Partial Payment Percentage", "yatra"),
4165 description: __(
4166 "Percentage of total amount required for partial payment",
4167 "yatra"
4168 ),
4169 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
4170 /* @__PURE__ */ jsxRuntimeExports.jsx(
4171 Input,
4172 {
4173 id: "partial_payment_percentage",
4174 type: "number",
4175 value: formData.partial_payment_percentage,
4176 name: "partial_payment_percentage",
4177 onChange: handleFieldChange,
4178 min: "0",
4179 max: "100",
4180 className: "flex-1"
4181 }
4182 ),
4183 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" })
4184 ] })
4185 }
4186 ),
4187 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
4188 /* @__PURE__ */ jsxRuntimeExports.jsx(
4189 "input",
4190 {
4191 type: "checkbox",
4192 id: "deposit_required",
4193 checked: formData.deposit_required,
4194 name: "deposit_required",
4195 onChange: handleFieldChange,
4196 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4197 }
4198 ),
4199 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
4200 /* @__PURE__ */ jsxRuntimeExports.jsx(
4201 Label,
4202 {
4203 htmlFor: "deposit_required",
4204 className: "font-medium cursor-pointer",
4205 children: __("Require Deposit", "yatra")
4206 }
4207 ),
4208 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Require a deposit to confirm bookings", "yatra") })
4209 ] })
4210 ] }),
4211 formData.deposit_required && /* @__PURE__ */ jsxRuntimeExports.jsx(
4212 FormField,
4213 {
4214 id: "deposit_percentage",
4215 label: __("Deposit Percentage", "yatra"),
4216 description: __(
4217 "Percentage of total amount required as deposit",
4218 "yatra"
4219 ),
4220 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
4221 /* @__PURE__ */ jsxRuntimeExports.jsx(
4222 Input,
4223 {
4224 id: "deposit_percentage",
4225 type: "number",
4226 value: formData.deposit_percentage,
4227 name: "deposit_percentage",
4228 onChange: handleFieldChange,
4229 min: "0",
4230 max: "100",
4231 className: "flex-1"
4232 }
4233 ),
4234 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" })
4235 ] })
4236 }
4237 )
4238 ] })
4239 }
4240 )
4241 ] }),
4242 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4243 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: [
4244 __("Scheduled balance payments", "yatra"),
4245 /* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_e = window.yatraAdmin) == null ? void 0 : _e.isPro })
4246 ] }),
4247 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-4", children: __(
4248 "After a deposit or partial payment, automatically schedule the remaining balance with your gateway (Stripe invoices or subscription schedules). Requires a gateway customer and payment method from checkout.",
4249 "yatra"
4250 ) }),
4251 /* @__PURE__ */ jsxRuntimeExports.jsx(
4252 ProFeature,
4253 {
4254 title: __("Scheduled Payments", "yatra"),
4255 description: __(
4256 "schedule the remaining balance after partial or deposit payments",
4257 "yatra"
4258 ),
4259 moduleName: "Scheduled Payments",
4260 pricingUrl: "https://wpyatra.com/pricing?module=scheduled-payments",
4261 isProActive: (_f = window.yatraAdmin) == null ? void 0 : _f.isPro,
4262 isModuleEnabled: (_g = window.yatraAdmin) == null ? void 0 : _g.scheduledPaymentsEnabled,
4263 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
4264 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
4265 /* @__PURE__ */ jsxRuntimeExports.jsx(
4266 "input",
4267 {
4268 type: "checkbox",
4269 id: "enable_scheduled_payments",
4270 checked: formData.enable_scheduled_payments,
4271 name: "enable_scheduled_payments",
4272 onChange: handleFieldChange,
4273 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4274 }
4275 ),
4276 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
4277 /* @__PURE__ */ jsxRuntimeExports.jsx(
4278 Label,
4279 {
4280 htmlFor: "enable_scheduled_payments",
4281 className: "font-medium cursor-pointer",
4282 children: __("Enable scheduled balance payments", "yatra")
4283 }
4284 ),
4285 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
4286 "When a booking still has an amount due after checkout, create gateway-side schedules using the rules below.",
4287 "yatra"
4288 ) })
4289 ] })
4290 ] }),
4291 formData.enable_scheduled_payments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4292 /* @__PURE__ */ jsxRuntimeExports.jsx(
4293 FormField,
4294 {
4295 id: "balance_anchor",
4296 label: __("Balance schedule", "yatra"),
4297 description: __(
4298 "Whether the remaining balance is scheduled a fixed number of days after the deposit, or relative to the tour start date.",
4299 "yatra"
4300 ),
4301 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4302 Select,
4303 {
4304 id: "balance_anchor",
4305 name: "balance_anchor",
4306 value: formData.balance_anchor,
4307 onChange: handleFieldChange,
4308 children: [
4309 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "booking", children: __("A fixed number of days after the deposit", "yatra") }),
4310 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "tour", children: __("A number of days before the tour date", "yatra") })
4311 ]
4312 }
4313 )
4314 }
4315 ),
4316 formData.balance_anchor === "tour" && /* @__PURE__ */ jsxRuntimeExports.jsx(
4317 FormField,
4318 {
4319 id: "balance_due_days",
4320 label: __("Days before tour", "yatra"),
4321 description: __(
4322 "The balance is collected this many days before the tour starts. Bookings made inside this window must pay in full up front.",
4323 "yatra"
4324 ),
4325 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4326 Input,
4327 {
4328 id: "balance_due_days",
4329 type: "number",
4330 min: 1,
4331 max: 365,
4332 value: formData.balance_due_days,
4333 name: "balance_due_days",
4334 onChange: handleFieldChange,
4335 className: "max-w-xs"
4336 }
4337 )
4338 }
4339 ),
4340 /* @__PURE__ */ jsxRuntimeExports.jsx(
4341 FormField,
4342 {
4343 id: "scheduled_payment_type",
4344 label: __("Schedule type", "yatra"),
4345 description: __(
4346 "Single final charge on a date, or multiple installments.",
4347 "yatra"
4348 ),
4349 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4350 Select,
4351 {
4352 id: "scheduled_payment_type",
4353 name: "scheduled_payment_type",
4354 value: formData.scheduled_payment_type,
4355 onChange: handleFieldChange,
4356 children: [
4357 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "single", children: __("Single balance payment", "yatra") }),
4358 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "installments", children: __("Multiple installments", "yatra") })
4359 ]
4360 }
4361 )
4362 }
4363 ),
4364 formData.balance_anchor !== "tour" && /* @__PURE__ */ jsxRuntimeExports.jsx(
4365 FormField,
4366 {
4367 id: "scheduled_payment_days",
4368 label: __("Days until first charge", "yatra"),
4369 description: __(
4370 "How many days after the initial payment to schedule the first balance collection.",
4371 "yatra"
4372 ),
4373 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4374 Input,
4375 {
4376 id: "scheduled_payment_days",
4377 type: "number",
4378 min: 0,
4379 max: 365,
4380 value: formData.scheduled_payment_days,
4381 name: "scheduled_payment_days",
4382 onChange: handleFieldChange,
4383 className: "max-w-xs"
4384 }
4385 )
4386 }
4387 ),
4388 formData.scheduled_payment_type === "installments" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4389 /* @__PURE__ */ jsxRuntimeExports.jsx(
4390 FormField,
4391 {
4392 id: "scheduled_payment_installments",
4393 label: __("Number of installments", "yatra"),
4394 description: __(
4395 "Total installments including the scheduled balance (Stripe subscription schedule).",
4396 "yatra"
4397 ),
4398 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4399 Input,
4400 {
4401 id: "scheduled_payment_installments",
4402 type: "number",
4403 min: 2,
4404 max: 24,
4405 value: formData.scheduled_payment_installments,
4406 name: "scheduled_payment_installments",
4407 onChange: handleFieldChange,
4408 className: "max-w-xs"
4409 }
4410 )
4411 }
4412 ),
4413 /* @__PURE__ */ jsxRuntimeExports.jsx(
4414 FormField,
4415 {
4416 id: "scheduled_payment_interval",
4417 label: __("Days between installments", "yatra"),
4418 description: __(
4419 "Spacing between installment charges when using multiple installments.",
4420 "yatra"
4421 ),
4422 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4423 Input,
4424 {
4425 id: "scheduled_payment_interval",
4426 type: "number",
4427 min: 1,
4428 max: 365,
4429 value: formData.scheduled_payment_interval,
4430 name: "scheduled_payment_interval",
4431 onChange: handleFieldChange,
4432 className: "max-w-xs"
4433 }
4434 )
4435 }
4436 )
4437 ] }),
4438 /* @__PURE__ */ jsxRuntimeExports.jsx(
4439 FormField,
4440 {
4441 id: "scheduled_payment_reminder_days",
4442 label: __("Payment reminder (days before)", "yatra"),
4443 description: __(
4444 "Send the scheduled payment reminder email this many days before the due date (0 to disable reminders).",
4445 "yatra"
4446 ),
4447 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4448 Input,
4449 {
4450 id: "scheduled_payment_reminder_days",
4451 type: "number",
4452 min: 0,
4453 max: 30,
4454 value: formData.scheduled_payment_reminder_days,
4455 name: "scheduled_payment_reminder_days",
4456 onChange: handleFieldChange,
4457 className: "max-w-xs"
4458 }
4459 )
4460 }
4461 )
4462 ] })
4463 ] })
4464 }
4465 )
4466 ] }),
4467 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
4468 /* @__PURE__ */ jsxRuntimeExports.jsx(
4469 "input",
4470 {
4471 type: "checkbox",
4472 id: "auto_confirm_pay_later",
4473 checked: formData.auto_confirm_pay_later,
4474 name: "auto_confirm_pay_later",
4475 onChange: handleFieldChange,
4476 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4477 }
4478 ),
4479 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
4480 /* @__PURE__ */ jsxRuntimeExports.jsx(
4481 Label,
4482 {
4483 htmlFor: "auto_confirm_pay_later",
4484 className: "font-medium cursor-pointer",
4485 children: __('Auto-confirm "Pay Later" Bookings', "yatra")
4486 }
4487 ),
4488 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
4489 'Automatically confirm bookings when "Book Now, Pay Later" is selected. If disabled, bookings will remain pending until payment is received.',
4490 "yatra"
4491 ) })
4492 ] })
4493 ] })
4494 ] }),
4495 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4496 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Payment Gateways", "yatra") }),
4497 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg mb-4", children: [
4498 /* @__PURE__ */ jsxRuntimeExports.jsx(
4499 "input",
4500 {
4501 type: "checkbox",
4502 id: "payment_test_mode",
4503 checked: formData.payment_test_mode,
4504 name: "payment_test_mode",
4505 onChange: handleFieldChange,
4506 className: "w-5 h-5 rounded border-gray-300 text-amber-600 focus:ring-amber-500"
4507 }
4508 ),
4509 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
4510 /* @__PURE__ */ jsxRuntimeExports.jsx(
4511 Label,
4512 {
4513 htmlFor: "payment_test_mode",
4514 className: "font-semibold cursor-pointer text-amber-800 dark:text-amber-200",
4515 children: __("Test Mode", "yatra")
4516 }
4517 ),
4518 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-amber-700 dark:text-amber-300 mt-0.5", children: __(
4519 "Enable test/sandbox mode for all payment gateways. Use test API keys for development and testing. Disable this for live payments.",
4520 "yatra"
4521 ) })
4522 ] }),
4523 formData.payment_test_mode && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 py-1 text-xs font-semibold bg-amber-200 dark:bg-amber-800 text-amber-800 dark:text-amber-200 rounded", children: __("TEST", "yatra") })
4524 ] }),
4525 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4 flex items-center gap-1", children: [
4526 /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-3.5 h-3.5" }),
4527 __(
4528 "Drag and drop to reorder gateways. Use arrows for precise positioning.",
4529 "yatra"
4530 )
4531 ] }),
4532 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
4533 gatewayDefinitions && gatewayOrder.filter((id) => gatewayDefinitions[id]).map((gatewayId, index) => {
4534 var _a3, _b3;
4535 const gateway = gatewayDefinitions[gatewayId];
4536 const config = ((_a3 = formData.gateway_configs) == null ? void 0 : _a3[gatewayId]) || gateway.config || { enabled: false };
4537 const isExpanded = expandedGateways[gatewayId];
4538 const isDragging = draggedGateway === gatewayId;
4539 const isPremium = gateway.requires_pro || false;
4540 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4541 Card,
4542 {
4543 className: `relative border transition-all !py-0 ${isDragging ? "border-blue-400 bg-blue-50 dark:bg-blue-900/20 opacity-75" : config.enabled ? "border-green-200 dark:border-green-800" : "border-gray-200 dark:border-gray-700"}`,
4544 draggable: !isPremium,
4545 onDragStart: (e) => !isPremium && handleDragStart(e, gatewayId),
4546 onDragOver: !isPremium ? handleDragOver : void 0,
4547 onDrop: (e) => !isPremium && handleDrop(e, gatewayId),
4548 onDragEnd: !isPremium ? handleDragEnd : void 0,
4549 children: [
4550 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
4551 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
4552 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "cursor-grab active:cursor-grabbing p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300", children: /* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { className: "w-4 h-4" }) }),
4553 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-0.5", children: [
4554 /* @__PURE__ */ jsxRuntimeExports.jsx(
4555 "button",
4556 {
4557 type: "button",
4558 onClick: () => moveGatewayUp(gatewayId),
4559 disabled: index === 0,
4560 className: "p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-not-allowed",
4561 title: __("Move up", "yatra"),
4562 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowUp, { className: "w-3 h-3" })
4563 }
4564 ),
4565 /* @__PURE__ */ jsxRuntimeExports.jsx(
4566 "button",
4567 {
4568 type: "button",
4569 onClick: () => moveGatewayDown(gatewayId),
4570 disabled: index === gatewayOrder.length - 1,
4571 className: "p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-not-allowed",
4572 title: __("Move down", "yatra"),
4573 children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowDown, { className: "w-3 h-3" })
4574 }
4575 )
4576 ] }),
4577 /* @__PURE__ */ jsxRuntimeExports.jsx(
4578 "input",
4579 {
4580 type: "checkbox",
4581 id: `gateway_enable_${gatewayId}`,
4582 checked: config.enabled || false,
4583 onChange: (e) => {
4584 var _a4;
4585 if (gateway.requires_pro && e.target.checked) {
4586 e.preventDefault();
4587 const pricingUrl = ((_a4 = window.yatraAdmin) == null ? void 0 : _a4.pricingUrl) || "https://wpyatra.com/pricing";
4588 window.open(pricingUrl, "_blank");
4589 return;
4590 }
4591 handleGatewayConfigChange(
4592 gatewayId,
4593 "enabled",
4594 e.target.checked
4595 );
4596 },
4597 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4598 }
4599 ),
4600 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
4601 gateway.icon && /* @__PURE__ */ jsxRuntimeExports.jsx(
4602 "img",
4603 {
4604 src: gateway.icon,
4605 alt: gateway.title,
4606 className: "w-10 h-10 object-contain"
4607 }
4608 ),
4609 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4610 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-sm font-semibold flex items-center gap-2", children: [
4611 gateway.title,
4612 config.enabled && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-normal px-1.5 py-0.5 bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 rounded", children: __("Active", "yatra") }),
4613 formData.payment_test_mode && gateway.sandbox_url && /* @__PURE__ */ jsxRuntimeExports.jsx(
4614 "a",
4615 {
4616 href: gateway.sandbox_url,
4617 target: "_blank",
4618 rel: "noopener noreferrer",
4619 className: "text-xs font-normal px-1.5 py-0.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400 rounded hover:bg-amber-200 dark:hover:bg-amber-800/40 transition-colors",
4620 onClick: (e) => e.stopPropagation(),
4621 children: __("Sandbox Docs →", "yatra")
4622 }
4623 )
4624 ] }),
4625 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: gateway.description })
4626 ] })
4627 ] })
4628 ] }),
4629 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
4630 gateway.requires_pro && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-gradient-to-r from-purple-500 to-blue-500 text-white shadow-sm", children: "PRO" }),
4631 /* @__PURE__ */ jsxRuntimeExports.jsx(
4632 Button,
4633 {
4634 variant: "ghost",
4635 size: "sm",
4636 onClick: () => toggleGatewayExpanded(gatewayId),
4637 className: "h-8",
4638 disabled: !((_b3 = gateway.fields) == null ? void 0 : _b3.length),
4639 children: isExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4" })
4640 }
4641 )
4642 ] })
4643 ] }) }),
4644 isExpanded && /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "pt-4 space-y-4 border-t border-gray-100 dark:border-gray-700", children: [
4645 gateway.is_offline && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-blue-700 dark:text-blue-300", children: gateway.id === "pay_later" ? __(
4646 "Allow customers to book now and pay later. Payment must be completed before the trip date.",
4647 "yatra"
4648 ) : __(
4649 "This is an offline payment method. Customers will be shown these details after booking.",
4650 "yatra"
4651 ) }) }),
4652 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
4653 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Frontend Display Settings", "yatra") }),
4654 /* @__PURE__ */ jsxRuntimeExports.jsx(
4655 FormField,
4656 {
4657 id: `${gatewayId}_icon`,
4658 label: __("Gateway Icon", "yatra"),
4659 description: __(
4660 "Icon URL or path displayed on the booking page",
4661 "yatra"
4662 ),
4663 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
4664 /* @__PURE__ */ jsxRuntimeExports.jsx(
4665 Input,
4666 {
4667 type: "text",
4668 value: config.icon || gateway.icon || "",
4669 onChange: (e) => handleGatewayConfigChange(
4670 gatewayId,
4671 "icon",
4672 e.target.value
4673 ),
4674 placeholder: __(
4675 "Enter icon URL or leave empty to use default",
4676 "yatra"
4677 ),
4678 className: "flex-1"
4679 }
4680 ),
4681 config.icon || gateway.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4682 "img",
4683 {
4684 src: config.icon || gateway.icon,
4685 alt: gateway.title,
4686 className: "w-10 h-10 object-contain border border-gray-300 dark:border-gray-600 rounded p-1 bg-white dark:bg-gray-800",
4687 onError: (e) => {
4688 e.target.style.display = "none";
4689 }
4690 }
4691 ) : null
4692 ] })
4693 }
4694 ),
4695 /* @__PURE__ */ jsxRuntimeExports.jsx(
4696 FormField,
4697 {
4698 id: `${gatewayId}_title`,
4699 label: __("Gateway Title", "yatra"),
4700 description: __(
4701 "Title displayed on the booking page",
4702 "yatra"
4703 ),
4704 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4705 Input,
4706 {
4707 type: "text",
4708 value: config.title || gateway.title || "",
4709 onChange: (e) => handleGatewayConfigChange(
4710 gatewayId,
4711 "title",
4712 e.target.value
4713 ),
4714 placeholder: gateway.title || __("Enter gateway title", "yatra")
4715 }
4716 )
4717 }
4718 ),
4719 /* @__PURE__ */ jsxRuntimeExports.jsx(
4720 FormField,
4721 {
4722 id: `${gatewayId}_description`,
4723 label: __("Gateway Description", "yatra"),
4724 description: __(
4725 "Description displayed below the title on the booking page",
4726 "yatra"
4727 ),
4728 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4729 "textarea",
4730 {
4731 value: config.description || gateway.description || "",
4732 onChange: (e) => handleGatewayConfigChange(
4733 gatewayId,
4734 "description",
4735 e.target.value
4736 ),
4737 placeholder: gateway.description || __("Enter gateway description", "yatra"),
4738 className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none",
4739 rows: 2
4740 }
4741 )
4742 }
4743 )
4744 ] }),
4745 gateway.fields && gateway.fields.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: gateway.fields.map((field) => {
4746 if (field.condition && !config[field.condition]) {
4747 return null;
4748 }
4749 if (field.show_when) {
4750 const shouldShow = Object.entries(
4751 field.show_when
4752 ).every(
4753 ([key, value]) => {
4754 var _a4;
4755 return (config[key] || ((_a4 = gateway.fields.find(
4756 (f) => f.id === key
4757 )) == null ? void 0 : _a4.default)) === value;
4758 }
4759 );
4760 if (!shouldShow) {
4761 return null;
4762 }
4763 }
4764 if (field.type === "webhook_url") {
4765 const webhookUrl = String(
4766 field.default || config[field.id] || ""
4767 );
4768 const stripeSetupUrl = formData.payment_test_mode ? field.help_url_test || field.help_url_live : field.help_url_live || field.help_url_test;
4769 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4770 FormField,
4771 {
4772 id: `${gatewayId}_${field.id}`,
4773 label: field.label,
4774 children: [
4775 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
4776 /* @__PURE__ */ jsxRuntimeExports.jsx(
4777 Input,
4778 {
4779 readOnly: true,
4780 value: webhookUrl,
4781 onFocus: (e) => e.currentTarget.select(),
4782 className: "font-mono text-xs"
4783 }
4784 ),
4785 /* @__PURE__ */ jsxRuntimeExports.jsx(
4786 Button,
4787 {
4788 type: "button",
4789 variant: "outline",
4790 size: "sm",
4791 onClick: (e) => {
4792 var _a4, _b4;
4793 const btn = e.currentTarget;
4794 const input = (_a4 = btn.parentElement) == null ? void 0 : _a4.querySelector(
4795 "input"
4796 );
4797 let copied = false;
4798 try {
4799 if (input) {
4800 input.focus();
4801 input.select();
4802 input.setSelectionRange(
4803 0,
4804 webhookUrl.length
4805 );
4806 copied = document.execCommand(
4807 "copy"
4808 );
4809 }
4810 } catch {
4811 }
4812 if ((_b4 = navigator.clipboard) == null ? void 0 : _b4.writeText) {
4813 navigator.clipboard.writeText(webhookUrl).catch(() => {
4814 });
4815 copied = true;
4816 }
4817 const orig = __(
4818 "Copy",
4819 "yatra"
4820 );
4821 btn.textContent = copied ? __("Copied!", "yatra") : __(
4822 "Select & copy",
4823 "yatra"
4824 );
4825 window.setTimeout(() => {
4826 btn.textContent = orig;
4827 }, 1500);
4828 },
4829 children: __("Copy", "yatra")
4830 }
4831 )
4832 ] }),
4833 field.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1.5 text-xs text-gray-500 dark:text-gray-400 leading-relaxed", children: field.description }),
4834 stripeSetupUrl && /* @__PURE__ */ jsxRuntimeExports.jsxs(
4835 "a",
4836 {
4837 href: stripeSetupUrl,
4838 target: "_blank",
4839 rel: "noopener noreferrer",
4840 className: "mt-1.5 inline-block text-xs font-medium text-blue-600 dark:text-blue-400 border-b border-blue-600 dark:border-blue-400 hover:border-transparent",
4841 children: [
4842 field.help_text || __(
4843 "Open Stripe → Webhooks",
4844 "yatra"
4845 ),
4846 " ",
4847 "→"
4848 ]
4849 }
4850 )
4851 ]
4852 },
4853 field.id
4854 );
4855 }
4856 if (field.type === "checkbox") {
4857 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4858 "div",
4859 {
4860 className: "flex items-center gap-2 p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-md",
4861 children: [
4862 /* @__PURE__ */ jsxRuntimeExports.jsx(
4863 "input",
4864 {
4865 type: "checkbox",
4866 id: `${gatewayId}_${field.id}`,
4867 checked: config[field.id] || false,
4868 onChange: (e) => handleGatewayConfigChange(
4869 gatewayId,
4870 field.id,
4871 e.target.checked
4872 ),
4873 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
4874 }
4875 ),
4876 /* @__PURE__ */ jsxRuntimeExports.jsxs(
4877 Label,
4878 {
4879 htmlFor: `${gatewayId}_${field.id}`,
4880 className: "font-normal cursor-pointer",
4881 children: [
4882 field.label,
4883 " ",
4884 field.description && `- ${field.description}`
4885 ]
4886 }
4887 )
4888 ]
4889 },
4890 field.id
4891 );
4892 }
4893 if (field.type === "textarea") {
4894 return /* @__PURE__ */ jsxRuntimeExports.jsx(
4895 FormField,
4896 {
4897 id: `${gatewayId}_${field.id}`,
4898 label: field.label,
4899 description: field.description,
4900 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4901 "textarea",
4902 {
4903 value: config[field.id] || field.default || "",
4904 onChange: (e) => handleGatewayConfigChange(
4905 gatewayId,
4906 field.id,
4907 e.target.value
4908 ),
4909 placeholder: field.placeholder,
4910 className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none",
4911 rows: 3
4912 }
4913 )
4914 },
4915 field.id
4916 );
4917 }
4918 if (gateway.id === "stripe" && field.id === "enabled_methods") {
4919 const rawValue = config[field.id];
4920 const selectedValues = Array.isArray(
4921 rawValue
4922 ) ? rawValue : typeof rawValue === "string" && rawValue.length > 0 ? rawValue.split(",").map((val) => val.trim()).filter(Boolean) : ["card", "google_pay", "apple_pay"];
4923 const methodOptions = [
4924 {
4925 value: "card",
4926 label: __(
4927 "Card (Stripe Elements)",
4928 "yatra"
4929 )
4930 },
4931 {
4932 value: "google_pay",
4933 label: __(
4934 "Google Pay (Payment Request Button)",
4935 "yatra"
4936 )
4937 },
4938 {
4939 value: "apple_pay",
4940 label: __(
4941 "Apple Pay (Payment Request Button)",
4942 "yatra"
4943 )
4944 }
4945 ];
4946 const handleStripeMethodsChange = (values) => {
4947 handleGatewayConfigChange(
4948 gatewayId,
4949 field.id,
4950 values.join(",")
4951 );
4952 };
4953 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4954 "div",
4955 {
4956 className: "space-y-2",
4957 children: [
4958 /* @__PURE__ */ jsxRuntimeExports.jsx(
4959 FormField,
4960 {
4961 id: `${gatewayId}_${field.id}`,
4962 label: field.label,
4963 description: field.description,
4964 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4965 MultiSelect,
4966 {
4967 value: selectedValues,
4968 onChange: handleStripeMethodsChange,
4969 options: methodOptions,
4970 placeholder: __(
4971 "Select payment methods...",
4972 "yatra"
4973 )
4974 }
4975 )
4976 }
4977 ),
4978 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: [
4979 __(
4980 "Apple Pay requires domain verification inside your Stripe Dashboard.",
4981 "yatra"
4982 ),
4983 (field.help_url || field.help_url_test || field.help_url_live) && /* @__PURE__ */ jsxRuntimeExports.jsx(
4984 "a",
4985 {
4986 href: formData.payment_test_mode ? field.help_url_test || field.help_url : field.help_url_live || field.help_url,
4987 target: "_blank",
4988 rel: "noopener noreferrer",
4989 className: "ml-1 border-b border-blue-600 dark:border-blue-400 hover:border-transparent",
4990 children: __("Learn more →", "yatra")
4991 }
4992 )
4993 ] })
4994 ]
4995 },
4996 field.id
4997 );
4998 }
4999 if (field.type === "multiselect" && field.options) {
5000 const rawValue = config[field.id];
5001 const selectedValues = Array.isArray(
5002 rawValue
5003 ) ? rawValue : typeof rawValue === "string" && rawValue.length > 0 ? rawValue.split(",").map((val) => val.trim()).filter(Boolean) : Array.isArray(field.default) ? field.default : [];
5004 const methodOptions = Object.entries(field.options).map(
5005 ([value, label]) => ({
5006 value,
5007 label: String(label)
5008 })
5009 );
5010 const handleMultiSelectChange = (values) => {
5011 handleGatewayConfigChange(
5012 gatewayId,
5013 field.id,
5014 values
5015 );
5016 };
5017 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
5018 "div",
5019 {
5020 className: "space-y-2",
5021 children: [
5022 /* @__PURE__ */ jsxRuntimeExports.jsx(
5023 FormField,
5024 {
5025 id: `${gatewayId}_${field.id}`,
5026 label: field.label,
5027 description: field.description,
5028 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5029 MultiSelect,
5030 {
5031 value: selectedValues,
5032 onChange: handleMultiSelectChange,
5033 options: methodOptions,
5034 placeholder: __(
5035 "Select options...",
5036 "yatra"
5037 )
5038 }
5039 )
5040 }
5041 ),
5042 field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text })
5043 ]
5044 },
5045 field.id
5046 );
5047 }
5048 if (field.type === "select" && field.options) {
5049 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
5050 "div",
5051 {
5052 className: "space-y-2",
5053 children: [
5054 /* @__PURE__ */ jsxRuntimeExports.jsx(
5055 FormField,
5056 {
5057 id: `${gatewayId}_${field.id}`,
5058 label: field.label,
5059 description: field.description,
5060 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5061 Select,
5062 {
5063 value: config[field.id] ?? field.default ?? "",
5064 onChange: (e) => handleGatewayConfigChange(
5065 gatewayId,
5066 field.id,
5067 e.target.value
5068 ),
5069 children: Object.entries(
5070 field.options
5071 ).map(([value, label]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
5072 "option",
5073 {
5074 value,
5075 children: label
5076 },
5077 value
5078 ))
5079 }
5080 )
5081 }
5082 ),
5083 field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text })
5084 ]
5085 },
5086 field.id
5087 );
5088 }
5089 if (field.readonly) {
5090 const roValue = String(
5091 config[field.id] ?? field.default ?? ""
5092 );
5093 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
5094 "div",
5095 {
5096 className: "space-y-2",
5097 children: [
5098 /* @__PURE__ */ jsxRuntimeExports.jsx(
5099 FormField,
5100 {
5101 id: `${gatewayId}_${field.id}`,
5102 label: field.label,
5103 description: field.description,
5104 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
5105 /* @__PURE__ */ jsxRuntimeExports.jsx(
5106 Input,
5107 {
5108 id: `${gatewayId}_${field.id}`,
5109 value: roValue,
5110 readOnly: true,
5111 className: "bg-gray-50 dark:bg-gray-900 font-mono text-sm"
5112 }
5113 ),
5114 /* @__PURE__ */ jsxRuntimeExports.jsx(
5115 Button,
5116 {
5117 variant: "outline",
5118 size: "sm",
5119 onClick: () => navigator.clipboard.writeText(
5120 roValue
5121 ),
5122 children: __("Copy", "yatra")
5123 }
5124 )
5125 ] })
5126 }
5127 ),
5128 field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text })
5129 ]
5130 },
5131 field.id
5132 );
5133 }
5134 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
5135 /* @__PURE__ */ jsxRuntimeExports.jsx(
5136 FormField,
5137 {
5138 id: `${gatewayId}_${field.id}`,
5139 label: field.label,
5140 description: field.description,
5141 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5142 Input,
5143 {
5144 type: field.type === "email" ? "email" : field.type,
5145 value: config[field.id] ?? field.default ?? "",
5146 onChange: (e) => handleGatewayConfigChange(
5147 gatewayId,
5148 field.id,
5149 // Keep an empty field empty while
5150 // editing so the last character can
5151 // be cleared and retyped. Coercing
5152 // "" to 0 (parseFloat("") || 0) made
5153 // the field snap back and blocked
5154 // re-entry. Numbers are coerced on
5155 // save; "" persists harmlessly.
5156 field.type === "number" ? e.target.value === "" ? "" : parseFloat(
5157 e.target.value
5158 ) || 0 : e.target.value
5159 ),
5160 placeholder: field.placeholder,
5161 min: field.min,
5162 max: field.max
5163 }
5164 )
5165 }
5166 ),
5167 field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: [
5168 field.help_text,
5169 (field.help_url || field.help_url_test || field.help_url_live) && /* @__PURE__ */ jsxRuntimeExports.jsx(
5170 "a",
5171 {
5172 href: formData.payment_test_mode ? field.help_url_test || field.help_url : field.help_url_live || field.help_url,
5173 target: "_blank",
5174 rel: "noopener noreferrer",
5175 className: "ml-1 border-b border-blue-600 dark:border-blue-400 hover:border-transparent transition-colors",
5176 children: __("Learn more →", "yatra")
5177 }
5178 )
5179 ] })
5180 ] }, field.id);
5181 }) })
5182 ] }),
5183 isPremium && /* @__PURE__ */ jsxRuntimeExports.jsx(
5184 "div",
5185 {
5186 className: "absolute inset-0 bg-gradient-to-br from-purple-500/5 to-blue-500/5 dark:from-purple-500/10 dark:to-blue-500/10 rounded-lg cursor-pointer hover:from-purple-500/10 hover:to-blue-500/10 dark:hover:from-purple-500/15 dark:hover:to-blue-500/15 transition-all duration-200",
5187 onClick: () => {
5188 setSelectedPremiumGateway(gateway.title);
5189 setShowPremiumDialog(true);
5190 }
5191 }
5192 )
5193 ]
5194 },
5195 gatewayId
5196 );
5197 }),
5198 (!gatewayDefinitions || Object.keys(gatewayDefinitions).length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __("Loading payment gateways...", "yatra") }) })
5199 ] })
5200 ] })
5201 ] });
5202 case "search":
5203 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
5204 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5205 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-1", children: __("Search Bar Fields", "yatra") }),
5206 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
5207 "Choose which fields appear in the trip search bar. Turn off the ones you don't need for a cleaner search.",
5208 "yatra"
5209 ) }),
5210 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: [
5211 {
5212 key: "search_show_keyword",
5213 label: __("Keyword search", "yatra"),
5214 description: __(
5215 "Free-text field to search by trip name or keyword.",
5216 "yatra"
5217 )
5218 },
5219 {
5220 key: "search_show_destination",
5221 label: __("Destination", "yatra"),
5222 description: __(
5223 "Dropdown to filter trips by destination.",
5224 "yatra"
5225 )
5226 },
5227 {
5228 key: "search_show_activities",
5229 label: __("Activities", "yatra"),
5230 description: __(
5231 "Dropdown to filter trips by activity.",
5232 "yatra"
5233 )
5234 },
5235 {
5236 key: "search_show_duration",
5237 label: __("Duration", "yatra"),
5238 description: __(
5239 "Range slider to filter trips by number of days.",
5240 "yatra"
5241 )
5242 },
5243 {
5244 key: "search_show_budget",
5245 label: __("Budget", "yatra"),
5246 description: __(
5247 "Dropdown to filter trips by price range.",
5248 "yatra"
5249 )
5250 },
5251 {
5252 key: "search_show_date",
5253 label: __("Date", "yatra"),
5254 description: __(
5255 "Date picker to find trips with a departure on a specific date.",
5256 "yatra"
5257 )
5258 }
5259 ].map((row) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5260 "div",
5261 {
5262 className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",
5263 children: [
5264 /* @__PURE__ */ jsxRuntimeExports.jsx(
5265 "input",
5266 {
5267 type: "checkbox",
5268 id: row.key,
5269 checked: !!formData[row.key],
5270 name: row.key,
5271 onChange: handleFieldChange,
5272 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5273 }
5274 ),
5275 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5276 /* @__PURE__ */ jsxRuntimeExports.jsx(
5277 Label,
5278 {
5279 htmlFor: row.key,
5280 className: "font-medium cursor-pointer",
5281 children: row.label
5282 }
5283 ),
5284 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: row.description })
5285 ] })
5286 ]
5287 },
5288 row.key
5289 )) })
5290 ] }),
5291 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5292 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-1", children: __("Mobile Filters", "yatra") }),
5293 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
5294 "Controls the filter sidebar on the trip listing page on mobile devices.",
5295 "yatra"
5296 ) }),
5297 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5298 /* @__PURE__ */ jsxRuntimeExports.jsx(
5299 "input",
5300 {
5301 type: "checkbox",
5302 id: "collapse_filters_on_mobile",
5303 checked: !!formData.collapse_filters_on_mobile,
5304 name: "collapse_filters_on_mobile",
5305 onChange: handleFieldChange,
5306 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5307 }
5308 ),
5309 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5310 /* @__PURE__ */ jsxRuntimeExports.jsx(
5311 Label,
5312 {
5313 htmlFor: "collapse_filters_on_mobile",
5314 className: "font-medium cursor-pointer",
5315 children: __("Collapse filters by default on mobile", "yatra")
5316 }
5317 ),
5318 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5319 "On mobile, show filter sections collapsed so trip listings are visible right away. Visitors tap a section to expand it. Desktop is unaffected.",
5320 "yatra"
5321 ) })
5322 ] })
5323 ] })
5324 ] })
5325 ] });
5326 case "booking":
5327 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
5328 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
5329 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5330 /* @__PURE__ */ jsxRuntimeExports.jsx(
5331 "input",
5332 {
5333 type: "checkbox",
5334 id: "booking_confirmation",
5335 checked: formData.booking_confirmation,
5336 name: "booking_confirmation",
5337 onChange: handleFieldChange,
5338 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5339 }
5340 ),
5341 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5342 /* @__PURE__ */ jsxRuntimeExports.jsx(
5343 Label,
5344 {
5345 htmlFor: "booking_confirmation",
5346 className: "font-medium cursor-pointer",
5347 children: __("Send Booking Confirmation Email", "yatra")
5348 }
5349 ),
5350 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5351 "Send a confirmation email to the customer immediately after a successful booking. The post-checkout page is always shown; this toggle only controls the email.",
5352 "yatra"
5353 ) })
5354 ] })
5355 ] }),
5356 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5357 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Auto-Confirm Bookings", "yatra") }),
5358 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5 mb-2", children: __(
5359 "Choose when a booking is automatically set to Confirmed. Offline methods (bank transfer, pay later) stay pending until you confirm them.",
5360 "yatra"
5361 ) }),
5362 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { role: "radiogroup", className: "flex flex-col gap-2", children: [
5363 {
5364 value: "none",
5365 label: __("Don't auto-confirm", "yatra"),
5366 sub: __(
5367 "Every booking stays Pending until you confirm it manually.",
5368 "yatra"
5369 )
5370 },
5371 {
5372 value: "online",
5373 label: __("Auto-confirm online payments only", "yatra"),
5374 sub: __(
5375 "When an online payment (Stripe, PayPal, Razorpay…) pays the balance in full, the booking is confirmed. Deposits/partial payments and offline methods stay Pending.",
5376 "yatra"
5377 )
5378 },
5379 {
5380 value: "all",
5381 label: __("Auto-confirm all bookings", "yatra"),
5382 sub: __(
5383 "Every booking is confirmed at checkout, whether or not it was paid.",
5384 "yatra"
5385 )
5386 }
5387 ].map((opt) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5388 "label",
5389 {
5390 htmlFor: `auto_confirm_mode_${opt.value}`,
5391 className: "flex items-start gap-2 cursor-pointer",
5392 children: [
5393 /* @__PURE__ */ jsxRuntimeExports.jsx(
5394 "input",
5395 {
5396 type: "radio",
5397 id: `auto_confirm_mode_${opt.value}`,
5398 name: "auto_confirm_mode",
5399 value: opt.value,
5400 checked: (formData.auto_confirm_mode || "none") === opt.value,
5401 onChange: () => setFormData(
5402 (prev) => prev ? {
5403 ...prev,
5404 auto_confirm_mode: opt.value,
5405 // Keep the legacy boolean in sync for any
5406 // external reader (all → true, otherwise false).
5407 auto_confirm_bookings: opt.value === "all"
5408 } : prev
5409 ),
5410 className: "mt-0.5 w-4 h-4 border-gray-300 text-blue-600 focus:ring-blue-500"
5411 }
5412 ),
5413 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5414 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-sm", children: opt.label }),
5415 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: opt.sub })
5416 ] })
5417 ]
5418 },
5419 opt.value
5420 )) })
5421 ] }),
5422 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5423 /* @__PURE__ */ jsxRuntimeExports.jsx(
5424 "input",
5425 {
5426 type: "checkbox",
5427 id: "require_login",
5428 checked: formData.require_login,
5429 name: "require_login",
5430 onChange: handleFieldChange,
5431 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5432 }
5433 ),
5434 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5435 /* @__PURE__ */ jsxRuntimeExports.jsx(
5436 Label,
5437 {
5438 htmlFor: "require_login",
5439 className: "font-medium cursor-pointer",
5440 children: __("Require Login for Booking", "yatra")
5441 }
5442 ),
5443 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5444 "Customers must create an account to make bookings",
5445 "yatra"
5446 ) })
5447 ] })
5448 ] }),
5449 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5450 /* @__PURE__ */ jsxRuntimeExports.jsx(
5451 "input",
5452 {
5453 type: "checkbox",
5454 id: "allow_guest_checkout",
5455 checked: formData.allow_guest_checkout,
5456 name: "allow_guest_checkout",
5457 onChange: handleFieldChange,
5458 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5459 }
5460 ),
5461 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5462 /* @__PURE__ */ jsxRuntimeExports.jsx(
5463 Label,
5464 {
5465 htmlFor: "allow_guest_checkout",
5466 className: "font-medium cursor-pointer",
5467 children: __("Allow Guest Checkout", "yatra")
5468 }
5469 ),
5470 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5471 "Allow customers to book without creating an account",
5472 "yatra"
5473 ) })
5474 ] })
5475 ] }),
5476 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5477 /* @__PURE__ */ jsxRuntimeExports.jsx(
5478 "input",
5479 {
5480 type: "checkbox",
5481 id: "require_guest_email_verification",
5482 checked: formData.require_guest_email_verification,
5483 name: "require_guest_email_verification",
5484 onChange: handleFieldChange,
5485 disabled: !formData.allow_guest_checkout || formData.require_login,
5486 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:opacity-50"
5487 }
5488 ),
5489 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5490 /* @__PURE__ */ jsxRuntimeExports.jsx(
5491 Label,
5492 {
5493 htmlFor: "require_guest_email_verification",
5494 className: "font-medium cursor-pointer",
5495 children: __("Require Guest Email Verification", "yatra")
5496 }
5497 ),
5498 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5499 "Hold guest bookings until the customer clicks a magic link sent to their email. Stops typo'd addresses and form-spam bots. Only applies when guest checkout is allowed and login isn't required — logged-in customers are already verified.",
5500 "yatra"
5501 ) })
5502 ] })
5503 ] }),
5504 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5505 /* @__PURE__ */ jsxRuntimeExports.jsx(
5506 "input",
5507 {
5508 type: "checkbox",
5509 id: "show_sold_out",
5510 checked: formData.show_sold_out !== false,
5511 name: "show_sold_out",
5512 onChange: handleFieldChange,
5513 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5514 }
5515 ),
5516 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5517 /* @__PURE__ */ jsxRuntimeExports.jsx(
5518 Label,
5519 {
5520 htmlFor: "show_sold_out",
5521 className: "font-medium cursor-pointer",
5522 children: __("Show sold-out dates", "yatra")
5523 }
5524 ),
5525 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5526 'Keep sold-out dates on the calendar marked "Sold out" — needed for the waitlist below. Turn this off to hide them entirely, the way blocked dates are hidden.',
5527 "yatra"
5528 ) })
5529 ] })
5530 ] }),
5531 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5532 FormField,
5533 {
5534 id: "availability_horizon_months",
5535 label: __("Booking horizon (months)", "yatra"),
5536 description: __(
5537 "How far ahead customers can see and book dates on the storefront calendar — 1 to 36 months (default 12). A trip whose Available To date is earlier stops there. Long horizons make flexible-booking trips (no dates or rules configured) load more dates per page.",
5538 "yatra"
5539 ),
5540 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5541 Input,
5542 {
5543 id: "availability_horizon_months",
5544 type: "number",
5545 value: formData.availability_horizon_months ?? 12,
5546 name: "availability_horizon_months",
5547 onChange: handleFieldChange,
5548 min: "1",
5549 max: "36"
5550 }
5551 )
5552 }
5553 ) }),
5554 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5555 /* @__PURE__ */ jsxRuntimeExports.jsx(
5556 "input",
5557 {
5558 type: "checkbox",
5559 id: "allow_waitlist",
5560 checked: formData.allow_waitlist,
5561 name: "allow_waitlist",
5562 onChange: handleFieldChange,
5563 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5564 }
5565 ),
5566 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5567 /* @__PURE__ */ jsxRuntimeExports.jsx(
5568 Label,
5569 {
5570 htmlFor: "allow_waitlist",
5571 className: "font-medium cursor-pointer",
5572 children: __("Allow waitlist when a date is full", "yatra")
5573 }
5574 ),
5575 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5576 "Customers can join a waitlist instead of being blocked when seats are gone (per-trip caps still apply).",
5577 "yatra"
5578 ) })
5579 ] })
5580 ] }),
5581 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5582 /* @__PURE__ */ jsxRuntimeExports.jsx(
5583 "input",
5584 {
5585 type: "checkbox",
5586 id: "waitlist_auto_confirm",
5587 checked: formData.waitlist_auto_confirm,
5588 name: "waitlist_auto_confirm",
5589 onChange: handleFieldChange,
5590 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5591 }
5592 ),
5593 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5594 /* @__PURE__ */ jsxRuntimeExports.jsx(
5595 Label,
5596 {
5597 htmlFor: "waitlist_auto_confirm",
5598 className: "font-medium cursor-pointer",
5599 children: __("Auto-confirm promoted waitlist bookings", "yatra")
5600 }
5601 ),
5602 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5603 "When a spot opens, move the next waitlisted booking to confirmed; otherwise it becomes pending for staff review.",
5604 "yatra"
5605 ) })
5606 ] })
5607 ] }),
5608 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5609 /* @__PURE__ */ jsxRuntimeExports.jsx(
5610 "input",
5611 {
5612 type: "checkbox",
5613 id: "date_picker_as_dropdown",
5614 checked: !!formData.date_picker_as_dropdown,
5615 name: "date_picker_as_dropdown",
5616 onChange: handleFieldChange,
5617 disabled: !((_h = window.yatraAdmin) == null ? void 0 : _h.isPro),
5618 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:opacity-50"
5619 }
5620 ),
5621 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5622 /* @__PURE__ */ jsxRuntimeExports.jsxs(
5623 Label,
5624 {
5625 htmlFor: "date_picker_as_dropdown",
5626 className: "font-medium cursor-pointer inline-flex items-center",
5627 children: [
5628 __("Show available dates as a dropdown", "yatra"),
5629 /* @__PURE__ */ jsxRuntimeExports.jsx(
5630 ProBadge,
5631 {
5632 isProActive: !!((_i = window.yatraAdmin) == null ? void 0 : _i.isPro)
5633 }
5634 )
5635 ]
5636 }
5637 ),
5638 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5639 "Replace the calendar date picker with a dropdown listing every available departure date on the single-trip sidebar and the mobile sticky bar. Best for trips with a small set of fixed departures.",
5640 "yatra"
5641 ) })
5642 ] })
5643 ] })
5644 ] }),
5645 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Booking Expiry & Reminders", "yatra") }),
5646 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
5647 /* @__PURE__ */ jsxRuntimeExports.jsx(
5648 FormField,
5649 {
5650 id: "booking_expiry_hours",
5651 label: __("Booking Expiry Hours", "yatra"),
5652 description: __(
5653 "Hours before unpaid bookings expire and are cancelled",
5654 "yatra"
5655 ),
5656 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5657 Input,
5658 {
5659 id: "booking_expiry_hours",
5660 type: "number",
5661 value: formData.booking_expiry_hours,
5662 name: "booking_expiry_hours",
5663 onChange: handleFieldChange,
5664 min: "1"
5665 }
5666 )
5667 }
5668 ),
5669 /* @__PURE__ */ jsxRuntimeExports.jsx(
5670 FormField,
5671 {
5672 id: "booking_reminder_days",
5673 label: __("Booking Reminder Days", "yatra"),
5674 description: __(
5675 "Send reminder emails this many days before departure",
5676 "yatra"
5677 ),
5678 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5679 Input,
5680 {
5681 id: "booking_reminder_days",
5682 type: "number",
5683 value: formData.booking_reminder_days,
5684 name: "booking_reminder_days",
5685 onChange: handleFieldChange,
5686 min: "0"
5687 }
5688 )
5689 }
5690 )
5691 ] })
5692 ] });
5693 case "pricing": {
5694 const adEnabled = !!((_j = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _j.advancedDiscountEnabled);
5695 const dpEnabled = !!((_k = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _k.dynamicPricingEnabled);
5696 const bothActive = adEnabled && dpEnabled;
5697 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
5698 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __(
5699 "Controls what happens when both a Discount (coupon or group discount) and a Dynamic Pricing rule could apply to the same booking. The control only takes effect when both the Advanced Discount and Dynamic Pricing modules are turned on.",
5700 "yatra"
5701 ) }),
5702 bothActive ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-800 dark:bg-green-900/20 dark:text-green-200", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [
5703 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mt-0.5 h-4 w-4 flex-shrink-0" }),
5704 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5705 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Active", "yatra") }),
5706 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0.5", children: __(
5707 "Advanced Discount and Dynamic Pricing are both enabled. Your stacking choice below is being applied to every new booking calculation.",
5708 "yatra"
5709 ) })
5710 ] })
5711 ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-200", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [
5712 /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "mt-0.5 h-4 w-4 flex-shrink-0" }),
5713 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5714 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Not active yet", "yatra") }),
5715 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0.5", children: __(
5716 "This setting only applies when BOTH modules below are enabled. Without both, bookings calculate exactly as they do today (no stacking control).",
5717 "yatra"
5718 ) }),
5719 /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "mt-2 space-y-1", children: [
5720 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex items-center gap-1.5", children: [
5721 adEnabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }),
5722 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
5723 __("Advanced Discount module", "yatra"),
5724 " ",
5725 adEnabled ? __("(enabled)", "yatra") : __("(not enabled)", "yatra")
5726 ] })
5727 ] }),
5728 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex items-center gap-1.5", children: [
5729 dpEnabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }),
5730 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
5731 __("Dynamic Pricing module", "yatra"),
5732 " ",
5733 dpEnabled ? __("(enabled)", "yatra") : __("(not enabled)", "yatra")
5734 ] })
5735 ] })
5736 ] }),
5737 /* @__PURE__ */ jsxRuntimeExports.jsxs(
5738 "button",
5739 {
5740 type: "button",
5741 onClick: () => navigateMenu("modules"),
5742 className: "mt-2 inline-flex items-center gap-1 text-amber-900 underline hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-300",
5743 children: [
5744 __("Open Modules", "yatra"),
5745 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "h-3 w-3" })
5746 ]
5747 }
5748 )
5749 ] })
5750 ] }) }),
5751 /* @__PURE__ */ jsxRuntimeExports.jsx(
5752 FormField,
5753 {
5754 id: "discount_stacking_mode",
5755 label: __("Discount Stacking", "yatra"),
5756 description: __(
5757 "Pick how Discounts and Dynamic Pricing combine on the same booking.",
5758 "yatra"
5759 ),
5760 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
5761 Select,
5762 {
5763 id: "discount_stacking_mode",
5764 name: "discount_stacking_mode",
5765 value: formData.discount_stacking_mode ?? "both",
5766 onChange: handleFieldChange,
5767 disabled: !bothActive,
5768 children: [
5769 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "both", children: __(
5770 "Both apply (legacy) — Dynamic Pricing and Discount stack",
5771 "yatra"
5772 ) }),
5773 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "best_for_customer", children: __(
5774 "Best for the customer — pick whichever single mechanism gives the larger reduction",
5775 "yatra"
5776 ) }),
5777 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "discount_only", children: __(
5778 "Discount only — if a coupon or group discount applies, ignore Dynamic Pricing",
5779 "yatra"
5780 ) }),
5781 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "dynamic_pricing_only", children: __(
5782 "Dynamic Pricing only — if a Dynamic Pricing rule fires, ignore the discount",
5783 "yatra"
5784 ) })
5785 ]
5786 }
5787 )
5788 }
5789 ),
5790 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-md border border-blue-200 bg-blue-50 p-3 text-xs text-blue-800 dark:border-blue-800 dark:bg-blue-900/20 dark:text-blue-200", children: [
5791 __("What each mode does:", "yatra"),
5792 /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "mt-2 ml-4 list-disc space-y-1", children: [
5793 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
5794 /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Both apply", "yatra") }),
5795 " — ",
5796 __(
5797 "default and matches the original behavior. A coupon stacks on top of the Dynamic Pricing-adjusted price.",
5798 "yatra"
5799 )
5800 ] }),
5801 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
5802 /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Best for the customer", "yatra") }),
5803 " — ",
5804 __(
5805 "calculates both scenarios and picks the cheaper one for the customer. Never combines.",
5806 "yatra"
5807 )
5808 ] }),
5809 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
5810 /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Discount only", "yatra") }),
5811 " — ",
5812 __(
5813 "when a discount is valid, Dynamic Pricing is skipped for that booking.",
5814 "yatra"
5815 )
5816 ] }),
5817 /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
5818 /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Dynamic Pricing only", "yatra") }),
5819 " — ",
5820 __(
5821 "when a Dynamic Pricing rule reduced the price, discount codes and group discounts are ignored for that booking.",
5822 "yatra"
5823 )
5824 ] })
5825 ] })
5826 ] })
5827 ] });
5828 }
5829 case "customer":
5830 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
5831 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5832 /* @__PURE__ */ jsxRuntimeExports.jsx(
5833 "input",
5834 {
5835 type: "checkbox",
5836 id: "customer_registration",
5837 checked: formData.customer_registration,
5838 name: "customer_registration",
5839 onChange: handleFieldChange,
5840 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5841 }
5842 ),
5843 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5844 /* @__PURE__ */ jsxRuntimeExports.jsx(
5845 Label,
5846 {
5847 htmlFor: "customer_registration",
5848 className: "font-medium cursor-pointer",
5849 children: __("Enable Customer Registration", "yatra")
5850 }
5851 ),
5852 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5853 "Allow customers to create accounts on your website",
5854 "yatra"
5855 ) })
5856 ] })
5857 ] }),
5858 /* @__PURE__ */ jsxRuntimeExports.jsx(
5859 FormField,
5860 {
5861 id: "customer_account_page",
5862 label: __("Customer Account Page", "yatra"),
5863 description: __(
5864 "URL path segment for the account area (e.g. my-account → /my-account/dashboard). Must match your frontend routes.",
5865 "yatra"
5866 ),
5867 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
5868 /* @__PURE__ */ jsxRuntimeExports.jsx(
5869 Input,
5870 {
5871 id: "customer_account_page",
5872 value: formData.customer_account_page,
5873 name: "customer_account_page",
5874 onChange: handleFieldChange,
5875 placeholder: "/my-account",
5876 className: "flex-1"
5877 }
5878 ),
5879 formData.customer_account_page && (() => {
5880 var _a3;
5881 const siteUrl = ((_a3 = window.yatraAdmin) == null ? void 0 : _a3.siteUrl) || "";
5882 const accountUrl = buildYatraAccountViewUrl(
5883 siteUrl,
5884 formData.customer_account_page
5885 );
5886 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
5887 "a",
5888 {
5889 href: accountUrl,
5890 target: "_blank",
5891 rel: "noopener noreferrer",
5892 className: "px-4 py-2 text-sm font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 whitespace-nowrap border border-blue-300 dark:border-blue-600 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",
5893 children: [
5894 __("View Page", "yatra"),
5895 " →"
5896 ]
5897 }
5898 );
5899 })()
5900 ] })
5901 }
5902 ),
5903 ((_l = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _l.isPro) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md border border-gray-200 dark:border-gray-700", children: [
5904 /* @__PURE__ */ jsxRuntimeExports.jsx(
5905 "input",
5906 {
5907 type: "checkbox",
5908 id: "enable_wishlist",
5909 checked: !!formData.enable_wishlist,
5910 name: "enable_wishlist",
5911 onChange: handleFieldChange,
5912 className: "w-4 h-4 mt-1 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5913 }
5914 ),
5915 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5916 /* @__PURE__ */ jsxRuntimeExports.jsx(
5917 Label,
5918 {
5919 htmlFor: "enable_wishlist",
5920 className: "font-medium cursor-pointer",
5921 children: __("Enable wishlist (saved trips)", "yatra")
5922 }
5923 ),
5924 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5925 "Shows the heart control on trip cards and single trips, and the Saved Trips area in the customer account. Requires Yatra Pro.",
5926 "yatra"
5927 ) })
5928 ] })
5929 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg border border-amber-200 dark:border-amber-900/50 bg-amber-50 dark:bg-amber-950/30 text-sm text-amber-900 dark:text-amber-100", children: __(
5930 "Wishlist / saved trips are a Yatra Pro feature. Install Yatra Pro to enable them and turn them on in Customer settings.",
5931 "yatra"
5932 ) }),
5933 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5934 /* @__PURE__ */ jsxRuntimeExports.jsx(
5935 "input",
5936 {
5937 type: "checkbox",
5938 id: "require_email_verification",
5939 checked: formData.require_email_verification,
5940 name: "require_email_verification",
5941 onChange: handleFieldChange,
5942 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5943 }
5944 ),
5945 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5946 /* @__PURE__ */ jsxRuntimeExports.jsx(
5947 Label,
5948 {
5949 htmlFor: "require_email_verification",
5950 className: "font-medium cursor-pointer",
5951 children: __("Require Email Verification", "yatra")
5952 }
5953 ),
5954 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5955 "Customers must verify their email before account activation",
5956 "yatra"
5957 ) })
5958 ] })
5959 ] })
5960 ] }) });
5961 case "review":
5962 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
5963 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __(
5964 "These options apply to trip review forms on the frontend (who may review, moderation, minimum stars, and reminder scheduling).",
5965 "yatra"
5966 ) }),
5967 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
5968 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5969 /* @__PURE__ */ jsxRuntimeExports.jsx(
5970 "input",
5971 {
5972 type: "checkbox",
5973 id: "enable_reviews",
5974 checked: formData.enable_reviews,
5975 name: "enable_reviews",
5976 onChange: handleFieldChange,
5977 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
5978 }
5979 ),
5980 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
5981 /* @__PURE__ */ jsxRuntimeExports.jsx(
5982 Label,
5983 {
5984 htmlFor: "enable_reviews",
5985 className: "font-medium cursor-pointer",
5986 children: __("Enable Reviews", "yatra")
5987 }
5988 ),
5989 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
5990 "Allow customers to leave reviews and ratings",
5991 "yatra"
5992 ) })
5993 ] })
5994 ] }),
5995 formData.enable_reviews && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
5996 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
5997 /* @__PURE__ */ jsxRuntimeExports.jsx(
5998 "input",
5999 {
6000 type: "checkbox",
6001 id: "require_booking",
6002 checked: formData.require_booking,
6003 name: "require_booking",
6004 onChange: handleFieldChange,
6005 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6006 }
6007 ),
6008 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6009 /* @__PURE__ */ jsxRuntimeExports.jsx(
6010 Label,
6011 {
6012 htmlFor: "require_booking",
6013 className: "font-medium cursor-pointer",
6014 children: __("Require Booking to Review", "yatra")
6015 }
6016 ),
6017 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6018 "Only customers who have booked can leave reviews",
6019 "yatra"
6020 ) })
6021 ] })
6022 ] }),
6023 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6024 /* @__PURE__ */ jsxRuntimeExports.jsx(
6025 "input",
6026 {
6027 type: "checkbox",
6028 id: "auto_approve_reviews",
6029 checked: formData.auto_approve_reviews,
6030 name: "auto_approve_reviews",
6031 onChange: handleFieldChange,
6032 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6033 }
6034 ),
6035 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6036 /* @__PURE__ */ jsxRuntimeExports.jsx(
6037 Label,
6038 {
6039 htmlFor: "auto_approve_reviews",
6040 className: "font-medium cursor-pointer",
6041 children: __("Auto-Approve Reviews", "yatra")
6042 }
6043 ),
6044 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6045 "Automatically publish reviews without moderation",
6046 "yatra"
6047 ) })
6048 ] })
6049 ] }),
6050 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6051 /* @__PURE__ */ jsxRuntimeExports.jsx(
6052 "input",
6053 {
6054 type: "checkbox",
6055 id: "review_moderation",
6056 checked: formData.review_moderation,
6057 name: "review_moderation",
6058 onChange: handleFieldChange,
6059 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6060 }
6061 ),
6062 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6063 /* @__PURE__ */ jsxRuntimeExports.jsx(
6064 Label,
6065 {
6066 htmlFor: "review_moderation",
6067 className: "font-medium cursor-pointer",
6068 children: __("Enable Review Moderation", "yatra")
6069 }
6070 ),
6071 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6072 "Manually approve reviews before they are published",
6073 "yatra"
6074 ) })
6075 ] })
6076 ] }),
6077 /* @__PURE__ */ jsxRuntimeExports.jsx(
6078 FormField,
6079 {
6080 id: "min_rating",
6081 label: __("Minimum Rating", "yatra"),
6082 description: __(
6083 "Lowest rating value allowed (1-5 stars)",
6084 "yatra"
6085 ),
6086 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
6087 Select,
6088 {
6089 id: "min_rating",
6090 value: formData.min_rating,
6091 name: "min_rating",
6092 onChange: handleFieldChange,
6093 children: [
6094 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "1", children: [
6095 "1 ",
6096 __("Star", "yatra")
6097 ] }),
6098 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "2", children: [
6099 "2 ",
6100 __("Stars", "yatra")
6101 ] }),
6102 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "3", children: [
6103 "3 ",
6104 __("Stars", "yatra")
6105 ] }),
6106 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "4", children: [
6107 "4 ",
6108 __("Stars", "yatra")
6109 ] }),
6110 /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "5", children: [
6111 "5 ",
6112 __("Stars", "yatra")
6113 ] })
6114 ]
6115 }
6116 )
6117 }
6118 ),
6119 /* @__PURE__ */ jsxRuntimeExports.jsx(
6120 FormField,
6121 {
6122 id: "review_reminder_days",
6123 label: __("Review Reminder Days", "yatra"),
6124 description: __(
6125 "Send the review request this many days after the trip ends. Set to 0 to never send one.",
6126 "yatra"
6127 ),
6128 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6129 Input,
6130 {
6131 id: "review_reminder_days",
6132 type: "number",
6133 value: formData.review_reminder_days,
6134 name: "review_reminder_days",
6135 onChange: handleFieldChange,
6136 min: "0"
6137 }
6138 )
6139 }
6140 ),
6141 /* @__PURE__ */ jsxRuntimeExports.jsx(
6142 FormField,
6143 {
6144 id: "review_reminder_max_age_days",
6145 label: __("Don't Ask About Trips Older Than", "yatra"),
6146 description: __(
6147 "Days. A trip that ended longer ago than this is never asked about — so marking a backlog of old bookings complete does not email those customers.",
6148 "yatra"
6149 ),
6150 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6151 Input,
6152 {
6153 id: "review_reminder_max_age_days",
6154 type: "number",
6155 value: formData.review_reminder_max_age_days,
6156 name: "review_reminder_max_age_days",
6157 onChange: handleFieldChange,
6158 min: "0"
6159 }
6160 )
6161 }
6162 )
6163 ] })
6164 ] })
6165 ] });
6166 case "tax":
6167 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
6168 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6169 /* @__PURE__ */ jsxRuntimeExports.jsx(
6170 "input",
6171 {
6172 type: "checkbox",
6173 id: "enable_tax",
6174 checked: formData.enable_tax,
6175 name: "enable_tax",
6176 onChange: handleFieldChange,
6177 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6178 }
6179 ),
6180 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6181 /* @__PURE__ */ jsxRuntimeExports.jsx(
6182 Label,
6183 {
6184 htmlFor: "enable_tax",
6185 className: "font-medium cursor-pointer",
6186 children: __("Enable Tax", "yatra")
6187 }
6188 ),
6189 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Add tax to booking prices", "yatra") })
6190 ] })
6191 ] }),
6192 formData.enable_tax && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6193 /* @__PURE__ */ jsxRuntimeExports.jsxs(
6194 FormField,
6195 {
6196 id: "multiple_taxes",
6197 label: __("Taxes", "yatra"),
6198 description: __(
6199 "Configure taxes to apply to bookings",
6200 "yatra"
6201 ),
6202 children: [
6203 /* @__PURE__ */ jsxRuntimeExports.jsx(
6204 MultipleTaxesEditor,
6205 {
6206 taxes: formData.multiple_taxes || [],
6207 onChange: (taxes) => {
6208 setFormData(
6209 (prev) => prev ? { ...prev, multiple_taxes: taxes } : prev
6210 );
6211 }
6212 }
6213 ),
6214 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-800 dark:border-gray-700 mt-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
6215 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6216 Input,
6217 {
6218 value: newTaxName,
6219 onChange: (e) => setNewTaxName(e.target.value),
6220 placeholder: __(
6221 "Tax name (e.g., VAT, GST)",
6222 "yatra"
6223 ),
6224 className: "w-full"
6225 }
6226 ) }),
6227 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
6228 /* @__PURE__ */ jsxRuntimeExports.jsx(
6229 Input,
6230 {
6231 type: "number",
6232 value: newTaxRate,
6233 onChange: (e) => setNewTaxRate(e.target.value),
6234 min: "0",
6235 max: "100",
6236 step: "0.01",
6237 placeholder: __("Rate", "yatra"),
6238 className: "w-full"
6239 }
6240 ),
6241 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" })
6242 ] }) }),
6243 /* @__PURE__ */ jsxRuntimeExports.jsxs(
6244 Button,
6245 {
6246 type: "button",
6247 onClick: () => {
6248 if (newTaxName && newTaxRate && parseFloat(newTaxRate) >= 0 && parseFloat(newTaxRate) <= 100) {
6249 setFormData((prev) => {
6250 const currentTaxes = (prev == null ? void 0 : prev.multiple_taxes) || [];
6251 const newTax = {
6252 name: newTaxName,
6253 rate: parseFloat(newTaxRate)
6254 };
6255 const updatedTaxes = [...currentTaxes, newTax];
6256 return prev ? { ...prev, multiple_taxes: updatedTaxes } : prev;
6257 });
6258 setNewTaxName("");
6259 setNewTaxRate("");
6260 }
6261 },
6262 disabled: !newTaxName || !newTaxRate || parseFloat(newTaxRate) < 0 || parseFloat(newTaxRate) > 100,
6263 className: "px-4 py-2 bg-green-600 hover:bg-green-700 text-white",
6264 children: [
6265 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4 mr-2" }),
6266 __("Add new Tax", "yatra")
6267 ]
6268 }
6269 )
6270 ] }) }),
6271 (formData.multiple_taxes || []).length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800 mt-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-medium text-blue-800 dark:text-blue-200", children: [
6272 __("Total Tax Rate:", "yatra"),
6273 " ",
6274 (formData.multiple_taxes || []).reduce((sum, tax) => sum + tax.rate, 0).toFixed(2),
6275 "%"
6276 ] }) })
6277 ]
6278 }
6279 ),
6280 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6281 /* @__PURE__ */ jsxRuntimeExports.jsx(
6282 "input",
6283 {
6284 type: "checkbox",
6285 id: "tax_inclusive",
6286 checked: formData.tax_inclusive,
6287 name: "tax_inclusive",
6288 onChange: handleFieldChange,
6289 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6290 }
6291 ),
6292 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6293 /* @__PURE__ */ jsxRuntimeExports.jsx(
6294 Label,
6295 {
6296 htmlFor: "tax_inclusive",
6297 className: "font-medium cursor-pointer",
6298 children: __("Tax Inclusive Pricing", "yatra")
6299 }
6300 ),
6301 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Tax is included in displayed prices", "yatra") })
6302 ] })
6303 ] }),
6304 /* @__PURE__ */ jsxRuntimeExports.jsx(
6305 FormField,
6306 {
6307 id: "vat_number",
6308 label: __("VAT Number", "yatra"),
6309 description: __(
6310 "Your company VAT or tax identification number",
6311 "yatra"
6312 ),
6313 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6314 Input,
6315 {
6316 id: "vat_number",
6317 value: formData.vat_number,
6318 name: "vat_number",
6319 onChange: handleFieldChange,
6320 placeholder: __("Enter VAT number", "yatra")
6321 }
6322 )
6323 }
6324 )
6325 ] })
6326 ] }) });
6327 case "currency":
6328 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
6329 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Currency Settings", "yatra") }),
6330 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [
6331 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
6332 /* @__PURE__ */ jsxRuntimeExports.jsx(
6333 FormField,
6334 {
6335 id: "currency",
6336 label: __("Default Currency", "yatra"),
6337 description: __(
6338 "Primary currency for all transactions",
6339 "yatra"
6340 ),
6341 required: true,
6342 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6343 SearchableSelect,
6344 {
6345 value: formData.currency,
6346 onChange: (val) => setFormData(
6347 (prev) => prev ? { ...prev, currency: val } : prev
6348 ),
6349 options: getCurrencyOptions(),
6350 placeholder: __("Select currency...", "yatra"),
6351 searchPlaceholder: __("Search currencies...", "yatra"),
6352 showValueId: false
6353 }
6354 )
6355 }
6356 ),
6357 /* @__PURE__ */ jsxRuntimeExports.jsx(
6358 FormField,
6359 {
6360 id: "currency_position",
6361 label: __("Currency Position", "yatra"),
6362 description: __(
6363 "Where to display currency symbol relative to amount",
6364 "yatra"
6365 ),
6366 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
6367 Select,
6368 {
6369 id: "currency_position",
6370 value: formData.currency_position,
6371 name: "currency_position",
6372 onChange: handleFieldChange,
6373 children: [
6374 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "left", children: "$100 (Left)" }),
6375 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "right", children: "100$ (Right)" }),
6376 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "left_space", children: "$ 100 (Left with Space)" }),
6377 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "right_space", children: "100 $ (Right with Space)" })
6378 ]
6379 }
6380 )
6381 }
6382 ),
6383 /* @__PURE__ */ jsxRuntimeExports.jsx(
6384 FormField,
6385 {
6386 id: "thousand_separator",
6387 label: __("Thousand Separator", "yatra"),
6388 description: __(
6389 "Character used to separate thousands (e.g., comma for 1,000)",
6390 "yatra"
6391 ),
6392 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6393 Input,
6394 {
6395 id: "thousand_separator",
6396 value: formData.thousand_separator,
6397 name: "thousand_separator",
6398 onChange: handleFieldChange,
6399 maxLength: 1,
6400 placeholder: ","
6401 }
6402 )
6403 }
6404 )
6405 ] }),
6406 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
6407 /* @__PURE__ */ jsxRuntimeExports.jsx(
6408 FormField,
6409 {
6410 id: "currency_decimals",
6411 label: __("Decimal Places", "yatra"),
6412 description: __(
6413 "Number of decimal places to show in prices",
6414 "yatra"
6415 ),
6416 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6417 Input,
6418 {
6419 id: "currency_decimals",
6420 type: "number",
6421 value: formData.currency_decimals,
6422 name: "currency_decimals",
6423 onChange: handleFieldChange,
6424 min: "0",
6425 max: "4"
6426 }
6427 )
6428 }
6429 ),
6430 /* @__PURE__ */ jsxRuntimeExports.jsx(
6431 FormField,
6432 {
6433 id: "decimal_separator",
6434 label: __("Decimal Separator", "yatra"),
6435 description: __(
6436 "Character used to separate decimal part (e.g., period for 99.99)",
6437 "yatra"
6438 ),
6439 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6440 Input,
6441 {
6442 id: "decimal_separator",
6443 value: formData.decimal_separator,
6444 name: "decimal_separator",
6445 onChange: handleFieldChange,
6446 maxLength: 1,
6447 placeholder: "."
6448 }
6449 )
6450 }
6451 )
6452 ] })
6453 ] })
6454 ] });
6455 case "integration":
6456 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
6457 window.yatraAdmin && window.yatraAdmin.showGoogleCalendarSettingsUI && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6458 /* @__PURE__ */ jsxRuntimeExports.jsx(
6459 SectionDivider,
6460 {
6461 title: __("Google Calendar Integration", "yatra")
6462 }
6463 ),
6464 /* @__PURE__ */ jsxRuntimeExports.jsx(
6465 GoogleCalendarIntegrationSection,
6466 {
6467 formData,
6468 setFormData
6469 }
6470 )
6471 ] }),
6472 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Mailchimp Integration", "yatra") }),
6473 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
6474 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
6475 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [
6476 /* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-5 h-5 text-yellow-500" }),
6477 __("Mailchimp", "yatra"),
6478 /* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_m = window.yatraAdmin) == null ? void 0 : _m.isPro })
6479 ] }),
6480 ((_p = (_o = (_n = window.yatraAdmin) == null ? void 0 : _n.mailchimp) == null ? void 0 : _o.connectionStatus) == null ? void 0 : _p.connected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [
6481 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
6482 __("Connected", "yatra")
6483 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [
6484 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
6485 __("Not Connected", "yatra")
6486 ] })
6487 ] }),
6488 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [
6489 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __(
6490 "Automatically sync customers to Mailchimp lists when they book. Add tags based on trips booked and build targeted email campaigns.",
6491 "yatra"
6492 ) }),
6493 /* @__PURE__ */ jsxRuntimeExports.jsx(
6494 ProFeature,
6495 {
6496 title: __("Mailchimp", "yatra"),
6497 description: __("automatically sync your customers", "yatra"),
6498 moduleName: "Mailchimp",
6499 pricingUrl: "https://wpyatra.com/pricing?module=mailchimp",
6500 isProActive: (_q = window.yatraAdmin) == null ? void 0 : _q.isPro,
6501 isModuleEnabled: (_r = window.yatraAdmin) == null ? void 0 : _r.showMailchimpSettingsUI,
6502 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
6503 /* @__PURE__ */ jsxRuntimeExports.jsxs(
6504 FormField,
6505 {
6506 id: "mailchimp_api_key",
6507 label: __("API Key", "yatra"),
6508 description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6509 __("Get your API key from", "yatra"),
6510 " ",
6511 /* @__PURE__ */ jsxRuntimeExports.jsx(
6512 "a",
6513 {
6514 href: "https://admin.mailchimp.com/account/api/",
6515 target: "_blank",
6516 rel: "noopener noreferrer",
6517 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline",
6518 children: __("Mailchimp Account Settings", "yatra")
6519 }
6520 )
6521 ] }),
6522 children: [
6523 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
6524 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex-1", children: [
6525 /* @__PURE__ */ jsxRuntimeExports.jsx(
6526 Input,
6527 {
6528 id: "mailchimp_api_key",
6529 type: showApiKey ? "text" : "password",
6530 value: formData.mailchimp_api_key || "",
6531 name: "mailchimp_api_key",
6532 onChange: handleFieldChange,
6533 placeholder: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us1",
6534 className: "pr-10"
6535 }
6536 ),
6537 /* @__PURE__ */ jsxRuntimeExports.jsx(
6538 "button",
6539 {
6540 type: "button",
6541 onClick: () => setShowApiKey(!showApiKey),
6542 className: "absolute inset-y-0 right-0 pr-3 flex items-center",
6543 tabIndex: -1,
6544 children: showApiKey ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" })
6545 }
6546 )
6547 ] }),
6548 /* @__PURE__ */ jsxRuntimeExports.jsx(
6549 Button,
6550 {
6551 type: "button",
6552 variant: "outline",
6553 size: "sm",
6554 onClick: validateMailchimpApiKey,
6555 disabled: !formData.mailchimp_api_key || validatingApiKey,
6556 className: "whitespace-nowrap",
6557 children: validatingApiKey ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6558 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 animate-spin mr-2" }),
6559 __("Validating...", "yatra")
6560 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6561 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }),
6562 __("Validate", "yatra")
6563 ] })
6564 }
6565 )
6566 ] }),
6567 formData.mailchimp_api_key && /* @__PURE__ */ jsxRuntimeExports.jsx(
6568 "div",
6569 {
6570 className: `mt-2 text-sm ${((_u = (_t = (_s = window.yatraAdmin) == null ? void 0 : _s.mailchimp) == null ? void 0 : _t.connectionStatus) == null ? void 0 : _u.connected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`,
6571 children: ((_x = (_w = (_v = window.yatraAdmin) == null ? void 0 : _v.mailchimp) == null ? void 0 : _w.connectionStatus) == null ? void 0 : _x.connected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6572 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }),
6573 __("Connected successfully!", "yatra")
6574 ] }) : ((_A = (_z = (_y = window.yatraAdmin) == null ? void 0 : _y.mailchimp) == null ? void 0 : _z.connectionStatus) == null ? void 0 : _A.error) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6575 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }),
6576 (_D = (_C = (_B = window.yatraAdmin) == null ? void 0 : _B.mailchimp) == null ? void 0 : _C.connectionStatus) == null ? void 0 : _D.error
6577 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6578 /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }),
6579 __(
6580 "API key entered. Click 'Validate' to test connection.",
6581 "yatra"
6582 )
6583 ] })
6584 }
6585 )
6586 ]
6587 }
6588 ),
6589 /* @__PURE__ */ jsxRuntimeExports.jsx(
6590 FormField,
6591 {
6592 id: "mailchimp_list_id",
6593 label: __("Audience/List", "yatra"),
6594 description: __(
6595 "Select the Mailchimp audience to sync subscribers to.",
6596 "yatra"
6597 ),
6598 children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
6599 Select,
6600 {
6601 id: "mailchimp_list_id",
6602 value: formData.mailchimp_list_id || "",
6603 name: "mailchimp_list_id",
6604 onChange: handleFieldChange,
6605 disabled: !((_G = (_F = (_E = window.yatraAdmin) == null ? void 0 : _E.mailchimp) == null ? void 0 : _F.connectionStatus) == null ? void 0 : _G.connected),
6606 children: [
6607 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: !((_J = (_I = (_H = window.yatraAdmin) == null ? void 0 : _H.mailchimp) == null ? void 0 : _I.connectionStatus) == null ? void 0 : _J.connected) ? __("Please validate API key first", "yatra") : __("Select an audience", "yatra") }),
6608 (_M = (_L = (_K = window.yatraAdmin) == null ? void 0 : _K.mailchimp) == null ? void 0 : _L.availableLists) == null ? void 0 : _M.map(
6609 (list) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: list.id, children: list.name }, list.id)
6610 )
6611 ]
6612 }
6613 )
6614 }
6615 ),
6616 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6617 /* @__PURE__ */ jsxRuntimeExports.jsx(
6618 "input",
6619 {
6620 type: "checkbox",
6621 id: "mailchimp_sync_on_booking",
6622 checked: formData.mailchimp_sync_on_booking ?? true,
6623 name: "mailchimp_sync_on_booking",
6624 onChange: handleFieldChange,
6625 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6626 }
6627 ),
6628 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6629 /* @__PURE__ */ jsxRuntimeExports.jsx(
6630 Label,
6631 {
6632 htmlFor: "mailchimp_sync_on_booking",
6633 className: "font-medium cursor-pointer",
6634 children: __("Sync on Booking", "yatra")
6635 }
6636 ),
6637 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6638 "Automatically add customers to Mailchimp when they make a booking",
6639 "yatra"
6640 ) })
6641 ] })
6642 ] }),
6643 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6644 /* @__PURE__ */ jsxRuntimeExports.jsx(
6645 "input",
6646 {
6647 type: "checkbox",
6648 id: "mailchimp_double_optin",
6649 checked: formData.mailchimp_double_optin ?? false,
6650 name: "mailchimp_double_optin",
6651 onChange: handleFieldChange,
6652 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6653 }
6654 ),
6655 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6656 /* @__PURE__ */ jsxRuntimeExports.jsx(
6657 Label,
6658 {
6659 htmlFor: "mailchimp_double_optin",
6660 className: "font-medium cursor-pointer",
6661 children: __("Double Opt-in", "yatra")
6662 }
6663 ),
6664 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6665 "Require email confirmation before adding to list (recommended for GDPR)",
6666 "yatra"
6667 ) })
6668 ] })
6669 ] }),
6670 formData.mailchimp_api_key && formData.mailchimp_list_id && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
6671 /* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-3 flex items-center gap-2", children: [
6672 /* @__PURE__ */ jsxRuntimeExports.jsx(ClipboardList, { className: "w-4 h-4" }),
6673 __("Field Mapping", "yatra")
6674 ] }),
6675 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
6676 "Map Yatra customer fields to Mailchimp merge fields. This controls what data is synced when a customer is added to your list.",
6677 "yatra"
6678 ) }),
6679 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: ((_P = (_O = (_N = window.yatraAdmin) == null ? void 0 : _N.mailchimp) == null ? void 0 : _O.mergeFields) == null ? void 0 : _P.length) > 0 ? (_R = (_Q = window.yatraAdmin) == null ? void 0 : _Q.mailchimp) == null ? void 0 : _R.mergeFields.map(
6680 (field) => {
6681 var _a3, _b3;
6682 const currentMapping = formData.mailchimp_field_mapping || {};
6683 const yatraFields = ((_b3 = (_a3 = window.yatraAdmin) == null ? void 0 : _a3.mailchimp) == null ? void 0 : _b3.yatraFields) || {};
6684 const yatraFieldOptions = yatraFields[field.type] || yatraFields["text"] || [];
6685 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
6686 "div",
6687 {
6688 className: "grid grid-cols-2 gap-3 items-center",
6689 children: [
6690 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 px-3 py-2 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
6691 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: field.name }),
6692 field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500", children: "*" }),
6693 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-400", children: [
6694 "(",
6695 field.tag,
6696 ")"
6697 ] })
6698 ] }) }),
6699 /* @__PURE__ */ jsxRuntimeExports.jsxs(
6700 Select,
6701 {
6702 value: currentMapping[field.tag] || "",
6703 onChange: (e) => {
6704 const newMapping = {
6705 ...formData.mailchimp_field_mapping || {}
6706 };
6707 if (e.target.value) {
6708 newMapping[field.tag] = e.target.value;
6709 } else {
6710 delete newMapping[field.tag];
6711 }
6712 setFormData((prev) => ({
6713 ...prev,
6714 mailchimp_field_mapping: newMapping
6715 }));
6716 },
6717 children: [
6718 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: __("Do not sync", "yatra") }),
6719 Object.entries(yatraFieldOptions).map(
6720 ([value, label]) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value, children: String(label) }, value)
6721 )
6722 ]
6723 }
6724 )
6725 ]
6726 },
6727 field.tag
6728 );
6729 }
6730 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-4 text-sm text-gray-500 dark:text-gray-400", children: __(
6731 "No merge fields available. Please select a list first.",
6732 "yatra"
6733 ) }) }),
6734 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
6735 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6736 /* @__PURE__ */ jsxRuntimeExports.jsx(
6737 "input",
6738 {
6739 type: "checkbox",
6740 id: "mailchimp_add_tags",
6741 checked: formData.mailchimp_add_tags ?? true,
6742 onChange: (e) => setFormData((prev) => ({
6743 ...prev,
6744 mailchimp_add_tags: e.target.checked
6745 })),
6746 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6747 }
6748 ),
6749 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
6750 /* @__PURE__ */ jsxRuntimeExports.jsx(
6751 Label,
6752 {
6753 htmlFor: "mailchimp_add_tags",
6754 className: "font-medium cursor-pointer",
6755 children: __("Add Trip Tags", "yatra")
6756 }
6757 ),
6758 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
6759 "Automatically tag subscribers with the trip name they booked",
6760 "yatra"
6761 ) })
6762 ] })
6763 ] }),
6764 /* @__PURE__ */ jsxRuntimeExports.jsx(
6765 FormField,
6766 {
6767 id: "mailchimp_default_tags",
6768 label: __("Default Tags", "yatra"),
6769 description: __(
6770 'Comma-separated tags to add to all synced subscribers (e.g., "yatra, booking")',
6771 "yatra"
6772 ),
6773 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6774 Input,
6775 {
6776 id: "mailchimp_default_tags",
6777 value: formData.mailchimp_default_tags || "",
6778 onChange: (e) => setFormData((prev) => ({
6779 ...prev,
6780 mailchimp_default_tags: e.target.value
6781 })),
6782 placeholder: "yatra, booking"
6783 }
6784 )
6785 }
6786 )
6787 ] })
6788 ] })
6789 ] })
6790 }
6791 )
6792 ] })
6793 ] }),
6794 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Facebook Pixel", "yatra") }),
6795 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
6796 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
6797 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [
6798 /* @__PURE__ */ jsxRuntimeExports.jsx(
6799 "svg",
6800 {
6801 className: "w-5 h-5 text-blue-600",
6802 viewBox: "0 0 24 24",
6803 fill: "currentColor",
6804 children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" })
6805 }
6806 ),
6807 __("Facebook Pixel", "yatra"),
6808 /* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_S = window.yatraAdmin) == null ? void 0 : _S.isPro })
6809 ] }),
6810 ((_V = (_U = (_T = window.yatraAdmin) == null ? void 0 : _T.facebookPixel) == null ? void 0 : _U.connectionStatus) == null ? void 0 : _V.pixelConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [
6811 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
6812 __("Connected", "yatra")
6813 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [
6814 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
6815 __("Not Connected", "yatra")
6816 ] })
6817 ] }),
6818 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [
6819 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __(
6820 "Track booking conversions with Facebook Pixel. Retarget visitors who viewed trips and optimize ad campaigns with accurate conversion data.",
6821 "yatra"
6822 ) }),
6823 /* @__PURE__ */ jsxRuntimeExports.jsx(
6824 ProFeature,
6825 {
6826 title: __("Facebook Pixel", "yatra"),
6827 description: __(
6828 "access advanced conversion tracking features",
6829 "yatra"
6830 ),
6831 moduleName: "Facebook Pixel",
6832 pricingUrl: "https://wpyatra.com/pricing?module=facebook-pixel",
6833 isProActive: (_W = window.yatraAdmin) == null ? void 0 : _W.isPro,
6834 isModuleEnabled: (_X = window.yatraAdmin) == null ? void 0 : _X.showFacebookPixelSettingsUI,
6835 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
6836 /* @__PURE__ */ jsxRuntimeExports.jsxs(
6837 FormField,
6838 {
6839 id: "facebook_pixel_id",
6840 label: __("Pixel ID", "yatra"),
6841 description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
6842 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __(
6843 "Your Facebook Pixel ID (e.g., 123456789012345).",
6844 "yatra"
6845 ) }),
6846 /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [
6847 /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer text-blue-600 hover:text-blue-500 dark:text-blue-400 font-medium", children: __("How to get your Pixel ID:", "yatra") }),
6848 /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [
6849 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6850 "Go to Facebook Business Manager: business.facebook.com",
6851 "yatra"
6852 ) }),
6853 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Select your Business Account", "yatra") }),
6854 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6855 "Click 'All tools' and select 'Pixels'",
6856 "yatra"
6857 ) }),
6858 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6859 "Click 'Add Pixel' if you don't have one",
6860 "yatra"
6861 ) }),
6862 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6863 "Enter a Pixel name and enter your website URL",
6864 "yatra"
6865 ) }),
6866 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Create Pixel'", "yatra") }),
6867 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6868 "Your Pixel ID will be displayed (e.g., 123456789012345)",
6869 "yatra"
6870 ) }),
6871 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
6872 "Copy this Pixel ID and paste it in the field above",
6873 "yatra"
6874 ) })
6875 ] })
6876 ] }),
6877 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6878 "a",
6879 {
6880 href: "https://business.facebook.com/events_manager",
6881 target: "_blank",
6882 rel: "noopener noreferrer",
6883 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm",
6884 children: __("Open Facebook Events Manager →", "yatra")
6885 }
6886 ) })
6887 ] }),
6888 children: [
6889 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
6890 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6891 Input,
6892 {
6893 id: "facebook_pixel_id",
6894 value: formData.facebook_pixel_id || "",
6895 name: "facebook_pixel_id",
6896 onChange: handleFieldChange,
6897 placeholder: "123456789012345"
6898 }
6899 ) }),
6900 /* @__PURE__ */ jsxRuntimeExports.jsx(
6901 Button,
6902 {
6903 type: "button",
6904 onClick: validateFacebookPixel,
6905 disabled: !formData.facebook_pixel_id || validatingPixel,
6906 variant: "outline",
6907 size: "sm",
6908 className: "whitespace-nowrap",
6909 children: validatingPixel ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6910 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
6911 __("Validating...", "yatra")
6912 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6913 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }),
6914 __("Validate", "yatra")
6915 ] })
6916 }
6917 )
6918 ] }),
6919 formData.facebook_pixel_id && /* @__PURE__ */ jsxRuntimeExports.jsx(
6920 "div",
6921 {
6922 className: `mt-2 text-sm ${((__2 = (_Z = (_Y = window.yatraAdmin) == null ? void 0 : _Y.facebookPixel) == null ? void 0 : _Z.connectionStatus) == null ? void 0 : __2.pixelConnected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`,
6923 children: ((_ba = (_aa = (_$ = window.yatraAdmin) == null ? void 0 : _$.facebookPixel) == null ? void 0 : _aa.connectionStatus) == null ? void 0 : _ba.pixelConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6924 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }),
6925 __("Pixel ID is valid!", "yatra")
6926 ] }) : ((_ea = (_da = (_ca = window.yatraAdmin) == null ? void 0 : _ca.facebookPixel) == null ? void 0 : _da.connectionStatus) == null ? void 0 : _ea.pixelError) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6927 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }),
6928 (_ha = (_ga = (_fa = window.yatraAdmin) == null ? void 0 : _fa.facebookPixel) == null ? void 0 : _ga.connectionStatus) == null ? void 0 : _ha.pixelError
6929 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6930 /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }),
6931 __(
6932 "Click 'Validate' to test Pixel ID.",
6933 "yatra"
6934 )
6935 ] })
6936 }
6937 )
6938 ]
6939 }
6940 ),
6941 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [
6942 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6943 /* @__PURE__ */ jsxRuntimeExports.jsx(
6944 "input",
6945 {
6946 type: "checkbox",
6947 id: "fb_track_view_content",
6948 checked: formData.fb_track_view_content ?? true,
6949 name: "fb_track_view_content",
6950 onChange: handleFieldChange,
6951 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6952 }
6953 ),
6954 /* @__PURE__ */ jsxRuntimeExports.jsx(
6955 Label,
6956 {
6957 htmlFor: "fb_track_view_content",
6958 className: "text-sm cursor-pointer",
6959 children: __("Track ViewContent", "yatra")
6960 }
6961 )
6962 ] }),
6963 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6964 /* @__PURE__ */ jsxRuntimeExports.jsx(
6965 "input",
6966 {
6967 type: "checkbox",
6968 id: "fb_track_initiate_checkout",
6969 checked: formData.fb_track_initiate_checkout ?? true,
6970 name: "fb_track_initiate_checkout",
6971 onChange: handleFieldChange,
6972 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6973 }
6974 ),
6975 /* @__PURE__ */ jsxRuntimeExports.jsx(
6976 Label,
6977 {
6978 htmlFor: "fb_track_initiate_checkout",
6979 className: "text-sm cursor-pointer",
6980 children: __("Track InitiateCheckout", "yatra")
6981 }
6982 )
6983 ] }),
6984 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
6985 /* @__PURE__ */ jsxRuntimeExports.jsx(
6986 "input",
6987 {
6988 type: "checkbox",
6989 id: "fb_track_purchase",
6990 checked: formData.fb_track_purchase ?? true,
6991 name: "fb_track_purchase",
6992 onChange: handleFieldChange,
6993 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
6994 }
6995 ),
6996 /* @__PURE__ */ jsxRuntimeExports.jsx(
6997 Label,
6998 {
6999 htmlFor: "fb_track_purchase",
7000 className: "text-sm cursor-pointer",
7001 children: __("Track Purchase", "yatra")
7002 }
7003 )
7004 ] }),
7005 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
7006 /* @__PURE__ */ jsxRuntimeExports.jsx(
7007 "input",
7008 {
7009 type: "checkbox",
7010 id: "fb_use_conversions_api",
7011 checked: formData.fb_use_conversions_api ?? false,
7012 name: "fb_use_conversions_api",
7013 onChange: handleFieldChange,
7014 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7015 }
7016 ),
7017 /* @__PURE__ */ jsxRuntimeExports.jsx(
7018 Label,
7019 {
7020 htmlFor: "fb_use_conversions_api",
7021 className: "text-sm cursor-pointer",
7022 children: __("Use Conversions API", "yatra")
7023 }
7024 )
7025 ] })
7026 ] }),
7027 formData.fb_use_conversions_api && /* @__PURE__ */ jsxRuntimeExports.jsx(
7028 FormField,
7029 {
7030 id: "facebook_access_token",
7031 label: __("Access Token", "yatra"),
7032 description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
7033 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __(
7034 "Required for Conversions API. Enables server-side tracking for better accuracy.",
7035 "yatra"
7036 ) }),
7037 /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [
7038 /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer text-blue-600 hover:text-blue-500 dark:text-blue-400 font-medium", children: __("How to get Access Token:", "yatra") }),
7039 /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [
7040 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7041 "Go to Facebook Business Manager: business.facebook.com",
7042 "yatra"
7043 ) }),
7044 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Select your Business Account", "yatra") }),
7045 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7046 "Click 'All tools' and select 'Events Manager'",
7047 "yatra"
7048 ) }),
7049 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7050 "Find your Pixel ID in the data sources list (it should match the Pixel ID you entered above)",
7051 "yatra"
7052 ) }),
7053 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7054 "Click on your Pixel name to open its settings",
7055 "yatra"
7056 ) }),
7057 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7058 "Click 'Settings' (gear icon ⚙️) in the top right",
7059 "yatra"
7060 ) }),
7061 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7062 "Scroll down to 'Conversions API' section",
7063 "yatra"
7064 ) }),
7065 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Generate access token'", "yatra") }),
7066 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7067 "Choose permissions: 'ads_management' and 'business_management'",
7068 "yatra"
7069 ) }),
7070 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Generate token'", "yatra") }),
7071 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7072 "Copy the generated access token",
7073 "yatra"
7074 ) }),
7075 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Paste it in the field above", "yatra") })
7076 ] }),
7077 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-800 dark:text-blue-300", children: [
7078 /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("💡 Tip:", "yatra") }),
7079 " ",
7080 __(
7081 "If you have multiple Pixels, look for the one that matches the Pixel ID you entered above. The Pixel ID is displayed next to each Pixel name in the list.",
7082 "yatra"
7083 )
7084 ] }) }),
7085 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 p-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-yellow-800 dark:text-yellow-300", children: __(
7086 "⚠️ Keep your access token secure and never share it publicly.",
7087 "yatra"
7088 ) }) })
7089 ] }),
7090 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7091 "a",
7092 {
7093 href: "https://business.facebook.com/settings/conversions-api",
7094 target: "_blank",
7095 rel: "noopener noreferrer",
7096 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm",
7097 children: __("Open Conversions API Settings →", "yatra")
7098 }
7099 ) })
7100 ] }),
7101 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
7102 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
7103 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 relative", children: [
7104 /* @__PURE__ */ jsxRuntimeExports.jsx(
7105 Input,
7106 {
7107 id: "facebook_access_token",
7108 type: showFacebookToken ? "text" : "password",
7109 value: formData.facebook_access_token || "",
7110 name: "facebook_access_token",
7111 onChange: handleFieldChange,
7112 placeholder: "EAAC...",
7113 className: "pr-10"
7114 }
7115 ),
7116 /* @__PURE__ */ jsxRuntimeExports.jsx(
7117 "button",
7118 {
7119 type: "button",
7120 onClick: () => setShowFacebookToken(!showFacebookToken),
7121 className: "absolute inset-y-0 right-0 pr-3 flex items-center",
7122 tabIndex: -1,
7123 children: showFacebookToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" })
7124 }
7125 )
7126 ] }),
7127 /* @__PURE__ */ jsxRuntimeExports.jsx(
7128 Button,
7129 {
7130 type: "button",
7131 onClick: validateFacebookToken,
7132 disabled: !formData.facebook_access_token || validatingToken,
7133 variant: "outline",
7134 size: "sm",
7135 className: "whitespace-nowrap",
7136 children: validatingToken ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7137 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
7138 __("Validating...", "yatra")
7139 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7140 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }),
7141 __("Validate", "yatra")
7142 ] })
7143 }
7144 )
7145 ] }),
7146 formData.facebook_access_token && /* @__PURE__ */ jsxRuntimeExports.jsx(
7147 "div",
7148 {
7149 className: `text-sm ${((_ka = (_ja = (_ia = window.yatraAdmin) == null ? void 0 : _ia.facebookPixel) == null ? void 0 : _ja.connectionStatus) == null ? void 0 : _ka.tokenConnected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`,
7150 children: ((_na = (_ma = (_la = window.yatraAdmin) == null ? void 0 : _la.facebookPixel) == null ? void 0 : _ma.connectionStatus) == null ? void 0 : _na.tokenConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7151 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }),
7152 __("Access token is valid!", "yatra")
7153 ] }) : ((_qa = (_pa = (_oa = window.yatraAdmin) == null ? void 0 : _oa.facebookPixel) == null ? void 0 : _pa.connectionStatus) == null ? void 0 : _qa.tokenError) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7154 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }),
7155 (_ta = (_sa = (_ra = window.yatraAdmin) == null ? void 0 : _ra.facebookPixel) == null ? void 0 : _sa.connectionStatus) == null ? void 0 : _ta.tokenError
7156 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7157 /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }),
7158 __(
7159 "Click 'Validate' to test access token.",
7160 "yatra"
7161 )
7162 ] })
7163 }
7164 )
7165 ] })
7166 }
7167 )
7168 ] })
7169 }
7170 ),
7171 ((_va = (_ua = window.yatraAdmin) == null ? void 0 : _ua.facebookPixel) == null ? void 0 : _va.pixelId) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
7172 /* @__PURE__ */ jsxRuntimeExports.jsx(
7173 "svg",
7174 {
7175 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
7176 fill: "none",
7177 stroke: "currentColor",
7178 viewBox: "0 0 24 24",
7179 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7180 "path",
7181 {
7182 strokeLinecap: "round",
7183 strokeLinejoin: "round",
7184 strokeWidth: 2,
7185 d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
7186 }
7187 )
7188 }
7189 ),
7190 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm", children: [
7191 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-blue-800 dark:text-blue-300 font-medium", children: __("Facebook Pixel Monitoring:", "yatra") }),
7192 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-blue-700 dark:text-blue-400 ml-1", children: [
7193 __(
7194 "View event statistics and activity in the ",
7195 "yatra"
7196 ),
7197 /* @__PURE__ */ jsxRuntimeExports.jsx(
7198 "a",
7199 {
7200 href: `${((_wa = window.yatraAdmin) == null ? void 0 : _wa.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=reports`,
7201 className: "underline hover:text-blue-600 dark:hover:text-blue-300 font-medium",
7202 children: __("Reports page", "yatra")
7203 }
7204 ),
7205 __(" → Facebook Pixel tab.", "yatra")
7206 ] })
7207 ] })
7208 ] }) })
7209 ] })
7210 ] }),
7211 /* @__PURE__ */ jsxRuntimeExports.jsx(
7212 SectionDivider,
7213 {
7214 title: __("Google Analytics 4 Enhanced", "yatra")
7215 }
7216 ),
7217 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "overflow-hidden border-gray-200 dark:border-gray-700 shadow-sm", children: [
7218 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row flex-wrap items-start gap-3 justify-between border-b border-gray-100 dark:border-gray-800 bg-gray-50/80 dark:bg-gray-900/40 pb-4", children: [
7219 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2.5 text-gray-900 dark:text-white", children: [
7220 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-9 w-9 items-center justify-center rounded-lg bg-orange-500/10 dark:bg-orange-500/15", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7221 BarChart3,
7222 {
7223 className: "w-5 h-5 text-orange-600 dark:text-orange-400",
7224 "aria-hidden": true
7225 }
7226 ) }),
7227 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex flex-wrap items-center gap-2 leading-tight", children: [
7228 __("Google Analytics 4 Enhanced", "yatra"),
7229 /* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_xa = window.yatraAdmin) == null ? void 0 : _xa.isPro })
7230 ] })
7231 ] }),
7232 (() => {
7233 var _a3, _b3, _c2;
7234 const ga4HasId = Boolean((_a3 = formData.ga4_measurement_id) == null ? void 0 : _a3.trim());
7235 const ga4Connected = ga4HasId || Boolean(
7236 (_c2 = (_b3 = window.yatraAdmin) == null ? void 0 : _b3.googleAnalytics) == null ? void 0 : _c2.connected
7237 );
7238 return ga4Connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline-flex items-center gap-1.5 rounded-full border border-green-200 bg-green-50 px-2.5 py-1 text-xs font-medium text-green-800 dark:border-green-800 dark:bg-green-950/40 dark:text-green-300", children: [
7239 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-3.5 h-3.5 shrink-0" }),
7240 __("Measurement ID set", "yatra")
7241 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400", children: [
7242 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-3.5 h-3.5 shrink-0" }),
7243 __("Not configured", "yatra")
7244 ] });
7245 })()
7246 ] }),
7247 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-6 pt-6", children: [
7248 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm leading-relaxed text-gray-600 dark:text-gray-300", children: __(
7249 "Connect GA4 for ecommerce events (view item, add to cart, checkout, purchase). Optional Measurement Protocol sends verified server-side events for more reliable attribution.",
7250 "yatra"
7251 ) }),
7252 /* @__PURE__ */ jsxRuntimeExports.jsx(
7253 ProFeature,
7254 {
7255 title: __("Google Analytics 4 Enhanced", "yatra"),
7256 description: __(
7257 "access enhanced e-commerce tracking features",
7258 "yatra"
7259 ),
7260 moduleName: "Google Analytics",
7261 pricingUrl: "https://wpyatra.com/pricing?module=google-analytics",
7262 isProActive: (_ya = window.yatraAdmin) == null ? void 0 : _ya.isPro,
7263 isModuleEnabled: (_za = window.yatraAdmin) == null ? void 0 : _za.showGoogleAnalyticsSettingsUI,
7264 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-8", children: [
7265 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [
7266 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
7267 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Connection", "yatra") }),
7268 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __(
7269 "Use your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). Find it under Admin → Data streams → your stream.",
7270 "yatra"
7271 ) })
7272 ] }),
7273 /* @__PURE__ */ jsxRuntimeExports.jsx(
7274 FormField,
7275 {
7276 id: "ga4_measurement_id",
7277 label: __("Measurement ID", "yatra"),
7278 description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
7279 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __(
7280 "Your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). The Validate button checks the format only — confirm the stream is live in your GA4 Admin.",
7281 "yatra"
7282 ) }),
7283 /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [
7284 /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400", children: __("How to get your Measurement ID:", "yatra") }),
7285 /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [
7286 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7287 "Go to Google Analytics: analytics.google.com",
7288 "yatra"
7289 ) }),
7290 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7291 "Sign in and select the property you want to track this site with (or create one: Admin → Create → Property → choose your business details).",
7292 "yatra"
7293 ) }),
7294 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7295 "In the bottom-left corner click the gear icon (Admin).",
7296 "yatra"
7297 ) }),
7298 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7299 "In the Property column click Data Streams.",
7300 "yatra"
7301 ) }),
7302 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7303 "Click your existing Web stream — or click Add stream → Web, enter your site URL and a stream name, then Create stream.",
7304 "yatra"
7305 ) }),
7306 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7307 "On the stream details panel, copy the Measurement ID at the top right (format G-XXXXXXXXXX).",
7308 "yatra"
7309 ) }),
7310 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7311 "Paste it in the field above and click Validate.",
7312 "yatra"
7313 ) })
7314 ] })
7315 ] }),
7316 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7317 "a",
7318 {
7319 href: "https://analytics.google.com/analytics/web/",
7320 target: "_blank",
7321 rel: "noopener noreferrer",
7322 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm",
7323 children: __("Open Google Analytics →", "yatra")
7324 }
7325 ) })
7326 ] }),
7327 actionButton: /* @__PURE__ */ jsxRuntimeExports.jsx(
7328 Button,
7329 {
7330 type: "button",
7331 variant: "outline",
7332 size: "sm",
7333 onClick: () => validateMeasurementId(),
7334 disabled: !((_Aa = formData.ga4_measurement_id) == null ? void 0 : _Aa.trim()) || validatingMeasurementId,
7335 className: "shrink-0",
7336 children: validatingMeasurementId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7337 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
7338 __("Validating...", "yatra")
7339 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7340 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mr-2 h-4 w-4" }),
7341 __("Validate", "yatra")
7342 ] })
7343 }
7344 ),
7345 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7346 Input,
7347 {
7348 id: "ga4_measurement_id",
7349 value: formData.ga4_measurement_id || "",
7350 name: "ga4_measurement_id",
7351 onChange: handleFieldChange,
7352 placeholder: "G-XXXXXXXXXX",
7353 className: "font-mono text-sm",
7354 spellCheck: false,
7355 autoComplete: "off"
7356 }
7357 )
7358 }
7359 )
7360 ] }),
7361 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [
7362 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
7363 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Events", "yatra") }),
7364 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __(
7365 "Choose which standard ecommerce events Yatra should emit to GA4 on the storefront and booking flow.",
7366 "yatra"
7367 ) })
7368 ] }),
7369 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [
7370 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [
7371 /* @__PURE__ */ jsxRuntimeExports.jsx(
7372 "input",
7373 {
7374 type: "checkbox",
7375 id: "ga4_track_view_item",
7376 checked: formData.ga4_track_view_item ?? true,
7377 name: "ga4_track_view_item",
7378 onChange: handleFieldChange,
7379 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7380 }
7381 ),
7382 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7383 /* @__PURE__ */ jsxRuntimeExports.jsx(
7384 Label,
7385 {
7386 htmlFor: "ga4_track_view_item",
7387 className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white",
7388 children: __("View item", "yatra")
7389 }
7390 ),
7391 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __(
7392 "Trip detail pages (recommended for remarketing).",
7393 "yatra"
7394 ) })
7395 ] })
7396 ] }),
7397 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [
7398 /* @__PURE__ */ jsxRuntimeExports.jsx(
7399 "input",
7400 {
7401 type: "checkbox",
7402 id: "ga4_track_add_to_cart",
7403 checked: formData.ga4_track_add_to_cart ?? true,
7404 name: "ga4_track_add_to_cart",
7405 onChange: handleFieldChange,
7406 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7407 }
7408 ),
7409 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7410 /* @__PURE__ */ jsxRuntimeExports.jsx(
7411 Label,
7412 {
7413 htmlFor: "ga4_track_add_to_cart",
7414 className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white",
7415 children: __("Add to cart", "yatra")
7416 }
7417 ),
7418 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __(
7419 "When a trip is added to the booking session / checkout.",
7420 "yatra"
7421 ) })
7422 ] })
7423 ] }),
7424 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [
7425 /* @__PURE__ */ jsxRuntimeExports.jsx(
7426 "input",
7427 {
7428 type: "checkbox",
7429 id: "ga4_track_begin_checkout",
7430 checked: formData.ga4_track_begin_checkout ?? true,
7431 name: "ga4_track_begin_checkout",
7432 onChange: handleFieldChange,
7433 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7434 }
7435 ),
7436 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7437 /* @__PURE__ */ jsxRuntimeExports.jsx(
7438 Label,
7439 {
7440 htmlFor: "ga4_track_begin_checkout",
7441 className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white",
7442 children: __("Begin checkout", "yatra")
7443 }
7444 ),
7445 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __(
7446 "When a booking is created (checkout started).",
7447 "yatra"
7448 ) })
7449 ] })
7450 ] }),
7451 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [
7452 /* @__PURE__ */ jsxRuntimeExports.jsx(
7453 "input",
7454 {
7455 type: "checkbox",
7456 id: "ga4_track_purchase",
7457 checked: formData.ga4_track_purchase ?? true,
7458 name: "ga4_track_purchase",
7459 onChange: handleFieldChange,
7460 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7461 }
7462 ),
7463 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7464 /* @__PURE__ */ jsxRuntimeExports.jsx(
7465 Label,
7466 {
7467 htmlFor: "ga4_track_purchase",
7468 className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white",
7469 children: __("Purchase", "yatra")
7470 }
7471 ),
7472 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __(
7473 "When payment completes (and on confirmation page).",
7474 "yatra"
7475 ) })
7476 ] })
7477 ] })
7478 ] })
7479 ] }),
7480 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [
7481 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
7482 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Server-side (Measurement Protocol)", "yatra") }),
7483 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __(
7484 "Send duplicate events from your server with an API secret—useful when ad blockers affect the browser tag or for reconciliation.",
7485 "yatra"
7486 ) })
7487 ] }),
7488 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [
7489 /* @__PURE__ */ jsxRuntimeExports.jsx(
7490 "input",
7491 {
7492 type: "checkbox",
7493 id: "ga4_use_measurement_protocol",
7494 checked: formData.ga4_use_measurement_protocol ?? false,
7495 name: "ga4_use_measurement_protocol",
7496 onChange: handleFieldChange,
7497 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7498 }
7499 ),
7500 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7501 /* @__PURE__ */ jsxRuntimeExports.jsx(
7502 Label,
7503 {
7504 htmlFor: "ga4_use_measurement_protocol",
7505 className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white",
7506 children: __("Enable Measurement Protocol", "yatra")
7507 }
7508 ),
7509 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __(
7510 "Requires an API secret from the same GA4 data stream.",
7511 "yatra"
7512 ) })
7513 ] })
7514 ] }),
7515 formData.ga4_use_measurement_protocol && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 space-y-4 border-t border-gray-100 pt-4 dark:border-gray-800", children: [
7516 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-amber-100 bg-amber-50/60 p-3 dark:border-amber-900/40 dark:bg-amber-950/20", children: [
7517 /* @__PURE__ */ jsxRuntimeExports.jsx(
7518 "input",
7519 {
7520 type: "checkbox",
7521 id: "ga4_debug_mode",
7522 checked: formData.ga4_debug_mode ?? false,
7523 name: "ga4_debug_mode",
7524 onChange: handleFieldChange,
7525 className: "mt-0.5 h-4 w-4 shrink-0 rounded border-amber-300 text-amber-600 focus:ring-amber-500"
7526 }
7527 ),
7528 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
7529 /* @__PURE__ */ jsxRuntimeExports.jsx(
7530 Label,
7531 {
7532 htmlFor: "ga4_debug_mode",
7533 className: "cursor-pointer text-sm font-medium text-amber-950 dark:text-amber-100",
7534 children: __(
7535 "Validation mode (debug endpoint)",
7536 "yatra"
7537 )
7538 }
7539 ),
7540 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-amber-900/90 dark:text-amber-200/90", children: __(
7541 "Send Measurement Protocol hits to Google’s validation URL for troubleshooting. Events won’t appear in standard reports.",
7542 "yatra"
7543 ) })
7544 ] })
7545 ] }),
7546 /* @__PURE__ */ jsxRuntimeExports.jsx(
7547 FormField,
7548 {
7549 id: "ga4_api_secret",
7550 label: __(
7551 "Measurement Protocol API secret",
7552 "yatra"
7553 ),
7554 description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
7555 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __(
7556 "Treat this like a password — anyone with it can send fake events to your GA4 property. Restrict who can view Yatra settings.",
7557 "yatra"
7558 ) }),
7559 /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [
7560 /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400", children: __("How to get your API secret:", "yatra") }),
7561 /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [
7562 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7563 "Go to Google Analytics: analytics.google.com",
7564 "yatra"
7565 ) }),
7566 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7567 "Sign in and select the same property you used for the Measurement ID above.",
7568 "yatra"
7569 ) }),
7570 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7571 "Click the gear icon (Admin) in the bottom-left corner.",
7572 "yatra"
7573 ) }),
7574 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7575 "In the Property column click Data Streams, then click your Web stream.",
7576 "yatra"
7577 ) }),
7578 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7579 "Scroll to Events → Measurement Protocol API secrets → Create.",
7580 "yatra"
7581 ) }),
7582 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7583 "Give the secret a nickname (e.g. “Yatra server”) and click Create.",
7584 "yatra"
7585 ) }),
7586 /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __(
7587 "Copy the Secret value (not the nickname) and paste it in the field above.",
7588 "yatra"
7589 ) })
7590 ] })
7591 ] }),
7592 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7593 "a",
7594 {
7595 href: "https://analytics.google.com/analytics/web/",
7596 target: "_blank",
7597 rel: "noopener noreferrer",
7598 className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm",
7599 children: __("Open Google Analytics →", "yatra")
7600 }
7601 ) })
7602 ] }),
7603 actionButton: /* @__PURE__ */ jsxRuntimeExports.jsx(
7604 Button,
7605 {
7606 type: "button",
7607 variant: "outline",
7608 size: "sm",
7609 onClick: () => validateApiSecret(),
7610 disabled: !formData.ga4_api_secret || !formData.ga4_measurement_id || validatingApiSecret,
7611 className: "shrink-0",
7612 children: validatingApiSecret ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7613 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
7614 __("Validating...", "yatra")
7615 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7616 /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mr-2 h-4 w-4" }),
7617 __("Validate", "yatra")
7618 ] })
7619 }
7620 ),
7621 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
7622 /* @__PURE__ */ jsxRuntimeExports.jsx(
7623 Input,
7624 {
7625 id: "ga4_api_secret",
7626 type: showGa4ApiSecret ? "text" : "password",
7627 value: formData.ga4_api_secret || "",
7628 name: "ga4_api_secret",
7629 onChange: handleFieldChange,
7630 placeholder: __(
7631 "Paste secret from GA4",
7632 "yatra"
7633 ),
7634 className: "pr-10 font-mono text-sm",
7635 spellCheck: false,
7636 autoComplete: "new-password"
7637 }
7638 ),
7639 /* @__PURE__ */ jsxRuntimeExports.jsx(
7640 "button",
7641 {
7642 type: "button",
7643 onClick: () => setShowGa4ApiSecret(!showGa4ApiSecret),
7644 className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",
7645 tabIndex: -1,
7646 "aria-label": showGa4ApiSecret ? __("Hide secret", "yatra") : __("Show secret", "yatra"),
7647 children: showGa4ApiSecret ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })
7648 }
7649 )
7650 ] })
7651 }
7652 )
7653 ] })
7654 ] })
7655 ] })
7656 }
7657 ),
7658 (Boolean((_Ba = formData.ga4_measurement_id) == null ? void 0 : _Ba.trim()) || Boolean(
7659 (_Da = (_Ca = window.yatraAdmin) == null ? void 0 : _Ca.googleAnalytics) == null ? void 0 : _Da.measurementId
7660 )) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-blue-200 bg-blue-50/90 p-4 dark:border-blue-800 dark:bg-blue-950/30", children: [
7661 /* @__PURE__ */ jsxRuntimeExports.jsx(BarChart3, { className: "mt-0.5 h-5 w-5 shrink-0 text-blue-600 dark:text-blue-400" }),
7662 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 text-sm leading-relaxed", children: [
7663 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium text-blue-900 dark:text-blue-100", children: __("Reports & event log", "yatra") }),
7664 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1 text-blue-800/90 dark:text-blue-200/90", children: [
7665 __(
7666 "Review connection status and recent Measurement Protocol activity under",
7667 "yatra"
7668 ),
7669 " ",
7670 /* @__PURE__ */ jsxRuntimeExports.jsx(
7671 "a",
7672 {
7673 href: `${((_Ea = window.yatraAdmin) == null ? void 0 : _Ea.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=reports`,
7674 className: "font-medium underline decoration-blue-600/40 underline-offset-2 hover:text-blue-950 dark:hover:text-white",
7675 children: __("Reports", "yatra")
7676 }
7677 ),
7678 " → ",
7679 __("Google Analytics 4.", "yatra")
7680 ] })
7681 ] })
7682 ] })
7683 ] })
7684 ] }),
7685 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Maps", "yatra") }),
7686 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [
7687 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-6 h-6 text-blue-600 dark:text-blue-400 mt-0.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7688 "path",
7689 {
7690 strokeLinecap: "round",
7691 strokeLinejoin: "round",
7692 strokeWidth: 2,
7693 d: "M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"
7694 }
7695 ) }) }),
7696 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
7697 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-blue-900 dark:text-blue-100 mb-1", children: __("OpenStreetMap Integration", "yatra") }),
7698 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-blue-700 dark:text-blue-300", children: __(
7699 "Maps are powered by OpenStreetMap - a free, open-source mapping service. No API key required! Maps will automatically display trip starting locations with custom markers.",
7700 "yatra"
7701 ) })
7702 ] })
7703 ] }) }) }),
7704 /* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("reCAPTCHA Settings", "yatra") }),
7705 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
7706 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
7707 /* @__PURE__ */ jsxRuntimeExports.jsx(
7708 "input",
7709 {
7710 type: "checkbox",
7711 id: "recaptcha_enabled",
7712 checked: formData.recaptcha_enabled,
7713 name: "recaptcha_enabled",
7714 onChange: handleFieldChange,
7715 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7716 }
7717 ),
7718 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
7719 /* @__PURE__ */ jsxRuntimeExports.jsx(
7720 Label,
7721 {
7722 htmlFor: "recaptcha_enabled",
7723 className: "font-medium cursor-pointer",
7724 children: __("Enable reCAPTCHA", "yatra")
7725 }
7726 ),
7727 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Protect forms from spam and bots", "yatra") })
7728 ] })
7729 ] }),
7730 formData.recaptcha_enabled && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7731 /* @__PURE__ */ jsxRuntimeExports.jsx(
7732 FormField,
7733 {
7734 id: "recaptcha_site_key",
7735 label: __("Site Key", "yatra"),
7736 description: __("Your reCAPTCHA site key", "yatra"),
7737 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7738 Input,
7739 {
7740 id: "recaptcha_site_key",
7741 value: formData.recaptcha_site_key,
7742 name: "recaptcha_site_key",
7743 onChange: handleFieldChange,
7744 placeholder: __("Enter site key", "yatra")
7745 }
7746 )
7747 }
7748 ),
7749 /* @__PURE__ */ jsxRuntimeExports.jsx(
7750 FormField,
7751 {
7752 id: "recaptcha_secret_key",
7753 label: __("Secret Key", "yatra"),
7754 description: __(
7755 "Your reCAPTCHA secret key (keep this secure)",
7756 "yatra"
7757 ),
7758 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7759 Input,
7760 {
7761 id: "recaptcha_secret_key",
7762 type: "password",
7763 value: formData.recaptcha_secret_key,
7764 name: "recaptcha_secret_key",
7765 onChange: handleFieldChange,
7766 placeholder: __("Enter secret key", "yatra")
7767 }
7768 )
7769 }
7770 ),
7771 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __(
7772 "Uses reCAPTCHA v3 (invisible, score-based). Create v3 keys at google.com/recaptcha and paste them above.",
7773 "yatra"
7774 ) }),
7775 /* @__PURE__ */ jsxRuntimeExports.jsx(
7776 FormField,
7777 {
7778 id: "recaptcha_score_threshold",
7779 label: __("Score Threshold", "yatra"),
7780 description: __(
7781 "Minimum v3 score (0.0–1.0) to accept a submission. Lower is more lenient, higher is stricter. Default 0.5.",
7782 "yatra"
7783 ),
7784 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7785 Input,
7786 {
7787 id: "recaptcha_score_threshold",
7788 type: "number",
7789 min: "0",
7790 max: "1",
7791 step: "0.1",
7792 value: String(formData.recaptcha_score_threshold ?? 0.5),
7793 name: "recaptcha_score_threshold",
7794 onChange: (e) => setFormData(
7795 (prev) => prev ? {
7796 ...prev,
7797 recaptcha_score_threshold: parseFloat(
7798 e.target.value
7799 )
7800 } : prev
7801 )
7802 }
7803 )
7804 }
7805 ),
7806 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pt-2", children: [
7807 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Protect these forms", "yatra") }),
7808 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5 mb-2", children: __(
7809 "Choose which forms reCAPTCHA should verify. Booking protection is off by default to avoid blocking a legitimate payment on a low score.",
7810 "yatra"
7811 ) }),
7812 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: [
7813 {
7814 key: "recaptcha_protect_enquiry",
7815 label: __("Enquiry form", "yatra")
7816 },
7817 {
7818 key: "recaptcha_protect_booking",
7819 label: __("Booking / checkout form", "yatra")
7820 },
7821 {
7822 key: "recaptcha_protect_registration",
7823 label: __("Customer registration", "yatra")
7824 }
7825 ].map((f) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
7826 "label",
7827 {
7828 className: "flex items-center gap-2 cursor-pointer",
7829 children: [
7830 /* @__PURE__ */ jsxRuntimeExports.jsx(
7831 "input",
7832 {
7833 type: "checkbox",
7834 id: f.key,
7835 name: f.key,
7836 checked: Boolean(
7837 formData[f.key]
7838 ),
7839 onChange: handleFieldChange,
7840 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
7841 }
7842 ),
7843 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm", children: f.label })
7844 ]
7845 },
7846 f.key
7847 )) })
7848 ] })
7849 ] })
7850 ] })
7851 ] });
7852 case "permalink": {
7853 const listingSite = (((_Fa = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _Fa.siteUrl) || "").replace(/\/$/, "");
7854 const listingHref = (segment) => buildYatraListingPublicUrl(segment, listingSite || void 0);
7855 const bookingConfirmationPreviewUrl = (bookingBase) => {
7856 const bb = bookingBase.replace(/^\/|\/$/g, "");
7857 const site = listingSite || "";
7858 if (isWordPressPlainPermalink()) {
7859 return site ? `${site}/?yatra_booking_confirmation=` : "/?yatra_booking_confirmation=";
7860 }
7861 return site ? `${site}/${bb}/confirmation/` : `/${bb}/confirmation/`;
7862 };
7863 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
7864 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
7865 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Permalink Settings", "yatra") }),
7866 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-6", children: __(
7867 "Configure URL slugs for your Yatra content types. These settings control how your trips, destinations, and activities appear in URLs.",
7868 "yatra"
7869 ) })
7870 ] }),
7871 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
7872 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7873 FormField,
7874 {
7875 id: "trip_base",
7876 label: __("Trip Base", "yatra"),
7877 description: __(
7878 'URL slug for trip single pages (e.g., "trip" will create URLs like /trip/everest-base-camp)',
7879 "yatra"
7880 ),
7881 children: [
7882 /* @__PURE__ */ jsxRuntimeExports.jsx(
7883 Input,
7884 {
7885 id: "trip_base",
7886 name: "trip_base",
7887 value: formData.trip_base || "trip",
7888 onChange: handleFieldChange,
7889 placeholder: "trip",
7890 className: "font-mono"
7891 }
7892 ),
7893 formData.trip_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [
7894 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
7895 __("Listing URL:", "yatra"),
7896 " ",
7897 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.trip_base || "trip") })
7898 ] }),
7899 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7900 "a",
7901 {
7902 href: listingHref(formData.trip_base || "trip"),
7903 target: "_blank",
7904 rel: "noreferrer",
7905 className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0",
7906 children: [
7907 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
7908 " ",
7909 __("View", "yatra")
7910 ]
7911 }
7912 )
7913 ] })
7914 ]
7915 }
7916 ),
7917 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7918 FormField,
7919 {
7920 id: "destination_base",
7921 label: __("Destination Base", "yatra"),
7922 description: __(
7923 'URL slug for destination archive pages (e.g., "destination" will create URLs like /destination/nepal)',
7924 "yatra"
7925 ),
7926 children: [
7927 /* @__PURE__ */ jsxRuntimeExports.jsx(
7928 Input,
7929 {
7930 id: "destination_base",
7931 name: "destination_base",
7932 value: formData.destination_base || "destination",
7933 onChange: handleFieldChange,
7934 placeholder: "destination",
7935 className: "font-mono"
7936 }
7937 ),
7938 formData.destination_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [
7939 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
7940 __("Listing URL:", "yatra"),
7941 " ",
7942 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(
7943 formData.destination_base || "destination"
7944 ) })
7945 ] }),
7946 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7947 "a",
7948 {
7949 href: listingHref(
7950 formData.destination_base || "destination"
7951 ),
7952 target: "_blank",
7953 rel: "noreferrer",
7954 className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0",
7955 children: [
7956 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
7957 " ",
7958 __("View", "yatra")
7959 ]
7960 }
7961 )
7962 ] })
7963 ]
7964 }
7965 ),
7966 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7967 FormField,
7968 {
7969 id: "activity_base",
7970 label: __("Activity Base", "yatra"),
7971 description: __(
7972 'URL slug for activity archive pages (e.g., "activity" will create URLs like /activity/trekking)',
7973 "yatra"
7974 ),
7975 children: [
7976 /* @__PURE__ */ jsxRuntimeExports.jsx(
7977 Input,
7978 {
7979 id: "activity_base",
7980 name: "activity_base",
7981 value: formData.activity_base || "activity",
7982 onChange: handleFieldChange,
7983 placeholder: "activity",
7984 className: "font-mono"
7985 }
7986 ),
7987 formData.activity_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [
7988 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
7989 __("Listing URL:", "yatra"),
7990 " ",
7991 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.activity_base || "activity") })
7992 ] }),
7993 /* @__PURE__ */ jsxRuntimeExports.jsxs(
7994 "a",
7995 {
7996 href: listingHref(formData.activity_base || "activity"),
7997 target: "_blank",
7998 rel: "noreferrer",
7999 className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0",
8000 children: [
8001 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
8002 " ",
8003 __("View", "yatra")
8004 ]
8005 }
8006 )
8007 ] })
8008 ]
8009 }
8010 ),
8011 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8012 FormField,
8013 {
8014 id: "trip_category_base",
8015 label: __("Trip Category Base", "yatra"),
8016 description: __(
8017 'URL slug for trip category archive pages (e.g., "trip-category" will create URLs like /trip-category/adventure)',
8018 "yatra"
8019 ),
8020 children: [
8021 /* @__PURE__ */ jsxRuntimeExports.jsx(
8022 Input,
8023 {
8024 id: "trip_category_base",
8025 name: "trip_category_base",
8026 value: formData.trip_category_base || "trip-category",
8027 onChange: handleFieldChange,
8028 placeholder: "trip-category",
8029 className: "font-mono"
8030 }
8031 ),
8032 formData.trip_category_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [
8033 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
8034 __("Listing URL:", "yatra"),
8035 " ",
8036 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(
8037 formData.trip_category_base || "trip-category"
8038 ) })
8039 ] }),
8040 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8041 "a",
8042 {
8043 href: listingHref(
8044 formData.trip_category_base || "trip-category"
8045 ),
8046 target: "_blank",
8047 rel: "noreferrer",
8048 className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0",
8049 children: [
8050 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
8051 " ",
8052 __("View", "yatra")
8053 ]
8054 }
8055 )
8056 ] })
8057 ]
8058 }
8059 )
8060 ] }),
8061 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-8 pt-6 border-t border-gray-200 dark:border-gray-700", children: [
8062 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Booking Page Settings", "yatra") }),
8063 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-6", children: __(
8064 "Configure the booking page URL. By default, bookings use /book/{trip-slug}. You can customize the URL base or use a custom WordPress page.",
8065 "yatra"
8066 ) }),
8067 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
8068 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8069 FormField,
8070 {
8071 id: "booking_base",
8072 label: __("Default Booking URL Base", "yatra"),
8073 description: __(
8074 'URL slug for the booking page (e.g., "book" will create URLs like /book/trip-name)',
8075 "yatra"
8076 ),
8077 children: [
8078 /* @__PURE__ */ jsxRuntimeExports.jsx(
8079 Input,
8080 {
8081 id: "booking_base",
8082 name: "booking_base",
8083 value: formData.booking_base || "book",
8084 onChange: handleFieldChange,
8085 placeholder: "book",
8086 className: "font-mono"
8087 }
8088 ),
8089 formData.booking_base && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
8090 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [
8091 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
8092 __("Booking hub URL:", "yatra"),
8093 " ",
8094 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.booking_base || "book") })
8095 ] }),
8096 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8097 "a",
8098 {
8099 href: listingHref(formData.booking_base || "book"),
8100 target: "_blank",
8101 rel: "noreferrer",
8102 className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0",
8103 children: [
8104 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }),
8105 " ",
8106 __("View", "yatra")
8107 ]
8108 }
8109 )
8110 ] }),
8111 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [
8112 __(
8113 "Booking confirmation base (pageless, same slug as above):",
8114 "yatra"
8115 ),
8116 " ",
8117 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: bookingConfirmationPreviewUrl(
8118 formData.booking_base || "book"
8119 ) }),
8120 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-400 dark:text-gray-500 ml-1", children: __(
8121 "append booking reference after checkout",
8122 "yatra"
8123 ) })
8124 ] }) })
8125 ] })
8126 ]
8127 }
8128 ),
8129 formData.use_booking_page && /* @__PURE__ */ jsxRuntimeExports.jsxs(
8130 FormField,
8131 {
8132 id: "booking_page_id",
8133 label: __("Select Booking Page", "yatra"),
8134 description: __(
8135 "Choose a page that contains the [yatra_booking] shortcode. If the page doesn't have the shortcode, you'll be prompted to add it.",
8136 "Choose a page that contains the [yatra_booking] shortcode. If the page doesn't have the shortcode, you'll be prompted to add it."
8137 ),
8138 children: [
8139 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
8140 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8141 "select",
8142 {
8143 id: "booking_page_id",
8144 name: "booking_page_id",
8145 value: formData.booking_page_id || 0,
8146 onChange: (e) => handleBookingPageChange(parseInt(e.target.value)),
8147 disabled: isCheckingShortcode,
8148 className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50 disabled:cursor-wait",
8149 children: [
8150 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("-- Select a page --", "yatra") }),
8151 pagesData == null ? void 0 : pagesData.map((page) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: page.id, children: page.title }, page.id))
8152 ]
8153 }
8154 ),
8155 isCheckingShortcode && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-8 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin text-blue-500" }) })
8156 ] }),
8157 formData.booking_page_id > 0 && pagesData && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: [
8158 __("Booking URL:", "yatra"),
8159 " ",
8160 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded", children: ((_Ga = pagesData.find(
8161 (p) => p.id === formData.booking_page_id
8162 )) == null ? void 0 : _Ga.url) || "" })
8163 ] })
8164 ]
8165 }
8166 )
8167 ] })
8168 ] }),
8169 showShortcodeDialog && selectedPageForShortcode && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full mx-4 p-6", children: [
8170 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Shortcode Required", "yatra") }),
8171 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
8172 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-3", children: [
8173 __("The page", "yatra"),
8174 " ",
8175 /* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [
8176 '"',
8177 selectedPageForShortcode.title,
8178 '"'
8179 ] }),
8180 " ",
8181 __("doesn't have the", "doesn't have the"),
8182 " ",
8183 /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-700 px-1 rounded", children: "[yatra_booking]" }),
8184 " ",
8185 __("shortcode.", "yatra")
8186 ] }),
8187 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __(
8188 "Would you like to add it automatically, or edit the page manually to place it where you want?",
8189 "yatra"
8190 ) })
8191 ] }),
8192 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
8193 /* @__PURE__ */ jsxRuntimeExports.jsx(
8194 Button,
8195 {
8196 onClick: handleConfirmInsertShortcode,
8197 disabled: insertShortcodeMutation.isPending,
8198 className: "w-full justify-center",
8199 children: insertShortcodeMutation.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
8200 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin mr-2" }),
8201 __("Adding...", "yatra")
8202 ] }) : __("Add Shortcode Automatically", "yatra")
8203 }
8204 ),
8205 /* @__PURE__ */ jsxRuntimeExports.jsx(
8206 Button,
8207 {
8208 variant: "outline",
8209 onClick: () => {
8210 var _a3;
8211 const editUrl = (_a3 = pagesData == null ? void 0 : pagesData.find(
8212 (p) => p.id === selectedPageForShortcode.id
8213 )) == null ? void 0 : _a3.url;
8214 if (editUrl) {
8215 window.open(
8216 `/wp-admin/post.php?post=${selectedPageForShortcode.id}&action=edit`,
8217 "_blank"
8218 );
8219 }
8220 setShowShortcodeDialog(false);
8221 setSelectedPageForShortcode(null);
8222 },
8223 className: "w-full justify-center",
8224 children: __("Edit Page Manually", "yatra")
8225 }
8226 ),
8227 /* @__PURE__ */ jsxRuntimeExports.jsx(
8228 Button,
8229 {
8230 variant: "ghost",
8231 onClick: () => {
8232 setShowShortcodeDialog(false);
8233 setSelectedPageForShortcode(null);
8234 handleFieldChange({
8235 target: { name: "booking_page_id", value: 0 }
8236 });
8237 },
8238 className: "w-full justify-center",
8239 children: __("Skip for now", "yatra")
8240 }
8241 )
8242 ] })
8243 ] }) }),
8244 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [
8245 /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" }),
8246 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 text-sm text-blue-800 dark:text-blue-200", children: [
8247 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium mb-1", children: __("Important:", "yatra") }),
8248 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-3", children: __(
8249 "After changing permalink settings, you must flush rewrite rules for the changes to take effect.",
8250 "yatra"
8251 ) }),
8252 /* @__PURE__ */ jsxRuntimeExports.jsx(
8253 Button,
8254 {
8255 type: "button",
8256 onClick: () => flushRewriteRulesMutation.mutate(),
8257 disabled: flushRewriteRulesMutation.isPending,
8258 variant: "outline",
8259 size: "sm",
8260 className: "flex items-center gap-2",
8261 children: flushRewriteRulesMutation.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
8262 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }),
8263 __("Flushing...", "yatra")
8264 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
8265 /* @__PURE__ */ jsxRuntimeExports.jsx(Globe, { className: "w-4 h-4" }),
8266 __("Flush Rewrite Rules", "yatra")
8267 ] })
8268 }
8269 )
8270 ] })
8271 ] }) })
8272 ] });
8273 }
8274 case "seo":
8275 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
8276 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
8277 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Trip Archive SEO Settings", "yatra") }),
8278 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
8279 "Configure SEO meta tags for the trip archive page (/trip/). These meta tags will be used for the main trip listing page.",
8280 "yatra"
8281 ) }),
8282 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
8283 /* @__PURE__ */ jsxRuntimeExports.jsx(
8284 FormField,
8285 {
8286 id: "seo_trip_meta_title",
8287 label: __("Trip Archive Meta Title", "yatra"),
8288 description: __(
8289 "Meta title for the trip archive page. This will appear in search engine results for /trip/ page.",
8290 "yatra"
8291 ),
8292 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8293 Input,
8294 {
8295 id: "seo_trip_meta_title",
8296 type: "text",
8297 value: formData.seo_trip_meta_title,
8298 onChange: (e) => setFormData(
8299 (prev) => prev ? { ...prev, seo_trip_meta_title: e.target.value } : null
8300 ),
8301 placeholder: __(
8302 "e.g., Browse All Trips - Find Your Perfect Adventure | Your Travel Agency",
8303 "yatra"
8304 ),
8305 className: "w-full"
8306 }
8307 )
8308 }
8309 ),
8310 /* @__PURE__ */ jsxRuntimeExports.jsx(
8311 FormField,
8312 {
8313 id: "seo_trip_meta_description",
8314 label: __("Trip Archive Meta Description", "yatra"),
8315 description: __(
8316 "Meta description for the trip archive page. Should be 150-160 characters for best SEO results.",
8317 "yatra"
8318 ),
8319 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8320 "textarea",
8321 {
8322 id: "seo_trip_meta_description",
8323 value: formData.seo_trip_meta_description,
8324 onChange: (e) => setFormData(
8325 (prev) => prev ? {
8326 ...prev,
8327 seo_trip_meta_description: e.target.value
8328 } : null
8329 ),
8330 placeholder: __(
8331 "e.g., Explore our complete collection of amazing trips and adventures. Find and book your perfect journey with us.",
8332 "yatra"
8333 ),
8334 rows: 3,
8335 className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"
8336 }
8337 )
8338 }
8339 ),
8340 /* @__PURE__ */ jsxRuntimeExports.jsx(
8341 FormField,
8342 {
8343 id: "seo_trip_meta_keywords",
8344 label: __("Trip Archive Meta Keywords", "yatra"),
8345 description: __(
8346 "Comma-separated keywords for the trip archive page. Include relevant travel and booking keywords.",
8347 "yatra"
8348 ),
8349 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8350 Input,
8351 {
8352 id: "seo_trip_meta_keywords",
8353 type: "text",
8354 value: formData.seo_trip_meta_keywords,
8355 onChange: (e) => setFormData(
8356 (prev) => prev ? { ...prev, seo_trip_meta_keywords: e.target.value } : null
8357 ),
8358 placeholder: __(
8359 "e.g., travel, trips, adventure, booking, tours, destinations, holidays",
8360 "yatra"
8361 ),
8362 className: "w-full"
8363 }
8364 )
8365 }
8366 ),
8367 /* @__PURE__ */ jsxRuntimeExports.jsx(
8368 FormField,
8369 {
8370 id: "seo_trip_meta_image",
8371 label: __("Trip Archive SEO Image", "yatra"),
8372 description: __(
8373 "Image for social media sharing and SEO. Recommended size: 1200x630 pixels. This image will appear when the trip archive page is shared on Facebook, Twitter, and other platforms.",
8374 "yatra"
8375 ),
8376 children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: formData.seo_trip_meta_image && formData.seo_trip_meta_image > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative group", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-800/50", children: [
8377 seoImageLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-24 h-24 flex items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-6 h-6 animate-spin text-gray-400" }) }) : seoImageUrl ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-24 h-24 overflow-hidden rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700", children: [
8378 /* @__PURE__ */ jsxRuntimeExports.jsx(
8379 "img",
8380 {
8381 src: seoImageUrl,
8382 alt: "SEO Preview",
8383 className: "w-full h-full object-cover"
8384 }
8385 ),
8386 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors" })
8387 ] }) : seoImageError ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-24 h-24 flex flex-col items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: [
8388 /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-6 h-6 text-red-400 mb-1" }),
8389 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500 dark:text-red-400 text-center px-1", children: seoImageError })
8390 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-24 h-24 flex flex-col items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: [
8391 /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-6 h-6 text-gray-400 mb-1" }),
8392 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: "No image" })
8393 ] }),
8394 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
8395 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
8396 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("SEO Image", "yatra") }),
8397 !seoImageLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
8398 "button",
8399 {
8400 type: "button",
8401 onClick: () => {
8402 setFormData(
8403 (prev) => prev ? { ...prev, seo_trip_meta_image: 0 } : null
8404 );
8405 },
8406 className: "opacity-0 group-hover:opacity-100 transition-opacity p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded",
8407 title: __("Remove image", "yatra"),
8408 children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-4 h-4" })
8409 }
8410 )
8411 ] }),
8412 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-3", children: __(
8413 "Recommended size: 1200x630 pixels for optimal social media display.",
8414 "yatra"
8415 ) }),
8416 /* @__PURE__ */ jsxRuntimeExports.jsx(
8417 Button,
8418 {
8419 type: "button",
8420 onClick: () => {
8421 if (window.wp && window.wp.media) {
8422 const mediaUploader = window.wp.media({
8423 title: __("Select SEO Image", "yatra"),
8424 button: {
8425 text: __("Use this image", "yatra")
8426 },
8427 multiple: false,
8428 library: { type: "image" }
8429 });
8430 mediaUploader.on("select", () => {
8431 const attachment = mediaUploader.state().get("selection").first().toJSON();
8432 setFormData(
8433 (prev) => prev ? {
8434 ...prev,
8435 seo_trip_meta_image: attachment.id
8436 } : null
8437 );
8438 });
8439 prepareWordPressMediaFrameOpen();
8440 mediaUploader.open();
8441 }
8442 },
8443 variant: "outline",
8444 size: "sm",
8445 children: __("Change Image", "yatra")
8446 }
8447 )
8448 ] })
8449 ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center hover:border-gray-400 dark:hover:border-gray-500 transition-colors", children: [
8450 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 h-16 mx-auto mb-4 flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-8 h-8 text-gray-400" }) }),
8451 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-gray-900 dark:text-white mb-2", children: __("Add SEO Image", "yatra") }),
8452 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4 max-w-sm mx-auto", children: __(
8453 "Upload an image that will appear when your trip archive page is shared on social media. Recommended size: 1200x630 pixels.",
8454 "yatra"
8455 ) }),
8456 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8457 Button,
8458 {
8459 type: "button",
8460 onClick: () => {
8461 if (window.wp && window.wp.media) {
8462 const mediaUploader = window.wp.media({
8463 title: __("Select SEO Image", "yatra"),
8464 button: { text: __("Use this image", "yatra") },
8465 multiple: false,
8466 library: { type: "image" }
8467 });
8468 mediaUploader.on("select", () => {
8469 const attachment = mediaUploader.state().get("selection").first().toJSON();
8470 setFormData(
8471 (prev) => prev ? {
8472 ...prev,
8473 seo_trip_meta_image: attachment.id
8474 } : null
8475 );
8476 });
8477 prepareWordPressMediaFrameOpen();
8478 mediaUploader.open();
8479 }
8480 },
8481 children: [
8482 /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4 mr-2" }),
8483 __("Select Image", "yatra")
8484 ]
8485 }
8486 )
8487 ] }) })
8488 }
8489 )
8490 ] })
8491 ] }),
8492 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
8493 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Sitemap", "yatra") }),
8494 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
8495 "Yatra publishes one sitemap of all trips, destinations, activities and categories so search engines can find them. It is advertised in robots.txt and linked into Yoast, Rank Math, AIOSEO and WordPress core sitemaps automatically.",
8496 "yatra"
8497 ) }),
8498 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
8499 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8500 /* @__PURE__ */ jsxRuntimeExports.jsx(
8501 "input",
8502 {
8503 type: "checkbox",
8504 id: "enable_sitemap",
8505 checked: formData.enable_sitemap,
8506 name: "enable_sitemap",
8507 onChange: handleFieldChange,
8508 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8509 }
8510 ),
8511 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8512 /* @__PURE__ */ jsxRuntimeExports.jsx(
8513 Label,
8514 {
8515 htmlFor: "enable_sitemap",
8516 className: "font-medium cursor-pointer",
8517 children: __("Enable Sitemap", "yatra")
8518 }
8519 ),
8520 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8521 "Generate /yatra-sitemap.xml and advertise it to search engines.",
8522 "yatra"
8523 ) })
8524 ] })
8525 ] }),
8526 formData.enable_sitemap && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8527 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Sitemap URL", "yatra") }),
8528 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex items-center gap-2", children: [
8529 /* @__PURE__ */ jsxRuntimeExports.jsx(
8530 "a",
8531 {
8532 href: ((_Ha = window.yatraAdmin) == null ? void 0 : _Ha.sitemapUrl) || "#",
8533 target: "_blank",
8534 rel: "noopener noreferrer",
8535 className: "flex-1 break-all text-sm text-blue-600 dark:text-blue-400 underline",
8536 children: ((_Ia = window.yatraAdmin) == null ? void 0 : _Ia.sitemapUrl) || ""
8537 }
8538 ),
8539 /* @__PURE__ */ jsxRuntimeExports.jsx(
8540 "button",
8541 {
8542 type: "button",
8543 onClick: () => {
8544 var _a3, _b3;
8545 return (_b3 = navigator.clipboard) == null ? void 0 : _b3.writeText(
8546 ((_a3 = window.yatraAdmin) == null ? void 0 : _a3.sitemapUrl) || ""
8547 );
8548 },
8549 className: "px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700",
8550 children: __("Copy", "yatra")
8551 }
8552 )
8553 ] }),
8554 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-2", children: [
8555 __(
8556 "Optional: submit this URL in Google Search Console or Bing Webmaster Tools. It is already listed in robots.txt, so search engines find it automatically.",
8557 "yatra"
8558 ),
8559 formData.enable_sitemap && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 border border-gray-200 dark:border-gray-700 rounded-md space-y-3", children: [
8560 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
8561 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Content in the sitemap", "yatra") }),
8562 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8563 "Uncheck a type to keep it out of /yatra-sitemap.xml.",
8564 "yatra"
8565 ) })
8566 ] }),
8567 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 gap-2", children: [
8568 { key: "trip", label: __("Trips", "yatra") },
8569 { key: "destination", label: __("Destinations", "yatra") },
8570 { key: "activity", label: __("Activities", "yatra") },
8571 { key: "category", label: __("Trip categories", "yatra") },
8572 { key: "archive", label: __("Listing pages", "yatra") }
8573 ].map((t) => {
8574 const selected = formData.sitemap_types ?? [];
8575 const checked = selected.includes(t.key);
8576 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
8577 "label",
8578 {
8579 className: "flex items-center gap-2 text-sm cursor-pointer",
8580 children: [
8581 /* @__PURE__ */ jsxRuntimeExports.jsx(
8582 "input",
8583 {
8584 type: "checkbox",
8585 checked,
8586 onChange: () => setFormData((prev) => {
8587 if (!prev) return prev;
8588 return {
8589 ...prev,
8590 sitemap_types: checked ? (prev.sitemap_types ?? []).filter(
8591 (x) => x !== t.key
8592 ) : [...prev.sitemap_types ?? [], t.key]
8593 };
8594 }),
8595 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8596 }
8597 ),
8598 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t.label })
8599 ]
8600 },
8601 t.key
8602 );
8603 }) }),
8604 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 pt-2 border-t border-gray-200 dark:border-gray-700", children: [
8605 /* @__PURE__ */ jsxRuntimeExports.jsx(
8606 "input",
8607 {
8608 type: "checkbox",
8609 id: "sitemap_noindex_excluded",
8610 name: "sitemap_noindex_excluded",
8611 checked: formData.sitemap_noindex_excluded,
8612 onChange: (e) => setFormData((prev) => {
8613 if (!prev) return prev;
8614 return {
8615 ...prev,
8616 sitemap_noindex_excluded: e.target.checked
8617 };
8618 }),
8619 className: "mt-0.5 w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8620 }
8621 ),
8622 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8623 /* @__PURE__ */ jsxRuntimeExports.jsx(
8624 Label,
8625 {
8626 htmlFor: "sitemap_noindex_excluded",
8627 className: "font-medium cursor-pointer",
8628 children: __("Also add noindex to excluded types", "yatra")
8629 }
8630 ),
8631 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8632 "Leaving a type out of the sitemap does not stop Google indexing it. Turn this on to send noindex on those pages as well — they will drop out of search results, so only do this for content you do not want found.",
8633 "yatra"
8634 ) })
8635 ] })
8636 ] })
8637 ] })
8638 ] })
8639 ] })
8640 ] })
8641 ] })
8642 ] });
8643 case "uninstall":
8644 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
8645 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300", children: __(
8646 "This only applies when Yatra is deleted from the Plugins screen. Deactivating the plugin never removes anything.",
8647 "yatra"
8648 ) }),
8649 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8650 /* @__PURE__ */ jsxRuntimeExports.jsx(
8651 "input",
8652 {
8653 type: "checkbox",
8654 id: "delete_data_on_uninstall",
8655 checked: formData.delete_data_on_uninstall,
8656 name: "delete_data_on_uninstall",
8657 onChange: handleFieldChange,
8658 className: "mt-1 w-4 h-4 rounded border-gray-300 text-red-600 focus:ring-red-500"
8659 }
8660 ),
8661 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8662 /* @__PURE__ */ jsxRuntimeExports.jsx(
8663 Label,
8664 {
8665 htmlFor: "delete_data_on_uninstall",
8666 className: "font-medium cursor-pointer",
8667 children: __("Delete all data on uninstall", "yatra")
8668 }
8669 ),
8670 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8671 "Permanently remove every Yatra database table, setting and scheduled task when the plugin is deleted. Yatra Pro follows the same switch and removes its own data too.",
8672 "yatra"
8673 ) })
8674 ] })
8675 ] }),
8676 formData.delete_data_on_uninstall ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-md border border-red-300 bg-red-50 p-3 dark:border-red-900 dark:bg-red-950/40", children: [
8677 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-red-800 dark:text-red-200", children: __("This cannot be undone", "yatra") }),
8678 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-700 dark:text-red-300 mt-1", children: __(
8679 "Trips, bookings, customers, payments, reviews and enquiries are destroyed along with the plugin. Take a backup, or use Tools to export first, if you may want this data again.",
8680 "yatra"
8681 ) })
8682 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __(
8683 "Your data is kept when Yatra is deleted, so reinstalling restores everything as it was.",
8684 "yatra"
8685 ) })
8686 ] }) });
8687 case "advanced":
8688 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
8689 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
8690 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __(
8691 "For PHP-level debug output, use WordPress wp-config.php (WP_DEBUG). The options below are implemented by the plugin.",
8692 "yatra"
8693 ) }),
8694 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8695 /* @__PURE__ */ jsxRuntimeExports.jsx(
8696 "input",
8697 {
8698 type: "checkbox",
8699 id: "enable_logging",
8700 checked: formData.enable_logging,
8701 name: "enable_logging",
8702 onChange: handleFieldChange,
8703 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8704 }
8705 ),
8706 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8707 /* @__PURE__ */ jsxRuntimeExports.jsx(
8708 Label,
8709 {
8710 htmlFor: "enable_logging",
8711 className: "font-medium cursor-pointer",
8712 children: __("Enable Logging", "yatra")
8713 }
8714 ),
8715 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8716 "Log system events and errors for troubleshooting",
8717 "yatra"
8718 ) })
8719 ] })
8720 ] }),
8721 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8722 /* @__PURE__ */ jsxRuntimeExports.jsx(
8723 "input",
8724 {
8725 type: "checkbox",
8726 id: "debug_mode",
8727 checked: formData.debug_mode,
8728 name: "debug_mode",
8729 onChange: handleFieldChange,
8730 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8731 }
8732 ),
8733 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8734 /* @__PURE__ */ jsxRuntimeExports.jsx(
8735 Label,
8736 {
8737 htmlFor: "debug_mode",
8738 className: "font-medium cursor-pointer",
8739 children: __("Debug mode", "yatra")
8740 }
8741 ),
8742 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8743 "Extra plugin-side diagnostics. When on, Yatra object cache is bypassed (same as when WP_DEBUG is true in wp-config).",
8744 "yatra"
8745 ) })
8746 ] })
8747 ] }),
8748 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8749 /* @__PURE__ */ jsxRuntimeExports.jsx(
8750 "input",
8751 {
8752 type: "checkbox",
8753 id: "cache_enabled",
8754 checked: formData.cache_enabled,
8755 name: "cache_enabled",
8756 onChange: handleFieldChange,
8757 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
8758 }
8759 ),
8760 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
8761 /* @__PURE__ */ jsxRuntimeExports.jsx(
8762 Label,
8763 {
8764 htmlFor: "cache_enabled",
8765 className: "font-medium cursor-pointer",
8766 children: __("Enable Cache", "yatra")
8767 }
8768 ),
8769 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __(
8770 "Stores frequently used data for faster loads. Stays off while WP_DEBUG or Debug mode (above) is on.",
8771 "yatra"
8772 ) })
8773 ] })
8774 ] })
8775 ] }),
8776 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-6", children: [
8777 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: __("Legal pages (Booking UI)", "yatra") }),
8778 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __(
8779 "Select the pages that will be linked from the booking Terms and Privacy consent checkboxes.",
8780 "yatra"
8781 ) }),
8782 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
8783 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
8784 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "terms_page_id", children: __("Terms & Conditions page", "yatra") }),
8785 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8786 "select",
8787 {
8788 id: "terms_page_id",
8789 name: "terms_page_id",
8790 value: formData.terms_page_id || 0,
8791 onChange: handleFieldChange,
8792 className: "mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900",
8793 children: [
8794 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("— Select —", "yatra") }),
8795 pagesData == null ? void 0 : pagesData.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.id, children: p.title }, p.id))
8796 ]
8797 }
8798 )
8799 ] }),
8800 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
8801 /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "privacy_policy_page_id", children: __("Privacy Policy page", "yatra") }),
8802 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8803 "select",
8804 {
8805 id: "privacy_policy_page_id",
8806 name: "privacy_policy_page_id",
8807 value: formData.privacy_policy_page_id || 0,
8808 onChange: handleFieldChange,
8809 className: "mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900",
8810 children: [
8811 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("— Select —", "yatra") }),
8812 pagesData == null ? void 0 : pagesData.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.id, children: p.title }, p.id))
8813 ]
8814 }
8815 ),
8816 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-[11px] text-gray-500 dark:text-gray-400", children: __(
8817 "If not set here, WordPress Settings → Privacy will be used when available.",
8818 "yatra"
8819 ) })
8820 ] })
8821 ] })
8822 ] }),
8823 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-6 mt-6", children: [
8824 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2 flex items-center gap-2", children: [
8825 /* @__PURE__ */ jsxRuntimeExports.jsx(BarChart3, { className: "w-4 h-4" }),
8826 __("Help us improve Yatra", "yatra")
8827 ] }),
8828 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: [
8829 __(
8830 "Share non-sensitive technical details so we can make Yatra better. You can turn this off anytime. See what we collect on our site:",
8831 "yatra"
8832 ),
8833 " ",
8834 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8835 "a",
8836 {
8837 className: "text-blue-600 hover:underline inline-flex items-center gap-0.5",
8838 href: "https://wpyatra.com/what-we-collect/",
8839 target: "_blank",
8840 rel: "noopener noreferrer",
8841 children: [
8842 __("What we collect", "yatra"),
8843 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3", "aria-hidden": true })
8844 ]
8845 }
8846 ),
8847 " · ",
8848 /* @__PURE__ */ jsxRuntimeExports.jsx(
8849 "a",
8850 {
8851 className: "text-blue-600 hover:underline",
8852 href: "https://mantrabrain.com/privacy-policy/",
8853 target: "_blank",
8854 rel: "noopener noreferrer",
8855 children: __("Privacy policy", "yatra")
8856 }
8857 )
8858 ] }),
8859 usageLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-500 flex items-center gap-2", children: [
8860 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }),
8861 __("Loading…", "yatra")
8862 ] }),
8863 !usageLoading && !usageStatus && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
8864 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-amber-600", children: __(
8865 "Could not load this section. You may need permission to manage Yatra.",
8866 "yatra"
8867 ) }),
8868 usageError && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: usageError })
8869 ] }),
8870 !usageLoading && usageStatus && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [
8871 /* @__PURE__ */ jsxRuntimeExports.jsx(
8872 "input",
8873 {
8874 type: "checkbox",
8875 id: "yatra_usage_tracking_enabled",
8876 checked: usageStatus.enabled,
8877 disabled: usageBusy,
8878 onChange: async (e) => {
8879 setUsageBusy(true);
8880 try {
8881 const r = await postUsageTrackingSettings(
8882 e.target.checked
8883 );
8884 setUsageStatus(
8885 (prev) => prev ? { ...prev, enabled: r.enabled } : prev
8886 );
8887 showToast(
8888 __("Preference saved.", "yatra"),
8889 "success"
8890 );
8891 } catch (err) {
8892 showToast(
8893 (err == null ? void 0 : err.message) || __("Could not save your preference.", "yatra"),
8894 "error"
8895 );
8896 } finally {
8897 setUsageBusy(false);
8898 }
8899 },
8900 className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 shrink-0"
8901 }
8902 ),
8903 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-[200px]", children: [
8904 /* @__PURE__ */ jsxRuntimeExports.jsx(
8905 Label,
8906 {
8907 htmlFor: "yatra_usage_tracking_enabled",
8908 className: "font-medium cursor-pointer",
8909 children: __(
8910 "Help us improve the product by sharing non-sensitive data",
8911 "yatra"
8912 )
8913 }
8914 ),
8915 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: [
8916 __(
8917 "Sent periodically while enabled. Learn more: ",
8918 "yatra"
8919 ),
8920 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8921 "a",
8922 {
8923 className: "text-blue-600 hover:underline inline-flex items-center gap-0.5",
8924 href: "https://wpyatra.com/what-we-collect/",
8925 target: "_blank",
8926 rel: "noopener noreferrer",
8927 children: [
8928 __("What we collect", "yatra"),
8929 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3", "aria-hidden": true })
8930 ]
8931 }
8932 )
8933 ] })
8934 ] }),
8935 /* @__PURE__ */ jsxRuntimeExports.jsxs(
8936 Button,
8937 {
8938 type: "button",
8939 variant: "default",
8940 size: "sm",
8941 disabled: usageBusy,
8942 onClick: async () => {
8943 setUsageBusy(true);
8944 try {
8945 await postUsageTrackingSend({
8946 force: !usageStatus.enabled
8947 });
8948 const s = await fetchUsageTrackingStatus();
8949 setUsageStatus(s);
8950 showToast(
8951 __("Sent successfully.", "yatra"),
8952 "success"
8953 );
8954 } catch (err) {
8955 showToast(
8956 (err == null ? void 0 : err.message) || __("Send failed.", "yatra"),
8957 "error"
8958 );
8959 } finally {
8960 setUsageBusy(false);
8961 }
8962 },
8963 children: [
8964 /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 mr-1" }),
8965 __("Send now", "yatra")
8966 ]
8967 }
8968 )
8969 ] }) })
8970 ] })
8971 ] });
8972 default:
8973 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: __("Settings section coming soon", "yatra") });
8974 }
8975 };
8976 if (isLoading) {
8977 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
8978 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
8979 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
8980 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-8 w-48 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }),
8981 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-96 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
8982 ] }),
8983 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
8984 ] }),
8985 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-3", children: [
8986 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "space-y-1 p-2", children: [...Array(12)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
8987 "div",
8988 {
8989 className: "w-full flex items-center gap-3 px-3 py-2.5 rounded-md",
8990 children: [
8991 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-4 h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }),
8992 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
8993 ]
8994 },
8995 `skeleton-nav-${index}`
8996 )) }) }) }) }),
8997 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
8998 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
8999 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-4 h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }),
9000 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
9001 ] }) }),
9002 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "pb-4 space-y-4", children: [
9003 [...Array(6)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
9004 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }),
9005 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
9006 ] }, `skeleton-field-${index}`)),
9007 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-4", children: [...Array(4)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
9008 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }),
9009 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" })
9010 ] }, `skeleton-grid-${index}`)) })
9011 ] })
9012 ] }) })
9013 ] })
9014 ] });
9015 }
9016 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
9017 /* @__PURE__ */ jsxRuntimeExports.jsx(
9018 PageHeader,
9019 {
9020 title: __("Settings", "yatra"),
9021 description: __(
9022 "Configure your travel booking plugin settings",
9023 "yatra"
9024 ),
9025 actions: /* @__PURE__ */ jsxRuntimeExports.jsx(
9026 Button,
9027 {
9028 onClick: handleSave,
9029 disabled: isSaving || !formData,
9030 className: "flex items-center gap-2",
9031 children: isSaving ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
9032 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }),
9033 __("Saving...", "yatra")
9034 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
9035 /* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "w-4 h-4" }),
9036 __("Save Settings", "yatra")
9037 ] })
9038 }
9039 )
9040 }
9041 ),
9042 /* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_manage_settings", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-3", children: [
9043 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "space-y-1 p-2", children: settingsSections.map((section) => {
9044 const Icon = section.icon;
9045 const isViewing = viewingSection === section.id;
9046 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
9047 "button",
9048 {
9049 onClick: () => setViewingSection(section.id),
9050 className: `w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-sm font-medium transition-colors ${isViewing ? "bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400" : "text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700"}`,
9051 children: [
9052 /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { className: "w-4 h-4" }),
9053 section.label
9054 ]
9055 },
9056 section.id
9057 );
9058 }) }) }) }) }),
9059 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
9060 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base flex items-center gap-2", children: (() => {
9061 const section = settingsSections.find(
9062 (s) => s.id === viewingSection
9063 );
9064 const Icon = (section == null ? void 0 : section.icon) || Settings$1;
9065 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
9066 /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { className: "w-4 h-4" }),
9067 (section == null ? void 0 : section.label) || __("Settings", "yatra")
9068 ] });
9069 })() }) }),
9070 /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "pb-4", children: renderSettingsContent() }),
9071 /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex justify-end pt-4 border-t border-gray-100 dark:border-gray-700/50", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
9072 Button,
9073 {
9074 onClick: handleSave,
9075 disabled: isSaving || !formData,
9076 className: "flex items-center gap-2",
9077 children: isSaving ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
9078 /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }),
9079 __("Saving...", "yatra")
9080 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
9081 /* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "w-4 h-4" }),
9082 __("Save Settings", "yatra")
9083 ] })
9084 }
9085 ) })
9086 ] }) })
9087 ] }) }),
9088 /* @__PURE__ */ jsxRuntimeExports.jsx(
9089 PremiumUpgradeDialog,
9090 {
9091 open: showPremiumDialog,
9092 onClose: () => setShowPremiumDialog(false),
9093 moduleName: selectedPremiumGateway,
9094 moduleDescription: `Unlock ${selectedPremiumGateway} payment gateway to accept payments from your customers. This premium gateway provides secure payment processing with advanced features.`,
9095 purchaseUrl: ((_b = window.yatraAdmin) == null ? void 0 : _b.pricingUrl) || "https://wpyatra.com/pricing"
9096 }
9097 )
9098 ] });
9099 };
9100 export {
9101 Settings as default
9102 };
9103 //# sourceMappingURL=Settings-NDffCp8Q.js.map
9104