@chaibuilder/sdk 4.0.0-beta.31 → 4.0.0-beta.33

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 (152) hide show
  1. package/dist/{2SSKDMRQ-gmj-yWTy.js → 2SSKDMRQ-BXAXoR9y.js} +5 -5
  2. package/dist/{2SSKDMRQ-BksFOLpD.cjs → 2SSKDMRQ-BqOsh3tf.cjs} +1 -1
  3. package/dist/{AP7HFJJL-kVgc0R61.js → AP7HFJJL-B78LfetW.js} +1 -1
  4. package/dist/{AP7HFJJL-CO-deD_p.cjs → AP7HFJJL-Cv6sqAAd.cjs} +1 -1
  5. package/dist/{IconPicker-D_GRfhwS.js → IconPicker-BlO5Pnyu.js} +1 -1
  6. package/dist/{IconPicker-BJHUCDn4.cjs → IconPicker-D4yq_b-k.cjs} +1 -1
  7. package/dist/{WDYDFRGG-C9_E3QW0.js → WDYDFRGG-BE7jgVqa.js} +4 -4
  8. package/dist/{WDYDFRGG-KPpWFul_.cjs → WDYDFRGG-Dz9d3cVW.cjs} +1 -1
  9. package/dist/{actions-registery-Bj-j1k5i.js → actions-registery-D3-4Yha7.js} +1108 -1061
  10. package/dist/{actions-registery-Cy1lqUVI.cjs → actions-registery-vPaY-3dZ.cjs} +25 -25
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/{active-in-another-tab-1GoKTVcF.js → active-in-another-tab-CA47uafJ.js} +2 -2
  14. package/dist/{active-in-another-tab-iEd5fZD0.cjs → active-in-another-tab-CNn_R-55.cjs} +1 -1
  15. package/dist/{add-new-language-page-B3GUvWdP.js → add-new-language-page-B-kPbhFd.js} +3 -3
  16. package/dist/{add-new-language-page-Cq8R42Ro.cjs → add-new-language-page-QAZbAFQe.cjs} +1 -1
  17. package/dist/{add-new-page-DiHnECAR.cjs → add-new-page-D4nbAHOp.cjs} +1 -1
  18. package/dist/add-new-page-Y0d9tHh0.js +31 -0
  19. package/dist/{ai-panel-content-BPpawv4D.cjs → ai-panel-content-DXbebC-m.cjs} +1 -1
  20. package/dist/{ai-panel-content-tExD3yhH.js → ai-panel-content-WMOeK5pF.js} +5 -5
  21. package/dist/{ai-panel-default-lang-DnYLHSaS.js → ai-panel-default-lang-CM_psX_h.js} +7 -7
  22. package/dist/{ai-panel-default-lang-C6N4wUUF.cjs → ai-panel-default-lang-hmfyAYPM.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-D1pCJluY.js → ai-panel-other-lang-BKANRJAb.js} +13 -13
  24. package/dist/{ai-panel-other-lang-C65lVVtZ.cjs → ai-panel-other-lang-D4GL1b-W.cjs} +1 -1
  25. package/dist/{ai-prompt-input-Dws5BHhQ.cjs → ai-prompt-input-Dwd0-pcD.cjs} +1 -1
  26. package/dist/{ai-prompt-input-B2q30bhR.js → ai-prompt-input-mxXtWptn.js} +13 -13
  27. package/dist/{ai-translation-prompt-DnwG2BmF.cjs → ai-translation-prompt-7M2aEZ1w.cjs} +1 -1
  28. package/dist/{ai-translation-prompt-Dnn6i_t3.js → ai-translation-prompt-C_Pb7BE4.js} +1 -1
  29. package/dist/{apply-binding-chfbBKi2.js → apply-binding-BYCW1k2l.js} +1 -1
  30. package/dist/{apply-binding-9XSrYzAE.cjs → apply-binding-xiigK7eK.cjs} +1 -1
  31. package/dist/{change-password-modal-LKtYY-8V.cjs → change-password-modal-BYZoefwT.cjs} +1 -1
  32. package/dist/{change-password-modal-C0MMizgl.js → change-password-modal-Dqf_mleR.js} +5 -5
  33. package/dist/{code-editor-CWOmKcUc.js → code-editor-1fSEocLK.js} +1 -1
  34. package/dist/{code-editor-Cim6jQVF.cjs → code-editor-uN7W7KMD.cjs} +1 -1
  35. package/dist/{continue-editing-in-this-client-oxYWGWON.js → continue-editing-in-this-client-DD7bBhjD.js} +2 -2
  36. package/dist/{continue-editing-in-this-client-Dd6nKIvX.cjs → continue-editing-in-this-client-DDM65ror.cjs} +1 -1
  37. package/dist/{core-BWQrViOY.cjs → core-czmLeR0h.cjs} +1 -1
  38. package/dist/{core-QlWEXm1d.js → core-nSRy3D7z.js} +16 -15
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +14 -2
  41. package/dist/core.js +19 -19
  42. package/dist/{css-import-modal-CXulmaB4.cjs → css-import-modal-BU7bJAaT.cjs} +1 -1
  43. package/dist/{css-import-modal-6bMTRlCg.js → css-import-modal-pBNRVmGj.js} +1 -1
  44. package/dist/default-theme-options-DN-3gIjM.cjs +22 -0
  45. package/dist/{plugin-BSjgGgwo.js → default-theme-options-saBIkWGT.js} +114 -114
  46. package/dist/{delete-page-D0tdn6VW.cjs → delete-page-8oEYsHPE.cjs} +1 -1
  47. package/dist/delete-page-B53nkF74.js +71 -0
  48. package/dist/{design-token-usage-D-hrcKz1.cjs → design-token-usage-Cm9m4AMz.cjs} +1 -1
  49. package/dist/{design-token-usage-lf7N_uOk.js → design-token-usage-DzWav2ip.js} +14 -14
  50. package/dist/{digital-asset-manager-DJhRhLGC.js → digital-asset-manager-1yLYGPuf.js} +5 -5
  51. package/dist/digital-asset-manager-BaTvMY8Q.cjs +1 -0
  52. package/dist/{duplicate-page-ChSp1TYN.cjs → duplicate-page-C2DZI4U0.cjs} +1 -1
  53. package/dist/{duplicate-page-CXzYy7vx.js → duplicate-page-DCRVR-kF.js} +6 -6
  54. package/dist/{dynamic-page-selector-btGtkyyv.cjs → dynamic-page-selector-CZJQnc-Q.cjs} +1 -1
  55. package/dist/{dynamic-page-selector-r5IR9_7k.js → dynamic-page-selector-DCGWkLVV.js} +12 -12
  56. package/dist/get-chai-builder-theme-C_qofMh_.cjs +1 -0
  57. package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-CyOkIlte.js} +1 -1
  58. package/dist/{image-compression-DsZ1oqpb.js → image-compression-DPFITwOL.js} +2 -2
  59. package/dist/image-compression-UaU7Bwqe.cjs +1 -0
  60. package/dist/{image-editor-CilPMtAC.js → image-editor-C0EYZJY_.js} +1 -1
  61. package/dist/{image-editor-BdW476J8.cjs → image-editor-DkgZrSGr.cjs} +1 -1
  62. package/dist/{index-DtMksfXx.js → index-BDrc0HJQ.js} +1729 -1680
  63. package/dist/index-BuXfCtgR.cjs +5 -0
  64. package/dist/{index-DsQXiNA_.js → index-C7bidKtE.js} +2786 -2752
  65. package/dist/index-DKjYF53r.cjs +160 -0
  66. package/dist/{json-diff-viewer-BkrnLb3B.cjs → json-diff-viewer-88jEhq8D.cjs} +1 -1
  67. package/dist/{json-diff-viewer-D3N3w3Ax.js → json-diff-viewer-wmzIZcuQ.js} +34 -34
  68. package/dist/{lang-panel-BAaaP4Qc.js → lang-panel--kWBnU_W.js} +7 -7
  69. package/dist/{lang-panel-BjDRrpwN.cjs → lang-panel-I_ABfjOZ.cjs} +1 -1
  70. package/dist/manage-design-tokens-CslCEOXU.cjs +1 -0
  71. package/dist/manage-design-tokens-JdVKj09s.js +445 -0
  72. package/dist/manage-design-tokens-modal-DA15ou0u.cjs +1 -0
  73. package/dist/{manage-design-tokens-modal-9qpcb-EC.js → manage-design-tokens-modal-xKxC72Bc.js} +9 -9
  74. package/dist/{mark-as-template-DNHYNjI9.js → mark-as-template-AbZrkEYl.js} +7 -7
  75. package/dist/{mark-as-template-IYRjta97.cjs → mark-as-template-ClQjC2p2.cjs} +1 -1
  76. package/dist/{nested-path-selector-content-Be-pbnVl.js → nested-path-selector-content-B04k-PPB.js} +1 -1
  77. package/dist/{nested-path-selector-content-CWmPgU-L.cjs → nested-path-selector-content-dFwZaM1r.cjs} +1 -1
  78. package/dist/{no-language-page-content-C-ltY7bj.js → no-language-page-content-CbUqxuC4.js} +2 -2
  79. package/dist/{no-language-page-content-8_J6y-cm.cjs → no-language-page-content-pzkWJAg6.cjs} +1 -1
  80. package/dist/{no-language-page-dialog-D5NXpDHi.js → no-language-page-dialog-AavD_Mmc.js} +2 -2
  81. package/dist/{no-language-page-dialog-BOZZZzqx.cjs → no-language-page-dialog-DhlOVXUm.cjs} +1 -1
  82. package/dist/{page-creator-BuHHnqiQ.js → page-creator-2OZveMsR.js} +95 -95
  83. package/dist/{page-creator-wtbae2U7.cjs → page-creator-DMjnStPf.cjs} +1 -1
  84. package/dist/{page-lock-pPGlTxj7.js → page-lock-5MwwTWe8.js} +2 -2
  85. package/dist/{page-lock-DN4iJc-V.cjs → page-lock-B3CpoFTs.cjs} +1 -1
  86. package/dist/{page-locked-dialog-Bl-ojgIW.js → page-locked-dialog-BhNZC9wZ.js} +13 -13
  87. package/dist/{page-locked-dialog-B_vdgv24.cjs → page-locked-dialog-ZOvjnxRI.cjs} +1 -1
  88. package/dist/page-manager-new-BcI-1Dms.cjs +1 -0
  89. package/dist/{page-manager-new-Bg8H6yrg.js → page-manager-new-l68-Lc9h.js} +85 -88
  90. package/dist/{page-manager-search-and-filter-CDXunXNd.cjs → page-manager-search-and-filter-BOpne6v-.cjs} +1 -1
  91. package/dist/{page-manager-search-and-filter-CyfO7O96.js → page-manager-search-and-filter-DJn98D02.js} +31 -30
  92. package/dist/{page-revisions-content-BKT8S9_g.cjs → page-revisions-content-B00tDCzu.cjs} +1 -1
  93. package/dist/{page-revisions-content-B-egQgoZ.js → page-revisions-content-Bqp-9bae.js} +23 -23
  94. package/dist/pages.cjs +1 -1
  95. package/dist/pages.d.ts +14 -2
  96. package/dist/pages.js +12 -12
  97. package/dist/{publish-pages-content-D2B_ScCQ.js → publish-pages-content-CtZLSG6O.js} +68 -75
  98. package/dist/publish-pages-content-DfYG0biw.cjs +1 -0
  99. package/dist/render.cjs +1 -1
  100. package/dist/render.js +5 -5
  101. package/dist/{rte-widget-modal-c3T09VeO.js → rte-widget-modal-DGEWoQ1b.js} +1 -1
  102. package/dist/{rte-widget-modal-CC1KcrAT.cjs → rte-widget-modal-DX66uSPv.cjs} +1 -1
  103. package/dist/runtime.cjs +6 -6
  104. package/dist/runtime.d.ts +2 -0
  105. package/dist/runtime.js +36 -35
  106. package/dist/{save-to-lib-dT1NDd5w.js → save-to-lib-CCxX5ZmQ.js} +26 -26
  107. package/dist/{save-to-lib-CiM0wiIr.cjs → save-to-lib-DmAjdhzU.cjs} +1 -1
  108. package/dist/sdk.css +1 -1
  109. package/dist/{selected-block-display-BgqcPsXI.cjs → selected-block-display-Csce27bR.cjs} +1 -1
  110. package/dist/{selected-block-display-BQndDPcY.js → selected-block-display-Cv6jBhJD.js} +20 -20
  111. package/dist/{seo-panel-DXZvGYEM.cjs → seo-panel-BZYXeYzE.cjs} +1 -1
  112. package/dist/{seo-panel-Z93Zf_bz.js → seo-panel-Ctstjs-d.js} +25 -25
  113. package/dist/{shared-json-ld-DwvUDGAS.cjs → shared-json-ld-BDWtjHgw.cjs} +1 -1
  114. package/dist/{shared-json-ld-Ct68RlWD.js → shared-json-ld-BNHGmUBd.js} +45 -45
  115. package/dist/{slug-input-CAqkFZBq.js → slug-input-Bui1Qmvh.js} +1 -1
  116. package/dist/{slug-input-Curnt2n3.cjs → slug-input-IAl_jfHr.cjs} +1 -1
  117. package/dist/supabase-actions.cjs +1 -1
  118. package/dist/supabase-actions.js +272 -206
  119. package/dist/{take-over-request-D6y2HcDr.cjs → take-over-request-Bl6jS1cK.cjs} +1 -1
  120. package/dist/{take-over-request-C6ngP1QR.js → take-over-request-Ceuqyk5K.js} +13 -13
  121. package/dist/{translation-warning-modal-B876S5yp.cjs → translation-warning-modal-CCmmwz1C.cjs} +1 -1
  122. package/dist/{translation-warning-modal-kRcfrPgo.js → translation-warning-modal-DA5dt2FA.js} +9 -9
  123. package/dist/types.d.ts +14 -2
  124. package/dist/{unmark-as-template-DeeWUTco.js → unmark-as-template-CKVMibvu.js} +13 -13
  125. package/dist/{unmark-as-template-f1dl_YTz.cjs → unmark-as-template-OEUqo0uc.cjs} +1 -1
  126. package/dist/unpublish-page-A5qn6E6g.js +28 -0
  127. package/dist/{unpublish-page-DEPFjGuu.cjs → unpublish-page-C81bYHLI.cjs} +1 -1
  128. package/dist/{unpublished-partials-modal-Ts5ZhAK9.js → unpublished-partials-modal-FqzTp5el.js} +3 -3
  129. package/dist/{unpublished-partials-modal-CEFXp1D1.cjs → unpublished-partials-modal-af5uDL7Y.cjs} +1 -1
  130. package/dist/utils.cjs +1 -1
  131. package/dist/utils.js +1 -1
  132. package/dist/web-blocks.cjs +1 -1
  133. package/dist/web-blocks.js +1 -1
  134. package/dist/{web-preview-CoT8r96b.js → web-preview-vge6uUSa.js} +1 -1
  135. package/dist/{web-preview-DTDoIE-c.cjs → web-preview-xtKkQOXy.cjs} +1 -1
  136. package/package.json +2 -7
  137. package/dist/add-new-page-C5HlQfzy.js +0 -31
  138. package/dist/delete-page-LnzR01A8.js +0 -71
  139. package/dist/digital-asset-manager-eCJHNSjj.cjs +0 -1
  140. package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
  141. package/dist/image-compression-DZ9WMmyn.cjs +0 -1
  142. package/dist/index-CAhDwfHE.cjs +0 -5
  143. package/dist/index-mPCp0j2h.cjs +0 -160
  144. package/dist/manage-design-tokens-BknGNAKE.cjs +0 -1
  145. package/dist/manage-design-tokens-Co5677WS.js +0 -428
  146. package/dist/manage-design-tokens-modal-BcgdwEXE.cjs +0 -1
  147. package/dist/page-manager-new-5W5M9_ue.cjs +0 -1
  148. package/dist/plugin-DHpuZZXz.cjs +0 -22
  149. package/dist/publish-pages-content-WJHTVYnx.cjs +0 -1
  150. package/dist/theme-panel-footer-CGZL2F7R.js +0 -26
  151. package/dist/theme-panel-footer-IgGj-_OA.cjs +0 -1
  152. package/dist/unpublish-page-U_79Pwc0.js +0 -28
@@ -1,17 +1,17 @@
1
1
  import { jsx as e, jsxs as n, Fragment as G } from "react/jsx-runtime";
2
- import { D as $, e as W, f as Y, g as X, q as y, a0 as U, a1 as _, as as R, a2 as q, a3 as H, at as M, a4 as K, a5 as Q, d as me, x as L, y as J, z as F, a6 as he, G as ue, H as ge, I as fe, au as pe, J as xe, T as Ne } from "./index-DsQXiNA_.js";
2
+ import { D as $, e as W, f as Y, g as X, p as y, a0 as U, a1 as _, at as R, a2 as H, a3 as M, au as q, a4 as Q, a5 as V, d as me, w as L, x as F, y as J, a6 as he, F as ue, G as ge, H as fe, av as pe, I as xe, T as Ne } from "./index-C7bidKtE.js";
3
3
  import { D as be, F as ye, z as j, B as v } from "./register-chai-top-bar-D6GjnauV.js";
4
- import { ar as ve, as as we, A as V, aw as le, aD as Ae, aE as se, aF as re, aG as de, aH as Ce, aI as Se, aJ as Pe, l as Te, aK as De } from "./index-DtMksfXx.js";
4
+ import { as as ve, at as we, A as K, ax as le, aC as Ce, aD as se, aE as re, aF as de, aG as Ae, aH as Se, aI as Pe, j as Te, aJ as De } from "./index-BDrc0HJQ.js";
5
5
  import { useQuery as Ee, useQueryClient as Le } from "@tanstack/react-query";
6
- import { filter as Je, find as Fe } from "lodash-es";
6
+ import { filter as Fe, find as Je } from "lodash-es";
7
7
  import { Info as Oe, Loader as O, Plus as ke, Eye as Ge, Edit as je, Trash as Be } from "lucide-react";
8
8
  import { useState as g, useEffect as Z, useMemo as z } from "react";
9
9
  import { toast as B } from "sonner";
10
10
  const oe = () => {
11
11
  const t = ve(), i = we();
12
12
  return Ee({
13
- queryKey: [V.GET_GLOBAL_JSONLD_ITEMS],
14
- queryFn: async () => i(t, { action: V.GET_GLOBAL_JSONLD_ITEMS })
13
+ queryKey: [K.GET_GLOBAL_JSONLD_ITEMS],
14
+ queryFn: async () => i(t, { action: K.GET_GLOBAL_JSONLD_ITEMS })
15
15
  });
16
16
  }, Ie = ({
17
17
  show: t,
@@ -27,7 +27,7 @@ const oe = () => {
27
27
  content: "",
28
28
  description: "",
29
29
  enabledByDefaultForNewPages: !1
30
- }), [x, S] = g(!1), { data: u } = le(), { mutateAsync: C, isPending: p } = Ae(), { mutateAsync: c } = se(), w = Le();
30
+ }), [x, S] = g(!1), { data: u } = le(), { mutateAsync: A, isPending: p } = Ce(), { mutateAsync: c } = se(), w = Le();
31
31
  Z(() => {
32
32
  f(a ? {
33
33
  name: a.name,
@@ -54,13 +54,13 @@ const oe = () => {
54
54
  description: d.description
55
55
  };
56
56
  a != null && a.primaryPageId && (N.primaryPage = a.primaryPageId);
57
- const A = await C(N);
58
- u != null && u.id && (A != null && A.id) && !(a != null && a.primaryPageId) && (await c({
59
- schemaId: A.id,
57
+ const C = await A(N);
58
+ u != null && u.id && (C != null && C.id) && !(a != null && a.primaryPageId) && (await c({
59
+ schemaId: C.id,
60
60
  pageId: u.id,
61
61
  enabled: !0
62
62
  }), w.invalidateQueries({
63
- queryKey: [V.GET_LANGUAGE_PAGES, u.id]
63
+ queryKey: [K.GET_LANGUAGE_PAGES, u.id]
64
64
  })), i();
65
65
  };
66
66
  return /* @__PURE__ */ n(W, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
@@ -164,7 +164,7 @@ const oe = () => {
164
164
  content: "",
165
165
  description: "",
166
166
  enabledByDefaultForNewPages: !1
167
- }), [f, x] = g(!1), [S, u] = g(!1), [C, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = Ce(), { mutateAsync: l } = Se(), { mutateAsync: N } = Pe();
167
+ }), [f, x] = g(!1), [S, u] = g(!1), [A, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = Ae(), { mutateAsync: l } = Se(), { mutateAsync: N } = Pe();
168
168
  Z(() => {
169
169
  var m, T;
170
170
  if (t && c) {
@@ -177,7 +177,7 @@ const oe = () => {
177
177
  }), p(!!b.primaryPage));
178
178
  }
179
179
  }, [t, c]);
180
- const A = async () => {
180
+ const C = async () => {
181
181
  if (!a.name || !a.content) {
182
182
  B.error("Please enter a name and content");
183
183
  return;
@@ -211,7 +211,7 @@ const oe = () => {
211
211
  return /* @__PURE__ */ n(W, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
212
212
  /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Edit Shared JSON-LD Schema" }) }),
213
213
  /* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
214
- !C && /* @__PURE__ */ n("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
214
+ !A && /* @__PURE__ */ n("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
215
215
  /* @__PURE__ */ n("div", { children: [
216
216
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-blue-900", children: "Manage Existing Pages" }),
217
217
  /* @__PURE__ */ e("div", { className: "text-xs text-blue-700", children: "Add or remove this schema from all existing pages on your site" })
@@ -259,7 +259,7 @@ const oe = () => {
259
259
  }
260
260
  )
261
261
  ] }),
262
- !C && /* @__PURE__ */ n("div", { className: "flex items-center space-x-2", children: [
262
+ !A && /* @__PURE__ */ n("div", { className: "flex items-center space-x-2", children: [
263
263
  /* @__PURE__ */ e(
264
264
  "input",
265
265
  {
@@ -277,7 +277,7 @@ const oe = () => {
277
277
  ] }),
278
278
  /* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
279
279
  /* @__PURE__ */ e(v, { disabled: o, variant: "outline", type: "button", size: "sm", onClick: () => i(), children: "Cancel" }),
280
- /* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick: A, children: o ? /* @__PURE__ */ n(G, { children: [
280
+ /* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick: C, children: o ? /* @__PURE__ */ n(G, { children: [
281
281
  /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }),
282
282
  " Updating"
283
283
  ] }) : "Update Schema" })
@@ -285,37 +285,37 @@ const oe = () => {
285
285
  ] }),
286
286
  /* @__PURE__ */ e(U, { open: f, onOpenChange: x, children: /* @__PURE__ */ n(_, { children: [
287
287
  /* @__PURE__ */ n(R, { children: [
288
- /* @__PURE__ */ e(q, { children: "Add to All Existing Pages?" }),
289
- /* @__PURE__ */ n(H, { children: [
288
+ /* @__PURE__ */ e(H, { children: "Add to All Existing Pages?" }),
289
+ /* @__PURE__ */ n(M, { children: [
290
290
  "This will add the schema ",
291
291
  /* @__PURE__ */ e("span", { className: "font-medium", children: a.name }),
292
292
  " to all existing pages on your site. This action cannot be undone automatically."
293
293
  ] })
294
294
  ] }),
295
- /* @__PURE__ */ n(M, { children: [
296
- /* @__PURE__ */ e(K, { children: "Cancel" }),
297
- /* @__PURE__ */ e(Q, { onClick: I, children: "Add to All" })
295
+ /* @__PURE__ */ n(q, { children: [
296
+ /* @__PURE__ */ e(Q, { children: "Cancel" }),
297
+ /* @__PURE__ */ e(V, { onClick: I, children: "Add to All" })
298
298
  ] })
299
299
  ] }) }),
300
300
  /* @__PURE__ */ e(U, { open: S, onOpenChange: u, children: /* @__PURE__ */ n(_, { children: [
301
301
  /* @__PURE__ */ n(R, { children: [
302
- /* @__PURE__ */ e(q, { children: "Remove from All Pages?" }),
303
- /* @__PURE__ */ n(H, { children: [
302
+ /* @__PURE__ */ e(H, { children: "Remove from All Pages?" }),
303
+ /* @__PURE__ */ n(M, { children: [
304
304
  "This will remove the schema ",
305
305
  /* @__PURE__ */ e("span", { className: "font-medium", children: a.name }),
306
306
  " from all existing pages on your site. This action cannot be undone automatically."
307
307
  ] })
308
308
  ] }),
309
- /* @__PURE__ */ n(M, { children: [
310
- /* @__PURE__ */ e(K, { children: "Cancel" }),
311
- /* @__PURE__ */ e(Q, { onClick: P, className: "bg-red-500 hover:bg-red-600", children: "Remove from All" })
309
+ /* @__PURE__ */ n(q, { children: [
310
+ /* @__PURE__ */ e(Q, { children: "Cancel" }),
311
+ /* @__PURE__ */ e(V, { onClick: P, className: "bg-red-500 hover:bg-red-600", children: "Remove from All" })
312
312
  ] })
313
313
  ] }) })
314
314
  ] });
315
315
  };
316
316
  function Xe() {
317
- const [t, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [S, u] = g(null), [C, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: l } = le(), { data: N } = Te(), { mutateAsync: A } = De(), { mutateAsync: I } = se(), P = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (P == null ? void 0 : P.globalJsonLds) || [], [P]), T = z(() => c ? Je(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
- const h = o ? Fe(c, (D) => D.primaryPage === r.id && D.lang === o) : null;
317
+ const [t, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [S, u] = g(null), [A, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: l } = le(), { data: N } = Te(), { mutateAsync: C } = De(), { mutateAsync: I } = se(), P = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (P == null ? void 0 : P.globalJsonLds) || [], [P]), T = z(() => c ? Fe(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
+ const h = o ? Je(c, (D) => D.primaryPage === r.id && D.lang === o) : null;
319
319
  return {
320
320
  defaultSchema: r,
321
321
  languageVersion: h,
@@ -346,7 +346,7 @@ function Xe() {
346
346
  }, ce = async (s) => {
347
347
  p(s);
348
348
  try {
349
- await A(s);
349
+ await C(s);
350
350
  } finally {
351
351
  p(null);
352
352
  }
@@ -359,7 +359,7 @@ function Xe() {
359
359
  ] }),
360
360
  !o && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
361
361
  /* @__PURE__ */ e(
362
- J,
362
+ F,
363
363
  {
364
364
  type: "button",
365
365
  disabled: w,
@@ -370,7 +370,7 @@ function Xe() {
370
370
  children: w ? /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ke, { className: "h-4 w-4" })
371
371
  }
372
372
  ),
373
- /* @__PURE__ */ e(F, { children: "Add new schema" })
373
+ /* @__PURE__ */ e(J, { children: "Add new schema" })
374
374
  ] })
375
375
  ] }),
376
376
  /* @__PURE__ */ n(he, { className: "max-h-96 overflow-y-auto", children: [
@@ -382,13 +382,13 @@ function Xe() {
382
382
  return /* @__PURE__ */ n(
383
383
  ue,
384
384
  {
385
- className: `relative border-gray-300 p-0 shadow-none transition-all ${C === r.id ? "pointer-events-none" : ""}`,
385
+ className: `relative border-gray-300 p-0 shadow-none transition-all ${A === r.id ? "pointer-events-none" : ""}`,
386
386
  children: [
387
- C === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
387
+ A === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
388
388
  /* @__PURE__ */ e(ge, { className: "p-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
389
389
  /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
390
390
  (h || !o) && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
391
- /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
391
+ /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
392
392
  "input",
393
393
  {
394
394
  type: "checkbox",
@@ -398,7 +398,7 @@ function Xe() {
398
398
  className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
399
399
  }
400
400
  ) }),
401
- h && o && /* @__PURE__ */ e(F, { children: "Using the default language state" })
401
+ h && o && /* @__PURE__ */ e(J, { children: "Using the default language state" })
402
402
  ] }),
403
403
  /* @__PURE__ */ n("div", { children: [
404
404
  /* @__PURE__ */ n(fe, { className: "flex items-center gap-2 text-sm leading-none", children: [
@@ -416,7 +416,7 @@ function Xe() {
416
416
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
417
417
  /* @__PURE__ */ e("div", { className: "mx-2 h-6 w-px bg-border" }),
418
418
  /* @__PURE__ */ n(L, { delayDuration: 0, children: [
419
- /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
419
+ /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
420
420
  v,
421
421
  {
422
422
  type: "button",
@@ -427,11 +427,11 @@ function Xe() {
427
427
  children: /* @__PURE__ */ e(Ge, { className: "h-4 w-4" })
428
428
  }
429
429
  ) }),
430
- /* @__PURE__ */ e(F, { children: "View schema" })
430
+ /* @__PURE__ */ e(J, { children: "View schema" })
431
431
  ] }),
432
432
  (h || !o) && /* @__PURE__ */ n(G, { children: [
433
433
  /* @__PURE__ */ n(L, { delayDuration: 0, children: [
434
- /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
434
+ /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
435
435
  v,
436
436
  {
437
437
  type: "button",
@@ -442,27 +442,27 @@ function Xe() {
442
442
  children: /* @__PURE__ */ e(je, { className: "h-4 w-4" })
443
443
  }
444
444
  ) }),
445
- /* @__PURE__ */ e(F, { children: "Edit schema" })
445
+ /* @__PURE__ */ e(J, { children: "Edit schema" })
446
446
  ] }),
447
447
  /* @__PURE__ */ n(U, { children: [
448
448
  /* @__PURE__ */ n(L, { delayDuration: 0, children: [
449
- /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(pe, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Be, { className: "h-4 w-4" }) }) }),
450
- /* @__PURE__ */ e(F, { children: "Delete schema" })
449
+ /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(pe, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Be, { className: "h-4 w-4" }) }) }),
450
+ /* @__PURE__ */ e(J, { children: "Delete schema" })
451
451
  ] }),
452
452
  /* @__PURE__ */ n(_, { children: [
453
453
  /* @__PURE__ */ n(R, { children: [
454
- /* @__PURE__ */ e(q, { children: "Delete Schema" }),
455
- /* @__PURE__ */ n(H, { children: [
454
+ /* @__PURE__ */ e(H, { children: "Delete Schema" }),
455
+ /* @__PURE__ */ n(M, { children: [
456
456
  "Are you sure you want to delete",
457
457
  " ",
458
458
  /* @__PURE__ */ e("span", { className: "font-medium", children: r.name }),
459
459
  "? This action cannot be undone."
460
460
  ] })
461
461
  ] }),
462
- /* @__PURE__ */ n(M, { children: [
463
- /* @__PURE__ */ e(K, { type: "button", children: "Cancel" }),
462
+ /* @__PURE__ */ n(q, { children: [
463
+ /* @__PURE__ */ e(Q, { type: "button", children: "Cancel" }),
464
464
  /* @__PURE__ */ e(
465
- Q,
465
+ V,
466
466
  {
467
467
  type: "button",
468
468
  onClick: () => ce(r.id),
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
2
  import { z as v } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { L as d } from "./index-DsQXiNA_.js";
3
+ import { L as d } from "./index-C7bidKtE.js";
4
4
  import { useState as x, useEffect as C } from "react";
5
5
  const y = (e) => {
6
6
  if (!e) return { base: e, extension: null };
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),u=require("./index-mPCp0j2h.cjs"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!u.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=d.useState(e),[l,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
1
+ "use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),u=require("./index-DKjYF53r.cjs"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!u.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=d.useState(e),[l,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty;var O=(u,t,e)=>t in u?D(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var y=(u,t,e)=>O(u,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./actions-registery-Cy1lqUVI.cjs"),w=require("lodash-es"),b=require("sharp"),i=require("zod");class A{constructor(t,e,r){this.appId=t,this.userId=e,this.supabase=r}appendUpdatedAtToUrl(t,e){if(w.isEmpty(t))return"";const r=new URL(t),o=new Date(e).getTime();return r.searchParams.set("t",o.toString()),`${r.origin}${r.pathname}${r.search}${r.hash}`}getBufferFromBase64(t){try{const e=t.split(",")[1]||t;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}async uploadImageFile(t,e,r,o){try{const s=this.getBufferFromBase64(t),n=await b(s).metadata(),c=["jpeg","jpg","png","webp","gif","svg","tiff"];if(!n.format||!c.includes(n.format.toLowerCase()))throw new Error(`Invalid image format: ${n.format||"unknown"}`);const d=o?await b(s).webp({quality:100}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer():await b(s).webp({quality:100}).toBuffer();let a=d;if(o&&d.length>120*1024){const _=Math.floor(90*(122880/d.length));a=await b(s).webp({quality:_}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer()}const l=await b(a).metadata(),g=await b(s).webp({quality:70}).resize({width:300}).toBuffer(),p=r.split("."),m=p.length>1?p.slice(0,-1).join("."):r,f=`${w.kebabCase(m)}.webp`,k=`${f}_thumbnail.webp`,T=this.appId,I=e?`${T}/${e}`:T,S=h.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:a.toString("base64"),fileName:f,contentType:"image/webp",folder:I});if(U.error)throw new Error(U.error);const E=await S.execute({file:g.toString("base64"),fileName:k,contentType:"image/webp",folder:I});if(E.error)throw new Error(E.error);return{url:U.data.url,thumbnailUrl:E.data.url,size:l.size||a.length,width:l.width||0,height:l.height||0,mimeType:"image/webp"}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(t,e,r){try{const o=this.getBufferFromBase64(t);let s,n;try{const f=await b(o).metadata();s=f.width,n=f.height}catch{}const c=r.split("."),d=c.length>1?c.slice(0,-1).join("."):r,a=`${w.kebabCase(d)}.svg`,l=this.appId,g=e?`${l}/${e}`:l,p=h.getChaiAction("UPLOAD_TO_STORAGE");if(!p)throw new Error("UPLOAD_TO_STORAGE action not found");p.setContext({appId:this.appId,userId:this.userId});const m=await p.execute({file:o.toString("base64"),fileName:a,contentType:"image/svg+xml",folder:g});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:o.length,width:s,height:n,mimeType:"image/svg+xml"}}catch(o){return console.error("SVG upload error:",o),{error:o instanceof Error?o.message:"Unknown error"}}}async upload({file:t,folderId:e,name:r,optimize:o=!0}){var s;try{const c=r.toLowerCase().endsWith(".svg")||t.includes("data:image/svg+xml")?await this.uploadSvgFile(t,e,r):await this.uploadImageFile(t,e,r,o??!0);if("error"in c)return c;const d={name:r,app:this.appId,url:c.url,thumbnailUrl:c.thumbnailUrl,size:(s=c.size)==null?void 0:s.toString(),width:c.width,height:c.height,format:c.mimeType.split("/")[1],folderId:e,type:c.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:a,error:l}=await this.supabase.from("app_assets").insert(d).select("*").single();if(l)throw new Error(`Failed to store asset in database: ${l.message}`);return{id:a.id,name:a.name,type:a.type,url:this.appendUpdatedAtToUrl(a.url,a.updatedAt),size:a.size,thumbnailUrl:this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt),width:a.width,height:a.height,format:a.format,folderId:a.folderId,createdBy:a.createdBy||"",createdAt:a.createdAt,updatedAt:a.updatedAt}}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}async getAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);return w.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),w.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:t="",page:e=1,limit:r=20}={}){try{const o=(e-1)*r;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});t&&(s=s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));const{data:n,error:c,count:d}=await s.range(o,o+r-1);if(c)throw new Error(c.message);return{assets:n.map(l=>(w.set(l,"url",this.appendUpdatedAtToUrl(l.url,l.updatedAt)),w.set(l,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(l.thumbnailUrl||"",l.updatedAt)),l)),total:d||0,page:e,pageSize:r}}catch(o){throw console.error("Error fetching assets:",o),o}}async deleteAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);if(e.url)try{const n=new URL(e.url).pathname.split("/"),c=n.indexOf("dam-assets");if(c!==-1){const d=n.slice(c+1).join("/"),a=h.getChaiAction("DELETE_FROM_STORAGE");if(a&&(a.setContext({appId:this.appId,userId:this.userId}),await a.execute({key:d})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const g=new URL(e.thumbnailUrl).pathname.split("/"),p=g.indexOf("dam-assets");if(p!==-1){const m=g.slice(p+1).join("/");a&&await a.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:o}=await this.supabase.from("app_assets").delete().eq("id",t);if(o)throw new Error(`Failed to delete asset: ${o.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:t,file:e,description:r}){var o,s;try{const{data:n,error:c}=await this.supabase.from("app_assets").select("*").eq("id",t).single();if(c)throw new Error(`Failed to fetch asset: ${c.message}`);const d={};if(r!==void 0&&(d.description=r,d.updatedAt=new Date().toISOString()),e){const p=((o=n.format)==null?void 0:o.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,n.folderId,n.name):await this.uploadImageFile(e,n.folderId,n.name,!0);if("error"in p)return p;d.url=p.url,d.thumbnailUrl=p.thumbnailUrl,d.size=(s=p.size)==null?void 0:s.toString(),d.width=p.width,d.height=p.height,d.format=p.mimeType.split("/")[1],d.updatedAt=new Date().toISOString()}const{data:a,error:l}=await this.supabase.from("app_assets").update(d).eq("id",t).select().single();if(l)throw new Error(`Failed to update asset: ${l.message}`);return w.set(a,"url",this.appendUpdatedAtToUrl(a.url,a.updatedAt)),w.set(a,"thumbnailUrl",this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt)),a}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}}const C=i.z.object({name:i.z.string(),file:i.z.string(),folderId:i.z.string().optional().nullable(),optimize:i.z.boolean().optional()});class P extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return C}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new A(e,r,this.supabase).upload(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const F=i.z.object({id:i.z.string()});class B extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return F}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new A(e,r,this.supabase).getAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const v=i.z.object({search:i.z.string().optional(),page:i.z.number().optional(),limit:i.z.number().optional()});class $ extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return v}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new A(e,r,this.supabase).getAssets(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const q=i.z.object({id:i.z.string()});class G extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return q}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new A(e,r,this.supabase).deleteAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const L=i.z.object({id:i.z.string(),file:i.z.string().optional(),description:i.z.string().optional()});class j extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return L}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new A(e,r,this.supabase).updateAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const R=i.z.object({userId:i.z.string()});class N extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return R}async execute(t){var e,r,o,s,n,c;try{const{userId:d}=t,{data:a,error:l}=await this.supabase.auth.admin.getUserById(d);return l?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=a.user)==null?void 0:e.id)||"unknown",email:((r=a.user)==null?void 0:r.email)||"unknown@chaibuilder.com",name:((s=(o=a.user)==null?void 0:o.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((c=(n=a.user)==null?void 0:n.user_metadata)==null?void 0:c.avatar_url)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const M=i.z.object({email:i.z.string().email(),oldPassword:i.z.string().min(1,"Old password is required"),newPassword:i.z.string().min(8,"New password must be at least 8 characters"),confirmPassword:i.z.string().min(1,"Confirm password is required")}).refine(u=>u.newPassword===u.confirmPassword,{message:"Confirm password does not match",path:["confirmPassword"]});class V extends h.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return M}async execute(t){try{const{email:e,oldPassword:r,newPassword:o}=t,{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:r});if(s)throw new h.ActionError("Current password is incorrect","INVALID_PASSWORD",400);const{error:n}=await this.supabase.auth.updateUser({password:o});if(n)throw new h.ActionError(n.message||"Failed to update password","UPDATE_FAILED",400);return{data:{message:"Password changed successfully"},status:200}}catch(e){throw e}}}const W=i.z.object({key:i.z.string()});class x extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return W}async execute(e){try{const{key:r}=e,{error:o}=await this.supabase.storage.from(this.bucketName).remove([r]);return o?{error:`Failed to delete from Supabase Storage: ${o.message}`,status:500}:{data:{success:!0},status:200}}catch(r){return console.error("DELETE_FROM_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const H=i.z.object({file:i.z.string(),fileName:i.z.string(),contentType:i.z.string().optional(),folder:i.z.string().optional(),metadata:i.z.record(i.z.string(),i.z.any()).optional()});class z extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return H}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:r}=this.context,{file:o,fileName:s,contentType:n,folder:c,metadata:d}=e;let a;if(typeof o=="string"){const f=o.split(",")[1]||o;a=Buffer.from(f,"base64")}else a=o;const l=c?`${c}/${s}`:`${r}/${s}`,{data:g,error:p}=await this.supabase.storage.from(this.bucketName).upload(l,a,{contentType:n||"application/octet-stream",upsert:!0,...d&&{metadata:d}});if(p)return{error:`Failed to upload to Supabase Storage: ${p.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(l);return{data:{url:m,key:g.path,size:a.length,metadata:d},status:200}}catch(r){return console.error("UPLOAD_TO_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const K=u=>({GET_CHAI_USER:new N(u),CHANGE_PASSWORD:new V(u)}),Q=u=>({UPLOAD_ASSET:new P(u),GET_ASSET:new B(u),GET_ASSETS:new $(u),DELETE_ASSET:new G(u),UPDATE_ASSET:new j(u),UPLOAD_TO_STORAGE:new z(u),DELETE_FROM_STORAGE:new x(u)});exports.DeleteFromStorageAction=x;exports.SupabaseAuthActions=K;exports.SupabaseStorageActions=Q;exports.UploadToStorageAction=z;
1
+ "use strict";var x=Object.defineProperty;var k=(u,t,e)=>t in u?x(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var E=(u,t,e)=>k(u,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./actions-registery-vPaY-3dZ.cjs"),A=require("lodash-es"),n=require("zod"),p=class p{constructor(t,e,r){this.appId=t,this.userId=e,this.supabase=r}appendUpdatedAtToUrl(t,e){if(A.isEmpty(t))return"";const r=new URL(t),a=new Date(e).getTime();return r.searchParams.set("t",a.toString()),`${r.origin}${r.pathname}${r.search}${r.hash}`}getBufferFromBase64(t){try{const e=t.split(",")[1]||t;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}getMimeType(t){var a;const e=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}[e]||"application/octet-stream"}getImageDimensions(t){if(t.length>=p.MIN_PNG_LENGTH&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(t.length>=p.MIN_GIF_LENGTH&&t[0]===71&&t[1]===73&&t[2]===70)return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80){if(t.length>=p.MIN_WEBP_VP8L_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===76){const e=t.readUInt32LE(21);return{width:(e&16383)+1,height:(e>>14&16383)+1}}if(t.length>=p.MIN_WEBP_VP8X_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===88)return{width:1+(t[24]|t[25]<<8|t[26]<<16),height:1+(t[27]|t[28]<<8|t[29]<<16)};if(t.length>=p.MIN_WEBP_VP8_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===32)return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383}}if(t.length>=2&&t[0]===255&&t[1]===216){let e=2;for(;e<t.length-1;){if(t[e]!==255){e++;continue}const r=t[e+1];if(r>=192&&r<=195||r>=197&&r<=199||r>=201&&r<=203||r>=205&&r<=207){if(e+p.MIN_JPEG_SOF_BYTES_FROM_MARKER<=t.length)return{width:t.readUInt16BE(e+7),height:t.readUInt16BE(e+5)};break}if(e+4>t.length)break;const a=t.readUInt16BE(e+2);e+=2+a}}return{width:0,height:0}}async uploadImageFile(t,e,r,a){try{const s=this.getBufferFromBase64(t),i=this.getMimeType(r);if(!["image/jpeg","image/png","image/webp","image/gif","image/tiff"].includes(i))throw new Error(`Invalid image format: ${i}`);const d=r.split("."),o=d.length>1?d.slice(0,-1).join("."):r,l=d.length>1?d[d.length-1].toLowerCase():"png",w=`${A.kebabCase(o)}.${l}`,h=this.appId,m=e?`${h}/${e}`:h,S=g.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:s.toString("base64"),fileName:w,contentType:i,folder:m});if(U.error)throw new Error(U.error);const{width:T,height:b}=this.getImageDimensions(s);return{url:U.data.url,thumbnailUrl:U.data.url,size:s.length,width:T,height:b,mimeType:i}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(t,e,r){try{const a=this.getBufferFromBase64(t);let s,i;try{const S=a.toString("utf-8"),U=S.match(/\bwidth=["'](\d+)/),T=S.match(/\bheight=["'](\d+)/);U&&(s=parseInt(U[1],10)),T&&(i=parseInt(T[1],10))}catch{}const c=r.split("."),d=c.length>1?c.slice(0,-1).join("."):r,o=`${A.kebabCase(d)}.svg`,l=this.appId,w=e?`${l}/${e}`:l,h=g.getChaiAction("UPLOAD_TO_STORAGE");if(!h)throw new Error("UPLOAD_TO_STORAGE action not found");h.setContext({appId:this.appId,userId:this.userId});const m=await h.execute({file:a.toString("base64"),fileName:o,contentType:"image/svg+xml",folder:w});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:a.length,width:s,height:i,mimeType:"image/svg+xml"}}catch(a){return console.error("SVG upload error:",a),{error:a instanceof Error?a.message:"Unknown error"}}}async upload({file:t,folderId:e,name:r,optimize:a=!0}){var s;try{const c=r.toLowerCase().endsWith(".svg")||t.includes("data:image/svg+xml")?await this.uploadSvgFile(t,e,r):await this.uploadImageFile(t,e,r,a??!0);if("error"in c)return c;const d={name:r,app:this.appId,url:c.url,thumbnailUrl:c.thumbnailUrl,size:(s=c.size)==null?void 0:s.toString(),width:c.width,height:c.height,format:c.mimeType.split("/")[1],folderId:e,type:c.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:o,error:l}=await this.supabase.from("app_assets").insert(d).select("*").single();if(l)throw new Error(`Failed to store asset in database: ${l.message}`);return{id:o.id,name:o.name,type:o.type,url:this.appendUpdatedAtToUrl(o.url,o.updatedAt),size:o.size,thumbnailUrl:this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt),width:o.width,height:o.height,format:o.format,folderId:o.folderId,createdBy:o.createdBy||"",createdAt:o.createdAt,updatedAt:o.updatedAt}}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}async getAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);return A.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),A.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:t="",page:e=1,limit:r=20}={}){try{const a=(e-1)*r;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});t&&(s=s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));const{data:i,error:c,count:d}=await s.range(a,a+r-1);if(c)throw new Error(c.message);return{assets:i.map(l=>(A.set(l,"url",this.appendUpdatedAtToUrl(l.url,l.updatedAt)),A.set(l,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(l.thumbnailUrl||"",l.updatedAt)),l)),total:d||0,page:e,pageSize:r}}catch(a){throw console.error("Error fetching assets:",a),a}}async deleteAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);if(e.url)try{const i=new URL(e.url).pathname.split("/"),c=i.indexOf("dam-assets");if(c!==-1){const d=i.slice(c+1).join("/"),o=g.getChaiAction("DELETE_FROM_STORAGE");if(o&&(o.setContext({appId:this.appId,userId:this.userId}),await o.execute({key:d})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const w=new URL(e.thumbnailUrl).pathname.split("/"),h=w.indexOf("dam-assets");if(h!==-1){const m=w.slice(h+1).join("/");o&&await o.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:a}=await this.supabase.from("app_assets").delete().eq("id",t);if(a)throw new Error(`Failed to delete asset: ${a.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:t,file:e,description:r}){var a,s;try{const{data:i,error:c}=await this.supabase.from("app_assets").select("*").eq("id",t).single();if(c)throw new Error(`Failed to fetch asset: ${c.message}`);const d={};if(r!==void 0&&(d.description=r,d.updatedAt=new Date().toISOString()),e){const h=((a=i.format)==null?void 0:a.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,i.folderId,i.name):await this.uploadImageFile(e,i.folderId,i.name,!0);if("error"in h)return h;d.url=h.url,d.thumbnailUrl=h.thumbnailUrl,d.size=(s=h.size)==null?void 0:s.toString(),d.width=h.width,d.height=h.height,d.format=h.mimeType.split("/")[1],d.updatedAt=new Date().toISOString()}const{data:o,error:l}=await this.supabase.from("app_assets").update(d).eq("id",t).select().single();if(l)throw new Error(`Failed to update asset: ${l.message}`);return A.set(o,"url",this.appendUpdatedAtToUrl(o.url,o.updatedAt)),A.set(o,"thumbnailUrl",this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt)),o}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}};E(p,"MIN_PNG_LENGTH",24),E(p,"MIN_GIF_LENGTH",10),E(p,"MIN_WEBP_VP8L_LENGTH",25),E(p,"MIN_WEBP_VP8X_LENGTH",30),E(p,"MIN_WEBP_VP8_LENGTH",30),E(p,"MIN_JPEG_SOF_BYTES_FROM_MARKER",9);let I=p;const P=n.z.object({name:n.z.string(),file:n.z.string(),folderId:n.z.string().optional().nullable(),optimize:n.z.boolean().optional()});class z extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return P}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).upload(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const f=n.z.object({id:n.z.string()});class O extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return f}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const D=n.z.object({search:n.z.string().optional(),page:n.z.number().optional(),limit:n.z.number().optional()});class L extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return D}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAssets(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=n.z.object({id:n.z.string()});class N extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return G}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).deleteAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const F=n.z.object({id:n.z.string(),file:n.z.string().optional(),description:n.z.string().optional()});class B extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return F}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).updateAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const M=n.z.object({userId:n.z.string()});class C extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return M}async execute(t){var e,r,a,s,i,c;try{const{userId:d}=t,{data:o,error:l}=await this.supabase.auth.admin.getUserById(d);return l?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=o.user)==null?void 0:e.id)||"unknown",email:((r=o.user)==null?void 0:r.email)||"unknown@chaibuilder.com",name:((s=(a=o.user)==null?void 0:a.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((c=(i=o.user)==null?void 0:i.user_metadata)==null?void 0:c.avatar_url)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const v=n.z.object({email:n.z.string().email(),oldPassword:n.z.string().min(1,"Old password is required"),newPassword:n.z.string().min(8,"New password must be at least 8 characters"),confirmPassword:n.z.string().min(1,"Confirm password is required")}).refine(u=>u.newPassword===u.confirmPassword,{message:"Confirm password does not match",path:["confirmPassword"]});class R extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return v}async execute(t){try{const{email:e,oldPassword:r,newPassword:a}=t,{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:r});if(s)throw new g.ActionError("Current password is incorrect","INVALID_PASSWORD",400);const{error:i}=await this.supabase.auth.updateUser({password:a});if(i)throw new g.ActionError(i.message||"Failed to update password","UPDATE_FAILED",400);return{data:{message:"Password changed successfully"},status:200}}catch(e){throw e}}}const $=n.z.object({key:n.z.string()});class y extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return $}async execute(e){try{const{key:r}=e,{error:a}=await this.supabase.storage.from(this.bucketName).remove([r]);return a?{error:`Failed to delete from Supabase Storage: ${a.message}`,status:500}:{data:{success:!0},status:200}}catch(r){return console.error("DELETE_FROM_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const j=n.z.object({file:n.z.string(),fileName:n.z.string(),contentType:n.z.string().optional(),folder:n.z.string().optional(),metadata:n.z.record(n.z.string(),n.z.any()).optional()});class _ extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return j}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:r}=this.context,{file:a,fileName:s,contentType:i,folder:c,metadata:d}=e;let o;if(typeof a=="string"){const S=a.split(",")[1]||a;o=Buffer.from(S,"base64")}else o=a;const l=c?`${c}/${s}`:`${r}/${s}`,{data:w,error:h}=await this.supabase.storage.from(this.bucketName).upload(l,o,{contentType:i||"application/octet-stream",upsert:!0,...d&&{metadata:d}});if(h)return{error:`Failed to upload to Supabase Storage: ${h.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(l);return{data:{url:m,key:w.path,size:o.length,metadata:d},status:200}}catch(r){return console.error("UPLOAD_TO_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const q=u=>({GET_CHAI_USER:new C(u),CHANGE_PASSWORD:new R(u)}),V=u=>({UPLOAD_ASSET:new z(u),GET_ASSET:new O(u),GET_ASSETS:new L(u),DELETE_ASSET:new N(u),UPDATE_ASSET:new B(u),UPLOAD_TO_STORAGE:new _(u),DELETE_FROM_STORAGE:new y(u)});exports.DeleteFromStorageAction=y;exports.SupabaseAuthActions=q;exports.SupabaseStorageActions=V;exports.UploadToStorageAction=_;