PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
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 / Reports-JeXttK0I.js

Reports-JeXttK0I.js in Yatra – Travel Booking & Tour Operator Software 3.0.16, at assets/dist/js/Reports-JeXttK0I.js

2,421 lines 139.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { r as reactExports, a6 as React, u as useQuery, j as jsxRuntimeExports } from "./react-vendor-CithbthY.js";
2 import { _ as __, f as formatYatraMoney, u as useToast, d as formatDateForInput, b as apiService, a as apiClient } from "./index-Dec_weLB.js";
3 import { a1 as canCap, B as Button, C as Card, f as CardHeader, g as CardTitle, h as CardDescription, S as Select, d as CardContent, a2 as BookingStatusChart, a3 as BookingsOverviewChart, a4 as isProPluginActive, a5 as isModuleActive, r as unwrapApiPayload } from "../../admin/dist/js/app.js";
4 function isoWeek(d) {
5 const target = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
6 const day = target.getUTCDay() || 7;
7 target.setUTCDate(target.getUTCDate() + 4 - day);
8 const firstThursday = new Date(Date.UTC(target.getUTCFullYear(), 0, 4));
9 const diff = (target.getTime() - firstThursday.getTime()) / 864e5;
10 return {
11 year: target.getUTCFullYear(),
12 week: 1 + Math.floor(diff / 7)
13 };
14 }
15 function parseISO(date) {
16 if (!date) return null;
17 const [y, m, d] = date.split("-").map((s) => parseInt(s, 10));
18 if (!y || !m || !d) return null;
19 return new Date(Date.UTC(y, m - 1, d));
20 }
21 const MONTH_LABELS = [
22 "Jan",
23 "Feb",
24 "Mar",
25 "Apr",
26 "May",
27 "Jun",
28 "Jul",
29 "Aug",
30 "Sep",
31 "Oct",
32 "Nov",
33 "Dec"
34 ];
35 function bucketSeries(points, view) {
36 if (view === "daily" || points.length === 0) {
37 return points;
38 }
39 if (view === "weekly") {
40 const buckets2 = /* @__PURE__ */ new Map();
41 for (const p of points) {
42 const d = parseISO(p.date);
43 if (!d) continue;
44 const { year, week } = isoWeek(d);
45 const key = `${year}-W${week.toString().padStart(2, "0")}`;
46 const existing = buckets2.get(key);
47 if (existing) {
48 existing.value += p.value;
49 } else {
50 buckets2.set(key, {
51 date: p.date,
52 // first-day-in-week anchor; UI rarely needs it
53 label: `W${week} ${MONTH_LABELS[d.getUTCMonth()]}`,
54 value: p.value
55 });
56 }
57 }
58 return Array.from(buckets2.values());
59 }
60 const buckets = /* @__PURE__ */ new Map();
61 for (const p of points) {
62 const d = parseISO(p.date);
63 if (!d) continue;
64 const key = `${d.getUTCFullYear()}-${(d.getUTCMonth() + 1).toString().padStart(2, "0")}`;
65 const existing = buckets.get(key);
66 if (existing) {
67 existing.value += p.value;
68 } else {
69 buckets.set(key, {
70 date: p.date,
71 label: `${MONTH_LABELS[d.getUTCMonth()]} ${d.getUTCFullYear()}`,
72 value: p.value
73 });
74 }
75 }
76 return Array.from(buckets.values());
77 }
78 function bucketStatusSeries(points, view) {
79 if (view === "daily" || points.length === 0) {
80 return points;
81 }
82 const keyFn = (d) => {
83 if (view === "weekly") {
84 const { year, week } = isoWeek(d);
85 return {
86 key: `${year}-W${week.toString().padStart(2, "0")}`,
87 label: `W${week} ${MONTH_LABELS[d.getUTCMonth()]}`
88 };
89 }
90 return {
91 key: `${d.getUTCFullYear()}-${(d.getUTCMonth() + 1).toString().padStart(2, "0")}`,
92 label: `${MONTH_LABELS[d.getUTCMonth()]} ${d.getUTCFullYear()}`
93 };
94 };
95 const buckets = /* @__PURE__ */ new Map();
96 for (const p of points) {
97 const d = parseISO(p.date);
98 if (!d) continue;
99 const { key, label } = keyFn(d);
100 const existing = buckets.get(key);
101 if (existing) {
102 existing.confirmed += p.confirmed;
103 existing.pending += p.pending;
104 existing.cancelled += p.cancelled;
105 existing.completed += p.completed;
106 } else {
107 buckets.set(key, {
108 date: p.date,
109 label,
110 confirmed: p.confirmed,
111 pending: p.pending,
112 cancelled: p.cancelled,
113 completed: p.completed
114 });
115 }
116 }
117 return Array.from(buckets.values());
118 }
119 function buildCsv(rows) {
120 const escape = (v) => {
121 const s = v == null ? "" : String(v);
122 if (/[",\r\n]/.test(s)) {
123 return `"${s.replace(/"/g, '""')}"`;
124 }
125 return s;
126 };
127 const body = rows.map((r) => r.map(escape).join(",")).join("\r\n");
128 return new Blob([body], { type: "text/csv;charset=utf-8" });
129 }
130 function downloadCsv(blob, filename) {
131 const url = URL.createObjectURL(blob);
132 const a = document.createElement("a");
133 a.href = url;
134 a.download = filename;
135 a.style.display = "none";
136 document.body.appendChild(a);
137 a.click();
138 document.body.removeChild(a);
139 setTimeout(() => URL.revokeObjectURL(url), 500);
140 }
141 function csvFilename(slug, from, to) {
142 if (from && to) {
143 return `yatra-${slug}-${from}-to-${to}.csv`;
144 }
145 const now = /* @__PURE__ */ new Date();
146 const today = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, "0")}-${now.getDate().toString().padStart(2, "0")}`;
147 return `yatra-${slug}-${today}.csv`;
148 }
149 const SkeletonCard = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
150 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
151 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse mb-2" }),
152 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-20" })
153 ] }),
154 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-10 h-10 bg-gray-200 dark:bg-gray-700 rounded-lg animate-pulse" })
155 ] }) });
156 const SkeletonReportSection = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
157 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-48" }),
158 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: [...Array(4)].map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-800 rounded-lg", children: [
159 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse mb-2" }),
160 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-16" })
161 ] }, i)) })
162 ] });
163 const SVGIcons = {
164 Calendar: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
165 "svg",
166 {
167 className: "w-6 h-6",
168 fill: "none",
169 stroke: "currentColor",
170 viewBox: "0 0 24 24",
171 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
172 "path",
173 {
174 strokeLinecap: "round",
175 strokeLinejoin: "round",
176 strokeWidth: 2,
177 d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
178 }
179 )
180 }
181 ),
182 DollarSign: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
183 "svg",
184 {
185 className: "w-6 h-6",
186 fill: "none",
187 stroke: "currentColor",
188 viewBox: "0 0 24 24",
189 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
190 "path",
191 {
192 strokeLinecap: "round",
193 strokeLinejoin: "round",
194 strokeWidth: 2,
195 d: "M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"
196 }
197 )
198 }
199 ),
200 MapPin: () => /* @__PURE__ */ jsxRuntimeExports.jsxs(
201 "svg",
202 {
203 className: "w-6 h-6",
204 fill: "none",
205 stroke: "currentColor",
206 viewBox: "0 0 24 24",
207 children: [
208 /* @__PURE__ */ jsxRuntimeExports.jsx(
209 "path",
210 {
211 strokeLinecap: "round",
212 strokeLinejoin: "round",
213 strokeWidth: 2,
214 d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"
215 }
216 ),
217 /* @__PURE__ */ jsxRuntimeExports.jsx(
218 "path",
219 {
220 strokeLinecap: "round",
221 strokeLinejoin: "round",
222 strokeWidth: 2,
223 d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z"
224 }
225 )
226 ]
227 }
228 ),
229 Truck: () => /* @__PURE__ */ jsxRuntimeExports.jsxs(
230 "svg",
231 {
232 className: "w-6 h-6",
233 fill: "none",
234 stroke: "currentColor",
235 viewBox: "0 0 24 24",
236 children: [
237 /* @__PURE__ */ jsxRuntimeExports.jsx(
238 "path",
239 {
240 strokeLinecap: "round",
241 strokeLinejoin: "round",
242 strokeWidth: 2,
243 d: "M9 17a2 2 0 11-4 0 2 2 0 014 0zM21 17a2 2 0 11-4 0 2 2 0 014 0z"
244 }
245 ),
246 /* @__PURE__ */ jsxRuntimeExports.jsx(
247 "path",
248 {
249 strokeLinecap: "round",
250 strokeLinejoin: "round",
251 strokeWidth: 2,
252 d: "M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6"
253 }
254 )
255 ]
256 }
257 ),
258 Users: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
259 "svg",
260 {
261 className: "w-6 h-6",
262 fill: "none",
263 stroke: "currentColor",
264 viewBox: "0 0 24 24",
265 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
266 "path",
267 {
268 strokeLinecap: "round",
269 strokeLinejoin: "round",
270 strokeWidth: 2,
271 d: "M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a4 4 0 11-8 0 4 4 0 018 0z"
272 }
273 )
274 }
275 ),
276 Activity: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
277 "svg",
278 {
279 className: "w-6 h-6",
280 fill: "none",
281 stroke: "currentColor",
282 viewBox: "0 0 24 24",
283 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
284 "path",
285 {
286 strokeLinecap: "round",
287 strokeLinejoin: "round",
288 strokeWidth: 2,
289 d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
290 }
291 )
292 }
293 ),
294 Facebook: () => /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { className: "w-6 h-6", fill: "currentColor", viewBox: "0 0 24 24", 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" }) }),
295 Google: () => /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className: "w-6 h-6", fill: "currentColor", viewBox: "0 0 24 24", children: [
296 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }),
297 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }),
298 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }),
299 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" })
300 ] }),
301 Target: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
302 "svg",
303 {
304 className: "w-6 h-6",
305 fill: "none",
306 stroke: "currentColor",
307 viewBox: "0 0 24 24",
308 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
309 "path",
310 {
311 strokeLinecap: "round",
312 strokeLinejoin: "round",
313 strokeWidth: 2,
314 d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
315 }
316 )
317 }
318 ),
319 BarChart: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
320 "svg",
321 {
322 className: "w-6 h-6",
323 fill: "none",
324 stroke: "currentColor",
325 viewBox: "0 0 24 24",
326 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
327 "path",
328 {
329 strokeLinecap: "round",
330 strokeLinejoin: "round",
331 strokeWidth: 2,
332 d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
333 }
334 )
335 }
336 ),
337 XCircle: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
338 "svg",
339 {
340 className: "w-6 h-6",
341 fill: "none",
342 stroke: "currentColor",
343 viewBox: "0 0 24 24",
344 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
345 "path",
346 {
347 strokeLinecap: "round",
348 strokeLinejoin: "round",
349 strokeWidth: 2,
350 d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
351 }
352 )
353 }
354 )
355 };
356 const TravelReportCategories = [
357 {
358 id: "booking-overview",
359 title: "Booking Overview",
360 icon: "Calendar",
361 description: "Booking volume, status distribution, trends",
362 cap: "yatra_view_operational_reports"
363 },
364 {
365 id: "revenue-analysis",
366 title: "Revenue Analysis",
367 icon: "DollarSign",
368 description: "Revenue trends, payment status, profitability",
369 cap: "yatra_view_financial_reports"
370 },
371 {
372 id: "trip-performance",
373 title: "Trip Performance",
374 icon: "MapPin",
375 description: "Trip popularity, occupancy rates, capacity utilization",
376 cap: "yatra_view_operational_reports"
377 },
378 {
379 id: "departure-management",
380 title: "Departure Management",
381 icon: "Truck",
382 description: "Upcoming departures, capacity planning, scheduling",
383 cap: "yatra_view_departures"
384 },
385 {
386 id: "customer-insights",
387 title: "Customer Insights",
388 icon: "Users",
389 description: "Customer behavior, retention, demographics",
390 cap: "yatra_view_customers"
391 },
392 {
393 id: "operational-metrics",
394 title: "Operational Metrics",
395 icon: "Activity",
396 description: "Lead times, cancellations, efficiency metrics",
397 cap: "yatra_view_operational_reports"
398 },
399 {
400 id: "facebook-pixel",
401 title: "Facebook Pixel",
402 icon: "Facebook",
403 description: "Conversion tracking, event analytics, pixel performance",
404 cap: "yatra_view_operational_reports"
405 },
406 {
407 id: "google-analytics",
408 title: "Google Analytics 4",
409 icon: "Google",
410 description: "Enhanced e-commerce tracking, Measurement Protocol, visitor analytics",
411 cap: "yatra_view_operational_reports"
412 }
413 ];
414 const DetailedBreakdownChart = ({ viewType, selectedCategory, reportData }) => {
415 var _a;
416 const globalCurrency = ((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.currency) || "USD";
417 const formatCurrencyAmount = (amount) => formatYatraMoney(Number(amount) || 0, globalCurrency, {
418 zeroAsUnknown: false
419 });
420 const sourceSeries = reactExports.useMemo(() => {
421 if (!reportData) return [];
422 if (selectedCategory === "revenue-analysis") {
423 return reportData.revenue_trend || [];
424 }
425 if (selectedCategory === "departure-management") {
426 const dep = reportData.departures_table || [];
427 if (Array.isArray(dep) && dep.length > 0) {
428 const byDay = /* @__PURE__ */ new Map();
429 for (const d of dep) {
430 const date = ((d == null ? void 0 : d.date) || "").slice(0, 10);
431 if (!date) continue;
432 byDay.set(date, (byDay.get(date) || 0) + 1);
433 }
434 return Array.from(byDay.entries()).map(([date, value]) => ({
435 date,
436 label: date,
437 value
438 }));
439 }
440 return reportData.booking_trend || [];
441 }
442 return reportData.booking_trend || [];
443 }, [reportData, selectedCategory]);
444 const view = viewType === "weekly" || viewType === "monthly" ? viewType : "daily";
445 const bucketed = reactExports.useMemo(
446 () => bucketSeries(sourceSeries, view),
447 [sourceSeries, view]
448 );
449 if (!reportData || bucketed.length === 0) {
450 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-10 text-center text-sm text-gray-500 dark:text-gray-400", children: __("No data in this period yet.", "yatra") });
451 }
452 const maxValue = Math.max(1, ...bucketed.map((p) => p.value));
453 const isRevenue = selectedCategory === "revenue-analysis";
454 const isDepartures = selectedCategory === "departure-management";
455 const barClass = isRevenue ? "bg-emerald-500" : isDepartures ? "bg-purple-500" : "bg-blue-500";
456 const valueLabel = (v) => isRevenue ? formatCurrencyAmount(v) : v.toLocaleString();
457 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
458 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-gray-900 dark:text-white", children: isRevenue ? __("Revenue Trend", "yatra") : isDepartures ? __("Departures Trend", "yatra") : __("Bookings Trend", "yatra") }) }),
459 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: bucketed.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
460 "div",
461 {
462 className: "flex items-center gap-2",
463 children: [
464 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-20 shrink-0 text-right text-xs text-gray-600 dark:text-gray-400", children: item.label }),
465 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-4 flex-1 rounded-full bg-gray-100 dark:bg-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
466 "div",
467 {
468 className: `flex h-4 items-center justify-end rounded-full pr-1.5 ${barClass}`,
469 style: {
470 width: `${Math.max(2, item.value / maxValue * 100)}%`
471 },
472 children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[11px] font-medium text-white", children: valueLabel(item.value) })
473 }
474 ) })
475 ]
476 },
477 `${item.date}-${index}`
478 )) }),
479 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-xs", children: [
480 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `h-3 w-3 rounded ${barClass}` }),
481 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400", children: isRevenue ? __("Revenue", "yatra") : isDepartures ? __("Departures", "yatra") : __("Bookings", "yatra") })
482 ] })
483 ] });
484 };
485 const DetailedBreakdownTable = ({ viewType, selectedCategory, reportData }) => {
486 var _a;
487 const effectiveView = viewType === "weekly" || viewType === "monthly" ? viewType : "daily";
488 const bookingTrend = (reportData == null ? void 0 : reportData.booking_trend) || [];
489 const revenueTrend = (reportData == null ? void 0 : reportData.revenue_trend) || [];
490 const statusTrend = (reportData == null ? void 0 : reportData.status_trend) || [];
491 (reportData == null ? void 0 : reportData.occupancy_trend) || [];
492 const bookingsBucketed = bucketSeries(bookingTrend, effectiveView);
493 const revenueBucketed = bucketSeries(revenueTrend, effectiveView);
494 const statusBucketed = bucketStatusSeries(statusTrend, effectiveView);
495 const departuresTable = (reportData == null ? void 0 : reportData.departures_table) || [];
496 const occByDay = /* @__PURE__ */ new Map();
497 for (const d of departuresTable) {
498 const date = ((d == null ? void 0 : d.date) || "").slice(0, 10);
499 if (!date) continue;
500 const acc = occByDay.get(date) || { booked: 0, capacity: 0 };
501 acc.booked += Number((d == null ? void 0 : d.bookedSeats) ?? (d == null ? void 0 : d.booked) ?? 0);
502 acc.capacity += Number((d == null ? void 0 : d.maxSeats) ?? (d == null ? void 0 : d.capacity) ?? 0);
503 occByDay.set(date, acc);
504 }
505 const occBookingSeries = Array.from(occByDay.entries()).map(
506 ([date, agg]) => ({ date, label: date, value: agg.booked })
507 );
508 const occCapacitySeries = Array.from(occByDay.entries()).map(
509 ([date, agg]) => ({ date, label: date, value: agg.capacity })
510 );
511 const occBookedBucketed = bucketSeries(occBookingSeries, effectiveView);
512 const occCapacityBucketed = bucketSeries(occCapacitySeries, effectiveView);
513 const breakdownData = bookingsBucketed.map((bRow, i) => {
514 var _a2;
515 const rev = ((_a2 = revenueBucketed[i]) == null ? void 0 : _a2.value) ?? 0;
516 const status = statusBucketed[i];
517 const ob = occBookedBucketed.find((p) => p.label === bRow.label);
518 const oc = occCapacityBucketed.find((p) => p.label === bRow.label);
519 const bookedSeats = (ob == null ? void 0 : ob.value) ?? 0;
520 const capacitySeats = (oc == null ? void 0 : oc.value) ?? 0;
521 const occRate = capacitySeats > 0 ? Math.round(bookedSeats / capacitySeats * 1e3) / 10 : 0;
522 return {
523 period: bRow.label,
524 fullDate: bRow.date,
525 bookings: bRow.value,
526 confirmed: (status == null ? void 0 : status.confirmed) ?? 0,
527 pending: (status == null ? void 0 : status.pending) ?? 0,
528 cancelled: (status == null ? void 0 : status.cancelled) ?? 0,
529 revenue: rev,
530 avgBookingValue: bRow.value > 0 ? Math.round(rev / bRow.value) : 0,
531 occupancyRate: occRate,
532 booked: bookedSeats,
533 capacity: capacitySeats,
534 departures: capacitySeats > 0 ? 1 : 0
535 // count via departures_table when available
536 };
537 });
538 if (departuresTable.length > 0) {
539 const depCountSeries = (() => {
540 const m = /* @__PURE__ */ new Map();
541 for (const d of departuresTable) {
542 const date = ((d == null ? void 0 : d.date) || "").slice(0, 10);
543 if (!date) continue;
544 m.set(date, (m.get(date) || 0) + 1);
545 }
546 return Array.from(m.entries()).map(([date, value]) => ({
547 date,
548 label: date,
549 value
550 }));
551 })();
552 const depBucketed = bucketSeries(depCountSeries, effectiveView);
553 breakdownData.forEach((row) => {
554 const hit = depBucketed.find((p) => p.label === row.period);
555 row.departures = (hit == null ? void 0 : hit.value) ?? 0;
556 });
557 }
558 const globalCurrency = ((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.currency) || "USD";
559 const formatCurrencyAmount = (amount) => formatYatraMoney(Number(amount) || 0, globalCurrency, {
560 zeroAsUnknown: false
561 });
562 const renderTableHeaders = () => {
563 switch (selectedCategory) {
564 case "booking-overview":
565 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
566 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
567 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Total Bookings", "yatra") }),
568 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Confirmed", "yatra") }),
569 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Pending", "yatra") }),
570 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Cancelled", "yatra") })
571 ] });
572 case "revenue-analysis":
573 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
574 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
575 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Total Revenue", "yatra") }),
576 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Bookings", "yatra") }),
577 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Avg Booking Value", "yatra") })
578 ] });
579 case "trip-performance":
580 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
581 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
582 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Trip Bookings", "yatra") }),
583 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Occupancy Rate", "yatra") }),
584 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Revenue", "yatra") })
585 ] });
586 case "departure-management":
587 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
588 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
589 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Departures", "yatra") }),
590 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Total Capacity", "yatra") }),
591 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Booked", "yatra") }),
592 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Utilization", "yatra") })
593 ] });
594 case "customer-insights":
595 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
596 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
597 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("New Customers", "yatra") }),
598 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Returning Customers", "yatra") }),
599 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Satisfaction", "yatra") }),
600 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Total Revenue", "yatra") })
601 ] });
602 case "operational-metrics":
603 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
604 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
605 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Lead Time (days)", "yatra") }),
606 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Cancellation Rate", "yatra") }),
607 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Efficiency", "yatra") }),
608 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Bookings", "yatra") })
609 ] });
610 default:
611 return /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
612 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Period", "yatra") }),
613 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Bookings", "yatra") }),
614 /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider", children: __("Revenue", "yatra") })
615 ] });
616 }
617 };
618 const renderTableRows = () => {
619 return breakdownData.map((row, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "hover:bg-gray-50 dark:hover:bg-gray-800", children: [
620 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white", children: row.period }),
621 selectedCategory === "booking-overview" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
622 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400", children: row.bookings }) }),
623 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/20 text-green-800 dark:text-green-400", children: row.confirmed }) }),
624 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 dark:bg-yellow-900/20 text-yellow-800 dark:text-yellow-400", children: row.pending }) }),
625 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 dark:bg-red-900/20 text-red-800 dark:text-red-400", children: row.cancelled }) })
626 ] }),
627 selectedCategory === "revenue-analysis" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
628 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm font-semibold text-green-600 dark:text-green-400", children: formatCurrencyAmount(row.revenue) }),
629 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400", children: row.bookings }) }),
630 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm font-semibold text-purple-600 dark:text-purple-400", children: formatCurrencyAmount(row.avgBookingValue) })
631 ] }),
632 selectedCategory === "trip-performance" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
633 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400", children: row.bookings }) }),
634 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
635 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-2 mr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
636 "div",
637 {
638 className: "bg-green-500 h-2 rounded-full",
639 style: { width: `${row.occupancyRate}%` }
640 }
641 ) }),
642 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs font-medium", children: [
643 row.occupancyRate,
644 "%"
645 ] })
646 ] }) }),
647 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm font-semibold text-green-600 dark:text-green-400", children: formatCurrencyAmount(row.revenue) })
648 ] }),
649 selectedCategory === "departure-management" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
650 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-900/20 text-purple-800 dark:text-purple-400", children: row.departures }) }),
651 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-300", children: row.capacity }) }),
652 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400", children: row.booked }) }),
653 /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
654 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-2 mr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
655 "div",
656 {
657 className: "bg-green-500 h-2 rounded-full",
658 style: {
659 width: row.capacity > 0 ? `${Math.round(row.booked / row.capacity * 100)}%` : "0%"
660 }
661 }
662 ) }),
663 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs font-medium", children: [
664 row.capacity > 0 ? Math.round(row.booked / row.capacity * 100) : 0,
665 "%"
666 ] })
667 ] }) })
668 ] })
669 ] }, index));
670 };
671 const categoriesWithoutBreakdown = /* @__PURE__ */ new Set([
672 "customer-insights",
673 "operational-metrics"
674 ]);
675 if (categoriesWithoutBreakdown.has(selectedCategory)) {
676 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border border-dashed border-gray-300 dark:border-gray-700 py-10 text-center text-sm text-gray-500 dark:text-gray-400", children: __(
677 "Per-period breakdown isn't available for this section. The summary cards above show the aggregate for the selected date range.",
678 "yatra"
679 ) });
680 }
681 if (breakdownData.length === 0) {
682 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border border-dashed border-gray-300 dark:border-gray-700 py-10 text-center text-sm text-gray-500 dark:text-gray-400", children: __("No data in this date range yet.", "yatra") });
683 }
684 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-auto", children: [
685 /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "min-w-full divide-y divide-gray-200 dark:divide-gray-700", children: [
686 /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { className: "bg-gray-50 dark:bg-gray-800", children: renderTableHeaders() }),
687 /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: renderTableRows() })
688 ] }),
689 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 md:grid-cols-4 gap-4 text-center", children: [
690 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
691 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Total Bookings", "yatra") }),
692 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-bold text-blue-600 dark:text-blue-400", children: breakdownData.reduce((sum, row) => sum + row.bookings, 0) })
693 ] }),
694 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
695 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Total Revenue", "yatra") }),
696 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-bold text-green-600 dark:text-green-400", children: formatCurrencyAmount(
697 breakdownData.reduce((sum, row) => sum + row.revenue, 0)
698 ) })
699 ] }),
700 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
701 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Total Departures", "yatra") }),
702 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-bold text-purple-600 dark:text-purple-400", children: breakdownData.reduce((sum, row) => sum + row.departures, 0) })
703 ] }),
704 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
705 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Avg Occupancy", "yatra") }),
706 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-lg font-bold text-orange-600 dark:text-orange-400", children: [
707 (breakdownData.reduce((sum, row) => sum + row.occupancyRate, 0) / breakdownData.length).toFixed(1),
708 "%"
709 ] })
710 ] })
711 ] }) })
712 ] });
713 };
714 const FacebookPixelReports = () => {
715 var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
716 const [clearingLogs, setClearingLogs] = reactExports.useState(false);
717 const { showToast } = useToast();
718 const {
719 data: freshPixelData,
720 refetch: refetchPixelData,
721 isLoading: isPixelLoading
722 } = useQuery({
723 queryKey: ["facebook-pixel-status"],
724 queryFn: async () => {
725 const response = await apiService.getFacebookPixelSettings();
726 return (response == null ? void 0 : response.data) || {};
727 },
728 refetchInterval: 3e4
729 // Refresh every 30 seconds
730 });
731 const facebookPixelData = freshPixelData || ((_a = window.yatraAdmin) == null ? void 0 : _a.facebookPixel) || {};
732 const getEventStats = () => {
733 const logs = facebookPixelData.eventLogs || [];
734 return {
735 success: logs.filter((log) => log.status === "success").length,
736 errors: logs.filter((log) => log.status === "error").length,
737 total: logs.length
738 };
739 };
740 const getRecentEvents = () => {
741 const logs = facebookPixelData.eventLogs || [];
742 return logs.slice(-10).reverse();
743 };
744 const clearPixelLogs = async () => {
745 setClearingLogs(true);
746 try {
747 const response = await apiService.clearFacebookPixelEventLogs();
748 if (response.success) {
749 showToast(__("Event logs cleared successfully.", "yatra"), "success");
750 await refetchPixelData();
751 }
752 } catch (error) {
753 showToast(error.message || __("Failed to clear logs.", "yatra"), "error");
754 } finally {
755 setClearingLogs(false);
756 }
757 };
758 const eventStats = getEventStats();
759 const recentEvents = getRecentEvents();
760 const fbModuleActive = isProPluginActive() && isModuleActive("facebook_pixel");
761 if (!fbModuleActive || !facebookPixelData.pixel_id) {
762 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-12", children: [
763 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
764 "svg",
765 {
766 className: "w-8 h-8 text-gray-400",
767 fill: "currentColor",
768 viewBox: "0 0 24 24",
769 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" })
770 }
771 ) }),
772 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-white mb-2", children: __("Facebook Pixel Not Configured", "yatra") }),
773 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-600 dark:text-gray-400 mb-4", children: !fbModuleActive ? __(
774 "Enable the Facebook Pixel module under Modules and add your Pixel ID in Settings to start tracking conversion events.",
775 "yatra"
776 ) : __(
777 "Configure your Facebook Pixel in Settings to start tracking conversion events.",
778 "yatra"
779 ) }),
780 /* @__PURE__ */ jsxRuntimeExports.jsx(
781 "a",
782 {
783 href: `${((_b = window.yatraAdmin) == null ? void 0 : _b.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=${!fbModuleActive ? "modules" : "settings#integration"}`,
784 className: "inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",
785 children: !fbModuleActive ? __("Open Modules", "yatra") : __("Configure Facebook Pixel", "yatra")
786 }
787 )
788 ] });
789 }
790 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
791 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
792 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Connection Status", "yatra") }),
793 /* @__PURE__ */ jsxRuntimeExports.jsx(
794 Button,
795 {
796 type: "button",
797 onClick: () => {
798 refetchPixelData();
799 showToast(__("Status refreshed successfully!", "yatra"), "success");
800 },
801 variant: "outline",
802 size: "sm",
803 disabled: isPixelLoading,
804 children: isPixelLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
805 /* @__PURE__ */ jsxRuntimeExports.jsxs(
806 "svg",
807 {
808 className: "animate-spin -ml-1 mr-2 h-4 w-4",
809 fill: "none",
810 viewBox: "0 0 24 24",
811 children: [
812 /* @__PURE__ */ jsxRuntimeExports.jsx(
813 "circle",
814 {
815 className: "opacity-25",
816 cx: "12",
817 cy: "12",
818 r: "10",
819 stroke: "currentColor",
820 strokeWidth: "4"
821 }
822 ),
823 /* @__PURE__ */ jsxRuntimeExports.jsx(
824 "path",
825 {
826 className: "opacity-75",
827 fill: "currentColor",
828 d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
829 }
830 )
831 ]
832 }
833 ),
834 __("Refreshing...", "yatra")
835 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
836 /* @__PURE__ */ jsxRuntimeExports.jsx(
837 "svg",
838 {
839 className: "-ml-1 mr-2 h-4 w-4",
840 fill: "none",
841 viewBox: "0 0 24 24",
842 stroke: "currentColor",
843 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
844 "path",
845 {
846 strokeLinecap: "round",
847 strokeLinejoin: "round",
848 strokeWidth: 2,
849 d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
850 }
851 )
852 }
853 ),
854 __("Refresh Status", "yatra")
855 ] })
856 }
857 )
858 ] }),
859 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
860 /* @__PURE__ */ jsxRuntimeExports.jsx(
861 "div",
862 {
863 className: `p-4 rounded-lg border ${((_c = facebookPixelData.connectionStatus) == null ? void 0 : _c.pixelConnected) ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800" : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800"}`,
864 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
865 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
866 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("Pixel Connection", "yatra") }),
867 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: ((_d = facebookPixelData.connectionStatus) == null ? void 0 : _d.pixelConnected) ? __("Connected", "yatra") : __("Not Connected", "yatra") })
868 ] }),
869 /* @__PURE__ */ jsxRuntimeExports.jsx(
870 "div",
871 {
872 className: `w-8 h-8 rounded-full flex items-center justify-center ${((_e = facebookPixelData.connectionStatus) == null ? void 0 : _e.pixelConnected) ? "bg-green-100 dark:bg-green-900/30" : "bg-red-100 dark:bg-red-900/30"}`,
873 children: ((_f = facebookPixelData.connectionStatus) == null ? void 0 : _f.pixelConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
874 "svg",
875 {
876 className: "w-4 h-4 text-green-600 dark:text-green-400",
877 fill: "none",
878 stroke: "currentColor",
879 viewBox: "0 0 24 24",
880 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
881 "path",
882 {
883 strokeLinecap: "round",
884 strokeLinejoin: "round",
885 strokeWidth: 2,
886 d: "M5 13l4 4L19 7"
887 }
888 )
889 }
890 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
891 "svg",
892 {
893 className: "w-4 h-4 text-red-600 dark:text-red-400",
894 fill: "none",
895 stroke: "currentColor",
896 viewBox: "0 0 24 24",
897 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
898 "path",
899 {
900 strokeLinecap: "round",
901 strokeLinejoin: "round",
902 strokeWidth: 2,
903 d: "M6 18L18 6M6 6l12 12"
904 }
905 )
906 }
907 )
908 }
909 )
910 ] })
911 }
912 ),
913 /* @__PURE__ */ jsxRuntimeExports.jsx(
914 "div",
915 {
916 className: `p-4 rounded-lg border ${((_g = facebookPixelData.connectionStatus) == null ? void 0 : _g.tokenConnected) ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800" : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800"}`,
917 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
918 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
919 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("API Token", "yatra") }),
920 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: ((_h = facebookPixelData.connectionStatus) == null ? void 0 : _h.tokenConnected) ? __("Valid", "yatra") : __("Invalid", "yatra") })
921 ] }),
922 /* @__PURE__ */ jsxRuntimeExports.jsx(
923 "div",
924 {
925 className: `w-8 h-8 rounded-full flex items-center justify-center ${((_i = facebookPixelData.connectionStatus) == null ? void 0 : _i.tokenConnected) ? "bg-green-100 dark:bg-green-900/30" : "bg-red-100 dark:bg-red-900/30"}`,
926 children: ((_j = facebookPixelData.connectionStatus) == null ? void 0 : _j.tokenConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
927 "svg",
928 {
929 className: "w-4 h-4 text-green-600 dark:text-green-400",
930 fill: "none",
931 stroke: "currentColor",
932 viewBox: "0 0 24 24",
933 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
934 "path",
935 {
936 strokeLinecap: "round",
937 strokeLinejoin: "round",
938 strokeWidth: 2,
939 d: "M5 13l4 4L19 7"
940 }
941 )
942 }
943 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
944 "svg",
945 {
946 className: "w-4 h-4 text-red-600 dark:text-red-400",
947 fill: "none",
948 stroke: "currentColor",
949 viewBox: "0 0 24 24",
950 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
951 "path",
952 {
953 strokeLinecap: "round",
954 strokeLinejoin: "round",
955 strokeWidth: 2,
956 d: "M6 18L18 6M6 6l12 12"
957 }
958 )
959 }
960 )
961 }
962 )
963 ] })
964 }
965 ),
966 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "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-center justify-between", children: [
967 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
968 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("Pixel ID", "yatra") }),
969 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: facebookPixelData.pixel_id || __("Not Set", "yatra") })
970 ] }),
971 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
972 "svg",
973 {
974 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
975 fill: "currentColor",
976 viewBox: "0 0 24 24",
977 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" })
978 }
979 ) })
980 ] }) })
981 ] }),
982 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700", children: [
983 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
984 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Event Statistics", "yatra") }),
985 /* @__PURE__ */ jsxRuntimeExports.jsx(
986 Button,
987 {
988 type: "button",
989 onClick: () => clearPixelLogs(),
990 variant: "outline",
991 size: "sm",
992 disabled: clearingLogs,
993 children: clearingLogs ? __("Clearing...", "yatra") : __("Clear Logs", "yatra")
994 }
995 )
996 ] }) }),
997 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-6", children: [
998 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
999 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-green-600 dark:text-green-400", children: eventStats.success }),
1000 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Successful Events", "yatra") })
1001 ] }),
1002 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
1003 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-red-600 dark:text-red-400", children: eventStats.errors }),
1004 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Failed Events", "yatra") })
1005 ] }),
1006 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
1007 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-blue-600 dark:text-blue-400", children: eventStats.total }),
1008 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Total Events", "yatra") })
1009 ] })
1010 ] }) })
1011 ] }),
1012 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700", children: [
1013 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Recent Activity", "yatra") }) }),
1014 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: recentEvents.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: recentEvents.map((log, index) => {
1015 var _a2, _b2, _c2;
1016 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
1017 "div",
1018 {
1019 className: "flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",
1020 children: [
1021 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
1022 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1023 "div",
1024 {
1025 className: `w-8 h-8 rounded-full flex items-center justify-center ${log.status === "success" ? "bg-green-100 dark:bg-green-900/30" : log.status === "error" ? "bg-red-100 dark:bg-red-900/30" : "bg-blue-100 dark:bg-blue-900/30"}`,
1026 children: [
1027 log.status === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1028 "svg",
1029 {
1030 className: "w-4 h-4 text-green-600 dark:text-green-400",
1031 fill: "none",
1032 stroke: "currentColor",
1033 viewBox: "0 0 24 24",
1034 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1035 "path",
1036 {
1037 strokeLinecap: "round",
1038 strokeLinejoin: "round",
1039 strokeWidth: 2,
1040 d: "M5 13l4 4L19 7"
1041 }
1042 )
1043 }
1044 ),
1045 log.status === "error" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1046 "svg",
1047 {
1048 className: "w-4 h-4 text-red-600 dark:text-red-400",
1049 fill: "none",
1050 stroke: "currentColor",
1051 viewBox: "0 0 24 24",
1052 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1053 "path",
1054 {
1055 strokeLinecap: "round",
1056 strokeLinejoin: "round",
1057 strokeWidth: 2,
1058 d: "M6 18L18 6M6 6l12 12"
1059 }
1060 )
1061 }
1062 ),
1063 log.status === "logged" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1064 "svg",
1065 {
1066 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1067 fill: "none",
1068 stroke: "currentColor",
1069 viewBox: "0 0 24 24",
1070 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1071 "path",
1072 {
1073 strokeLinecap: "round",
1074 strokeLinejoin: "round",
1075 strokeWidth: 2,
1076 d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
1077 }
1078 )
1079 }
1080 )
1081 ]
1082 }
1083 ),
1084 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1085 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: log.event_name }),
1086 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: ((_a2 = log.event_data) == null ? void 0 : _a2.trip_name) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1087 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
1088 __("Trip:", "yatra"),
1089 " "
1090 ] }),
1091 ((_b2 = log.event_data) == null ? void 0 : _b2.trip_url) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1092 "a",
1093 {
1094 href: log.event_data.trip_url,
1095 target: "_blank",
1096 rel: "noopener noreferrer",
1097 className: "text-blue-600 hover:text-blue-800 underline",
1098 children: log.event_data.trip_name
1099 }
1100 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: log.event_data.trip_name })
1101 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: log.event_type || "Frontend" }) }),
1102 ((_c2 = log.event_data) == null ? void 0 : _c2.value) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-500", children: [
1103 __("Value:", "yatra"),
1104 " ",
1105 log.event_data.currency || "USD",
1106 " ",
1107 log.event_data.value
1108 ] })
1109 ] })
1110 ] }),
1111 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-right", children: [
1112 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: new Date(log.timestamp).toLocaleTimeString() }),
1113 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-600 dark:text-gray-400", children: new Date(log.timestamp).toLocaleDateString() })
1114 ] })
1115 ]
1116 },
1117 index
1118 );
1119 }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-8", children: [
1120 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-12 h-12 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1121 "svg",
1122 {
1123 className: "w-6 h-6 text-gray-400",
1124 fill: "none",
1125 stroke: "currentColor",
1126 viewBox: "0 0 24 24",
1127 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1128 "path",
1129 {
1130 strokeLinecap: "round",
1131 strokeLinejoin: "round",
1132 strokeWidth: 2,
1133 d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
1134 }
1135 )
1136 }
1137 ) }),
1138 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-white mb-2", children: __("No Events Yet", "yatra") }),
1139 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-600 dark:text-gray-400", children: __(
1140 "Events will appear here once users start interacting with your site.",
1141 "yatra"
1142 ) })
1143 ] }) })
1144 ] }),
1145 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-6", children: [
1146 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Quick Links", "yatra") }),
1147 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1148 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1149 "a",
1150 {
1151 href: `https://www.facebook.com/events_manager2/list/pixel/${facebookPixelData.pixel_id}/test_events`,
1152 target: "_blank",
1153 rel: "noopener noreferrer",
1154 className: "flex items-center gap-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-200 dark:border-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",
1155 children: [
1156 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1157 "svg",
1158 {
1159 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1160 fill: "currentColor",
1161 viewBox: "0 0 24 24",
1162 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" })
1163 }
1164 ) }),
1165 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1166 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: __("Test Events", "yatra") }),
1167 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Facebook Events Manager", "yatra") })
1168 ] })
1169 ]
1170 }
1171 ),
1172 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1173 "a",
1174 {
1175 href: `${((_k = window.yatraAdmin) == null ? void 0 : _k.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=settings#integration`,
1176 className: "flex items-center gap-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-200 dark:border-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",
1177 children: [
1178 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1179 "svg",
1180 {
1181 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1182 fill: "none",
1183 stroke: "currentColor",
1184 viewBox: "0 0 24 24",
1185 children: [
1186 /* @__PURE__ */ jsxRuntimeExports.jsx(
1187 "path",
1188 {
1189 strokeLinecap: "round",
1190 strokeLinejoin: "round",
1191 strokeWidth: 2,
1192 d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
1193 }
1194 ),
1195 /* @__PURE__ */ jsxRuntimeExports.jsx(
1196 "path",
1197 {
1198 strokeLinecap: "round",
1199 strokeLinejoin: "round",
1200 strokeWidth: 2,
1201 d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
1202 }
1203 )
1204 ]
1205 }
1206 ) }),
1207 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1208 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: __("Pixel Settings", "yatra") }),
1209 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Configuration & Options", "yatra") })
1210 ] })
1211 ]
1212 }
1213 )
1214 ] })
1215 ] })
1216 ] });
1217 };
1218 const GoogleAnalyticsReports = () => {
1219 var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1220 const [clearingLogs, setClearingLogs] = reactExports.useState(false);
1221 const { showToast } = useToast();
1222 const {
1223 data: freshGAData,
1224 refetch: refetchGAData,
1225 isLoading: isGALoading
1226 } = useQuery({
1227 queryKey: ["google-analytics-status"],
1228 queryFn: async () => {
1229 const raw = await apiService.getGoogleAnalyticsSettings();
1230 const payload = unwrapApiPayload(raw);
1231 return payload && typeof payload === "object" ? payload : {};
1232 },
1233 refetchInterval: 3e4
1234 // Refresh every 30 seconds
1235 });
1236 const googleAnalyticsData = freshGAData || {};
1237 const getEventStats = () => {
1238 const logs = googleAnalyticsData.eventLogs || [];
1239 return {
1240 success: logs.filter((log) => log.status === "success").length,
1241 errors: logs.filter((log) => log.status === "error").length,
1242 total: logs.length
1243 };
1244 };
1245 const getRecentEvents = () => {
1246 const logs = googleAnalyticsData.eventLogs || [];
1247 return logs.slice(-10).reverse();
1248 };
1249 const clearGALogs = async () => {
1250 setClearingLogs(true);
1251 try {
1252 const raw = await apiService.clearGoogleAnalyticsEventLogs();
1253 if (raw == null ? void 0 : raw.success) {
1254 showToast(__("Event logs cleared successfully.", "yatra"), "success");
1255 await refetchGAData();
1256 }
1257 } catch (error) {
1258 showToast(error.message || __("Failed to clear logs.", "yatra"), "error");
1259 } finally {
1260 setClearingLogs(false);
1261 }
1262 };
1263 const eventStats = getEventStats();
1264 const recentEvents = getRecentEvents();
1265 const gaModuleActive = isProPluginActive() && isModuleActive("google_analytics");
1266 if (!gaModuleActive || !googleAnalyticsData.measurement_id) {
1267 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-12", children: [
1268 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1269 "svg",
1270 {
1271 className: "w-8 h-8 text-gray-400",
1272 fill: "currentColor",
1273 viewBox: "0 0 24 24",
1274 children: [
1275 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }),
1276 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }),
1277 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }),
1278 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" })
1279 ]
1280 }
1281 ) }),
1282 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-white mb-2", children: __("Google Analytics 4 Not Configured", "yatra") }),
1283 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-600 dark:text-gray-400 mb-4", children: !gaModuleActive ? __(
1284 "Enable the Google Analytics 4 module under Modules and add your Measurement ID in Settings to start tracking conversion events.",
1285 "yatra"
1286 ) : __(
1287 "Configure your Google Analytics 4 in Settings to start tracking conversion events.",
1288 "yatra"
1289 ) }),
1290 /* @__PURE__ */ jsxRuntimeExports.jsx(
1291 "a",
1292 {
1293 href: `${((_a = window.yatraAdmin) == null ? void 0 : _a.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=${!gaModuleActive ? "modules" : "settings#integration"}`,
1294 className: "inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",
1295 children: !gaModuleActive ? __("Open Modules", "yatra") : __("Configure Google Analytics 4", "yatra")
1296 }
1297 )
1298 ] });
1299 }
1300 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1301 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
1302 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Connection Status", "yatra") }),
1303 /* @__PURE__ */ jsxRuntimeExports.jsx(
1304 Button,
1305 {
1306 type: "button",
1307 onClick: () => {
1308 refetchGAData();
1309 showToast(__("Status refreshed successfully!", "yatra"), "success");
1310 },
1311 variant: "outline",
1312 size: "sm",
1313 disabled: isGALoading,
1314 children: isGALoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1315 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1316 "svg",
1317 {
1318 className: "animate-spin -ml-1 mr-2 h-4 w-4",
1319 fill: "none",
1320 viewBox: "0 0 24 24",
1321 children: [
1322 /* @__PURE__ */ jsxRuntimeExports.jsx(
1323 "circle",
1324 {
1325 className: "opacity-25",
1326 cx: "12",
1327 cy: "12",
1328 r: "10",
1329 stroke: "currentColor",
1330 strokeWidth: "4"
1331 }
1332 ),
1333 /* @__PURE__ */ jsxRuntimeExports.jsx(
1334 "path",
1335 {
1336 className: "opacity-75",
1337 fill: "currentColor",
1338 d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
1339 }
1340 )
1341 ]
1342 }
1343 ),
1344 __("Refreshing...", "yatra")
1345 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1346 /* @__PURE__ */ jsxRuntimeExports.jsx(
1347 "svg",
1348 {
1349 className: "-ml-1 mr-2 h-4 w-4",
1350 fill: "none",
1351 viewBox: "0 0 24 24",
1352 stroke: "currentColor",
1353 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1354 "path",
1355 {
1356 strokeLinecap: "round",
1357 strokeLinejoin: "round",
1358 strokeWidth: 2,
1359 d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
1360 }
1361 )
1362 }
1363 ),
1364 __("Refresh Status", "yatra")
1365 ] })
1366 }
1367 )
1368 ] }),
1369 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
1370 /* @__PURE__ */ jsxRuntimeExports.jsx(
1371 "div",
1372 {
1373 className: `p-4 rounded-lg border ${((_b = googleAnalyticsData.connectionStatus) == null ? void 0 : _b.measurementConnected) ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800" : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800"}`,
1374 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1375 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1376 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("Measurement ID", "yatra") }),
1377 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: ((_c = googleAnalyticsData.connectionStatus) == null ? void 0 : _c.measurementConnected) ? __("Connected", "yatra") : __("Not Connected", "yatra") })
1378 ] }),
1379 /* @__PURE__ */ jsxRuntimeExports.jsx(
1380 "div",
1381 {
1382 className: `w-8 h-8 rounded-full flex items-center justify-center ${((_d = googleAnalyticsData.connectionStatus) == null ? void 0 : _d.measurementConnected) ? "bg-green-100 dark:bg-green-900/30" : "bg-red-100 dark:bg-red-900/30"}`,
1383 children: ((_e = googleAnalyticsData.connectionStatus) == null ? void 0 : _e.measurementConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1384 "svg",
1385 {
1386 className: "w-4 h-4 text-green-600 dark:text-green-400",
1387 fill: "none",
1388 stroke: "currentColor",
1389 viewBox: "0 0 24 24",
1390 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1391 "path",
1392 {
1393 strokeLinecap: "round",
1394 strokeLinejoin: "round",
1395 strokeWidth: 2,
1396 d: "M5 13l4 4L19 7"
1397 }
1398 )
1399 }
1400 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
1401 "svg",
1402 {
1403 className: "w-4 h-4 text-red-600 dark:text-red-400",
1404 fill: "none",
1405 stroke: "currentColor",
1406 viewBox: "0 0 24 24",
1407 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1408 "path",
1409 {
1410 strokeLinecap: "round",
1411 strokeLinejoin: "round",
1412 strokeWidth: 2,
1413 d: "M6 18L18 6M6 6l12 12"
1414 }
1415 )
1416 }
1417 )
1418 }
1419 )
1420 ] })
1421 }
1422 ),
1423 /* @__PURE__ */ jsxRuntimeExports.jsx(
1424 "div",
1425 {
1426 className: `p-4 rounded-lg border ${((_f = googleAnalyticsData.connectionStatus) == null ? void 0 : _f.apiSecretConnected) ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800" : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800"}`,
1427 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1428 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1429 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("API Secret", "yatra") }),
1430 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: ((_g = googleAnalyticsData.connectionStatus) == null ? void 0 : _g.apiSecretConnected) ? __("Valid", "yatra") : __("Invalid", "yatra") })
1431 ] }),
1432 /* @__PURE__ */ jsxRuntimeExports.jsx(
1433 "div",
1434 {
1435 className: `w-8 h-8 rounded-full flex items-center justify-center ${((_h = googleAnalyticsData.connectionStatus) == null ? void 0 : _h.apiSecretConnected) ? "bg-green-100 dark:bg-green-900/30" : "bg-red-100 dark:bg-red-900/30"}`,
1436 children: ((_i = googleAnalyticsData.connectionStatus) == null ? void 0 : _i.apiSecretConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1437 "svg",
1438 {
1439 className: "w-4 h-4 text-green-600 dark:text-green-400",
1440 fill: "none",
1441 stroke: "currentColor",
1442 viewBox: "0 0 24 24",
1443 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1444 "path",
1445 {
1446 strokeLinecap: "round",
1447 strokeLinejoin: "round",
1448 strokeWidth: 2,
1449 d: "M5 13l4 4L19 7"
1450 }
1451 )
1452 }
1453 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
1454 "svg",
1455 {
1456 className: "w-4 h-4 text-red-600 dark:text-red-400",
1457 fill: "none",
1458 stroke: "currentColor",
1459 viewBox: "0 0 24 24",
1460 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1461 "path",
1462 {
1463 strokeLinecap: "round",
1464 strokeLinejoin: "round",
1465 strokeWidth: 2,
1466 d: "M6 18L18 6M6 6l12 12"
1467 }
1468 )
1469 }
1470 )
1471 }
1472 )
1473 ] })
1474 }
1475 ),
1476 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "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-center justify-between", children: [
1477 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1478 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("Measurement Protocol", "yatra") }),
1479 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 mt-1", children: googleAnalyticsData.use_measurement_protocol ? __("Enabled", "yatra") : __("Disabled", "yatra") })
1480 ] }),
1481 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1482 "svg",
1483 {
1484 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1485 fill: "currentColor",
1486 viewBox: "0 0 24 24",
1487 children: [
1488 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }),
1489 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" })
1490 ]
1491 }
1492 ) })
1493 ] }) })
1494 ] }),
1495 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700", children: [
1496 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1497 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Event Statistics", "yatra") }),
1498 /* @__PURE__ */ jsxRuntimeExports.jsx(
1499 Button,
1500 {
1501 type: "button",
1502 onClick: () => clearGALogs(),
1503 variant: "outline",
1504 size: "sm",
1505 disabled: clearingLogs,
1506 children: clearingLogs ? __("Clearing...", "yatra") : __("Clear Logs", "yatra")
1507 }
1508 )
1509 ] }) }),
1510 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-6", children: [
1511 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
1512 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-green-600 dark:text-green-400", children: eventStats.success }),
1513 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Successful Events", "yatra") })
1514 ] }),
1515 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
1516 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-red-600 dark:text-red-400", children: eventStats.errors }),
1517 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Failed Events", "yatra") })
1518 ] }),
1519 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
1520 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-3xl font-bold text-blue-600 dark:text-blue-400", children: eventStats.total }),
1521 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400 mt-1", children: __("Total Events", "yatra") })
1522 ] })
1523 ] }) })
1524 ] }),
1525 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700", children: [
1526 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Recent Activity", "yatra") }) }),
1527 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: recentEvents.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: recentEvents.map((log, index) => {
1528 var _a2, _b2, _c2;
1529 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
1530 "div",
1531 {
1532 className: "flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",
1533 children: [
1534 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
1535 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1536 "div",
1537 {
1538 className: `w-8 h-8 rounded-full flex items-center justify-center ${log.status === "success" ? "bg-green-100 dark:bg-green-900/30" : log.status === "error" ? "bg-red-100 dark:bg-red-900/30" : "bg-blue-100 dark:bg-blue-900/30"}`,
1539 children: [
1540 log.status === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1541 "svg",
1542 {
1543 className: "w-4 h-4 text-green-600 dark:text-green-400",
1544 fill: "none",
1545 stroke: "currentColor",
1546 viewBox: "0 0 24 24",
1547 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1548 "path",
1549 {
1550 strokeLinecap: "round",
1551 strokeLinejoin: "round",
1552 strokeWidth: 2,
1553 d: "M5 13l4 4L19 7"
1554 }
1555 )
1556 }
1557 ),
1558 log.status === "error" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1559 "svg",
1560 {
1561 className: "w-4 h-4 text-red-600 dark:text-red-400",
1562 fill: "none",
1563 stroke: "currentColor",
1564 viewBox: "0 0 24 24",
1565 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1566 "path",
1567 {
1568 strokeLinecap: "round",
1569 strokeLinejoin: "round",
1570 strokeWidth: 2,
1571 d: "M6 18L18 6M6 6l12 12"
1572 }
1573 )
1574 }
1575 ),
1576 log.status === "logged" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1577 "svg",
1578 {
1579 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1580 fill: "none",
1581 stroke: "currentColor",
1582 viewBox: "0 0 24 24",
1583 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1584 "path",
1585 {
1586 strokeLinecap: "round",
1587 strokeLinejoin: "round",
1588 strokeWidth: 2,
1589 d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
1590 }
1591 )
1592 }
1593 )
1594 ]
1595 }
1596 ),
1597 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1598 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: log.event_name }),
1599 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: ((_a2 = log.event_data) == null ? void 0 : _a2.trip_name) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1600 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
1601 __("Trip:", "yatra"),
1602 " "
1603 ] }),
1604 ((_b2 = log.event_data) == null ? void 0 : _b2.trip_url) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1605 "a",
1606 {
1607 href: log.event_data.trip_url,
1608 target: "_blank",
1609 rel: "noopener noreferrer",
1610 className: "text-blue-600 hover:text-blue-800 underline",
1611 children: log.event_data.trip_name
1612 }
1613 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: log.event_data.trip_name })
1614 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: log.event_type || "Frontend" }) }),
1615 ((_c2 = log.event_data) == null ? void 0 : _c2.value) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-500", children: [
1616 __("Value:", "yatra"),
1617 " ",
1618 log.event_data.currency || "USD",
1619 " ",
1620 log.event_data.value
1621 ] })
1622 ] })
1623 ] }),
1624 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-right", children: [
1625 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: new Date(log.timestamp).toLocaleTimeString() }),
1626 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-600 dark:text-gray-400", children: new Date(log.timestamp).toLocaleDateString() })
1627 ] })
1628 ]
1629 },
1630 index
1631 );
1632 }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-8", children: [
1633 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-12 h-12 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1634 "svg",
1635 {
1636 className: "w-6 h-6 text-gray-400",
1637 fill: "none",
1638 stroke: "currentColor",
1639 viewBox: "0 0 24 24",
1640 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1641 "path",
1642 {
1643 strokeLinecap: "round",
1644 strokeLinejoin: "round",
1645 strokeWidth: 2,
1646 d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
1647 }
1648 )
1649 }
1650 ) }),
1651 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-white mb-2", children: __("No Events Yet", "yatra") }),
1652 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-600 dark:text-gray-400", children: __(
1653 "Events will appear here once users start interacting with your site.",
1654 "yatra"
1655 ) })
1656 ] }) })
1657 ] }),
1658 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-6", children: [
1659 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Quick Links", "yatra") }),
1660 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1661 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1662 "a",
1663 {
1664 href: `https://analytics.google.com/analytics/web/#/debugview`,
1665 target: "_blank",
1666 rel: "noopener noreferrer",
1667 className: "flex items-center gap-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-200 dark:border-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",
1668 children: [
1669 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1670 "svg",
1671 {
1672 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1673 fill: "currentColor",
1674 viewBox: "0 0 24 24",
1675 children: [
1676 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }),
1677 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" })
1678 ]
1679 }
1680 ) }),
1681 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1682 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: __("Debug View", "yatra") }),
1683 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Google Analytics Debug", "yatra") })
1684 ] })
1685 ]
1686 }
1687 ),
1688 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1689 "a",
1690 {
1691 href: `${((_j = window.yatraAdmin) == null ? void 0 : _j.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=settings#integration`,
1692 className: "flex items-center gap-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-200 dark:border-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",
1693 children: [
1694 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1695 "svg",
1696 {
1697 className: "w-4 h-4 text-blue-600 dark:text-blue-400",
1698 fill: "none",
1699 stroke: "currentColor",
1700 viewBox: "0 0 24 24",
1701 children: [
1702 /* @__PURE__ */ jsxRuntimeExports.jsx(
1703 "path",
1704 {
1705 strokeLinecap: "round",
1706 strokeLinejoin: "round",
1707 strokeWidth: 2,
1708 d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
1709 }
1710 ),
1711 /* @__PURE__ */ jsxRuntimeExports.jsx(
1712 "path",
1713 {
1714 strokeLinecap: "round",
1715 strokeLinejoin: "round",
1716 strokeWidth: 2,
1717 d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
1718 }
1719 )
1720 ]
1721 }
1722 ) }),
1723 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1724 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium text-gray-900 dark:text-white", children: __("GA4 Settings", "yatra") }),
1725 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Configuration & Options", "yatra") })
1726 ] })
1727 ]
1728 }
1729 )
1730 ] })
1731 ] })
1732 ] });
1733 };
1734 const TravelBookingReports = () => {
1735 var _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;
1736 const visibleCategories = reactExports.useMemo(
1737 () => TravelReportCategories.filter((c) => canCap(c.cap)),
1738 []
1739 );
1740 const [selectedCategory, setSelectedCategory] = reactExports.useState(
1741 () => {
1742 var _a2;
1743 return ((_a2 = visibleCategories[0]) == null ? void 0 : _a2.id) || "booking-overview";
1744 }
1745 );
1746 const [dateRange, setDateRange] = reactExports.useState("last_30_days");
1747 const [viewType, setViewType] = reactExports.useState("summary");
1748 React.useEffect(() => {
1749 var _a2;
1750 if (!visibleCategories.some((c) => c.id === selectedCategory)) {
1751 const fallback = (_a2 = visibleCategories[0]) == null ? void 0 : _a2.id;
1752 if (fallback) setSelectedCategory(fallback);
1753 }
1754 }, [visibleCategories, selectedCategory]);
1755 const { data: reportData, isLoading } = useQuery({
1756 queryKey: ["yatra-travel-reports", dateRange],
1757 queryFn: async () => {
1758 const params = getDateRangeParams(dateRange);
1759 const response = await apiClient.get(
1760 `/reports?date_from=${params.start}&date_to=${params.end}`
1761 );
1762 return (response == null ? void 0 : response.data) || {};
1763 }
1764 });
1765 function getDateRangeParams(range) {
1766 const today = /* @__PURE__ */ new Date();
1767 const start = /* @__PURE__ */ new Date();
1768 switch (range) {
1769 case "today":
1770 start.setHours(0, 0, 0, 0);
1771 break;
1772 case "last_7_days":
1773 start.setDate(today.getDate() - 7);
1774 break;
1775 case "last_30_days":
1776 start.setDate(today.getDate() - 30);
1777 break;
1778 case "last_90_days":
1779 start.setDate(today.getDate() - 90);
1780 break;
1781 case "this_year":
1782 start.setMonth(0, 1);
1783 break;
1784 default:
1785 start.setDate(today.getDate() - 30);
1786 }
1787 return {
1788 start: formatDateForInput(start),
1789 end: formatDateForInput(today)
1790 };
1791 }
1792 const travelKPIs = reactExports.useMemo(() => {
1793 var _a2, _b2, _c2, _d2, _e2, _f2;
1794 if (!reportData)
1795 return {
1796 totalBookings: 0,
1797 totalRevenue: 0,
1798 occupancyRate: 0,
1799 avgBookingValue: 0,
1800 cancellationRate: 0,
1801 upcomingDepartures: 0
1802 };
1803 return {
1804 totalBookings: ((_a2 = reportData.booking_stats) == null ? void 0 : _a2.total) || 0,
1805 totalRevenue: ((_b2 = reportData.revenue_stats) == null ? void 0 : _b2.total) || 0,
1806 occupancyRate: ((_c2 = reportData.operational_stats) == null ? void 0 : _c2.occupancyRate) || 0,
1807 avgBookingValue: ((_d2 = reportData.revenue_stats) == null ? void 0 : _d2.average) || 0,
1808 cancellationRate: ((_e2 = reportData.booking_stats) == null ? void 0 : _e2.cancellationRate) || 0,
1809 upcomingDepartures: ((_f2 = reportData.operational_stats) == null ? void 0 : _f2.upcomingDepartures) || 0
1810 };
1811 }, [reportData]);
1812 const globalCurrency = ((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.currency) || "USD";
1813 const formatCurrencyAmount = (amount) => formatYatraMoney(Number(amount) || 0, globalCurrency, {
1814 zeroAsUnknown: false
1815 });
1816 const handleExportCsv = () => {
1817 const params = getDateRangeParams(dateRange);
1818 const rows = [];
1819 rows.push(["Yatra Reports — Summary"]);
1820 rows.push([`Date range: ${params.start} to ${params.end}`]);
1821 rows.push([]);
1822 rows.push(["Metric", "Value"]);
1823 rows.push(["Total bookings", travelKPIs.totalBookings]);
1824 rows.push(["Total revenue", travelKPIs.totalRevenue]);
1825 rows.push(["Avg booking value", travelKPIs.avgBookingValue]);
1826 rows.push(["Occupancy rate (%)", travelKPIs.occupancyRate]);
1827 rows.push(["Cancellation rate (%)", travelKPIs.cancellationRate]);
1828 rows.push(["Upcoming departures", travelKPIs.upcomingDepartures]);
1829 rows.push([]);
1830 const trend = (reportData == null ? void 0 : reportData.booking_trend) || [];
1831 const revenueTrend = (reportData == null ? void 0 : reportData.revenue_trend) || [];
1832 if (trend.length) {
1833 rows.push(["Day", "Bookings", "Revenue"]);
1834 trend.forEach((row, i) => {
1835 var _a2;
1836 rows.push([
1837 row.date || row.label,
1838 row.value,
1839 ((_a2 = revenueTrend[i]) == null ? void 0 : _a2.value) ?? ""
1840 ]);
1841 });
1842 rows.push([]);
1843 }
1844 const tp = (reportData == null ? void 0 : reportData.trip_performance) || [];
1845 if (tp.length) {
1846 rows.push(["Trip", "Bookings", "Revenue", "Occupancy %"]);
1847 tp.forEach((t) => {
1848 rows.push([t.label, t.value, t.revenue, t.occupancy]);
1849 });
1850 rows.push([]);
1851 }
1852 const pm = (reportData == null ? void 0 : reportData.payment_methods) || [];
1853 if (pm.length) {
1854 rows.push(["Payment method", "Count", "Revenue"]);
1855 pm.forEach((m) => {
1856 rows.push([m.method, m.count, m.revenue]);
1857 });
1858 rows.push([]);
1859 }
1860 const dest = (reportData == null ? void 0 : reportData.top_destinations) || [];
1861 if (dest.length) {
1862 rows.push(["Destination", "Bookings", "Revenue"]);
1863 dest.forEach((d) => {
1864 rows.push([d.label, d.value, d.revenue]);
1865 });
1866 rows.push([]);
1867 }
1868 const blob = buildCsv(rows);
1869 downloadCsv(blob, csvFilename("reports", params.start, params.end));
1870 };
1871 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1872 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between", children: [
1873 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1874 /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { className: "flex items-center gap-3 text-2xl font-bold text-gray-900 dark:text-white", children: [
1875 /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.BarChart, {}),
1876 __("Travel Booking Reports", "yatra")
1877 ] }),
1878 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __(
1879 "Essential analytics for your travel booking business.",
1880 "yatra"
1881 ) })
1882 ] }),
1883 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
1884 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1885 "select",
1886 {
1887 value: dateRange,
1888 onChange: (e) => setDateRange(e.target.value),
1889 className: "rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white",
1890 "aria-label": __("Date range", "yatra"),
1891 children: [
1892 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "today", children: __("Today", "yatra") }),
1893 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "last_7_days", children: __("Last 7 days", "yatra") }),
1894 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "last_30_days", children: __("Last 30 days", "yatra") }),
1895 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "last_90_days", children: __("Last 90 days", "yatra") }),
1896 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "this_year", children: __("This year", "yatra") })
1897 ]
1898 }
1899 ),
1900 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1901 "select",
1902 {
1903 value: viewType,
1904 onChange: (e) => setViewType(e.target.value),
1905 className: "rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white",
1906 "aria-label": __("Breakdown view", "yatra"),
1907 children: [
1908 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "summary", children: __("Summary View", "yatra") }),
1909 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "daily", children: __("Daily Breakdown", "yatra") }),
1910 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "weekly", children: __("Weekly Breakdown", "yatra") }),
1911 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "monthly", children: __("Monthly Breakdown", "yatra") })
1912 ]
1913 }
1914 ),
1915 /* @__PURE__ */ jsxRuntimeExports.jsx(
1916 Button,
1917 {
1918 type: "button",
1919 variant: "outline",
1920 size: "sm",
1921 onClick: handleExportCsv,
1922 disabled: isLoading || !reportData,
1923 title: __("Download this report's data as CSV", "yatra"),
1924 children: __("Export CSV", "yatra")
1925 }
1926 )
1927 ] })
1928 ] }),
1929 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: [...Array(6)].map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonCard, {}, i)) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1930 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1931 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1932 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Bookings", "yatra") }),
1933 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: travelKPIs.totalBookings })
1934 ] }),
1935 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.Calendar, {}) })
1936 ] }) }),
1937 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1938 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1939 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Revenue", "yatra") }),
1940 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-emerald-600 dark:text-emerald-400", children: formatCurrencyAmount(travelKPIs.totalRevenue) })
1941 ] }),
1942 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.DollarSign, {}) })
1943 ] }) }),
1944 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1945 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1946 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Occupancy Rate", "yatra") }),
1947 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xl font-bold text-purple-600 dark:text-purple-400", children: [
1948 travelKPIs.occupancyRate.toFixed(1),
1949 "%"
1950 ] })
1951 ] }),
1952 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-purple-50 dark:bg-purple-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.Target, {}) })
1953 ] }) }),
1954 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1955 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1956 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Avg Booking Value", "yatra") }),
1957 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-amber-600 dark:text-amber-400", children: formatCurrencyAmount(travelKPIs.avgBookingValue) })
1958 ] }),
1959 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-amber-50 dark:bg-amber-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.BarChart, {}) })
1960 ] }) }),
1961 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1962 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1963 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Cancellation Rate", "yatra") }),
1964 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xl font-bold text-red-600 dark:text-red-400", children: [
1965 travelKPIs.cancellationRate.toFixed(1),
1966 "%"
1967 ] })
1968 ] }),
1969 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-red-50 dark:bg-red-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.XCircle, {}) })
1970 ] }) }),
1971 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1972 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1973 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Upcoming Departures", "yatra") }),
1974 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600 dark:text-blue-400", children: travelKPIs.upcomingDepartures })
1975 ] }),
1976 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.Truck, {}) })
1977 ] }) })
1978 ] }) }),
1979 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
1980 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
1981 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "flex items-center gap-2", children: [
1982 /* @__PURE__ */ jsxRuntimeExports.jsx(SVGIcons.BarChart, {}),
1983 __("Travel Business Reports", "yatra")
1984 ] }),
1985 /* @__PURE__ */ jsxRuntimeExports.jsx(CardDescription, { children: __(
1986 "Comprehensive analytics for your travel booking operations",
1987 "yatra"
1988 ) })
1989 ] }),
1990 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-b border-gray-200 dark:border-gray-700 min-w-0", children: [
1991 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 pt-2 pb-3 md:hidden", children: [
1992 /* @__PURE__ */ jsxRuntimeExports.jsx(
1993 "label",
1994 {
1995 htmlFor: "yatra-report-section-select",
1996 className: "mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400",
1997 children: __("Report section", "yatra")
1998 }
1999 ),
2000 /* @__PURE__ */ jsxRuntimeExports.jsx(
2001 Select,
2002 {
2003 id: "yatra-report-section-select",
2004 value: selectedCategory,
2005 onChange: (e) => setSelectedCategory(e.target.value),
2006 "aria-label": __("Report section", "yatra"),
2007 children: visibleCategories.map((category) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: category.id, children: __(category.title, "yatra") }, category.id))
2008 }
2009 )
2010 ] }),
2011 /* @__PURE__ */ jsxRuntimeExports.jsx(
2012 "nav",
2013 {
2014 className: "hidden md:flex min-w-0 flex-nowrap items-stretch gap-1 overflow-x-auto overflow-y-hidden scroll-smooth px-4 pe-6 pb-1 sm:px-6 sm:pe-8 [scrollbar-width:thin] [-webkit-overflow-scrolling:touch]",
2015 "aria-label": __("Report sections", "yatra"),
2016 children: visibleCategories.map((category) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2017 "button",
2018 {
2019 type: "button",
2020 onClick: () => setSelectedCategory(category.id),
2021 className: `shrink-0 snap-start inline-flex max-w-none items-center gap-2 rounded-t-md border-b-2 px-3 py-3 text-left text-sm font-medium whitespace-nowrap transition-colors sm:px-4 sm:py-3.5 ${selectedCategory === category.id ? "border-blue-500 text-blue-600 dark:text-blue-400 bg-blue-50/60 dark:bg-blue-950/30" : "border-transparent text-gray-600 dark:text-gray-400 hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:border-gray-600 dark:hover:bg-gray-800/50 dark:hover:text-gray-200"}`,
2022 children: [
2023 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex shrink-0 [&_svg]:h-5 [&_svg]:w-5", children: React.createElement(
2024 SVGIcons[category.icon]
2025 ) }),
2026 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-tight", children: __(category.title, "yatra") })
2027 ]
2028 },
2029 category.id
2030 ))
2031 }
2032 )
2033 ] })
2034 ] }),
2035 /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonReportSection, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
2036 selectedCategory === "booking-overview" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
2037 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Booking Overview", "yatra") }),
2038 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: [
2039 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2040 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Confirmed Bookings", "yatra") }),
2041 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-green-600", children: ((_b = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _b.confirmed) || 0 })
2042 ] }),
2043 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2044 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Pending Bookings", "yatra") }),
2045 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-yellow-600", children: ((_c = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _c.pending) || 0 })
2046 ] }),
2047 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2048 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Cancelled Bookings", "yatra") }),
2049 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-red-600", children: ((_d = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _d.cancelled) || 0 })
2050 ] }),
2051 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2052 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __("Completed Bookings", "yatra") }),
2053 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600", children: ((_e = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _e.completed) || 0 })
2054 ] })
2055 ] }),
2056 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: [
2057 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
2058 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { children: __("Booking Status Distribution", "yatra") }) }),
2059 /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2060 BookingStatusChart,
2061 {
2062 data: [
2063 {
2064 label: "Confirmed",
2065 value: ((_f = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _f.confirmed) || 0,
2066 color: "#10b981"
2067 },
2068 {
2069 label: "Pending",
2070 value: ((_g = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _g.pending) || 0,
2071 color: "#f59e0b"
2072 },
2073 {
2074 label: "Cancelled",
2075 value: ((_h = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _h.cancelled) || 0,
2076 color: "#ef4444"
2077 },
2078 {
2079 label: "Completed",
2080 value: ((_i = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _i.completed) || 0,
2081 color: "#3b82f6"
2082 }
2083 ]
2084 }
2085 ) })
2086 ] }),
2087 /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
2088 /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { children: __("Revenue Trend", "yatra") }) }),
2089 /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2090 BookingsOverviewChart,
2091 {
2092 data: (reportData == null ? void 0 : reportData.revenue_trend) || [],
2093 currency: globalCurrency
2094 }
2095 ) })
2096 ] })
2097 ] })
2098 ] }),
2099 selectedCategory === "revenue-analysis" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2100 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: "Revenue Analysis" }),
2101 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
2102 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2103 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Total Revenue" }),
2104 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-green-600", children: formatCurrencyAmount(
2105 ((_j = reportData == null ? void 0 : reportData.revenue_stats) == null ? void 0 : _j.total) || 0
2106 ) })
2107 ] }),
2108 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2109 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Average Booking Value" }),
2110 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600", children: formatCurrencyAmount(
2111 ((_k = reportData == null ? void 0 : reportData.revenue_stats) == null ? void 0 : _k.average) || 0
2112 ) })
2113 ] }),
2114 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2115 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Revenue Lost (Cancellations)" }),
2116 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-red-600", children: formatCurrencyAmount(
2117 ((_l = reportData == null ? void 0 : reportData.cancellations) == null ? void 0 : _l.revenueLost) || 0
2118 ) })
2119 ] })
2120 ] })
2121 ] }),
2122 selectedCategory === "trip-performance" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2123 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: "Trip Performance" }),
2124 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: ((reportData == null ? void 0 : reportData.trip_performance) || []).slice(0, 5).map((trip, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2125 "div",
2126 {
2127 className: "flex justify-between items-center p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",
2128 children: [
2129 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2130 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium text-gray-900 dark:text-white", children: trip.label }),
2131 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: [
2132 trip.value,
2133 " bookings"
2134 ] })
2135 ] }),
2136 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-right", children: [
2137 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-bold text-green-600", children: formatCurrencyAmount(trip.revenue || 0) }),
2138 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Revenue" })
2139 ] })
2140 ]
2141 },
2142 index
2143 )) })
2144 ] }),
2145 selectedCategory === "departure-management" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2146 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: "Departure Management" }),
2147 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
2148 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2149 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Upcoming Departures" }),
2150 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600", children: ((_m = reportData == null ? void 0 : reportData.operational_stats) == null ? void 0 : _m.upcomingDepartures) || 0 })
2151 ] }),
2152 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2153 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Total Capacity" }),
2154 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-purple-600", children: ((_n = reportData == null ? void 0 : reportData.operational_stats) == null ? void 0 : _n.totalCapacity) || 0 })
2155 ] }),
2156 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2157 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Booked Capacity" }),
2158 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-green-600", children: ((_o = reportData == null ? void 0 : reportData.operational_stats) == null ? void 0 : _o.bookedCapacity) || 0 })
2159 ] })
2160 ] })
2161 ] }),
2162 selectedCategory === "customer-insights" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2163 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: "Customer Insights" }),
2164 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-4 gap-4", children: [
2165 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2166 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Total Customers" }),
2167 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600", children: ((_p = reportData == null ? void 0 : reportData.customer_analytics) == null ? void 0 : _p.totalCustomers) || 0 })
2168 ] }),
2169 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2170 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "New Customers" }),
2171 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-green-600", children: ((_q = reportData == null ? void 0 : reportData.customer_analytics) == null ? void 0 : _q.newCustomers) || 0 })
2172 ] }),
2173 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2174 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Returning Customers" }),
2175 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-purple-600", children: ((_r = reportData == null ? void 0 : reportData.customer_analytics) == null ? void 0 : _r.returningCustomers) || 0 })
2176 ] }),
2177 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2178 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Customer Lifetime Value" }),
2179 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-orange-600", children: formatCurrencyAmount(
2180 ((_s = reportData == null ? void 0 : reportData.customer_analytics) == null ? void 0 : _s.customerLifetimeValue) || 0
2181 ) })
2182 ] })
2183 ] })
2184 ] }),
2185 selectedCategory === "operational-metrics" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2186 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: "Operational Metrics" }),
2187 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
2188 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2189 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Occupancy Rate" }),
2190 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xl font-bold text-green-600", children: [
2191 (((_t = reportData == null ? void 0 : reportData.operational_stats) == null ? void 0 : _t.occupancyRate) || 0).toFixed(1),
2192 "%"
2193 ] })
2194 ] }),
2195 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2196 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Average Group Size" }),
2197 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600", children: (((_u = reportData == null ? void 0 : reportData.operational_stats) == null ? void 0 : _u.averageGroupSize) || 0).toFixed(1) })
2198 ] }),
2199 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-700 rounded-lg", children: [
2200 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Cancellation Rate" }),
2201 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xl font-bold text-red-600", children: [
2202 (((_v = reportData == null ? void 0 : reportData.booking_stats) == null ? void 0 : _v.cancellationRate) || 0).toFixed(1),
2203 "%"
2204 ] })
2205 ] })
2206 ] })
2207 ] }),
2208 selectedCategory === "revenue-analysis" && Array.isArray(reportData == null ? void 0 : reportData.payment_methods) && reportData.payment_methods.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6", children: [
2209 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "mb-3 text-lg font-semibold text-gray-900 dark:text-white", children: __("Payment Methods", "yatra") }),
2210 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-3 text-xs text-gray-500 dark:text-gray-400", children: __(
2211 "Bookings and gross revenue split by payment gateway. Ranked by revenue.",
2212 "yatra"
2213 ) }),
2214 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3", children: reportData.payment_methods.slice(0, 6).map((m) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2215 "div",
2216 {
2217 className: "rounded-lg border border-gray-100 bg-white p-3 dark:border-gray-700 dark:bg-gray-800",
2218 children: [
2219 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400", children: m.method }),
2220 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-lg font-semibold tabular-nums text-emerald-600 dark:text-emerald-400", children: formatCurrencyAmount(m.revenue) }),
2221 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: [
2222 m.count,
2223 " ",
2224 __("bookings", "yatra")
2225 ] })
2226 ]
2227 },
2228 m.method
2229 )) })
2230 ] }),
2231 selectedCategory === "trip-performance" && Array.isArray(reportData == null ? void 0 : reportData.top_destinations) && reportData.top_destinations.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6", children: [
2232 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "mb-3 text-lg font-semibold text-gray-900 dark:text-white", children: __("Top Destinations", "yatra") }),
2233 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-3 text-xs text-gray-500 dark:text-gray-400", children: __(
2234 "Booking count and revenue by primary destination. Useful for spotting geographic concentration.",
2235 "yatra"
2236 ) }),
2237 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: reportData.top_destinations.map((d) => {
2238 const max = Math.max(
2239 1,
2240 ...reportData.top_destinations.map(
2241 (x) => x.value
2242 )
2243 );
2244 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2245 "div",
2246 {
2247 className: "flex items-center gap-3",
2248 children: [
2249 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-32 truncate text-sm text-gray-700 dark:text-gray-200", children: d.label }),
2250 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-3 flex-1 rounded-full bg-gray-100 dark:bg-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2251 "div",
2252 {
2253 className: "h-3 rounded-full bg-blue-500",
2254 style: {
2255 width: `${Math.max(2, d.value / max * 100)}%`
2256 }
2257 }
2258 ) }),
2259 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 text-right text-sm tabular-nums text-gray-700 dark:text-gray-200", children: d.value }),
2260 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-24 text-right text-sm font-medium tabular-nums text-emerald-600 dark:text-emerald-400", children: formatCurrencyAmount(d.revenue || 0) })
2261 ]
2262 },
2263 d.label
2264 );
2265 }) })
2266 ] }),
2267 selectedCategory === "operational-metrics" && (reportData == null ? void 0 : reportData.lead_time) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6", children: [
2268 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "mb-3 text-lg font-semibold text-gray-900 dark:text-white", children: __("Booking Lead Time", "yatra") }),
2269 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-3 text-xs text-gray-500 dark:text-gray-400", children: [
2270 __(
2271 "Time between booking creation and travel date. Average:",
2272 "yatra"
2273 ),
2274 " ",
2275 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-medium text-gray-700 dark:text-gray-200", children: [
2276 Number(reportData.lead_time.averageDays || 0).toFixed(
2277 1
2278 ),
2279 " ",
2280 __("days", "yatra")
2281 ] }),
2282 " ",
2283 "(",
2284 reportData.lead_time.sampleSize,
2285 " ",
2286 __("bookings sampled", "yatra"),
2287 ")"
2288 ] }),
2289 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: (reportData.lead_time.buckets || []).map((b) => {
2290 const total = (reportData.lead_time.buckets || []).reduce((s, x) => s + x.value, 0);
2291 const pct = total > 0 ? Math.round(b.value / total * 100) : 0;
2292 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2293 "div",
2294 {
2295 className: "flex items-center gap-3",
2296 children: [
2297 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-44 truncate text-sm text-gray-700 dark:text-gray-200", children: b.label }),
2298 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-3 flex-1 rounded-full bg-gray-100 dark:bg-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2299 "div",
2300 {
2301 className: "h-3 rounded-full",
2302 style: {
2303 width: `${Math.max(2, pct)}%`,
2304 background: b.color || "#3b82f6"
2305 }
2306 }
2307 ) }),
2308 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 text-right text-sm tabular-nums text-gray-700 dark:text-gray-200", children: b.value }),
2309 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-12 text-right text-xs text-gray-500 dark:text-gray-400", children: [
2310 pct,
2311 "%"
2312 ] })
2313 ]
2314 },
2315 b.label
2316 );
2317 }) })
2318 ] }),
2319 selectedCategory === "operational-metrics" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6", children: [
2320 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "mb-3 text-lg font-semibold text-gray-900 dark:text-white", children: __("Refunds", "yatra") }),
2321 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-4", children: [
2322 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-100 bg-white p-3 dark:border-gray-700 dark:bg-gray-800", children: [
2323 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400", children: __("Refunds issued", "yatra") }),
2324 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-lg font-semibold tabular-nums text-red-600 dark:text-red-400", children: ((_w = reportData == null ? void 0 : reportData.refunds) == null ? void 0 : _w.count) ?? 0 })
2325 ] }),
2326 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-100 bg-white p-3 dark:border-gray-700 dark:bg-gray-800", children: [
2327 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400", children: __("Refund total", "yatra") }),
2328 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-lg font-semibold tabular-nums text-red-600 dark:text-red-400", children: formatCurrencyAmount(
2329 Number((_x = reportData == null ? void 0 : reportData.refunds) == null ? void 0 : _x.total) || 0
2330 ) })
2331 ] }),
2332 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-100 bg-white p-3 dark:border-gray-700 dark:bg-gray-800", children: [
2333 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400", children: __("Refund rate", "yatra") }),
2334 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1 text-lg font-semibold tabular-nums text-amber-600 dark:text-amber-400", children: [
2335 Number(((_y = reportData == null ? void 0 : reportData.refunds) == null ? void 0 : _y.refundRate) || 0).toFixed(
2336 1
2337 ),
2338 "%"
2339 ] })
2340 ] }),
2341 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-100 bg-white p-3 dark:border-gray-700 dark:bg-gray-800", children: [
2342 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400", children: __("Avg refund", "yatra") }),
2343 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-lg font-semibold tabular-nums text-gray-700 dark:text-gray-200", children: formatCurrencyAmount(
2344 Number((_z = reportData == null ? void 0 : reportData.refunds) == null ? void 0 : _z.avgRefund) || 0
2345 ) })
2346 ] })
2347 ] })
2348 ] }),
2349 selectedCategory === "facebook-pixel" && /* @__PURE__ */ jsxRuntimeExports.jsx(FacebookPixelReports, {}),
2350 selectedCategory === "google-analytics" && /* @__PURE__ */ jsxRuntimeExports.jsx(GoogleAnalyticsReports, {})
2351 ] }) }) }),
2352 viewType !== "summary" && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "mt-6", children: [
2353 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
2354 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "flex items-center gap-2", children: [
2355 /* @__PURE__ */ jsxRuntimeExports.jsx(
2356 "svg",
2357 {
2358 className: "w-5 h-5",
2359 fill: "none",
2360 stroke: "currentColor",
2361 viewBox: "0 0 24 24",
2362 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2363 "path",
2364 {
2365 strokeLinecap: "round",
2366 strokeLinejoin: "round",
2367 strokeWidth: 2,
2368 d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
2369 }
2370 )
2371 }
2372 ),
2373 __("Detailed", "yatra"),
2374 " ",
2375 viewType.charAt(0).toUpperCase() + viewType.slice(1),
2376 " ",
2377 __("Report", "yatra")
2378 ] }),
2379 /* @__PURE__ */ jsxRuntimeExports.jsxs(CardDescription, { children: [
2380 viewType === "daily" && __(
2381 "Daily breakdown of bookings, revenue, and departures",
2382 "yatra"
2383 ),
2384 viewType === "weekly" && __(
2385 "Weekly breakdown of bookings, revenue, and departures",
2386 "yatra"
2387 ),
2388 viewType === "monthly" && __(
2389 "Monthly breakdown of bookings, revenue, and departures",
2390 "yatra"
2391 )
2392 ] })
2393 ] }),
2394 /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-6", children: [
2395 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2396 DetailedBreakdownTable,
2397 {
2398 viewType,
2399 dateRange,
2400 selectedCategory,
2401 reportData
2402 }
2403 ) }),
2404 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2405 DetailedBreakdownChart,
2406 {
2407 viewType,
2408 dateRange,
2409 selectedCategory,
2410 reportData
2411 }
2412 ) })
2413 ] }) })
2414 ] })
2415 ] });
2416 };
2417 export {
2418 TravelBookingReports as default
2419 };
2420 //# sourceMappingURL=Reports-JeXttK0I.js.map
2421