@chaibuilder/sdk 4.0.0-beta.2 → 4.0.0-beta.4

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 (186) hide show
  1. package/dist/{2SSKDMRQ-C4VFVd-q.cjs → 2SSKDMRQ-CopJgtZb.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-DSnzF_1o.js → 2SSKDMRQ-Difo_1pg.js} +2 -2
  3. package/dist/{AP7HFJJL-Cxwj01Aq.js → AP7HFJJL-BPuPBqj4.js} +1 -1
  4. package/dist/{AP7HFJJL-B7YYCY9q.cjs → AP7HFJJL-DYxDgaOs.cjs} +1 -1
  5. package/dist/{IconPicker-RqVvq6G2.js → IconPicker-B2-oriq2.js} +8 -7
  6. package/dist/IconPicker-C0oycHbs.cjs +1 -0
  7. package/dist/{WDYDFRGG-b3T2SQbz.cjs → WDYDFRGG-DbejaRPK.cjs} +1 -1
  8. package/dist/{WDYDFRGG-C7aSUcjs.js → WDYDFRGG-KK8pkcW1.js} +2 -2
  9. package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
  10. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/active-in-another-tab-Cu_ASKtx.cjs +1 -0
  14. package/dist/active-in-another-tab-DkR2HWI4.js +35 -0
  15. package/dist/add-new-language-page-BXuwluuU.cjs +1 -0
  16. package/dist/{add-new-language-page-D7NDABl1.js → add-new-language-page-CBY0RR6q.js} +54 -53
  17. package/dist/{add-new-page-BNfwKjRd.cjs → add-new-page-C_PzKby8.cjs} +1 -1
  18. package/dist/{add-new-page-B4hc0B-g.js → add-new-page-DJLJFLAd.js} +2 -2
  19. package/dist/{ai-panel-content-BnbURb7j.js → ai-panel-content--YM01Aly.js} +12 -11
  20. package/dist/ai-panel-content-rRmJdH7L.cjs +1 -0
  21. package/dist/{ai-panel-default-lang-oVk4TDeb.js → ai-panel-default-lang-BZl0tPYo.js} +40 -40
  22. package/dist/{ai-panel-default-lang-3tCHzab5.cjs → ai-panel-default-lang-D2zhXvKP.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-DmQ3QMDD.js → ai-panel-other-lang-Bfjk2CYZ.js} +8 -8
  24. package/dist/{ai-panel-other-lang-BBHCCSen.cjs → ai-panel-other-lang-Y4bEKHoG.cjs} +1 -1
  25. package/dist/{ai-prompt-input-DaTyfib-.js → ai-prompt-input-DueQYNf-.js} +68 -67
  26. package/dist/ai-prompt-input-N9PcYCFa.cjs +1 -0
  27. package/dist/{ai-translation-prompt-DJPe2O-n.js → ai-translation-prompt-B36F3d7K.js} +2 -2
  28. package/dist/ai-translation-prompt-IAdWMNZb.cjs +1 -0
  29. package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
  30. package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
  31. package/dist/{code-display-BzBq5xSn.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/{code-editor-DWWnphW9.js → code-editor-Bb7JumZy.js} +11 -10
  34. package/dist/code-editor-DQB8lAOk.cjs +1 -0
  35. package/dist/{continue-editing-in-this-client-BllU94XG.js → continue-editing-in-this-client-Dm9cCj7K.js} +10 -9
  36. package/dist/continue-editing-in-this-client-DmGFLHXw.cjs +1 -0
  37. package/dist/core-Dr7QYemB.js +56 -0
  38. package/dist/core-Y0lXLwkq.cjs +1 -0
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +3 -3
  41. package/dist/core.js +41 -39
  42. package/dist/{css-import-modal-D72a-16X.js → css-import-modal-9P_0uNa4.js} +4 -3
  43. package/dist/css-import-modal-Rh1QAVxo.cjs +13 -0
  44. package/dist/{delete-design-token-D_TLlO3I.cjs → delete-design-token-BG8yHcS5.cjs} +1 -1
  45. package/dist/{delete-design-token-Cd1ZDtqT.js → delete-design-token-COvR4G1S.js} +1 -1
  46. package/dist/{delete-page-DC8pzvWW.js → delete-page-CNucxe4P.js} +11 -10
  47. package/dist/delete-page-DAvEjHwF.cjs +1 -0
  48. package/dist/design-token-usage-CXglXgcJ.cjs +1 -0
  49. package/dist/{design-token-usage-DE4XCDdn.js → design-token-usage-MNYsFlPG.js} +14 -13
  50. package/dist/digital-asset-manager-CB5MRBcW.cjs +1 -0
  51. package/dist/{digital-asset-manager-C_gL_0YY.js → digital-asset-manager-CqCWBO0s.js} +6 -5
  52. package/dist/{duplicate-page-BoVhko2q.js → duplicate-page-BknLfqr0.js} +19 -18
  53. package/dist/duplicate-page-DzZByALW.cjs +1 -0
  54. package/dist/{dynamic-page-selector-CSndg2-y.js → dynamic-page-selector-DoW7OyUB.js} +15 -14
  55. package/dist/dynamic-page-selector-WA007Sni.cjs +1 -0
  56. package/dist/get-chai-builder-tailwind-config-BFePCEIS.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-BXf_xLHk.js} +5 -5
  58. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
  59. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
  60. package/dist/{image-editor-oypq8asR.js → image-editor-CQnNtak2.js} +1 -1
  61. package/dist/{image-editor-DTspjj_c.cjs → image-editor-CqwaVxO2.cjs} +1 -1
  62. package/dist/index-C0-pgg_p.cjs +5 -0
  63. package/dist/index-C99FhuF1.cjs +160 -0
  64. package/dist/{index-BDnwJqMw.js → index-Dno42B0a.js} +716 -714
  65. package/dist/{index-S8ibZk9Q.js → index-rAcNbjk_.js} +3744 -3920
  66. package/dist/{json-diff-viewer-XX1pgabt.cjs → json-diff-viewer-CLuUHiPU.cjs} +3 -3
  67. package/dist/{json-diff-viewer-B5dr-Y_L.js → json-diff-viewer-CMvGUvJ2.js} +5 -4
  68. package/dist/{lang-panel-Cn83SRzd.js → lang-panel-CnwTb05j.js} +15 -14
  69. package/dist/lang-panel-fDCYm5Jm.cjs +1 -0
  70. package/dist/{manage-design-tokens-lP4HLS0P.js → manage-design-tokens-BsSZE9Vs.js} +12 -11
  71. package/dist/manage-design-tokens-BvH5KTJX.cjs +1 -0
  72. package/dist/mark-as-template-CpWEBJGd.cjs +1 -0
  73. package/dist/{mark-as-template-jncsjfHm.js → mark-as-template-DBLshWb5.js} +17 -16
  74. package/dist/{nested-path-selector-content-B-8LqhXI.js → nested-path-selector-content-6OBJ8LG8.js} +24 -23
  75. package/dist/nested-path-selector-content-C2sD9dkq.cjs +1 -0
  76. package/dist/no-language-page-content-BvPDdccK.cjs +1 -0
  77. package/dist/{no-language-page-content-D_zd9Rb0.js → no-language-page-content-CzENgtnu.js} +10 -9
  78. package/dist/{no-language-page-dialog-C5Ps6YYL.js → no-language-page-dialog-CbYI2cVg.js} +2 -2
  79. package/dist/{no-language-page-dialog-fXmbQO7L.cjs → no-language-page-dialog-CgW4yJBC.cjs} +1 -1
  80. package/dist/{page-creator-wCMtlE6Z.js → page-creator-Cc83uQqw.js} +113 -112
  81. package/dist/page-creator-g8GqgcKH.cjs +1 -0
  82. package/dist/{page-lock-BPCxfv9J.js → page-lock-BJUkyxdh.js} +2 -2
  83. package/dist/{page-lock-DweiYy1w.cjs → page-lock-CT7SmQqp.cjs} +1 -1
  84. package/dist/page-locked-dialog-Co5b9XIZ.cjs +1 -0
  85. package/dist/{page-locked-dialog-ByGl18_m.js → page-locked-dialog-DsEbWRed.js} +18 -15
  86. package/dist/{page-manager-new-BWFE-S-O.js → page-manager-new-5rFP5DyQ.js} +30 -29
  87. package/dist/page-manager-new-BOkJImo2.cjs +1 -0
  88. package/dist/page-manager-search-and-filter-Bfm0j1gg.cjs +1 -0
  89. package/dist/{page-manager-search-and-filter-kNJFWJ86.js → page-manager-search-and-filter-zq-LfhQ1.js} +13 -12
  90. package/dist/{page-revisions-content-Ulr8slUN.js → page-revisions-content-D38G2tJM.js} +34 -31
  91. package/dist/page-revisions-content-ag-MHBGr.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +22 -23
  94. package/dist/pages.js +12 -12
  95. package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
  96. package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
  97. package/dist/publish-pages-content-BiX-GMLw.cjs +1 -0
  98. package/dist/{publish-pages-content-BTPzt_m4.js → publish-pages-content-CS7f41Ac.js} +66 -65
  99. package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
  100. package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
  101. package/dist/render.cjs +2 -2
  102. package/dist/render.d.ts +2 -2
  103. package/dist/render.js +87 -80
  104. package/dist/rte-widget-modal-BKNx2wln.cjs +1 -0
  105. package/dist/{rte-widget-modal-Rk_NW3KU.js → rte-widget-modal-D6Zik0Ta.js} +15 -14
  106. package/dist/runtime.cjs +1 -1
  107. package/dist/runtime.d.ts +168 -4
  108. package/dist/runtime.js +68 -38
  109. package/dist/{save-to-lib-BK3uTFss.js → save-to-lib-WwOzbgiF.js} +39 -38
  110. package/dist/save-to-lib-ffjCZYJ5.cjs +1 -0
  111. package/dist/sdk.css +1 -1
  112. package/dist/{selected-block-display-CU3TwIMA.js → selected-block-display-B1SG_UXw.js} +37 -36
  113. package/dist/selected-block-display-BOgnQRLF.cjs +16 -0
  114. package/dist/{seo-panel-jbzxFioc.js → seo-panel-BkOgRoWd.js} +12 -11
  115. package/dist/seo-panel-FjS1UF_y.cjs +2 -0
  116. package/dist/{shared-json-ld-BL_dv3_q.js → shared-json-ld-uka9TOgA.js} +68 -67
  117. package/dist/shared-json-ld-yJkXjENy.cjs +1 -0
  118. package/dist/slug-input-Cyd6NR6J.cjs +1 -0
  119. package/dist/{slug-input-1qwKkXhA.js → slug-input-DHLmUNrH.js} +9 -8
  120. package/dist/supabase-actions.cjs +1 -1
  121. package/dist/supabase-actions.d.ts +1 -1
  122. package/dist/supabase-actions.js +1 -1
  123. package/dist/{take-over-request-DKvKi3mM.js → take-over-request-Ca0X-qyf.js} +17 -16
  124. package/dist/take-over-request-CmpJVe9T.cjs +1 -0
  125. package/dist/{theme-panel-footer-DbMDLYGI.js → theme-panel-footer-BUXIu252.js} +11 -10
  126. package/dist/theme-panel-footer-CKO9YYwZ.cjs +1 -0
  127. package/dist/{translation-warning-modal-9wTwIy_9.js → translation-warning-modal-DrpFeI83.js} +9 -8
  128. package/dist/translation-warning-modal-pSZVKcNW.cjs +1 -0
  129. package/dist/{unmark-as-template-Dulvf7Zw.js → unmark-as-template-BMqgelv-.js} +11 -10
  130. package/dist/unmark-as-template-DF1Ms4VN.cjs +1 -0
  131. package/dist/unpublish-page-BJ0Bsvt2.js +28 -0
  132. package/dist/unpublish-page-Bsq2yEqQ.cjs +1 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +4 -1
  135. package/dist/utils.js +2 -2
  136. package/dist/web-blocks.cjs +1 -1
  137. package/dist/web-blocks.js +5 -5
  138. package/dist/{web-preview-DXE4Jnf5.js → web-preview-D6h1L2nV.js} +2 -2
  139. package/dist/web-preview-kres0aG7.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-C9-ieDWm.cjs +0 -1
  142. package/dist/active-in-another-tab-Clng6zpY.cjs +0 -1
  143. package/dist/active-in-another-tab-wb8qolB8.js +0 -34
  144. package/dist/add-new-language-page-C4BuMTaN.cjs +0 -1
  145. package/dist/ai-panel-content-DPy2jgKw.cjs +0 -1
  146. package/dist/ai-prompt-input-b5ty81RB.cjs +0 -1
  147. package/dist/ai-translation-prompt-c0Q3zkT2.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-Q3_sK_Ta.cjs +0 -1
  150. package/dist/code-editor-BQZi6-FB.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +0 -1
  152. package/dist/core-BoRDjj4h.cjs +0 -1
  153. package/dist/core-yvI6kCyw.js +0 -56
  154. package/dist/css-import-modal-BSMGKA2T.cjs +0 -13
  155. package/dist/delete-page-ByQwBupJ.cjs +0 -1
  156. package/dist/design-token-usage-BqZeR1sT.cjs +0 -1
  157. package/dist/digital-asset-manager-BYLKFEYi.cjs +0 -1
  158. package/dist/duplicate-page-vdvwLQLo.cjs +0 -1
  159. package/dist/dynamic-page-selector-DdnbCuQZ.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-CbwxUFy_.cjs +0 -5
  162. package/dist/index-CnSjWE1P.cjs +0 -160
  163. package/dist/lang-panel-BPxex-M2.cjs +0 -1
  164. package/dist/manage-design-tokens-ConiyuPr.cjs +0 -1
  165. package/dist/mark-as-template-DYRxre1f.cjs +0 -1
  166. package/dist/nested-path-selector-content-BYtLi7mC.cjs +0 -1
  167. package/dist/no-language-page-content-DAbLq0gX.cjs +0 -1
  168. package/dist/page-creator-VWIB2VAs.cjs +0 -1
  169. package/dist/page-locked-dialog-BlbgvaG2.cjs +0 -1
  170. package/dist/page-manager-new-D0lGfNnS.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DpGMoOII.cjs +0 -1
  172. package/dist/page-revisions-content-DYxXZqmh.cjs +0 -1
  173. package/dist/publish-pages-content-D6g8GAsd.cjs +0 -1
  174. package/dist/rte-widget-modal-DrMzWWjw.cjs +0 -1
  175. package/dist/save-to-lib-DHHUO12i.cjs +0 -1
  176. package/dist/selected-block-display-DSFhddPj.cjs +0 -16
  177. package/dist/seo-panel-Dl0IDV09.cjs +0 -2
  178. package/dist/shared-json-ld-DPNkqDC1.cjs +0 -1
  179. package/dist/slug-input-YVLjtTI3.cjs +0 -1
  180. package/dist/take-over-request-DvMIg_cZ.cjs +0 -1
  181. package/dist/theme-panel-footer-BMOaPLWc.cjs +0 -1
  182. package/dist/translation-warning-modal-DjTwz75c.cjs +0 -1
  183. package/dist/unmark-as-template-CdqIJJER.cjs +0 -1
  184. package/dist/unpublish-page-BwSVBf0_.cjs +0 -1
  185. package/dist/unpublish-page-Degu5Cy9.js +0 -27
  186. package/dist/web-preview-YzKxyXft.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CnSjWE1P.cjs"),s=require("./index-CbwxUFy_.cjs"),a=require("lucide-react"),c=require("react-i18next"),l=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:n}=c.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(a.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:n("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:n("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(t.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(a.Edit,{className:"h-4 w-4"}),n("Continue Editing Here")]})})]})})};exports.default=l;
@@ -1,34 +0,0 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { W as r, X as i, Y as o, Z as l, _ as c, B as d } from "./index-S8ibZk9Q.js";
3
- import { ao as m, a as h, B as u, E as N, P as p } from "./index-BDnwJqMw.js";
4
- import { TableIcon as T, Edit as f } from "lucide-react";
5
- import { useTranslation as E } from "react-i18next";
6
- const S = () => {
7
- const s = m(), { setPageStatus: n } = h(), { t: a } = E();
8
- return /* @__PURE__ */ e(u, { children: /* @__PURE__ */ t(r, { className: "mx-auto w-full max-w-md", children: [
9
- /* @__PURE__ */ e(i, { className: "space-y-1", children: /* @__PURE__ */ t(o, { className: "flex items-center gap-2 text-xl font-medium", children: [
10
- /* @__PURE__ */ e(T, { className: "h-6 w-6 text-green-500" }),
11
- /* @__PURE__ */ e("span", { children: a("Active in Another Tab") })
12
- ] }) }),
13
- /* @__PURE__ */ e(l, { className: "space-y-4", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a(
14
- "This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab."
15
- ) }) }),
16
- /* @__PURE__ */ e(c, { className: "flex justify-end gap-2", children: /* @__PURE__ */ t(
17
- d,
18
- {
19
- variant: "default",
20
- onClick: () => {
21
- s(N.CONTINUE_EDITING_IN_THIS_TAB_REQUEST), n(p.CHECKING);
22
- },
23
- className: "gap-2",
24
- children: [
25
- /* @__PURE__ */ e(f, { className: "h-4 w-4" }),
26
- a("Continue Editing Here")
27
- ]
28
- }
29
- ) })
30
- ] }) });
31
- };
32
- export {
33
- S as default
34
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("./index-CnSjWE1P.cjs"),V=require("./slug-input-YVLjtTI3.cjs"),g=require("./index-CbwxUFy_.cjs"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),T=require("react-i18next"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=T.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(f.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${g.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?g.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:g.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=T.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(f.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(f.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:S})=>{const{t:r}=T.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(f.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(f.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(f.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:S()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:S})=>{const{t:r}=T.useTranslation(),A=S||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(f.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(f.Button,{type:"submit",disabled:A&&!o.dynamic,children:S?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(f.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:g.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:S,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:S,useLanguagePrefix:r,isSlugValid:v,isPending:p})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:S,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:p,setSlug:C,isSlugValid:U,setIsSlugValid:k,getSlug:I,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:S,slug:p,isSlugValid:U,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:S,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:U,setIsSlugValid:k,getSlug:I})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:S,isSlugValid:U,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[S,r]=N.useState(""),[A,v]=N.useState(!0),[p,C]=N.useState(!0),{mutate:U,isPending:k}=g.useCreatePage(),{mutate:I,isPending:$}=g.useUpdatePage(),D=k||$,{data:L,isFetching:H}=g.useWebsiteSetting(),j=g.useFallbackLang(),{data:w,isFetching:b}=g.useLanguagePages(u),{data:F=[],isFetching:y}=g.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=g.usePageTypes(),{setSelectedLang:O}=f.useLanguages(),{t:M}=T.useTranslation(),[,ss]=g.useSearchParams(),[,es]=f.useSidebarActivePanel(),ns=H||b||y||P,G=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(w,{lang:n})),[L,w]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const E=n.slug||"",{initSlug:R,prefix:as}=V.parseSlugForEdit(E,s);r(R),C(as)},[t,c,w,s,i]),N.useEffect(()=>{if(i)m(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${g.LANGUAGES[n]}`)}},[i,G,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:p?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(E=>E.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,p,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${p?[d,S].filter(Boolean).join("/"):S}`:n=`${V.removeSlugExtension(K)}/${S}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const E=new URLSearchParams(window.location.search);j&&n===j?E.delete("lang"):E.set("lang",n),ss(E),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?I(E,{onSuccess:R}):U(E,{onSuccess:R})};return e.jsx(f.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(f.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:M(t?"Edit language":"Add new language page")}),e.jsx(f.DialogDescription,{className:"font-light",children:M("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:G,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:S,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-CnSjWE1P.cjs"),m=require("./index-CbwxUFy_.cjs"),N=require("lucide-react"),s=require("react"),M=require("react-i18next"),k=require("sonner"),A=require("./models-5gOsRC56.cjs"),R=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-3tCHzab5.cjs"))),z=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-BBHCCSen.cjs"))),B=()=>{const{t:r}=M.useTranslation(),[S,a]=s.useState(""),[t,l]=s.useState([]),[c,i]=s.useState(!1),[u,d]=s.useState(null),[p,f]=s.useState(null),[b,P]=s.useState(A.getDefaultModel().id),{selectedLang:h,fallbackLang:q}=j.useLanguages(),v=m.useBuilderFetch(),[w]=m.useSearchParams(),y=w.get("page"),C=(t==null?void 0:t.filter(n=>n.role==="user").length)>=4,L=(t==null?void 0:t.filter(n=>n.role==="user").length)>=10;s.useEffect(()=>{l([])},[h,y]);const g=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:r,fetch:v,input:S,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(n=>{const o=n[n.length-1];return o&&o.role==="assistant"&&o.isReasoning&&o.isStreaming?n.slice(0,-1):n}),k.toast.info(r("Generation stopped"))},handleReset:g,setMessages:l,setIsLoading:i,currentBlock:p,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:L,suggestNewConversation:C,selectedModel:b,onModelChange:P};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(j.Button,{variant:"outline",size:"icon",onClick:g,className:"h-6 w-6",disabled:c,children:e.jsx(N.Plus,{})})]}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:h?e.jsx(z,{...x,selectedLang:h}):e.jsx(R,{...x})})]})]})};exports.default=B;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./index-CnSjWE1P.cjs"),y=require("lucide-react"),ee=require("nanoid"),l=require("react"),_=require("class-variance-authority"),te=require("react-i18next"),L=require("./models-5gOsRC56.cjs");function se({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:o.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const ne=_.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function W({className:t,align:s="inline-start",...i}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:o.cn(ne({align:s}),t),onClick:u=>{var c,f;u.target.closest("button")||(f=(c=u.currentTarget.parentElement)==null?void 0:c.querySelector("input"))==null||f.focus()},...i})}const re=_.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function H({className:t,type:s="button",variant:i="ghost",size:u="xs",...c}){return e.jsx(o.Button,{type:s,"data-size":u,variant:i,className:o.cn(re({size:u}),t),...c})}function ae({className:t,...s}){return e.jsx(o.Textarea,{"data-slot":"input-group-control",className:o.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const oe=l.createContext(null),ie=l.createContext(null),K=()=>l.useContext(oe),ce=()=>l.useContext(ie),X=l.createContext(null),O=()=>{const t=ce(),s=l.useContext(X),i=t??s;if(!i)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return i};function le({data:t,className:s,...i}){var x;const u=O(),c=t.filename||"",p=((x=t.mediaType)!=null&&x.startsWith("image/")&&t.url?"image":"file")==="image",v=c||(p?"Image":"Attachment");return e.jsxs(Ne,{children:[e.jsx(o.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:o.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...i,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:p?e.jsx("img",{alt:c||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(y.PaperclipIcon,{className:"size-3"})})}),e.jsxs(o.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:I=>{I.stopPropagation(),u.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(y.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:v})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[p&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:c||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:c||(p?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function ue({children:t,className:s,...i}){const u=O();return u.files.length?e.jsx("div",{className:o.cn("flex flex-wrap items-center gap-2 p-3",s),...i,children:u.files.map(c=>e.jsx(l.Fragment,{children:t(c)},c.id))}):null}const de=({label:t="Add photos or files",...s})=>{const i=O();return e.jsxs(o.DropdownMenuItem,{...s,onSelect:u=>{u.preventDefault(),i.openFileDialog()},children:[e.jsx(y.ImageIcon,{className:"mr-2 size-4"})," ",t]})},pe=({className:t,accept:s,multiple:i,globalDrop:u,syncHiddenInput:c,maxFiles:f,maxFileSize:p,onError:v,onSubmit:x,children:I,...D})=>{const n=K(),a=!!n,m=l.useRef(null),k=l.useRef(null),N=l.useRef(null);l.useEffect(()=>{var j;const r=(j=k.current)==null?void 0:j.closest("form");r instanceof HTMLFormElement&&(N.current=r)},[]);const[S,z]=l.useState([]),g=a?n.attachments.files:S,T=l.useCallback(()=>{var r;(r=m.current)==null||r.click()},[]),R=l.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),M=l.useCallback(r=>{const j=Array.from(r),h=j.filter(w=>R(w));if(j.length&&h.length===0){v==null||v({code:"accept",message:"No files match the accepted types."});return}const d=w=>p?w.size<=p:!0,b=h.filter(d);if(h.length>0&&b.length===0){v==null||v({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof f=="number"?Math.max(0,f-w.length):void 0,Z=typeof C=="number"?b.slice(0,C):b;typeof C=="number"&&b.length>C&&(v==null||v({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const q of Z)B.push({id:ee.nanoid(),type:"file",url:URL.createObjectURL(q),mediaType:q.type,filename:q.name});return w.concat(B)})},[R,f,p,v]),P=a?r=>n.attachments.add(r):M,A=a?r=>n.attachments.remove(r):r=>z(j=>{const h=j.find(d=>d.id===r);return h!=null&&h.url&&URL.revokeObjectURL(h.url),j.filter(d=>d.id!==r)}),U=a?()=>n.attachments.clear():()=>z(r=>{for(const j of r)j.url&&URL.revokeObjectURL(j.url);return[]}),F=a?()=>n.attachments.openFileDialog():T;l.useEffect(()=>{a&&n.__registerFileInput(m,()=>{var r;return(r=m.current)==null?void 0:r.click()})},[a,n]),l.useEffect(()=>{c&&m.current&&g.length===0&&(m.current.value="")},[g,c]),l.useEffect(()=>{const r=N.current;if(!r)return;const j=d=>{var b,w;(w=(b=d.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&d.preventDefault()},h=d=>{var b,w,C;(w=(b=d.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&d.preventDefault(),(C=d.dataTransfer)!=null&&C.files&&d.dataTransfer.files.length>0&&P(d.dataTransfer.files)};return r.addEventListener("dragover",j),r.addEventListener("drop",h),()=>{r.removeEventListener("dragover",j),r.removeEventListener("drop",h)}},[P]),l.useEffect(()=>{if(!u)return;const r=h=>{var d,b;(b=(d=h.dataTransfer)==null?void 0:d.types)!=null&&b.includes("Files")&&h.preventDefault()},j=h=>{var d,b,w;(b=(d=h.dataTransfer)==null?void 0:d.types)!=null&&b.includes("Files")&&h.preventDefault(),(w=h.dataTransfer)!=null&&w.files&&h.dataTransfer.files.length>0&&P(h.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",j),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",j)}},[P,u]),l.useEffect(()=>()=>{if(!a)for(const r of g)r.url&&URL.revokeObjectURL(r.url)},[a,g]);const $=r=>{r.currentTarget.files&&P(r.currentTarget.files)},Y=async r=>{const h=await(await fetch(r)).blob();return new Promise((d,b)=>{const w=new FileReader;w.onloadend=()=>d(w.result),w.onerror=b,w.readAsDataURL(h)})},J=l.useMemo(()=>({files:g.map(r=>({...r,id:r.id})),add:P,remove:A,clear:U,openFileDialog:F,fileInputRef:m}),[g,P,A,U,F]),Q=r=>{r.preventDefault();const j=r.currentTarget,h=a?n.textInput.value:new FormData(j).get("message")||"";a||j.reset(),Promise.all(g.map(async({...d})=>d.url&&d.url.startsWith("blob:")?{...d,url:await Y(d.url)}:d)).then(d=>{try{const b=x({text:h,files:d},r);b instanceof Promise?b.then(()=>{U(),a&&n.textInput.clear()}).catch(()=>{}):(U(),a&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:k}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:i,onChange:$,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:o.cn("w-full",t),onSubmit:Q,...D,children:e.jsx(se,{className:"overflow-hidden",children:I})})]});return a?G:e.jsx(X.Provider,{value:J,children:G})},me=({onChange:t,className:s,placeholder:i="What would you like to know?",...u})=>{const c=K(),f=O(),[p,v]=l.useState(!1),x=n=>{if(n.key==="Enter"){if(p||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const a=n.currentTarget.form,m=a==null?void 0:a.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;a==null||a.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&f.files.length>0){n.preventDefault();const a=f.files.at(-1);a&&f.remove(a.id)}},I=n=>{var k;const a=(k=n.clipboardData)==null?void 0:k.items;if(!a)return;const m=[];for(const N of a)if(N.kind==="file"){const S=N.getAsFile();S&&m.push(S)}m.length>0&&(n.preventDefault(),f.add(m))},D=c?{value:c.textInput.value,onChange:n=>{c.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(ae,{className:o.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>v(!1),onCompositionStart:()=>v(!0),onKeyDown:x,onPaste:I,placeholder:i,...u,...D})},fe=({className:t,...s})=>e.jsx(W,{align:"block-end",className:o.cn("order-first flex-wrap gap-1",t),...s}),he=({className:t,...s})=>e.jsx(W,{align:"block-end",className:o.cn("justify-between gap-1",t),...s}),xe=({className:t,...s})=>e.jsx("div",{className:o.cn("flex items-center gap-1",t),...s}),E=({variant:t="ghost",className:s,size:i,...u})=>{const c=i??(l.Children.count(u.children)>1?"sm":"icon-sm");return e.jsx(H,{className:o.cn(s),size:c,type:"button",variant:t,...u})},ge=t=>e.jsx(o.DropdownMenu,{...t}),ve=({className:t,children:s,...i})=>e.jsx(o.DropdownMenuTrigger,{asChild:!0,children:e.jsx(E,{className:t,...i,children:s??e.jsx(y.PlusIcon,{className:"size-4"})})}),je=({className:t,...s})=>e.jsx(o.DropdownMenuContent,{align:"start",className:o.cn(t),...s}),be=({className:t,variant:s="default",size:i="icon-sm",status:u,children:c,...f})=>{let p=e.jsx(y.CornerDownLeftIcon,{className:"size-4"});return u==="submitted"?p=e.jsx(y.Loader2Icon,{className:"size-4 animate-spin"}):u==="streaming"?p=e.jsx(y.SquareIcon,{className:"size-4"}):u==="error"&&(p=e.jsx(y.XIcon,{className:"size-4"})),e.jsx(H,{"aria-label":"Submit",className:o.cn(t),size:i,type:"submit",variant:s,...f,children:c??p})},we=({className:t,textareaRef:s,onTranscriptionChange:i,...u})=>{const[c,f]=l.useState(!1),[p,v]=l.useState(null),x=l.useRef(null);l.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const D=window.SpeechRecognition||window.webkitSpeechRecognition,n=new D;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{f(!0)},n.onend=()=>{f(!1)},n.onresult=a=>{var k;let m="";for(let N=a.resultIndex;N<a.results.length;N++){const S=a.results[N];S.isFinal&&(m+=((k=S[0])==null?void 0:k.transcript)??"")}if(m&&(s!=null&&s.current)){const N=s.current,S=N.value,z=S+(S?" ":"")+m;N.value=z,N.dispatchEvent(new Event("input",{bubbles:!0})),i==null||i(z)}},n.onerror=a=>{console.error("Speech recognition error:",a.error),f(!1)},x.current=n,v(n)}return()=>{x.current&&x.current.stop()}},[s,i]);const I=l.useCallback(()=>{p&&(c?p.stop():p.start())},[p,c]);return e.jsx(E,{className:o.cn("relative transition-all duration-200",c&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!p,onClick:I,...u,children:e.jsx(y.MicIcon,{className:"size-4"})})},Ne=({openDelay:t=0,closeDelay:s=0,...i})=>e.jsx(o.HoverCard,{closeDelay:s,openDelay:t,...i}),Ie=({align:t="start",...s})=>e.jsx(o.HoverCardContent,{align:t,...s}),ye=t=>e.jsx(o.Dialog,{...t}),Se=t=>e.jsx(o.DialogTrigger,{...t}),ke=({className:t,children:s,title:i="Model Selector",...u})=>e.jsxs(o.DialogContent,{className:o.cn("p-0",t),...u,children:[e.jsx(o.DialogTitle,{className:"sr-only",children:i}),e.jsx(o.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),De=({className:t,...s})=>e.jsx(o.CommandInput,{className:o.cn("h-auto py-3.5",t),...s}),Pe=t=>e.jsx(o.CommandList,{...t}),ze=t=>e.jsx(o.CommandGroup,{...t}),Te=t=>e.jsx(o.CommandItem,{...t}),Ce=({provider:t,className:s,...i})=>e.jsx("img",{...i,alt:`${t} logo`,className:o.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ae=({className:t,...s})=>e.jsx("span",{className:o.cn("flex-1 truncate text-left",t),...s}),Le=({selectedModel:t,onModelChange:s,disabled:i=!1})=>{const[u,c]=l.useState(!1),[f,p]=l.useState(""),v=L.getModelById(t)||L.getDefaultModel(),I=L.AI_MODELS.filter(n=>n.name.toLowerCase().includes(f.toLowerCase())||n.provider.toLowerCase().includes(f.toLowerCase())).reduce((n,a)=>(n[a.provider]||(n[a.provider]=[]),n[a.provider].push(a),n),{}),D=n=>{s(n),c(!1),p("")};return e.jsxs(ye,{open:u,onOpenChange:c,children:[e.jsx(Se,{asChild:!0,children:e.jsxs(o.Button,{variant:"outline",size:"sm",disabled:i,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(y.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:v.name})]})}),e.jsxs(ke,{className:"w-96 p-0",children:[e.jsx(De,{placeholder:"Search models...",value:f,onValueChange:p}),e.jsx(Pe,{children:Object.entries(I).map(([n,a])=>e.jsx(ze,{heading:n.charAt(0).toUpperCase()+n.slice(1),children:a.map(m=>e.jsxs(Te,{value:m.id,onSelect:()=>D(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ce,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ae,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},n))})]})]})},V="chai-ai-selected-model",Re=({input:t,setInput:s,onSend:i,onStop:u,isLoading:c,disabled:f,selectedLang:p,selectedModel:v=L.getDefaultModel().id,onModelChange:x})=>{const{t:I}=te.useTranslation(),[D,n]=l.useState(v),[a,m]=l.useState(null),k=l.useRef(null),[N,S]=l.useState(!1);l.useEffect(()=>{if(!p){const g=localStorage.getItem(V);if(g)n(g),x==null||x(g);else{const T=L.getDefaultModel().id;n(T),x==null||x(T)}}},[p,x]);const z=g=>{var M;const T=g.files.find(P=>{var A;return(A=P.mediaType)==null?void 0:A.startsWith("image/")}),R=(T==null?void 0:T.url)||a;i((M=g.text)==null?void 0:M.trim(),void 0,R,D),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(pe,{onSubmit:z,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(fe,{className:"p-0",children:e.jsx(ue,{className:"pb-0",children:g=>e.jsx(le,{className:"text-xs",data:g})})}),e.jsx(me,{ref:k,value:t,onChange:g=>s(g.target.value),placeholder:I(p?"Ask to update content":"Ask me anything..."),disabled:c,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(he,{children:[p?e.jsx("div",{}):e.jsxs(xe,{children:[e.jsxs(ge,{children:[e.jsx(ve,{disabled:c,children:e.jsx(y.Paperclip,{size:16})}),e.jsx(je,{children:e.jsx(de,{})})]}),e.jsx(we,{textareaRef:k,onTranscriptionChange:s,disabled:c}),e.jsx(Le,{selectedModel:D,onModelChange:g=>{n(g),x==null||x(g),localStorage.setItem(V,g)},disabled:c}),e.jsxs(E,{className:"hidden",size:"sm",onClick:()=>S(!N),variant:N?"default":"ghost",children:[e.jsx(y.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),c?e.jsxs("button",{onClick:u,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:I("Stop generation"),children:[e.jsx(y.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:I("Stop")})]}):e.jsx(be,{disabled:!t.trim()||f,children:e.jsx(y.Send,{size:16})})]})]})})})};exports.default=Re;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-CnSjWE1P.cjs"),r=require("./index-CbwxUFy_.cjs"),i=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:l,onClick:a})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:l?e.jsx(c.Button,{variant:"outline",className:"h-auto",onClick:()=>a("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",r.LANGUAGES[s]," ",e.jsx(i.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
@@ -1 +0,0 @@
1
- "use strict";const T=require("./common-functions-B3a4xKt_.cjs"),t=require("lodash-es"),f=require("himalaya"),V=require("./core-BoRDjj4h.cjs"),U=require("tailwind-merge"),m="#styles:",Y="__ADD_BLOCK_INTERNAL_ROOT",K="@",H="#",v="dt#",M=e=>{if(e=e.replace(m,""),!e)return{baseClasses:"",classes:""};const l=e.split(/,(?![^\[]*\])/);if(l.length===1)return{baseClasses:"",classes:l[0].trim()};const[n,...s]=l;return{baseClasses:n.trim(),classes:s.join(",").trim().replace(/ +(?= )/g,"")}};function X(e,l,n){const s=t.get(n,"i18nProps",[]);if(t.isEmpty(l)||t.isEmpty(s))return e;const a=t.cloneDeep(e);return t.forEach(t.keys(a),o=>{if(t.includes(s,o)&&!t.isEmpty(l)){const r=t.get(a,o),i=t.get(a,`${o}-${l}`,"");t.isString(r)?a[o]=t.isString(i)&&!t.isEmpty(i.trim())&&i.trimStart()||r:a[o]=t.isEmpty(i)?r:i}}),a}const O=(e,l)=>{const{baseClasses:n,classes:s}=M(e),o=s.split(" ").filter(i=>i.startsWith(v)).map(i=>{var d;return(d=l[i])==null?void 0:d.value}),r=s.split(" ").filter(i=>!i.startsWith(v)).join(" ");return U.twMerge.apply(null,[n,...o,r])};function G(e,l){return t.get(e,`${l}_attrs`,{})}function Z(e,l=!0,n={}){const s={};return Object.keys(e).forEach(a=>{if(t.isString(e[a])&&e[a].startsWith(m)){const o=O(e[a],n),r=G(e,a);s[a]={...!t.isEmpty(o)&&{className:o},...r,...l?{"data-style-prop":a,"data-block-parent":e._id,"data-style-id":`${a}-${e._id}`}:{}}}}),s}const Q=t.memoize(e=>{const l=V.getRegisteredChaiBlock(e),n=t.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(n).filter(([,s])=>t.get(s,"runtime",!1)))}),tt=(e,l)=>{if(!t.isArray(e))return e;let n=e,s;return typeof l.limit=="number"&&l.limit>0&&(s=l.limit),s!==void 0&&(n=n.slice(0,s)),n},et=(e,l)=>{const n=t.cloneDeep(e);return t.forEach(t.keys(n),s=>{if(t.isString(n[s])&&!t.startsWith(s,"_")){let a=n[s];s==="repeaterItems"&&(n.repeaterItemsBinding=a);const o=/\{\{(.*?)\}\}/g,r=a.match(o);r&&r.forEach(i=>{let d=i.slice(2,-2);const c=t.get(l,d,i);a=t.isArray(c)?c:a.replace(i,c)}),n[s]=a}}),n},st=e=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(e)||n.test(e)},nt=e=>{if(t.isEmpty(e))return e;const l=/<video[^>]+src=['"]([^'">]+)['"]/,n=/<iframe[^>]+src=['"]([^'">]+)['"]/,s=e.match(l),a=e.match(n),o=s?s[1]:a?a[1]:null,r=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,i=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return o&&(r.test(o)||i.test(o))?o:e},F=["chai-name","data-chai-name"],at={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},lt=(e,l)=>e.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),E=e=>e.map(l=>l.type==="text"?t.get(l,"content",""):t.isEmpty(l.children)?"":E(l.children)).join(""),B=e=>e===null?"":e,J=e=>{const l=t.compact(t.map(e.split(/\s+/),t.trim)),n=t.find(l,i=>/^w-/.test(i)),s=t.find(l,i=>/^h-/.test(i));if(!s||!n)return{height:"",width:""};const a=i=>{if(!i)return;const d=i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!d)return;if(d[1])return d[1];const c=d[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||t.includes(c,"%")?c:"16px"},o=a(n),r=a(s);return{width:t.includes(o,"px")?o:"16px",height:t.includes(r,"px")?r:"16px"}},q=e=>{if(e.tagName==="svg")return{};const l={},n=at[e.tagName]||{},s=e.attributes;return t.forEach(s,({key:a,value:o})=>{var r;if(!t.includes(F,a))if(a==="bid"&&(l._bid=B(o)),n[a]){if(e.tagName==="img"&&a==="src"&&!o.startsWith("http")){const i=t.find(e.attributes,{key:"width"}),d=t.find(e.attributes,{key:"height"});i&&d?o=`https://picsum.photos/${i==null?void 0:i.value}x${d==null?void 0:d.value}`:o="https://picsum.photos/150x150"}else if(e.tagName==="a"){const i=t.find(e.attributes,{key:"href"});i&&typeof(i==null?void 0:i.value)=="string"&&((r=i==null?void 0:i.value)!=null&&r.startsWith("pageType:"))&&t.set(l,"link.type","pageType")}t.set(l,n[a],B(o))}else t.includes(["style","class","srcset","bid"],a)||(t.has(l,"styles_attrs")||(l.styles_attrs={}),t.startsWith(a,"@")&&(a=a.replace("@","x-on:")),l.styles_attrs[`${a}`]=B(o))}),delete l.class,l},ot=(e,l="styles")=>{if(!e.attributes)return{[l]:`${m},`};const n=t.find(e.attributes,{key:"class"});if(n){const s=n.value;return{[l]:`${m},${s}`}}return{[l]:`${m},`}},rt=e=>{const l=t.get(e,"attributes",[]),n=l.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),s=l.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),a=l.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),o=l.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),r=l.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content"),i=l.find(c=>c.key==="class"),d=i&&i.value.split(/\s+/).includes("rte");if(a)return{_type:"Dropdown"};if(o)return{_type:"DropdownButton"};if(r)return{_type:"DropdownContent"};if(n||d)return{_type:"Paragraph"};if(s)return{_type:"LightBoxLink"};switch(e.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:e.tagName,_listType:e.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:e.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:e.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:e.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:e.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const c=t.get(e,"children",[]).length>0?"Box":"EmptyBox";return{_type:c,tag:e.tagName,_name:c=="EmptyBox"||e.tagName==="div"?c:t.capitalize(e.tagName)}}}},w=(e,l=null)=>t.flatMapDeep(e,n=>{var D,I,C,$,N,L,W,A,P,R;if(n.type==="comment")return[];let s={_id:T.generateUUID()};if(l&&(s._parent=l.block._id),n.type==="text")return t.isEmpty(t.get(n,"content",""))?[]:l&&lt(l.node,l.block)?(t.set(l,"block.content",t.get(n,"content","")),[]):{...s,_type:"Text",content:t.get(n,"content","")};if(t.startsWith(n.tagName,"chai-")){const p=n.attributes,u=t.find(p,{key:"chai-type"}),y=(u==null?void 0:u.value)||t.startCase(n.tagName.replace("chai-","")).replace(/\s+/g,"");s._type=y,t.forEach(p,({key:h,value:j})=>{if(h==="about-this-component"||h==="chai-type"||h==="can-move"||h==="can-delete")return;if(h==="id"){s._id=j;return}const z=t.startsWith(h,"_")?h:t.camelCase(h);let k=B(j);typeof k=="string"&&t.startsWith(k,"#styles:")&&(k=k.replace("#styles:","#styles:,")),s[z]=k});const g=w(n.children,{block:s,node:n});return[s,...g]}const a=t.get(n,"attributes",[]),o=n.tagName==="p"||a.find(p=>p.key==="data-chai-richtext"||p.key==="chai-richtext"),r=a.find(p=>p.key==="class"),i=r&&r.value.split(/\s+/).includes("rte"),d=a.find(p=>p.key==="data-chai-lightbox"||p.key==="chai-lightbox"),c=a.find(p=>p.key==="data-chai-dropdown"||p.key==="chai-dropdown"),b=a.find(p=>p.key==="data-chai-dropdown-button"||p.key==="chai-dropdown-button"),_=a.find(p=>p.key==="data-chai-dropdown-content"||p.key==="chai-dropdown-content");if(s={...s,...rt(n),...q(n),...ot(n)},n.attributes){const p=n.attributes.find(u=>t.includes(F,u.key));p&&(s._name=p.value)}if(o||i)return s.content=`<p>${f.stringify(n.children||[])}</p>`,t.has(s,"styles_attrs.data-chai-richtext")&&delete s.styles_attrs["data-chai-richtext"],t.has(s,"styles_attrs.chai-richtext")&&delete s.styles_attrs["chai-richtext"],[s];if(d){const p=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];s={...s,href:((D=a.find(u=>u.key==="href"))==null?void 0:D.value)||"",hrefType:((I=a.find(u=>u.key==="data-vbtype"))==null?void 0:I.value)||"video",autoplay:((C=a.find(u=>u.key==="data-autoplay"))==null?void 0:C.value)==="true"?"true":"false",maxWidth:((N=($=a.find(u=>u.key==="data-maxwidth"))==null?void 0:$.value)==null?void 0:N.replace("px",""))||"",backdropColor:((L=a.find(u=>u.key==="data-overlay"))==null?void 0:L.value)||"",galleryName:((W=a.find(u=>u.key==="data-gall"))==null?void 0:W.value)||""},t.forEach(p,u=>{t.has(s,`styles_attrs.${u}`)&&delete s.styles_attrs[u]})}if(c&&(delete s.styles_attrs,s.showDropdown=!1),_&&delete s.styles_attrs,b){delete s.styles_attrs;const p=t.filter(n.children||[],y=>(y==null?void 0:y.tagName)!=="span");s.content=E(p);const u=t.find(n.children||[],y=>(y==null?void 0:y.tagName)==="span"&&t.some(y.children||[],g=>(g==null?void 0:g.tagName)==="svg"));if(u){const y=t.find(u.children||[],g=>(g==null?void 0:g.tagName)==="svg");if(y){s.icon=f.stringify([y]);const{height:g,width:h}=ct(y,"16px","16px");s.iconHeight=g,s.iconWidth=h}}return[s]}if(s._type==="Input"){const p=s.inputType||"text";p==="checkbox"?t.set(s,"_type","Checkbox"):p==="radio"&&t.set(s,"_type","Radio")}else if(n.tagName==="video"||n.tagName==="iframe"){const p=f.stringify([n]);return st(p)&&(t.set(s,"_type","Video"),t.set(s,"url",nt(p)),t.set(s,"styles",`${m},`),t.set(s,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),s.content=p,[s]}else if(n.tagName==="svg"){const p=t.get(t.find(n.attributes,{key:"class"}),"value",""),{height:u,width:y}=J(p);if(u&&y)s.styles=`${m}, ${T.cn(`w-${y} h-${u}`,p)}`.trim(),s.height=u==null?void 0:u.replace("px",""),s.width=y==null?void 0:y.replace("px","");else{const g=(A=t.find(n.attributes,{key:"height"}))==null?void 0:A.value,h=(P=t.find(n.attributes,{key:"width"}))==null?void 0:P.value;g&&h?(s.styles=`${m}, ${T.cn(`w-[${h}px] h-[${g}px]`,p)}`.trim(),s.height=g,s.width=h):s.styles=`${m}, ${T.cn("w-full h-full",p)}`.trim()}return n.attributes=t.filter(n.attributes,g=>!t.includes(["style","width","height","class"],g.key)),s.icon=f.stringify([n]),[s]}else if(n.tagName=="option"&&l&&((R=l.block)==null?void 0:R._type)==="Select")return l.block.options.push({label:E(n.children),...q(n)}),[];const x=w(n.children,{block:s,node:n});return[s,...x]}),ct=(e,l,n)=>{var d,c;const s=t.get(e,"attributes",[]),{height:a,width:o}=J(t.get(t.find(s,{key:"class"}),"value",""));if(a&&o)return{height:`[${a}px]`,width:`[${o}px]`};const r=(d=t.find(s,{key:"height"}))==null?void 0:d.value,i=(c=t.find(s,{key:"width"}))==null?void 0:c.value;return{height:r?`[${r}px]`:n,width:i?`[${i}px]`:l}},pt=e=>{e=e.replace(/(\w+)=\\?"(.*?)\\?"/g,(s,a,o)=>{let r=o.replace(/\\"/g,'"');return r=r.replace(/{([^}]+)}/g,i=>i.replace(/"/g,'\\"')),`${a}="${r.replace(/\\"/g,'"')}"`}),e=e.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),e=e.replace(/\$name="[^"]*"/g,"");const l=e.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):e).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},ut=e=>{const l=f.parse(pt(e));if(t.isEmpty(e))return[];const n=t.flatten(w(l));return V.syncBlocksWithDefaults(n)},dt=(e,l)=>e.map(n=>{const s=t.keys(n).filter(a=>t.isString(n[a])&&n[a].startsWith(m));return t.each(s,a=>{n[a]=`${m},${O(n[a],l)}`}),n}),yt=e=>{const l=t.last(e);return e.map(n=>{const s=Object.keys(n);for(let a=0;a<s.length;a++)if(t.isString(n[s[a]])&&t.startsWith(s[a],"content")){const o=n===l?"":" ";n[s[a]]=`${n[s[a]].trim()}${o}`}return n})},S=(e,l,{index:n,key:s},a)=>{if(t.isString(e)){let o=e;const r=/\{\{(.*?)\}\}/g,i=e.match(r);if(i){const d=a==="image"||a==="mobileImage";i.forEach(c=>{let b=c.slice(2,-2).trim(),_=s.slice(2,-2).trim();n!==-1&&t.startsWith(b,"$index.")?b=`${_}.${n}.${b.slice(7)}`:n!==-1&&t.startsWith(b,"$index")&&(b=`${_}.${n}`);const x=t.get(l,b);x===void 0?o=o.replace(c,""):d&&!t.isArray(x)?o=x:o=t.isArray(x)?x:o.replace(c,x)})}return o}if(t.isArray(e))return e.map(o=>S(o,l,{index:n,key:s},a));if(e&&typeof e=="object"){const o={};return t.forEach(t.keys(e),r=>{!t.startsWith(r,"_")&&r!=="$repeaterItemsKey"?o[r]=S(e[r],l,{index:n,key:s},r):o[r]=e[r]}),o}return e},gt=(e,l,{index:n,key:s})=>{let a=t.cloneDeep(e);return a.repeaterItems&&(a.$repeaterItemsKey=a.repeaterItems,t.startsWith(a.repeaterItems,`{{${H}`)&&(a.$repeaterItemsKey=a.repeaterItems=`${a.repeaterItems.replace("}}",`/${a._id}}}`)}`),!t.isEmpty(a.repeaterItems)&&a.pagination&&(a.repeaterTotalItems=`${a.repeaterItems.replace("}}",`/${a._id}/totalItems}}`)}`)),S(a,l,{index:n,key:s})};exports.COLLECTION_PREFIX=H;exports.DESIGN_TOKEN_PREFIX=v;exports.REPEATER_PREFIX=K;exports.ROOT_TEMP_KEY=Y;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=yt;exports.applyBindingToBlockProps=gt;exports.applyChaiDataBinding=et;exports.applyDesignTokens=dt;exports.applyLanguage=X;exports.applyLimit=tt;exports.getBlockRuntimeProps=Q;exports.getBlockTagAttributes=Z;exports.getBlocksFromHTML=ut;exports.getSplitChaiClasses=M;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-CnSjWE1P.cjs"),m=require("@monaco-editor/react"),t=require("@radix-ui/react-icons"),r=require("react");function j({code:l,onCopy:d,language:s="javascript",onDownload:c,downloadText:u="Download"}){const[n,a]=r.useState(!1),[o,p]=r.useState(l),f=()=>{d(o),a(!0),setTimeout(()=>{a(!1)},2e3)},h=()=>{c(o)};return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"h-[500px] max-h-full overflow-hidden rounded-md border py-2",children:e.jsx(m,{height:"100%",defaultLanguage:s,language:s,value:o,onChange:x=>p(x||""),theme:"vs-light",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"off",roundedSelection:!1,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,insertSpaces:!0,wordWrap:"on",bracketPairColorization:{enabled:!0},suggest:{showKeywords:!1,showSnippets:!1}}})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(i.Button,{type:"button",variant:"outline",onClick:f,children:[n?e.jsx(t.CheckIcon,{className:"text-green-500"}):e.jsx(t.CopyIcon,{})," ",n?"Copied":"Copy"]}),e.jsxs(i.Button,{type:"button",onClick:h,children:[e.jsx(t.DownloadIcon,{})," ",u]})]})]})}exports.default=j;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CnSjWE1P.cjs"),k=require("@react-hookz/web"),c=require("react"),g=require("react-i18next"),x=l=>{const o=document.createElement("div");return o.innerHTML=l,o.innerHTML};function j(){const{t:l}=g.useTranslation(),[o,m]=c.useState(!1),[a,h]=c.useState(""),[s,i]=t.useCodeEditor(),[d]=t.useSelectedBlockIds(),p=t.useUpdateBlocksProps(),b=t.useUpdateBlocksPropsRealtime(),f=k.useThrottledCallback(n=>{const r=x(n);b([s.blockId],{[s.blockProp]:r})},[],300),u=c.useCallback(()=>{if(o){const n=x(a);p([s.blockId],{[s.blockProp]:n})}},[o,a]);c.useEffect(()=>{d.includes(s==null?void 0:s.blockId)||(u(),i(null))},[d]);const C=()=>{u(),i(null)};return e.jsx(t.Dialog,{open:!0,onOpenChange:C,children:e.jsxs(t.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[e.jsx(t.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:e.jsx(t.DialogTitle,{className:"flex items-center justify-between text-black",children:e.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:l("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:l("Scripts will be only executed in preview and live mode.")})]})})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:a||s.initialCode,onChange:n=>{const r=n.target.value;m(!0),h(r),f(r)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CnSjWE1P.cjs"),a=require("./index-CbwxUFy_.cjs"),n=require("lucide-react"),i=require("react-i18next"),l=()=>{const{setPageLockMeta:c}=a.usePageLockMeta(),{t}=i.useTranslation(),r=async()=>{c({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(s.Button,{variant:"default",onClick:r,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=l;
@@ -1 +0,0 @@
1
- "use strict";const r=require("lodash-es"),g=require("react"),o={},B=()=>o,k=e=>g.useMemo(()=>r.get(o,e,null),[e]),l=e=>r.get(o,e,null),i=e=>{const t=r.get(o,`${e}.schema.properties`,{}),s={};return r.each(t,(c,n)=>{r.has(c,"block")||r.set(s,n,c.default)}),s},h=e=>r.get(o,`${e}.i18nProps`,[]),d=e=>r.get(o,`${e}.aiProps`,[]),f=e=>{const t=l(e);if(!t)return null;const s=r.cloneDeep(t.schema),c=r.get(s,"properties",{}),n=r.omitBy(c,a=>a.styles===!0);r.set(s,"properties",n);const u=r.get(o,`${e}.uiSchema`,{});return{schema:s,uiSchema:u}},C=e=>e.map(t=>r.has(o,t._type)?{...i(t._type),...t}:t),p=(e,t)=>{const s=r.get(o,t.type);s?r.set(o,t.type,{...s,component:e,...t}):r.set(o,t.type,{component:e,...t})},P=(e,t)=>{p(e,{...t,category:t.category||"core"})},m=(e,t)=>{const s=r.get(o,t.type);s?r.set(o,t.type,{...s,component:e,...t}):r.set(o,t.type,{component:e,...t})},y=(e,t)=>{const s=l(e);if(!s)throw new Error(`Block ${e} not found`);r.set(o,e,{...s,dataProvider:t})},S=(e,t)=>{const s=l(e);if(!s)throw new Error(`Block ${e} not found`);r.set(o,e,{...s,component:t})},R=(e,t)=>({type:"null",block:e,prop:t,default:null,runtime:!0,ui:{"ui:widget":"hidden"}});exports.closestBlockProp=R;exports.getAIBlockProps=d;exports.getBlockFormSchemas=f;exports.getDefaultBlockProps=i;exports.getI18nBlockProps=h;exports.getRegisteredChaiBlock=l;exports.registerChaiBlock=P;exports.registerChaiServerBlock=m;exports.setChaiBlockComponent=S;exports.setChaiServerBlockDataProvider=y;exports.syncBlocksWithDefaults=C;exports.useRegisteredChaiBlock=k;exports.useRegisteredChaiBlocks=B;
@@ -1,56 +0,0 @@
1
- import { get as o, each as g, has as i, set as c, cloneDeep as k, omitBy as f } from "lodash-es";
2
- import { useMemo as h } from "react";
3
- const s = {}, y = () => s, P = (e) => h(() => o(s, e, null), [e]), a = (e) => o(s, e, null), d = (e) => {
4
- const r = o(s, `${e}.schema.properties`, {}), t = {};
5
- return g(r, (n, l) => {
6
- i(n, "block") || c(t, l, n.default);
7
- }), t;
8
- }, S = (e) => o(s, `${e}.i18nProps`, []), $ = (e) => o(s, `${e}.aiProps`, []), w = (e) => {
9
- const r = a(e);
10
- if (!r)
11
- return null;
12
- const t = k(r.schema), n = o(t, "properties", {}), l = f(n, (B) => B.styles === !0);
13
- c(t, "properties", l);
14
- const u = o(s, `${e}.uiSchema`, {});
15
- return { schema: t, uiSchema: u };
16
- }, D = (e) => e.map((r) => i(s, r._type) ? { ...d(r._type), ...r } : r), p = (e, r) => {
17
- const t = o(s, r.type);
18
- t ? c(s, r.type, { ...t, component: e, ...r }) : c(s, r.type, { component: e, ...r });
19
- }, E = (e, r) => {
20
- p(e, { ...r, category: r.category || "core" });
21
- }, I = (e, r) => {
22
- const t = o(s, r.type);
23
- t ? c(s, r.type, { ...t, component: e, ...r }) : c(s, r.type, { component: e, ...r });
24
- }, R = (e, r) => {
25
- const t = a(e);
26
- if (!t)
27
- throw new Error(`Block ${e} not found`);
28
- c(s, e, { ...t, dataProvider: r });
29
- }, _ = (e, r) => {
30
- const t = a(e);
31
- if (!t)
32
- throw new Error(`Block ${e} not found`);
33
- c(s, e, { ...t, component: r });
34
- }, v = (e, r) => ({
35
- type: "null",
36
- block: e,
37
- prop: r,
38
- default: null,
39
- runtime: !0,
40
- ui: { "ui:widget": "hidden" }
41
- });
42
- export {
43
- w as a,
44
- d as b,
45
- v as c,
46
- S as d,
47
- a as e,
48
- I as f,
49
- $ as g,
50
- _ as h,
51
- D as i,
52
- y as j,
53
- E as r,
54
- R as s,
55
- P as u
56
- };
@@ -1,13 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("./index-CnSjWE1P.cjs");require("lodash-es");const w=require("culori"),T=require("./fonts-B-Xt29pe.cjs"),V=require("react"),N=require("react-i18next");function $(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const y=$(w),S=$(V),f=e=>e?e%1===0?e:e.toFixed(4):"0",R=e=>`hsl(${f(e.h)} ${f(e.s*100)}% ${f(e.l*100)}%)`,E=(e,o="hsl",t="4")=>{try{const r=y.parse(e);if(!r)throw new Error("Invalid color input");switch(o){case"hsl":{const s=y.converter("hsl")(r);return t==="4"?R(s):`${f(s.h)} ${f(s.s*100)}% ${f(s.l*100)}%`}case"rgb":return y.formatRgb(r);case"oklch":{const s=y.converter("oklch")(r);return`oklch(${f(s.l)} ${f(s.c)} ${f(s.h)})`}case"hex":return y.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},b=e=>E(e,"hex"),I=e=>{const o={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{const t=F(e);if(!t.isValid)return console.warn("CSS validation failed:",t.error),k();const r=C(e,":root"),s=C(e,".dark"),l=u(r,"--font-sans")||u(r,"--font-family")||u(r,"--font-heading")||u(r,"--font-body"),a=q(l);o.fontFamily={heading:a,body:a};const m=u(r,"--radius")||u(r,"--border-radius")||"0.5rem";o.borderRadius=D(m),["background","foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","destructive-foreground","border","input","ring","card","card-foreground","popover","popover-foreground"].forEach(i=>{const p=u(r,`--${i}`),g=u(s,`--${i}`);if(p||g){const d=p?v(p):"#000000",x=g?v(g):d;o.colors[i]=[d,x]}})}catch(t){return console.error("Error parsing CSS to ChaiThemeValues:",t),k()}return o},C=(e,o)=>{var r,s;const t=new RegExp(`${j(o)}\\s*{([^}]+)}`);return((s=(r=e.match(t))==null?void 0:r[1])==null?void 0:s.trim())||null},u=(e,o)=>{var s;if(!e)return null;const t=new RegExp(`${j(o)}\\s*:\\s*([^;]+)`),r=e.match(t);return((s=r==null?void 0:r[1])==null?void 0:s.trim())||null},v=e=>{if(!e||typeof e!="string")return"#000000";try{const o=e.replace(/var\([^)]+\)/g,"").trim();if(!o)return"#000000";if(/^[a-z]+$/i.test(o))return b(o)||"#000000";if(/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(o.replace(/#/g,""))){const r=o.startsWith("#")?o:`#${o}`;return r.length<=5?`#${r.slice(1).split("").map(s=>s+s).join("")}`.slice(0,7):r.length>7?r.slice(0,7):r}if(/^(rgb|hsl|oklch)a?\(/i.test(o))return b(o)||"#000000";const t=o.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(t){const[,r,s,l]=t,a=`hsl(${r} ${s}% ${l}%)`;return b(a)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(o)){const r=o.split(/[\s,]+/).filter(Boolean);if(r.length>=3){const l=r.some(a=>a.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return b(l)||"#000000"}}return b(o)||"#000000"}catch(o){return console.warn("Failed to process color:",e,o),"#000000"}},q=e=>{const o=T.getAllRegisteredFonts();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{const r=e.replace(/["']/g,"").trim().split(",")[0].trim(),s=o.find(l=>l.family.toLowerCase()===r.toLowerCase());return(s==null?void 0:s.family)||"ui-sans-serif, system-ui, sans-serif"}catch(t){return console.warn("Error processing font family:",e,t),"ui-sans-serif, system-ui, sans-serif"}},D=e=>{try{const o=e.trim();if(o.endsWith("px"))return o;if(o.endsWith("rem")){const r=parseFloat(o.replace("rem",""));if(!isNaN(r))return`${Math.round(r*16)}px`}if(o.endsWith("em")){const r=parseFloat(o.replace("em",""));if(!isNaN(r))return`${Math.round(r*16)}px`}const t=parseFloat(o);return isNaN(t)?"8px":`${Math.round(t)}px`}catch(o){return console.warn("Error converting border radius to px:",e,o),"8px"}},k=()=>({fontFamily:{heading:"ui-sans-serif, system-ui, sans-serif",body:"ui-sans-serif, system-ui, sans-serif"},borderRadius:"8px",colors:{background:["#ffffff","#000000"],foreground:["#000000","#ffffff"],primary:["#3b82f6","#60a5fa"],"primary-foreground":["#ffffff","#1e293b"],secondary:["#f1f5f9","#334155"],"secondary-foreground":["#0f172a","#f8fafc"],muted:["#f8fafc","#1e293b"],"muted-foreground":["#64748b","#94a3b8"],accent:["#f1f5f9","#334155"],"accent-foreground":["#0f172a","#f8fafc"],destructive:["#ef4444","#f87171"],"destructive-foreground":["#ffffff","#1e293b"],border:["#e2e8f0","#475569"],input:["#e2e8f0","#475569"],ring:["#3b82f6","#60a5fa"],card:["#ffffff","#0f172a"],"card-foreground":["#000000","#f8fafc"],popover:["#ffffff","#0f172a"],"popover-foreground":["#000000","#f8fafc"]}}),j=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=e=>["background","foreground","primary","primary-foreground"].every(r=>e.colors[r]&&Array.isArray(e.colors[r])&&e.colors[r].length>=2)&&!!e.fontFamily.heading&&!!e.fontFamily.body&&!!e.borderRadius,F=e=>{if(!e||typeof e!="string")return{isValid:!1,error:"Please enter valid CSS content"};const o=e.trim();if(!o)return{isValid:!1,error:"Please enter CSS content"};try{if(!o.includes("{")||!o.includes("}"))return{isValid:!1,error:"Invalid CSS format. CSS should contain proper block structure with { }"};const t=(o.match(/{/g)||[]).length,r=(o.match(/}/g)||[]).length;return t!==r?{isValid:!1,error:"Invalid CSS format. Unmatched braces detected"}:!o.includes("--")||!o.includes(":")?{isValid:!1,error:"Invalid CSS format. CSS should contain variable definitions like --primary: #color"}:!o.includes(":root")&&!o.includes(".dark")?{isValid:!1,error:"CSS should contain at least :root or .dark selector with theme variables"}:{isValid:!0}}catch(t){return console.error("CSS validation error:",t),{isValid:!1,error:"Failed to parse CSS. Please check your syntax."}}},M=`:root {
2
- --background: 0 0% 100%;
3
- --foreground: oklch(0.52 0.13 144.17);
4
- --primary: #3e2723;
5
- --primary-foreground: #ffffff;
6
- }
7
-
8
- .dark {
9
- --background: 222.2 84% 4.9%;
10
- --foreground: hsl(37.50 36.36% 95.69%);
11
- --primary: rgb(46, 125, 50);
12
- --primary-foreground: #ffffff;
13
- }`,B=({open:e,onOpenChange:o,onImport:t})=>{const[r,s]=S.useState(""),[l,a]=S.useState(null),[m,h]=S.useState(!1),{t:i}=N.useTranslation(),p=async()=>{h(!0),a(null);try{const d=F(r);if(!d.isValid){a(d.error||i("Invalid CSS format")),setTimeout(()=>{a(null)},5e3),h(!1);return}const x=I(r);if(!P(x)){a(i("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors.")),setTimeout(()=>{a(null)},5e3),h(!1);return}t(x),s(""),a(null),o(!1)}catch(d){console.error("Error importing CSS:",d),a(i("Failed to parse CSS. Please check your syntax and try again.")),setTimeout(()=>{a(null)},5e3)}finally{h(!1)}},g=()=>{s(""),a(null),o(!1)};return n.jsx(c.Dialog,{open:e,onOpenChange:o,children:n.jsxs(c.DialogContent,{className:"flex max-h-[80vh] max-w-2xl flex-col",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:i("Import CSS Theme")}),n.jsxs(c.DialogDescription,{className:"space-y-2",children:[n.jsx("p",{children:i("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.")}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("p",{className:"font-bold",children:"Get theme resources:"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://tweakcn.com/","_blank"),children:"TweakCN"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://ui.shadcn.com/themes#themes","_blank"),children:"shadcn/ui Themes"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://zippystarter.com/tools/shadcn-ui-theme-generator","_blank"),children:"ZippyStarter"})]})]})]}),n.jsxs("div",{className:"flex-1 space-y-4 overflow-hidden",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(c.Label,{htmlFor:"css-input",children:i("CSS Variables")}),n.jsx(c.Textarea,{id:"css-input",placeholder:M,value:r,onChange:d=>s(d.target.value),className:"min-h-[300px] resize-none font-mono text-sm",disabled:m})]}),l&&n.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:n.jsx("p",{className:"text-sm text-red-600",children:l})})]}),n.jsxs(c.DialogFooter,{className:"gap-2",children:[n.jsx(c.Button,{variant:"outline",onClick:g,disabled:m,children:i("Cancel")}),n.jsx(c.Button,{onClick:p,disabled:!r.trim()||m,children:i(m?"Importing...":"Import Theme")})]})]})})};exports.CssImportModal=B;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("./index-CnSjWE1P.cjs"),o=require("./index-CbwxUFy_.cjs"),L=require("lodash-es"),D=require("react"),N=require("react-i18next"),f=(e,r)=>{const n=r.filter(u=>u.parent===e);if(n.length===0)return 0;let a=n.length;return n.forEach(u=>{a+=f(u.id,r)}),a};function A({page:e,onClose:r}){const{t:n}=N.useTranslation(),[,a]=o.useSearchParams(),{mutate:u,isPending:x}=o.useDeletePage(),{data:P}=o.usePageTypes(),{data:h=[]}=o.useWebsitePages(),{setSelectedLang:v,fallbackLang:S}=s.useLanguages(),[,w]=s.useSidebarActivePanel(),l=!(e!=null&&e.primaryPage),{data:i=[]}=o.useLanguagePages(l?e==null?void 0:e.id:void 0),j=D.useMemo(()=>!l||!i?0:i.filter(d=>d.id!==(e==null?void 0:e.id)).length,[l,i,e==null?void 0:e.id]),m=D.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let d=f(e.id,h);return l&&i&&i.length>0&&i.forEach(y=>{y.id!==e.id&&(d+=f(y.id,h))}),d},[e==null?void 0:e.id,h,l,i]),C=()=>{x||u(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),a(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),a(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),v(S),w("outline"),r()}})},c=P==null?void 0:P.find(d=>d.key===(e==null?void 0:e.pageType));return t.jsx(s.Dialog,{open:!!e,onOpenChange:r,children:t.jsxs(s.DialogContent,{children:[t.jsxs(s.DialogHeader,{children:[t.jsx(s.DialogTitle,{children:n("Confirm Deletion")}),t.jsxs(s.DialogDescription,{className:"py-4 text-slate-500",children:[t.jsxs("div",{children:[n("Are you sure you want to remove")," ",t.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",c!=null&&c.hasSlug?(c==null?void 0:c.name)+"?":n("page?")]}),l&&(j>0||m>0)&&t.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[t.jsxs("div",{className:"font-semibold text-red-800",children:[n("Warning: Deleting this primary page will also delete"),":"]}),t.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[m>0&&t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:m})," ",n(m===1?"nested child page":"nested child pages")]}),j>0&&t.jsx("li",{children:n("All associated language pages")})]})]}),e.lang&&t.jsxs("div",{className:"py-2 text-sm",children:[n("Language"),":"," ",t.jsx("span",{className:"font-medium text-gray-500",children:L.get(o.LANGUAGES,e.lang,e.lang)})]})]})]}),t.jsxs(s.DialogFooter,{children:[t.jsx(s.Button,{variant:"outline",onClick:r,children:n("Cancel")}),t.jsx(s.Button,{variant:"destructive",disabled:x,onClick:C,children:n(x?"Deleting...":"Delete")})]})]})})}exports.default=A;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),r=require("./index-CnSjWE1P.cjs"),p=require("@radix-ui/react-icons"),L=require("lodash-es"),d=require("react"),w=require("react-i18next"),x=({title:n,items:l,emptyLabel:o,onSelect:t,icon:i})=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n}),l.length>0?s.jsx("div",{className:"space-y-1",children:l.map(a=>s.jsx("button",{type:"button",onClick:()=>t(a.id),className:r.cn("group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition","hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",a.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:s.jsxs("span",{className:"flex items-center space-x-2",children:[i&&i,s.jsx("span",{className:"truncate",children:a.label})]})},a.id))}):s.jsx("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:o})]}),M="#styles:",_=n=>{const o=[typeof n._name=="string"?n._name:void 0,typeof n._type=="string"?n._type:void 0].filter(Boolean).find(t=>t.trim().length>0);return o?o.length>40?`${o.slice(0,37)}...`:o:n._id},q=(n,l)=>{const o=`${l}`;return n.filter(t=>Object.values(t).some(i=>typeof i!="string"||!i.startsWith(M)?!1:i.includes(o))).map(t=>({id:t._id,label:_(t)}))},C=({tokenId:n,tokenName:l,children:o})=>{const{t}=w.useTranslation(),[i]=r.useBlocksStore(),[a,b]=r.useSelectedBlockIds(),g=r.useBuilderProp("pageId"),m=r.useBuilderProp("siteWideUsage"),h=d.useMemo(()=>q(i,n),[i,n]),P=d.useMemo(()=>h.map(e=>({id:e.id,label:e.label,isSelected:a.includes(e.id)})),[h,a]),u=d.useMemo(()=>m?Object.entries(m).reduce((e,[f,c])=>(f===g||!(c!=null&&c.designTokens)||!Object.keys(c.designTokens).some(j=>typeof j!="string"?!1:j===n)||e.push({id:f,name:c.name||f,isPartial:!!c.isPartial}),e),[]):[],[m,l,n,g]),S=d.useMemo(()=>u.filter(e=>!e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),k=d.useMemo(()=>u.filter(e=>e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),v=d.useCallback(e=>{b([e])},[b]),B=r.useBuilderProp("gotoPage",L.noop),{selectedLang:N,fallbackLang:T}=r.useLanguages(),{savePageAsync:I}=r.useSavePage(),y=async e=>{e&&(await I(!0),B({pageId:e,lang:N||T}))};return s.jsxs(r.Popover,{children:[s.jsx(r.PopoverTrigger,{asChild:!0,children:o}),s.jsxs(r.PopoverContent,{side:"bottom",align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"space-y-1 px-4 py-3",children:[s.jsx("p",{className:"text-xs font-semibold",children:l}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Usage summary for this design token across your site.")})]}),s.jsxs("div",{className:"no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4",children:[s.jsx(x,{title:t("Blocks affected on this page"),items:P,emptyLabel:t("None"),onSelect:v,icon:s.jsx(p.ArrowRightIcon,{fontSize:4})}),s.jsx(x,{title:t("Blocks affected on other pages"),items:S,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.FileIcon,{fontSize:8})}),s.jsx(x,{title:t("Blocks affected on partial blocks"),items:k,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.GlobeIcon,{fontSize:8})})]})]})]})};exports.default=C;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-CnSjWE1P.cjs"),Y=require("./image-compression-DZ9WMmyn.cjs"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),pe=require("react-dropzone"),ge=require("react-error-boundary"),G=require("react-i18next"),w=require("sonner"),z=require("@tanstack/react-query"),g=require("./index-CbwxUFy_.cjs"),ee=require("./common-functions-B3a4xKt_.cjs"),je=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ve=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},ye=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function Ne({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:"h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const be=(n={})=>{const r=g.useApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},we=n=>{const r=g.useApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function Ce(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const Ae=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=G.useTranslation(),{data:l,isLoading:E,isError:N}=we(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"mx-auto max-w-md p-6 text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"mb-2 text-lg font-medium text-gray-900",children:s("No Asset Found")}),e.jsx("p",{className:"mb-6 text-sm text-gray-500",children:s(N?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex flex-1 flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"mr-2 h-4 w-4"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid flex-1 grid-cols-2 items-start gap-6 overflow-hidden",children:[e.jsx("div",{className:"relative flex h-[calc(80vh-200px)] w-full items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"h-full max-h-max w-full max-w-max rounded-lg object-contain"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 rounded-md border bg-white p-2 text-sm",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:Ce(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-1/4 w-max px-2 text-left font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 rounded-md border p-2 text-sm",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"relative grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"bg-white hover:border-black/40"}),e.jsx("div",{className:"absolute right-2 top-1.5 flex items-start justify-end",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`rounded-md bg-blue-500 px-3 py-0 py-0.5 text-sm text-white ${o||!J(v,l)?"cursor-not-allowed opacity-50":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"mr-2 h-4 w-4 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Se=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DTspjj_c.cjs"))),Te=25*1024*1024,Ee=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=G.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise(($,B)=>{const q=new FileReader;q.readAsDataURL(U),q.onload=async()=>{$({file:q.result,folderId:void 0,name:S.name,optimize:l})},q.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Te?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=pe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...b(),className:ee.cn("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Ie({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=G.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,$]=u.useState(""),[B,q]=u.useState(""),[M,_]=u.useState(1),[R]=u.useState(30),[T,Q]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{$(B),_(1)},300);return()=>clearTimeout(t)},[B]);const{data:L,isLoading:P,refetch:te}=be({search:U.toLowerCase().trim(),page:M,limit:R}),D=(L==null?void 0:L.assets)||[],se=(L==null?void 0:L.total)||0,I=Math.ceil(se/R);u.useEffect(()=>{P||I<=0||_(t=>t>I?I:t<1?1:t)},[P,I]);const ie=(D==null?void 0:D.length)>0,{mutate:le}=ve(),{mutateAsync:K,isPending:ae}=je(),{mutateAsync:W,isPending:re}=ye(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==M&&_(h)},[I,M]),ne=t=>{q(t.target.value)},oe=u.useCallback(t=>{Q(h=>F.find(h,{id:t.id})?[]:[t])},[s]),ce=u.useCallback(()=>{Q([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},de=async t=>{b(t)},ue=async()=>{j&&(A(j==null?void 0:j.id),await le(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},me=t=>{v(t.id),S("details")},he=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},xe=u.useCallback(t=>{Q([t])},[]),fe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:re,isUploadingAsset:ae,onUploaded:xe}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:ne,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>ce(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>te(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:P?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!P&&!ie?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:ee.cn("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>oe(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),me(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),de(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(ge.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(Ne,{currentPage:M,totalPages:I,onPageChange:fe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Ae,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Se,{imageUrl:c.file,onSave:he,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:ue,children:o("Delete")})]})]})})]})}exports.default=Ie;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-CnSjWE1P.cjs"),p=require("./index-CbwxUFy_.cjs"),N=require("@tanstack/react-query"),v=require("sonner"),P=require("lodash-es"),E=require("lucide-react"),g=require("react"),C=require("react-i18next"),A=require("./slug-input-YVLjtTI3.cjs"),T=()=>{const t=p.useApiUrl(),u=N.useQueryClient(),h=p.useFetch();return N.useMutation({mutationFn:async({pageId:s,name:x,slug:r})=>{const o={pageId:s,name:x};return r&&(o.slug=r),await h(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),v.toast.success("Page duplicated successfully")},onError:s=>{v.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},w=({page:t,onClose:u,closePanel:h=()=>{}})=>{const{t:s}=C.useTranslation(),{mutate:x,isPending:r}=T(),[o,i]=g.useState(null),[d,D]=g.useState(`${t.name} (Copy)`),I=p.useChangePage(),n=P.isEmpty(t.slug),[m,b]=g.useState(n?"":`${t.slug.split("/").pop()}-copy`),f=n?"":P.initial(t.slug.split("/")).join("/"),[y,j]=g.useState(!1),q=l=>{if(l.preventDefault(),!d.trim()){i(s("Name is required"));return}if(!n&&!m.trim()){i(s("Slug is required"));return}i(null),j(!0);const S={pageId:t.id,name:d};n||(S.slug=`${f}/${m}`),x(S,{onSuccess:c=>{j(!1),u(),I(c.id,h)},onError:c=>{j(!1),c.code==="SLUG_EXISTS"?i(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?i(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?i(s("You don't have permission to duplicate this page.")):i(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Duplicate Page")}),e.jsx(a.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!n&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(a.Input,{id:"name",value:d,onChange:l=>D(l.target.value),required:!0})]}),!n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:l=>b(l),parentSlug:f,onValidationChange:l=>{i(l?null:s("Invalid slug"))}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(E.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!n&&!m.trim()||r||y,children:s(r||y?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=w;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./index-CnSjWE1P.cjs"),x=require("./index-CbwxUFy_.cjs"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(o.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),f=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:a,fallbackLang:i}=o.useLanguages(),u=(a==null?void 0:a.length)===0;return e.jsxs(o.DropdownMenu,{children:[e.jsx(o.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"ghost",className:"h-max w-max rounded-md border border-[0px] border-gray-200 py-1 pl-4 text-sm hover:bg-gray-100 focus:outline-none focus:ring-0",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(o.DropdownMenuContent,{className:"max-h-[75vh] w-96 divide-y p-0 shadow-xl",children:[e.jsx("div",{className:"bg-gray-50/30 p-1.5",children:e.jsx(g,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"flex h-24 items-center justify-center text-xs",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(o.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:a!==s.lang,className:`no-scrollbar flex cursor-pointer flex-col justify-start overflow-x-auto whitespace-nowrap ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full whitespace-nowrap px-2 py-[2px] text-xs",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"truncate rounded-full border border-gray-300 px-2 py-[1px] font-mono text-xs font-medium text-gray-500",children:s.slug})]})})},s.id))]})]})},m=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:a,updateSearchQuery:i,onChangeLanguage:u}=x.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(f,{dynamicPage:r,setDynamicPage:a,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=m;
@@ -1 +0,0 @@
1
- "use strict";const a=require("@tailwindcss/aspect-ratio"),n=require("@tailwindcss/forms"),d=require("@tailwindcss/typography"),i=require("tailwindcss-animate");function r(){return{colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}const s=({content:o,theme:e})=>({darkMode:"class",content:[...o,"node_modules/@chaibuilder/sdk/dist/*.{js,cjs}"],theme:{extend:{...r(),...e}},plugins:[i,d,n,a]});exports.getChaiBuilderTailwindConfig=s;exports.shadcnTheme=r;