@oneclick.dev/cms-core-modules 0.0.120 → 0.0.122

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 (61) hide show
  1. package/dist/{ContentEditor-YFnqVZrX.js → ContentEditor-CoJjsV-m.js} +43 -43
  2. package/dist/{ContentEditor-W4YrQyBW.mjs → ContentEditor-DIwqplfB.mjs} +9952 -11359
  3. package/dist/{Detail-C8wQiDcv.js → Detail-BCUUNWvp.js} +1 -1
  4. package/dist/{Detail-CtItxMX4.mjs → Detail-B_scnidb.mjs} +1 -1
  5. package/dist/Detail-Cn9Bk0u0.mjs +852 -0
  6. package/dist/Detail-DGg_xXZc.js +1 -0
  7. package/dist/Detail-Dk8E6_uF.mjs +3731 -0
  8. package/dist/Detail-Sc2qZdxj.js +1 -0
  9. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-4_t0PPqM.mjs +78 -0
  10. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-D1b9_iiN.js +1 -0
  11. package/dist/Overview-CVgViW3c.mjs +852 -0
  12. package/dist/Overview-DEF-z7Yb.js +1 -0
  13. package/dist/SendPush-CgSBEex2.js +1 -0
  14. package/dist/SendPush-CmbjcQBL.mjs +680 -0
  15. package/dist/{agenda-BusN9-XG.js → agenda-B54F8cEr.js} +1 -1
  16. package/dist/{agenda-CJXKaIo0.mjs → agenda-BCKDYOeF.mjs} +1 -1
  17. package/dist/{availability-UUKdgidr.js → availability-C4v46rha.js} +1 -1
  18. package/dist/{availability-BP6GACqo.mjs → availability-DVT1Mdxq.mjs} +1 -1
  19. package/dist/{booking-data-BHfLyOlu.js → booking-data-A5JrLY4j.js} +1 -1
  20. package/dist/{booking-data-WCBcpOOo.mjs → booking-data-lZvSYna2.mjs} +1 -1
  21. package/dist/{exceptions-B8r2psu2.mjs → exceptions-DJHfvADv.mjs} +1 -1
  22. package/dist/{exceptions-BazAiy2s.js → exceptions-DKc8fO1S.js} +1 -1
  23. package/dist/{index-BiKWKrEs.js → index-Bk3yLv_G.js} +1 -1
  24. package/dist/{index-Dnn2SCSl.js → index-CZau1wR8.js} +1 -1
  25. package/dist/{index-DRqJOqUR.mjs → index-DE8rdSjd.mjs} +0 -22
  26. package/dist/{index-DJxex3Dt.mjs → index-DU3Ib10Z.mjs} +1 -1
  27. package/dist/index.cjs.js +1 -1
  28. package/dist/index.mjs +50 -37
  29. package/dist/languages-C_8yMQOH.mjs +4 -0
  30. package/dist/languages-Dqvk3X8G.js +1 -0
  31. package/dist/{orders-CAAuDhkQ.js → orders-BMosTk6r.js} +1 -1
  32. package/dist/{orders-B8C6u4iF.mjs → orders-CElKNc1v.mjs} +1 -1
  33. package/dist/{payment-BOOJ1O6M.mjs → payment-DSQ_2FIT.mjs} +1 -1
  34. package/dist/{payment-IxA9qiCV.js → payment-DlgYuea2.js} +1 -1
  35. package/dist/{refunds-CqGKm1NG.js → refunds-Cvw9N--u.js} +1 -1
  36. package/dist/{refunds-CI0qpJC0.mjs → refunds-xR936Ted.mjs} +1 -1
  37. package/dist/reports-BQT_GZzU.js +158 -0
  38. package/dist/reports-DksZCTOw.mjs +837 -0
  39. package/dist/{resources-dIZDh4Sz.mjs → resources-C-5BU9Ux.mjs} +1 -1
  40. package/dist/{resources-B75nXreU.js → resources-D04yKKVN.js} +1 -1
  41. package/dist/src/productCollections/components/detail/Subcollections.vue.d.ts +2 -0
  42. package/dist/src/productCollections/types.d.ts +1 -4
  43. package/dist/src/products/components/detail/variants/VariantList.vue.d.ts +48 -6
  44. package/dist/src/products/components/detail/variants/dialogs/VariantDialog.vue.d.ts +4 -0
  45. package/dist/src/push-notifications/config.d.ts +22 -0
  46. package/dist/src/push-notifications/index.d.ts +22 -0
  47. package/dist/src/push-notifications/types.d.ts +5 -0
  48. package/dist/{vee-validate-zod-CcOwoF6y.mjs → vee-validate-zod-SjDT8X35.mjs} +92 -90
  49. package/dist/{vee-validate-zod-ByykgYKJ.js → vee-validate-zod-VCmLnrtQ.js} +1 -1
  50. package/package.json +2 -2
  51. package/dist/Detail-C1Blq61w.mjs +0 -585
  52. package/dist/Detail-CPqug27l.js +0 -1
  53. package/dist/Detail-CjuhjPby.js +0 -1
  54. package/dist/Detail-Dnpnmy4-.mjs +0 -3477
  55. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-BXVf9gZW.mjs +0 -77
  56. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-CFFZ6r8i.js +0 -1
  57. package/dist/Overview-BWLxUksJ.mjs +0 -860
  58. package/dist/Overview-DAxCu9XC.js +0 -1
  59. package/dist/SendPush-COns44j7.js +0 -1
  60. package/dist/SendPush-CPIOjVX4.mjs +0 -184
  61. /package/dist/src/{productCollections/components/detail/SEO.vue.d.ts → appointments/pages/edit/reports.vue.d.ts} +0 -0
@@ -0,0 +1,3731 @@
1
+ import { defineComponent as ne, inject as pt, resolveComponent as m, openBlock as b, createBlock as R, withCtx as c, createVNode as r, createElementVNode as p, createTextVNode as P, isRef as Y, unref as g, createElementBlock as k, toDisplayString as z, createCommentVNode as F, computed as G, watch as te, useTemplateRef as Ie, ref as L, nextTick as Re, Fragment as J, renderList as ce, withModifiers as fe, onMounted as vt, normalizeClass as De, withKeys as hn, provide as Pt, withAsyncContext as yn } from "vue";
2
+ import { u as Ee, a as B, t as xn, o as Ne, b as ye, s as X, p as Oe, c as xe, d as Fe, e as Nt, f as Dn } from "./vee-validate-zod-SjDT8X35.mjs";
3
+ import { Info as Sn, GripVertical as ut, CircleX as Cn, Trash2 as wn, PlusCircle as Tt, X as Rt, Loader2 as ft, Search as It, ListFilter as kn, ChevronDown as $t, Ellipsis as Vn, ImagePlus as Et, Plus as Pn, CornerDownRight as Nn, Tag as Tn, ChevronRight as In, Archive as $n, Trash as En } from "lucide-vue-next";
4
+ import { animations as Ut } from "@formkit/drag-and-drop";
5
+ import { useConfirmation as Lt, useModuleRoute as Bt, useFirebaseIntegration as jt, useModulePermissions as Mn, useModuleBreadcrumbs as An } from "@oneclick.dev/cms-kit";
6
+ import { g as zn } from "./google-CvtuJwgk.mjs";
7
+ import { t as de } from "./index-RLz1QPrf.mjs";
8
+ const On = { class: "flex flex-col gap-4" }, Fn = { class: "flex flex-col" }, Rn = {
9
+ key: 0,
10
+ class: "text-red-500 text-sm mt-1"
11
+ }, Un = { class: "flex flex-col gap-4" }, Ln = { class: "flex flex-col" }, Bn = {
12
+ key: 0,
13
+ class: "text-red-500 text-sm mt-1"
14
+ }, jn = { class: "flex flex-col gap-4" }, Hn = { class: "flex flex-col" }, Xn = {
15
+ key: 0,
16
+ class: "text-red-500 text-sm mt-1"
17
+ }, Yn = /* @__PURE__ */ ne({
18
+ __name: "Main",
19
+ setup(e) {
20
+ const t = pt("sources"), n = pt("defaultSource"), { errors: o } = Ee(), { value: l } = B("title"), { value: s } = B("description"), { value: i } = B("media");
21
+ return (d, a) => {
22
+ const x = m("Label"), v = m("Input"), f = m("Textarea"), D = m("MediaPicker"), C = m("CardContent"), N = m("Card");
23
+ return b(), R(N, null, {
24
+ default: c(() => [
25
+ r(C, { class: "flex flex-col gap-4" }, {
26
+ default: c(() => [
27
+ p("div", On, [
28
+ p("div", Fn, [
29
+ r(x, {
30
+ for: "title",
31
+ class: "text-sm mb-2"
32
+ }, {
33
+ default: c(() => [...a[3] || (a[3] = [
34
+ P("Title", -1)
35
+ ])]),
36
+ _: 1
37
+ }),
38
+ r(v, {
39
+ type: "text",
40
+ id: "title",
41
+ placeholder: "T-shirt with red heart",
42
+ modelValue: g(l),
43
+ "onUpdate:modelValue": a[0] || (a[0] = (E) => Y(l) ? l.value = E : null)
44
+ }, null, 8, ["modelValue"]),
45
+ g(o).title ? (b(), k("p", Rn, z(g(o).title), 1)) : F("", !0)
46
+ ])
47
+ ]),
48
+ p("div", Un, [
49
+ p("div", Ln, [
50
+ r(x, {
51
+ for: "description",
52
+ class: "text-sm mb-2"
53
+ }, {
54
+ default: c(() => [...a[4] || (a[4] = [
55
+ P("Description", -1)
56
+ ])]),
57
+ _: 1
58
+ }),
59
+ r(f, {
60
+ id: "description",
61
+ placeholder: "Lovely T-shirt featuring a red heart",
62
+ modelValue: g(s),
63
+ "onUpdate:modelValue": a[1] || (a[1] = (E) => Y(s) ? s.value = E : null)
64
+ }, null, 8, ["modelValue"]),
65
+ g(o).description ? (b(), k("p", Bn, z(g(o).description), 1)) : F("", !0)
66
+ ])
67
+ ]),
68
+ p("div", jn, [
69
+ p("div", Hn, [
70
+ r(x, {
71
+ for: "media",
72
+ class: "text-sm mb-2"
73
+ }, {
74
+ default: c(() => [...a[5] || (a[5] = [
75
+ P("Media", -1)
76
+ ])]),
77
+ _: 1
78
+ }),
79
+ r(D, {
80
+ id: "media",
81
+ modelValue: g(i),
82
+ "onUpdate:modelValue": a[2] || (a[2] = (E) => Y(i) ? i.value = E : null),
83
+ sources: g(t),
84
+ defaultSource: g(n)
85
+ }, null, 8, ["modelValue", "sources", "defaultSource"]),
86
+ g(o).media ? (b(), k("p", Xn, z(g(o).media), 1)) : F("", !0)
87
+ ])
88
+ ])
89
+ ]),
90
+ _: 1
91
+ })
92
+ ]),
93
+ _: 1
94
+ });
95
+ };
96
+ }
97
+ }), Kn = { class: "grid grid-cols-2 gap-4 mb-4" }, Gn = { class: "relative" }, qn = {
98
+ key: 0,
99
+ class: "text-red-500 text-sm mt-1"
100
+ }, Jn = { class: "relative" }, Wn = { class: "absolute right-2 top-1/2 -translate-y-1/2" }, Zn = {
101
+ key: 0,
102
+ class: "text-red-500 text-sm mt-1"
103
+ }, Qn = { class: "flex items-center gap-2 mb-4" }, eo = { class: "flex items-center border-t mt-4 pt-4" }, to = { class: "relative" }, no = {
104
+ key: 0,
105
+ class: "text-red-500 text-sm mt-1"
106
+ }, oo = /* @__PURE__ */ ne({
107
+ __name: "Price",
108
+ setup(e) {
109
+ const { errors: t } = Ee(), { value: n } = B("price"), { value: o } = B("compareAtPrice"), { value: l } = B("isTaxable"), { value: s } = B("costPerItem");
110
+ return G(() => Number(n.value) > 0), (i, d) => {
111
+ const a = m("Label"), x = m("Input"), v = m("TooltipTrigger"), f = m("TooltipContent"), D = m("Tooltip"), C = m("Checkbox"), N = m("CardContent"), E = m("Card");
112
+ return b(), R(E, null, {
113
+ default: c(() => [
114
+ r(N, null, {
115
+ default: c(() => [
116
+ d[12] || (d[12] = p("h3", { class: "text-lg font-semibold mb-4" }, "Pricing", -1)),
117
+ p("div", Kn, [
118
+ p("div", null, [
119
+ r(a, {
120
+ for: "price",
121
+ class: "text-sm mb-2"
122
+ }, {
123
+ default: c(() => [...d[4] || (d[4] = [
124
+ P("Price", -1)
125
+ ])]),
126
+ _: 1
127
+ }),
128
+ p("div", Gn, [
129
+ r(x, {
130
+ type: "number",
131
+ id: "price",
132
+ class: "pl-10 no-spinner",
133
+ modelValue: g(n),
134
+ "onUpdate:modelValue": d[0] || (d[0] = (M) => Y(n) ? n.value = M : null)
135
+ }, null, 8, ["modelValue"]),
136
+ d[5] || (d[5] = p("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1))
137
+ ]),
138
+ g(t).price ? (b(), k("p", qn, z(g(t).price), 1)) : F("", !0)
139
+ ]),
140
+ p("div", null, [
141
+ r(a, {
142
+ for: "compare-at-price",
143
+ class: "text-sm mb-2"
144
+ }, {
145
+ default: c(() => [...d[6] || (d[6] = [
146
+ P("Compare-at price", -1)
147
+ ])]),
148
+ _: 1
149
+ }),
150
+ p("div", Jn, [
151
+ r(x, {
152
+ type: "number",
153
+ id: "compare-at-price",
154
+ class: "pl-10 no-spinner",
155
+ modelValue: g(o),
156
+ "onUpdate:modelValue": d[1] || (d[1] = (M) => Y(o) ? o.value = M : null)
157
+ }, null, 8, ["modelValue"]),
158
+ d[8] || (d[8] = p("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1)),
159
+ r(D, null, {
160
+ default: c(() => [
161
+ r(v, { "as-child": "" }, {
162
+ default: c(() => [
163
+ p("button", Wn, [
164
+ r(g(Sn), { class: "size-4 text-muted-foreground" })
165
+ ])
166
+ ]),
167
+ _: 1
168
+ }),
169
+ r(f, null, {
170
+ default: c(() => [...d[7] || (d[7] = [
171
+ p("p", null, [
172
+ P(" To display a markdown, enter a value higher than your price."),
173
+ p("br"),
174
+ P(" Often shown with a strikethrough (e.g. "),
175
+ p("span", { class: "font-semibold line-through" }, "€25,00"),
176
+ P("). ")
177
+ ], -1)
178
+ ])]),
179
+ _: 1
180
+ })
181
+ ]),
182
+ _: 1
183
+ })
184
+ ]),
185
+ g(t).compareAtPrice ? (b(), k("p", Zn, z(g(t).compareAtPrice), 1)) : F("", !0)
186
+ ])
187
+ ]),
188
+ p("div", Qn, [
189
+ r(C, {
190
+ id: "charge-tax",
191
+ modelValue: g(l),
192
+ "onUpdate:modelValue": d[2] || (d[2] = (M) => Y(l) ? l.value = M : null)
193
+ }, null, 8, ["modelValue"]),
194
+ r(a, {
195
+ for: "charge-tax",
196
+ class: "text-sm"
197
+ }, {
198
+ default: c(() => [...d[9] || (d[9] = [
199
+ P("Charge tax on this product", -1)
200
+ ])]),
201
+ _: 1
202
+ })
203
+ ]),
204
+ p("div", eo, [
205
+ p("div", null, [
206
+ r(a, {
207
+ for: "cost-per-item",
208
+ class: "text-sm mb-2"
209
+ }, {
210
+ default: c(() => [...d[10] || (d[10] = [
211
+ P("Cost per item", -1)
212
+ ])]),
213
+ _: 1
214
+ }),
215
+ p("div", to, [
216
+ r(x, {
217
+ type: "number",
218
+ id: "cost-per-item",
219
+ class: "pl-10 no-spinner",
220
+ modelValue: g(s),
221
+ "onUpdate:modelValue": d[3] || (d[3] = (M) => Y(s) ? s.value = M : null)
222
+ }, null, 8, ["modelValue"]),
223
+ d[11] || (d[11] = p("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1))
224
+ ]),
225
+ g(t).costPerItem ? (b(), k("p", no, z(g(t).costPerItem), 1)) : F("", !0)
226
+ ])
227
+ ])
228
+ ]),
229
+ _: 1
230
+ })
231
+ ]),
232
+ _: 1
233
+ });
234
+ };
235
+ }
236
+ }), lo = { class: "grid grid-cols-2 gap-4 mb-4" }, ro = { class: "flex items-center gap-2 mb-4" }, ao = {
237
+ key: 0,
238
+ class: "grid grid-cols-2 gap-4 mb-4"
239
+ }, so = { class: "flex items-center gap-2" }, io = /* @__PURE__ */ ne({
240
+ __name: "Inventory",
241
+ setup(e) {
242
+ const { errors: t } = Ee(), { value: n } = B("sku"), { value: o } = B("barcode"), { value: l } = B("trackInventory"), { value: s } = B("allowBackorder"), { value: i } = B("stock"), { value: d } = B("options"), { value: a } = B("variants"), x = G(() => a.value.reduce((v, f) => f.stock < 0 ? v : v + f.stock, 0));
243
+ return (v, f) => {
244
+ const D = m("Label"), C = m("Input"), N = m("Checkbox"), E = m("TooltipTrigger"), M = m("TooltipContent"), A = m("Tooltip"), S = m("CardContent"), w = m("Card");
245
+ return b(), R(w, null, {
246
+ default: c(() => [
247
+ r(S, null, {
248
+ default: c(() => [
249
+ f[12] || (f[12] = p("h3", { class: "text-lg font-semibold mb-4" }, "Inventory", -1)),
250
+ p("div", lo, [
251
+ p("div", null, [
252
+ r(D, {
253
+ for: "sku",
254
+ class: "text-sm mb-2"
255
+ }, {
256
+ default: c(() => [...f[6] || (f[6] = [
257
+ P("SKU (Stock Keeping Unit)", -1)
258
+ ])]),
259
+ _: 1
260
+ }),
261
+ r(C, {
262
+ id: "sku",
263
+ modelValue: g(n),
264
+ "onUpdate:modelValue": f[0] || (f[0] = (U) => Y(n) ? n.value = U : null)
265
+ }, null, 8, ["modelValue"])
266
+ ]),
267
+ p("div", null, [
268
+ r(D, {
269
+ for: "barcode",
270
+ class: "text-sm mb-2"
271
+ }, {
272
+ default: c(() => [...f[7] || (f[7] = [
273
+ P("Barcode (ISBN, UPC, GTIN, etc.)", -1)
274
+ ])]),
275
+ _: 1
276
+ }),
277
+ r(C, {
278
+ id: "barcode",
279
+ modelValue: g(o),
280
+ "onUpdate:modelValue": f[1] || (f[1] = (U) => Y(o) ? o.value = U : null)
281
+ }, null, 8, ["modelValue"])
282
+ ])
283
+ ]),
284
+ p("div", ro, [
285
+ r(N, {
286
+ id: "track-quantity",
287
+ modelValue: g(l),
288
+ "onUpdate:modelValue": f[2] || (f[2] = (U) => Y(l) ? l.value = U : null)
289
+ }, null, 8, ["modelValue"]),
290
+ r(D, {
291
+ for: "track-quantity",
292
+ class: "text-sm"
293
+ }, {
294
+ default: c(() => [...f[8] || (f[8] = [
295
+ P("Track quantity", -1)
296
+ ])]),
297
+ _: 1
298
+ })
299
+ ]),
300
+ g(l) ? (b(), k("div", ao, [
301
+ p("div", null, [
302
+ r(D, {
303
+ for: "stock",
304
+ class: "text-sm mb-2"
305
+ }, {
306
+ default: c(() => [...f[9] || (f[9] = [
307
+ P("Stock", -1)
308
+ ])]),
309
+ _: 1
310
+ }),
311
+ !g(d) || g(d)?.length === 0 ? (b(), R(C, {
312
+ key: 0,
313
+ id: "stock",
314
+ type: "number",
315
+ modelValue: g(i),
316
+ "onUpdate:modelValue": f[3] || (f[3] = (U) => Y(i) ? i.value = U : null),
317
+ class: "no-spinner"
318
+ }, null, 8, ["modelValue"])) : (b(), R(A, { key: 1 }, {
319
+ default: c(() => [
320
+ r(E, { class: "cursor-not-allowed" }, {
321
+ default: c(() => [
322
+ r(C, {
323
+ modelValue: x.value,
324
+ "onUpdate:modelValue": f[4] || (f[4] = (U) => x.value = U),
325
+ disabled: "",
326
+ class: "no-spinner"
327
+ }, null, 8, ["modelValue"])
328
+ ]),
329
+ _: 1
330
+ }),
331
+ r(M, null, {
332
+ default: c(() => [...f[10] || (f[10] = [
333
+ p("p", null, "Total stock of all variants", -1)
334
+ ])]),
335
+ _: 1
336
+ })
337
+ ]),
338
+ _: 1
339
+ }))
340
+ ])
341
+ ])) : F("", !0),
342
+ p("div", so, [
343
+ r(N, {
344
+ id: "continue-selling",
345
+ modelValue: g(s),
346
+ "onUpdate:modelValue": f[5] || (f[5] = (U) => Y(s) ? s.value = U : null)
347
+ }, null, 8, ["modelValue"]),
348
+ r(D, {
349
+ for: "continue-selling",
350
+ class: "text-sm"
351
+ }, {
352
+ default: c(() => [...f[11] || (f[11] = [
353
+ P("Continue selling when out of stock", -1)
354
+ ])]),
355
+ _: 1
356
+ })
357
+ ])
358
+ ]),
359
+ _: 1
360
+ })
361
+ ]),
362
+ _: 1
363
+ });
364
+ };
365
+ }
366
+ }), uo = { class: "flex items-center gap-2 mb-4" }, co = {
367
+ key: 0,
368
+ class: "grid grid-cols-2 gap-4 mb-4"
369
+ }, po = /* @__PURE__ */ ne({
370
+ __name: "Shipping",
371
+ setup(e) {
372
+ const { errors: t } = Ee(), { value: n } = B("isPhysicalProduct"), { value: o } = B("weight"), { value: l } = B("weightUnit");
373
+ return (s, i) => {
374
+ const d = m("Checkbox"), a = m("Label"), x = m("Input"), v = m("SelectValue"), f = m("SelectTrigger"), D = m("SelectItem"), C = m("SelectGroup"), N = m("SelectContent"), E = m("Select"), M = m("CardContent"), A = m("Card");
375
+ return b(), R(A, null, {
376
+ default: c(() => [
377
+ r(M, null, {
378
+ default: c(() => [
379
+ i[10] || (i[10] = p("h3", { class: "text-lg font-semibold mb-4" }, "Shipping", -1)),
380
+ p("div", uo, [
381
+ r(d, {
382
+ id: "is-physical-product",
383
+ modelValue: g(n),
384
+ "onUpdate:modelValue": i[0] || (i[0] = (S) => Y(n) ? n.value = S : null)
385
+ }, null, 8, ["modelValue"]),
386
+ r(a, {
387
+ for: "is-physical-product",
388
+ class: "text-sm"
389
+ }, {
390
+ default: c(() => [...i[3] || (i[3] = [
391
+ P("This is a physical product", -1)
392
+ ])]),
393
+ _: 1
394
+ })
395
+ ]),
396
+ g(n) ? (b(), k("div", co, [
397
+ p("div", null, [
398
+ r(a, {
399
+ for: "weight",
400
+ class: "text-sm mb-2"
401
+ }, {
402
+ default: c(() => [...i[4] || (i[4] = [
403
+ P("Weight", -1)
404
+ ])]),
405
+ _: 1
406
+ }),
407
+ r(x, {
408
+ id: "weight",
409
+ type: "number",
410
+ modelValue: g(o),
411
+ "onUpdate:modelValue": i[1] || (i[1] = (S) => Y(o) ? o.value = S : null),
412
+ class: "no-spinner"
413
+ }, null, 8, ["modelValue"])
414
+ ]),
415
+ p("div", null, [
416
+ r(a, {
417
+ for: "weight-unit",
418
+ class: "text-sm mb-2"
419
+ }, {
420
+ default: c(() => [...i[5] || (i[5] = [
421
+ P("Weight unit", -1)
422
+ ])]),
423
+ _: 1
424
+ }),
425
+ r(E, {
426
+ modelValue: g(l),
427
+ "onUpdate:modelValue": i[2] || (i[2] = (S) => Y(l) ? l.value = S : null)
428
+ }, {
429
+ default: c(() => [
430
+ r(f, null, {
431
+ default: c(() => [
432
+ r(v, { placeholder: "Select unit" })
433
+ ]),
434
+ _: 1
435
+ }),
436
+ r(N, null, {
437
+ default: c(() => [
438
+ r(C, null, {
439
+ default: c(() => [
440
+ r(D, { value: "lb" }, {
441
+ default: c(() => [...i[6] || (i[6] = [
442
+ P(" lb ", -1)
443
+ ])]),
444
+ _: 1
445
+ }),
446
+ r(D, { value: "oz" }, {
447
+ default: c(() => [...i[7] || (i[7] = [
448
+ P(" oz ", -1)
449
+ ])]),
450
+ _: 1
451
+ }),
452
+ r(D, { value: "kg" }, {
453
+ default: c(() => [...i[8] || (i[8] = [
454
+ P(" kg ", -1)
455
+ ])]),
456
+ _: 1
457
+ }),
458
+ r(D, { value: "g" }, {
459
+ default: c(() => [...i[9] || (i[9] = [
460
+ P(" g ", -1)
461
+ ])]),
462
+ _: 1
463
+ })
464
+ ]),
465
+ _: 1
466
+ })
467
+ ]),
468
+ _: 1
469
+ })
470
+ ]),
471
+ _: 1
472
+ }, 8, ["modelValue"])
473
+ ])
474
+ ])) : F("", !0)
475
+ ]),
476
+ _: 1
477
+ })
478
+ ]),
479
+ _: 1
480
+ });
481
+ };
482
+ }
483
+ });
484
+ function Q(e) {
485
+ e.preventDefault();
486
+ }
487
+ function ve(e) {
488
+ e.stopPropagation();
489
+ }
490
+ function Ht() {
491
+ const e = /* @__PURE__ */ new Map();
492
+ return [function(o, l) {
493
+ e.get(o) && e.get(o).forEach((s) => {
494
+ s(l);
495
+ });
496
+ }, function(o, l) {
497
+ const s = e.get(o) ?? [];
498
+ s.push(l), e.set(o, s);
499
+ }];
500
+ }
501
+ var [Xt, Yt] = Ht();
502
+ function fo(e, t) {
503
+ return e.source === t.source && e.flags.split("").sort().join("") === t.flags.split("").sort().join("");
504
+ }
505
+ function Ue(e, t, n = !0, o = ["__key"]) {
506
+ if (e === t) return !0;
507
+ if (typeof t == "object" && typeof e == "object" && e !== null && t !== null) {
508
+ if (e instanceof Map || e instanceof Set) return !1;
509
+ if (e instanceof Date && t instanceof Date)
510
+ return e.getTime() === t.getTime();
511
+ if (e instanceof RegExp && t instanceof RegExp)
512
+ return fo(e, t);
513
+ if (e === null || t === null) return !1;
514
+ const l = e, s = t;
515
+ if (Object.keys(l).length !== Object.keys(s).length) return !1;
516
+ for (const i of o)
517
+ if ((i in l || i in s) && l[i] !== s[i]) return !1;
518
+ for (const i in l)
519
+ if (!(i in s) || l[i] !== s[i] && !n || n && !Ue(l[i], s[i], n, o)) return !1;
520
+ return !0;
521
+ }
522
+ return !1;
523
+ }
524
+ function Kt(e) {
525
+ return e.split(" ").filter((t) => t);
526
+ }
527
+ function Me(e) {
528
+ return { x: e.clientX, y: e.clientY };
529
+ }
530
+ Array();
531
+ var bt = typeof window < "u", Z = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap();
532
+ function Gt() {
533
+ if (!bt) return !1;
534
+ if ("userAgentData" in navigator)
535
+ return navigator.userAgentData.mobile === !0;
536
+ const e = navigator.userAgent, t = /android|iphone|ipod/i.test(e), n = /iPad/.test(e) || e.includes("Macintosh") && navigator.maxTouchPoints > 1;
537
+ return t || n;
538
+ }
539
+ var go = {
540
+ affectedNodes: [],
541
+ coordinates: {
542
+ x: 0,
543
+ y: 0
544
+ },
545
+ currentTargetValue: void 0,
546
+ on: Yt,
547
+ emit: Xt,
548
+ originalZIndex: void 0,
549
+ pointerSelection: !1,
550
+ preventEnter: !1,
551
+ rootUserSelect: void 0,
552
+ nodePointerdown: void 0,
553
+ longPress: !1,
554
+ scrolling: !1,
555
+ longPressTimeout: void 0,
556
+ remapJustFinished: !1,
557
+ selectedNodes: [],
558
+ selectedParent: void 0,
559
+ preventSynthDrag: !1,
560
+ pointerDown: void 0,
561
+ lastScrollContainerX: null,
562
+ lastScrollContainerY: null,
563
+ rootScrollWidth: void 0,
564
+ rootScrollHeight: void 0,
565
+ dragItemRect: void 0,
566
+ windowScrollX: void 0,
567
+ windowScrollY: void 0,
568
+ lastScrollDirectionX: void 0,
569
+ lastScrollDirectionY: void 0,
570
+ scrollDebounceTimeout: void 0,
571
+ frameIdX: void 0,
572
+ frameIdY: void 0
573
+ }, _ = go, me = !1, Mt, ct;
574
+ function mo() {
575
+ _.scrollDebounceTimeout && clearTimeout(_.scrollDebounceTimeout), _.longPressTimeout && clearTimeout(_.longPressTimeout), _.frameIdX !== void 0 && cancelAnimationFrame(_.frameIdX), _.frameIdY !== void 0 && cancelAnimationFrame(_.frameIdY), _ = { ...{
576
+ affectedNodes: [],
577
+ coordinates: {
578
+ x: 0,
579
+ y: 0
580
+ },
581
+ on: Yt,
582
+ emit: Xt,
583
+ currentTargetValue: void 0,
584
+ originalZIndex: void 0,
585
+ pointerId: void 0,
586
+ preventEnter: !1,
587
+ remapJustFinished: !1,
588
+ selectedNodes: [],
589
+ nodePointerdown: void 0,
590
+ rootUserSelect: void 0,
591
+ preventSynthDrag: !1,
592
+ scrolling: !1,
593
+ selectedParent: void 0,
594
+ pointerSelection: !1,
595
+ synthScrollDirection: void 0,
596
+ draggedNodeDisplay: void 0,
597
+ synthDragScrolling: !1,
598
+ longPress: !1,
599
+ pointerDown: void 0,
600
+ longPressTimeout: void 0,
601
+ lastScrollContainerX: null,
602
+ lastScrollContainerY: null,
603
+ rootScrollWidth: void 0,
604
+ rootScrollHeight: void 0,
605
+ dragItemRect: void 0,
606
+ windowScrollX: void 0,
607
+ windowScrollY: void 0,
608
+ lastScrollDirectionX: void 0,
609
+ lastScrollDirectionY: void 0,
610
+ scrollDebounceTimeout: void 0,
611
+ frameIdX: void 0,
612
+ frameIdY: void 0
613
+ } };
614
+ }
615
+ function qt(e) {
616
+ return Object.assign(_, e), e.initialParent.data.emit("dragStarted", _), me = !1, _.emit("dragStarted", _), _;
617
+ }
618
+ function vo() {
619
+ _.activeState && Ce(_.activeState.parent, void 0, _), _.selectedState && Se(_.selectedState.nodes, _.selectedState.parent, _), _.selectedState = _.activeState = void 0;
620
+ }
621
+ function bo() {
622
+ if (_.pointerDown && (_.pointerDown.node.el.draggable = !0), _.pointerDown = void 0, !re(_)) return;
623
+ const e = _.currentParent.data.config;
624
+ re(_) && e.handleEnd(_);
625
+ }
626
+ function _o(e) {
627
+ e.key === "Escape" && (_.selectedState && Se(_.selectedState.nodes, _.selectedState.parent, _), _.activeState && Ce(_.activeState.parent, void 0, _), _.selectedState = _.activeState = void 0);
628
+ }
629
+ function ho(e) {
630
+ if (!ee(_)) return;
631
+ me = !0;
632
+ const t = _.initialParent.data.config.handleEnd;
633
+ t(_);
634
+ }
635
+ function yo(e) {
636
+ if (!ee(_)) return;
637
+ Q(e);
638
+ const { x: t, y: n } = Me(e);
639
+ ee(_) && Je({ x: t, y: n }, e, _);
640
+ }
641
+ function xo(e) {
642
+ if (!_.pointerDown || !_.pointerDown.validated) return;
643
+ const t = _.pointerDown.parent.data.config;
644
+ if (!(e.pointerType === "mouse" && !Gt()))
645
+ if (re(_))
646
+ re(_) && At(e, _);
647
+ else {
648
+ if (Q(e), t.longPress && !_.longPress) {
649
+ clearTimeout(_.longPressTimeout), _.longPress = !1;
650
+ return;
651
+ }
652
+ const n = t.draggedNodes(_.pointerDown);
653
+ t.dragstartClasses(_.pointerDown.node, n, t, !0);
654
+ const o = _.pointerDown.node.el.getBoundingClientRect(), l = Wo(
655
+ _.pointerDown.node,
656
+ _.pointerDown.parent,
657
+ e,
658
+ _,
659
+ n,
660
+ o
661
+ );
662
+ At(e, l, !0);
663
+ }
664
+ }
665
+ function Do({
666
+ parent: e,
667
+ getValues: t,
668
+ setValues: n,
669
+ config: o = {}
670
+ }) {
671
+ if (!bt) return;
672
+ Mt || (Mt = Ke(document, {
673
+ dragover: yo,
674
+ pointerdown: vo,
675
+ pointerup: bo,
676
+ keydown: _o,
677
+ drop: ho,
678
+ pointermove: xo,
679
+ pointercancel: le(o.handlePointercancel),
680
+ touchmove: (a) => {
681
+ ee(_) && a.cancelable && Q(a);
682
+ },
683
+ contextmenu: (a) => {
684
+ re(_) && Q(a);
685
+ }
686
+ })), Vo(e);
687
+ const [l, s] = Ht(), i = {
688
+ getValues: t,
689
+ setValues: n,
690
+ config: {
691
+ dragDropEffect: o.dragDropEffect ?? "move",
692
+ dragEffectAllowed: o.dragEffectAllowed ?? "move",
693
+ draggedNodes: zo,
694
+ dragstartClasses: Uo,
695
+ handleNodeKeydown: Bo,
696
+ handleDragstart: Fo,
697
+ handleNodeDragover: Qo,
698
+ handleParentDragover: el,
699
+ handleNodeDrop: Ho,
700
+ handleNodeFocus: Xo,
701
+ handleNodeBlur: Yo,
702
+ handlePointercancel: Go,
703
+ handleEnd: qo,
704
+ handleDragend: Ko,
705
+ handleParentFocus: Co,
706
+ handleNodePointerup: Jo,
707
+ handleNodePointerover: jo,
708
+ handleParentPointerover: tl,
709
+ handleParentScroll: Oo,
710
+ handleNodePointerdown: Ro,
711
+ handleNodeDragenter: ol,
712
+ handleNodeDragleave: ll,
713
+ handleParentDrop: ko,
714
+ multiDrag: o.multiDrag ?? !1,
715
+ nativeDrag: o.nativeDrag ?? !0,
716
+ performSort: So,
717
+ performTransfer: wo,
718
+ root: o.root ?? document,
719
+ setupNode: No,
720
+ setupNodeRemap: Wt,
721
+ reapplyDragClasses: To,
722
+ tearDownNode: $o,
723
+ tearDownNodeRemap: Io,
724
+ remapFinished: Mo,
725
+ threshold: {
726
+ horizontal: 0,
727
+ vertical: 0
728
+ },
729
+ ...o
730
+ },
731
+ enabledNodes: [],
732
+ abortControllers: {},
733
+ privateClasses: [],
734
+ on: s,
735
+ emit: l
736
+ };
737
+ new MutationObserver(Eo).observe(e, { childList: !0 }), Z.set(e, i), o.plugins?.forEach((a) => {
738
+ a(e)?.tearDown?.();
739
+ }), o.plugins?.forEach((a) => {
740
+ a(e)?.tearDown?.();
741
+ }), o.plugins?.forEach((a) => {
742
+ a(e)?.setup?.();
743
+ }), Po(e, i), Ge(e, !0);
744
+ }
745
+ function Jt(e, t, n, o, l, s) {
746
+ const { x: i, y: d } = Me(n), a = e.el.getBoundingClientRect();
747
+ return {
748
+ affectedNodes: [],
749
+ ascendingDirection: !1,
750
+ clonedDraggedEls: [],
751
+ coordinates: {
752
+ x: i,
753
+ y: d
754
+ },
755
+ draggedNode: {
756
+ el: e.el,
757
+ data: e.data
758
+ },
759
+ draggedNodes: o,
760
+ incomingDirection: void 0,
761
+ initialIndex: e.data.index,
762
+ initialParent: {
763
+ el: t.el,
764
+ data: t.data
765
+ },
766
+ currentParent: {
767
+ el: t.el,
768
+ data: t.data
769
+ },
770
+ longPress: t.data.config.longPress ?? !1,
771
+ longPressTimeout: void 0,
772
+ currentTargetValue: e.data.value,
773
+ scrollEls: [],
774
+ startLeft: l || i - (a?.left ?? 0),
775
+ startTop: s || d - (a?.top ?? 0),
776
+ targetIndex: e.data.index,
777
+ transferred: !1
778
+ };
779
+ }
780
+ function So({
781
+ parent: e,
782
+ draggedNodes: t,
783
+ targetNodes: n
784
+ }) {
785
+ Ge(e.el);
786
+ const o = t.map((a) => a.data.value), l = $e(e.el, e.data), s = t[0].data.index, i = [...e.data.enabledNodes], d = [
787
+ ...l.filter((a) => !o.some((x) => Ue(a, x)))
788
+ ];
789
+ d.splice(n[0].data.index, 0, ...o), "draggedNode" in _ && (_.currentTargetValue = n[0].data.value), gt(e.el, e.data, [...d]), e.data.config.onSort && e.data.config.onSort({
790
+ parent: {
791
+ el: e.el,
792
+ data: e.data
793
+ },
794
+ previousValues: [...l],
795
+ previousNodes: [...i],
796
+ nodes: [...e.data.enabledNodes],
797
+ values: [...d],
798
+ draggedNodes: t,
799
+ previousPosition: s,
800
+ position: n[0].data.index,
801
+ targetNodes: n,
802
+ state: _
803
+ });
804
+ }
805
+ function Ce(e, t, n) {
806
+ if (!t) {
807
+ n.activeState = void 0;
808
+ return;
809
+ }
810
+ n.activeState = {
811
+ node: t,
812
+ parent: e
813
+ };
814
+ }
815
+ function Se(e, t, n) {
816
+ const o = t.data.config.selectedClass;
817
+ if (!n.selectedState) return;
818
+ const l = Array.from(e);
819
+ ge(
820
+ e.map((s) => s.el),
821
+ o
822
+ );
823
+ for (const s of l) {
824
+ s.el.setAttribute("aria-selected", "false");
825
+ const i = n.selectedState.nodes.findIndex((d) => d.el === s.el);
826
+ i !== -1 && n.selectedState.nodes.splice(i, 1);
827
+ }
828
+ }
829
+ function Xe(e, t, n, o, l = !1) {
830
+ o.pointerSelection = l;
831
+ for (const s of t)
832
+ s.el.setAttribute("aria-selected", "true"), Te([s.el], e.data.config.selectedClass, !0);
833
+ o.selectedState = {
834
+ nodes: t,
835
+ parent: e
836
+ }, Ce(e, n, o);
837
+ }
838
+ function Co(e, t) {
839
+ const n = e.targetData.parent.data.enabledNodes[0];
840
+ n && (t.selectedState && t.selectedState.parent.el !== e.targetData.parent.el ? Ce(e.targetData.parent, n, t) : t.selectedState || Ce(e.targetData.parent, n, t));
841
+ }
842
+ function wo({
843
+ currentParent: e,
844
+ targetParent: t,
845
+ initialParent: n,
846
+ draggedNodes: o,
847
+ initialIndex: l,
848
+ targetNodes: s,
849
+ state: i
850
+ }) {
851
+ Ge(n.el);
852
+ const d = o.map((D) => D.data.value), a = [
853
+ ...$e(e.el, e.data).filter(
854
+ (D) => !d.some((C) => Ue(D, C))
855
+ )
856
+ ], x = $e(t.el, t.data), v = n.el === t.el && t.data.config.sortable === !1;
857
+ let f;
858
+ s.length ? (v ? f = l : t.data.config.sortable === !1 ? f = t.data.enabledNodes.length : f = s[0].data.index, x.splice(f, 0, ...d)) : (f = v ? l : t.data.enabledNodes.length, x.splice(f, 0, ...d)), gt(e.el, e.data, a), gt(t.el, t.data, x), t.data.config.onTransfer && t.data.config.onTransfer({
859
+ sourceParent: e,
860
+ targetParent: t,
861
+ initialParent: n,
862
+ draggedNodes: o,
863
+ targetIndex: f,
864
+ state: i,
865
+ targetNodes: s
866
+ }), e.data.config.onTransfer && e.data.config.onTransfer({
867
+ sourceParent: e,
868
+ targetParent: t,
869
+ initialParent: n,
870
+ draggedNodes: o,
871
+ targetIndex: f,
872
+ state: i,
873
+ targetNodes: s || []
874
+ });
875
+ }
876
+ function $e(e, t) {
877
+ return [...t.getValues(e)];
878
+ }
879
+ function gt(e, t, n) {
880
+ t.setValues(n, e);
881
+ }
882
+ function ko(e, t) {
883
+ ve(e.e), me = !0;
884
+ const n = t.initialParent.data.config.handleEnd;
885
+ n(t);
886
+ }
887
+ function Vo(e) {
888
+ const t = Z.get(e);
889
+ t && t.abortControllers.mainParent && t.abortControllers.mainParent.abort();
890
+ }
891
+ function ee(e) {
892
+ return "draggedNode" in e && !!e.draggedNode;
893
+ }
894
+ function re(e) {
895
+ return "synthDragging" in e && !!e.synthDragging;
896
+ }
897
+ function Po(e, t) {
898
+ t.abortControllers.mainParent = Ke(e, {
899
+ dragover: Ye(t.config.handleParentDragover),
900
+ handleParentPointerover: t.config.handleParentPointerover,
901
+ scroll: Ye(t.config.handleParentScroll),
902
+ drop: Ye(t.config.handleParentDrop),
903
+ hasNestedParent: (n) => {
904
+ const o = Z.get(n.target);
905
+ o && (o.nestedParent = n.detail.parent);
906
+ },
907
+ focus: Ye(t.config.handleParentFocus)
908
+ }), t.config.externalDragHandle && t.config.externalDragHandle.el && t.config.externalDragHandle.callback && (t.abortControllers.externalDragHandle = Ke(
909
+ t.config.externalDragHandle.el,
910
+ {
911
+ pointerdown: (n) => {
912
+ if (!t.config.externalDragHandle || !t.config.externalDragHandle.callback)
913
+ return;
914
+ const o = t.config.externalDragHandle.callback();
915
+ if (!We(o)) {
916
+ console.warn(
917
+ "No draggable item found from external drag handle callback"
918
+ );
919
+ return;
920
+ }
921
+ const l = ue.get(o);
922
+ if (!l) return;
923
+ const s = o.parentNode;
924
+ if (!(s instanceof HTMLElement)) return;
925
+ const i = Z.get(s);
926
+ i && (_.pointerDown = {
927
+ parent: {
928
+ el: s,
929
+ data: i
930
+ },
931
+ node: {
932
+ el: o,
933
+ data: l
934
+ },
935
+ validated: !0
936
+ }, o.draggable = !0);
937
+ }
938
+ }
939
+ ));
940
+ }
941
+ function No(e) {
942
+ const t = e.parent.data.config;
943
+ e.node.data.abortControllers.mainNode = Ke(e.node.el, {
944
+ keydown: le(t.handleNodeKeydown),
945
+ dragstart: le(t.handleDragstart),
946
+ dragover: le(t.handleNodeDragover),
947
+ dragenter: le(t.handleNodeDragenter),
948
+ dragleave: le(t.handleNodeDragleave),
949
+ dragend: le(t.handleDragend),
950
+ drop: le(t.handleNodeDrop),
951
+ focus: le(t.handleNodeFocus),
952
+ blur: le(t.handleNodeBlur),
953
+ pointerup: le(t.handleNodePointerup),
954
+ pointercancel: le(t.handlePointercancel),
955
+ pointerdown: le(t.handleNodePointerdown),
956
+ handleNodePointerover: t.handleNodePointerover,
957
+ touchmove: (n) => {
958
+ ee(_) && n.cancelable && Q(n);
959
+ },
960
+ contextmenu: (n) => {
961
+ re(_) && Q(n);
962
+ }
963
+ }), e.node.el.draggable = !0, t.reapplyDragClasses(e.node.el, e.parent.data), e.parent.data.config.plugins?.forEach((n) => {
964
+ n(e.parent.el)?.setupNode?.(e);
965
+ });
966
+ }
967
+ function Wt(e) {
968
+ ue.set(e.node.el, e.node.data), e.parent.data.config.plugins?.forEach((t) => {
969
+ t(e.parent.el)?.setupNodeRemap?.(e);
970
+ });
971
+ }
972
+ function To(e, t) {
973
+ if (!ee(_)) return;
974
+ const n = re(_) ? t.config.synthDropZoneClass : t.config.dropZoneClass;
975
+ _.draggedNode.el === e && Te([e], n, !0);
976
+ }
977
+ function Io(e) {
978
+ e.parent.data.config.plugins?.forEach((t) => {
979
+ t(e.parent.el)?.tearDownNodeRemap?.(e);
980
+ });
981
+ }
982
+ function $o(e) {
983
+ e.parent.data.config.plugins?.forEach((t) => {
984
+ t(e.parent.el)?.tearDownNode?.(e);
985
+ }), e.node.el.draggable = !1, e.node.data?.abortControllers?.mainNode && e.node.data?.abortControllers?.mainNode.abort();
986
+ }
987
+ function Eo(e) {
988
+ if (e.length === 1 && e[0].addedNodes.length === 1 && !(e[0].addedNodes[0] instanceof HTMLElement))
989
+ return;
990
+ const t = e[0].target;
991
+ !(t instanceof HTMLElement) || !Z.get(t) || Ge(t);
992
+ }
993
+ function Ge(e, t) {
994
+ const n = Z.get(e);
995
+ if (!n) return;
996
+ n.privateClasses = Array.from(e.classList);
997
+ const o = [], l = n.config;
998
+ for (let d = 0; d < e.children.length; d++) {
999
+ const a = e.children[d];
1000
+ if (!We(a) || a.id === "dnd-dragged-node-clone") continue;
1001
+ const x = ue.get(a);
1002
+ (t || !x) && l.tearDownNode({
1003
+ parent: {
1004
+ el: e,
1005
+ data: n
1006
+ },
1007
+ node: {
1008
+ el: a,
1009
+ data: x
1010
+ }
1011
+ }), !l.disabled && (!l.draggable || l.draggable && l.draggable(a)) && o.push(a);
1012
+ }
1013
+ if (o.length !== n.getValues(e).length && !l.disabled) {
1014
+ console.warn(
1015
+ "The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior."
1016
+ );
1017
+ return;
1018
+ }
1019
+ const s = n.getValues(e), i = [];
1020
+ for (let d = 0; d < o.length; d++) {
1021
+ const a = o[d], x = ue.get(a);
1022
+ if (l.draggableValue && !l.draggableValue(s[d])) continue;
1023
+ const v = Object.assign(
1024
+ x ?? {
1025
+ privateClasses: [],
1026
+ abortControllers: {}
1027
+ },
1028
+ {
1029
+ value: s[d],
1030
+ index: d
1031
+ }
1032
+ );
1033
+ if (!ee(_) && _.activeState && Ue(_.activeState.node.data.value, v.value) && Ce(
1034
+ {
1035
+ data: n,
1036
+ el: e
1037
+ },
1038
+ {
1039
+ el: a,
1040
+ data: v
1041
+ },
1042
+ _
1043
+ ), ee(_) && Ue(_.draggedNode.data.value, v.value)) {
1044
+ _.draggedNode.data = v, _.draggedNode.el = a;
1045
+ const f = _.draggedNodes.find(
1046
+ (D) => D.data.value === v.value
1047
+ );
1048
+ f && (f.el = a);
1049
+ }
1050
+ i.push({
1051
+ el: a,
1052
+ data: v
1053
+ }), (t || !x) && l.setupNode({
1054
+ parent: {
1055
+ el: e,
1056
+ data: n
1057
+ },
1058
+ node: {
1059
+ el: a,
1060
+ data: v
1061
+ }
1062
+ }), Wt({
1063
+ parent: {
1064
+ el: e,
1065
+ data: n
1066
+ },
1067
+ node: {
1068
+ el: a,
1069
+ data: v
1070
+ }
1071
+ });
1072
+ }
1073
+ Z.set(e, { ...n, enabledNodes: i }), l.remapFinished(n), n.config.plugins?.forEach((d) => {
1074
+ d(e)?.remapFinished?.();
1075
+ });
1076
+ }
1077
+ function Mo() {
1078
+ _.remapJustFinished = !0, "draggedNode" in _ && (_.affectedNodes = []);
1079
+ }
1080
+ function Ao(e) {
1081
+ return !!e.targetData.parent.data.config.nativeDrag;
1082
+ }
1083
+ function zo(e) {
1084
+ if (e.parent.data.config.multiDrag) {
1085
+ if (_.selectedState)
1086
+ return [
1087
+ e.node,
1088
+ ..._.selectedState?.nodes.filter(
1089
+ (t) => t.el !== e.node.el
1090
+ )
1091
+ ];
1092
+ } else return [e.node];
1093
+ return [];
1094
+ }
1095
+ function Oo(e) {
1096
+ ee(_) && (_.emit("scrollStarted", _), !re(_) && (_.preventEnter = !0, ct && clearTimeout(ct), ct = setTimeout(() => {
1097
+ _.preventEnter = !1, _.emit("scrollEnded", _);
1098
+ }, 100)));
1099
+ }
1100
+ function Fo(e, t) {
1101
+ const n = e.targetData.parent.data.config;
1102
+ if (!n.nativeDrag || !Ao(e) || !Zt({
1103
+ x: e.e.clientX,
1104
+ y: e.e.clientY,
1105
+ node: e.targetData.node,
1106
+ config: n
1107
+ })) {
1108
+ Q(e.e);
1109
+ return;
1110
+ }
1111
+ let o = n.draggedNodes({
1112
+ parent: e.targetData.parent,
1113
+ node: e.targetData.node
1114
+ });
1115
+ o.length === 0 && (o = [e.targetData.node]), n.dragstartClasses(e.targetData.node, o, n);
1116
+ const l = Lo(e, o);
1117
+ if (n.onDragstart) {
1118
+ const s = {
1119
+ parent: e.targetData.parent,
1120
+ values: $e(
1121
+ e.targetData.parent.el,
1122
+ e.targetData.parent.data
1123
+ ),
1124
+ draggedNode: l.draggedNode,
1125
+ draggedNodes: l.draggedNodes,
1126
+ position: l.initialIndex,
1127
+ state: l
1128
+ };
1129
+ n.onDragstart(s);
1130
+ }
1131
+ }
1132
+ function Ro(e, t) {
1133
+ if (ve(e.e), t.pointerDown = {
1134
+ parent: e.targetData.parent,
1135
+ node: e.targetData.node,
1136
+ validated: !1
1137
+ }, !Zt({
1138
+ x: e.e.clientX,
1139
+ y: e.e.clientY,
1140
+ node: e.targetData.node,
1141
+ config: e.targetData.parent.data.config
1142
+ }))
1143
+ return;
1144
+ t.pointerDown.validated = !0, Zo(e, t, e.targetData.node);
1145
+ const n = e.targetData.parent.data;
1146
+ let o = [e.targetData.node];
1147
+ const l = e.e.ctrlKey || e.e.metaKey, s = e.e.shiftKey, i = e.targetData.node;
1148
+ if (l && n.config.multiDrag) {
1149
+ t.selectedState ? t.selectedState.nodes.findIndex(
1150
+ (a) => a.el === i.el
1151
+ ) === -1 ? o = [...t.selectedState.nodes, i] : o = t.selectedState.nodes.filter(
1152
+ (a) => a.el !== i.el
1153
+ ) : o = [i], Xe(
1154
+ e.targetData.parent,
1155
+ o,
1156
+ e.targetData.node,
1157
+ t,
1158
+ !0
1159
+ );
1160
+ return;
1161
+ }
1162
+ if (s && n.config.multiDrag) {
1163
+ const d = e.targetData.parent.data.enabledNodes;
1164
+ if (t.selectedState && t.activeState)
1165
+ if (t.selectedState.parent.el !== e.targetData.parent.el) {
1166
+ Se(t.selectedState.nodes, t.selectedState.parent, t), t.selectedState = void 0;
1167
+ for (let a = 0; a <= i.data.index; a++)
1168
+ o.push(d[a]);
1169
+ } else {
1170
+ const [a, x] = t.activeState.node.data.index < e.targetData.node.data.index ? [
1171
+ t.activeState.node.data.index,
1172
+ e.targetData.node.data.index
1173
+ ] : [
1174
+ e.targetData.node.data.index,
1175
+ t.activeState.node.data.index
1176
+ ];
1177
+ o = d.slice(a, x + 1);
1178
+ }
1179
+ else
1180
+ for (let a = 0; a <= i.data.index; a++)
1181
+ o.push(d[a]);
1182
+ Xe(
1183
+ e.targetData.parent,
1184
+ o,
1185
+ e.targetData.node,
1186
+ t,
1187
+ !0
1188
+ );
1189
+ return;
1190
+ }
1191
+ t.selectedState?.nodes?.length ? t.selectedState.nodes.findIndex(
1192
+ (a) => a.el === e.targetData.node.el
1193
+ ) === -1 && (t.selectedState.parent.el !== e.targetData.parent.el ? Se(t.selectedState.nodes, e.targetData.parent, t) : n.config.multiDrag && Gt() ? o.push(...t.selectedState.nodes) : Se(t.selectedState.nodes, e.targetData.parent, t), Xe(
1194
+ e.targetData.parent,
1195
+ o,
1196
+ e.targetData.node,
1197
+ t,
1198
+ !0
1199
+ )) : Xe(
1200
+ e.targetData.parent,
1201
+ [e.targetData.node],
1202
+ e.targetData.node,
1203
+ t,
1204
+ !0
1205
+ );
1206
+ }
1207
+ function Uo(e, t, n, o = !1) {
1208
+ Te(
1209
+ t.map((l) => l.el),
1210
+ o ? n.synthDraggingClass : n.draggingClass
1211
+ ), setTimeout(() => {
1212
+ ge(
1213
+ t.map((l) => l.el),
1214
+ o ? n.synthDraggingClass : n.draggingClass
1215
+ ), Te(
1216
+ t.map((l) => l.el),
1217
+ o ? n.synthDragPlaceholderClass : n.dragPlaceholderClass
1218
+ ), Te(
1219
+ t.map((l) => l.el),
1220
+ o ? n.synthDropZoneClass : n.dropZoneClass
1221
+ ), ge(
1222
+ t.map((l) => l.el),
1223
+ n.selectedClass
1224
+ );
1225
+ });
1226
+ }
1227
+ function Lo(e, t) {
1228
+ ve(e.e);
1229
+ const n = qt(
1230
+ Jt(
1231
+ e.targetData.node,
1232
+ e.targetData.parent,
1233
+ e.e,
1234
+ t
1235
+ )
1236
+ );
1237
+ if (e.e.dataTransfer) {
1238
+ const o = e.targetData.parent.data.config;
1239
+ e.e.dataTransfer.dropEffect = o.dragDropEffect, e.e.dataTransfer.effectAllowed = o.dragEffectAllowed;
1240
+ let l;
1241
+ if (e.e.dataTransfer.setData("text/plain", ""), o.dragImage)
1242
+ l = o.dragImage(e, t);
1243
+ else {
1244
+ if (!o.multiDrag || t.length === 1)
1245
+ return e.targetData.node.el.style.zIndex = "9999", e.targetData.node.el.style.boxSizing = "border-box", e.e.dataTransfer.setDragImage(
1246
+ e.targetData.node.el,
1247
+ e.e.offsetX,
1248
+ e.e.offsetY
1249
+ ), n.originalZIndex = e.targetData.node.el.style.zIndex, n;
1250
+ {
1251
+ const s = document.createElement("div");
1252
+ s.setAttribute("id", "dnd-dragged-node-clone"), s.setAttribute("popover", "manual");
1253
+ for (const d of t) {
1254
+ const a = d.el.cloneNode(!0);
1255
+ a.id = d.el.id + "-clone", a.style.pointerEvents = "none", s.appendChild(a);
1256
+ }
1257
+ const { width: i } = t[0].el.getBoundingClientRect();
1258
+ Object.assign(s.style, {
1259
+ display: "flex",
1260
+ flexDirection: "column",
1261
+ width: `${i}px`,
1262
+ position: "absolute",
1263
+ pointerEvents: "none",
1264
+ zIndex: "9999",
1265
+ left: "-9999px",
1266
+ boxSizing: "border-box",
1267
+ background: "transparent",
1268
+ overflow: "hidden"
1269
+ }), e.targetData.parent.el.appendChild(s), s.showPopover(), s.getBoundingClientRect(), l = s, e.e.dataTransfer.setDragImage(
1270
+ l,
1271
+ e.e.offsetX,
1272
+ e.e.offsetY
1273
+ );
1274
+ }
1275
+ }
1276
+ setTimeout(() => {
1277
+ l?.remove();
1278
+ });
1279
+ }
1280
+ return n;
1281
+ }
1282
+ function Zt({
1283
+ x: e,
1284
+ y: t,
1285
+ node: n,
1286
+ config: o
1287
+ }) {
1288
+ if (o.externalDragHandle) return !1;
1289
+ if (!o.dragHandle) return !0;
1290
+ const l = n.el.querySelectorAll(o.dragHandle);
1291
+ if (!l) return !1;
1292
+ const s = o.root.elementFromPoint(e, t);
1293
+ if (!s) return !1;
1294
+ for (const i of Array.from(l))
1295
+ if (s === i || i.contains(s)) return !0;
1296
+ return !1;
1297
+ }
1298
+ function Bo(e) {
1299
+ }
1300
+ function jo(e) {
1301
+ e.detail.targetData.parent.el === e.detail.state.currentParent.el ? en(e.detail, e.detail.state) : qe(e.detail, e.detail.state);
1302
+ }
1303
+ function Ho(e, t) {
1304
+ const n = e.targetData.parent.data.config;
1305
+ n.nativeDrag && (ve(e.e), me = !0, n.handleEnd(t));
1306
+ }
1307
+ function Xo(e) {
1308
+ e.e.target !== e.e.currentTarget && _.pointerDown && (_.pointerDown.node.el.draggable = !1);
1309
+ }
1310
+ function Yo(e) {
1311
+ e.e.target !== e.e.currentTarget && _.pointerDown && (_.pointerDown.node.el.draggable = !0);
1312
+ }
1313
+ function Ko(e, t) {
1314
+ const n = e.targetData.parent.data.config;
1315
+ if (n.nativeDrag) {
1316
+ if (Q(e.e), ve(e.e), me) {
1317
+ me = !1;
1318
+ return;
1319
+ }
1320
+ n.handleEnd(t);
1321
+ }
1322
+ }
1323
+ function Go(e, t) {
1324
+ if (!re(t)) return;
1325
+ if (Q(e.e), me) {
1326
+ me = !1;
1327
+ return;
1328
+ }
1329
+ const n = Z.get(t.initialParent.el)?.config;
1330
+ n?.onDragend && n.onDragend({
1331
+ parent: t.currentParent,
1332
+ values: $e(t.currentParent.el, t.currentParent.data),
1333
+ draggedNode: t.draggedNode,
1334
+ draggedNodes: t.draggedNodes,
1335
+ state: t
1336
+ }), n?.handleEnd(t);
1337
+ }
1338
+ function qo(e) {
1339
+ e.draggedNode && (e.draggedNode.el.draggable = !0);
1340
+ const t = e.draggedNodes.map((v) => v.el), n = e.initialParent.data, o = re(e), l = Z.get(e.initialParent.el)?.config, s = o ? l?.synthDropZoneClass : l?.dropZoneClass, i = n?.config?.longPressClass, d = o ? n?.config?.synthDragPlaceholderClass : n?.config?.dragPlaceholderClass, a = e.originalZIndex;
1341
+ re(e) && (e.clonedDraggedNode && e.clonedDraggedNode.remove(), e.longPressTimeout && clearTimeout(e.longPressTimeout)), mt(e), e.lastScrollDirectionX = void 0, e.lastScrollDirectionY = void 0, e.preventEnter = !1, e.scrollDebounceTimeout && (clearTimeout(e.scrollDebounceTimeout), e.scrollDebounceTimeout = void 0), a !== void 0 && e.draggedNode && (e.draggedNode.el.style.zIndex = a), requestAnimationFrame(() => {
1342
+ ge(t, s), ge(t, i), ge(t, d);
1343
+ }), Se(e.draggedNodes, e.currentParent, e), Ce(e.currentParent, void 0, e);
1344
+ const x = { ...e };
1345
+ l?.onDragend?.({
1346
+ parent: x.currentParent,
1347
+ values: $e(
1348
+ x.currentParent.el,
1349
+ x.currentParent.data
1350
+ ),
1351
+ draggedNode: x.draggedNode,
1352
+ draggedNodes: x.draggedNodes,
1353
+ state: x
1354
+ }), e.emit("dragEnded", x), mo();
1355
+ }
1356
+ function Jo(e, t) {
1357
+ ve(e.e), !t.pointerSelection && t.selectedState && Se(t.selectedState.nodes, e.targetData.parent, t);
1358
+ const n = e.targetData.parent.data.config;
1359
+ t.pointerSelection = !1, "longPressTimeout" in t && t.longPressTimeout && clearTimeout(t.longPressTimeout), t.longPress = !1, ge(
1360
+ e.targetData.parent.data.enabledNodes.map((o) => o.el),
1361
+ n.longPressClass
1362
+ ), ee(t) && n.handleEnd(t);
1363
+ }
1364
+ function Wo(e, t, n, o, l, s) {
1365
+ const i = t.data.config;
1366
+ let d, a;
1367
+ const x = [
1368
+ "display",
1369
+ "flexDirection",
1370
+ "alignItems",
1371
+ "justifyContent",
1372
+ "padding",
1373
+ "paddingTop",
1374
+ "margin",
1375
+ "marginTop",
1376
+ "marginBottom",
1377
+ "marginLeft",
1378
+ "marginRight",
1379
+ "paddingBottom",
1380
+ "paddingLeft",
1381
+ "paddingRight",
1382
+ "border",
1383
+ "borderRadius",
1384
+ "background",
1385
+ "backgroundColor",
1386
+ "boxShadow",
1387
+ "font",
1388
+ "color",
1389
+ "lineHeight",
1390
+ "gap",
1391
+ "width",
1392
+ "height",
1393
+ "boxSizing",
1394
+ "overflow"
1395
+ ], v = (N, E) => {
1396
+ const M = window.getComputedStyle(N);
1397
+ x.forEach((A) => {
1398
+ E.style[A] = M[A];
1399
+ });
1400
+ }, f = (N, E = {}) => {
1401
+ Object.assign(N.style, {
1402
+ position: "absolute",
1403
+ zIndex: "9999",
1404
+ pointerEvents: "none",
1405
+ willChange: "transform",
1406
+ boxSizing: "border-box",
1407
+ opacity: "0",
1408
+ overflow: "hidden",
1409
+ width: `${s.width}px`,
1410
+ height: `${s.height}px`,
1411
+ ...E
1412
+ });
1413
+ };
1414
+ if (i.synthDragImage)
1415
+ a = i.synthDragImage(e, t, n, l), d = a.dragImage, d.setAttribute("popover", "manual"), f(d);
1416
+ else if (!i.multiDrag || l.length === 1)
1417
+ d = e.el.cloneNode(!0), v(e.el, d), d.setAttribute("popover", "manual"), f(d);
1418
+ else {
1419
+ const N = document.createElement("div");
1420
+ N.setAttribute("popover", "manual"), l.forEach((E) => {
1421
+ const M = E.el.cloneNode(!0);
1422
+ v(E.el, M), M.style.pointerEvents = "none", M.style.margin = "0", N.append(M);
1423
+ }), N.style.display = "flex", N.style.flexDirection = "column", N.style.padding = "0", N.style.margin = "0", N.style.position = "absolute", N.style.zIndex = "9999", N.style.pointerEvents = "none", d = N;
1424
+ }
1425
+ d.id = "dnd-dragged-node-clone", t.el.appendChild(d), d.showPopover();
1426
+ const D = {
1427
+ clonedDraggedEls: [],
1428
+ clonedDraggedNode: d,
1429
+ synthDragScrolling: !1,
1430
+ synthDragging: !0,
1431
+ rootScrollWidth: document.scrollingElement?.scrollWidth,
1432
+ rootScrollHeight: document.scrollingElement?.scrollHeight
1433
+ };
1434
+ return qt({
1435
+ ...Jt(
1436
+ e,
1437
+ t,
1438
+ n,
1439
+ l,
1440
+ a?.offsetX,
1441
+ a?.offsetY
1442
+ ),
1443
+ ...D
1444
+ });
1445
+ }
1446
+ function Zo(e, t, n) {
1447
+ const o = e.targetData.parent.data.config;
1448
+ t.longPressTimeout = setTimeout(() => {
1449
+ t && (t.longPress = !0, o.longPressClass && e.e.cancelable && Te([n.el], o.longPressClass), Q(e.e));
1450
+ }, o.longPressDuration || 1e3);
1451
+ }
1452
+ function mt(e, t = !0, n = !0) {
1453
+ t && (e.frameIdX !== void 0 && (cancelAnimationFrame(e.frameIdX), e.frameIdX = void 0), e.lastScrollDirectionX = void 0), n && (e.frameIdY !== void 0 && (cancelAnimationFrame(e.frameIdY), e.frameIdY = void 0), e.lastScrollDirectionY = void 0), !e.frameIdX && !e.frameIdY && (e.preventEnter = !1);
1454
+ }
1455
+ function Qt(e, t = !1) {
1456
+ const { x: n, y: o } = e.coordinates, l = e.startLeft ?? 0, s = e.startTop ?? 0, i = window.scrollX ?? 0, d = window.scrollY ?? 0, a = n - l + i, x = o - s + d;
1457
+ e.clonedDraggedNode.style.transform = `translate3d(${a}px, ${x}px, 0px)`, t && (e.clonedDraggedNode.style.opacity = "1", ge(
1458
+ e.draggedNodes.map((v) => v.el),
1459
+ e.initialParent.data.config?.longPressClass
1460
+ ));
1461
+ }
1462
+ function At(e, t, n = !1) {
1463
+ const o = Me(e);
1464
+ t.coordinates.x = o.x, t.coordinates.y = o.y, Qt(t, n), t.scrollDebounceTimeout && (clearTimeout(t.scrollDebounceTimeout), t.scrollDebounceTimeout = void 0), t.scrollDebounceTimeout = setTimeout(() => {
1465
+ re(t) && Je(t.coordinates, e, t);
1466
+ }, 16);
1467
+ const l = il(o);
1468
+ if (!l) {
1469
+ document.dispatchEvent(
1470
+ new CustomEvent("handleRootPointerover", {
1471
+ detail: {
1472
+ e,
1473
+ state: t
1474
+ }
1475
+ })
1476
+ );
1477
+ return;
1478
+ }
1479
+ const s = {
1480
+ e,
1481
+ targetData: l,
1482
+ state: t
1483
+ };
1484
+ "node" in l ? l.node.el.dispatchEvent(
1485
+ new CustomEvent("handleNodePointerover", {
1486
+ detail: s
1487
+ })
1488
+ ) : l.parent.el.dispatchEvent(
1489
+ new CustomEvent("handleParentPointerover", {
1490
+ detail: s
1491
+ })
1492
+ );
1493
+ }
1494
+ function Qo(e, t) {
1495
+ if (!e.targetData.parent.data.config.nativeDrag) return;
1496
+ const { x: o, y: l } = Me(e.e);
1497
+ t.coordinates.y = l, t.coordinates.x = o, Q(e.e), ve(e.e), ee(t) && Je({ x: o, y: l }, e.e, t), e.targetData.parent.el === t.currentParent?.el ? en(e, t) : qe(e, t);
1498
+ }
1499
+ function el(e, t) {
1500
+ if (!e.targetData.parent.data.config.nativeDrag) return;
1501
+ Q(e.e), ve(e.e);
1502
+ const { x: o, y: l } = Me(e.e);
1503
+ ee(t) && Je({ x: o, y: l }, e.e, t), qe(e, t);
1504
+ }
1505
+ function tl(e) {
1506
+ e.detail.targetData.parent.el !== e.detail.state.currentParent.el && qe(e.detail, e.detail.state);
1507
+ }
1508
+ function nl({
1509
+ currentParent: e,
1510
+ targetParent: t,
1511
+ initialParent: n,
1512
+ draggedNodes: o,
1513
+ state: l
1514
+ }) {
1515
+ if (t.el === e.el) return !1;
1516
+ const s = t.data.config;
1517
+ if (o[0].el.contains(t.el) || s.dropZone === !1) return !1;
1518
+ const i = n.data.config;
1519
+ return s.accepts ? s.accepts(
1520
+ t,
1521
+ n,
1522
+ e,
1523
+ l
1524
+ ) : !(!s.group || s.group !== i.group);
1525
+ }
1526
+ function ol(e, t) {
1527
+ Q(e.e);
1528
+ }
1529
+ function ll(e, t) {
1530
+ Q(e.e);
1531
+ }
1532
+ function rl(e, t, n, o) {
1533
+ if (t.affectedNodes.map((v) => v.data.value).includes(e.targetData.node.data.value))
1534
+ return !1;
1535
+ if (t.remapJustFinished)
1536
+ return t.remapJustFinished = !1, (e.targetData.node.data.value === t.currentTargetValue || t.draggedNodes.map((v) => v.el).includes(e.targetData.node.el)) && (t.currentTargetValue = e.targetData.node.data.value), !1;
1537
+ if (t.preventEnter) return !1;
1538
+ if (t.draggedNodes.map((v) => v.el).includes(e.targetData.node.el))
1539
+ return t.currentTargetValue = void 0, !1;
1540
+ if (e.targetData.node.data.value === t.currentTargetValue || e.targetData.parent.el !== t.currentParent?.el || e.targetData.parent.data.config.sortable === !1 || e.targetData.node.el.contains(t.draggedNodes[0].el)) return !1;
1541
+ const l = e.targetData.node.el.getBoundingClientRect(), s = t.draggedNode.el.getBoundingClientRect(), i = l.y - s.y, d = l.x - s.x;
1542
+ let a;
1543
+ Math.abs(i) > Math.abs(d) ? a = i > 0 ? "above" : "below" : a = d > 0 ? "left" : "right";
1544
+ const x = t.currentParent.data.config.threshold;
1545
+ switch (a) {
1546
+ case "left":
1547
+ if (n > l.x + l.width * x.horizontal)
1548
+ return t.incomingDirection = "left", !0;
1549
+ break;
1550
+ case "right":
1551
+ if (n < l.x + l.width * (1 - x.horizontal))
1552
+ return t.incomingDirection = "right", !0;
1553
+ break;
1554
+ case "above":
1555
+ if (o > l.y + l.height * x.vertical)
1556
+ return t.incomingDirection = "above", !0;
1557
+ break;
1558
+ case "below":
1559
+ if (o < l.y + l.height * (1 - x.vertical))
1560
+ return t.incomingDirection = "below", !0;
1561
+ break;
1562
+ }
1563
+ return !1;
1564
+ }
1565
+ function en(e, t) {
1566
+ const { x: n, y: o } = Me(e.e);
1567
+ if (!rl(e, t, n, o))
1568
+ return;
1569
+ const l = t.draggedNode.data.index > e.targetData.node.data.index ? [e.targetData.node.data.index, t.draggedNode.data.index] : [t.draggedNode.data.index, e.targetData.node.data.index];
1570
+ t.targetIndex = e.targetData.node.data.index, t.affectedNodes = e.targetData.parent.data.enabledNodes.filter(
1571
+ (s) => l[0] <= s.data.index && s.data.index <= l[1] && s.el !== t.draggedNode.el
1572
+ ), e.targetData.parent.data.config.performSort({
1573
+ parent: e.targetData.parent,
1574
+ draggedNodes: t.draggedNodes,
1575
+ targetNodes: [e.targetData.node]
1576
+ });
1577
+ }
1578
+ function le(e) {
1579
+ function t(n) {
1580
+ const o = ue.get(n);
1581
+ if (!o) return;
1582
+ const l = Z.get(n.parentNode);
1583
+ if (l)
1584
+ return {
1585
+ node: {
1586
+ el: n,
1587
+ data: o
1588
+ },
1589
+ parent: {
1590
+ el: n.parentNode,
1591
+ data: l
1592
+ }
1593
+ };
1594
+ }
1595
+ return (n) => {
1596
+ const o = t(n.currentTarget);
1597
+ if (o)
1598
+ return e(
1599
+ {
1600
+ e: n,
1601
+ targetData: o
1602
+ },
1603
+ _
1604
+ );
1605
+ };
1606
+ }
1607
+ function qe(e, t) {
1608
+ Q(e.e), nl({
1609
+ currentParent: t.currentParent,
1610
+ targetParent: e.targetData.parent,
1611
+ initialParent: t.initialParent,
1612
+ draggedNodes: t.draggedNodes,
1613
+ state: t
1614
+ }) && (e.targetData.parent.data.config.performTransfer({
1615
+ currentParent: t.currentParent,
1616
+ targetParent: e.targetData.parent,
1617
+ initialParent: t.initialParent,
1618
+ draggedNodes: t.draggedNodes,
1619
+ initialIndex: t.initialIndex,
1620
+ state: t,
1621
+ targetNodes: "node" in e.targetData ? [e.targetData.node] : []
1622
+ }), t.currentParent = e.targetData.parent, t.transferred = !0);
1623
+ }
1624
+ function Ye(e) {
1625
+ function t(n) {
1626
+ const o = Z.get(n);
1627
+ if (o)
1628
+ return {
1629
+ parent: {
1630
+ el: n,
1631
+ data: o
1632
+ }
1633
+ };
1634
+ }
1635
+ return (n) => {
1636
+ const o = t(n.currentTarget);
1637
+ if (o)
1638
+ return e(
1639
+ {
1640
+ e: n,
1641
+ targetData: o
1642
+ },
1643
+ _
1644
+ );
1645
+ };
1646
+ }
1647
+ function Te(e, t, n = !1) {
1648
+ function o(l, s) {
1649
+ ue.set(l, s);
1650
+ }
1651
+ for (const l of e) {
1652
+ const s = ue.get(l), i = al(l, t, s, n);
1653
+ i && o(l, i);
1654
+ }
1655
+ }
1656
+ function al(e, t, n, o = !1) {
1657
+ if (!t) return;
1658
+ const l = Kt(t);
1659
+ if (!l.length) return;
1660
+ if (!n) {
1661
+ e.classList.add(...l);
1662
+ return;
1663
+ }
1664
+ const s = [];
1665
+ for (const i of l)
1666
+ e.classList.contains(i) ? (
1667
+ // Only add to privateClasses if the element already had the class
1668
+ // AND omitAppendPrivateClass is specifically false for THIS call.
1669
+ e.classList.contains(i) && o === !1 && s.push(i)
1670
+ ) : e.classList.add(i);
1671
+ return n.privateClasses = s, n;
1672
+ }
1673
+ function ge(e, t) {
1674
+ if (!t) return;
1675
+ const n = Kt(t);
1676
+ if (n.length)
1677
+ for (const o of e) {
1678
+ if (!We(o)) {
1679
+ o.classList.remove(...n);
1680
+ continue;
1681
+ }
1682
+ const l = ue.get(o) || Z.get(o);
1683
+ if (l)
1684
+ for (const s of n)
1685
+ l.privateClasses.includes(s) || o.classList.remove(s);
1686
+ }
1687
+ }
1688
+ function zt(e, t, n, o, l) {
1689
+ const i = l.axis === "x", d = e === document.scrollingElement, a = i ? "scrollLeft" : "scrollTop", x = i ? "clientWidth" : "clientHeight", v = i ? "offsetWidth" : "offsetHeight", f = i ? "scrollWidth" : "scrollHeight", D = i ? t.clientX : t.clientY, C = i ? o.left : o.top, N = i ? n.overflowX : n.overflowY;
1690
+ if (d) {
1691
+ const E = e[a], M = e[x], A = E > 0, S = E + M < (i ? l.state.rootScrollWidth || 0 : e[f]);
1692
+ return i ? {
1693
+ left: A && D < M * 0.075,
1694
+ right: S && D > M * (1 - 0.075)
1695
+ } : {
1696
+ up: A && D < M * 0.075,
1697
+ down: S && D > M * (1 - 0.075)
1698
+ };
1699
+ }
1700
+ if ((N === "auto" || N === "scroll") && e !== document.body && e !== document.documentElement) {
1701
+ const E = e[f], M = e[v], A = e[a], S = A > 0, w = A < E - M;
1702
+ return i ? {
1703
+ left: S && D < C + M * 0.075,
1704
+ right: w && D > C + M * (1 - 0.075)
1705
+ } : {
1706
+ up: S && D < C + M * 0.075,
1707
+ down: w && D > C + M * (1 - 0.075)
1708
+ };
1709
+ }
1710
+ return i ? { left: !1, right: !1 } : { up: !1, down: !1 };
1711
+ }
1712
+ function sl(e, t, n, o) {
1713
+ if (!ee(n) || !n.draggedNode)
1714
+ return;
1715
+ n.preventEnter = !0;
1716
+ const l = o.axis === "x", s = o.direction === "positive" ? 1 : -1, i = 20, d = l ? "lastScrollDirectionX" : "lastScrollDirectionY", a = l ? "frameIdX" : "frameIdY";
1717
+ n[a] !== void 0 && (cancelAnimationFrame(n[a]), n[a] = void 0), n[d] = o.direction;
1718
+ const x = () => {
1719
+ if (!ee(n) || !n.draggedNode) {
1720
+ n[a] !== void 0 && (cancelAnimationFrame(n[a]), n[a] = void 0);
1721
+ return;
1722
+ }
1723
+ const v = l ? "scrollLeft" : "scrollTop", f = l ? "clientWidth" : "clientHeight", D = l ? "scrollWidth" : "scrollHeight", C = e[v], N = e[f], E = e[D];
1724
+ if (!(s > 0 ? C + N < E : C > 0)) {
1725
+ n[a] = void 0, n[d] = void 0;
1726
+ return;
1727
+ }
1728
+ e[v] += i * s, re(n) && Qt(n), n[a] = requestAnimationFrame(x);
1729
+ };
1730
+ n[a] = requestAnimationFrame(x);
1731
+ }
1732
+ function Ot(e, t, n) {
1733
+ const o = e.getBoundingClientRect();
1734
+ return t >= o.left && t <= o.right && n >= o.top && n <= o.bottom;
1735
+ }
1736
+ function Je(e, t, n) {
1737
+ if (!ee(n) || !n.draggedNode)
1738
+ return;
1739
+ mt(n);
1740
+ const { x: o, y: l } = e;
1741
+ let s = !1;
1742
+ const i = (a, x, v) => {
1743
+ sl(v, t, n, { axis: a, direction: x }), s = !0;
1744
+ }, d = (a) => {
1745
+ const x = window.getComputedStyle(a), v = a.getBoundingClientRect(), f = zt(a, t, x, v, {
1746
+ axis: "x",
1747
+ state: n
1748
+ }), D = zt(a, t, x, v, { axis: "y" });
1749
+ (f.left || f.right) && (n.lastScrollContainerX = a, i("x", f.right ? "positive" : "negative", a)), (D.up || D.down) && (n.lastScrollContainerY = a, i("y", D.down ? "positive" : "negative", a));
1750
+ };
1751
+ if (n.lastScrollContainerX && Ot(n.lastScrollContainerX, o, l) && d(n.lastScrollContainerX), !s && n.lastScrollContainerY && Ot(n.lastScrollContainerY, o, l) && d(n.lastScrollContainerY), !s) {
1752
+ let a = document.elementFromPoint(o, l);
1753
+ for (; a && !(s && n.lastScrollContainerX && n.lastScrollContainerY); )
1754
+ a instanceof HTMLElement && d(a), a = a.parentElement;
1755
+ }
1756
+ if (!s) {
1757
+ const a = document.scrollingElement;
1758
+ a instanceof HTMLElement && d(a);
1759
+ }
1760
+ s || mt(n);
1761
+ }
1762
+ function il(e) {
1763
+ let t = document.elementFromPoint(e.x, e.y);
1764
+ if (!We(t)) return;
1765
+ let n, o = !0;
1766
+ for (; t && o; ) {
1767
+ if (ue.has(t) || Z.has(t)) {
1768
+ o = !1, n = Z.has(t);
1769
+ break;
1770
+ }
1771
+ t = t.parentNode;
1772
+ }
1773
+ if (n) {
1774
+ const l = Z.get(t);
1775
+ return l ? {
1776
+ parent: {
1777
+ el: t,
1778
+ data: l
1779
+ }
1780
+ } : void 0;
1781
+ } else {
1782
+ const l = ue.get(t);
1783
+ if (!l) return;
1784
+ const s = Z.get(t.parentNode);
1785
+ return s ? {
1786
+ node: {
1787
+ el: t,
1788
+ data: l
1789
+ },
1790
+ parent: {
1791
+ el: t.parentNode,
1792
+ data: s
1793
+ }
1794
+ } : void 0;
1795
+ }
1796
+ }
1797
+ function We(e) {
1798
+ return e instanceof HTMLElement && e.parentNode instanceof HTMLElement;
1799
+ }
1800
+ function Ke(e, t) {
1801
+ const n = new AbortController();
1802
+ for (const o in t) {
1803
+ const l = t[o];
1804
+ e.addEventListener(o, l, {
1805
+ signal: n.signal,
1806
+ passive: !1,
1807
+ capture: o === "focus" || o === "blur"
1808
+ });
1809
+ }
1810
+ return n;
1811
+ }
1812
+ function Ft(e) {
1813
+ if (e instanceof HTMLElement) return e;
1814
+ if (e.value instanceof HTMLElement) return e.value;
1815
+ if ("$el" in e && e.$el instanceof HTMLElement)
1816
+ return e.$el;
1817
+ }
1818
+ function dl(e, t) {
1819
+ Array.isArray(e) || (e = [e]);
1820
+ for (const n of e) {
1821
+ const o = Ft(n);
1822
+ if (o) return t(o);
1823
+ const l = te(n, (s) => {
1824
+ if (!s) return;
1825
+ const i = Ft(s);
1826
+ i ? t(i) : console.warn("Invalid parent element", s), l();
1827
+ });
1828
+ }
1829
+ }
1830
+ var _t = /* @__PURE__ */ new WeakMap();
1831
+ function ul(e) {
1832
+ const t = _t.get(e);
1833
+ return t ? "value" in t ? t.value : t : (console.warn("No values found for parent element"), []);
1834
+ }
1835
+ function cl(e, t) {
1836
+ const n = _t.get(t);
1837
+ n && "value" in n && (n.value = e);
1838
+ }
1839
+ function tn(e) {
1840
+ bt && (Array.isArray(e) || (e = [e]), e.forEach((t) => {
1841
+ const { parent: n, values: o, ...l } = t;
1842
+ dl(n, pl(l, o));
1843
+ }));
1844
+ }
1845
+ function pl(e, t) {
1846
+ return (n) => {
1847
+ _t.set(n, t), Do({
1848
+ parent: n,
1849
+ getValues: ul,
1850
+ setValues: cl,
1851
+ config: {
1852
+ ...e
1853
+ }
1854
+ });
1855
+ };
1856
+ }
1857
+ const fl = {
1858
+ key: 0,
1859
+ class: "flex gap-4 p-6 border-b last:border-b-0"
1860
+ }, gl = { class: "option-drag-handle flex-none mt-9.5 cursor-grab" }, ml = { class: "flex-1" }, vl = { class: "mb-3" }, bl = { class: "flex items-center" }, _l = {
1861
+ key: 0,
1862
+ class: "mt-1 text-sm text-red-600"
1863
+ }, hl = { class: "flex items-center gap-1" }, yl = { class: "mb-2" }, xl = {
1864
+ key: 0,
1865
+ class: "option-value-drag-handle absolute -left-7 top-1/2 -translate-y-1/2 flex-none mr-2 cursor-grab"
1866
+ }, Dl = ["onClick"], Sl = { class: "flex justify-between" }, Cl = { class: "flex-1" }, wl = { class: "text-sm mb-2" }, kl = { class: "flex flex-wrap gap-2" }, Vl = {
1867
+ key: 0,
1868
+ class: "px-2 py-1 border rounded-full bg-muted text-muted-foreground text-sm"
1869
+ }, Pl = /* @__PURE__ */ ne({
1870
+ __name: "Option",
1871
+ props: {
1872
+ option: {
1873
+ type: Object,
1874
+ required: !0
1875
+ }
1876
+ },
1877
+ emits: ["update:option", "remove"],
1878
+ setup(e, { expose: t, emit: n }) {
1879
+ const o = e, { confirm: l } = Lt(), s = n, i = G({
1880
+ get() {
1881
+ return o.option;
1882
+ },
1883
+ set(S) {
1884
+ s("update:option", S);
1885
+ }
1886
+ }), d = G({
1887
+ get() {
1888
+ return i.value.values;
1889
+ },
1890
+ set(S) {
1891
+ i.value.values = S;
1892
+ }
1893
+ }), a = Ie("valueListRef"), x = L(!1);
1894
+ te(x, async (S) => {
1895
+ S || (await Re(), tn({
1896
+ parent: a?.value,
1897
+ values: d,
1898
+ group: "valueList",
1899
+ dragHandle: ".option-value-drag-handle",
1900
+ plugins: [Ut()]
1901
+ }));
1902
+ }, { immediate: !0 });
1903
+ const v = () => Math.random().toString(36).substring(2, 15), f = () => {
1904
+ i.value.values.push({ id: v(), value: "" });
1905
+ }, D = async () => {
1906
+ (i.value.name.trim() || i.value.values.filter((S) => S.value.trim() !== "").length > 0) && !await l("Are you sure you want to remove this option?") || s("remove");
1907
+ }, C = (S) => {
1908
+ i.value.values.splice(S, 1);
1909
+ }, N = (S) => {
1910
+ S.name.trim() ? S.nameError = void 0 : S.nameError = "Option name is required.";
1911
+ }, E = (S, w) => {
1912
+ const U = S.target, W = i.value.values;
1913
+ if (S.key === "Backspace" && U.value === "" && W?.length > 2) {
1914
+ C(w);
1915
+ return;
1916
+ }
1917
+ }, M = (S, w) => {
1918
+ S.target;
1919
+ const U = i.value.values, W = U?.[w];
1920
+ W.touched = !0, U?.every((oe) => oe.value.trim() !== "") && f();
1921
+ }, A = (S) => {
1922
+ const w = i.value, U = w?.values.every((W, j) => W.value.trim() !== "" || j === S);
1923
+ w && w.values[S].value.trim() === "" && !U && C(S);
1924
+ };
1925
+ return t({
1926
+ minified: x
1927
+ }), (S, w) => {
1928
+ const U = m("Input"), W = m("Button");
1929
+ return x.value ? (b(), k("div", {
1930
+ key: 1,
1931
+ class: "flex gap-4 p-6 border-b last:border-b-0 hover:bg-accent dark:hover:bg-accent/50 cursor-pointer transition-colors duration-200",
1932
+ onClick: w[5] || (w[5] = (j) => x.value = !1)
1933
+ }, [
1934
+ p("div", null, [
1935
+ p("div", {
1936
+ class: "option-drag-handle flex-none mt-5 cursor-grab",
1937
+ onClick: w[4] || (w[4] = fe(() => {
1938
+ }, ["stop"]))
1939
+ }, [
1940
+ r(g(ut), { class: "size-4 text-gray-400" })
1941
+ ])
1942
+ ]),
1943
+ p("div", Cl, [
1944
+ p("p", wl, z(i.value.name), 1),
1945
+ p("div", kl, [
1946
+ (b(!0), k(J, null, ce(d.value, (j) => (b(), k(J, {
1947
+ key: j.id
1948
+ }, [
1949
+ j.value ? (b(), k("span", Vl, z(j.value), 1)) : F("", !0)
1950
+ ], 64))), 128))
1951
+ ])
1952
+ ])
1953
+ ])) : (b(), k("div", fl, [
1954
+ p("div", null, [
1955
+ p("div", gl, [
1956
+ r(g(ut), { class: "size-4 text-gray-400" })
1957
+ ])
1958
+ ]),
1959
+ p("div", ml, [
1960
+ p("div", vl, [
1961
+ w[6] || (w[6] = p("label", { class: "block text-sm mb-2" }, "Option name", -1)),
1962
+ p("div", bl, [
1963
+ r(U, {
1964
+ modelValue: i.value.name,
1965
+ "onUpdate:modelValue": w[0] || (w[0] = (j) => i.value.name = j),
1966
+ onBlur: w[1] || (w[1] = (j) => N(i.value)),
1967
+ "aria-invalid": i.value.nameError ? "true" : "false",
1968
+ placeholder: "Color",
1969
+ spellcheck: "false"
1970
+ }, null, 8, ["modelValue", "aria-invalid"])
1971
+ ]),
1972
+ i.value.nameError ? (b(), k("p", _l, [
1973
+ p("span", hl, [
1974
+ r(g(Cn), { class: "size-4" }),
1975
+ P(" " + z(i.value.nameError), 1)
1976
+ ])
1977
+ ])) : F("", !0)
1978
+ ]),
1979
+ p("div", yl, [
1980
+ w[7] || (w[7] = p("label", { class: "block text-sm mb-2" }, "Option values", -1)),
1981
+ p("div", {
1982
+ ref_key: "valueListRef",
1983
+ ref: a
1984
+ }, [
1985
+ d.value ? (b(!0), k(J, { key: 0 }, ce(d.value, (j, oe) => (b(), k("div", {
1986
+ key: j.id,
1987
+ class: "relative flex items-center mb-2"
1988
+ }, [
1989
+ j.touched ? (b(), k("div", xl, [
1990
+ r(g(ut), { class: "size-4 text-gray-400" })
1991
+ ])) : F("", !0),
1992
+ r(U, {
1993
+ modelValue: j.value,
1994
+ "onUpdate:modelValue": (ie) => j.value = ie,
1995
+ placeholder: "Option value",
1996
+ class: "pr-12",
1997
+ onKeydown: (ie) => E(ie, oe),
1998
+ onKeyup: (ie) => M(ie, oe),
1999
+ onBlur: (ie) => A(oe),
2000
+ spellcheck: "false"
2001
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onKeydown", "onKeyup", "onBlur"]),
2002
+ d.value.length > 2 && j.touched ? (b(), k("button", {
2003
+ key: 1,
2004
+ onClick: (ie) => C(oe),
2005
+ class: "absolute right-2 top-1/2 -translate-y-1/2 ml-2 p-2 text-muted-foreground/50 hover:text-muted-foreground",
2006
+ type: "button"
2007
+ }, [
2008
+ r(g(wn), { class: "size-4" })
2009
+ ], 8, Dl)) : F("", !0)
2010
+ ]))), 128)) : F("", !0)
2011
+ ], 512)
2012
+ ]),
2013
+ p("div", Sl, [
2014
+ r(W, {
2015
+ size: "sm",
2016
+ variant: "outline",
2017
+ onClick: w[2] || (w[2] = (j) => D()),
2018
+ class: "text-red-500 hover:text-red-600"
2019
+ }, {
2020
+ default: c(() => [...w[8] || (w[8] = [
2021
+ P("Delete", -1)
2022
+ ])]),
2023
+ _: 1
2024
+ }),
2025
+ r(W, {
2026
+ size: "sm",
2027
+ onClick: w[3] || (w[3] = (j) => x.value = !0),
2028
+ disabled: i.value.name.trim() === ""
2029
+ }, {
2030
+ default: c(() => [...w[9] || (w[9] = [
2031
+ P("Done", -1)
2032
+ ])]),
2033
+ _: 1
2034
+ }, 8, ["disabled"])
2035
+ ])
2036
+ ])
2037
+ ]));
2038
+ };
2039
+ }
2040
+ }), Nl = /* @__PURE__ */ ne({
2041
+ __name: "Options",
2042
+ props: {
2043
+ modelValue: {
2044
+ type: Array,
2045
+ default: () => []
2046
+ }
2047
+ },
2048
+ emits: ["update:modelValue"],
2049
+ setup(e, { expose: t, emit: n }) {
2050
+ const o = e, l = n, s = L([]), i = Ie("optionsListRefElement"), d = Ie("optionRefs"), a = G({
2051
+ get() {
2052
+ return o.modelValue;
2053
+ },
2054
+ set(A) {
2055
+ l("update:modelValue", A);
2056
+ }
2057
+ }), x = L(!1);
2058
+ te(a, (A) => {
2059
+ x.value || (!s.value || s.value.length === 0 && A.length > 0) && (x.value = !0, s.value = A ? JSON.parse(JSON.stringify(A)) : []);
2060
+ }, { deep: !0 }), te(s, (A) => {
2061
+ a.value = A?.map((S) => ({
2062
+ ...S,
2063
+ values: S.values.filter((w) => w.value.trim() !== "")
2064
+ })), !E.value && A.length > 0 && M();
2065
+ }, { deep: !0 });
2066
+ const v = () => Math.random().toString(36).substring(2, 15), f = () => {
2067
+ const S = {
2068
+ id: v(),
2069
+ name: "",
2070
+ values: [{ id: v(), value: "" }],
2071
+ nameError: void 0
2072
+ };
2073
+ s.value.push(S);
2074
+ }, D = () => {
2075
+ d.value?.forEach((A) => {
2076
+ A && (A.minified = !0);
2077
+ });
2078
+ }, C = (A) => {
2079
+ const S = s.value.findIndex((w) => w.id === A.id);
2080
+ S !== -1 && (s.value[S] = A);
2081
+ }, N = (A) => {
2082
+ const S = s.value.findIndex((w) => w.id === A.id);
2083
+ S !== -1 && s.value.splice(S, 1);
2084
+ }, E = L(!1), M = () => {
2085
+ try {
2086
+ E.value = !0, tn({
2087
+ parent: i?.value,
2088
+ values: s,
2089
+ group: "optionsList",
2090
+ dragHandle: ".option-drag-handle",
2091
+ plugins: [Ut()]
2092
+ });
2093
+ } catch (A) {
2094
+ console.error(A);
2095
+ }
2096
+ };
2097
+ return vt(() => {
2098
+ s.value = o.modelValue ? JSON.parse(JSON.stringify(o.modelValue)) : [], s.value.length > 0 && M();
2099
+ }), t({
2100
+ minifyAll: D
2101
+ }), (A, S) => {
2102
+ const w = m("Button");
2103
+ return b(), k("div", null, [
2104
+ p("div", {
2105
+ class: De(["rounded-lg", s.value.length > 0 ? "border mb-6" : ""])
2106
+ }, [
2107
+ p("div", {
2108
+ ref_key: "optionsListRefElement",
2109
+ ref: i
2110
+ }, [
2111
+ (b(!0), k(J, null, ce(s.value, (U) => (b(), R(Pl, {
2112
+ ref_for: !0,
2113
+ ref_key: "optionRefs",
2114
+ ref: d,
2115
+ key: U.id,
2116
+ option: U,
2117
+ "onUpdate:option": S[0] || (S[0] = (W) => C(W)),
2118
+ onRemove: (W) => N(U)
2119
+ }, null, 8, ["option", "onRemove"]))), 128))
2120
+ ], 512),
2121
+ s.value && s.value.length < 3 ? (b(), k("div", {
2122
+ key: 0,
2123
+ class: De(s.value.length > 0 ? "border-t" : "")
2124
+ }, [
2125
+ s.value.length === 0 ? (b(), R(w, {
2126
+ key: 0,
2127
+ onClick: f,
2128
+ variant: "outline"
2129
+ }, {
2130
+ default: c(() => [
2131
+ r(g(Tt), { class: "size-4" }),
2132
+ S[1] || (S[1] = P(" Add options like size or color ", -1))
2133
+ ]),
2134
+ _: 1
2135
+ })) : (b(), R(w, {
2136
+ key: 1,
2137
+ onClick: f,
2138
+ variant: "ghost",
2139
+ class: "w-full justify-start pl-2 rounded-t-none"
2140
+ }, {
2141
+ default: c(() => [
2142
+ r(g(Tt), { class: "size-4" }),
2143
+ S[2] || (S[2] = P(" Add another option ", -1))
2144
+ ]),
2145
+ _: 1
2146
+ }))
2147
+ ], 2)) : F("", !0)
2148
+ ], 2)
2149
+ ]);
2150
+ };
2151
+ }
2152
+ }), Tl = { class: "grid gap-4 py-2" }, Il = /* @__PURE__ */ ne({
2153
+ __name: "VariantDialog",
2154
+ setup(e, { expose: t }) {
2155
+ const n = L(!1), o = L(!1), l = L(null);
2156
+ return t({
2157
+ openVariantDialog: (i) => {
2158
+ n.value = !0, l.value = i;
2159
+ }
2160
+ }), (i, d) => {
2161
+ const a = m("ResponsiveModalTitle"), x = m("ResponsiveModalHeader"), v = m("Button"), f = m("ResponsiveModalClose"), D = m("ResponsiveModalFooter"), C = m("ResponsiveModalScrollContent"), N = m("ResponsiveModal");
2162
+ return b(), R(N, {
2163
+ open: g(n),
2164
+ "onUpdate:open": d[0] || (d[0] = (E) => Y(n) ? n.value = E : null)
2165
+ }, {
2166
+ default: c(() => [
2167
+ r(C, { class: "sm:max-w-xl" }, {
2168
+ default: c(() => [
2169
+ r(x, null, {
2170
+ default: c(() => [
2171
+ r(a, null, {
2172
+ default: c(() => [...d[1] || (d[1] = [
2173
+ P("Edit ", -1)
2174
+ ])]),
2175
+ _: 1
2176
+ })
2177
+ ]),
2178
+ _: 1
2179
+ }),
2180
+ p("div", Tl, " variant " + z(g(l)), 1),
2181
+ r(D, null, {
2182
+ default: c(() => [
2183
+ r(f, { "as-child": "" }, {
2184
+ default: c(() => [
2185
+ r(v, {
2186
+ variant: "secondary",
2187
+ disabled: g(o)
2188
+ }, {
2189
+ default: c(() => [
2190
+ r(g(Rt), { class: "mr-2 size-4" }),
2191
+ d[2] || (d[2] = P(" Close ", -1))
2192
+ ]),
2193
+ _: 1
2194
+ }, 8, ["disabled"])
2195
+ ]),
2196
+ _: 1
2197
+ }),
2198
+ r(v, {
2199
+ class: "gap-2",
2200
+ disabled: g(o)
2201
+ }, {
2202
+ default: c(() => [
2203
+ g(o) ? (b(), R(g(ft), {
2204
+ key: 0,
2205
+ class: "size-4 animate-spin"
2206
+ })) : F("", !0),
2207
+ d[3] || (d[3] = P(" Update variant ", -1))
2208
+ ]),
2209
+ _: 1
2210
+ }, 8, ["disabled"])
2211
+ ]),
2212
+ _: 1
2213
+ })
2214
+ ]),
2215
+ _: 1
2216
+ })
2217
+ ]),
2218
+ _: 1
2219
+ }, 8, ["open"]);
2220
+ };
2221
+ }
2222
+ }), $l = { key: 0 }, El = { class: "flex items-center justify-between gap-2 mb-2" }, Ml = {
2223
+ key: 0,
2224
+ class: "flex items-center gap-2"
2225
+ }, Al = {
2226
+ key: 0,
2227
+ class: "mb-4"
2228
+ }, zl = { class: "flex flex-wrap gap-2" }, Ol = ["onClick"], Fl = { class: "-mx-6 w-[calc(100%+3rem)]" }, Rl = { class: "text-muted-foreground text-xs" }, Ul = { class: "z-[101] sticky -top-4 py-2 font-normal bg-accent dark:bg-border" }, Ll = { class: "z-[101] sticky -top-4 py-2 font-normal whitespace-nowrap bg-accent dark:bg-border" }, Bl = { class: "flex items-center gap-2" }, jl = { class: "z-[101] sticky -top-4 py-2 pr-6 font-normal bg-accent dark:bg-border" }, Hl = {
2229
+ key: 1,
2230
+ class: "z-[101] sticky -top-4 py-2 font-normal whitespace-nowrap bg-accent dark:bg-border text-left",
2231
+ colspan: "3"
2232
+ }, Xl = { class: "text-sm" }, Yl = ["onClick"], Kl = { class: "w-10 p-2" }, Gl = { class: "p-2" }, ql = { class: "flex items-stretch gap-2" }, Jl = ["src"], Wl = {
2233
+ key: 2,
2234
+ class: "relative"
2235
+ }, Zl = ["src"], Ql = ["src"], er = { class: "flex flex-col justify-center px-2" }, tr = { class: "text-md mb-0.5 hover:underline select-none" }, nr = { class: "flex items-center gap-1 text-xs text-muted-foreground hover:opacity-70 transition-opacity duration-200 cursor-pointer select-none" }, or = { class: "p-2 w-[30%]" }, lr = { class: "relative" }, rr = { key: 0 }, ar = { key: 1 }, sr = {
2236
+ key: 0,
2237
+ class: "absolute inset-0 top-1/2 -translate-y-1/2 px-2 truncate text-sm text-muted-foreground w-full text-center pointer-events-none"
2238
+ }, ir = { class: "p-2 w-[18%]" }, dr = ["onClick"], ur = { class: "w-10" }, cr = { class: "w-10 p-2 translate-x-10" }, pr = { class: "p-2 pl-12" }, fr = { class: "flex items-stretch gap-2" }, gr = ["src"], mr = { class: "flex flex-col justify-center px-2" }, vr = { class: "p-2 w-[30%]" }, br = { class: "p-2 w-[18%] group" }, _r = { class: "text-center text-sm text-muted-foreground bg-accent dark:bg-border p-3 -mx-6 -mb-6 rounded-b-lg" }, hr = { key: 0 }, yr = /* @__PURE__ */ ne({
2239
+ __name: "VariantList",
2240
+ props: {
2241
+ options: {
2242
+ type: Object,
2243
+ required: !0
2244
+ },
2245
+ modelValue: {
2246
+ type: Array,
2247
+ required: !0
2248
+ },
2249
+ hide: {
2250
+ type: Boolean,
2251
+ default: !1
2252
+ }
2253
+ },
2254
+ emits: ["update:modelValue"],
2255
+ setup(e, { expose: t, emit: n }) {
2256
+ const o = e, l = n, s = G({
2257
+ get() {
2258
+ return o.modelValue;
2259
+ },
2260
+ set(h) {
2261
+ l("update:modelValue", h);
2262
+ }
2263
+ }), i = pt("sources"), d = L(""), a = L(""), x = L(!1), v = L([]), f = L({}), D = L([]), C = L({}), N = Ie("variantDialog"), E = () => {
2264
+ const h = Object.keys(o.options);
2265
+ if (h.length === 0) {
2266
+ a.value = "";
2267
+ return;
2268
+ }
2269
+ (!a.value || !h.includes(a.value)) && (a.value = h[0]);
2270
+ }, M = () => {
2271
+ const h = Object.entries(f.value).reduce((u, [y, I]) => (o.options?.[y]?.values?.some((K) => K.id === I) && (u[y] = I), u), {});
2272
+ JSON.stringify(h) !== JSON.stringify(f.value) && (f.value = h);
2273
+ };
2274
+ te(() => o.options, () => {
2275
+ E(), M();
2276
+ }, { immediate: !0, deep: !0 }), te(C, (h) => {
2277
+ A();
2278
+ }, { deep: !0 }), te(() => o.hide, (h) => {
2279
+ h || (E(), A());
2280
+ });
2281
+ function A() {
2282
+ if (!C.value) {
2283
+ s.value = [];
2284
+ return;
2285
+ }
2286
+ let h = [];
2287
+ Object.keys(C.value)?.forEach((u) => {
2288
+ h.push({
2289
+ combinedOptions: u,
2290
+ name: U(u),
2291
+ disabled: !1,
2292
+ price: C.value[u].price,
2293
+ stock: C.value[u].stock,
2294
+ image: C.value[u].image,
2295
+ options: W(u)
2296
+ });
2297
+ }), s.value = h.filter((u) => u.options?.length === Object.keys(o.options).length && u.options?.every((y) => Object.entries(o.options).find(([, I]) => I.id === y.optionId)));
2298
+ }
2299
+ function S(h) {
2300
+ return h.reduce(
2301
+ (u, y) => u.flatMap((I) => y.map((H) => [...I, H])),
2302
+ [[]]
2303
+ );
2304
+ }
2305
+ function w(h) {
2306
+ return h.slice().sort((u, y) => u.optionId.localeCompare(y.optionId)).map(({ optionId: u, valueId: y }) => `${u}:${y}`).join("|");
2307
+ }
2308
+ const U = (h) => h.split("|").map((y) => {
2309
+ const [I, H] = y.split(":");
2310
+ return { optionId: I, valueId: H };
2311
+ }).map((y) => o.options?.[y.optionId]?.values?.find((K) => K.id === y.valueId)?.value || "").join(" "), W = (h) => h.split("|").map((y) => {
2312
+ const [I, H] = y.split(":");
2313
+ return { optionId: I, valueId: H };
2314
+ }).map((y) => {
2315
+ const I = o.options?.[y.optionId], H = I?.values?.find((K) => K.id === y.valueId);
2316
+ return {
2317
+ optionId: I?.id || y.optionId,
2318
+ option: I?.name || "",
2319
+ valueId: H?.id || y.valueId,
2320
+ value: H?.value || ""
2321
+ };
2322
+ }), j = G(() => {
2323
+ const h = Object.values(o.options).map(
2324
+ (y) => y.values.map((I) => ({
2325
+ optionId: y.id,
2326
+ optionName: y.name,
2327
+ valueId: I.id,
2328
+ value: I.value
2329
+ }))
2330
+ );
2331
+ return S(h).map((y) => {
2332
+ const I = w(y);
2333
+ return C.value[I] || (C.value[I] = { price: 0, stock: 0 }), {
2334
+ key: I,
2335
+ options: y,
2336
+ ...C.value[I]
2337
+ };
2338
+ });
2339
+ }), oe = G(() => {
2340
+ let h = [...j.value];
2341
+ const u = d.value.trim().toLowerCase();
2342
+ return u && (h = h.filter((y) => y.options?.some((I) => I.value.toLowerCase().includes(u)))), Object.entries(f.value).forEach(([y, I]) => {
2343
+ I && (h = h.filter((H) => H.options?.some((K) => K.optionId === y && K.valueId === I)));
2344
+ }), h;
2345
+ }), ie = G(() => Object.keys(f.value).length > 0), Ze = (h, u) => {
2346
+ if (!u) {
2347
+ we(h);
2348
+ return;
2349
+ }
2350
+ f.value = {
2351
+ ...f.value,
2352
+ [h]: u
2353
+ };
2354
+ }, we = (h) => {
2355
+ const u = { ...f.value };
2356
+ delete u[h], f.value = u;
2357
+ }, Qe = (h) => h.values?.find((u) => u.id === f.value[h.id])?.value, q = (h) => oe.value.filter((u) => u.options?.find((y) => y.optionId === a.value)?.valueId === h), be = G(() => {
2358
+ const h = o.options?.[a.value]?.values || [];
2359
+ return !d.value.trim() && !ie.value ? h : h.filter((u) => q(u.id).length > 0);
2360
+ }), ke = G(() => oe.value.map((h) => h.key)), Ae = G(() => D.value.length), Ve = G(() => {
2361
+ const h = new Set(D.value);
2362
+ return ke.value.filter((u) => h.has(u)).length;
2363
+ }), V = G(() => ke.value.length === 0 || Ve.value === 0 ? !1 : Ve.value === ke.value.length ? !0 : "indeterminate");
2364
+ te(be, (h) => {
2365
+ const u = new Set(h.map((y) => y.id));
2366
+ v.value = v.value.filter((y) => u.has(y));
2367
+ }), te(j, (h) => {
2368
+ const u = new Set(h.map((I) => I.key)), y = D.value.filter((I) => u.has(I));
2369
+ y.length !== D.value.length && (D.value = y);
2370
+ });
2371
+ const $ = (h, u) => {
2372
+ const y = new Set(h);
2373
+ if (u) {
2374
+ D.value = Array.from(/* @__PURE__ */ new Set([...D.value, ...h]));
2375
+ return;
2376
+ }
2377
+ D.value = D.value.filter((I) => !y.has(I));
2378
+ }, ae = (h, u) => {
2379
+ $([h], u === !0);
2380
+ }, _e = (h, u) => {
2381
+ $(q(h).map((y) => y.key), u === !0);
2382
+ }, ze = (h) => {
2383
+ $(ke.value, h === !0);
2384
+ }, Le = (h) => {
2385
+ const u = q(h).map((H) => H.key);
2386
+ if (u.length === 0) return !1;
2387
+ const y = new Set(D.value), I = u.filter((H) => y.has(H)).length;
2388
+ return I === 0 ? !1 : I === u.length ? !0 : "indeterminate";
2389
+ }, et = (h, u) => {
2390
+ const y = q(u);
2391
+ y && y.forEach((I) => {
2392
+ C.value[w(I.options)].image = h;
2393
+ });
2394
+ }, Be = (h) => q(h).every((y) => !y.image), tt = (h) => {
2395
+ const u = q(h);
2396
+ return u.filter((I, H) => I.image && u.findIndex((K) => K.image === I.image) === H).length === 1;
2397
+ }, je = (h) => q(h).filter((y) => y.image)[0]?.image, ht = (h) => q(h).filter((y) => y.image)[1]?.image, nn = (h) => {
2398
+ const u = q(h);
2399
+ if (u.length === 0) return "0";
2400
+ const y = u.map((I) => I.price);
2401
+ return Math.min(...y) === Math.max(...y) ? y[0]?.toString() || "0" : `${Math.min(...y)} - ${Math.max(...y)}`;
2402
+ }, yt = (h) => q(h).reduce((u, y) => y.stock > 0 ? u + y.stock : u, 0), on = (h) => q(h).reduce((u, y) => y.stock < 0 ? u + y.stock : u, 0), ln = () => {
2403
+ let h = 0;
2404
+ return be.value?.forEach((u) => {
2405
+ h += yt(u.id);
2406
+ }), h;
2407
+ }, xt = () => {
2408
+ let h = 0;
2409
+ return be.value?.forEach((u) => {
2410
+ h += on(u.id);
2411
+ }), h;
2412
+ }, He = L(null), he = L(""), rn = async (h, u) => {
2413
+ h.preventDefault();
2414
+ const y = oe?.value?.filter((K) => K.options?.find((nt) => nt.optionId === a.value)?.valueId === u.id).map((K) => K.price), I = y.length === 0 ? !0 : y.every((K) => K === y[0]);
2415
+ He.value = u.id, he.value = I ? y[0].toString() : "", await Re();
2416
+ const H = document.getElementById(`variant-price-${u.id}`);
2417
+ H?.focus(), H?.select();
2418
+ }, an = (h) => {
2419
+ Dt(h), He.value = null, he.value = "";
2420
+ }, Dt = (h) => {
2421
+ if (he.value.trim() && Number(he.value.trim().replace(",", ".")) > 0) {
2422
+ const u = Number(he.value.trim().replace(",", "."));
2423
+ oe?.value?.filter((y) => y.options?.find((I) => I.optionId === a.value)?.valueId === h).forEach((y) => {
2424
+ C.value[w(y.options)].price = u;
2425
+ });
2426
+ }
2427
+ }, sn = (h) => {
2428
+ C.value = h.reduce((u, y) => (u[y.combinedOptions] = {
2429
+ price: y.price,
2430
+ stock: y.stock,
2431
+ image: y.image
2432
+ }, u), {});
2433
+ };
2434
+ return vt(() => {
2435
+ E();
2436
+ }), t({
2437
+ setVariantMap: sn,
2438
+ refreshVariants: A
2439
+ }), (h, u) => {
2440
+ const y = m("SelectValue"), I = m("SelectTrigger"), H = m("SelectItem"), K = m("SelectContent"), nt = m("Select"), pe = m("Button"), St = m("Input"), dn = m("PopoverTrigger"), un = m("RadioGroupItem"), cn = m("Label"), pn = m("RadioGroup"), fn = m("PopoverContent"), gn = m("Popover"), ot = m("Checkbox"), lt = m("TooltipTrigger"), rt = m("TooltipContent"), at = m("Tooltip"), Ct = m("DropdownMenuTrigger"), Pe = m("DropdownMenuItem"), wt = m("DropdownMenuContent"), kt = m("DropdownMenu"), mn = m("DropdownMenuGroup"), vn = m("DropdownMenuSeparator"), Vt = m("MediaPickerDialog"), st = m("NumberFieldInput"), it = m("NumberFieldContent"), dt = m("NumberField"), bn = m("NumberFieldDecrement"), _n = m("NumberFieldIncrement");
2441
+ return b(), k(J, null, [
2442
+ e.hide ? F("", !0) : (b(), k("div", $l, [
2443
+ p("div", El, [
2444
+ Object.keys(e.options).length > 1 ? (b(), k("div", Ml, [
2445
+ u[13] || (u[13] = p("p", null, "Group by", -1)),
2446
+ r(nt, {
2447
+ modelValue: a.value,
2448
+ "onUpdate:modelValue": u[0] || (u[0] = (T) => a.value = T)
2449
+ }, {
2450
+ default: c(() => [
2451
+ r(I, { size: "sm" }, {
2452
+ default: c(() => [
2453
+ r(y, { placeholder: "Option" })
2454
+ ]),
2455
+ _: 1
2456
+ }),
2457
+ r(K, null, {
2458
+ default: c(() => [
2459
+ (b(!0), k(J, null, ce(e.options, (T) => (b(), R(H, {
2460
+ key: T.id,
2461
+ value: T.id
2462
+ }, {
2463
+ default: c(() => [
2464
+ P(z(T.name), 1)
2465
+ ]),
2466
+ _: 2
2467
+ }, 1032, ["value"]))), 128))
2468
+ ]),
2469
+ _: 1
2470
+ })
2471
+ ]),
2472
+ _: 1
2473
+ }, 8, ["modelValue"])
2474
+ ])) : F("", !0),
2475
+ x.value ? (b(), R(pe, {
2476
+ key: 2,
2477
+ variant: "outline",
2478
+ onClick: u[2] || (u[2] = (T) => x.value = !1),
2479
+ size: "sm",
2480
+ class: "ml-auto"
2481
+ }, {
2482
+ default: c(() => [...u[14] || (u[14] = [
2483
+ P(" Cancel ", -1)
2484
+ ])]),
2485
+ _: 1
2486
+ })) : (b(), R(pe, {
2487
+ key: 1,
2488
+ variant: "outline",
2489
+ onClick: u[1] || (u[1] = (T) => x.value = !0),
2490
+ size: "sm",
2491
+ class: "ml-auto"
2492
+ }, {
2493
+ default: c(() => [
2494
+ r(g(It), { class: "size-4" }),
2495
+ r(g(kn), { class: "size-4" })
2496
+ ]),
2497
+ _: 1
2498
+ }))
2499
+ ]),
2500
+ x.value ? (b(), k("div", Al, [
2501
+ p("div", {
2502
+ class: De(["relative", { "mb-4": Object.keys(e.options).length > 0 }])
2503
+ }, [
2504
+ r(St, {
2505
+ placeholder: "Search",
2506
+ class: "pl-10",
2507
+ modelValue: d.value,
2508
+ "onUpdate:modelValue": u[3] || (u[3] = (T) => d.value = T)
2509
+ }, null, 8, ["modelValue"]),
2510
+ r(g(It), { class: "size-4 absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none" })
2511
+ ], 2),
2512
+ p("div", zl, [
2513
+ (b(!0), k(J, null, ce(e.options, (T) => (b(), R(gn, {
2514
+ key: T.id
2515
+ }, {
2516
+ default: c(() => [
2517
+ r(dn, { asChild: "" }, {
2518
+ default: c(() => [
2519
+ r(pe, {
2520
+ variant: "outline",
2521
+ size: "sm",
2522
+ class: "border-dashed"
2523
+ }, {
2524
+ default: c(() => [
2525
+ f.value[T.id] ? (b(), k(J, { key: 1 }, [
2526
+ P(z(T.name) + " is " + z(Qe(T)) + " ", 1),
2527
+ p("div", {
2528
+ class: "p-2",
2529
+ onClick: fe((O) => we(T.id), ["stop", "prevent"])
2530
+ }, [
2531
+ r(g(Rt), { class: "size-3" })
2532
+ ], 8, Ol)
2533
+ ], 64)) : (b(), k(J, { key: 0 }, [
2534
+ P(z(T.name) + " ", 1),
2535
+ r(g($t), { class: "size-3" })
2536
+ ], 64))
2537
+ ]),
2538
+ _: 2
2539
+ }, 1024)
2540
+ ]),
2541
+ _: 2
2542
+ }, 1024),
2543
+ r(fn, null, {
2544
+ default: c(() => [
2545
+ r(pn, {
2546
+ "model-value": f.value[T.id] || "",
2547
+ class: "mb-4",
2548
+ "onUpdate:modelValue": (O) => Ze(T.id, O)
2549
+ }, {
2550
+ default: c(() => [
2551
+ (b(!0), k(J, null, ce(T.values, (O) => (b(), k("div", {
2552
+ class: "flex items-center space-x-2",
2553
+ key: O.id
2554
+ }, [
2555
+ r(un, {
2556
+ id: O.id,
2557
+ value: O.id,
2558
+ class: "border-ring"
2559
+ }, null, 8, ["id", "value"]),
2560
+ r(cn, {
2561
+ for: O.id
2562
+ }, {
2563
+ default: c(() => [
2564
+ P(z(O.value), 1)
2565
+ ]),
2566
+ _: 2
2567
+ }, 1032, ["for"])
2568
+ ]))), 128))
2569
+ ]),
2570
+ _: 2
2571
+ }, 1032, ["model-value", "onUpdate:modelValue"]),
2572
+ r(pe, {
2573
+ variant: "ghost",
2574
+ onClick: (O) => we(T.id),
2575
+ size: "sm",
2576
+ class: "ml-auto",
2577
+ disabled: !f.value[T.id]
2578
+ }, {
2579
+ default: c(() => [...u[15] || (u[15] = [
2580
+ P(" Clear ", -1)
2581
+ ])]),
2582
+ _: 1
2583
+ }, 8, ["onClick", "disabled"])
2584
+ ]),
2585
+ _: 2
2586
+ }, 1024)
2587
+ ]),
2588
+ _: 2
2589
+ }, 1024))), 128))
2590
+ ])
2591
+ ])) : F("", !0),
2592
+ a.value ? (b(), k(J, { key: 1 }, [
2593
+ p("table", Fl, [
2594
+ p("thead", Rl, [
2595
+ p("tr", null, [
2596
+ p("th", Ul, [
2597
+ r(ot, {
2598
+ class: "border-muted-foreground translate-y-0.5",
2599
+ "model-value": V.value,
2600
+ "onUpdate:modelValue": ze
2601
+ }, null, 8, ["model-value"])
2602
+ ]),
2603
+ Ae.value === 0 ? (b(), k(J, { key: 0 }, [
2604
+ p("th", Ll, [
2605
+ p("div", Bl, [
2606
+ u[16] || (u[16] = p("span", null, "Variant", -1)),
2607
+ u[17] || (u[17] = p("span", null, "·", -1)),
2608
+ v.value.length > 0 ? (b(), k("button", {
2609
+ key: 0,
2610
+ class: "hover:underline cursor-pointer",
2611
+ onClick: u[4] || (u[4] = (T) => v.value = [])
2612
+ }, "Collapse all")) : (b(), k("button", {
2613
+ key: 1,
2614
+ class: "hover:underline cursor-pointer",
2615
+ onClick: u[5] || (u[5] = (T) => v.value = be.value.map((O) => O.id))
2616
+ }, "Expand all"))
2617
+ ])
2618
+ ]),
2619
+ u[20] || (u[20] = p("th", { class: "z-[101] sticky -top-4 py-2 font-normal bg-accent dark:bg-border" }, "Price", -1)),
2620
+ p("th", jl, [
2621
+ r(at, null, {
2622
+ default: c(() => [
2623
+ r(lt, { class: "underline decoration-dashed underline-offset-4" }, {
2624
+ default: c(() => [...u[18] || (u[18] = [
2625
+ P("Available", -1)
2626
+ ])]),
2627
+ _: 1
2628
+ }),
2629
+ r(rt, null, {
2630
+ default: c(() => [...u[19] || (u[19] = [
2631
+ p("p", null, "Inventory at your store that can be sold.", -1)
2632
+ ])]),
2633
+ _: 1
2634
+ })
2635
+ ]),
2636
+ _: 1
2637
+ })
2638
+ ])
2639
+ ], 64)) : (b(), k("th", Hl, [
2640
+ r(kt, null, {
2641
+ default: c(() => [
2642
+ r(Ct, { "as-child": "" }, {
2643
+ default: c(() => [
2644
+ r(pe, {
2645
+ variant: "outline",
2646
+ class: "mr-2",
2647
+ size: "sm"
2648
+ }, {
2649
+ default: c(() => [
2650
+ P(z(Ae.value) + " selected ", 1)
2651
+ ]),
2652
+ _: 1
2653
+ })
2654
+ ]),
2655
+ _: 1
2656
+ }),
2657
+ r(wt, {
2658
+ class: "w-56",
2659
+ align: "start"
2660
+ }, {
2661
+ default: c(() => [
2662
+ r(Pe, null, {
2663
+ default: c(() => [...u[21] || (u[21] = [
2664
+ P(" Deselect all ", -1)
2665
+ ])]),
2666
+ _: 1
2667
+ })
2668
+ ]),
2669
+ _: 1
2670
+ })
2671
+ ]),
2672
+ _: 1
2673
+ }),
2674
+ r(kt, null, {
2675
+ default: c(() => [
2676
+ r(Ct, { "as-child": "" }, {
2677
+ default: c(() => [
2678
+ r(pe, { size: "sm" }, {
2679
+ default: c(() => [
2680
+ r(g(Vn), { class: "size-3" })
2681
+ ]),
2682
+ _: 1
2683
+ })
2684
+ ]),
2685
+ _: 1
2686
+ }),
2687
+ r(wt, {
2688
+ class: "w-56",
2689
+ align: "start"
2690
+ }, {
2691
+ default: c(() => [
2692
+ r(mn, null, {
2693
+ default: c(() => [
2694
+ r(Pe, null, {
2695
+ default: c(() => [...u[22] || (u[22] = [
2696
+ P(" Edit price ", -1)
2697
+ ])]),
2698
+ _: 1
2699
+ }),
2700
+ r(Pe, null, {
2701
+ default: c(() => [...u[23] || (u[23] = [
2702
+ P(" Edit SKU ", -1)
2703
+ ])]),
2704
+ _: 1
2705
+ }),
2706
+ r(Pe, null, {
2707
+ default: c(() => [...u[24] || (u[24] = [
2708
+ P(" Edit barcode ", -1)
2709
+ ])]),
2710
+ _: 1
2711
+ }),
2712
+ r(Pe, null, {
2713
+ default: c(() => [...u[25] || (u[25] = [
2714
+ P(" Change image ", -1)
2715
+ ])]),
2716
+ _: 1
2717
+ })
2718
+ ]),
2719
+ _: 1
2720
+ }),
2721
+ r(vn),
2722
+ r(Pe, null, {
2723
+ default: c(() => [
2724
+ P(" Remove variant" + z(Ae.value > 1 ? "s" : ""), 1)
2725
+ ]),
2726
+ _: 1
2727
+ })
2728
+ ]),
2729
+ _: 1
2730
+ })
2731
+ ]),
2732
+ _: 1
2733
+ })
2734
+ ]))
2735
+ ])
2736
+ ]),
2737
+ p("tbody", Xl, [
2738
+ (b(!0), k(J, null, ce(be.value, (T) => (b(), k(J, {
2739
+ key: T.id
2740
+ }, [
2741
+ p("tr", {
2742
+ class: "hover:bg-accent/50 cursor-pointer transition-colors duration-200 border-b border-input",
2743
+ onClick: (O) => v.value.includes(T.id) ? v.value.splice(v.value.indexOf(T.id), 1) : v.value.push(T.id)
2744
+ }, [
2745
+ p("td", Kl, [
2746
+ r(ot, {
2747
+ class: "border-muted-foreground translate-y-0.5",
2748
+ "model-value": Le(T.id),
2749
+ "onUpdate:modelValue": (O) => _e(T.id, O),
2750
+ onClick: u[6] || (u[6] = fe(() => {
2751
+ }, ["stop"]))
2752
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
2753
+ ]),
2754
+ p("td", Gl, [
2755
+ p("div", ql, [
2756
+ p("div", null, [
2757
+ r(Vt, {
2758
+ sources: g(i),
2759
+ maxFiles: 1,
2760
+ "initial-value": Be(T.id) ? [] : tt(T.id) ? [je(T.id)] : [je(T.id), ht(T.id)],
2761
+ onSubmit: (O) => et(O, T.id)
2762
+ }, {
2763
+ default: c(() => [
2764
+ p("button", {
2765
+ onClick: u[7] || (u[7] = fe(() => {
2766
+ }, ["stop"])),
2767
+ tabindex: "-1",
2768
+ class: "cursor-pointer"
2769
+ }, [
2770
+ Be(T.id) ? (b(), R(pe, {
2771
+ key: 0,
2772
+ variant: "outline",
2773
+ class: "size-15 border-dashed cursor-pointer"
2774
+ }, {
2775
+ default: c(() => [
2776
+ r(g(Et))
2777
+ ]),
2778
+ _: 1
2779
+ })) : tt(T.id) ? (b(), k("img", {
2780
+ key: 1,
2781
+ src: je(T.id),
2782
+ class: "size-15 rounded-md object-cover",
2783
+ draggable: "false"
2784
+ }, null, 8, Jl)) : (b(), k("div", Wl, [
2785
+ p("img", {
2786
+ src: ht(T.id),
2787
+ class: "absolute rotate-[12deg] size-15 rounded-md object-cover",
2788
+ draggable: "false"
2789
+ }, null, 8, Zl),
2790
+ p("img", {
2791
+ src: je(T.id),
2792
+ class: "relative size-15 rounded-md shadow object-cover",
2793
+ draggable: "false"
2794
+ }, null, 8, Ql)
2795
+ ]))
2796
+ ])
2797
+ ]),
2798
+ _: 2
2799
+ }, 1032, ["sources", "initial-value", "onSubmit"])
2800
+ ]),
2801
+ p("div", er, [
2802
+ p("p", tr, z(T.value), 1),
2803
+ p("button", nr, [
2804
+ P(z(q(T.id).length) + " variants ", 1),
2805
+ r(g($t), {
2806
+ class: De(["size-3 transition-transform duration-200", v.value.includes(T.id) ? "rotate-180" : ""])
2807
+ }, null, 8, ["class"])
2808
+ ])
2809
+ ])
2810
+ ])
2811
+ ]),
2812
+ p("td", or, [
2813
+ p("div", lr, [
2814
+ r(at, null, {
2815
+ default: c(() => [
2816
+ r(lt, {
2817
+ class: "w-full",
2818
+ asChild: ""
2819
+ }, {
2820
+ default: c(() => [
2821
+ r(St, {
2822
+ id: `variant-price-${T.id}`,
2823
+ modelValue: he.value,
2824
+ "onUpdate:modelValue": u[8] || (u[8] = (O) => he.value = O),
2825
+ class: De(["dark:bg-transparent dark:border-ring/50 text-center", He.value === T.id ? "" : "text-transparent"]),
2826
+ onClick: u[9] || (u[9] = fe(() => {
2827
+ }, ["stop"])),
2828
+ onFocus: (O) => rn(O, T),
2829
+ onBlur: (O) => an(T.id),
2830
+ onKeydown: hn((O) => Dt(T.id), ["enter"])
2831
+ }, null, 8, ["id", "modelValue", "class", "onFocus", "onBlur", "onKeydown"])
2832
+ ]),
2833
+ _: 2
2834
+ }, 1024),
2835
+ r(rt, null, {
2836
+ default: c(() => [
2837
+ q(T.id).length === 1 ? (b(), k("p", rr, "Applies to 1 variant")) : (b(), k("p", ar, "Applies to all " + z(q(T.id).length) + " variants", 1))
2838
+ ]),
2839
+ _: 2
2840
+ }, 1024)
2841
+ ]),
2842
+ _: 2
2843
+ }, 1024),
2844
+ He.value !== T.id ? (b(), k("span", sr, z(nn(T.id)), 1)) : F("", !0)
2845
+ ])
2846
+ ]),
2847
+ p("td", ir, [
2848
+ r(at, null, {
2849
+ default: c(() => [
2850
+ r(lt, {
2851
+ class: "w-full focus-visible:outline-none",
2852
+ onClick: u[10] || (u[10] = fe(() => {
2853
+ }, ["stop"]))
2854
+ }, {
2855
+ default: c(() => [
2856
+ r(dt, null, {
2857
+ default: c(() => [
2858
+ r(it, null, {
2859
+ default: c(() => [
2860
+ r(st, {
2861
+ value: yt(T.id),
2862
+ class: "dark:border-ring/50",
2863
+ disabled: ""
2864
+ }, null, 8, ["value"])
2865
+ ]),
2866
+ _: 2
2867
+ }, 1024)
2868
+ ]),
2869
+ _: 2
2870
+ }, 1024)
2871
+ ]),
2872
+ _: 2
2873
+ }, 1024),
2874
+ r(rt, null, {
2875
+ default: c(() => [...u[26] || (u[26] = [
2876
+ p("p", null, "Update for individual variants only", -1)
2877
+ ])]),
2878
+ _: 1
2879
+ })
2880
+ ]),
2881
+ _: 2
2882
+ }, 1024)
2883
+ ])
2884
+ ], 8, Yl),
2885
+ v.value.includes(T.id) ? (b(!0), k(J, { key: 0 }, ce(q(T.id), (O) => (b(), k("tr", {
2886
+ key: O.key,
2887
+ class: "hover:bg-accent/50 cursor-pointer transition-colors duration-200 border-b border-input",
2888
+ onClick: (se) => g(N).openVariantDialog(O)
2889
+ }, [
2890
+ p("td", ur, [
2891
+ p("div", cr, [
2892
+ r(ot, {
2893
+ class: "border-muted-foreground translate-y-0.5",
2894
+ "model-value": D.value.includes(O.key),
2895
+ "onUpdate:modelValue": (se) => ae(O.key, se),
2896
+ onClick: u[11] || (u[11] = fe(() => {
2897
+ }, ["stop"]))
2898
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
2899
+ ])
2900
+ ]),
2901
+ p("td", pr, [
2902
+ p("div", fr, [
2903
+ p("div", null, [
2904
+ r(Vt, {
2905
+ sources: g(i),
2906
+ maxFiles: 1,
2907
+ "initial-value": C.value[w(O.options)].image ? [C.value[w(O.options)].image] : [],
2908
+ onSubmit: (se) => C.value[w(O.options)].image = se
2909
+ }, {
2910
+ default: c(() => [
2911
+ p("button", {
2912
+ onClick: u[12] || (u[12] = fe(() => {
2913
+ }, ["stop"])),
2914
+ tabindex: "-1",
2915
+ class: "cursor-pointer"
2916
+ }, [
2917
+ C.value[w(O.options)].image ? (b(), k("img", {
2918
+ key: 0,
2919
+ src: C.value[w(O.options)].image,
2920
+ class: "size-10 object-cover rounded-md",
2921
+ draggable: "false"
2922
+ }, null, 8, gr)) : (b(), R(pe, {
2923
+ key: 1,
2924
+ variant: "outline",
2925
+ class: "size-10 border-dashed cursor-pointer"
2926
+ }, {
2927
+ default: c(() => [
2928
+ r(g(Et))
2929
+ ]),
2930
+ _: 1
2931
+ }))
2932
+ ])
2933
+ ]),
2934
+ _: 2
2935
+ }, 1032, ["sources", "initial-value", "onSubmit"])
2936
+ ]),
2937
+ p("div", mr, [
2938
+ p("p", null, z(O.options.filter((se) => se.optionId !== a.value).map((se) => se.value).join(" / ")), 1)
2939
+ ])
2940
+ ])
2941
+ ]),
2942
+ p("td", vr, [
2943
+ r(dt, {
2944
+ "format-options": {
2945
+ style: "currency",
2946
+ currency: "EUR",
2947
+ currencyDisplay: "symbol",
2948
+ currencySign: "standard"
2949
+ },
2950
+ modelValue: C.value[w(O.options)].price,
2951
+ "onUpdate:modelValue": (se) => C.value[w(O.options)].price = se,
2952
+ min: 0
2953
+ }, {
2954
+ default: c(() => [
2955
+ r(it, null, {
2956
+ default: c(() => [
2957
+ r(st, { class: "dark:border-ring/50" })
2958
+ ]),
2959
+ _: 1
2960
+ })
2961
+ ]),
2962
+ _: 1
2963
+ }, 8, ["modelValue", "onUpdate:modelValue"])
2964
+ ]),
2965
+ p("td", br, [
2966
+ r(dt, {
2967
+ modelValue: C.value[w(O.options)].stock,
2968
+ "onUpdate:modelValue": (se) => C.value[w(O.options)].stock = se
2969
+ }, {
2970
+ default: c(() => [
2971
+ r(it, null, {
2972
+ default: c(() => [
2973
+ r(bn, { class: "group-hover:opacity-100 opacity-0 transition-opacity duration-200" }),
2974
+ r(st, { class: "dark:border-ring/50" }),
2975
+ r(_n, { class: "group-hover:opacity-100 opacity-0 transition-opacity duration-200" })
2976
+ ]),
2977
+ _: 1
2978
+ })
2979
+ ]),
2980
+ _: 1
2981
+ }, 8, ["modelValue", "onUpdate:modelValue"])
2982
+ ])
2983
+ ], 8, dr))), 128)) : F("", !0)
2984
+ ], 64))), 128))
2985
+ ])
2986
+ ]),
2987
+ p("div", _r, [
2988
+ P(" Total inventory at Webshop: " + z(ln()) + " ", 1),
2989
+ xt() < 0 ? (b(), k("span", hr, "(" + z(xt()) + ")", 1)) : F("", !0),
2990
+ u[27] || (u[27] = P(" available ", -1))
2991
+ ])
2992
+ ], 64)) : F("", !0)
2993
+ ])),
2994
+ r(Il, {
2995
+ ref_key: "variantDialog",
2996
+ ref: N
2997
+ }, null, 512)
2998
+ ], 64);
2999
+ };
3000
+ }
3001
+ }), xr = /* @__PURE__ */ ne({
3002
+ __name: "Variants",
3003
+ setup(e) {
3004
+ const { params: t } = Bt(), { value: n } = B("options"), { value: o } = B("variants"), l = L([]), s = L([]), i = Ie("optionsEl"), d = Ie("variantsEl");
3005
+ te(l, async (f) => {
3006
+ n.value = f ? JSON.parse(JSON.stringify(f)) : [], await Re(), d.value?.refreshVariants();
3007
+ }, { deep: !0 }), te(s, (f) => {
3008
+ o.value = f ? JSON.parse(JSON.stringify(f)) : [];
3009
+ }, { deep: !0 });
3010
+ const a = L(!1), x = L(!1);
3011
+ te(n, async (f) => {
3012
+ t.value.productId == "new" || !f || Array.isArray(f) && f.length === 0 || a.value || (a.value = !0, l.value = JSON.parse(JSON.stringify(f)), await Re(), f.length > 1 && i.value?.minifyAll());
3013
+ }, { deep: !0, immediate: !0 }), te(o, async (f) => {
3014
+ t.value.productId == "new" || !f || Array.isArray(f) && f.length === 0 || x.value || (x.value = !0, s.value = JSON.parse(JSON.stringify(f)), await Re(), d.value?.setVariantMap(f));
3015
+ }, { deep: !0, immediate: !0 });
3016
+ const v = G(() => {
3017
+ let f = l.value || [], D = {};
3018
+ return !f || !Array.isArray(f) || f.forEach((C) => {
3019
+ !C.name.trim() || C.values?.filter((N) => N.value.trim() !== "")?.length === 0 || (D[C.id] = {
3020
+ id: C.id,
3021
+ name: C.name,
3022
+ values: C.values?.map((N) => ({ id: N.id, value: N.value }))?.filter((N) => N.value.trim() !== "") || []
3023
+ });
3024
+ }), D;
3025
+ });
3026
+ return (f, D) => {
3027
+ const C = m("CardContent"), N = m("Card");
3028
+ return b(), R(N, null, {
3029
+ default: c(() => [
3030
+ r(C, null, {
3031
+ default: c(() => [
3032
+ D[2] || (D[2] = p("h3", { class: "text-lg font-semibold mb-4" }, "Variants", -1)),
3033
+ r(Nl, {
3034
+ modelValue: l.value,
3035
+ "onUpdate:modelValue": D[0] || (D[0] = (E) => l.value = E),
3036
+ ref_key: "optionsEl",
3037
+ ref: i
3038
+ }, null, 8, ["modelValue"]),
3039
+ r(yr, {
3040
+ ref_key: "variantsEl",
3041
+ ref: d,
3042
+ options: v.value,
3043
+ modelValue: s.value,
3044
+ "onUpdate:modelValue": D[1] || (D[1] = (E) => s.value = E),
3045
+ hide: Object.keys(v.value).length === 0
3046
+ }, null, 8, ["options", "modelValue", "hide"])
3047
+ ]),
3048
+ _: 1
3049
+ })
3050
+ ]),
3051
+ _: 1
3052
+ });
3053
+ };
3054
+ }
3055
+ }), Dr = { class: "bg-white dark:bg-gray-50 border-4 dark:border-gray-600 p-4 rounded-lg mb-4" }, Sr = { class: "flex items-center gap-2 mb-2" }, Cr = ["src"], wr = { class: "text-[#1a0dab] text-lg" }, kr = { class: "text-[#006621] text-[13px]" }, Vr = { class: "text-[#545454] text-[13px]" }, Pr = { class: "flex flex-col gap-4 mb-4" }, Nr = { class: "flex flex-col" }, Tr = {
3056
+ key: 0,
3057
+ class: "text-red-500 text-sm mt-1"
3058
+ }, Ir = { class: "flex flex-col gap-4 mb-4" }, $r = { class: "flex flex-col" }, Er = {
3059
+ key: 0,
3060
+ class: "text-red-500 text-sm mt-1"
3061
+ }, Mr = { class: "flex flex-col gap-4" }, Ar = { class: "flex flex-col" }, zr = { class: "flex gap-2" }, Or = {
3062
+ key: 0,
3063
+ class: "text-red-500 text-sm mt-1"
3064
+ }, Fr = {
3065
+ key: 1,
3066
+ class: "text-[#545454] text-[13px]"
3067
+ }, Rr = {
3068
+ key: 2,
3069
+ class: "text-orange-500 text-[13px]"
3070
+ }, Ur = /* @__PURE__ */ ne({
3071
+ __name: "SEO",
3072
+ setup(e) {
3073
+ const { errors: t } = Ee(), { value: n } = B("title"), { value: o } = B("slug"), { value: l } = B("seo");
3074
+ function s(i) {
3075
+ return i ? i.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").trim().replace(/[-\s]+/g, "-") : "";
3076
+ }
3077
+ return te(n, (i, d) => {
3078
+ (!o.value || s(d) === o.value) && (o.value = s(i)), (!l.value.title || d === l.value.title) && (l.value.title = i);
3079
+ }), (i, d) => {
3080
+ const a = m("Label"), x = m("Input"), v = m("Textarea"), f = m("ProgressCircle"), D = m("CardContent"), C = m("Card");
3081
+ return b(), R(C, null, {
3082
+ default: c(() => [
3083
+ r(D, null, {
3084
+ default: c(() => [
3085
+ d[7] || (d[7] = p("h3", { class: "text-lg font-semibold mb-4" }, "Search engine listing", -1)),
3086
+ p("div", Dr, [
3087
+ p("div", Sr, [
3088
+ p("img", {
3089
+ src: g(zn),
3090
+ alt: "Google",
3091
+ class: "w-16 pointer-events-none",
3092
+ draggable: "false"
3093
+ }, null, 8, Cr),
3094
+ d[3] || (d[3] = p("span", { class: "text-[#4186f5] font-medium text-xs" }, "Preview", -1))
3095
+ ]),
3096
+ p("p", wr, z(g(l).title), 1),
3097
+ p("p", kr, z(g(o)), 1),
3098
+ p("p", Vr, z(g(l).description?.slice(0, 155)) + z(g(l).description?.length > 155 ? " ..." : ""), 1)
3099
+ ]),
3100
+ p("div", Pr, [
3101
+ p("div", Nr, [
3102
+ r(a, {
3103
+ for: "slug",
3104
+ class: "text-sm mb-2"
3105
+ }, {
3106
+ default: c(() => [...d[4] || (d[4] = [
3107
+ P("Slug", -1)
3108
+ ])]),
3109
+ _: 1
3110
+ }),
3111
+ r(x, {
3112
+ id: "slug",
3113
+ placeholder: "t-shirt-with-red-heart",
3114
+ modelValue: g(o),
3115
+ "onUpdate:modelValue": d[0] || (d[0] = (N) => Y(o) ? o.value = N : null)
3116
+ }, null, 8, ["modelValue"]),
3117
+ g(t).slug ? (b(), k("p", Tr, z(g(t).slug), 1)) : F("", !0)
3118
+ ])
3119
+ ]),
3120
+ p("div", Ir, [
3121
+ p("div", $r, [
3122
+ r(a, {
3123
+ for: "meta-title",
3124
+ class: "text-sm mb-2"
3125
+ }, {
3126
+ default: c(() => [...d[5] || (d[5] = [
3127
+ P("Title", -1)
3128
+ ])]),
3129
+ _: 1
3130
+ }),
3131
+ r(x, {
3132
+ id: "meta-title",
3133
+ placeholder: "T-shirt with red heart",
3134
+ modelValue: g(l).title,
3135
+ "onUpdate:modelValue": d[1] || (d[1] = (N) => g(l).title = N)
3136
+ }, null, 8, ["modelValue"]),
3137
+ g(t).seo?.title ? (b(), k("p", Er, z(g(t).seo.title), 1)) : F("", !0)
3138
+ ])
3139
+ ]),
3140
+ p("div", Mr, [
3141
+ p("div", Ar, [
3142
+ r(a, {
3143
+ for: "meta-description",
3144
+ class: "text-sm mb-2"
3145
+ }, {
3146
+ default: c(() => [...d[6] || (d[6] = [
3147
+ P("Description", -1)
3148
+ ])]),
3149
+ _: 1
3150
+ }),
3151
+ r(v, {
3152
+ id: "meta-description",
3153
+ placeholder: "Lovely T-shirt featuring a red heart",
3154
+ modelValue: g(l).description,
3155
+ "onUpdate:modelValue": d[2] || (d[2] = (N) => g(l).description = N),
3156
+ class: "mb-2 resize-none"
3157
+ }, null, 8, ["modelValue"]),
3158
+ p("div", zr, [
3159
+ r(f, {
3160
+ progress: (g(l).description?.length ?? 0) / 155
3161
+ }, null, 8, ["progress"]),
3162
+ g(t).seo?.description ? (b(), k("p", Or, z(g(t).seo.description), 1)) : g(l).description?.length < 155 ? (b(), k("p", Fr, z(g(l).description.length) + " characters", 1)) : (b(), k("p", Rr, "Please keep it under 155 characters"))
3163
+ ])
3164
+ ])
3165
+ ])
3166
+ ]),
3167
+ _: 1
3168
+ })
3169
+ ]),
3170
+ _: 1
3171
+ });
3172
+ };
3173
+ }
3174
+ }), Lr = /* @__PURE__ */ ne({
3175
+ __name: "NewSection",
3176
+ setup(e) {
3177
+ return (t, n) => {
3178
+ const o = m("Button"), l = m("CardContent"), s = m("Card");
3179
+ return b(), k(J, null, [
3180
+ n[3] || (n[3] = p("hr", { class: "my-4" }, null, -1)),
3181
+ r(s, null, {
3182
+ default: c(() => [
3183
+ r(l, null, {
3184
+ default: c(() => [
3185
+ n[1] || (n[1] = p("h2", { class: "text-lg font-medium" }, "New Section", -1)),
3186
+ n[2] || (n[2] = p("p", { class: "text-sm text-muted-foreground mb-4" }, "As an admin, you can define new sections within the product detail page.", -1)),
3187
+ r(o, null, {
3188
+ default: c(() => [
3189
+ r(g(Pn), { class: "size-4" }),
3190
+ n[0] || (n[0] = P(" Create new section ", -1))
3191
+ ]),
3192
+ _: 1
3193
+ })
3194
+ ]),
3195
+ _: 1
3196
+ })
3197
+ ]),
3198
+ _: 1
3199
+ })
3200
+ ], 64);
3201
+ };
3202
+ }
3203
+ }), Br = { class: "flex items-center gap-2" }, jr = {
3204
+ key: 0,
3205
+ class: "size-3 rounded-full bg-green-500"
3206
+ }, Hr = {
3207
+ key: 1,
3208
+ class: "size-3 rounded-full bg-blue-500"
3209
+ }, Xr = {
3210
+ key: 2,
3211
+ class: "size-3 rounded-full bg-gray-300"
3212
+ }, Yr = /* @__PURE__ */ ne({
3213
+ __name: "Status",
3214
+ setup(e) {
3215
+ const { errors: t } = Ee(), { value: n } = B("status");
3216
+ return (o, l) => {
3217
+ const s = m("SelectValue"), i = m("SelectTrigger"), d = m("SelectItem"), a = m("SelectGroup"), x = m("SelectContent"), v = m("Select"), f = m("CardContent"), D = m("Card");
3218
+ return b(), R(D, null, {
3219
+ default: c(() => [
3220
+ r(f, null, {
3221
+ default: c(() => [
3222
+ l[4] || (l[4] = p("h3", { class: "text-lg font-semibold mb-4" }, "Status", -1)),
3223
+ r(v, {
3224
+ modelValue: g(n),
3225
+ "onUpdate:modelValue": l[0] || (l[0] = (C) => Y(n) ? n.value = C : null),
3226
+ class: "w-full"
3227
+ }, {
3228
+ default: c(() => [
3229
+ r(i, { class: "w-full" }, {
3230
+ default: c(() => [
3231
+ p("div", Br, [
3232
+ g(n) === "published" ? (b(), k("span", jr)) : g(n) === "draft" ? (b(), k("span", Hr)) : g(n) === "archived" ? (b(), k("span", Xr)) : F("", !0),
3233
+ r(s, { placeholder: "Status" })
3234
+ ])
3235
+ ]),
3236
+ _: 1
3237
+ }),
3238
+ r(x, null, {
3239
+ default: c(() => [
3240
+ r(a, null, {
3241
+ default: c(() => [
3242
+ r(d, { value: "published" }, {
3243
+ default: c(() => [...l[1] || (l[1] = [
3244
+ p("span", { class: "size-3 rounded-full bg-green-500" }, null, -1),
3245
+ P(" Published ", -1)
3246
+ ])]),
3247
+ _: 1
3248
+ }),
3249
+ r(d, { value: "draft" }, {
3250
+ default: c(() => [...l[2] || (l[2] = [
3251
+ p("span", { class: "size-3 rounded-full bg-blue-500" }, null, -1),
3252
+ P(" Draft ", -1)
3253
+ ])]),
3254
+ _: 1
3255
+ }),
3256
+ r(d, { value: "archived" }, {
3257
+ default: c(() => [...l[3] || (l[3] = [
3258
+ p("span", { class: "size-3 rounded-full bg-gray-300" }, null, -1),
3259
+ P(" Archived ", -1)
3260
+ ])]),
3261
+ _: 1
3262
+ })
3263
+ ]),
3264
+ _: 1
3265
+ })
3266
+ ]),
3267
+ _: 1
3268
+ })
3269
+ ]),
3270
+ _: 1
3271
+ }, 8, ["modelValue"])
3272
+ ]),
3273
+ _: 1
3274
+ })
3275
+ ]),
3276
+ _: 1
3277
+ });
3278
+ };
3279
+ }
3280
+ }), Kr = { class: "flex items-center gap-2 truncate" }, Gr = {
3281
+ key: 0,
3282
+ class: "text-muted-foreground"
3283
+ }, qr = {
3284
+ key: 1,
3285
+ class: "truncate"
3286
+ }, Jr = {
3287
+ key: 2,
3288
+ class: "truncate"
3289
+ }, Wr = {
3290
+ key: 3,
3291
+ class: "truncate"
3292
+ }, Zr = { class: "truncate" }, Qr = /* @__PURE__ */ ne({
3293
+ __name: "Collections",
3294
+ props: {
3295
+ config: {
3296
+ type: Object,
3297
+ required: !0
3298
+ }
3299
+ },
3300
+ setup(e) {
3301
+ const t = e, n = jt(t.config.project), o = async () => {
3302
+ if (!t.config.collectionsCollection) return [];
3303
+ const v = t.config.collectionsCollection.split(":");
3304
+ return v.length !== 2 ? [] : (await n.get(v[0]))?.[v[1]] || [];
3305
+ }, l = L([]);
3306
+ (async () => {
3307
+ const v = await o();
3308
+ l.value = v;
3309
+ })();
3310
+ const { value: i } = B("collections"), d = G(() => l.value.flatMap((v) => {
3311
+ const f = v.status || "draft", D = [
3312
+ {
3313
+ id: v.id,
3314
+ title: v.title,
3315
+ status: f,
3316
+ isSubcollection: !1
3317
+ }
3318
+ ];
3319
+ return Array.isArray(v.subcollections) && D.push(...v.subcollections.map((C) => ({
3320
+ id: C.id,
3321
+ title: C.title,
3322
+ status: f === "published" && C.status || f,
3323
+ isSubcollection: !0,
3324
+ parentTitle: v.title
3325
+ }))), D;
3326
+ })), a = G(() => Array.isArray(i.value) ? i.value.map((v) => d.value.find((f) => f.id === v)).filter(Boolean) : []), x = (v) => v.isSubcollection ? `${v.parentTitle} / ${v.title}` : v.title;
3327
+ return (v, f) => {
3328
+ const D = m("SelectTrigger"), C = m("SelectItem"), N = m("SelectGroup"), E = m("SelectContent"), M = m("Select"), A = m("CardContent"), S = m("Card");
3329
+ return b(), R(S, null, {
3330
+ default: c(() => [
3331
+ r(A, null, {
3332
+ default: c(() => [
3333
+ f[1] || (f[1] = p("h3", { class: "text-lg font-semibold mb-4" }, "Collections", -1)),
3334
+ r(M, {
3335
+ modelValue: g(i),
3336
+ "onUpdate:modelValue": f[0] || (f[0] = (w) => Y(i) ? i.value = w : null),
3337
+ class: "w-full",
3338
+ multiple: !0
3339
+ }, {
3340
+ default: c(() => [
3341
+ r(D, { class: "w-full" }, {
3342
+ default: c(() => [
3343
+ p("div", Kr, [
3344
+ a.value.length === 0 ? (b(), k("span", Gr, "Collections")) : a.value.length === 1 ? (b(), k("span", qr, z(x(a.value[0])), 1)) : a.value.length === 2 ? (b(), k("span", Jr, z(x(a.value[0])) + ", " + z(x(a.value[1])), 1)) : (b(), k("span", Wr, z(x(a.value[0])) + ", " + z(x(a.value[1])) + " + " + z(a.value.length - 2), 1))
3345
+ ])
3346
+ ]),
3347
+ _: 1
3348
+ }),
3349
+ r(E, null, {
3350
+ default: c(() => [
3351
+ r(N, null, {
3352
+ default: c(() => [
3353
+ (b(!0), k(J, null, ce(d.value, (w) => (b(), R(C, {
3354
+ key: w.id,
3355
+ value: w.id
3356
+ }, {
3357
+ default: c(() => [
3358
+ p("div", {
3359
+ class: De(["flex min-w-0 items-center gap-2", { "pl-4": w.isSubcollection }])
3360
+ }, [
3361
+ w.isSubcollection ? (b(), R(g(Nn), {
3362
+ key: 0,
3363
+ class: "size-4 shrink-0 text-muted-foreground"
3364
+ })) : F("", !0),
3365
+ p("div", {
3366
+ class: De(["size-2 rounded-full shrink-0", w.status === "published" ? "bg-green-500" : "bg-blue-500"])
3367
+ }, null, 2),
3368
+ p("span", Zr, z(w.title), 1)
3369
+ ], 2)
3370
+ ]),
3371
+ _: 2
3372
+ }, 1032, ["value"]))), 128))
3373
+ ]),
3374
+ _: 1
3375
+ })
3376
+ ]),
3377
+ _: 1
3378
+ })
3379
+ ]),
3380
+ _: 1
3381
+ }, 8, ["modelValue"])
3382
+ ]),
3383
+ _: 1
3384
+ })
3385
+ ]),
3386
+ _: 1
3387
+ });
3388
+ };
3389
+ }
3390
+ }), ea = { class: "relative @container" }, ta = { class: "flex flex-row gap-4 justify-between max-w-5xl mx-auto mt-4 mb-6" }, na = { class: "flex items-center" }, oa = { class: "text-lg font-semibold mx-2" }, la = {
3391
+ key: 0,
3392
+ class: "bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"
3393
+ }, ra = {
3394
+ key: 1,
3395
+ class: "bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"
3396
+ }, aa = {
3397
+ key: 2,
3398
+ class: "bg-gray-300 dark:bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"
3399
+ }, sa = { class: "flex flex-col @3xl:flex-row gap-4 max-w-5xl mx-auto pb-24" }, ia = { class: "flex flex-col gap-4 w-full @3xl:w-2/3" }, da = { class: "flex flex-col gap-4 w-full @3xl:w-1/3" }, ua = {
3400
+ key: 0,
3401
+ class: "fixed bottom-4 left-0 md:left-12 right-0 min-w-xs max-w-5xl w-[calc(100%-2rem)] md:w-[calc(100%-5rem)] xl:w-[calc(100%-2rem)] h-16 border border-white/10 backdrop-blur-sm border-t border-border flex items-center justify-center px-4 mx-auto z-[9999] rounded-xl overflow-hidden shadow bg-[radial-gradient(#ffffff80,transparent)] dark:bg-[radial-gradient(#00000080,transparent)]"
3402
+ }, ca = { class: "w-full max-w-5xl flex items-center justify-end mx-auto" }, ha = /* @__PURE__ */ ne({
3403
+ __name: "Detail",
3404
+ props: {
3405
+ config: {
3406
+ type: Object,
3407
+ required: !0
3408
+ }
3409
+ },
3410
+ async setup(e) {
3411
+ let t, n;
3412
+ const o = e, { hasPermission: l, hasAnyPermission: s, isAdmin: i } = Mn(), { params: d, navigateTo: a } = Bt(), { confirm: x } = Lt(), v = jt(o.config.project);
3413
+ Pt("sources", o.config.allowedMediaSources), Pt("defaultSource", o.config.defaultUploadMediaSource);
3414
+ const f = L(!1), D = G(() => !d.value.productId || d.value.productId === "new"), C = L(""), N = L([]);
3415
+ N.value = ([t, n] = yn(() => Ae()), t = await t, n(), t);
3416
+ const E = xn(Ne({
3417
+ title: X().min(1, "Title is required"),
3418
+ description: X().optional(),
3419
+ media: ye(X()).optional(),
3420
+ price: xe.number().positive("Must be positive"),
3421
+ compareAtPrice: Oe(
3422
+ (V) => V === "" ? void 0 : V,
3423
+ xe.number().positive("Must be positive").optional()
3424
+ ),
3425
+ isTaxable: Fe().optional(),
3426
+ costPerItem: Oe(
3427
+ (V) => V === "" ? void 0 : V,
3428
+ xe.number().positive("Must be positive").optional()
3429
+ ),
3430
+ currency: X(),
3431
+ stock: Oe(
3432
+ (V) => V === "" ? void 0 : V,
3433
+ xe.number().optional()
3434
+ ),
3435
+ trackInventory: Fe().optional(),
3436
+ allowBackorder: Fe().optional(),
3437
+ isPhysicalProduct: Fe().optional(),
3438
+ weight: Oe(
3439
+ (V) => V === "" ? void 0 : V,
3440
+ xe.number().optional()
3441
+ ),
3442
+ weightUnit: X().optional(),
3443
+ slug: X(),
3444
+ seo: Ne({
3445
+ title: X().optional(),
3446
+ description: X().optional()
3447
+ }).optional(),
3448
+ createdAt: Nt(),
3449
+ updatedAt: Nt(),
3450
+ status: X(),
3451
+ options: ye(Ne({
3452
+ id: X(),
3453
+ name: X().min(1),
3454
+ values: ye(Ne({
3455
+ id: X(),
3456
+ value: X()
3457
+ }))
3458
+ })).optional(),
3459
+ variants: ye(Ne({
3460
+ combinedOptions: X().min(1),
3461
+ name: X().min(1),
3462
+ disabled: Fe().optional(),
3463
+ price: xe.number().positive("Must be positive"),
3464
+ stock: Oe(
3465
+ (V) => V === "" ? void 0 : V,
3466
+ xe.number().optional()
3467
+ ),
3468
+ image: X().optional(),
3469
+ options: ye(Ne({
3470
+ optionId: X(),
3471
+ option: X(),
3472
+ valueId: X(),
3473
+ value: X()
3474
+ }))
3475
+ })).optional(),
3476
+ tags: ye(X()).optional(),
3477
+ collections: ye(X()).optional()
3478
+ })), { handleSubmit: M, errors: A, values: S, setValues: w } = Dn({
3479
+ validationSchema: E,
3480
+ initialValues: {
3481
+ createdAt: /* @__PURE__ */ new Date(),
3482
+ updatedAt: /* @__PURE__ */ new Date(),
3483
+ status: "draft",
3484
+ options: [],
3485
+ variants: [],
3486
+ media: [],
3487
+ isTaxable: !1,
3488
+ trackInventory: !1,
3489
+ allowBackorder: !1,
3490
+ isPhysicalProduct: !0,
3491
+ weight: 0,
3492
+ weightUnit: "kg",
3493
+ tags: [],
3494
+ collections: [],
3495
+ currency: o.config.defaultCurrency || "USD",
3496
+ price: 1,
3497
+ stock: 0,
3498
+ seo: {
3499
+ title: "",
3500
+ description: ""
3501
+ }
3502
+ }
3503
+ });
3504
+ An(() => [
3505
+ { text: D.value ? "New Product" : S.title || "Product" }
3506
+ ]);
3507
+ const U = (V) => {
3508
+ let $ = {
3509
+ ...V,
3510
+ maxPrice: W(),
3511
+ minPrice: j(),
3512
+ maxCompareAtPrice: ie(),
3513
+ minCompareAtPrice: oe(),
3514
+ isSingleVariant: !V.variants || V.variants.length === 0,
3515
+ variantsTotal: V.variants?.length || 1,
3516
+ stock: Ze(),
3517
+ featuredMedia: V.media?.[0]
3518
+ };
3519
+ return $.isPhysicalProduct ? $.type = "physical" : ($.weight = 0, $.weightUnit = "kg", $.type = "digital"), $;
3520
+ }, W = () => !S.variants || S.variants.length === 0 ? S.price : Math.max(...S.variants.map((V) => V.price)), j = () => !S.variants || S.variants.length === 0 ? S.price : Math.min(...S.variants.map((V) => V.price)), oe = () => S.compareAtPrice, ie = () => S.compareAtPrice, Ze = () => !S.variants || S.variants.length === 0 ? S.stock : S.variants.reduce((V, $) => $.stock < 0 ? V : V + $.stock, 0), we = M(async (V) => {
3521
+ f.value = !0;
3522
+ let $ = U(V);
3523
+ if (D.value) {
3524
+ if (await Ve($.slug)) {
3525
+ de.error("Product slug already exists");
3526
+ return;
3527
+ }
3528
+ $.createdAt = /* @__PURE__ */ new Date(), $.updatedAt = /* @__PURE__ */ new Date();
3529
+ const ae = await v.add(o.config.productCollection, $);
3530
+ a(ae.id), de.success("Product created");
3531
+ } else {
3532
+ if (C.value !== $.slug && await Ve($.slug)) {
3533
+ de.error("Product slug already exists");
3534
+ return;
3535
+ }
3536
+ $.updatedAt = /* @__PURE__ */ new Date(), await v.update(o.config.productCollection, d.value.productId, $), a(`${d.value.productId}`), de.success("Product updated");
3537
+ }
3538
+ f.value = !1;
3539
+ }), Qe = async () => {
3540
+ const V = await v.get(o.config.productCollection, d.value.productId);
3541
+ if (!V) {
3542
+ de.error("Product not found"), a("");
3543
+ return;
3544
+ }
3545
+ V.createdAt = new Date(V.createdAt), V.updatedAt = new Date(V.updatedAt), V.options?.forEach(($) => {
3546
+ $.values.forEach((ae) => {
3547
+ ae.touched = !0;
3548
+ }), $.values.push({ id: Math.random().toString(36).substring(2, 15), value: "" });
3549
+ }), w(V), C.value = V.slug;
3550
+ }, q = async () => {
3551
+ try {
3552
+ let V = { ...S }, $ = V.slug + "-copy", ae = 2;
3553
+ for (; await Ve($); )
3554
+ $ = V.slug + "-copy-" + ae, ae++;
3555
+ V.id = void 0, V.createdAt = /* @__PURE__ */ new Date(), V.updatedAt = /* @__PURE__ */ new Date(), V.slug = $, V.status = "draft", V.title = V.title + " (copy)";
3556
+ const _e = await v.add(o.config.productCollection, V);
3557
+ a(_e.id), de.success("Product duplicated");
3558
+ } catch {
3559
+ de.error("Failed to duplicate product");
3560
+ }
3561
+ }, be = async () => {
3562
+ try {
3563
+ await v.update(o.config.productCollection, d.value.productId, { status: "archived" }), w({ status: "archived" }, { force: !1 }), de.success("Product archived");
3564
+ } catch {
3565
+ de.error("Failed to archive product");
3566
+ }
3567
+ }, ke = async () => {
3568
+ if (await x("Are you sure you want to delete this product?"))
3569
+ try {
3570
+ await v.remove(o.config.productCollection, d.value.productId), a(""), de.success("Product deleted");
3571
+ } catch {
3572
+ de.error("Failed to delete product");
3573
+ }
3574
+ };
3575
+ async function Ae() {
3576
+ if (!o.config.collectionsCollection) return [];
3577
+ const V = o.config.collectionsCollection.split(":");
3578
+ return V.length !== 2 ? [] : (await v.get(V[0]))?.[V[1]] || [];
3579
+ }
3580
+ async function Ve(V) {
3581
+ return (await v.find(o.config.productCollection, {
3582
+ filters: [
3583
+ {
3584
+ field: "slug",
3585
+ operator: "==",
3586
+ value: V
3587
+ }
3588
+ ]
3589
+ })).length > 0;
3590
+ }
3591
+ return vt(() => {
3592
+ D.value || Qe();
3593
+ }), (V, $) => {
3594
+ const ae = m("Button"), _e = m("MenubarTrigger"), ze = m("MenubarMenu"), Le = m("MenubarItem"), et = m("MenubarContent"), Be = m("Menubar");
3595
+ return b(), k("div", ea, [
3596
+ p("div", ta, [
3597
+ p("div", na, [
3598
+ r(ae, {
3599
+ variant: "ghost",
3600
+ onClick: $[0] || ($[0] = (tt) => g(a)(""))
3601
+ }, {
3602
+ default: c(() => [
3603
+ r(g(Tn), { class: "size-4" })
3604
+ ]),
3605
+ _: 1
3606
+ }),
3607
+ r(g(In), { class: "size-3" }),
3608
+ p("h1", oa, z(D.value ? "New Product" : g(S).title), 1),
3609
+ g(S).status === "published" ? (b(), k("span", la, "Published")) : g(S).status === "draft" ? (b(), k("span", ra, "Draft")) : g(S).status === "archived" ? (b(), k("span", aa, "Archived")) : F("", !0)
3610
+ ]),
3611
+ D.value ? F("", !0) : (b(), R(Be, {
3612
+ key: 0,
3613
+ class: "rounded-lg shadow-xs"
3614
+ }, {
3615
+ default: c(() => [
3616
+ g(l)("create-product") ? (b(), R(ze, { key: 0 }, {
3617
+ default: c(() => [
3618
+ r(_e, { onClick: q }, {
3619
+ default: c(() => [...$[1] || ($[1] = [
3620
+ P("Duplicate", -1)
3621
+ ])]),
3622
+ _: 1
3623
+ })
3624
+ ]),
3625
+ _: 1
3626
+ })) : F("", !0),
3627
+ r(ze, null, {
3628
+ default: c(() => [
3629
+ r(_e, null, {
3630
+ default: c(() => [...$[2] || ($[2] = [
3631
+ P("Preview", -1)
3632
+ ])]),
3633
+ _: 1
3634
+ })
3635
+ ]),
3636
+ _: 1
3637
+ }),
3638
+ g(s)("edit-product", "delete-product") ? (b(), R(ze, { key: 1 }, {
3639
+ default: c(() => [
3640
+ r(_e, null, {
3641
+ default: c(() => [...$[3] || ($[3] = [
3642
+ P("More actions", -1)
3643
+ ])]),
3644
+ _: 1
3645
+ }),
3646
+ r(et, null, {
3647
+ default: c(() => [
3648
+ g(l)("edit-product") ? (b(), R(Le, {
3649
+ key: 0,
3650
+ onClick: be
3651
+ }, {
3652
+ default: c(() => [
3653
+ r(g($n), { class: "size-4" }),
3654
+ $[4] || ($[4] = P(" Archive product ", -1))
3655
+ ]),
3656
+ _: 1
3657
+ })) : F("", !0),
3658
+ g(l)("delete-product") ? (b(), R(Le, {
3659
+ key: 1,
3660
+ variant: "destructive",
3661
+ onClick: ke
3662
+ }, {
3663
+ default: c(() => [
3664
+ r(g(En), { class: "size-4" }),
3665
+ $[5] || ($[5] = P(" Delete product ", -1))
3666
+ ]),
3667
+ _: 1
3668
+ })) : F("", !0)
3669
+ ]),
3670
+ _: 1
3671
+ })
3672
+ ]),
3673
+ _: 1
3674
+ })) : F("", !0)
3675
+ ]),
3676
+ _: 1
3677
+ }))
3678
+ ]),
3679
+ p("div", sa, [
3680
+ p("div", ia, [
3681
+ r(Yn),
3682
+ r(oo),
3683
+ r(io),
3684
+ r(po),
3685
+ r(xr),
3686
+ r(Ur),
3687
+ g(i)() ? (b(), R(Lr, { key: 0 })) : F("", !0)
3688
+ ]),
3689
+ p("div", da, [
3690
+ r(Yr),
3691
+ r(Qr, { config: e.config }, null, 8, ["config"])
3692
+ ])
3693
+ ]),
3694
+ g(s)("create-product", "edit-product") ? (b(), k("div", ua, [
3695
+ p("div", ca, [
3696
+ D.value && g(l)("create-product") ? (b(), R(ae, {
3697
+ key: 0,
3698
+ onClick: g(we),
3699
+ disabled: f.value
3700
+ }, {
3701
+ default: c(() => [
3702
+ f.value ? (b(), R(g(ft), {
3703
+ key: 0,
3704
+ class: "size-4 animate-spin"
3705
+ })) : F("", !0),
3706
+ P(" " + z(f.value ? "Creating" : "Create") + " New Product ", 1)
3707
+ ]),
3708
+ _: 1
3709
+ }, 8, ["onClick", "disabled"])) : g(l)("edit-product") ? (b(), R(ae, {
3710
+ key: 1,
3711
+ onClick: g(we),
3712
+ disabled: f.value
3713
+ }, {
3714
+ default: c(() => [
3715
+ f.value ? (b(), R(g(ft), {
3716
+ key: 0,
3717
+ class: "size-4 animate-spin"
3718
+ })) : F("", !0),
3719
+ P(" " + z(f.value ? "Saving" : "Save") + " Changes ", 1)
3720
+ ]),
3721
+ _: 1
3722
+ }, 8, ["onClick", "disabled"])) : F("", !0)
3723
+ ])
3724
+ ])) : F("", !0)
3725
+ ]);
3726
+ };
3727
+ }
3728
+ });
3729
+ export {
3730
+ ha as default
3731
+ };