@oneclick.dev/cms-core-modules 0.0.82 → 0.0.84

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 (68) hide show
  1. package/dist/{ContentEditor-Dk-iDEjl.mjs → ContentEditor-DPhhOkx3.mjs} +7085 -5936
  2. package/dist/{ContentEditor-4e80zFyn.js → ContentEditor-DrxtH_Hq.js} +42 -42
  3. package/dist/{Create-DtFzwxn_.mjs → Create-6uT9HWar.mjs} +35 -35
  4. package/dist/{Create-CRn2sMHp.js → Create-DuZ5nZrX.js} +1 -1
  5. package/dist/{DateFormatter-DfIwyrnF.mjs → DateFormatter-2B0R-DY4.mjs} +213 -406
  6. package/dist/DateFormatter-DbtOLV0L.js +1 -0
  7. package/dist/{Detail-Bxi7lG9x.js → Detail-BZ-iE9vf.js} +1 -1
  8. package/dist/{Detail-B4b_FLDa.mjs → Detail-C1Blq61w.mjs} +90 -90
  9. package/dist/{Detail-BayNaAg9.js → Detail-C8wQiDcv.js} +1 -1
  10. package/dist/{Detail-BwDnY42G.mjs → Detail-CJVMJDP7.mjs} +17 -17
  11. package/dist/{Detail-CnK-qbhE.js → Detail-CPqug27l.js} +1 -1
  12. package/dist/Detail-CjuhjPby.js +1 -0
  13. package/dist/{Detail-U0mgLKt6.mjs → Detail-CtItxMX4.mjs} +62 -63
  14. package/dist/{Detail-CVgWHbMC.mjs → Detail-Dnpnmy4-.mjs} +158 -158
  15. package/dist/{Entries-D7MHylQE.mjs → Entries-BkOPae4R.mjs} +49 -49
  16. package/dist/Entries-CcEW98F5.js +1 -0
  17. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-Ds7z0qeH.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-Bc946oSc.mjs} +1 -1
  18. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-C5YczjNb.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-CqERfyYb.js} +1 -1
  19. package/dist/{Overview-CwCAeBnX.js → Overview-CA8wh_BI.js} +1 -1
  20. package/dist/{Overview-CgViRnNc.mjs → Overview-D4MFwRI_.mjs} +67 -68
  21. package/dist/{Overview-pCO_47Zt.js → Overview-Da0XexiT.js} +1 -1
  22. package/dist/Overview-DeQQ0FY3.js +1 -0
  23. package/dist/{Overview--XpvBbqz.mjs → Overview-DoOASlNz.mjs} +1 -3
  24. package/dist/{Overview-CuCQgqVp.mjs → Overview-gJSvftdE.mjs} +34 -34
  25. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-B7ks5mbf.mjs → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Cohhnd5x.mjs} +0 -1
  26. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Vxubki_v.js → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-VWVIxIr6.js} +1 -1
  27. package/dist/{SeoHealth-CC0rW1AG.mjs → SeoHealth-Bc5chnaa.mjs} +14 -14
  28. package/dist/{SeoHealth-EZzDmPDM.js → SeoHealth-BkpJ1F2Y.js} +1 -1
  29. package/dist/TableView-BPWAx--G.mjs +5743 -0
  30. package/dist/TableView-D63QrVlK.js +4 -0
  31. package/dist/View-BL70u98U.js +1 -0
  32. package/dist/{View-DDXN0tKD.mjs → View-BO5N911y.mjs} +5 -5
  33. package/dist/{agenda-XqvbrU72.mjs → agenda-C5grvzSa.mjs} +166 -169
  34. package/dist/agenda-DXMwVWpN.js +1 -0
  35. package/dist/{availability-B-tRp8hB.mjs → availability-C1NqOFsQ.mjs} +81 -81
  36. package/dist/{availability-BiBbzEIM.js → availability-D_wnfLsH.js} +1 -1
  37. package/dist/cms-core-modules.css +1 -1
  38. package/dist/{exceptions-CLgeeUSy.mjs → exceptions-BIwMhYa4.mjs} +1 -1
  39. package/dist/{exceptions-wEQEVzIs.js → exceptions-Cn7zooEu.js} +1 -1
  40. package/dist/{index-DTzdHh6g.js → index-C9pSS15N.js} +2 -2
  41. package/dist/{index-N0NoDEsI.mjs → index-MwjeLHPP.mjs} +3 -3
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/index.mjs +50 -36
  44. package/dist/orders-CG1QUCN8.js +1 -0
  45. package/dist/orders-CeixEBcU.mjs +396 -0
  46. package/dist/server-handlers.cjs.js +1 -1
  47. package/dist/server-handlers.mjs +292 -256
  48. package/dist/src/contentManager/config.d.ts +28 -0
  49. package/dist/src/contentManager/index.d.ts +28 -0
  50. package/dist/src/contentManager/server.d.ts +7 -0
  51. package/dist/src/server-handlers.d.ts +1 -0
  52. package/package.json +2 -2
  53. package/dist/DateFormatter-C9qfmQnP.js +0 -1
  54. package/dist/Detail-BcboL7NF.js +0 -1
  55. package/dist/Entries-BPkZ7Jg5.js +0 -1
  56. package/dist/Overview-B-8TLLjh.js +0 -1
  57. package/dist/TableView-Ce8H65pL.js +0 -586
  58. package/dist/TableView-DRQvOW85.mjs +0 -89190
  59. package/dist/View-DfzaVOzS.js +0 -1
  60. package/dist/agenda-wNFDKn0G.js +0 -1
  61. package/dist/floating-ui.dom-BO2Hr6mz.mjs +0 -1292
  62. package/dist/floating-ui.dom-CAr9LGoC.js +0 -1
  63. package/dist/index-DYpruS-A-CA2jEOA3.js +0 -88
  64. package/dist/index-DYpruS-A-D38FBcI3.mjs +0 -4211
  65. package/dist/index-YMaY4uuk-BgpTtr73.js +0 -1
  66. package/dist/index-YMaY4uuk-C_xV5K9Z.mjs +0 -1300
  67. package/dist/orders-Bqa3Z3tH.mjs +0 -356
  68. package/dist/orders-D5GJOZXN.js +0 -1
@@ -1,6 +1,6 @@
1
- import { defineComponent as G, resolveComponent as n, openBlock as c, createElementBlock as k, Fragment as te, renderList as le, createBlock as w, unref as b, withCtx as l, createElementVNode as o, normalizeClass as oe, resolveDynamicComponent as ne, toDisplayString as P, createCommentVNode as U, createVNode as t, withModifiers as Ee, createTextVNode as d, ref as v, computed as q, useTemplateRef as Se, onMounted as De } from "vue";
1
+ import { defineComponent as G, resolveComponent as n, openBlock as c, createElementBlock as k, Fragment as te, renderList as le, createBlock as w, unref as C, withCtx as l, createElementVNode as o, normalizeClass as oe, resolveDynamicComponent as ne, toDisplayString as P, createCommentVNode as U, createVNode as t, withModifiers as Ee, createTextVNode as d, ref as v, computed as q, useTemplateRef as Se, onMounted as De } from "vue";
2
2
  import { icons as ae, EllipsisVertical as Te, Paintbrush as Pe, ToyBrick as Me, Plus as Ue } from "lucide-vue-next";
3
- import { useModuleRoute as se, useConfirmation as ie, useModuleStorage as $e, useModulePermissions as Ne, useModuleBreadcrumbs as Ae, useFirebaseIntegration as Re } from "@oneclick.dev/cms-kit";
3
+ import { useModuleRoute as se, useConfirmation as ie, useModuleStorage as $e, useModulePermissions as Ne, useModuleBreadcrumbs as Re, useFirebaseIntegration as Ae } from "@oneclick.dev/cms-kit";
4
4
  import { i as Le } from "./interpolation-BHSqsh8Q.mjs";
5
5
  import { t as z } from "./index-RLz1QPrf.mjs";
6
6
  const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl:grid-cols-5 gap-4" }, Ie = { class: "relative flex pl-3 @5xl:pl-6 pr-1.5 @5xl:pr-3 gap-3" }, Fe = { class: "self-center overflow-hidden w-full group-hover:w-[calc(100%-6.5rem)]" }, ze = ["title"], Oe = ["title"], je = { class: "absolute -top-1 right-2 self-start opacity-0 group-hover:opacity-100" }, qe = /* @__PURE__ */ G({
@@ -15,19 +15,19 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
15
15
  setup(M, { emit: V }) {
16
16
  const { navigateTo: $ } = se(), N = V;
17
17
  return (I, g) => {
18
- const R = n("Button"), y = n("DropdownMenuTrigger"), m = n("DropdownMenuItem"), E = n("DropdownMenuContent"), C = n("DropdownMenu"), _ = n("Card");
18
+ const A = n("Button"), y = n("DropdownMenuTrigger"), m = n("DropdownMenuItem"), E = n("DropdownMenuContent"), b = n("DropdownMenu"), _ = n("Card");
19
19
  return c(), k("div", Be, [
20
20
  (c(!0), k(te, null, le(M.collections, (u) => (c(), w(_, {
21
21
  key: u.id,
22
22
  class: "group hover:bg-input/50 cursor-pointer transition-colors duration-200",
23
- onClick: (x) => b($)("collections/" + u.id)
23
+ onClick: (x) => C($)("collections/" + u.id)
24
24
  }, {
25
25
  default: l(() => [
26
26
  o("div", Ie, [
27
27
  o("div", {
28
28
  class: oe(`p-2 bg-${u.tint} rounded-md self-center mr-3`)
29
29
  }, [
30
- (c(), w(ne(b(ae)[u.icon]), { class: "size-6 text-white" }))
30
+ (c(), w(ne(C(ae)[u.icon]), { class: "size-6 text-white" }))
31
31
  ], 2),
32
32
  o("div", Fe, [
33
33
  o("p", {
@@ -41,18 +41,18 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
41
41
  }, " Manage " + P(u.contentEntryNamePlural || u.contentEntryName) + " here ", 9, Oe)) : U("", !0)
42
42
  ]),
43
43
  o("div", je, [
44
- t(C, null, {
44
+ t(b, null, {
45
45
  default: l(() => [
46
46
  t(y, { "as-child": "" }, {
47
47
  default: l(() => [
48
- t(R, {
48
+ t(A, {
49
49
  variant: "ghost",
50
50
  size: "icon",
51
51
  onClick: g[0] || (g[0] = Ee(() => {
52
52
  }, ["stop"]))
53
53
  }, {
54
54
  default: l(() => [
55
- t(b(Te), { class: "size-5" })
55
+ t(C(Te), { class: "size-5" })
56
56
  ]),
57
57
  _: 1
58
58
  })
@@ -62,7 +62,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
62
62
  t(E, null, {
63
63
  default: l(() => [
64
64
  t(m, {
65
- onClick: (x) => b($)("collections/" + u.id)
65
+ onClick: (x) => C($)("collections/" + u.id)
66
66
  }, {
67
67
  default: l(() => [...g[1] || (g[1] = [
68
68
  d("Open Collection...", -1)
@@ -124,44 +124,44 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
124
124
  { name: "id", type: "string" },
125
125
  { name: "slug", type: "string" },
126
126
  { name: "lang", type: "string" }
127
- ], { confirm: I } = ie(), g = $, R = M, y = v(!1), m = v("create"), E = v(""), C = v(""), _ = v(""), u = v(""), x = v(""), T = v(""), S = v(!0), i = v(!1), a = v(null), p = v("{{ slug }}"), f = v("/{{ lang }}/{{ slug }}"), D = v("all"), A = v([]), W = q(() => J(p.value)), H = q(() => J(f.value));
127
+ ], { confirm: I } = ie(), g = $, A = M, y = v(!1), m = v("create"), E = v(""), b = v(""), _ = v(""), u = v(""), x = v(""), T = v(""), S = v(!0), i = v(!1), s = v(null), p = v("{{ slug }}"), f = v("/{{ lang }}/{{ slug }}"), D = v("all"), R = v([]), W = q(() => J(p.value)), H = q(() => J(f.value));
128
128
  function J(r) {
129
129
  if (!r) return "";
130
- let e = R.config.domain || "https://domain.com";
130
+ let e = A.config.domain || "https://domain.com";
131
131
  return e.endsWith("/") && (e = e.slice(0, -1)), r.startsWith("/") || (r = "/" + r), Le(e + r, [{ name: "slug", value: "example-slug" }, { name: "id", value: "12345" }, { name: "lang", value: "en" }]);
132
132
  }
133
133
  const ue = (r) => {
134
- r ? (m.value = "edit", E.value = r.id, C.value = r.name || "", _.value = r.tint || "", u.value = r.icon || "", x.value = r.contentEntryName || "", T.value = r.contentEntryNamePlural || "", S.value = r.allowUserEntryManagement ?? !0, i.value = !!r.customSettings, a.value = r.customSettings || null, p.value = r.defaultLanguageRoutePattern || "{{ slug }}", f.value = r.multilingualRoutePattern || "/{{ lang }}/{{ slug }}", D.value = r.componentAvailability || "all", A.value = r.selectedComponents || []) : (m.value = "create", E.value = "", C.value = "", _.value = "", u.value = "", x.value = "", T.value = "", S.value = !0, i.value = !1, a.value = null, p.value = "{{ slug }}", f.value = "/{{ lang }}/{{ slug }}", D.value = "all", A.value = []), y.value = !0;
134
+ r ? (m.value = "edit", E.value = r.id, b.value = r.name || "", _.value = r.tint || "", u.value = r.icon || "", x.value = r.contentEntryName || "", T.value = r.contentEntryNamePlural || "", S.value = r.allowUserEntryManagement ?? !0, i.value = !!r.customSettings, s.value = r.customSettings || null, p.value = r.defaultLanguageRoutePattern || "{{ slug }}", f.value = r.multilingualRoutePattern || "/{{ lang }}/{{ slug }}", D.value = r.componentAvailability || "all", R.value = r.selectedComponents || []) : (m.value = "create", E.value = "", b.value = "", _.value = "", u.value = "", x.value = "", T.value = "", S.value = !0, i.value = !1, s.value = null, p.value = "{{ slug }}", f.value = "/{{ lang }}/{{ slug }}", D.value = "all", R.value = []), y.value = !0;
135
135
  }, de = () => {
136
136
  g("add", {
137
- name: C.value,
137
+ name: b.value,
138
138
  tint: _.value,
139
139
  icon: u.value,
140
140
  contentEntryName: x.value,
141
141
  contentEntryNamePlural: T.value,
142
142
  allowUserEntryManagement: S.value,
143
143
  showCustomSettings: i.value,
144
- customSettings: i.value ? a.value : null,
144
+ customSettings: i.value ? s.value : null,
145
145
  defaultLanguageRoutePattern: p.value,
146
146
  multilingualRoutePattern: f.value,
147
147
  componentAvailability: D.value,
148
- selectedComponents: D.value === "all" ? [] : A.value
148
+ selectedComponents: D.value === "all" ? [] : R.value
149
149
  }), y.value = !1;
150
150
  }, re = () => {
151
151
  g("edit", {
152
152
  id: E.value,
153
- name: C.value,
153
+ name: b.value,
154
154
  tint: _.value,
155
155
  icon: u.value,
156
156
  contentEntryName: x.value,
157
157
  contentEntryNamePlural: T.value,
158
158
  allowUserEntryManagement: S.value,
159
159
  showCustomSettings: i.value,
160
- customSettings: i.value ? a.value : null,
160
+ customSettings: i.value ? s.value : null,
161
161
  defaultLanguageRoutePattern: p.value,
162
162
  multilingualRoutePattern: f.value,
163
163
  componentAvailability: D.value,
164
- selectedComponents: D.value === "all" ? [] : A.value
164
+ selectedComponents: D.value === "all" ? [] : R.value
165
165
  }), y.value = !1;
166
166
  }, me = async () => {
167
167
  await I("Are you sure you want to delete this collection? This action cannot be undone.", "Delete Collection", "Delete") && (g("delete", E.value), y.value = !1);
@@ -169,10 +169,10 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
169
169
  return V({
170
170
  openDialog: ue
171
171
  }), (r, e) => {
172
- const ce = n("DialogTitle"), ve = n("DialogDescription"), pe = n("DialogHeader"), L = n("TabsTrigger"), ge = n("TabsList"), O = n("Input"), fe = n("TailwindColorPicker"), ye = n("LucideIconPicker"), B = n("TabsContent"), _e = n("Checkbox"), K = n("Label"), xe = n("Switch"), Ce = n("FormBuilderSelect"), Q = n("SelectValue"), X = n("SelectTrigger"), F = n("SelectItem"), Y = n("SelectGroup"), Z = n("SelectContent"), h = n("Select"), ee = n("Sandbox"), be = n("Tabs"), j = n("Button"), we = n("DialogFooter"), ke = n("DialogScrollContent"), Ve = n("Dialog");
172
+ const ce = n("DialogTitle"), ve = n("DialogDescription"), pe = n("DialogHeader"), L = n("TabsTrigger"), ge = n("TabsList"), O = n("Input"), fe = n("TailwindColorPicker"), ye = n("LucideIconPicker"), B = n("TabsContent"), _e = n("Checkbox"), K = n("Label"), xe = n("Switch"), be = n("FormBuilderSelect"), Q = n("SelectValue"), X = n("SelectTrigger"), F = n("SelectItem"), Y = n("SelectGroup"), Z = n("SelectContent"), h = n("Select"), ee = n("Sandbox"), Ce = n("Tabs"), j = n("Button"), we = n("DialogFooter"), ke = n("DialogScrollContent"), Ve = n("Dialog");
173
173
  return c(), w(Ve, {
174
174
  open: y.value,
175
- "onUpdate:open": e[12] || (e[12] = (s) => y.value = s)
175
+ "onUpdate:open": e[12] || (e[12] = (a) => y.value = a)
176
176
  }, {
177
177
  default: l(() => [
178
178
  t(ke, { class: "sm:max-w-2xl" }, {
@@ -195,7 +195,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
195
195
  _: 1
196
196
  }),
197
197
  o("div", Ge, [
198
- t(be, {
198
+ t(Ce, {
199
199
  "default-value": "account",
200
200
  class: "w-full"
201
201
  }, {
@@ -244,8 +244,8 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
244
244
  class: "text-sm mb-1 block font-medium"
245
245
  }, "Collection Name", -1)),
246
246
  t(O, {
247
- modelValue: C.value,
248
- "onUpdate:modelValue": e[0] || (e[0] = (s) => C.value = s),
247
+ modelValue: b.value,
248
+ "onUpdate:modelValue": e[0] || (e[0] = (a) => b.value = a),
249
249
  id: "collection-dialog-display-name"
250
250
  }, null, 8, ["modelValue"])
251
251
  ]),
@@ -253,7 +253,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
253
253
  e[20] || (e[20] = o("label", { class: "text-sm mb-1 block font-medium" }, "Tint", -1)),
254
254
  t(fe, {
255
255
  modelValue: _.value,
256
- "onUpdate:modelValue": e[1] || (e[1] = (s) => _.value = s),
256
+ "onUpdate:modelValue": e[1] || (e[1] = (a) => _.value = a),
257
257
  "default-value": "white"
258
258
  }, null, 8, ["modelValue"])
259
259
  ]),
@@ -261,7 +261,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
261
261
  e[21] || (e[21] = o("label", { class: "text-sm mb-1 block font-medium" }, "Icon", -1)),
262
262
  t(ye, {
263
263
  modelValue: u.value,
264
- "onUpdate:modelValue": e[2] || (e[2] = (s) => u.value = s)
264
+ "onUpdate:modelValue": e[2] || (e[2] = (a) => u.value = a)
265
265
  }, null, 8, ["modelValue"])
266
266
  ])
267
267
  ])
@@ -280,7 +280,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
280
280
  }, "Entry name (singular)", -1)),
281
281
  t(O, {
282
282
  modelValue: x.value,
283
- "onUpdate:modelValue": e[3] || (e[3] = (s) => x.value = s),
283
+ "onUpdate:modelValue": e[3] || (e[3] = (a) => x.value = a),
284
284
  id: "collection-dialog-entry-name",
285
285
  placeholder: "Entry"
286
286
  }, null, 8, ["modelValue"])
@@ -292,7 +292,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
292
292
  }, "Entry name (plural)", -1)),
293
293
  t(O, {
294
294
  modelValue: T.value,
295
- "onUpdate:modelValue": e[4] || (e[4] = (s) => T.value = s),
295
+ "onUpdate:modelValue": e[4] || (e[4] = (a) => T.value = a),
296
296
  id: "collection-dialog-entry-name-plural",
297
297
  placeholder: "Entries"
298
298
  }, null, 8, ["modelValue"])
@@ -301,7 +301,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
301
301
  o("div", he, [
302
302
  t(_e, {
303
303
  modelValue: S.value,
304
- "onUpdate:modelValue": e[5] || (e[5] = (s) => S.value = s),
304
+ "onUpdate:modelValue": e[5] || (e[5] = (a) => S.value = a),
305
305
  id: "collection-dialog-allow-user-entry-management"
306
306
  }, null, 8, ["modelValue"]),
307
307
  t(K, { for: "collection-dialog-allow-user-entry-management" }, {
@@ -317,7 +317,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
317
317
  o("div", et, [
318
318
  t(xe, {
319
319
  modelValue: i.value,
320
- "onUpdate:modelValue": e[6] || (e[6] = (s) => i.value = s),
320
+ "onUpdate:modelValue": e[6] || (e[6] = (a) => i.value = a),
321
321
  id: "collection-dialog-component-settings-toggle",
322
322
  class: "mb-4"
323
323
  }, null, 8, ["modelValue"]),
@@ -331,10 +331,10 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
331
331
  _: 1
332
332
  })
333
333
  ]),
334
- i.value ? (c(), w(Ce, {
334
+ i.value ? (c(), w(be, {
335
335
  key: 0,
336
- modelValue: a.value,
337
- "onUpdate:modelValue": e[7] || (e[7] = (s) => a.value = s),
336
+ modelValue: s.value,
337
+ "onUpdate:modelValue": e[7] || (e[7] = (a) => s.value = a),
338
338
  class: "w-1/2"
339
339
  }, null, 8, ["modelValue"])) : U("", !0)
340
340
  ])
@@ -347,7 +347,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
347
347
  o("div", tt, [
348
348
  t(h, {
349
349
  modelValue: D.value,
350
- "onUpdate:modelValue": e[8] || (e[8] = (s) => D.value = s)
350
+ "onUpdate:modelValue": e[8] || (e[8] = (a) => D.value = a)
351
351
  }, {
352
352
  default: l(() => [
353
353
  t(X, { class: "w-full" }, {
@@ -390,8 +390,8 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
390
390
  D.value !== "all" ? (c(), w(h, {
391
391
  key: 0,
392
392
  multiple: !0,
393
- modelValue: A.value,
394
- "onUpdate:modelValue": e[9] || (e[9] = (s) => A.value = s)
393
+ modelValue: R.value,
394
+ "onUpdate:modelValue": e[9] || (e[9] = (a) => R.value = a)
395
395
  }, {
396
396
  default: l(() => [
397
397
  t(X, { class: "w-full" }, {
@@ -404,17 +404,17 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
404
404
  default: l(() => [
405
405
  t(Y, null, {
406
406
  default: l(() => [
407
- (c(!0), k(te, null, le(M.components, (s) => (c(), w(F, {
408
- key: s.id,
409
- value: s.id
407
+ (c(!0), k(te, null, le(M.components, (a) => (c(), w(F, {
408
+ key: a.id,
409
+ value: a.id
410
410
  }, {
411
411
  default: l(() => [
412
412
  o("div", {
413
- class: oe(`p-1 bg-${s.tint} rounded-md flex items-center justify-center`)
413
+ class: oe(`p-1 bg-${a.tint} rounded-md flex items-center justify-center`)
414
414
  }, [
415
- (c(), w(ne(b(ae)[s.icon]), { class: "size-4 text-white" }))
415
+ (c(), w(ne(C(ae)[a.icon]), { class: "size-4 text-white" }))
416
416
  ], 2),
417
- d(" " + P(s.name), 1)
417
+ d(" " + P(a.name), 1)
418
418
  ]),
419
419
  _: 2
420
420
  }, 1032, ["value"]))), 128))
@@ -446,7 +446,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
446
446
  e[35] || (e[35] = o("label", { class: "text-sm basis-[200px] block font-medium" }, "Default Language Route", -1)),
447
447
  t(ee, {
448
448
  modelValue: p.value,
449
- "onUpdate:modelValue": e[10] || (e[10] = (s) => p.value = s),
449
+ "onUpdate:modelValue": e[10] || (e[10] = (a) => p.value = a),
450
450
  variables: N,
451
451
  class: "flex-1"
452
452
  }, null, 8, ["modelValue"])
@@ -458,7 +458,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
458
458
  e[36] || (e[36] = o("label", { class: "text-sm basis-[200px] block font-medium" }, "Multilingual Route", -1)),
459
459
  t(ee, {
460
460
  modelValue: f.value,
461
- "onUpdate:modelValue": e[11] || (e[11] = (s) => f.value = s),
461
+ "onUpdate:modelValue": e[11] || (e[11] = (a) => f.value = a),
462
462
  variables: N,
463
463
  class: "flex-1"
464
464
  }, null, 8, ["modelValue"])
@@ -525,7 +525,7 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
525
525
  }, pt = {
526
526
  key: 0,
527
527
  class: "flex items-center gap-4"
528
- }, Ct = /* @__PURE__ */ G({
528
+ }, bt = /* @__PURE__ */ G({
529
529
  __name: "Overview",
530
530
  props: {
531
531
  config: {
@@ -534,27 +534,26 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
534
534
  }
535
535
  },
536
536
  setup(M) {
537
- const V = M, { getModuleData: $ } = $e(), { hasPermission: N, isAdmin: I } = Ne(), { navigateTo: g } = se(), { confirm: R } = ie();
538
- Ae(() => []);
539
- const y = Re(V.config.project), m = v(null), E = v([]), C = v(null);
540
- q(() => m.value?.find((i) => i.id === C.value) || null);
537
+ const V = M, { getModuleData: $ } = $e(), { hasPermission: N, isAdmin: I } = Ne(), { navigateTo: g } = se(), { confirm: A } = ie();
538
+ Re(() => []);
539
+ const y = Ae(V.config.project), m = v(null), E = v([]), b = v(null);
540
+ q(() => m.value?.find((i) => i.id === b.value) || null);
541
541
  const _ = Se("collectionModal"), u = async () => {
542
542
  const i = await y.find(V.config.collectionsCollection);
543
543
  m.value = i || [];
544
544
  }, x = async (i) => {
545
- const a = await y.add(V.config.collectionsCollection, i);
546
- console.log("Added collection", a);
545
+ await y.add(V.config.collectionsCollection, i);
547
546
  }, T = async (i) => {
548
547
  try {
549
548
  await y.update(V.config.collectionsCollection, i.id, i);
550
- const a = m.value.findIndex((p) => p.id === i.id);
551
- a !== -1 && (m.value[a] = i), z.success("Collection updated");
549
+ const s = m.value.findIndex((p) => p.id === i.id);
550
+ s !== -1 && (m.value[s] = i), z.success("Collection updated");
552
551
  } catch {
553
552
  z.error("Failed to update collection");
554
553
  }
555
554
  }, S = (i) => {
556
- R("Are you sure you want to delete this collection? This action cannot be undone.").then(async (a) => {
557
- if (a)
555
+ A("Are you sure you want to delete this collection? This action cannot be undone.").then(async (s) => {
556
+ if (s)
558
557
  try {
559
558
  await y.remove(V.config.collectionsCollection, i), m.value = m.value.filter((p) => p.id !== i), z.success("Collection deleted");
560
559
  } catch {
@@ -566,44 +565,44 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
566
565
  u(), $("components").then((i) => {
567
566
  E.value = i;
568
567
  });
569
- }), (i, a) => {
568
+ }), (i, s) => {
570
569
  const p = n("Button");
571
570
  return c(), k("div", dt, [
572
571
  o("div", rt, [
573
572
  o("div", mt, [
574
573
  m.value !== null ? (c(), k("p", ct, P(m.value.length) + " " + P(m.value.length === 1 ? "Collection" : "Collections"), 1)) : (c(), k("p", vt, "Loading Collections..."))
575
574
  ]),
576
- b(I)() ? (c(), k("div", pt, [
575
+ C(I)() ? (c(), k("div", pt, [
577
576
  t(p, {
578
577
  variant: "outline",
579
578
  class: "text-primary hover:text-primary",
580
- onClick: a[0] || (a[0] = (f) => b(g)("global-styling"))
579
+ onClick: s[0] || (s[0] = (f) => C(g)("global-styling"))
581
580
  }, {
582
581
  default: l(() => [
583
- t(b(Pe), { class: "size-4" }),
584
- a[5] || (a[5] = d(" Global Styling ", -1))
582
+ t(C(Pe), { class: "size-4" }),
583
+ s[5] || (s[5] = d(" Global Styling ", -1))
585
584
  ]),
586
585
  _: 1
587
586
  }),
588
587
  t(p, {
589
588
  variant: "outline",
590
589
  class: "text-primary hover:text-primary",
591
- onClick: a[1] || (a[1] = (f) => b(g)("components"))
590
+ onClick: s[1] || (s[1] = (f) => C(g)("components"))
592
591
  }, {
593
592
  default: l(() => [
594
- t(b(Me), { class: "size-4" }),
595
- a[6] || (a[6] = d(" Components ", -1))
593
+ t(C(Me), { class: "size-4" }),
594
+ s[6] || (s[6] = d(" Components ", -1))
596
595
  ]),
597
596
  _: 1
598
597
  }),
599
598
  t(p, {
600
599
  variant: "outline",
601
600
  class: "text-primary hover:text-primary",
602
- onClick: a[2] || (a[2] = (f) => _.value.openDialog())
601
+ onClick: s[2] || (s[2] = (f) => _.value.openDialog())
603
602
  }, {
604
603
  default: l(() => [
605
- t(b(Ue), { class: "size-4" }),
606
- a[7] || (a[7] = d(" New Collection ", -1))
604
+ t(C(Ue), { class: "size-4" }),
605
+ s[7] || (s[7] = d(" New Collection ", -1))
607
606
  ]),
608
607
  _: 1
609
608
  })
@@ -611,8 +610,8 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
611
610
  ]),
612
611
  t(qe, {
613
612
  collections: m.value,
614
- onOpen: a[3] || (a[3] = (f) => C.value = f),
615
- onEdit: a[4] || (a[4] = (f) => _.value.openDialog(f)),
613
+ onOpen: s[3] || (s[3] = (f) => b.value = f),
614
+ onEdit: s[4] || (s[4] = (f) => _.value.openDialog(f)),
616
615
  onDelete: S
617
616
  }, null, 8, ["collections"]),
618
617
  t(ut, {
@@ -629,5 +628,5 @@ const Be = { class: "grid @lg:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4 @7xl
629
628
  }
630
629
  });
631
630
  export {
632
- Ct as default
631
+ bt as default
633
632
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("@oneclick.dev/cms-kit");require("./index-BuzLn4Km.js");const D=require("./index-DYpruS-A-CA2jEOA3.js"),a=require("lucide-vue-next"),c=require("./index-DQYBP8Js.js"),N=require("./index-C4YUVWzJ.js"),Y={class:"w-full max-w-7xl mx-auto py-8 px-4 space-y-6"},Z={class:"flex items-center justify-between"},J={class:"text-muted-foreground text-sm mt-1"},Q={key:0,class:"flex items-center gap-2"},ee={class:"flex items-center border rounded-lg overflow-hidden"},te=["onClick"],oe={class:"text-sm text-destructive font-medium"},se={key:2,class:"flex items-center justify-center py-20"},ae={class:"flex items-start justify-between"},ne={class:"flex items-center gap-2"},le={class:"text-sm font-medium"},re={class:"grid grid-cols-2 @sm:grid-cols-4 gap-4"},ce={class:"flex items-center gap-1.5 text-muted-foreground mb-2"},ie={class:"text-xs font-medium uppercase tracking-wide"},de={class:"text-2xl font-semibold tabular-nums"},ue={key:0,class:"flex items-center gap-1 mt-1"},me={class:"grid @lg:grid-cols-2 gap-6"},pe={class:"grid @lg:grid-cols-2 gap-6"},fe={class:"divide-y"},xe={class:"flex items-center gap-3 min-w-0"},ve={class:"text-muted-foreground w-5 text-right shrink-0"},ge={class:"truncate font-mono text-xs"},he={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ve={class:"text-muted-foreground text-xs w-16 text-right"},Ne={class:"text-muted-foreground text-xs w-16 text-right"},_e={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},ye={class:"divide-y"},Ce={class:"flex items-center gap-3 min-w-0"},we={class:"text-muted-foreground w-5 text-right shrink-0"},ke={class:"truncate"},be={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ee={class:"text-muted-foreground text-xs w-20 text-right"},Be={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},De={class:"grid @lg:grid-cols-2 gap-6"},Se={class:"space-y-3"},Te={class:"text-sm capitalize flex-1"},$e={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Pe={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ue={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Fe={class:"space-y-3"},ze={class:"text-sm flex-1"},Re={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Me={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ae={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Le=e.defineComponent({__name:"Overview",setup(qe){const{config:S}=F.useModule(),{moduleId:G}=F.useModuleRoute();F.useModuleBreadcrumbs(()=>[{label:"Overview"}]);const x=e.ref(!0),_=e.ref(null),y=e.ref("30"),h=e.ref([]),r=e.ref({}),I=e.ref({}),i=e.ref({}),z=e.ref(0),T=e.ref([]),$=e.ref([]),C=e.ref([]),w=e.ref([]),k=e.computed(()=>!!(S.serviceAccount&&S.propertyId));function v(s){return`/api/v1/modules/${G}${s}`}const O=[{label:"7 days",value:"7"},{label:"14 days",value:"14"},{label:"30 days",value:"30"},{label:"90 days",value:"90"}],m={sessions:"#3b82f6",users:"#8b5cf6",pageViews:"#10b981"},P={sessions:{label:"Sessions",color:m.sessions},totalUsers:{label:"Users",color:m.users}},U={screenPageViews:{label:"Page Views",color:m.pageViews}},V=(s,t)=>t,R=s=>s.sessions||0,X=s=>s.totalUsers||0,M=s=>s.screenPageViews||0,A=s=>{const t=h.value[Math.round(s)];if(!t)return"";const l=new Date(t.date);return`${l.getDate()}/${l.getMonth()+1}`},L=s=>{const t=h.value[Math.round(Number(s))];return t?new Date(t.date).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):""},W=e.computed(()=>[{label:"Sessions",value:d(r.value.sessions||0),icon:a.MousePointerClick,change:i.value.sessions},{label:"Users",value:d(r.value.totalUsers||0),icon:a.Users,change:i.value.totalUsers},{label:"Page Views",value:d(r.value.screenPageViews||0),icon:a.Eye,change:i.value.screenPageViews},{label:"Avg. Duration",value:H(r.value.averageSessionDuration||0),icon:a.Clock,change:i.value.averageSessionDuration},{label:"Engagement",value:`${((r.value.engagementRate||0)*100).toFixed(1)}%`,icon:a.Zap,change:i.value.engagementRate,positive:!0},{label:"Bounce Rate",value:`${((r.value.bounceRate||0)*100).toFixed(1)}%`,icon:(r.value.bounceRate||0)>.5?a.TrendingDown:a.TrendingUp,change:i.value.bounceRate,positive:!1},{label:"New Users",value:d(r.value.newUsers||0),icon:a.UserPlus,change:i.value.newUsers},{label:"Pages / Session",value:(r.value.screenPageViewsPerSession||0).toFixed(1),icon:a.Activity,change:i.value.screenPageViewsPerSession}]);function d(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:Math.round(s).toString()}function H(s){const t=Math.floor(s/60),l=Math.round(s%60);return t>0?`${t}m ${l}s`:`${l}s`}function b(s,t=!0){if(s==null)return{text:"—",cls:"text-muted-foreground",icon:a.Minus};const n=`${Math.abs(s).toFixed(1)}%`,f=s>0;return{text:n,cls:(t?f:!f)?"text-emerald-600 dark:text-emerald-400":"text-red-500 dark:text-red-400",icon:f?a.TrendingUp:a.TrendingDown}}function K(s){const t=s.toLowerCase();return t==="mobile"?a.Smartphone:t==="tablet"?a.Tablet:a.Monitor}async function E(){if(!k.value)return;x.value=!0,_.value=null;const s=`${y.value}daysAgo`;try{const[t,l,n,f,u,p]=await Promise.all([$fetch(v(`/report?startDate=${s}&endDate=today`)),$fetch(v("/realtime")).catch(()=>({activeUsers:0})),$fetch(v(`/top-pages?startDate=${s}&endDate=today&limit=10`)),$fetch(v(`/top-sources?startDate=${s}&endDate=today`)),$fetch(v(`/devices?startDate=${s}&endDate=today`)),$fetch(v(`/countries?startDate=${s}&endDate=today`))]);h.value=t.rows||[],r.value=t.totals||{},I.value=t.previousTotals||{},i.value=t.changes||{},z.value=l.activeUsers||0,T.value=n.rows||[],$.value=f.rows||[],C.value=u.rows||[],w.value=p.rows||[]}catch(t){console.error("Failed to fetch analytics data:",t),_.value=t?.data?.statusMessage||t?.message||"Failed to load analytics data"}finally{x.value=!1}}return e.watch(y,()=>E()),e.onMounted(()=>{k.value?E():x.value=!1}),(s,t)=>{const l=e.resolveComponent("Button"),n=e.resolveComponent("Card"),f=e.resolveComponent("Badge"),u=e.resolveComponent("CardTitle"),p=e.resolveComponent("CardHeader"),q=e.resolveComponent("ChartLegendContent"),j=e.resolveComponent("ChartContainer"),g=e.resolveComponent("CardContent");return e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("div",Z,[e.createElementVNode("div",null,[t[0]||(t[0]=e.createElementVNode("h1",{class:"text-2xl font-semibold"},"Analytics Overview",-1)),e.createElementVNode("p",J,"Property "+e.toDisplayString(e.unref(S).propertyId||"—"),1)]),k.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(O,o=>e.createElementVNode("button",{key:o.value,class:e.normalizeClass(["px-3 py-1.5 text-xs font-medium transition-colors",y.value===o.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"]),onClick:B=>y.value=o.value},e.toDisplayString(o.label),11,te)),64))]),e.createVNode(l,{variant:"outline",size:"icon",onClick:E,disabled:x.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.RefreshCw),{class:e.normalizeClass(["size-4",{"animate-spin":x.value}])},null,8,["class"])]),_:1},8,["disabled"])])):e.createCommentVNode("",!0)]),k.value?_.value?(e.openBlock(),e.createBlock(n,{key:1,class:"p-6 border-destructive/50 bg-destructive/5"},{default:e.withCtx(()=>[e.createElementVNode("p",oe,e.toDisplayString(_.value),1),e.createVNode(l,{variant:"outline",size:"sm",class:"mt-3",onClick:E},{default:e.withCtx(()=>[...t[2]||(t[2]=[e.createTextVNode("Retry",-1)])]),_:1})]),_:1})):x.value?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(e.unref(a.Loader2),{class:"size-8 animate-spin text-muted-foreground"})])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(n,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ae,[e.createElementVNode("div",ne,[t[3]||(t[3]=e.createElementVNode("span",{class:"relative flex h-2.5 w-2.5"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})],-1)),e.createElementVNode("span",le,e.toDisplayString(z.value)+" visitors",1),t[4]||(t[4]=e.createElementVNode("span",{class:"text-xs text-muted-foreground translate-y-0.25"},"in the last 30 minutes",-1))]),e.createVNode(f,{variant:"outline",class:"text-xs"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Live",-1)])]),_:1})])]),_:1}),e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createBlock(n,{key:o.label,class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ce,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{class:"size-3.5"})),e.createElementVNode("span",ie,e.toDisplayString(o.label),1)]),e.createElementVNode("p",de,e.toDisplayString(o.value),1),o.change!==void 0?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b(o.change,o.positive!==!1).icon),{class:e.normalizeClass(["size-3",b(o.change,o.positive!==!1).cls])},null,8,["class"])),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium",b(o.change,o.positive!==!1).cls])},e.toDisplayString(b(o.change,o.positive!==!1).text),3),t[6]||(t[6]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"vs prev.",-1))])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),e.createElementVNode("div",me,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[7]||(t[7]=[e.createTextVNode("Sessions & Users",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createVNode(j,{config:P,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:R,color:m.sessions,opacity:.1,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:R,color:m.sessions,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:X,color:m.users,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.st)(P,e.unref(D.Ue),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:P})]),_:1})]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[8]||(t[8]=[e.createTextVNode("Page Views",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createVNode(j,{config:U,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:M,color:m.pageViews,opacity:.15,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:M,color:m.pageViews,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.st)(U,e.unref(D.Ue),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:U})]),_:1})]),_:1})]),_:1})]),e.createElementVNode("div",pe,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("Top Pages",-1)])]),_:1})]),_:1}),e.createVNode(g,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.pagePath,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",xe,[e.createElementVNode("span",ve,e.toDisplayString(B+1),1),e.createElementVNode("span",ge,e.toDisplayString(o.pagePath),1)]),e.createElementVNode("div",he,[e.createElementVNode("span",Ve,e.toDisplayString(d(o.screenPageViews))+" views",1),e.createElementVNode("span",Ne,e.toDisplayString(d(o.totalUsers))+" users",1)])]))),128)),T.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_e,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[10]||(t[10]=[e.createTextVNode("Traffic Sources",-1)])]),_:1})]),_:1}),e.createVNode(g,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.sessionSource,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",Ce,[e.createElementVNode("span",we,e.toDisplayString(B+1),1),e.createVNode(e.unref(a.ArrowUpRight),{class:"size-3.5 text-muted-foreground shrink-0"}),e.createElementVNode("span",ke,e.toDisplayString(o.sessionSource||"(direct)"),1)]),e.createElementVNode("div",be,[e.createElementVNode("span",Ee,e.toDisplayString(d(o.sessions))+" sessions",1)])]))),128)),$.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Be,"No data available"))])]),_:1})]),_:1})]),e.createElementVNode("div",De,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("Devices",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createElementVNode("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.deviceCategory,class:"flex items-center gap-3"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(K(o.deviceCategory)),{class:"size-4 text-muted-foreground shrink-0"})),e.createElementVNode("span",Te,e.toDisplayString(o.deviceCategory),1),e.createElementVNode("div",$e,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(C.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Pe,e.toDisplayString(d(o.sessions)),1)]))),128)),C.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ue,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("Top Countries",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.country,class:"flex items-center gap-3"},[e.createVNode(e.unref(a.Globe),{class:"size-4 text-muted-foreground shrink-0"}),e.createElementVNode("span",ze,e.toDisplayString(o.country),1),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(w.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Me,e.toDisplayString(d(o.sessions)),1)]))),128)),w.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ae,"No data available"))])]),_:1})]),_:1})])],64)):(e.openBlock(),e.createBlock(n,{key:0,class:"p-8 text-center"},{default:e.withCtx(()=>[...t[1]||(t[1]=[e.createElementVNode("div",{class:"mx-auto max-w-md space-y-3"},[e.createElementVNode("p",{class:"text-lg font-medium"},"Setup required"),e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"Connect a Google Service Account and enter your GA4 Property ID in the module settings to start seeing analytics.")],-1)])]),_:1}))])}}});exports.default=Le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),U=require("@oneclick.dev/cms-kit");require("./index-BuzLn4Km.js");const D=require("@oneclick.dev/cms-kit/charts"),a=require("lucide-vue-next"),c=require("./index-DQYBP8Js.js"),N=require("./index-C4YUVWzJ.js"),Z={class:"w-full max-w-7xl mx-auto py-8 px-4 space-y-6"},J={class:"flex items-center justify-between"},Q={class:"text-muted-foreground text-sm mt-1"},Y={key:0,class:"flex items-center gap-2"},ee={class:"flex items-center border rounded-lg overflow-hidden"},te=["onClick"],oe={class:"text-sm text-destructive font-medium"},se={key:2,class:"flex items-center justify-center py-20"},ae={class:"flex items-start justify-between"},ne={class:"flex items-center gap-2"},le={class:"text-sm font-medium"},re={class:"grid grid-cols-2 @sm:grid-cols-4 gap-4"},ce={class:"flex items-center gap-1.5 text-muted-foreground mb-2"},ie={class:"text-xs font-medium uppercase tracking-wide"},de={class:"text-2xl font-semibold tabular-nums"},ue={key:0,class:"flex items-center gap-1 mt-1"},me={class:"grid @lg:grid-cols-2 gap-6"},pe={class:"grid @lg:grid-cols-2 gap-6"},fe={class:"divide-y"},xe={class:"flex items-center gap-3 min-w-0"},ge={class:"text-muted-foreground w-5 text-right shrink-0"},ve={class:"truncate font-mono text-xs"},he={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ve={class:"text-muted-foreground text-xs w-16 text-right"},Ne={class:"text-muted-foreground text-xs w-16 text-right"},_e={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},ye={class:"divide-y"},Ce={class:"flex items-center gap-3 min-w-0"},we={class:"text-muted-foreground w-5 text-right shrink-0"},ke={class:"truncate"},be={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ee={class:"text-muted-foreground text-xs w-20 text-right"},Be={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},De={class:"grid @lg:grid-cols-2 gap-6"},Se={class:"space-y-3"},Te={class:"text-sm capitalize flex-1"},$e={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Pe={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Fe={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Ue={class:"space-y-3"},ze={class:"text-sm flex-1"},Re={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Me={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ae={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Le=e.defineComponent({__name:"Overview",setup(qe){const{config:S}=U.useModule(),{moduleId:G}=U.useModuleRoute();U.useModuleBreadcrumbs(()=>[{label:"Overview"}]);const x=e.ref(!0),_=e.ref(null),y=e.ref("30"),h=e.ref([]),r=e.ref({}),I=e.ref({}),i=e.ref({}),z=e.ref(0),T=e.ref([]),$=e.ref([]),C=e.ref([]),w=e.ref([]),k=e.computed(()=>!!(S.serviceAccount&&S.propertyId));function g(s){return`/api/v1/modules/${G}${s}`}const O=[{label:"7 days",value:"7"},{label:"14 days",value:"14"},{label:"30 days",value:"30"},{label:"90 days",value:"90"}],m={sessions:"#3b82f6",users:"#8b5cf6",pageViews:"#10b981"},P={sessions:{label:"Sessions",color:m.sessions},totalUsers:{label:"Users",color:m.users}},F={screenPageViews:{label:"Page Views",color:m.pageViews}},V=(s,t)=>t,R=s=>s.sessions||0,X=s=>s.totalUsers||0,M=s=>s.screenPageViews||0,A=s=>{const t=h.value[Math.round(s)];if(!t)return"";const l=new Date(t.date);return`${l.getDate()}/${l.getMonth()+1}`},L=s=>{const t=h.value[Math.round(Number(s))];return t?new Date(t.date).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):""},W=e.computed(()=>[{label:"Sessions",value:d(r.value.sessions||0),icon:a.MousePointerClick,change:i.value.sessions},{label:"Users",value:d(r.value.totalUsers||0),icon:a.Users,change:i.value.totalUsers},{label:"Page Views",value:d(r.value.screenPageViews||0),icon:a.Eye,change:i.value.screenPageViews},{label:"Avg. Duration",value:H(r.value.averageSessionDuration||0),icon:a.Clock,change:i.value.averageSessionDuration},{label:"Engagement",value:`${((r.value.engagementRate||0)*100).toFixed(1)}%`,icon:a.Zap,change:i.value.engagementRate,positive:!0},{label:"Bounce Rate",value:`${((r.value.bounceRate||0)*100).toFixed(1)}%`,icon:(r.value.bounceRate||0)>.5?a.TrendingDown:a.TrendingUp,change:i.value.bounceRate,positive:!1},{label:"New Users",value:d(r.value.newUsers||0),icon:a.UserPlus,change:i.value.newUsers},{label:"Pages / Session",value:(r.value.screenPageViewsPerSession||0).toFixed(1),icon:a.Activity,change:i.value.screenPageViewsPerSession}]);function d(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:Math.round(s).toString()}function H(s){const t=Math.floor(s/60),l=Math.round(s%60);return t>0?`${t}m ${l}s`:`${l}s`}function b(s,t=!0){if(s==null)return{text:"—",cls:"text-muted-foreground",icon:a.Minus};const n=`${Math.abs(s).toFixed(1)}%`,f=s>0;return{text:n,cls:(t?f:!f)?"text-emerald-600 dark:text-emerald-400":"text-red-500 dark:text-red-400",icon:f?a.TrendingUp:a.TrendingDown}}function K(s){const t=s.toLowerCase();return t==="mobile"?a.Smartphone:t==="tablet"?a.Tablet:a.Monitor}async function E(){if(!k.value)return;x.value=!0,_.value=null;const s=`${y.value}daysAgo`;try{const[t,l,n,f,u,p]=await Promise.all([$fetch(g(`/report?startDate=${s}&endDate=today`)),$fetch(g("/realtime")).catch(()=>({activeUsers:0})),$fetch(g(`/top-pages?startDate=${s}&endDate=today&limit=10`)),$fetch(g(`/top-sources?startDate=${s}&endDate=today`)),$fetch(g(`/devices?startDate=${s}&endDate=today`)),$fetch(g(`/countries?startDate=${s}&endDate=today`))]);h.value=t.rows||[],r.value=t.totals||{},I.value=t.previousTotals||{},i.value=t.changes||{},z.value=l.activeUsers||0,T.value=n.rows||[],$.value=f.rows||[],C.value=u.rows||[],w.value=p.rows||[]}catch(t){console.error("Failed to fetch analytics data:",t),_.value=t?.data?.statusMessage||t?.message||"Failed to load analytics data"}finally{x.value=!1}}return e.watch(y,()=>E()),e.onMounted(()=>{k.value?E():x.value=!1}),(s,t)=>{const l=e.resolveComponent("Button"),n=e.resolveComponent("Card"),f=e.resolveComponent("Badge"),u=e.resolveComponent("CardTitle"),p=e.resolveComponent("CardHeader"),q=e.resolveComponent("ChartLegendContent"),j=e.resolveComponent("ChartContainer"),v=e.resolveComponent("CardContent");return e.openBlock(),e.createElementBlock("div",Z,[e.createElementVNode("div",J,[e.createElementVNode("div",null,[t[0]||(t[0]=e.createElementVNode("h1",{class:"text-2xl font-semibold"},"Analytics Overview",-1)),e.createElementVNode("p",Q,"Property "+e.toDisplayString(e.unref(S).propertyId||"—"),1)]),k.value?(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(O,o=>e.createElementVNode("button",{key:o.value,class:e.normalizeClass(["px-3 py-1.5 text-xs font-medium transition-colors",y.value===o.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"]),onClick:B=>y.value=o.value},e.toDisplayString(o.label),11,te)),64))]),e.createVNode(l,{variant:"outline",size:"icon",onClick:E,disabled:x.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.RefreshCw),{class:e.normalizeClass(["size-4",{"animate-spin":x.value}])},null,8,["class"])]),_:1},8,["disabled"])])):e.createCommentVNode("",!0)]),k.value?_.value?(e.openBlock(),e.createBlock(n,{key:1,class:"p-6 border-destructive/50 bg-destructive/5"},{default:e.withCtx(()=>[e.createElementVNode("p",oe,e.toDisplayString(_.value),1),e.createVNode(l,{variant:"outline",size:"sm",class:"mt-3",onClick:E},{default:e.withCtx(()=>[...t[2]||(t[2]=[e.createTextVNode("Retry",-1)])]),_:1})]),_:1})):x.value?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(e.unref(a.Loader2),{class:"size-8 animate-spin text-muted-foreground"})])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(n,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ae,[e.createElementVNode("div",ne,[t[3]||(t[3]=e.createElementVNode("span",{class:"relative flex h-2.5 w-2.5"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})],-1)),e.createElementVNode("span",le,e.toDisplayString(z.value)+" visitors",1),t[4]||(t[4]=e.createElementVNode("span",{class:"text-xs text-muted-foreground translate-y-0.25"},"in the last 30 minutes",-1))]),e.createVNode(f,{variant:"outline",class:"text-xs"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Live",-1)])]),_:1})])]),_:1}),e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createBlock(n,{key:o.label,class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ce,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{class:"size-3.5"})),e.createElementVNode("span",ie,e.toDisplayString(o.label),1)]),e.createElementVNode("p",de,e.toDisplayString(o.value),1),o.change!==void 0?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b(o.change,o.positive!==!1).icon),{class:e.normalizeClass(["size-3",b(o.change,o.positive!==!1).cls])},null,8,["class"])),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium",b(o.change,o.positive!==!1).cls])},e.toDisplayString(b(o.change,o.positive!==!1).text),3),t[6]||(t[6]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"vs prev.",-1))])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),e.createElementVNode("div",me,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[7]||(t[7]=[e.createTextVNode("Sessions & Users",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createVNode(j,{config:P,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:R,color:m.sessions,opacity:.1,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:R,color:m.sessions,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:X,color:m.users,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.componentToString)(P,e.unref(D.ChartTooltipContent),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:P})]),_:1})]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[8]||(t[8]=[e.createTextVNode("Page Views",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createVNode(j,{config:F,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:M,color:m.pageViews,opacity:.15,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:M,color:m.pageViews,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.componentToString)(F,e.unref(D.ChartTooltipContent),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:F})]),_:1})]),_:1})]),_:1})]),e.createElementVNode("div",pe,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("Top Pages",-1)])]),_:1})]),_:1}),e.createVNode(v,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.pagePath,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",xe,[e.createElementVNode("span",ge,e.toDisplayString(B+1),1),e.createElementVNode("span",ve,e.toDisplayString(o.pagePath),1)]),e.createElementVNode("div",he,[e.createElementVNode("span",Ve,e.toDisplayString(d(o.screenPageViews))+" views",1),e.createElementVNode("span",Ne,e.toDisplayString(d(o.totalUsers))+" users",1)])]))),128)),T.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_e,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[10]||(t[10]=[e.createTextVNode("Traffic Sources",-1)])]),_:1})]),_:1}),e.createVNode(v,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.sessionSource,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",Ce,[e.createElementVNode("span",we,e.toDisplayString(B+1),1),e.createVNode(e.unref(a.ArrowUpRight),{class:"size-3.5 text-muted-foreground shrink-0"}),e.createElementVNode("span",ke,e.toDisplayString(o.sessionSource||"(direct)"),1)]),e.createElementVNode("div",be,[e.createElementVNode("span",Ee,e.toDisplayString(d(o.sessions))+" sessions",1)])]))),128)),$.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Be,"No data available"))])]),_:1})]),_:1})]),e.createElementVNode("div",De,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("Devices",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createElementVNode("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.deviceCategory,class:"flex items-center gap-3"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(K(o.deviceCategory)),{class:"size-4 text-muted-foreground shrink-0"})),e.createElementVNode("span",Te,e.toDisplayString(o.deviceCategory),1),e.createElementVNode("div",$e,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(C.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Pe,e.toDisplayString(d(o.sessions)),1)]))),128)),C.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fe,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("Top Countries",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createElementVNode("div",Ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.country,class:"flex items-center gap-3"},[e.createVNode(e.unref(a.Globe),{class:"size-4 text-muted-foreground shrink-0"}),e.createElementVNode("span",ze,e.toDisplayString(o.country),1),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(w.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Me,e.toDisplayString(d(o.sessions)),1)]))),128)),w.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ae,"No data available"))])]),_:1})]),_:1})])],64)):(e.openBlock(),e.createBlock(n,{key:0,class:"p-8 text-center"},{default:e.withCtx(()=>[...t[1]||(t[1]=[e.createElementVNode("div",{class:"mx-auto max-w-md space-y-3"},[e.createElementVNode("p",{class:"text-lg font-medium"},"Setup required"),e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"Connect a Google Service Account and enter your GA4 Property ID in the module settings to start seeing analytics.")],-1)])]),_:1}))])}}});exports.default=Le;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),B=require("lucide-vue-next"),_=require("@oneclick.dev/cms-kit"),X=require("./index-CxETuRsG.js"),j=require("./utils-D6CaKJbp.js"),y=require("./index-ijdf0d9-.js"),J={class:"grid @md:grid-cols-2 @2xl:grid-cols-3 @3xl:grid-cols-4 @4xl:grid-cols-5 @5xl:grid-cols-6 gap-6"},Y=["onClick","onContextmenu"],Z=["src"],ee={class:"font-semibold"},te={class:"text-sm text-muted-foreground flex items-center gap-2"},oe={class:"flex items-center gap-2"},ne={key:0},le=e.defineComponent({__name:"GridView",props:{products:{type:Array,required:!0}},setup(T){const o=e.inject("selection"),{navigateTo:f}=_.useModuleRoute(),{hasPermission:g}=_.useModulePermissions(),v=(i,l)=>{const u=l.ctrlKey||l.metaKey;if(!l.shiftKey)if(u||o.value.length>0){const x=o.value.indexOf(i.id);x>-1?o.value.splice(x,1):o.value.push(i.id)}else o.value=[],f(i.id)},n=i=>{i.target.closest(".GRID_ITEM")||(o.value=[])},d=(i,l)=>{l.ctrlKey||l.metaKey?o.value.includes(i.id)?o.value.splice(o.value.indexOf(i.id),1):o.value.push(i.id):o.value.includes(i.id)||(o.value=[i.id])};return(i,l)=>(e.openBlock(),e.createElementBlock("div",{class:"@container mb-4 flex-1 select-none",onClick:l[0]||(l[0]=u=>o.value=[]),onContextmenu:n},[e.createElementVNode("div",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.products,u=>(e.openBlock(),e.createElementBlock("div",{key:u.id,onClick:e.withModifiers(k=>v(u,k),["stop"]),onContextmenu:k=>d(u,k),class:"GRID_ITEM cursor-pointer"},[e.createElementVNode("div",{class:e.normalizeClass(["aspect-square bg-muted rounded-xl overflow-hidden mb-2 transition-all duration-200",{"outline outline-4 outline-primary/50":e.unref(o).includes(u.id)}])},[u.featuredMedia?(e.openBlock(),e.createElementBlock("img",{key:0,src:u.featuredMedia,class:"w-full h-full object-cover pointer-events-none",draggable:"false"},null,8,Z)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",null,[e.createElementVNode("p",ee,e.toDisplayString(u.title),1),e.createElementVNode("p",te,[e.createElementVNode("span",oe,[u.status==="published"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[1]||(l[1]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-green-500"},null,-1)),l[2]||(l[2]=e.createTextVNode(" Published ",-1))],64)):u.status==="draft"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-blue-500"},null,-1)),l[4]||(l[4]=e.createTextVNode(" Draft ",-1))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-gray-300"},null,-1)),l[6]||(l[6]=e.createTextVNode(" Archived ",-1))],64))]),u.variantsTotal>1?(e.openBlock(),e.createElementBlock("span",ne,"| "+e.toDisplayString(u.variantsTotal)+" variants",1)):e.createCommentVNode("",!0)])])],40,Y))),128))])],32))}}),re={class:"flex items-center gap-2"},se={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},ae={key:1,class:"bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"},ie={key:2,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},ce=e.defineComponent({__name:"ListView",props:{products:{type:Array,required:!0}},setup(T){const o=e.inject("selection"),{navigateTo:f}=_.useModuleRoute(),{hasPermission:g}=_.useModulePermissions(),v=(n,d)=>{n?o.value.push(d):o.value=o.value.filter(i=>i!==d)};return(n,d)=>{const i=e.resolveComponent("TableHead"),l=e.resolveComponent("TableRow"),u=e.resolveComponent("TableHeader"),k=e.resolveComponent("Checkbox"),x=e.resolveComponent("TableCell"),m=e.resolveComponent("AvatarImage"),t=e.resolveComponent("AvatarFallback"),p=e.resolveComponent("Avatar"),C=e.resolveComponent("TableBody"),V=e.resolveComponent("Table"),N=e.resolveComponent("Card");return e.openBlock(),e.createBlock(N,{class:"w-full py-4 px-4"},{default:e.withCtx(()=>[e.createVNode(V,{class:"rounded overflow-hidden"},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(l,null,{default:e.withCtx(()=>[e.unref(o)?.length>0?(e.openBlock(),e.createBlock(i,{key:0})):e.createCommentVNode("",!0),e.createVNode(i,null,{default:e.withCtx(()=>[...d[1]||(d[1]=[e.createTextVNode("Title",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[2]||(d[2]=[e.createTextVNode("Status",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[3]||(d[3]=[e.createTextVNode(" Variants",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[4]||(d[4]=[e.createTextVNode("Price",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(C,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.products,c=>(e.openBlock(),e.createBlock(l,{key:c.id,onClick:w=>e.unref(f)(c.id),class:"cursor-pointer"},{default:e.withCtx(()=>[e.unref(o)?.length>0?(e.openBlock(),e.createBlock(x,{key:0},{default:e.withCtx(()=>[e.createVNode(k,{"model-value":e.unref(o)?.includes(c.id),"onUpdate:modelValue":w=>v(w,c.id),onClick:d[0]||(d[0]=e.withModifiers(()=>{},["prevent","stop"]))},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024)):e.createCommentVNode("",!0),e.createVNode(x,{class:"font-medium"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(p,{class:"size-12 rounded-xl"},{default:e.withCtx(()=>[e.createVNode(m,{src:c.media?.[0],class:"object-cover"},null,8,["src"]),e.createVNode(t,{class:"rounded-xl"})]),_:2},1024),e.createElementVNode("span",null,e.toDisplayString(c.title),1)])]),_:2},1024),e.createVNode(x,null,{default:e.withCtx(()=>[c.status==="published"?(e.openBlock(),e.createElementBlock("span",se,"Published")):c.status==="draft"?(e.openBlock(),e.createElementBlock("span",ae,"Draft")):c.status==="archived"?(e.openBlock(),e.createElementBlock("span",ie,"Archived")):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.variantsTotal),1)]),_:2},1024),e.createVNode(x,{class:"text-right"},{default:e.withCtx(()=>[e.createTextVNode(" € "+e.toDisplayString(c.price||0),1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]),_:1})}}}),de={class:"truncate"},ue={key:0},me={key:1},pe={key:2},fe={key:3},ve={class:"relative w-full max-w-sm items-center"},Ce={class:"truncate"},xe={class:"truncate"},ge={class:"flex items-center space-x-2 mb-4"},Ve={class:"flex items-center space-x-2 mb-4"},Ne={class:"flex items-center space-x-2 mb-4"},ke=e.defineComponent({__name:"FilterPopover",setup(T){const o=e.inject("filter"),f=e.inject("collections"),g=()=>{o.value={collections:[],published:!0,draft:!0,archived:!1}};return(v,n)=>{const d=e.resolveComponent("Button"),i=e.resolveComponent("PopoverTrigger"),l=e.resolveComponent("ComboboxTrigger"),u=e.resolveComponent("ComboboxAnchor"),k=e.resolveComponent("ComboboxInput"),x=e.resolveComponent("ComboboxEmpty"),m=e.resolveComponent("ComboboxItemIndicator"),t=e.resolveComponent("ComboboxItem"),p=e.resolveComponent("ScrollArea"),C=e.resolveComponent("ComboboxGroup"),V=e.resolveComponent("ComboboxList"),N=e.resolveComponent("Combobox"),c=e.resolveComponent("Checkbox"),w=e.resolveComponent("PopoverContent"),h=e.resolveComponent("Popover");return e.openBlock(),e.createBlock(h,null,{default:e.withCtx(()=>[e.createVNode(i,{asChild:""},{default:e.withCtx(()=>[e.createVNode(d,{variant:"outline"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.Filter),{class:"size-4"}),n[4]||(n[4]=e.createTextVNode(" Filter ",-1))]),_:1})]),_:1}),e.createVNode(w,{class:"w-64"},{default:e.withCtx(()=>[n[14]||(n[14]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Collection ",-1)),e.createVNode(N,{modelValue:e.unref(o).collections,"onUpdate:modelValue":n[0]||(n[0]=s=>e.unref(o).collections=s),by:"id",multiple:!0,class:"mb-6"},{default:e.withCtx(()=>[e.createVNode(u,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(l,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(d,{variant:"outline",class:"justify-between w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",de,[e.unref(o).collections.length===1?(e.openBlock(),e.createElementBlock("span",ue,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title),1)):e.unref(o).collections.length===2?(e.openBlock(),e.createElementBlock("span",me,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title)+", "+e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[1])?.title),1)):e.unref(o).collections.length>2?(e.openBlock(),e.createElementBlock("span",pe,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title)+", "+e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[1])?.title)+" + "+e.toDisplayString(e.unref(o).collections.length-2),1)):(e.openBlock(),e.createElementBlock("span",fe,"Select collection"))]),e.createVNode(e.unref(B.ChevronsUpDown),{class:"ml-2 size-4 shrink-0 opacity-50"})]),_:1})]),_:1})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createElementVNode("div",ve,[e.createVNode(k,{placeholder:"Select category..."})]),e.createVNode(x,null,{default:e.withCtx(()=>[...n[5]||(n[5]=[e.createTextVNode(" No category found. ",-1)])]),_:1}),e.unref(f)?.filter(s=>s.status==="published")?.length>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[7]||(n[7]=e.createElementVNode("p",{class:"px-2 py-1.5 text-sm font-medium mt-2"},"Published",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"max-h-[200px] overflow-y-auto"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f).filter(s=>s.status==="published"),s=>(e.openBlock(),e.createBlock(t,{key:s.id,value:s.id},{default:e.withCtx(()=>[n[6]||(n[6]=e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1)),e.createElementVNode("span",Ce,e.toDisplayString(s.title),1),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.Check),{class:e.normalizeClass(e.unref(j.classNames)("ml-auto size-4"))},null,8,["class"])]),_:1})]),_:2},1032,["value"]))),128))]),_:1})]),_:1})],64)):e.createCommentVNode("",!0),e.unref(f)?.filter(s=>s.status==="draft")?.length>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[n[9]||(n[9]=e.createElementVNode("p",{class:"px-2 py-1.5 text-sm font-medium"},"Drafts",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"max-h-[200px] overflow-y-auto"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f).filter(s=>s.status==="draft"),s=>(e.openBlock(),e.createBlock(t,{key:s.id,value:s.id},{default:e.withCtx(()=>[n[8]||(n[8]=e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1)),e.createElementVNode("span",xe,e.toDisplayString(s.title),1),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.Check),{class:e.normalizeClass(e.unref(j.classNames)("ml-auto size-4"))},null,8,["class"])]),_:1})]),_:2},1032,["value"]))),128))]),_:1})]),_:1})],64)):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["modelValue"]),n[15]||(n[15]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Status ",-1)),e.createElementVNode("div",ge,[e.createVNode(c,{id:"chk_published_products",modelValue:e.unref(o).published,"onUpdate:modelValue":n[1]||(n[1]=s=>e.unref(o).published=s)},null,8,["modelValue"]),n[10]||(n[10]=e.createElementVNode("label",{for:"chk_published_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show published products ",-1))]),e.createElementVNode("div",Ve,[e.createVNode(c,{id:"chk_draft_products",modelValue:e.unref(o).draft,"onUpdate:modelValue":n[2]||(n[2]=s=>e.unref(o).draft=s)},null,8,["modelValue"]),n[11]||(n[11]=e.createElementVNode("label",{for:"chk_draft_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show draft products ",-1))]),e.createElementVNode("div",Ne,[e.createVNode(c,{id:"chk_archived_products",modelValue:e.unref(o).archived,"onUpdate:modelValue":n[3]||(n[3]=s=>e.unref(o).archived=s)},null,8,["modelValue"]),n[12]||(n[12]=e.createElementVNode("label",{for:"chk_archived_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show archived products ",-1))]),e.unref(o).collections.length>0||!e.unref(o).published||!e.unref(o).draft||e.unref(o).archived?(e.openBlock(),e.createBlock(d,{key:0,variant:"secondary",class:"ml-auto my-2",size:"sm",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.RotateCcw),{class:"size-3"}),n[13]||(n[13]=e.createElementVNode("span",{class:"ml-0.5 text-xs"},"Reset filters",-1))]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})}}}),be=e.defineComponent({__name:"ProductContextMenu",emits:["selectAll","duplicateProduct","deleteProduct","deleteSelection"],setup(T,{emit:o}){const f=o,g=e.inject("products"),v=e.inject("selection"),n=e.inject("config"),{hasPermission:d}=_.useModulePermissions(),{navigateTo:i}=_.useModuleRoute(),l=e.computed(()=>v.value?.length!==1?null:g.value?.find(m=>m.id===v.value[0])),u=m=>{let t=n.previewUrl;t=t.replace("{{ id","{{id"),t=t.replace("id }}","id}}"),t=t.replace("{{id}}",m.id),t=t.replace("{{ slug","{{slug"),t=t.replace("slug }}","slug}}"),t=t.replace("{{slug}}",m.slug),window.open(t,"_blank")},k=async(m,t)=>{try{if(!["draft","published","archived"].includes(t))return;await _.useFirebaseIntegration(n.project).update(n.productCollection,m.id,{status:t}),m.status=t,y.toast.success("Product status changed")}catch{y.toast.error("Failed to change product status")}},x=async m=>{try{if(!["draft","published","archived"].includes(m))return;const t=_.useFirebaseIntegration(n.project),p=[];v.value.forEach(async C=>{p.push(t.update(n.productCollection,C,{status:m}))}),y.toast.promise(Promise.all(p),{loading:`Changing status of ${v.value.length} products...`,success:()=>{const C=v.value.length;return v.value.forEach(V=>{g.value.find(N=>N.id==V).status=m}),v.value=[],`Product status changed for ${C} products`},error:C=>"Failed to change product status"})}catch{y.toast.error("Failed to change product status")}};return(m,t)=>{const p=e.resolveComponent("ContextMenuTrigger"),C=e.resolveComponent("ContextMenuShortcut"),V=e.resolveComponent("ContextMenuItem"),N=e.resolveComponent("ContextMenuContent"),c=e.resolveComponent("ContextMenuSeparator"),w=e.resolveComponent("ContextMenuSubTrigger"),h=e.resolveComponent("ContextMenuCheckboxItem"),s=e.resolveComponent("ContextMenuSubContent"),$=e.resolveComponent("ContextMenuSub"),z=e.resolveComponent("ContextMenu");return e.openBlock(),e.createBlock(z,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"flex flex-1"},{default:e.withCtx(()=>[e.renderSlot(m.$slots,"default")]),_:3}),e.unref(v).length===0?(e.openBlock(),e.createBlock(N,{key:0,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(V,{inset:"",onClick:t[0]||(t[0]=b=>f("selectAll"))},{default:e.withCtx(()=>[t[13]||(t[13]=e.createTextVNode(" Select all ",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("⌘ + A",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(v).length===1&&l.value?(e.openBlock(),e.createBlock(N,{key:1,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(V,{inset:"",onClick:t[1]||(t[1]=b=>e.unref(i)(l.value.id))},{default:e.withCtx(()=>[...t[14]||(t[14]=[e.createTextVNode(" Edit product ",-1)])]),_:1}),e.createVNode(c),e.unref(n).previewUrl?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(V,{inset:"",onClick:t[2]||(t[2]=b=>u(l.value))},{default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Preview product ",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.ExternalLink),{class:"size-4"})]),_:1})]),_:1}),e.createVNode(c)],64)):e.createCommentVNode("",!0),e.createVNode(V,{inset:"",onClick:t[3]||(t[3]=b=>f("duplicateProduct",l.value))},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode(" Duplicate product ",-1)])]),_:1}),e.createVNode($,null,{default:e.withCtx(()=>[e.createVNode(w,{inset:""},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode(" Change status ",-1)])]),_:1}),e.createVNode(s,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[4]||(t[4]=b=>k(l.value,"draft")),modelValue:l.value.status==="draft"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[5]||(t[5]=b=>k(l.value,"published")),modelValue:l.value.status==="published"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[6]||(t[6]=b=>k(l.value,"archived")),modelValue:l.value.status==="archived"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1},8,["modelValue"])]),_:1})]),_:1}),e.createVNode(V,{inset:"",variant:"destructive",onClick:t[7]||(t[7]=b=>f("deleteProduct",l.value))},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode(" Delete product ",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(v).length>1?(e.openBlock(),e.createBlock(N,{key:2,class:"w-64"},{default:e.withCtx(()=>[e.createVNode($,null,{default:e.withCtx(()=>[e.createVNode(w,{inset:""},{default:e.withCtx(()=>[e.createTextVNode(" Change status ("+e.toDisplayString(e.unref(v).length)+") ",1)]),_:1}),e.createVNode(s,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[8]||(t[8]=b=>x("draft"))},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1}),e.createVNode(h,{onClick:t[9]||(t[9]=b=>x("published"))},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1}),e.createVNode(h,{onClick:t[10]||(t[10]=b=>x("archived"))},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(V,{inset:"",variant:"destructive",onClick:t[11]||(t[11]=b=>f("deleteSelection"))},{default:e.withCtx(()=>[e.createTextVNode(" Delete products ("+e.toDisplayString(e.unref(v).length)+") ",1)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:3})}}}),_e={class:"relative flex flex-col flex-1"},we={ref:"container",class:"flex items-center justify-between gap-4 w-full mt-12 mb-8"},he={class:"flex items-center gap-4"},ye={class:"text-lg whitespace-nowrap"},Be={class:"relative w-full max-w-sm items-center"},Ee={class:"absolute start-0 inset-y-0 flex items-center justify-center px-2"},Pe={class:"flex items-center gap-4"},Te={class:"flex flex-1"},Se=e.defineComponent({__name:"Overview",props:{config:{type:Object,required:!0}},async setup(T){let o,f;const g=T,{hasPermission:v}=_.useModulePermissions(),{navigateTo:n}=_.useModuleRoute(),{confirm:d}=_.useConfirmation();_.useModuleBreadcrumbs(()=>[]);const i=_.useFirebaseIntegration(g.config.project),l=e.ref([]),u=async()=>{const a=await i.find(g.config.productCollection);l.value=a||[]},k=e.useTemplateRef("container"),{width:x}=X.useElementSize(k),m=e.ref("grid"),t=e.ref(1),p=e.ref([]),C=e.ref(""),V=e.ref([]);V.value=([o,f]=e.withAsyncContext(()=>h()),o=await o,f(),o);const N=e.computed(()=>m.value==="grid"?x.value<768?6:x.value<896?8:x.value<1024?10:12:10),c=e.computed(()=>l.value.filter(a=>!(S.value.collections.length>0&&!a.collections?.some(r=>S.value.collections.includes(r))||!S.value.published&&a.status==="published"||!S.value.draft&&a.status==="draft"||!S.value.archived&&a.status==="archived")).filter(a=>a.title.toLowerCase().includes(C.value.toLowerCase())||a.slug.toLowerCase().includes(C.value.toLowerCase())||a.id.toLowerCase().includes(C.value.toLowerCase()))),w=e.computed(()=>{if(c.value.length<=N.value)return c.value;const a=(t.value-1)*N.value,r=a+N.value;return c.value.slice(a,r)});async function h(){if(!g.config.collectionsCollection)return[];const a=g.config.collectionsCollection.split(":");return a.length!==2?[]:(await i.get(a[0]))?.[a[1]]||[]}async function s(a){return(await i.find(g.config.productCollection,{filters:[{field:"slug",operator:"==",value:a}]})).length>0}const $=()=>{p.value=w.value.map(a=>a.id)},z=async a=>{try{let r={...a},P=r.slug+"-copy",M=2;for(;await s(P);)P=r.slug+"-copy-"+M,M++;r.id=void 0,r.createdAt=new Date,r.updatedAt=new Date,r.slug=P,r.status="draft",r.title=r.title+" (copy)";const F=await i.add(g.config.productCollection,r);n(F.id),y.toast.success("Product duplicated")}catch{y.toast.error("Failed to duplicate product")}},b=async a=>{if(await d(`Are you sure you want to delete "${a.title}"?`))try{await i.remove(g.config.productCollection,a.id),l.value=l.value.filter(P=>P.id!==a.id),p.value=[],y.toast.success("Product deleted")}catch{y.toast.error("Failed to delete product")}},A=async()=>{if(await d(`Are you sure you want to delete all selected products (${p.value.length})?`))try{p.value.forEach(async r=>{await i.remove(g.config.productCollection,r)}),l.value=l.value.filter(r=>!p.value.includes(r.id)),p.value=[],y.toast.success("Products deleted")}catch{y.toast.error("Failed to delete products")}},S=e.ref({collections:[],published:!0,draft:!0,archived:!1});e.watch(S,()=>{t.value=1});const I=a=>{a.target?.matches("input, textarea")||a.target?.isContentEditable||(a.key==="Escape"&&(p.value=[]),(a.metaKey||a.ctrlKey)&&a.key.toLowerCase()==="a"&&(a.preventDefault(),$()))};return e.onMounted(()=>{u(),window.addEventListener("keydown",I)}),e.onUnmounted(()=>{window.removeEventListener("keydown",I)}),e.provide("config",g.config),e.provide("filter",S),e.provide("products",l),e.provide("collections",V),e.provide("selection",p),(a,r)=>{const P=e.resolveComponent("Input"),M=e.resolveComponent("Button"),F=e.resolveComponent("SegmentedControlButton"),R=e.resolveComponent("SegmentedControl"),U=e.resolveComponent("PaginationFirst"),K=e.resolveComponent("PaginationPrev"),q=e.resolveComponent("PaginationListItem"),G=e.resolveComponent("PaginationEllipsis"),O=e.resolveComponent("PaginationNext"),H=e.resolveComponent("PaginationLast"),Q=e.resolveComponent("PaginationList"),W=e.resolveComponent("Pagination");return e.openBlock(),e.createElementBlock("div",_e,[e.createElementVNode("div",we,[e.createElementVNode("div",he,[e.createElementVNode("p",ye,e.toDisplayString(c.value?.length)+" products",1),e.createElementVNode("div",Be,[e.createVNode(P,{id:"search",type:"text",placeholder:"Search...",class:"pl-8",onKeydown:r[0]||(r[0]=e.withKeys(E=>C.value="",["escape"])),modelValue:C.value,"onUpdate:modelValue":r[1]||(r[1]=E=>C.value=E)},null,8,["modelValue"]),e.createElementVNode("span",Ee,[e.createVNode(e.unref(B.Search),{class:"size-4 text-muted-foreground"})])])]),e.createElementVNode("div",Pe,[p.value.length>0?(e.openBlock(),e.createBlock(M,{key:0,variant:"destructive",onClick:A},{default:e.withCtx(()=>[e.createTextVNode(" Delete Selection ("+e.toDisplayString(p.value.length)+") ",1)]),_:1})):e.createCommentVNode("",!0),e.unref(v)("create-product")?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(M,{variant:"outline",onClick:r[2]||(r[2]=E=>e.unref(n)("new"))},{default:e.withCtx(()=>[e.createVNode(e.unref(B.Plus),{class:"size-4"}),r[5]||(r[5]=e.createTextVNode(" New Product ",-1))]),_:1}),r[6]||(r[6]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1))],64)):e.createCommentVNode("",!0),e.createVNode(ke),r[7]||(r[7]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1)),e.createElementVNode("div",null,[e.createVNode(R,{modelValue:m.value,"onUpdate:modelValue":r[3]||(r[3]=E=>m.value=E),"aria-label":"View mode"},{default:e.withCtx(()=>[e.createVNode(F,{value:"grid"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.LayoutGrid),{class:"size-4"})]),_:1}),e.createVNode(F,{value:"list"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.List),{class:"size-4"})]),_:1})]),_:1},8,["modelValue"])])])],512),e.createElementVNode("div",Te,[e.createVNode(be,{onSelectAll:$,onDuplicateProduct:z,onDeleteProduct:b,onDeleteSelection:A},{default:e.withCtx(()=>[m.value==="grid"?(e.openBlock(),e.createBlock(le,{key:0,products:w.value},null,8,["products"])):(e.openBlock(),e.createBlock(ce,{key:1,products:w.value},null,8,["products"]))]),_:1})]),c.value?.length>N.value?(e.openBlock(),e.createBlock(W,{key:0,page:t.value,"onUpdate:page":r[4]||(r[4]=E=>t.value=E),"items-per-page":N.value,total:c.value?.length,"sibling-count":1,"show-edges":""},{default:e.withCtx(()=>[e.createVNode(Q,{class:"flex items-center gap-1"},{default:e.withCtx(({items:E})=>[e.createVNode(U),e.createVNode(K),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E,(D,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[D.type==="page"?(e.openBlock(),e.createBlock(q,{key:L,value:D.value,"as-child":""},{default:e.withCtx(()=>[e.createVNode(M,{class:"size-10 p-0",variant:D.value===t.value?"default":"outline"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:2},1032,["variant"])]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(G,{key:D.type,index:L},null,8,["index"]))],64))),256)),e.createVNode(O),e.createVNode(H)]),_:1})]),_:1},8,["page","items-per-page","total"])):e.createCommentVNode("",!0)])}}});exports.default=Se;
@@ -15,9 +15,7 @@ const Ee = { class: "grid @md:grid-cols-2 @2xl:grid-cols-3 @3xl:grid-cols-4 @4xl
15
15
  setup(U) {
16
16
  const n = K("selection"), { navigateTo: y } = J(), { hasPermission: S } = Y(), w = (f, u) => {
17
17
  const b = u.ctrlKey || u.metaKey;
18
- if (u.shiftKey)
19
- console.log("range");
20
- else if (b || n.value.length > 0) {
18
+ if (!u.shiftKey) if (b || n.value.length > 0) {
21
19
  const h = n.value.indexOf(f.id);
22
20
  h > -1 ? n.value.splice(h, 1) : n.value.push(f.id);
23
21
  } else