@chaibuilder/pages 0.16.18 → 0.16.20
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.
- package/dist/{2AITGKQY-DbBNqqNQ.cjs → 2AITGKQY-BH_4lP5P.cjs} +1 -1
- package/dist/{2AITGKQY-jev6nZ--.js → 2AITGKQY-BuWtti7-.js} +2 -2
- package/dist/{NCMVHL6D-BjH1Tg1s.cjs → NCMVHL6D-CfRPe-3L.cjs} +1 -1
- package/dist/{NCMVHL6D-BtVmDJZQ.js → NCMVHL6D-DbC9VYfW.js} +2 -2
- package/dist/{ZDWCUMSJ-Nezb42Bx.cjs → ZDWCUMSJ-BxhCnC2U.cjs} +1 -1
- package/dist/{ZDWCUMSJ-S9dikjgz.js → ZDWCUMSJ-CE0Md3aC.js} +1 -1
- package/dist/{active-in-another-tab-nD0Ct2zR.js → active-in-another-tab-C4o8FQXv.js} +1 -1
- package/dist/{active-in-another-tab-B2jwquvi.cjs → active-in-another-tab-SSCyhy2-.cjs} +1 -1
- package/dist/{add-new-language-page-BJk1ZO-t.js → add-new-language-page-BCu4Npk2.js} +2 -2
- package/dist/{add-new-language-page-B2CGLeBl.cjs → add-new-language-page-DUkVmwsT.cjs} +1 -1
- package/dist/{add-new-page-Y4l1kKgu.cjs → add-new-page-BDpRUueB.cjs} +1 -1
- package/dist/{add-new-page-DNMc1_m8.js → add-new-page-D1pc9kLA.js} +1 -1
- package/dist/{ai-panel-content-B2R5ac1Q.cjs → ai-panel-content-Bq3BC1Dm.cjs} +1 -1
- package/dist/{ai-panel-content-BZDagIjt.js → ai-panel-content-Dg6P7vk7.js} +2 -2
- package/dist/{ai-panel-default-lang-DFVRw2XO.js → ai-panel-default-lang-BxYd_6VF.js} +3 -3
- package/dist/{ai-panel-default-lang-DpRzlKuh.cjs → ai-panel-default-lang-C0X_Srso.cjs} +2 -2
- package/dist/{ai-panel-other-lang-mjWK495u.cjs → ai-panel-other-lang-BOu1wJ5J.cjs} +1 -1
- package/dist/{ai-panel-other-lang-CGiXHbUA.js → ai-panel-other-lang-CBAP_iX-.js} +3 -3
- package/dist/{ai-prompt-input-B6dhDx3f.js → ai-prompt-input-CiZCB6jc.js} +2 -2
- package/dist/{ai-prompt-input-B3799aqQ.cjs → ai-prompt-input-bqLGbsQ2.cjs} +1 -1
- package/dist/{ai-translation-prompt-C3SvF46x.cjs → ai-translation-prompt-Cas13J-r.cjs} +1 -1
- package/dist/{ai-translation-prompt-D5ndfcqu.js → ai-translation-prompt-D3XU5z3f.js} +1 -1
- package/dist/{continue-editing-in-this-client-BtPTGxtF.js → continue-editing-in-this-client-DIpi2ZSi.js} +1 -1
- package/dist/{continue-editing-in-this-client-ClnIhAB4.cjs → continue-editing-in-this-client-DbHzW_zt.cjs} +1 -1
- package/dist/{delete-page-CgbNmdX3.js → delete-page-CODOstkw.js} +1 -1
- package/dist/{delete-page-BWQiX4Qy.cjs → delete-page-DPHNAOC6.cjs} +1 -1
- package/dist/{digital-asset-manager-CHPG0akQ.cjs → digital-asset-manager-BllbsemN.cjs} +1 -1
- package/dist/{digital-asset-manager-D2DU2Arz.js → digital-asset-manager-BuYVjKfQ.js} +1 -1
- package/dist/{duplicate-page-D9YHfSTB.cjs → duplicate-page-Dc6_UBNZ.cjs} +1 -1
- package/dist/{duplicate-page-nhaRQq48.js → duplicate-page-DfH67AsW.js} +2 -2
- package/dist/{dynamic-page-selector-BpAx2T1D.js → dynamic-page-selector-C2UK6qGj.js} +1 -1
- package/dist/{dynamic-page-selector-BhFVhQXO.cjs → dynamic-page-selector-Dd8Orls1.cjs} +1 -1
- package/dist/index--Lu_Q_nO.cjs +5 -0
- package/dist/{index-tOCLaJS0.js → index-B_T6ZeA4.js} +106 -106
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-diff-viewer-B7VUOCAk.cjs → json-diff-viewer-1IHmR_Nt.cjs} +1 -1
- package/dist/{json-diff-viewer-BHsCH0rV.js → json-diff-viewer-D8uyTokS.js} +1 -1
- package/dist/{lang-panel-CBDont1C.cjs → lang-panel-D-Pbw2bR.cjs} +1 -1
- package/dist/{lang-panel-Bf4bybUW.js → lang-panel-d7376A7w.js} +2 -2
- package/dist/{mark-as-template-mD5zJnTi.js → mark-as-template-Bx-MAB5M.js} +1 -1
- package/dist/{mark-as-template-ClVxTs7-.cjs → mark-as-template-DHFkkBvV.cjs} +1 -1
- package/dist/{no-language-page-content-BGqiBsuw.cjs → no-language-page-content-DkK7mBnG.cjs} +1 -1
- package/dist/{no-language-page-content-C91jYzRM.js → no-language-page-content-if-qlxZz.js} +1 -1
- package/dist/{no-language-page-dialog-DnN17tvI.cjs → no-language-page-dialog-49fBehZo.cjs} +1 -1
- package/dist/{no-language-page-dialog-CU_Y_GF8.js → no-language-page-dialog-CCLWQP1E.js} +2 -2
- package/dist/{page-creator-Dwn4aALC.js → page-creator-DRDoy3nM.js} +2 -2
- package/dist/{page-creator-BYEKqyKF.cjs → page-creator-DlJXKAhw.cjs} +1 -1
- package/dist/{page-lock-DAWrc3GC.cjs → page-lock-DOnPhjGp.cjs} +1 -1
- package/dist/{page-lock-DHoFXsEj.js → page-lock-pwxPivz-.js} +2 -2
- package/dist/{page-locked-dialog-QL8ZUQQd.js → page-locked-dialog-238NohyB.js} +1 -1
- package/dist/{page-locked-dialog-DMDIpR6r.cjs → page-locked-dialog-DKn93bBu.cjs} +1 -1
- package/dist/{page-manager-new-r1540okw.cjs → page-manager-new-Ch0UNJM1.cjs} +1 -1
- package/dist/{page-manager-new-1RGAp9KU.js → page-manager-new-hEQwUorR.js} +2 -2
- package/dist/{page-manager-search-and-filter-Dp1Z6uDu.cjs → page-manager-search-and-filter-4JatGyBT.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-B9kZBAGe.js → page-manager-search-and-filter-B86rQEO4.js} +1 -1
- package/dist/{page-revisions-content-qrkR9Stz.cjs → page-revisions-content-ChOACVs4.cjs} +1 -1
- package/dist/{page-revisions-content-BLLa8Sar.js → page-revisions-content-V9S1rPUy.js} +2 -2
- package/dist/{publish-pages-content-DquiwxG5.cjs → publish-pages-content-CXKknMnI.cjs} +1 -1
- package/dist/{publish-pages-content-CML_ott4.js → publish-pages-content-GKnG7R5W.js} +2 -2
- package/dist/{save-to-lib-DZOs6H7V.js → save-to-lib-BO3WEr-u.js} +1 -1
- package/dist/{save-to-lib-BBZn9sEZ.cjs → save-to-lib-BderZ0Qz.cjs} +1 -1
- package/dist/{selected-block-display-qF0wXDpP.js → selected-block-display-DAe0XQgw.js} +1 -1
- package/dist/{selected-block-display-DWpFg5KU.cjs → selected-block-display-yB5bvo9w.cjs} +1 -1
- package/dist/{seo-panel-CmqA8v6p.cjs → seo-panel-C2WY1dTf.cjs} +1 -1
- package/dist/{seo-panel-DcTu-rLl.js → seo-panel-DuC3gQQy.js} +1 -1
- package/dist/{shared-json-ld-DZ2eZ35l.cjs → shared-json-ld-ChfktUpf.cjs} +1 -1
- package/dist/{shared-json-ld-Bs_lzQ6G.js → shared-json-ld-DMpCm3M4.js} +1 -1
- package/dist/{slug-input-Df9ug5YA.js → slug-input-CO6AGAQD.js} +1 -1
- package/dist/{slug-input-BvRnz9Xf.cjs → slug-input-CrjrFrxP.cjs} +1 -1
- package/dist/{take-over-request-BBmLlOro.js → take-over-request-Du7grW5x.js} +1 -1
- package/dist/{take-over-request-eUnq0CcU.cjs → take-over-request-mNydSSFX.cjs} +1 -1
- package/dist/{theme-panel-footer-BO6xk08X.js → theme-panel-footer-CSC6DpWO.js} +1 -1
- package/dist/{theme-panel-footer-CzntKXBS.cjs → theme-panel-footer-eZ1bbLzq.cjs} +1 -1
- package/dist/{unmark-as-template-BHbGyEJS.cjs → unmark-as-template-DzU6-XK7.cjs} +1 -1
- package/dist/{unmark-as-template-CSpTbvOz.js → unmark-as-template-dEb6wFT9.js} +1 -1
- package/dist/{unpublish-page-DTVEQJoy.js → unpublish-page-CxAB3-Cj.js} +1 -1
- package/dist/{unpublish-page-kHxAVlJS.cjs → unpublish-page-DGd2Kktq.cjs} +1 -1
- package/dist/{web-preview-CW4XBgip.cjs → web-preview-B6G0vdiq.cjs} +1 -1
- package/dist/{web-preview-SaTB5Pss.js → web-preview-yBF4EXzm.js} +1 -1
- package/package.json +3 -3
- package/dist/index-Nz9M0K-w.cjs +0 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var xs = Object.defineProperty;
|
|
2
2
|
var ws = (e, t, n) => t in e ? xs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var _e = (e, t, n) => ws(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { y as Vn, z as jn, C as K, D as sr, F as H, x as y, G as W, H as oe, S as R, w as O, I as $e, J as Ce, K as G, M as A, N as He, O as ft, Q as ve, R as Ro, U as V, V as $s, W as P, X as wt, Y as un, Z as k, _ as T, $ as Cs, a0 as Kt, a1 as Ss, a2 as ks, a3 as Cn, a4 as Es, a5 as Ds, a6 as Ms, a7 as Nt, a8 as As, a9 as Ts, aa as Fs, ab as ar, ac as Hr, ad as qs, ae as _t, af as Ko, ag as Ur, ah as Is, ai as Os, aj as Kn, ak as Ls, al as Ps, am as _s } from "./index-
|
|
4
|
+
import { y as Vn, z as jn, C as K, D as sr, F as H, x as y, G as W, H as oe, S as R, w as O, I as $e, J as Ce, K as G, M as A, N as He, O as ft, Q as ve, R as Ro, U as V, V as $s, W as P, X as wt, Y as un, Z as k, _ as T, $ as Cs, a0 as Kt, a1 as Ss, a2 as ks, a3 as Cn, a4 as Es, a5 as Ds, a6 as Ms, a7 as Nt, a8 as As, a9 as Ts, aa as Fs, ab as ar, ac as Hr, ad as qs, ae as _t, af as Ko, ag as Ur, ah as Is, ai as Os, aj as Kn, ak as Ls, al as Ps, am as _s } from "./index-B_T6ZeA4.js";
|
|
5
5
|
var zs = (e) => e != null, Rs = (e) => e.filter(zs);
|
|
6
6
|
function Ks(e) {
|
|
7
7
|
return (...t) => {
|
|
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation as r } from "@chaibuilder/sdk";
|
|
3
3
|
import { Card as i, CardHeader as o, CardTitle as l, CardContent as c, CardFooter as d, Button as m } from "@chaibuilder/sdk/ui";
|
|
4
4
|
import { TableIcon as h, Edit as u } from "lucide-react";
|
|
5
|
-
import { an as N, a as p, B as T, E as f, P as E } from "./index-
|
|
5
|
+
import { an as N, a as p, B as T, E as f, P as E } from "./index-B_T6ZeA4.js";
|
|
6
6
|
const S = () => {
|
|
7
7
|
const n = N(), { setPageStatus: s } = p(), { t } = r();
|
|
8
8
|
return /* @__PURE__ */ e(T, { children: /* @__PURE__ */ a(i, { className: "mx-auto w-full max-w-md", children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),a=require("lucide-react"),s=require("./index
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),a=require("lucide-react"),s=require("./index--Lu_Q_nO.cjs"),l=()=>{const i=s.useSendRealtimeEvent(),{setPageStatus:r}=s.usePageLockStatus(),{t:n}=c.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(a.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:n("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:n("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(t.Button,{variant:"default",onClick:()=>{i(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),r(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(a.Edit,{className:"h-4 w-4"}),n("Continue Editing Here")]})})]})})};exports.default=l;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
|
|
2
|
-
import { p as fn, r as gn, S as mn } from "./slug-input-
|
|
3
|
-
import { g as xn, h as vn, i as Sn, j as pn, k as Nn, l as Z, m as Fn, c as wn, L as A } from "./index-
|
|
2
|
+
import { p as fn, r as gn, S as mn } from "./slug-input-CO6AGAQD.js";
|
|
3
|
+
import { g as xn, h as vn, i as Sn, j as pn, k as Nn, l as Z, m as Fn, c as wn, L as A } from "./index-B_T6ZeA4.js";
|
|
4
4
|
import { useLanguages as An, useTranslation as k, useSidebarActivePanel as Cn } from "@chaibuilder/sdk";
|
|
5
5
|
import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as kn, Label as I, Input as Tn, Alert as H, DialogFooter as Un, Button as Rn } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { filter as Wn, find as Bn, startsWith as In } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-CrjrFrxP.cjs"),f=require("./index--Lu_Q_nO.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.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?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.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(S.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(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.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:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-DlJXKAhw.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,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 { useTranslation as a } from "@chaibuilder/sdk";
|
|
3
3
|
import { Dialog as c, DialogContent as m, DialogHeader as p, DialogTitle as h, DialogDescription as f } from "@chaibuilder/sdk/ui";
|
|
4
4
|
import { lazy as D, Suspense as u } from "react";
|
|
5
|
-
const x = D(() => import("./page-creator-
|
|
5
|
+
const x = D(() => import("./page-creator-DRDoy3nM.js")), C = ({
|
|
6
6
|
addEditPage: o,
|
|
7
7
|
setAddEditPage: i,
|
|
8
8
|
closePanel: t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),C=require("./index
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),C=require("./index--Lu_Q_nO.cjs"),S=require("@chaibuilder/sdk"),N=require("@chaibuilder/sdk/ui"),A=require("lucide-react"),n=require("react"),I=require("sonner"),h=[{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"0.5x Credits",multiplier:.5},{id:"google/gemini-2.5-flash-pro",name:"Gemini 2.5 Flash Pro",provider:"google",description:"1.25x Credits",multiplier:1.25},{id:"google/gemini-3-pro",name:"Gemini 3 Pro",provider:"google",description:"2.5x Credits",multiplier:2.5},{id:"openai/gpt-5",name:"GPT-5",provider:"openai",description:"2x Credits",multiplier:2},{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",provider:"anthropic",description:"1x Credits",multiplier:1},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"openai/gpt-4.1",name:"GPT-4.1",provider:"openai",description:"2x Credits",multiplier:2}],B=s=>h.find(r=>r.id===s),j=()=>h[0],F=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-C0X_Srso.cjs"))),G=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-BOu1wJ5J.cjs"))),_=()=>{const{t:s}=S.useTranslation(),[r,a]=n.useState(""),[t,o]=n.useState([]),[c,d]=n.useState(!1),[u,p]=n.useState(null),[v,g]=n.useState(null),[P,b]=n.useState(j().id),{selectedLang:f,fallbackLang:M}=S.useLanguages(),y=C.useBuilderFetch(),[L]=C.useSearchParams(),q=L.get("page"),w=(t==null?void 0:t.filter(i=>i.role==="user").length)>=4,k=(t==null?void 0:t.filter(i=>i.role==="user").length)>=10;n.useEffect(()=>{o([])},[f,q]);const m=()=>{o([]),a(""),g(null),p(null),d(!1)},x={t:s,fetch:y,input:r,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),p(null)),d(!1),a(""),g(null),o(i=>{const l=i[i.length-1];return l&&l.role==="assistant"&&l.isReasoning&&l.isStreaming?i.slice(0,-1):i}),I.toast.info(s("Generation stopped"))},handleReset:m,setMessages:o,setIsLoading:d,currentBlock:v,fallbackLang:M,abortController:u,setCurrentBlock:g,setAbortController:p,forceNewConversation:k,suggestNewConversation:w,selectedModel:P,onModelChange:b};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:s("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(N.Button,{variant:"outline",size:"icon",onClick:m,className:"h-6 w-6",disabled:c,children:e.jsx(A.Plus,{})})]}),e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:f?e.jsx(G,{...x,selectedLang:f}):e.jsx(F,{...x})})]})]})},z=Object.freeze(Object.defineProperty({__proto__:null,default:_},Symbol.toStringTag,{value:"Module"}));exports.AI_MODELS=h;exports.aiPanelContent=z;exports.getDefaultModel=j;exports.getModelById=B;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as g, Fragment as k, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { at as A, c as F } from "./index-
|
|
2
|
+
import { at as A, c as F } from "./index-B_T6ZeA4.js";
|
|
3
3
|
import { useTranslation as G, useLanguages as B } from "@chaibuilder/sdk";
|
|
4
4
|
import { Button as I } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { Plus as _ } from "lucide-react";
|
|
@@ -62,7 +62,7 @@ const v = [
|
|
|
62
62
|
description: "2x Credits",
|
|
63
63
|
multiplier: 2
|
|
64
64
|
}
|
|
65
|
-
], X = (o) => v.find((s) => s.id === o), D = () => v[0], E = C(() => import("./ai-panel-default-lang-
|
|
65
|
+
], X = (o) => v.find((s) => s.id === o), D = () => v[0], E = C(() => import("./ai-panel-default-lang-BxYd_6VF.js")), R = C(() => import("./ai-panel-other-lang-CBAP_iX-.js")), H = () => {
|
|
66
66
|
const { t: o } = G(), [s, a] = i(""), [e, l] = i([]), [c, d] = i(!1), [u, p] = i(null), [P, m] = i(null), [b, S] = i(D().id), { selectedLang: f, fallbackLang: w } = B(), L = A(), [M] = F(), y = M.get("page"), N = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, j = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
|
|
67
67
|
z(() => {
|
|
68
68
|
l([]);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as C, Fragment as F, jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import { C as P, a as W, b as O, R as $, c as q, d as V, T as K, M as _, e as j, f as G, h as z, S as Q, i as U } from "./selected-block-display-
|
|
2
|
+
import { C as P, a as W, b as O, R as $, c as q, d as V, T as K, M as _, e as j, f as G, h as z, S as Q, i as U } from "./selected-block-display-DAe0XQgw.js";
|
|
3
3
|
import { useAddBlock as J, useReplaceBlock as X, useRemoveBlocks as Y, getBlocksFromHTML as L, useSelectedBlock as Z, useSelectedBlockIds as tt, useBlocksHtmlForAi as et } from "@chaibuilder/sdk";
|
|
4
4
|
import { Bot as nt } from "lucide-react";
|
|
5
5
|
import { useCallback as rt, lazy as st, Fragment as ot, Suspense as it } from "react";
|
|
6
6
|
import { toast as at } from "sonner";
|
|
7
|
-
import { g as ct } from "./ai-panel-content-
|
|
7
|
+
import { g as ct } from "./ai-panel-content-Dg6P7vk7.js";
|
|
8
8
|
import { useQueryClient as lt } from "@tanstack/react-query";
|
|
9
9
|
const ut = () => {
|
|
10
10
|
const { addPredefinedBlock: k } = J(), x = X(), y = Y(), v = lt(), w = async (s, e) => {
|
|
@@ -199,7 +199,7 @@ const ut = () => {
|
|
|
199
199
|
},
|
|
200
200
|
[y]
|
|
201
201
|
);
|
|
202
|
-
}, dt = st(() => import("./ai-prompt-input-
|
|
202
|
+
}, dt = st(() => import("./ai-prompt-input-CiZCB6jc.js")), bt = ({
|
|
203
203
|
t: k,
|
|
204
204
|
fetch: x,
|
|
205
205
|
input: y,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),g=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),g=require("./selected-block-display-yB5bvo9w.cjs"),y=require("@chaibuilder/sdk"),L=require("lucide-react"),j=require("react"),P=require("sonner"),F=require("./ai-panel-content-Bq3BC1Dm.cjs"),O=require("@tanstack/react-query"),W=()=>{const{addPredefinedBlock:b}=y.useAddBlock(),H=y.useReplaceBlock(),I=y.useRemoveBlocks(),C=O.useQueryClient(),T=async(s,e)=>{if(!e)return;const r=y.getBlocksFromHTML(e);await b(r,s.parentId,s.position)},B=async(s,e)=>{if(!s.blockId||!e)return;const r=y.getBlocksFromHTML(e);await H(s.blockId,r)},v=async s=>{!s.ids||s.ids.length===0||await I(s.ids)};let f=null;const w=(s,e)=>{const r=document.getElementById("canvas-iframe");if(!r)return null;const l=r==null?void 0:r.contentDocument;if(!l)return null;l.querySelectorAll("[data-stream-canvas]").forEach(d=>d.remove());let n=null;if(s&&s!=="undefined"&&(n=l.querySelector(`[data-block-id="${s}"]`)),n||(n=l.body),!n)return null;if(f=l.createElement("div"),f.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&n.children){const d=Math.min(e,n.children.length);d<n.children.length?n.insertBefore(f,n.children[d]):n.appendChild(f)}else n.appendChild(f);return f},N=s=>{var n;const e=document.getElementById("canvas-iframe");if(!e)return null;const r=e==null?void 0:e.contentDocument;if(!r)return null;r.querySelectorAll("[data-stream-canvas]").forEach(d=>d.remove());const u=r.querySelector(`[data-block-id="${s}"]`);return u?(f=r.createElement("div"),f.setAttribute("data-stream-canvas","true"),(n=u.parentNode)==null||n.insertBefore(f,u.nextSibling),u.style.display="none",f):null},E=(s,e,r)=>{const l=w(e,r);if(l){l.innerHTML=s;const u=l.getBoundingClientRect(),n=document.getElementById("canvas-iframe"),d=n==null?void 0:n.contentWindow;d&&(u.top>=0&&u.bottom<=d.innerHeight||l.scrollIntoView({behavior:"smooth",block:"nearest"}))}},x=(s,e)=>{const r=N(e);r&&(r.innerHTML=s)},M=s=>{const e=s.match(/^--ACTION=(.+)--$/);if(!e)return null;let l=e[1].replace(/--/g,"").split("|");const n={type:l[0]};return l.forEach(d=>{const t=d.trim();if(t.startsWith("PARENT=")){const A=t.substring(7);n.parentId=A==="undefined"?void 0:A}else t.startsWith("POS=")?n.position=parseInt(t.substring(4)):t.startsWith("ID=")?n.blockId=t.substring(3):t.startsWith("IDS=")&&(n.ids=t.substring(4).split(",").map(A=>A.trim()))}),n};return j.useCallback(async(s,e)=>{const r=new TextDecoder;let l="",u="",n=!1,d=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async m=>{const o=m.trim();if(o==="--START--"){n=!0;return}if(n){if(o==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),f&&(f.remove(),f=null);return}if(o.startsWith("--THINKING=")){const i=o.substring(11);e(c=>{const h=[...c],p=h[h.length-1];if(p&&p.role==="assistant"&&p.isReasoning)p.content=i,p.isStreaming=!1;else{const k={id:Date.now().toString(),role:"assistant",content:i,isReasoning:!0,isStreaming:!1};h.push(k)}return h});return}if(o.startsWith("--TASK=")){const i=o.substring(7),c=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:c,role:"assistant",content:i.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};d=c,e(p=>[...p,h]);return}if(o.startsWith("--MSG=")){const i=o.substring(6),c={id:Date.now().toString(),role:"assistant",content:i.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(h=>[...h,c]);return}if(o.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),t.currentAction=M(o),t.htmlBuffer="",t.isInAction=!0;return}if(o==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),d&&(e(i=>i.map(c=>c.isTask?{...c,isTaskCompleted:!0}:c)),d=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(o==="--HTML--"){t.isCapturingHtml=!0;return}if(o==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(o.startsWith("--HTML--")&&o.includes("--ENDHTML--")){const i=o.match(/^--HTML--(.+?)--ENDHTML--$/);if(i&&t.currentAction){const c=i[1];t.htmlBuffer+=c,t.currentAction.type==="ADD"?E(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=m+`
|
|
2
2
|
`,t.currentAction.type==="ADD"?E(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId))}},S=async(m,o)=>{try{switch(m.type){case"ADD":await T(m,o);break;case"EDIT":await B(m,o);break;case"REMOVE":await v(m);break}e(i=>i.filter(c=>!c.isTask))}catch(i){console.log(i)}};try{for(;;){const{done:m,value:o}=await s.read();if(m)break;const i=r.decode(o,{stream:!0});l+=i,u+=i;const c=u.split(`
|
|
3
|
-
`);u=c.pop()||"";for(const h of c)await A(h)}u&&await A(u),C.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[I])},$=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-
|
|
3
|
+
`);u=c.pop()||"";for(const h of c)await A(h)}u&&await A(u),C.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[I])},$=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-bqLGbsQ2.cjs"))),V=({t:b,fetch:H,input:I,messages:C,setInput:T,isLoading:B,setMessages:v,handleStop:f,setIsLoading:w,currentBlock:N,fallbackLang:E,setCurrentBlock:x,setAbortController:M,selectedModel:s=F.getDefaultModel().id,onModelChange:e})=>{const r=y.useSelectedBlock(),[,l]=y.useSelectedBlockIds(),u=y.useBlocksHtmlForAi(),n=W(),d=async(t,A,S,m)=>{var p;if(!t||B)return;x(r);const o=u(r?{blockId:r._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(r&&!o){P.toast.error(b("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:g.getUserPrompt({language:E,userInput:A||t,currentHtml:o}),userMessage:t},c={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};v(k=>[...k,i,c]),w(!0);const h=new AbortController;M(h);try{const k={messages:[i].map(q=>({role:q.role,content:q.content})),model:m||s};S&&(k.image=S);const D=await H({body:{action:"ASK_AI",data:k},streamResponse:!0});if(!D.ok)throw new Error(b("Failed to get AI response"));const R=(p=D.body)==null?void 0:p.getReader();if(!R)throw new Error(b("Response body is not readable"));await n(R,v)}catch(k){if(k.name!=="AbortError"){const D={id:(Date.now()+1).toString(),role:"assistant",content:b("Sorry, I encountered an error. Please try again.")};v(R=>[...R,D])}}finally{T(""),w(!1),x(null),M(null)}};return a.jsxs(a.Fragment,{children:[a.jsxs(g.Conversation,{className:"no-scrollbar",children:[a.jsxs(g.ConversationContent,{className:"gap-2 px-0",children:[C.length===0&&a.jsx(g.ConversationEmptyState,{icon:a.jsx(L.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")}),C.map(t=>t.role!=="system"&&a.jsx(j.Fragment,{children:t.isReasoning?a.jsxs(g.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[a.jsx(g.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),a.jsx(g.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask&&!t.isTaskCompleted?a.jsx(g.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):a.jsx(g.Message,{from:t.role,children:a.jsx(g.MessageContent,{className:"p-0",children:t.role==="assistant"?a.jsx(g.MessageResponse,{className:"p-0 text-xs",children:t.content}):a.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]}),a.jsx(g.ConversationScrollButton,{})]}),a.jsxs("div",{className:"border-gray-200 pb-2",children:[a.jsx(g.SelectedBlockDisplay,{onRemove:()=>l([]),isLoading:B}),a.jsx(j.Suspense,{fallback:a.jsx("div",{children:"Loading..."}),children:a.jsx($,{input:I,setInput:T,onSend:d,onStop:f,isLoading:B,selectedLang:"",currentBlock:r||N,disabled:(I==null?void 0:I.length)===0,selectedModel:s,onModelChange:e})})]})]})};exports.default=V;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./selected-block-display-yB5bvo9w.cjs"),a=require("@chaibuilder/sdk"),G=require("lucide-react"),o=require("react"),H=require("./ai-panel-content-Bq3BC1Dm.cjs"),Q=o.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-Cas13J-r.cjs"))),X=o.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-bqLGbsQ2.cjs"))),Y=({fetch:v,input:c,messages:u,setInput:j,isLoading:i,handleStop:P,setMessages:y,setIsLoading:h,selectedLang:l,currentBlock:q,fallbackLang:A,abortController:x,setAbortController:E,setCurrentBlock:k,selectedModel:S=H.getDefaultModel().id,onModelChange:M})=>{const{t:s}=a.useTranslation(),O=o.useRef(null),d=a.useSelectedBlock(),[,C]=a.useSelectedBlockIds(),T=a.useI18nBlocks(),D=a.useStreamMultipleBlocksProps(),I=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};o.useEffect(()=>{I()},[u,i]);const f=async(t,m,F)=>{var b;d&&k(d);const p=(t==null?void 0:t.toLowerCase())==="translate",R={id:Date.now().toString(),role:"user",content:n.getTranslationUserPrompt({fallbackLang:A,userInput:m||t,language:l,blocks:p?T():T(l)}),userMessage:m||t||s("Translate the content")},_={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};h(!0);const z=new AbortController;E(z),y(w=>[...w,R,_]),h(!0);try{const N=await v({body:{action:"ASK_AI",data:{messages:[R],initiator:p?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:F||S}},streamResponse:!0});if(!N.ok)throw new Error(s("Failed to get AI response"));const B=(b=N.body)==null?void 0:b.getReader(),U=new TextDecoder;let r="";if(!B)throw new Error(s("Response body is not readable"));for(;;){const{done:K,value:V}=await B.read();if(K)break;const W=U.decode(V,{stream:!0});r+=W,y(g=>(g[g.length-1].content=r,[...g]))}const J=JSON.parse(r==null?void 0:r.replace("```json","").replace("```",""));D(J)}catch{x==null||x.abort()}finally{h(!1),j(""),k(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{children:s("Loading...")}),children:e.jsx(Q,{isLoading:i,selectedBlock:d,selectedLang:l,onClick:f})})}),e.jsx(n.Conversation,{children:e.jsxs(n.ConversationContent,{className:"gap-4 px-0",children:[u.length===0&&e.jsx(n.ConversationEmptyState,{icon:e.jsx(G.Bot,{size:48,className:"text-gray-300"}),title:s("Start a conversation with the AI assistant to translate/edit your content"),description:s("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),u.map(t=>t.role!=="system"&&e.jsx(o.Fragment,{children:t.isReasoning?e.jsxs(n.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(n.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(n.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(n.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(n.Message,{from:t.role,children:e.jsx(n.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(n.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(n.SelectedBlockDisplay,{onRemove:()=>C([]),isLoading:i}),e.jsx(o.Suspense,{fallback:e.jsx("div",{children:s("Loading...")}),children:e.jsx(X,{input:c,setInput:j,onSend:f,onStop:P,isLoading:i,selectedLang:l,currentBlock:d||q,disabled:(c==null?void 0:c.length)===0,selectedModel:S,onModelChange:M})})]})]})};exports.default=Y;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as $, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { C as G, a as H, b as Q, R as X, c as Y, d as Z, T as L, M as ee, e as te, f as ne, S as oe, g as se } from "./selected-block-display-
|
|
2
|
+
import { C as G, a as H, b as Q, R as X, c as Y, d as Z, T as L, M as ee, e as te, f as ne, S as oe, g as se } from "./selected-block-display-DAe0XQgw.js";
|
|
3
3
|
import { useTranslation as ae, useSelectedBlock as re, useSelectedBlockIds as ce, useI18nBlocks as ie, useStreamMultipleBlocksProps as le } from "@chaibuilder/sdk";
|
|
4
4
|
import { Bot as de } from "lucide-react";
|
|
5
5
|
import { lazy as v, useRef as ue, useEffect as he, Suspense as B, Fragment as ge } from "react";
|
|
6
|
-
import { g as me } from "./ai-panel-content-
|
|
7
|
-
const fe = v(() => import("./ai-translation-prompt-
|
|
6
|
+
import { g as me } from "./ai-panel-content-Dg6P7vk7.js";
|
|
7
|
+
const fe = v(() => import("./ai-translation-prompt-D3XU5z3f.js")), pe = v(() => import("./ai-prompt-input-CiZCB6jc.js")), be = ({
|
|
8
8
|
fetch: A,
|
|
9
9
|
input: s,
|
|
10
10
|
messages: l,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c, Fragment as Ce } from "react/jsx-runtime";
|
|
2
|
-
import { j as s, B as $ } from "./selected-block-display-
|
|
2
|
+
import { j as s, B as $ } from "./selected-block-display-DAe0XQgw.js";
|
|
3
3
|
import * as p from "react";
|
|
4
4
|
import { createContext as X, Fragment as Te, useRef as B, useEffect as j, useState as A, useCallback as V, useMemo as Pe, Children as Le, useContext as Y } from "react";
|
|
5
5
|
import { Command as D } from "cmdk";
|
|
@@ -10,7 +10,7 @@ import * as H from "@radix-ui/react-hover-card";
|
|
|
10
10
|
import { cva as re } from "class-variance-authority";
|
|
11
11
|
import * as S from "@radix-ui/react-select";
|
|
12
12
|
import { useTranslation as Ye } from "@chaibuilder/sdk";
|
|
13
|
-
import { a as Je, g as K, A as Qe } from "./ai-panel-content-
|
|
13
|
+
import { a as Je, g as K, A as Qe } from "./ai-panel-content-Dg6P7vk7.js";
|
|
14
14
|
const Ze = C.Root, et = C.Trigger, tt = C.Portal, se = p.forwardRef(({ className: e, ...a }, n) => /* @__PURE__ */ t(
|
|
15
15
|
C.Overlay,
|
|
16
16
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./selected-block-display-DWpFg5KU.cjs"),d=require("react"),R=require("cmdk"),b=require("lucide-react"),ye=require("@radix-ui/react-dialog"),Ne=require("@radix-ui/react-dropdown-menu"),we=require("@radix-ui/react-hover-card"),J=require("class-variance-authority"),Se=require("@radix-ui/react-select"),Ie=require("@chaibuilder/sdk"),U=require("./ai-panel-content-B2R5ac1Q.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const p=q(d),z=q(ye),w=q(Ne),G=q(we),I=q(Se),Ce=z.Root,ke=z.Trigger,Re=z.Portal,Q=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Overlay,{ref:a,className:r.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Q.displayName=z.Overlay.displayName;const Z=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(Re,{children:[e.jsx(Q,{}),e.jsxs(z.Content,{ref:n,className:r.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(b.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Z.displayName=z.Content.displayName;const ee=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Title,{ref:a,className:r.cn("text-lg font-semibold leading-none tracking-tight",t),...s}));ee.displayName=z.Title.displayName;const De=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Description,{ref:a,className:r.cn("text-sm text-muted-foreground",t),...s}));De.displayName=z.Description.displayName;const te=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command,{ref:a,className:r.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));te.displayName=R.Command.displayName;const se=p.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(R.Command.Input,{ref:a,className:r.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));se.displayName=R.Command.Input.displayName;const ae=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.List,{ref:a,className:r.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ae.displayName=R.Command.List.displayName;const ze=p.forwardRef((t,s)=>e.jsx(R.Command.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));ze.displayName=R.Command.Empty.displayName;const ne=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Group,{ref:a,className:r.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));ne.displayName=R.Command.Group.displayName;const Pe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Separator,{ref:a,className:r.cn("-mx-1 h-px bg-border",t),...s}));Pe.displayName=R.Command.Separator.displayName;const oe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Item,{ref:a,className:r.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));oe.displayName=R.Command.Item.displayName;const Te=w.Root,Le=w.Trigger,Ae=p.forwardRef(({className:t,inset:s,children:a,...n},l)=>e.jsxs(w.SubTrigger,{ref:l,className:r.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n,children:[a,e.jsx(b.ChevronRight,{className:"ml-auto"})]}));Ae.displayName=w.SubTrigger.displayName;const Me=p.forwardRef(({className:t,...s},a)=>e.jsx(w.SubContent,{ref:a,className:r.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));Me.displayName=w.SubContent.displayName;const re=p.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(w.Portal,{children:e.jsx(w.Content,{ref:n,sideOffset:s,className:r.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));re.displayName=w.Content.displayName;const ie=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Item,{ref:n,className:r.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a}));ie.displayName=w.Item.displayName;const _e=p.forwardRef(({className:t,children:s,checked:a,...n},l)=>e.jsxs(w.CheckboxItem,{ref:l,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),s]}));_e.displayName=w.CheckboxItem.displayName;const Oe=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(w.RadioItem,{ref:n,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Circle,{className:"h-2 w-2 fill-current"})})}),s]}));Oe.displayName=w.RadioItem.displayName;const Ue=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Label,{ref:n,className:r.cn("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...a}));Ue.displayName=w.Label.displayName;const qe=p.forwardRef(({className:t,...s},a)=>e.jsx(w.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));qe.displayName=w.Separator.displayName;const Be=G.Root,Ee=G.Trigger,le=p.forwardRef(({className:t,align:s="center",sideOffset:a=4,...n},l)=>e.jsx(G.Content,{ref:l,align:s,sideOffset:a,className:r.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));le.displayName=G.Content.displayName;const Fe=p.forwardRef(({className:t,type:s,...a},n)=>e.jsx("input",{type:s,className:r.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...a}));Fe.displayName="Input";const ce=p.forwardRef(({className:t,...s},a)=>e.jsx("textarea",{className:r.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...s}));ce.displayName="Textarea";function Ge({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:r.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","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-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const Ve=J.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 de({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:r.cn(Ve({align:s}),t),onClick:n=>{var l,g;n.target.closest("button")||(g=(l=n.currentTarget.parentElement)==null?void 0:l.querySelector("input"))==null||g.focus()},...a})}const He=J.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 ue({className:t,type:s="button",variant:a="ghost",size:n="xs",...l}){return e.jsx(r.Button,{type:s,"data-size":n,variant:a,className:r.cn(He({size:n}),t),...l})}function We({className:t,...s}){return e.jsx(ce,{"data-slot":"input-group-control",className:r.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 Ke=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Trigger,{ref:n,className:r.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(I.Icon,{asChild:!0,children:e.jsx(b.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ke.displayName=I.Trigger.displayName;const me=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollUpButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronUp,{className:"h-4 w-4"})}));me.displayName=I.ScrollUpButton.displayName;const pe=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollDownButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronDown,{className:"h-4 w-4"})}));pe.displayName=I.ScrollDownButton.displayName;const Xe=p.forwardRef(({className:t,children:s,position:a="popper",...n},l)=>e.jsx(I.Portal,{children:e.jsxs(I.Content,{ref:l,className:r.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[e.jsx(me,{}),e.jsx(I.Viewport,{className:r.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(pe,{})]})}));Xe.displayName=I.Content.displayName;const Ye=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Label,{ref:a,className:r.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ye.displayName=I.Label.displayName;const $e=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Item,{ref:n,className:r.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(I.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),e.jsx(I.ItemText,{children:s})]}));$e.displayName=I.Item.displayName;const Je=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));Je.displayName=I.Separator.displayName;const Qe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ze=(t=21)=>{let s="",a=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)s+=Qe[a[t]&63];return s};const et=d.createContext(null),tt=d.createContext(null),fe=()=>d.useContext(et),st=()=>d.useContext(tt),xe=d.createContext(null),V=()=>{const t=st(),s=d.useContext(xe),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function at({data:t,className:s,...a}){var v;const n=V(),l=t.filename||"",u=((v=t.mediaType)!=null&&v.startsWith("image/")&&t.url?"image":"file")==="image",y=l||(u?"Image":"Attachment");return e.jsxs(gt,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("div",{className:r.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:u?e.jsx("img",{alt:l||"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(b.PaperclipIcon,{className:"size-3"})})}),e.jsxs(r.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:k=>{k.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(b.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:y})]},t.id)}),e.jsx(ht,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[u&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:l||"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:l||(u?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function nt({children:t,className:s,...a}){const n=V();return n.files.length?e.jsx("div",{className:r.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:n.files.map(l=>e.jsx(d.Fragment,{children:t(l)},l.id))}):null}const ot=({label:t="Add photos or files",...s})=>{const a=V();return e.jsxs(ie,{...s,onSelect:n=>{n.preventDefault(),a.openFileDialog()},children:[e.jsx(b.ImageIcon,{className:"mr-2 size-4"})," ",t]})},rt=({className:t,accept:s,multiple:a,globalDrop:n,syncHiddenInput:l,maxFiles:g,maxFileSize:u,onError:y,onSubmit:v,children:k,...T})=>{const o=fe(),c=!!o,m=d.useRef(null),P=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var N;const i=(N=P.current)==null?void 0:N.closest("form");i instanceof HTMLFormElement&&(C.current=i)},[]);const[D,A]=d.useState([]),j=c?o.attachments.files:D,M=d.useCallback(()=>{var i;(i=m.current)==null||i.click()},[]),B=d.useCallback(i=>!s||s.trim()===""?!0:s.includes("image/*")?i.type.startsWith("image/"):!0,[s]),E=d.useCallback(i=>{const N=Array.from(i),h=N.filter(S=>B(S));if(N.length&&h.length===0){y==null||y({code:"accept",message:"No files match the accepted types."});return}const x=S=>u?S.size<=u:!0,f=h.filter(x);if(h.length>0&&f.length===0){y==null||y({code:"max_file_size",message:"All files exceed the maximum size."});return}A(S=>{const _=typeof g=="number"?Math.max(0,g-S.length):void 0,je=typeof _=="number"?f.slice(0,_):f;typeof _=="number"&&f.length>_&&(y==null||y({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const H of je)Y.push({id:Ze(),type:"file",url:URL.createObjectURL(H),mediaType:H.type,filename:H.name});return S.concat(Y)})},[B,g,u,y]),L=c?i=>o.attachments.add(i):E,O=c?i=>o.attachments.remove(i):i=>A(N=>{const h=N.find(x=>x.id===i);return h!=null&&h.url&&URL.revokeObjectURL(h.url),N.filter(x=>x.id!==i)}),F=c?()=>o.attachments.clear():()=>A(i=>{for(const N of i)N.url&&URL.revokeObjectURL(N.url);return[]}),K=c?()=>o.attachments.openFileDialog():M;d.useEffect(()=>{c&&o.__registerFileInput(m,()=>{var i;return(i=m.current)==null?void 0:i.click()})},[c,o]),d.useEffect(()=>{l&&m.current&&j.length===0&&(m.current.value="")},[j,l]),d.useEffect(()=>{const i=C.current;if(!i)return;const N=x=>{var f,S;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault()},h=x=>{var f,S,_;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault(),(_=x.dataTransfer)!=null&&_.files&&x.dataTransfer.files.length>0&&L(x.dataTransfer.files)};return i.addEventListener("dragover",N),i.addEventListener("drop",h),()=>{i.removeEventListener("dragover",N),i.removeEventListener("drop",h)}},[L]),d.useEffect(()=>{if(!n)return;const i=h=>{var x,f;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault()},N=h=>{var x,f,S;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault(),(S=h.dataTransfer)!=null&&S.files&&h.dataTransfer.files.length>0&&L(h.dataTransfer.files)};return document.addEventListener("dragover",i),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",i),document.removeEventListener("drop",N)}},[L,n]),d.useEffect(()=>()=>{if(!c)for(const i of j)i.url&&URL.revokeObjectURL(i.url)},[c,j]);const ge=i=>{i.currentTarget.files&&L(i.currentTarget.files)},he=async i=>{const h=await(await fetch(i)).blob();return new Promise((x,f)=>{const S=new FileReader;S.onloadend=()=>x(S.result),S.onerror=f,S.readAsDataURL(h)})},be=d.useMemo(()=>({files:j.map(i=>({...i,id:i.id})),add:L,remove:O,clear:F,openFileDialog:K,fileInputRef:m}),[j,L,O,F,K]),ve=i=>{i.preventDefault();const N=i.currentTarget,h=c?o.textInput.value:new FormData(N).get("message")||"";c||N.reset(),Promise.all(j.map(async({id:x,...f})=>f.url&&f.url.startsWith("blob:")?{...f,url:await he(f.url)}:f)).then(x=>{try{const f=v({text:h,files:x},i);f instanceof Promise?f.then(()=>{F(),c&&o.textInput.clear()}).catch(()=>{}):(F(),c&&o.textInput.clear())}catch{}})},X=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:P}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:ge,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:r.cn("w-full",t),onSubmit:ve,...T,children:e.jsx(Ge,{className:"overflow-hidden",children:k})})]});return c?X:e.jsx(xe.Provider,{value:be,children:X})},it=({onChange:t,className:s,placeholder:a="What would you like to know?",...n})=>{const l=fe(),g=V(),[u,y]=d.useState(!1),v=o=>{if(o.key==="Enter"){if(u||o.nativeEvent.isComposing||o.shiftKey)return;o.preventDefault();const c=o.currentTarget.form,m=c==null?void 0:c.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;c==null||c.requestSubmit()}if(o.key==="Backspace"&&o.currentTarget.value===""&&g.files.length>0){o.preventDefault();const c=g.files.at(-1);c&&g.remove(c.id)}},k=o=>{var P;const c=(P=o.clipboardData)==null?void 0:P.items;if(!c)return;const m=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&m.push(D)}m.length>0&&(o.preventDefault(),g.add(m))},T=l?{value:l.textInput.value,onChange:o=>{l.textInput.setInput(o.currentTarget.value),t==null||t(o)}}:{onChange:t};return e.jsx(We,{className:r.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>y(!1),onCompositionStart:()=>y(!0),onKeyDown:v,onPaste:k,placeholder:a,...n,...T})},lt=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("order-first flex-wrap gap-1",t),...s}),ct=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("justify-between gap-1",t),...s}),dt=({className:t,...s})=>e.jsx("div",{className:r.cn("flex items-center gap-1",t),...s}),W=({variant:t="ghost",className:s,size:a,...n})=>{const l=a??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ue,{className:r.cn(s),size:l,type:"button",variant:t,...n})},ut=t=>e.jsx(Te,{...t}),mt=({className:t,children:s,...a})=>e.jsx(Le,{asChild:!0,children:e.jsx(W,{className:t,...a,children:s??e.jsx(b.PlusIcon,{className:"size-4"})})}),pt=({className:t,...s})=>e.jsx(re,{align:"start",className:r.cn(t),...s}),ft=({className:t,variant:s="default",size:a="icon-sm",status:n,children:l,...g})=>{let u=e.jsx(b.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?u=e.jsx(b.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?u=e.jsx(b.SquareIcon,{className:"size-4"}):n==="error"&&(u=e.jsx(b.XIcon,{className:"size-4"})),e.jsx(ue,{"aria-label":"Submit",className:r.cn(t),size:a,type:"submit",variant:s,...g,children:l??u})},xt=({className:t,textareaRef:s,onTranscriptionChange:a,...n})=>{const[l,g]=d.useState(!1),[u,y]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const T=window.SpeechRecognition||window.webkitSpeechRecognition,o=new T;o.continuous=!0,o.interimResults=!0,o.lang="en-US",o.onstart=()=>{g(!0)},o.onend=()=>{g(!1)},o.onresult=c=>{var P;let m="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(m+=((P=D[0])==null?void 0:P.transcript)??"")}if(m&&(s!=null&&s.current)){const C=s.current,D=C.value,A=D+(D?" ":"")+m;C.value=A,C.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(A)}},o.onerror=c=>{console.error("Speech recognition error:",c.error),g(!1)},v.current=o,y(o)}return()=>{v.current&&v.current.stop()}},[s,a]);const k=d.useCallback(()=>{u&&(l?u.stop():u.start())},[u,l]);return e.jsx(W,{className:r.cn("relative transition-all duration-200",l&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!u,onClick:k,...n,children:e.jsx(b.MicIcon,{className:"size-4"})})},gt=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(Be,{closeDelay:s,openDelay:t,...a}),ht=({align:t="start",...s})=>e.jsx(le,{align:t,...s}),bt=t=>e.jsx(Ce,{...t}),vt=t=>e.jsx(ke,{...t}),jt=({className:t,children:s,title:a="Model Selector",...n})=>e.jsxs(Z,{className:r.cn("p-0",t),...n,children:[e.jsx(ee,{className:"sr-only",children:a}),e.jsx(te,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),yt=({className:t,...s})=>e.jsx(se,{className:r.cn("h-auto py-3.5",t),...s}),Nt=t=>e.jsx(ae,{...t}),wt=t=>e.jsx(ne,{...t}),St=t=>e.jsx(oe,{...t}),It=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:r.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ct=({className:t,...s})=>e.jsx("span",{className:r.cn("flex-1 truncate text-left",t),...s}),kt=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[n,l]=d.useState(!1),[g,u]=d.useState(""),y=U.getModelById(t)||U.getDefaultModel(),k=U.AI_MODELS.filter(o=>o.name.toLowerCase().includes(g.toLowerCase())||o.provider.toLowerCase().includes(g.toLowerCase())).reduce((o,c)=>(o[c.provider]||(o[c.provider]=[]),o[c.provider].push(c),o),{}),T=o=>{s(o),l(!1),u("")};return e.jsxs(bt,{open:n,onOpenChange:l,children:[e.jsx(vt,{asChild:!0,children:e.jsxs(r.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(b.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:y.name})]})}),e.jsxs(jt,{className:"w-96 p-0",children:[e.jsx(yt,{placeholder:"Search models...",value:g,onValueChange:u}),e.jsx(Nt,{children:Object.entries(k).map(([o,c])=>e.jsx(wt,{heading:o.charAt(0).toUpperCase()+o.slice(1),children:c.map(m=>e.jsxs(St,{value:m.id,onSelect:()=>T(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(It,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ct,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},o))})]})]})},$="chai-ai-selected-model",Rt=({input:t,setInput:s,onSend:a,onStop:n,isLoading:l,disabled:g,selectedLang:u,selectedModel:y=U.getDefaultModel().id,onModelChange:v})=>{const{t:k}=Ie.useTranslation(),[T,o]=d.useState(y),[c,m]=d.useState(null),P=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!u){const j=localStorage.getItem($);if(j)o(j),v==null||v(j);else{const M=U.getDefaultModel().id;o(M),v==null||v(M)}}},[u,v]);const A=j=>{var E;const M=j.files.find(L=>{var O;return(O=L.mediaType)==null?void 0:O.startsWith("image/")}),B=(M==null?void 0:M.url)||c;a((E=j.text)==null?void 0:E.trim(),void 0,B,T),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(rt,{onSubmit:A,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(lt,{className:"p-0",children:e.jsx(nt,{className:"pb-0",children:j=>e.jsx(at,{className:"text-xs",data:j})})}),e.jsx(it,{ref:P,value:t,onChange:j=>s(j.target.value),placeholder:k(u?"Ask to update content":"Ask me anything..."),disabled:l,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ct,{children:[u?e.jsx("div",{}):e.jsxs(dt,{children:[e.jsxs(ut,{children:[e.jsx(mt,{disabled:l,children:e.jsx(b.Paperclip,{size:16})}),e.jsx(pt,{children:e.jsx(ot,{})})]}),e.jsx(xt,{textareaRef:P,onTranscriptionChange:s,disabled:l}),e.jsx(kt,{selectedModel:T,onModelChange:j=>{o(j),v==null||v(j),localStorage.setItem($,j)},disabled:l}),e.jsxs(W,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(b.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),l?e.jsxs("button",{onClick:n,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:k("Stop generation"),children:[e.jsx(b.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:k("Stop")})]}):e.jsx(ft,{disabled:!t.trim()||g,children:e.jsx(b.Send,{size:16})})]})]})})})};exports.default=Rt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./selected-block-display-yB5bvo9w.cjs"),d=require("react"),R=require("cmdk"),b=require("lucide-react"),ye=require("@radix-ui/react-dialog"),Ne=require("@radix-ui/react-dropdown-menu"),we=require("@radix-ui/react-hover-card"),J=require("class-variance-authority"),Se=require("@radix-ui/react-select"),Ie=require("@chaibuilder/sdk"),U=require("./ai-panel-content-Bq3BC1Dm.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const p=q(d),z=q(ye),w=q(Ne),G=q(we),I=q(Se),Ce=z.Root,ke=z.Trigger,Re=z.Portal,Q=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Overlay,{ref:a,className:r.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Q.displayName=z.Overlay.displayName;const Z=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(Re,{children:[e.jsx(Q,{}),e.jsxs(z.Content,{ref:n,className:r.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(b.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Z.displayName=z.Content.displayName;const ee=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Title,{ref:a,className:r.cn("text-lg font-semibold leading-none tracking-tight",t),...s}));ee.displayName=z.Title.displayName;const De=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Description,{ref:a,className:r.cn("text-sm text-muted-foreground",t),...s}));De.displayName=z.Description.displayName;const te=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command,{ref:a,className:r.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));te.displayName=R.Command.displayName;const se=p.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(R.Command.Input,{ref:a,className:r.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));se.displayName=R.Command.Input.displayName;const ae=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.List,{ref:a,className:r.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ae.displayName=R.Command.List.displayName;const ze=p.forwardRef((t,s)=>e.jsx(R.Command.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));ze.displayName=R.Command.Empty.displayName;const ne=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Group,{ref:a,className:r.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));ne.displayName=R.Command.Group.displayName;const Pe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Separator,{ref:a,className:r.cn("-mx-1 h-px bg-border",t),...s}));Pe.displayName=R.Command.Separator.displayName;const oe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Item,{ref:a,className:r.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));oe.displayName=R.Command.Item.displayName;const Te=w.Root,Le=w.Trigger,Ae=p.forwardRef(({className:t,inset:s,children:a,...n},l)=>e.jsxs(w.SubTrigger,{ref:l,className:r.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n,children:[a,e.jsx(b.ChevronRight,{className:"ml-auto"})]}));Ae.displayName=w.SubTrigger.displayName;const Me=p.forwardRef(({className:t,...s},a)=>e.jsx(w.SubContent,{ref:a,className:r.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));Me.displayName=w.SubContent.displayName;const re=p.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(w.Portal,{children:e.jsx(w.Content,{ref:n,sideOffset:s,className:r.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));re.displayName=w.Content.displayName;const ie=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Item,{ref:n,className:r.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a}));ie.displayName=w.Item.displayName;const _e=p.forwardRef(({className:t,children:s,checked:a,...n},l)=>e.jsxs(w.CheckboxItem,{ref:l,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),s]}));_e.displayName=w.CheckboxItem.displayName;const Oe=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(w.RadioItem,{ref:n,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Circle,{className:"h-2 w-2 fill-current"})})}),s]}));Oe.displayName=w.RadioItem.displayName;const Ue=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Label,{ref:n,className:r.cn("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...a}));Ue.displayName=w.Label.displayName;const qe=p.forwardRef(({className:t,...s},a)=>e.jsx(w.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));qe.displayName=w.Separator.displayName;const Be=G.Root,Ee=G.Trigger,le=p.forwardRef(({className:t,align:s="center",sideOffset:a=4,...n},l)=>e.jsx(G.Content,{ref:l,align:s,sideOffset:a,className:r.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));le.displayName=G.Content.displayName;const Fe=p.forwardRef(({className:t,type:s,...a},n)=>e.jsx("input",{type:s,className:r.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...a}));Fe.displayName="Input";const ce=p.forwardRef(({className:t,...s},a)=>e.jsx("textarea",{className:r.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...s}));ce.displayName="Textarea";function Ge({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:r.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","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-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const Ve=J.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 de({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:r.cn(Ve({align:s}),t),onClick:n=>{var l,g;n.target.closest("button")||(g=(l=n.currentTarget.parentElement)==null?void 0:l.querySelector("input"))==null||g.focus()},...a})}const He=J.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 ue({className:t,type:s="button",variant:a="ghost",size:n="xs",...l}){return e.jsx(r.Button,{type:s,"data-size":n,variant:a,className:r.cn(He({size:n}),t),...l})}function We({className:t,...s}){return e.jsx(ce,{"data-slot":"input-group-control",className:r.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 Ke=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Trigger,{ref:n,className:r.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(I.Icon,{asChild:!0,children:e.jsx(b.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ke.displayName=I.Trigger.displayName;const me=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollUpButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronUp,{className:"h-4 w-4"})}));me.displayName=I.ScrollUpButton.displayName;const pe=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollDownButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronDown,{className:"h-4 w-4"})}));pe.displayName=I.ScrollDownButton.displayName;const Xe=p.forwardRef(({className:t,children:s,position:a="popper",...n},l)=>e.jsx(I.Portal,{children:e.jsxs(I.Content,{ref:l,className:r.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[e.jsx(me,{}),e.jsx(I.Viewport,{className:r.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(pe,{})]})}));Xe.displayName=I.Content.displayName;const Ye=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Label,{ref:a,className:r.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ye.displayName=I.Label.displayName;const $e=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Item,{ref:n,className:r.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(I.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),e.jsx(I.ItemText,{children:s})]}));$e.displayName=I.Item.displayName;const Je=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));Je.displayName=I.Separator.displayName;const Qe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ze=(t=21)=>{let s="",a=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)s+=Qe[a[t]&63];return s};const et=d.createContext(null),tt=d.createContext(null),fe=()=>d.useContext(et),st=()=>d.useContext(tt),xe=d.createContext(null),V=()=>{const t=st(),s=d.useContext(xe),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function at({data:t,className:s,...a}){var v;const n=V(),l=t.filename||"",u=((v=t.mediaType)!=null&&v.startsWith("image/")&&t.url?"image":"file")==="image",y=l||(u?"Image":"Attachment");return e.jsxs(gt,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("div",{className:r.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:u?e.jsx("img",{alt:l||"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(b.PaperclipIcon,{className:"size-3"})})}),e.jsxs(r.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:k=>{k.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(b.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:y})]},t.id)}),e.jsx(ht,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[u&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:l||"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:l||(u?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function nt({children:t,className:s,...a}){const n=V();return n.files.length?e.jsx("div",{className:r.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:n.files.map(l=>e.jsx(d.Fragment,{children:t(l)},l.id))}):null}const ot=({label:t="Add photos or files",...s})=>{const a=V();return e.jsxs(ie,{...s,onSelect:n=>{n.preventDefault(),a.openFileDialog()},children:[e.jsx(b.ImageIcon,{className:"mr-2 size-4"})," ",t]})},rt=({className:t,accept:s,multiple:a,globalDrop:n,syncHiddenInput:l,maxFiles:g,maxFileSize:u,onError:y,onSubmit:v,children:k,...T})=>{const o=fe(),c=!!o,m=d.useRef(null),P=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var N;const i=(N=P.current)==null?void 0:N.closest("form");i instanceof HTMLFormElement&&(C.current=i)},[]);const[D,A]=d.useState([]),j=c?o.attachments.files:D,M=d.useCallback(()=>{var i;(i=m.current)==null||i.click()},[]),B=d.useCallback(i=>!s||s.trim()===""?!0:s.includes("image/*")?i.type.startsWith("image/"):!0,[s]),E=d.useCallback(i=>{const N=Array.from(i),h=N.filter(S=>B(S));if(N.length&&h.length===0){y==null||y({code:"accept",message:"No files match the accepted types."});return}const x=S=>u?S.size<=u:!0,f=h.filter(x);if(h.length>0&&f.length===0){y==null||y({code:"max_file_size",message:"All files exceed the maximum size."});return}A(S=>{const _=typeof g=="number"?Math.max(0,g-S.length):void 0,je=typeof _=="number"?f.slice(0,_):f;typeof _=="number"&&f.length>_&&(y==null||y({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const H of je)Y.push({id:Ze(),type:"file",url:URL.createObjectURL(H),mediaType:H.type,filename:H.name});return S.concat(Y)})},[B,g,u,y]),L=c?i=>o.attachments.add(i):E,O=c?i=>o.attachments.remove(i):i=>A(N=>{const h=N.find(x=>x.id===i);return h!=null&&h.url&&URL.revokeObjectURL(h.url),N.filter(x=>x.id!==i)}),F=c?()=>o.attachments.clear():()=>A(i=>{for(const N of i)N.url&&URL.revokeObjectURL(N.url);return[]}),K=c?()=>o.attachments.openFileDialog():M;d.useEffect(()=>{c&&o.__registerFileInput(m,()=>{var i;return(i=m.current)==null?void 0:i.click()})},[c,o]),d.useEffect(()=>{l&&m.current&&j.length===0&&(m.current.value="")},[j,l]),d.useEffect(()=>{const i=C.current;if(!i)return;const N=x=>{var f,S;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault()},h=x=>{var f,S,_;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault(),(_=x.dataTransfer)!=null&&_.files&&x.dataTransfer.files.length>0&&L(x.dataTransfer.files)};return i.addEventListener("dragover",N),i.addEventListener("drop",h),()=>{i.removeEventListener("dragover",N),i.removeEventListener("drop",h)}},[L]),d.useEffect(()=>{if(!n)return;const i=h=>{var x,f;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault()},N=h=>{var x,f,S;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault(),(S=h.dataTransfer)!=null&&S.files&&h.dataTransfer.files.length>0&&L(h.dataTransfer.files)};return document.addEventListener("dragover",i),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",i),document.removeEventListener("drop",N)}},[L,n]),d.useEffect(()=>()=>{if(!c)for(const i of j)i.url&&URL.revokeObjectURL(i.url)},[c,j]);const ge=i=>{i.currentTarget.files&&L(i.currentTarget.files)},he=async i=>{const h=await(await fetch(i)).blob();return new Promise((x,f)=>{const S=new FileReader;S.onloadend=()=>x(S.result),S.onerror=f,S.readAsDataURL(h)})},be=d.useMemo(()=>({files:j.map(i=>({...i,id:i.id})),add:L,remove:O,clear:F,openFileDialog:K,fileInputRef:m}),[j,L,O,F,K]),ve=i=>{i.preventDefault();const N=i.currentTarget,h=c?o.textInput.value:new FormData(N).get("message")||"";c||N.reset(),Promise.all(j.map(async({id:x,...f})=>f.url&&f.url.startsWith("blob:")?{...f,url:await he(f.url)}:f)).then(x=>{try{const f=v({text:h,files:x},i);f instanceof Promise?f.then(()=>{F(),c&&o.textInput.clear()}).catch(()=>{}):(F(),c&&o.textInput.clear())}catch{}})},X=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:P}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:ge,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:r.cn("w-full",t),onSubmit:ve,...T,children:e.jsx(Ge,{className:"overflow-hidden",children:k})})]});return c?X:e.jsx(xe.Provider,{value:be,children:X})},it=({onChange:t,className:s,placeholder:a="What would you like to know?",...n})=>{const l=fe(),g=V(),[u,y]=d.useState(!1),v=o=>{if(o.key==="Enter"){if(u||o.nativeEvent.isComposing||o.shiftKey)return;o.preventDefault();const c=o.currentTarget.form,m=c==null?void 0:c.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;c==null||c.requestSubmit()}if(o.key==="Backspace"&&o.currentTarget.value===""&&g.files.length>0){o.preventDefault();const c=g.files.at(-1);c&&g.remove(c.id)}},k=o=>{var P;const c=(P=o.clipboardData)==null?void 0:P.items;if(!c)return;const m=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&m.push(D)}m.length>0&&(o.preventDefault(),g.add(m))},T=l?{value:l.textInput.value,onChange:o=>{l.textInput.setInput(o.currentTarget.value),t==null||t(o)}}:{onChange:t};return e.jsx(We,{className:r.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>y(!1),onCompositionStart:()=>y(!0),onKeyDown:v,onPaste:k,placeholder:a,...n,...T})},lt=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("order-first flex-wrap gap-1",t),...s}),ct=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("justify-between gap-1",t),...s}),dt=({className:t,...s})=>e.jsx("div",{className:r.cn("flex items-center gap-1",t),...s}),W=({variant:t="ghost",className:s,size:a,...n})=>{const l=a??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ue,{className:r.cn(s),size:l,type:"button",variant:t,...n})},ut=t=>e.jsx(Te,{...t}),mt=({className:t,children:s,...a})=>e.jsx(Le,{asChild:!0,children:e.jsx(W,{className:t,...a,children:s??e.jsx(b.PlusIcon,{className:"size-4"})})}),pt=({className:t,...s})=>e.jsx(re,{align:"start",className:r.cn(t),...s}),ft=({className:t,variant:s="default",size:a="icon-sm",status:n,children:l,...g})=>{let u=e.jsx(b.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?u=e.jsx(b.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?u=e.jsx(b.SquareIcon,{className:"size-4"}):n==="error"&&(u=e.jsx(b.XIcon,{className:"size-4"})),e.jsx(ue,{"aria-label":"Submit",className:r.cn(t),size:a,type:"submit",variant:s,...g,children:l??u})},xt=({className:t,textareaRef:s,onTranscriptionChange:a,...n})=>{const[l,g]=d.useState(!1),[u,y]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const T=window.SpeechRecognition||window.webkitSpeechRecognition,o=new T;o.continuous=!0,o.interimResults=!0,o.lang="en-US",o.onstart=()=>{g(!0)},o.onend=()=>{g(!1)},o.onresult=c=>{var P;let m="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(m+=((P=D[0])==null?void 0:P.transcript)??"")}if(m&&(s!=null&&s.current)){const C=s.current,D=C.value,A=D+(D?" ":"")+m;C.value=A,C.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(A)}},o.onerror=c=>{console.error("Speech recognition error:",c.error),g(!1)},v.current=o,y(o)}return()=>{v.current&&v.current.stop()}},[s,a]);const k=d.useCallback(()=>{u&&(l?u.stop():u.start())},[u,l]);return e.jsx(W,{className:r.cn("relative transition-all duration-200",l&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!u,onClick:k,...n,children:e.jsx(b.MicIcon,{className:"size-4"})})},gt=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(Be,{closeDelay:s,openDelay:t,...a}),ht=({align:t="start",...s})=>e.jsx(le,{align:t,...s}),bt=t=>e.jsx(Ce,{...t}),vt=t=>e.jsx(ke,{...t}),jt=({className:t,children:s,title:a="Model Selector",...n})=>e.jsxs(Z,{className:r.cn("p-0",t),...n,children:[e.jsx(ee,{className:"sr-only",children:a}),e.jsx(te,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),yt=({className:t,...s})=>e.jsx(se,{className:r.cn("h-auto py-3.5",t),...s}),Nt=t=>e.jsx(ae,{...t}),wt=t=>e.jsx(ne,{...t}),St=t=>e.jsx(oe,{...t}),It=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:r.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ct=({className:t,...s})=>e.jsx("span",{className:r.cn("flex-1 truncate text-left",t),...s}),kt=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[n,l]=d.useState(!1),[g,u]=d.useState(""),y=U.getModelById(t)||U.getDefaultModel(),k=U.AI_MODELS.filter(o=>o.name.toLowerCase().includes(g.toLowerCase())||o.provider.toLowerCase().includes(g.toLowerCase())).reduce((o,c)=>(o[c.provider]||(o[c.provider]=[]),o[c.provider].push(c),o),{}),T=o=>{s(o),l(!1),u("")};return e.jsxs(bt,{open:n,onOpenChange:l,children:[e.jsx(vt,{asChild:!0,children:e.jsxs(r.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(b.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:y.name})]})}),e.jsxs(jt,{className:"w-96 p-0",children:[e.jsx(yt,{placeholder:"Search models...",value:g,onValueChange:u}),e.jsx(Nt,{children:Object.entries(k).map(([o,c])=>e.jsx(wt,{heading:o.charAt(0).toUpperCase()+o.slice(1),children:c.map(m=>e.jsxs(St,{value:m.id,onSelect:()=>T(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(It,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ct,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},o))})]})]})},$="chai-ai-selected-model",Rt=({input:t,setInput:s,onSend:a,onStop:n,isLoading:l,disabled:g,selectedLang:u,selectedModel:y=U.getDefaultModel().id,onModelChange:v})=>{const{t:k}=Ie.useTranslation(),[T,o]=d.useState(y),[c,m]=d.useState(null),P=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!u){const j=localStorage.getItem($);if(j)o(j),v==null||v(j);else{const M=U.getDefaultModel().id;o(M),v==null||v(M)}}},[u,v]);const A=j=>{var E;const M=j.files.find(L=>{var O;return(O=L.mediaType)==null?void 0:O.startsWith("image/")}),B=(M==null?void 0:M.url)||c;a((E=j.text)==null?void 0:E.trim(),void 0,B,T),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(rt,{onSubmit:A,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(lt,{className:"p-0",children:e.jsx(nt,{className:"pb-0",children:j=>e.jsx(at,{className:"text-xs",data:j})})}),e.jsx(it,{ref:P,value:t,onChange:j=>s(j.target.value),placeholder:k(u?"Ask to update content":"Ask me anything..."),disabled:l,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ct,{children:[u?e.jsx("div",{}):e.jsxs(dt,{children:[e.jsxs(ut,{children:[e.jsx(mt,{disabled:l,children:e.jsx(b.Paperclip,{size:16})}),e.jsx(pt,{children:e.jsx(ot,{})})]}),e.jsx(xt,{textareaRef:P,onTranscriptionChange:s,disabled:l}),e.jsx(kt,{selectedModel:T,onModelChange:j=>{o(j),v==null||v(j),localStorage.setItem($,j)},disabled:l}),e.jsxs(W,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(b.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),l?e.jsxs("button",{onClick:n,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:k("Stop generation"),children:[e.jsx(b.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:k("Stop")})]}):e.jsx(ft,{disabled:!t.trim()||g,children:e.jsx(b.Send,{size:16})})]})]})})})};exports.default=Rt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index--Lu_Q_nO.cjs"),c=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),o=require("lucide-react"),x=({selectedLang:s,isLoading:n,selectedBlock:l,onClick:i})=>{const{t}=c.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:l?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>i("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")," ",a.LANGUAGES[s]," ",e.jsx(o.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import { L as r } from "./index-
|
|
2
|
+
import { L as r } from "./index-B_T6ZeA4.js";
|
|
3
3
|
import { useTranslation as i } from "@chaibuilder/sdk";
|
|
4
4
|
import { Button as c } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { ArrowRight as m } from "lucide-react";
|
|
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation as r } from "@chaibuilder/sdk";
|
|
3
3
|
import { Card as c, CardHeader as o, CardTitle as i, CardContent as l, CardFooter as d, Button as m } from "@chaibuilder/sdk/ui";
|
|
4
4
|
import { CheckCircle as h, Check as u } from "lucide-react";
|
|
5
|
-
import { b as p, B as C } from "./index-
|
|
5
|
+
import { b as p, B as C } from "./index-B_T6ZeA4.js";
|
|
6
6
|
const k = () => {
|
|
7
7
|
const { setPageLockMeta: n } = p(), { t: a } = r(), s = async () => {
|
|
8
8
|
n({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),a=require("lucide-react"),n=require("./index
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),a=require("lucide-react"),n=require("./index--Lu_Q_nO.cjs"),l=()=>{const{setPageLockMeta:c}=n.usePageLockMeta(),{t}=i.useTranslation(),r=async()=>{c({})};return e.jsx(n.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(a.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(s.Button,{variant:"default",onClick:r,className:"flex-1 gap-2",children:[e.jsx(a.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=l;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { c as N, q as A, m as E, g as b, l as k, L as U } from "./index-
|
|
2
|
+
import { c as N, q as A, m as E, g as b, l as k, L as U } from "./index-B_T6ZeA4.js";
|
|
3
3
|
import { useTranslation as G, useLanguages as R, useSidebarActivePanel as W } from "@chaibuilder/sdk";
|
|
4
4
|
import { Dialog as q, DialogContent as B, DialogHeader as F, DialogTitle as H, DialogDescription as M, DialogFooter as Q, Button as v } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { get as $ } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index--Lu_Q_nO.cjs"),f=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),N=require("lodash-es"),v=require("react"),j=(e,r)=>{const n=r.filter(u=>u.parent===e);if(n.length===0)return 0;let a=n.length;return n.forEach(u=>{a+=j(u.id,r)}),a};function A({page:e,onClose:r}){const{t:n}=f.useTranslation(),[,a]=o.useSearchParams(),{mutate:u,isPending:x}=o.useDeletePage(),{data:P}=o.usePageTypes(),{data:h=[]}=o.useWebsitePages(),{setSelectedLang:S,fallbackLang:w}=f.useLanguages(),[,C]=f.useSidebarActivePanel(),l=!(e!=null&&e.primaryPage),{data:i=[]}=o.useLanguagePages(l?e==null?void 0:e.id:void 0),y=v.useMemo(()=>!l||!i?0:i.filter(c=>c.id!==(e==null?void 0:e.id)).length,[l,i,e==null?void 0:e.id]),m=v.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let c=j(e.id,h);return l&&i&&i.length>0&&i.forEach(D=>{D.id!==e.id&&(c+=j(D.id,h))}),c},[e==null?void 0:e.id,h,l,i]),L=()=>{x||u(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),a(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),a(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),S(w),C("outline"),r()}})},d=P==null?void 0:P.find(c=>c.key===(e==null?void 0:e.pageType));return t.jsx(s.Dialog,{open:!!e,onOpenChange:r,children:t.jsxs(s.DialogContent,{children:[t.jsxs(s.DialogHeader,{children:[t.jsx(s.DialogTitle,{children:n("Confirm Deletion")}),t.jsxs(s.DialogDescription,{className:"py-4 text-slate-500",children:[t.jsxs("div",{children:[n("Are you sure you want to remove")," ",t.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",d!=null&&d.hasSlug?(d==null?void 0:d.name)+"?":n("page?")]}),l&&(y>0||m>0)&&t.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[t.jsxs("div",{className:"font-semibold text-red-800",children:[n("Warning: Deleting this primary page will also delete"),":"]}),t.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[m>0&&t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:m})," ",n(m===1?"nested child page":"nested child pages")]}),y>0&&t.jsx("li",{children:n("All associated language pages")})]})]}),e.lang&&t.jsxs("div",{className:"py-2 text-sm",children:[n("Language"),":"," ",t.jsx("span",{className:"font-medium text-gray-500",children:N.get(o.LANGUAGES,e.lang,e.lang)})]})]})]}),t.jsxs(s.DialogFooter,{children:[t.jsx(s.Button,{variant:"outline",onClick:r,children:n("Cancel")}),t.jsx(s.Button,{variant:"destructive",disabled:x,onClick:L,children:n(x?"Deleting...":"Delete")})]})]})})}exports.default=A;
|