@chaibuilder/sdk 4.0.0-beta.49 → 4.0.0-beta.50

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 (79) hide show
  1. package/README.md +0 -5
  2. package/dist/{2SSKDMRQ-CjvuNdPo.cjs → 2SSKDMRQ-DRvGNTLs.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-Dvf9zadl.js → 2SSKDMRQ-DqIyZppU.js} +2 -2
  4. package/dist/{AP7HFJJL-DYFttFoI.cjs → AP7HFJJL-BWwvxG86.cjs} +1 -1
  5. package/dist/{AP7HFJJL-q4dJdyFs.js → AP7HFJJL-DlUIW-7z.js} +1 -1
  6. package/dist/{WDYDFRGG-BEksfGMC.cjs → WDYDFRGG-N7kNyI7H.cjs} +1 -1
  7. package/dist/{WDYDFRGG-O9GIrtX0.js → WDYDFRGG-SsaVMSIa.js} +2 -2
  8. package/dist/{active-in-another-tab-B4Ur0JP7.js → active-in-another-tab-3S4Tzg0v.js} +1 -1
  9. package/dist/{active-in-another-tab-BPdx4lWh.cjs → active-in-another-tab-C83x4jHw.cjs} +1 -1
  10. package/dist/{add-new-language-page-CRR93tLq.js → add-new-language-page-BnPnQ-3A.js} +1 -1
  11. package/dist/{add-new-language-page-BfUp5Ua2.cjs → add-new-language-page-QIaeQ_fJ.cjs} +1 -1
  12. package/dist/{add-new-page-B8NGK6WS.cjs → add-new-page-Ddoy3kTu.cjs} +1 -1
  13. package/dist/{add-new-page-Ppy5-y5j.js → add-new-page-aLHfIIHC.js} +1 -1
  14. package/dist/{ai-panel-default-lang-BXYQye3N.js → ai-panel-default-lang-BOCTOIH_.js} +3 -3
  15. package/dist/{ai-panel-default-lang-VhgmHFoQ.cjs → ai-panel-default-lang-FNeOfRkj.cjs} +2 -2
  16. package/dist/{ai-panel-other-lang-DaCf-cq4.js → ai-panel-other-lang-C2j7qGZx.js} +3 -3
  17. package/dist/{ai-panel-other-lang-Ds0EXeUC.cjs → ai-panel-other-lang-DgRzCQGx.cjs} +1 -1
  18. package/dist/{ai-prompt-input-nZ5_Dm7X.cjs → ai-prompt-input-SJnya_UU.cjs} +1 -1
  19. package/dist/{ai-prompt-input-7iWk72w5.js → ai-prompt-input-p5KHwgCW.js} +1 -1
  20. package/dist/{ai-translation-prompt-1OUs1P7n.js → ai-translation-prompt-BTEXWPQq.js} +1 -1
  21. package/dist/{ai-translation-prompt-B16cK-1Q.cjs → ai-translation-prompt-Dhh-bNJr.cjs} +1 -1
  22. package/dist/{change-password-modal-CdvJR1Ln.js → change-password-modal-BkBFwrxi.js} +1 -1
  23. package/dist/{change-password-modal-D5eXjiYq.cjs → change-password-modal-BwBRdCeD.cjs} +1 -1
  24. package/dist/{continue-editing-in-this-client-BrSvK-Ay.js → continue-editing-in-this-client-DTmWmAee.js} +1 -1
  25. package/dist/{continue-editing-in-this-client-Cmi-GkYZ.cjs → continue-editing-in-this-client-DgtsPYZ4.cjs} +1 -1
  26. package/dist/{delete-page-DLohaU-U.cjs → delete-page-BNZclrjF.cjs} +1 -1
  27. package/dist/{delete-page-C99K2qzS.js → delete-page-BYh290jY.js} +1 -1
  28. package/dist/{digital-asset-manager-BZMb6sC7.js → digital-asset-manager-BINMP8H4.js} +1 -1
  29. package/dist/{digital-asset-manager-Z5aJxkq0.cjs → digital-asset-manager-DnNRvKt8.cjs} +1 -1
  30. package/dist/{duplicate-page-CDc2X0eW.js → duplicate-page-B_j9rgxU.js} +1 -1
  31. package/dist/{duplicate-page-D5Gtvqdv.cjs → duplicate-page-DgxKd840.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-DvNBXo6o.js → dynamic-page-selector-B2HE4wRM.js} +1 -1
  33. package/dist/{dynamic-page-selector-DZHhX008.cjs → dynamic-page-selector-CDuWB_Yw.cjs} +1 -1
  34. package/dist/{index-BVwFJWDq.cjs → index-CzBSRTj0.cjs} +3 -3
  35. package/dist/{index-LBTm1Jmk.js → index-nzqILA37.js} +17 -17
  36. package/dist/{json-diff-viewer-Cb1CmRqP.cjs → json-diff-viewer-3C7leKFH.cjs} +1 -1
  37. package/dist/{json-diff-viewer-DG6qMOBS.js → json-diff-viewer-CMw5W_Li.js} +1 -1
  38. package/dist/{lang-panel-DxoJ0v4y.cjs → lang-panel-DIdkbjDj.cjs} +1 -1
  39. package/dist/{lang-panel-B3USOxGq.js → lang-panel-S3dD5t_t.js} +2 -2
  40. package/dist/{mark-as-template-B9yLcasI.cjs → mark-as-template-6kAFYYpY.cjs} +1 -1
  41. package/dist/{mark-as-template-CP_F9ZQ4.js → mark-as-template-BP6ltrws.js} +1 -1
  42. package/dist/{no-language-page-content-C-MCdPXt.cjs → no-language-page-content-HjxRSjI0.cjs} +1 -1
  43. package/dist/{no-language-page-content-D8t5dfgh.js → no-language-page-content-MPJjIXir.js} +1 -1
  44. package/dist/{no-language-page-dialog-D4QIAHnE.cjs → no-language-page-dialog-CoRH5H9v.cjs} +1 -1
  45. package/dist/{no-language-page-dialog-C_fHI2zI.js → no-language-page-dialog-D06JM3cU.js} +2 -2
  46. package/dist/{page-creator-DKEkuGCO.js → page-creator-Cu6i7LZ1.js} +134 -134
  47. package/dist/page-creator-QCmVlpyE.cjs +1 -0
  48. package/dist/{page-lock-DdCvtA-I.cjs → page-lock-D5BkmYCP.cjs} +1 -1
  49. package/dist/{page-lock-CwZKJ4IE.js → page-lock-csXU_vk5.js} +2 -2
  50. package/dist/{page-locked-dialog-CrTDBoC4.cjs → page-locked-dialog-BfmE52P5.cjs} +1 -1
  51. package/dist/{page-locked-dialog-DqLlooUz.js → page-locked-dialog-o9eCXo2g.js} +1 -1
  52. package/dist/{page-manager-new-ttsrxdW9.js → page-manager-new-CwYu8Am_.js} +2 -2
  53. package/dist/{page-manager-new-ah6QYar2.cjs → page-manager-new-KUeOWmce.cjs} +1 -1
  54. package/dist/{page-manager-search-and-filter-D7AupT6_.cjs → page-manager-search-and-filter-BE7w_2hv.cjs} +1 -1
  55. package/dist/{page-manager-search-and-filter-bsqZ6wnI.js → page-manager-search-and-filter-BwxrJZgv.js} +1 -1
  56. package/dist/{page-revisions-content-C5O8_Fms.js → page-revisions-content-DmXFnqRE.js} +2 -2
  57. package/dist/{page-revisions-content-B6hsIla7.cjs → page-revisions-content-qIljNtcN.cjs} +1 -1
  58. package/dist/pages.cjs +1 -1
  59. package/dist/pages.js +1 -1
  60. package/dist/{publish-pages-content-KZVMHT6V.js → publish-pages-content-BmaVd0qz.js} +2 -2
  61. package/dist/{publish-pages-content-BrajJUcP.cjs → publish-pages-content-gMEMzV-_.cjs} +1 -1
  62. package/dist/{save-to-lib-DMnv7ENo.js → save-to-lib-CPqQG37K.js} +1 -1
  63. package/dist/{save-to-lib-Dc700Aop.cjs → save-to-lib-DMPQDhKe.cjs} +1 -1
  64. package/dist/{selected-block-display-CidmQ-wz.js → selected-block-display-C7iOI7Wd.js} +1 -1
  65. package/dist/{selected-block-display-CAFEOrLV.cjs → selected-block-display-CSYAaqzP.cjs} +1 -1
  66. package/dist/{seo-panel-CMY-adM-.cjs → seo-panel-CgDo_uDs.cjs} +1 -1
  67. package/dist/{seo-panel-Br8gxDxu.js → seo-panel-DUVBUbG3.js} +1 -1
  68. package/dist/{shared-json-ld-CMH-eRUq.cjs → shared-json-ld-Clk0cKIp.cjs} +1 -1
  69. package/dist/{shared-json-ld-uvMmwCYp.js → shared-json-ld-nS_mdAYR.js} +1 -1
  70. package/dist/{take-over-request-KdR1_h_K.js → take-over-request-Bjyi22us.js} +1 -1
  71. package/dist/{take-over-request-IRLgF1dG.cjs → take-over-request-GdscXVYh.cjs} +1 -1
  72. package/dist/{unmark-as-template-C5ovsEBP.js → unmark-as-template-BStQtwjr.js} +1 -1
  73. package/dist/{unmark-as-template-F7TdgWjI.cjs → unmark-as-template-D_-Bbbl_.cjs} +1 -1
  74. package/dist/{unpublish-page-CUr8Xub6.cjs → unpublish-page-CGZWa57H.cjs} +1 -1
  75. package/dist/{unpublish-page-0fR1o0b7.js → unpublish-page-Dsqk_IA1.js} +1 -1
  76. package/dist/{web-preview-D9pXonAv.js → web-preview-_TrLPhaZ.js} +1 -1
  77. package/dist/{web-preview-CuMYekVJ.cjs → web-preview-e2NMKzzH.cjs} +1 -1
  78. package/package.json +1 -1
  79. package/dist/page-creator-Cz_ah-qE.cjs +0 -1
@@ -1,7 +1,7 @@
1
1
  var xs = Object.defineProperty;
2
2
  var $s = (e, t, n) => t in e ? xs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Re = (e, t, n) => $s(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { y as $e, z as B, C as ft, D as H, w as P, x as m, F as No, G as ve, S as K, H as _, I as k, J as U, K as F, M as Cs, N as ur, O as Ce, Q as V, R as Qn, U as Yn, V as gt, W as T, X as Ss, Y as Ut, Z as _t, _ as qe, $ as ks, a0 as Rt, a1 as Bt, a2 as Es, a3 as Ds, a4 as En, a5 as As, a6 as Ht, a7 as Ho, a8 as Ms, a9 as Ts, aa as W, ab as Vr, ac as Fs, ad as Is, ae as cr, af as Os, ag as Ls, ah as Hn, ai as Ps, aj as qs, ak as ie, al as _s, am as Rs } from "./index-LBTm1Jmk.js";
4
+ import { y as $e, z as B, C as ft, D as H, w as P, x as m, F as No, G as ve, S as K, H as _, I as k, J as U, K as F, M as Cs, N as ur, O as Ce, Q as V, R as Qn, U as Yn, V as gt, W as T, X as Ss, Y as Ut, Z as _t, _ as qe, $ as ks, a0 as Rt, a1 as Bt, a2 as Es, a3 as Ds, a4 as En, a5 as As, a6 as Ht, a7 as Ho, a8 as Ms, a9 as Ts, aa as W, ab as Vr, ac as Fs, ad as Is, ae as cr, af as Os, ag as Ls, ah as Hn, ai as Ps, aj as qs, ak as ie, al as _s, am as Rs } from "./index-nzqILA37.js";
5
5
  var zs = (e) => e != null, Ks = (e) => e.filter(zs);
6
6
  function Bs(e) {
7
7
  return (...t) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AP7HFJJL-DYFttFoI.cjs"),t=require("./index-BVwFJWDq.cjs");var s=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),a=t.getPreferredColorScheme(),l=t.createMemo(()=>{const c=o.theme||r.theme_preference||e.THEME_PREFERENCE;return c!=="system"?c:a()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:l,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:n})}})}})}})},u=s;exports.default=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AP7HFJJL-BWwvxG86.cjs"),t=require("./index-CzBSRTj0.cjs");var s=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),a=t.getPreferredColorScheme(),l=t.createMemo(()=>{const c=o.theme||r.theme_preference||e.THEME_PREFERENCE;return c!=="system"?c:a()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:l,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:n})}})}})}})},u=s;exports.default=u;
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as v, D as u, Q as i } from "./AP7HFJJL-q4dJdyFs.js";
2
- import { v as d, w as f, x as e } from "./index-LBTm1Jmk.js";
1
+ import { c, T as l, P as m, a as v, D as u, Q as i } from "./AP7HFJJL-DlUIW-7z.js";
2
+ import { v as d, w as f, x as e } from "./index-nzqILA37.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { J as i, K as o, M as l, O as c, Q as d } from "./index-OuHV9Ann.js";
4
- import { an as m, a as h, B as u, E as p, P as N } from "./index-LBTm1Jmk.js";
4
+ import { an as m, a as h, B as u, E as p, P as N } from "./index-nzqILA37.js";
5
5
  import { TableIcon as f, Edit as T } from "lucide-react";
6
6
  import { useTranslation as E } from "react-i18next";
7
7
  const b = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-DCJDQs1a.cjs"),s=require("./index-BVwFJWDq.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:a}=l.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(n.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:a("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("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(c.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(n.Edit,{className:"h-4 w-4"}),a("Continue Editing Here")]})})]})})};exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-DCJDQs1a.cjs"),s=require("./index-CzBSRTj0.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:a}=l.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(n.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:a("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("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(c.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(n.Edit,{className:"h-4 w-4"}),a("Continue Editing Here")]})})]})})};exports.default=o;
@@ -2,7 +2,7 @@ import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
2
2
  import { z as fn, D as H, B as gn } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { d as mn, n as xn, D as vn, e as pn, f as Sn, g as Nn, o as Fn, p as I, q as wn } from "./index-OuHV9Ann.js";
4
4
  import { p as An, r as Cn, S as Dn } from "./slug-input-DLWTMTsO.js";
5
- import { e as En, f as $n, g as Ln, h as kn, i as Tn, j as Z, k as Un, c as Bn, L as A } from "./index-LBTm1Jmk.js";
5
+ import { e as En, f as $n, g as Ln, h as kn, i as Tn, j as Z, k as Un, c as Bn, L as A } from "./index-nzqILA37.js";
6
6
  import { filter as Rn, find as Wn, startsWith as In } from "lodash-es";
7
7
  import { Loader as qn } from "lucide-react";
8
8
  import { useMemo as $, useState as L, useEffect as _ } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-DCJDQs1a.cjs"),Y=require("./slug-input-CiHC5l3r.cjs"),g=require("./index-BVwFJWDq.cjs"),j=require("lodash-es"),ds=require("lucide-react"),v=require("react"),U=require("react-i18next"),Z=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.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&&(j.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))]})]})},_=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(k.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})]})},cs=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:S,getSlug:f})=>{const{t:r}=U.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(N.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(N.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(k.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(Y.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:S,fullSlug:f()})]})},H=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:S,isPending:f})=>{const{t:r}=U.useTranslation(),A=f||!h||!a||s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)||!l&&!(x&&d)&&(!S||!u);return e.jsx(N.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(k.Button,{type:"submit",disabled:A&&!o.dynamic,children:f?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(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.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(k.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.")]})})})},rs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,slug:A,isSlugValid:m,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(_,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(H,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,isSlugValid:m,isPending:p})]}),hs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:S,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M,isPending:$,id:q,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(ds.Loader,{className:"animate-spin"})}):d?e.jsx(rs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:q,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,slug:p,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(_,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(cs,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:S,lang:u,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M})]}),e.jsx(H,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:q,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,isSlugValid:T,isPending:$})]}),xs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePrimaryPages(),s=v.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=v.useState(""),[d,S]=v.useState(""),[f,r]=v.useState(""),[A,m]=v.useState(!0),[p,C]=v.useState(!0),{mutate:T,isPending:I}=g.useCreatePage(),{mutate:M,isPending:$}=g.useUpdatePage(),q=I||$,{data:L,isFetching:b}=g.useWebsiteSetting(),z=g.useFallbackLang(),{data:w,isFetching:y}=g.useLanguagePages(u),{data:F=[],isFetching:P}=g.useLanguagePages(s==null?void 0:s.parent),{data:J=[],isFetching:O}=g.usePageTypes(),{setSelectedLang:ss}=N.useLanguages(),{t:B}=U.useTranslation(),[,es]=g.useSearchParams(),[,ns]=N.useSidebarActivePanel(),ts=b||y||P||O,G=v.useMemo(()=>j.filter(L==null?void 0:L.languages,n=>!j.find(w,{lang:n})),[L,w]),W=v.useMemo(()=>J.find(n=>n.key===(s==null?void 0:s.pageType)),[J,s==null?void 0:s.pageType]),K=!(W!=null&&W.hasSlug),V=(s==null?void 0:s.slug)==="/";v.useEffect(()=>{if(!t&&s&&i&&(S(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(is=>is.id===c);if(!n)return;x(n.name),S(n.lang);const E=n.slug||"",{initSlug:R,prefix:us}=Y.parseSlugForEdit(E,s);r(R),C(us)},[t,c,w,s,i]),v.useEffect(()=>{if(i)S(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;S(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:Q,isRootPage:D}=v.useMemo(()=>{if(V||!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,V]),os=v.useMemo(()=>D?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,D]),X=()=>{let n="";return D?n=`/${p?[d,f].filter(Boolean).join("/"):f}`:n=`${Y.removeSlugExtension(Q)}/${f}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ls=n=>{const E=new URLSearchParams(window.location.search);z&&n===z?E.delete("lang"):E.set("lang",n),es(E),window.dispatchEvent(new PopStateEvent("popstate"))},as=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:K?"":X(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(ss(d),ls(d)),ns("outline"),a()};t?M(E,{onSuccess:R}):T(E,{onSuccess:R})};return e.jsx(N.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(N.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(N.DialogHeader,{children:[e.jsx(N.DialogTitle,{children:B(t?"Edit language":"Add new language page")}),e.jsx(N.DialogDescription,{className:"font-light",children:B("Enter the details for the language")})]}),e.jsx(hs,{id:c,pages:o,loading:ts,onSubmit:as,edit:t,lang:d,languages:G,name:l,setLang:S,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:os,isNonSlugPageType:K,isRootPage:D,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:V,parentSlug:Q,slug:f,setSlug:r,isSlugValid:A,setIsSlugValid:m,getSlug:X,isPending:q})]})})};exports.default=xs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-DCJDQs1a.cjs"),Y=require("./slug-input-CiHC5l3r.cjs"),g=require("./index-CzBSRTj0.cjs"),j=require("lodash-es"),ds=require("lucide-react"),v=require("react"),U=require("react-i18next"),Z=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.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&&(j.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))]})]})},_=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(k.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})]})},cs=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:S,getSlug:f})=>{const{t:r}=U.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(N.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(N.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(k.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(Y.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:S,fullSlug:f()})]})},H=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:S,isPending:f})=>{const{t:r}=U.useTranslation(),A=f||!h||!a||s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)||!l&&!(x&&d)&&(!S||!u);return e.jsx(N.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(k.Button,{type:"submit",disabled:A&&!o.dynamic,children:f?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(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.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(k.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.")]})})})},rs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,slug:A,isSlugValid:m,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(_,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(H,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,isSlugValid:m,isPending:p})]}),hs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:S,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M,isPending:$,id:q,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(ds.Loader,{className:"animate-spin"})}):d?e.jsx(rs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:q,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,slug:p,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(_,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(cs,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:S,lang:u,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M})]}),e.jsx(H,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:q,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,isSlugValid:T,isPending:$})]}),xs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePrimaryPages(),s=v.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=v.useState(""),[d,S]=v.useState(""),[f,r]=v.useState(""),[A,m]=v.useState(!0),[p,C]=v.useState(!0),{mutate:T,isPending:I}=g.useCreatePage(),{mutate:M,isPending:$}=g.useUpdatePage(),q=I||$,{data:L,isFetching:b}=g.useWebsiteSetting(),z=g.useFallbackLang(),{data:w,isFetching:y}=g.useLanguagePages(u),{data:F=[],isFetching:P}=g.useLanguagePages(s==null?void 0:s.parent),{data:J=[],isFetching:O}=g.usePageTypes(),{setSelectedLang:ss}=N.useLanguages(),{t:B}=U.useTranslation(),[,es]=g.useSearchParams(),[,ns]=N.useSidebarActivePanel(),ts=b||y||P||O,G=v.useMemo(()=>j.filter(L==null?void 0:L.languages,n=>!j.find(w,{lang:n})),[L,w]),W=v.useMemo(()=>J.find(n=>n.key===(s==null?void 0:s.pageType)),[J,s==null?void 0:s.pageType]),K=!(W!=null&&W.hasSlug),V=(s==null?void 0:s.slug)==="/";v.useEffect(()=>{if(!t&&s&&i&&(S(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(is=>is.id===c);if(!n)return;x(n.name),S(n.lang);const E=n.slug||"",{initSlug:R,prefix:us}=Y.parseSlugForEdit(E,s);r(R),C(us)},[t,c,w,s,i]),v.useEffect(()=>{if(i)S(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;S(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:Q,isRootPage:D}=v.useMemo(()=>{if(V||!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,V]),os=v.useMemo(()=>D?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,D]),X=()=>{let n="";return D?n=`/${p?[d,f].filter(Boolean).join("/"):f}`:n=`${Y.removeSlugExtension(Q)}/${f}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ls=n=>{const E=new URLSearchParams(window.location.search);z&&n===z?E.delete("lang"):E.set("lang",n),es(E),window.dispatchEvent(new PopStateEvent("popstate"))},as=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:K?"":X(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(ss(d),ls(d)),ns("outline"),a()};t?M(E,{onSuccess:R}):T(E,{onSuccess:R})};return e.jsx(N.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(N.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(N.DialogHeader,{children:[e.jsx(N.DialogTitle,{children:B(t?"Edit language":"Add new language page")}),e.jsx(N.DialogDescription,{className:"font-light",children:B("Enter the details for the language")})]}),e.jsx(hs,{id:c,pages:o,loading:ts,onSubmit:as,edit:t,lang:d,languages:G,name:l,setLang:S,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:os,isNonSlugPageType:K,isRootPage:D,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:V,parentSlug:Q,slug:f,setSlug:r,isSlugValid:A,setIsSlugValid:m,getSlug:X,isPending:q})]})})};exports.default=xs;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DCJDQs1a.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-Cz_ah-qE.cjs"))),x=({addEditPage:n,setAddEditPage:r,closePanel:l})=>{const{t:o}=a.useTranslation(),t=!!(n!=null&&n.id),i=!!n;return e.jsx(s.Dialog,{open:i,onOpenChange:()=>r(void 0),children:i&&e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{children:[o(t?"Edit":"Add New")," "]}),e.jsx(s.DialogDescription,{children:o(t?"Update your page name":"Enter details to create a new page")})]}),e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:l,addEditPage:n,close:()=>r(void 0)})})]})})};exports.default=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DCJDQs1a.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-QCmVlpyE.cjs"))),x=({addEditPage:n,setAddEditPage:r,closePanel:l})=>{const{t:o}=a.useTranslation(),t=!!(n!=null&&n.id),i=!!n;return e.jsx(s.Dialog,{open:i,onOpenChange:()=>r(void 0),children:i&&e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{children:[o(t?"Edit":"Add New")," "]}),e.jsx(s.DialogDescription,{children:o(t?"Update your page name":"Enter details to create a new page")})]}),e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:l,addEditPage:n,close:()=>r(void 0)})})]})})};exports.default=x;
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
2
  import { D as t, e as c, f as m, g as p, o as h } from "./index-OuHV9Ann.js";
3
3
  import { Suspense as f, lazy as D } from "react";
4
4
  import { useTranslation as u } from "react-i18next";
5
- const x = D(() => import("./page-creator-DKEkuGCO.js")), C = ({
5
+ const x = D(() => import("./page-creator-Cu6i7LZ1.js")), C = ({
6
6
  addEditPage: o,
7
7
  setAddEditPage: s,
8
8
  closePanel: l
@@ -1,10 +1,10 @@
1
1
  import { jsxs as R, Fragment as X, jsx as m } from "react/jsx-runtime";
2
2
  import { ab as Y, ac as Z, ad as tt, r as et, a as nt, ae as rt } from "./index-OuHV9Ann.js";
3
- import { C as st, a as ot, b as at, R as it, c as ct, d as lt, T as ut, M as dt, e as mt, f as ft, h as pt, S as ht, i as gt } from "./selected-block-display-CidmQ-wz.js";
3
+ import { C as st, a as ot, b as at, R as it, c as ct, d as lt, T as ut, M as dt, e as mt, f as ft, h as pt, S as ht, i as gt } from "./selected-block-display-C7iOI7Wd.js";
4
4
  import { Bot as At } from "lucide-react";
5
5
  import { useCallback as kt, Fragment as yt, Suspense as It, lazy as bt, startTransition as Q } from "react";
6
6
  import { toast as St } from "sonner";
7
- import { l as Ct, m as Et } from "./index-LBTm1Jmk.js";
7
+ import { l as Ct, m as Et } from "./index-nzqILA37.js";
8
8
  import { g as U } from "./apply-binding-vAuN-TGV.js";
9
9
  import { useQueryClient as vt } from "@tanstack/react-query";
10
10
  const wt = () => {
@@ -199,7 +199,7 @@ const wt = () => {
199
199
  },
200
200
  [b]
201
201
  );
202
- }, Bt = bt(() => import("./ai-prompt-input-7iWk72w5.js")), Ft = ({
202
+ }, Bt = bt(() => import("./ai-prompt-input-p5KHwgCW.js")), Ft = ({
203
203
  t: I,
204
204
  fetch: F,
205
205
  input: b,
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),T=require("./index-DCJDQs1a.cjs"),p=require("./selected-block-display-CAFEOrLV.cjs"),Z=require("lucide-react"),C=require("react"),ee=require("sonner"),J=require("./index-BVwFJWDq.cjs"),X=require("./apply-binding-CBSjMYSk.cjs"),te=require("@tanstack/react-query"),ne=()=>{const{addPredefinedBlock:b}=T.useAddBlock(),W=T.useReplaceBlock(),S=T.useRemoveBlocks(),N=te.useQueryClient(),H=async(o,n)=>{if(!n)return;const t=X.getBlocksFromHTML(n);await b(t,o.parentId,o.position)},w=async(o,n)=>{if(!o.blockId||!n)return;const t=X.getBlocksFromHTML(n);await W(o.blockId,t)},x=async o=>{!o.ids||o.ids.length===0||await S(o.ids)};let m=null;const q=(o,n)=>{const t=document.getElementById("canvas-iframe");if(!t)return null;const u=t==null?void 0:t.contentDocument;if(!u)return null;u.querySelectorAll("[data-stream-canvas]").forEach(f=>f.remove());let s=null;if(o&&o!=="undefined"&&(s=u.querySelector(`[data-block-id="${o}"]`)),s||(s=u.body),!s)return null;if(m=u.createElement("div"),m.setAttribute("data-stream-canvas","true"),n!==void 0&&n>=0&&s.children){const f=Math.min(n,s.children.length);f<s.children.length?s.insertBefore(m,s.children[f]):s.appendChild(m)}else s.appendChild(m);return m},F=o=>{var s;const n=document.getElementById("canvas-iframe");if(!n)return null;const t=n==null?void 0:n.contentDocument;if(!t)return null;t.querySelectorAll("[data-stream-canvas]").forEach(f=>f.remove());const d=t.querySelector(`[data-block-id="${o}"]`);return d?(m=t.createElement("div"),m.setAttribute("data-stream-canvas","true"),(s=d.parentNode)==null||s.insertBefore(m,d.nextSibling),d.style.display="none",m):null},L=o=>{const n=document.getElementById("canvas-iframe");(n==null?void 0:n.contentWindow)&&o.scrollIntoView({behavior:"smooth",block:"end"})},M=(o,n,t)=>{const u=q(n,t);u&&(u.innerHTML=o,L(u))},D=(o,n)=>{const t=F(n);t&&(t.innerHTML=o,L(t))},O=o=>{const n=o.match(/^--ACTION=(.+)--$/);if(!n)return null;let u=n[1].replace(/--/g,"").split("|");const s={type:u[0]};return u.forEach(f=>{const e=f.trim();if(e.startsWith("PARENT=")){const A=e.substring(7);s.parentId=A==="undefined"?void 0:A}else e.startsWith("POS=")?s.position=parseInt(e.substring(4)):e.startsWith("ID=")?s.blockId=e.substring(3):e.startsWith("IDS=")&&(s.ids=e.substring(4).split(",").map(A=>A.trim()))}),s};return C.useCallback(async(o,n)=>{const t=new TextDecoder;let u="",d="",s=!1,f=null;const e={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async r=>{const i=r.trim();if(i==="--START--"){s=!0;return}if(s){if(i==="--END--"){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),m&&(m.remove(),m=null);return}if(i.startsWith("--THINKING=")){const a=i.substring(11);n(l=>{const h=[...l],g=h[h.length-1];if(g&&g.role==="assistant"&&g.isReasoning)g.content=a,g.isStreaming=!1;else{const $={id:Date.now().toString(),role:"assistant",content:a,isReasoning:!0,isStreaming:!1};h.push($)}return h});return}if(i.startsWith("--TASK=")){const a=i.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:l,role:"assistant",content:a.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};f=l,n(g=>[...g,h]);return}if(i.startsWith("--MSG=")){const a=i.substring(6),l={id:Date.now().toString(),role:"assistant",content:a.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};n(h=>[...h,l]);return}if(i.startsWith("--ACTION=")){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),e.currentAction=O(i),e.htmlBuffer="",e.isInAction=!0;return}if(i==="--ENDACTION--"){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),f&&(n(a=>a.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),f=null),e.currentAction=null,e.htmlBuffer="",e.isInAction=!1;return}if(i==="--HTML--"){e.isCapturingHtml=!0;return}if(i==="--ENDHTML--"){e.isCapturingHtml=!1;return}if(i.startsWith("--HTML--")&&i.includes("--ENDHTML--")){const a=i.match(/^--HTML--(.+?)--ENDHTML--$/);if(a&&e.currentAction){const l=a[1];e.htmlBuffer+=l,e.currentAction.type==="ADD"?M(e.htmlBuffer,e.currentAction.parentId,e.currentAction.position):e.currentAction.type==="EDIT"&&e.currentAction.blockId&&D(e.htmlBuffer,e.currentAction.blockId)}return}e.isCapturingHtml&&e.currentAction&&(e.htmlBuffer+=r+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),T=require("./index-DCJDQs1a.cjs"),p=require("./selected-block-display-CSYAaqzP.cjs"),Z=require("lucide-react"),C=require("react"),ee=require("sonner"),J=require("./index-CzBSRTj0.cjs"),X=require("./apply-binding-CBSjMYSk.cjs"),te=require("@tanstack/react-query"),ne=()=>{const{addPredefinedBlock:b}=T.useAddBlock(),W=T.useReplaceBlock(),S=T.useRemoveBlocks(),N=te.useQueryClient(),H=async(o,n)=>{if(!n)return;const t=X.getBlocksFromHTML(n);await b(t,o.parentId,o.position)},w=async(o,n)=>{if(!o.blockId||!n)return;const t=X.getBlocksFromHTML(n);await W(o.blockId,t)},x=async o=>{!o.ids||o.ids.length===0||await S(o.ids)};let m=null;const q=(o,n)=>{const t=document.getElementById("canvas-iframe");if(!t)return null;const u=t==null?void 0:t.contentDocument;if(!u)return null;u.querySelectorAll("[data-stream-canvas]").forEach(f=>f.remove());let s=null;if(o&&o!=="undefined"&&(s=u.querySelector(`[data-block-id="${o}"]`)),s||(s=u.body),!s)return null;if(m=u.createElement("div"),m.setAttribute("data-stream-canvas","true"),n!==void 0&&n>=0&&s.children){const f=Math.min(n,s.children.length);f<s.children.length?s.insertBefore(m,s.children[f]):s.appendChild(m)}else s.appendChild(m);return m},F=o=>{var s;const n=document.getElementById("canvas-iframe");if(!n)return null;const t=n==null?void 0:n.contentDocument;if(!t)return null;t.querySelectorAll("[data-stream-canvas]").forEach(f=>f.remove());const d=t.querySelector(`[data-block-id="${o}"]`);return d?(m=t.createElement("div"),m.setAttribute("data-stream-canvas","true"),(s=d.parentNode)==null||s.insertBefore(m,d.nextSibling),d.style.display="none",m):null},L=o=>{const n=document.getElementById("canvas-iframe");(n==null?void 0:n.contentWindow)&&o.scrollIntoView({behavior:"smooth",block:"end"})},M=(o,n,t)=>{const u=q(n,t);u&&(u.innerHTML=o,L(u))},D=(o,n)=>{const t=F(n);t&&(t.innerHTML=o,L(t))},O=o=>{const n=o.match(/^--ACTION=(.+)--$/);if(!n)return null;let u=n[1].replace(/--/g,"").split("|");const s={type:u[0]};return u.forEach(f=>{const e=f.trim();if(e.startsWith("PARENT=")){const A=e.substring(7);s.parentId=A==="undefined"?void 0:A}else e.startsWith("POS=")?s.position=parseInt(e.substring(4)):e.startsWith("ID=")?s.blockId=e.substring(3):e.startsWith("IDS=")&&(s.ids=e.substring(4).split(",").map(A=>A.trim()))}),s};return C.useCallback(async(o,n)=>{const t=new TextDecoder;let u="",d="",s=!1,f=null;const e={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async r=>{const i=r.trim();if(i==="--START--"){s=!0;return}if(s){if(i==="--END--"){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),m&&(m.remove(),m=null);return}if(i.startsWith("--THINKING=")){const a=i.substring(11);n(l=>{const h=[...l],g=h[h.length-1];if(g&&g.role==="assistant"&&g.isReasoning)g.content=a,g.isStreaming=!1;else{const $={id:Date.now().toString(),role:"assistant",content:a,isReasoning:!0,isStreaming:!1};h.push($)}return h});return}if(i.startsWith("--TASK=")){const a=i.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:l,role:"assistant",content:a.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};f=l,n(g=>[...g,h]);return}if(i.startsWith("--MSG=")){const a=i.substring(6),l={id:Date.now().toString(),role:"assistant",content:a.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};n(h=>[...h,l]);return}if(i.startsWith("--ACTION=")){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),e.currentAction=O(i),e.htmlBuffer="",e.isInAction=!0;return}if(i==="--ENDACTION--"){e.currentAction&&(e.htmlBuffer||e.currentAction.type==="REMOVE")&&await R(e.currentAction,e.htmlBuffer),f&&(n(a=>a.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),f=null),e.currentAction=null,e.htmlBuffer="",e.isInAction=!1;return}if(i==="--HTML--"){e.isCapturingHtml=!0;return}if(i==="--ENDHTML--"){e.isCapturingHtml=!1;return}if(i.startsWith("--HTML--")&&i.includes("--ENDHTML--")){const a=i.match(/^--HTML--(.+?)--ENDHTML--$/);if(a&&e.currentAction){const l=a[1];e.htmlBuffer+=l,e.currentAction.type==="ADD"?M(e.htmlBuffer,e.currentAction.parentId,e.currentAction.position):e.currentAction.type==="EDIT"&&e.currentAction.blockId&&D(e.htmlBuffer,e.currentAction.blockId)}return}e.isCapturingHtml&&e.currentAction&&(e.htmlBuffer+=r+`
2
2
  `,e.currentAction.type==="ADD"?M(e.htmlBuffer,e.currentAction.parentId,e.currentAction.position):e.currentAction.type==="EDIT"&&e.currentAction.blockId&&D(e.htmlBuffer,e.currentAction.blockId))}},R=async(r,i)=>{try{switch(r.type){case"ADD":await H(r,i);break;case"EDIT":await w(r,i);break;case"REMOVE":await x(r);break}n(a=>a.filter(l=>!l.isTask))}catch(a){console.log(a)}};try{for(;;){const{done:r,value:i}=await o.read();if(r)break;const a=t.decode(i,{stream:!0});u+=a,d+=a;const l=d.split(`
3
- `);d=l.pop()||"";for(const h of l)await A(h)}d&&await A(d),N.invalidateQueries({queryKey:["AI_USAGE"]})}catch(r){console.log(r)}},[S])},re=C.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-nZ5_Dm7X.cjs"))),se=({t:b,fetch:W,input:S,messages:N,setInput:H,isLoading:w,setMessages:x,handleStop:m,setIsLoading:q,currentBlock:F,fallbackLang:L,setCurrentBlock:M,setAbortController:D,selectedModel:O,onModelChange:o})=>{const{models:n}=J.useAIModels(),t=J.useAIConfig(),u=n.find(r=>r.id==="google/gemini-3-flash")||n[0],d=O||u.id,s=T.useSelectedBlock(),[,f]=T.useSelectedBlockIds(),e=T.useBlocksHtmlForAi(),A=ne(),R=async(r,i,a,l)=>{var _,K;if(!r||w)return;M(s);const h=e(s?{blockId:s._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(s&&!h){ee.toast.error(b("Something went wrong. Please try again."));return}const g={id:Date.now().toString(),role:"user",content:p.getUserPrompt({language:L,userInput:i||r,currentHtml:h}),userMessage:r},$={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};x(k=>[...k,g,$]),q(!0);const Y=new AbortController;D(Y);const v=l||d;(_=t.onAIEvent)==null||_.call(t,{type:"stream_start",model:v,timestamp:Date.now()});try{const k={messages:[g].map(y=>({role:y.role,content:y.content})),model:l||d,context:t.context};a&&(k.image=a);const P=await W({body:{action:"ASK_AI",data:k},streamResponse:!0});if(!P.ok)throw new Error(b("Failed to get AI response"));const I=(K=P.body)==null?void 0:K.getReader();if(!I)throw new Error(b("Response body is not readable"));await A(I,x),x(y=>(C.startTransition(()=>{var G,Q,z,U;const j=y.filter(V=>V.role==="assistant"&&!V.isReasoning&&!V.isTask),B=((G=j[j.length-1])==null?void 0:G.content)||"",E=Date.now();(Q=t.onSuccess)==null||Q.call(t,{content:B,model:v,timestamp:E}),(z=t.onComplete)==null||z.call(t,{success:!0,content:B,model:v,timestamp:E}),(U=t.onAIEvent)==null||U.call(t,{type:"completion",content:B,model:v,timestamp:E})}),y))}catch(k){if(k.name!=="AbortError"){const P={id:(Date.now()+1).toString(),role:"assistant",content:b("Sorry, I encountered an error. Please try again.")};x(I=>[...I,P]),C.startTransition(()=>{var j,B,E;const I=k instanceof Error?k.message:String(k),y=Date.now();(j=t.onError)==null||j.call(t,{error:I,model:v,timestamp:y}),(B=t.onComplete)==null||B.call(t,{success:!1,error:I,model:v,timestamp:y}),(E=t.onAIEvent)==null||E.call(t,{type:"error",error:I,model:v,timestamp:y})})}}finally{H(""),q(!1),M(null),D(null)}};return c.jsxs(c.Fragment,{children:[c.jsxs(p.Conversation,{className:"no-scrollbar",children:[c.jsxs(p.ConversationContent,{className:"gap-2 px-0",children:[N.length===0&&c.jsx(p.ConversationEmptyState,{icon:c.jsx(Z.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:b("Start a conversation with the AI assistant to add/edit current page")}),N.map(r=>r.role!=="system"&&c.jsx(C.Fragment,{children:r.isReasoning?c.jsxs(p.Reasoning,{isStreaming:r.isStreaming,defaultOpen:!0,children:[c.jsx(p.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),c.jsx(p.ReasoningContent,{className:"p-0 text-xs",children:r.content})]}):r.isTask&&!r.isTaskCompleted?c.jsx(p.TaskMessage,{content:r.content,isLoading:r.isTaskLoading}):c.jsx(p.Message,{from:r.role,children:c.jsx(p.MessageContent,{className:"p-0",children:r.role==="assistant"?c.jsx(p.MessageResponse,{className:"p-0 text-xs",children:r.content}):c.jsx("div",{className:"p-0 text-xs",children:r.userMessage||r.content})})})},r.id))]}),c.jsx(p.ConversationScrollButton,{})]}),c.jsxs("div",{className:"border-gray-200 pb-2",children:[c.jsx(p.SelectedBlockDisplay,{onRemove:()=>f([]),isLoading:w}),c.jsx(C.Suspense,{fallback:c.jsx("div",{children:"Loading..."}),children:c.jsx(re,{input:S,setInput:H,onSend:R,onStop:m,isLoading:w,selectedLang:"",currentBlock:s||F,disabled:(S==null?void 0:S.length)===0,selectedModel:d,onModelChange:o})})]})]})};exports.default=se;
3
+ `);d=l.pop()||"";for(const h of l)await A(h)}d&&await A(d),N.invalidateQueries({queryKey:["AI_USAGE"]})}catch(r){console.log(r)}},[S])},re=C.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-SJnya_UU.cjs"))),se=({t:b,fetch:W,input:S,messages:N,setInput:H,isLoading:w,setMessages:x,handleStop:m,setIsLoading:q,currentBlock:F,fallbackLang:L,setCurrentBlock:M,setAbortController:D,selectedModel:O,onModelChange:o})=>{const{models:n}=J.useAIModels(),t=J.useAIConfig(),u=n.find(r=>r.id==="google/gemini-3-flash")||n[0],d=O||u.id,s=T.useSelectedBlock(),[,f]=T.useSelectedBlockIds(),e=T.useBlocksHtmlForAi(),A=ne(),R=async(r,i,a,l)=>{var _,K;if(!r||w)return;M(s);const h=e(s?{blockId:s._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(s&&!h){ee.toast.error(b("Something went wrong. Please try again."));return}const g={id:Date.now().toString(),role:"user",content:p.getUserPrompt({language:L,userInput:i||r,currentHtml:h}),userMessage:r},$={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};x(k=>[...k,g,$]),q(!0);const Y=new AbortController;D(Y);const v=l||d;(_=t.onAIEvent)==null||_.call(t,{type:"stream_start",model:v,timestamp:Date.now()});try{const k={messages:[g].map(y=>({role:y.role,content:y.content})),model:l||d,context:t.context};a&&(k.image=a);const P=await W({body:{action:"ASK_AI",data:k},streamResponse:!0});if(!P.ok)throw new Error(b("Failed to get AI response"));const I=(K=P.body)==null?void 0:K.getReader();if(!I)throw new Error(b("Response body is not readable"));await A(I,x),x(y=>(C.startTransition(()=>{var G,Q,z,U;const j=y.filter(V=>V.role==="assistant"&&!V.isReasoning&&!V.isTask),B=((G=j[j.length-1])==null?void 0:G.content)||"",E=Date.now();(Q=t.onSuccess)==null||Q.call(t,{content:B,model:v,timestamp:E}),(z=t.onComplete)==null||z.call(t,{success:!0,content:B,model:v,timestamp:E}),(U=t.onAIEvent)==null||U.call(t,{type:"completion",content:B,model:v,timestamp:E})}),y))}catch(k){if(k.name!=="AbortError"){const P={id:(Date.now()+1).toString(),role:"assistant",content:b("Sorry, I encountered an error. Please try again.")};x(I=>[...I,P]),C.startTransition(()=>{var j,B,E;const I=k instanceof Error?k.message:String(k),y=Date.now();(j=t.onError)==null||j.call(t,{error:I,model:v,timestamp:y}),(B=t.onComplete)==null||B.call(t,{success:!1,error:I,model:v,timestamp:y}),(E=t.onAIEvent)==null||E.call(t,{type:"error",error:I,model:v,timestamp:y})})}}finally{H(""),q(!1),M(null),D(null)}};return c.jsxs(c.Fragment,{children:[c.jsxs(p.Conversation,{className:"no-scrollbar",children:[c.jsxs(p.ConversationContent,{className:"gap-2 px-0",children:[N.length===0&&c.jsx(p.ConversationEmptyState,{icon:c.jsx(Z.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:b("Start a conversation with the AI assistant to add/edit current page")}),N.map(r=>r.role!=="system"&&c.jsx(C.Fragment,{children:r.isReasoning?c.jsxs(p.Reasoning,{isStreaming:r.isStreaming,defaultOpen:!0,children:[c.jsx(p.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),c.jsx(p.ReasoningContent,{className:"p-0 text-xs",children:r.content})]}):r.isTask&&!r.isTaskCompleted?c.jsx(p.TaskMessage,{content:r.content,isLoading:r.isTaskLoading}):c.jsx(p.Message,{from:r.role,children:c.jsx(p.MessageContent,{className:"p-0",children:r.role==="assistant"?c.jsx(p.MessageResponse,{className:"p-0 text-xs",children:r.content}):c.jsx("div",{className:"p-0 text-xs",children:r.userMessage||r.content})})})},r.id))]}),c.jsx(p.ConversationScrollButton,{})]}),c.jsxs("div",{className:"border-gray-200 pb-2",children:[c.jsx(p.SelectedBlockDisplay,{onRemove:()=>f([]),isLoading:w}),c.jsx(C.Suspense,{fallback:c.jsx("div",{children:"Loading..."}),children:c.jsx(re,{input:S,setInput:H,onSend:R,onStop:m,isLoading:w,selectedLang:"",currentBlock:s||F,disabled:(S==null?void 0:S.length)===0,selectedModel:d,onModelChange:o})})]})]})};exports.default=se;
@@ -1,11 +1,11 @@
1
1
  import { jsxs as g, Fragment as L, jsx as s } from "react/jsx-runtime";
2
2
  import { r as ee, a as te, s as se, t as oe } from "./index-OuHV9Ann.js";
3
- import { C as ne, a as re, b as ae, R as le, c as ce, d as ie, T as de, M as me, e as ue, f as he, S as pe, g as Se } from "./selected-block-display-CidmQ-wz.js";
3
+ import { C as ne, a as re, b as ae, R as le, c as ce, d as ie, T as de, M as me, e as ue, f as he, S as pe, g as Se } from "./selected-block-display-C7iOI7Wd.js";
4
4
  import { Bot as ye } from "lucide-react";
5
5
  import { useRef as Te, useEffect as ke, Suspense as P, lazy as _, Fragment as ge, startTransition as F } from "react";
6
6
  import { useTranslation as fe } from "react-i18next";
7
- import { l as we, m as xe } from "./index-LBTm1Jmk.js";
8
- const Ae = _(() => import("./ai-translation-prompt-1OUs1P7n.js")), Me = _(() => import("./ai-prompt-input-7iWk72w5.js")), Ce = ({
7
+ import { l as we, m as xe } from "./index-nzqILA37.js";
8
+ const Ae = _(() => import("./ai-translation-prompt-BTEXWPQq.js")), Me = _(() => import("./ai-prompt-input-p5KHwgCW.js")), Ce = ({
9
9
  fetch: j,
10
10
  input: m,
11
11
  messages: f,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("./index-DCJDQs1a.cjs"),n=require("./selected-block-display-CAFEOrLV.cjs"),L=require("lucide-react"),r=require("react"),ee=require("react-i18next"),O=require("./index-BVwFJWDq.cjs"),te=r.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-B16cK-1Q.cjs"))),se=r.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-nZ5_Dm7X.cjs"))),ne=({fetch:_,input:x,messages:w,setInput:b,isLoading:m,handleStop:F,setMessages:A,setIsLoading:v,selectedLang:j,currentBlock:z,fallbackLang:U,abortController:R,setAbortController:J,setCurrentBlock:M,selectedModel:K,onModelChange:V})=>{const{t:l}=ee.useTranslation(),{models:N}=O.useAIModels(),s=O.useAIConfig(),W=N.find(e=>e.id==="google/gemini-3-flash")||N[0],E=K||W.id,G=r.useRef(null),p=g.useSelectedBlock(),[,H]=g.useSelectedBlockIds(),B=g.useI18nBlocks(),Q=g.useStreamMultipleBlocksProps(),X=()=>{var e;(e=G.current)==null||e.scrollIntoView({behavior:"smooth"})};r.useEffect(()=>{X()},[w,m]);const I=async(e,f,Y)=>{var C,D;p&&M(p);const q=(e==null?void 0:e.toLowerCase())==="translate",P={id:Date.now().toString(),role:"user",content:n.getTranslationUserPrompt({fallbackLang:U,userInput:f||e,language:j,blocks:q?B():B(j)}),userMessage:f||e||l("Translate the content")},Z={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};v(!0);const $=new AbortController;J($),A(c=>[...c,P,Z]),v(!0);const a=Y||E;(C=s.onAIEvent)==null||C.call(s,{type:"stream_start",model:a,timestamp:Date.now()});try{const c={messages:[P],initiator:q?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:a,context:s.context},i=await _({body:{action:"ASK_AI",data:c},streamResponse:!0});if(!i.ok)throw new Error(l("Failed to get AI response"));const d=(D=i.body)==null?void 0:D.getReader(),y=new TextDecoder;let o="";if(!d)throw new Error(l("Response body is not readable"));for(;;){const{done:h,value:T}=await d.read();if(h)break;const k=y.decode(T,{stream:!0});o+=k,A(u=>(u[u.length-1].content=o,[...u]))}const S=JSON.parse(o==null?void 0:o.replace("```json","").replace("```",""));Q(S),r.startTransition(()=>{var T,k,u;const h=Date.now();(T=s.onSuccess)==null||T.call(s,{content:o,model:a,timestamp:h}),(k=s.onComplete)==null||k.call(s,{success:!0,content:o,model:a,timestamp:h}),(u=s.onAIEvent)==null||u.call(s,{type:"completion",content:o,model:a,timestamp:h})})}catch(c){R==null||R.abort(),r.startTransition(()=>{var y,o,S;const i=c instanceof Error?c.message:String(c),d=Date.now();(y=s.onError)==null||y.call(s,{error:i,model:a,timestamp:d}),(o=s.onComplete)==null||o.call(s,{success:!1,error:i,model:a,timestamp:d}),(S=s.onAIEvent)==null||S.call(s,{type:"error",error:i,model:a,timestamp:d})})}finally{v(!1),b(""),M(null)}};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"py-2",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(te,{isLoading:m,selectedBlock:p,selectedLang:j,onClick:I})})}),t.jsx(n.Conversation,{children:t.jsxs(n.ConversationContent,{className:"gap-4 px-0",children:[w.length===0&&t.jsx(n.ConversationEmptyState,{icon:t.jsx(L.Bot,{size:48,className:"text-gray-300"}),title:l("Start a conversation with the AI assistant to translate/edit your content"),description:l("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),w.map(e=>e.role!=="system"&&t.jsx(r.Fragment,{children:e.isReasoning?t.jsxs(n.Reasoning,{isStreaming:e.isStreaming,defaultOpen:!0,children:[t.jsx(n.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),t.jsx(n.ReasoningContent,{className:"p-0 text-xs",children:e.content})]}):e.isTask?t.jsx(n.TaskMessage,{content:e.content,isLoading:e.isTaskLoading}):t.jsx(n.Message,{from:e.role,children:t.jsx(n.MessageContent,{className:"p-0",children:e.role==="assistant"?t.jsx(n.MessageResponse,{className:"p-0 text-xs",children:e.content}):t.jsx("div",{className:"p-0 text-xs",children:e.userMessage||e.content})})})},e.id))]})}),t.jsxs("div",{className:"border-gray-200 pb-2",children:[t.jsx(n.SelectedBlockDisplay,{onRemove:()=>H([]),isLoading:m}),t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(se,{input:x,setInput:b,onSend:I,onStop:F,isLoading:m,selectedLang:j,currentBlock:p||z,disabled:(x==null?void 0:x.length)===0,selectedModel:E,onModelChange:V})})]})]})};exports.default=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("./index-DCJDQs1a.cjs"),n=require("./selected-block-display-CSYAaqzP.cjs"),L=require("lucide-react"),r=require("react"),ee=require("react-i18next"),O=require("./index-CzBSRTj0.cjs"),te=r.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-Dhh-bNJr.cjs"))),se=r.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-SJnya_UU.cjs"))),ne=({fetch:_,input:x,messages:w,setInput:b,isLoading:m,handleStop:F,setMessages:A,setIsLoading:v,selectedLang:j,currentBlock:z,fallbackLang:U,abortController:R,setAbortController:J,setCurrentBlock:M,selectedModel:K,onModelChange:V})=>{const{t:l}=ee.useTranslation(),{models:N}=O.useAIModels(),s=O.useAIConfig(),W=N.find(e=>e.id==="google/gemini-3-flash")||N[0],E=K||W.id,G=r.useRef(null),p=g.useSelectedBlock(),[,H]=g.useSelectedBlockIds(),B=g.useI18nBlocks(),Q=g.useStreamMultipleBlocksProps(),X=()=>{var e;(e=G.current)==null||e.scrollIntoView({behavior:"smooth"})};r.useEffect(()=>{X()},[w,m]);const I=async(e,f,Y)=>{var C,D;p&&M(p);const q=(e==null?void 0:e.toLowerCase())==="translate",P={id:Date.now().toString(),role:"user",content:n.getTranslationUserPrompt({fallbackLang:U,userInput:f||e,language:j,blocks:q?B():B(j)}),userMessage:f||e||l("Translate the content")},Z={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};v(!0);const $=new AbortController;J($),A(c=>[...c,P,Z]),v(!0);const a=Y||E;(C=s.onAIEvent)==null||C.call(s,{type:"stream_start",model:a,timestamp:Date.now()});try{const c={messages:[P],initiator:q?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:a,context:s.context},i=await _({body:{action:"ASK_AI",data:c},streamResponse:!0});if(!i.ok)throw new Error(l("Failed to get AI response"));const d=(D=i.body)==null?void 0:D.getReader(),y=new TextDecoder;let o="";if(!d)throw new Error(l("Response body is not readable"));for(;;){const{done:h,value:T}=await d.read();if(h)break;const k=y.decode(T,{stream:!0});o+=k,A(u=>(u[u.length-1].content=o,[...u]))}const S=JSON.parse(o==null?void 0:o.replace("```json","").replace("```",""));Q(S),r.startTransition(()=>{var T,k,u;const h=Date.now();(T=s.onSuccess)==null||T.call(s,{content:o,model:a,timestamp:h}),(k=s.onComplete)==null||k.call(s,{success:!0,content:o,model:a,timestamp:h}),(u=s.onAIEvent)==null||u.call(s,{type:"completion",content:o,model:a,timestamp:h})})}catch(c){R==null||R.abort(),r.startTransition(()=>{var y,o,S;const i=c instanceof Error?c.message:String(c),d=Date.now();(y=s.onError)==null||y.call(s,{error:i,model:a,timestamp:d}),(o=s.onComplete)==null||o.call(s,{success:!1,error:i,model:a,timestamp:d}),(S=s.onAIEvent)==null||S.call(s,{type:"error",error:i,model:a,timestamp:d})})}finally{v(!1),b(""),M(null)}};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"py-2",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(te,{isLoading:m,selectedBlock:p,selectedLang:j,onClick:I})})}),t.jsx(n.Conversation,{children:t.jsxs(n.ConversationContent,{className:"gap-4 px-0",children:[w.length===0&&t.jsx(n.ConversationEmptyState,{icon:t.jsx(L.Bot,{size:48,className:"text-gray-300"}),title:l("Start a conversation with the AI assistant to translate/edit your content"),description:l("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),w.map(e=>e.role!=="system"&&t.jsx(r.Fragment,{children:e.isReasoning?t.jsxs(n.Reasoning,{isStreaming:e.isStreaming,defaultOpen:!0,children:[t.jsx(n.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),t.jsx(n.ReasoningContent,{className:"p-0 text-xs",children:e.content})]}):e.isTask?t.jsx(n.TaskMessage,{content:e.content,isLoading:e.isTaskLoading}):t.jsx(n.Message,{from:e.role,children:t.jsx(n.MessageContent,{className:"p-0",children:e.role==="assistant"?t.jsx(n.MessageResponse,{className:"p-0 text-xs",children:e.content}):t.jsx("div",{className:"p-0 text-xs",children:e.userMessage||e.content})})})},e.id))]})}),t.jsxs("div",{className:"border-gray-200 pb-2",children:[t.jsx(n.SelectedBlockDisplay,{onRemove:()=>H([]),isLoading:m}),t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(se,{input:x,setInput:b,onSend:I,onStop:F,isLoading:m,selectedLang:j,currentBlock:p||z,disabled:(x==null?void 0:x.length)===0,selectedModel:E,onModelChange:V})})]})]})};exports.default=ne;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),y=require("./index-DCJDQs1a.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),_=require("./index-BVwFJWDq.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.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 re=W.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 H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.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 K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.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 ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.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),...a,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:d?e.jsx("img",{alt:o||"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(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.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:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"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:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=se.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,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:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),y=require("./index-DCJDQs1a.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),_=require("./index-CzBSRTj0.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.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 re=W.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 H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.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 K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.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 ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.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),...a,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:d?e.jsx("img",{alt:o||"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(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.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:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"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:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=se.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,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:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
@@ -6,7 +6,7 @@ import { PaperclipIcon as Se, XIcon as Y, PlusIcon as ke, ImageIcon as ze, MicIc
6
6
  import { nanoid as Ue } from "nanoid";
7
7
  import { useContext as W, useRef as F, useEffect as A, useState as L, useCallback as O, useMemo as Fe, createContext as _, Fragment as Oe, startTransition as Ge, Children as Be } from "react";
8
8
  import { useTranslation as Ee } from "react-i18next";
9
- import { l as J } from "./index-LBTm1Jmk.js";
9
+ import { l as J } from "./index-nzqILA37.js";
10
10
  function We({ className: t, ...n }) {
11
11
  return /* @__PURE__ */ e(
12
12
  "div",
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { L as i } from "./index-LBTm1Jmk.js";
3
+ import { L as i } from "./index-nzqILA37.js";
4
4
  import { ArrowRight as c } from "lucide-react";
5
5
  import { useTranslation as m } from "react-i18next";
6
6
  const u = ({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-BVwFJWDq.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{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:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("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")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-CzBSRTj0.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{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:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("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")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
@@ -1,7 +1,7 @@
1
1
  import { jsx as s, jsxs as t, Fragment as L } from "react/jsx-runtime";
2
2
  import { z as h, B as F } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { D as T, e as q, f as O, g as z, o as B, p as f, q as H } from "./index-OuHV9Ann.js";
4
- import { aq as I, ar as M, A as E, ay as R } from "./index-LBTm1Jmk.js";
4
+ import { aq as I, ar as M, A as E, ay as R } from "./index-nzqILA37.js";
5
5
  import { useMutation as U } from "@tanstack/react-query";
6
6
  import { Loader2 as W } from "lucide-react";
7
7
  import { useState as c, useCallback as S, useEffect as G } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),u=require("./index-BVwFJWDq.cjs"),A=require("@tanstack/react-query"),F=require("lucide-react"),d=require("react"),k=require("react-i18next"),m=require("zod"),E=()=>{const r=u.useApiUrl(),o=u.useFetch();return A.useMutation({mutationKey:[u.ACTIONS.CHANGE_PASSWORD],mutationFn:async e=>{const t=await o(r,{action:u.ACTIONS.CHANGE_PASSWORD,data:e});return t==null?void 0:t.data}})},L=r=>m.z.object({oldPassword:m.z.string().min(1,r("Current password is required")),newPassword:m.z.string().min(8,r("Password must be at least 8 characters")).max(128,r("Password must be less than 128 characters")).regex(/[A-Z]/,r("Password must contain at least one uppercase letter")).regex(/[a-z]/,r("Password must contain at least one lowercase letter")).regex(/[0-9]/,r("Password must contain at least one number")).regex(/[!@#$%^&*(),.?":{}|<>]/,r("Password must contain at least one special character")),confirmPassword:m.z.string().min(1,r("Confirm password is required"))}).refine(o=>o.newPassword===o.confirmPassword,{message:r("New password and confirm password do not match"),path:["confirmPassword"]}).refine(o=>o.oldPassword!==o.newPassword,{message:r("New password must be different from current password"),path:["newPassword"]}),T=({open:r,onOpenChange:o})=>{const{t:e}=k.useTranslation(),t=u.usePagesProp("currentUser",null),{mutate:q,isPending:h,isSuccess:p,reset:P}=E(),[x,f]=d.useState(""),[j,C]=d.useState(""),[N,v]=d.useState(""),[b,i]=d.useState(null),S=d.useCallback(()=>{f(""),C(""),v(""),i(null),P()},[P]),w=d.useCallback(a=>{o(a),a||S()},[o,S]);d.useEffect(()=>{if(p){const a=setTimeout(()=>{w(!1)},2e3);return()=>clearTimeout(a)}},[p,w]);const D=()=>{var y;i(null);const a={oldPassword:x.trim(),newPassword:j.trim(),confirmPassword:N.trim()},c=L(e).safeParse(a);if(!c.success){i(((y=c.error.issues[0])==null?void 0:y.message)||e("Validation failed"));return}if(!(t!=null&&t.email)){i(e("User email not found"));return}q({email:t.email,oldPassword:c.data.oldPassword,newPassword:c.data.newPassword,confirmPassword:c.data.confirmPassword},{onError:g=>{i((g==null?void 0:g.message)||e("Failed to change password"))}})};return s.jsx(n.Dialog,{open:r,onOpenChange:w,children:s.jsx(n.DialogContent,{className:"sm:max-w-[425px]",children:h?s.jsx("div",{className:"flex h-[340px] items-center justify-center",children:s.jsx(F.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):p?s.jsxs("div",{className:"flex h-[340px] flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"rounded-full bg-green-100 p-3",children:s.jsx("svg",{className:"h-6 w-6 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("p",{className:"text-lg font-medium",children:e("Password updated successfully")})]}):s.jsxs(s.Fragment,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:e("Change Password")}),s.jsx(n.DialogDescription,{children:e("Enter your current password and a new password.")})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"old-password",children:e("Current Password")}),s.jsx(l.Input,{id:"old-password",type:"password",value:x,onChange:a=>f(a.target.value),placeholder:e("Enter current password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"new-password",children:e("New Password")}),s.jsx(l.Input,{id:"new-password",type:"password",value:j,onChange:a=>C(a.target.value),placeholder:e("Enter new password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"confirm-password",children:e("Confirm Password")}),s.jsx(l.Input,{id:"confirm-password",type:"password",value:N,onChange:a=>v(a.target.value),placeholder:e("Confirm new password")})]}),b&&s.jsx("p",{className:"text-sm text-destructive",children:b})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(l.Button,{variant:"outline",onClick:()=>w(!1),disabled:h,children:e("Cancel")}),s.jsx(l.Button,{onClick:D,disabled:h,children:e("Change Password")})]})]})})})};exports.ChangePasswordModal=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),u=require("./index-CzBSRTj0.cjs"),A=require("@tanstack/react-query"),F=require("lucide-react"),d=require("react"),k=require("react-i18next"),m=require("zod"),E=()=>{const r=u.useApiUrl(),o=u.useFetch();return A.useMutation({mutationKey:[u.ACTIONS.CHANGE_PASSWORD],mutationFn:async e=>{const t=await o(r,{action:u.ACTIONS.CHANGE_PASSWORD,data:e});return t==null?void 0:t.data}})},L=r=>m.z.object({oldPassword:m.z.string().min(1,r("Current password is required")),newPassword:m.z.string().min(8,r("Password must be at least 8 characters")).max(128,r("Password must be less than 128 characters")).regex(/[A-Z]/,r("Password must contain at least one uppercase letter")).regex(/[a-z]/,r("Password must contain at least one lowercase letter")).regex(/[0-9]/,r("Password must contain at least one number")).regex(/[!@#$%^&*(),.?":{}|<>]/,r("Password must contain at least one special character")),confirmPassword:m.z.string().min(1,r("Confirm password is required"))}).refine(o=>o.newPassword===o.confirmPassword,{message:r("New password and confirm password do not match"),path:["confirmPassword"]}).refine(o=>o.oldPassword!==o.newPassword,{message:r("New password must be different from current password"),path:["newPassword"]}),T=({open:r,onOpenChange:o})=>{const{t:e}=k.useTranslation(),t=u.usePagesProp("currentUser",null),{mutate:q,isPending:h,isSuccess:p,reset:P}=E(),[x,f]=d.useState(""),[j,C]=d.useState(""),[N,v]=d.useState(""),[b,i]=d.useState(null),S=d.useCallback(()=>{f(""),C(""),v(""),i(null),P()},[P]),w=d.useCallback(a=>{o(a),a||S()},[o,S]);d.useEffect(()=>{if(p){const a=setTimeout(()=>{w(!1)},2e3);return()=>clearTimeout(a)}},[p,w]);const D=()=>{var y;i(null);const a={oldPassword:x.trim(),newPassword:j.trim(),confirmPassword:N.trim()},c=L(e).safeParse(a);if(!c.success){i(((y=c.error.issues[0])==null?void 0:y.message)||e("Validation failed"));return}if(!(t!=null&&t.email)){i(e("User email not found"));return}q({email:t.email,oldPassword:c.data.oldPassword,newPassword:c.data.newPassword,confirmPassword:c.data.confirmPassword},{onError:g=>{i((g==null?void 0:g.message)||e("Failed to change password"))}})};return s.jsx(n.Dialog,{open:r,onOpenChange:w,children:s.jsx(n.DialogContent,{className:"sm:max-w-[425px]",children:h?s.jsx("div",{className:"flex h-[340px] items-center justify-center",children:s.jsx(F.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):p?s.jsxs("div",{className:"flex h-[340px] flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"rounded-full bg-green-100 p-3",children:s.jsx("svg",{className:"h-6 w-6 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("p",{className:"text-lg font-medium",children:e("Password updated successfully")})]}):s.jsxs(s.Fragment,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:e("Change Password")}),s.jsx(n.DialogDescription,{children:e("Enter your current password and a new password.")})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"old-password",children:e("Current Password")}),s.jsx(l.Input,{id:"old-password",type:"password",value:x,onChange:a=>f(a.target.value),placeholder:e("Enter current password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"new-password",children:e("New Password")}),s.jsx(l.Input,{id:"new-password",type:"password",value:j,onChange:a=>C(a.target.value),placeholder:e("Enter new password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"confirm-password",children:e("Confirm Password")}),s.jsx(l.Input,{id:"confirm-password",type:"password",value:N,onChange:a=>v(a.target.value),placeholder:e("Confirm new password")})]}),b&&s.jsx("p",{className:"text-sm text-destructive",children:b})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(l.Button,{variant:"outline",onClick:()=>w(!1),disabled:h,children:e("Cancel")}),s.jsx(l.Button,{onClick:D,disabled:h,children:e("Change Password")})]})]})})})};exports.ChangePasswordModal=T;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { J as o, K as c, M as i, O as l, Q as m } from "./index-OuHV9Ann.js";
4
- import { b as d, B as h } from "./index-LBTm1Jmk.js";
4
+ import { b as d, B as h } from "./index-nzqILA37.js";
5
5
  import { CheckCircle as u, Check as p } from "lucide-react";
6
6
  import { useTranslation as C } from "react-i18next";
7
7
  const y = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-DCJDQs1a.cjs"),a=require("./index-BVwFJWDq.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};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(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-DCJDQs1a.cjs"),a=require("./index-CzBSRTj0.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};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(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),l=require("./index-BVwFJWDq.cjs"),C=require("lodash-es"),f=require("react"),g=require("react-i18next"),S=(e,d)=>{const t=d.filter(m=>m.parent===e);if(t.length===0)return 0;let u=t.length;return t.forEach(m=>{u+=S(m.id,d)}),u};function U({page:e,onClose:d}){const{t}=g.useTranslation(),[,u]=l.useSearchParams(),{mutate:m,isPending:P}=l.useDeletePage(),{data:j}=l.usePageTypes(),{data:h=[]}=l.useWebsitePrimaryPages(),{setSelectedLang:E,fallbackLang:L}=n.useLanguages(),[,q]=n.useSidebarActivePanel(),c=!(e!=null&&e.primaryPage),{data:r=[]}=l.useLanguagePages(c?e==null?void 0:e.id:void 0),{data:y}=l.useSiteWideUsage(),v=f.useMemo(()=>C.isEmpty(e==null?void 0:e.slug),[e==null?void 0:e.slug]),w=f.useMemo(()=>{if(!v||!(e!=null&&e.id)||!y)return[];const i=[];return Object.entries(y).forEach(([o,D])=>{D.partialBlocks.includes(e.id)&&!D.isPartial&&i.push({id:o,name:D.name})}),i},[v,e.id,y]),N=f.useMemo(()=>!c||!r?0:r.filter(i=>i.id!==e.id).length,[c,r,e.id]),x=f.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let i=S(e.id,h);return c&&r&&r.length>0&&r.forEach(o=>{o.id!==e.id&&(i+=S(o.id,h))}),i},[e.id,h,c,r]),A=()=>{P||m(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),u(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),u(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),E(L),q("outline"),d()}})},a=j==null?void 0:j.find(i=>i.key===(e==null?void 0:e.pageType));return s.jsx(n.Dialog,{open:!!e,onOpenChange:d,children:s.jsxs(n.DialogContent,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:t("Confirm Deletion")}),s.jsxs(n.DialogDescription,{className:"py-4 text-slate-500",children:[s.jsxs("div",{children:[t("Are you sure you want to remove")," ",s.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",a!=null&&a.hasSlug?(a==null?void 0:a.name)+"?":t("page?")]}),c&&(N>0||x>0)&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: Deleting this primary page will also delete"),":"]}),s.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[x>0&&s.jsxs("li",{children:[s.jsx("span",{className:"font-medium",children:x})," ",t(x===1?"nested child page":"nested child pages")]}),N>0&&s.jsx("li",{children:t("All associated language pages")})]})]}),v&&w.length>0&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: This partial is currently used in the following pages"),":"]}),s.jsx("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:w.map(({id:i,name:o})=>s.jsx("li",{children:s.jsx("span",{className:"font-medium",children:o})},i))})]}),e.lang&&s.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),":"," ",s.jsx("span",{className:"font-medium text-gray-500",children:C.get(l.LANGUAGES,e.lang,e.lang)})]})]})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(b.Button,{variant:"outline",onClick:d,children:t("Cancel")}),s.jsx(b.Button,{variant:"destructive",disabled:P,onClick:A,children:t(P?"Deleting...":"Delete")})]})]})})}exports.default=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),l=require("./index-CzBSRTj0.cjs"),C=require("lodash-es"),f=require("react"),g=require("react-i18next"),S=(e,d)=>{const t=d.filter(m=>m.parent===e);if(t.length===0)return 0;let u=t.length;return t.forEach(m=>{u+=S(m.id,d)}),u};function U({page:e,onClose:d}){const{t}=g.useTranslation(),[,u]=l.useSearchParams(),{mutate:m,isPending:P}=l.useDeletePage(),{data:j}=l.usePageTypes(),{data:h=[]}=l.useWebsitePrimaryPages(),{setSelectedLang:E,fallbackLang:L}=n.useLanguages(),[,q]=n.useSidebarActivePanel(),c=!(e!=null&&e.primaryPage),{data:r=[]}=l.useLanguagePages(c?e==null?void 0:e.id:void 0),{data:y}=l.useSiteWideUsage(),v=f.useMemo(()=>C.isEmpty(e==null?void 0:e.slug),[e==null?void 0:e.slug]),w=f.useMemo(()=>{if(!v||!(e!=null&&e.id)||!y)return[];const i=[];return Object.entries(y).forEach(([o,D])=>{D.partialBlocks.includes(e.id)&&!D.isPartial&&i.push({id:o,name:D.name})}),i},[v,e.id,y]),N=f.useMemo(()=>!c||!r?0:r.filter(i=>i.id!==e.id).length,[c,r,e.id]),x=f.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let i=S(e.id,h);return c&&r&&r.length>0&&r.forEach(o=>{o.id!==e.id&&(i+=S(o.id,h))}),i},[e.id,h,c,r]),A=()=>{P||m(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),u(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),u(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),E(L),q("outline"),d()}})},a=j==null?void 0:j.find(i=>i.key===(e==null?void 0:e.pageType));return s.jsx(n.Dialog,{open:!!e,onOpenChange:d,children:s.jsxs(n.DialogContent,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:t("Confirm Deletion")}),s.jsxs(n.DialogDescription,{className:"py-4 text-slate-500",children:[s.jsxs("div",{children:[t("Are you sure you want to remove")," ",s.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",a!=null&&a.hasSlug?(a==null?void 0:a.name)+"?":t("page?")]}),c&&(N>0||x>0)&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: Deleting this primary page will also delete"),":"]}),s.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[x>0&&s.jsxs("li",{children:[s.jsx("span",{className:"font-medium",children:x})," ",t(x===1?"nested child page":"nested child pages")]}),N>0&&s.jsx("li",{children:t("All associated language pages")})]})]}),v&&w.length>0&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: This partial is currently used in the following pages"),":"]}),s.jsx("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:w.map(({id:i,name:o})=>s.jsx("li",{children:s.jsx("span",{className:"font-medium",children:o})},i))})]}),e.lang&&s.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),":"," ",s.jsx("span",{className:"font-medium text-gray-500",children:C.get(l.LANGUAGES,e.lang,e.lang)})]})]})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(b.Button,{variant:"outline",onClick:d,children:t("Cancel")}),s.jsx(b.Button,{variant:"destructive",disabled:P,onClick:A,children:t(P?"Deleting...":"Delete")})]})]})})}exports.default=U;
@@ -1,7 +1,7 @@
1
1
  import { jsx as s, jsxs as t } from "react/jsx-runtime";
2
2
  import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { d as k, n as U, D as W, e as g, f as B, g as q, o as G, q as R } from "./index-OuHV9Ann.js";
4
- import { c as j, o as F, k as H, e as M, j as Q, q as T, L as $ } from "./index-LBTm1Jmk.js";
4
+ import { c as j, o as F, k as H, e as M, j as Q, q as T, L as $ } from "./index-nzqILA37.js";
5
5
  import { isEmpty as z, get as I } from "lodash-es";
6
6
  import { useMemo as f } from "react";
7
7
  import { useTranslation as J } from "react-i18next";
@@ -10,7 +10,7 @@ import { ErrorBoundary as ot } from "react-error-boundary";
10
10
  import { useTranslation as ee } from "react-i18next";
11
11
  import { toast as A } from "sonner";
12
12
  import { useQueryClient as te, useMutation as ie, useQuery as ge } from "@tanstack/react-query";
13
- import { aq as K, ar as Q, A as b } from "./index-LBTm1Jmk.js";
13
+ import { aq as K, ar as Q, A as b } from "./index-nzqILA37.js";
14
14
  import { c as xe } from "./common-functions-D2lMFR6K.js";
15
15
  const dt = () => {
16
16
  const s = K(), n = te(), h = Q();