@oneclick.dev/cms-core-modules 0.0.102 → 0.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/AgendaOpeningHoursCard-B7ROIPWw.js +1 -0
  2. package/dist/AgendaOpeningHoursCard-Cp4wxUeK.mjs +172 -0
  3. package/dist/AppointmentListTable-DZJNmTMb.mjs +177 -0
  4. package/dist/AppointmentListTable-Dieu9US_.js +1 -0
  5. package/dist/{ContentEditor-Cjqgb64R.mjs → ContentEditor-B1nfKG_5.mjs} +706 -677
  6. package/dist/{ContentEditor-YgOS3kxS.js → ContentEditor-DdFU8piH.js} +15 -16
  7. package/dist/{Create-6uT9HWar.mjs → Create-BRBh0xjM.mjs} +2 -2
  8. package/dist/{Create-DuZ5nZrX.js → Create-qPeQxkdl.js} +1 -1
  9. package/dist/{DateFormatter-2B0R-DY4.mjs → DateFormatter-Bw-87W31.mjs} +212 -227
  10. package/dist/DateFormatter-CYAD4GBN.js +1 -0
  11. package/dist/{Detail-BZ-iE9vf.js → Detail-C857g62L.js} +1 -1
  12. package/dist/{Detail-CJVMJDP7.mjs → Detail-CujdFApD.mjs} +2 -2
  13. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-DWMqQvHl.mjs +76 -0
  14. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-kpjbVSXg.js +1 -0
  15. package/dist/{Entries-DkRhOt95.js → Entries-BaS6H6ak.js} +1 -1
  16. package/dist/{Entries-dLlCrXXe.mjs → Entries-C8UJkrVC.mjs} +1 -1
  17. package/dist/{Find-Bd1uLqSa.mjs → Find-B24ZEhYM.mjs} +1 -1
  18. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-Bc946oSc.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-9Q7TMm4u.mjs} +37 -37
  19. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-CqERfyYb.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-DiNzGl-q.js} +1 -1
  20. package/dist/{Overview-DoOASlNz.mjs → Overview-3HWhsqaz.mjs} +2 -2
  21. package/dist/{Overview-37nilXzE.js → Overview-CpHhuiaV.js} +1 -1
  22. package/dist/{Overview-DeQQ0FY3.js → Overview-DAxCu9XC.js} +1 -1
  23. package/dist/{Overview-C--dq51X.mjs → Overview-D_T3K6aq.mjs} +1 -1
  24. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Cz_22Oce.mjs +2927 -0
  25. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-DPPNc-Z5.js +349 -0
  26. package/dist/TableView-CPAw3h8g.js +4 -0
  27. package/dist/TableView-DXmEF6pY.mjs +6143 -0
  28. package/dist/agenda-BNG05SAq.js +1 -0
  29. package/dist/agenda-D1RxMxBS.mjs +1152 -0
  30. package/dist/availability-CMrRa5y2.mjs +269 -0
  31. package/dist/availability-Cf2YfMwM.js +1 -0
  32. package/dist/booking-data-DgJd0BcM.mjs +889 -0
  33. package/dist/booking-data-Di5GmH_8.js +1 -0
  34. package/dist/cms-core-modules.css +1 -1
  35. package/dist/{exceptions-Bp5BSvxO.js → exceptions-CI0B4xVj.js} +1 -1
  36. package/dist/{exceptions-C97cNZYl.mjs → exceptions-vo8SA5SE.mjs} +68 -68
  37. package/dist/index-BtujSJeg.js +35 -0
  38. package/dist/{index-CrGjxSwa.mjs → index-CrgzoTyR.mjs} +1 -1
  39. package/dist/{index-D2a6wEPh.js → index-DPd3waTN.js} +1 -1
  40. package/dist/{index-CABh6Qn6.mjs → index-DrXxXB2F.mjs} +15 -15
  41. package/dist/{index-B-lVEpFX.mjs → index-MYWjg0zi.mjs} +3 -3
  42. package/dist/index-dOdMm1pV.mjs +1105 -0
  43. package/dist/index.cjs.js +1 -1
  44. package/dist/index.mjs +196 -143
  45. package/dist/interpolation-DEDSLETn.mjs +128 -0
  46. package/dist/interpolation-DERg6Lwt.js +1 -0
  47. package/dist/orders-CzzcFQha.mjs +559 -0
  48. package/dist/orders-ETtbA4aQ.js +1 -0
  49. package/dist/{payment-Bosr0m3u.mjs → payment-C3ohkehF.mjs} +1 -1
  50. package/dist/{payment-DDnC03jb.js → payment-Dfr-Ro-a.js} +1 -1
  51. package/dist/{resources-BtF5RUUq.js → resources-CxeFd57z.js} +1 -1
  52. package/dist/{resources-B7qDBC91.mjs → resources-WI_4SO6T.mjs} +2 -2
  53. package/dist/server-handlers.cjs.js +1 -1
  54. package/dist/server-handlers.mjs +457 -387
  55. package/dist/src/appointments/chat-components/AgendaOpeningHoursCard.vue.d.ts +15 -0
  56. package/dist/src/appointments/components/edit/CustomerInformationFieldEditorDialog.vue.d.ts +17 -5
  57. package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +8 -3
  58. package/dist/src/appointments/components/edit/EventDialog/EventDialog.vue.d.ts +1 -0
  59. package/dist/src/appointments/components/edit/EventDialog/ReservationDetailDialog.vue.d.ts +6 -3
  60. package/dist/src/appointments/components/edit/EventTimeline.vue.d.ts +3 -0
  61. package/dist/src/appointments/components/edit/EventView.vue.d.ts +6 -1
  62. package/dist/src/appointments/components/edit/MetadataSchemaEditorDialog.vue.d.ts +12 -0
  63. package/dist/src/appointments/components/edit/OrderMetadataDisplay.vue.d.ts +21 -0
  64. package/dist/src/appointments/components/edit/dashboard/BookingsList.vue.d.ts +8 -3
  65. package/dist/src/appointments/index.d.ts +53 -0
  66. package/dist/src/appointments/pages/edit/agenda.vue.d.ts +3 -1
  67. package/dist/src/appointments/pages/edit/availability.vue.d.ts +1 -26
  68. package/dist/src/appointments/pages/edit/booking-data.vue.d.ts +65 -0
  69. package/dist/src/appointments/pages/edit/orders.vue.d.ts +7 -3
  70. package/dist/src/appointments/tools.d.ts +52 -0
  71. package/dist/src/appointments/types.d.ts +12 -0
  72. package/dist/src/table/config.d.ts +200 -0
  73. package/dist/src/table/get_data_flow-DEFAULT.json.d.ts +129 -0
  74. package/dist/src/table/index.d.ts +200 -0
  75. package/dist/utils-CanmrIWO.mjs +47 -0
  76. package/dist/utils-Yd6F5mea.js +3 -0
  77. package/package.json +2 -2
  78. package/src/appointments/tools.ts +38 -0
  79. package/dist/AppointmentListTable-CQ0WIXtj.js +0 -1
  80. package/dist/AppointmentListTable-aV_UJd6j.mjs +0 -159
  81. package/dist/DateFormatter-DbtOLV0L.js +0 -1
  82. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-DXa-Xxue.mjs +0 -74
  83. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-ozYrxb2g.js +0 -1
  84. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-CL5kbDII.mjs +0 -2782
  85. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-DcyyNvf6.js +0 -349
  86. package/dist/TableView-CIJs118q.mjs +0 -5929
  87. package/dist/TableView-DzZYf34i.js +0 -4
  88. package/dist/agenda-CCOjPiwP.mjs +0 -1133
  89. package/dist/agenda-CNPQfaIQ.js +0 -1
  90. package/dist/availability-B1D4Fyzi.mjs +0 -629
  91. package/dist/availability-DxrUcYbW.js +0 -1
  92. package/dist/index-BOnqrBfY.js +0 -35
  93. package/dist/index-Bj0qaL1N.mjs +0 -1091
  94. package/dist/interpolation-BBwG_ON6.mjs +0 -65
  95. package/dist/interpolation-CsOrww73.js +0 -1
  96. package/dist/orders-BJV5vRQr.mjs +0 -397
  97. package/dist/orders-C1C5IEIP.js +0 -1
  98. package/dist/regular-slots-Cc1jmKuC.mjs +0 -222
  99. package/dist/regular-slots-DBs1XVeN.js +0 -1
  100. package/dist/src/appointments/pages/edit/regular-slots.vue.d.ts +0 -2
  101. package/dist/utils-BVKy9S2J.mjs +0 -29
  102. package/dist/utils-D6CaKJbp.js +0 -2
@@ -1,219 +1,289 @@
1
- import { createRouter as v, defineEventHandler as y, createError as w, getRouterParam as N, getQuery as D } from "h3";
1
+ import { createRouter as v, defineEventHandler as w, createError as y, getRouterParam as q, getQuery as C } from "h3";
2
2
  import "vue";
3
- function $(f) {
4
- const { initFirebase: R, normalizeTimestamps: A } = f, g = v();
5
- async function m(d) {
6
- const { supabase: c, instanceId: l } = d.context.module, { data: e, error: a } = await c.from("project_modules").select("config").eq("id", l).single();
7
- if (a || !e?.config)
8
- throw w({ statusCode: 500, statusMessage: "Failed to load module config." });
9
- const n = e.config, t = n.project, s = n.productCollection || "products";
3
+ function $(h) {
4
+ const { initFirebase: P, normalizeTimestamps: A } = h, g = v();
5
+ async function m(u) {
6
+ const { supabase: i, instanceId: d } = u.context.module, { data: e, error: o } = await i.from("project_modules").select("config").eq("id", d).single();
7
+ if (o || !e?.config)
8
+ throw y({ statusCode: 500, statusMessage: "Failed to load module config." });
9
+ const s = e.config, t = s.project, a = s.productCollection || "products";
10
10
  if (!t)
11
- throw w({ statusCode: 400, statusMessage: "Products module has no Firebase integration configured." });
12
- return { firebase: await R(d, t), collection: s };
11
+ throw y({ statusCode: 400, statusMessage: "Products module has no Firebase integration configured." });
12
+ return { firebase: await P(u, t), collection: a };
13
13
  }
14
- return g.get("/products", y(async (d) => {
14
+ return g.get("/products", w(async (u) => {
15
15
  try {
16
- const { firebase: c, collection: l } = await m(d);
17
- return (await c.firestore().collection(l).get()).docs.map((a) => A({
18
- id: a.id,
19
- ...a.data()
16
+ const { firebase: i, collection: d } = await m(u);
17
+ return (await i.firestore().collection(d).get()).docs.map((o) => A({
18
+ id: o.id,
19
+ ...o.data()
20
20
  }));
21
- } catch (c) {
22
- throw console.error("Products handler — list error:", c), w({
23
- statusCode: c.statusCode || 500,
24
- statusMessage: c.statusMessage || "Failed to list products"
21
+ } catch (i) {
22
+ throw console.error("Products handler — list error:", i), y({
23
+ statusCode: i.statusCode || 500,
24
+ statusMessage: i.statusMessage || "Failed to list products"
25
25
  });
26
26
  }
27
- })), g.get("/products/:productId", y(async (d) => {
28
- const c = N(d, "productId");
29
- if (!c)
30
- throw w({ statusCode: 400, statusMessage: "Product ID is required." });
27
+ })), g.get("/products/:productId", w(async (u) => {
28
+ const i = q(u, "productId");
29
+ if (!i)
30
+ throw y({ statusCode: 400, statusMessage: "Product ID is required." });
31
31
  try {
32
- const { firebase: l, collection: e } = await m(d), a = await l.firestore().collection(e).doc(c).get();
33
- if (!a.exists)
34
- throw w({ statusCode: 404, statusMessage: "Product not found." });
32
+ const { firebase: d, collection: e } = await m(u), o = await d.firestore().collection(e).doc(i).get();
33
+ if (!o.exists)
34
+ throw y({ statusCode: 404, statusMessage: "Product not found." });
35
35
  return A({
36
- id: a.id,
37
- ...a.data()
36
+ id: o.id,
37
+ ...o.data()
38
38
  });
39
- } catch (l) {
40
- throw console.error("Products handler — get error:", l), w({
41
- statusCode: l.statusCode || 500,
42
- statusMessage: l.statusMessage || "Failed to get product"
39
+ } catch (d) {
40
+ throw console.error("Products handler — get error:", d), y({
41
+ statusCode: d.statusCode || 500,
42
+ statusMessage: d.statusMessage || "Failed to get product"
43
43
  });
44
44
  }
45
- })), g.get("/empty-stock", y(async (d) => {
46
- const l = D(d).category;
45
+ })), g.get("/empty-stock", w(async (u) => {
46
+ const d = C(u).category;
47
47
  try {
48
- const { firebase: e, collection: a } = await m(d);
49
- let n = e.firestore().collection(a).where("stock", "==", 0);
50
- l && (n = n.where("collections", "array-contains", l));
51
- const s = (await n.get()).docs.map((o) => A({
52
- id: o.id,
53
- ...o.data()
48
+ const { firebase: e, collection: o } = await m(u);
49
+ let s = e.firestore().collection(o).where("stock", "==", 0);
50
+ d && (s = s.where("collections", "array-contains", d));
51
+ const a = (await s.get()).docs.map((n) => A({
52
+ id: n.id,
53
+ ...n.data()
54
54
  }));
55
55
  return {
56
- count: s.length,
57
- products: s.map((o) => ({
58
- id: o.id,
59
- title: o.title,
60
- slug: o.slug,
61
- stock: o.stock,
62
- price: o.price,
63
- currency: o.currency,
64
- status: o.status
56
+ count: a.length,
57
+ products: a.map((n) => ({
58
+ id: n.id,
59
+ title: n.title,
60
+ slug: n.slug,
61
+ stock: n.stock,
62
+ price: n.price,
63
+ currency: n.currency,
64
+ status: n.status
65
65
  }))
66
66
  };
67
67
  } catch (e) {
68
- throw console.error("Products handler — empty-stock error:", e), w({
68
+ throw console.error("Products handler — empty-stock error:", e), y({
69
69
  statusCode: e.statusCode || 500,
70
70
  statusMessage: e.statusMessage || "Failed to query empty stock"
71
71
  });
72
72
  }
73
73
  })), g.handler;
74
74
  }
75
- function x(f) {
76
- const { initFirebase: R, normalizeTimestamps: A } = f, g = v();
77
- async function m(c) {
78
- const { supabase: l, instanceId: e } = c.context.module, { data: a, error: n } = await l.from("project_modules").select("config").eq("id", e).single();
79
- if (n || !a?.config)
80
- throw w({ statusCode: 500, statusMessage: "Failed to load module config." });
81
- const t = a.config, s = t.project, o = t.reservationsCollection || "bookings_orders", r = t.agendaCollection || "agendas";
82
- if (!s)
83
- throw w({ statusCode: 400, statusMessage: "Appointments module has no Firebase integration configured." });
84
- return { firebase: await R(c, s), reservationsCollection: o, agendaCollection: r };
75
+ function x(h) {
76
+ const { initFirebase: P, normalizeTimestamps: A } = h, g = v();
77
+ async function m(i) {
78
+ const { supabase: d, instanceId: e } = i.context.module, { data: o, error: s } = await d.from("project_modules").select("config").eq("id", e).single();
79
+ if (s || !o?.config)
80
+ throw y({ statusCode: 500, statusMessage: "Failed to load module config." });
81
+ const t = o.config, a = t.project, n = t.reservationsCollection || "bookings_orders", r = t.agendaCollection || "agendas";
82
+ if (!a)
83
+ throw y({ statusCode: 400, statusMessage: "Appointments module has no Firebase integration configured." });
84
+ return { firebase: await P(i, a), reservationsCollection: n, agendaCollection: r };
85
85
  }
86
- function d(c) {
87
- return (c.reservations || []).map((e) => ({
88
- orderId: c.id,
86
+ function u(i) {
87
+ return (i.reservations || []).map((e) => ({
88
+ orderId: i.id,
89
89
  reservationId: e.id,
90
- customerInfo: c.customerInfo,
90
+ customerInfo: i.customerInfo,
91
91
  date: e.date,
92
92
  startTime: e.timeslot?.startTime,
93
93
  endTime: e.timeslot?.endTime,
94
94
  spots: e.spots,
95
- status: c.status,
95
+ status: i.status,
96
96
  reservationStatus: e.status,
97
97
  resourceId: e.resourceId,
98
98
  reservationPrice: e.totalPrice,
99
99
  reservationBasePrice: e.basePrice,
100
100
  reservationAddOnsPrice: e.addOnsPrice,
101
101
  pricingOption: e.pricingOption,
102
- amountDue: c.amountDue,
103
- amountPaid: c.amountPaid,
104
- createdAt: c.createdAt
102
+ amountDue: i.amountDue,
103
+ amountPaid: i.amountPaid,
104
+ createdAt: i.createdAt,
105
+ metadata: i.metadata || {},
106
+ reservationMetadata: e.metadata || {}
105
107
  }));
106
108
  }
107
- return g.get("/appointments", y(async (c) => {
108
- const l = D(c), e = Math.min(Number(l.quantity) || 20, 100);
109
+ return g.get("/agendas", w(async (i) => {
109
110
  try {
110
- const { firebase: a, reservationsCollection: n } = await m(c), s = (await a.firestore().collection(n).orderBy("createdAt", "desc").limit(e).get()).docs.flatMap(
111
- (o) => d(A({ id: o.id, ...o.data() }))
112
- );
111
+ const { firebase: d, agendaCollection: e } = await m(i), s = (await d.firestore().collection(e).get()).docs.map((t) => {
112
+ const a = t.data();
113
+ return {
114
+ id: t.id,
115
+ serviceName: a.serviceName || "",
116
+ type: a.type || "regular"
117
+ };
118
+ });
113
119
  return {
114
120
  count: s.length,
115
- appointments: s
121
+ agendas: s
122
+ };
123
+ } catch (d) {
124
+ throw console.error("Appointments handler — list agendas error:", d), y({
125
+ statusCode: d.statusCode || 500,
126
+ statusMessage: d.statusMessage || "Failed to list agendas"
127
+ });
128
+ }
129
+ })), g.get("/agendas/:agendaId/opening-hours", w(async (i) => {
130
+ const d = q(i, "agendaId"), o = C(i).date;
131
+ if (!d)
132
+ throw y({ statusCode: 400, statusMessage: "Agenda ID is required." });
133
+ if (!o)
134
+ throw y({ statusCode: 400, statusMessage: "Date is required (YYYY-MM-DD)." });
135
+ try {
136
+ const { firebase: s, agendaCollection: t } = await m(i), a = await s.firestore().collection(t).doc(d).get();
137
+ if (!a.exists)
138
+ throw y({ statusCode: 404, statusMessage: "Agenda not found." });
139
+ const n = a.data(), r = (n.resources || []).filter((f) => f.isActive), c = n.exceptions || [], p = (/* @__PURE__ */ new Date(o + "T00:00:00")).getDay(), D = r.map((f) => {
140
+ const R = f.openingHours?.[p] || [], I = c.find((S) => {
141
+ const b = o >= S.startDate && o <= S.endDate, M = !S.resourceIds || S.resourceIds.length === 0 || S.resourceIds.includes(f.id);
142
+ return b && M;
143
+ });
144
+ return I ? {
145
+ resourceId: f.id,
146
+ resourceName: f.name,
147
+ date: o,
148
+ dayOfWeek: p,
149
+ isClosed: I.isClosed,
150
+ hours: I.isClosed ? [] : (I.timeslots || []).map((S) => ({
151
+ start: S.startTime,
152
+ end: S.endTime
153
+ })),
154
+ isException: !0
155
+ } : {
156
+ resourceId: f.id,
157
+ resourceName: f.name,
158
+ date: o,
159
+ dayOfWeek: p,
160
+ isClosed: R.length === 0,
161
+ hours: R,
162
+ isException: !1
163
+ };
164
+ });
165
+ return {
166
+ agendaId: d,
167
+ serviceName: n.serviceName || "",
168
+ date: o,
169
+ resources: D
170
+ };
171
+ } catch (s) {
172
+ throw console.error("Appointments handler — opening hours error:", s), y({
173
+ statusCode: s.statusCode || 500,
174
+ statusMessage: s.statusMessage || "Failed to get opening hours"
175
+ });
176
+ }
177
+ })), g.get("/appointments", w(async (i) => {
178
+ const d = C(i), e = Math.min(Number(d.quantity) || 20, 100), o = d.status || "confirmed";
179
+ try {
180
+ const { firebase: s, reservationsCollection: t } = await m(i), n = (await s.firestore().collection(t).orderBy("createdAt", "desc").where("status", "==", o).limit(e).get()).docs.flatMap(
181
+ (r) => u(A({ id: r.id, ...r.data() }))
182
+ );
183
+ return {
184
+ count: n.length,
185
+ appointments: n
116
186
  };
117
- } catch (a) {
118
- throw console.error("Appointments handler — list error:", a), w({
119
- statusCode: a.statusCode || 500,
120
- statusMessage: a.statusMessage || "Failed to list appointments"
187
+ } catch (s) {
188
+ throw console.error("Appointments handler — list error:", s), y({
189
+ statusCode: s.statusCode || 500,
190
+ statusMessage: s.statusMessage || "Failed to list appointments"
121
191
  });
122
192
  }
123
- })), g.get("/appointments/find", y(async (c) => {
124
- const l = D(c), e = (l.name || "").toLowerCase().trim(), a = (l.email || "").toLowerCase().trim(), n = l.date;
193
+ })), g.get("/appointments/find", w(async (i) => {
194
+ const d = C(i), e = (d.name || "").toLowerCase().trim(), o = (d.email || "").toLowerCase().trim(), s = d.date;
125
195
  try {
126
- const { firebase: t, reservationsCollection: s } = await m(c);
127
- let o = t.firestore().collection(s);
128
- a && (o = o.where("customerInfo.email", "==", a));
129
- let i = (await o.orderBy("createdAt", "desc").limit(200).get()).docs.flatMap(
130
- (u) => d(A({ id: u.id, ...u.data() }))
196
+ const { firebase: t, reservationsCollection: a } = await m(i);
197
+ let n = t.firestore().collection(a);
198
+ o && (n = n.where("customerInfo.email", "==", o));
199
+ let c = (await n.orderBy("createdAt", "desc").limit(200).get()).docs.flatMap(
200
+ (l) => u(A({ id: l.id, ...l.data() }))
131
201
  );
132
- return n && (i = i.filter((u) => u.date === n)), e && (i = i.filter((u) => {
133
- const p = (u.customerInfo?.firstName || "").toLowerCase(), h = (u.customerInfo?.lastName || "").toLowerCase();
134
- return p.includes(e) || h.includes(e) || `${p} ${h}`.includes(e);
202
+ return s && (c = c.filter((l) => l.date === s)), e && (c = c.filter((l) => {
203
+ const p = (l.customerInfo?.firstName || "").toLowerCase(), D = (l.customerInfo?.lastName || "").toLowerCase();
204
+ return p.includes(e) || D.includes(e) || `${p} ${D}`.includes(e);
135
205
  })), {
136
- count: i.length,
137
- appointments: i
206
+ count: c.length,
207
+ appointments: c
138
208
  };
139
209
  } catch (t) {
140
- throw console.error("Appointments handler — find error:", t), w({
210
+ throw console.error("Appointments handler — find error:", t), y({
141
211
  statusCode: t.statusCode || 500,
142
212
  statusMessage: t.statusMessage || "Failed to find appointments"
143
213
  });
144
214
  }
145
- })), g.get("/appointments/:appointmentId", y(async (c) => {
146
- const l = N(c, "appointmentId");
147
- if (!l)
148
- throw w({ statusCode: 400, statusMessage: "Appointment ID is required." });
215
+ })), g.get("/appointments/:appointmentId", w(async (i) => {
216
+ const d = q(i, "appointmentId");
217
+ if (!d)
218
+ throw y({ statusCode: 400, statusMessage: "Appointment ID is required." });
149
219
  try {
150
- const { firebase: e, reservationsCollection: a } = await m(c), n = await e.firestore().collection(a).doc(l).get();
151
- if (!n.exists)
152
- throw w({ statusCode: 404, statusMessage: "Appointment not found." });
153
- const t = A({ id: n.id, ...n.data() });
220
+ const { firebase: e, reservationsCollection: o } = await m(i), s = await e.firestore().collection(o).doc(d).get();
221
+ if (!s.exists)
222
+ throw y({ statusCode: 404, statusMessage: "Appointment not found." });
223
+ const t = A({ id: s.id, ...s.data() });
154
224
  return {
155
225
  ...t,
156
- reservations: d(t)
226
+ reservations: u(t)
157
227
  };
158
228
  } catch (e) {
159
- throw console.error("Appointments handler — get error:", e), w({
229
+ throw console.error("Appointments handler — get error:", e), y({
160
230
  statusCode: e.statusCode || 500,
161
231
  statusMessage: e.statusMessage || "Failed to get appointment"
162
232
  });
163
233
  }
164
234
  })), g.handler;
165
235
  }
166
- const M = "https://analyticsdata.googleapis.com/v1beta", F = [
236
+ const T = "https://analyticsdata.googleapis.com/v1beta", V = [
167
237
  "https://www.googleapis.com/auth/analytics.readonly",
168
238
  "https://www.googleapis.com/auth/webmasters.readonly"
169
- ], b = "https://searchconsole.googleapis.com/webmasters/v3";
170
- function G(f) {
171
- const { decrypt: R, getGoogleAccessToken: A } = f, g = v();
239
+ ], N = "https://searchconsole.googleapis.com/webmasters/v3";
240
+ function G(h) {
241
+ const { decrypt: P, getGoogleAccessToken: A } = h, g = v();
172
242
  async function m(e) {
173
- const { supabase: a, instanceId: n } = e.context.module, { data: t, error: s } = await a.from("project_modules").select("config").eq("id", n).single();
174
- if (s || !t?.config)
175
- throw w({ statusCode: 500, statusMessage: "Failed to load module config." });
176
- const o = t.config, r = o.propertyId, i = o.serviceAccount, u = o.siteUrl || "";
177
- if (!i)
178
- throw w({ statusCode: 400, statusMessage: "No Google Service Account configured for this module." });
243
+ const { supabase: o, instanceId: s } = e.context.module, { data: t, error: a } = await o.from("project_modules").select("config").eq("id", s).single();
244
+ if (a || !t?.config)
245
+ throw y({ statusCode: 500, statusMessage: "Failed to load module config." });
246
+ const n = t.config, r = n.propertyId, c = n.serviceAccount, l = n.siteUrl || "";
247
+ if (!c)
248
+ throw y({ statusCode: 400, statusMessage: "No Google Service Account configured for this module." });
179
249
  if (!r)
180
- throw w({ statusCode: 400, statusMessage: "No GA4 Property ID configured for this module." });
181
- const { data: p, error: h } = await a.from("integrations").select("config").eq("id", i).single();
182
- let C = p?.config;
183
- if (h || !C) {
184
- const { data: q, error: U } = await a.from("agency_integrations").select("config").eq("id", i).single();
185
- if (U || !q?.config)
186
- throw w({ statusCode: 500, statusMessage: "Failed to load Google Service Account credentials." });
187
- C = q.config;
250
+ throw y({ statusCode: 400, statusMessage: "No GA4 Property ID configured for this module." });
251
+ const { data: p, error: D } = await o.from("integrations").select("config").eq("id", c).single();
252
+ let f = p?.config;
253
+ if (D || !f) {
254
+ const { data: M, error: F } = await o.from("agency_integrations").select("config").eq("id", c).single();
255
+ if (F || !M?.config)
256
+ throw y({ statusCode: 500, statusMessage: "Failed to load Google Service Account credentials." });
257
+ f = M.config;
188
258
  }
189
- const k = R(C.clientEmail), P = R(C.privateKey), S = R(C.projectId);
259
+ const R = P(f.clientEmail), I = P(f.privateKey), S = P(f.projectId);
190
260
  return { accessToken: await A(
191
- { clientEmail: k, privateKey: P, projectId: S },
192
- F
193
- ), propertyId: r, siteUrl: u };
261
+ { clientEmail: R, privateKey: I, projectId: S },
262
+ V
263
+ ), propertyId: r, siteUrl: l };
194
264
  }
195
- async function d(e, a, n) {
196
- const t = await fetch(`${M}/properties/${a}:runReport`, {
265
+ async function u(e, o, s) {
266
+ const t = await fetch(`${T}/properties/${o}:runReport`, {
197
267
  method: "POST",
198
268
  headers: {
199
269
  Authorization: `Bearer ${e}`,
200
270
  "Content-Type": "application/json"
201
271
  },
202
- body: JSON.stringify(n)
272
+ body: JSON.stringify(s)
203
273
  });
204
274
  if (!t.ok) {
205
- const s = await t.json().catch(() => ({}));
206
- throw console.error("GA4 runReport failed:", s), w({
275
+ const a = await t.json().catch(() => ({}));
276
+ throw console.error("GA4 runReport failed:", a), y({
207
277
  statusCode: t.status,
208
- statusMessage: s?.error?.message || "GA4 API request failed"
278
+ statusMessage: a?.error?.message || "GA4 API request failed"
209
279
  });
210
280
  }
211
281
  return t.json();
212
282
  }
213
283
  g.get(
214
284
  "/report",
215
- y(async (e) => {
216
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = s.match(/^(\d+)daysAgo$/), i = r ? parseInt(r[1], 10) : 30, u = `${i * 2}daysAgo`, p = `${i + 1}daysAgo`, h = [
285
+ w(async (e) => {
286
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = a.match(/^(\d+)daysAgo$/), c = r ? parseInt(r[1], 10) : 30, l = `${c * 2}daysAgo`, p = `${c + 1}daysAgo`, D = [
217
287
  { name: "sessions" },
218
288
  { name: "totalUsers" },
219
289
  { name: "screenPageViews" },
@@ -224,38 +294,38 @@ function G(f) {
224
294
  { name: "sessionsPerUser" },
225
295
  { name: "screenPageViewsPerSession" }
226
296
  ];
227
- let C, k = !0;
297
+ let f, R = !0;
228
298
  try {
229
- C = await d(a, n, {
299
+ f = await u(o, s, {
230
300
  dateRanges: [
231
- { startDate: s, endDate: o, name: "current" },
232
- { startDate: u, endDate: p, name: "previous" }
301
+ { startDate: a, endDate: n, name: "current" },
302
+ { startDate: l, endDate: p, name: "previous" }
233
303
  ],
234
304
  dimensions: [{ name: "date" }],
235
- metrics: h,
305
+ metrics: D,
236
306
  metricAggregations: ["TOTAL"],
237
307
  orderBys: [{ dimension: { dimensionName: "date" } }]
238
308
  });
239
309
  } catch {
240
- k = !1, C = await d(a, n, {
241
- dateRanges: [{ startDate: s, endDate: o }],
310
+ R = !1, f = await u(o, s, {
311
+ dateRanges: [{ startDate: a, endDate: n }],
242
312
  dimensions: [{ name: "date" }],
243
- metrics: h,
313
+ metrics: D,
244
314
  metricAggregations: ["TOTAL"],
245
315
  orderBys: [{ dimension: { dimensionName: "date" } }]
246
316
  });
247
317
  }
248
- return V(C, k);
318
+ return E(f, R);
249
319
  })
250
320
  ), g.get(
251
321
  "/realtime",
252
- y(async (e) => {
253
- const { accessToken: a, propertyId: n } = await m(e), t = await fetch(
254
- `${M}/properties/${n}:runRealtimeReport`,
322
+ w(async (e) => {
323
+ const { accessToken: o, propertyId: s } = await m(e), t = await fetch(
324
+ `${T}/properties/${s}:runRealtimeReport`,
255
325
  {
256
326
  method: "POST",
257
327
  headers: {
258
- Authorization: `Bearer ${a}`,
328
+ Authorization: `Bearer ${o}`,
259
329
  "Content-Type": "application/json"
260
330
  },
261
331
  body: JSON.stringify({
@@ -267,23 +337,23 @@ function G(f) {
267
337
  }
268
338
  );
269
339
  if (!t.ok) {
270
- const i = await t.json().catch(() => ({}));
271
- throw w({ statusCode: t.status, statusMessage: i?.error?.message || "Realtime API failed" });
340
+ const c = await t.json().catch(() => ({}));
341
+ throw y({ statusCode: t.status, statusMessage: c?.error?.message || "Realtime API failed" });
272
342
  }
273
- const s = await t.json(), o = (s?.rows || []).reduce(
274
- (i, u) => i + parseInt(u.metricValues?.[0]?.value || "0", 10),
343
+ const a = await t.json(), n = (a?.rows || []).reduce(
344
+ (c, l) => c + parseInt(l.metricValues?.[0]?.value || "0", 10),
275
345
  0
276
- ), r = (s?.rows || []).map((i) => ({
277
- page: i.dimensionValues?.[0]?.value || "(not set)",
278
- activeUsers: parseInt(i.metricValues?.[0]?.value || "0", 10)
346
+ ), r = (a?.rows || []).map((c) => ({
347
+ page: c.dimensionValues?.[0]?.value || "(not set)",
348
+ activeUsers: parseInt(c.metricValues?.[0]?.value || "0", 10)
279
349
  }));
280
- return { activeUsers: o, activePages: r };
350
+ return { activeUsers: n, activePages: r };
281
351
  })
282
352
  ), g.get(
283
353
  "/top-pages",
284
- y(async (e) => {
285
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = parseInt(t.limit || "10", 10), i = await d(a, n, {
286
- dateRanges: [{ startDate: s, endDate: o }],
354
+ w(async (e) => {
355
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = parseInt(t.limit || "10", 10), c = await u(o, s, {
356
+ dateRanges: [{ startDate: a, endDate: n }],
287
357
  dimensions: [{ name: "pagePath" }],
288
358
  metrics: [
289
359
  { name: "screenPageViews" },
@@ -293,23 +363,23 @@ function G(f) {
293
363
  orderBys: [{ metric: { metricName: "screenPageViews" }, desc: !0 }],
294
364
  limit: r * 2
295
365
  // fetch extra to account for duplicates before aggregation
296
- }), u = I(i, "pagePath"), p = /* @__PURE__ */ new Map();
297
- for (const C of u.rows) {
298
- const k = C.pagePath.toLowerCase().replace(/\/+$/, ""), P = p.get(k);
299
- if (P) {
300
- P.screenPageViews += C.screenPageViews || 0, P.totalUsers += C.totalUsers || 0;
301
- const S = P.screenPageViews;
302
- S > 0 && (P.averageSessionDuration = (P.averageSessionDuration * (S - (C.screenPageViews || 0)) + (C.averageSessionDuration || 0) * (C.screenPageViews || 0)) / S);
366
+ }), l = k(c, "pagePath"), p = /* @__PURE__ */ new Map();
367
+ for (const f of l.rows) {
368
+ const R = f.pagePath.toLowerCase().replace(/\/+$/, ""), I = p.get(R);
369
+ if (I) {
370
+ I.screenPageViews += f.screenPageViews || 0, I.totalUsers += f.totalUsers || 0;
371
+ const S = I.screenPageViews;
372
+ S > 0 && (I.averageSessionDuration = (I.averageSessionDuration * (S - (f.screenPageViews || 0)) + (f.averageSessionDuration || 0) * (f.screenPageViews || 0)) / S);
303
373
  } else
304
- p.set(k, { ...C });
374
+ p.set(R, { ...f });
305
375
  }
306
- return { rows: [...p.values()].sort((C, k) => (k.screenPageViews || 0) - (C.screenPageViews || 0)).slice(0, r), rowCount: u.rowCount };
376
+ return { rows: [...p.values()].sort((f, R) => (R.screenPageViews || 0) - (f.screenPageViews || 0)).slice(0, r), rowCount: l.rowCount };
307
377
  })
308
378
  ), g.get(
309
379
  "/top-sources",
310
- y(async (e) => {
311
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
312
- dateRanges: [{ startDate: s, endDate: o }],
380
+ w(async (e) => {
381
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
382
+ dateRanges: [{ startDate: a, endDate: n }],
313
383
  dimensions: [{ name: "sessionSource" }],
314
384
  metrics: [
315
385
  { name: "sessions" },
@@ -318,13 +388,13 @@ function G(f) {
318
388
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
319
389
  limit: 10
320
390
  });
321
- return I(r, "sessionSource");
391
+ return k(r, "sessionSource");
322
392
  })
323
393
  ), g.get(
324
394
  "/devices",
325
- y(async (e) => {
326
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
327
- dateRanges: [{ startDate: s, endDate: o }],
395
+ w(async (e) => {
396
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
397
+ dateRanges: [{ startDate: a, endDate: n }],
328
398
  dimensions: [{ name: "deviceCategory" }],
329
399
  metrics: [
330
400
  { name: "sessions" },
@@ -332,13 +402,13 @@ function G(f) {
332
402
  ],
333
403
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }]
334
404
  });
335
- return I(r, "deviceCategory");
405
+ return k(r, "deviceCategory");
336
406
  })
337
407
  ), g.get(
338
408
  "/countries",
339
- y(async (e) => {
340
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
341
- dateRanges: [{ startDate: s, endDate: o }],
409
+ w(async (e) => {
410
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
411
+ dateRanges: [{ startDate: a, endDate: n }],
342
412
  dimensions: [{ name: "country" }],
343
413
  metrics: [
344
414
  { name: "sessions" },
@@ -347,13 +417,13 @@ function G(f) {
347
417
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
348
418
  limit: 10
349
419
  });
350
- return I(r, "country");
420
+ return k(r, "country");
351
421
  })
352
422
  ), g.get(
353
423
  "/acquisition/channels",
354
- y(async (e) => {
355
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
356
- dateRanges: [{ startDate: s, endDate: o }],
424
+ w(async (e) => {
425
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
426
+ dateRanges: [{ startDate: a, endDate: n }],
357
427
  dimensions: [{ name: "sessionDefaultChannelGroup" }],
358
428
  metrics: [
359
429
  { name: "sessions" },
@@ -367,13 +437,13 @@ function G(f) {
367
437
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
368
438
  limit: 15
369
439
  });
370
- return I(r, "sessionDefaultChannelGroup");
440
+ return k(r, "sessionDefaultChannelGroup");
371
441
  })
372
442
  ), g.get(
373
443
  "/acquisition/source-medium",
374
- y(async (e) => {
375
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
376
- dateRanges: [{ startDate: s, endDate: o }],
444
+ w(async (e) => {
445
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
446
+ dateRanges: [{ startDate: a, endDate: n }],
377
447
  dimensions: [{ name: "sessionSourceMedium" }],
378
448
  metrics: [
379
449
  { name: "sessions" },
@@ -386,13 +456,13 @@ function G(f) {
386
456
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
387
457
  limit: 20
388
458
  });
389
- return I(r, "sessionSourceMedium");
459
+ return k(r, "sessionSourceMedium");
390
460
  })
391
461
  ), g.get(
392
462
  "/acquisition/referrals",
393
- y(async (e) => {
394
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
395
- dateRanges: [{ startDate: s, endDate: o }],
463
+ w(async (e) => {
464
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
465
+ dateRanges: [{ startDate: a, endDate: n }],
396
466
  dimensions: [{ name: "sessionSource" }],
397
467
  dimensionFilter: {
398
468
  filter: {
@@ -409,13 +479,13 @@ function G(f) {
409
479
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
410
480
  limit: 20
411
481
  });
412
- return I(r, "sessionSource");
482
+ return k(r, "sessionSource");
413
483
  })
414
484
  ), g.get(
415
485
  "/acquisition/campaigns",
416
- y(async (e) => {
417
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
418
- dateRanges: [{ startDate: s, endDate: o }],
486
+ w(async (e) => {
487
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
488
+ dateRanges: [{ startDate: a, endDate: n }],
419
489
  dimensions: [{ name: "sessionCampaignName" }],
420
490
  dimensionFilter: {
421
491
  notExpression: {
@@ -434,13 +504,13 @@ function G(f) {
434
504
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
435
505
  limit: 20
436
506
  });
437
- return I(r, "sessionCampaignName");
507
+ return k(r, "sessionCampaignName");
438
508
  })
439
509
  ), g.get(
440
510
  "/content/all-pages",
441
- y(async (e) => {
442
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = parseInt(t.limit || "50", 10), i = await d(a, n, {
443
- dateRanges: [{ startDate: s, endDate: o }],
511
+ w(async (e) => {
512
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = parseInt(t.limit || "50", 10), c = await u(o, s, {
513
+ dateRanges: [{ startDate: a, endDate: n }],
444
514
  dimensions: [{ name: "pagePath" }],
445
515
  metrics: [
446
516
  { name: "screenPageViews" },
@@ -454,13 +524,13 @@ function G(f) {
454
524
  orderBys: [{ metric: { metricName: "screenPageViews" }, desc: !0 }],
455
525
  limit: r
456
526
  });
457
- return I(i, "pagePath");
527
+ return k(c, "pagePath");
458
528
  })
459
529
  ), g.get(
460
530
  "/content/landing-pages",
461
- y(async (e) => {
462
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
463
- dateRanges: [{ startDate: s, endDate: o }],
531
+ w(async (e) => {
532
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
533
+ dateRanges: [{ startDate: a, endDate: n }],
464
534
  dimensions: [{ name: "landingPagePlusQueryString" }],
465
535
  metrics: [
466
536
  { name: "sessions" },
@@ -473,13 +543,13 @@ function G(f) {
473
543
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
474
544
  limit: 30
475
545
  });
476
- return I(r, "landingPagePlusQueryString");
546
+ return k(r, "landingPagePlusQueryString");
477
547
  })
478
548
  ), g.get(
479
549
  "/content/exit-pages",
480
- y(async (e) => {
481
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
482
- dateRanges: [{ startDate: s, endDate: o }],
550
+ w(async (e) => {
551
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
552
+ dateRanges: [{ startDate: a, endDate: n }],
483
553
  dimensions: [{ name: "pagePath" }],
484
554
  metrics: [
485
555
  { name: "sessions" },
@@ -489,51 +559,51 @@ function G(f) {
489
559
  ],
490
560
  orderBys: [{ metric: { metricName: "screenPageViews" }, desc: !0 }],
491
561
  limit: 20
492
- }), i = I(r, "pagePath");
493
- return i.rows = i.rows.map((u) => ({
494
- ...u,
495
- exitRate: u.bounceRate || 0
496
- })), i;
562
+ }), c = k(r, "pagePath");
563
+ return c.rows = c.rows.map((l) => ({
564
+ ...l,
565
+ exitRate: l.bounceRate || 0
566
+ })), c;
497
567
  })
498
568
  ), g.get(
499
569
  "/content/search-terms",
500
- y(async (e) => {
501
- const { accessToken: a, propertyId: n, siteUrl: t } = await m(e), s = D(e), o = s.startDate || "30daysAgo", r = s.endDate || "today";
570
+ w(async (e) => {
571
+ const { accessToken: o, propertyId: s, siteUrl: t } = await m(e), a = C(e), n = a.startDate || "30daysAgo", r = a.endDate || "today";
502
572
  if (t)
503
573
  try {
504
- const p = `${b}/sites/${encodeURIComponent(t)}/searchAnalytics/query`, h = await fetch(
574
+ const p = `${N}/sites/${encodeURIComponent(t)}/searchAnalytics/query`, D = await fetch(
505
575
  p,
506
576
  {
507
577
  method: "POST",
508
578
  headers: {
509
- Authorization: `Bearer ${a}`,
579
+ Authorization: `Bearer ${o}`,
510
580
  "Content-Type": "application/json"
511
581
  },
512
582
  body: JSON.stringify({
513
- startDate: c(o),
514
- endDate: c(r),
583
+ startDate: i(n),
584
+ endDate: i(r),
515
585
  dimensions: ["query"],
516
586
  rowLimit: 30
517
587
  })
518
588
  }
519
589
  );
520
- if (h.ok) {
521
- const k = ((await h.json()).rows || []).map((P) => ({
522
- query: P.keys[0],
523
- clicks: P.clicks,
524
- impressions: P.impressions,
525
- ctr: P.ctr,
526
- position: P.position
590
+ if (D.ok) {
591
+ const R = ((await D.json()).rows || []).map((I) => ({
592
+ query: I.keys[0],
593
+ clicks: I.clicks,
594
+ impressions: I.impressions,
595
+ ctr: I.ctr,
596
+ position: I.position
527
597
  }));
528
- if (k.length > 0)
598
+ if (R.length > 0)
529
599
  return {
530
- rows: k,
531
- rowCount: k.length,
600
+ rows: R,
601
+ rowCount: R.length,
532
602
  source: "search_console"
533
603
  };
534
604
  } else {
535
- const C = await h.text().catch(() => "");
536
- console.error(`[GA Module] Search Console API error (${h.status}):`, C);
605
+ const f = await D.text().catch(() => "");
606
+ console.error(`[GA Module] Search Console API error (${D.status}):`, f);
537
607
  }
538
608
  } catch (p) {
539
609
  console.error("[GA Module] Search Console request failed:", p?.message || p);
@@ -541,8 +611,8 @@ function G(f) {
541
611
  else
542
612
  console.log("[GA Module] No siteUrl configured, skipping Search Console");
543
613
  try {
544
- const p = await d(a, n, {
545
- dateRanges: [{ startDate: o, endDate: r }],
614
+ const p = await u(o, s, {
615
+ dateRanges: [{ startDate: n, endDate: r }],
546
616
  dimensions: [{ name: "sessionGoogleAdsQuery" }],
547
617
  metrics: [
548
618
  { name: "sessions" },
@@ -573,13 +643,13 @@ function G(f) {
573
643
  },
574
644
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
575
645
  limit: 30
576
- }), h = I(p, "sessionGoogleAdsQuery");
577
- if (h.rows.length > 0)
578
- return { ...h, source: "google_ads" };
646
+ }), D = k(p, "sessionGoogleAdsQuery");
647
+ if (D.rows.length > 0)
648
+ return { ...D, source: "google_ads" };
579
649
  } catch {
580
650
  }
581
- const i = await d(a, n, {
582
- dateRanges: [{ startDate: o, endDate: r }],
651
+ const c = await u(o, s, {
652
+ dateRanges: [{ startDate: n, endDate: r }],
583
653
  dimensions: [{ name: "landingPagePlusQueryString" }],
584
654
  metrics: [
585
655
  { name: "sessions" },
@@ -612,13 +682,13 @@ function G(f) {
612
682
  orderBys: [{ metric: { metricName: "sessions" }, desc: !0 }],
613
683
  limit: 30
614
684
  });
615
- return { ...I(i, "landingPagePlusQueryString"), source: "organic_landing_pages" };
685
+ return { ...k(c, "landingPagePlusQueryString"), source: "organic_landing_pages" };
616
686
  })
617
687
  ), g.get(
618
688
  "/audience/overview",
619
- y(async (e) => {
620
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
621
- dateRanges: [{ startDate: s, endDate: o }],
689
+ w(async (e) => {
690
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
691
+ dateRanges: [{ startDate: a, endDate: n }],
622
692
  dimensions: [{ name: "newVsReturning" }],
623
693
  metrics: [
624
694
  { name: "totalUsers" },
@@ -629,14 +699,14 @@ function G(f) {
629
699
  ],
630
700
  metricAggregations: ["TOTAL"]
631
701
  });
632
- return I(r, "newVsReturning");
702
+ return k(r, "newVsReturning");
633
703
  })
634
704
  ), g.get(
635
705
  "/audience/technology",
636
- y(async (e) => {
637
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = t.dimension || "browser", u = ["browser", "operatingSystem", "screenResolution"].includes(r) ? r : "browser", p = await d(a, n, {
638
- dateRanges: [{ startDate: s, endDate: o }],
639
- dimensions: [{ name: u }],
706
+ w(async (e) => {
707
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = t.dimension || "browser", l = ["browser", "operatingSystem", "screenResolution"].includes(r) ? r : "browser", p = await u(o, s, {
708
+ dateRanges: [{ startDate: a, endDate: n }],
709
+ dimensions: [{ name: l }],
640
710
  metrics: [
641
711
  { name: "totalUsers" },
642
712
  { name: "sessions" },
@@ -645,13 +715,13 @@ function G(f) {
645
715
  orderBys: [{ metric: { metricName: "totalUsers" }, desc: !0 }],
646
716
  limit: 10
647
717
  });
648
- return I(p, u);
718
+ return k(p, l);
649
719
  })
650
720
  ), g.get(
651
721
  "/audience/languages",
652
- y(async (e) => {
653
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
654
- dateRanges: [{ startDate: s, endDate: o }],
722
+ w(async (e) => {
723
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
724
+ dateRanges: [{ startDate: a, endDate: n }],
655
725
  dimensions: [{ name: "language" }],
656
726
  metrics: [
657
727
  { name: "totalUsers" },
@@ -660,13 +730,13 @@ function G(f) {
660
730
  orderBys: [{ metric: { metricName: "totalUsers" }, desc: !0 }],
661
731
  limit: 15
662
732
  });
663
- return I(r, "language");
733
+ return k(r, "language");
664
734
  })
665
735
  ), g.get(
666
736
  "/audience/hours",
667
- y(async (e) => {
668
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
669
- dateRanges: [{ startDate: s, endDate: o }],
737
+ w(async (e) => {
738
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
739
+ dateRanges: [{ startDate: a, endDate: n }],
670
740
  dimensions: [{ name: "dayOfWeekName" }, { name: "hour" }],
671
741
  metrics: [{ name: "sessions" }],
672
742
  orderBys: [
@@ -676,13 +746,13 @@ function G(f) {
676
746
  limit: 168
677
747
  // 7 days × 24 hours
678
748
  });
679
- return T(r, ["dayOfWeekName", "hour"]);
749
+ return U(r, ["dayOfWeekName", "hour"]);
680
750
  })
681
751
  ), g.get(
682
752
  "/audience/cities",
683
- y(async (e) => {
684
- const { accessToken: a, propertyId: n } = await m(e), t = D(e), s = t.startDate || "30daysAgo", o = t.endDate || "today", r = await d(a, n, {
685
- dateRanges: [{ startDate: s, endDate: o }],
753
+ w(async (e) => {
754
+ const { accessToken: o, propertyId: s } = await m(e), t = C(e), a = t.startDate || "30daysAgo", n = t.endDate || "today", r = await u(o, s, {
755
+ dateRanges: [{ startDate: a, endDate: n }],
686
756
  dimensions: [{ name: "city" }, { name: "country" }],
687
757
  metrics: [
688
758
  { name: "totalUsers" },
@@ -699,95 +769,95 @@ function G(f) {
699
769
  orderBys: [{ metric: { metricName: "totalUsers" }, desc: !0 }],
700
770
  limit: 20
701
771
  });
702
- return T(r, ["city", "country"]);
772
+ return U(r, ["city", "country"]);
703
773
  })
704
774
  );
705
- function c(e) {
706
- const a = e.match(/^(\d+)daysAgo$/);
707
- if (a) {
708
- const n = /* @__PURE__ */ new Date();
709
- return n.setDate(n.getDate() - parseInt(a[1], 10)), n.toISOString().slice(0, 10);
775
+ function i(e) {
776
+ const o = e.match(/^(\d+)daysAgo$/);
777
+ if (o) {
778
+ const s = /* @__PURE__ */ new Date();
779
+ return s.setDate(s.getDate() - parseInt(o[1], 10)), s.toISOString().slice(0, 10);
710
780
  }
711
781
  if (e === "today") return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
712
782
  if (e === "yesterday") {
713
- const n = /* @__PURE__ */ new Date();
714
- return n.setDate(n.getDate() - 1), n.toISOString().slice(0, 10);
783
+ const s = /* @__PURE__ */ new Date();
784
+ return s.setDate(s.getDate() - 1), s.toISOString().slice(0, 10);
715
785
  }
716
786
  return e;
717
787
  }
718
- async function l(e, a, n) {
719
- const t = `${b}/sites/${encodeURIComponent(a)}/searchAnalytics/query`, s = await fetch(t, {
788
+ async function d(e, o, s) {
789
+ const t = `${N}/sites/${encodeURIComponent(o)}/searchAnalytics/query`, a = await fetch(t, {
720
790
  method: "POST",
721
791
  headers: {
722
792
  Authorization: `Bearer ${e}`,
723
793
  "Content-Type": "application/json"
724
794
  },
725
- body: JSON.stringify(n)
795
+ body: JSON.stringify(s)
726
796
  });
727
- if (!s.ok) {
728
- const o = await s.json().catch(() => ({}));
729
- throw w({
730
- statusCode: s.status,
731
- statusMessage: o?.error?.message || "Search Console API request failed"
797
+ if (!a.ok) {
798
+ const n = await a.json().catch(() => ({}));
799
+ throw y({
800
+ statusCode: a.status,
801
+ statusMessage: n?.error?.message || "Search Console API request failed"
732
802
  });
733
803
  }
734
- return s.json();
804
+ return a.json();
735
805
  }
736
806
  return g.get(
737
807
  "/seo/keywords",
738
- y(async (e) => {
739
- const { accessToken: a, siteUrl: n } = await m(e);
740
- if (!n)
741
- throw w({ statusCode: 400, statusMessage: "Search Console Site URL is not configured. Add it in module settings." });
742
- const t = D(e), s = c(t.startDate || "30daysAgo"), o = c(t.endDate || "today"), r = Math.min(parseInt(t.limit) || 50, 100), i = await l(a, n, {
743
- startDate: s,
744
- endDate: o,
808
+ w(async (e) => {
809
+ const { accessToken: o, siteUrl: s } = await m(e);
810
+ if (!s)
811
+ throw y({ statusCode: 400, statusMessage: "Search Console Site URL is not configured. Add it in module settings." });
812
+ const t = C(e), a = i(t.startDate || "30daysAgo"), n = i(t.endDate || "today"), r = Math.min(parseInt(t.limit) || 50, 100), c = await d(o, s, {
813
+ startDate: a,
814
+ endDate: n,
745
815
  dimensions: ["query"],
746
816
  rowLimit: r
747
817
  });
748
818
  return {
749
- rows: (i.rows || []).map((u) => ({
750
- query: u.keys[0],
751
- clicks: u.clicks,
752
- impressions: u.impressions,
753
- ctr: u.ctr,
754
- position: u.position
819
+ rows: (c.rows || []).map((l) => ({
820
+ query: l.keys[0],
821
+ clicks: l.clicks,
822
+ impressions: l.impressions,
823
+ ctr: l.ctr,
824
+ position: l.position
755
825
  })),
756
- rowCount: i.rows?.length || 0
826
+ rowCount: c.rows?.length || 0
757
827
  };
758
828
  })
759
829
  ), g.get(
760
830
  "/seo/pages",
761
- y(async (e) => {
762
- const { accessToken: a, siteUrl: n } = await m(e);
763
- if (!n)
764
- throw w({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
765
- const t = D(e), s = c(t.startDate || "30daysAgo"), o = c(t.endDate || "today"), r = Math.min(parseInt(t.limit) || 50, 100), i = await l(a, n, {
766
- startDate: s,
767
- endDate: o,
831
+ w(async (e) => {
832
+ const { accessToken: o, siteUrl: s } = await m(e);
833
+ if (!s)
834
+ throw y({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
835
+ const t = C(e), a = i(t.startDate || "30daysAgo"), n = i(t.endDate || "today"), r = Math.min(parseInt(t.limit) || 50, 100), c = await d(o, s, {
836
+ startDate: a,
837
+ endDate: n,
768
838
  dimensions: ["page"],
769
839
  rowLimit: r
770
840
  });
771
841
  return {
772
- rows: (i.rows || []).map((u) => ({
773
- page: u.keys[0],
774
- clicks: u.clicks,
775
- impressions: u.impressions,
776
- ctr: u.ctr,
777
- position: u.position
842
+ rows: (c.rows || []).map((l) => ({
843
+ page: l.keys[0],
844
+ clicks: l.clicks,
845
+ impressions: l.impressions,
846
+ ctr: l.ctr,
847
+ position: l.position
778
848
  })),
779
- rowCount: i.rows?.length || 0
849
+ rowCount: c.rows?.length || 0
780
850
  };
781
851
  })
782
852
  ), g.get(
783
853
  "/seo/trends",
784
- y(async (e) => {
785
- const { accessToken: a, siteUrl: n } = await m(e);
786
- if (!n)
787
- throw w({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
788
- const t = D(e), s = c(t.startDate || "30daysAgo"), o = c(t.endDate || "today"), i = ((await l(a, n, {
789
- startDate: s,
790
- endDate: o,
854
+ w(async (e) => {
855
+ const { accessToken: o, siteUrl: s } = await m(e);
856
+ if (!s)
857
+ throw y({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
858
+ const t = C(e), a = i(t.startDate || "30daysAgo"), n = i(t.endDate || "today"), c = ((await d(o, s, {
859
+ startDate: a,
860
+ endDate: n,
791
861
  dimensions: ["date"],
792
862
  rowLimit: 500
793
863
  })).rows || []).map((p) => ({
@@ -796,132 +866,132 @@ function G(f) {
796
866
  impressions: p.impressions,
797
867
  ctr: p.ctr,
798
868
  position: p.position
799
- })).sort((p, h) => p.date.localeCompare(h.date)), u = i.reduce(
800
- (p, h) => ({
801
- clicks: p.clicks + h.clicks,
802
- impressions: p.impressions + h.impressions
869
+ })).sort((p, D) => p.date.localeCompare(D.date)), l = c.reduce(
870
+ (p, D) => ({
871
+ clicks: p.clicks + D.clicks,
872
+ impressions: p.impressions + D.impressions
803
873
  }),
804
874
  { clicks: 0, impressions: 0 }
805
875
  );
806
- return u.ctr = u.impressions > 0 ? u.clicks / u.impressions : 0, u.avgPosition = i.length > 0 ? i.reduce((p, h) => p + h.position, 0) / i.length : 0, { rows: i, totals: u, rowCount: i.length };
876
+ return l.ctr = l.impressions > 0 ? l.clicks / l.impressions : 0, l.avgPosition = c.length > 0 ? c.reduce((p, D) => p + D.position, 0) / c.length : 0, { rows: c, totals: l, rowCount: c.length };
807
877
  })
808
878
  ), g.get(
809
879
  "/seo/query-pages",
810
- y(async (e) => {
811
- const { accessToken: a, siteUrl: n } = await m(e);
812
- if (!n)
813
- throw w({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
814
- const t = D(e), s = c(t.startDate || "30daysAgo"), o = c(t.endDate || "today"), r = await l(a, n, {
815
- startDate: s,
816
- endDate: o,
880
+ w(async (e) => {
881
+ const { accessToken: o, siteUrl: s } = await m(e);
882
+ if (!s)
883
+ throw y({ statusCode: 400, statusMessage: "Search Console Site URL is not configured." });
884
+ const t = C(e), a = i(t.startDate || "30daysAgo"), n = i(t.endDate || "today"), r = await d(o, s, {
885
+ startDate: a,
886
+ endDate: n,
817
887
  dimensions: ["query", "page"],
818
888
  rowLimit: 100
819
889
  });
820
890
  return {
821
- rows: (r.rows || []).map((i) => ({
822
- query: i.keys[0],
823
- page: i.keys[1],
824
- clicks: i.clicks,
825
- impressions: i.impressions,
826
- ctr: i.ctr,
827
- position: i.position
891
+ rows: (r.rows || []).map((c) => ({
892
+ query: c.keys[0],
893
+ page: c.keys[1],
894
+ clicks: c.clicks,
895
+ impressions: c.impressions,
896
+ ctr: c.ctr,
897
+ position: c.position
828
898
  })),
829
899
  rowCount: r.rows?.length || 0
830
900
  };
831
901
  })
832
902
  ), g.handler;
833
903
  }
834
- function V(f, R = !0) {
835
- const A = (f.metricHeaders || []).map((s) => s.name), m = (f.dimensionHeaders || []).map((s) => s.name).indexOf("date"), d = [];
836
- (f.rows || []).forEach((s) => {
837
- const o = m >= 0 ? s.dimensionValues[m]?.value : s.dimensionValues[0]?.value;
838
- if (!o || o.length < 8) return;
839
- const i = { date: `${o.slice(0, 4)}-${o.slice(4, 6)}-${o.slice(6, 8)}` };
840
- A.forEach((u, p) => {
841
- i[u] = parseFloat(s.metricValues[p]?.value || "0");
842
- }), d.push(i);
904
+ function E(h, P = !0) {
905
+ const A = (h.metricHeaders || []).map((a) => a.name), m = (h.dimensionHeaders || []).map((a) => a.name).indexOf("date"), u = [];
906
+ (h.rows || []).forEach((a) => {
907
+ const n = m >= 0 ? a.dimensionValues[m]?.value : a.dimensionValues[0]?.value;
908
+ if (!n || n.length < 8) return;
909
+ const c = { date: `${n.slice(0, 4)}-${n.slice(4, 6)}-${n.slice(6, 8)}` };
910
+ A.forEach((l, p) => {
911
+ c[l] = parseFloat(a.metricValues[p]?.value || "0");
912
+ }), u.push(c);
843
913
  });
844
- const c = {}, l = {};
845
- f.totals && f.totals.length >= 2 ? A.forEach((s, o) => {
846
- c[s] = parseFloat(f.totals[0]?.metricValues?.[o]?.value || "0"), l[s] = parseFloat(f.totals[1]?.metricValues?.[o]?.value || "0");
847
- }) : f.totals && f.totals.length === 1 && A.forEach((s, o) => {
848
- c[s] = parseFloat(f.totals[0]?.metricValues?.[o]?.value || "0");
914
+ const i = {}, d = {};
915
+ h.totals && h.totals.length >= 2 ? A.forEach((a, n) => {
916
+ i[a] = parseFloat(h.totals[0]?.metricValues?.[n]?.value || "0"), d[a] = parseFloat(h.totals[1]?.metricValues?.[n]?.value || "0");
917
+ }) : h.totals && h.totals.length === 1 && A.forEach((a, n) => {
918
+ i[a] = parseFloat(h.totals[0]?.metricValues?.[n]?.value || "0");
849
919
  });
850
920
  const e = {};
851
- A.forEach((s) => {
852
- const o = c[s] || 0, r = l[s];
853
- r !== void 0 && r !== 0 ? e[s] = (o - r) / r * 100 : e[s] = null;
921
+ A.forEach((a) => {
922
+ const n = i[a] || 0, r = d[a];
923
+ r !== void 0 && r !== 0 ? e[a] = (n - r) / r * 100 : e[a] = null;
854
924
  });
855
- const a = /* @__PURE__ */ new Map();
856
- for (const s of d)
857
- a.has(s.date) || a.set(s.date, s);
858
- const n = Array.from(a.values()).sort((s, o) => s.date.localeCompare(o.date)), t = R && f.totals && f.totals.length >= 2 ? n.slice(-Math.ceil(n.length / 2)) : n;
925
+ const o = /* @__PURE__ */ new Map();
926
+ for (const a of u)
927
+ o.has(a.date) || o.set(a.date, a);
928
+ const s = Array.from(o.values()).sort((a, n) => a.date.localeCompare(n.date)), t = P && h.totals && h.totals.length >= 2 ? s.slice(-Math.ceil(s.length / 2)) : s;
859
929
  return {
860
930
  rows: t,
861
- totals: c,
862
- previousTotals: l,
931
+ totals: i,
932
+ previousTotals: d,
863
933
  changes: e,
864
934
  rowCount: t.length
865
935
  };
866
936
  }
867
- function I(f, R) {
868
- const A = (f.metricHeaders || []).map((m) => m.name), g = (f.rows || []).map((m) => {
869
- const d = {
870
- [R]: m.dimensionValues[0].value
937
+ function k(h, P) {
938
+ const A = (h.metricHeaders || []).map((m) => m.name), g = (h.rows || []).map((m) => {
939
+ const u = {
940
+ [P]: m.dimensionValues[0].value
871
941
  };
872
- return A.forEach((c, l) => {
873
- d[c] = parseFloat(m.metricValues[l].value);
874
- }), d;
942
+ return A.forEach((i, d) => {
943
+ u[i] = parseFloat(m.metricValues[d].value);
944
+ }), u;
875
945
  });
876
- return { rows: g, rowCount: f.rowCount || g.length };
946
+ return { rows: g, rowCount: h.rowCount || g.length };
877
947
  }
878
- function T(f, R) {
879
- const A = (f.metricHeaders || []).map((m) => m.name), g = (f.rows || []).map((m) => {
880
- const d = {};
881
- return R.forEach((c, l) => {
882
- d[c] = m.dimensionValues[l]?.value || "";
883
- }), A.forEach((c, l) => {
884
- d[c] = parseFloat(m.metricValues[l].value);
885
- }), d;
948
+ function U(h, P) {
949
+ const A = (h.metricHeaders || []).map((m) => m.name), g = (h.rows || []).map((m) => {
950
+ const u = {};
951
+ return P.forEach((i, d) => {
952
+ u[i] = m.dimensionValues[d]?.value || "";
953
+ }), A.forEach((i, d) => {
954
+ u[i] = parseFloat(m.metricValues[d].value);
955
+ }), u;
886
956
  });
887
- return { rows: g, rowCount: f.rowCount || g.length };
957
+ return { rows: g, rowCount: h.rowCount || g.length };
888
958
  }
889
- function j(f) {
890
- const { decrypt: R } = f, A = v();
959
+ function j(h) {
960
+ const { decrypt: P } = h, A = v();
891
961
  async function g(m) {
892
- const { supabase: d, instanceId: c } = m.context.module, { data: l, error: e } = await d.from("project_modules").select("config").eq("id", c).single();
893
- if (e || !l?.config)
894
- throw w({ statusCode: 500, statusMessage: "Failed to load module config." });
895
- const a = l.config, n = a.githubIntegration, t = a.githubRepo, s = a.githubOwner;
896
- if (!n || !t || !s)
897
- throw w({ statusCode: 400, statusMessage: "No GitHub integration configured for this module." });
898
- const { data: o, error: r } = await d.from("integrations").select("config").eq("id", n).single();
899
- let i = o?.config;
900
- if (r || !i) {
901
- const { data: p, error: h } = await d.from("agency_integrations").select("config").eq("id", n).single();
902
- if (h || !p?.config)
903
- throw w({ statusCode: 500, statusMessage: "Failed to load Github credentials." });
904
- i = p.config;
962
+ const { supabase: u, instanceId: i } = m.context.module, { data: d, error: e } = await u.from("project_modules").select("config").eq("id", i).single();
963
+ if (e || !d?.config)
964
+ throw y({ statusCode: 500, statusMessage: "Failed to load module config." });
965
+ const o = d.config, s = o.githubIntegration, t = o.githubRepo, a = o.githubOwner;
966
+ if (!s || !t || !a)
967
+ throw y({ statusCode: 400, statusMessage: "No GitHub integration configured for this module." });
968
+ const { data: n, error: r } = await u.from("integrations").select("config").eq("id", s).single();
969
+ let c = n?.config;
970
+ if (r || !c) {
971
+ const { data: p, error: D } = await u.from("agency_integrations").select("config").eq("id", s).single();
972
+ if (D || !p?.config)
973
+ throw y({ statusCode: 500, statusMessage: "Failed to load Github credentials." });
974
+ c = p.config;
905
975
  }
906
- return { token: R(i.token), repo: t, owner: s };
976
+ return { token: P(c.token), repo: t, owner: a };
907
977
  }
908
978
  return A.post(
909
979
  "/github/deploy",
910
- y(async (m) => {
980
+ w(async (m) => {
911
981
  try {
912
- const { token: d, repo: c, owner: l } = await g(m);
913
- await fetch(`https://api.github.com/repos/${l}/${c}/dispatches`, {
982
+ const { token: u, repo: i, owner: d } = await g(m);
983
+ await fetch(`https://api.github.com/repos/${d}/${i}/dispatches`, {
914
984
  method: "POST",
915
985
  headers: {
916
- Authorization: `Bearer ${d}`,
986
+ Authorization: `Bearer ${u}`,
917
987
  Accept: "application/vnd.github+json"
918
988
  },
919
989
  body: JSON.stringify({
920
990
  event_type: "deploy-site"
921
991
  })
922
992
  });
923
- } catch (d) {
924
- throw console.error("Error triggering GitHub deployment:", d), w({ statusCode: 500, statusMessage: "Failed to trigger deployment." });
993
+ } catch (u) {
994
+ throw console.error("Error triggering GitHub deployment:", u), y({ statusCode: 500, statusMessage: "Failed to trigger deployment." });
925
995
  }
926
996
  })
927
997
  ), A.handler;