@chaibuilder/sdk 2.1.1 → 2.1.2
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/core.cjs +4 -4
- package/dist/core.d.ts +9 -21
- package/dist/core.js +290 -296
- package/package.json +3 -3
package/dist/core.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var X=Object.defineProperty;var J=(a,l,c)=>l in a?X(a,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[l]=c;var W=(a,l,c)=>J(a,typeof l!="symbol"?l+"":l,c);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),React=require("react"),tooltip=require("./tooltip-CkYl0YhP.cjs"),jotai=require("jotai"),lodashEs=require("lodash-es"),reactWrapBalancer=require("react-wrap-balancer"),reactI18next=require("react-i18next"),Functions=require("./Functions-BZmyleS1.cjs"),dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),reactIcons=require("@radix-ui/react-icons"),web=require("@react-hookz/web"),flagged=require("flagged"),runtime=require("@chaibuilder/runtime"),lucideReact=require("lucide-react"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),clsx=require("clsx"),tailwindMerge=require("tailwind-merge"),Autosuggest=require("react-autosuggest"),sonner=require("sonner"),Fuse=require("fuse.js"),chaiThemeHelpers=require("./chai-theme-helpers-D2bHv81c.cjs"),getSplitClasses=require("./getSplitClasses-DodqA_KW.cjs"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),TooltipPrimitive=require("@radix-ui/react-tooltip"),i18n=require("i18next"),reactErrorBoundary=require("react-error-boundary"),reactHotkeysHook=require("react-hotkeys-hook"),framerMotion=require("framer-motion"),TreeModel=require("tree-model"),aspectRatio=require("@tailwindcss/aspect-ratio"),containerQueries=require("@tailwindcss/container-queries"),forms=require("@tailwindcss/forms"),typography=require("@tailwindcss/typography"),ReactDOM=require("react-dom"),reResizable=require("re-resizable");function _interopNamespaceDefault(a){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const c in a)if(c!=="default"){const d=Object.getOwnPropertyDescriptor(a,c);Object.defineProperty(l,c,d.get?d:{enumerable:!0,get:()=>a[c]})}}return l.default=a,Object.freeze(l)}const React__namespace=_interopNamespaceDefault(React),isSelfAtom=(a,l)=>a.unstable_is?a.unstable_is(l):l===a,hasInitialValue=a=>"init"in a,isActuallyWritableAtom=a=>!!a.write,isAtomStateInitialized=a=>"v"in a||"e"in a,returnAtomValue=a=>{if("e"in a)throw a.e;return a.v},PROMISE_STATE=Symbol(),getPromiseState=a=>a[PROMISE_STATE],isPendingPromise=a=>{var l;return isPromiseLike$2(a)&&!((l=getPromiseState(a))!=null&&l[1])},cancelPromise=(a,l)=>{const c=getPromiseState(a);c&&(c[1]=!0,c[0].forEach(d=>d(l)))},patchPromiseForCancelability=a=>{if(getPromiseState(a))return;const l=[new Set,!1];a[PROMISE_STATE]=l;const c=()=>{l[1]=!0};a.then(c,c),a.onCancel=d=>{l[0].add(d)}},isPromiseLike$2=a=>typeof(a==null?void 0:a.then)=="function",addPendingPromiseToDependency=(a,l,c)=>{c.p.has(a)||(c.p.add(a),l.then(()=>{c.p.delete(a)},()=>{c.p.delete(a)}))},setAtomStateValueOrPromise=(a,l,c)=>{const d=c(a),u="v"in d,p=d.v,m=isPendingPromise(d.v)?d.v:null;if(isPromiseLike$2(l)){patchPromiseForCancelability(l);for(const h of d.d.keys())addPendingPromiseToDependency(a,l,c(h))}d.v=l,delete d.e,(!u||!Object.is(p,d.v))&&(++d.n,m&&cancelPromise(m,l))},getMountedOrPendingDependents=(a,l,c)=>{var d;const u=new Set;for(const p of((d=c.get(a))==null?void 0:d.t)||[])c.has(p)&&u.add(p);for(const p of l.p)u.add(p);return u},BUILDING_BLOCKS=Symbol(),buildStore=(a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new Set,u=new Set,p=new Set,m={},h=(b,...j)=>b.read(...j),g=(b,...j)=>b.write(...j),x=(b,j)=>{var R;return(R=b.unstable_onInit)==null?void 0:R.call(b,j)},f=(b,j)=>{var R;return(R=b.onMount)==null?void 0:R.call(b,j)},...y)=>{const b=y[0]||(B=>{let D=a.get(B);return D||(D={d:new Map,p:new Set,n:0},a.set(B,D),x==null||x(B,A)),D}),j=y[1]||(()=>{let B,D;const _=E=>{try{E()}catch(N){B||(B=!0,D=N)}};do{m.f&&_(m.f);const E=new Set,N=E.add.bind(E);d.forEach(P=>{var L;return(L=l.get(P))==null?void 0:L.l.forEach(N)}),d.clear(),p.forEach(N),p.clear(),u.forEach(N),u.clear(),E.forEach(_),d.size&&R()}while(d.size||p.size||u.size);if(B)throw D}),R=y[2]||(()=>{const B=[],D=new WeakSet,_=new WeakSet,E=Array.from(d);for(;E.length;){const N=E[E.length-1],P=b(N);if(_.has(N)){E.pop();continue}if(D.has(N)){c.get(N)===P.n&&B.push([N,P]),_.add(N),E.pop();continue}D.add(N);for(const L of getMountedOrPendingDependents(N,P,l))D.has(L)||E.push(L)}for(let N=B.length-1;N>=0;--N){const[P,L]=B[N];let M=!1;for(const O of L.d.keys())if(O!==P&&d.has(O)){M=!0;break}M&&(k(P),C(P)),c.delete(P)}}),k=y[3]||(B=>{var D,_;const E=b(B);if(isAtomStateInitialized(E)&&(l.has(B)&&c.get(B)!==E.n||Array.from(E.d).every(([U,$])=>k(U).n===$)))return E;E.d.clear();let N=!0;const P=()=>{l.has(B)&&(C(B),R(),j())},L=U=>{var $;if(isSelfAtom(B,U)){const H=b(U);if(!isAtomStateInitialized(H))if(hasInitialValue(U))setAtomStateValueOrPromise(U,U.init,b);else throw new Error("no atom init");return returnAtomValue(H)}const F=k(U);try{return returnAtomValue(F)}finally{E.d.set(U,F.n),isPendingPromise(E.v)&&addPendingPromiseToDependency(B,E.v,F),($=l.get(U))==null||$.t.add(B),N||P()}};let M,O;const Z={get signal(){return M||(M=new AbortController),M.signal},get setSelf(){return!O&&isActuallyWritableAtom(B)&&(O=(...U)=>{if(!N)try{return S(B,...U)}finally{R(),j()}}),O}},V=E.n;try{const U=h(B,L,Z);return setAtomStateValueOrPromise(B,U,b),isPromiseLike$2(U)&&((D=U.onCancel)==null||D.call(U,()=>M==null?void 0:M.abort()),U.then(P,P)),E}catch(U){return delete E.v,E.e=U,++E.n,E}finally{N=!1,V!==E.n&&c.get(B)===V&&(c.set(B,E.n),d.add(B),(_=m.c)==null||_.call(m,B))}}),v=y[4]||(B=>{const D=[B];for(;D.length;){const _=D.pop(),E=b(_);for(const N of getMountedOrPendingDependents(_,E,l)){const P=b(N);c.set(N,P.n),D.push(N)}}}),S=y[5]||((B,...D)=>{let _=!0;const E=P=>returnAtomValue(k(P)),N=(P,...L)=>{var M;const O=b(P);try{if(isSelfAtom(B,P)){if(!hasInitialValue(P))throw new Error("atom not writable");const Z=O.n,V=L[0];setAtomStateValueOrPromise(P,V,b),C(P),Z!==O.n&&(d.add(P),(M=m.c)==null||M.call(m,P),v(P));return}else return S(P,...L)}finally{_||(R(),j())}};try{return g(B,E,N,...D)}finally{_=!1}}),C=y[6]||(B=>{var D;const _=b(B),E=l.get(B);if(E&&!isPendingPromise(_.v)){for(const[N,P]of _.d)if(!E.d.has(N)){const L=b(N);I(N).t.add(B),E.d.add(N),P!==L.n&&(d.add(N),(D=m.c)==null||D.call(m,N),v(N))}for(const N of E.d||[])if(!_.d.has(N)){E.d.delete(N);const P=w(N);P==null||P.t.delete(B)}}}),I=y[7]||(B=>{var D;const _=b(B);let E=l.get(B);if(!E){k(B);for(const N of _.d.keys())I(N).t.add(B);if(E={l:new Set,d:new Set(_.d.keys()),t:new Set},l.set(B,E),(D=m.m)==null||D.call(m,B),isActuallyWritableAtom(B)){const N=()=>{let P=!0;const L=(...M)=>{try{return S(B,...M)}finally{P||(R(),j())}};try{const M=f(B,L);M&&(E.u=()=>{P=!0;try{M()}finally{P=!1}})}finally{P=!1}};u.add(N)}}return E}),w=y[8]||(B=>{var D;const _=b(B);let E=l.get(B);if(E&&!E.l.size&&!Array.from(E.t).some(N=>{var P;return(P=l.get(N))==null?void 0:P.d.has(B)})){E.u&&p.add(E.u),E=void 0,l.delete(B),(D=m.u)==null||D.call(m,B);for(const N of _.d.keys()){const P=w(N);P==null||P.t.delete(B)}return}return E}),T=[a,l,c,d,u,p,m,h,g,x,f,b,j,R,k,v,S,C,I,w],A={get:B=>returnAtomValue(k(B)),set:(B,...D)=>{try{return S(B,...D)}finally{R(),j()}},sub:(B,D)=>{const E=I(B).l;return E.add(D),j(),()=>{E.delete(D),w(B),j()}}};return Object.defineProperty(A,BUILDING_BLOCKS,{value:T}),A},INTERNAL_buildStoreRev1=buildStore;let keyCount=0;function atom(a,l){const c=`atom${++keyCount}`,d={toString(){return c}};return typeof a=="function"?d.read=a:(d.init=a,d.read=defaultRead,d.write=defaultWrite),l&&(d.write=l),d}function defaultRead(a){return a(this)}function defaultWrite(a,l,c){return l(this,typeof c=="function"?c(a(this)):c)}const createStore=()=>INTERNAL_buildStoreRev1();let defaultStore;const getDefaultStore=()=>(defaultStore||(defaultStore=createStore()),defaultStore),RESET=Symbol(""),getCached$1=(a,l,c)=>(l.has(c)?l:l.set(c,a())).get(c),cache1$2=new WeakMap,memo2$1=(a,l,c)=>{const d=getCached$1(()=>new WeakMap,cache1$2,l);return getCached$1(a,d,c)},cacheKeyForEmptyKeyExtractor={},isWritable=a=>!!a.write,isFunction=a=>typeof a=="function";function splitAtom(a,l){return memo2$1(()=>{const c=new WeakMap,d=(m,h)=>{let g=c.get(m);if(g)return g;const x=h&&c.get(h),f=[],y=[];return m.forEach((b,j)=>{const R=j;y[j]=R;const k=x&&x.atomList[x.keyList.indexOf(R)];if(k){f[j]=k;return}const v=C=>{const I=C(u),w=C(a),A=d(w,I==null?void 0:I.arr).keyList.indexOf(R);if(A<0||A>=w.length){const B=m[d(m).keyList.indexOf(R)];if(B)return B;throw new Error("splitAtom: index out of bounds for read")}return w[A]},S=(C,I,w)=>{const T=C(u),A=C(a),D=d(A,T==null?void 0:T.arr).keyList.indexOf(R);if(D<0||D>=A.length)throw new Error("splitAtom: index out of bounds for write");const _=isFunction(w)?w(A[D]):w;Object.is(A[D],_)||I(a,[...A.slice(0,D),_,...A.slice(D+1)])};f[j]=isWritable(a)?atom(v,S):atom(v)}),x&&x.keyList.length===y.length&&x.keyList.every((b,j)=>b===y[j])?g=x:g={arr:m,atomList:f,keyList:y},c.set(m,g),g},u=atom(m=>{const h=m(u),g=m(a);return d(g,h==null?void 0:h.arr)});u.init=void 0;const p=isWritable(a)?atom(m=>m(u).atomList,(m,h,g)=>{switch(g.type){case"remove":{const x=m(p).indexOf(g.atom);if(x>=0){const f=m(a);h(a,[...f.slice(0,x),...f.slice(x+1)])}break}case"insert":{const x=g.before?m(p).indexOf(g.before):m(p).length;if(x>=0){const f=m(a);h(a,[...f.slice(0,x),g.value,...f.slice(x)])}break}case"move":{const x=m(p).indexOf(g.atom),f=g.before?m(p).indexOf(g.before):m(p).length;if(x>=0&&f>=0){const y=m(a);x<f?h(a,[...y.slice(0,x),...y.slice(x+1,f),y[x],...y.slice(f)]):h(a,[...y.slice(0,f),y[x],...y.slice(f,x),...y.slice(x+1)])}break}}}):atom(m=>m(u).atomList);return p},a,cacheKeyForEmptyKeyExtractor)}const isPromiseLike$1=a=>typeof(a==null?void 0:a.then)=="function";function createJSONStorage(a=()=>{try{return window.localStorage}catch{return}},l){var c;let d,u;const p={getItem:(g,x)=>{var f,y;const b=R=>{if(R=R||"",d!==R){try{u=JSON.parse(R,l==null?void 0:l.reviver)}catch{return x}d=R}return u},j=(y=(f=a())==null?void 0:f.getItem(g))!=null?y:null;return isPromiseLike$1(j)?j.then(b):b(j)},setItem:(g,x)=>{var f;return(f=a())==null?void 0:f.setItem(g,JSON.stringify(x,void 0))},removeItem:g=>{var x;return(x=a())==null?void 0:x.removeItem(g)}},m=g=>(x,f,y)=>g(x,b=>{let j;try{j=JSON.parse(b||"")}catch{j=y}f(j)});let h;try{h=(c=a())==null?void 0:c.subscribe}catch{}return!h&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(h=(g,x)=>{if(!(a()instanceof window.Storage))return()=>{};const f=y=>{y.storageArea===a()&&y.key===g&&x(y.newValue)};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}}),h&&(p.subscribe=m(h)),p}const defaultStorage=createJSONStorage();function atomWithStorage(a,l,c=defaultStorage,d){const u=atom(l);return u.onMount=m=>{m(c.getItem(a,l));let h;return c.subscribe&&(h=c.subscribe(a,m,l)),h},atom(m=>m(u),(m,h,g)=>{const x=typeof g=="function"?g(m(u)):g;return x===RESET?(h(u,l),c.removeItem(a)):x instanceof Promise?x.then(f=>(h(u,f),c.setItem(a,f))):(h(u,x),c.setItem(a,x))})}const StoreContext=React.createContext(void 0),useStore=a=>{const l=React.useContext(StoreContext);return(a==null?void 0:a.store)||l||getDefaultStore()},isPromiseLike=a=>typeof(a==null?void 0:a.then)=="function",attachPromiseMeta=a=>{a.status="pending",a.then(l=>{a.status="fulfilled",a.value=l},l=>{a.status="rejected",a.reason=l})},use=React.use||(a=>{if(a.status==="pending")throw a;if(a.status==="fulfilled")return a.value;throw a.status==="rejected"?a.reason:(attachPromiseMeta(a),a)}),continuablePromiseMap=new WeakMap,createContinuablePromise=a=>{let l=continuablePromiseMap.get(a);return l||(l=new Promise((c,d)=>{let u=a;const p=g=>x=>{u===g&&c(x)},m=g=>x=>{u===g&&d(x)},h=g=>{"onCancel"in g&&typeof g.onCancel=="function"&&g.onCancel(x=>{isPromiseLike(x)?(continuablePromiseMap.set(x,l),u=x,x.then(p(x),m(x)),h(x)):c(x)})};a.then(p(a),m(a)),h(a)}),continuablePromiseMap.set(a,l)),l};function useAtomValue(a,l){const c=useStore(l),[[d,u,p],m]=React.useReducer(x=>{const f=c.get(a);return Object.is(x[0],f)&&x[1]===c&&x[2]===a?x:[f,c,a]},void 0,()=>[c.get(a),c,a]);let h=d;if((u!==c||p!==a)&&(m(),h=c.get(a)),React.useEffect(()=>{const x=c.sub(a,()=>{m()});return m(),x},[c,a,void 0]),React.useDebugValue(h),isPromiseLike(h)){const x=createContinuablePromise(h);return use(x)}return h}function useSetAtom(a,l){const c=useStore(l);return React.useCallback((...u)=>c.set(a,...u),[c,a])}function useAtom(a,l){return[useAtomValue(a,l),useSetAtom(a,l)]}function useAtomCallback(a,l){const c=React.useMemo(()=>atom(null,(d,u,...p)=>a(d,u,...p)),[a]);return useSetAtom(c,l)}const readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const inlineEditingActiveAtom=jotai.atom("");inlineEditingActiveAtom.debugLabel="inlineEditingActiveAtom";const draggingFlagAtom=jotai.atom(!1);draggingFlagAtom.debugLabel="draggingFlagAtom";const treeRefAtom=jotai.atom(null);treeRefAtom.debugLabel="treeRefAtom";const canvasSettingsAtom=jotai.atom({});canvasSettingsAtom.debugLabel="canvasSettingsAtom";const aiAssistantActiveAtom=jotai.atom(!1);aiAssistantActiveAtom.debugLabel="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";class Content extends React.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return React.Children.only(this.props.children)}}let doc,win;typeof document<"u"&&(doc=document);typeof window<"u"&&(win=window);const FrameContext=React.createContext({document:doc,window:win}),useFrame=()=>React.useContext(FrameContext),{Provider:FrameContextProvider,Consumer:FrameContextConsumer}=FrameContext;class Frame extends React.Component{constructor(c,d){super(c,d);W(this,"setRef",c=>{this.nodeRef.current=c;const{forwardedRef:d}=this.props;typeof d=="function"?d(c):d&&(d.current=c)});W(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});W(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=React.createRef(),this.state={iframeLoaded:!1}}componentDidMount(){this._isMounted=!0,this.getDoc()&&this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded",this.handleLoad)}componentWillUnmount(){this._isMounted=!1,this.nodeRef.current.removeEventListener("DOMContentLoaded",this.handleLoad)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){const c=this.getDoc();return this.props.mountTarget?c.querySelector(this.props.mountTarget):c.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const c=this.getDoc();if(!c)return null;const d=this.props.contentDidMount,u=this.props.contentDidUpdate,p=c.defaultView||c.parentView,m=jsxRuntime.jsx(Content,{contentDidMount:d,contentDidUpdate:u,children:jsxRuntime.jsx(FrameContextProvider,{value:{document:c,window:p},children:jsxRuntime.jsx("div",{className:"frame-content",children:this.props.children})})}),h=this.getMountTarget();return[ReactDOM.createPortal(this.props.head,this.getDoc().head),ReactDOM.createPortal(m,h)]}render(){const c={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete c.head,delete c.initialContent,delete c.mountTarget,delete c.contentDidMount,delete c.contentDidUpdate,delete c.forwardedRef,jsxRuntime.jsx("iframe",{...c,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}W(Frame,"defaultProps",{style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'});const ChaiFrame=React.forwardRef((a,l)=>jsxRuntime.jsx(Frame,{...a,forwardedRef:l}));function duplicateBlocks(a,l,c){const d=lodashEs.filter(a,p=>p._parent===l),u=[];for(let p=0;p<d.length;p++){const m=getSlots(d[p]);if(Object.keys(m).length>0&&Object.keys(m).forEach(h=>{d[p][h]=`slot:${Functions.generateUUID()}`}),lodashEs.filter(a,{_parent:d[p]._id}).length>0){const h=Functions.generateUUID();u.push({...d[p],oldId:d[p]._id,_id:h,_parent:c}),u.push(lodashEs.flatten(duplicateBlocks(a,d[p]._id,h)))}else u.push({...d[p],oldId:d[p]._id,_id:Functions.generateUUID(),_parent:c})}return lodashEs.flatten(u)}function convertToBlocksTree(a){const l={};a.forEach(d=>{l[d._id]={...d,children:[]}});const c=[];return a.forEach(d=>{if(d._parent){const u=l[d._parent];u&&u.children.push(l[d._id])}else c.push(l[d._id])}),c}const getSlots=a=>{const l={};return Object.keys(a).forEach(c=>{lodashEs.isString(a[c])&&a[c].startsWith("slot")&&(l[c]=a[c].replace("slot:",""))}),l},getDuplicatedBlocks=(a,l,c=null)=>{let d=lodashEs.find(a,{_id:l});d={...d,oldId:d._id,_id:Functions.generateUUID()},c!==(d==null?void 0:d._parent)&&(d={...d,_parent:c});const u=[d];lodashEs.filter(a,{_parent:l}).length>0&&u.push(lodashEs.flatten(duplicateBlocks(a,l,d._id)));const p=lodashEs.flatten(u);return lodashEs.map(p,m=>{const h=m,g=getSlots(h);return Object.keys(g).length>0&&Object.keys(g).forEach(x=>{const f=lodashEs.find(p,{oldId:g[x].replace("slot:","")});h[x]=`slot:${f._id}`}),lodashEs.omit(h,["global","oldId"])})},presentBlocksAtom=jotai.atom([]);presentBlocksAtom.debugLabel="presentBlocksAtom";const treeDSBlocks=jotai.atom(a=>{const l=a(presentBlocksAtom);return convertToBlocksTree([...l])});treeDSBlocks.debugLabel="treeDSBlocks";const pageBlocksAtomsAtom=splitAtom(presentBlocksAtom);pageBlocksAtomsAtom.debugLabel="pageBlocksAtomsAtom";const builderActivePageAtom=jotai.atom("");builderActivePageAtom.debugLabel="builderActivePageAtom";const destinationDropIndexAtom=jotai.atom(-1);destinationDropIndexAtom.debugLabel="destinationDropIndexAtom";const buildingBlocksAtom=jotai.atom([]);buildingBlocksAtom.debugLabel="buildingBlocksAtom";const globalBlocksAtom=jotai.atom(a=>{const l=a(buildingBlocksAtom);return lodashEs.filter(l,c=>lodashEs.has(c,"blockId"))});globalBlocksAtom.debugLabel="globalBlocksAtom";const broadcastChannel=new BroadcastChannel("chaibuilder"),useBroadcastChannel=()=>{const a=useBuilderProp("pageId","chaibuilder_page");return{postMessage:web.useDebouncedCallback(c=>broadcastChannel.postMessage({...c,pageId:a}),[a],200)}},useUnmountBroadcastChannel=()=>{const[,a]=useBlocksStore(),l=useBuilderProp("pageId","chaibuilder_page"),{updateBlocksProps:c}=useBlocksStoreManager();React.useEffect(()=>(broadcastChannel.onmessageerror=d=>{console.log("error",d)},broadcastChannel.onmessage=d=>{d.data.type==="blocks-updated"&&d.data.pageId===l&&a(d.data.blocks),d.data.type==="blocks-props-updated"&&d.data.pageId===l&&c(d.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[a,l])},selectedBlockIdsAtom=jotai.atom([]);selectedBlockIdsAtom.debugLabel="selectedBlockIdsAtom";const selectedBlocksAtom=jotai.atom(a=>{const l=a(presentBlocksAtom),c=a(selectedBlockIdsAtom);return lodashEs.map(lodashEs.filter(l,({_id:d})=>lodashEs.includes(c,d)),d=>({...d}))});selectedBlocksAtom.debugLabel="selectedBlocksAtom";const selectedBlockAtom=jotai.atom(a=>{const l=a(selectedBlocksAtom);if(l.length===0)return null;if(l.length===1)return l[0]});selectedBlockAtom.debugLabel="selectedBlockAtom";const getParentId=a=>lodashEs.get(a,"_parent",null),selectedBlocksParentsAtom=jotai.atom(a=>{const l=a(selectedBlocksAtom),c=lodashEs.map(l,getParentId);return lodashEs.filter(a(presentBlocksAtom),d=>lodashEs.includes(c,d._id))});selectedBlocksParentsAtom.debugLabel="selectedBlocksParentsAtom";const selectedBlockFlexChildAtom=jotai.atom(()=>!1);selectedBlockFlexChildAtom.debugLabel="selectedBlockFlexChildAtom";const selectedBlockGridChildAtom=jotai.atom(()=>!1);selectedBlockGridChildAtom.debugLabel="selectedBlockGridChildAtom";const styleStateAtom=jotai.atom("");styleStateAtom.debugLabel="styleStateAtom";const styleBreakpointAtom=atomWithStorage("styleBreakpoint","xs");styleBreakpointAtom.debugLabel="styleBreakpointAtom";const useSelectedBlocksDisplayChild=()=>({flexChild:jotai.useAtomValue(selectedBlockFlexChildAtom),gridChild:jotai.useAtomValue(selectedBlockGridChildAtom)}),useSelectedBlock=()=>jotai.useAtomValue(selectedBlockAtom),selectedBlockHierarchy=jotai.atom(a=>{const l=a(selectedBlockAtom),c=a(presentBlocksAtom);let d=l;const u=[l];do{const p=c.find(({_id:m})=>m===(d==null?void 0:d._parent));d=p,p&&u.push(p)}while(d!=null&&d._parent);return u}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[a,l]=jotai.useAtom(selectedBlockIdsAtom),c=React.useCallback(d=>{l(u=>lodashEs.includes(u,d)?lodashEs.without(u,d):[...u,d])},[l]);return[a,l,c]},removeNestedBlocks=(a,l)=>{let c=[...a],d=[];l.forEach(h=>{const g=c.find(y=>y._id===h);if(!g||!g._parent)return;const x=g._parent,f=c.filter(y=>y._parent===x);if(f.length===2){const y=f.find(b=>b._id!==h);if(y&&y._type==="Text"){const b=c.find(j=>j._id===x);b&&"content"in b&&(c=c.map(j=>{if(j._id===x){const R={...j,content:y.content};return Object.keys(y).forEach(k=>{k.startsWith("content-")&&(R[k]=y[k])}),R}return j}),d.push(y._id))}}});const u=[...l,...d],p=[],m=lodashEs.filter(c,h=>lodashEs.includes(u,h._id)||lodashEs.includes(u,h._parent)?(p.push(h._id),!1):!0);return lodashEs.isEmpty(p)?m:removeNestedBlocks(m,p)},useRemoveBlocks=()=>{const[a]=useBlocksStore(),[l,c]=useSelectedBlockIds(),{setNewBlocks:d}=useBlocksStoreUndoableActions(),{hasPermission:u}=usePermissions();return React.useCallback(p=>{var h;if(!u(PERMISSIONS.DELETE_BLOCK))return;const m=((h=lodashEs.find(a,{_id:p[0]}))==null?void 0:h._parent)||null;d(removeNestedBlocks(a,p)),setTimeout(()=>c(m?[m]:[]),200)},[a,c,l,u])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(a,l,{id:c,props:d})=>{const u=a(pageBlocksAtomsAtom),p=lodashEs.find(u,m=>a(m)._id===c);if(!p)throw new Error(`Block with id ${c} not found`);return l(p,{...a(p),...d})}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtomValue=a=>useAtomCallback(React.useCallback((l,c,d)=>{const u=l(a);if(!u||!u.length)throw new Error("No blocks available");const p=lodashEs.find(u,m=>l(m)._id===(lodashEs.isString(d)?d:l(d)._id));if(!p)throw new Error(`Block with id ${d} not found`);return l(p)},[a]),{store:builderStore}),useGetBlockAtom=a=>useAtomCallback(React.useCallback((l,c,d)=>{const u=l(a);if(!u||!u.length)return console.warn("No blocks available in splitAtoms"),null;const p=lodashEs.find(u,m=>l(m)._id===(lodashEs.isString(d)?d:l(d)._id));return p||(console.warn(`Block with id ${d} not found`),null)},[a]),{store:builderStore});function insertBlocksAtPosition(a,l,c,d){const u=[...l];let p=[...a];if(c){const x=a.find(f=>f._id===c);if(x&&x.content!==void 0&&x.content!==""&&!a.some(y=>y._parent===c)){const b={_id:Functions.generateUUID(),_parent:c,_type:"Text",content:x.content};Object.keys(x).forEach(j=>{j.startsWith("content-")&&(b[j]=x[j])}),u.unshift(b),p=p.map(j=>{if(j._id===c){const R={...j,content:""};return Object.keys(R).forEach(k=>{k.startsWith("content-")&&(R[k]="")}),R}return j})}}let m=p.filter(x=>!x._parent);c&&(m=p.filter(x=>x._parent===c));const h=!isNaN(d)||d>-1?Math.min(d,m.length):m.length;let g=p.length;for(let x=0,f=0;x<p.length;x++)if(c!==void 0?p[x]._parent===c:!p[x]._parent){if(f===h){g=x;break}f++}return!c&&d!==void 0&&d>=m.length&&(g=p.length),[...p.slice(0,g),...u,...p.slice(g)]}function getBlocksTree(a){return convertToBlocksTree(a)}function flattenTree(a){let l=[];return a.walk(c=>(delete c.model.children,l.push(c.model),!0)),l}function findNodeById(a,l){return a.first(c=>c.model._id===l)||null}function moveNode(a,l,c,d){var x,f;const u=findNodeById(a,l),p=findNodeById(a,c);if(!u||!p)return!1;p.children||(p.model.children=[]);let m=(x=p==null?void 0:p.children)==null?void 0:x.findIndex(y=>y.model._id===l);u.drop(),m=Math.max(m,0);const g=(((f=u==null?void 0:u.model)==null?void 0:f._parent)||"root")===c&&m<=d?d-1:d;try{p.addChildAtIndex(u,g)}catch(y){return console.error("Error adding child to parent:",y),!1}return!0}function handleOldParentTextBlock(a,l){if(!l||!l._parent)return a;const c=l._parent,d=a.find(p=>p._id===c);if(!d)return a;const u=a.filter(p=>p._parent===c);if(u.length===2){const p=u.find(m=>m._id!==l._id);if(p&&p._type==="Text"&&"content"in d)return a.map(h=>{if(h._id===c){const g={...h,content:p.content};return Object.keys(p).forEach(x=>{x.startsWith("content-")&&(g[x]=p[x])}),g}return h}).filter(h=>h._id!==p._id)}return a}function handleNewParentTextBlock(a,l,c){if(!c||c==="root")return a;const d=a.find(u=>u._id===c);if(!d)return a;if(d.content!==void 0&&d.content!==""&&!a.some(p=>p._parent===c&&p._id!==l._id)){const m={_id:Functions.generateUUID(),_parent:c,_type:"Text",content:d.content};Object.keys(d).forEach(x=>{x.startsWith("content-")&&(m[x]=d[x])});const h=a.map(x=>{if(x._id===c){const f={...x,content:""};return Object.keys(f).forEach(y=>{y.startsWith("content-")&&(f[y]="")}),f}return x}),g=h.findIndex(x=>x._id===l._id);return g!==-1?[...h.slice(0,g),m,...h.slice(g)]:[m,...h]}return a}function moveBlocksWithChildren(a,l,c,d){if(!l)return a;const u=a.find(x=>x._id===l);if(!u)return a;let p=handleOldParentTextBlock(a,u);const m=c||"root",g=new TreeModel().parse({_id:"root",children:getBlocksTree(p)});if(moveNode(g,l,m,d)){let x=flattenTree(g);const f=x.find(y=>y._id===l);return f&&(f._parent=m==="root"?null:m),x.shift(),c&&(x=handleNewParentTextBlock(x,u,c)),x}return p}const useBlocksStoreManager=()=>{const[,a]=useBlocksStore(),{postMessage:l}=useBroadcastChannel(),c=useUpdateBlockAtom();return{setNewBlocks:d=>{a(d),l({type:"blocks-updated",blocks:d})},addBlocks:(d,u,p)=>{a(m=>{const h=insertBlocksAtPosition(m,d,u,p);return l({type:"blocks-updated",blocks:h}),h})},removeBlocks:d=>{a(u=>{const p=removeNestedBlocks(u,d);return l({type:"blocks-updated",blocks:p}),p})},moveBlocks:(d,u,p)=>{a(m=>{let h=[...m];for(let g=0;g<d.length;g++)h=moveBlocksWithChildren(h,d[g],u,p);return lodashEs.each(d,g=>{const x=lodashEs.find(h,f=>f._id===g);x&&c({id:g,props:{_parent:x._parent||null}})}),l({type:"blocks-updated",blocks:h}),h})},updateBlocksProps:d=>{d.forEach(u=>{const p=lodashEs.omit(u,"_id");c({id:u._id,props:p})}),l({type:"blocks-props-updated",blocks:d})}}};var undomanager={exports:{}},hasRequiredUndomanager;function requireUndomanager(){return hasRequiredUndomanager||(hasRequiredUndomanager=1,function(a){(function(){function l(d,u,p){return d.splice(u,!p||1+p-u+(!(p<0^u>=0)&&(p<0||-1)*d.length)),d.length}let c=function(){let d=[],u=-1,p=0,m=!1,h;function g(x,f){return!x||typeof x[f]!="function"?this:(m=!0,x[f](),m=!1,this)}return{add:function(x){return m?this:(d.splice(u+1,d.length-u),d.push(x),p&&d.length>p&&l(d,0,-(p+1)),u=d.length-1,h&&h(),this)},setCallback:function(x){h=x},undo:function(){let x=d[u];if(!x)return this;const f=x.groupId;for(;x.groupId===f&&(g(x,"undo"),u-=1,x=d[u],!(!x||!x.groupId)););return h&&h(),this},redo:function(){let x=d[u+1];if(!x)return this;const f=x.groupId;for(;x.groupId===f&&(g(x,"redo"),u+=1,x=d[u+1],!(!x||!x.groupId)););return h&&h(),this},clear:function(){let x=d.length;d=[],u=-1,h&&x>0&&h()},hasUndo:function(){return u!==-1},hasRedo:function(){return u<d.length-1},getCommands:function(x){return x?d.filter(f=>f.groupId===x):d},getIndex:function(){return u},setLimit:function(x){p=x}}};a.exports?a.exports=c:window.UndoManager=c})()}(undomanager)),undomanager.exports}var undomanagerExports=requireUndomanager();const UndoManager=chaiThemeHelpers.getDefaultExportFromCjs(undomanagerExports),chaiBuilderPropsAtom=jotai.atom(null);chaiBuilderPropsAtom.debugLabel="chaiBuilderPropsAtom";const chaiExternalDataAtom=jotai.atom({});chaiExternalDataAtom.debugLabel="chaiExternalDataAtom";const chaiRjsfFieldsAtom=jotai.atom({});chaiRjsfFieldsAtom.debugLabel="chaiRjsfFieldsAtom";const chaiRjsfWidgetsAtom=jotai.atom({});chaiRjsfWidgetsAtom.debugLabel="chaiRjsfWidgetsAtom";const chaiRjsfTemplatesAtom=jotai.atom({});chaiRjsfTemplatesAtom.debugLabel="chaiRjsfTemplatesAtom";const chaiPageExternalDataAtom=jotai.atom({});chaiPageExternalDataAtom.debugLabel="chaiPageExternalDataAtom";const usePageExternalData=()=>jotai.useAtomValue(chaiPageExternalDataAtom),useBuilderProp=(a,l=void 0)=>{const c=jotai.useAtomValue(chaiBuilderPropsAtom);return lodashEs.get(c,a,l)},MODIFIERS=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"],BRANDING_OPTIONS_DEFAULTS={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"},brandingOptionsAtom=jotai.atom(BRANDING_OPTIONS_DEFAULTS);jotai.atom(null);const useBrandingOptions=()=>{const[a,l]=jotai.useAtom(brandingOptionsAtom);return[lodashEs.isObject(a)?{...BRANDING_OPTIONS_DEFAULTS,...a}:BRANDING_OPTIONS_DEFAULTS,l]},currentPageAtom=jotai.atom(null),useCurrentPage=()=>({currentPage:jotai.useAtomValue(currentPageAtom)}),getBlockBuilderProps=lodashEs.memoize(a=>{const l=runtime.getRegisteredChaiBlock(a),c=lodashEs.get(l,"schema.properties",{});return lodashEs.compact(Object.keys(c).map(d=>lodashEs.get(c[d],"builderProp",!1)||lodashEs.get(c[d],"runtime",!1)?d:null))}),useGetPageData=()=>{const[a]=useBrandingOptions(),{currentPage:l}=useCurrentPage(),[c]=useBlocksStore();return React.useCallback(()=>{const d=lodashEs.map(c,u=>lodashEs.omit(u,getBlockBuilderProps(u._type)));return{currentPage:l,blocks:d}},[a,l,c])},usePermissions=()=>{const a=useBuilderProp("permissions",void 0);return{hasPermission:React.useCallback(c=>a?a.includes(c):!0,[a])}},getDefaultThemeValues=(a=chaiThemeHelpers.defaultThemeOptions)=>{const l={};return a.fontFamily&&(l.fontFamily=Object.entries(a.fontFamily).reduce((c,[d,u])=>({...c,[d.replace("font-","")]:u}),{})),l.borderRadius=a.borderRadius,a.colors&&(l.colors=a.colors.reduce((c,d)=>(Object.entries(d.items).forEach(([u,p])=>{c[u]=p}),c),{})),l},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const a=useThemeOptions(),l=React.useMemo(()=>getDefaultThemeValues(a),[a]),c=useBuilderProp("theme",{}),[d,u]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...l,...!lodashEs.isEmpty(c)&&c,...!lodashEs.isEmpty(d)&&d}),[l,c,d]),u]},useThemeOptions=()=>{const a=useBuilderProp("themeOptions",c=>c);return React.useMemo(()=>a(chaiThemeHelpers.defaultThemeOptions),[a])},rightPanelAtom=jotai.atom("block"),useRightPanel=()=>jotai.useAtom(rightPanelAtom),builderSaveStateAtom=jotai.atom("SAVED");builderSaveStateAtom.debugLabel="builderSaveStateAtom";const useSavePage=()=>{const[a,l]=jotai.useAtom(builderSaveStateAtom),c=useBuilderProp("onSave",async g=>{}),d=useBuilderProp("onSaveStateChange",lodashEs.noop),u=useGetPageData(),[p]=useTheme(),{hasPermission:m}=usePermissions();return{savePage:web.useThrottledCallback(async(g=!1)=>{if(!m("save_page"))return;l("SAVING"),d("SAVING");const x=u();return await c({autoSave:g,blocks:x.blocks,theme:p}),setTimeout(()=>{l("SAVED"),d("SAVED")},100),!0},[u,l,p,c,d],3e3),saveState:a,setSaveState:l}},undoManager=new UndoManager;undoManager.setLimit(50);const useUndoManager=()=>{const[,a]=jotai.useAtom(builderSaveStateAtom),l=useBuilderProp("onSaveStateChange",lodashEs.noop);return React.useEffect(()=>(undoManager.setCallback(()=>{a("UNSAVED"),l("UNSAVED")}),()=>{undoManager.setCallback(lodashEs.noop)}),[]),{add:undoManager.add,undo:undoManager.undo,redo:undoManager.redo,hasRedo:undoManager.hasRedo,hasUndo:undoManager.hasUndo,clear:undoManager.clear}},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:a}=useUndoManager(),[l]=useBlocksStore(),{setNewBlocks:c,addBlocks:d,removeBlocks:u,moveBlocks:p,updateBlocksProps:m}=useBlocksStoreManager();return{moveBlocks:(R,k,v)=>{const S=lodashEs.map(R,I=>{const T=l.find(D=>D._id===I)._parent||null,B=l.filter(D=>T?D._parent===T:!D._parent).map(D=>D._id).indexOf(I);return{_id:I,oldParent:T,oldPosition:B}}),C=S.find(({_id:I})=>I===R[0]);C&&C.oldParent===k&&C.oldPosition===v||(p(R,k,v),a({undo:()=>lodashEs.each(S,({_id:I,oldParent:w,oldPosition:T})=>{p([I],w,T)}),redo:()=>p(R,k,v)}))},addBlocks:(R,k,v)=>{d(R,k,v),a({undo:()=>u(lodashEs.map(R,"_id")),redo:()=>d(R,k,v)})},removeBlocks:R=>{var C;const k=(C=lodashEs.first(R))==null?void 0:C._parent,S=l.filter(I=>k?I._parent===k:!I._parent).indexOf(lodashEs.first(R));u(lodashEs.map(R,"_id")),a({undo:()=>d(R,k,S),redo:()=>u(lodashEs.map(R,"_id"))})},updateBlocks:(R,k,v)=>{let S=[];if(v)S=lodashEs.map(R,C=>({_id:C,...v}));else{const C=lodashEs.keys(k);S=lodashEs.map(R,I=>{const w=l.find(A=>A._id===I),T={_id:I};return lodashEs.each(C,A=>T[A]=w[A]),T})}m(lodashEs.map(R,C=>({_id:C,...k}))),a({undo:()=>m(S),redo:()=>m(lodashEs.map(R,C=>({_id:C,...k})))})},updateBlocksRuntime:(R,k)=>{m(lodashEs.map(R,v=>({_id:v,...k})))},setNewBlocks:R=>{c(R),a({undo:()=>c(l),redo:()=>c(R)})},updateMultipleBlocksProps:R=>{let k=[];k=lodashEs.map(R,v=>{const S=lodashEs.keys(v),C=l.find(w=>w._id===v._id),I={};return lodashEs.each(S,w=>I[w]=C[w]),I}),m(R),a({undo:()=>m(k),redo:()=>m(R)})}}},libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=a=>{const[l,c]=jotai.useAtom(libraryBlocksAtom),d=useBuilderProp("getUILibraryBlocks",lodashEs.noop),u=lodashEs.get(l,`${a==null?void 0:a.id}.blocks`,null),p=lodashEs.get(l,`${a==null?void 0:a.id}.loading`,"idle"),m=React.useRef("idle");React.useEffect(()=>{(async()=>{if(p==="complete"||m.current==="loading")return;m.current="loading",c(x=>({...x,[a==null?void 0:a.id]:{loading:"loading",blocks:[]}}));const g=await d(a);m.current="idle",c(x=>({...x,[a==null?void 0:a.id]:{loading:"complete",blocks:g||[]}}))})()},[a,u,p,m,c,d]);const h=React.useCallback(()=>{c(g=>({...g,[a==null?void 0:a.id]:{loading:"idle",blocks:[]}}))},[a,c]);return{data:u||[],isLoading:p==="loading",resetLibrary:h}},canAcceptChildBlock=(a,l)=>{if(!a)return!0;const c=runtime.getRegisteredChaiBlock(a);return c&&lodashEs.has(c,"canAcceptBlock")?c.canAcceptBlock(l):!1},canAddChildBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l?lodashEs.has(l,"canAcceptBlock"):!1},canBeNestedInside=(a,l)=>{const c=runtime.getRegisteredChaiBlock(l);return c&&lodashEs.has(c,"canBeNested")?c.canBeNested(a):!0},canDuplicateBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l&&lodashEs.has(l,"canDuplicate")?l.canDuplicate():!0},canDeleteBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l&&lodashEs.has(l,"canDelete")?l.canDelete():!0},canDropBlock=(a,{dragSource:l,dropTarget:c})=>{const d=lodashEs.get(l,"data._type",""),u=lodashEs.get(c,"data._type","");return canAcceptChildBlock(u,d)},useAddBlock=()=>{const[a]=useBlocksStore(),[,l]=useSelectedBlockIds(),{addBlocks:c}=useBlocksStoreUndoableActions(),d=React.useCallback((p,m,h)=>{var b;for(let j=0;j<p.length;j++){const{_id:R}=p[j];p[j]._id=Functions.generateUUID();const k=lodashEs.filter(p,{_parent:R});for(let v=0;v<k.length;v++)k[v]._parent=p[j]._id}const g=lodashEs.first(p);let x,f;return m&&(x=lodashEs.find(a,{_id:m}),p[0]._parent=m,f=m),!(x?canAcceptChildBlock(x==null?void 0:x._type,g._type):!0)&&x&&(p[0]._parent=x._parent,f=x._parent),c(p,f,h),l([(b=lodashEs.first(p))==null?void 0:b._id]),lodashEs.first(p)},[c,a,l]);return{addCoreBlock:React.useCallback((p,m,h)=>{if(lodashEs.has(p,"blocks")){const k=p.blocks;return d(k,m,h)}const g=Functions.generateUUID(),x=runtime.getDefaultBlockProps(p.type),f={_type:p.type,_id:g,...x,...lodashEs.has(p,"_name")&&{_name:p._name},...lodashEs.has(p,"partialBlockId")&&{partialBlockId:p.partialBlockId}};let y,b;return m&&(y=lodashEs.find(a,{_id:m}),f._parent=m,b=m),!canAcceptChildBlock(y==null?void 0:y._type,f._type)&&y&&(f._parent=y._parent,b=y._parent),c([f],b,h),l([f._id]),f},[c,d,a,l]),addPredefinedBlock:d}},STANDARD=[0,1,2,3,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],CLASS_VALUES={columns:[...lodashEs.range(1,13),"auto","3xs","2xs","xs","sm","md","lg","xl",...lodashEs.map(lodashEs.range(2,8),a=>`${a}xl`)],breakAfter:["auto","avoid","all","avoid-page","page","left","right","column"],breakInside:["auto","avoid","avoid-page","avoid-column"],display:["block","flex","grid","inline-block","inline","hidden"],objectFit:["contain","cover","fill","none","scale-down"],objectPosition:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],overflow:["auto","hidden","clip","visible","scroll"],overscroll:["auto","contain","none"],trbl:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"auto","1/2","1/3","2/3","1/4","2/4","3/4","full"],flexBasis:[...STANDARD,"auto","px","0.5","1.5","2.5","3.5","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12","full"],padding:[...STANDARD,"px","0.5","1.5","2.5","3.5"],margin:["auto",...STANDARD,"px","0.5","1.5","2.5","3.5"],scale:[0,50,75,90,95,100,105,110,125,150],origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left"],blendEffect:["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],borderWidth:[0,2,4,8],borderRadius:["global","none","sm","md","lg","xl","2xl","3xl","full"],indent:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],maxHeight:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"full","screen","min","max","fit"],space:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"px","reverse"],width:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12"],maxWidth:["0","none","xs","sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","full","min","max","fit","prose","screen-sm","screen-md","screen-lg","screen-xl","screen-2xl"],height:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","full","screen","min","max","fit"]},CLASSES_LIST={textColor:{classes:[],regExp:"text-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:lodashEs.map(CLASS_VALUES.columns,a=>`columns-${a}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:lodashEs.map(CLASS_VALUES.breakAfter,a=>`break-after-${a}`),regExp:"break-after-\\S+"},breakBefore:{classes:lodashEs.map(CLASS_VALUES.breakAfter,a=>`break-before-${a}`),regExp:"break-before-\\S+"},breakInside:{classes:lodashEs.map(CLASS_VALUES.breakInside,a=>`break-inside-${a}`),regExp:"break-inside-\\S+"},boxDecoration:{classes:["box-decoration-clone","box-decoration-slice"],regExp:"box-decoration-\\S+"},boxSizing:{classes:["box-border","box-content"],regExp:"box-(border|content)"},flexDirection:{classes:["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],regExp:"flex-(row|row-reverse|col|col-reverse)"},flexWrap:{classes:["flex-wrap","flex-wrap-reverse","flex-nowrap"],regExp:"flex-(wrap|wrap-reverse|nowrap)"},flexGrowShrink:{classes:["flex-1","flex-auto","flex-initial","flex-none"],regExp:"flex-1|flex-auto|flex-initial|flex-none"},gridColumns:{classes:lodashEs.map([...lodashEs.range(0,13),"none"],a=>`grid-cols-${a}`),regExp:"grid-cols-(\\d+|none)"},gridFlow:{classes:["grid-flow-row","grid-flow-col","grid-flow-row-dense","grid-flow-col-dense"],regExp:"grid-flow-(row|col|row-dense|col-dense)"},outlineStyle:{classes:lodashEs.map(["none","dashed","dotted","double","hidden"],a=>`outline-${a}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","hidden","none"],a=>`border-${a}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-${a}`),regExp:`overflow-(${CLASS_VALUES.overflow.join("|")})`},overflowX:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-x-${a}`),regExp:`overflow-x-(${CLASS_VALUES.overflow.join("|")})`},overflowY:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-y-${a}`),regExp:`overflow-y-(${CLASS_VALUES.overflow.join("|")})`},gridRows:{classes:lodashEs.map([1,2,3,4,5,6,"none"],a=>`grid-rows-${a}`),regExp:"grid-rows-(\\d|none)"},display:{classes:lodashEs.map(CLASS_VALUES.display,a=>a.toString()),regExp:`(${CLASS_VALUES.display.join("|")})`},float:{classes:["float-right","float-left","float-none"],regExp:"float-\\S+"},clear:{classes:["clear-right","clear-left","clear-none","clear-both"],regExp:"clear-\\S+"},isolation:{classes:["isolate","isolation-auto"],regExp:"isolate|isolation-auto"},objectFit:{classes:lodashEs.map(CLASS_VALUES.objectFit,a=>`object-${a}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:lodashEs.map(CLASS_VALUES.objectPosition,a=>`object-${a}`),regExp:`object-(${CLASS_VALUES.objectPosition.join("|")})`},overscroll:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-${a}`),regExp:`overscroll-(${CLASS_VALUES.overscroll.join("|")})`},overscrollX:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-x-${a}`),regExp:`overscroll-x-(${CLASS_VALUES.overscroll.join("|")})`},overscrollY:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-y-${a}`),regExp:`overscroll-y-(${CLASS_VALUES.overscroll.join("|")})`},inset:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-${a}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-x-${a}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-y-${a}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-${a}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-x-${a}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-y-${a}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-${a}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-x-${a}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-y-${a}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-${a}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-x-${a}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-y-${a}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-${a}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-x-${a}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-y-${a}`),regExp:"-?left-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},visibility:{classes:["visible","invisible"],regExp:"invisible|visible"},zIndex:{classes:lodashEs.map(["0",10,20,30,40,50,"auto"],a=>`z-${a}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:lodashEs.map(CLASS_VALUES.flexBasis,a=>`basis-${a}`),regExp:"basis-(\\d+|\\S+)"},flexGrow:{classes:["grow","grow-0"],regExp:"grow(-0)?"},flexShrink:{classes:["shrink","shrink-0"],regExp:"shrink(-0)?"},gridColSpan:{classes:["col-auto",...lodashEs.map(lodashEs.range(1,13),a=>`col-span-${a}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...lodashEs.map(lodashEs.range(1,14),a=>`col-start-${a}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...lodashEs.map(lodashEs.range(1,14),a=>`col-end-${a}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...lodashEs.map(lodashEs.range(1,7),a=>`row-span-${a}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...lodashEs.map(lodashEs.range(1,8),a=>`row-start-${a}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...lodashEs.map(lodashEs.range(1,8),a=>`row-end-${a}`),"row-end-auto"],regExp:"row-end-(\\d+|auto)"},gridAutoColumns:{classes:["auto-cols-auto","auto-cols-min","auto-cols-max","auto-cols-fr"],regExp:"auto-cols-(auto|min|max|fr)"},gridAutoRows:{classes:["auto-rows-auto","auto-rows-min","auto-rows-max","auto-rows-fr"],regExp:"auto-rows-(auto|min|max|fr)"},gap:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-${a}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-x-${a}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-y-${a}`),regExp:"gap-y-(px|\\d.\\d|\\d|\\[.*\\])"},justifyContent:{classes:["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"],regExp:"justify-(start|end|center|between|around|evenly)"},justifyItems:{classes:["justify-items-start","justify-items-end","justify-items-center","justify-items-stretch"],regExp:"justify-items-(start|end|center|stretch)"},justifySelf:{classes:["justify-self-auto","justify-self-start","justify-self-end","justify-self-center","justify-self-stretch"],regExp:"justify-self-(auto|start|end|center|stretch)"},placeContent:{classes:["place-content-center","place-content-start","place-content-end","place-content-between","place-content-around","place-content-evenly","place-content-stretch"],regExp:"place-content-(center|start|end|between|around|evenly|stretch)"},placeItems:{classes:["place-items-start","place-items-end","place-items-center","place-items-stretch"],regExp:"place-items-(start|end|center|stretch)"},placeSelf:{classes:["place-self-auto","place-self-start","place-self-end","place-self-center","place-self-stretch"],regExp:"place-self-(auto|start|end|center|stretch)"},alignContent:{classes:["content-center","content-start","content-end","content-between","content-around","content-evenly"],regExp:"content-(center|start|end|between|around|evenly)"},alignItems:{classes:["items-start","items-end","items-center","items-baseline","items-stretch"],regExp:"items-(start|end|center|baseline|stretch)"},alignSelf:{classes:["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"],regExp:"self-(auto|start|end|center|stretch|baseline)"},backgroundClip:{classes:["bg-clip-border","bg-clip-padding","bg-clip-content","bg-clip-text"],regExp:"bg-clip-(border|padding|content|text)"},dropShadow:{classes:lodashEs.map(["sm","md","lg","xl","2xl","none"],a=>`drop-shadow-${a}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],a=>`backdrop-blur-${a}`),regExp:"backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)"},backdropBrightness:{classes:lodashEs.map([0,50,75,90,95,100,105,110,125,150,200],a=>`backdrop-brightness-${a}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:lodashEs.map([0,50,75,100,125,150,200],a=>`backdrop-contrast-${a}`),regExp:"backdrop-contrast-(\\d+)"},backdropGrayScale:{classes:["backdrop-grayscale-0","backdrop-grayscale"],regExp:"backdrop-grayscale(-0)?"},backdropHueRotate:{classes:lodashEs.map([0,15,30,60,90,180],a=>`backdrop-hue-rotate-${a}`),regExp:"-?backdrop-hue-rotate-(\\d+)"},backdropInvert:{classes:["backdrop-invert-0","backdrop-invert"],regExp:"backdrop-invert(-0)?"},backdropOpacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],a=>`backdrop-opacity-${a}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:lodashEs.map([0,50,100,150,200],a=>`backdrop-saturate-${a}`),regExp:"backdrop-saturate-(\\d+)"},backdropSepia:{classes:["backdrop-sepia-0, backdrop-sepia"],regExp:"backdrop-sepia(-0)?"},backgroundOrigin:{classes:["bg-origin-border","bg-origin-padding","bg-origin-content"],regExp:"bg-origin-(border|padding|content)"},transformOrigin:{classes:lodashEs.map(CLASS_VALUES.origin,a=>`origin-${a}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`p-${a}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`px-${a}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`py-${a}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pt-${a}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pr-${a}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pb-${a}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pl-${a}`),regExp:"pl-(\\d+|\\S+|\\[.*\\])"},textDecorationStyle:{classes:["decoration-solid","decoration-double","decoration-dotted","decoration-dashed","decoration-wavy"],regExp:"decoration-(solid|double|dotted|dashed|wavy)"},textDecorationThickness:{classes:lodashEs.map(["auto","from-font","0",1,2,4,8],a=>`decoration-${a}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},margin:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`m-${a}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mx-${a}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`my-${a}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mt-${a}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mr-${a}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mb-${a}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`ml-${a}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:lodashEs.map(CLASS_VALUES.space,a=>`space-x-${a}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:lodashEs.map(CLASS_VALUES.space,a=>`space-y-${a}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:lodashEs.map(["sm","md","lg","xl","2xl","inner","none"],a=>`shadow-${a}`),regExp:"shadow-(sm|md|lg|xl|2xl|inner|none)"},minWidth:{classes:["min-w-0","min-w-full","min-w-min","min-w-max","min-w-fit"],regExp:"min-w-(\\d+|\\S+|\\[.*\\])"},maxWidth:{classes:lodashEs.map(CLASS_VALUES.maxWidth,a=>`max-w-${a}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:lodashEs.map([...CLASS_VALUES.width,"full","screen","min","max","fit"],a=>`w-${a}`),regExp:"w-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])$"},minHeight:{classes:["min-h-0","min-h-full","min-h-screen","min-h-min","min-h-max","min-h-fit"],regExp:"min-h-(\\d+|\\S+|\\[.*\\])"},maxHeight:{classes:lodashEs.map(CLASS_VALUES.maxHeight,a=>`max-h-${a}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:lodashEs.map(CLASS_VALUES.height,a=>`h-${a}`),regExp:"h-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])"},fontFamily:{classes:["font-heading","font-body","font-sans","font-serif","font-mono"],regExp:"font-(heading|body|sans|serif|mono)"},textAlign:{classes:["text-left","text-center","text-right","text-justify"],regExp:"text-(left|center|right|justify)"},textOverflow:{classes:["truncate","text-ellipsis","text-clip"],regExp:"truncate|text-ellipsis|text-clip"},verticalAlign:{classes:["align-baseline","align-top","align-middle","align-bottom","align-text-top","align-text-bottom","align-sub","align-super"],regExp:"align-(baseline|top|middle|bottom|text-top|text-bottom|sub|super)"},fontSize:{classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"],regExp:"text-(\\d+|\\S+|\\[.*\\])"},fontSmoothing:{classes:["antialiased","subpixel-antialiased"],regExp:"antialiased|subpixel-antialiased"},fontStyle:{classes:["italic","not-italic"],regExp:"not-italic|italic"},fontWeight:{classes:["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"],regExp:"font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)"},fontVariantNum:{classes:["normal-nums","ordinal","diagonal-fractions","stacked-fractions","tabular-nums","oldstyle-nums","proportional-nums","lining-nums","slashed-zero"],regExp:"normal-nums|ordinal|diagonal-fractions|stacked-fractions|tabular-nums|oldstyle-nums|proportional-nums|lining-nums|slashed-zero"},letterSpacing:{classes:["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"],regExp:"-?tracking-(tighter|tight|normal|wide|wider|widest|\\[.*\\])"},lineHeight:{classes:["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"],regExp:"leading-(none|tight|snug|normal|relaxed|loose|\\[.*\\]|\\d+)"},listStyleType:{classes:["list-none","list-disc","list-decimal"],regExp:"list-(none|disc|decimal)"},listStylePosition:{classes:["list-inside","list-outside"],regExp:"list-(inside|outside)"},textUnderlineOffset:{classes:["underline-offset-auto","underline-offset-0","underline-offset-1","underline-offset-2","underline-offset-4","underline-offset-8"],regExp:"underline-offset-(auto|\\d+|\\S+)"},textDecoration:{classes:["underline","overline","line-through","no-underline"],regExp:"underline|overline|line-through|no-underline"},textDecorationColor:{classes:[],regExp:"decoration-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`indent-${a}`),regExp:"-?indent-(\\d+|\\S+)"},whitespace:{classes:["whitespace-normal","whitespace-no-wrap","whitespace-pre","whitespace-pre-line","whitespace-pre-wrap"],regExp:"whitespace-(normal|no-wrap|pre|pre-line|pre-wrap)"},wordBreak:{classes:["break-normal","break-words","break-all"],regExp:"break-(normal|words|all)"},content:{classes:["content-none"],regExp:"content-none"},backgroundAttachment:{classes:lodashEs.map(["fixed","local","scroll"],a=>`bg-${a}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-tl-${a}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-tr-${a}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-br-${a}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-bl-${a}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-t-${a}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-r-${a}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-b-${a}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-l-${a}`)],regExp:`(rounded-l-(${CLASS_VALUES.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-${a}`)],regExp:`(rounded-(${CLASS_VALUES.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-x-${a}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-y-${a}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-t-${a}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-r-${a}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-b-${a}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-l-${a}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"^border-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-${a}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},order:{classes:lodashEs.map([...lodashEs.range(0,13),"first","last","none"],a=>`order-${a}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:lodashEs.map(["0",2,4,8],a=>`divide-x-${a}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:lodashEs.map(["0",2,4,8],a=>`divide-y-${a}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},divideStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","none"],a=>`divide-${a}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:lodashEs.map([0,1,2,4,8],a=>`outline-${a}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:lodashEs.map([0,1,2,4,8],a=>`outline-offset-${a}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringWidth:{classes:lodashEs.map([0,1,2,4,8,"inset"],a=>`ring-${a}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:lodashEs.map([0,1,2,4,8],a=>`ring-offset-${a}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],a=>`opacity-${a}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,a=>`mix-blend-${a}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,a=>`bg-blend-${a}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],a=>`blur-${a}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:lodashEs.map([0,50,75,90,95,100,105,110,125,150,200],a=>`brightness-${a}`),regExp:"brightness-(\\d+)"},contrast:{classes:lodashEs.map([0,50,75,100,125,150,200],a=>`contrast-${a}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:lodashEs.map([0,15,30,60,90,180],a=>`hue-rotate-${a}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:lodashEs.map([0,50,100,150,200],a=>`saturate-${a}`),regExp:"saturate-(\\d+)"},sepia:{classes:["sepia-0","sepia"],regExp:"sepia(-0)?"},transition:{classes:["transition-none","transition-all","transition-colors","transition-opacity","transition-shadow","transition-transform"],regExp:"transition-(none|all|colors|opacity|shadow|transform)"},duration:{classes:lodashEs.map([75,100,150,200,300,500,700,1e3],a=>`duration-${a}`),regExp:"duration-(\\d+|\\[.*\\])"},transitionEase:{classes:["ease-linear","ease-in","ease-out","ease-in-out"],regExp:"eas(e-linear|e-in|e-out|e-in-out)"},transitionDelay:{classes:lodashEs.map([75,100,150,200,300,500,700,1e3],a=>`delay-${a}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animation-none","animation-spin","animation-ping"],regExp:"animation-(none|spin|ping)"},scaleX:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-x-${a}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-y-${a}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-${a}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:lodashEs.map([0,1,2,3,6,12,45,90,180],a=>`rotate-${a}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:lodashEs.map([0,"px","0.5",1],a=>`translate-x-${a}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:lodashEs.map([0,"px","0.5",1],a=>`translate-y-${a}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:lodashEs.map([0,1,2,3,6,12],a=>`skew-x-${a}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:lodashEs.map([0,1,2,3,6,12],a=>`skew-y-${a}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},colorOptions={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},soloColors=["current","inherit","transparent","black","white"],shadedColors=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],shades=["50","100","200","300","400","500","600","700","800","900"],colorKeys=lodashEs.map(lodashEs.values(colorOptions),a=>a),ALL_COLORS=lodashEs.flattenDeep([...lodashEs.map(soloColors,a=>lodashEs.flatten(lodashEs.map(colorKeys,l=>`${l}-${a}`))),...lodashEs.map(shadedColors,a=>lodashEs.flattenDeep(lodashEs.map(colorKeys,l=>lodashEs.flattenDeep(lodashEs.map(shades,c=>`${l}-${a}-${c}`)))))]),ALL_TW_CLASSES=lodashEs.map(lodashEs.flattenDeep(lodashEs.values(CLASSES_LIST).map(a=>a.classes).concat(ALL_COLORS)),a=>({name:a})),useFuseSearch=()=>{const a=useThemeOptions(),l=React.useMemo(()=>{let c=[];if(a.colors){const d=lodashEs.flattenDeep(lodashEs.map(a.colors,({items:u})=>lodashEs.keys(u)));c=lodashEs.flattenDeep(lodashEs.map(d,u=>lodashEs.flatten(lodashEs.map(colorKeys,p=>`${p}-${u}`))))}return a.fontFamily&&(c=[...c,...lodashEs.map(lodashEs.keys(a.fontFamily),d=>`${d}`)]),lodashEs.map(c,d=>({name:d}))},[a]);return React.useMemo(()=>new Fuse([...ALL_TW_CLASSES,...l],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[l])},useTailwindClassList=()=>{const a=useThemeOptions(),l=React.useMemo(()=>{if(a.colors){const u=lodashEs.flattenDeep(lodashEs.map(a.colors,({items:p})=>lodashEs.keys(p)));lodashEs.each(CLASSES_LIST,(p,m)=>{lodashEs.set(CLASSES_LIST,`${m}.regExp`,p.regExp.replace("__THEME_COLORS_REGEXP__",u.join("|")))})}return CLASSES_LIST},[a]),c=React.useCallback((u,p)=>{const m=lodashEs.get(l,`${u}.regExp`,"");return p.match(new RegExp(m))},[l]),d=React.useCallback((u,p=[])=>lodashEs.get(l,`${u}.classes`,p),[l]);return{match:c,getClasses:d}};function getMqForCls(a){if(lodashEs.isEmpty(a.trim()))return"";const l=a.match(/sm:|md:|lg:|xl:|2xl:/g);return lodashEs.get(l,0,"xs").replace(":","")}function getModForCls(a){const l=lodashEs.map(MODIFIERS,d=>`${d}:`).join("|"),c=new RegExp(l,"g");return lodashEs.get(c.exec(a.trim()),0,"").replace(":","")}function getPureClsName(a){return a.trim().split(":").pop()||""}const memoizedProps={};function getPropertyForClass(a){if(lodashEs.isEmpty(a))return"";if(memoizedProps[a])return memoizedProps[a];let l="";for(const c in CLASSES_LIST){const d=lodashEs.get(CLASSES_LIST,`${c}.regExp`,"");if(new RegExp(d,"g").test(a)){l=c,memoizedProps[a]=l;break}}return l}function constructClassObject(a){return lodashEs.isEmpty(a)?null:{dark:lodashEs.startsWith(a,"dark:"),mq:getMqForCls(a),mod:getModForCls(a),cls:getPureClsName(a),fullCls:a,property:getPropertyForClass(a)}}function generateFullClsName(a){let l="";return a.dark&&(l+="dark:"),a.mq.toLowerCase()!=="xs"&&(l+=`${a.mq}:`),a.mod&&(l+=`${a.mod}:`),l+=a.cls,l}function orderClassesByBreakpoint(a){a=a.replace(/\s+/g," ");const l=a.split(" ").map(constructClassObject),c=["xs","sm","md","lg","xl","2xl"];return l.sort((d,u)=>c.indexOf(d.mq)-c.indexOf(u.mq)).map(d=>d.fullCls).join(" ")}function removeDuplicateClasses(a){if(a=a.replace(/\s+/g," "),!a)return"";const l=["xs","sm","md","lg","xl","2xl"],c=a.split(" ").map(constructClassObject);let d=a;if(c.length===1)return c[0].fullCls;for(const u of c){const p=u.property,m=l.indexOf(u.mq);for(let h=m+1;h<l.length;h++){const g=l[h],x=c.find(f=>f.property===p&&f.mq===g);if(x&&x.cls===u.cls)d=d.replace(x.fullCls,"");else if(x&&x.cls!==u.cls)break}}return d.replace(/\s+/g," ").trim()}const selectedStylingBlocksAtom=jotai.atom([]);selectedStylingBlocksAtom.debugLabel="selectedStylingBlocksAtom";const useSelectedStylingBlocks=()=>jotai.useAtom(selectedStylingBlocksAtom),addClassesToBlocksAtom=jotai.atom(null,(a,l,{blockIds:c,newClasses:d})=>{const u=lodashEs.filter(a(pageBlocksAtomsAtom),m=>c.includes(a(m)._id)),p=lodashEs.first(a(selectedStylingBlocksAtom));return lodashEs.map(u,m=>{const h=a(m),g=lodashEs.get(h,p.prop,`${getSplitClasses.STYLES_KEY},`),{classes:x}=getSplitClasses.getSplitChaiClasses(g);return{ids:[h._id],props:{[p.prop]:`${getSplitClasses.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(x,d)))}`}}})}),useAddClassesToBlocks=()=>{const a=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:l,updateBlocksRuntime:c}=useBlocksStoreUndoableActions();return React.useCallback((d,u,p=!1)=>{const m=a({blockIds:d,newClasses:u});if(!p){c(d,m[0].props);return}l(d,m[0].props)},[a,l,c])},LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},languageAtom=jotai.atom("");languageAtom.debugLabel="selectedLanguageAtom";const useLanguages=()=>{const a=useBuilderProp("languages",[]),l=useBuilderProp("fallbackLang","en"),[c,d]=jotai.useAtom(languageAtom),u=p=>{d(l===p?"":p)};return{languages:a==null?void 0:a.filter(p=>p!==l),fallbackLang:l,selectedLang:c,setSelectedLang:u}},updatePropsForLanguage=(a,l,c)=>{const d=runtime.getRegisteredChaiBlock(lodashEs.get(c,"_type"));if(!d)return a;const u={...a};return lodashEs.forEach(lodashEs.keys(a),p=>{if(lodashEs.includes(lodashEs.get(d,"i18nProps",[]),p)&&!lodashEs.isEmpty(l)){const m=`${p}-${l}`;lodashEs.set(u,m,a[p]),lodashEs.unset(u,p)}}),u},useUpdateBlocksProps=()=>{const{updateBlocks:a}=useBlocksStoreUndoableActions(),{selectedLang:l}=useLanguages(),c=useSelectedBlock();return React.useCallback((d,u,p)=>{const m=updatePropsForLanguage(u,l,c);a(d,m,p)},[l,c,a])},useUpdateMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:a}=useBlocksStoreUndoableActions();return React.useCallback(l=>{a(l)},[a])},useFakeStreamEffect=()=>{const{updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback(async(l,c,d=30)=>{const u=lodashEs.keys(lodashEs.omit(c,["_id"]));for(const p of u){const m=c[p];if(lodashEs.isString(m)){const h=lodashEs.chunk(m.split(""),12);let g="";a([l],{[p]:""});for(let x=0;x<h.length;x++)g+=h[x].join(""),a([l],{[p]:g}),await new Promise(f=>setTimeout(f,d))}}},[a])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:a}=useBlocksStoreUndoableActions(),l=useFakeStreamEffect();return React.useCallback(async c=>{for(const d of c)await l(d._id,d);a(c)},[l,a])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:a}=useBlocksStoreUndoableActions(),{selectedLang:l}=useLanguages(),c=useSelectedBlock();return React.useCallback((d,u)=>{const p=updatePropsForLanguage(u,l,c);a(d,p)},[l,c,a])};function getChildBlocks(a,l,c){c.push(lodashEs.find(a,{_id:l}));const d=lodashEs.filter(a,{_parent:l});for(const u of d)c.push(...getBlockWithChildren(u._id,a));return c}const getBlockWithChildren=(a,l)=>{let c=[];return c=lodashEs.flattenDeep([...c,...getChildBlocks(l,a,c)]),c},pickOnlyAIProps=(a,l)=>lodashEs.compact(a.map(c=>{const d=["_id","_type","_parent"],u=lodashEs.pick(c,d),p=runtime.getRegisteredChaiBlock(c._type),m={},h=lodashEs.get(p,"aiProps",[]);for(const g in c)d.includes(g)||h.includes(g)&&(m[g]=lodashEs.get(c,`${g}-${l}`,c[g]));return lodashEs.isEmpty(m)?!1:(lodashEs.has(u,"_parent")&&lodashEs.isEmpty(u._parent)&&delete u._parent,{...u,...m})})),addLangToPrompt=(a,l,c)=>!l||c!=="content"?a:`${a}. Generate content in ${lodashEs.get(LANGUAGES,l,l)} language.`,askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[a,l]=jotai.useAtom(askAiProcessingAtom),[c,d]=React.useState(null),u=useBuilderProp("askAiCallBack",null),p=useStreamMultipleBlocksProps(),m=useUpdateMultipleBlocksProps(),[h]=useBlocksStore(),{selectedLang:g,fallbackLang:x}=useLanguages(),f=g.length?g:x,y=(b,j)=>{const R=lodashEs.cloneDeep(j.find(k=>k._id===b));for(const k in R){const v=R[k];if(typeof v=="string"&&lodashEs.startsWith(v,getSplitClasses.STYLES_KEY)){const{baseClasses:S,classes:C}=getSplitClasses.getSplitChaiClasses(v);R[k]=lodashEs.compact(lodashEs.flattenDeep([S,C])).join(" ")}else k!=="_id"&&delete R[k]}return R};return{askAi:React.useCallback(async(b,j,R,k)=>{if(u){l(!0),d(null);try{const v=g===x?"":g,S=b==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(j,h)),g):[y(j,h)],C=await u(b,addLangToPrompt(R,f,b),S,v),{blocks:I,error:w}=C;if(w){d(w);return}if(b==="styles"){const T=I.map(A=>{for(const B in A)B!=="_id"&&(A[B]=`${getSplitClasses.STYLES_KEY},${A[B]}`);return A});m(T)}else p(I);k&&k(C)}catch(v){d(v)}finally{l(!1),k&&k()}}},[u,l,g,x,h,f,m,p]),loading:a,error:c}},useAiAssistant=()=>{const[,a]=useRightPanel();return React.useCallback(l=>{a(l?"ai":"block")},[a])};let lastHighlighted=null;const useBlockHighlight=()=>{const[a]=jotai.useAtom(canvasIframeAtom),l=React.useMemo(()=>{var u;return(a==null?void 0:a.contentDocument)||((u=a==null?void 0:a.contentWindow)==null?void 0:u.document)},[a]);return{highlightBlock:React.useCallback(u=>{if(l)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof u!="string")u.setAttribute("data-highlighted","true"),lastHighlighted=u;else if(typeof u=="string"){const p=l.querySelector(`[data-block-id="${u}"]`);p&&(p.setAttribute("data-highlighted","true"),lastHighlighted=p)}else lastHighlighted=null},[l]),clearHighlight:()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},lastHighlighted}},partialBlocksStoreAtom=atom({}),partialBlocksLoadingStateAtom=atom({}),usePartailBlocksStore=()=>{const[a,l]=useAtom(partialBlocksStoreAtom),c=React.useCallback(u=>lodashEs.get(a,u,[]),[a]),d=React.useCallback(()=>l({}),[l]);return{getPartailBlocks:c,reset:d}},useWatchPartailBlocks=()=>{const[a]=useBlocksStore(),[l,c]=useAtom(partialBlocksStoreAtom),[d,u]=useAtom(partialBlocksLoadingStateAtom),p=useBuilderProp("getPartialBlockBlocks",async h=>[]),m=React.useMemo(()=>a.filter(h=>h._type==="PartialBlock"||h._type==="GlobalBlock").map(h=>lodashEs.get(h,"partialBlockId",lodashEs.get(h,"globalBlock",""))),[a]);React.useEffect(()=>{lodashEs.forEach(m,h=>{lodashEs.has(l,h)||lodashEs.get(d,`${h}.loading`,!1)||(u(g=>({...g,[h]:{loading:!0,error:null}})),p(h).then(g=>{c(x=>({...x,[h]:g})),u(x=>({...x,[h]:{loading:!1,error:null}}))}).catch(g=>{u(x=>({...x,[h]:{loading:!1,error:g.message}}))}))})},[p,l,d,c,u,m])},partialBlocksListAtom=atom({}),usePartialBlocksList=()=>{const[a,l]=React.useState(!1),[c,d]=React.useState(null),[u,p]=useAtom(partialBlocksListAtom),m=useBuilderProp("getPartialBlocks",async()=>[]),h=React.useCallback(async()=>{l(!0),d(null);try{const g=await m();p(g),l(!1)}catch(g){d(g instanceof Error?g.message:"Failed to fetch partial blocks"),l(!1)}},[m,p]);return React.useEffect(()=>{h()},[]),{data:u,isLoading:a,refetch:h,error:c}},useBuilderReset=()=>{const{clear:a}=useUndoManager(),[,l]=useSelectedBlockIds(),{clearHighlight:c}=useBlockHighlight(),[,d]=useSelectedStylingBlocks(),[,u]=useAtom(aiAssistantActiveAtom),{reset:p}=usePartailBlocksStore(),{setSaveState:m}=useSavePage();return()=>{l([]),d([]),c(),a(),u(!1),p(),m("SAVED")}},canvasZoomAtom=atomWithStorage("canvasZoom",100),useCanvasZoom=()=>jotai.useAtom(canvasZoomAtom),codeEditorAtom=jotai.atom(null),useCodeEditor=()=>jotai.useAtom(codeEditorAtom),cutBlockIdsAtom=jotai.atom([]),useCutBlockIds=()=>{const[a,l]=jotai.useAtom(cutBlockIdsAtom),c=jotai.useSetAtom(copiedBlockIdsAtom),d=React.useCallback(u=>{l(u),c([])},[l,c]);return[a,d]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlockIds=()=>{const[a]=useBlocksStore(),[l,c]=jotai.useAtom(copiedBlockIdsAtom),d=jotai.useSetAtom(cutBlockIdsAtom),u=React.useCallback(async p=>{try{c(p),d([]);const m={_chai_copied_blocks:p.flatMap(h=>getDuplicatedBlocks(a,h,null))};await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy blocks to clipboard:",m)}},[c,d,a]);return[l,u]},useCopyToClipboard=()=>{const[a,l]=React.useState(null),c=React.useCallback(async d=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(d),l(d),!0}catch(u){return console.warn("Copy failed",u),l(null),!1}},[]);return[a,c]},darkModeAtom=atomWithStorage("darkMode",!1),useDarkMode=()=>{const[a,l]=jotai.useAtom(darkModeAtom);return[a,l]},useDuplicateBlocks=()=>{const[a]=useBlocksStore(),[,l]=useSelectedBlockIds(),{addBlocks:c}=useBlocksStoreUndoableActions();return React.useCallback((d,u=null)=>{const p=[];lodashEs.each(d,m=>{const h=a.find(b=>b._id===m);u?u==="root"&&(u=null):u=h._parent;const f=lodashEs.filter(a,b=>lodashEs.isString(u)?b._parent===u:!b._parent).indexOf(h)+1,y=getDuplicatedBlocks(a,m,u);c(y,u,f),p.push(lodashEs.get(y,"0._id",""))}),l(p)},[a,l])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[a,l]=jotai.useAtom(hiddenBlockIdsAtom),c=React.useCallback(d=>{l(u=>lodashEs.includes(u,d)?lodashEs.without(u,d):[...u,d])},[l]);return[a,l,c]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),useCanPaste=()=>{const[a]=useBlocksStore();return(l,c)=>{var p;const d=((p=lodashEs.find(a,{_id:c}))==null?void 0:p._type)||null,u=lodashEs.first(l.map(m=>{var h;return(h=lodashEs.find(a,{_id:m}))==null?void 0:h._type}));return canAcceptChildBlock(d,u)}},useMoveCutBlocks=()=>{const a=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:l}=useBlocksStoreUndoableActions();return React.useCallback((c,d)=>{const u=Array.isArray(d)?d[0]:d;if(d==="root"){const p=a==null?void 0:a.filter(m=>!m._parent);l(c,null,(p==null?void 0:p.length)||0)}else{const p=a==null?void 0:a.filter(m=>m._parent===u);l(c,u,(p==null?void 0:p.length)||0)}},[l,a])},usePasteBlocks=()=>{const[a,l]=useCutBlockIds(),c=useMoveCutBlocks(),d=useCanPaste(),{addPredefinedBlock:u}=useAddBlock();return{canPaste:React.useCallback(async m=>{if(a.length>0)return d(a,m);try{const h=await navigator.clipboard.readText();if(h){const g=JSON.parse(h);return lodashEs.has(g,"_chai_copied_blocks")}}catch{return!1}return!1},[d,a]),pasteBlocks:React.useCallback(async m=>{const h=Array.isArray(m)?m[0]:m;if(!lodashEs.isEmpty(a)){c(a,m),l([]),await navigator.clipboard.writeText("");return}try{const g=await navigator.clipboard.readText();if(g){const x=JSON.parse(g);lodashEs.has(x,"_chai_copied_blocks")?u(x._chai_copied_blocks,h==="root"?null:h):sonner.toast.error("Nothing to paste")}else sonner.toast.error("Nothing to paste")}catch{sonner.toast.error("Failed to paste blocks from clipboard")}},[a,u,c,l])}},previewModeAtom=jotai.atom(!1),usePreviewMode=()=>{const[a,l]=jotai.useAtom(previewModeAtom);return[a,l]},removeClassFromBlocksAtom=jotai.atom(null,(a,l,{blockIds:c,fullClasses:d})=>{const u=lodashEs.first(a(selectedStylingBlocksAtom)),p=lodashEs.filter(a(pageBlocksAtomsAtom),m=>c.includes(a(m)._id));return lodashEs.map(p,m=>{const h=a(m),g=d;let{classes:x,baseClasses:f}=getSplitClasses.getSplitChaiClasses(lodashEs.get(h,u.prop,`${getSplitClasses.STYLES_KEY},`));return lodashEs.each(g,y=>{const b=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(^|\\s)${b}(?=\\s|$)`,"g");x=x.replace(j," ").replace(/\s+/g," ").trim();const R=lodashEs.first(y.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],R)&&g.push(y.split(":").pop().trim())}),lodashEs.each(g,y=>{const b=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(^|\\s)${b}(?=\\s|$)`,"g");f=f.replace(j," ").replace(/\s+/g," ").trim()}),{ids:[h._id],props:{[u.prop]:`${getSplitClasses.STYLES_KEY}${f},${x}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:a,updateBlocksRuntime:l}=useBlocksStoreUndoableActions(),c=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((d,u,p=!1)=>{const m=c({blockIds:d,fullClasses:u});p?a(d,m[0].props):l(d,m[0].props)},[c])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(a=>{const l=a(canvasWidthAtom);return Functions.getBreakpointValue(l).toLowerCase()}),useScreenSizeWidth=()=>{const[a,l]=jotai.useAtom(canvasWidthAtom),c=jotai.useAtomValue(canvasBreakpointAtom),[d,u]=useStylingBreakpoint();return React.useEffect(()=>{d!=="xs"&&u(c)},[c,d,u]),[a,c,l]},useCanvasDisplayWidth=()=>{const[a,l]=jotai.useAtom(canvasDisplayWidthAtom);return[a,l]},selectedBlockAllClassesAtom=jotai.atom(a=>{const l=lodashEs.first(a(selectedStylingBlocksAtom)),c=a(selectedBlockAtom);if(!l||l.blockId!==lodashEs.get(c,"_id",null))return[];const d=lodashEs.get(c,l.prop,`${getSplitClasses.STYLES_KEY},`),{classes:u}=getSplitClasses.getSplitChaiClasses(d);return lodashEs.filter(lodashEs.map(u.trim().split(" "),constructClassObject),p=>!lodashEs.isNull(p))}),useSelectedBlockAllClasses=()=>jotai.useAtomValue(selectedBlockAllClassesAtom),MQ={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},selectedBlockCurrentClassesAtom=jotai.atom(a=>{const l=a(canvasBreakpointAtom),c=a(styleStateAtom),d=a(darkModeAtom),u=getQueries(l);let p=lodashEs.filter(a(selectedBlockAllClassesAtom),{mod:c});return lodashEs.startsWith(c,"_")||(p=lodashEs.filter(p,m=>u.includes(m.mq))),p=p.sort((m,h)=>MQ[m.mq]-MQ[h.mq]),d||(p=lodashEs.filter(p,{dark:!1})),p}),getQueries=a=>{let l=[];switch(a){case"xs":l=["xs"];break;case"sm":l=["xs","sm"];break;case"md":l=["xs","sm","md"];break;case"lg":l=["xs","sm","md","lg"];break;case"xl":l=["xs","sm","md","lg","xl"];break;case"2xl":l=["xs","sm","md","lg","xl","2xl"];break;default:l=["xs"];break}return l},useSelectedBlockCurrentClasses=()=>jotai.useAtomValue(selectedBlockCurrentClassesAtom),selectedBreakpointsAtom=atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),useSelectedBreakpoints=()=>{const[a,l]=jotai.useAtom(selectedBreakpointsAtom);return[a,l]},useStylingState=()=>jotai.useAtom(styleStateAtom),useUILibraryBlocks=()=>({data:useBuilderProp("uiLibraries",[]),isLoading:!1}),wrapperBlockAtom=jotai.atom(a=>{var m;const l=a(presentBlocksAtom),c=a(selectedBlockIdsAtom),d=c.length===1?c[0]:null;if(!d)return null;const u=lodashEs.find(l,{_id:d});if(!u)return null;let p=u._parent;for(;p;){const h=lodashEs.find(l,{_id:p});if(!h)return null;if((m=runtime.getRegisteredChaiBlock(h._type))!=null&&m.wrapper)return h;p=h._parent}return null});wrapperBlockAtom.debugLabel="wrapperBlockAtom";const useWrapperBlock=()=>jotai.useAtomValue(wrapperBlockAtom),sidebarActivePanelAtom=jotai.atom("outline");sidebarActivePanelAtom.debugLabel="sidebarActivePanelAtom";const useSidebarActivePanel=()=>jotai.useAtom(sidebarActivePanelAtom);function getOrientation(a,l=null){const c=window.getComputedStyle(a),d=l?window.getComputedStyle(l):null,u=c.display,p=d?d.display:null;if(u==="flex"||u==="inline-flex"){const m=c.flexDirection;return m==="column"||m==="column-reverse"?"vertical":"horizontal"}else if(u==="grid"){const m=c.gridAutoFlow,h=c.gridTemplateColumns;return m.includes("column")||h&&h!=="none"&&h!==""&&!h.includes("calc")&&h.split(" ").length<=1?"vertical":"horizontal"}else if(p==="inline-block"||p==="inline")return"horizontal";return"vertical"}const CONTROLS=[{ControlIcon:reactIcons.PinTopIcon,dir:"VERTICAL",key:"UP"},{ControlIcon:reactIcons.PinBottomIcon,dir:"VERTICAL",key:"DOWN"},{ControlIcon:reactIcons.PinLeftIcon,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:reactIcons.PinRightIcon,dir:"HORIZONTAL",key:"RIGHT"}],getParentBlockOrientation=(a,l,c)=>{try{if(!a||!c)return"VERTICAL";const d=`[data-block-id='${a}']`,u=c==null?void 0:c.querySelector(d);if(u){const p=c==null?void 0:c.querySelector(`[data-block-id='${l}']`);return getOrientation(u,p).toUpperCase()}return"VERTICAL"}catch{return"VERTICAL"}},isDisabledControl=(a,l,c)=>!!(a&&(c==="UP"||c==="LEFT")||l&&(c==="DOWN"||c==="RIGHT")),useBlockController=(a,l)=>{const[c]=useBlocksStore(),{document:d}=useFrame(),{moveBlocks:u}=useBlocksStoreUndoableActions(),p=lodashEs.get(a,"_id"),m=lodashEs.get(a,"_parent"),h=lodashEs.filter(c,R=>m?lodashEs.get(R,"_parent")===m:!lodashEs.get(R,"_parent")),g=(h==null?void 0:h.length)<=1,x=lodashEs.findIndex(h,{_id:p}),f=x<=0,y=x+1===(h==null?void 0:h.length),b=getParentBlockOrientation(m,p,d),j=React.useCallback(R=>{isDisabledControl(f,y,R)||g||(R==="UP"||R==="LEFT"?u([p],m||null,x-1):(R==="DOWN"||R==="RIGHT")&&u([p],m||null,x+2),l())},[f,y,g,x,p,m,l]);return reactHotkeysHook.useHotkeys("shift+up, shift+down, shift+left, shift+right",({key:R})=>{var k;j((k=R==null?void 0:R.replace("Arrow",""))==null?void 0:k.toUpperCase())},{document:d==null?void 0:d.contentDocument},[j]),{isOnlyChild:g,isFirstBlock:f,isLastBlock:y,moveBlock:j,orientation:b}},BlockController=({block:a,updateFloatingBar:l})=>{const{isOnlyChild:c,isFirstBlock:d,isLastBlock:u,moveBlock:p,orientation:m}=useBlockController(a,l);return c?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:CONTROLS.map(({ControlIcon:h,dir:g,key:x})=>{if(m!==g)return null;const f=isDisabledControl(d,u,x);return f?null:jsxRuntime.jsx(h,{onClick:()=>p(x),className:`${f?"pointer-events-none cursor-not-allowed opacity-50":"duration-300 hover:scale-95 hover:opacity-80"}`},x)})})},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS"};class PubSub{constructor(){W(this,"subscribers",new Map)}subscribe(l,c){return this.subscribers.has(l)||this.subscribers.set(l,new Set),this.subscribers.get(l).add(c),()=>{const d=this.subscribers.get(l);d&&(d.delete(c),d.size===0&&this.subscribers.delete(l))}}publish(l,c){const d=this.subscribers.get(l);d&&d.forEach(u=>u(c))}}const pubsub=new PubSub,AddBlockDropdown=({block:a,children:l})=>{const{t:c}=reactI18next.useTranslation(),[d]=useBlocksStore(),{hasPermission:u}=usePermissions(),p=lodashEs.get(a,"_id"),m=lodashEs.get(a,"_parent"),h=lodashEs.filter(d,y=>m?lodashEs.get(y,"_parent")===m:!lodashEs.get(y,"_parent")),g=canAddChildBlock(lodashEs.get(a,"_type","")),x=lodashEs.findIndex(h,{_id:p}),f=y=>{if(y==="CHILD")pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,a);else{const b={_id:m||"",position:h==null?void 0:h.length};y==="BEFORE"?b.position=Math.max(x,0):y==="AFTER"&&(b.position=x+1),pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,b)}};return u(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(tooltip.DropdownMenu,{children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{children:l}),jsxRuntime.jsxs(tooltip.DropdownMenuContent,{className:"border border-blue-500 bg-blue-500 text-white shadow-2xl",children:[g&&jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("CHILD"),children:c("Add inside")}),jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("BEFORE"),children:c("Add before")}),jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("AFTER"),children:c("Add after")})]})]}):null},draggedBlockAtom=jotai.atom(null),dropTargetBlockIdAtom=jotai.atom(null),BlockActionLabel=({block:a,label:l})=>{const[,c]=useSelectedBlockIds(),[,d]=useHighlightBlockId(),[,u]=jotai.useAtom(draggedBlockAtom),p=flagged.useFeature("dnd");return jsxRuntime.jsxs("div",{className:"mr-10 flex cursor-default items-center space-x-1 px-1",draggable:p?"true":"false",onDragStart:m=>{m.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.pick(a,["_id","_type","_name"]))),u(a),setTimeout(()=>{c([]),d(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),l]})},BlockFloatingSelector=({selectedBlockElement:a,block:l})=>{const c=useRemoveBlocks(),d=useDuplicateBlocks(),[,u]=useSelectedBlockIds(),[,p]=useHighlightBlockId(),[,m]=useSelectedStylingBlocks(),{hasPermission:h}=usePermissions(),[g]=jotai.useAtom(inlineEditingActiveAtom),{document:x}=useFrame(),{floatingStyles:f,refs:y,update:b}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:a}});web.useResizeObserver(a,()=>b(),a!==null),web.useResizeObserver(x==null?void 0:x.body,()=>b(),(x==null?void 0:x.body)!==null);const j=lodashEs.get(l,"_parent",null),R=lodashEs.isEmpty(lodashEs.get(l,"_name",""))?lodashEs.get(l,"_type",""):lodashEs.get(l,"_name","");return!a||!l||g?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:y.setFloating,style:f,onClick:k=>{k.stopPropagation(),k.preventDefault()},onMouseEnter:k=>{k.stopPropagation(),p(null)},onKeyDown:k=>k.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[j&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{m([]),u([j])}}),jsxRuntime.jsx(BlockActionLabel,{label:R,block:l}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1.5",children:[jsxRuntime.jsx(AddBlockDropdown,{block:l,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105"})}),canDuplicateBlock(lodashEs.get(l,"_type",""))&&h(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>d([l==null?void 0:l._id])}):null,canDeleteBlock(lodashEs.get(l,"_type",""))&&h(PERMISSIONS.DELETE_BLOCK)?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>c([l==null?void 0:l._id])}):null,h(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(BlockController,{block:l,updateFloatingBar:b})]})]})})},IframeInitialContent=`<!doctype html>
|
|
1
|
+
"use strict";var X=Object.defineProperty;var J=(a,l,c)=>l in a?X(a,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[l]=c;var W=(a,l,c)=>J(a,typeof l!="symbol"?l+"":l,c);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),React=require("react"),tooltip=require("./tooltip-CkYl0YhP.cjs"),jotai=require("jotai"),lodashEs=require("lodash-es"),reactWrapBalancer=require("react-wrap-balancer"),reactI18next=require("react-i18next"),Functions=require("./Functions-BZmyleS1.cjs"),dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),reactIcons=require("@radix-ui/react-icons"),web=require("@react-hookz/web"),flagged=require("flagged"),runtime=require("@chaibuilder/runtime"),lucideReact=require("lucide-react"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),clsx=require("clsx"),tailwindMerge=require("tailwind-merge"),Autosuggest=require("react-autosuggest"),sonner=require("sonner"),Fuse=require("fuse.js"),chaiThemeHelpers=require("./chai-theme-helpers-D2bHv81c.cjs"),getSplitClasses=require("./getSplitClasses-DodqA_KW.cjs"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),TooltipPrimitive=require("@radix-ui/react-tooltip"),i18n=require("i18next"),reactErrorBoundary=require("react-error-boundary"),reactHotkeysHook=require("react-hotkeys-hook"),framerMotion=require("framer-motion"),TreeModel=require("tree-model"),aspectRatio=require("@tailwindcss/aspect-ratio"),containerQueries=require("@tailwindcss/container-queries"),forms=require("@tailwindcss/forms"),typography=require("@tailwindcss/typography"),ReactDOM=require("react-dom"),reResizable=require("re-resizable");function _interopNamespaceDefault(a){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const c in a)if(c!=="default"){const d=Object.getOwnPropertyDescriptor(a,c);Object.defineProperty(l,c,d.get?d:{enumerable:!0,get:()=>a[c]})}}return l.default=a,Object.freeze(l)}const React__namespace=_interopNamespaceDefault(React),isSelfAtom=(a,l)=>a.unstable_is?a.unstable_is(l):l===a,hasInitialValue=a=>"init"in a,isActuallyWritableAtom=a=>!!a.write,isAtomStateInitialized=a=>"v"in a||"e"in a,returnAtomValue=a=>{if("e"in a)throw a.e;return a.v},PROMISE_STATE=Symbol(),getPromiseState=a=>a[PROMISE_STATE],isPendingPromise=a=>{var l;return isPromiseLike$2(a)&&!((l=getPromiseState(a))!=null&&l[1])},cancelPromise=(a,l)=>{const c=getPromiseState(a);c&&(c[1]=!0,c[0].forEach(d=>d(l)))},patchPromiseForCancelability=a=>{if(getPromiseState(a))return;const l=[new Set,!1];a[PROMISE_STATE]=l;const c=()=>{l[1]=!0};a.then(c,c),a.onCancel=d=>{l[0].add(d)}},isPromiseLike$2=a=>typeof(a==null?void 0:a.then)=="function",addPendingPromiseToDependency=(a,l,c)=>{c.p.has(a)||(c.p.add(a),l.then(()=>{c.p.delete(a)},()=>{c.p.delete(a)}))},setAtomStateValueOrPromise=(a,l,c)=>{const d=c(a),u="v"in d,p=d.v,m=isPendingPromise(d.v)?d.v:null;if(isPromiseLike$2(l)){patchPromiseForCancelability(l);for(const h of d.d.keys())addPendingPromiseToDependency(a,l,c(h))}d.v=l,delete d.e,(!u||!Object.is(p,d.v))&&(++d.n,m&&cancelPromise(m,l))},getMountedOrPendingDependents=(a,l,c)=>{var d;const u=new Set;for(const p of((d=c.get(a))==null?void 0:d.t)||[])c.has(p)&&u.add(p);for(const p of l.p)u.add(p);return u},BUILDING_BLOCKS=Symbol(),buildStore=(a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new Set,u=new Set,p=new Set,m={},h=(b,...j)=>b.read(...j),g=(b,...j)=>b.write(...j),x=(b,j)=>{var R;return(R=b.unstable_onInit)==null?void 0:R.call(b,j)},f=(b,j)=>{var R;return(R=b.onMount)==null?void 0:R.call(b,j)},...y)=>{const b=y[0]||(B=>{let D=a.get(B);return D||(D={d:new Map,p:new Set,n:0},a.set(B,D),x==null||x(B,A)),D}),j=y[1]||(()=>{let B,D;const w=E=>{try{E()}catch(N){B||(B=!0,D=N)}};do{m.f&&w(m.f);const E=new Set,N=E.add.bind(E);d.forEach(P=>{var L;return(L=l.get(P))==null?void 0:L.l.forEach(N)}),d.clear(),p.forEach(N),p.clear(),u.forEach(N),u.clear(),E.forEach(w),d.size&&R()}while(d.size||p.size||u.size);if(B)throw D}),R=y[2]||(()=>{const B=[],D=new WeakSet,w=new WeakSet,E=Array.from(d);for(;E.length;){const N=E[E.length-1],P=b(N);if(w.has(N)){E.pop();continue}if(D.has(N)){c.get(N)===P.n&&B.push([N,P]),w.add(N),E.pop();continue}D.add(N);for(const L of getMountedOrPendingDependents(N,P,l))D.has(L)||E.push(L)}for(let N=B.length-1;N>=0;--N){const[P,L]=B[N];let M=!1;for(const O of L.d.keys())if(O!==P&&d.has(O)){M=!0;break}M&&(k(P),C(P)),c.delete(P)}}),k=y[3]||(B=>{var D,w;const E=b(B);if(isAtomStateInitialized(E)&&(l.has(B)&&c.get(B)!==E.n||Array.from(E.d).every(([U,$])=>k(U).n===$)))return E;E.d.clear();let N=!0;const P=()=>{l.has(B)&&(C(B),R(),j())},L=U=>{var $;if(isSelfAtom(B,U)){const H=b(U);if(!isAtomStateInitialized(H))if(hasInitialValue(U))setAtomStateValueOrPromise(U,U.init,b);else throw new Error("no atom init");return returnAtomValue(H)}const F=k(U);try{return returnAtomValue(F)}finally{E.d.set(U,F.n),isPendingPromise(E.v)&&addPendingPromiseToDependency(B,E.v,F),($=l.get(U))==null||$.t.add(B),N||P()}};let M,O;const Z={get signal(){return M||(M=new AbortController),M.signal},get setSelf(){return!O&&isActuallyWritableAtom(B)&&(O=(...U)=>{if(!N)try{return S(B,...U)}finally{R(),j()}}),O}},V=E.n;try{const U=h(B,L,Z);return setAtomStateValueOrPromise(B,U,b),isPromiseLike$2(U)&&((D=U.onCancel)==null||D.call(U,()=>M==null?void 0:M.abort()),U.then(P,P)),E}catch(U){return delete E.v,E.e=U,++E.n,E}finally{N=!1,V!==E.n&&c.get(B)===V&&(c.set(B,E.n),d.add(B),(w=m.c)==null||w.call(m,B))}}),v=y[4]||(B=>{const D=[B];for(;D.length;){const w=D.pop(),E=b(w);for(const N of getMountedOrPendingDependents(w,E,l)){const P=b(N);c.set(N,P.n),D.push(N)}}}),S=y[5]||((B,...D)=>{let w=!0;const E=P=>returnAtomValue(k(P)),N=(P,...L)=>{var M;const O=b(P);try{if(isSelfAtom(B,P)){if(!hasInitialValue(P))throw new Error("atom not writable");const Z=O.n,V=L[0];setAtomStateValueOrPromise(P,V,b),C(P),Z!==O.n&&(d.add(P),(M=m.c)==null||M.call(m,P),v(P));return}else return S(P,...L)}finally{w||(R(),j())}};try{return g(B,E,N,...D)}finally{w=!1}}),C=y[6]||(B=>{var D;const w=b(B),E=l.get(B);if(E&&!isPendingPromise(w.v)){for(const[N,P]of w.d)if(!E.d.has(N)){const L=b(N);I(N).t.add(B),E.d.add(N),P!==L.n&&(d.add(N),(D=m.c)==null||D.call(m,N),v(N))}for(const N of E.d||[])if(!w.d.has(N)){E.d.delete(N);const P=T(N);P==null||P.t.delete(B)}}}),I=y[7]||(B=>{var D;const w=b(B);let E=l.get(B);if(!E){k(B);for(const N of w.d.keys())I(N).t.add(B);if(E={l:new Set,d:new Set(w.d.keys()),t:new Set},l.set(B,E),(D=m.m)==null||D.call(m,B),isActuallyWritableAtom(B)){const N=()=>{let P=!0;const L=(...M)=>{try{return S(B,...M)}finally{P||(R(),j())}};try{const M=f(B,L);M&&(E.u=()=>{P=!0;try{M()}finally{P=!1}})}finally{P=!1}};u.add(N)}}return E}),T=y[8]||(B=>{var D;const w=b(B);let E=l.get(B);if(E&&!E.l.size&&!Array.from(E.t).some(N=>{var P;return(P=l.get(N))==null?void 0:P.d.has(B)})){E.u&&p.add(E.u),E=void 0,l.delete(B),(D=m.u)==null||D.call(m,B);for(const N of w.d.keys()){const P=T(N);P==null||P.t.delete(B)}return}return E}),_=[a,l,c,d,u,p,m,h,g,x,f,b,j,R,k,v,S,C,I,T],A={get:B=>returnAtomValue(k(B)),set:(B,...D)=>{try{return S(B,...D)}finally{R(),j()}},sub:(B,D)=>{const E=I(B).l;return E.add(D),j(),()=>{E.delete(D),T(B),j()}}};return Object.defineProperty(A,BUILDING_BLOCKS,{value:_}),A},INTERNAL_buildStoreRev1=buildStore;let keyCount=0;function atom(a,l){const c=`atom${++keyCount}`,d={toString(){return c}};return typeof a=="function"?d.read=a:(d.init=a,d.read=defaultRead,d.write=defaultWrite),l&&(d.write=l),d}function defaultRead(a){return a(this)}function defaultWrite(a,l,c){return l(this,typeof c=="function"?c(a(this)):c)}const createStore=()=>INTERNAL_buildStoreRev1();let defaultStore;const getDefaultStore=()=>(defaultStore||(defaultStore=createStore()),defaultStore),RESET=Symbol(""),getCached$1=(a,l,c)=>(l.has(c)?l:l.set(c,a())).get(c),cache1$2=new WeakMap,memo2$1=(a,l,c)=>{const d=getCached$1(()=>new WeakMap,cache1$2,l);return getCached$1(a,d,c)},cacheKeyForEmptyKeyExtractor={},isWritable=a=>!!a.write,isFunction=a=>typeof a=="function";function splitAtom(a,l){return memo2$1(()=>{const c=new WeakMap,d=(m,h)=>{let g=c.get(m);if(g)return g;const x=h&&c.get(h),f=[],y=[];return m.forEach((b,j)=>{const R=j;y[j]=R;const k=x&&x.atomList[x.keyList.indexOf(R)];if(k){f[j]=k;return}const v=C=>{const I=C(u),T=C(a),A=d(T,I==null?void 0:I.arr).keyList.indexOf(R);if(A<0||A>=T.length){const B=m[d(m).keyList.indexOf(R)];if(B)return B;throw new Error("splitAtom: index out of bounds for read")}return T[A]},S=(C,I,T)=>{const _=C(u),A=C(a),D=d(A,_==null?void 0:_.arr).keyList.indexOf(R);if(D<0||D>=A.length)throw new Error("splitAtom: index out of bounds for write");const w=isFunction(T)?T(A[D]):T;Object.is(A[D],w)||I(a,[...A.slice(0,D),w,...A.slice(D+1)])};f[j]=isWritable(a)?atom(v,S):atom(v)}),x&&x.keyList.length===y.length&&x.keyList.every((b,j)=>b===y[j])?g=x:g={arr:m,atomList:f,keyList:y},c.set(m,g),g},u=atom(m=>{const h=m(u),g=m(a);return d(g,h==null?void 0:h.arr)});u.init=void 0;const p=isWritable(a)?atom(m=>m(u).atomList,(m,h,g)=>{switch(g.type){case"remove":{const x=m(p).indexOf(g.atom);if(x>=0){const f=m(a);h(a,[...f.slice(0,x),...f.slice(x+1)])}break}case"insert":{const x=g.before?m(p).indexOf(g.before):m(p).length;if(x>=0){const f=m(a);h(a,[...f.slice(0,x),g.value,...f.slice(x)])}break}case"move":{const x=m(p).indexOf(g.atom),f=g.before?m(p).indexOf(g.before):m(p).length;if(x>=0&&f>=0){const y=m(a);x<f?h(a,[...y.slice(0,x),...y.slice(x+1,f),y[x],...y.slice(f)]):h(a,[...y.slice(0,f),y[x],...y.slice(f,x),...y.slice(x+1)])}break}}}):atom(m=>m(u).atomList);return p},a,cacheKeyForEmptyKeyExtractor)}const isPromiseLike$1=a=>typeof(a==null?void 0:a.then)=="function";function createJSONStorage(a=()=>{try{return window.localStorage}catch{return}},l){var c;let d,u;const p={getItem:(g,x)=>{var f,y;const b=R=>{if(R=R||"",d!==R){try{u=JSON.parse(R,l==null?void 0:l.reviver)}catch{return x}d=R}return u},j=(y=(f=a())==null?void 0:f.getItem(g))!=null?y:null;return isPromiseLike$1(j)?j.then(b):b(j)},setItem:(g,x)=>{var f;return(f=a())==null?void 0:f.setItem(g,JSON.stringify(x,void 0))},removeItem:g=>{var x;return(x=a())==null?void 0:x.removeItem(g)}},m=g=>(x,f,y)=>g(x,b=>{let j;try{j=JSON.parse(b||"")}catch{j=y}f(j)});let h;try{h=(c=a())==null?void 0:c.subscribe}catch{}return!h&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(h=(g,x)=>{if(!(a()instanceof window.Storage))return()=>{};const f=y=>{y.storageArea===a()&&y.key===g&&x(y.newValue)};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}}),h&&(p.subscribe=m(h)),p}const defaultStorage=createJSONStorage();function atomWithStorage(a,l,c=defaultStorage,d){const u=atom(l);return u.onMount=m=>{m(c.getItem(a,l));let h;return c.subscribe&&(h=c.subscribe(a,m,l)),h},atom(m=>m(u),(m,h,g)=>{const x=typeof g=="function"?g(m(u)):g;return x===RESET?(h(u,l),c.removeItem(a)):x instanceof Promise?x.then(f=>(h(u,f),c.setItem(a,f))):(h(u,x),c.setItem(a,x))})}const StoreContext=React.createContext(void 0),useStore=a=>{const l=React.useContext(StoreContext);return(a==null?void 0:a.store)||l||getDefaultStore()},isPromiseLike=a=>typeof(a==null?void 0:a.then)=="function",attachPromiseMeta=a=>{a.status="pending",a.then(l=>{a.status="fulfilled",a.value=l},l=>{a.status="rejected",a.reason=l})},use=React.use||(a=>{if(a.status==="pending")throw a;if(a.status==="fulfilled")return a.value;throw a.status==="rejected"?a.reason:(attachPromiseMeta(a),a)}),continuablePromiseMap=new WeakMap,createContinuablePromise=a=>{let l=continuablePromiseMap.get(a);return l||(l=new Promise((c,d)=>{let u=a;const p=g=>x=>{u===g&&c(x)},m=g=>x=>{u===g&&d(x)},h=g=>{"onCancel"in g&&typeof g.onCancel=="function"&&g.onCancel(x=>{isPromiseLike(x)?(continuablePromiseMap.set(x,l),u=x,x.then(p(x),m(x)),h(x)):c(x)})};a.then(p(a),m(a)),h(a)}),continuablePromiseMap.set(a,l)),l};function useAtomValue(a,l){const c=useStore(l),[[d,u,p],m]=React.useReducer(x=>{const f=c.get(a);return Object.is(x[0],f)&&x[1]===c&&x[2]===a?x:[f,c,a]},void 0,()=>[c.get(a),c,a]);let h=d;if((u!==c||p!==a)&&(m(),h=c.get(a)),React.useEffect(()=>{const x=c.sub(a,()=>{m()});return m(),x},[c,a,void 0]),React.useDebugValue(h),isPromiseLike(h)){const x=createContinuablePromise(h);return use(x)}return h}function useSetAtom(a,l){const c=useStore(l);return React.useCallback((...u)=>c.set(a,...u),[c,a])}function useAtom(a,l){return[useAtomValue(a,l),useSetAtom(a,l)]}function useAtomCallback(a,l){const c=React.useMemo(()=>atom(null,(d,u,...p)=>a(d,u,...p)),[a]);return useSetAtom(c,l)}const readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const inlineEditingActiveAtom=jotai.atom("");inlineEditingActiveAtom.debugLabel="inlineEditingActiveAtom";const draggingFlagAtom=jotai.atom(!1);draggingFlagAtom.debugLabel="draggingFlagAtom";const treeRefAtom=jotai.atom(null);treeRefAtom.debugLabel="treeRefAtom";const canvasSettingsAtom=jotai.atom({});canvasSettingsAtom.debugLabel="canvasSettingsAtom";const aiAssistantActiveAtom=jotai.atom(!1);aiAssistantActiveAtom.debugLabel="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";class Content extends React.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return React.Children.only(this.props.children)}}let doc,win;typeof document<"u"&&(doc=document);typeof window<"u"&&(win=window);const FrameContext=React.createContext({document:doc,window:win}),useFrame=()=>React.useContext(FrameContext),{Provider:FrameContextProvider,Consumer:FrameContextConsumer}=FrameContext;class Frame extends React.Component{constructor(c,d){super(c,d);W(this,"setRef",c=>{this.nodeRef.current=c;const{forwardedRef:d}=this.props;typeof d=="function"?d(c):d&&(d.current=c)});W(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});W(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=React.createRef(),this.state={iframeLoaded:!1}}componentDidMount(){this._isMounted=!0,this.getDoc()&&this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded",this.handleLoad)}componentWillUnmount(){this._isMounted=!1,this.nodeRef.current.removeEventListener("DOMContentLoaded",this.handleLoad)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){const c=this.getDoc();return this.props.mountTarget?c.querySelector(this.props.mountTarget):c.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const c=this.getDoc();if(!c)return null;const d=this.props.contentDidMount,u=this.props.contentDidUpdate,p=c.defaultView||c.parentView,m=jsxRuntime.jsx(Content,{contentDidMount:d,contentDidUpdate:u,children:jsxRuntime.jsx(FrameContextProvider,{value:{document:c,window:p},children:jsxRuntime.jsx("div",{className:"frame-content",children:this.props.children})})}),h=this.getMountTarget();return[ReactDOM.createPortal(this.props.head,this.getDoc().head),ReactDOM.createPortal(m,h)]}render(){const c={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete c.head,delete c.initialContent,delete c.mountTarget,delete c.contentDidMount,delete c.contentDidUpdate,delete c.forwardedRef,jsxRuntime.jsx("iframe",{...c,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}W(Frame,"defaultProps",{style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'});const ChaiFrame=React.forwardRef((a,l)=>jsxRuntime.jsx(Frame,{...a,forwardedRef:l}));function duplicateBlocks(a,l,c){const d=lodashEs.filter(a,p=>p._parent===l),u=[];for(let p=0;p<d.length;p++){const m=getSlots(d[p]);if(Object.keys(m).length>0&&Object.keys(m).forEach(h=>{d[p][h]=`slot:${Functions.generateUUID()}`}),lodashEs.filter(a,{_parent:d[p]._id}).length>0){const h=Functions.generateUUID();u.push({...d[p],oldId:d[p]._id,_id:h,_parent:c}),u.push(lodashEs.flatten(duplicateBlocks(a,d[p]._id,h)))}else u.push({...d[p],oldId:d[p]._id,_id:Functions.generateUUID(),_parent:c})}return lodashEs.flatten(u)}function convertToBlocksTree(a){const l={};a.forEach(d=>{l[d._id]={...d,children:[]}});const c=[];return a.forEach(d=>{if(d._parent){const u=l[d._parent];u&&u.children.push(l[d._id])}else c.push(l[d._id])}),c}const getSlots=a=>{const l={};return Object.keys(a).forEach(c=>{lodashEs.isString(a[c])&&a[c].startsWith("slot")&&(l[c]=a[c].replace("slot:",""))}),l},getDuplicatedBlocks=(a,l,c=null)=>{let d=lodashEs.find(a,{_id:l});d={...d,oldId:d._id,_id:Functions.generateUUID()},c!==(d==null?void 0:d._parent)&&(d={...d,_parent:c});const u=[d];lodashEs.filter(a,{_parent:l}).length>0&&u.push(lodashEs.flatten(duplicateBlocks(a,l,d._id)));const p=lodashEs.flatten(u);return lodashEs.map(p,m=>{const h=m,g=getSlots(h);return Object.keys(g).length>0&&Object.keys(g).forEach(x=>{const f=lodashEs.find(p,{oldId:g[x].replace("slot:","")});h[x]=`slot:${f._id}`}),lodashEs.omit(h,["global","oldId"])})},presentBlocksAtom=jotai.atom([]);presentBlocksAtom.debugLabel="presentBlocksAtom";const treeDSBlocks=jotai.atom(a=>{const l=a(presentBlocksAtom);return convertToBlocksTree([...l])});treeDSBlocks.debugLabel="treeDSBlocks";const pageBlocksAtomsAtom=splitAtom(presentBlocksAtom);pageBlocksAtomsAtom.debugLabel="pageBlocksAtomsAtom";const builderActivePageAtom=jotai.atom("");builderActivePageAtom.debugLabel="builderActivePageAtom";const destinationDropIndexAtom=jotai.atom(-1);destinationDropIndexAtom.debugLabel="destinationDropIndexAtom";const buildingBlocksAtom=jotai.atom([]);buildingBlocksAtom.debugLabel="buildingBlocksAtom";const globalBlocksAtom=jotai.atom(a=>{const l=a(buildingBlocksAtom);return lodashEs.filter(l,c=>lodashEs.has(c,"blockId"))});globalBlocksAtom.debugLabel="globalBlocksAtom";const broadcastChannel=new BroadcastChannel("chaibuilder"),useBroadcastChannel=()=>{const a=useBuilderProp("pageId","chaibuilder_page");return{postMessage:web.useDebouncedCallback(c=>broadcastChannel.postMessage({...c,pageId:a}),[a],200)}},useUnmountBroadcastChannel=()=>{const[,a]=useBlocksStore(),l=useBuilderProp("pageId","chaibuilder_page"),{updateBlocksProps:c}=useBlocksStoreManager();React.useEffect(()=>(broadcastChannel.onmessageerror=d=>{console.log("error",d)},broadcastChannel.onmessage=d=>{d.data.type==="blocks-updated"&&d.data.pageId===l&&a(d.data.blocks),d.data.type==="blocks-props-updated"&&d.data.pageId===l&&c(d.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[a,l])},selectedBlockIdsAtom=jotai.atom([]);selectedBlockIdsAtom.debugLabel="selectedBlockIdsAtom";const selectedBlocksAtom=jotai.atom(a=>{const l=a(presentBlocksAtom),c=a(selectedBlockIdsAtom);return lodashEs.map(lodashEs.filter(l,({_id:d})=>lodashEs.includes(c,d)),d=>({...d}))});selectedBlocksAtom.debugLabel="selectedBlocksAtom";const selectedBlockAtom=jotai.atom(a=>{const l=a(selectedBlocksAtom);if(l.length===0)return null;if(l.length===1)return l[0]});selectedBlockAtom.debugLabel="selectedBlockAtom";const getParentId=a=>lodashEs.get(a,"_parent",null),selectedBlocksParentsAtom=jotai.atom(a=>{const l=a(selectedBlocksAtom),c=lodashEs.map(l,getParentId);return lodashEs.filter(a(presentBlocksAtom),d=>lodashEs.includes(c,d._id))});selectedBlocksParentsAtom.debugLabel="selectedBlocksParentsAtom";const selectedBlockFlexChildAtom=jotai.atom(()=>!1);selectedBlockFlexChildAtom.debugLabel="selectedBlockFlexChildAtom";const selectedBlockGridChildAtom=jotai.atom(()=>!1);selectedBlockGridChildAtom.debugLabel="selectedBlockGridChildAtom";const styleStateAtom=jotai.atom("");styleStateAtom.debugLabel="styleStateAtom";const styleBreakpointAtom=atomWithStorage("styleBreakpoint","xs");styleBreakpointAtom.debugLabel="styleBreakpointAtom";const useSelectedBlocksDisplayChild=()=>({flexChild:jotai.useAtomValue(selectedBlockFlexChildAtom),gridChild:jotai.useAtomValue(selectedBlockGridChildAtom)}),useSelectedBlock=()=>jotai.useAtomValue(selectedBlockAtom),selectedBlockHierarchy=jotai.atom(a=>{const l=a(selectedBlockAtom),c=a(presentBlocksAtom);let d=l;const u=[l];do{const p=c.find(({_id:m})=>m===(d==null?void 0:d._parent));d=p,p&&u.push(p)}while(d!=null&&d._parent);return u}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[a,l]=jotai.useAtom(selectedBlockIdsAtom),c=React.useCallback(d=>{l(u=>lodashEs.includes(u,d)?lodashEs.without(u,d):[...u,d])},[l]);return[a,l,c]},removeNestedBlocks=(a,l)=>{let c=[...a],d=[];l.forEach(h=>{const g=c.find(y=>y._id===h);if(!g||!g._parent)return;const x=g._parent,f=c.filter(y=>y._parent===x);if(f.length===2){const y=f.find(b=>b._id!==h);if(y&&y._type==="Text"){const b=c.find(j=>j._id===x);b&&"content"in b&&(c=c.map(j=>{if(j._id===x){const R={...j,content:y.content};return Object.keys(y).forEach(k=>{k.startsWith("content-")&&(R[k]=y[k])}),R}return j}),d.push(y._id))}}});const u=[...l,...d],p=[],m=lodashEs.filter(c,h=>lodashEs.includes(u,h._id)||lodashEs.includes(u,h._parent)?(p.push(h._id),!1):!0);return lodashEs.isEmpty(p)?m:removeNestedBlocks(m,p)},useRemoveBlocks=()=>{const[a]=useBlocksStore(),[l,c]=useSelectedBlockIds(),{setNewBlocks:d}=useBlocksStoreUndoableActions(),{hasPermission:u}=usePermissions();return React.useCallback(p=>{var h;if(!u(PERMISSIONS.DELETE_BLOCK))return;const m=((h=lodashEs.find(a,{_id:p[0]}))==null?void 0:h._parent)||null;d(removeNestedBlocks(a,p)),setTimeout(()=>c(m?[m]:[]),200)},[a,c,l,u])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(a,l,{id:c,props:d})=>{const u=a(pageBlocksAtomsAtom),p=lodashEs.find(u,m=>a(m)._id===c);if(!p)throw new Error(`Block with id ${c} not found`);return l(p,{...a(p),...d})}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtomValue=a=>useAtomCallback(React.useCallback((l,c,d)=>{const u=l(a);if(!u||!u.length)throw new Error("No blocks available");const p=lodashEs.find(u,m=>l(m)._id===(lodashEs.isString(d)?d:l(d)._id));if(!p)throw new Error(`Block with id ${d} not found`);return l(p)},[a]),{store:builderStore}),useGetBlockAtom=a=>useAtomCallback(React.useCallback((l,c,d)=>{const u=l(a);if(!u||!u.length)return console.warn("No blocks available in splitAtoms"),null;const p=lodashEs.find(u,m=>l(m)._id===(lodashEs.isString(d)?d:l(d)._id));return p||(console.warn(`Block with id ${d} not found`),null)},[a]),{store:builderStore});function insertBlocksAtPosition(a,l,c,d){const u=[...l];let p=[...a];if(c){const x=a.find(f=>f._id===c);if(x&&x.content!==void 0&&x.content!==""&&!a.some(y=>y._parent===c)){const b={_id:Functions.generateUUID(),_parent:c,_type:"Text",content:x.content};Object.keys(x).forEach(j=>{j.startsWith("content-")&&(b[j]=x[j])}),u.unshift(b),p=p.map(j=>{if(j._id===c){const R={...j,content:""};return Object.keys(R).forEach(k=>{k.startsWith("content-")&&(R[k]="")}),R}return j})}}let m=p.filter(x=>!x._parent);c&&(m=p.filter(x=>x._parent===c));const h=!isNaN(d)||d>-1?Math.min(d,m.length):m.length;let g=p.length;for(let x=0,f=0;x<p.length;x++)if(c!==void 0?p[x]._parent===c:!p[x]._parent){if(f===h){g=x;break}f++}return!c&&d!==void 0&&d>=m.length&&(g=p.length),[...p.slice(0,g),...u,...p.slice(g)]}function getBlocksTree(a){return convertToBlocksTree(a)}function flattenTree(a){let l=[];return a.walk(c=>(delete c.model.children,l.push(c.model),!0)),l}function findNodeById(a,l){return a.first(c=>c.model._id===l)||null}function moveNode(a,l,c,d){var x,f;const u=findNodeById(a,l),p=findNodeById(a,c);if(!u||!p)return!1;p.children||(p.model.children=[]);let m=(x=p==null?void 0:p.children)==null?void 0:x.findIndex(y=>y.model._id===l);u.drop(),m=Math.max(m,0);const g=(((f=u==null?void 0:u.model)==null?void 0:f._parent)||"root")===c&&m<=d?d-1:d;try{p.addChildAtIndex(u,g)}catch(y){return console.error("Error adding child to parent:",y),!1}return!0}function handleOldParentTextBlock(a,l){if(!l||!l._parent)return a;const c=l._parent,d=a.find(p=>p._id===c);if(!d)return a;const u=a.filter(p=>p._parent===c);if(u.length===2){const p=u.find(m=>m._id!==l._id);if(p&&p._type==="Text"&&"content"in d)return a.map(h=>{if(h._id===c){const g={...h,content:p.content};return Object.keys(p).forEach(x=>{x.startsWith("content-")&&(g[x]=p[x])}),g}return h}).filter(h=>h._id!==p._id)}return a}function handleNewParentTextBlock(a,l,c){if(!c||c==="root")return a;const d=a.find(u=>u._id===c);if(!d)return a;if(d.content!==void 0&&d.content!==""&&!a.some(p=>p._parent===c&&p._id!==l._id)){const m={_id:Functions.generateUUID(),_parent:c,_type:"Text",content:d.content};Object.keys(d).forEach(x=>{x.startsWith("content-")&&(m[x]=d[x])});const h=a.map(x=>{if(x._id===c){const f={...x,content:""};return Object.keys(f).forEach(y=>{y.startsWith("content-")&&(f[y]="")}),f}return x}),g=h.findIndex(x=>x._id===l._id);return g!==-1?[...h.slice(0,g),m,...h.slice(g)]:[m,...h]}return a}function moveBlocksWithChildren(a,l,c,d){if(!l)return a;const u=a.find(x=>x._id===l);if(!u)return a;let p=handleOldParentTextBlock(a,u);const m=c||"root",g=new TreeModel().parse({_id:"root",children:getBlocksTree(p)});if(moveNode(g,l,m,d)){let x=flattenTree(g);const f=x.find(y=>y._id===l);return f&&(f._parent=m==="root"?null:m),x.shift(),c&&(x=handleNewParentTextBlock(x,u,c)),x}return p}const useBlocksStoreManager=()=>{const[,a]=useBlocksStore(),{postMessage:l}=useBroadcastChannel(),c=useUpdateBlockAtom();return{setNewBlocks:d=>{a(d),l({type:"blocks-updated",blocks:d})},addBlocks:(d,u,p)=>{a(m=>{const h=insertBlocksAtPosition(m,d,u,p);return l({type:"blocks-updated",blocks:h}),h})},removeBlocks:d=>{a(u=>{const p=removeNestedBlocks(u,d);return l({type:"blocks-updated",blocks:p}),p})},moveBlocks:(d,u,p)=>{a(m=>{let h=[...m];for(let g=0;g<d.length;g++)h=moveBlocksWithChildren(h,d[g],u,p);return lodashEs.each(d,g=>{const x=lodashEs.find(h,f=>f._id===g);x&&c({id:g,props:{_parent:x._parent||null}})}),l({type:"blocks-updated",blocks:h}),h})},updateBlocksProps:d=>{d.forEach(u=>{const p=lodashEs.omit(u,"_id");c({id:u._id,props:p})}),l({type:"blocks-props-updated",blocks:d})}}};var undomanager={exports:{}},hasRequiredUndomanager;function requireUndomanager(){return hasRequiredUndomanager||(hasRequiredUndomanager=1,function(a){(function(){function l(d,u,p){return d.splice(u,!p||1+p-u+(!(p<0^u>=0)&&(p<0||-1)*d.length)),d.length}let c=function(){let d=[],u=-1,p=0,m=!1,h;function g(x,f){return!x||typeof x[f]!="function"?this:(m=!0,x[f](),m=!1,this)}return{add:function(x){return m?this:(d.splice(u+1,d.length-u),d.push(x),p&&d.length>p&&l(d,0,-(p+1)),u=d.length-1,h&&h(),this)},setCallback:function(x){h=x},undo:function(){let x=d[u];if(!x)return this;const f=x.groupId;for(;x.groupId===f&&(g(x,"undo"),u-=1,x=d[u],!(!x||!x.groupId)););return h&&h(),this},redo:function(){let x=d[u+1];if(!x)return this;const f=x.groupId;for(;x.groupId===f&&(g(x,"redo"),u+=1,x=d[u+1],!(!x||!x.groupId)););return h&&h(),this},clear:function(){let x=d.length;d=[],u=-1,h&&x>0&&h()},hasUndo:function(){return u!==-1},hasRedo:function(){return u<d.length-1},getCommands:function(x){return x?d.filter(f=>f.groupId===x):d},getIndex:function(){return u},setLimit:function(x){p=x}}};a.exports?a.exports=c:window.UndoManager=c})()}(undomanager)),undomanager.exports}var undomanagerExports=requireUndomanager();const UndoManager=chaiThemeHelpers.getDefaultExportFromCjs(undomanagerExports),chaiBuilderPropsAtom=jotai.atom(null);chaiBuilderPropsAtom.debugLabel="chaiBuilderPropsAtom";const chaiExternalDataAtom=jotai.atom({});chaiExternalDataAtom.debugLabel="chaiExternalDataAtom";const chaiRjsfFieldsAtom=jotai.atom({});chaiRjsfFieldsAtom.debugLabel="chaiRjsfFieldsAtom";const chaiRjsfWidgetsAtom=jotai.atom({});chaiRjsfWidgetsAtom.debugLabel="chaiRjsfWidgetsAtom";const chaiRjsfTemplatesAtom=jotai.atom({});chaiRjsfTemplatesAtom.debugLabel="chaiRjsfTemplatesAtom";const chaiPageExternalDataAtom=jotai.atom({});chaiPageExternalDataAtom.debugLabel="chaiPageExternalDataAtom";const usePageExternalData=()=>jotai.useAtomValue(chaiPageExternalDataAtom),useBuilderProp=(a,l=void 0)=>{const c=jotai.useAtomValue(chaiBuilderPropsAtom);return lodashEs.get(c,a,l)},MODIFIERS=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"],BRANDING_OPTIONS_DEFAULTS={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"},brandingOptionsAtom=jotai.atom(BRANDING_OPTIONS_DEFAULTS);jotai.atom(null);const useBrandingOptions=()=>{const[a,l]=jotai.useAtom(brandingOptionsAtom);return[lodashEs.isObject(a)?{...BRANDING_OPTIONS_DEFAULTS,...a}:BRANDING_OPTIONS_DEFAULTS,l]},currentPageAtom=jotai.atom(null),useCurrentPage=()=>({currentPage:jotai.useAtomValue(currentPageAtom)}),getBlockBuilderProps=lodashEs.memoize(a=>{const l=runtime.getRegisteredChaiBlock(a),c=lodashEs.get(l,"schema.properties",{});return lodashEs.compact(Object.keys(c).map(d=>lodashEs.get(c[d],"builderProp",!1)||lodashEs.get(c[d],"runtime",!1)?d:null))}),useGetPageData=()=>{const[a]=useBrandingOptions(),{currentPage:l}=useCurrentPage(),[c]=useBlocksStore();return React.useCallback(()=>{const d=lodashEs.map(c,u=>lodashEs.omit(u,getBlockBuilderProps(u._type)));return{currentPage:l,blocks:d}},[a,l,c])},usePermissions=()=>{const a=useBuilderProp("permissions",void 0);return{hasPermission:React.useCallback(c=>a?a.includes(c):!0,[a])}},getDefaultThemeValues=(a=chaiThemeHelpers.defaultThemeOptions)=>{const l={};return a.fontFamily&&(l.fontFamily=Object.entries(a.fontFamily).reduce((c,[d,u])=>({...c,[d.replace("font-","")]:u}),{})),l.borderRadius=a.borderRadius,a.colors&&(l.colors=a.colors.reduce((c,d)=>(Object.entries(d.items).forEach(([u,p])=>{c[u]=p}),c),{})),l},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const a=useThemeOptions(),l=React.useMemo(()=>getDefaultThemeValues(a),[a]),c=useBuilderProp("theme",{}),[d,u]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...l,...!lodashEs.isEmpty(c)&&c,...!lodashEs.isEmpty(d)&&d}),[l,c,d]),u]},useThemeOptions=()=>{const a=useBuilderProp("themeOptions",c=>c);return React.useMemo(()=>a(chaiThemeHelpers.defaultThemeOptions),[a])},rightPanelAtom=jotai.atom("block"),useRightPanel=()=>jotai.useAtom(rightPanelAtom),builderSaveStateAtom=jotai.atom("SAVED");builderSaveStateAtom.debugLabel="builderSaveStateAtom";const useSavePage=()=>{const[a,l]=jotai.useAtom(builderSaveStateAtom),c=useBuilderProp("onSave",async g=>{}),d=useBuilderProp("onSaveStateChange",lodashEs.noop),u=useGetPageData(),[p]=useTheme(),{hasPermission:m}=usePermissions();return{savePage:web.useThrottledCallback(async(g=!1)=>{if(!m("save_page"))return;l("SAVING"),d("SAVING");const x=u();return await c({autoSave:g,blocks:x.blocks,theme:p}),setTimeout(()=>{l("SAVED"),d("SAVED")},100),!0},[u,l,p,c,d],3e3),saveState:a,setSaveState:l}},undoManager=new UndoManager;undoManager.setLimit(50);const useUndoManager=()=>{const[,a]=jotai.useAtom(builderSaveStateAtom),l=useBuilderProp("onSaveStateChange",lodashEs.noop);return React.useEffect(()=>(undoManager.setCallback(()=>{a("UNSAVED"),l("UNSAVED")}),()=>{undoManager.setCallback(lodashEs.noop)}),[]),{add:undoManager.add,undo:undoManager.undo,redo:undoManager.redo,hasRedo:undoManager.hasRedo,hasUndo:undoManager.hasUndo,clear:undoManager.clear}},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:a}=useUndoManager(),[l]=useBlocksStore(),{setNewBlocks:c,addBlocks:d,removeBlocks:u,moveBlocks:p,updateBlocksProps:m}=useBlocksStoreManager();return{moveBlocks:(R,k,v)=>{const S=lodashEs.map(R,I=>{const _=l.find(D=>D._id===I)._parent||null,B=l.filter(D=>_?D._parent===_:!D._parent).map(D=>D._id).indexOf(I);return{_id:I,oldParent:_,oldPosition:B}}),C=S.find(({_id:I})=>I===R[0]);C&&C.oldParent===k&&C.oldPosition===v||(p(R,k,v),a({undo:()=>lodashEs.each(S,({_id:I,oldParent:T,oldPosition:_})=>{p([I],T,_)}),redo:()=>p(R,k,v)}))},addBlocks:(R,k,v)=>{d(R,k,v),a({undo:()=>u(lodashEs.map(R,"_id")),redo:()=>d(R,k,v)})},removeBlocks:R=>{var C;const k=(C=lodashEs.first(R))==null?void 0:C._parent,S=l.filter(I=>k?I._parent===k:!I._parent).indexOf(lodashEs.first(R));u(lodashEs.map(R,"_id")),a({undo:()=>d(R,k,S),redo:()=>u(lodashEs.map(R,"_id"))})},updateBlocks:(R,k,v)=>{let S=[];if(v)S=lodashEs.map(R,C=>({_id:C,...v}));else{const C=lodashEs.keys(k);S=lodashEs.map(R,I=>{const T=l.find(A=>A._id===I),_={_id:I};return lodashEs.each(C,A=>_[A]=T[A]),_})}m(lodashEs.map(R,C=>({_id:C,...k}))),a({undo:()=>m(S),redo:()=>m(lodashEs.map(R,C=>({_id:C,...k})))})},updateBlocksRuntime:(R,k)=>{m(lodashEs.map(R,v=>({_id:v,...k})))},setNewBlocks:R=>{c(R),a({undo:()=>c(l),redo:()=>c(R)})},updateMultipleBlocksProps:R=>{let k=[];k=lodashEs.map(R,v=>{const S=lodashEs.keys(v),C=l.find(T=>T._id===v._id),I={};return lodashEs.each(S,T=>I[T]=C[T]),I}),m(R),a({undo:()=>m(k),redo:()=>m(R)})}}},libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=a=>{const[l,c]=jotai.useAtom(libraryBlocksAtom),d=useBuilderProp("getUILibraryBlocks",lodashEs.noop),u=lodashEs.get(l,`${a==null?void 0:a.id}.blocks`,null),p=lodashEs.get(l,`${a==null?void 0:a.id}.loading`,"idle"),m=React.useRef("idle");React.useEffect(()=>{(async()=>{if(p==="complete"||m.current==="loading")return;m.current="loading",c(x=>({...x,[a==null?void 0:a.id]:{loading:"loading",blocks:[]}}));const g=await d(a);m.current="idle",c(x=>({...x,[a==null?void 0:a.id]:{loading:"complete",blocks:g||[]}}))})()},[a,u,p,m,c,d]);const h=React.useCallback(()=>{c(g=>({...g,[a==null?void 0:a.id]:{loading:"idle",blocks:[]}}))},[a,c]);return{data:u||[],isLoading:p==="loading",resetLibrary:h}},canAcceptChildBlock=(a,l)=>{if(!a)return!0;const c=runtime.getRegisteredChaiBlock(a);return c&&lodashEs.has(c,"canAcceptBlock")?c.canAcceptBlock(l):!1},canAddChildBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l?lodashEs.has(l,"canAcceptBlock"):!1},canBeNestedInside=(a,l)=>{const c=runtime.getRegisteredChaiBlock(l);return c&&lodashEs.has(c,"canBeNested")?c.canBeNested(a):!0},canDuplicateBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l&&lodashEs.has(l,"canDuplicate")?l.canDuplicate():!0},canDeleteBlock=a=>{const l=runtime.getRegisteredChaiBlock(a);return l&&lodashEs.has(l,"canDelete")?l.canDelete():!0},canDropBlock=(a,{dragSource:l,dropTarget:c})=>{const d=lodashEs.get(l,"data._type",""),u=lodashEs.get(c,"data._type","");return canAcceptChildBlock(u,d)},useAddBlock=()=>{const[a]=useBlocksStore(),[,l]=useSelectedBlockIds(),{addBlocks:c}=useBlocksStoreUndoableActions(),d=React.useCallback((p,m,h)=>{var b;for(let j=0;j<p.length;j++){const{_id:R}=p[j];p[j]._id=Functions.generateUUID();const k=lodashEs.filter(p,{_parent:R});for(let v=0;v<k.length;v++)k[v]._parent=p[j]._id}const g=lodashEs.first(p);let x,f;return m&&(x=lodashEs.find(a,{_id:m}),p[0]._parent=m,f=m),!(x?canAcceptChildBlock(x==null?void 0:x._type,g._type):!0)&&x&&(p[0]._parent=x._parent,f=x._parent),c(p,f,h),l([(b=lodashEs.first(p))==null?void 0:b._id]),lodashEs.first(p)},[c,a,l]);return{addCoreBlock:React.useCallback((p,m,h)=>{if(lodashEs.has(p,"blocks")){const k=p.blocks;return d(k,m,h)}const g=Functions.generateUUID(),x=runtime.getDefaultBlockProps(p.type),f={_type:p.type,_id:g,...x,...lodashEs.has(p,"_name")&&{_name:p._name},...lodashEs.has(p,"partialBlockId")&&{partialBlockId:p.partialBlockId}};let y,b;return m&&(y=lodashEs.find(a,{_id:m}),f._parent=m,b=m),!canAcceptChildBlock(y==null?void 0:y._type,f._type)&&y&&(f._parent=y._parent,b=y._parent),c([f],b,h),l([f._id]),f},[c,d,a,l]),addPredefinedBlock:d}},STANDARD=[0,1,2,3,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],CLASS_VALUES={columns:[...lodashEs.range(1,13),"auto","3xs","2xs","xs","sm","md","lg","xl",...lodashEs.map(lodashEs.range(2,8),a=>`${a}xl`)],breakAfter:["auto","avoid","all","avoid-page","page","left","right","column"],breakInside:["auto","avoid","avoid-page","avoid-column"],display:["block","flex","grid","inline-block","inline","hidden"],objectFit:["contain","cover","fill","none","scale-down"],objectPosition:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],overflow:["auto","hidden","clip","visible","scroll"],overscroll:["auto","contain","none"],trbl:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"auto","1/2","1/3","2/3","1/4","2/4","3/4","full"],flexBasis:[...STANDARD,"auto","px","0.5","1.5","2.5","3.5","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12","full"],padding:[...STANDARD,"px","0.5","1.5","2.5","3.5"],margin:["auto",...STANDARD,"px","0.5","1.5","2.5","3.5"],scale:[0,50,75,90,95,100,105,110,125,150],origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left"],blendEffect:["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],borderWidth:[0,2,4,8],borderRadius:["global","none","sm","md","lg","xl","2xl","3xl","full"],indent:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],maxHeight:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"full","screen","min","max","fit"],space:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...lodashEs.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"px","reverse"],width:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12"],maxWidth:["0","none","xs","sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","full","min","max","fit","prose","screen-sm","screen-md","screen-lg","screen-xl","screen-2xl"],height:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","full","screen","min","max","fit"]},CLASSES_LIST={textColor:{classes:[],regExp:"text-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:lodashEs.map(CLASS_VALUES.columns,a=>`columns-${a}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:lodashEs.map(CLASS_VALUES.breakAfter,a=>`break-after-${a}`),regExp:"break-after-\\S+"},breakBefore:{classes:lodashEs.map(CLASS_VALUES.breakAfter,a=>`break-before-${a}`),regExp:"break-before-\\S+"},breakInside:{classes:lodashEs.map(CLASS_VALUES.breakInside,a=>`break-inside-${a}`),regExp:"break-inside-\\S+"},boxDecoration:{classes:["box-decoration-clone","box-decoration-slice"],regExp:"box-decoration-\\S+"},boxSizing:{classes:["box-border","box-content"],regExp:"box-(border|content)"},flexDirection:{classes:["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],regExp:"flex-(row|row-reverse|col|col-reverse)"},flexWrap:{classes:["flex-wrap","flex-wrap-reverse","flex-nowrap"],regExp:"flex-(wrap|wrap-reverse|nowrap)"},flexGrowShrink:{classes:["flex-1","flex-auto","flex-initial","flex-none"],regExp:"flex-1|flex-auto|flex-initial|flex-none"},gridColumns:{classes:lodashEs.map([...lodashEs.range(0,13),"none"],a=>`grid-cols-${a}`),regExp:"grid-cols-(\\d+|none)"},gridFlow:{classes:["grid-flow-row","grid-flow-col","grid-flow-row-dense","grid-flow-col-dense"],regExp:"grid-flow-(row|col|row-dense|col-dense)"},outlineStyle:{classes:lodashEs.map(["none","dashed","dotted","double","hidden"],a=>`outline-${a}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","hidden","none"],a=>`border-${a}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-${a}`),regExp:`overflow-(${CLASS_VALUES.overflow.join("|")})`},overflowX:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-x-${a}`),regExp:`overflow-x-(${CLASS_VALUES.overflow.join("|")})`},overflowY:{classes:lodashEs.map(CLASS_VALUES.overflow,a=>`overflow-y-${a}`),regExp:`overflow-y-(${CLASS_VALUES.overflow.join("|")})`},gridRows:{classes:lodashEs.map([1,2,3,4,5,6,"none"],a=>`grid-rows-${a}`),regExp:"grid-rows-(\\d|none)"},display:{classes:lodashEs.map(CLASS_VALUES.display,a=>a.toString()),regExp:`(${CLASS_VALUES.display.join("|")})`},float:{classes:["float-right","float-left","float-none"],regExp:"float-\\S+"},clear:{classes:["clear-right","clear-left","clear-none","clear-both"],regExp:"clear-\\S+"},isolation:{classes:["isolate","isolation-auto"],regExp:"isolate|isolation-auto"},objectFit:{classes:lodashEs.map(CLASS_VALUES.objectFit,a=>`object-${a}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:lodashEs.map(CLASS_VALUES.objectPosition,a=>`object-${a}`),regExp:`object-(${CLASS_VALUES.objectPosition.join("|")})`},overscroll:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-${a}`),regExp:`overscroll-(${CLASS_VALUES.overscroll.join("|")})`},overscrollX:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-x-${a}`),regExp:`overscroll-x-(${CLASS_VALUES.overscroll.join("|")})`},overscrollY:{classes:lodashEs.map(CLASS_VALUES.overscroll,a=>`overscroll-y-${a}`),regExp:`overscroll-y-(${CLASS_VALUES.overscroll.join("|")})`},inset:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-${a}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-x-${a}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`inset-y-${a}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-${a}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-x-${a}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`top-y-${a}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-${a}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-x-${a}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`right-y-${a}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-${a}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-x-${a}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`bottom-y-${a}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-${a}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-x-${a}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:lodashEs.map(CLASS_VALUES.trbl,a=>`left-y-${a}`),regExp:"-?left-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},visibility:{classes:["visible","invisible"],regExp:"invisible|visible"},zIndex:{classes:lodashEs.map(["0",10,20,30,40,50,"auto"],a=>`z-${a}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:lodashEs.map(CLASS_VALUES.flexBasis,a=>`basis-${a}`),regExp:"basis-(\\d+|\\S+)"},flexGrow:{classes:["grow","grow-0"],regExp:"grow(-0)?"},flexShrink:{classes:["shrink","shrink-0"],regExp:"shrink(-0)?"},gridColSpan:{classes:["col-auto",...lodashEs.map(lodashEs.range(1,13),a=>`col-span-${a}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...lodashEs.map(lodashEs.range(1,14),a=>`col-start-${a}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...lodashEs.map(lodashEs.range(1,14),a=>`col-end-${a}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...lodashEs.map(lodashEs.range(1,7),a=>`row-span-${a}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...lodashEs.map(lodashEs.range(1,8),a=>`row-start-${a}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...lodashEs.map(lodashEs.range(1,8),a=>`row-end-${a}`),"row-end-auto"],regExp:"row-end-(\\d+|auto)"},gridAutoColumns:{classes:["auto-cols-auto","auto-cols-min","auto-cols-max","auto-cols-fr"],regExp:"auto-cols-(auto|min|max|fr)"},gridAutoRows:{classes:["auto-rows-auto","auto-rows-min","auto-rows-max","auto-rows-fr"],regExp:"auto-rows-(auto|min|max|fr)"},gap:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-${a}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-x-${a}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`gap-y-${a}`),regExp:"gap-y-(px|\\d.\\d|\\d|\\[.*\\])"},justifyContent:{classes:["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"],regExp:"justify-(start|end|center|between|around|evenly)"},justifyItems:{classes:["justify-items-start","justify-items-end","justify-items-center","justify-items-stretch"],regExp:"justify-items-(start|end|center|stretch)"},justifySelf:{classes:["justify-self-auto","justify-self-start","justify-self-end","justify-self-center","justify-self-stretch"],regExp:"justify-self-(auto|start|end|center|stretch)"},placeContent:{classes:["place-content-center","place-content-start","place-content-end","place-content-between","place-content-around","place-content-evenly","place-content-stretch"],regExp:"place-content-(center|start|end|between|around|evenly|stretch)"},placeItems:{classes:["place-items-start","place-items-end","place-items-center","place-items-stretch"],regExp:"place-items-(start|end|center|stretch)"},placeSelf:{classes:["place-self-auto","place-self-start","place-self-end","place-self-center","place-self-stretch"],regExp:"place-self-(auto|start|end|center|stretch)"},alignContent:{classes:["content-center","content-start","content-end","content-between","content-around","content-evenly"],regExp:"content-(center|start|end|between|around|evenly)"},alignItems:{classes:["items-start","items-end","items-center","items-baseline","items-stretch"],regExp:"items-(start|end|center|baseline|stretch)"},alignSelf:{classes:["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"],regExp:"self-(auto|start|end|center|stretch|baseline)"},backgroundClip:{classes:["bg-clip-border","bg-clip-padding","bg-clip-content","bg-clip-text"],regExp:"bg-clip-(border|padding|content|text)"},dropShadow:{classes:lodashEs.map(["sm","md","lg","xl","2xl","none"],a=>`drop-shadow-${a}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],a=>`backdrop-blur-${a}`),regExp:"backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)"},backdropBrightness:{classes:lodashEs.map([0,50,75,90,95,100,105,110,125,150,200],a=>`backdrop-brightness-${a}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:lodashEs.map([0,50,75,100,125,150,200],a=>`backdrop-contrast-${a}`),regExp:"backdrop-contrast-(\\d+)"},backdropGrayScale:{classes:["backdrop-grayscale-0","backdrop-grayscale"],regExp:"backdrop-grayscale(-0)?"},backdropHueRotate:{classes:lodashEs.map([0,15,30,60,90,180],a=>`backdrop-hue-rotate-${a}`),regExp:"-?backdrop-hue-rotate-(\\d+)"},backdropInvert:{classes:["backdrop-invert-0","backdrop-invert"],regExp:"backdrop-invert(-0)?"},backdropOpacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],a=>`backdrop-opacity-${a}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:lodashEs.map([0,50,100,150,200],a=>`backdrop-saturate-${a}`),regExp:"backdrop-saturate-(\\d+)"},backdropSepia:{classes:["backdrop-sepia-0, backdrop-sepia"],regExp:"backdrop-sepia(-0)?"},backgroundOrigin:{classes:["bg-origin-border","bg-origin-padding","bg-origin-content"],regExp:"bg-origin-(border|padding|content)"},transformOrigin:{classes:lodashEs.map(CLASS_VALUES.origin,a=>`origin-${a}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`p-${a}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`px-${a}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`py-${a}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pt-${a}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pr-${a}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pb-${a}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:lodashEs.map(CLASS_VALUES.padding,a=>`pl-${a}`),regExp:"pl-(\\d+|\\S+|\\[.*\\])"},textDecorationStyle:{classes:["decoration-solid","decoration-double","decoration-dotted","decoration-dashed","decoration-wavy"],regExp:"decoration-(solid|double|dotted|dashed|wavy)"},textDecorationThickness:{classes:lodashEs.map(["auto","from-font","0",1,2,4,8],a=>`decoration-${a}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},margin:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`m-${a}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mx-${a}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`my-${a}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mt-${a}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mr-${a}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`mb-${a}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:lodashEs.map(CLASS_VALUES.margin,a=>`ml-${a}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:lodashEs.map(CLASS_VALUES.space,a=>`space-x-${a}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:lodashEs.map(CLASS_VALUES.space,a=>`space-y-${a}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:lodashEs.map(["sm","md","lg","xl","2xl","inner","none"],a=>`shadow-${a}`),regExp:"shadow-(sm|md|lg|xl|2xl|inner|none)"},minWidth:{classes:["min-w-0","min-w-full","min-w-min","min-w-max","min-w-fit"],regExp:"min-w-(\\d+|\\S+|\\[.*\\])"},maxWidth:{classes:lodashEs.map(CLASS_VALUES.maxWidth,a=>`max-w-${a}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:lodashEs.map([...CLASS_VALUES.width,"full","screen","min","max","fit"],a=>`w-${a}`),regExp:"w-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])$"},minHeight:{classes:["min-h-0","min-h-full","min-h-screen","min-h-min","min-h-max","min-h-fit"],regExp:"min-h-(\\d+|\\S+|\\[.*\\])"},maxHeight:{classes:lodashEs.map(CLASS_VALUES.maxHeight,a=>`max-h-${a}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:lodashEs.map(CLASS_VALUES.height,a=>`h-${a}`),regExp:"h-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])"},fontFamily:{classes:["font-heading","font-body","font-sans","font-serif","font-mono"],regExp:"font-(heading|body|sans|serif|mono)"},textAlign:{classes:["text-left","text-center","text-right","text-justify"],regExp:"text-(left|center|right|justify)"},textOverflow:{classes:["truncate","text-ellipsis","text-clip"],regExp:"truncate|text-ellipsis|text-clip"},verticalAlign:{classes:["align-baseline","align-top","align-middle","align-bottom","align-text-top","align-text-bottom","align-sub","align-super"],regExp:"align-(baseline|top|middle|bottom|text-top|text-bottom|sub|super)"},fontSize:{classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"],regExp:"text-(\\d+|\\S+|\\[.*\\])"},fontSmoothing:{classes:["antialiased","subpixel-antialiased"],regExp:"antialiased|subpixel-antialiased"},fontStyle:{classes:["italic","not-italic"],regExp:"not-italic|italic"},fontWeight:{classes:["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"],regExp:"font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)"},fontVariantNum:{classes:["normal-nums","ordinal","diagonal-fractions","stacked-fractions","tabular-nums","oldstyle-nums","proportional-nums","lining-nums","slashed-zero"],regExp:"normal-nums|ordinal|diagonal-fractions|stacked-fractions|tabular-nums|oldstyle-nums|proportional-nums|lining-nums|slashed-zero"},letterSpacing:{classes:["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"],regExp:"-?tracking-(tighter|tight|normal|wide|wider|widest|\\[.*\\])"},lineHeight:{classes:["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"],regExp:"leading-(none|tight|snug|normal|relaxed|loose|\\[.*\\]|\\d+)"},listStyleType:{classes:["list-none","list-disc","list-decimal"],regExp:"list-(none|disc|decimal)"},listStylePosition:{classes:["list-inside","list-outside"],regExp:"list-(inside|outside)"},textUnderlineOffset:{classes:["underline-offset-auto","underline-offset-0","underline-offset-1","underline-offset-2","underline-offset-4","underline-offset-8"],regExp:"underline-offset-(auto|\\d+|\\S+)"},textDecoration:{classes:["underline","overline","line-through","no-underline"],regExp:"underline|overline|line-through|no-underline"},textDecorationColor:{classes:[],regExp:"decoration-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:lodashEs.map(CLASS_VALUES.indent,a=>`indent-${a}`),regExp:"-?indent-(\\d+|\\S+)"},whitespace:{classes:["whitespace-normal","whitespace-no-wrap","whitespace-pre","whitespace-pre-line","whitespace-pre-wrap"],regExp:"whitespace-(normal|no-wrap|pre|pre-line|pre-wrap)"},wordBreak:{classes:["break-normal","break-words","break-all"],regExp:"break-(normal|words|all)"},content:{classes:["content-none"],regExp:"content-none"},backgroundAttachment:{classes:lodashEs.map(["fixed","local","scroll"],a=>`bg-${a}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-tl-${a}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-tr-${a}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-br-${a}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-bl-${a}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-t-${a}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-r-${a}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-b-${a}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-l-${a}`)],regExp:`(rounded-l-(${CLASS_VALUES.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...lodashEs.map(CLASS_VALUES.borderRadius,a=>`rounded-${a}`)],regExp:`(rounded-(${CLASS_VALUES.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-x-${a}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-y-${a}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-t-${a}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-r-${a}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-b-${a}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-l-${a}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"^border-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...lodashEs.map(CLASS_VALUES.borderWidth,a=>`border-${a}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},order:{classes:lodashEs.map([...lodashEs.range(0,13),"first","last","none"],a=>`order-${a}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:lodashEs.map(["0",2,4,8],a=>`divide-x-${a}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:lodashEs.map(["0",2,4,8],a=>`divide-y-${a}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},divideStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","none"],a=>`divide-${a}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:lodashEs.map([0,1,2,4,8],a=>`outline-${a}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:lodashEs.map([0,1,2,4,8],a=>`outline-offset-${a}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringWidth:{classes:lodashEs.map([0,1,2,4,8,"inset"],a=>`ring-${a}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:lodashEs.map([0,1,2,4,8],a=>`ring-offset-${a}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],a=>`opacity-${a}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,a=>`mix-blend-${a}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,a=>`bg-blend-${a}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],a=>`blur-${a}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:lodashEs.map([0,50,75,90,95,100,105,110,125,150,200],a=>`brightness-${a}`),regExp:"brightness-(\\d+)"},contrast:{classes:lodashEs.map([0,50,75,100,125,150,200],a=>`contrast-${a}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:lodashEs.map([0,15,30,60,90,180],a=>`hue-rotate-${a}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:lodashEs.map([0,50,100,150,200],a=>`saturate-${a}`),regExp:"saturate-(\\d+)"},sepia:{classes:["sepia-0","sepia"],regExp:"sepia(-0)?"},transition:{classes:["transition-none","transition-all","transition-colors","transition-opacity","transition-shadow","transition-transform"],regExp:"transition-(none|all|colors|opacity|shadow|transform)"},duration:{classes:lodashEs.map([75,100,150,200,300,500,700,1e3],a=>`duration-${a}`),regExp:"duration-(\\d+|\\[.*\\])"},transitionEase:{classes:["ease-linear","ease-in","ease-out","ease-in-out"],regExp:"eas(e-linear|e-in|e-out|e-in-out)"},transitionDelay:{classes:lodashEs.map([75,100,150,200,300,500,700,1e3],a=>`delay-${a}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animation-none","animation-spin","animation-ping"],regExp:"animation-(none|spin|ping)"},scaleX:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-x-${a}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-y-${a}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:lodashEs.map(CLASS_VALUES.scale,a=>`scale-${a}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:lodashEs.map([0,1,2,3,6,12,45,90,180],a=>`rotate-${a}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:lodashEs.map([0,"px","0.5",1],a=>`translate-x-${a}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:lodashEs.map([0,"px","0.5",1],a=>`translate-y-${a}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:lodashEs.map([0,1,2,3,6,12],a=>`skew-x-${a}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:lodashEs.map([0,1,2,3,6,12],a=>`skew-y-${a}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},colorOptions={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},soloColors=["current","inherit","transparent","black","white"],shadedColors=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],shades=["50","100","200","300","400","500","600","700","800","900"],colorKeys=lodashEs.map(lodashEs.values(colorOptions),a=>a),ALL_COLORS=lodashEs.flattenDeep([...lodashEs.map(soloColors,a=>lodashEs.flatten(lodashEs.map(colorKeys,l=>`${l}-${a}`))),...lodashEs.map(shadedColors,a=>lodashEs.flattenDeep(lodashEs.map(colorKeys,l=>lodashEs.flattenDeep(lodashEs.map(shades,c=>`${l}-${a}-${c}`)))))]),ALL_TW_CLASSES=lodashEs.map(lodashEs.flattenDeep(lodashEs.values(CLASSES_LIST).map(a=>a.classes).concat(ALL_COLORS)),a=>({name:a})),useFuseSearch=()=>{const a=useThemeOptions(),l=React.useMemo(()=>{let c=[];if(a.colors){const d=lodashEs.flattenDeep(lodashEs.map(a.colors,({items:u})=>lodashEs.keys(u)));c=lodashEs.flattenDeep(lodashEs.map(d,u=>lodashEs.flatten(lodashEs.map(colorKeys,p=>`${p}-${u}`))))}return a.fontFamily&&(c=[...c,...lodashEs.map(lodashEs.keys(a.fontFamily),d=>`${d}`)]),lodashEs.map(c,d=>({name:d}))},[a]);return React.useMemo(()=>new Fuse([...ALL_TW_CLASSES,...l],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[l])},useTailwindClassList=()=>{const a=useThemeOptions(),l=React.useMemo(()=>{if(a.colors){const u=lodashEs.flattenDeep(lodashEs.map(a.colors,({items:p})=>lodashEs.keys(p)));lodashEs.each(CLASSES_LIST,(p,m)=>{lodashEs.set(CLASSES_LIST,`${m}.regExp`,p.regExp.replace("__THEME_COLORS_REGEXP__",u.join("|")))})}return CLASSES_LIST},[a]),c=React.useCallback((u,p)=>{const m=lodashEs.get(l,`${u}.regExp`,"");return p.match(new RegExp(m))},[l]),d=React.useCallback((u,p=[])=>lodashEs.get(l,`${u}.classes`,p),[l]);return{match:c,getClasses:d}};function getMqForCls(a){if(lodashEs.isEmpty(a.trim()))return"";const l=a.match(/sm:|md:|lg:|xl:|2xl:/g);return lodashEs.get(l,0,"xs").replace(":","")}function getModForCls(a){const l=lodashEs.map(MODIFIERS,d=>`${d}:`).join("|"),c=new RegExp(l,"g");return lodashEs.get(c.exec(a.trim()),0,"").replace(":","")}function getPureClsName(a){return a.trim().split(":").pop()||""}const memoizedProps={};function getPropertyForClass(a){if(lodashEs.isEmpty(a))return"";if(memoizedProps[a])return memoizedProps[a];let l="";for(const c in CLASSES_LIST){const d=lodashEs.get(CLASSES_LIST,`${c}.regExp`,"");if(new RegExp(d,"g").test(a)){l=c,memoizedProps[a]=l;break}}return l}function constructClassObject(a){return lodashEs.isEmpty(a)?null:{dark:lodashEs.startsWith(a,"dark:"),mq:getMqForCls(a),mod:getModForCls(a),cls:getPureClsName(a),fullCls:a,property:getPropertyForClass(a)}}function generateFullClsName(a){let l="";return a.dark&&(l+="dark:"),a.mq.toLowerCase()!=="xs"&&(l+=`${a.mq}:`),a.mod&&(l+=`${a.mod}:`),l+=a.cls,l}function orderClassesByBreakpoint(a){a=a.replace(/\s+/g," ");const l=a.split(" ").map(constructClassObject),c=["xs","sm","md","lg","xl","2xl"];return l.sort((d,u)=>c.indexOf(d.mq)-c.indexOf(u.mq)).map(d=>d.fullCls).join(" ")}function removeDuplicateClasses(a){if(a=a.replace(/\s+/g," "),!a)return"";const l=["xs","sm","md","lg","xl","2xl"],c=a.split(" ").map(constructClassObject);let d=a;if(c.length===1)return c[0].fullCls;for(const u of c){const p=u.property,m=l.indexOf(u.mq);for(let h=m+1;h<l.length;h++){const g=l[h],x=c.find(f=>f.property===p&&f.mq===g);if(x&&x.cls===u.cls)d=d.replace(x.fullCls,"");else if(x&&x.cls!==u.cls)break}}return d.replace(/\s+/g," ").trim()}const selectedStylingBlocksAtom=jotai.atom([]);selectedStylingBlocksAtom.debugLabel="selectedStylingBlocksAtom";const useSelectedStylingBlocks=()=>jotai.useAtom(selectedStylingBlocksAtom),addClassesToBlocksAtom=jotai.atom(null,(a,l,{blockIds:c,newClasses:d})=>{const u=lodashEs.filter(a(pageBlocksAtomsAtom),m=>c.includes(a(m)._id)),p=lodashEs.first(a(selectedStylingBlocksAtom));return lodashEs.map(u,m=>{const h=a(m),g=lodashEs.get(h,p.prop,`${getSplitClasses.STYLES_KEY},`),{classes:x}=getSplitClasses.getSplitChaiClasses(g);return{ids:[h._id],props:{[p.prop]:`${getSplitClasses.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(x,d)))}`}}})}),useAddClassesToBlocks=()=>{const a=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:l,updateBlocksRuntime:c}=useBlocksStoreUndoableActions();return React.useCallback((d,u,p=!1)=>{const m=a({blockIds:d,newClasses:u});if(!p){c(d,m[0].props);return}l(d,m[0].props)},[a,l,c])},LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},languageAtom=jotai.atom("");languageAtom.debugLabel="selectedLanguageAtom";const useLanguages=()=>{const a=useBuilderProp("languages",[]),l=useBuilderProp("fallbackLang","en"),[c,d]=jotai.useAtom(languageAtom),u=p=>{d(l===p?"":p)};return{languages:a==null?void 0:a.filter(p=>p!==l),fallbackLang:l,selectedLang:c,setSelectedLang:u}},updatePropsForLanguage=(a,l,c)=>{const d=runtime.getRegisteredChaiBlock(lodashEs.get(c,"_type"));if(!d)return a;const u={...a};return lodashEs.forEach(lodashEs.keys(a),p=>{if(lodashEs.includes(lodashEs.get(d,"i18nProps",[]),p)&&!lodashEs.isEmpty(l)){const m=`${p}-${l}`;lodashEs.set(u,m,a[p]),lodashEs.unset(u,p)}}),u},useUpdateBlocksProps=()=>{const{updateBlocks:a}=useBlocksStoreUndoableActions(),{selectedLang:l}=useLanguages(),c=useSelectedBlock();return React.useCallback((d,u,p)=>{const m=updatePropsForLanguage(u,l,c);a(d,m,p)},[l,c,a])},useUpdateMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:a}=useBlocksStoreUndoableActions();return React.useCallback(l=>{a(l)},[a])},useFakeStreamEffect=()=>{const{updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback(async(l,c,d=30)=>{const u=lodashEs.keys(lodashEs.omit(c,["_id"]));for(const p of u){const m=c[p];if(lodashEs.isString(m)){const h=lodashEs.chunk(m.split(""),12);let g="";a([l],{[p]:""});for(let x=0;x<h.length;x++)g+=h[x].join(""),a([l],{[p]:g}),await new Promise(f=>setTimeout(f,d))}}},[a])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:a}=useBlocksStoreUndoableActions(),l=useFakeStreamEffect();return React.useCallback(async c=>{for(const d of c)await l(d._id,d);a(c)},[l,a])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:a}=useBlocksStoreUndoableActions(),{selectedLang:l}=useLanguages(),c=useSelectedBlock();return React.useCallback((d,u)=>{const p=updatePropsForLanguage(u,l,c);a(d,p)},[l,c,a])};function getChildBlocks(a,l,c){c.push(lodashEs.find(a,{_id:l}));const d=lodashEs.filter(a,{_parent:l});for(const u of d)c.push(...getBlockWithChildren(u._id,a));return c}const getBlockWithChildren=(a,l)=>{let c=[];return c=lodashEs.flattenDeep([...c,...getChildBlocks(l,a,c)]),c},pickOnlyAIProps=(a,l)=>lodashEs.compact(a.map(c=>{const d=["_id","_type","_parent"],u=lodashEs.pick(c,d),p=runtime.getRegisteredChaiBlock(c._type),m={},h=lodashEs.get(p,"aiProps",[]);for(const g in c)d.includes(g)||h.includes(g)&&(m[g]=lodashEs.get(c,`${g}-${l}`,c[g]));return lodashEs.isEmpty(m)?!1:(lodashEs.has(u,"_parent")&&lodashEs.isEmpty(u._parent)&&delete u._parent,{...u,...m})})),addLangToPrompt=(a,l,c)=>!l||c!=="content"?a:`${a}. Generate content in ${lodashEs.get(LANGUAGES,l,l)} language.`,askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[a,l]=jotai.useAtom(askAiProcessingAtom),[c,d]=React.useState(null),u=useBuilderProp("askAiCallBack",null),p=useStreamMultipleBlocksProps(),m=useUpdateMultipleBlocksProps(),[h]=useBlocksStore(),{selectedLang:g,fallbackLang:x}=useLanguages(),f=g.length?g:x,y=(b,j)=>{const R=lodashEs.cloneDeep(j.find(k=>k._id===b));for(const k in R){const v=R[k];if(typeof v=="string"&&lodashEs.startsWith(v,getSplitClasses.STYLES_KEY)){const{baseClasses:S,classes:C}=getSplitClasses.getSplitChaiClasses(v);R[k]=lodashEs.compact(lodashEs.flattenDeep([S,C])).join(" ")}else k!=="_id"&&delete R[k]}return R};return{askAi:React.useCallback(async(b,j,R,k)=>{if(u){l(!0),d(null);try{const v=g===x?"":g,S=b==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(j,h)),g):[y(j,h)],C=await u(b,addLangToPrompt(R,f,b),S,v),{blocks:I,error:T}=C;if(T){d(T);return}if(b==="styles"){const _=I.map(A=>{for(const B in A)B!=="_id"&&(A[B]=`${getSplitClasses.STYLES_KEY},${A[B]}`);return A});m(_)}else p(I);k&&k(C)}catch(v){d(v)}finally{l(!1),k&&k()}}},[u,l,g,x,h,f,m,p]),loading:a,error:c}},useAiAssistant=()=>{const[,a]=useRightPanel();return React.useCallback(l=>{a(l?"ai":"block")},[a])};let lastHighlighted=null;const useBlockHighlight=()=>{const[a]=jotai.useAtom(canvasIframeAtom),l=React.useMemo(()=>{var u;return(a==null?void 0:a.contentDocument)||((u=a==null?void 0:a.contentWindow)==null?void 0:u.document)},[a]);return{highlightBlock:React.useCallback(u=>{if(l)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof u!="string")u.setAttribute("data-highlighted","true"),lastHighlighted=u;else if(typeof u=="string"){const p=l.querySelector(`[data-block-id="${u}"]`);p&&(p.setAttribute("data-highlighted","true"),lastHighlighted=p)}else lastHighlighted=null},[l]),clearHighlight:()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},lastHighlighted}},partialBlocksStoreAtom=atom({}),partialBlocksLoadingStateAtom=atom({}),usePartailBlocksStore=()=>{const[a,l]=useAtom(partialBlocksStoreAtom),c=React.useCallback(u=>lodashEs.get(a,u,[]),[a]),d=React.useCallback(()=>l({}),[l]);return{getPartailBlocks:c,reset:d}},useWatchPartailBlocks=()=>{const[a]=useBlocksStore(),[l,c]=useAtom(partialBlocksStoreAtom),[d,u]=useAtom(partialBlocksLoadingStateAtom),p=useBuilderProp("getPartialBlockBlocks",async h=>[]),m=React.useMemo(()=>a.filter(h=>h._type==="PartialBlock"||h._type==="GlobalBlock").map(h=>lodashEs.get(h,"partialBlockId",lodashEs.get(h,"globalBlock",""))),[a]);React.useEffect(()=>{lodashEs.forEach(m,h=>{lodashEs.has(l,h)||lodashEs.get(d,`${h}.loading`,!1)||(u(g=>({...g,[h]:{loading:!0,error:null}})),p(h).then(g=>{c(x=>({...x,[h]:g})),u(x=>({...x,[h]:{loading:!1,error:null}}))}).catch(g=>{u(x=>({...x,[h]:{loading:!1,error:g.message}}))}))})},[p,l,d,c,u,m])},partialBlocksListAtom=atom({}),usePartialBlocksList=()=>{const[a,l]=React.useState(!1),[c,d]=React.useState(null),[u,p]=useAtom(partialBlocksListAtom),m=useBuilderProp("getPartialBlocks",async()=>[]),h=React.useCallback(async()=>{l(!0),d(null);try{const g=await m();p(g),l(!1)}catch(g){d(g instanceof Error?g.message:"Failed to fetch partial blocks"),l(!1)}},[m,p]);return React.useEffect(()=>{h()},[]),{data:u,isLoading:a,refetch:h,error:c}},useBuilderReset=()=>{const{clear:a}=useUndoManager(),[,l]=useSelectedBlockIds(),{clearHighlight:c}=useBlockHighlight(),[,d]=useSelectedStylingBlocks(),[,u]=useAtom(aiAssistantActiveAtom),{reset:p}=usePartailBlocksStore(),{setSaveState:m}=useSavePage();return()=>{l([]),d([]),c(),a(),u(!1),p(),m("SAVED")}},canvasZoomAtom=atomWithStorage("canvasZoom",100),useCanvasZoom=()=>jotai.useAtom(canvasZoomAtom),codeEditorAtom=jotai.atom(null),useCodeEditor=()=>jotai.useAtom(codeEditorAtom),cutBlockIdsAtom=jotai.atom([]),useCutBlockIds=()=>{const[a,l]=jotai.useAtom(cutBlockIdsAtom),c=jotai.useSetAtom(copiedBlockIdsAtom),d=React.useCallback(u=>{l(u),c([])},[l,c]);return[a,d]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlockIds=()=>{const[a]=useBlocksStore(),[l,c]=jotai.useAtom(copiedBlockIdsAtom),d=jotai.useSetAtom(cutBlockIdsAtom),u=React.useCallback(async p=>{try{c(p),d([]);const m={_chai_copied_blocks:p.flatMap(h=>getDuplicatedBlocks(a,h,null))};await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy blocks to clipboard:",m)}},[c,d,a]);return[l,u]},useCopyToClipboard=()=>{const[a,l]=React.useState(null),c=React.useCallback(async d=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(d),l(d),!0}catch(u){return console.warn("Copy failed",u),l(null),!1}},[]);return[a,c]},darkModeAtom=atomWithStorage("darkMode",!1),useDarkMode=()=>{const[a,l]=jotai.useAtom(darkModeAtom);return[a,l]},useDuplicateBlocks=()=>{const[a]=useBlocksStore(),[,l]=useSelectedBlockIds(),{addBlocks:c}=useBlocksStoreUndoableActions();return React.useCallback((d,u=null)=>{const p=[];lodashEs.each(d,m=>{const h=a.find(b=>b._id===m);u?u==="root"&&(u=null):u=h._parent;const f=lodashEs.filter(a,b=>lodashEs.isString(u)?b._parent===u:!b._parent).indexOf(h)+1,y=getDuplicatedBlocks(a,m,u);c(y,u,f),p.push(lodashEs.get(y,"0._id",""))}),l(p)},[a,l])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[a,l]=jotai.useAtom(hiddenBlockIdsAtom),c=React.useCallback(d=>{l(u=>lodashEs.includes(u,d)?lodashEs.without(u,d):[...u,d])},[l]);return[a,l,c]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),useCanPaste=()=>{const[a]=useBlocksStore();return(l,c)=>{var p;const d=((p=lodashEs.find(a,{_id:c}))==null?void 0:p._type)||null,u=lodashEs.first(l.map(m=>{var h;return(h=lodashEs.find(a,{_id:m}))==null?void 0:h._type}));return canAcceptChildBlock(d,u)}},useMoveCutBlocks=()=>{const a=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:l}=useBlocksStoreUndoableActions();return React.useCallback((c,d)=>{const u=Array.isArray(d)?d[0]:d;if(d==="root"){const p=a==null?void 0:a.filter(m=>!m._parent);l(c,null,(p==null?void 0:p.length)||0)}else{const p=a==null?void 0:a.filter(m=>m._parent===u);l(c,u,(p==null?void 0:p.length)||0)}},[l,a])},usePasteBlocks=()=>{const[a,l]=useCutBlockIds(),c=useMoveCutBlocks(),d=useCanPaste(),{addPredefinedBlock:u}=useAddBlock();return{canPaste:React.useCallback(async m=>{if(a.length>0)return d(a,m);try{const h=await navigator.clipboard.readText();if(h){const g=JSON.parse(h);return lodashEs.has(g,"_chai_copied_blocks")}}catch{return!1}return!1},[d,a]),pasteBlocks:React.useCallback(async m=>{const h=Array.isArray(m)?m[0]:m;if(!lodashEs.isEmpty(a)){c(a,m),l([]),await navigator.clipboard.writeText("");return}try{const g=await navigator.clipboard.readText();if(g){const x=JSON.parse(g);lodashEs.has(x,"_chai_copied_blocks")?u(x._chai_copied_blocks,h==="root"?null:h):sonner.toast.error("Nothing to paste")}else sonner.toast.error("Nothing to paste")}catch{sonner.toast.error("Failed to paste blocks from clipboard")}},[a,u,c,l])}},previewModeAtom=jotai.atom(!1),usePreviewMode=()=>{const[a,l]=jotai.useAtom(previewModeAtom);return[a,l]},removeClassFromBlocksAtom=jotai.atom(null,(a,l,{blockIds:c,fullClasses:d})=>{const u=lodashEs.first(a(selectedStylingBlocksAtom)),p=lodashEs.filter(a(pageBlocksAtomsAtom),m=>c.includes(a(m)._id));return lodashEs.map(p,m=>{const h=a(m),g=d;let{classes:x,baseClasses:f}=getSplitClasses.getSplitChaiClasses(lodashEs.get(h,u.prop,`${getSplitClasses.STYLES_KEY},`));return lodashEs.each(g,y=>{const b=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(^|\\s)${b}(?=\\s|$)`,"g");x=x.replace(j," ").replace(/\s+/g," ").trim();const R=lodashEs.first(y.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],R)&&g.push(y.split(":").pop().trim())}),lodashEs.each(g,y=>{const b=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(^|\\s)${b}(?=\\s|$)`,"g");f=f.replace(j," ").replace(/\s+/g," ").trim()}),{ids:[h._id],props:{[u.prop]:`${getSplitClasses.STYLES_KEY}${f},${x}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:a,updateBlocksRuntime:l}=useBlocksStoreUndoableActions(),c=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((d,u,p=!1)=>{const m=c({blockIds:d,fullClasses:u});p?a(d,m[0].props):l(d,m[0].props)},[c])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(a=>{const l=a(canvasWidthAtom);return Functions.getBreakpointValue(l).toLowerCase()}),useScreenSizeWidth=()=>{const[a,l]=jotai.useAtom(canvasWidthAtom),c=jotai.useAtomValue(canvasBreakpointAtom),[d,u]=useStylingBreakpoint();return React.useEffect(()=>{d!=="xs"&&u(c)},[c,d,u]),[a,c,l]},useCanvasDisplayWidth=()=>{const[a,l]=jotai.useAtom(canvasDisplayWidthAtom);return[a,l]},selectedBlockAllClassesAtom=jotai.atom(a=>{const l=lodashEs.first(a(selectedStylingBlocksAtom)),c=a(selectedBlockAtom);if(!l||l.blockId!==lodashEs.get(c,"_id",null))return[];const d=lodashEs.get(c,l.prop,`${getSplitClasses.STYLES_KEY},`),{classes:u}=getSplitClasses.getSplitChaiClasses(d);return lodashEs.filter(lodashEs.map(u.trim().split(" "),constructClassObject),p=>!lodashEs.isNull(p))}),useSelectedBlockAllClasses=()=>jotai.useAtomValue(selectedBlockAllClassesAtom),MQ={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},selectedBlockCurrentClassesAtom=jotai.atom(a=>{const l=a(canvasBreakpointAtom),c=a(styleStateAtom),d=a(darkModeAtom),u=getQueries(l);let p=lodashEs.filter(a(selectedBlockAllClassesAtom),{mod:c});return lodashEs.startsWith(c,"_")||(p=lodashEs.filter(p,m=>u.includes(m.mq))),p=p.sort((m,h)=>MQ[m.mq]-MQ[h.mq]),d||(p=lodashEs.filter(p,{dark:!1})),p}),getQueries=a=>{let l=[];switch(a){case"xs":l=["xs"];break;case"sm":l=["xs","sm"];break;case"md":l=["xs","sm","md"];break;case"lg":l=["xs","sm","md","lg"];break;case"xl":l=["xs","sm","md","lg","xl"];break;case"2xl":l=["xs","sm","md","lg","xl","2xl"];break;default:l=["xs"];break}return l},useSelectedBlockCurrentClasses=()=>jotai.useAtomValue(selectedBlockCurrentClassesAtom),selectedBreakpointsAtom=atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),useSelectedBreakpoints=()=>{const[a,l]=jotai.useAtom(selectedBreakpointsAtom);return[a,l]},useStylingState=()=>jotai.useAtom(styleStateAtom),useUILibraryBlocks=()=>({data:useBuilderProp("uiLibraries",[]),isLoading:!1}),wrapperBlockAtom=jotai.atom(a=>{var m;const l=a(presentBlocksAtom),c=a(selectedBlockIdsAtom),d=c.length===1?c[0]:null;if(!d)return null;const u=lodashEs.find(l,{_id:d});if(!u)return null;let p=u._parent;for(;p;){const h=lodashEs.find(l,{_id:p});if(!h)return null;if((m=runtime.getRegisteredChaiBlock(h._type))!=null&&m.wrapper)return h;p=h._parent}return null});wrapperBlockAtom.debugLabel="wrapperBlockAtom";const useWrapperBlock=()=>jotai.useAtomValue(wrapperBlockAtom),sidebarActivePanelAtom=jotai.atom("outline");sidebarActivePanelAtom.debugLabel="sidebarActivePanelAtom";const useSidebarActivePanel=()=>jotai.useAtom(sidebarActivePanelAtom);function getOrientation(a,l=null){const c=window.getComputedStyle(a),d=l?window.getComputedStyle(l):null,u=c.display,p=d?d.display:null;if(u==="flex"||u==="inline-flex"){const m=c.flexDirection;return m==="column"||m==="column-reverse"?"vertical":"horizontal"}else if(u==="grid"){const m=c.gridAutoFlow,h=c.gridTemplateColumns;return m.includes("column")||h&&h!=="none"&&h!==""&&!h.includes("calc")&&h.split(" ").length<=1?"vertical":"horizontal"}else if(p==="inline-block"||p==="inline")return"horizontal";return"vertical"}const CONTROLS=[{ControlIcon:reactIcons.PinTopIcon,dir:"VERTICAL",key:"UP"},{ControlIcon:reactIcons.PinBottomIcon,dir:"VERTICAL",key:"DOWN"},{ControlIcon:reactIcons.PinLeftIcon,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:reactIcons.PinRightIcon,dir:"HORIZONTAL",key:"RIGHT"}],getParentBlockOrientation=(a,l,c)=>{try{if(!a||!c)return"VERTICAL";const d=`[data-block-id='${a}']`,u=c==null?void 0:c.querySelector(d);if(u){const p=c==null?void 0:c.querySelector(`[data-block-id='${l}']`);return getOrientation(u,p).toUpperCase()}return"VERTICAL"}catch{return"VERTICAL"}},isDisabledControl=(a,l,c)=>!!(a&&(c==="UP"||c==="LEFT")||l&&(c==="DOWN"||c==="RIGHT")),useBlockController=(a,l)=>{const[c]=useBlocksStore(),{document:d}=useFrame(),{moveBlocks:u}=useBlocksStoreUndoableActions(),p=lodashEs.get(a,"_id"),m=lodashEs.get(a,"_parent"),h=lodashEs.filter(c,R=>m?lodashEs.get(R,"_parent")===m:!lodashEs.get(R,"_parent")),g=(h==null?void 0:h.length)<=1,x=lodashEs.findIndex(h,{_id:p}),f=x<=0,y=x+1===(h==null?void 0:h.length),b=getParentBlockOrientation(m,p,d),j=React.useCallback(R=>{isDisabledControl(f,y,R)||g||(R==="UP"||R==="LEFT"?u([p],m||null,x-1):(R==="DOWN"||R==="RIGHT")&&u([p],m||null,x+2),l())},[f,y,g,x,p,m,l]);return reactHotkeysHook.useHotkeys("shift+up, shift+down, shift+left, shift+right",({key:R})=>{var k;j((k=R==null?void 0:R.replace("Arrow",""))==null?void 0:k.toUpperCase())},{document:d==null?void 0:d.contentDocument},[j]),{isOnlyChild:g,isFirstBlock:f,isLastBlock:y,moveBlock:j,orientation:b}},BlockController=({block:a,updateFloatingBar:l})=>{const{isOnlyChild:c,isFirstBlock:d,isLastBlock:u,moveBlock:p,orientation:m}=useBlockController(a,l);return c?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:CONTROLS.map(({ControlIcon:h,dir:g,key:x})=>{if(m!==g)return null;const f=isDisabledControl(d,u,x);return f?null:jsxRuntime.jsx(h,{onClick:()=>p(x),className:`${f?"pointer-events-none cursor-not-allowed opacity-50":"duration-300 hover:scale-95 hover:opacity-80"}`},x)})})},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS"};class PubSub{constructor(){W(this,"subscribers",new Map)}subscribe(l,c){return this.subscribers.has(l)||this.subscribers.set(l,new Set),this.subscribers.get(l).add(c),()=>{const d=this.subscribers.get(l);d&&(d.delete(c),d.size===0&&this.subscribers.delete(l))}}publish(l,c){const d=this.subscribers.get(l);d&&d.forEach(u=>u(c))}}const pubsub=new PubSub,AddBlockDropdown=({block:a,children:l})=>{const{t:c}=reactI18next.useTranslation(),[d]=useBlocksStore(),{hasPermission:u}=usePermissions(),p=lodashEs.get(a,"_id"),m=lodashEs.get(a,"_parent"),h=lodashEs.filter(d,y=>m?lodashEs.get(y,"_parent")===m:!lodashEs.get(y,"_parent")),g=canAddChildBlock(lodashEs.get(a,"_type","")),x=lodashEs.findIndex(h,{_id:p}),f=y=>{if(y==="CHILD")pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,a);else{const b={_id:m||"",position:h==null?void 0:h.length};y==="BEFORE"?b.position=Math.max(x,0):y==="AFTER"&&(b.position=x+1),pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,b)}};return u(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(tooltip.DropdownMenu,{children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{children:l}),jsxRuntime.jsxs(tooltip.DropdownMenuContent,{className:"border border-blue-500 bg-blue-500 text-white shadow-2xl",children:[g&&jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("CHILD"),children:c("Add inside")}),jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("BEFORE"),children:c("Add before")}),jsxRuntime.jsx(tooltip.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>f("AFTER"),children:c("Add after")})]})]}):null},draggedBlockAtom=jotai.atom(null),dropTargetBlockIdAtom=jotai.atom(null),BlockActionLabel=({block:a,label:l})=>{const[,c]=useSelectedBlockIds(),[,d]=useHighlightBlockId(),[,u]=jotai.useAtom(draggedBlockAtom),p=flagged.useFeature("dnd");return jsxRuntime.jsxs("div",{className:"mr-10 flex cursor-default items-center space-x-1 px-1",draggable:p?"true":"false",onDragStart:m=>{m.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.pick(a,["_id","_type","_name"]))),u(a),setTimeout(()=>{c([]),d(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),l]})},BlockFloatingSelector=({selectedBlockElement:a,block:l})=>{const c=useRemoveBlocks(),d=useDuplicateBlocks(),[,u]=useSelectedBlockIds(),[,p]=useHighlightBlockId(),[,m]=useSelectedStylingBlocks(),{hasPermission:h}=usePermissions(),[g]=jotai.useAtom(inlineEditingActiveAtom),{document:x}=useFrame(),{floatingStyles:f,refs:y,update:b}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:a}});web.useResizeObserver(a,()=>b(),a!==null),web.useResizeObserver(x==null?void 0:x.body,()=>b(),(x==null?void 0:x.body)!==null);const j=lodashEs.get(l,"_parent",null),R=lodashEs.isEmpty(lodashEs.get(l,"_name",""))?lodashEs.get(l,"_type",""):lodashEs.get(l,"_name","");return!a||!l||g?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:y.setFloating,style:f,onClick:k=>{k.stopPropagation(),k.preventDefault()},onMouseEnter:k=>{k.stopPropagation(),p(null)},onKeyDown:k=>k.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[j&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{m([]),u([j])}}),jsxRuntime.jsx(BlockActionLabel,{label:R,block:l}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1.5",children:[jsxRuntime.jsx(AddBlockDropdown,{block:l,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105"})}),canDuplicateBlock(lodashEs.get(l,"_type",""))&&h(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>d([l==null?void 0:l._id])}):null,canDeleteBlock(lodashEs.get(l,"_type",""))&&h(PERMISSIONS.DELETE_BLOCK)?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>c([l==null?void 0:l._id])}):null,h(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(BlockController,{block:l,updateFloatingBar:b})]})]})})},IframeInitialContent=`<!doctype html>
|
|
2
2
|
<html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
<body class="font-body antialiased h-full">
|
|
54
54
|
<div class="frame-root h-full"></div>
|
|
55
55
|
</body>
|
|
56
|
-
</html>`,useKeyEventWatcher=a=>{const[l,c]=useSelectedBlockIds(),d=useSelectedBlock(),u=useRemoveBlocks(),p=useDuplicateBlocks(),{undo:m,redo:h}=useUndoManager(),[,g]=useCutBlockIds(),[,x]=useCopyBlockIds(),{canPaste:f,pasteBlocks:y}=usePasteBlocks(),b=a?{document:a}:{};reactHotkeysHook.useHotkeys("ctrl+z,command+z",()=>m(),{},[m]),reactHotkeysHook.useHotkeys("ctrl+y,command+y",()=>h(),{},[h]),reactHotkeysHook.useHotkeys("ctrl+x,command+x",()=>g(l),{},[l,g]),reactHotkeysHook.useHotkeys("ctrl+c,command+c",()=>x(l),{},[l,x]),reactHotkeysHook.useHotkeys("ctrl+v,command+v",()=>{f(l[0])&&y(l)},{...b,preventDefault:!0},[l,f,y]),reactHotkeysHook.useHotkeys("esc",()=>c([]),b,[c]),reactHotkeysHook.useHotkeys("ctrl+d,command+d",()=>p(l),{...b,preventDefault:!0},[l,p]),reactHotkeysHook.useHotkeys("del, backspace",j=>{j.preventDefault(),canDeleteBlock(lodashEs.get(d,"_type",""))&&u(l)},b,[l,u])},KeyboardHandler=()=>{const{document:a}=useFrame();return useKeyEventWatcher(a),null},AddBlockAtBottom=()=>{const{t:a}=reactI18next.useTranslation(),{hasPermission:l}=usePermissions();return l(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer py-2",children:[jsxRuntime.jsx("br",{}),jsxRuntime.jsx("div",{role:"button",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),className:"block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(lucideReact.PlusIcon,{className:"size-2.5 stroke-[3]"})," ",a("Add block")]})}),jsxRuntime.jsx("br",{})]}):null};let iframeDocument=null,possiblePositions=[],dropTarget=null,dropIndex=null;const positionPlaceholder=(a,l,c)=>{if(!iframeDocument||!a)return;const d=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder"),u=possiblePositions.map(([g])=>g),p=u.reduce((g,x)=>Math.abs(x-c)<Math.abs(g-c)?x:g,0),m=u.indexOf(p);if(!possiblePositions[m])return;const h=possiblePositions[m];d.style.width=l==="vertical"?h[2]+"px":"2px",d.style.height=l==="vertical"?"2px":h[2]+"px",d.style.display="block",l==="vertical"?(d.style.top=h[0]+"px",d.style.left=h[1]+"px"):(d.style.top=h[1]+"px",d.style.left=h[0]+"px")};function calculateDropIndex(a,l){let c=0,d=1/0;return l.forEach((u,p)=>{const m=Math.abs(u[0]-a);m<d&&(d=m,c=p)}),c}const calculatePossiblePositions=a=>{const c=getOrientation(a)==="horizontal";possiblePositions=[],Array.from(a.children).forEach((d,u)=>{if(d.classList.contains("pointer-events-none"))return;const p=c?d.offsetLeft:d.offsetTop,m=c?[d.offsetTop,d.clientHeight]:[d.offsetLeft,d.clientWidth];if(possiblePositions.push([p,m[0],m[1]]),u===a.children.length-1){const h=c?d.offsetLeft+d.clientWidth:d.offsetTop+d.clientHeight;possiblePositions.push([h,m[0],m[1]])}})},throttledDragOver=lodashEs.throttle(a=>{var u;const l=a.target,c=getOrientation(l),d=(u=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:u.scrollY;c==="vertical"?positionPlaceholder(l,c,a.clientY+d):positionPlaceholder(l,c,a.clientX)},0);function removePlaceholder(){const a=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder");a.style.display="none",removeClassFromElements("pointer-none"),removeDataDrop()}function removeClassFromElements(a){(iframeDocument==null?void 0:iframeDocument.querySelectorAll(`.${a}`)).forEach(c=>{c.classList.remove(a)})}function removeDataDrop(){const a=iframeDocument==null?void 0:iframeDocument.querySelector('[data-drop="yes"]');a&&a.removeAttribute("data-drop")}const useDnd=()=>{const{document:a}=useFrame(),[l,c]=jotai.useAtom(draggingFlagAtom),{addCoreBlock:d}=useAddBlock(),[,u]=useHighlightBlockId(),[,p]=useSelectedBlockIds(),{moveBlocks:m}=useBlocksStoreUndoableActions(),[h,g]=jotai.useAtom(draggedBlockAtom),[,x]=jotai.useAtom(dropTargetBlockIdAtom);if(!flagged.useFeature("dnd"))return{};const y=()=>{removePlaceholder(),c(!1),g(null),x(null),possiblePositions=[]};return iframeDocument=a,{isDragging:l,onDragOver:b=>{b.preventDefault(),b.stopPropagation(),throttledDragOver(b)},onDrop:b=>{var
|
|
56
|
+
</html>`,useKeyEventWatcher=a=>{const[l,c]=useSelectedBlockIds(),d=useSelectedBlock(),u=useRemoveBlocks(),p=useDuplicateBlocks(),{undo:m,redo:h}=useUndoManager(),[,g]=useCutBlockIds(),[,x]=useCopyBlockIds(),{canPaste:f,pasteBlocks:y}=usePasteBlocks(),b=a?{document:a}:{};reactHotkeysHook.useHotkeys("ctrl+z,command+z",()=>m(),{},[m]),reactHotkeysHook.useHotkeys("ctrl+y,command+y",()=>h(),{},[h]),reactHotkeysHook.useHotkeys("ctrl+x,command+x",()=>g(l),{},[l,g]),reactHotkeysHook.useHotkeys("ctrl+c,command+c",()=>x(l),{},[l,x]),reactHotkeysHook.useHotkeys("ctrl+v,command+v",()=>{f(l[0])&&y(l)},{...b,preventDefault:!0},[l,f,y]),reactHotkeysHook.useHotkeys("esc",()=>c([]),b,[c]),reactHotkeysHook.useHotkeys("ctrl+d,command+d",()=>p(l),{...b,preventDefault:!0},[l,p]),reactHotkeysHook.useHotkeys("del, backspace",j=>{j.preventDefault(),canDeleteBlock(lodashEs.get(d,"_type",""))&&u(l)},b,[l,u])},KeyboardHandler=()=>{const{document:a}=useFrame();return useKeyEventWatcher(a),null},AddBlockAtBottom=()=>{const{t:a}=reactI18next.useTranslation(),{hasPermission:l}=usePermissions();return l(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer py-2",children:[jsxRuntime.jsx("br",{}),jsxRuntime.jsx("div",{role:"button",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),className:"block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(lucideReact.PlusIcon,{className:"size-2.5 stroke-[3]"})," ",a("Add block")]})}),jsxRuntime.jsx("br",{})]}):null};let iframeDocument=null,possiblePositions=[],dropTarget=null,dropIndex=null;const positionPlaceholder=(a,l,c)=>{if(!iframeDocument||!a)return;const d=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder"),u=possiblePositions.map(([g])=>g),p=u.reduce((g,x)=>Math.abs(x-c)<Math.abs(g-c)?x:g,0),m=u.indexOf(p);if(!possiblePositions[m])return;const h=possiblePositions[m];d.style.width=l==="vertical"?h[2]+"px":"2px",d.style.height=l==="vertical"?"2px":h[2]+"px",d.style.display="block",l==="vertical"?(d.style.top=h[0]+"px",d.style.left=h[1]+"px"):(d.style.top=h[1]+"px",d.style.left=h[0]+"px")};function calculateDropIndex(a,l){let c=0,d=1/0;return l.forEach((u,p)=>{const m=Math.abs(u[0]-a);m<d&&(d=m,c=p)}),c}const calculatePossiblePositions=a=>{const c=getOrientation(a)==="horizontal";possiblePositions=[],Array.from(a.children).forEach((d,u)=>{if(d.classList.contains("pointer-events-none"))return;const p=c?d.offsetLeft:d.offsetTop,m=c?[d.offsetTop,d.clientHeight]:[d.offsetLeft,d.clientWidth];if(possiblePositions.push([p,m[0],m[1]]),u===a.children.length-1){const h=c?d.offsetLeft+d.clientWidth:d.offsetTop+d.clientHeight;possiblePositions.push([h,m[0],m[1]])}})},throttledDragOver=lodashEs.throttle(a=>{var u;const l=a.target,c=getOrientation(l),d=(u=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:u.scrollY;c==="vertical"?positionPlaceholder(l,c,a.clientY+d):positionPlaceholder(l,c,a.clientX)},0);function removePlaceholder(){const a=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder");a.style.display="none",removeClassFromElements("pointer-none"),removeDataDrop()}function removeClassFromElements(a){(iframeDocument==null?void 0:iframeDocument.querySelectorAll(`.${a}`)).forEach(c=>{c.classList.remove(a)})}function removeDataDrop(){const a=iframeDocument==null?void 0:iframeDocument.querySelector('[data-drop="yes"]');a&&a.removeAttribute("data-drop")}const useDnd=()=>{const{document:a}=useFrame(),[l,c]=jotai.useAtom(draggingFlagAtom),{addCoreBlock:d}=useAddBlock(),[,u]=useHighlightBlockId(),[,p]=useSelectedBlockIds(),{moveBlocks:m}=useBlocksStoreUndoableActions(),[h,g]=jotai.useAtom(draggedBlockAtom),[,x]=jotai.useAtom(dropTargetBlockIdAtom);if(!flagged.useFeature("dnd"))return{};const y=()=>{removePlaceholder(),c(!1),g(null),x(null),possiblePositions=[]};return iframeDocument=a,{isDragging:l,onDragOver:b=>{b.preventDefault(),b.stopPropagation(),throttledDragOver(b)},onDrop:b=>{var T;const j=dropTarget,k=getOrientation(j)==="vertical"?b.clientY+((T=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:T.scrollY):b.clientX;dropIndex=calculateDropIndex(k,possiblePositions);const v=h,S=j.getAttribute("data-block-id"),C=dropTarget.getAttribute("data-dnd-dragged")!=="yes";if((v==null?void 0:v._id)===S||!C){y();return}if(!lodashEs.has(v,"_id")){d(v,S==="canvas"?null:S,dropIndex),setTimeout(y,300);return}let I=j.getAttribute("data-block-id");I===null&&(I=b.target.parentElement.getAttribute("data-block-id")),m([v._id],I==="canvas"?null:I,dropIndex),y(),setTimeout(removePlaceholder,300)},onDragEnter:b=>{const j=b,R=j.target;dropTarget=R;const k=R.getAttribute("data-block-id"),v=R.getAttribute("data-dnd-dragged")!=="yes";x(k),j.stopPropagation(),j.preventDefault(),possiblePositions=[],v&&calculatePossiblePositions(R),c(!0),u(""),p([])},onDragLeave:b=>{b.target.getAttribute("data-block-id")==="canvas"&&(x(null),c(!1),removePlaceholder(),possiblePositions=[])}}};function getTargetedBlock(a){if(a.getAttribute("data-block-id")==="canvas")return null;if(a.getAttribute("data-block-id")||a.getAttribute("data-block-parent"))return a;const l=a.closest("[data-block-id]");return(l==null?void 0:l.getAttribute("data-block-id"))==="canvas"?null:l}const useHandleCanvasDblClick=(a,l)=>{const c=[],d=useUpdateBlocksProps(),[u,p]=jotai.useAtom(inlineEditingActiveAtom),{clearHighlight:m}=useBlockHighlight(),h=useGetBlockAtomValue(pageBlocksAtomsAtom);return React.useCallback(g=>{if(u)return;const x=getTargetedBlock(g.target);if(!x)return;const f=x.getAttribute("data-block-type");if(!f||!c.includes(f))return;const y=x.getAttribute("data-block-id");if(!y)return;a.on("update",({editor:j})=>{console.log(j.getHTML())}),a.on("blur",()=>{console.log("blur");const j=a.getHTML();d([y],{content:j}),l.style.display="none",x.style.visibility="visible"}),p(y);const b=h(y).content;a.commands.setContent(b),l.style.display="block",x.style.visibility="hidden",l.style.position="absolute",l.style.top=`${x.offsetTop}px`,l.style.left=`${x.offsetLeft}px`,l.style.width=`${x.offsetWidth}px`,l.style.height=`${x.offsetHeight}px`,l.classList.add(...x.classList)},[u,m,h,p,d,a,l])},useHandleCanvasClick=()=>{const[,a]=useSelectedStylingBlocks(),[l,c]=useSelectedBlockIds(),[d]=jotai.useAtom(inlineEditingActiveAtom),[u]=jotai.useAtom(treeRefAtom),{clearHighlight:p}=useBlockHighlight();return m=>{if(d)return;m.stopPropagation();const h=getTargetedBlock(m.target);if(h!=null&&h.getAttribute("data-block-id")&&(h==null?void 0:h.getAttribute("data-block-id"))==="container"){c([]),a([]),p();return}if(h!=null&&h.getAttribute("data-block-parent")){const g=h.getAttribute("data-style-prop"),x=h.getAttribute("data-style-id"),f=h.getAttribute("data-block-parent");l.includes(f)||u==null||u.closeAll(),a([{id:x,prop:g,blockId:f}]),c([f])}else if(h!=null&&h.getAttribute("data-block-id")){const g=h.getAttribute("data-block-id");l.includes(g)||u==null||u.closeAll(),a([]),c(g==="canvas"?[]:[g])}p()}},useHandleMouseMove=()=>{const[a]=jotai.useAtom(inlineEditingActiveAtom),{highlightBlock:l}=useBlockHighlight();return lodashEs.throttle(c=>{if(a)return;const d=getTargetedBlock(c.target);d&&l(d)},20)},useHandleMouseLeave=()=>{const{clearHighlight:a}=useBlockHighlight();return a},Canvas=({children:a})=>{const{document:l}=useFrame(),[c]=useSelectedBlockIds(),[d,u]=useSelectedStylingBlocks(),{clearHighlight:p}=useBlockHighlight();React.useEffect(()=>p,[p]),React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(d))return;const j=getElementByDataBlockId(l,lodashEs.first(c));if(j){const R=j.getAttribute("data-style-prop");if(R){const k=j.getAttribute("data-style-id"),v=j.getAttribute("data-block-parent");u([{id:k,prop:R,blockId:v}])}}},100)},[l,c,u,d]);const m=react.useEditor({extensions:[StarterKit]}),h=React.useRef(null),g=useHandleCanvasDblClick(m,h.current),x=useHandleCanvasClick(),f=useHandleMouseMove(),y=useHandleMouseLeave(),b=useDnd();return jsxRuntime.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:x,onDoubleClick:g,onMouseMove:f,onMouseLeave:y,...lodashEs.omit(b,"isDragging"),className:"relative h-full max-w-full p-px "+(b.isDragging?"dragging":""),children:a})},getElementByDataBlockId=(a,l)=>a.querySelector(`[data-block-id="${l}"]`),HeadTags=()=>{const[a]=useTheme(),l=useThemeOptions(),[c]=useSelectedBlockIds(),[d]=useDarkMode(),[u]=useSelectedStylingBlocks(),[p]=jotai.useAtom(draggedBlockAtom),[m]=jotai.useAtom(dropTargetBlockIdAtom),{document:h,window:g}=useFrame(),[x]=React.useState(h==null?void 0:h.getElementById("highlighted-block")),[f]=React.useState(h==null?void 0:h.getElementById("selected-block")),[y]=React.useState(h==null?void 0:h.getElementById("selected-styling-block")),[b]=React.useState(h==null?void 0:h.getElementById("dragged-block"));React.useEffect(()=>{d?h==null||h.documentElement.classList.add("dark"):h==null||h.documentElement.classList.remove("dark")},[d,h]);const j=runtime.useRegisteredFonts();React.useEffect(()=>{!g||!g.tailwind||(g.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...chaiThemeHelpers.getChaiThemeOptions(l)}},plugins:[typography,forms,aspectRatio,containerQueries,chaiThemeHelpers.plugin(function({addBase:C,theme:I}){C({"h1,h2,h3,h4,h5,h6":{fontFamily:I("fontFamily.heading")},body:{fontFamily:I("fontFamily.body"),color:I("colors.foreground"),backgroundColor:I("colors.background")}})})]})},[a,l,g]),React.useEffect(()=>{f&&(f.textContent=`${lodashEs.map(c,C=>`[data-block-id="${C}"]`).join(",")}{
|
|
57
57
|
outline: 1px solid ${c.length===1?"#42a1fc !important":"orange !important"}; outline-offset: -1px;
|
|
58
58
|
}`)},[c,f]),React.useEffect(()=>{b.textContent=p?`[data-block-id="${p._id}"], [data-block-id="${p._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}`:""},[p,b]),React.useEffect(()=>{x&&(x.textContent='[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}')},[x]),React.useEffect(()=>{y&&(y.textContent=`${lodashEs.map(u,({id:C})=>`[data-style-id="${C}"]`).join(",")}{
|
|
59
59
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
60
|
-
}`)},[u,y]),React.useEffect(()=>{h.querySelector("#drop-target-block").innerHTML=m?`[data-block-id="${m}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[m,h]);const R=React.useMemo(()=>chaiThemeHelpers.getChaiThemeCssVariables(a),[a]),k=React.useMemo(()=>{const{heading:C,body:I}={heading:lodashEs.get(a,"fontFamily.heading"),body:lodashEs.get(a,"fontFamily.body")};return j.filter(w=>w.family===C||w.family===I)},[a==null?void 0:a.fontFamily,j]),v=React.useMemo(()=>chaiThemeHelpers.getThemeFontsLinkMarkup(lodashEs.filter(k,C=>lodashEs.has(C,"url"))),[k]),S=React.useMemo(()=>chaiThemeHelpers.getThemeCustomFontFace(lodashEs.filter(k,C=>lodashEs.has(C,"src"))),[k]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{id:"chai-theme",children:R}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:v}}),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:S}})]})},ResizableCanvasWrapper=({children:a,onMount:l,onResize:c})=>{const[,d]=useSelectedBlockIds(),[,u]=useSelectedStylingBlocks(),p=React.useRef(null),m=web.useDebouncedCallback(()=>{const{clientWidth:g}=p.current;c(g)},[p.current],100);web.useResizeObserver(p.current,m,p.current!==null),React.useEffect(()=>{const{clientWidth:g}=p.current;l(g)},[]);const h=()=>{d([]),u([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:h,className:"h-full w-full p-8 pb-0",ref:p,children:a})};function applyLanguage(a,l,c){const d=lodashEs.get(c,"i18nProps",[]);if(lodashEs.isEmpty(l)||lodashEs.isEmpty(d))return a;const u=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(u),p=>{lodashEs.includes(d,p)&&!lodashEs.isEmpty(l)&&(u[p]=lodashEs.get(u,`${p}-${l}`,u[p]))}),u}const applyBinding=(a,l)=>{const c=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(c),d=>{if(lodashEs.isString(c[d])&&!lodashEs.startsWith(d,"_")){let u=c[d];const p=/\{\{(.*?)\}\}/g,m=u.match(p);m&&m.forEach(h=>{const g=h.slice(2,-2),x=lodashEs.get(l,g,h);u=u.replace(h,x)}),c[d]=u}}),c},generateClassNames=lodashEs.memoize(a=>{const{baseClasses:l,classes:c}=getSplitClasses.getSplitChaiClasses(a);return tailwindMerge.twMerge(l,c)});function getElementAttrs(a,l){return lodashEs.get(a,`${l}_attrs`,{})}function getBlockTagAttributes(a){const l={};return Object.keys(a).forEach(c=>{if(lodashEs.isString(a[c])&&a[c].startsWith(getSplitClasses.STYLES_KEY)){const d=generateClassNames(a[c]),u=getElementAttrs(a,c);l[c]={className:d,"data-style-prop":c,"data-block-parent":a._id,"data-style-id":`${c}-${a._id}`,...u}}}),l}const getBlockRuntimeProps=lodashEs.memoize(a=>{const l=runtime.getRegisteredChaiBlock(a),c=lodashEs.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(c).filter(([,d])=>lodashEs.get(d,"runtime",!1)))}),useBlockRuntimeProps=()=>{const[a]=useBlocksStore();return React.useCallback((l,c)=>lodashEs.isEmpty(c)?{}:Object.entries(c).reduce((d,[u,p])=>{const m=[];let h=lodashEs.find(a,{_id:l});for(;h;)m.push(h),h=lodashEs.find(a,{_id:h._parent});const g=lodashEs.find(m,{_type:p.block});return g&&(d[u]=lodashEs.get(g,lodashEs.get(p,"prop"),null)),d},{}),[a])},BlockRenderer=({blockAtom:a,children:l})=>{const[c]=jotai.useAtom(a),d=React.useMemo(()=>runtime.getRegisteredChaiBlock(c._type),[c._type]),{selectedLang:u,fallbackLang:p}=useLanguages(),m=useBlockRuntimeProps(),h=usePageExternalData(),[g]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),f=lodashEs.get(d,"component",null),y=React.useMemo(()=>x?applyBinding(applyLanguage(c,u,d),h):applyLanguage(c,u,d),[c,u,d,h,x]),b=React.useMemo(()=>getBlockTagAttributes(c),[c,getBlockTagAttributes]),j=React.useMemo(()=>m(c._id,getBlockRuntimeProps(c._type)),[c._id,c._type,m,getBlockRuntimeProps]),R=React.useMemo(()=>!lodashEs.has(d,"dataProvider")||!lodashEs.isFunction(d.dataProvider)?{}:d.dataProvider(c,u),[c,u,d]),k=React.useMemo(()=>({blockProps:{"data-block-id":c._id,"data-block-type":c._type},inBuilder:!0,lang:u||p,...y,...b,...j,...R}),[c._id,c._type,u,p,y,b,j,R]);return lodashEs.isNull(f)||g.includes(c._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(f,{...k,children:l})})},PartialBlocksRenderer=({partialBlockId:a})=>{const{getPartailBlocks:l}=usePartailBlocksStore(),c=React.useMemo(()=>l(a),[l,a]),d=React.useMemo(()=>splitAtom(jotai.atom(c)),[c]);return lodashEs.isEmpty(c)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:d,blocks:c})},BlocksRenderer=({blocks:a,parent:l=null,splitAtoms:c=void 0})=>{const d=useGetBlockAtom(c),u=React.useMemo(()=>lodashEs.filter(a,m=>lodashEs.has(m,"_id")&&(lodashEs.isEmpty(l)?!m._parent:m._parent===l)),[a,l]),p=React.useCallback(m=>lodashEs.filter(a,h=>h._parent===m._id).length>0,[a]);return lodashEs.map(u,m=>{const h=d(m._id);return h?jsxRuntime.jsx(BlockRenderer,{blockAtom:h,children:m._type==="GlobalBlock"||m._type==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:lodashEs.get(m,"partialBlockId",lodashEs.get(m,"globalBlock",""))})}):p(m)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:c,blocks:a,parent:m._id}):null},m._id):null})},PageBlocksRenderer=()=>{const[a]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:a})},StaticBlocksRenderer=()=>{const[a]=useBlocksStore(),l=lodashEs.isEmpty(a)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:l})},useCanvasScale=a=>{const[l]=useCanvasDisplayWidth(),[,c]=useCanvasZoom(),d=useBuilderProp("htmlDir","ltr"),[u,p]=React.useState({}),m=React.useCallback(()=>{const{width:h,height:g}=a;if(h<l){const x=parseFloat((h/l).toFixed(2).toString());let f={};const y=g*x,b=h*x;g&&(f={height:100+(g-y)/y*100+"%",width:100+(h-b)/b*100+"%"}),p({position:"relative",top:0,transform:`scale(${x})`,transformOrigin:d==="rtl"?"top right":"top left",...f,maxWidth:"none"}),c(x*100)}else p({}),c(100)},[l,a,d,c]);return React.useEffect(()=>{m()},[l,a,c,m]),u},getElementByStyleId=(a,l)=>a.querySelector(`[data-style-id="${l}"]`),StaticCanvas=()=>{const[a]=jotai.useAtom(networkModeAtom),[l]=useCanvasDisplayWidth(),[,c]=useSelectedBlockIds(),d=useSelectedBlock(),[,u]=useHighlightBlockId(),p=React.useRef(null),m=React.useRef(null),[h,g]=React.useState({width:0,height:0}),x=useCanvasScale(h),[f,y]=React.useState([]),[,b]=React.useState([]),[,j]=jotai.useAtom(canvasIframeAtom),[R,k]=useSelectedStylingBlocks(),v=useBuilderProp("loading",!1),S=useBuilderProp("htmlDir","ltr"),C=T=>{g(A=>({...A,width:T}))};React.useEffect(()=>{if(!m.current)return;const{clientWidth:T,clientHeight:A}=m.current;g({width:T,height:A})},[m,l]);const I=(T,A=0)=>{const{top:B}=T.getBoundingClientRect();return B+A>=0&&B-A<=window.innerHeight};React.useEffect(()=>{var T,A;if(d&&d.type!=="Multiple"&&p.current){const B=getElementByDataBlockId(p.current.contentDocument,d._id);B&&(I(B)||(A=(T=p.current)==null?void 0:T.contentWindow)==null||A.scrollTo({top:B.offsetTop,behavior:"smooth"}),y([B]))}},[d]),React.useEffect(()=>{if(!lodashEs.isEmpty(R)&&p.current){const T=getElementByStyleId(p.current.contentDocument,lodashEs.first(R).id);b(T?[T]:[null])}else b([null])},[R]);const w=React.useMemo(()=>{let T=IframeInitialContent;return T=T.replace("__HTML_DIR__",S),a==="offline"&&(T=T.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),T},[a,S]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:C,onResize:C,children:jsxRuntime.jsx("div",{onClick:()=>{c([]),k([])},onMouseLeave:()=>setTimeout(()=>u(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:m,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>j(p.current),ref:p,id:"canvas-iframe",style:{...x,...lodashEs.isEmpty(x)?{width:`${l}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:w,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:d,selectedBlockElement:lodashEs.first(f)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[v?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),ICON_CLASS="h-3 w-3 stroke-[2]",TypeIcon=a=>{const l=runtime.useRegisteredChaiBlocks(),c=lodashEs.get(l,[a==null?void 0:a.type,"icon"]);return c?React.createElement(c,{className:ICON_CLASS}):jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:ICON_CLASS})},Breadcrumb=()=>{const a=useSelectedBlockHierarchy(),[,l]=useSelectedBlockIds(),{highlightBlock:c}=useBlockHighlight();return jsxRuntime.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{onClick:()=>l([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(a).map((d,u)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(tooltip.Button,{onMouseEnter:()=>{c(d==null?void 0:d._id)},onClick:()=>l([d==null?void 0:d._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:d==null?void 0:d._type}),d._name||d._type]}),u!==a.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},u))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-BG4oToVY.cjs"))),CanvasArea=()=>{const[a]=useCodeEditor(),l=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsx(StaticCanvas,{})})}),a?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"widget"}},registerBlockSettingField=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"field"}},registerBlockSettingTemplate=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"template"}},useBlockSettingComponents=a=>Object.values(RJSF_EXTENSIONS).filter(l=>l.type===a).reduce((l,c)=>(l[c.id]=c.component,l),{}),removeSizeAttributes=a=>{try{return a.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return a}},IconPickerField=({value:a,onChange:l,id:c})=>{const{t:d}=reactI18next.useTranslation(),[u,p]=React.useState(a||"");React.useEffect(()=>{p(a||"")},[a]);const m=h=>{p(h);const g=removeSizeAttributes(h);l(g)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:u?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:u}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:c,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:u,onChange:h=>m(h.target.value),placeholder:d("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:d("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:a,onSelect:l,mode:c="image"})=>{const[d,u]=React.useState(""),[p,m]=React.useState(!1),[h,g]=React.useState(!1),[x,f]=React.useState(null),y=async j=>{if(!j.trim()){g(!1),f("Please enter a URL");return}try{m(!0),f(null);const R=await fetch(j,{method:"HEAD"});if(!R.ok){g(!1),f("Invalid asset URL");return}const k=R.headers.get("content-type")||"";c==="image"&&k.startsWith("image/")||c==="video"&&k.startsWith("video/")||c==="audio"&&k.startsWith("audio/")?(g(!0),f(null)):(g(!1),f(`URL does not point to a valid ${c} file`))}catch{g(!1),f("Error validating URL")}finally{m(!1)}},{t:b}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:b(`${c.charAt(0).toUpperCase()+c.slice(1)} Manager`)}),x&&jsxRuntime.jsxs(tooltip.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(tooltip.AlertDescription,{children:x})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(tooltip.Input,{placeholder:b(`Enter ${c} URL`),value:d,onChange:j=>u(j.target.value),onBlur:()=>y(d)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(tooltip.Button,{variant:"outline",onClick:a,children:b("Cancel")}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>l([d]),disabled:!h||p,children:b("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=a=>{MEDIA_MANAGER.component=a},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({children:a,onSelect:l,mode:c="image"})=>{const[d,u]=React.useState(!1),p=useMediaManagerComponent(),m=(...h)=>{l.call(void 0,...h),u(!1)};return jsxRuntime.jsxs(tooltip.Dialog,{open:d,onOpenChange:h=>u(h),children:[jsxRuntime.jsx(tooltip.DialogTrigger,{asChild:!0,children:a}),jsxRuntime.jsx(tooltip.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:p?jsxRuntime.jsx(p,{close:()=>u(!1),onSelect:m,mode:c}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:a,onChange:l,id:c,onBlur:d})=>{const{t:u}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[a?jsxRuntime.jsx("img",{src:a,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsx(MediaManagerModal,{onSelect:p=>l(lodashEs.first(p)),mode:"image",children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:l,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:a||!lodashEs.isEmpty(a)?u("Replace image"):u("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsx("input",{id:c,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:u("Enter image URL"),value:a,onBlur:({target:{value:p}})=>d(c,p),onChange:p=>l(p.target.value)})]})]})};function NestedPathSelector({data:a,onSelect:l,dataType:c="value"}){const[d,u]=React__namespace.useState(!1),[p,m]=React__namespace.useState([]),[h,g]=React__namespace.useState(a);React.useEffect(()=>{d||m([]),g(a)},[d,a]);const x=j=>Array.isArray(j)?"array":typeof j=="object"&&j!==null?"object":"value",f=React__namespace.useCallback(j=>{const R=k=>c==="value"?k==="value"||k==="object":c==="array"?k==="array":k===c;j.type==="object"?(m(k=>[...k,j.key]),g(j.value)):R(j.type)&&(l([...p,j.key].join(".")),u(!1))},[p,l,c]),y=React__namespace.useCallback(()=>{if(p.length>0){const j=p.slice(0,-1);m(j),g(j.reduce((R,k)=>R[k],a))}},[p,a]),b=React__namespace.useMemo(()=>Object.entries(h).map(([j,R])=>({key:j,value:R,type:x(R)})).filter(j=>c==="value"?j.type==="value"||j.type==="object":c==="array"?j.type==="array"||j.type==="object":c==="object"?j.type==="object":!0),[h,c]);return jsxRuntime.jsxs(tooltip.Popover,{open:d,onOpenChange:u,children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"outline",className:"h-5 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":d,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3"})})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(tooltip.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(tooltip.Command,{className:"fields-command",children:[jsxRuntime.jsx(tooltip.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(tooltip.CommandList,{children:[jsxRuntime.jsx(tooltip.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(tooltip.CommandGroup,{children:[p.length>0&&jsxRuntime.jsxs(tooltip.CommandItem,{onSelect:y,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),b.map(j=>jsxRuntime.jsxs(tooltip.CommandItem,{value:j.key,disabled:!1,onSelect:()=>f(j),className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:j.key}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[c==="object"&&j.type==="object"&&jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:R=>{R.stopPropagation(),l([...p,j.key].join(".")),u(!1)},children:"Select"}),(j.type==="object"||j.type==="array")&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},j.key))]})]})]})})]})}function cn(...a){return tailwindMerge.twMerge(clsx.clsx(a))}const MenuBar=({editor:a,onExpand:l})=>{if(!a)return null;const c=()=>{const u=window.prompt("URL");u&&a.chain().focus().extendMarkRange("link").setLink({href:u}).run()},d=()=>{a.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:c,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:d,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!a.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:l,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:a,onClose:l,id:c,value:d,onChange:u,onBlur:p})=>{const m=React.useRef(null),h=React.useRef(d||""),g=usePageExternalData();React.useEffect(()=>{if(a){const y=document.createElement("style");return y.id="rte-modal-styles",y.innerHTML=`
|
|
60
|
+
}`)},[u,y]),React.useEffect(()=>{h.querySelector("#drop-target-block").innerHTML=m?`[data-block-id="${m}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[m,h]);const R=React.useMemo(()=>chaiThemeHelpers.getChaiThemeCssVariables(a),[a]),k=React.useMemo(()=>{const{heading:C,body:I}={heading:lodashEs.get(a,"fontFamily.heading"),body:lodashEs.get(a,"fontFamily.body")};return j.filter(T=>T.family===C||T.family===I)},[a==null?void 0:a.fontFamily,j]),v=React.useMemo(()=>chaiThemeHelpers.getThemeFontsLinkMarkup(lodashEs.filter(k,C=>lodashEs.has(C,"url"))),[k]),S=React.useMemo(()=>chaiThemeHelpers.getThemeCustomFontFace(lodashEs.filter(k,C=>lodashEs.has(C,"src"))),[k]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{id:"chai-theme",children:R}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:v}}),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:S}})]})},ResizableCanvasWrapper=({children:a,onMount:l,onResize:c})=>{const[,d]=useSelectedBlockIds(),[,u]=useSelectedStylingBlocks(),p=React.useRef(null),m=web.useDebouncedCallback(()=>{const{clientWidth:g}=p.current;c(g)},[p.current],100);web.useResizeObserver(p.current,m,p.current!==null),React.useEffect(()=>{const{clientWidth:g}=p.current;l(g)},[]);const h=()=>{d([]),u([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:h,className:"h-full w-full p-8 pb-0",ref:p,children:a})};function applyLanguage(a,l,c){const d=lodashEs.get(c,"i18nProps",[]);if(lodashEs.isEmpty(l)||lodashEs.isEmpty(d))return a;const u=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(u),p=>{lodashEs.includes(d,p)&&!lodashEs.isEmpty(l)&&(u[p]=lodashEs.get(u,`${p}-${l}`,u[p]))}),u}const applyBinding=(a,l)=>{const c=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(c),d=>{if(lodashEs.isString(c[d])&&!lodashEs.startsWith(d,"_")){let u=c[d];const p=/\{\{(.*?)\}\}/g,m=u.match(p);m&&m.forEach(h=>{const g=h.slice(2,-2),x=lodashEs.get(l,g,h);u=u.replace(h,x)}),c[d]=u}}),c},generateClassNames=lodashEs.memoize(a=>{const{baseClasses:l,classes:c}=getSplitClasses.getSplitChaiClasses(a);return tailwindMerge.twMerge(l,c)});function getElementAttrs(a,l){return lodashEs.get(a,`${l}_attrs`,{})}function getBlockTagAttributes(a){const l={};return Object.keys(a).forEach(c=>{if(lodashEs.isString(a[c])&&a[c].startsWith(getSplitClasses.STYLES_KEY)){const d=generateClassNames(a[c]),u=getElementAttrs(a,c);l[c]={className:d,"data-style-prop":c,"data-block-parent":a._id,"data-style-id":`${c}-${a._id}`,...u}}}),l}const getBlockRuntimeProps=lodashEs.memoize(a=>{const l=runtime.getRegisteredChaiBlock(a),c=lodashEs.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(c).filter(([,d])=>lodashEs.get(d,"runtime",!1)))}),useBlockRuntimeProps=()=>{const[a]=useBlocksStore();return React.useCallback((l,c)=>lodashEs.isEmpty(c)?{}:Object.entries(c).reduce((d,[u,p])=>{const m=[];let h=lodashEs.find(a,{_id:l});for(;h;)m.push(h),h=lodashEs.find(a,{_id:h._parent});const g=lodashEs.find(m,{_type:p.block});return g&&(d[u]=lodashEs.get(g,lodashEs.get(p,"prop"),null)),d},{}),[a])},BlockRenderer=({blockAtom:a,children:l})=>{const[c]=jotai.useAtom(a),d=React.useMemo(()=>runtime.getRegisteredChaiBlock(c._type),[c._type]),{selectedLang:u,fallbackLang:p}=useLanguages(),m=useBlockRuntimeProps(),h=usePageExternalData(),[g]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),f=lodashEs.get(d,"component",null),y=React.useMemo(()=>x?applyBinding(applyLanguage(c,u,d),h):applyLanguage(c,u,d),[c,u,d,h,x]),b=React.useMemo(()=>getBlockTagAttributes(c),[c,getBlockTagAttributes]),j=React.useMemo(()=>m(c._id,getBlockRuntimeProps(c._type)),[c._id,c._type,m,getBlockRuntimeProps]),R=React.useMemo(()=>!lodashEs.has(d,"dataProvider")||!lodashEs.isFunction(d.dataProvider)?{}:d.dataProvider(c,u),[c,u,d]),k=React.useMemo(()=>({blockProps:{"data-block-id":c._id,"data-block-type":c._type},inBuilder:!0,lang:u||p,...y,...b,...j,...R}),[c._id,c._type,u,p,y,b,j,R]);return lodashEs.isNull(f)||g.includes(c._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(f,{...k,children:l})})},PartialBlocksRenderer=({partialBlockId:a})=>{const{getPartailBlocks:l}=usePartailBlocksStore(),c=React.useMemo(()=>l(a),[l,a]),d=React.useMemo(()=>splitAtom(jotai.atom(c)),[c]);return lodashEs.isEmpty(c)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:d,blocks:c})},BlocksRenderer=({blocks:a,parent:l=null,splitAtoms:c=void 0})=>{const d=useGetBlockAtom(c),u=React.useMemo(()=>lodashEs.filter(a,m=>lodashEs.has(m,"_id")&&(lodashEs.isEmpty(l)?!m._parent:m._parent===l)),[a,l]),p=React.useCallback(m=>lodashEs.filter(a,h=>h._parent===m._id).length>0,[a]);return lodashEs.map(u,m=>{const h=d(m._id);return h?jsxRuntime.jsx(BlockRenderer,{blockAtom:h,children:m._type==="GlobalBlock"||m._type==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:lodashEs.get(m,"partialBlockId",lodashEs.get(m,"globalBlock",""))})}):p(m)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:c,blocks:a,parent:m._id}):null},m._id):null})},PageBlocksRenderer=()=>{const[a]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:a})},StaticBlocksRenderer=()=>{const[a]=useBlocksStore(),l=lodashEs.isEmpty(a)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:l})},useCanvasScale=a=>{const[l]=useCanvasDisplayWidth(),[,c]=useCanvasZoom(),d=useBuilderProp("htmlDir","ltr"),[u,p]=React.useState({}),m=React.useCallback(()=>{const{width:h,height:g}=a;if(h<l){const x=parseFloat((h/l).toFixed(2).toString());let f={};const y=g*x,b=h*x;g&&(f={height:100+(g-y)/y*100+"%",width:100+(h-b)/b*100+"%"}),p({position:"relative",top:0,transform:`scale(${x})`,transformOrigin:d==="rtl"?"top right":"top left",...f,maxWidth:"none"}),c(x*100)}else p({}),c(100)},[l,a,d,c]);return React.useEffect(()=>{m()},[l,a,c,m]),u},getElementByStyleId=(a,l)=>a.querySelector(`[data-style-id="${l}"]`),StaticCanvas=()=>{const[a]=jotai.useAtom(networkModeAtom),[l]=useCanvasDisplayWidth(),[,c]=useSelectedBlockIds(),d=useSelectedBlock(),[,u]=useHighlightBlockId(),p=React.useRef(null),m=React.useRef(null),[h,g]=React.useState({width:0,height:0}),x=useCanvasScale(h),[f,y]=React.useState([]),[,b]=React.useState([]),[,j]=jotai.useAtom(canvasIframeAtom),[R,k]=useSelectedStylingBlocks(),v=useBuilderProp("loading",!1),S=useBuilderProp("htmlDir","ltr"),C=_=>{g(A=>({...A,width:_}))};React.useEffect(()=>{if(!m.current)return;const{clientWidth:_,clientHeight:A}=m.current;g({width:_,height:A})},[m,l]);const I=(_,A=0)=>{const{top:B}=_.getBoundingClientRect();return B+A>=0&&B-A<=window.innerHeight};React.useEffect(()=>{var _,A;if(d&&d.type!=="Multiple"&&p.current){const B=getElementByDataBlockId(p.current.contentDocument,d._id);B&&(I(B)||(A=(_=p.current)==null?void 0:_.contentWindow)==null||A.scrollTo({top:B.offsetTop,behavior:"smooth"}),y([B]))}},[d]),React.useEffect(()=>{if(!lodashEs.isEmpty(R)&&p.current){const _=getElementByStyleId(p.current.contentDocument,lodashEs.first(R).id);b(_?[_]:[null])}else b([null])},[R]);const T=React.useMemo(()=>{let _=IframeInitialContent;return _=_.replace("__HTML_DIR__",S),a==="offline"&&(_=_.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),_},[a,S]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:C,onResize:C,children:jsxRuntime.jsx("div",{onClick:()=>{c([]),k([])},onMouseLeave:()=>setTimeout(()=>u(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:m,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>j(p.current),ref:p,id:"canvas-iframe",style:{...x,...lodashEs.isEmpty(x)?{width:`${l}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:T,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:d,selectedBlockElement:lodashEs.first(f)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[v?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),ICON_CLASS="h-3 w-3 stroke-[2]",TypeIcon=a=>{const l=runtime.useRegisteredChaiBlocks(),c=lodashEs.get(l,[a==null?void 0:a.type,"icon"]);return c?React.createElement(c,{className:ICON_CLASS}):jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:ICON_CLASS})},Breadcrumb=()=>{const a=useSelectedBlockHierarchy(),[,l]=useSelectedBlockIds(),{highlightBlock:c}=useBlockHighlight();return jsxRuntime.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{onClick:()=>l([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(a).map((d,u)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(tooltip.Button,{onMouseEnter:()=>{c(d==null?void 0:d._id)},onClick:()=>l([d==null?void 0:d._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:d==null?void 0:d._type}),d._name||d._type]}),u!==a.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},u))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-BG4oToVY.cjs"))),CanvasArea=()=>{const[a]=useCodeEditor(),l=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsx(StaticCanvas,{})})}),a?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"widget"}},registerBlockSettingField=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"field"}},registerBlockSettingTemplate=(a,l)=>{RJSF_EXTENSIONS[a]={id:a,component:l,type:"template"}},useBlockSettingComponents=a=>Object.values(RJSF_EXTENSIONS).filter(l=>l.type===a).reduce((l,c)=>(l[c.id]=c.component,l),{}),removeSizeAttributes=a=>{try{return a.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return a}},IconPickerField=({value:a,onChange:l,id:c})=>{const{t:d}=reactI18next.useTranslation(),[u,p]=React.useState(a||"");React.useEffect(()=>{p(a||"")},[a]);const m=h=>{p(h);const g=removeSizeAttributes(h);l(g)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:u?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:u}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:c,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:u,onChange:h=>m(h.target.value),placeholder:d("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:d("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:a,onSelect:l,mode:c="image"})=>{const[d,u]=React.useState(""),[p,m]=React.useState(!1),[h,g]=React.useState(!1),[x,f]=React.useState(null),y=async j=>{if(!j.trim()){g(!1),f("Please enter a URL");return}try{m(!0),f(null);const R=await fetch(j,{method:"HEAD"});if(!R.ok){g(!1),f("Invalid asset URL");return}const k=R.headers.get("content-type")||"";c==="image"&&k.startsWith("image/")||c==="video"&&k.startsWith("video/")||c==="audio"&&k.startsWith("audio/")?(g(!0),f(null)):(g(!1),f(`URL does not point to a valid ${c} file`))}catch{g(!1),f("Error validating URL")}finally{m(!1)}},{t:b}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:b(`${c.charAt(0).toUpperCase()+c.slice(1)} Manager`)}),x&&jsxRuntime.jsxs(tooltip.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(tooltip.AlertDescription,{children:x})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(tooltip.Input,{placeholder:b(`Enter ${c} URL`),value:d,onChange:j=>u(j.target.value),onBlur:()=>y(d)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(tooltip.Button,{variant:"outline",onClick:a,children:b("Cancel")}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>l([d]),disabled:!h||p,children:b("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=a=>{MEDIA_MANAGER.component=a},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({children:a,onSelect:l,mode:c="image"})=>{const[d,u]=React.useState(!1),p=useMediaManagerComponent(),m=(...h)=>{l.call(void 0,...h),u(!1)};return jsxRuntime.jsxs(tooltip.Dialog,{open:d,onOpenChange:h=>u(h),children:[jsxRuntime.jsx(tooltip.DialogTrigger,{asChild:!0,children:a}),jsxRuntime.jsx(tooltip.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:p?jsxRuntime.jsx(p,{close:()=>u(!1),onSelect:m,mode:c}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:a,onChange:l,id:c,onBlur:d})=>{const{t:u}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[a?jsxRuntime.jsx("img",{src:a,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsx(MediaManagerModal,{onSelect:p=>l(lodashEs.first(p)),mode:"image",children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:l,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:a||!lodashEs.isEmpty(a)?u("Replace image"):u("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsx("input",{id:c,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:u("Enter image URL"),value:a,onBlur:({target:{value:p}})=>d(c,p),onChange:p=>l(p.target.value)})]})]})};function NestedPathSelector({data:a,onSelect:l,dataType:c="value"}){const[d,u]=React__namespace.useState(!1),[p,m]=React__namespace.useState([]),[h,g]=React__namespace.useState(a);React.useEffect(()=>{d||m([]),g(a)},[d,a]);const x=j=>Array.isArray(j)?"array":typeof j=="object"&&j!==null?"object":"value",f=React__namespace.useCallback(j=>{const R=k=>c==="value"?k==="value"||k==="object":c==="array"?k==="array":k===c;j.type==="object"?(m(k=>[...k,j.key]),g(j.value)):R(j.type)&&(l([...p,j.key].join(".")),u(!1))},[p,l,c]),y=React__namespace.useCallback(()=>{if(p.length>0){const j=p.slice(0,-1);m(j),g(j.reduce((R,k)=>R[k],a))}},[p,a]),b=React__namespace.useMemo(()=>Object.entries(h).map(([j,R])=>({key:j,value:R,type:x(R)})).filter(j=>c==="value"?j.type==="value"||j.type==="object":c==="array"?j.type==="array"||j.type==="object":c==="object"?j.type==="object":!0),[h,c]);return jsxRuntime.jsxs(tooltip.Popover,{open:d,onOpenChange:u,children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"outline",className:"h-5 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":d,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3"})})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(tooltip.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(tooltip.Command,{className:"fields-command",children:[jsxRuntime.jsx(tooltip.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(tooltip.CommandList,{children:[jsxRuntime.jsx(tooltip.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(tooltip.CommandGroup,{children:[p.length>0&&jsxRuntime.jsxs(tooltip.CommandItem,{onSelect:y,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),b.map(j=>jsxRuntime.jsxs(tooltip.CommandItem,{value:j.key,disabled:!1,onSelect:()=>f(j),className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:j.key}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[c==="object"&&j.type==="object"&&jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:R=>{R.stopPropagation(),l([...p,j.key].join(".")),u(!1)},children:"Select"}),(j.type==="object"||j.type==="array")&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},j.key))]})]})]})})]})}function cn(...a){return tailwindMerge.twMerge(clsx.clsx(a))}const MenuBar=({editor:a,onExpand:l})=>{if(!a)return null;const c=()=>{const u=window.prompt("URL");u&&a.chain().focus().extendMarkRange("link").setLink({href:u}).run()},d=()=>{a.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:c,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":a.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:d,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!a.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:l,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:a,onClose:l,id:c,value:d,onChange:u,onBlur:p})=>{const m=React.useRef(null),h=React.useRef(d||""),g=usePageExternalData();React.useEffect(()=>{if(a){const y=document.createElement("style");return y.id="rte-modal-styles",y.innerHTML=`
|
|
61
61
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
62
62
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
63
63
|
[data-radix-popper-content-wrapper] {
|
|
64
64
|
z-index: 9999 !important;
|
|
65
65
|
}
|
|
66
|
-
`,document.head.appendChild(y),()=>{const b=document.getElementById("rte-modal-styles");b&&b.remove()}}},[a]);const x=react.useEditor({extensions:[StarterKit,Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),TextAlign.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Underline],content:d||"",onUpdate:({editor:y})=>{const b=y.getHTML();u(b)},onBlur:({editor:y})=>{const b=y.getHTML();p(c,b)},editorProps:{attributes:{class:"prose prose-sm focus:outline-none min-h-[300px] p-2 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"}}});React.useEffect(()=>{a&&x&&(h.current!==d&&(h.current=d||"",x.commands.setContent(d||"")),setTimeout(()=>{x.commands.focus()},100))},[a,x]),React.useEffect(()=>{m.current&&x&&(m.current.__chaiRTE=x)},[x,a]);const f=y=>{if(!x)return;const b=`{{${y}}}`;x.commands.focus();const{from:j,to:R}=x.state.selection;if(j!==R)x.chain().deleteSelection().insertContent(b).run();else{const{state:v}=x,S=v.selection.from,C=v.doc.textBetween(Math.max(0,S-1),S),I=v.doc.textBetween(S,Math.min(S+1,v.doc.content.size));let w="";S>0&&C!==" "&&!/[.,!?;:]/.test(C)&&(w=" ");let T="";I&&I!==" "&&!/[.,!?;:]/.test(I)&&(T=" "),x.chain().insertContent(w+b+T).run()}};return jsxRuntime.jsx(tooltip.Dialog,{open:a,onOpenChange:y=>!y&&l(),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[jsxRuntime.jsx(tooltip.DialogHeader,{children:jsxRuntime.jsxs(tooltip.DialogTitle,{className:"flex items-center justify-between pr-8",children:[jsxRuntime.jsx("span",{children:"Rich Text Editor"}),g&&Object.keys(g).length>0&&jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),jsxRuntime.jsx("div",{className:"rte-path-selector",children:jsxRuntime.jsx(NestedPathSelector,{data:g,onSelect:f})})]})]})}),jsxRuntime.jsxs("div",{id:`chai-rte-modal-${c}`,ref:m,className:"rounded-md border border-input",children:[jsxRuntime.jsx(MenuBar,{editor:x}),jsxRuntime.jsx(react.EditorContent,{editor:x,id:`modal-${c}`,className:"p-2"})]}),jsxRuntime.jsx("div",{className:"mt-4 flex justify-end",children:jsxRuntime.jsx(tooltip.Button,{onClick:l,children:"Done"})})]})})},RichTextEditorField=({id:a,placeholder:l,value:c,onChange:d,onBlur:u})=>{const p=React.useRef(null),[m,h]=React.useState(!1),[g,x]=React.useState(""),f=react.useEditor({extensions:[StarterKit,Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),TextAlign.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Underline],content:c||"",onUpdate:({editor:j})=>{const R=j.getHTML();d(R),m||x(R)},onBlur:({editor:j})=>{const R=j.getHTML();u(a,R)},editorProps:{attributes:{class:"prose prose-sm focus:outline-none min-h-[100px] p-1 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"}}});React.useEffect(()=>{p.current.__chaiRTE=f},[f]),React.useEffect(()=>{x(c||"")},[c]);const y=j=>{d(j)},b=()=>{h(!1),f&&f.commands.setContent(g)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsxs("div",{id:`chai-rte-${a}`,ref:p,className:"mt-1 rounded-md border border-input",children:[jsxRuntime.jsx(MenuBar,{editor:f,onExpand:()=>h(!0)}),jsxRuntime.jsx(react.EditorContent,{editor:f,id:a,placeholder:l})]})}),m&&jsxRuntime.jsx(RTEModal,{isOpen:m,onClose:b,id:a,value:g,onChange:y,onBlur:u})]})},PageTypeField=({href:a,pageTypes:l,onChange:c})=>{var D;const{t:d}=reactI18next.useTranslation(),u=useBuilderProp("searchPageTypeItems",(_,E)=>[]),[p,m]=React.useState(!1),[h,g]=React.useState(!1),[x,f]=React.useState("page"),[y,b]=React.useState(""),[j,R]=React.useState([]),[k,v]=React.useState(-1),S=React.useRef(null),C=(D=l==null?void 0:l.find(_=>_.key===x))==null?void 0:D.name;React.useEffect(()=>{if(b(""),R([]),v(-1),g(!1),!a||p||!lodashEs.startsWith(a,"pageType:"))return;const _=lodashEs.split(a,":"),E=lodashEs.get(_,1,"page")||"page";f(E),(async()=>{const N=await u(E,[lodashEs.get(_,2,"page")]);N&&Array.isArray(N)&&b(lodashEs.get(N,[0,"name"],""))})()},[a]);const I=web.useDebouncedCallback(async _=>{if(lodashEs.isEmpty(_))R([]);else{const E=await u(x,_);R(E)}m(!1),v(-1)},[x],300),w=_=>{const E=["pageType",x,_.id];E[1]&&(c(E.join(":")),b(_.name),g(!1),R([]),v(-1))},T=_=>{switch(_.key){case"ArrowDown":_.preventDefault(),v(E=>E<j.length-1?E+1:E);break;case"ArrowUp":_.preventDefault(),v(E=>E>0?E-1:E);break;case"Enter":if(_.preventDefault(),j.length===0)return;k>=0&&w(j[k]);break;case"Escape":_.preventDefault(),A();break}};React.useEffect(()=>{if(k>=0&&S.current){const _=S.current.children[k];_==null||_.scrollIntoView({block:"nearest"})}},[k]);const A=()=>{b(""),R([]),v(-1),g(!1),c("")},B=_=>{b(_),g(!lodashEs.isEmpty(_)),m(!0),I(_)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:x,onChange:_=>f(_.target.value),children:lodashEs.map(l,_=>jsxRuntime.jsx("option",{value:_.key,children:_.name},_.key))}),x&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:y,onChange:_=>B(_.target.value),onKeyDown:T,placeholder:d(`Search ${C??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:y&&jsxRuntime.jsx("button",{onClick:A,className:"text-gray-400 hover:text-gray-600",title:d("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(p||!lodashEs.isEmpty(j)||h&&lodashEs.isEmpty(j))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:p?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):h&&lodashEs.isEmpty(j)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[d("No results found for"),' "',y,'"']}):jsxRuntime.jsx("ul",{ref:S,children:lodashEs.map(j==null?void 0:j.slice(0,20),(_,E)=>jsxRuntime.jsxs("li",{onClick:()=>w(_),className:`cursor-pointer p-2 text-xs ${a!=null&&a.includes(_.id)?"bg-blue-200":E===k?"bg-gray-100":"hover:bg-gray-100"}`,children:[_.name," ",_.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",_.slug," )"]})]},_.id))})})]})},LinkField=({schema:a,formData:l,onChange:c})=>{const{t:d}=reactI18next.useTranslation(),{type:u="pageType",href:p="",target:m="self"}=l,h=useBuilderProp("pageTypes",[]),g=u==="pageType"&&lodashEs.isEmpty(h)?"url":u;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-xs font-medium",children:(a==null?void 0:a.title)??"Link"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:u,onChange:x=>c({...l,type:x.target.value}),children:lodashEs.map([...lodashEs.isEmpty(h)?[]:[{const:"pageType",title:d("Goto Page")}],{const:"url",title:d("Open URL")},{const:"email",title:d("Compose Email")},{const:"telephone",title:d("Call Phone")},{const:"scroll",title:d("Scroll to element")}],x=>jsxRuntime.jsx("option",{value:x.const,children:x.title},x.const))}),g==="pageType"&&!lodashEs.isEmpty(h)?jsxRuntime.jsx(PageTypeField,{href:p,pageTypes:h,onChange:x=>c({...l,href:x})}):jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:p,onChange:x=>c({...l,href:x.target.value}),placeholder:d(u==="url"?"Enter URL":u==="scroll"?"#ElementID":"Enter details")}),g==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:m==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>c({...l,target:m==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:d("Open in new tab")})]})]})]})},RowColField=()=>{const a=useSelectedBlock(),l=useWrapperBlock(),{addCoreBlock:c}=useAddBlock();if(!a&&!l)return null;const d=(a==null?void 0:a._type)==="Row"?a:l;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>c({type:"Column",styles:"#styles:,"},d==null?void 0:d._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})},SliderField=({formData:a,onChange:l})=>{const[c]=useBlocksStore(),d=useSelectedBlock(),u=useWrapperBlock(),{addCoreBlock:p}=useAddBlock(),[,m]=useSelectedBlockIds();if(!d&&!u)return null;const h=(d==null?void 0:d._type)==="Slider"?d:u,g=lodashEs.find(c,{_parent:h==null?void 0:h._id,_type:"Slides"});if(!g)return null;const x=lodashEs.filter(c,{_parent:g==null?void 0:g._id,_type:"Slide"}),f=(a==null?void 0:a.currentSlide)||lodashEs.get(x,"0._id");React.useEffect(()=>{(d==null?void 0:d._type)==="Slide"&&(a==null?void 0:a.currentSlide)!==(d==null?void 0:d._id)&&l({...a,currentSlide:d==null?void 0:d._id})},[d]),React.useEffect(()=>{x!=null&&x.length&&!lodashEs.find(x,{_id:a==null?void 0:a.currentSlide})&&l({...a,currentSlide:lodashEs.get(x,"0._id")})},[a,x]);const y=()=>{const R=lodashEs.findIndex(x,{_id:f});if(R>-1){const k=(R+1)%x.length,v=lodashEs.get(x,[k,"_id"]);if(!v)return;l({...a,currentSlide:v}),m([v])}},b=()=>{const R=lodashEs.findIndex(x,{_id:f});if(R>-1){const k=(R-1+x.length)%x.length,v=lodashEs.get(x,[k,"_id"]);if(!v)return;l({...a,currentSlide:v}),m([v])}},j=()=>{const R=p({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},g==null?void 0:g._id),k=R==null?void 0:R._id;k&&(l({...a,currentSlide:k}),m([k]))};return jsxRuntime.jsxs("div",{className:"space-y-1.5 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[jsxRuntime.jsx("button",{onClick:b,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-3 w-3 stroke-[3]"})}),jsxRuntime.jsx("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:f?jsxRuntime.jsxs("span",{className:"",children:[jsxRuntime.jsxs("b",{className:"text-[12px]",children:[" ",lodashEs.findIndex(x,{_id:f})+1]}),"/",x.length]}):"-"}),jsxRuntime.jsx("button",{onClick:y,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3 stroke-[3]"})}),jsxRuntime.jsxs("button",{onClick:j,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[jsxRuntime.jsx(lucideReact.PlusCircle,{className:"h-3 w-3 stroke-[2]"}),"Add Slide"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.showSlideButton),onChange:()=>l({...a,showSlideButton:!(a!=null&&a.showSlideButton)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Buttons"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.showSlideNavbar),onChange:()=>l({...a,showSlideNavbar:!(a!=null&&a.showSlideNavbar)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Navbar"})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.autoplay),onChange:()=>l({...a,autoplay:!(a!=null&&a.autoplay)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Autoplay slides"})]}),(a==null?void 0:a.autoplay)&&jsxRuntime.jsxs("div",{className:"pt-0.5 leading-tight",children:[jsxRuntime.jsxs("label",{htmlFor:"interval",className:"whitespace-nowrap text-[9px]",children:["Autoplay Interval ",jsxRuntime.jsx("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),jsxRuntime.jsx("input",{type:"number",id:"interval",name:"interval",placeholder:"0",value:a==null?void 0:a.autoplayInterval,className:"text-xs",pattern:"[0-9]*",onChange:R=>{let k=R.target.value;k.length&&(k=k.replace("-","")),l({...a,autoplayInterval:k})}})]})]})})]})},BindingWidget=()=>jsxRuntime.jsx("div",{className:"text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100",children:"Data binding is set for this field"}),CodeEditor=({id:a,placeholder:l})=>{const{t:c}=reactI18next.useTranslation(),[,d]=useCodeEditor(),u=useSelectedBlock();if(typeof window>"u")return null;const p=a.replace("root.",""),m=lodashEs.get(u,p,""),h=()=>{const g=u==null?void 0:u._id;d({blockId:g,blockProp:p,placeholder:l,initialCode:lodashEs.get(u,p,m)})};return jsxRuntime.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[jsxRuntime.jsx("button",{onClick:h,className:"w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",children:m.trim().length>0?m.substring(0,46):l||"Eg: <script>console.log('Hello, world!');<\/script>"}),jsxRuntime.jsx(tooltip.Button,{onClick:h,size:"sm",variant:"outline",className:"w-fit",children:c("Open code editor")})]})},JSONFormFieldTemplate=({id:a,classNames:l,label:c,children:d,errors:u,help:p,description:m,hidden:h,required:g,schema:x,formData:f,onChange:y})=>{const{selectedLang:b,fallbackLang:j,languages:R}=useLanguages(),k=lodashEs.isEmpty(R)?"":lodashEs.isEmpty(b)?j:b,v=lodashEs.get(LANGUAGES,k,k),S=usePageExternalData(),C=useSelectedBlock(),I=runtime.useRegisteredChaiBlocks(),w=lodashEs.get(I,[C==null?void 0:C._type,"i18nProps"],[])||[],[T,A]=React.useState(null),B=React.useCallback(E=>{const N=O=>/[.,!?;:]/.test(O),P=(O,Z,V)=>{let U="",$="";const F=Z>0?O[Z-1]:"",H=Z<O.length?O[Z]:"";return Z>0&&(F==="."||!N(F)&&F!==" ")&&(U=" "),Z<O.length&&!N(H)&&H!==" "&&($=" "),{text:U+V+$,prefixLength:U.length,suffixLength:$.length}},L=document.getElementById(a);if(!L)return;const M=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(M&&(M.querySelector(".ProseMirror")||M.__chaiRTE)){const O=M.__chaiRTE;if(O){const Z=`{{${E}}}`;O.commands.focus();const{from:V,to:U}=O.state.selection;if(V!==U)O.chain().deleteSelection().insertContent(Z).run();else{const{state:F}=O,H=F.selection.from,K=F.doc.textBetween(Math.max(0,H-1),H),G=F.doc.textBetween(H,Math.min(H+1,F.doc.content.size));let Y="";H>0&&K!==" "&&!N(K)&&(Y=" ");let q="";G&&G!==" "&&!N(G)&&(q=" "),O.chain().insertContent(Y+Z+q).run()}setTimeout(()=>y(O.getHTML(),{},a),100);return}}else{const O=L,Z=O.selectionStart||0,V=O.value||"",U=O.selectionEnd||Z;if(U>Z){const G=`{{${E}}}`,{text:Y}=P(V,Z,G),q=V.slice(0,Z)+Y+V.slice(U);y(q,{},a);return}const F=`{{${E}}}`,{text:H}=P(V,Z,F),K=V.slice(0,Z)+H+V.slice(Z);y(K,{},a)}},[a,y,f,C==null?void 0:C._id]);if(h)return null;if(x.type==="boolean")return jsxRuntime.jsx("div",{className:l,children:d});const _=w==null?void 0:w.includes(a.replace("root.",""));if(x.type==="array"){const E=T===a;return jsxRuntime.jsxs("div",{className:`${l} relative`,children:[x.title&&jsxRuntime.jsxs("label",{htmlFor:a,onClick:()=>A(E?null:a),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[E?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3"}),jsxRuntime.jsx(lucideReact.List,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{className:"leading-tight",children:c})," ",jsxRuntime.jsx(tooltip.Badge,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:jsxRuntime.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:f==null?void 0:f.length})})]}),(f==null?void 0:f.length)===0?jsxRuntime.jsx("div",{className:"h-0 overflow-hidden",children:d}):jsxRuntime.jsxs("div",{className:`${E?"pt-0.5":"h-0 overflow-hidden"}`,children:[m,d,u,p]})]})}return jsxRuntime.jsxs("div",{className:l,children:[x.title&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("label",{htmlFor:a,className:x.type==="object"?"pb-2":"",children:[c," ",_&&jsxRuntime.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",v]}),g&&x.type!=="object"?" *":null]}),x.type==="string"&&!x.enum&&!x.oneOf&&S&&jsxRuntime.jsx(NestedPathSelector,{data:S,onSelect:B,dataType:"value"})]}),m,d,u,p]})},CustomAddButton=a=>jsxRuntime.jsx("button",{...a,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-3 w-3"})," ",jsxRuntime.jsx("span",{children:"Add"})]})}),JSONForm=React.memo(({blockId:a,schema:l,uiSchema:c,formData:d,onChange:u})=>{const{selectedLang:p}=useLanguages(),m=useBlockSettingComponents("widget"),h=useBlockSettingComponents("field"),g=useBlockSettingComponents("template"),x=web.useThrottledCallback(async({formData:f},y)=>{u({formData:f},y)},[u,p],400);return jsxRuntime.jsx(RjForm,{widgets:{binding:BindingWidget,richtext:RichTextEditorField,icon:IconPickerField,image:ImagePickerField,code:CodeEditor,colCount:RowColField,...m},fields:{link:LinkField,slider:SliderField,...h},templates:{FieldTemplate:JSONFormFieldTemplate,ButtonTemplates:{AddButton:CustomAddButton},...g},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator,uiSchema:c,schema:l,formData:d,onChange:({formData:f},y)=>{if(!y||a!==(f==null?void 0:f._id))return;const b=lodashEs.take(y.split("."),2).join(".").replace("root.","");x({formData:f},b)}},p)}),GlobalBlockSettings=()=>{const a=useSelectedBlock(),{data:l,refetch:c,isLoading:d}=usePartialBlocksList(),u=useUpdateBlocksProps();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(a==null?void 0:a.globalBlock)||"",onChange:p=>{var m;u([a._id],{globalBlock:p.target.value,_name:`Global Block: ${lodashEs.startCase((m=lodashEs.get(l,p.target.value,""))==null?void 0:m.name)}`})},children:[jsxRuntime.jsx("option",{value:"",children:"Select a global block"}),Object.keys(l).map(p=>jsxRuntime.jsx("option",{value:p,children:l[p].name||p},p))]}),jsxRuntime.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsx("button",{onClick:c,className:"rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",children:d?"Loading...":"Refresh List"})})]})},formDataWithSelectedLang=(a,l,c)=>{const d=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(a),u=>{lodashEs.includes(lodashEs.get(c,"i18nProps",[]),u)&&!lodashEs.isEmpty(l)&&(d[u]=lodashEs.get(a,`${u}-${l}`))}),d};function BlockSettings(){const{selectedLang:a}=useLanguages(),l=useSelectedBlock(),c=useUpdateBlocksPropsRealtime(),d=useUpdateBlocksProps(),u=runtime.getRegisteredChaiBlock(l==null?void 0:l._type),p=formDataWithSelectedLang(l,a,u),[m,h]=React.useState(p),[g,x]=React.useState(!1),f=useWrapperBlock(),y=runtime.getRegisteredChaiBlock(f==null?void 0:f._type),b=formDataWithSelectedLang(f,a,y),j=({formData:T},A,B)=>{A&&(m==null?void 0:m._id)===l._id&&d([l._id],{[A]:lodashEs.get(T,A)},B)},R=React.useCallback(lodashEs.debounce(({formData:T},A,B)=>{j({formData:T},A,B),h(T)},1500),[l==null?void 0:l._id,a]),k=({formData:T},A)=>{A&&(c([l._id],{[A]:lodashEs.get(T,A)}),R({formData:T},A,{[A]:lodashEs.get(m,A)}))},v=({formData:T},A)=>{A&&(c([f._id],{[A]:lodashEs.get(T,A)}),R({formData:T},A,{[A]:lodashEs.get(m,A)}))};lodashEs.keys(lodashEs.get(p,"_bindings",{}));const{schema:S,uiSchema:C}=React.useMemo(()=>{const T=l==null?void 0:l._type;if(T)return runtime.getBlockFormSchemas(T)},[l]),{wrapperSchema:I,wrapperUiSchema:w}=React.useMemo(()=>{if(!f||!(f!=null&&f._type))return{wrapperSchema:{},wrapperUiSchema:{}};const T=f==null?void 0:f._type,{schema:A={},uiSchema:B={}}=runtime.getBlockFormSchemas(T);return{wrapperSchema:A,wrapperUiSchema:B}},[f]);return jsxRuntime.jsxs("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[!lodashEs.isEmpty(f)&&jsxRuntime.jsxs("div",{className:"mb-4 rounded border bg-zinc-100 px-1",children:[jsxRuntime.jsxs("div",{onClick:()=>x(T=>!T),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[g?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 stroke-[3] text-slate-400"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 stroke-[3] text-slate-400"}),lodashEs.startCase(f._type)," settings"," ",f._name&&jsxRuntime.jsxs("span",{className:"text-[11px] font-light text-slate-400",children:["(",f._name,")"]})]}),jsxRuntime.jsx("div",{className:g?"h-auto":"invisible h-0",children:jsxRuntime.jsx(JSONForm,{blockId:f==null?void 0:f._id,onChange:v,formData:b,schema:I,uiSchema:w})})]}),lodashEs.isEmpty(S)?null:jsxRuntime.jsx(JSONForm,{blockId:l==null?void 0:l._id,onChange:k,formData:p,schema:S,uiSchema:C}),(l==null?void 0:l._type)==="GlobalBlock"?jsxRuntime.jsx(GlobalBlockSettings,{}):null]})}const TabletIcon=({landscape:a=!1})=>jsxRuntime.jsx("svg",{className:a?"rotate-90":"",stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",height:"14px",width:"14px",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),WEB_BREAKPOINTS=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:jsxRuntime.jsx(reactIcons.MobileIcon,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:jsxRuntime.jsx(reactIcons.MobileIcon,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:jsxRuntime.jsx(TabletIcon,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:jsxRuntime.jsx(TabletIcon,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:jsxRuntime.jsx(reactIcons.LaptopIcon,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:jsxRuntime.jsx(reactIcons.DesktopIcon,{}),width:1920}],BreakpointCard=({canvas:a=!1,openDelay:l=400,tooltip:c=!0,title:d,content:u,currentBreakpoint:p,breakpoint:m,width:h,icon:g,onClick:x})=>{const{t:f}=reactI18next.useTranslation();return c?jsxRuntime.jsxs(tooltip.HoverCard,{openDelay:l,children:[jsxRuntime.jsx(tooltip.HoverCardTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{onClick:()=>x(h),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:m===p?"outline":"ghost",children:g})}),jsxRuntime.jsx(tooltip.HoverCardContent,{className:"w-fit max-w-52 border-border",children:jsxRuntime.jsx("div",{className:"flex justify-between space-x-4",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold",children:f(d)}),a&&jsxRuntime.jsx("p",{className:"text-xs",children:f(u)})]})})})]}):jsxRuntime.jsx(tooltip.Button,{onClick:()=>x(h),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:m===p?"outline":"ghost",children:g})},Breakpoints$1=({openDelay:a=400,canvas:l=!1,tooltip:c=!0})=>{const[d,,u]=useScreenSizeWidth(),[p,m]=useCanvasDisplayWidth(),[h,g]=useSelectedBreakpoints(),x=h,f=g,{t:y}=reactI18next.useTranslation(),b=useBuilderProp("breakpoints",WEB_BREAKPOINTS),j=v=>{x.includes(v)?x.length>2&&f(x.filter(S=>S!==v)):f(S=>[...S,v])},R=v=>{l||u(v),m(v)},k=Functions.getBreakpointValue(l?p:d).toLowerCase();return b.length<4?jsxRuntime.jsx("div",{className:"flex items-center rounded-md",children:lodashEs.map(b,v=>React.createElement(BreakpointCard,{canvas:l,...v,onClick:R,key:v.breakpoint,currentBreakpoint:k}))}):jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between rounded-md",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:lodashEs.map(b.filter(v=>lodashEs.includes(x,lodashEs.toUpper(v.breakpoint))),v=>React.createElement(BreakpointCard,{canvas:l,openDelay:a,tooltip:c,...v,onClick:R,key:v.breakpoint,currentBreakpoint:k}))}),jsxRuntime.jsxs(tooltip.DropdownMenu,{children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:jsxRuntime.jsx(reactIcons.DotsVerticalIcon,{className:"scale-90 transform"})})}),jsxRuntime.jsxs(tooltip.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[jsxRuntime.jsx(tooltip.DropdownMenuLabel,{children:y("Screen sizes")}),jsxRuntime.jsx(tooltip.DropdownMenuSeparator,{}),lodashEs.map(b,v=>jsxRuntime.jsx(tooltip.DropdownMenuCheckboxItem,{disabled:v.breakpoint==="xs",onCheckedChange:()=>j(lodashEs.toUpper(v.breakpoint)),checked:lodashEs.includes(x,lodashEs.toUpper(v.breakpoint)),children:y(v.title)},v.breakpoint))]})]})]})};function BreakpointSelector(){const[,a]=useScreenSizeWidth(),l=React.useMemo(()=>{const c=WEB_BREAKPOINTS.find(d=>d.breakpoint===a);return c==null?void 0:c.content},[a,WEB_BREAKPOINTS]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Screen: "}),jsxRuntime.jsx(Breakpoints$1,{openDelay:1e3,tooltip:!1})]}),jsxRuntime.jsx("div",{className:"mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1",children:jsxRuntime.jsx("p",{className:"flex flex-1 items-center space-x-2 text-[10px] text-foreground",children:jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[jsxRuntime.jsx("span",{className:"rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground",children:a==="xs"?"Base":a})," ",l]})})})]})}const SECONDS=10;function Countdown(){const[a,l]=React.useState(SECONDS),[c,d]=React.useState(!1);React.useEffect(()=>{if(c&&a>0){const g=setTimeout(()=>{l(a-.1)},100);return()=>clearTimeout(g)}else a<=0&&(d(!1),l(SECONDS))},[c,a]);const u=()=>{d(!0),l(SECONDS)};React.useEffect(()=>{a===SECONDS&&u()},[a]);const p=18,m=2*Math.PI*p,h=m*(1-(SECONDS-a)/SECONDS);return jsxRuntime.jsxs("div",{className:"relative h-4 w-4",children:[jsxRuntime.jsxs("svg",{className:"h-full w-full",viewBox:"0 0 40 40",children:[jsxRuntime.jsx("circle",{className:"text-gray-300",strokeWidth:"4",stroke:"currentColor",fill:"transparent",r:p,cx:"20",cy:"20"}),jsxRuntime.jsx("circle",{className:"text-blue-600",strokeWidth:"4",strokeDasharray:m,strokeDashoffset:h,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:p,cx:"20",cy:"20"})]}),jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold",children:" "})})]})}const AskAIStyles=({blockId:a})=>{const{t:l}=reactI18next.useTranslation(),{askAi:c,loading:d,error:u}=useAskAi(),[p,m]=React.useState(""),h=React.useRef(null),g=React.useRef(null),[x,f]=React.useState();React.useEffect(()=>{var b;(b=h.current)==null||b.focus()},[]);const y=b=>{const{usage:j}=b||{};!u&&j&&f(j),g.current=setTimeout(()=>f(void 0),1e4),u||m("")};return jsxRuntime.jsxs("div",{className:"",children:[jsxRuntime.jsx("h2",{className:"mb-1 text-sm font-semibold leading-none tracking-tight",children:l("Ask AI")}),jsxRuntime.jsx(tooltip.Textarea,{ref:h,value:p,onChange:b=>m(b.target.value),placeholder:l("Ask AI to edit styles"),className:"no-scrollbar my-2 w-full border border-border p-2 text-xs",rows:4,onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),g.current&&clearTimeout(g.current),f(void 0),c("styles",a,p,y))}}),jsxRuntime.jsxs("div",{className:"my-2 flex items-center gap-2",children:[d?null:jsxRuntime.jsx(tooltip.Button,{disabled:p.trim().length<5||d,onClick:()=>{g.current&&clearTimeout(g.current),f(void 0),c("styles",a,p,y)},variant:"default",className:"w-fit",size:"sm",children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),l("Generating... Please wait...")]}):l("Edit with AI")}),d?jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs(tooltip.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-4 w-4 animate-spin text-gray-500",size:16}),jsxRuntime.jsx("p",{className:"text-xs",children:l("Generating... Please wait...")})]}),jsxRuntime.jsx(tooltip.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:l("Stop")})]}):null]}),x?jsxRuntime.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxs("span",{children:[l("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsx(Countdown,{})]})}):null,jsxRuntime.jsx("div",{className:"max-w-full",children:u&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})})]})};function ManualClasses(){var P;const a=React.useRef(null),[l,c]=React.useState(""),[d,u]=React.useState(-1),p=useFuseSearch(),{t:m}=reactI18next.useTranslation(),[h]=useSelectedStylingBlocks(),g=useSelectedBlock(),x=useAddClassesToBlocks(),f=useRemoveClassesFromBlocks(),[y]=useSelectedBlockIds(),b=useBuilderProp("askAiCallBack",null),[j,R]=React.useState(""),k=(P=lodashEs.first(h))==null?void 0:P.prop,{classes:v}=getSplitClasses.getSplitChaiClasses(lodashEs.get(g,k,"")),S=v.split(" ").filter(L=>!lodashEs.isEmpty(L)),C=()=>{const L=j.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");x(y,L,!0),R("")},[I,w]=React.useState([]),T=({value:L})=>{const M=L.trim().toLowerCase(),O=M.match(/.+:/g);let Z=[];if(O&&O.length>0){const[V]=O,U=M.replace(V,"");Z=p.search(U).map(F=>({...F,item:{...F.item,name:V+F.item.name}}))}else Z=p.search(M);return w(lodashEs.map(Z,"item"))},A=()=>{w([])},B=L=>L.name,D=L=>jsxRuntime.jsx("div",{className:"rounded-md p-1",children:L.name}),_=React.useMemo(()=>({ref:a,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:m("Enter classes separated by space"),value:j,onKeyDown:L=>{L.key==="Enter"&&j.trim()!==""&&C()},onChange:(L,{newValue:M})=>R(M),className:"w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"}),[j,m,a]),E=L=>{debugger;const M=l.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");f(y,[L]),x(y,M,!0),c(""),u(-1)},N=()=>{if(navigator.clipboard===void 0){sonner.toast.error(m("Clipboard not supported"));return}navigator.clipboard.writeText(S.join(" ")),sonner.toast.success(m("Classes copied to clipboard"))};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-1.5 border-b border-border pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("span",{children:m("Classes")}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactIcons.CopyIcon,{onClick:N,className:"cursor-pointer"})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:m("Copy classes to clipboard")})})]})]}),b?jsxRuntime.jsxs(tooltip.Popover,{children:[jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(tooltip.Button,{variant:"default",className:"h-6 w-fit",size:"sm",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"ml-2",children:m("Ask AI")})]})}),jsxRuntime.jsx(tooltip.PopoverContent,{side:"left",className:"p-2",children:jsxRuntime.jsx(AskAIStyles,{blockId:g==null?void 0:g._id})})]}):null]}),jsxRuntime.jsxs("div",{className:"relative flex items-center gap-x-3",children:[jsxRuntime.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:jsxRuntime.jsx(Autosuggest,{suggestions:I,onSuggestionsFetchRequested:T,onSuggestionsClearRequested:A,getSuggestionValue:B,renderSuggestion:D,inputProps:_,containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border text-xs"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),jsxRuntime.jsx(tooltip.Button,{variant:"outline",className:"h-6 border-border",onClick:C,disabled:j.trim()==="",size:"sm",children:jsxRuntime.jsx(reactIcons.PlusIcon,{})})]}),jsxRuntime.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:S.map((L,M)=>d===M?jsxRuntime.jsx("input",{ref:a,value:l,onChange:O=>c(O.target.value),onBlur:()=>{E(L)},onKeyDown:O=>{O.key==="Enter"&&E(L)},className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"},L):jsxRuntime.jsxs("button",{className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[L,l!==L&&jsxRuntime.jsx(reactIcons.Cross2Icon,{onClick:()=>f(y,[L],!0),className:"invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"})]},L))})]})}const BASIC_UNITS=["px","%","em","rem","ch","vh","vw"],FLEX_CHILD_SECTION={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:BASIC_UNITS,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},GRID_CHILD_SECTION={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},SETTINGS_SECTIONS=[{heading:"Styles",items:[{component:ManualClasses},{component:BreakpointSelector},{type:"arbitrary",label:"layout.width",units:BASIC_UNITS.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:BASIC_UNITS.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...BASIC_UNITS,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"Typography",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:BASIC_UNITS},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:BASIC_UNITS.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"Background",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),[...BASIC_UNITS],BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("-");const BlockStylingProps=()=>{const a=useSelectedBlock(),[l,c]=useSelectedStylingBlocks(),{t:d}=reactI18next.useTranslation();if(!a)return null;const u=Object.keys(a).filter(m=>typeof a[m]=="string"&&a[m].startsWith("#styles:"));if(lodashEs.isEmpty(u)||u.length<=1)return null;const p=m=>lodashEs.find(l,h=>h.prop===m);return jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[jsxRuntime.jsxs("label",{htmlFor:"block-styling-props",className:"py-1 text-xs",children:[d("Style element"),":"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:lodashEs.map(u,m=>jsxRuntime.jsx(tooltip.Badge,{className:"cursor-pointer",onClick:()=>{c([{id:`${m}-${a._id}`,blockId:a._id,prop:m}])},variant:p(m)?"default":"secondary",children:lodashEs.startCase(m)},m))}),jsxRuntime.jsx("div",{className:"my-2 h-[1px] w-full bg-border"})]})},StyleContext=React.createContext({canReset:!1,canChange:!0}),BlockStyleProvider=({children:a,canReset:l=!1,canChange:c=!0})=>jsxRuntime.jsx(StyleContext.Provider,{value:{canReset:l,canChange:c},children:a}),DropDownChoices=({label:a,property:l,onChange:c})=>{const{getClasses:d}=useTailwindClassList(),u=d(l),p=useCurrentClassByProperty(l),m=React.useMemo(()=>lodashEs.get(p,"cls",""),[p]),{canChange:h}=React.useContext(StyleContext),g=/\[.*\]/g.test(m);return jsxRuntime.jsx("div",{className:a?"w-full rounded":"grow",children:g?jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(tooltip.Input,{className:"w-[70%] rounded py-1",readOnly:!0,value:m}),jsxRuntime.jsxs(tooltip.Tooltip,{delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Current value is using a Tailwind arbitrary value."})]})]}):jsxRuntime.jsx(DropDown,{rounded:a,onChange:x=>c(x,l),selected:m,options:u,disabled:!h})})};function DropDown({selected:a,onChange:l,rounded:c=!1,options:d,disabled:u=!1}){const p=a.replace(/.*:/g,"").trim(),{undo:m,redo:h}=useUndoManager();return jsxRuntime.jsxs("select",{disabled:!d.length||u,className:`${c?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:g=>l(g.target.value),onKeyDown:g=>{g.ctrlKey&&(g.key==="z"&&m(),g.key==="y"&&h())},value:p,children:[jsxRuntime.jsx("option",{className:"bg-transparent",value:""}),d.map((g,x)=>jsxRuntime.jsx("option",{className:"bg-transparent",value:g,children:g},`option-${x}`))]})}const COLOR_PROP={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},ColorChoice=({property:a,onChange:l})=>{const c=useCurrentClassByProperty(a),d=React.useMemo(()=>lodashEs.get(c,"cls",""),[c]),{canChange:u}=React.useContext(StyleContext),[p,m]=React.useState([]),[h,g]=React.useState({color:"",shade:""}),x=d.split("-"),f=lodashEs.get(x,"1",""),y=lodashEs.get(x,"2",""),b=React.useCallback(k=>{["current","inherit","transparent","black","white"].includes(k)?(m([]),g({color:k})):(m(["50","100","200","300","400","500","600","700","800","900"]),g(v=>({...v,color:k,shade:v.shade?v.shade:"500"})))},[m,g]);React.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(f))return m([]);m(["50","100","200","300","400","500","600","700","800","900"])},[f]);const j=React.useCallback(k=>{g({color:f,shade:k})},[f]);React.useEffect(()=>{g({color:"",shade:""})},[c]);const{match:R}=useTailwindClassList();return React.useEffect(()=>{const v=`${lodashEs.get(COLOR_PROP,a,"")}-${h.color}${h.shade?`-${h.shade}`:""}`;R(a,v)&&l(v,a)},[R,h,l,a]),jsxRuntime.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[jsxRuntime.jsx("div",{className:"grow text-center",children:jsxRuntime.jsx(DropDown,{disabled:!u,rounded:!0,selected:f,onChange:b,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),jsxRuntime.jsx("button",{type:"button",className:"grow text-center",children:jsxRuntime.jsx(DropDown,{rounded:!0,selected:y,disabled:!f||!u,onChange:j,options:p})})]})},EDITOR_ICONS={"not-italic":()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:reactIcons.EyeOpenIcon,invisible:reactIcons.EyeClosedIcon,hidden:reactIcons.EyeClosedIcon,gap:reactIcons.BorderAllIcon,gapX:reactIcons.WidthIcon,gapY:reactIcons.HeightIcon,spaceX:reactIcons.WidthIcon,spaceY:reactIcons.HeightIcon,overscroll:reactIcons.BorderAllIcon,overscrollX:reactIcons.WidthIcon,overscrollY:reactIcons.HeightIcon,overflow:reactIcons.BorderAllIcon,overflowX:reactIcons.WidthIcon,overflowY:reactIcons.HeightIcon,top:reactIcons.ArrowUpIcon,right:reactIcons.ArrowRightIcon,bottom:reactIcons.ArrowDownIcon,left:reactIcons.ArrowLeftIcon,inset:reactIcons.BorderAllIcon,insetX:reactIcons.WidthIcon,insetY:reactIcons.HeightIcon,border:reactIcons.BorderAllIcon,borderX:reactIcons.WidthIcon,borderY:reactIcons.HeightIcon,borderTop:reactIcons.ArrowUpIcon,borderRight:reactIcons.ArrowRightIcon,borderBottom:reactIcons.ArrowDownIcon,borderLeft:reactIcons.ArrowLeftIcon,borderRadius:reactIcons.BorderAllIcon,borderRadiusX:reactIcons.WidthIcon,borderRadiusY:reactIcons.HeightIcon,borderRadiusTop:reactIcons.ArrowUpIcon,borderRadiusRight:reactIcons.ArrowRightIcon,borderRadiusBottom:reactIcons.ArrowDownIcon,borderRadiusLeft:reactIcons.ArrowLeftIcon,borderRadiusTopLeft:reactIcons.ArrowTopLeftIcon,borderRadiusTopRight:reactIcons.ArrowTopRightIcon,borderRadiusBottomRight:reactIcons.ArrowBottomRightIcon,borderRadiusBottomLeft:reactIcons.ArrowBottomLeftIcon,divideXWidth:reactIcons.WidthIcon,divideYWidth:reactIcons.HeightIcon,scale:reactIcons.BorderAllIcon,scaleX:reactIcons.WidthIcon,scaleY:reactIcons.HeightIcon,skewX:reactIcons.WidthIcon,skewY:reactIcons.HeightIcon,translateX:reactIcons.WidthIcon,translateY:reactIcons.HeightIcon,padding:reactIcons.BorderAllIcon,paddingX:reactIcons.WidthIcon,paddingY:reactIcons.HeightIcon,paddingTop:reactIcons.ArrowUpIcon,paddingRight:reactIcons.ArrowRightIcon,paddingBottom:reactIcons.ArrowDownIcon,paddingLeft:reactIcons.ArrowLeftIcon,margin:reactIcons.BorderAllIcon,marginX:reactIcons.WidthIcon,marginY:reactIcons.HeightIcon,marginTop:reactIcons.ArrowUpIcon,marginRight:reactIcons.ArrowRightIcon,marginBottom:reactIcons.ArrowDownIcon,marginLeft:reactIcons.ArrowLeftIcon,textLeft:reactIcons.AlignLeftIcon,textCenter:reactIcons.AlignCenterHorizontallyIcon,textRight:reactIcons.AlignRightIcon,textJustify:reactIcons.StretchHorizontallyIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,overline:reactIcons.OverlineIcon,uppercase:reactIcons.LetterCaseUppercaseIcon,block:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":reactIcons.Cross2Icon,fixed:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:reactIcons.Cross1Icon},IconChoices=({property:a,onChange:l})=>{const{getClasses:c}=useTailwindClassList(),d=c(a),{canChange:u}=React.useContext(StyleContext),p=useCurrentClassByProperty(a),m=React.useMemo(()=>lodashEs.get(p,"cls",""),[p]);return jsxRuntime.jsx("div",{className:"flex grow flex-wrap gap-1",children:lodashEs.map(d,h=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",disabled:!u,onClick:()=>l(h,a),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${m===h?"bg-blue-500 text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:React.createElement(lodashEs.get(EDITOR_ICONS,h,reactIcons.BoxIcon))})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(h))})]}))})},RangeChoices=({property:a,onChange:l})=>{const{canReset:c,canChange:d}=React.useContext(StyleContext),u=useCurrentClassByProperty(a),p=React.useMemo(()=>lodashEs.get(u,"cls",""),[u]),{getClasses:m}=useTailwindClassList(),h=m(a,[""]),g=h.indexOf(p)>-1?h.indexOf(p):0,x=/\[.*\]/g.test(p);return jsxRuntime.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:x?jsxRuntime.jsx("div",{className:"px-2 py-[5px]",children:p}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!d&&(!c||g-1<0),onClick:()=>l(lodashEs.nth(h,g-1),a),children:jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsx(reactIcons.MinusIcon,{className:!d&&(!c||g-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),jsxRuntime.jsx("div",{className:"w-8/12 text-center",children:jsxRuntime.jsx(DropDownChoices,{label:!1,property:a,onChange:l})}),jsxRuntime.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!d&&(!c||g+1>=h.length),onClick:()=>l(lodashEs.nth(h,g+1),a),children:jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:!d&&(!c||g+1>=h.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})},getUserInputValues=(a,l)=>{a=a.toLowerCase();let c=a.trim().replace(/ |\+/g,"");if((c==="auto"||c==="none")&&l.includes(c))return{value:"",unit:c};const d=l.length?new RegExp(l.join("|"),"g"):/XXXXXX/g;c=c.replace(d,"");const u=a.match(d),p=u&&u.length>1,m=!lodashEs.isEmpty(c)&&Number.isNaN(Number(c));return p||m?{error:"Invalid value"}:u&&(u[0]==="auto"||u[0]==="none")?{value:u[0],unit:""}:{value:c,unit:u?u[0]:""}},getTwClassValue=a=>{const l=a.startsWith("-")?"-":"",c=a.split("-").pop();if(["auto","none"].includes(c))return{value:"",unit:c};if(c==="px")return{value:"1",unit:"px"};if(c==="screen")return{value:"100",unit:a.indexOf("w-")!==-1?"vw":"vh"};if(c==="full")return{value:"100",unit:"%"};if(lodashEs.includes(a,"skew-"))return{value:`${l}${c}`,unit:"deg"};if(lodashEs.includes(a,"rotate-"))return{value:`${l}${c}`,unit:"deg"};if(lodashEs.includes(a,"opacity-"))return{value:`${c/100}`,unit:"-"};if(lodashEs.includes(a,"duration-")||lodashEs.includes(a,"delay-"))return{value:`${c}`,unit:"ms"};if(lodashEs.includes(a,"translate-")&&!c.includes("/"))return{value:`${l}${`${c/4}`}`,unit:"rem"};if(lodashEs.includes(a,"scale-"))return{value:`${l}${`${c/100}`}`,unit:"-"};if(lodashEs.startsWith(a,"border")){const d=a.match(/border-?(x|y|t|r|b|l)?\d+/g);if(d)return{value:d[0].split("-").pop(),unit:"px"};if(a.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(lodashEs.startsWith(a,"max-w-")){if(a==="max-w-screen-sm")return{value:"640",unit:"px"};if(a==="max-w-screen-md")return{value:"768",unit:"px"};if(a==="max-w-screen-lg")return{value:"1024",unit:"px"};if(a==="max-w-screen-xl")return{value:"1280",unit:"px"};if(a==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(c==="xs")return{value:"320",unit:"px"};if(c==="sm")return{value:"384",unit:"px"};if(c==="md")return{value:"448",unit:"px"};if(c==="lg")return{value:"512",unit:"px"};if(c==="xl")return{value:"576",unit:"px"};if(c==="2xl")return{value:"672",unit:"px"};if(c==="3xl")return{value:"768",unit:"px"};if(c==="4xl")return{value:"896",unit:"px"};if(c==="5xl")return{value:"1024",unit:"px"};if(c==="6xl")return{value:"1152",unit:"px"};if(c==="7xl")return{value:"1280",unit:"px"};if(c==="prose")return{value:"65",unit:"ch"}}if(lodashEs.startsWith(a,"text-")){if(c==="xs")return{value:"12",unit:"px"};if(c==="sm")return{value:"14",unit:"px"};if(c==="base")return{value:"16",unit:"px"};if(c==="lg")return{value:"18",unit:"px"};if(c==="xl")return{value:"20",unit:"px"};if(c==="2xl")return{value:"24",unit:"px"};if(c==="3xl")return{value:"30",unit:"px"};if(c==="4xl")return{value:"36",unit:"px"};if(c==="5xl")return{value:"48",unit:"px"};if(c==="6xl")return{value:"60",unit:"px"};if(c==="7xl")return{value:"72",unit:"px"};if(c==="8xl")return{value:"96",unit:"px"};if(c==="9xl")return{value:"128",unit:"px"}}if(lodashEs.startsWith(a,"leading-")){if(c==="none")return{value:"1",unit:"-"};if(c==="tight")return{value:"1.25",unit:"-"};if(c==="snug")return{value:"1.375",unit:"-"};if(c==="normal")return{value:"1.5",unit:"-"};if(c==="relaxed")return{value:"1.625",unit:"-"};if(c==="loose")return{value:"2",unit:"-"}}if(lodashEs.startsWith(a,"tracking-")){if(c==="tighter")return{value:"-0.05",unit:"em"};if(c==="tight")return{value:"-0.025",unit:"em"};if(c==="normal")return{value:"0",unit:"em"};if(c==="wide")return{value:"0.025",unit:"em"};if(c==="wider")return{value:"0.05",unit:"em"};if(c==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(c))return{value:a,unit:"class"};if(c.includes("/")){const[d,u]=lodashEs.map(c.split("/"),p=>parseInt(p,10));return{value:l+(d/u*100).toFixed(2).replace(".00",""),unit:"%"}}return lodashEs.isNumber(parseFloat(c))?{value:`${l+parseFloat(c)*4}`,unit:"px"}:{value:c,unit:"class"}},getClassValueAndUnit=a=>{if(lodashEs.isEmpty(a))return{value:"",unit:""};const l=a.match(/\[.*\]/g);if(l===null)return getValueAndUnitForTWClass(a);const c=lodashEs.get(l,"0","").replace(/\[|\]/g,""),d=a.startsWith("-")?"-":"",u=lodashEs.first(c.match(/\d+.\d+|\d+/g));return{value:`${d}${u}`,unit:c.replace(u,"")}},getValueAndUnitForTWClass=a=>lodashEs.isEmpty(a)?{value:"",unit:""}:getTwClassValue(a),BlockSettingsContext=React.createContext({setDragData:()=>{}}),DragStyleButton=({unit:a,currentValue:l,onDrag:c,onDragEnd:d,onDragStart:u,negative:p,cssProperty:m})=>{const{setDragData:h}=React.useContext(BlockSettingsContext);return jsxRuntime.jsx("button",{type:"button",onMouseDown:g=>{const x={onDrag:c,onDragEnd:d,dragging:!0,dragStartY:g.pageY,dragStartValue:`${l}`,dragUnit:a,negative:p,cssProperty:m};u(x),h(x)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:jsxRuntime.jsx(reactIcons.RowSpacingIcon,{})})},UnitSelection=({onSelect:a,current:l,units:c})=>jsxRuntime.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:c.map(d=>jsxRuntime.jsx(tooltip.Button,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:l===d?"primary":void 0,size:"sm",onClick:u=>{u.stopPropagation(),a(d)},children:d},d))}),THROTTLE_TIME=50,AdvanceChoices=a=>{const[l,c]=React.useState(!1),[d,u]=React.useState(""),{currentClass:p,onChange:m,classPrefix:h,cssProperty:g,units:x,negative:f}=a,[y,b]=React.useState(g!=null&&g.toLowerCase().includes("width")?"%":x[0]),[j,R]=React.useState(!1),[k,v]=React.useState(""),[S,C]=React.useState(!1),[I,w]=React.useState(!1);React.useEffect(()=>{const{value:_,unit:E}=getClassValueAndUnit(p);if(E===""){u(_),b(g!=null&&g.toLowerCase().includes("width")?"%":lodashEs.first(x));return}b(E),u(E==="class"||lodashEs.isEmpty(_)?"":_)},[p,g,x]);const T=web.useThrottledCallback(_=>m(_),[m],THROTTLE_TIME),A=web.useThrottledCallback(_=>m(_,!1),[m],THROTTLE_TIME),B=React.useCallback((_=!1)=>{const E=getUserInputValues(`${d}`,x);if(lodashEs.get(E,"error",!1)){R(!0);return}const N=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):y;if(N==="auto"||N==="none"){T(`${h}${N}`);return}if(lodashEs.get(E,"value")==="")return;const L=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${h}[${lodashEs.get(E,"value","").replace("-","")}${N==="-"?"":N}]`;_?A(L):T(L)},[T,A,d,y,h,x]),D=React.useCallback(_=>{const E=getUserInputValues(`${d}`,x);if(lodashEs.get(E,"error",!1)){R(!0);return}if(_==="auto"||_==="none"){T(`${h}${_}`);return}if(lodashEs.get(E,"value")==="")return;const N=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):_,L=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${h}[${lodashEs.get(E,"value","").replace("-","")}${N==="-"?"":N}]`;T(L)},[T,d,h,x]);return jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx("div",{className:"flex items-center justify-start",children:y==="class"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{className:"h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:p}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Current value is using a Tailwind preset class."})]})]}):jsxRuntime.jsxs("div",{className:`group relative flex items-center ${S?"z-auto":""}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(y)!==-1?null:jsxRuntime.jsx("input",{readOnly:y==="class",onKeyPress:_=>{_.key==="Enter"&&B()},onKeyDown:_=>{if(_.keyCode!==38&&_.keyCode!==40)return;_.preventDefault(),w(!0);const E=lodashEs.parseInt(_.target.value);let N=lodashEs.isNaN(E)?0:E;_.keyCode===38&&(N+=1),_.keyCode===40&&(N-=1);const P=`${N}`,M=`${P.startsWith("-")?"-":""}${h}[${P.replace("-","")}${y==="-"?"":y}]`;A(M)},onKeyUp:_=>{I&&(_.preventDefault(),w(!1))},onBlur:()=>B(),onChange:_=>{R(!1),u(_.target.value)},onClick:_=>{var E;(E=_==null?void 0:_.target)==null||E.select(),c(!1)},value:S?k:d,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",j?"border-red-500 text-red-500":"border-foreground/20")}),jsxRuntime.jsxs(tooltip.Tooltip,{open:l,delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(!l),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[jsxRuntime.jsx("span",{className:`inline-block ${x.length===1?"px-2 font-semibold":""}`,children:y}),x.length>1?jsxRuntime.jsx(reactIcons.TriangleDownIcon,{}):null]})}),jsxRuntime.jsx(tooltip.TooltipPortal,{children:jsxRuntime.jsx(tooltip.TooltipContent,{className:"bg-background",children:jsxRuntime.jsx(UnitSelection,{units:x,current:y,onSelect:_=>{c(!1),b(_),D(_)}})})})]})]}),["none","auto"].indexOf(y)!==-1||S?null:jsxRuntime.jsx(DragStyleButton,{onDragStart:()=>C(!0),onDragEnd:_=>{if(v(()=>""),C(!1),lodashEs.isEmpty(_))return;const E=`${_}`,P=`${E.startsWith("-")?"-":""}${h}[${E.replace("-","")}${y==="-"?"":y}]`;T(P)},onDrag:_=>{if(lodashEs.isEmpty(_))return;v(_);const E=`${_}`,P=`${E.startsWith("-")?"-":""}${h}[${E.replace("-","")}${y==="-"?"":y}]`;A(P)},currentValue:d,unit:y,negative:f,cssProperty:g})]})})})},useCurrentClassByProperty=a=>{const l=useSelectedBlockCurrentClasses();return lodashEs.findLast(l,{property:a})},canChangeClass=(a,l)=>{const c={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return c[lodashEs.get(a,"mq","xs")]<=c[l]},CLASS_PREFIXES={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},BREAKPOINTS={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},getBreakpoint=a=>`${a.toUpperCase()} ${BREAKPOINTS[a]?`(${BREAKPOINTS[a]} & up)`:""}`,BlockStyle=a=>{const{t:l}=reactI18next.useTranslation(),{type:c="icons",label:d,property:u,onEmitChange:p=()=>{},units:m,negative:h=!1}=a,[g]=useDarkMode(),[x]=useStylingState(),[,f]=useScreenSizeWidth(),y=useCurrentClassByProperty(u),b=useAddClassesToBlocks(),j=useRemoveClassesFromBlocks(),[R]=useSelectedBlockIds(),k=React.useMemo(()=>lodashEs.get(y,"fullCls",""),[y]),v=React.useCallback((A,B=!0)=>{const D={dark:g,mq:f,mod:x,cls:A,property:u,fullCls:""};(g||x!=="")&&(D.mq="xs");const _=generateFullClsName(D);b(R,[_],B)},[R,g,f,x,u,b]),S=React.useCallback(()=>{j(R,[k],!0)},[R,k,j]),C=React.useMemo(()=>canChangeClass(y,f),[y,f]);React.useEffect(()=>{p(C,y)},[C,p,y]);const[,,I]=useScreenSizeWidth(),w=React.useCallback(A=>{I({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[A])},[I]),T=lodashEs.get(y,"dark",null)===g&&lodashEs.get(y,"mod",null)===x&&lodashEs.get(y,"mq",null)===f;return jsxRuntime.jsx(BlockStyleProvider,{canChange:C,canReset:y&&T,children:jsxRuntime.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[jsxRuntime.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:jsxRuntime.jsx("span",{className:`text-[11px] ${y&&!T?"text-foreground":""}`,children:l(d)})}),jsxRuntime.jsxs("div",{className:"flex flex-row items-center",children:[jsxRuntime.jsxs("div",{className:"w-[150px]",children:[c==="arbitrary"?jsxRuntime.jsx(AdvanceChoices,{currentClass:lodashEs.get(y,"cls",""),classPrefix:lodashEs.get(CLASS_PREFIXES,u,""),units:m||[],onChange:v,negative:h,cssProperty:u}):null,c==="icons"&&jsxRuntime.jsx(IconChoices,{property:u,onChange:v}),c==="range"&&jsxRuntime.jsx(RangeChoices,{property:u,onChange:v}),c==="color"&&jsxRuntime.jsx(ColorChoice,{property:u,onChange:v}),c==="dropdown"&&jsxRuntime.jsx(DropDownChoices,{label:d,property:u,onChange:v})]}),jsxRuntime.jsx("div",{className:`w-[30px] cursor-pointer ${k?"visible":"invisible"}`,children:T?jsxRuntime.jsx("button",{type:"button",onClick:()=>S(),title:"Reset",className:"flex px-1.5 text-xs",children:jsxRuntime.jsx(reactIcons.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):C&&y?jsxRuntime.jsxs(tooltip.Tooltip,{delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs("div",{children:["Current style is set at ",jsxRuntime.jsxs("span",{className:"font-bold",children:[getBreakpoint(lodashEs.get(y,"mq")),g&&!y.dark?"(Light mode)":""]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>w(lodashEs.get(y,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",lodashEs.get(y,"mq").toUpperCase()]})]})})})]}):null})]})]})})},basicUnits=["px","%","em","rem","ch","vh","vw"],MultipleChoices=({label:a,options:l,borderB:c=!1,borderT:d=!1,type:u="arbitrary",units:p=basicUnits,negative:m=!1})=>{const{t:h}=reactI18next.useTranslation(),[g,x]=React.useState(l[0].key),f=useSelectedBlockCurrentClasses(),y=React.useCallback(b=>lodashEs.map(f,"property").includes(b),[f]);return jsxRuntime.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${c?"border-b":""} ${d?"border-t":""}`,children:[jsxRuntime.jsxs("div",{className:"flex flex-row text-xs",children:[a&&jsxRuntime.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:h(a)}),jsxRuntime.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:l.map(({label:b,key:j},R)=>jsxRuntime.jsx("div",{className:"first:rounded-l last:rounded-r",children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(j),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${j===g?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[React.createElement("div",{className:y(j)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),React.createElement(lodashEs.get(EDITOR_ICONS,j,reactIcons.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(b))})]})},`option-${R}`))})]}),jsxRuntime.jsx("div",{className:"mt-0 flex items-center",children:jsxRuntime.jsx(BlockStyle,{type:u,units:[...p],label:"",property:g,negative:m})})]})},NestedOptions=({heading:a,items:l})=>{const{t:c}=reactI18next.useTranslation(),d=useSelectedBlockCurrentClasses(),u=React.useMemo(()=>{const p=g=>lodashEs.flatten(g.map(x=>x.styleType==="multiple"?lodashEs.map(x.options,"key"):x.property)),m=lodashEs.flatten(l.map(g=>g.styleType==="accordion"?p(g.items):g.styleType==="multiple"?lodashEs.map(g.options,"key"):g.property)),h=lodashEs.map(d,"property");return lodashEs.intersection(m,h).length>0},[d,l]);return jsxRuntime.jsxs("details",{children:[jsxRuntime.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:jsxRuntime.jsxs("div",{className:"inline",children:[lodashEs.startCase(c(a.toLowerCase())),u?jsxRuntime.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${u?"bg-blue-500":"bg-gray-300"}`}):null]})}),jsxRuntime.jsx("div",{className:"p-2",children:l.map(p=>p.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...p},p.label):jsxRuntime.jsx(BlockStyle,{...p},p.label))})]})},SectionContext=React.createContext({}),StylingGroup=({section:a,showAccordian:l})=>{const{t:c}=reactI18next.useTranslation(),d=useSelectedBlockCurrentClasses(),u=React.useCallback((m=[])=>{const h={};for(let x=0;x<d.length;x++)h[d[x].property]=d[x].cls;let g=!0;for(const x in m)if(!lodashEs.has(h,x)||h[x]!==m[x]){g=!1;break}return g},[d]),p=React.useMemo(()=>({}),[]);return jsxRuntime.jsx(SectionContext.Provider,{value:p,children:l?jsxRuntime.jsxs(tooltip.AccordionItem,{value:a.heading,className:"border-none",children:[jsxRuntime.jsx(tooltip.AccordionTrigger,{className:"border-slate-150 border-t py-2 text-xs",children:jsxRuntime.jsx("div",{className:"flex items-center py-2",children:jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:lodashEs.startCase(c(a.heading))})})}),jsxRuntime.jsx(tooltip.AccordionContent,{className:"py-2",children:a.items.map(m=>lodashEs.has(m,"component")?React.createElement(m.component,{key:m.label}):lodashEs.has(m,"styleType")?m.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...m},m.label):m.styleType==="accordion"&&u(m==null?void 0:m.conditions)?jsxRuntime.jsx(NestedOptions,{...m},m.label):null:jsxRuntime.jsx(BlockStyle,{...m},m.label))})]}):jsxRuntime.jsx("div",{className:"py-2",children:a.items.map(m=>lodashEs.has(m,"component")?React.createElement(m.component,{key:m.label}):lodashEs.has(m,"styleType")?m.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...m},m.label):m.styleType==="accordion"&&u(m==null?void 0:m.conditions)?jsxRuntime.jsx(NestedOptions,{...m},m.label):null:jsxRuntime.jsx(BlockStyle,{...m},m.label))})})},MAPPER={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function BlockStyling(){const{flexChild:a,gridChild:l}=useSelectedBlocksDisplayChild(),[c]=useSelectedStylingBlocks(),[d,u]=React.useState(""),[p,m]=React.useState({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),h=web.useThrottledCallback(x=>{const f=!lodashEs.get(p,"negative",!1),y=lodashEs.get(p,"cssProperty","");let b=parseFloat(p.dragStartValue);b=isNaN(b)?0:b;let j=MAPPER[p.dragUnit];(lodashEs.startsWith(y,"scale")||y==="opacity")&&(j=10);let k=(p.dragStartY-x.pageY)/j+b;f&&k<0&&(k=0),y==="opacity"&&k>1&&(k=1),p.onDrag(`${k}`),u(`${k}`)},[p],50),g=React.useCallback(()=>{setTimeout(()=>p.onDragEnd(`${d}`),100),m({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[p,d,m]);return lodashEs.isEmpty(c)?null:jsxRuntime.jsxs(BlockSettingsContext.Provider,{value:{setDragData:m},children:[p.dragging?jsxRuntime.jsx("div",{onMouseMove:h,onMouseUp:()=>g(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx(BlockStylingProps,{}),jsxRuntime.jsxs(tooltip.Accordion,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[a&&jsxRuntime.jsx(StylingGroup,{section:FLEX_CHILD_SECTION,showAccordian:a||l}),l&&jsxRuntime.jsx(StylingGroup,{section:GRID_CHILD_SECTION,showAccordian:a||l}),SETTINGS_SECTIONS.map(x=>jsxRuntime.jsx(StylingGroup,{section:x,showAccordian:a||l},x.heading))]})]})]})}const ADD_BLOCK_TABS={},registerChaiAddBlockTab=(a,l)=>{lodashEs.has(ADD_BLOCK_TABS,a)&&console.warn(`Add block tab with id ${a} already registered`),lodashEs.set(ADD_BLOCK_TABS,a,{id:a,...l})},useChaiAddBlockTabs=()=>React.useMemo(()=>lodashEs.values(ADD_BLOCK_TABS),[]),CoreBlock=({block:a,disabled:l,parentId:c,position:d})=>{const[,u]=jotai.useAtom(draggedBlockAtom),{type:p,icon:m,label:h}=a,{addCoreBlock:g,addPredefinedBlock:x}=useAddBlock(),[,f]=useSelectedBlockIds(),{clearHighlight:y}=useBlockHighlight(),b=()=>{if(console.log("addBlockToPage",a),lodashEs.has(a,"blocks")){const k=lodashEs.isFunction(a.blocks)?a.blocks():a.blocks;x(runtime.syncBlocksWithDefaults(k),c||null,d)}else g(a,c||null,d);pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},j=flagged.useFeature("dnd"),{t:R}=reactI18next.useTranslation();return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{disabled:l,onClick:b,type:"button",onDragStart:k=>{k.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.omit(a,["component","icon"]))),k.dataTransfer.setDragImage(new Image,0,0),u(lodashEs.omit(a,["component","icon"])),setTimeout(()=>{f([]),y()},200)},draggable:j?"true":"false",className:"cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",children:[React.createElement(m||reactIcons.BoxIcon,{className:"w-4 h-4 mx-auto"}),jsxRuntime.jsx("p",{className:"truncate text-xs",children:lodashEs.capitalize(R(h||p))})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:R(h||p)})})]})})},DefaultChaiBlocks=({parentId:a,position:l,gridCols:c="grid-cols-2"})=>{const d=runtime.useRegisteredChaiBlocks(),u=lodashEs.groupBy(d,"category"),p=lodashEs.uniq(lodashEs.map(u.core,"group"));return jsxRuntime.jsx(ChaiBuilderBlocks,{gridCols:c,parentId:a,position:l,groups:p,blocks:u.core})},hasVideoEmbed=a=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,c=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(a)||c.test(a)},getVideoURLFromHTML=a=>{if(lodashEs.isEmpty(a))return a;const l=/<video[^>]+src=['"]([^'">]+)['"]/,c=/<iframe[^>]+src=['"]([^'">]+)['"]/,d=a.match(l),u=a.match(c),p=d?d[1]:u?u[1]:null,m=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,h=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return p&&(m.test(p)||h.test(p))?p:a},NAME_ATTRIBUTES=["chai-name","data-chai-name"],ATTRIBUTE_MAP={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},shouldAddText=(a,l)=>a.children.length===1&&lodashEs.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),getTextContent=a=>a.map(l=>l.type==="text"?lodashEs.get(l,"content",""):lodashEs.isEmpty(l.children)?"":getTextContent(l.children)).join(""),getSanitizedValue=a=>a===null?"":a,getAttrs=a=>{if(a.tagName==="svg")return{};const l={},c=ATTRIBUTE_MAP[a.tagName]||{},d=a.attributes;return lodashEs.forEach(d,({key:u,value:p})=>{if(!lodashEs.includes(NAME_ATTRIBUTES,u))if(c[u]){if(a.tagName==="img"&&u==="src"&&!p.startsWith("http")){const m=lodashEs.find(a.attributes,{key:"width"}),h=lodashEs.find(a.attributes,{key:"height"});m&&h?p=`https://via.placeholder.com/${m==null?void 0:m.value}x${h==null?void 0:h.value}`:p="https://via.placeholder.com/150x150"}lodashEs.set(l,c[u],getSanitizedValue(p))}else lodashEs.includes(["style","class","srcset"],u)||(lodashEs.has(l,"styles_attrs")||(l.styles_attrs={}),lodashEs.startsWith(u,"@")&&(u=u.replace("@","x-on:")),l.styles_attrs[`${u}`]=getSanitizedValue(p))}),delete l.class,l},getStyles=(a,l="styles")=>{if(!a.attributes)return{[l]:`${getSplitClasses.STYLES_KEY},`};const c=lodashEs.find(a.attributes,{key:"class"});if(c){const d=c.value;return{[l]:`${getSplitClasses.STYLES_KEY},${d}`}}return{[l]:`${getSplitClasses.STYLES_KEY},`}},getBlockProps=a=>{const l=lodashEs.get(a,"attributes",[]),c=l.find(h=>h.key==="data-chai-richtext"||h.key==="chai-richtext"),d=l.find(h=>h.key==="data-chai-lightbox"||h.key==="chai-lightbox"),u=l.find(h=>h.key==="data-chai-dropdown"||h.key==="chai-dropdown"),p=l.find(h=>h.key==="data-chai-dropdown-button"||h.key==="chai-dropdown-button"),m=l.find(h=>h.key==="data-chai-dropdown-content"||h.key==="chai-dropdown-content");if(u)return{_type:"Dropdown"};if(p)return{_type:"DropdownButton"};if(m)return{_type:"DropdownContent"};if(c)return{_type:"RichText"};if(d)return{_type:"LightBoxLink"};switch(a.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:a.tagName,_listType:a.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:a.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:a.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:a.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:a.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const h=lodashEs.get(a,"children",[]).length>0?"Box":"EmptyBox";return{_type:h,tag:a.tagName,_name:h=="EmptyBox"||a.tagName==="div"?h:lodashEs.capitalize(a.tagName)}}}},traverseNodes=(a,l=null)=>lodashEs.flatMapDeep(a,c=>{var y,b,j,R,k,v,S,C;if(c.type==="comment")return[];console.log("node ===>",c);let d={_id:Functions.generateUUID()};if(l&&(d._parent=l.block._id),c.type==="text")return lodashEs.isEmpty(lodashEs.get(c,"content",""))?[]:l&&shouldAddText(l.node,l.block)?(lodashEs.set(l,"block.content",lodashEs.get(c,"content","")),[]):{...d,_type:"Text",content:lodashEs.get(c,"content","")};const u=lodashEs.get(c,"attributes",[]),p=u.find(I=>I.key==="data-chai-richtext"||I.key==="chai-richtext"),m=u.find(I=>I.key==="data-chai-lightbox"||I.key==="chai-lightbox"),h=u.find(I=>I.key==="data-chai-dropdown"||I.key==="chai-dropdown"),g=u.find(I=>I.key==="data-chai-dropdown-button"||I.key==="chai-dropdown-button"),x=u.find(I=>I.key==="data-chai-dropdown-content"||I.key==="chai-dropdown-content");if(d={...d,...getBlockProps(c),...getAttrs(c),...getStyles(c)},c.attributes){const I=c.attributes.find(w=>lodashEs.includes(NAME_ATTRIBUTES,w.key));I&&(d._name=I.value)}if(p)return d.content=himalaya.stringify(c.children),lodashEs.has(d,"styles_attrs.data-chai-richtext")&&delete d.styles_attrs["data-chai-richtext"],lodashEs.has(d,"styles_attrs.chai-richtext")&&delete d.styles_attrs["chai-richtext"],[d];if(m){const I=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];d={...d,href:((y=u.find(w=>w.key==="href"))==null?void 0:y.value)||"",hrefType:((b=u.find(w=>w.key==="data-vbtype"))==null?void 0:b.value)||"video",autoplay:((j=u.find(w=>w.key==="data-autoplay"))==null?void 0:j.value)==="true"?"true":"false",maxWidth:((k=(R=u.find(w=>w.key==="data-maxwidth"))==null?void 0:R.value)==null?void 0:k.replace("px",""))||"",backdropColor:((v=u.find(w=>w.key==="data-overlay"))==null?void 0:v.value)||"",galleryName:((S=u.find(w=>w.key==="data-gall"))==null?void 0:S.value)||""},lodashEs.forEach(I,w=>{lodashEs.has(d,`styles_attrs.${w}`)&&delete d.styles_attrs[w]})}if(h&&(delete d.styles_attrs,d.showDropdown=!1),x&&delete d.styles_attrs,g){delete d.styles_attrs;const I=lodashEs.filter(c.children||[],T=>(T==null?void 0:T.tagName)!=="span");d.content=getTextContent(I);const w=lodashEs.find(c.children||[],T=>(T==null?void 0:T.tagName)==="span"&&lodashEs.some(T.children||[],A=>(A==null?void 0:A.tagName)==="svg"));if(w){const T=lodashEs.find(w.children||[],A=>(A==null?void 0:A.tagName)==="svg");if(T){d.icon=himalaya.stringify([T]);const{height:A,width:B}=getSvgDimensions(T,"16px","16px");d.iconHeight=A,d.iconWidth=B}}return[d]}if(d._type==="Input"){const I=d.inputType||"text";I==="checkbox"?lodashEs.set(d,"_type","Checkbox"):I==="radio"&&lodashEs.set(d,"_type","Radio")}else if(c.tagName==="video"||c.tagName==="iframe"){const I=himalaya.stringify([c]);return hasVideoEmbed(I)&&(lodashEs.set(d,"_type","Video"),lodashEs.set(d,"url",getVideoURLFromHTML(I)),lodashEs.set(d,"styles",`${getSplitClasses.STYLES_KEY},`),lodashEs.set(d,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),d.content=I,[d]}else if(c.tagName==="svg"){const I=lodashEs.find(c.attributes,{key:"height"}),w=lodashEs.find(c.attributes,{key:"width"}),T=lodashEs.get(I,"value")?`[${lodashEs.get(I,"value")}px]`:"24px",A=lodashEs.get(w,"value")?`[${lodashEs.get(w,"value")}px]`:"24px",B=lodashEs.get(lodashEs.find(c.attributes,{key:"class"}),"value","w-full h-full");return d.styles=`${getSplitClasses.STYLES_KEY}, ${Functions.cn(`w-${A} h-${T}`,B)}`.trim(),c.attributes=lodashEs.filter(c.attributes,D=>!lodashEs.includes(["style","width","height","class"],D.key)),d.icon=himalaya.stringify([c]),[d]}else if(c.tagName=="option"&&l&&((C=l.block)==null?void 0:C._type)==="Select")return l.block.options.push({label:getTextContent(c.children),...getAttrs(c)}),[];const f=traverseNodes(c.children,{block:d,node:c});return[d,...f]}),getSvgDimensions=(a,l,c)=>{const d=lodashEs.get(a,"attributes",[]),u=lodashEs.find(d,{key:"height"}),p=lodashEs.find(d,{key:"width"});return{height:lodashEs.get(u,"value")?`[${lodashEs.get(u,"value")}px]`:c,width:lodashEs.get(p,"value")?`[${lodashEs.get(p,"value")}px]`:l}},getSanitizedHTML=a=>{a=a.replace(/(\w+)=\\?"(.*?)\\?"/g,(d,u,p)=>{let m=p.replace(/\\"/g,'"');return m=m.replace(/{([^}]+)}/g,h=>h.replace(/"/g,'\\"')),`${u}="${m.replace(/\\"/g,'"')}"`}),a=a.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),a=a.replace(/\$name="[^"]*"/g,"");const l=a.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):a).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},getBlocksFromHTML=a=>{const l=himalaya.parse(getSanitizedHTML(a));return lodashEs.isEmpty(a)?[]:lodashEs.flatten(traverseNodes(l))},ImportHTML=({parentId:a,position:l})=>{const{t:c}=reactI18next.useTranslation(),[d,u]=React.useState(""),{addPredefinedBlock:p}=useAddBlock(),m=()=>{const h=getBlocksFromHTML(d);p([...h],a,l),u(""),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)};return jsxRuntime.jsxs(tooltip.Card,{className:"border-border/0 p-0 shadow-none",children:[jsxRuntime.jsx(tooltip.CardHeader,{className:"p-3",children:jsxRuntime.jsx(tooltip.CardDescription,{children:c("Use HTML snippets from Tailwind CSS component libraries")})}),jsxRuntime.jsx(tooltip.CardContent,{className:"space-y-2 px-3 py-0",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"current",className:"text-sm",children:c("Tailwind HTML snippet")}),jsxRuntime.jsx(tooltip.Textarea,{autoFocus:!0,tabIndex:1,ref:h=>h&&h.focus(),onChange:h=>u(h.target.value),rows:12,value:d,placeholder:c("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),jsxRuntime.jsx(tooltip.CardFooter,{className:"flex flex-col justify-end p-3",children:jsxRuntime.jsx(tooltip.Button,{disabled:d.trim()==="",onClick:()=>m(),size:"sm",className:"w-fit",children:c("Import HTML")})})]})},partialBlocksDataAtom=jotai.atom({blocks:[],groups:[],isLoading:!0,error:null}),hasInitializedPartialBlocksAtom=jotai.atom(!1),formatReadableName=a=>{if(!a)return"";let l=a.replace(/[-_]/g," ");return l=l.replace(/([a-z])([A-Z])/g,"$1 $2"),l.split(" ").map(c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()).join(" ")},PartialBlocks=({parentId:a,position:l,gridCols:c="grid-cols-2"})=>{const{data:d,isLoading:u,refetch:p,error:m}=usePartialBlocksList(),[h,g]=jotai.useAtom(partialBlocksDataAtom),[x,f]=jotai.useAtom(hasInitializedPartialBlocksAtom);React.useEffect(()=>{if(!x||Object.keys(h.blocks).length===0)if(m)g({blocks:[],groups:[],isLoading:!1,error:m}),f(!0);else if(!u&&Object.keys(d||{}).length>0){const b=Object.entries(d).map(([R,k])=>{const v=k,S=v.type||"partial",C=formatReadableName(S);return{type:"PartialBlock",label:formatReadableName(v.name||R),description:v.description||"",icon:lucideReact.Globe,group:C,category:"partial",partialBlockId:R,_name:v.name}}),j=lodashEs.uniq(lodashEs.map(b,"group"));g({blocks:b,groups:j,isLoading:!1,error:null}),f(!0)}else u?g(b=>({...b,isLoading:!0,error:null})):!u&&Object.keys(d||{}).length===0&&(g({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),f(!0))},[u,d,x,f,g,h.blocks,m]);const y=()=>{g(b=>({...b,isLoading:!0,error:null})),f(!1),p()};return h.isLoading?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):h.error||h.blocks.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[jsxRuntime.jsx("p",{children:h.error||"No partial blocks available"}),jsxRuntime.jsx("button",{onClick:y,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):jsxRuntime.jsx(ChaiBuilderBlocks,{gridCols:c,parentId:a,position:l,groups:h.groups,blocks:h.blocks})},ChaiSelect=({defaultValue:a="",onValueChange:l,options:c,placeholder:d="Select",className:u="",height:p=""})=>{const[m,h]=React.useState(a),g=x=>{const f=x.target.value;h(f),l(f)};return jsxRuntime.jsx("div",{className:Functions.cn("relative inline-block w-full",u),children:jsxRuntime.jsxs("select",{className:Functions.cn("mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground 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",p),value:m,onChange:g,children:[jsxRuntime.jsx("option",{value:"",disabled:!0,children:d}),c.map(x=>jsxRuntime.jsx("option",{value:x.value,children:x.label},x.value))]})})};function UILibrariesSelect({uiLibraries:a,library:l,setLibrary:c}){const{t:d}=reactI18next.useTranslation();return l?jsxRuntime.jsxs("div",{className:"h-12",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold text-gray-500",children:d("Choose library")}),jsxRuntime.jsx(ChaiSelect,{className:"mt-1",options:a.map(u=>({value:u.id,label:u.name})),defaultValue:l,onValueChange:u=>c(u)})]}):null}const BlockCard=({block:a,library:l,parentId:c=void 0,position:d=-1})=>{const[u,p]=React.useState(!1),m=useBuilderProp("getUILibraryBlock",lodashEs.noop),{addCoreBlock:h,addPredefinedBlock:g}=useAddBlock(),[,x]=useSelectedBlockIds(),{clearHighlight:f}=useBlockHighlight(),y=lodashEs.get(a,"name",lodashEs.get(a,"label")),b=flagged.useFeature("dnd"),[,j]=jotai.useAtom(draggedBlockAtom),R=S=>{const C=lodashEs.has(S,"styles_attrs.data-page-section");return S._type==="Box"&&C},k=React.useCallback(async S=>{if(S.stopPropagation(),lodashEs.has(a,"component")){h(a,c,d),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);return}p(!0);const C=await m(l,a);lodashEs.isEmpty(C)||g(runtime.syncBlocksWithDefaults(C),c,d),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},[h,g,a,m,l,c,d]),v=async S=>{const C=await m(l,a);let I=c;if(R(lodashEs.first(C))&&(I=null),!lodashEs.isEmpty(C)){const w={blocks:C,uiLibrary:!0,parent:I};if(S.dataTransfer.setData("text/plain",JSON.stringify(w)),a.preview){const T=new Image;T.src=a.preview,T.onload=()=>{S.dataTransfer.setDragImage(T,0,0)}}else S.dataTransfer.setDragImage(new Image,0,0);j(w),setTimeout(()=>{x([]),f(),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},200)}};return jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{onClick:u?()=>{}:k,draggable:b?"true":"false",onDragStart:v,className:clsx("relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"),children:[u&&jsxRuntime.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"animate-spin",size:15,color:"white"}),jsxRuntime.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),a.preview?jsxRuntime.jsx("img",{src:a.preview,className:"min-h-[45px] w-full rounded-md",alt:y}):jsxRuntime.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border bg-gray-200",children:jsxRuntime.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:y})})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:y})})]})},UILibrarySection=({parentId:a,position:l})=>{const[c,d]=jotai.useAtom(selectedLibraryAtom),u=useBuilderProp("uiLibraries",[]),p=u.find(S=>S.id===c)||lodashEs.first(u),{data:m,isLoading:h}=useLibraryBlocks(p),g=lodashEs.groupBy([...m],"group"),[x,f]=React.useState(null);React.useEffect(()=>{x||f(lodashEs.first(lodashEs.keys(g)))},[g,x]);const y=lodashEs.get(g,x,[]),b=React.useRef(null),{t:j}=reactI18next.useTranslation(),R=S=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{b.current&&f(S)},300)};if(h)return jsxRuntime.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[jsxRuntime.jsx(tooltip.Skeleton,{className:"col-span-3 h-full"}),jsxRuntime.jsx(tooltip.Skeleton,{className:"col-span-9 h-full"})]});const k=lodashEs.filter(y,(S,C)=>C%2===0),v=lodashEs.filter(y,(S,C)=>C%2===1);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"relative mt-2 flex h-full max-h-full overflow-hidden bg-background",children:jsxRuntime.jsxs("div",{className:"flex h-full pt-2",children:[jsxRuntime.jsxs("div",{className:"flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2",children:[jsxRuntime.jsx(UILibrariesSelect,{library:p==null?void 0:p.id,setLibrary:d,uiLibraries:u}),jsxRuntime.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-gray-500",children:j("Groups")}),jsxRuntime.jsx("hr",{className:"mt-1 border-border"}),jsxRuntime.jsx("div",{className:"no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20",children:lodashEs.map(g,(S,C)=>jsxRuntime.jsxs("div",{onMouseEnter:()=>R(C),onMouseLeave:()=>clearTimeout(b.current),onClick:()=>f(C),className:Functions.cn("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",C===x?"bg-blue-500 text-white hover:bg-blue-600":""),children:[jsxRuntime.jsx("span",{children:lodashEs.capitalize(j(C.toLowerCase()))}),jsxRuntime.jsx(reactIcons.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},C))})]})]}),jsxRuntime.jsxs(tooltip.ScrollArea,{onMouseEnter:()=>b.current?clearTimeout(b.current):null,className:"z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:k.map((S,C)=>jsxRuntime.jsx(BlockCard,{parentId:a,position:l,block:S,library:p},`block-${C}`))}),jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:v.map((S,C)=>jsxRuntime.jsx(BlockCard,{parentId:a,position:l,block:S,library:p},`block-${C}`))})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})]})})})},UILibrariesPanel=({parentId:a,position:l})=>jsxRuntime.jsx(UILibrarySection,{parentId:a,position:l}),CORE_GROUPS=["basic","typography","media","layout","form","advanced","other"],ChaiBuilderBlocks=({groups:a,blocks:l,parentId:c,position:d,gridCols:u="grid-cols-4"})=>{var _;const{t:p}=reactI18next.useTranslation(),[m]=useBlocksStore(),[h,g]=React.useState(""),x=React.useRef(null),[f]=jotai.useAtom(addBlockTabAtom),y=(_=lodashEs.find(m,E=>E._id===c))==null?void 0:_._type,[b,j]=React.useState("all"),[R,k]=React.useState(null),v=React.useRef(null);React.useEffect(()=>{const E=setTimeout(()=>{var N;(N=x.current)==null||N.focus()},0);return()=>clearTimeout(E)},[f]),React.useEffect(()=>{h&&(j("all"),k(null))},[h]),React.useEffect(()=>(v.current=lodashEs.debounce(E=>{j(E)},500),()=>{v.current&&v.current.cancel()}),[]);const S=React.useCallback(E=>{k(E),v.current&&v.current(E)},[]),C=React.useCallback(()=>{k(null),v.current&&v.current.cancel()},[]),I=React.useCallback(E=>{v.current&&v.current.cancel(),j(E),k(null)},[]),w=React.useMemo(()=>h?lodashEs.values(l).filter(E=>{var N,P;return(((N=E.label)==null?void 0:N.toLowerCase())+" "+((P=E.type)==null?void 0:P.toLowerCase())).includes(h.toLowerCase())}):l,[l,h]),T=React.useMemo(()=>h?a.filter(E=>lodashEs.reject(lodashEs.filter(lodashEs.values(w),{group:E}),{hidden:!0}).length>0):a.filter(E=>lodashEs.reject(lodashEs.filter(lodashEs.values(l),{group:E}),{hidden:!0}).length>0),[l,w,a,h]),A=React.useMemo(()=>lodashEs.sortBy(T,E=>CORE_GROUPS.indexOf(E)===-1?99:CORE_GROUPS.indexOf(E)),[T]),B=React.useMemo(()=>b==="all"?w:lodashEs.filter(lodashEs.values(w),{group:b}),[w,b]),D=React.useMemo(()=>b==="all"?A:[b],[A,b]);return jsxRuntime.jsxs("div",{className:"mx-auto flex h-full w-full max-w-3xl flex-col",children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm",children:jsxRuntime.jsx(tooltip.Input,{ref:x,type:"search",placeholder:p("Search blocks..."),value:h,className:"-ml-2",onChange:E=>g(E.target.value)})}),jsxRuntime.jsxs("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden",children:[A.length>0&&jsxRuntime.jsx("div",{className:"w-1/4 min-w-[120px] border-r",children:jsxRuntime.jsx(tooltip.ScrollArea,{className:"h-full",children:jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("button",{onClick:()=>I("all"),onMouseEnter:()=>S("all"),onMouseLeave:C,className:`w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${b==="all"||R==="all"?"bg-accent text-accent-foreground":"hover:bg-accent/50 hover:text-accent-foreground"}`,children:p("All")},"sidebar-all"),A.map(E=>jsxRuntime.jsx("button",{onClick:()=>I(E),onMouseEnter:()=>S(E),onMouseLeave:C,className:`w-full rounded-md px-2 py-1.5 text-left text-sm ${b===E||R===E?"bg-accent text-accent-foreground":"hover:bg-accent/50 hover:text-accent-foreground"}`,children:lodashEs.capitalize(p(E.toLowerCase()))},`sidebar-${E}`))]})})}),jsxRuntime.jsx("div",{className:"h-full w-3/4 flex-1 overflow-hidden",children:jsxRuntime.jsx(tooltip.ScrollArea,{id:"add-blocks-scroll-area",className:"no-scrollbar mr-4 h-full",children:T.length===0&&h?jsxRuntime.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:jsxRuntime.jsxs("p",{children:[p("No blocks found matching"),' "',h,'"']})}):jsxRuntime.jsx("div",{className:"space-y-6 p-4",children:D.map(E=>jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h3",{className:"px-1 text-sm font-medium",children:lodashEs.capitalize(p(E.toLowerCase()))}),jsxRuntime.jsx("div",{className:"grid gap-2 "+u,children:lodashEs.reject(b==="all"?lodashEs.filter(lodashEs.values(B),{group:E}):lodashEs.values(B),{hidden:!0}).map(N=>jsxRuntime.jsx(CoreBlock,{parentId:c,position:d,block:N,disabled:!canAcceptChildBlock(y,N.type)||!canBeNestedInside(y,N.type)},N.type))})]},E))})})})]})]})},addBlockTabAtom=atomWithStorage("__add_block_tab","library"),AddBlocksPanel=({className:a,showHeading:l=!0,parentId:c=void 0,position:d=-1})=>{const{t:u}=reactI18next.useTranslation(),[p,m]=jotai.useAtom(addBlockTabAtom),[,h]=jotai.useAtom(showPredefinedBlockCategoryAtom),g=useBuilderProp("importHTMLSupport",!0),{data:x}=usePartialBlocksList(),f=Object.keys(x||{}).length>0,{hasPermission:y}=usePermissions();React.useEffect(()=>{p==="partials"&&!f&&m("library")},[p,f,m]);const b=React.useCallback(()=>{pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},[]),j=useChaiAddBlockTabs(),R=g&&y(PERMISSIONS.IMPORT_HTML),v=useBuilderProp("uiLibraries",[]).length>0;return React.useEffect(()=>{p==="library"&&!v&&m("core")},[p,v,m]),jsxRuntime.jsxs("div",{className:Functions.cn("flex h-full w-full flex-col overflow-hidden",a),children:[l?jsxRuntime.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[jsxRuntime.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:u("Add block")}),jsxRuntime.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:u(p==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,jsxRuntime.jsxs(tooltip.Tabs,{onValueChange:S=>{h(""),m(S)},value:p,className:"flex h-full max-h-full flex-col overflow-hidden",children:[jsxRuntime.jsxs(tooltip.TabsList,{className:"flex w-full items-center",children:[v&&jsxRuntime.jsx(tooltip.TabsTrigger,{value:"library",children:u("Library")}),jsxRuntime.jsx(tooltip.TabsTrigger,{value:"core",children:u("Blocks")}),f&&jsxRuntime.jsx(tooltip.TabsTrigger,{value:"partials",children:u("Partials")}),R?jsxRuntime.jsx(tooltip.TabsTrigger,{value:"html",children:u("Import")}):null,lodashEs.map(j,S=>jsxRuntime.jsx(tooltip.TabsTrigger,{value:S.id,children:React.createElement(S.tab)},`tab-add-block-${S.id}`))]}),jsxRuntime.jsx(tooltip.TabsContent,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx("div",{className:"-mx-1.5 h-full max-h-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"mt-2 h-full w-full",children:jsxRuntime.jsx(DefaultChaiBlocks,{gridCols:"grid-cols-4",parentId:c,position:d})})})}),v&&jsxRuntime.jsx(tooltip.TabsContent,{value:"library",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx(UILibrariesPanel,{parentId:c,position:d})}),f&&jsxRuntime.jsx(tooltip.TabsContent,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx("div",{className:"-mx-1.5 h-full max-h-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"mt-2 h-full w-full",children:jsxRuntime.jsx(PartialBlocks,{gridCols:"grid-cols-4",parentId:c,position:d})})})}),R?jsxRuntime.jsx(tooltip.TabsContent,{value:"html",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx(ImportHTML,{parentId:c,position:d})}):null,lodashEs.map(j,S=>jsxRuntime.jsx(tooltip.TabsContent,{value:S.id,children:React.createElement(S.tabContent,{close:b,parentId:c,position:d})},`panel-add-block-${S.id}`))]})]})},PERMISSIONS={ADD_BLOCK:"add_block",DELETE_BLOCK:"delete_block",EDIT_BLOCK:"edit_block",MOVE_BLOCK:"move_block",EDIT_THEME:"edit_theme",SAVE_PAGE:"save_page",EDIT_STYLES:"edit_styles",IMPORT_HTML:"import_html",CREATE_LIBRARY_BLOCK:"create_library_block",CREATE_LIBRARY_GROUP:"create_library_group",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_GROUP:"edit_library_group",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_GROUP:"delete_library_group"};Object.values(PERMISSIONS);const PasteAtRootContextMenu=({parentContext:a,setParentContext:l})=>{const{t:c}=reactI18next.useTranslation(),{canPaste:d,pasteBlocks:u}=usePasteBlocks();return React.useEffect(()=>{d("root")||l(null)},[d("root")]),!a||!d("root")?null:jsxRuntime.jsx("div",{style:{position:"absolute",top:a.y-75,left:a.x-56},children:jsxRuntime.jsxs(tooltip.DropdownMenu,{open:!0,onOpenChange:()=>l(null),children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{className:"hidden"}),jsxRuntime.jsx(tooltip.DropdownMenuContent,{className:"w-28 p-1 text-xs",children:jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{u("root"),l(null)},children:[jsxRuntime.jsx(reactIcons.CardStackIcon,{})," ",c("Paste")]})})]})})},CopyPasteBlocks=()=>{const[a]=useBlocksStore(),[l]=useSelectedBlockIds(),{pasteBlocks:c}=usePasteBlocks(),[,d]=useCopyBlockIds(),{t:u}=reactI18next.useTranslation(),p=useSelectedBlock(),m=React.useCallback(()=>{const h=l.map(g=>{const x=a.find(f=>f._id===g);return{id:g,data:x}});d(h.map(g=>g.id))},[l,a,d]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDuplicateBlock(p==null?void 0:p._type),onClick:m,className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsx(reactIcons.CopyIcon,{})," ",u("Copy")]}),jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{c(l)},children:[jsxRuntime.jsx(reactIcons.CardStackIcon,{})," ",u("Paste")]})]})},CutBlocks=()=>{const[a]=useSelectedBlockIds(),[,l]=useCutBlockIds(),{t:c}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>l(a),children:[jsxRuntime.jsx(reactIcons.ScissorsIcon,{})," ",c("Cut")]})},RemoveBlocks=()=>{const[a]=useSelectedBlockIds(),l=useRemoveBlocks(),c=useSelectedBlock(),{t:d}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDeleteBlock(c==null?void 0:c._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>l(a),children:[jsxRuntime.jsx(reactIcons.TrashIcon,{})," ",d("Remove")]})},RenameBlock=({node:a})=>{const{t:l}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),a.edit(),a.deselect()},className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsx(lucideReact.PencilIcon,{className:"h-4 w-4"})," ",l("Rename")]})},BlockContextMenuContent=({node:a})=>{const{t:l}=reactI18next.useTranslation(),[c]=useSelectedBlockIds(),d=useDuplicateBlocks(),u=useSelectedBlock(),{hasPermission:p}=usePermissions(),m=React.useCallback(()=>{d(c)},[c,d]);return jsxRuntime.jsxs(tooltip.DropdownMenuContent,{side:"bottom",className:"border-border text-xs",children:[p(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canAddChildBlock(u==null?void 0:u._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,u),children:[jsxRuntime.jsx(lucideReact.PlusIcon,{size:"14"})," ",l("Add block")]}),jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDuplicateBlock(u==null?void 0:u._type),className:"flex items-center gap-x-4 text-xs",onClick:m,children:[jsxRuntime.jsx(reactIcons.CardStackPlusIcon,{})," ",l("Duplicate")]})]}),jsxRuntime.jsx(RenameBlock,{node:a}),p(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(CutBlocks,{}),p(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsx(CopyPasteBlocks,{}),p(PERMISSIONS.DELETE_BLOCK)&&jsxRuntime.jsx(RemoveBlocks,{})]})},BlockMoreOptions=({children:a,id:l,node:c})=>{const[,d]=useSelectedBlockIds();return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(tooltip.DropdownMenu,{onOpenChange:u=>{u&&d([l])},children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{children:a}),jsxRuntime.jsx(BlockContextMenuContent,{node:c})]})})},placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:l,left:c}){const d={position:"absolute",pointerEvents:"none",top:l+"px",left:c+"px",right:0};return jsxRuntime.jsx("div",{style:{...placeholderStyle,...d},children:jsxRuntime.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:l,isDragging:c}){return c?jsxRuntime.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:l}):null}),DefaultDragPreview=React.memo(({id:a,isDragging:l,mouse:c})=>{const[d]=useBlocksStore(),u=React.useMemo(()=>d.find(m=>m._id===a),[d,a]),p=React.useMemo(()=>({transform:`translate(${(c==null?void 0:c.x)-10}px, ${(c==null?void 0:c.y)-10}px)`}),[c]);return c?jsxRuntime.jsx("div",{children:jsxRuntime.jsx(Overlay,{isDragging:l,children:jsxRuntime.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:p,children:jsxRuntime.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${u==null?void 0:u._type}`,children:[jsxRuntime.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsx(TypeIcon,{type:u==null?void 0:u._type})}),jsxRuntime.jsx("div",{className:"ml-2 truncate text-[11px]",children:(u==null?void 0:u._name)||(u==null?void 0:u._type)})]})})})}):jsxRuntime.jsx("div",{className:"hidden"})}),defaultShortcuts=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function selectFirst(a){a.firstNode&&a.select(a.firstNode.id)}function selectLast(a){a.lastNode&&a.select(a.lastNode.id)}function selectNext(a){const l=a.selectedNodes[0].next||a.firstNode;a.select(l.id)}function selectPrev(a){const l=a.selectedNodes[0].prev||a.lastNode;a.select(l.id)}const selectParent=(a,l)=>{var d;const c=((d=a.selectedIds[0])==null?void 0:d.parent)||null;c&&l&&a.select(c.id)},open=(a,l)=>{const c=a.selectedNodes[0];c.isInternal&&l&&c.open()},close=(a,l)=>{const c=a.selectedNodes[0];c.isInternal&&l&&c.close()},Input=({node:a})=>{var l,c;return jsxRuntime.jsx("input",{autoFocus:!0,className:cn("ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",a.isSelected?"text-black dark:text-white":""),type:"text",defaultValue:((l=a.data)==null?void 0:l._name)||((c=a.data)==null?void 0:c._type),onFocus:d=>d.currentTarget.select(),onBlur:d=>a.submit(d.currentTarget.value),onKeyDown:d=>{d.key==="Enter"&&a.submit(d.currentTarget.value)}})},currentAddSelection=jotai.atom(null),Node=React.memo(({node:a,style:l,dragHandle:c})=>{var O;const{t:d}=reactI18next.useTranslation(),[u,,p]=useHiddenBlockIds(),[m]=jotai.useAtom(canvasIframeAtom),{hasPermission:h}=usePermissions();let g=null;const x=a.children.length>0,{highlightBlock:f,clearHighlight:y}=useBlockHighlight(),{id:b,data:j,isSelected:R,willReceiveDrop:k,isDragging:v,isEditing:S,handleClick:C}=a,I=Z=>{Z.stopPropagation(),!u.includes(b)&&a.toggle()},w=Z=>{Z.isInternal&&(g=Z.isOpen,Z.isOpen&&Z.close())},T=Z=>{Z.isInternal&&g!==null&&(g?Z.open():Z.close(),g=null)},[A,B]=jotai.useAtom(currentAddSelection),D=()=>{var Z;_(),a.parent.isSelected||B((Z=a==null?void 0:a.parent)==null?void 0:Z.id)},_=()=>{B(null)},E=Z=>{_(),Z.stopPropagation(),!a.isOpen&&!u.includes(b)&&a.toggle(),C(Z)};React.useEffect(()=>{const Z=setTimeout(()=>{k&&!a.isOpen&&!v&&!u.includes(b)&&a.toggle()},500);return()=>clearTimeout(Z)},[k,a,v]);const N=React.useMemo(()=>{const Z=Object.keys(j),V=[];for(let U=0;U<Z.length;U++)if(Z[U].endsWith("_attrs")){const $=j[Z[U]],F=Object.keys($).join("|");F.match(/x-data/)&&V.push("data"),F.match(/x-on/)&&V.push("event"),F.match(/x-show|x-if/)&&V.push("show")}return V},[j]),P=(Z,V)=>{const U=m.contentDocument||m.contentWindow.document,$=U.querySelector(`[data-block-id=${Z}]`);$&&$.setAttribute("data-drop",V);const F=$.getBoundingClientRect(),H=m.getBoundingClientRect();F.top>=H.top&&F.left>=H.left&&F.bottom<=H.bottom&&F.right<=H.right||(U.documentElement.scrollTop=$.offsetTop-H.top)},L=Z=>{_();const V=lodashEs.get(a,"parent.id");V!=="__REACT_ARBORIST_INTERNAL_ROOT__"?pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{_id:V,position:Z}):pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{position:Z})};if(b===getSplitClasses.ROOT_TEMP_KEY)return jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer",children:[jsxRuntime.jsx("br",{}),h(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsx("div",{role:"button",onClick:()=>L(-1),className:"h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-2 w-2 stroke-[3]"})," ",d("Add block")]})}),jsxRuntime.jsx("br",{})]});const M=React.useMemo(()=>lodashEs.has(j,"_libBlockId"),[j]);return jsxRuntime.jsx("div",{className:"w-full",children:jsxRuntime.jsxs("div",{onMouseEnter:()=>f(b),onMouseLeave:()=>y(),onClick:E,style:l,"data-node-id":b,ref:u.includes(b)?null:c,onDragStart:()=>w(a),onDragEnd:()=>T(a),onDragOver:Z=>{Z.preventDefault(),P(b,"yes")},onDragLeave:Z=>{Z.preventDefault(),P(b,"no")},onDrop:Z=>{Z.preventDefault(),P(b,"no")},children:[h(PERMISSIONS.ADD_BLOCK)&&(a==null?void 0:a.rowIndex)>0&&(a.parent.isOpen&&canAddChildBlock(lodashEs.get(a,"parent.data._type"))||((O=a==null?void 0:a.parent)==null?void 0:O.id)==="__REACT_ARBORIST_INTERNAL_ROOT__")&&jsxRuntime.jsx("div",{className:"group relative ml-5 h-full w-full cursor-pointer",children:jsxRuntime.jsx("div",{onClick:Z=>{Z.stopPropagation(),L(a.childIndex)},onMouseEnter:D,onMouseLeave:_,className:"absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",children:jsxRuntime.jsx("div",{className:"absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500",children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-3 w-3 stroke-[4] text-white"})})})}),jsxRuntime.jsxs("div",{className:cn("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",R?"bg-blue-500 text-white":"hover:bg-slate-200 dark:hover:bg-gray-800",k&&canAcceptChildBlock(j._type,"Icon")?"bg-green-200":"",(a==null?void 0:a.id)===A?"bg-purple-100":"",v&&"opacity-20",u.includes(b)?"opacity-50":""),children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${a.isOpen?"rotate-90":""}`,children:x&&jsxRuntime.jsx("button",{onClick:I,type:"button",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:`h-3 w-3 stroke-[3] ${R?"text-slate-200":"text-slate-400"}`})})}),jsxRuntime.jsxs("div",{className:cn("leading-1 flex items-center",M&&"text-orange-400"),children:[jsxRuntime.jsx(TypeIcon,{type:j==null?void 0:j._type}),S?jsxRuntime.jsx(Input,{node:a}):jsxRuntime.jsxs("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",onDoubleClick:Z=>{Z.stopPropagation(),a.edit(),a.deselect()},children:[jsxRuntime.jsx("span",{children:(j==null?void 0:j._name)||(j==null?void 0:j._type.split("/").pop())}),N.includes("data")&&jsxRuntime.jsx(lucideReact.FileJson,{className:"h-3 w-3 text-orange-600"}),N.includes("event")&&jsxRuntime.jsx(lucideReact.Zap,{className:"h-3 w-3 text-yellow-500"}),N.includes("show")&&jsxRuntime.jsx(lucideReact.EyeOffIcon,{className:"h-3 w-3 text-orange-600"})]})]})]}),jsxRuntime.jsxs("div",{className:"invisible flex items-center space-x-1.5 pr-2 group-hover:visible",children:[canAddChildBlock(j==null?void 0:j._type)&&!u.includes(b)&&h(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(TooltipPrimitive.Tooltip,{children:[jsxRuntime.jsx(TooltipPrimitive.TooltipTrigger,{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{_id:b}),className:"cursor-pointer rounded bg-transparent hover:text-black",asChild:!0,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-3 w-3"})}),jsxRuntime.jsx(TooltipPrimitive.TooltipContent,{className:"isolate z-[9999]",side:"left",children:d("Add block")})]}):null,jsxRuntime.jsxs(TooltipPrimitive.Tooltip,{children:[jsxRuntime.jsx(TooltipPrimitive.TooltipTrigger,{onClick:Z=>{Z.stopPropagation(),p(b),a.isOpen&&a.toggle()},className:"cursor-pointer rounded bg-transparent hover:text-black",asChild:!0,children:jsxRuntime.jsx(lucideReact.EyeOffIcon,{size:"15"})}),jsxRuntime.jsx(TooltipPrimitive.TooltipContent,{className:"isolate z-[9999]",side:"left",children:d("Hide block")})]}),jsxRuntime.jsx(BlockMoreOptions,{node:a,id:b,children:jsxRuntime.jsx(lucideReact.MoreVertical,{size:"15"})})]})]})]})})}),r=(a,l,c)=>{if(a&&"reportValidity"in a){const d=tooltip.get(c,l);a.setCustomValidity(d&&d.message||""),a.reportValidity()}},o=(a,l)=>{for(const c in l.fields){const d=l.fields[c];d&&d.ref&&"reportValidity"in d.ref?r(d.ref,c,a):d&&d.refs&&d.refs.forEach(u=>r(u,c,a))}},s$1=(a,l)=>{l.shouldUseNativeValidation&&o(a,l);const c={};for(const d in a){const u=tooltip.get(l.fields,d),p=Object.assign(a[d]||{},{ref:u&&u.ref});if(i(l.names||Object.keys(a),d)){const m=Object.assign({},tooltip.get(c,d));tooltip.set(m,"root",p),tooltip.set(c,d,m)}else tooltip.set(c,d,p)}return c},i=(a,l)=>{const c=n$1(l);return a.some(d=>n$1(d).match(`^${c}\\.\\d+`))};function n$1(a){return a.replace(/\]|\[/g,"")}function n(a,l){for(var c={};a.length;){var d=a[0],u=d.code,p=d.message,m=d.path.join(".");if(!c[m])if("unionErrors"in d){var h=d.unionErrors[0].errors[0];c[m]={message:h.message,type:h.code}}else c[m]={message:p,type:u};if("unionErrors"in d&&d.unionErrors.forEach(function(f){return f.errors.forEach(function(y){return a.push(y)})}),l){var g=c[m].types,x=g&&g[d.code];c[m]=tooltip.appendErrors(m,l,c,u,x?[].concat(x,d.message):d.message)}a.shift()}return c}function s(a,l,c){return c===void 0&&(c={}),function(d,u,p){try{return Promise.resolve(function(m,h){try{var g=Promise.resolve(a[c.mode==="sync"?"parse":"parseAsync"](d,l)).then(function(x){return p.shouldUseNativeValidation&&o({},p),{errors:{},values:c.raw?Object.assign({},d):x}})}catch(x){return h(x)}return g&&g.then?g.then(void 0,h):g}(0,function(m){if(function(h){return Array.isArray(h==null?void 0:h.errors)}(m))return{values:{},errors:s$1(n(m.errors,!p.shouldUseNativeValidation&&p.criteriaMode==="all"),p)};throw m}))}catch(m){return Promise.reject(m)}}}var util;(function(a){a.assertEqual=u=>u;function l(u){}a.assertIs=l;function c(u){throw new Error}a.assertNever=c,a.arrayToEnum=u=>{const p={};for(const m of u)p[m]=m;return p},a.getValidEnumValues=u=>{const p=a.objectKeys(u).filter(h=>typeof u[u[h]]!="number"),m={};for(const h of p)m[h]=u[h];return a.objectValues(m)},a.objectValues=u=>a.objectKeys(u).map(function(p){return u[p]}),a.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{const p=[];for(const m in u)Object.prototype.hasOwnProperty.call(u,m)&&p.push(m);return p},a.find=(u,p)=>{for(const m of u)if(p(m))return m},a.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&isFinite(u)&&Math.floor(u)===u;function d(u,p=" | "){return u.map(m=>typeof m=="string"?`'${m}'`:m).join(p)}a.joinValues=d,a.jsonStringifyReplacer=(u,p)=>typeof p=="bigint"?p.toString():p})(util||(util={}));var objectUtil;(function(a){a.mergeShapes=(l,c)=>({...l,...c})})(objectUtil||(objectUtil={}));const ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=a=>{switch(typeof a){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(a)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(a)?ZodParsedType.array:a===null?ZodParsedType.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&a instanceof Map?ZodParsedType.map:typeof Set<"u"&&a instanceof Set?ZodParsedType.set:typeof Date<"u"&&a instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{get errors(){return this.issues}constructor(l){super(),this.issues=[],this.addIssue=d=>{this.issues=[...this.issues,d]},this.addIssues=(d=[])=>{this.issues=[...this.issues,...d]};const c=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,c):this.__proto__=c,this.name="ZodError",this.issues=l}format(l){const c=l||function(p){return p.message},d={_errors:[]},u=p=>{for(const m of p.issues)if(m.code==="invalid_union")m.unionErrors.map(u);else if(m.code==="invalid_return_type")u(m.returnTypeError);else if(m.code==="invalid_arguments")u(m.argumentsError);else if(m.path.length===0)d._errors.push(c(m));else{let h=d,g=0;for(;g<m.path.length;){const x=m.path[g];g===m.path.length-1?(h[x]=h[x]||{_errors:[]},h[x]._errors.push(c(m))):h[x]=h[x]||{_errors:[]},h=h[x],g++}}};return u(this),d}static assert(l){if(!(l instanceof ZodError))throw new Error(`Not a ZodError: ${l}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(l=c=>c.message){const c={},d=[];for(const u of this.issues)u.path.length>0?(c[u.path[0]]=c[u.path[0]]||[],c[u.path[0]].push(l(u))):d.push(l(u));return{formErrors:d,fieldErrors:c}}get formErrors(){return this.flatten()}}ZodError.create=a=>new ZodError(a);const errorMap=(a,l)=>{let c;switch(a.code){case ZodIssueCode.invalid_type:a.received===ZodParsedType.undefined?c="Required":c=`Expected ${a.expected}, received ${a.received}`;break;case ZodIssueCode.invalid_literal:c=`Invalid literal value, expected ${JSON.stringify(a.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:c=`Unrecognized key(s) in object: ${util.joinValues(a.keys,", ")}`;break;case ZodIssueCode.invalid_union:c="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:c=`Invalid discriminator value. Expected ${util.joinValues(a.options)}`;break;case ZodIssueCode.invalid_enum_value:c=`Invalid enum value. Expected ${util.joinValues(a.options)}, received '${a.received}'`;break;case ZodIssueCode.invalid_arguments:c="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:c="Invalid function return type";break;case ZodIssueCode.invalid_date:c="Invalid date";break;case ZodIssueCode.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(c=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(c=`${c} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?c=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?c=`Invalid input: must end with "${a.validation.endsWith}"`:util.assertNever(a.validation):a.validation!=="regex"?c=`Invalid ${a.validation}`:c="Invalid";break;case ZodIssueCode.too_small:a.type==="array"?c=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?c=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?c=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?c=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:c="Invalid input";break;case ZodIssueCode.too_big:a.type==="array"?c=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?c=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?c=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?c=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?c=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:c="Invalid input";break;case ZodIssueCode.custom:c="Invalid input";break;case ZodIssueCode.invalid_intersection_types:c="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:c=`Number must be a multiple of ${a.multipleOf}`;break;case ZodIssueCode.not_finite:c="Number must be finite";break;default:c=l.defaultError,util.assertNever(a)}return{message:c}};let overrideErrorMap=errorMap;function setErrorMap(a){overrideErrorMap=a}function getErrorMap(){return overrideErrorMap}const makeIssue=a=>{const{data:l,path:c,errorMaps:d,issueData:u}=a,p=[...c,...u.path||[]],m={...u,path:p};if(u.message!==void 0)return{...u,path:p,message:u.message};let h="";const g=d.filter(x=>!!x).slice().reverse();for(const x of g)h=x(m,{data:l,defaultError:h}).message;return{...u,path:p,message:h}},EMPTY_PATH=[];function addIssueToContext(a,l){const c=getErrorMap(),d=makeIssue({issueData:l,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,c,c===errorMap?void 0:errorMap].filter(u=>!!u)});a.common.issues.push(d)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(l,c){const d=[];for(const u of c){if(u.status==="aborted")return INVALID;u.status==="dirty"&&l.dirty(),d.push(u.value)}return{status:l.value,value:d}}static async mergeObjectAsync(l,c){const d=[];for(const u of c){const p=await u.key,m=await u.value;d.push({key:p,value:m})}return ParseStatus.mergeObjectSync(l,d)}static mergeObjectSync(l,c){const d={};for(const u of c){const{key:p,value:m}=u;if(p.status==="aborted"||m.status==="aborted")return INVALID;p.status==="dirty"&&l.dirty(),m.status==="dirty"&&l.dirty(),p.value!=="__proto__"&&(typeof m.value<"u"||u.alwaysSet)&&(d[p.value]=m.value)}return{status:l.value,value:d}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=a=>({status:"dirty",value:a}),OK=a=>({status:"valid",value:a}),isAborted=a=>a.status==="aborted",isDirty=a=>a.status==="dirty",isValid=a=>a.status==="valid",isAsync=a=>typeof Promise<"u"&&a instanceof Promise;function __classPrivateFieldGet(a,l,c,d){if(typeof l=="function"?a!==l||!d:!l.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return l.get(a)}function __classPrivateFieldSet(a,l,c,d,u){if(typeof l=="function"?a!==l||!u:!l.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return l.set(a,c),c}typeof SuppressedError=="function"&&SuppressedError;var errorUtil;(function(a){a.errToObj=l=>typeof l=="string"?{message:l}:l||{},a.toString=l=>typeof l=="string"?l:l==null?void 0:l.message})(errorUtil||(errorUtil={}));var _ZodEnum_cache,_ZodNativeEnum_cache;class ParseInputLazyPath{constructor(l,c,d,u){this._cachedPath=[],this.parent=l,this.data=c,this._path=d,this._key=u}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(a,l)=>{if(isValid(l))return{success:!0,data:l.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const c=new ZodError(a.common.issues);return this._error=c,this._error}}};function processCreateParams(a){if(!a)return{};const{errorMap:l,invalid_type_error:c,required_error:d,description:u}=a;if(l&&(c||d))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return l?{errorMap:l,description:u}:{errorMap:(m,h)=>{var g,x;const{message:f}=a;return m.code==="invalid_enum_value"?{message:f??h.defaultError}:typeof h.data>"u"?{message:(g=f??d)!==null&&g!==void 0?g:h.defaultError}:m.code!=="invalid_type"?{message:h.defaultError}:{message:(x=f??c)!==null&&x!==void 0?x:h.defaultError}},description:u}}class ZodType{get description(){return this._def.description}_getType(l){return getParsedType(l.data)}_getOrReturnCtx(l,c){return c||{common:l.parent.common,data:l.data,parsedType:getParsedType(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}_processInputParams(l){return{status:new ParseStatus,ctx:{common:l.parent.common,data:l.data,parsedType:getParsedType(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}}_parseSync(l){const c=this._parse(l);if(isAsync(c))throw new Error("Synchronous parse encountered promise.");return c}_parseAsync(l){const c=this._parse(l);return Promise.resolve(c)}parse(l,c){const d=this.safeParse(l,c);if(d.success)return d.data;throw d.error}safeParse(l,c){var d;const u={common:{issues:[],async:(d=c==null?void 0:c.async)!==null&&d!==void 0?d:!1,contextualErrorMap:c==null?void 0:c.errorMap},path:(c==null?void 0:c.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)},p=this._parseSync({data:l,path:u.path,parent:u});return handleResult(u,p)}"~validate"(l){var c,d;const u={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)};if(!this["~standard"].async)try{const p=this._parseSync({data:l,path:[],parent:u});return isValid(p)?{value:p.value}:{issues:u.common.issues}}catch(p){!((d=(c=p==null?void 0:p.message)===null||c===void 0?void 0:c.toLowerCase())===null||d===void 0)&&d.includes("encountered")&&(this["~standard"].async=!0),u.common={issues:[],async:!0}}return this._parseAsync({data:l,path:[],parent:u}).then(p=>isValid(p)?{value:p.value}:{issues:u.common.issues})}async parseAsync(l,c){const d=await this.safeParseAsync(l,c);if(d.success)return d.data;throw d.error}async safeParseAsync(l,c){const d={common:{issues:[],contextualErrorMap:c==null?void 0:c.errorMap,async:!0},path:(c==null?void 0:c.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)},u=this._parse({data:l,path:d.path,parent:d}),p=await(isAsync(u)?u:Promise.resolve(u));return handleResult(d,p)}refine(l,c){const d=u=>typeof c=="string"||typeof c>"u"?{message:c}:typeof c=="function"?c(u):c;return this._refinement((u,p)=>{const m=l(u),h=()=>p.addIssue({code:ZodIssueCode.custom,...d(u)});return typeof Promise<"u"&&m instanceof Promise?m.then(g=>g?!0:(h(),!1)):m?!0:(h(),!1)})}refinement(l,c){return this._refinement((d,u)=>l(d)?!0:(u.addIssue(typeof c=="function"?c(d,u):c),!1))}_refinement(l){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:l}})}superRefine(l){return this._refinement(l)}constructor(l){this.spa=this.safeParseAsync,this._def=l,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:c=>this["~validate"](c)}}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this)}promise(){return ZodPromise.create(this,this._def)}or(l){return ZodUnion.create([this,l],this._def)}and(l){return ZodIntersection.create(this,l,this._def)}transform(l){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:l}})}default(l){const c=typeof l=="function"?l:()=>l;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:c,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(l){const c=typeof l=="function"?l:()=>l;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:c,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(l){const c=this.constructor;return new c({...this._def,description:l})}pipe(l){return ZodPipeline.create(this,l)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/i,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nanoidRegex=/^[a-z0-9_-]{21}$/i,jwtRegex=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,durationRegex=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4CidrRegex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6Regex=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ipv6CidrRegex=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64urlRegex=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dateRegexSource="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dateRegex=new RegExp(`^${dateRegexSource}$`);function timeRegexSource(a){let l="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return a.precision?l=`${l}\\.\\d{${a.precision}}`:a.precision==null&&(l=`${l}(\\.\\d+)?`),l}function timeRegex(a){return new RegExp(`^${timeRegexSource(a)}$`)}function datetimeRegex(a){let l=`${dateRegexSource}T${timeRegexSource(a)}`;const c=[];return c.push(a.local?"Z?":"Z"),a.offset&&c.push("([+-]\\d{2}:?\\d{2})"),l=`${l}(${c.join("|")})`,new RegExp(`^${l}$`)}function isValidIP(a,l){return!!((l==="v4"||!l)&&ipv4Regex.test(a)||(l==="v6"||!l)&&ipv6Regex.test(a))}function isValidJWT(a,l){if(!jwtRegex.test(a))return!1;try{const[c]=a.split("."),d=c.replace(/-/g,"+").replace(/_/g,"/").padEnd(c.length+(4-c.length%4)%4,"="),u=JSON.parse(atob(d));return!(typeof u!="object"||u===null||!u.typ||!u.alg||l&&u.alg!==l)}catch{return!1}}function isValidCidr(a,l){return!!((l==="v4"||!l)&&ipv4CidrRegex.test(a)||(l==="v6"||!l)&&ipv6CidrRegex.test(a))}class ZodString extends ZodType{_parse(l){if(this._def.coerce&&(l.data=String(l.data)),this._getType(l)!==ZodParsedType.string){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:p.parsedType}),INVALID}const d=new ParseStatus;let u;for(const p of this._def.checks)if(p.kind==="min")l.data.length<p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_small,minimum:p.value,type:"string",inclusive:!0,exact:!1,message:p.message}),d.dirty());else if(p.kind==="max")l.data.length>p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_big,maximum:p.value,type:"string",inclusive:!0,exact:!1,message:p.message}),d.dirty());else if(p.kind==="length"){const m=l.data.length>p.value,h=l.data.length<p.value;(m||h)&&(u=this._getOrReturnCtx(l,u),m?addIssueToContext(u,{code:ZodIssueCode.too_big,maximum:p.value,type:"string",inclusive:!0,exact:!0,message:p.message}):h&&addIssueToContext(u,{code:ZodIssueCode.too_small,minimum:p.value,type:"string",inclusive:!0,exact:!0,message:p.message}),d.dirty())}else if(p.kind==="email")emailRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"email",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="emoji")emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"emoji",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="uuid")uuidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"uuid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="nanoid")nanoidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"nanoid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="cuid")cuidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cuid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="cuid2")cuid2Regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="ulid")ulidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"ulid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="url")try{new URL(l.data)}catch{u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"url",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()}else p.kind==="regex"?(p.regex.lastIndex=0,p.regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"regex",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty())):p.kind==="trim"?l.data=l.data.trim():p.kind==="includes"?l.data.includes(p.value,p.position)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{includes:p.value,position:p.position},message:p.message}),d.dirty()):p.kind==="toLowerCase"?l.data=l.data.toLowerCase():p.kind==="toUpperCase"?l.data=l.data.toUpperCase():p.kind==="startsWith"?l.data.startsWith(p.value)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{startsWith:p.value},message:p.message}),d.dirty()):p.kind==="endsWith"?l.data.endsWith(p.value)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{endsWith:p.value},message:p.message}),d.dirty()):p.kind==="datetime"?datetimeRegex(p).test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"datetime",message:p.message}),d.dirty()):p.kind==="date"?dateRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"date",message:p.message}),d.dirty()):p.kind==="time"?timeRegex(p).test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"time",message:p.message}),d.dirty()):p.kind==="duration"?durationRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"duration",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="ip"?isValidIP(l.data,p.version)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"ip",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="jwt"?isValidJWT(l.data,p.alg)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"jwt",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="cidr"?isValidCidr(l.data,p.version)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cidr",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="base64"?base64Regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"base64",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="base64url"?base64urlRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"base64url",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):util.assertNever(p);return{status:d.value,value:l.data}}_regex(l,c,d){return this.refinement(u=>l.test(u),{validation:c,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(d)})}_addCheck(l){return new ZodString({...this._def,checks:[...this._def.checks,l]})}email(l){return this._addCheck({kind:"email",...errorUtil.errToObj(l)})}url(l){return this._addCheck({kind:"url",...errorUtil.errToObj(l)})}emoji(l){return this._addCheck({kind:"emoji",...errorUtil.errToObj(l)})}uuid(l){return this._addCheck({kind:"uuid",...errorUtil.errToObj(l)})}nanoid(l){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(l)})}cuid(l){return this._addCheck({kind:"cuid",...errorUtil.errToObj(l)})}cuid2(l){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(l)})}ulid(l){return this._addCheck({kind:"ulid",...errorUtil.errToObj(l)})}base64(l){return this._addCheck({kind:"base64",...errorUtil.errToObj(l)})}base64url(l){return this._addCheck({kind:"base64url",...errorUtil.errToObj(l)})}jwt(l){return this._addCheck({kind:"jwt",...errorUtil.errToObj(l)})}ip(l){return this._addCheck({kind:"ip",...errorUtil.errToObj(l)})}cidr(l){return this._addCheck({kind:"cidr",...errorUtil.errToObj(l)})}datetime(l){var c,d;return typeof l=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:l}):this._addCheck({kind:"datetime",precision:typeof(l==null?void 0:l.precision)>"u"?null:l==null?void 0:l.precision,offset:(c=l==null?void 0:l.offset)!==null&&c!==void 0?c:!1,local:(d=l==null?void 0:l.local)!==null&&d!==void 0?d:!1,...errorUtil.errToObj(l==null?void 0:l.message)})}date(l){return this._addCheck({kind:"date",message:l})}time(l){return typeof l=="string"?this._addCheck({kind:"time",precision:null,message:l}):this._addCheck({kind:"time",precision:typeof(l==null?void 0:l.precision)>"u"?null:l==null?void 0:l.precision,...errorUtil.errToObj(l==null?void 0:l.message)})}duration(l){return this._addCheck({kind:"duration",...errorUtil.errToObj(l)})}regex(l,c){return this._addCheck({kind:"regex",regex:l,...errorUtil.errToObj(c)})}includes(l,c){return this._addCheck({kind:"includes",value:l,position:c==null?void 0:c.position,...errorUtil.errToObj(c==null?void 0:c.message)})}startsWith(l,c){return this._addCheck({kind:"startsWith",value:l,...errorUtil.errToObj(c)})}endsWith(l,c){return this._addCheck({kind:"endsWith",value:l,...errorUtil.errToObj(c)})}min(l,c){return this._addCheck({kind:"min",value:l,...errorUtil.errToObj(c)})}max(l,c){return this._addCheck({kind:"max",value:l,...errorUtil.errToObj(c)})}length(l,c){return this._addCheck({kind:"length",value:l,...errorUtil.errToObj(c)})}nonempty(l){return this.min(1,errorUtil.errToObj(l))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(l=>l.kind==="datetime")}get isDate(){return!!this._def.checks.find(l=>l.kind==="date")}get isTime(){return!!this._def.checks.find(l=>l.kind==="time")}get isDuration(){return!!this._def.checks.find(l=>l.kind==="duration")}get isEmail(){return!!this._def.checks.find(l=>l.kind==="email")}get isURL(){return!!this._def.checks.find(l=>l.kind==="url")}get isEmoji(){return!!this._def.checks.find(l=>l.kind==="emoji")}get isUUID(){return!!this._def.checks.find(l=>l.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(l=>l.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(l=>l.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(l=>l.kind==="cuid2")}get isULID(){return!!this._def.checks.find(l=>l.kind==="ulid")}get isIP(){return!!this._def.checks.find(l=>l.kind==="ip")}get isCIDR(){return!!this._def.checks.find(l=>l.kind==="cidr")}get isBase64(){return!!this._def.checks.find(l=>l.kind==="base64")}get isBase64url(){return!!this._def.checks.find(l=>l.kind==="base64url")}get minLength(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxLength(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}}ZodString.create=a=>{var l;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(l=a==null?void 0:a.coerce)!==null&&l!==void 0?l:!1,...processCreateParams(a)})};function floatSafeRemainder(a,l){const c=(a.toString().split(".")[1]||"").length,d=(l.toString().split(".")[1]||"").length,u=c>d?c:d,p=parseInt(a.toFixed(u).replace(".","")),m=parseInt(l.toFixed(u).replace(".",""));return p%m/Math.pow(10,u)}class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(l){if(this._def.coerce&&(l.data=Number(l.data)),this._getType(l)!==ZodParsedType.number){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:p.parsedType}),INVALID}let d;const u=new ParseStatus;for(const p of this._def.checks)p.kind==="int"?util.isInteger(l.data)||(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:p.message}),u.dirty()):p.kind==="min"?(p.inclusive?l.data<p.value:l.data<=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:p.value,type:"number",inclusive:p.inclusive,exact:!1,message:p.message}),u.dirty()):p.kind==="max"?(p.inclusive?l.data>p.value:l.data>=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:p.value,type:"number",inclusive:p.inclusive,exact:!1,message:p.message}),u.dirty()):p.kind==="multipleOf"?floatSafeRemainder(l.data,p.value)!==0&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_multiple_of,multipleOf:p.value,message:p.message}),u.dirty()):p.kind==="finite"?Number.isFinite(l.data)||(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_finite,message:p.message}),u.dirty()):util.assertNever(p);return{status:u.value,value:l.data}}gte(l,c){return this.setLimit("min",l,!0,errorUtil.toString(c))}gt(l,c){return this.setLimit("min",l,!1,errorUtil.toString(c))}lte(l,c){return this.setLimit("max",l,!0,errorUtil.toString(c))}lt(l,c){return this.setLimit("max",l,!1,errorUtil.toString(c))}setLimit(l,c,d,u){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:l,value:c,inclusive:d,message:errorUtil.toString(u)}]})}_addCheck(l){return new ZodNumber({...this._def,checks:[...this._def.checks,l]})}int(l){return this._addCheck({kind:"int",message:errorUtil.toString(l)})}positive(l){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(l)})}negative(l){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(l)})}multipleOf(l,c){return this._addCheck({kind:"multipleOf",value:l,message:errorUtil.toString(c)})}finite(l){return this._addCheck({kind:"finite",message:errorUtil.toString(l)})}safe(l){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(l)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(l)})}get minValue(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxValue(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}get isInt(){return!!this._def.checks.find(l=>l.kind==="int"||l.kind==="multipleOf"&&util.isInteger(l.value))}get isFinite(){let l=null,c=null;for(const d of this._def.checks){if(d.kind==="finite"||d.kind==="int"||d.kind==="multipleOf")return!0;d.kind==="min"?(c===null||d.value>c)&&(c=d.value):d.kind==="max"&&(l===null||d.value<l)&&(l=d.value)}return Number.isFinite(c)&&Number.isFinite(l)}}ZodNumber.create=a=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(l){if(this._def.coerce)try{l.data=BigInt(l.data)}catch{return this._getInvalidInput(l)}if(this._getType(l)!==ZodParsedType.bigint)return this._getInvalidInput(l);let d;const u=new ParseStatus;for(const p of this._def.checks)p.kind==="min"?(p.inclusive?l.data<p.value:l.data<=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_small,type:"bigint",minimum:p.value,inclusive:p.inclusive,message:p.message}),u.dirty()):p.kind==="max"?(p.inclusive?l.data>p.value:l.data>=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_big,type:"bigint",maximum:p.value,inclusive:p.inclusive,message:p.message}),u.dirty()):p.kind==="multipleOf"?l.data%p.value!==BigInt(0)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_multiple_of,multipleOf:p.value,message:p.message}),u.dirty()):util.assertNever(p);return{status:u.value,value:l.data}}_getInvalidInput(l){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:c.parsedType}),INVALID}gte(l,c){return this.setLimit("min",l,!0,errorUtil.toString(c))}gt(l,c){return this.setLimit("min",l,!1,errorUtil.toString(c))}lte(l,c){return this.setLimit("max",l,!0,errorUtil.toString(c))}lt(l,c){return this.setLimit("max",l,!1,errorUtil.toString(c))}setLimit(l,c,d,u){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:l,value:c,inclusive:d,message:errorUtil.toString(u)}]})}_addCheck(l){return new ZodBigInt({...this._def,checks:[...this._def.checks,l]})}positive(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(l)})}negative(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(l)})}multipleOf(l,c){return this._addCheck({kind:"multipleOf",value:l,message:errorUtil.toString(c)})}get minValue(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxValue(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}}ZodBigInt.create=a=>{var l;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(l=a==null?void 0:a.coerce)!==null&&l!==void 0?l:!1,...processCreateParams(a)})};class ZodBoolean extends ZodType{_parse(l){if(this._def.coerce&&(l.data=!!l.data),this._getType(l)!==ZodParsedType.boolean){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:d.parsedType}),INVALID}return OK(l.data)}}ZodBoolean.create=a=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodDate extends ZodType{_parse(l){if(this._def.coerce&&(l.data=new Date(l.data)),this._getType(l)!==ZodParsedType.date){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:p.parsedType}),INVALID}if(isNaN(l.data.getTime())){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_date}),INVALID}const d=new ParseStatus;let u;for(const p of this._def.checks)p.kind==="min"?l.data.getTime()<p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_small,message:p.message,inclusive:!0,exact:!1,minimum:p.value,type:"date"}),d.dirty()):p.kind==="max"?l.data.getTime()>p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_big,message:p.message,inclusive:!0,exact:!1,maximum:p.value,type:"date"}),d.dirty()):util.assertNever(p);return{status:d.value,value:new Date(l.data.getTime())}}_addCheck(l){return new ZodDate({...this._def,checks:[...this._def.checks,l]})}min(l,c){return this._addCheck({kind:"min",value:l.getTime(),message:errorUtil.toString(c)})}max(l,c){return this._addCheck({kind:"max",value:l.getTime(),message:errorUtil.toString(c)})}get minDate(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l!=null?new Date(l):null}get maxDate(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l!=null?new Date(l):null}}ZodDate.create=a=>new ZodDate({checks:[],coerce:(a==null?void 0:a.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(a)});class ZodSymbol extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.symbol){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:d.parsedType}),INVALID}return OK(l.data)}}ZodSymbol.create=a=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(a)});class ZodUndefined extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.undefined){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:d.parsedType}),INVALID}return OK(l.data)}}ZodUndefined.create=a=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(a)});class ZodNull extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.null){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:d.parsedType}),INVALID}return OK(l.data)}}ZodNull.create=a=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(a)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(l){return OK(l.data)}}ZodAny.create=a=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(a)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(l){return OK(l.data)}}ZodUnknown.create=a=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(a)});class ZodNever extends ZodType{_parse(l){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:c.parsedType}),INVALID}}ZodNever.create=a=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(a)});class ZodVoid extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.undefined){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:d.parsedType}),INVALID}return OK(l.data)}}ZodVoid.create=a=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(a)});class ZodArray extends ZodType{_parse(l){const{ctx:c,status:d}=this._processInputParams(l),u=this._def;if(c.parsedType!==ZodParsedType.array)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:c.parsedType}),INVALID;if(u.exactLength!==null){const m=c.data.length>u.exactLength.value,h=c.data.length<u.exactLength.value;(m||h)&&(addIssueToContext(c,{code:m?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:h?u.exactLength.value:void 0,maximum:m?u.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:u.exactLength.message}),d.dirty())}if(u.minLength!==null&&c.data.length<u.minLength.value&&(addIssueToContext(c,{code:ZodIssueCode.too_small,minimum:u.minLength.value,type:"array",inclusive:!0,exact:!1,message:u.minLength.message}),d.dirty()),u.maxLength!==null&&c.data.length>u.maxLength.value&&(addIssueToContext(c,{code:ZodIssueCode.too_big,maximum:u.maxLength.value,type:"array",inclusive:!0,exact:!1,message:u.maxLength.message}),d.dirty()),c.common.async)return Promise.all([...c.data].map((m,h)=>u.type._parseAsync(new ParseInputLazyPath(c,m,c.path,h)))).then(m=>ParseStatus.mergeArray(d,m));const p=[...c.data].map((m,h)=>u.type._parseSync(new ParseInputLazyPath(c,m,c.path,h)));return ParseStatus.mergeArray(d,p)}get element(){return this._def.type}min(l,c){return new ZodArray({...this._def,minLength:{value:l,message:errorUtil.toString(c)}})}max(l,c){return new ZodArray({...this._def,maxLength:{value:l,message:errorUtil.toString(c)}})}length(l,c){return new ZodArray({...this._def,exactLength:{value:l,message:errorUtil.toString(c)}})}nonempty(l){return this.min(1,l)}}ZodArray.create=(a,l)=>new ZodArray({type:a,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(l)});function deepPartialify(a){if(a instanceof ZodObject){const l={};for(const c in a.shape){const d=a.shape[c];l[c]=ZodOptional.create(deepPartialify(d))}return new ZodObject({...a._def,shape:()=>l})}else return a instanceof ZodArray?new ZodArray({...a._def,type:deepPartialify(a.element)}):a instanceof ZodOptional?ZodOptional.create(deepPartialify(a.unwrap())):a instanceof ZodNullable?ZodNullable.create(deepPartialify(a.unwrap())):a instanceof ZodTuple?ZodTuple.create(a.items.map(l=>deepPartialify(l))):a}class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const l=this._def.shape(),c=util.objectKeys(l);return this._cached={shape:l,keys:c}}_parse(l){if(this._getType(l)!==ZodParsedType.object){const x=this._getOrReturnCtx(l);return addIssueToContext(x,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:x.parsedType}),INVALID}const{status:d,ctx:u}=this._processInputParams(l),{shape:p,keys:m}=this._getCached(),h=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const x in u.data)m.includes(x)||h.push(x);const g=[];for(const x of m){const f=p[x],y=u.data[x];g.push({key:{status:"valid",value:x},value:f._parse(new ParseInputLazyPath(u,y,u.path,x)),alwaysSet:x in u.data})}if(this._def.catchall instanceof ZodNever){const x=this._def.unknownKeys;if(x==="passthrough")for(const f of h)g.push({key:{status:"valid",value:f},value:{status:"valid",value:u.data[f]}});else if(x==="strict")h.length>0&&(addIssueToContext(u,{code:ZodIssueCode.unrecognized_keys,keys:h}),d.dirty());else if(x!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const x=this._def.catchall;for(const f of h){const y=u.data[f];g.push({key:{status:"valid",value:f},value:x._parse(new ParseInputLazyPath(u,y,u.path,f)),alwaysSet:f in u.data})}}return u.common.async?Promise.resolve().then(async()=>{const x=[];for(const f of g){const y=await f.key,b=await f.value;x.push({key:y,value:b,alwaysSet:f.alwaysSet})}return x}).then(x=>ParseStatus.mergeObjectSync(d,x)):ParseStatus.mergeObjectSync(d,g)}get shape(){return this._def.shape()}strict(l){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...l!==void 0?{errorMap:(c,d)=>{var u,p,m,h;const g=(m=(p=(u=this._def).errorMap)===null||p===void 0?void 0:p.call(u,c,d).message)!==null&&m!==void 0?m:d.defaultError;return c.code==="unrecognized_keys"?{message:(h=errorUtil.errToObj(l).message)!==null&&h!==void 0?h:g}:{message:g}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(l){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...l})})}merge(l){return new ZodObject({unknownKeys:l._def.unknownKeys,catchall:l._def.catchall,shape:()=>({...this._def.shape(),...l._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(l,c){return this.augment({[l]:c})}catchall(l){return new ZodObject({...this._def,catchall:l})}pick(l){const c={};return util.objectKeys(l).forEach(d=>{l[d]&&this.shape[d]&&(c[d]=this.shape[d])}),new ZodObject({...this._def,shape:()=>c})}omit(l){const c={};return util.objectKeys(this.shape).forEach(d=>{l[d]||(c[d]=this.shape[d])}),new ZodObject({...this._def,shape:()=>c})}deepPartial(){return deepPartialify(this)}partial(l){const c={};return util.objectKeys(this.shape).forEach(d=>{const u=this.shape[d];l&&!l[d]?c[d]=u:c[d]=u.optional()}),new ZodObject({...this._def,shape:()=>c})}required(l){const c={};return util.objectKeys(this.shape).forEach(d=>{if(l&&!l[d])c[d]=this.shape[d];else{let p=this.shape[d];for(;p instanceof ZodOptional;)p=p._def.innerType;c[d]=p}}),new ZodObject({...this._def,shape:()=>c})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(a,l)=>new ZodObject({shape:()=>a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});ZodObject.strictCreate=(a,l)=>new ZodObject({shape:()=>a,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});ZodObject.lazycreate=(a,l)=>new ZodObject({shape:a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});class ZodUnion extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d=this._def.options;function u(p){for(const h of p)if(h.result.status==="valid")return h.result;for(const h of p)if(h.result.status==="dirty")return c.common.issues.push(...h.ctx.common.issues),h.result;const m=p.map(h=>new ZodError(h.ctx.common.issues));return addIssueToContext(c,{code:ZodIssueCode.invalid_union,unionErrors:m}),INVALID}if(c.common.async)return Promise.all(d.map(async p=>{const m={...c,common:{...c.common,issues:[]},parent:null};return{result:await p._parseAsync({data:c.data,path:c.path,parent:m}),ctx:m}})).then(u);{let p;const m=[];for(const g of d){const x={...c,common:{...c.common,issues:[]},parent:null},f=g._parseSync({data:c.data,path:c.path,parent:x});if(f.status==="valid")return f;f.status==="dirty"&&!p&&(p={result:f,ctx:x}),x.common.issues.length&&m.push(x.common.issues)}if(p)return c.common.issues.push(...p.ctx.common.issues),p.result;const h=m.map(g=>new ZodError(g));return addIssueToContext(c,{code:ZodIssueCode.invalid_union,unionErrors:h}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(a,l)=>new ZodUnion({options:a,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(l)});const getDiscriminator=a=>a instanceof ZodLazy?getDiscriminator(a.schema):a instanceof ZodEffects?getDiscriminator(a.innerType()):a instanceof ZodLiteral?[a.value]:a instanceof ZodEnum?a.options:a instanceof ZodNativeEnum?util.objectValues(a.enum):a instanceof ZodDefault?getDiscriminator(a._def.innerType):a instanceof ZodUndefined?[void 0]:a instanceof ZodNull?[null]:a instanceof ZodOptional?[void 0,...getDiscriminator(a.unwrap())]:a instanceof ZodNullable?[null,...getDiscriminator(a.unwrap())]:a instanceof ZodBranded||a instanceof ZodReadonly?getDiscriminator(a.unwrap()):a instanceof ZodCatch?getDiscriminator(a._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.object)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:c.parsedType}),INVALID;const d=this.discriminator,u=c.data[d],p=this.optionsMap.get(u);return p?c.common.async?p._parseAsync({data:c.data,path:c.path,parent:c}):p._parseSync({data:c.data,path:c.path,parent:c}):(addIssueToContext(c,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[d]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(l,c,d){const u=new Map;for(const p of c){const m=getDiscriminator(p.shape[l]);if(!m.length)throw new Error(`A discriminator value for key \`${l}\` could not be extracted from all schema options`);for(const h of m){if(u.has(h))throw new Error(`Discriminator property ${String(l)} has duplicate value ${String(h)}`);u.set(h,p)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:l,options:c,optionsMap:u,...processCreateParams(d)})}}function mergeValues(a,l){const c=getParsedType(a),d=getParsedType(l);if(a===l)return{valid:!0,data:a};if(c===ZodParsedType.object&&d===ZodParsedType.object){const u=util.objectKeys(l),p=util.objectKeys(a).filter(h=>u.indexOf(h)!==-1),m={...a,...l};for(const h of p){const g=mergeValues(a[h],l[h]);if(!g.valid)return{valid:!1};m[h]=g.data}return{valid:!0,data:m}}else if(c===ZodParsedType.array&&d===ZodParsedType.array){if(a.length!==l.length)return{valid:!1};const u=[];for(let p=0;p<a.length;p++){const m=a[p],h=l[p],g=mergeValues(m,h);if(!g.valid)return{valid:!1};u.push(g.data)}return{valid:!0,data:u}}else return c===ZodParsedType.date&&d===ZodParsedType.date&&+a==+l?{valid:!0,data:a}:{valid:!1}}class ZodIntersection extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l),u=(p,m)=>{if(isAborted(p)||isAborted(m))return INVALID;const h=mergeValues(p.value,m.value);return h.valid?((isDirty(p)||isDirty(m))&&c.dirty(),{status:c.value,value:h.data}):(addIssueToContext(d,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return d.common.async?Promise.all([this._def.left._parseAsync({data:d.data,path:d.path,parent:d}),this._def.right._parseAsync({data:d.data,path:d.path,parent:d})]).then(([p,m])=>u(p,m)):u(this._def.left._parseSync({data:d.data,path:d.path,parent:d}),this._def.right._parseSync({data:d.data,path:d.path,parent:d}))}}ZodIntersection.create=(a,l,c)=>new ZodIntersection({left:a,right:l,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(c)});class ZodTuple extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.array)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:d.parsedType}),INVALID;if(d.data.length<this._def.items.length)return addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&d.data.length>this._def.items.length&&(addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),c.dirty());const p=[...d.data].map((m,h)=>{const g=this._def.items[h]||this._def.rest;return g?g._parse(new ParseInputLazyPath(d,m,d.path,h)):null}).filter(m=>!!m);return d.common.async?Promise.all(p).then(m=>ParseStatus.mergeArray(c,m)):ParseStatus.mergeArray(c,p)}get items(){return this._def.items}rest(l){return new ZodTuple({...this._def,rest:l})}}ZodTuple.create=(a,l)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:a,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(l)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.object)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:d.parsedType}),INVALID;const u=[],p=this._def.keyType,m=this._def.valueType;for(const h in d.data)u.push({key:p._parse(new ParseInputLazyPath(d,h,d.path,h)),value:m._parse(new ParseInputLazyPath(d,d.data[h],d.path,h)),alwaysSet:h in d.data});return d.common.async?ParseStatus.mergeObjectAsync(c,u):ParseStatus.mergeObjectSync(c,u)}get element(){return this._def.valueType}static create(l,c,d){return c instanceof ZodType?new ZodRecord({keyType:l,valueType:c,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(d)}):new ZodRecord({keyType:ZodString.create(),valueType:l,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(c)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.map)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:d.parsedType}),INVALID;const u=this._def.keyType,p=this._def.valueType,m=[...d.data.entries()].map(([h,g],x)=>({key:u._parse(new ParseInputLazyPath(d,h,d.path,[x,"key"])),value:p._parse(new ParseInputLazyPath(d,g,d.path,[x,"value"]))}));if(d.common.async){const h=new Map;return Promise.resolve().then(async()=>{for(const g of m){const x=await g.key,f=await g.value;if(x.status==="aborted"||f.status==="aborted")return INVALID;(x.status==="dirty"||f.status==="dirty")&&c.dirty(),h.set(x.value,f.value)}return{status:c.value,value:h}})}else{const h=new Map;for(const g of m){const x=g.key,f=g.value;if(x.status==="aborted"||f.status==="aborted")return INVALID;(x.status==="dirty"||f.status==="dirty")&&c.dirty(),h.set(x.value,f.value)}return{status:c.value,value:h}}}}ZodMap.create=(a,l,c)=>new ZodMap({valueType:l,keyType:a,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(c)});class ZodSet extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.set)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:d.parsedType}),INVALID;const u=this._def;u.minSize!==null&&d.data.size<u.minSize.value&&(addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:u.minSize.value,type:"set",inclusive:!0,exact:!1,message:u.minSize.message}),c.dirty()),u.maxSize!==null&&d.data.size>u.maxSize.value&&(addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:u.maxSize.value,type:"set",inclusive:!0,exact:!1,message:u.maxSize.message}),c.dirty());const p=this._def.valueType;function m(g){const x=new Set;for(const f of g){if(f.status==="aborted")return INVALID;f.status==="dirty"&&c.dirty(),x.add(f.value)}return{status:c.value,value:x}}const h=[...d.data.values()].map((g,x)=>p._parse(new ParseInputLazyPath(d,g,d.path,x)));return d.common.async?Promise.all(h).then(g=>m(g)):m(h)}min(l,c){return new ZodSet({...this._def,minSize:{value:l,message:errorUtil.toString(c)}})}max(l,c){return new ZodSet({...this._def,maxSize:{value:l,message:errorUtil.toString(c)}})}size(l,c){return this.min(l,c).max(l,c)}nonempty(l){return this.min(1,l)}}ZodSet.create=(a,l)=>new ZodSet({valueType:a,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(l)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.function)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:c.parsedType}),INVALID;function d(h,g){return makeIssue({data:h,path:c.path,errorMaps:[c.common.contextualErrorMap,c.schemaErrorMap,getErrorMap(),errorMap].filter(x=>!!x),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:g}})}function u(h,g){return makeIssue({data:h,path:c.path,errorMaps:[c.common.contextualErrorMap,c.schemaErrorMap,getErrorMap(),errorMap].filter(x=>!!x),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:g}})}const p={errorMap:c.common.contextualErrorMap},m=c.data;if(this._def.returns instanceof ZodPromise){const h=this;return OK(async function(...g){const x=new ZodError([]),f=await h._def.args.parseAsync(g,p).catch(j=>{throw x.addIssue(d(g,j)),x}),y=await Reflect.apply(m,this,f);return await h._def.returns._def.type.parseAsync(y,p).catch(j=>{throw x.addIssue(u(y,j)),x})})}else{const h=this;return OK(function(...g){const x=h._def.args.safeParse(g,p);if(!x.success)throw new ZodError([d(g,x.error)]);const f=Reflect.apply(m,this,x.data),y=h._def.returns.safeParse(f,p);if(!y.success)throw new ZodError([u(f,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...l){return new ZodFunction({...this._def,args:ZodTuple.create(l).rest(ZodUnknown.create())})}returns(l){return new ZodFunction({...this._def,returns:l})}implement(l){return this.parse(l)}strictImplement(l){return this.parse(l)}static create(l,c,d){return new ZodFunction({args:l||ZodTuple.create([]).rest(ZodUnknown.create()),returns:c||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(d)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(l){const{ctx:c}=this._processInputParams(l);return this._def.getter()._parse({data:c.data,path:c.path,parent:c})}}ZodLazy.create=(a,l)=>new ZodLazy({getter:a,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(l)});class ZodLiteral extends ZodType{_parse(l){if(l.data!==this._def.value){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{received:c.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:l.data}}get value(){return this._def.value}}ZodLiteral.create=(a,l)=>new ZodLiteral({value:a,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(l)});function createZodEnum(a,l){return new ZodEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(l)})}class ZodEnum extends ZodType{constructor(){super(...arguments),_ZodEnum_cache.set(this,void 0)}_parse(l){if(typeof l.data!="string"){const c=this._getOrReturnCtx(l),d=this._def.values;return addIssueToContext(c,{expected:util.joinValues(d),received:c.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodEnum_cache)||__classPrivateFieldSet(this,_ZodEnum_cache,new Set(this._def.values)),!__classPrivateFieldGet(this,_ZodEnum_cache).has(l.data)){const c=this._getOrReturnCtx(l),d=this._def.values;return addIssueToContext(c,{received:c.data,code:ZodIssueCode.invalid_enum_value,options:d}),INVALID}return OK(l.data)}get options(){return this._def.values}get enum(){const l={};for(const c of this._def.values)l[c]=c;return l}get Values(){const l={};for(const c of this._def.values)l[c]=c;return l}get Enum(){const l={};for(const c of this._def.values)l[c]=c;return l}extract(l,c=this._def){return ZodEnum.create(l,{...this._def,...c})}exclude(l,c=this._def){return ZodEnum.create(this.options.filter(d=>!l.includes(d)),{...this._def,...c})}}_ZodEnum_cache=new WeakMap;ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),_ZodNativeEnum_cache.set(this,void 0)}_parse(l){const c=util.getValidEnumValues(this._def.values),d=this._getOrReturnCtx(l);if(d.parsedType!==ZodParsedType.string&&d.parsedType!==ZodParsedType.number){const u=util.objectValues(c);return addIssueToContext(d,{expected:util.joinValues(u),received:d.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodNativeEnum_cache)||__classPrivateFieldSet(this,_ZodNativeEnum_cache,new Set(util.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,_ZodNativeEnum_cache).has(l.data)){const u=util.objectValues(c);return addIssueToContext(d,{received:d.data,code:ZodIssueCode.invalid_enum_value,options:u}),INVALID}return OK(l.data)}get enum(){return this._def.values}}_ZodNativeEnum_cache=new WeakMap;ZodNativeEnum.create=(a,l)=>new ZodNativeEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(l)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.promise&&c.common.async===!1)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:c.parsedType}),INVALID;const d=c.parsedType===ZodParsedType.promise?c.data:Promise.resolve(c.data);return OK(d.then(u=>this._def.type.parseAsync(u,{path:c.path,errorMap:c.common.contextualErrorMap})))}}ZodPromise.create=(a,l)=>new ZodPromise({type:a,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(l)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(l){const{status:c,ctx:d}=this._processInputParams(l),u=this._def.effect||null,p={addIssue:m=>{addIssueToContext(d,m),m.fatal?c.abort():c.dirty()},get path(){return d.path}};if(p.addIssue=p.addIssue.bind(p),u.type==="preprocess"){const m=u.transform(d.data,p);if(d.common.async)return Promise.resolve(m).then(async h=>{if(c.value==="aborted")return INVALID;const g=await this._def.schema._parseAsync({data:h,path:d.path,parent:d});return g.status==="aborted"?INVALID:g.status==="dirty"||c.value==="dirty"?DIRTY(g.value):g});{if(c.value==="aborted")return INVALID;const h=this._def.schema._parseSync({data:m,path:d.path,parent:d});return h.status==="aborted"?INVALID:h.status==="dirty"||c.value==="dirty"?DIRTY(h.value):h}}if(u.type==="refinement"){const m=h=>{const g=u.refinement(h,p);if(d.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return h};if(d.common.async===!1){const h=this._def.schema._parseSync({data:d.data,path:d.path,parent:d});return h.status==="aborted"?INVALID:(h.status==="dirty"&&c.dirty(),m(h.value),{status:c.value,value:h.value})}else return this._def.schema._parseAsync({data:d.data,path:d.path,parent:d}).then(h=>h.status==="aborted"?INVALID:(h.status==="dirty"&&c.dirty(),m(h.value).then(()=>({status:c.value,value:h.value}))))}if(u.type==="transform")if(d.common.async===!1){const m=this._def.schema._parseSync({data:d.data,path:d.path,parent:d});if(!isValid(m))return m;const h=u.transform(m.value,p);if(h instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:c.value,value:h}}else return this._def.schema._parseAsync({data:d.data,path:d.path,parent:d}).then(m=>isValid(m)?Promise.resolve(u.transform(m.value,p)).then(h=>({status:c.value,value:h})):m);util.assertNever(u)}}ZodEffects.create=(a,l,c)=>new ZodEffects({schema:a,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:l,...processCreateParams(c)});ZodEffects.createWithPreprocess=(a,l,c)=>new ZodEffects({schema:l,effect:{type:"preprocess",transform:a},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(c)});class ZodOptional extends ZodType{_parse(l){return this._getType(l)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(l)}unwrap(){return this._def.innerType}}ZodOptional.create=(a,l)=>new ZodOptional({innerType:a,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(l)});class ZodNullable extends ZodType{_parse(l){return this._getType(l)===ZodParsedType.null?OK(null):this._def.innerType._parse(l)}unwrap(){return this._def.innerType}}ZodNullable.create=(a,l)=>new ZodNullable({innerType:a,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(l)});class ZodDefault extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l);let d=c.data;return c.parsedType===ZodParsedType.undefined&&(d=this._def.defaultValue()),this._def.innerType._parse({data:d,path:c.path,parent:c})}removeDefault(){return this._def.innerType}}ZodDefault.create=(a,l)=>new ZodDefault({innerType:a,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof l.default=="function"?l.default:()=>l.default,...processCreateParams(l)});class ZodCatch extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d={...c,common:{...c.common,issues:[]}},u=this._def.innerType._parse({data:d.data,path:d.path,parent:{...d}});return isAsync(u)?u.then(p=>({status:"valid",value:p.status==="valid"?p.value:this._def.catchValue({get error(){return new ZodError(d.common.issues)},input:d.data})})):{status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new ZodError(d.common.issues)},input:d.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(a,l)=>new ZodCatch({innerType:a,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof l.catch=="function"?l.catch:()=>l.catch,...processCreateParams(l)});class ZodNaN extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.nan){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:d.parsedType}),INVALID}return{status:"valid",value:l.data}}}ZodNaN.create=a=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(a)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d=c.data;return this._def.type._parse({data:d,path:c.path,parent:c})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.common.async)return(async()=>{const p=await this._def.in._parseAsync({data:d.data,path:d.path,parent:d});return p.status==="aborted"?INVALID:p.status==="dirty"?(c.dirty(),DIRTY(p.value)):this._def.out._parseAsync({data:p.value,path:d.path,parent:d})})();{const u=this._def.in._parseSync({data:d.data,path:d.path,parent:d});return u.status==="aborted"?INVALID:u.status==="dirty"?(c.dirty(),{status:"dirty",value:u.value}):this._def.out._parseSync({data:u.value,path:d.path,parent:d})}}static create(l,c){return new ZodPipeline({in:l,out:c,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(l){const c=this._def.innerType._parse(l),d=u=>(isValid(u)&&(u.value=Object.freeze(u.value)),u);return isAsync(c)?c.then(u=>d(u)):d(c)}unwrap(){return this._def.innerType}}ZodReadonly.create=(a,l)=>new ZodReadonly({innerType:a,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(l)});function custom(a,l={},c){return a?ZodAny.create().superRefine((d,u)=>{var p,m;if(!a(d)){const h=typeof l=="function"?l(d):typeof l=="string"?{message:l}:l,g=(m=(p=h.fatal)!==null&&p!==void 0?p:c)!==null&&m!==void 0?m:!0,x=typeof h=="string"?{message:h}:h;u.addIssue({code:"custom",...x,fatal:g})}}):ZodAny.create()}const late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(a,l={message:`Input not instance of ${a.name}`})=>custom(c=>c instanceof a,l),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:a=>ZodString.create({...a,coerce:!0}),number:a=>ZodNumber.create({...a,coerce:!0}),boolean:a=>ZodBoolean.create({...a,coerce:!0}),bigint:a=>ZodBigInt.create({...a,coerce:!0}),date:a=>ZodDate.create({...a,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap,getErrorMap,makeIssue,EMPTY_PATH,addIssueToContext,ParseStatus,INVALID,DIRTY,OK,isAborted,isDirty,isValid,isAsync,get util(){return util},get objectUtil(){return objectUtil},ZodParsedType,getParsedType,ZodType,datetimeRegex,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodTransformer:ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,custom,Schema:ZodType,ZodSchema:ZodType,late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean,onumber,optional:optionalType,ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER,ZodIssueCode,quotelessJson,ZodError});const saveToLibraryModalAtom=jotai.atom({isOpen:!1,blockId:null}),SaveToLibraryModal=()=>{const[a,l]=jotai.useAtom(saveToLibraryModalAtom),{t:c}=reactI18next.useTranslation(),{hasPermission:d}=usePermissions(),[u]=useBlocksStore(),p=useBuilderProp("uiLibraries",[]),m=React.useMemo(()=>a.blockId?lodashEs.find(u,{_id:a.blockId}):null,[u,a.blockId]),h=!!(m!=null&&m._libBlockId),g=z.object({library:z.string().min(1,{message:c("Library is required")}),name:z.string().min(1,{message:c("Name is required")}),group:z.string().min(1,{message:c("Group is required")}),description:z.string().optional(),screenshot:z.any().optional()}),x=tooltip.useForm({resolver:s(g),defaultValues:{library:"",name:(m==null?void 0:m._name)||"",group:"",description:""},mode:"onChange"}),[f,y]=React.useState(null),b=React.useRef(null),j=P=>{var M;const L=(M=P.target.files)==null?void 0:M[0];if(L){x.setValue("screenshot",L);const O=new FileReader;O.onload=()=>{y(O.result)},O.readAsDataURL(L)}},R=()=>{y(null),x.setValue("screenshot",void 0),b.current&&(b.current.value="")},k=useUpdateBlocksPropsRealtime(),v=useBuilderProp("upsertLibraryBlock",null),S=async P=>{if(!v||typeof v!="function"){console.error("Something went wrong!!");return}try{const L=await v({...P,...(m==null?void 0:m._libBlockId)&&{id:m==null?void 0:m._libBlockId}});if(L instanceof Error){sonner.toast.error(L.message);return}const{id:M}=L;k([m==null?void 0:m._id],{_libBlockId:M}),sonner.toast.success(c(h?"Library block updated":"Added to library")),l({isOpen:!1,blockId:null})}catch(L){sonner.toast.error(c("Failed to save to library")),console.error("Error saving to library:",L)}},[C,I]=React.useState([]),[w,T]=React.useState(""),[A,B]=React.useState(!1),D=P=>{x.setValue("group",P)},_=()=>{B(!0)},E=()=>{if(w){const P=w.toLowerCase().replace(/\s+/g,"-");I([...C,{id:P,name:w}]),x.setValue("group",P),T(""),B(!1)}},N=()=>{T(""),B(!1)};return jsxRuntime.jsx(tooltip.Dialog,{open:a.isOpen,onOpenChange:P=>!P&&l({isOpen:!1,blockId:null}),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"p-4 sm:max-w-[450px]",children:[jsxRuntime.jsx(tooltip.DialogHeader,{className:"pb-2",children:jsxRuntime.jsx(tooltip.DialogTitle,{children:c(h?"Update Library Block":"Save to Library")})}),jsxRuntime.jsx(tooltip.Form,{...x,children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"library",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Library")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(ChaiSelect,{height:"h-8",options:p.map(L=>({value:L.id,label:L.name})),defaultValue:P.value,onValueChange:P.onChange,placeholder:c("Select a library")})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"name",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Name")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(tooltip.Input,{className:"h-8",placeholder:c("Enter name"),...P})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"group",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Group")}),A?jsxRuntime.jsxs("div",{className:"flex space-x-1",children:[jsxRuntime.jsx(tooltip.Input,{className:"h-8",placeholder:c("Enter new group name"),value:w,onChange:L=>T(L.target.value)}),jsxRuntime.jsx(tooltip.Button,{type:"button",onClick:E,disabled:!w,size:"sm",className:"h-8",children:c("Add")}),jsxRuntime.jsx(tooltip.Button,{type:"button",onClick:N,variant:"outline",size:"sm",className:"h-8",children:c("Cancel")})]}):jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("div",{className:"flex space-x-1",children:[jsxRuntime.jsx(tooltip.FormControl,{className:"flex-1",children:jsxRuntime.jsx(ChaiSelect,{height:"h-8",options:C.map(L=>({value:L.id,label:L.name})),defaultValue:P.value,onValueChange:D,placeholder:c("Select a group")})}),d(PERMISSIONS.CREATE_LIBRARY_GROUP)&&jsxRuntime.jsx(tooltip.Button,{type:"button",variant:"outline",className:"h-8 whitespace-nowrap text-xs",onClick:_,size:"sm",children:c("Create new")})]})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Screenshot")}),jsxRuntime.jsx("div",{className:"mt-0",children:f?jsxRuntime.jsxs("div",{className:"relative h-20 w-full",children:[jsxRuntime.jsx("img",{src:f,alt:"Screenshot preview",className:"h-full w-full rounded-md border border-gray-200 object-contain"}),jsxRuntime.jsx("button",{type:"button",onClick:R,className:"absolute -right-2 -top-2 rounded-full bg-background text-foreground hover:text-destructive","aria-label":"Remove image",children:jsxRuntime.jsx(lucideReact.XCircle,{size:20})})]}):jsxRuntime.jsxs(tooltip.Label,{htmlFor:"screenshot",className:"flex h-20 w-full cursor-pointer flex-col items-center justify-center rounded-md border border-dashed border-gray-300 bg-gray-50 hover:bg-gray-100",children:[jsxRuntime.jsx("div",{className:"flex flex-col items-center justify-center py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-gray-500",children:c("Drop your image here, or click to browse")})}),jsxRuntime.jsx(tooltip.Input,{id:"screenshot",ref:b,type:"file",accept:"image/*",className:"hidden",onChange:j})]})})]}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"description",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Description")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(tooltip.Textarea,{placeholder:c("Enter description for AI"),className:"h-20 resize-none",...P})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsxs(tooltip.DialogFooter,{className:"pt-2",children:[jsxRuntime.jsx(tooltip.Button,{type:"button",variant:"outline",onClick:()=>l({isOpen:!1,blockId:null}),size:"sm",children:c("Cancel")}),jsxRuntime.jsx(tooltip.Button,{type:"submit",onClick:x.handleSubmit(S),disabled:!x.formState.isValid||x.formState.isSubmitting,size:"sm",children:c(h?"Update":"Save")})]})]})})]})})},useCanMove=()=>{const[a]=useBlocksStore();return(l,c)=>{var p;const d=(p=lodashEs.find(a,{_id:c}))==null?void 0:p._type,u=lodashEs.first(l.map(m=>{var h;return(h=lodashEs.find(a,{_id:m}))==null?void 0:h._type}));return canAcceptChildBlock(d,u)}},ListTree=()=>{const[treeData]=jotai.useAtom(treeDSBlocks),[ids,setIds]=useSelectedBlockIds(),[cutBlocksIds]=useCutBlockIds(),[,setHiddenBlocks]=useHiddenBlockIds(),updateBlockProps=useUpdateBlocksProps(),[,setStyleBlocks]=useSelectedStylingBlocks(),{moveBlocks}=useBlocksStoreUndoableActions(),canMove=useCanMove(),treeRef=React.useRef(null),[,setTreeRef]=jotai.useAtom(treeRefAtom),{t}=reactI18next.useTranslation(),[parentContext,setParentContext]=React.useState(null),clearSelection=()=>{setIds([]),setStyleBlocks([])},filteredTreeData=React.useMemo(()=>{const a=(c,d)=>c.filter(u=>!d.includes(u._id)).map(u=>({...u,children:u.children?a(u.children,d):[]}));return[...a(treeData,cutBlocksIds),{_type:getSplitClasses.ROOT_TEMP_KEY,_id:getSplitClasses.ROOT_TEMP_KEY,children:[]}]},[treeData,cutBlocksIds]),onRename=({id:a,name:l,node:c})=>{updateBlockProps([a],{_name:l},c.data._name)},onMove=({dragIds:a,parentId:l,index:c})=>{canMove(a,l)&&moveBlocks(a,l,c)},onSelect=a=>{if(a.length===0)return;const l=a[0]?a[0].id:"";setStyleBlocks([]),setIds([l])},onContextMenu=a=>{var d;a.preventDefault(),parentContext&&setParentContext(null);const l=a.target,c=l.getAttribute("data-node-id")||((d=l.closest("[data-node-id]"))==null?void 0:d.getAttribute("data-node-id"));c?(setStyleBlocks([]),setIds([c])):(setStyleBlocks([]),setIds([]),setParentContext({x:a.clientX,y:a.clientY}))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:a,dragNodes:l})=>{var c;return(a==null?void 0:a.data._type)===getSplitClasses.ROOT_TEMP_KEY||!canAcceptChildBlock(a==null?void 0:a.data._type,(c=l[0])==null?void 0:c.data._type)},[],300),handleKeyDown=e=>{if(!treeRef.current)return;const tree=treeRef.current,selectedNode=tree.selectedNodes[0];if(!selectedNode)return;setIds[selectedNode.id],setStyleBlocks([]);const isLeaf=!selectedNode.isInternal,isClosed=!selectedNode.isOpen,isOpen=selectedNode.isOpen,shortcut=defaultShortcuts.find(s=>s.key===e.key&&(!s.when||eval(s.when)));if(shortcut)switch(e.preventDefault(),shortcut.command){case"selectNext":selectNext(tree);break;case"selectPrev":selectPrev(tree);break;case"selectParent":selectParent(tree,isLeaf||isClosed);break;case"close":close(tree,isOpen);break;case"open":open(tree,isClosed);break;case"selectFirst":selectFirst(tree);break;case"selectLast":selectLast(tree);break}};React.useEffect(()=>{const a=()=>{treeRef.current&&setTreeRef(treeRef.current)};a();const l=new MutationObserver(a);return l.observe(document.body,{childList:!0,subtree:!0}),()=>l.disconnect()},[setTreeRef]);const{hasPermission}=usePermissions();return lodashEs.isEmpty(treeData)?jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("This page is empty"),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),hasPermission(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsxs(tooltip.Button,{disabled:!hasPermission(PERMISSIONS.ADD_BLOCK),onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),variant:"default",size:"sm",children:["+ ",t("Add Block")]})]})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:Functions.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxs("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto text-sm",onKeyDown:a=>{treeRef.current.isEditing||handleKeyDown(a)},children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground",children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{onClick:()=>setHiddenBlocks([]),variant:"outline",className:"h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",size:"sm",children:jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Show hidden blocks")})]}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"h-fit p-1",onClick:()=>{var a;return(a=treeRef==null?void 0:treeRef.current)==null?void 0:a.openAll()},variant:"outline",size:"sm",children:jsxRuntime.jsx(lucideReact.ChevronsDown,{size:14})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Expand all")})]}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"h-fit p-1",onClick:()=>{var a;return(a=treeRef==null?void 0:treeRef.current)==null?void 0:a.closeAll()},variant:"outline",size:"sm",children:jsxRuntime.jsx(lucideReact.ChevronsUp,{size:14})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Collapse all")})]})]}),jsxRuntime.jsx("div",{className:"group relative z-[9999] ml-5 w-full cursor-pointer",children:jsxRuntime.jsx("div",{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{position:0}),className:"h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsx("div",{className:"absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500",children:jsxRuntime.jsx(lucideReact.PlusIcon,{className:"h-3 w-3 stroke-[3] text-white"})})})}),jsxRuntime.jsx(reactArborist.Tree,{ref:treeRef,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",rowClassName:"flex items-center h-full border-b border-transparent",selection:ids[0]||"",onRename,openByDefault:!1,onMove,data:[...filteredTreeData],renderCursor:DefaultCursor,onSelect,childrenAccessor:a=>a.children,width:"100%",rowHeight:28,renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})]})}),jsxRuntime.jsx(PasteAtRootContextMenu,{parentContext,setParentContext}),jsxRuntime.jsx(SaveToLibraryModal,{})]})},BorderRadiusInput=({value:a,onChange:l,disabled:c})=>{const d=lodashEs.debounce(u=>l(u),200);return jsxRuntime.jsx("input",{type:"range",min:"0",step:"1",max:"30",disabled:c,defaultValue:a.replace("px",""),onChange:u=>d(u.target.value),className:"flex-1 cursor-pointer"})},ColorPickerInput=({value:a,onChange:l})=>{const c=lodashEs.debounce(d=>l(d),200);return jsxRuntime.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:a},children:jsxRuntime.jsx("input",{type:"color",value:a.startsWith("#")?a:"#000000",onChange:d=>{const u=d.target.value;/^#[0-9A-F]{6}$/i.test(u)&&c(u)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},FontSelector=({label:a,value:l,onChange:c})=>{const d=runtime.useRegisteredFonts();return jsxRuntime.jsxs("div",{className:"space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:lodashEs.startCase(a)}),jsxRuntime.jsx("select",{className:"mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:l,onChange:u=>c(u.target.value),children:d.map(u=>jsxRuntime.jsx("option",{value:u.family,children:u.family},u.family))})]})},ThemeConfigPanel=React__namespace.memo(({className:a=""})=>{const[l]=useDarkMode(),[c,d]=React__namespace.useState(""),u=useBuilderProp("themePresets",[]),p=useBuilderProp("themePanelComponent",null),{hasPermission:m}=usePermissions(),[h,g]=useTheme(),x=useThemeOptions(),{t:f}=reactI18next.useTranslation(),y=S=>{d(S)},b=()=>{const S=u.find(C=>Object.keys(C)[0]===c);if(S){const C=Object.values(S)[0];C&&typeof C=="object"&&"fontFamily"in C&&"borderRadius"in C&&"colors"in C?g(C):console.error("Invalid preset structure:",C)}else console.error("Preset not found:",c)},j=web.useDebouncedCallback((S,C)=>{g(()=>({...h,fontFamily:{...h.fontFamily,[S.replace(/font-/g,"")]:C}}))},[h],200),R=web.useDebouncedCallback(S=>{g(()=>({...h,borderRadius:`${S}px`}))},[h],200),k=web.useDebouncedCallback((S,C)=>{g(()=>{const I=lodashEs.get(h,`colors.${S}`);return l?lodashEs.set(I,1,C):lodashEs.set(I,0,C),{...h,colors:{...h.colors,[S]:I}}})},[h],200),v=S=>jsxRuntime.jsx("div",{className:"grid grid-cols-1",children:Object.entries(S.items).map(([C])=>{const I=lodashEs.get(h,`colors.${C}.${l?1:0}`);return jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-x-2",children:[jsxRuntime.jsx(ColorPickerInput,{value:I,onChange:w=>k(C,w)}),jsxRuntime.jsx(tooltip.Label,{className:"text-xs font-normal leading-tight text-slate-600",children:C.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(" ")+(!C.toLowerCase().includes("foreground")&&!C.toLowerCase().includes("border")&&!C.toLowerCase().includes("input")&&!C.toLowerCase().includes("ring")&&!C.toLowerCase().includes("background")?" Background":"")})]},C)})});return m("edit_theme")?jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsxs("div",{className:Functions.cn("no-scrollbar h-full w-full overflow-y-auto",a),children:[u.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-2 py-2",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Presets")}),jsxRuntime.jsxs("select",{value:c,onChange:S=>y(S.target.value),className:"w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[jsxRuntime.jsx("option",{value:"",children:"Select preset"}),Array.isArray(u)&&u.map(S=>jsxRuntime.jsx("option",{value:Object.keys(S)[0],children:lodashEs.capitalize(Object.keys(S)[0])},Object.keys(S)[0]))]})]}),jsxRuntime.jsx("div",{className:"flex w-[30%] items-end",children:jsxRuntime.jsx(tooltip.Button,{className:"w-full text-sm",disabled:c==="",variant:"default",onClick:b,children:f("Apply")})})]}),jsxRuntime.jsxs("div",{className:Functions.cn("space-y-2",a),children:[(x==null?void 0:x.fontFamily)&&jsxRuntime.jsx("div",{className:"grid gap-4",children:Object.entries(x.fontFamily).map(([S,C])=>jsxRuntime.jsx(FontSelector,{label:S,value:h.fontFamily[S.replace(/font-/g,"")]||C[Object.keys(C)[0]],onChange:I=>j(S,I)},S))}),(x==null?void 0:x.borderRadius)&&jsxRuntime.jsxs("div",{className:"space-y-0.5 py-3",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Border Radius")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 py-2",children:[jsxRuntime.jsx(BorderRadiusInput,{value:h.borderRadius,onChange:R}),jsxRuntime.jsx("span",{className:"w-12 text-sm",children:h.borderRadius})]})]}),(x==null?void 0:x.colors)&&jsxRuntime.jsxs("div",{className:"mt-4 space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Colors")}),jsxRuntime.jsx("div",{className:"w-full space-y-4 pt-2",children:x.colors.map(S=>v(S))},l?"dark":"light")]})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),p&&jsxRuntime.jsx("div",{className:"absolute bottom-4 w-full",children:React__namespace.createElement(p)})]}):jsxRuntime.jsx("div",{className:"relative w-full",children:jsxRuntime.jsx("div",{className:Functions.cn("no-scrollbar h-full w-full overflow-y-auto text-center",a),children:jsxRuntime.jsx("div",{className:"mt-10 h-full items-center justify-center gap-2 text-muted-foreground",children:jsxRuntime.jsx("p",{className:"text-sm",children:"You don't have permission to edit the theme. Please contact your administrator to get access."})})})})}),Core="Core",Import="Import",Breakpoints="Breakpoints",Clear="Clear",Cancel="Cancel",Yes="Yes",Preview="Preview",Settings="Settings",Styling="Styling",Remove="Remove",Choose="Choose",Cut="Cut",Copy="Copy",Paste="Paste",Delete="Delete",classes="classes",Theme="Theme",Outline="Outline",Copied="Copied",Stop="Stop",Edit="Edit",Tag="Tag",Value="Value",Images="Images",Library="Library",Blocks="Blocks",Basic="Basic",Media="Media",Advanced="Advanced",Form="Form",Groups="Groups",Accordions="Accordions",Buttons="Buttons",Layouts="Layouts",FAQ="FAQ",Hero="Hero",Features="Features",Footer="Footer",Navbar="Navbar",Icons="Icons",Testimonials="Testimonials",Blog="Blog",Saved="Saved",Unsaved="Unsaved",Randomize="Randomize",theme_config={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},Undo="Undo",Redo="Redo",Duplicate="Duplicate",Close="Close",Selected="Selected",Select="Select",Attributes="Attributes",apply="apply",presets="presets",Orientation="Orientation",Color="Color",Upload="Upload",lngEn={"Add block":"Add Block","Add blocks":"Add blocks","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core,"Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import,"Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints,Clear,"Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel,Yes,Preview,Settings,Styling,"Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove,"You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose,"Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut,Copy,Paste,Delete,"Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes,Theme,Outline,"Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied,"Enter Classes":"Enter classes separated by space","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop,"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit,"Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag,Value,"Background Image":"Background Image","Enter image URL":"Enter image URL","Replace image":"Replace image","Choose image":"Choose image",Images,Library,Blocks,Basic,Media,Advanced,Form,"Choose Icon or SVG":"Choose an icon or enter SVG",Groups,"UI Libraries":"UI Libraries",Accordions,Buttons,Layouts,"Choose Library":"Choose library","No Library Found":"No library found.",FAQ,Hero,Features,Footer,Navbar,Icons,Testimonials,Blog,"Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved,Unsaved,"Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Fix grammar":"Fix grammar","Make longer":"Make longer","Make shorter":"Make shorter","Add emojis":"Add emojis",Randomize,"Edit Block":"Edit Block","AI Assistant":"AI Assistant","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)"},"flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config,web_blocks,"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo,Redo,Duplicate,"Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close,"Coming soon":"Coming soon",Selected,Select,"Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes,"Apply Presets":"Apply Presets",apply,presets,"Global presets":"Global presets",Orientation,Color,"Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload,"Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Clear search":"Clear search","No results found for":"No results found for","Search {pageTypeName}":"Search {pageTypeName}"};i18n.use(reactI18next.initReactI18next).init({resources:{en:{translation:lngEn}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const QUICK_PROMPTS=[{name:"Improve writing",icon:lucideReact.FileEdit,prompt:"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."},{name:"Replace placeholder content",icon:lucideReact.Recycle,prompt:"Discard current placeholder content and replace with meaningful relevant content."},{name:"Fix grammar",icon:reactIcons.CheckIcon,prompt:"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."},{name:"Make longer",icon:reactIcons.ArrowUpIcon,prompt:"Make all text elements longer."},{name:"Make shorter",icon:reactIcons.ArrowDownIcon,prompt:"Make all text elements shorter."},{name:"Add emojis",icon:lucideReact.SmileIcon,prompt:"Add emojis to text elements if relevant."},{name:"Randomize",icon:lucideReact.ShuffleIcon,prompt:"Randomize all text elements."}];function QuickPrompts({onClick:a}){const{loading:l}=useAskAi(),{t:c}=reactI18next.useTranslation(),{selectedLang:d,fallbackLang:u}=useLanguages(),p=[...QUICK_PROMPTS];return d&&d!==u&&p.splice(0,0,{name:`Translate to ${lodashEs.get(LANGUAGES,d,d)}`,icon:lucideReact.Languages,prompt:`Translate the content to ${lodashEs.get(LANGUAGES,d,d)}. Maintain same tone, style and length.`}),jsxRuntime.jsx("div",{className:l?"pointer-events-none opacity-50":"",children:jsxRuntime.jsx("ul",{className:"space-y-2",children:p.map(({name:m,icon:h,subMenus:g,prompt:x})=>g?jsxRuntime.jsxs(tooltip.Popover,{children:[jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsx(h,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:m})]},m)}),jsxRuntime.jsx(tooltip.PopoverContent,{side:"right",children:jsxRuntime.jsx("ul",{children:jsxRuntime.jsx("li",{children:"Happy"})})})]}):jsxRuntime.jsxs("li",{onClick:()=>a(x),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsx(h,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:c(m)})]},m))})})}const AIUserPrompt=({blockId:a})=>{const{t:l}=reactI18next.useTranslation(),{askAi:c,loading:d,error:u}=useAskAi(),[p,m]=React.useState(""),[h,g]=React.useState(!0),[x,f]=React.useState(),y=React.useRef(null),b=React.useRef(null);React.useEffect(()=>{var R;(R=y.current)==null||R.focus()},[]);const j=R=>{const{usage:k}=R||{};!u&&k&&f(k),b.current=setTimeout(()=>f(void 0),1e4),u||m("")};return jsxRuntime.jsxs("div",{className:"",children:[jsxRuntime.jsxs("div",{onClick:()=>g(!h),className:"flex cursor-pointer items-center justify-between border-t border-border py-2 text-sm font-medium hover:underline",children:[jsxRuntime.jsx("span",{children:l("Ask AI")}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(h?"rotate-180":"")})})]}),h&&a?jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsx(tooltip.Textarea,{ref:y,value:p,onChange:R=>m(R.target.value),placeholder:l("Ask AI to edit content"),className:"w-full",rows:3,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),b.current&&clearTimeout(b.current),f(void 0),c("content",a,p,j))}}),jsxRuntime.jsxs("div",{className:"my-2 flex items-center gap-2",children:[d?null:jsxRuntime.jsx(tooltip.Button,{disabled:p.trim().length<5||d,onClick:()=>{b.current&&clearTimeout(b.current),f(void 0),c("content",a,p,j)},variant:"default",className:"w-fit",size:"sm",children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),l("Generating... Please wait...")]}):l("Edit with AI")}),d?jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs(tooltip.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsx("p",{className:"text-xs",children:l("Generating... Please wait...")})]}),jsxRuntime.jsx(tooltip.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:l("Stop")})]}):null]}),x?jsxRuntime.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxs("span",{children:[l("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsx(Countdown,{})]})}):null,jsxRuntime.jsx("div",{className:"max-w-full",children:u&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx(QuickPrompts,{onClick:R=>{b.current&&clearTimeout(b.current),f(void 0),c("content",a,R,j)}})]}):h?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"mx-auto text-3xl text-muted-foreground"}),jsxRuntime.jsx("h1",{children:l("Please select a block to Ask AI")})]})}):null]})},AISetContext=()=>{const{t:a}=reactI18next.useTranslation(),l=useBuilderProp("aiContext",""),[c,d]=React.useState(l),u=React.useRef(null),p=useBuilderProp("saveAiContextCallback",lodashEs.noop),[m,h]=React.useState(!1),[g,x]=React.useState(null),[,f]=React.useState(!1),y=React.useRef(null);React.useEffect(()=>{l&&d(l)},[l]);const b=async()=>{try{h(!0),x(null),await p(c),sonner.toast.success(a("Updated AI Context")),y.current.click()}catch(j){x(j)}finally{h(!1)}};return jsxRuntime.jsx(tooltip.Accordion,{onValueChange:j=>{f(j!=="")},type:"single",collapsible:!0,children:jsxRuntime.jsxs(tooltip.AccordionItem,{value:"set-context",className:"border-none",children:[jsxRuntime.jsx(tooltip.AccordionTrigger,{ref:y,className:"border-0 border-border py-2",children:jsxRuntime.jsx("div",{className:"flex w-full items-center justify-between",children:jsxRuntime.jsx("span",{className:"font-medium",children:a("AI Context")})})}),jsxRuntime.jsxs(tooltip.AccordionContent,{children:[jsxRuntime.jsx(tooltip.Textarea,{ref:u,value:c,onChange:j=>d(j.target.value),placeholder:a("Tell about this page eg this page is about"),className:"mt-1 w-full",rows:10,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b())}}),l.trim().length===0?jsxRuntime.jsx("p",{className:"mt-2 text-xs text-gray-500",children:a("Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.")}):null,jsxRuntime.jsxs("div",{className:"mt-2 flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{disabled:c.trim().length<5,onClick:()=>b(),variant:"default",className:"w-fit",size:"sm",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),a("Saving... Please wait...")]}):a("Save")}),l.trim().length>0?jsxRuntime.jsxs(tooltip.AlertDialog,{children:[jsxRuntime.jsx(tooltip.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{disabled:l.trim().length===0,variant:"ghost",className:"w-fit",size:"sm",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),a("Deleting... Please wait...")]}):a("Delete")})}),jsxRuntime.jsxs(tooltip.AlertDialogContent,{children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{children:[jsxRuntime.jsxs(tooltip.AlertDialogTitle,{children:[a("Delete context")," ?"]}),jsxRuntime.jsx(tooltip.AlertDialogDescription,{})]}),jsxRuntime.jsxs(tooltip.AlertDialogFooter,{children:[jsxRuntime.jsx(tooltip.AlertDialogCancel,{children:a("Cancel")}),jsxRuntime.jsx(tooltip.AlertDialogAction,{onClick:()=>{d(""),b()},children:a("Yes, Delete")})]})]})]}):null]}),jsxRuntime.jsx("div",{className:"mt-2 max-w-full",children:g&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:g.message})})]})]})})},AskAI=()=>{const[a]=useSelectedBlockIds();return jsxRuntime.jsxs("div",{className:"no-scrollbar mt-2 flex-1 overflow-y-auto",children:[jsxRuntime.jsx(AISetContext,{}),jsxRuntime.jsx(AIUserPrompt,{blockId:lodashEs.first(a)})]})};function DarkMode(){const[a,l]=useDarkMode();return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(reactIcons.SunIcon,{className:"size-4 shrink-0"}),jsxRuntime.jsx(tooltip.Switch,{id:"dark-mode-switch",checked:a,onCheckedChange:()=>{l(!a)},className:`${a?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:jsxRuntime.jsx("span",{"aria-hidden":"true",className:`${a?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})}),jsxRuntime.jsx(lucideReact.Moon,{className:"ml-3 size-4 shrink-0",size:16})]})}const UndoRedo=()=>{const{hasUndo:a,hasRedo:l,undo:c,redo:d}=useUndoManager();return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{disabled:!a(),size:"sm",onClick:c,className:"rounded-full",variant:"ghost",children:jsxRuntime.jsx(reactIcons.ResetIcon,{})}),jsxRuntime.jsx(tooltip.Button,{disabled:!l(),onClick:d,size:"sm",className:"rounded-full",variant:"ghost",children:jsxRuntime.jsx(reactIcons.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function getFromQueryParams(a){var c;return(c=new URLSearchParams(window.location.search).get("flags"))==null?void 0:c.includes(a)}const FEATURE_TOGGLES={dnd:getFromQueryParams("dnd"),aiChat:getFromQueryParams("ai-chat")},setDebugLogs=a=>{},getParentNodeIds=(a,l)=>{const c=[];let d=lodashEs.find(a,{_id:l}),u=lodashEs.get(d,"_parent","");for(;lodashEs.isString(u)&&!lodashEs.isEmpty(u);)c.push(d==null?void 0:d._parent),d=lodashEs.find(a,{_id:u}),u=d==null?void 0:d._parent;return lodashEs.flatten(c)},expandedIdsAtom=jotai.atom([]),useExpandTree=()=>{const[a]=useSelectedBlockIds(),l=jotai.useAtomValue(presentBlocksAtom),[,c]=jotai.useAtom(expandedIdsAtom);React.useEffect(()=>{let d=[];const u=lodashEs.first(a);lodashEs.isString(u)&&(d=[u,...getParentNodeIds(l,u)]),c(d)},[a,l,c])},CHAI_BUILDER_PANELS={},registerChaiSidebarPanel=(a,l)=>{lodashEs.has(CHAI_BUILDER_PANELS,a)&&console.warn(`Panel ${a} already registered. Overriding...`),lodashEs.set(CHAI_BUILDER_PANELS,a,{id:a,...l})},useChaiSidebarPanels=a=>React.useMemo(()=>lodashEs.filter(lodashEs.values(CHAI_BUILDER_PANELS),l=>l.position===a),[a]),DefaultTopBar=()=>jsxRuntime.jsx("div",{children:"TopBar"}),TOP_BAR={component:DefaultTopBar},registerChaiTopBar=a=>{TOP_BAR.component=a},useTopBarComponent=()=>React.useMemo(()=>TOP_BAR.component,[]);function usePubSub(a,l){React.useEffect(()=>{const c=pubsub.subscribe(a,l);return()=>c()},[a,l])}function AIChatPanel(){const[a,l]=React.useState([]),[c,d]=React.useState(""),[u,p]=React.useState(!1),[m,h]=React.useState(null),g=React.useRef(null),x=React.useRef(null),f=React.useRef(null);React.useEffect(()=>{var v;(v=x.current)==null||v.scrollIntoView({behavior:"smooth"})},[a]),React.useEffect(()=>{f.current&&(f.current.style.height="auto",f.current.style.height=`${Math.min(f.current.scrollHeight,120)}px`)},[c]);const y=async()=>{if(!c.trim()&&!m)return;const v={id:Date.now().toString(),role:"user",content:c,timestamp:new Date};l(S=>[...S,v]),d(""),p(!0),setTimeout(()=>{const S={id:(Date.now()+1).toString(),role:"assistant",content:"This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",timestamp:new Date};l(C=>[...C,S]),p(!1),h(null)},1500)},b=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),y())},j=v=>{var C;const S=(C=v.target.files)==null?void 0:C[0];if(S){const I=new FileReader;I.onload=w=>{var T;h((T=w.target)==null?void 0:T.result)},I.readAsDataURL(S)}},R=()=>{var v;(v=g.current)==null||v.click()},k=()=>{h(null),g.current&&(g.current.value="")};return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col rounded-lg bg-background shadow-sm",children:[jsxRuntime.jsx(tooltip.ScrollArea,{className:"flex-1 p-3",children:a.length===0?jsxRuntime.jsxs("div",{className:"mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Sparkles,{className:"mb-2 h-8 w-8 text-primary/50"}),jsxRuntime.jsx("p",{className:"text-sm",children:"Ask me anything to get started"})]}):jsxRuntime.jsxs("div",{className:"space-y-4",children:[a.map(v=>jsxRuntime.jsxs("div",{className:cn("flex max-w-full gap-2",v.role==="assistant"?"items-start":"items-start justify-end"),children:[v.role==="assistant"&&jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary/10",children:jsxRuntime.jsx(lucideReact.Sparkles,{className:"h-3 w-3 text-primary"})}),jsxRuntime.jsx("div",{className:cn("rounded-lg px-3 py-2 text-sm",v.role==="assistant"?"bg-muted text-foreground":"bg-primary text-primary-foreground"),children:v.content}),v.role==="user"&&jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary",children:jsxRuntime.jsx("span",{className:"text-xs text-primary-foreground",children:"You"})})]},v.id)),u&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary/10",children:jsxRuntime.jsx(lucideReact.Sparkles,{className:"h-3 w-3 text-primary"})}),jsxRuntime.jsx("div",{className:"rounded-lg bg-muted px-3 py-2",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),jsxRuntime.jsx("div",{ref:x})]})}),m&&jsxRuntime.jsx("div",{className:"px-3 pt-2",children:jsxRuntime.jsxs("div",{className:"relative h-20 w-20 overflow-hidden rounded-md",children:[jsxRuntime.jsx("img",{src:m||"/placeholder.svg",alt:"Attachment",className:"h-full w-full object-cover"}),jsxRuntime.jsx(tooltip.Button,{size:"icon",variant:"destructive",className:"absolute right-0 top-0 h-5 w-5 rounded-full p-0",onClick:k,children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3",children:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsxs("div",{className:"relative flex-1",children:[jsxRuntime.jsx(tooltip.Textarea,{ref:f,value:c,onChange:v=>d(v.target.value),onKeyDown:b,placeholder:"Ask something...",className:"max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"}),jsxRuntime.jsx("input",{type:"file",ref:g,onChange:j,accept:"image/*",className:"hidden"}),jsxRuntime.jsx(tooltip.Button,{size:"icon",variant:"ghost",className:"absolute bottom-2 right-2 h-6 w-6",onClick:R,children:jsxRuntime.jsx(lucideReact.Image,{className:"h-4 w-4 text-muted-foreground"})})]}),jsxRuntime.jsxs(tooltip.Button,{size:"sm",className:"h-10 px-3",onClick:y,disabled:u||!c.trim()&&!m,children:[jsxRuntime.jsx(lucideReact.Send,{className:"mr-1 h-4 w-4"}),"Send"]})]})})]})}const AiAssistant=()=>{const a=useAiAssistant(),[l]=useRightPanel(),c=useBuilderProp("askAiCallBack",null),{t:d}=reactI18next.useTranslation(),{hasPermission:u}=usePermissions();return!c||!u(PERMISSIONS.EDIT_BLOCK)?null:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(tooltip.Label,{htmlFor:"ai-assistant",className:"flex items-center gap-x-1 text-sm text-yellow-600",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"w-4"}),d("AI Assistant")]}),jsxRuntime.jsx(tooltip.Switch,{className:"scale-90",checked:l==="ai",onCheckedChange:p=>{a(p)},id:"ai-assistant"})]})},ClearCanvas=()=>{const{t:a}=reactI18next.useTranslation(),{setNewBlocks:l}=useBlocksStoreUndoableActions(),[,c]=useSelectedBlockIds(),[,d]=useSelectedStylingBlocks(),u=React.useCallback(()=>{l([]),c([]),d([])},[l]);return jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(tooltip.AlertDialog,{children:[jsxRuntime.jsx(tooltip.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(tooltip.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[jsxRuntime.jsx(reactIcons.EraserIcon,{})," ",a("Clear")]})}),jsxRuntime.jsxs(tooltip.AlertDialogContent,{className:"border-border",children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{children:[jsxRuntime.jsx(tooltip.AlertDialogTitle,{className:"text-foreground",children:a("Clear whole canvas? ")}),jsxRuntime.jsx(tooltip.AlertDialogDescription,{children:a("Are you sure you want to clear the page?")})]}),jsxRuntime.jsxs(tooltip.AlertDialogFooter,{children:[jsxRuntime.jsx(tooltip.AlertDialogCancel,{className:"text-foreground",children:a("Cancel")}),jsxRuntime.jsx(tooltip.AlertDialogAction,{onClick:u,children:a("Yes")})]})]})]})})},DataBinding=()=>{const a=usePageExternalData(),[l,c]=jotai.useAtom(dataBindingActiveAtom),{t:d}=reactI18next.useTranslation();return lodashEs.isEmpty(a)?null:jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"rounded-full",variant:"ghost",onClick:()=>c(!l),children:jsxRuntime.jsx(lucideReact.DatabaseZapIcon,{className:Functions.cn("h-4 w-4",l?"text-green-500":"text-gray-500")})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:d("Toggle Data Binding")})})]})})},CanvasTopBar=()=>{const a=useBuilderProp("darkMode",!0),l=flagged.useFeature("aiChat"),[c]=useCanvasZoom();return jsxRuntime.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2",children:[jsxRuntime.jsxs("div",{className:"flex h-full space-x-2",children:[jsxRuntime.jsx(Breakpoints$1,{canvas:!0,openDelay:400}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"}),a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(DarkMode,{}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"})]}):null,jsxRuntime.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[jsxRuntime.jsx(reactIcons.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",jsxRuntime.jsxs("div",{className:"text-xs leading-3",children:[lodashEs.round(c,0),"%"]})]}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"}),jsxRuntime.jsx(UndoRedo,{}),jsxRuntime.jsx(DataBinding,{})]}),jsxRuntime.jsxs("div",{className:"flex h-full items-center space-x-2",children:[jsxRuntime.jsx(ClearCanvas,{}),l?null:jsxRuntime.jsx(AiAssistant,{})]})]})},AddBlocksDialog=()=>{const{t:a}=reactI18next.useTranslation(),[l,c]=React.useState(""),[d,u]=React.useState(-1),[p,m]=React.useState(!1);return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,h=>{c(h?h._id:null),u(isNaN(h==null?void 0:h.position)?-1:h==null?void 0:h.position),m(!0)}),usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK,()=>{c(""),u(-1),m(!1)}),jsxRuntime.jsx(tooltip.AlertDialog,{open:p,onOpenChange:()=>p?m(!1):"",children:jsxRuntime.jsxs(tooltip.AlertDialogContent,{className:"max-w-5xl overflow-hidden border-border",children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsx(tooltip.AlertDialogTitle,{className:"text-foreground",children:a("Add blocks")}),jsxRuntime.jsx("button",{onClick:()=>m(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:jsxRuntime.jsx(AddBlocksPanel,{parentId:l,position:d,showHeading:!1})})]})})},AttrsEditor=React.memo(function a({preloadedAttributes:l=[],onAttributesChange:c}){const[d,u]=React.useState([]),[p,m]=React.useState(""),[h,g]=React.useState(""),[x,f]=React.useState(null),[y,b]=React.useState(""),j=React.useRef(null),R=React.useRef(null),k=usePageExternalData();React.useEffect(()=>{u(l)},[l]);const v=()=>{if(p.startsWith("@")){b("Attribute keys cannot start with '@'");return}if(p){const A=[...d,{key:p,value:h}];c(A),u(d),m(""),g(""),b("")}},S=A=>{const B=d.filter((D,_)=>_!==A);c(B),u(B)},C=A=>{f(A),m(d[A].key),g(d[A].value)},I=()=>{if(p.startsWith("@")){b("Attribute keys cannot start with '@'");return}if(x!==null&&p){const A=[...d];A[x]={key:p,value:h},c(A),u(A),f(null),m(""),g(""),b("")}},w=A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),x!==null?I():v())},T=React.useCallback(A=>{const B=E=>/[.,!?;:]/.test(E),D=(E,N,P)=>{let L="",M="";const O=N>0?E[N-1]:"",Z=N<E.length?E[N]:"";return N>0&&(O==="."||!B(O)&&O!==" ")&&(L=" "),N<E.length&&!B(Z)&&Z!==" "&&(M=" "),{text:L+P+M,prefixLength:L.length,suffixLength:M.length}},_=R.current;if(_){const E=_.selectionStart||0,N=_.value||"",P=_.selectionEnd||E;if(P>E){const V=`{{${A}}}`,{text:U}=D(N,E,V),$=N.slice(0,E)+U+N.slice(P);g($);return}const M=`{{${A}}}`,{text:O}=D(N,E,M),Z=N.slice(0,E)+O+N.slice(E);g(Z)}},[]);return jsxRuntime.jsxs("div",{className:"flex max-h-full flex-1 flex-col",children:[jsxRuntime.jsxs("form",{onSubmit:A=>{A.preventDefault(),x!==null?I():v()},className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"attrKey",className:"text-[11px] font-normal leading-tight text-slate-600",children:"Key"}),jsxRuntime.jsx(tooltip.Input,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:j,value:p,onChange:A=>m(A.target.value),placeholder:"Enter Key",className:"py-0 text-xs font-normal leading-tight placeholder:text-slate-400"})]}),jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"attrValue",className:"text-[11px] font-normal text-slate-600",children:"Value"}),!lodashEs.isEmpty(k)&&jsxRuntime.jsx(NestedPathSelector,{data:k,onSelect:T})]}),jsxRuntime.jsx(tooltip.Textarea,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",rows:2,ref:R,value:h,onChange:A=>g(A.target.value),onKeyDown:w,placeholder:"Enter Value",className:"text-xs font-normal leading-tight placeholder:text-slate-400"})]})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(tooltip.Button,{type:"submit",disabled:!p.length,variant:"default",size:"sm",className:"h-8 w-24 text-xs",children:x!==null?"Save":"Add"})}),y&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:y})]}),jsxRuntime.jsx("div",{className:"space-y-1 py-4",children:d.map((A,B)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[jsxRuntime.jsxs("div",{className:"flex flex-col text-xs leading-tight",children:[jsxRuntime.jsx("span",{className:"truncate text-[12px] font-light text-muted-foreground",children:A.key}),jsxRuntime.jsx("span",{className:"max-w-[200px] text-wrap font-normal",children:A.value.toString()})]}),jsxRuntime.jsxs("div",{className:"flex-shrink-0 text-slate-400",children:[jsxRuntime.jsx(tooltip.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(B),children:jsxRuntime.jsx(lucideReact.Edit2,{className:"h-3 w-3"})}),jsxRuntime.jsx(tooltip.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>S(B),children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})]},B))})]})}),BlockAttributesEditor=React__namespace.memo(()=>{const a=useSelectedBlock(),[l,c]=React.useState([]),[d]=useSelectedStylingBlocks(),u=useUpdateBlocksProps(),p=`${lodashEs.get(d,"0.prop")}_attrs`;React__namespace.useEffect(()=>{const h=lodashEs.map(lodashEs.get(a,p),(g,x)=>({key:x,value:g}));lodashEs.isEmpty(h)?c([]):c(h)},[lodashEs.get(a,p)]);const m=React__namespace.useCallback((h=[])=>{const g={};lodashEs.forEach(h,x=>{lodashEs.isEmpty(x.key)||lodashEs.set(g,x.key,x.value)}),u([lodashEs.get(a,"_id")],{[p]:g})},[a,u,p]);return jsxRuntime.jsx("div",{className:"flex-col gap-y-2",children:jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(AttrsEditor,{preloadedAttributes:l,onAttributesChange:m})})})})});function BlockAttributesToggle(){const{t:a}=reactI18next.useTranslation(),[l,c]=React.useState(!0),[d]=useSelectedStylingBlocks();return lodashEs.isEmpty(d)?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{onClick:()=>c(!l),className:"flex cursor-pointer items-center justify-between border-t border-border py-3 text-xs font-medium hover:underline",children:[jsxRuntime.jsx("span",{children:a("Attributes")}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(l?"rotate-180":"")})})]}),l&&jsxRuntime.jsx(BlockAttributesEditor,{})]})}const SettingsPanel=()=>{const a=useSelectedBlock(),{t:l}=reactI18next.useTranslation(),c=useBuilderProp("onError",lodashEs.noop),{hasPermission:d}=usePermissions();let u=!d(PERMISSIONS.EDIT_BLOCK);const p=!d(PERMISSIONS.EDIT_STYLES);return lodashEs.isNull(a)?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsx("h1",{children:l("Please select a block to edit settings or styles")})]})}):u&&p?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsx("h1",{children:l("You don't have permission to edit settings or styles")}),jsxRuntime.jsx("p",{children:l("Please contact your administrator to get access")})]})}):p?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[jsxRuntime.jsx(BlockSettings,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}):u?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[jsxRuntime.jsx(BlockStyling,{}),jsxRuntime.jsx(BlockAttributesToggle,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}):jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs(tooltip.Tabs,{defaultValue:"settings",className:"flex flex-1 flex-col",children:[jsxRuntime.jsxs(tooltip.TabsList,{className:"grid h-auto w-full grid-cols-2 p-1 py-1",children:[jsxRuntime.jsx(tooltip.TabsTrigger,{value:"settings",className:"text-xs",children:"Settings"}),jsxRuntime.jsx(tooltip.TabsTrigger,{value:"styles",className:"text-xs",children:"Styles"})]}),jsxRuntime.jsxs(tooltip.TabsContent,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[jsxRuntime.jsx(BlockSettings,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsxs(tooltip.TabsContent,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[jsxRuntime.jsx(BlockStyling,{}),jsxRuntime.jsx(BlockAttributesToggle,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})]})})},DEFAULT_PANEL_WIDTH=280;function useSidebarMenuItems(){const a=useBuilderProp("askAiCallBack",null),l=flagged.useFeature("aiChat");return React.useMemo(()=>{const c=[];return c.push({id:"outline",icon:jsxRuntime.jsx(lucideReact.Layers,{size:20}),label:"Outline",isInternal:!0,width:DEFAULT_PANEL_WIDTH,component:()=>jsxRuntime.jsx("div",{className:"-mt-8",children:jsxRuntime.jsx(ListTree,{})})}),a&&l&&c.unshift({id:"ai",icon:jsxRuntime.jsx(lucideReact.SparklesIcon,{size:20}),label:"AI Assistant",isInternal:!0,width:450,component:()=>jsxRuntime.jsx("div",{className:"-mt-8 h-full max-h-full",children:jsxRuntime.jsx(AIChatPanel,{})})}),lodashEs.compact(c)},[a,l])}const RootLayout=()=>{const a=useTopBarComponent(),[l,c]=useSidebarActivePanel(),d=React.useRef("outline"),[u,p]=React.useState(DEFAULT_PANEL_WIDTH),[m,h]=useRightPanel();usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS,()=>{c("outline")});const g=useChaiSidebarPanels("top"),x=useChaiSidebarPanels("bottom"),f=w=>{w.preventDefault()},y=w=>{c(l===w?null:w)},b=useSidebarMenuItems(),{t:j}=reactI18next.useTranslation(),R=React.useMemo(()=>[...b,...g],[b,g]),k=useBuilderProp("htmlDir","ltr"),v=lodashEs.find(R,{id:l})??lodashEs.first(R),S=lodashEs.get(v,"width",DEFAULT_PANEL_WIDTH);React.useEffect(()=>{if(l!==null){const w=lodashEs.find(R,{id:l});w&&lodashEs.get(w,"view","standard")==="standard"&&(d.current=l,p(lodashEs.get(w,"width",DEFAULT_PANEL_WIDTH)))}},[l,R]);const C=React.useMemo(()=>{if(l===null)return 0;const w=lodashEs.find(R,{id:l});return lodashEs.get(w,"view","standard")==="standard"?S:u},[l,S,u,R]),I=()=>{c(d.current)};return React.useEffect(()=>{lodashEs.find(R,{id:l})||c("outline")},[l,R]),jsxRuntime.jsx("div",{dir:k,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:jsxRuntime.jsxs(tooltip.TooltipProvider,{children:[jsxRuntime.jsxs("div",{onContextMenu:f,className:"flex h-screen max-h-full flex-col bg-background text-foreground",children:[jsxRuntime.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:jsxRuntime.jsx(React.Suspense,{children:jsxRuntime.jsx(a,{})})}),jsxRuntime.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[jsxRuntime.jsxs("div",{id:"sidebar",className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:R.map((w,T)=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{variant:l===w.id?"default":"ghost",className:"mb-2 rounded-lg p-2 transition-colors",onClick:()=>y(w.id),children:lodashEs.get(w,"icon",null)},T)}),jsxRuntime.jsx(tooltip.TooltipContent,{side:"right",children:jsxRuntime.jsx("p",{children:j(w.label)})})]},"button-"+T))}),jsxRuntime.jsx("div",{className:"flex flex-col space-y-1"}),jsxRuntime.jsx("div",{className:"flex flex-col",children:x==null?void 0:x.map((w,T)=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{variant:l===w.id?"default":"ghost",className:"mb-2 rounded-lg p-2 transition-colors",onClick:()=>y(w.id),children:lodashEs.get(w,"icon",null)},T)}),jsxRuntime.jsx(tooltip.TooltipContent,{side:"right",children:jsxRuntime.jsx("p",{children:j(w.label)})})]},"button-"+T))})]}),jsxRuntime.jsx(framerMotion.motion.div,{id:"left-panel",className:"h-full max-h-full border-r border-border",initial:{width:C},animate:{width:C},transition:{duration:.3,ease:"easeInOut"},children:l!==null&&lodashEs.get(v,"view","standard")==="standard"&&jsxRuntime.jsxs("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[jsxRuntime.jsxs("div",{className:`absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${lodashEs.get(v,"isInternal",!1)?"":"w-64"}`,children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]}),jsxRuntime.jsx("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto pt-10",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"component",null),{})})})]})}),jsxRuntime.jsxs("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[jsxRuntime.jsx(CanvasTopBar,{}),jsxRuntime.jsx(React.Suspense,{children:jsxRuntime.jsx(CanvasArea,{})})]}),jsxRuntime.jsx(framerMotion.motion.div,{id:"right-panel",className:"h-full max-h-full border-l border-border",initial:{width:l==="ai"?0:DEFAULT_PANEL_WIDTH},animate:{width:l==="ai"?0:DEFAULT_PANEL_WIDTH},transition:{duration:.3,ease:"easeInOut"},children:jsxRuntime.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[jsxRuntime.jsx("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:jsxRuntime.jsx("div",{className:"flex grow items-center gap-2",children:jsxRuntime.jsx("div",{className:"flex w-full items-center justify-between gap-2",children:m==="ai"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(reactIcons.LightningBoltIcon,{className:"rtl:ml-2"})," ",j("AI Assistant")]})}):m==="theme"?jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Paintbrush,{className:"h-4 w-4 rtl:ml-2"}),j("Theme Settings")]}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>h("block"),variant:"ghost",size:"icon",className:"text-xs text-gray-400",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 rtl:ml-2"})})]}):null})})}),jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:m==="ai"?jsxRuntime.jsx(AskAI,{}):m==="theme"?jsxRuntime.jsx(ThemeConfigPanel,{}):jsxRuntime.jsx(SettingsPanel,{})})})]})})}),l!==null&&lodashEs.get(v,"view")==="drawer"&&jsxRuntime.jsx(tooltip.Sheet,{open:!0,onOpenChange:()=>I(),children:jsxRuntime.jsxs(tooltip.SheetContent,{side:"left",className:"p-0 sm:max-w-full",style:{width:`${S}px`},children:[jsxRuntime.jsx(tooltip.SheetHeader,{className:"border-b border-border p-4 pb-2",children:jsxRuntime.jsxs(tooltip.SheetTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]})}),jsxRuntime.jsx("div",{className:"h-full max-h-full overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"component",null),{})})})]})}),l!==null&&lodashEs.get(v,"view")==="modal"&&jsxRuntime.jsx(tooltip.Dialog,{open:!0,onOpenChange:()=>I(),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"p-0",style:{maxWidth:`${S}px`},children:[jsxRuntime.jsx(tooltip.DialogHeader,{className:"border-b border-border p-4 pb-2",children:jsxRuntime.jsxs(tooltip.DialogTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]})}),jsxRuntime.jsx("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"component",null),{})})})]})}),l!==null&&lodashEs.get(v,"view")==="overlay"&&jsxRuntime.jsx(framerMotion.motion.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:jsxRuntime.jsx("div",{className:"h-full w-full",children:jsxRuntime.jsxs(framerMotion.motion.div,{className:"flex h-full w-full flex-col bg-background",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-border p-4 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-lg font-bold",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>I(),variant:"ghost",size:"icon",className:"text-gray-400",children:jsxRuntime.jsx(lucideReact.X,{className:"h-5 w-5"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"component",null),{})})})]})})})]})]}),jsxRuntime.jsx(AddBlocksDialog,{})]})})},PreviewScreen=()=>{const[a,l]=usePreviewMode(),{t:c}=reactI18next.useTranslation(),d=useBuilderProp("previewComponent",null);return a?jsxRuntime.jsxs("div",{className:Functions.cn("fixed inset-0 z-[999] bg-background",a?"block":"hidden"),children:[jsxRuntime.jsxs(tooltip.Button,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>l(!1),children:[jsxRuntime.jsx(reactIcons.EyeClosedIcon,{}),jsxRuntime.jsx("span",{children:c("Close Preview")})]}),jsxRuntime.jsx("div",{children:d?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-96 w-full"}),children:React.createElement(d)}):null})]}):null},SmallScreenMessage=()=>jsxRuntime.jsx("section",{className:"h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden",children:jsxRuntime.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:jsxRuntime.jsxs("div",{className:"mx-auto max-w-md text-center",children:[jsxRuntime.jsx("img",{src:"https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/chaibuilder-blob-storage/175ac8d8-37fe-4707-bb4a-3c0cd6a6db75/gVH7O-Ir_400x400.png",alt:"Chai Builder",className:"mx-auto w-14 rounded-full"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("h2",{className:"text-4xl font-bold text-white",children:"Screen too small"}),jsxRuntime.jsx("p",{className:"mt-6 text-sm font-medium leading-6 text-white text-opacity-70",children:"Please view this page on greater than 1280px screen width."})]})})}),useAutoSave=()=>{const{savePage:a}=useSavePage(),l=useBuilderProp("autoSaveSupport",!0),c=useBuilderProp("autoSaveInterval",60);web.useIntervalEffect(()=>{l&&a(!0)},c*1e3)},ChaiBuilderComponent=a=>{const[,l]=useBlocksStore(),c=useBuilderReset(),[d]=useAtom(builderSaveStateAtom),u=React.useMemo(()=>a.layout||RootLayout,[a.layout]);useAtom(selectedLibraryAtom),useKeyEventWatcher(),useExpandTree(),useAutoSave(),useWatchPartailBlocks(),useUnmountBroadcastChannel();const{postMessage:p}=useBroadcastChannel();return React.useEffect(()=>{builderStore.set(chaiBuilderPropsAtom,lodashEs.omit(a,["blocks","translations","pageExternalData"]))},[a]),React.useEffect(()=>{builderStore.set(chaiPageExternalDataAtom,a.pageExternalData||{})},[a.pageExternalData]),React.useEffect(()=>{setTimeout(()=>{const m=runtime.syncBlocksWithDefaults(a.blocks||[]);l(m),m&&m.length>0&&p({type:"blocks-updated",blocks:m}),c()},400)},[a.blocks]),React.useEffect(()=>{i18n.changeLanguage(a.locale||"en")},[a.locale]),React.useEffect(()=>{setDebugLogs(a.debugLogs)},[a.debugLogs]),React.useEffect(()=>{a.translations&&lodashEs.each(a.translations,(m,h)=>{i18n.addResourceBundle(h,"translation",m,!0,!0)})},[a.translations]),React.useEffect(()=>(d!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[d]),jsxRuntime.jsx(u,{})},ChaiBuilderEditor=a=>{const l=a.onError||lodashEs.noop;return jsxRuntime.jsx("div",{className:"h-screen w-screen",children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsxs(flagged.FlagsProvider,{features:{...FEATURE_TOGGLES},children:[jsxRuntime.jsx(SmallScreenMessage,{}),jsxRuntime.jsx(ChaiBuilderComponent,{...a}),jsxRuntime.jsx(PreviewScreen,{}),jsxRuntime.jsx(tooltip.Toaster,{})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>reactI18next.useTranslation});exports.generateBlockId=Functions.generateUUID;exports.mergeClasses=Functions.cn;exports.i18n=i18n;exports.ADD_BLOCK_TABS=ADD_BLOCK_TABS;exports.CHAI_BUILDER_PANELS=CHAI_BUILDER_PANELS;exports.ChaiAddBlocksDialog=AddBlocksDialog;exports.ChaiAddBlocksPanel=AddBlocksPanel;exports.ChaiAskAiPanel=AISetContext;exports.ChaiAskAiUserPrompt=AIUserPrompt;exports.ChaiBlockAttributesEditor=BlockAttributesEditor;exports.ChaiBlockPropsEditor=BlockSettings;exports.ChaiBlockStyleEditor=BlockStyling;exports.ChaiBuilderCanvas=CanvasArea;exports.ChaiBuilderEditor=ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=DarkMode;exports.ChaiDefaultBlocks=DefaultChaiBlocks;exports.ChaiImportHTML=ImportHTML;exports.ChaiOutline=ListTree;exports.ChaiScreenSizes=Breakpoints$1;exports.ChaiThemeConfigPanel=ThemeConfigPanel;exports.ChaiUILibrariesPanel=UILibrariesPanel;exports.ChaiUndoRedo=UndoRedo;exports.PERMISSIONS=PERMISSIONS;exports.RJSF_EXTENSIONS=RJSF_EXTENSIONS;exports.convertHTMLToChaiBlocks=getBlocksFromHTML;exports.getBlocksFromHTML=getBlocksFromHTML;exports.registerBlockSettingField=registerBlockSettingField;exports.registerBlockSettingTemplate=registerBlockSettingTemplate;exports.registerBlockSettingWidget=registerBlockSettingWidget;exports.registerChaiAddBlockTab=registerChaiAddBlockTab;exports.registerChaiMediaManager=registerChaiMediaManager;exports.registerChaiSidebarPanel=registerChaiSidebarPanel;exports.registerChaiTopBar=registerChaiTopBar;exports.useAddBlock=useAddBlock;exports.useAddClassesToBlocks=useAddClassesToBlocks;exports.useAskAi=useAskAi;exports.useBlockHighlight=useBlockHighlight;exports.useBlockSettingComponents=useBlockSettingComponents;exports.useBlocksStore=useBlocksStore;exports.useBlocksStoreUndoableActions=useBlocksStoreUndoableActions;exports.useBrandingOptions=useBrandingOptions;exports.useBuilderProp=useBuilderProp;exports.useBuilderReset=useBuilderReset;exports.useCanvasDisplayWidth=useCanvasDisplayWidth;exports.useCanvasZoom=useCanvasZoom;exports.useChaiSidebarPanels=useChaiSidebarPanels;exports.useCodeEditor=useCodeEditor;exports.useCopyBlockIds=useCopyBlockIds;exports.useCopyToClipboard=useCopyToClipboard;exports.useCurrentPage=useCurrentPage;exports.useCutBlockIds=useCutBlockIds;exports.useDarkMode=useDarkMode;exports.useDuplicateBlocks=useDuplicateBlocks;exports.useHiddenBlockIds=useHiddenBlockIds;exports.useHighlightBlockId=useHighlightBlockId;exports.useLanguages=useLanguages;exports.useLibraryBlocks=useLibraryBlocks;exports.useMediaManagerComponent=useMediaManagerComponent;exports.usePartailBlocksStore=usePartailBlocksStore;exports.usePartialBlocksList=usePartialBlocksList;exports.usePasteBlocks=usePasteBlocks;exports.usePermissions=usePermissions;exports.usePreviewMode=usePreviewMode;exports.useRemoveBlocks=useRemoveBlocks;exports.useRemoveClassesFromBlocks=useRemoveClassesFromBlocks;exports.useRightPanel=useRightPanel;exports.useSavePage=useSavePage;exports.useScreenSizeWidth=useScreenSizeWidth;exports.useSelectedBlock=useSelectedBlock;exports.useSelectedBlockAllClasses=useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=useSelectedBreakpoints;exports.useSelectedStylingBlocks=useSelectedStylingBlocks;exports.useSidebarActivePanel=useSidebarActivePanel;exports.useStylingBreakpoint=useStylingBreakpoint;exports.useStylingState=useStylingState;exports.useTheme=useTheme;exports.useThemeOptions=useThemeOptions;exports.useTopBarComponent=useTopBarComponent;exports.useUILibraryBlocks=useUILibraryBlocks;exports.useUndoManager=useUndoManager;exports.useUpdateBlocksProps=useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=useUpdateBlocksPropsRealtime;exports.useWrapperBlock=useWrapperBlock;
|
|
66
|
+
`,document.head.appendChild(y),()=>{const b=document.getElementById("rte-modal-styles");b&&b.remove()}}},[a]);const x=react.useEditor({extensions:[StarterKit,Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),TextAlign.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Underline],content:d||"",onUpdate:({editor:y})=>{const b=y.getHTML();u(b)},onBlur:({editor:y})=>{const b=y.getHTML();p(c,b)},editorProps:{attributes:{class:"prose prose-sm focus:outline-none min-h-[300px] p-2 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"}}});React.useEffect(()=>{a&&x&&(h.current!==d&&(h.current=d||"",x.commands.setContent(d||"")),setTimeout(()=>{x.commands.focus()},100))},[a,x]),React.useEffect(()=>{m.current&&x&&(m.current.__chaiRTE=x)},[x,a]);const f=y=>{if(!x)return;const b=`{{${y}}}`;x.commands.focus();const{from:j,to:R}=x.state.selection;if(j!==R)x.chain().deleteSelection().insertContent(b).run();else{const{state:v}=x,S=v.selection.from,C=v.doc.textBetween(Math.max(0,S-1),S),I=v.doc.textBetween(S,Math.min(S+1,v.doc.content.size));let T="";S>0&&C!==" "&&!/[.,!?;:]/.test(C)&&(T=" ");let _="";I&&I!==" "&&!/[.,!?;:]/.test(I)&&(_=" "),x.chain().insertContent(T+b+_).run()}};return jsxRuntime.jsx(tooltip.Dialog,{open:a,onOpenChange:y=>!y&&l(),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[jsxRuntime.jsx(tooltip.DialogHeader,{children:jsxRuntime.jsxs(tooltip.DialogTitle,{className:"flex items-center justify-between pr-8",children:[jsxRuntime.jsx("span",{children:"Rich Text Editor"}),g&&Object.keys(g).length>0&&jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),jsxRuntime.jsx("div",{className:"rte-path-selector",children:jsxRuntime.jsx(NestedPathSelector,{data:g,onSelect:f})})]})]})}),jsxRuntime.jsxs("div",{id:`chai-rte-modal-${c}`,ref:m,className:"rounded-md border border-input",children:[jsxRuntime.jsx(MenuBar,{editor:x}),jsxRuntime.jsx(react.EditorContent,{editor:x,id:`modal-${c}`,className:"p-2"})]}),jsxRuntime.jsx("div",{className:"mt-4 flex justify-end",children:jsxRuntime.jsx(tooltip.Button,{onClick:l,children:"Done"})})]})})},RichTextEditorField=({id:a,placeholder:l,value:c,onChange:d,onBlur:u})=>{const p=React.useRef(null),[m,h]=React.useState(!1),[g,x]=React.useState(""),f=react.useEditor({extensions:[StarterKit,Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),TextAlign.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Underline],content:c||"",onUpdate:({editor:j})=>{const R=j.getHTML();d(R),m||x(R)},onBlur:({editor:j})=>{const R=j.getHTML();u(a,R)},editorProps:{attributes:{class:"prose prose-sm focus:outline-none min-h-[100px] p-1 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"}}});React.useEffect(()=>{p.current.__chaiRTE=f},[f]),React.useEffect(()=>{x(c||"")},[c]);const y=j=>{d(j)},b=()=>{h(!1),f&&f.commands.setContent(g)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsxs("div",{id:`chai-rte-${a}`,ref:p,className:"mt-1 rounded-md border border-input",children:[jsxRuntime.jsx(MenuBar,{editor:f,onExpand:()=>h(!0)}),jsxRuntime.jsx(react.EditorContent,{editor:f,id:a,placeholder:l})]})}),m&&jsxRuntime.jsx(RTEModal,{isOpen:m,onClose:b,id:a,value:g,onChange:y,onBlur:u})]})},PageTypeField=({href:a,pageTypes:l,onChange:c})=>{var D;const{t:d}=reactI18next.useTranslation(),u=useBuilderProp("searchPageTypeItems",(w,E)=>[]),[p,m]=React.useState(!1),[h,g]=React.useState(!1),[x,f]=React.useState("page"),[y,b]=React.useState(""),[j,R]=React.useState([]),[k,v]=React.useState(-1),S=React.useRef(null),C=(D=l==null?void 0:l.find(w=>w.key===x))==null?void 0:D.name;React.useEffect(()=>{if(b(""),R([]),v(-1),g(!1),!a||p||!lodashEs.startsWith(a,"pageType:"))return;const w=lodashEs.split(a,":"),E=lodashEs.get(w,1,"page")||"page";f(E),(async()=>{const N=await u(E,[lodashEs.get(w,2,"page")]);N&&Array.isArray(N)&&b(lodashEs.get(N,[0,"name"],""))})()},[a]);const I=web.useDebouncedCallback(async w=>{if(lodashEs.isEmpty(w))R([]);else{const E=await u(x,w);R(E)}m(!1),v(-1)},[x],300),T=w=>{const E=["pageType",x,w.id];E[1]&&(c(E.join(":")),b(w.name),g(!1),R([]),v(-1))},_=w=>{switch(w.key){case"ArrowDown":w.preventDefault(),v(E=>E<j.length-1?E+1:E);break;case"ArrowUp":w.preventDefault(),v(E=>E>0?E-1:E);break;case"Enter":if(w.preventDefault(),j.length===0)return;k>=0&&T(j[k]);break;case"Escape":w.preventDefault(),A();break}};React.useEffect(()=>{if(k>=0&&S.current){const w=S.current.children[k];w==null||w.scrollIntoView({block:"nearest"})}},[k]);const A=()=>{b(""),R([]),v(-1),g(!1),c("")},B=w=>{b(w),g(!lodashEs.isEmpty(w)),m(!0),I(w)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:x,onChange:w=>f(w.target.value),children:lodashEs.map(l,w=>jsxRuntime.jsx("option",{value:w.key,children:w.name},w.key))}),x&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:y,onChange:w=>B(w.target.value),onKeyDown:_,placeholder:d(`Search ${C??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:y&&jsxRuntime.jsx("button",{onClick:A,className:"text-gray-400 hover:text-gray-600",title:d("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(p||!lodashEs.isEmpty(j)||h&&lodashEs.isEmpty(j))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:p?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):h&&lodashEs.isEmpty(j)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[d("No results found for"),' "',y,'"']}):jsxRuntime.jsx("ul",{ref:S,children:lodashEs.map(j==null?void 0:j.slice(0,20),(w,E)=>jsxRuntime.jsxs("li",{onClick:()=>T(w),className:`cursor-pointer p-2 text-xs ${a!=null&&a.includes(w.id)?"bg-blue-200":E===k?"bg-gray-100":"hover:bg-gray-100"}`,children:[w.name," ",w.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",w.slug," )"]})]},w.id))})})]})},LinkField=({schema:a,formData:l,onChange:c})=>{const{t:d}=reactI18next.useTranslation(),{type:u="pageType",href:p="",target:m="self"}=l,h=useBuilderProp("pageTypes",[]),g=u==="pageType"&&lodashEs.isEmpty(h)?"url":u;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-xs font-medium",children:(a==null?void 0:a.title)??"Link"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:u,onChange:x=>c({...l,type:x.target.value}),children:lodashEs.map([...lodashEs.isEmpty(h)?[]:[{const:"pageType",title:d("Goto Page")}],{const:"url",title:d("Open URL")},{const:"email",title:d("Compose Email")},{const:"telephone",title:d("Call Phone")},{const:"scroll",title:d("Scroll to element")}],x=>jsxRuntime.jsx("option",{value:x.const,children:x.title},x.const))}),g==="pageType"&&!lodashEs.isEmpty(h)?jsxRuntime.jsx(PageTypeField,{href:p,pageTypes:h,onChange:x=>c({...l,href:x})}):jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:p,onChange:x=>c({...l,href:x.target.value}),placeholder:d(u==="url"?"Enter URL":u==="scroll"?"#ElementID":"Enter details")}),g==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:m==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>c({...l,target:m==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:d("Open in new tab")})]})]})]})},RowColField=()=>{const a=useSelectedBlock(),l=useWrapperBlock(),{addCoreBlock:c}=useAddBlock();if(!a&&!l)return null;const d=(a==null?void 0:a._type)==="Row"?a:l;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>c({type:"Column",styles:"#styles:,"},d==null?void 0:d._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})},SliderField=({formData:a,onChange:l})=>{const[c]=useBlocksStore(),d=useSelectedBlock(),u=useWrapperBlock(),{addCoreBlock:p}=useAddBlock(),[,m]=useSelectedBlockIds();if(!d&&!u)return null;const h=(d==null?void 0:d._type)==="Slider"?d:u,g=lodashEs.find(c,{_parent:h==null?void 0:h._id,_type:"Slides"});if(!g)return null;const x=lodashEs.filter(c,{_parent:g==null?void 0:g._id,_type:"Slide"}),f=(a==null?void 0:a.currentSlide)||lodashEs.get(x,"0._id");React.useEffect(()=>{(d==null?void 0:d._type)==="Slide"&&(a==null?void 0:a.currentSlide)!==(d==null?void 0:d._id)&&l({...a,currentSlide:d==null?void 0:d._id})},[d]),React.useEffect(()=>{x!=null&&x.length&&!lodashEs.find(x,{_id:a==null?void 0:a.currentSlide})&&l({...a,currentSlide:lodashEs.get(x,"0._id")})},[a,x]);const y=()=>{const R=lodashEs.findIndex(x,{_id:f});if(R>-1){const k=(R+1)%x.length,v=lodashEs.get(x,[k,"_id"]);if(!v)return;l({...a,currentSlide:v}),m([v])}},b=()=>{const R=lodashEs.findIndex(x,{_id:f});if(R>-1){const k=(R-1+x.length)%x.length,v=lodashEs.get(x,[k,"_id"]);if(!v)return;l({...a,currentSlide:v}),m([v])}},j=()=>{const R=p({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},g==null?void 0:g._id),k=R==null?void 0:R._id;k&&(l({...a,currentSlide:k}),m([k]))};return jsxRuntime.jsxs("div",{className:"space-y-1.5 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[jsxRuntime.jsx("button",{onClick:b,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-3 w-3 stroke-[3]"})}),jsxRuntime.jsx("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:f?jsxRuntime.jsxs("span",{className:"",children:[jsxRuntime.jsxs("b",{className:"text-[12px]",children:[" ",lodashEs.findIndex(x,{_id:f})+1]}),"/",x.length]}):"-"}),jsxRuntime.jsx("button",{onClick:y,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3 stroke-[3]"})}),jsxRuntime.jsxs("button",{onClick:j,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[jsxRuntime.jsx(lucideReact.PlusCircle,{className:"h-3 w-3 stroke-[2]"}),"Add Slide"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.showSlideButton),onChange:()=>l({...a,showSlideButton:!(a!=null&&a.showSlideButton)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Buttons"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.showSlideNavbar),onChange:()=>l({...a,showSlideNavbar:!(a!=null&&a.showSlideNavbar)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Navbar"})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!(a!=null&&a.autoplay),onChange:()=>l({...a,autoplay:!(a!=null&&a.autoplay)}),className:"cursor-pointer"}),jsxRuntime.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Autoplay slides"})]}),(a==null?void 0:a.autoplay)&&jsxRuntime.jsxs("div",{className:"pt-0.5 leading-tight",children:[jsxRuntime.jsxs("label",{htmlFor:"interval",className:"whitespace-nowrap text-[9px]",children:["Autoplay Interval ",jsxRuntime.jsx("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),jsxRuntime.jsx("input",{type:"number",id:"interval",name:"interval",placeholder:"0",value:a==null?void 0:a.autoplayInterval,className:"text-xs",pattern:"[0-9]*",onChange:R=>{let k=R.target.value;k.length&&(k=k.replace("-","")),l({...a,autoplayInterval:k})}})]})]})})]})},BindingWidget=()=>jsxRuntime.jsx("div",{className:"text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100",children:"Data binding is set for this field"}),CodeEditor=({id:a,placeholder:l})=>{const{t:c}=reactI18next.useTranslation(),[,d]=useCodeEditor(),u=useSelectedBlock();if(typeof window>"u")return null;const p=a.replace("root.",""),m=lodashEs.get(u,p,""),h=()=>{const g=u==null?void 0:u._id;d({blockId:g,blockProp:p,placeholder:l,initialCode:lodashEs.get(u,p,m)})};return jsxRuntime.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[jsxRuntime.jsx("button",{onClick:h,className:"w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",children:m.trim().length>0?m.substring(0,46):l||"Eg: <script>console.log('Hello, world!');<\/script>"}),jsxRuntime.jsx(tooltip.Button,{onClick:h,size:"sm",variant:"outline",className:"w-fit",children:c("Open code editor")})]})},JSONFormFieldTemplate=({id:a,classNames:l,label:c,children:d,errors:u,help:p,description:m,hidden:h,required:g,schema:x,formData:f,onChange:y})=>{const{selectedLang:b,fallbackLang:j,languages:R}=useLanguages(),k=lodashEs.isEmpty(R)?"":lodashEs.isEmpty(b)?j:b,v=lodashEs.get(LANGUAGES,k,k),S=usePageExternalData(),C=useSelectedBlock(),I=runtime.useRegisteredChaiBlocks(),T=lodashEs.get(I,[C==null?void 0:C._type,"i18nProps"],[])||[],[_,A]=React.useState(null),B=React.useCallback(E=>{const N=O=>/[.,!?;:]/.test(O),P=(O,Z,V)=>{let U="",$="";const F=Z>0?O[Z-1]:"",H=Z<O.length?O[Z]:"";return Z>0&&(F==="."||!N(F)&&F!==" ")&&(U=" "),Z<O.length&&!N(H)&&H!==" "&&($=" "),{text:U+V+$,prefixLength:U.length,suffixLength:$.length}},L=document.getElementById(a);if(!L)return;const M=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(M&&(M.querySelector(".ProseMirror")||M.__chaiRTE)){const O=M.__chaiRTE;if(O){const Z=`{{${E}}}`;O.commands.focus();const{from:V,to:U}=O.state.selection;if(V!==U)O.chain().deleteSelection().insertContent(Z).run();else{const{state:F}=O,H=F.selection.from,K=F.doc.textBetween(Math.max(0,H-1),H),G=F.doc.textBetween(H,Math.min(H+1,F.doc.content.size));let Y="";H>0&&K!==" "&&!N(K)&&(Y=" ");let q="";G&&G!==" "&&!N(G)&&(q=" "),O.chain().insertContent(Y+Z+q).run()}setTimeout(()=>y(O.getHTML(),{},a),100);return}}else{const O=L,Z=O.selectionStart||0,V=O.value||"",U=O.selectionEnd||Z;if(U>Z){const G=`{{${E}}}`,{text:Y}=P(V,Z,G),q=V.slice(0,Z)+Y+V.slice(U);y(q,{},a);return}const F=`{{${E}}}`,{text:H}=P(V,Z,F),K=V.slice(0,Z)+H+V.slice(Z);y(K,{},a)}},[a,y,f,C==null?void 0:C._id]);if(h)return null;if(x.type==="boolean")return jsxRuntime.jsx("div",{className:l,children:d});const w=T==null?void 0:T.includes(a.replace("root.",""));if(x.type==="array"){const E=_===a;return jsxRuntime.jsxs("div",{className:`${l} relative`,children:[x.title&&jsxRuntime.jsxs("label",{htmlFor:a,onClick:()=>A(E?null:a),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[E?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3"}),jsxRuntime.jsx(lucideReact.List,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{className:"leading-tight",children:c})," ",jsxRuntime.jsx(tooltip.Badge,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:jsxRuntime.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:f==null?void 0:f.length})})]}),(f==null?void 0:f.length)===0?jsxRuntime.jsx("div",{className:"h-0 overflow-hidden",children:d}):jsxRuntime.jsxs("div",{className:`${E?"pt-0.5":"h-0 overflow-hidden"}`,children:[m,d,u,p]})]})}return jsxRuntime.jsxs("div",{className:l,children:[x.title&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("label",{htmlFor:a,className:x.type==="object"?"pb-2":"",children:[c," ",w&&jsxRuntime.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",v]}),g&&x.type!=="object"?" *":null]}),x.type==="string"&&!x.enum&&!x.oneOf&&S&&jsxRuntime.jsx(NestedPathSelector,{data:S,onSelect:B,dataType:"value"})]}),m,d,u,p]})},CustomAddButton=a=>jsxRuntime.jsx("button",{...a,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-3 w-3"})," ",jsxRuntime.jsx("span",{children:"Add"})]})}),JSONForm=React.memo(({blockId:a,schema:l,uiSchema:c,formData:d,onChange:u})=>{const{selectedLang:p}=useLanguages(),m=useBlockSettingComponents("widget"),h=useBlockSettingComponents("field"),g=useBlockSettingComponents("template"),x=web.useThrottledCallback(async({formData:f},y)=>{u({formData:f},y)},[u,p],400);return jsxRuntime.jsx(RjForm,{widgets:{binding:BindingWidget,richtext:RichTextEditorField,icon:IconPickerField,image:ImagePickerField,code:CodeEditor,colCount:RowColField,...m},fields:{link:LinkField,slider:SliderField,...h},templates:{FieldTemplate:JSONFormFieldTemplate,ButtonTemplates:{AddButton:CustomAddButton},...g},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator,uiSchema:c,schema:l,formData:d,onChange:({formData:f},y)=>{if(!y||a!==(f==null?void 0:f._id))return;const b=lodashEs.take(y.split("."),2).join(".").replace("root.","");x({formData:f},b)}},p)}),GlobalBlockSettings=()=>{const a=useSelectedBlock(),{data:l,refetch:c,isLoading:d}=usePartialBlocksList(),u=useUpdateBlocksProps();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(a==null?void 0:a.globalBlock)||"",onChange:p=>{var m;u([a._id],{globalBlock:p.target.value,_name:`Global Block: ${lodashEs.startCase((m=lodashEs.get(l,p.target.value,""))==null?void 0:m.name)}`})},children:[jsxRuntime.jsx("option",{value:"",children:"Select a global block"}),Object.keys(l).map(p=>jsxRuntime.jsx("option",{value:p,children:l[p].name||p},p))]}),jsxRuntime.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsx("button",{onClick:c,className:"rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",children:d?"Loading...":"Refresh List"})})]})},formDataWithSelectedLang=(a,l,c)=>{const d=lodashEs.cloneDeep(a);return lodashEs.forEach(lodashEs.keys(a),u=>{lodashEs.includes(lodashEs.get(c,"i18nProps",[]),u)&&!lodashEs.isEmpty(l)&&(d[u]=lodashEs.get(a,`${u}-${l}`))}),d};function BlockSettings(){const{selectedLang:a}=useLanguages(),l=useSelectedBlock(),c=useUpdateBlocksPropsRealtime(),d=useUpdateBlocksProps(),u=runtime.getRegisteredChaiBlock(l==null?void 0:l._type),p=formDataWithSelectedLang(l,a,u),[m,h]=React.useState(p),[g,x]=React.useState(!1),f=useWrapperBlock(),y=runtime.getRegisteredChaiBlock(f==null?void 0:f._type),b=formDataWithSelectedLang(f,a,y),j=({formData:_},A,B)=>{A&&(m==null?void 0:m._id)===l._id&&d([l._id],{[A]:lodashEs.get(_,A)},B)},R=React.useCallback(lodashEs.debounce(({formData:_},A,B)=>{j({formData:_},A,B),h(_)},1500),[l==null?void 0:l._id,a]),k=({formData:_},A)=>{A&&(c([l._id],{[A]:lodashEs.get(_,A)}),R({formData:_},A,{[A]:lodashEs.get(m,A)}))},v=({formData:_},A)=>{A&&(c([f._id],{[A]:lodashEs.get(_,A)}),R({formData:_},A,{[A]:lodashEs.get(m,A)}))};lodashEs.keys(lodashEs.get(p,"_bindings",{}));const{schema:S,uiSchema:C}=React.useMemo(()=>{const _=l==null?void 0:l._type;if(_)return runtime.getBlockFormSchemas(_)},[l]),{wrapperSchema:I,wrapperUiSchema:T}=React.useMemo(()=>{if(!f||!(f!=null&&f._type))return{wrapperSchema:{},wrapperUiSchema:{}};const _=f==null?void 0:f._type,{schema:A={},uiSchema:B={}}=runtime.getBlockFormSchemas(_);return{wrapperSchema:A,wrapperUiSchema:B}},[f]);return jsxRuntime.jsxs("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[!lodashEs.isEmpty(f)&&jsxRuntime.jsxs("div",{className:"mb-4 rounded border bg-zinc-100 px-1",children:[jsxRuntime.jsxs("div",{onClick:()=>x(_=>!_),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[g?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 stroke-[3] text-slate-400"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 stroke-[3] text-slate-400"}),lodashEs.startCase(f._type)," settings"," ",f._name&&jsxRuntime.jsxs("span",{className:"text-[11px] font-light text-slate-400",children:["(",f._name,")"]})]}),jsxRuntime.jsx("div",{className:g?"h-auto":"invisible h-0",children:jsxRuntime.jsx(JSONForm,{blockId:f==null?void 0:f._id,onChange:v,formData:b,schema:I,uiSchema:T})})]}),lodashEs.isEmpty(S)?null:jsxRuntime.jsx(JSONForm,{blockId:l==null?void 0:l._id,onChange:k,formData:p,schema:S,uiSchema:C}),(l==null?void 0:l._type)==="GlobalBlock"?jsxRuntime.jsx(GlobalBlockSettings,{}):null]})}const TabletIcon=({landscape:a=!1})=>jsxRuntime.jsx("svg",{className:a?"rotate-90":"",stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",height:"14px",width:"14px",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),WEB_BREAKPOINTS=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:jsxRuntime.jsx(reactIcons.MobileIcon,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:jsxRuntime.jsx(reactIcons.MobileIcon,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:jsxRuntime.jsx(TabletIcon,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:jsxRuntime.jsx(TabletIcon,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:jsxRuntime.jsx(reactIcons.LaptopIcon,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:jsxRuntime.jsx(reactIcons.DesktopIcon,{}),width:1920}],BreakpointCard=({canvas:a=!1,openDelay:l=400,tooltip:c=!0,title:d,content:u,currentBreakpoint:p,breakpoint:m,width:h,icon:g,onClick:x})=>{const{t:f}=reactI18next.useTranslation();return c?jsxRuntime.jsxs(tooltip.HoverCard,{openDelay:l,children:[jsxRuntime.jsx(tooltip.HoverCardTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{onClick:()=>x(h),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:m===p?"outline":"ghost",children:g})}),jsxRuntime.jsx(tooltip.HoverCardContent,{className:"w-fit max-w-52 border-border",children:jsxRuntime.jsx("div",{className:"flex justify-between space-x-4",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold",children:f(d)}),a&&jsxRuntime.jsx("p",{className:"text-xs",children:f(u)})]})})})]}):jsxRuntime.jsx(tooltip.Button,{onClick:()=>x(h),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:m===p?"outline":"ghost",children:g})},Breakpoints$1=({openDelay:a=400,canvas:l=!1,tooltip:c=!0})=>{const[d,,u]=useScreenSizeWidth(),[p,m]=useCanvasDisplayWidth(),[h,g]=useSelectedBreakpoints(),x=h,f=g,{t:y}=reactI18next.useTranslation(),b=useBuilderProp("breakpoints",WEB_BREAKPOINTS),j=v=>{x.includes(v)?x.length>2&&f(x.filter(S=>S!==v)):f(S=>[...S,v])},R=v=>{l||u(v),m(v)},k=Functions.getBreakpointValue(l?p:d).toLowerCase();return b.length<4?jsxRuntime.jsx("div",{className:"flex items-center rounded-md",children:lodashEs.map(b,v=>React.createElement(BreakpointCard,{canvas:l,...v,onClick:R,key:v.breakpoint,currentBreakpoint:k}))}):jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between rounded-md",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:lodashEs.map(b.filter(v=>lodashEs.includes(x,lodashEs.toUpper(v.breakpoint))),v=>React.createElement(BreakpointCard,{canvas:l,openDelay:a,tooltip:c,...v,onClick:R,key:v.breakpoint,currentBreakpoint:k}))}),jsxRuntime.jsxs(tooltip.DropdownMenu,{children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:jsxRuntime.jsx(reactIcons.DotsVerticalIcon,{className:"scale-90 transform"})})}),jsxRuntime.jsxs(tooltip.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[jsxRuntime.jsx(tooltip.DropdownMenuLabel,{children:y("Screen sizes")}),jsxRuntime.jsx(tooltip.DropdownMenuSeparator,{}),lodashEs.map(b,v=>jsxRuntime.jsx(tooltip.DropdownMenuCheckboxItem,{disabled:v.breakpoint==="xs",onCheckedChange:()=>j(lodashEs.toUpper(v.breakpoint)),checked:lodashEs.includes(x,lodashEs.toUpper(v.breakpoint)),children:y(v.title)},v.breakpoint))]})]})]})};function BreakpointSelector(){const[,a]=useScreenSizeWidth(),l=React.useMemo(()=>{const c=WEB_BREAKPOINTS.find(d=>d.breakpoint===a);return c==null?void 0:c.content},[a,WEB_BREAKPOINTS]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Screen: "}),jsxRuntime.jsx(Breakpoints$1,{openDelay:1e3,tooltip:!1})]}),jsxRuntime.jsx("div",{className:"mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1",children:jsxRuntime.jsx("p",{className:"flex flex-1 items-center space-x-2 text-[10px] text-foreground",children:jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[jsxRuntime.jsx("span",{className:"rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground",children:a==="xs"?"Base":a})," ",l]})})})]})}const SECONDS=10;function Countdown(){const[a,l]=React.useState(SECONDS),[c,d]=React.useState(!1);React.useEffect(()=>{if(c&&a>0){const g=setTimeout(()=>{l(a-.1)},100);return()=>clearTimeout(g)}else a<=0&&(d(!1),l(SECONDS))},[c,a]);const u=()=>{d(!0),l(SECONDS)};React.useEffect(()=>{a===SECONDS&&u()},[a]);const p=18,m=2*Math.PI*p,h=m*(1-(SECONDS-a)/SECONDS);return jsxRuntime.jsxs("div",{className:"relative h-4 w-4",children:[jsxRuntime.jsxs("svg",{className:"h-full w-full",viewBox:"0 0 40 40",children:[jsxRuntime.jsx("circle",{className:"text-gray-300",strokeWidth:"4",stroke:"currentColor",fill:"transparent",r:p,cx:"20",cy:"20"}),jsxRuntime.jsx("circle",{className:"text-blue-600",strokeWidth:"4",strokeDasharray:m,strokeDashoffset:h,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:p,cx:"20",cy:"20"})]}),jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold",children:" "})})]})}const AskAIStyles=({blockId:a})=>{const{t:l}=reactI18next.useTranslation(),{askAi:c,loading:d,error:u}=useAskAi(),[p,m]=React.useState(""),h=React.useRef(null),g=React.useRef(null),[x,f]=React.useState();React.useEffect(()=>{var b;(b=h.current)==null||b.focus()},[]);const y=b=>{const{usage:j}=b||{};!u&&j&&f(j),g.current=setTimeout(()=>f(void 0),1e4),u||m("")};return jsxRuntime.jsxs("div",{className:"",children:[jsxRuntime.jsx("h2",{className:"mb-1 text-sm font-semibold leading-none tracking-tight",children:l("Ask AI")}),jsxRuntime.jsx(tooltip.Textarea,{ref:h,value:p,onChange:b=>m(b.target.value),placeholder:l("Ask AI to edit styles"),className:"no-scrollbar my-2 w-full border border-border p-2 text-xs",rows:4,onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),g.current&&clearTimeout(g.current),f(void 0),c("styles",a,p,y))}}),jsxRuntime.jsxs("div",{className:"my-2 flex items-center gap-2",children:[d?null:jsxRuntime.jsx(tooltip.Button,{disabled:p.trim().length<5||d,onClick:()=>{g.current&&clearTimeout(g.current),f(void 0),c("styles",a,p,y)},variant:"default",className:"w-fit",size:"sm",children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),l("Generating... Please wait...")]}):l("Edit with AI")}),d?jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs(tooltip.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-4 w-4 animate-spin text-gray-500",size:16}),jsxRuntime.jsx("p",{className:"text-xs",children:l("Generating... Please wait...")})]}),jsxRuntime.jsx(tooltip.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:l("Stop")})]}):null]}),x?jsxRuntime.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxs("span",{children:[l("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsx(Countdown,{})]})}):null,jsxRuntime.jsx("div",{className:"max-w-full",children:u&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})})]})};function ManualClasses(){var P;const a=React.useRef(null),[l,c]=React.useState(""),[d,u]=React.useState(-1),p=useFuseSearch(),{t:m}=reactI18next.useTranslation(),[h]=useSelectedStylingBlocks(),g=useSelectedBlock(),x=useAddClassesToBlocks(),f=useRemoveClassesFromBlocks(),[y]=useSelectedBlockIds(),b=useBuilderProp("askAiCallBack",null),[j,R]=React.useState(""),k=(P=lodashEs.first(h))==null?void 0:P.prop,{classes:v}=getSplitClasses.getSplitChaiClasses(lodashEs.get(g,k,"")),S=v.split(" ").filter(L=>!lodashEs.isEmpty(L)),C=()=>{const L=j.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");x(y,L,!0),R("")},[I,T]=React.useState([]),_=({value:L})=>{const M=L.trim().toLowerCase(),O=M.match(/.+:/g);let Z=[];if(O&&O.length>0){const[V]=O,U=M.replace(V,"");Z=p.search(U).map(F=>({...F,item:{...F.item,name:V+F.item.name}}))}else Z=p.search(M);return T(lodashEs.map(Z,"item"))},A=()=>{T([])},B=L=>L.name,D=L=>jsxRuntime.jsx("div",{className:"rounded-md p-1",children:L.name}),w=React.useMemo(()=>({ref:a,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:m("Enter classes separated by space"),value:j,onKeyDown:L=>{L.key==="Enter"&&j.trim()!==""&&C()},onChange:(L,{newValue:M})=>R(M),className:"w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"}),[j,m,a]),E=L=>{debugger;const M=l.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");f(y,[L]),x(y,M,!0),c(""),u(-1)},N=()=>{if(navigator.clipboard===void 0){sonner.toast.error(m("Clipboard not supported"));return}navigator.clipboard.writeText(S.join(" ")),sonner.toast.success(m("Classes copied to clipboard"))};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-1.5 border-b border-border pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("span",{children:m("Classes")}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactIcons.CopyIcon,{onClick:N,className:"cursor-pointer"})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:m("Copy classes to clipboard")})})]})]}),b?jsxRuntime.jsxs(tooltip.Popover,{children:[jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(tooltip.Button,{variant:"default",className:"h-6 w-fit",size:"sm",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"ml-2",children:m("Ask AI")})]})}),jsxRuntime.jsx(tooltip.PopoverContent,{side:"left",className:"p-2",children:jsxRuntime.jsx(AskAIStyles,{blockId:g==null?void 0:g._id})})]}):null]}),jsxRuntime.jsxs("div",{className:"relative flex items-center gap-x-3",children:[jsxRuntime.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:jsxRuntime.jsx(Autosuggest,{suggestions:I,onSuggestionsFetchRequested:_,onSuggestionsClearRequested:A,getSuggestionValue:B,renderSuggestion:D,inputProps:w,containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border text-xs"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),jsxRuntime.jsx(tooltip.Button,{variant:"outline",className:"h-6 border-border",onClick:C,disabled:j.trim()==="",size:"sm",children:jsxRuntime.jsx(reactIcons.PlusIcon,{})})]}),jsxRuntime.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:S.map((L,M)=>d===M?jsxRuntime.jsx("input",{ref:a,value:l,onChange:O=>c(O.target.value),onBlur:()=>{E(L)},onKeyDown:O=>{O.key==="Enter"&&E(L)},className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"},L):jsxRuntime.jsxs("button",{className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[L,l!==L&&jsxRuntime.jsx(reactIcons.Cross2Icon,{onClick:()=>f(y,[L],!0),className:"invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"})]},L))})]})}const BASIC_UNITS=["px","%","em","rem","ch","vh","vw"],FLEX_CHILD_SECTION={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:BASIC_UNITS,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},GRID_CHILD_SECTION={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},SETTINGS_SECTIONS=[{heading:"Styles",items:[{component:ManualClasses},{component:BreakpointSelector},{type:"arbitrary",label:"layout.width",units:BASIC_UNITS.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:BASIC_UNITS.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...BASIC_UNITS,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"Typography",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:BASIC_UNITS},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:BASIC_UNITS.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"Background",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),[...BASIC_UNITS],BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("-");const BlockStylingProps=()=>{const a=useSelectedBlock(),[l,c]=useSelectedStylingBlocks(),{t:d}=reactI18next.useTranslation();if(!a)return null;const u=Object.keys(a).filter(m=>typeof a[m]=="string"&&a[m].startsWith("#styles:"));if(lodashEs.isEmpty(u)||u.length<=1)return null;const p=m=>lodashEs.find(l,h=>h.prop===m);return jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[jsxRuntime.jsxs("label",{htmlFor:"block-styling-props",className:"py-1 text-xs",children:[d("Style element"),":"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:lodashEs.map(u,m=>jsxRuntime.jsx(tooltip.Badge,{className:"cursor-pointer",onClick:()=>{c([{id:`${m}-${a._id}`,blockId:a._id,prop:m}])},variant:p(m)?"default":"secondary",children:lodashEs.startCase(m)},m))}),jsxRuntime.jsx("div",{className:"my-2 h-[1px] w-full bg-border"})]})},StyleContext=React.createContext({canReset:!1,canChange:!0}),BlockStyleProvider=({children:a,canReset:l=!1,canChange:c=!0})=>jsxRuntime.jsx(StyleContext.Provider,{value:{canReset:l,canChange:c},children:a}),DropDownChoices=({label:a,property:l,onChange:c})=>{const{getClasses:d}=useTailwindClassList(),u=d(l),p=useCurrentClassByProperty(l),m=React.useMemo(()=>lodashEs.get(p,"cls",""),[p]),{canChange:h}=React.useContext(StyleContext),g=/\[.*\]/g.test(m);return jsxRuntime.jsx("div",{className:a?"w-full rounded":"grow",children:g?jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(tooltip.Input,{className:"w-[70%] rounded py-1",readOnly:!0,value:m}),jsxRuntime.jsxs(tooltip.Tooltip,{delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Current value is using a Tailwind arbitrary value."})]})]}):jsxRuntime.jsx(DropDown,{rounded:a,onChange:x=>c(x,l),selected:m,options:u,disabled:!h})})};function DropDown({selected:a,onChange:l,rounded:c=!1,options:d,disabled:u=!1}){const p=a.replace(/.*:/g,"").trim(),{undo:m,redo:h}=useUndoManager();return jsxRuntime.jsxs("select",{disabled:!d.length||u,className:`${c?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:g=>l(g.target.value),onKeyDown:g=>{g.ctrlKey&&(g.key==="z"&&m(),g.key==="y"&&h())},value:p,children:[jsxRuntime.jsx("option",{className:"bg-transparent",value:""}),d.map((g,x)=>jsxRuntime.jsx("option",{className:"bg-transparent",value:g,children:g},`option-${x}`))]})}const COLOR_PROP={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},ColorChoice=({property:a,onChange:l})=>{const c=useCurrentClassByProperty(a),d=React.useMemo(()=>lodashEs.get(c,"cls",""),[c]),{canChange:u}=React.useContext(StyleContext),[p,m]=React.useState([]),[h,g]=React.useState({color:"",shade:""}),x=d.split("-"),f=lodashEs.get(x,"1",""),y=lodashEs.get(x,"2",""),b=React.useCallback(k=>{["current","inherit","transparent","black","white"].includes(k)?(m([]),g({color:k})):(m(["50","100","200","300","400","500","600","700","800","900"]),g(v=>({...v,color:k,shade:v.shade?v.shade:"500"})))},[m,g]);React.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(f))return m([]);m(["50","100","200","300","400","500","600","700","800","900"])},[f]);const j=React.useCallback(k=>{g({color:f,shade:k})},[f]);React.useEffect(()=>{g({color:"",shade:""})},[c]);const{match:R}=useTailwindClassList();return React.useEffect(()=>{const v=`${lodashEs.get(COLOR_PROP,a,"")}-${h.color}${h.shade?`-${h.shade}`:""}`;R(a,v)&&l(v,a)},[R,h,l,a]),jsxRuntime.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[jsxRuntime.jsx("div",{className:"grow text-center",children:jsxRuntime.jsx(DropDown,{disabled:!u,rounded:!0,selected:f,onChange:b,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),jsxRuntime.jsx("button",{type:"button",className:"grow text-center",children:jsxRuntime.jsx(DropDown,{rounded:!0,selected:y,disabled:!f||!u,onChange:j,options:p})})]})},EDITOR_ICONS={"not-italic":()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:reactIcons.EyeOpenIcon,invisible:reactIcons.EyeClosedIcon,hidden:reactIcons.EyeClosedIcon,gap:reactIcons.BorderAllIcon,gapX:reactIcons.WidthIcon,gapY:reactIcons.HeightIcon,spaceX:reactIcons.WidthIcon,spaceY:reactIcons.HeightIcon,overscroll:reactIcons.BorderAllIcon,overscrollX:reactIcons.WidthIcon,overscrollY:reactIcons.HeightIcon,overflow:reactIcons.BorderAllIcon,overflowX:reactIcons.WidthIcon,overflowY:reactIcons.HeightIcon,top:reactIcons.ArrowUpIcon,right:reactIcons.ArrowRightIcon,bottom:reactIcons.ArrowDownIcon,left:reactIcons.ArrowLeftIcon,inset:reactIcons.BorderAllIcon,insetX:reactIcons.WidthIcon,insetY:reactIcons.HeightIcon,border:reactIcons.BorderAllIcon,borderX:reactIcons.WidthIcon,borderY:reactIcons.HeightIcon,borderTop:reactIcons.ArrowUpIcon,borderRight:reactIcons.ArrowRightIcon,borderBottom:reactIcons.ArrowDownIcon,borderLeft:reactIcons.ArrowLeftIcon,borderRadius:reactIcons.BorderAllIcon,borderRadiusX:reactIcons.WidthIcon,borderRadiusY:reactIcons.HeightIcon,borderRadiusTop:reactIcons.ArrowUpIcon,borderRadiusRight:reactIcons.ArrowRightIcon,borderRadiusBottom:reactIcons.ArrowDownIcon,borderRadiusLeft:reactIcons.ArrowLeftIcon,borderRadiusTopLeft:reactIcons.ArrowTopLeftIcon,borderRadiusTopRight:reactIcons.ArrowTopRightIcon,borderRadiusBottomRight:reactIcons.ArrowBottomRightIcon,borderRadiusBottomLeft:reactIcons.ArrowBottomLeftIcon,divideXWidth:reactIcons.WidthIcon,divideYWidth:reactIcons.HeightIcon,scale:reactIcons.BorderAllIcon,scaleX:reactIcons.WidthIcon,scaleY:reactIcons.HeightIcon,skewX:reactIcons.WidthIcon,skewY:reactIcons.HeightIcon,translateX:reactIcons.WidthIcon,translateY:reactIcons.HeightIcon,padding:reactIcons.BorderAllIcon,paddingX:reactIcons.WidthIcon,paddingY:reactIcons.HeightIcon,paddingTop:reactIcons.ArrowUpIcon,paddingRight:reactIcons.ArrowRightIcon,paddingBottom:reactIcons.ArrowDownIcon,paddingLeft:reactIcons.ArrowLeftIcon,margin:reactIcons.BorderAllIcon,marginX:reactIcons.WidthIcon,marginY:reactIcons.HeightIcon,marginTop:reactIcons.ArrowUpIcon,marginRight:reactIcons.ArrowRightIcon,marginBottom:reactIcons.ArrowDownIcon,marginLeft:reactIcons.ArrowLeftIcon,textLeft:reactIcons.AlignLeftIcon,textCenter:reactIcons.AlignCenterHorizontallyIcon,textRight:reactIcons.AlignRightIcon,textJustify:reactIcons.StretchHorizontallyIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,overline:reactIcons.OverlineIcon,uppercase:reactIcons.LetterCaseUppercaseIcon,block:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":reactIcons.Cross2Icon,fixed:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),jsxRuntime.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:reactIcons.Cross1Icon},IconChoices=({property:a,onChange:l})=>{const{getClasses:c}=useTailwindClassList(),d=c(a),{canChange:u}=React.useContext(StyleContext),p=useCurrentClassByProperty(a),m=React.useMemo(()=>lodashEs.get(p,"cls",""),[p]);return jsxRuntime.jsx("div",{className:"flex grow flex-wrap gap-1",children:lodashEs.map(d,h=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",disabled:!u,onClick:()=>l(h,a),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${m===h?"bg-blue-500 text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:React.createElement(lodashEs.get(EDITOR_ICONS,h,reactIcons.BoxIcon))})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(h))})]}))})},RangeChoices=({property:a,onChange:l})=>{const{canReset:c,canChange:d}=React.useContext(StyleContext),u=useCurrentClassByProperty(a),p=React.useMemo(()=>lodashEs.get(u,"cls",""),[u]),{getClasses:m}=useTailwindClassList(),h=m(a,[""]),g=h.indexOf(p)>-1?h.indexOf(p):0,x=/\[.*\]/g.test(p);return jsxRuntime.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:x?jsxRuntime.jsx("div",{className:"px-2 py-[5px]",children:p}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!d&&(!c||g-1<0),onClick:()=>l(lodashEs.nth(h,g-1),a),children:jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsx(reactIcons.MinusIcon,{className:!d&&(!c||g-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),jsxRuntime.jsx("div",{className:"w-8/12 text-center",children:jsxRuntime.jsx(DropDownChoices,{label:!1,property:a,onChange:l})}),jsxRuntime.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!d&&(!c||g+1>=h.length),onClick:()=>l(lodashEs.nth(h,g+1),a),children:jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:!d&&(!c||g+1>=h.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})},getUserInputValues=(a,l)=>{a=a.toLowerCase();let c=a.trim().replace(/ |\+/g,"");if((c==="auto"||c==="none")&&l.includes(c))return{value:"",unit:c};const d=l.length?new RegExp(l.join("|"),"g"):/XXXXXX/g;c=c.replace(d,"");const u=a.match(d),p=u&&u.length>1,m=!lodashEs.isEmpty(c)&&Number.isNaN(Number(c));return p||m?{error:"Invalid value"}:u&&(u[0]==="auto"||u[0]==="none")?{value:u[0],unit:""}:{value:c,unit:u?u[0]:""}},getTwClassValue=a=>{const l=a.startsWith("-")?"-":"",c=a.split("-").pop();if(["auto","none"].includes(c))return{value:"",unit:c};if(c==="px")return{value:"1",unit:"px"};if(c==="screen")return{value:"100",unit:a.indexOf("w-")!==-1?"vw":"vh"};if(c==="full")return{value:"100",unit:"%"};if(lodashEs.includes(a,"skew-"))return{value:`${l}${c}`,unit:"deg"};if(lodashEs.includes(a,"rotate-"))return{value:`${l}${c}`,unit:"deg"};if(lodashEs.includes(a,"opacity-"))return{value:`${c/100}`,unit:"-"};if(lodashEs.includes(a,"duration-")||lodashEs.includes(a,"delay-"))return{value:`${c}`,unit:"ms"};if(lodashEs.includes(a,"translate-")&&!c.includes("/"))return{value:`${l}${`${c/4}`}`,unit:"rem"};if(lodashEs.includes(a,"scale-"))return{value:`${l}${`${c/100}`}`,unit:"-"};if(lodashEs.startsWith(a,"border")){const d=a.match(/border-?(x|y|t|r|b|l)?\d+/g);if(d)return{value:d[0].split("-").pop(),unit:"px"};if(a.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(lodashEs.startsWith(a,"max-w-")){if(a==="max-w-screen-sm")return{value:"640",unit:"px"};if(a==="max-w-screen-md")return{value:"768",unit:"px"};if(a==="max-w-screen-lg")return{value:"1024",unit:"px"};if(a==="max-w-screen-xl")return{value:"1280",unit:"px"};if(a==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(c==="xs")return{value:"320",unit:"px"};if(c==="sm")return{value:"384",unit:"px"};if(c==="md")return{value:"448",unit:"px"};if(c==="lg")return{value:"512",unit:"px"};if(c==="xl")return{value:"576",unit:"px"};if(c==="2xl")return{value:"672",unit:"px"};if(c==="3xl")return{value:"768",unit:"px"};if(c==="4xl")return{value:"896",unit:"px"};if(c==="5xl")return{value:"1024",unit:"px"};if(c==="6xl")return{value:"1152",unit:"px"};if(c==="7xl")return{value:"1280",unit:"px"};if(c==="prose")return{value:"65",unit:"ch"}}if(lodashEs.startsWith(a,"text-")){if(c==="xs")return{value:"12",unit:"px"};if(c==="sm")return{value:"14",unit:"px"};if(c==="base")return{value:"16",unit:"px"};if(c==="lg")return{value:"18",unit:"px"};if(c==="xl")return{value:"20",unit:"px"};if(c==="2xl")return{value:"24",unit:"px"};if(c==="3xl")return{value:"30",unit:"px"};if(c==="4xl")return{value:"36",unit:"px"};if(c==="5xl")return{value:"48",unit:"px"};if(c==="6xl")return{value:"60",unit:"px"};if(c==="7xl")return{value:"72",unit:"px"};if(c==="8xl")return{value:"96",unit:"px"};if(c==="9xl")return{value:"128",unit:"px"}}if(lodashEs.startsWith(a,"leading-")){if(c==="none")return{value:"1",unit:"-"};if(c==="tight")return{value:"1.25",unit:"-"};if(c==="snug")return{value:"1.375",unit:"-"};if(c==="normal")return{value:"1.5",unit:"-"};if(c==="relaxed")return{value:"1.625",unit:"-"};if(c==="loose")return{value:"2",unit:"-"}}if(lodashEs.startsWith(a,"tracking-")){if(c==="tighter")return{value:"-0.05",unit:"em"};if(c==="tight")return{value:"-0.025",unit:"em"};if(c==="normal")return{value:"0",unit:"em"};if(c==="wide")return{value:"0.025",unit:"em"};if(c==="wider")return{value:"0.05",unit:"em"};if(c==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(c))return{value:a,unit:"class"};if(c.includes("/")){const[d,u]=lodashEs.map(c.split("/"),p=>parseInt(p,10));return{value:l+(d/u*100).toFixed(2).replace(".00",""),unit:"%"}}return lodashEs.isNumber(parseFloat(c))?{value:`${l+parseFloat(c)*4}`,unit:"px"}:{value:c,unit:"class"}},getClassValueAndUnit=a=>{if(lodashEs.isEmpty(a))return{value:"",unit:""};const l=a.match(/\[.*\]/g);if(l===null)return getValueAndUnitForTWClass(a);const c=lodashEs.get(l,"0","").replace(/\[|\]/g,""),d=a.startsWith("-")?"-":"",u=lodashEs.first(c.match(/\d+.\d+|\d+/g));return{value:`${d}${u}`,unit:c.replace(u,"")}},getValueAndUnitForTWClass=a=>lodashEs.isEmpty(a)?{value:"",unit:""}:getTwClassValue(a),BlockSettingsContext=React.createContext({setDragData:()=>{}}),DragStyleButton=({unit:a,currentValue:l,onDrag:c,onDragEnd:d,onDragStart:u,negative:p,cssProperty:m})=>{const{setDragData:h}=React.useContext(BlockSettingsContext);return jsxRuntime.jsx("button",{type:"button",onMouseDown:g=>{const x={onDrag:c,onDragEnd:d,dragging:!0,dragStartY:g.pageY,dragStartValue:`${l}`,dragUnit:a,negative:p,cssProperty:m};u(x),h(x)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:jsxRuntime.jsx(reactIcons.RowSpacingIcon,{})})},UnitSelection=({onSelect:a,current:l,units:c})=>jsxRuntime.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:c.map(d=>jsxRuntime.jsx(tooltip.Button,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:l===d?"primary":void 0,size:"sm",onClick:u=>{u.stopPropagation(),a(d)},children:d},d))}),THROTTLE_TIME=50,AdvanceChoices=a=>{const[l,c]=React.useState(!1),[d,u]=React.useState(""),{currentClass:p,onChange:m,classPrefix:h,cssProperty:g,units:x,negative:f}=a,[y,b]=React.useState(g!=null&&g.toLowerCase().includes("width")?"%":x[0]),[j,R]=React.useState(!1),[k,v]=React.useState(""),[S,C]=React.useState(!1),[I,T]=React.useState(!1);React.useEffect(()=>{const{value:w,unit:E}=getClassValueAndUnit(p);if(E===""){u(w),b(g!=null&&g.toLowerCase().includes("width")?"%":lodashEs.first(x));return}b(E),u(E==="class"||lodashEs.isEmpty(w)?"":w)},[p,g,x]);const _=web.useThrottledCallback(w=>m(w),[m],THROTTLE_TIME),A=web.useThrottledCallback(w=>m(w,!1),[m],THROTTLE_TIME),B=React.useCallback((w=!1)=>{const E=getUserInputValues(`${d}`,x);if(lodashEs.get(E,"error",!1)){R(!0);return}const N=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):y;if(N==="auto"||N==="none"){_(`${h}${N}`);return}if(lodashEs.get(E,"value")==="")return;const L=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${h}[${lodashEs.get(E,"value","").replace("-","")}${N==="-"?"":N}]`;w?A(L):_(L)},[_,A,d,y,h,x]),D=React.useCallback(w=>{const E=getUserInputValues(`${d}`,x);if(lodashEs.get(E,"error",!1)){R(!0);return}if(w==="auto"||w==="none"){_(`${h}${w}`);return}if(lodashEs.get(E,"value")==="")return;const N=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):w,L=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${h}[${lodashEs.get(E,"value","").replace("-","")}${N==="-"?"":N}]`;_(L)},[_,d,h,x]);return jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx("div",{className:"flex items-center justify-start",children:y==="class"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{className:"h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:p}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Current value is using a Tailwind preset class."})]})]}):jsxRuntime.jsxs("div",{className:`group relative flex items-center ${S?"z-auto":""}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(y)!==-1?null:jsxRuntime.jsx("input",{readOnly:y==="class",onKeyPress:w=>{w.key==="Enter"&&B()},onKeyDown:w=>{if(w.keyCode!==38&&w.keyCode!==40)return;w.preventDefault(),T(!0);const E=lodashEs.parseInt(w.target.value);let N=lodashEs.isNaN(E)?0:E;w.keyCode===38&&(N+=1),w.keyCode===40&&(N-=1);const P=`${N}`,M=`${P.startsWith("-")?"-":""}${h}[${P.replace("-","")}${y==="-"?"":y}]`;A(M)},onKeyUp:w=>{I&&(w.preventDefault(),T(!1))},onBlur:()=>B(),onChange:w=>{R(!1),u(w.target.value)},onClick:w=>{var E;(E=w==null?void 0:w.target)==null||E.select(),c(!1)},value:S?k:d,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",j?"border-red-500 text-red-500":"border-foreground/20")}),jsxRuntime.jsxs(tooltip.Tooltip,{open:l,delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(!l),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[jsxRuntime.jsx("span",{className:`inline-block ${x.length===1?"px-2 font-semibold":""}`,children:y}),x.length>1?jsxRuntime.jsx(reactIcons.TriangleDownIcon,{}):null]})}),jsxRuntime.jsx(tooltip.TooltipPortal,{children:jsxRuntime.jsx(tooltip.TooltipContent,{className:"bg-background",children:jsxRuntime.jsx(UnitSelection,{units:x,current:y,onSelect:w=>{c(!1),b(w),D(w)}})})})]})]}),["none","auto"].indexOf(y)!==-1||S?null:jsxRuntime.jsx(DragStyleButton,{onDragStart:()=>C(!0),onDragEnd:w=>{if(v(()=>""),C(!1),lodashEs.isEmpty(w))return;const E=`${w}`,P=`${E.startsWith("-")?"-":""}${h}[${E.replace("-","")}${y==="-"?"":y}]`;_(P)},onDrag:w=>{if(lodashEs.isEmpty(w))return;v(w);const E=`${w}`,P=`${E.startsWith("-")?"-":""}${h}[${E.replace("-","")}${y==="-"?"":y}]`;A(P)},currentValue:d,unit:y,negative:f,cssProperty:g})]})})})},useCurrentClassByProperty=a=>{const l=useSelectedBlockCurrentClasses();return lodashEs.findLast(l,{property:a})},canChangeClass=(a,l)=>{const c={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return c[lodashEs.get(a,"mq","xs")]<=c[l]},CLASS_PREFIXES={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},BREAKPOINTS={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},getBreakpoint=a=>`${a.toUpperCase()} ${BREAKPOINTS[a]?`(${BREAKPOINTS[a]} & up)`:""}`,BlockStyle=a=>{const{t:l}=reactI18next.useTranslation(),{type:c="icons",label:d,property:u,onEmitChange:p=()=>{},units:m,negative:h=!1}=a,[g]=useDarkMode(),[x]=useStylingState(),[,f]=useScreenSizeWidth(),y=useCurrentClassByProperty(u),b=useAddClassesToBlocks(),j=useRemoveClassesFromBlocks(),[R]=useSelectedBlockIds(),k=React.useMemo(()=>lodashEs.get(y,"fullCls",""),[y]),v=React.useCallback((A,B=!0)=>{const D={dark:g,mq:f,mod:x,cls:A,property:u,fullCls:""};(g||x!=="")&&(D.mq="xs");const w=generateFullClsName(D);b(R,[w],B)},[R,g,f,x,u,b]),S=React.useCallback(()=>{j(R,[k],!0)},[R,k,j]),C=React.useMemo(()=>canChangeClass(y,f),[y,f]);React.useEffect(()=>{p(C,y)},[C,p,y]);const[,,I]=useScreenSizeWidth(),T=React.useCallback(A=>{I({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[A])},[I]),_=lodashEs.get(y,"dark",null)===g&&lodashEs.get(y,"mod",null)===x&&lodashEs.get(y,"mq",null)===f;return jsxRuntime.jsx(BlockStyleProvider,{canChange:C,canReset:y&&_,children:jsxRuntime.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[jsxRuntime.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:jsxRuntime.jsx("span",{className:`text-[11px] ${y&&!_?"text-foreground":""}`,children:l(d)})}),jsxRuntime.jsxs("div",{className:"flex flex-row items-center",children:[jsxRuntime.jsxs("div",{className:"w-[150px]",children:[c==="arbitrary"?jsxRuntime.jsx(AdvanceChoices,{currentClass:lodashEs.get(y,"cls",""),classPrefix:lodashEs.get(CLASS_PREFIXES,u,""),units:m||[],onChange:v,negative:h,cssProperty:u}):null,c==="icons"&&jsxRuntime.jsx(IconChoices,{property:u,onChange:v}),c==="range"&&jsxRuntime.jsx(RangeChoices,{property:u,onChange:v}),c==="color"&&jsxRuntime.jsx(ColorChoice,{property:u,onChange:v}),c==="dropdown"&&jsxRuntime.jsx(DropDownChoices,{label:d,property:u,onChange:v})]}),jsxRuntime.jsx("div",{className:`w-[30px] cursor-pointer ${k?"visible":"invisible"}`,children:_?jsxRuntime.jsx("button",{type:"button",onClick:()=>S(),title:"Reset",className:"flex px-1.5 text-xs",children:jsxRuntime.jsx(reactIcons.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):C&&y?jsxRuntime.jsxs(tooltip.Tooltip,{delayDuration:100,children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",children:jsxRuntime.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs("div",{children:["Current style is set at ",jsxRuntime.jsxs("span",{className:"font-bold",children:[getBreakpoint(lodashEs.get(y,"mq")),g&&!y.dark?"(Light mode)":""]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>T(lodashEs.get(y,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",lodashEs.get(y,"mq").toUpperCase()]})]})})})]}):null})]})]})})},basicUnits=["px","%","em","rem","ch","vh","vw"],MultipleChoices=({label:a,options:l,borderB:c=!1,borderT:d=!1,type:u="arbitrary",units:p=basicUnits,negative:m=!1})=>{const{t:h}=reactI18next.useTranslation(),[g,x]=React.useState(l[0].key),f=useSelectedBlockCurrentClasses(),y=React.useCallback(b=>lodashEs.map(f,"property").includes(b),[f]);return jsxRuntime.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${c?"border-b":""} ${d?"border-t":""}`,children:[jsxRuntime.jsxs("div",{className:"flex flex-row text-xs",children:[a&&jsxRuntime.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:h(a)}),jsxRuntime.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:l.map(({label:b,key:j},R)=>jsxRuntime.jsx("div",{className:"first:rounded-l last:rounded-r",children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(j),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${j===g?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[React.createElement("div",{className:y(j)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),React.createElement(lodashEs.get(EDITOR_ICONS,j,reactIcons.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(b))})]})},`option-${R}`))})]}),jsxRuntime.jsx("div",{className:"mt-0 flex items-center",children:jsxRuntime.jsx(BlockStyle,{type:u,units:[...p],label:"",property:g,negative:m})})]})},NestedOptions=({heading:a,items:l})=>{const{t:c}=reactI18next.useTranslation(),d=useSelectedBlockCurrentClasses(),u=React.useMemo(()=>{const p=g=>lodashEs.flatten(g.map(x=>x.styleType==="multiple"?lodashEs.map(x.options,"key"):x.property)),m=lodashEs.flatten(l.map(g=>g.styleType==="accordion"?p(g.items):g.styleType==="multiple"?lodashEs.map(g.options,"key"):g.property)),h=lodashEs.map(d,"property");return lodashEs.intersection(m,h).length>0},[d,l]);return jsxRuntime.jsxs("details",{children:[jsxRuntime.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:jsxRuntime.jsxs("div",{className:"inline",children:[lodashEs.startCase(c(a.toLowerCase())),u?jsxRuntime.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${u?"bg-blue-500":"bg-gray-300"}`}):null]})}),jsxRuntime.jsx("div",{className:"p-2",children:l.map(p=>p.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...p},p.label):jsxRuntime.jsx(BlockStyle,{...p},p.label))})]})},SectionContext=React.createContext({}),StylingGroup=({section:a,showAccordian:l})=>{const{t:c}=reactI18next.useTranslation(),d=useSelectedBlockCurrentClasses(),u=React.useCallback((m=[])=>{const h={};for(let x=0;x<d.length;x++)h[d[x].property]=d[x].cls;let g=!0;for(const x in m)if(!lodashEs.has(h,x)||h[x]!==m[x]){g=!1;break}return g},[d]),p=React.useMemo(()=>({}),[]);return jsxRuntime.jsx(SectionContext.Provider,{value:p,children:l?jsxRuntime.jsxs(tooltip.AccordionItem,{value:a.heading,className:"border-none",children:[jsxRuntime.jsx(tooltip.AccordionTrigger,{className:"border-slate-150 border-t py-2 text-xs",children:jsxRuntime.jsx("div",{className:"flex items-center py-2",children:jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:lodashEs.startCase(c(a.heading))})})}),jsxRuntime.jsx(tooltip.AccordionContent,{className:"py-2",children:a.items.map(m=>lodashEs.has(m,"component")?React.createElement(m.component,{key:m.label}):lodashEs.has(m,"styleType")?m.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...m},m.label):m.styleType==="accordion"&&u(m==null?void 0:m.conditions)?jsxRuntime.jsx(NestedOptions,{...m},m.label):null:jsxRuntime.jsx(BlockStyle,{...m},m.label))})]}):jsxRuntime.jsx("div",{className:"py-2",children:a.items.map(m=>lodashEs.has(m,"component")?React.createElement(m.component,{key:m.label}):lodashEs.has(m,"styleType")?m.styleType==="multiple"?jsxRuntime.jsx(MultipleChoices,{...m},m.label):m.styleType==="accordion"&&u(m==null?void 0:m.conditions)?jsxRuntime.jsx(NestedOptions,{...m},m.label):null:jsxRuntime.jsx(BlockStyle,{...m},m.label))})})},MAPPER={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function BlockStyling(){const{flexChild:a,gridChild:l}=useSelectedBlocksDisplayChild(),[c]=useSelectedStylingBlocks(),[d,u]=React.useState(""),[p,m]=React.useState({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),h=web.useThrottledCallback(x=>{const f=!lodashEs.get(p,"negative",!1),y=lodashEs.get(p,"cssProperty","");let b=parseFloat(p.dragStartValue);b=isNaN(b)?0:b;let j=MAPPER[p.dragUnit];(lodashEs.startsWith(y,"scale")||y==="opacity")&&(j=10);let k=(p.dragStartY-x.pageY)/j+b;f&&k<0&&(k=0),y==="opacity"&&k>1&&(k=1),p.onDrag(`${k}`),u(`${k}`)},[p],50),g=React.useCallback(()=>{setTimeout(()=>p.onDragEnd(`${d}`),100),m({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[p,d,m]);return lodashEs.isEmpty(c)?null:jsxRuntime.jsxs(BlockSettingsContext.Provider,{value:{setDragData:m},children:[p.dragging?jsxRuntime.jsx("div",{onMouseMove:h,onMouseUp:()=>g(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx(BlockStylingProps,{}),jsxRuntime.jsxs(tooltip.Accordion,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[a&&jsxRuntime.jsx(StylingGroup,{section:FLEX_CHILD_SECTION,showAccordian:a||l}),l&&jsxRuntime.jsx(StylingGroup,{section:GRID_CHILD_SECTION,showAccordian:a||l}),SETTINGS_SECTIONS.map(x=>jsxRuntime.jsx(StylingGroup,{section:x,showAccordian:a||l},x.heading))]})]})]})}const ADD_BLOCK_TABS={},registerChaiAddBlockTab=(a,l)=>{lodashEs.has(ADD_BLOCK_TABS,a)&&console.warn(`Add block tab with id ${a} already registered`),lodashEs.set(ADD_BLOCK_TABS,a,{id:a,...l})},useChaiAddBlockTabs=()=>React.useMemo(()=>lodashEs.values(ADD_BLOCK_TABS),[]),CoreBlock=({block:a,disabled:l,parentId:c,position:d})=>{const[,u]=jotai.useAtom(draggedBlockAtom),{type:p,icon:m,label:h}=a,{addCoreBlock:g,addPredefinedBlock:x}=useAddBlock(),[,f]=useSelectedBlockIds(),{clearHighlight:y}=useBlockHighlight(),b=()=>{if(console.log("addBlockToPage",a),lodashEs.has(a,"blocks")){const k=lodashEs.isFunction(a.blocks)?a.blocks():a.blocks;x(runtime.syncBlocksWithDefaults(k),c||null,d)}else g(a,c||null,d);pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},j=flagged.useFeature("dnd"),{t:R}=reactI18next.useTranslation();return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("button",{disabled:l,onClick:b,type:"button",onDragStart:k=>{k.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.omit(a,["component","icon"]))),k.dataTransfer.setDragImage(new Image,0,0),u(lodashEs.omit(a,["component","icon"])),setTimeout(()=>{f([]),y()},200)},draggable:j?"true":"false",className:"cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",children:[React.createElement(m||reactIcons.BoxIcon,{className:"w-4 h-4 mx-auto"}),jsxRuntime.jsx("p",{className:"truncate text-xs",children:lodashEs.capitalize(R(h||p))})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:R(h||p)})})]})})},DefaultChaiBlocks=({parentId:a,position:l,gridCols:c="grid-cols-2"})=>{const d=runtime.useRegisteredChaiBlocks(),u=lodashEs.groupBy(d,"category"),p=lodashEs.uniq(lodashEs.map(u.core,"group"));return jsxRuntime.jsx(ChaiBuilderBlocks,{gridCols:c,parentId:a,position:l,groups:p,blocks:u.core})},hasVideoEmbed=a=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,c=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(a)||c.test(a)},getVideoURLFromHTML=a=>{if(lodashEs.isEmpty(a))return a;const l=/<video[^>]+src=['"]([^'">]+)['"]/,c=/<iframe[^>]+src=['"]([^'">]+)['"]/,d=a.match(l),u=a.match(c),p=d?d[1]:u?u[1]:null,m=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,h=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return p&&(m.test(p)||h.test(p))?p:a},NAME_ATTRIBUTES=["chai-name","data-chai-name"],ATTRIBUTE_MAP={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},shouldAddText=(a,l)=>a.children.length===1&&lodashEs.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),getTextContent=a=>a.map(l=>l.type==="text"?lodashEs.get(l,"content",""):lodashEs.isEmpty(l.children)?"":getTextContent(l.children)).join(""),getSanitizedValue=a=>a===null?"":a,getAttrs=a=>{if(a.tagName==="svg")return{};const l={},c=ATTRIBUTE_MAP[a.tagName]||{},d=a.attributes;return lodashEs.forEach(d,({key:u,value:p})=>{if(!lodashEs.includes(NAME_ATTRIBUTES,u))if(c[u]){if(a.tagName==="img"&&u==="src"&&!p.startsWith("http")){const m=lodashEs.find(a.attributes,{key:"width"}),h=lodashEs.find(a.attributes,{key:"height"});m&&h?p=`https://via.placeholder.com/${m==null?void 0:m.value}x${h==null?void 0:h.value}`:p="https://via.placeholder.com/150x150"}lodashEs.set(l,c[u],getSanitizedValue(p))}else lodashEs.includes(["style","class","srcset"],u)||(lodashEs.has(l,"styles_attrs")||(l.styles_attrs={}),lodashEs.startsWith(u,"@")&&(u=u.replace("@","x-on:")),l.styles_attrs[`${u}`]=getSanitizedValue(p))}),delete l.class,l},getStyles=(a,l="styles")=>{if(!a.attributes)return{[l]:`${getSplitClasses.STYLES_KEY},`};const c=lodashEs.find(a.attributes,{key:"class"});if(c){const d=c.value;return{[l]:`${getSplitClasses.STYLES_KEY},${d}`}}return{[l]:`${getSplitClasses.STYLES_KEY},`}},getBlockProps=a=>{const l=lodashEs.get(a,"attributes",[]),c=l.find(h=>h.key==="data-chai-richtext"||h.key==="chai-richtext"),d=l.find(h=>h.key==="data-chai-lightbox"||h.key==="chai-lightbox"),u=l.find(h=>h.key==="data-chai-dropdown"||h.key==="chai-dropdown"),p=l.find(h=>h.key==="data-chai-dropdown-button"||h.key==="chai-dropdown-button"),m=l.find(h=>h.key==="data-chai-dropdown-content"||h.key==="chai-dropdown-content");if(u)return{_type:"Dropdown"};if(p)return{_type:"DropdownButton"};if(m)return{_type:"DropdownContent"};if(c)return{_type:"RichText"};if(d)return{_type:"LightBoxLink"};switch(a.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:a.tagName,_listType:a.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:a.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:a.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:a.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:a.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const h=lodashEs.get(a,"children",[]).length>0?"Box":"EmptyBox";return{_type:h,tag:a.tagName,_name:h=="EmptyBox"||a.tagName==="div"?h:lodashEs.capitalize(a.tagName)}}}},traverseNodes=(a,l=null)=>lodashEs.flatMapDeep(a,c=>{var y,b,j,R,k,v,S,C;if(c.type==="comment")return[];console.log("node ===>",c);let d={_id:Functions.generateUUID()};if(l&&(d._parent=l.block._id),c.type==="text")return lodashEs.isEmpty(lodashEs.get(c,"content",""))?[]:l&&shouldAddText(l.node,l.block)?(lodashEs.set(l,"block.content",lodashEs.get(c,"content","")),[]):{...d,_type:"Text",content:lodashEs.get(c,"content","")};const u=lodashEs.get(c,"attributes",[]),p=u.find(I=>I.key==="data-chai-richtext"||I.key==="chai-richtext"),m=u.find(I=>I.key==="data-chai-lightbox"||I.key==="chai-lightbox"),h=u.find(I=>I.key==="data-chai-dropdown"||I.key==="chai-dropdown"),g=u.find(I=>I.key==="data-chai-dropdown-button"||I.key==="chai-dropdown-button"),x=u.find(I=>I.key==="data-chai-dropdown-content"||I.key==="chai-dropdown-content");if(d={...d,...getBlockProps(c),...getAttrs(c),...getStyles(c)},c.attributes){const I=c.attributes.find(T=>lodashEs.includes(NAME_ATTRIBUTES,T.key));I&&(d._name=I.value)}if(p)return d.content=himalaya.stringify(c.children),lodashEs.has(d,"styles_attrs.data-chai-richtext")&&delete d.styles_attrs["data-chai-richtext"],lodashEs.has(d,"styles_attrs.chai-richtext")&&delete d.styles_attrs["chai-richtext"],[d];if(m){const I=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];d={...d,href:((y=u.find(T=>T.key==="href"))==null?void 0:y.value)||"",hrefType:((b=u.find(T=>T.key==="data-vbtype"))==null?void 0:b.value)||"video",autoplay:((j=u.find(T=>T.key==="data-autoplay"))==null?void 0:j.value)==="true"?"true":"false",maxWidth:((k=(R=u.find(T=>T.key==="data-maxwidth"))==null?void 0:R.value)==null?void 0:k.replace("px",""))||"",backdropColor:((v=u.find(T=>T.key==="data-overlay"))==null?void 0:v.value)||"",galleryName:((S=u.find(T=>T.key==="data-gall"))==null?void 0:S.value)||""},lodashEs.forEach(I,T=>{lodashEs.has(d,`styles_attrs.${T}`)&&delete d.styles_attrs[T]})}if(h&&(delete d.styles_attrs,d.showDropdown=!1),x&&delete d.styles_attrs,g){delete d.styles_attrs;const I=lodashEs.filter(c.children||[],_=>(_==null?void 0:_.tagName)!=="span");d.content=getTextContent(I);const T=lodashEs.find(c.children||[],_=>(_==null?void 0:_.tagName)==="span"&&lodashEs.some(_.children||[],A=>(A==null?void 0:A.tagName)==="svg"));if(T){const _=lodashEs.find(T.children||[],A=>(A==null?void 0:A.tagName)==="svg");if(_){d.icon=himalaya.stringify([_]);const{height:A,width:B}=getSvgDimensions(_,"16px","16px");d.iconHeight=A,d.iconWidth=B}}return[d]}if(d._type==="Input"){const I=d.inputType||"text";I==="checkbox"?lodashEs.set(d,"_type","Checkbox"):I==="radio"&&lodashEs.set(d,"_type","Radio")}else if(c.tagName==="video"||c.tagName==="iframe"){const I=himalaya.stringify([c]);return hasVideoEmbed(I)&&(lodashEs.set(d,"_type","Video"),lodashEs.set(d,"url",getVideoURLFromHTML(I)),lodashEs.set(d,"styles",`${getSplitClasses.STYLES_KEY},`),lodashEs.set(d,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),d.content=I,[d]}else if(c.tagName==="svg"){const I=lodashEs.find(c.attributes,{key:"height"}),T=lodashEs.find(c.attributes,{key:"width"}),_=lodashEs.get(I,"value")?`[${lodashEs.get(I,"value")}px]`:"24px",A=lodashEs.get(T,"value")?`[${lodashEs.get(T,"value")}px]`:"24px",B=lodashEs.get(lodashEs.find(c.attributes,{key:"class"}),"value","w-full h-full");return d.styles=`${getSplitClasses.STYLES_KEY}, ${Functions.cn(`w-${A} h-${_}`,B)}`.trim(),c.attributes=lodashEs.filter(c.attributes,D=>!lodashEs.includes(["style","width","height","class"],D.key)),d.icon=himalaya.stringify([c]),[d]}else if(c.tagName=="option"&&l&&((C=l.block)==null?void 0:C._type)==="Select")return l.block.options.push({label:getTextContent(c.children),...getAttrs(c)}),[];const f=traverseNodes(c.children,{block:d,node:c});return[d,...f]}),getSvgDimensions=(a,l,c)=>{const d=lodashEs.get(a,"attributes",[]),u=lodashEs.find(d,{key:"height"}),p=lodashEs.find(d,{key:"width"});return{height:lodashEs.get(u,"value")?`[${lodashEs.get(u,"value")}px]`:c,width:lodashEs.get(p,"value")?`[${lodashEs.get(p,"value")}px]`:l}},getSanitizedHTML=a=>{a=a.replace(/(\w+)=\\?"(.*?)\\?"/g,(d,u,p)=>{let m=p.replace(/\\"/g,'"');return m=m.replace(/{([^}]+)}/g,h=>h.replace(/"/g,'\\"')),`${u}="${m.replace(/\\"/g,'"')}"`}),a=a.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),a=a.replace(/\$name="[^"]*"/g,"");const l=a.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):a).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},getBlocksFromHTML=a=>{const l=himalaya.parse(getSanitizedHTML(a));return lodashEs.isEmpty(a)?[]:lodashEs.flatten(traverseNodes(l))},ImportHTML=({parentId:a,position:l})=>{const{t:c}=reactI18next.useTranslation(),[d,u]=React.useState(""),{addPredefinedBlock:p}=useAddBlock(),m=()=>{const h=getBlocksFromHTML(d);p([...h],a,l),u(""),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)};return jsxRuntime.jsxs(tooltip.Card,{className:"border-border/0 p-0 shadow-none",children:[jsxRuntime.jsx(tooltip.CardHeader,{className:"p-3",children:jsxRuntime.jsx(tooltip.CardDescription,{children:c("Use HTML snippets from Tailwind CSS component libraries")})}),jsxRuntime.jsx(tooltip.CardContent,{className:"space-y-2 px-3 py-0",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"current",className:"text-sm",children:c("Tailwind HTML snippet")}),jsxRuntime.jsx(tooltip.Textarea,{autoFocus:!0,tabIndex:1,ref:h=>h&&h.focus(),onChange:h=>u(h.target.value),rows:12,value:d,placeholder:c("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),jsxRuntime.jsx(tooltip.CardFooter,{className:"flex flex-col justify-end p-3",children:jsxRuntime.jsx(tooltip.Button,{disabled:d.trim()==="",onClick:()=>m(),size:"sm",className:"w-fit",children:c("Import HTML")})})]})},partialBlocksDataAtom=jotai.atom({blocks:[],groups:[],isLoading:!0,error:null}),hasInitializedPartialBlocksAtom=jotai.atom(!1),formatReadableName=a=>{if(!a)return"";let l=a.replace(/[-_]/g," ");return l=l.replace(/([a-z])([A-Z])/g,"$1 $2"),l.split(" ").map(c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()).join(" ")},PartialBlocks=({parentId:a,position:l,gridCols:c="grid-cols-2"})=>{const{data:d,isLoading:u,refetch:p,error:m}=usePartialBlocksList(),[h,g]=jotai.useAtom(partialBlocksDataAtom),[x,f]=jotai.useAtom(hasInitializedPartialBlocksAtom);React.useEffect(()=>{if(!x||Object.keys(h.blocks).length===0)if(m)g({blocks:[],groups:[],isLoading:!1,error:m}),f(!0);else if(!u&&Object.keys(d||{}).length>0){const b=Object.entries(d).map(([R,k])=>{const v=k,S=v.type||"partial",C=formatReadableName(S);return{type:"PartialBlock",label:formatReadableName(v.name||R),description:v.description||"",icon:lucideReact.Globe,group:C,category:"partial",partialBlockId:R,_name:v.name}}),j=lodashEs.uniq(lodashEs.map(b,"group"));g({blocks:b,groups:j,isLoading:!1,error:null}),f(!0)}else u?g(b=>({...b,isLoading:!0,error:null})):!u&&Object.keys(d||{}).length===0&&(g({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),f(!0))},[u,d,x,f,g,h.blocks,m]);const y=()=>{g(b=>({...b,isLoading:!0,error:null})),f(!1),p()};return h.isLoading?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):h.error||h.blocks.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[jsxRuntime.jsx("p",{children:h.error||"No partial blocks available"}),jsxRuntime.jsx("button",{onClick:y,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):jsxRuntime.jsx(ChaiBuilderBlocks,{gridCols:c,parentId:a,position:l,groups:h.groups,blocks:h.blocks})},ChaiSelect=({defaultValue:a="",onValueChange:l,options:c,placeholder:d="Select",className:u="",height:p=""})=>{const[m,h]=React.useState(a),g=x=>{const f=x.target.value;h(f),l(f)};return jsxRuntime.jsx("div",{className:Functions.cn("relative inline-block w-full",u),children:jsxRuntime.jsxs("select",{className:Functions.cn("mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground 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",p),value:m,onChange:g,children:[jsxRuntime.jsx("option",{value:"",disabled:!0,children:d}),c.map(x=>jsxRuntime.jsx("option",{value:x.value,children:x.label},x.value))]})})};function UILibrariesSelect({uiLibraries:a,library:l,setLibrary:c}){const{t:d}=reactI18next.useTranslation();return l?jsxRuntime.jsxs("div",{className:"h-12",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold text-gray-500",children:d("Choose library")}),jsxRuntime.jsx(ChaiSelect,{className:"mt-1",options:a.map(u=>({value:u.id,label:u.name})),defaultValue:l,onValueChange:u=>c(u)})]}):null}const BlockCard=({block:a,library:l,parentId:c=void 0,position:d=-1})=>{const[u,p]=React.useState(!1),m=useBuilderProp("getUILibraryBlock",lodashEs.noop),{addCoreBlock:h,addPredefinedBlock:g}=useAddBlock(),[,x]=useSelectedBlockIds(),{clearHighlight:f}=useBlockHighlight(),y=lodashEs.get(a,"name",lodashEs.get(a,"label")),b=flagged.useFeature("dnd"),[,j]=jotai.useAtom(draggedBlockAtom),R=S=>{const C=lodashEs.has(S,"styles_attrs.data-page-section");return S._type==="Box"&&C},k=React.useCallback(async S=>{if(S.stopPropagation(),lodashEs.has(a,"component")){h(a,c,d),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);return}p(!0);const C=await m(l,a);lodashEs.isEmpty(C)||g(runtime.syncBlocksWithDefaults(C),c,d),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},[h,g,a,m,l,c,d]),v=async S=>{const C=await m(l,a);let I=c;if(R(lodashEs.first(C))&&(I=null),!lodashEs.isEmpty(C)){const T={blocks:C,uiLibrary:!0,parent:I};if(S.dataTransfer.setData("text/plain",JSON.stringify(T)),a.preview){const _=new Image;_.src=a.preview,_.onload=()=>{S.dataTransfer.setDragImage(_,0,0)}}else S.dataTransfer.setDragImage(new Image,0,0);j(T),setTimeout(()=>{x([]),f(),pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},200)}};return jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{onClick:u?()=>{}:k,draggable:b?"true":"false",onDragStart:v,className:clsx("relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"),children:[u&&jsxRuntime.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"animate-spin",size:15,color:"white"}),jsxRuntime.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),a.preview?jsxRuntime.jsx("img",{src:a.preview,className:"min-h-[45px] w-full rounded-md",alt:y}):jsxRuntime.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border bg-gray-200",children:jsxRuntime.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:y})})]})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:y})})]})},UILibrarySection=({parentId:a,position:l})=>{const[c,d]=jotai.useAtom(selectedLibraryAtom),u=useBuilderProp("uiLibraries",[]),p=u.find(S=>S.id===c)||lodashEs.first(u),{data:m,isLoading:h}=useLibraryBlocks(p),g=lodashEs.groupBy([...m],"group"),[x,f]=React.useState(null);React.useEffect(()=>{x||f(lodashEs.first(lodashEs.keys(g)))},[g,x]);const y=lodashEs.get(g,x,[]),b=React.useRef(null),{t:j}=reactI18next.useTranslation(),R=S=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{b.current&&f(S)},300)};if(h)return jsxRuntime.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[jsxRuntime.jsx(tooltip.Skeleton,{className:"col-span-3 h-full"}),jsxRuntime.jsx(tooltip.Skeleton,{className:"col-span-9 h-full"})]});const k=lodashEs.filter(y,(S,C)=>C%2===0),v=lodashEs.filter(y,(S,C)=>C%2===1);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"relative mt-2 flex h-full max-h-full overflow-hidden bg-background",children:jsxRuntime.jsxs("div",{className:"flex h-full pt-2",children:[jsxRuntime.jsxs("div",{className:"flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2",children:[jsxRuntime.jsx(UILibrariesSelect,{library:p==null?void 0:p.id,setLibrary:d,uiLibraries:u}),jsxRuntime.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-gray-500",children:j("Groups")}),jsxRuntime.jsx("hr",{className:"mt-1 border-border"}),jsxRuntime.jsx("div",{className:"no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20",children:lodashEs.map(g,(S,C)=>jsxRuntime.jsxs("div",{onMouseEnter:()=>R(C),onMouseLeave:()=>clearTimeout(b.current),onClick:()=>f(C),className:Functions.cn("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",C===x?"bg-blue-500 text-white hover:bg-blue-600":""),children:[jsxRuntime.jsx("span",{children:lodashEs.capitalize(j(C.toLowerCase()))}),jsxRuntime.jsx(reactIcons.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},C))})]})]}),jsxRuntime.jsxs(tooltip.ScrollArea,{onMouseEnter:()=>b.current?clearTimeout(b.current):null,className:"z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:k.map((S,C)=>jsxRuntime.jsx(BlockCard,{parentId:a,position:l,block:S,library:p},`block-${C}`))}),jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:v.map((S,C)=>jsxRuntime.jsx(BlockCard,{parentId:a,position:l,block:S,library:p},`block-${C}`))})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})]})})})},UILibrariesPanel=({parentId:a,position:l})=>jsxRuntime.jsx(UILibrarySection,{parentId:a,position:l}),CORE_GROUPS=["basic","typography","media","layout","form","advanced","other"],ChaiBuilderBlocks=({groups:a,blocks:l,parentId:c,position:d,gridCols:u="grid-cols-4"})=>{var w;const{t:p}=reactI18next.useTranslation(),[m]=useBlocksStore(),[h,g]=React.useState(""),x=React.useRef(null),[f]=jotai.useAtom(addBlockTabAtom),y=(w=lodashEs.find(m,E=>E._id===c))==null?void 0:w._type,[b,j]=React.useState("all"),[R,k]=React.useState(null),v=React.useRef(null);React.useEffect(()=>{const E=setTimeout(()=>{var N;(N=x.current)==null||N.focus()},0);return()=>clearTimeout(E)},[f]),React.useEffect(()=>{h&&(j("all"),k(null))},[h]),React.useEffect(()=>(v.current=lodashEs.debounce(E=>{j(E)},500),()=>{v.current&&v.current.cancel()}),[]);const S=React.useCallback(E=>{k(E),v.current&&v.current(E)},[]),C=React.useCallback(()=>{k(null),v.current&&v.current.cancel()},[]),I=React.useCallback(E=>{v.current&&v.current.cancel(),j(E),k(null)},[]),T=React.useMemo(()=>h?lodashEs.values(l).filter(E=>{var N,P;return(((N=E.label)==null?void 0:N.toLowerCase())+" "+((P=E.type)==null?void 0:P.toLowerCase())).includes(h.toLowerCase())}):l,[l,h]),_=React.useMemo(()=>h?a.filter(E=>lodashEs.reject(lodashEs.filter(lodashEs.values(T),{group:E}),{hidden:!0}).length>0):a.filter(E=>lodashEs.reject(lodashEs.filter(lodashEs.values(l),{group:E}),{hidden:!0}).length>0),[l,T,a,h]),A=React.useMemo(()=>lodashEs.sortBy(_,E=>CORE_GROUPS.indexOf(E)===-1?99:CORE_GROUPS.indexOf(E)),[_]),B=React.useMemo(()=>b==="all"?T:lodashEs.filter(lodashEs.values(T),{group:b}),[T,b]),D=React.useMemo(()=>b==="all"?A:[b],[A,b]);return jsxRuntime.jsxs("div",{className:"mx-auto flex h-full w-full max-w-3xl flex-col",children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm",children:jsxRuntime.jsx(tooltip.Input,{ref:x,type:"search",placeholder:p("Search blocks..."),value:h,className:"-ml-2",onChange:E=>g(E.target.value)})}),jsxRuntime.jsxs("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden",children:[A.length>0&&jsxRuntime.jsx("div",{className:"w-1/4 min-w-[120px] border-r",children:jsxRuntime.jsx(tooltip.ScrollArea,{className:"h-full",children:jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("button",{onClick:()=>I("all"),onMouseEnter:()=>S("all"),onMouseLeave:C,className:`w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${b==="all"||R==="all"?"bg-accent text-accent-foreground":"hover:bg-accent/50 hover:text-accent-foreground"}`,children:p("All")},"sidebar-all"),A.map(E=>jsxRuntime.jsx("button",{onClick:()=>I(E),onMouseEnter:()=>S(E),onMouseLeave:C,className:`w-full rounded-md px-2 py-1.5 text-left text-sm ${b===E||R===E?"bg-accent text-accent-foreground":"hover:bg-accent/50 hover:text-accent-foreground"}`,children:lodashEs.capitalize(p(E.toLowerCase()))},`sidebar-${E}`))]})})}),jsxRuntime.jsx("div",{className:"h-full w-3/4 flex-1 overflow-hidden",children:jsxRuntime.jsx(tooltip.ScrollArea,{id:"add-blocks-scroll-area",className:"no-scrollbar mr-4 h-full",children:_.length===0&&h?jsxRuntime.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:jsxRuntime.jsxs("p",{children:[p("No blocks found matching"),' "',h,'"']})}):jsxRuntime.jsx("div",{className:"space-y-6 p-4",children:D.map(E=>jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h3",{className:"px-1 text-sm font-medium",children:lodashEs.capitalize(p(E.toLowerCase()))}),jsxRuntime.jsx("div",{className:"grid gap-2 "+u,children:lodashEs.reject(b==="all"?lodashEs.filter(lodashEs.values(B),{group:E}):lodashEs.values(B),{hidden:!0}).map(N=>jsxRuntime.jsx(CoreBlock,{parentId:c,position:d,block:N,disabled:!canAcceptChildBlock(y,N.type)||!canBeNestedInside(y,N.type)},N.type))})]},E))})})})]})]})},addBlockTabAtom=atomWithStorage("__add_block_tab","library"),AddBlocksPanel=({className:a,showHeading:l=!0,parentId:c=void 0,position:d=-1})=>{const{t:u}=reactI18next.useTranslation(),[p,m]=jotai.useAtom(addBlockTabAtom),[,h]=jotai.useAtom(showPredefinedBlockCategoryAtom),g=useBuilderProp("importHTMLSupport",!0),{data:x}=usePartialBlocksList(),f=Object.keys(x||{}).length>0,{hasPermission:y}=usePermissions();React.useEffect(()=>{p==="partials"&&!f&&m("library")},[p,f,m]);const b=React.useCallback(()=>{pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK)},[]),j=useChaiAddBlockTabs(),R=g&&y(PERMISSIONS.IMPORT_HTML),v=useBuilderProp("uiLibraries",[]).length>0;return React.useEffect(()=>{p==="library"&&!v&&m("core")},[p,v,m]),jsxRuntime.jsxs("div",{className:Functions.cn("flex h-full w-full flex-col overflow-hidden",a),children:[l?jsxRuntime.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[jsxRuntime.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:u("Add block")}),jsxRuntime.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:u(p==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,jsxRuntime.jsxs(tooltip.Tabs,{onValueChange:S=>{h(""),m(S)},value:p,className:"flex h-full max-h-full flex-col overflow-hidden",children:[jsxRuntime.jsxs(tooltip.TabsList,{className:"flex w-full items-center",children:[v&&jsxRuntime.jsx(tooltip.TabsTrigger,{value:"library",children:u("Library")}),jsxRuntime.jsx(tooltip.TabsTrigger,{value:"core",children:u("Blocks")}),f&&jsxRuntime.jsx(tooltip.TabsTrigger,{value:"partials",children:u("Partials")}),R?jsxRuntime.jsx(tooltip.TabsTrigger,{value:"html",children:u("Import")}):null,lodashEs.map(j,S=>jsxRuntime.jsx(tooltip.TabsTrigger,{value:S.id,children:React.createElement(S.tab)},`tab-add-block-${S.id}`))]}),jsxRuntime.jsx(tooltip.TabsContent,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx("div",{className:"-mx-1.5 h-full max-h-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"mt-2 h-full w-full",children:jsxRuntime.jsx(DefaultChaiBlocks,{gridCols:"grid-cols-4",parentId:c,position:d})})})}),v&&jsxRuntime.jsx(tooltip.TabsContent,{value:"library",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx(UILibrariesPanel,{parentId:c,position:d})}),f&&jsxRuntime.jsx(tooltip.TabsContent,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx("div",{className:"-mx-1.5 h-full max-h-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"mt-2 h-full w-full",children:jsxRuntime.jsx(PartialBlocks,{gridCols:"grid-cols-4",parentId:c,position:d})})})}),R?jsxRuntime.jsx(tooltip.TabsContent,{value:"html",className:"h-full max-h-full flex-1 pb-20",children:jsxRuntime.jsx(ImportHTML,{parentId:c,position:d})}):null,lodashEs.map(j,S=>jsxRuntime.jsx(tooltip.TabsContent,{value:S.id,children:React.createElement(S.tabContent,{close:b,parentId:c,position:d})},`panel-add-block-${S.id}`))]})]})},PERMISSIONS={ADD_BLOCK:"add_block",DELETE_BLOCK:"delete_block",EDIT_BLOCK:"edit_block",MOVE_BLOCK:"move_block",EDIT_THEME:"edit_theme",SAVE_PAGE:"save_page",EDIT_STYLES:"edit_styles",IMPORT_HTML:"import_html",CREATE_LIBRARY_BLOCK:"create_library_block",CREATE_LIBRARY_GROUP:"create_library_group",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_GROUP:"edit_library_group",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_GROUP:"delete_library_group"};Object.values(PERMISSIONS);const PasteAtRootContextMenu=({parentContext:a,setParentContext:l})=>{const{t:c}=reactI18next.useTranslation(),{canPaste:d,pasteBlocks:u}=usePasteBlocks();return React.useEffect(()=>{d("root")||l(null)},[d("root")]),!a||!d("root")?null:jsxRuntime.jsx("div",{style:{position:"absolute",top:a.y-75,left:a.x-56},children:jsxRuntime.jsxs(tooltip.DropdownMenu,{open:!0,onOpenChange:()=>l(null),children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{className:"hidden"}),jsxRuntime.jsx(tooltip.DropdownMenuContent,{className:"w-28 p-1 text-xs",children:jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{u("root"),l(null)},children:[jsxRuntime.jsx(reactIcons.CardStackIcon,{})," ",c("Paste")]})})]})})},CopyPasteBlocks=()=>{const[a]=useBlocksStore(),[l]=useSelectedBlockIds(),{pasteBlocks:c}=usePasteBlocks(),[,d]=useCopyBlockIds(),{t:u}=reactI18next.useTranslation(),p=useSelectedBlock(),m=React.useCallback(()=>{const h=l.map(g=>{const x=a.find(f=>f._id===g);return{id:g,data:x}});d(h.map(g=>g.id))},[l,a,d]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDuplicateBlock(p==null?void 0:p._type),onClick:m,className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsx(reactIcons.CopyIcon,{})," ",u("Copy")]}),jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{c(l)},children:[jsxRuntime.jsx(reactIcons.CardStackIcon,{})," ",u("Paste")]})]})},CutBlocks=()=>{const[a]=useSelectedBlockIds(),[,l]=useCutBlockIds(),{t:c}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>l(a),children:[jsxRuntime.jsx(reactIcons.ScissorsIcon,{})," ",c("Cut")]})},RemoveBlocks=()=>{const[a]=useSelectedBlockIds(),l=useRemoveBlocks(),c=useSelectedBlock(),{t:d}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDeleteBlock(c==null?void 0:c._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>l(a),children:[jsxRuntime.jsx(reactIcons.TrashIcon,{})," ",d("Remove")]})},RenameBlock=({node:a})=>{const{t:l}=reactI18next.useTranslation();return jsxRuntime.jsxs(tooltip.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),a.edit(),a.deselect()},className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsx(lucideReact.PencilIcon,{className:"h-4 w-4"})," ",l("Rename")]})},BlockContextMenuContent=({node:a})=>{const{t:l}=reactI18next.useTranslation(),[c]=useSelectedBlockIds(),d=useDuplicateBlocks(),u=useSelectedBlock(),{hasPermission:p}=usePermissions(),m=React.useCallback(()=>{d(c)},[c,d]);return jsxRuntime.jsxs(tooltip.DropdownMenuContent,{side:"bottom",className:"border-border text-xs",children:[p(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canAddChildBlock(u==null?void 0:u._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,u),children:[jsxRuntime.jsx(lucideReact.PlusIcon,{size:"14"})," ",l("Add block")]}),jsxRuntime.jsxs(tooltip.DropdownMenuItem,{disabled:!canDuplicateBlock(u==null?void 0:u._type),className:"flex items-center gap-x-4 text-xs",onClick:m,children:[jsxRuntime.jsx(reactIcons.CardStackPlusIcon,{})," ",l("Duplicate")]})]}),jsxRuntime.jsx(RenameBlock,{node:a}),p(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(CutBlocks,{}),p(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsx(CopyPasteBlocks,{}),p(PERMISSIONS.DELETE_BLOCK)&&jsxRuntime.jsx(RemoveBlocks,{})]})},BlockMoreOptions=({children:a,id:l,node:c})=>{const[,d]=useSelectedBlockIds();return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(tooltip.DropdownMenu,{onOpenChange:u=>{u&&d([l])},children:[jsxRuntime.jsx(tooltip.DropdownMenuTrigger,{children:a}),jsxRuntime.jsx(BlockContextMenuContent,{node:c})]})})},placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:l,left:c}){const d={position:"absolute",pointerEvents:"none",top:l+"px",left:c+"px",right:0};return jsxRuntime.jsx("div",{style:{...placeholderStyle,...d},children:jsxRuntime.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:l,isDragging:c}){return c?jsxRuntime.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:l}):null}),DefaultDragPreview=React.memo(({id:a,isDragging:l,mouse:c})=>{const[d]=useBlocksStore(),u=React.useMemo(()=>d.find(m=>m._id===a),[d,a]),p=React.useMemo(()=>({transform:`translate(${(c==null?void 0:c.x)-10}px, ${(c==null?void 0:c.y)-10}px)`}),[c]);return c?jsxRuntime.jsx("div",{children:jsxRuntime.jsx(Overlay,{isDragging:l,children:jsxRuntime.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:p,children:jsxRuntime.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${u==null?void 0:u._type}`,children:[jsxRuntime.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsx(TypeIcon,{type:u==null?void 0:u._type})}),jsxRuntime.jsx("div",{className:"ml-2 truncate text-[11px]",children:(u==null?void 0:u._name)||(u==null?void 0:u._type)})]})})})}):jsxRuntime.jsx("div",{className:"hidden"})}),defaultShortcuts=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function selectFirst(a){a.firstNode&&a.select(a.firstNode.id)}function selectLast(a){a.lastNode&&a.select(a.lastNode.id)}function selectNext(a){const l=a.selectedNodes[0].next||a.firstNode;a.select(l.id)}function selectPrev(a){const l=a.selectedNodes[0].prev||a.lastNode;a.select(l.id)}const selectParent=(a,l)=>{var d;const c=((d=a.selectedIds[0])==null?void 0:d.parent)||null;c&&l&&a.select(c.id)},open=(a,l)=>{const c=a.selectedNodes[0];c.isInternal&&l&&c.open()},close=(a,l)=>{const c=a.selectedNodes[0];c.isInternal&&l&&c.close()},Input=({node:a})=>{var l,c;return jsxRuntime.jsx("input",{autoFocus:!0,className:cn("ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",a.isSelected?"text-black dark:text-white":""),type:"text",defaultValue:((l=a.data)==null?void 0:l._name)||((c=a.data)==null?void 0:c._type),onFocus:d=>d.currentTarget.select(),onBlur:d=>a.submit(d.currentTarget.value),onKeyDown:d=>{d.key==="Enter"&&a.submit(d.currentTarget.value)}})},currentAddSelection=jotai.atom(null),Node=React.memo(({node:a,style:l,dragHandle:c})=>{var O;const{t:d}=reactI18next.useTranslation(),[u,,p]=useHiddenBlockIds(),[m]=jotai.useAtom(canvasIframeAtom),{hasPermission:h}=usePermissions();let g=null;const x=a.children.length>0,{highlightBlock:f,clearHighlight:y}=useBlockHighlight(),{id:b,data:j,isSelected:R,willReceiveDrop:k,isDragging:v,isEditing:S,handleClick:C}=a,I=Z=>{Z.stopPropagation(),!u.includes(b)&&a.toggle()},T=Z=>{Z.isInternal&&(g=Z.isOpen,Z.isOpen&&Z.close())},_=Z=>{Z.isInternal&&g!==null&&(g?Z.open():Z.close(),g=null)},[A,B]=jotai.useAtom(currentAddSelection),D=()=>{var Z;w(),a.parent.isSelected||B((Z=a==null?void 0:a.parent)==null?void 0:Z.id)},w=()=>{B(null)},E=Z=>{w(),Z.stopPropagation(),!a.isOpen&&!u.includes(b)&&a.toggle(),C(Z)};React.useEffect(()=>{const Z=setTimeout(()=>{k&&!a.isOpen&&!v&&!u.includes(b)&&a.toggle()},500);return()=>clearTimeout(Z)},[k,a,v]);const N=React.useMemo(()=>{const Z=Object.keys(j),V=[];for(let U=0;U<Z.length;U++)if(Z[U].endsWith("_attrs")){const $=j[Z[U]],F=Object.keys($).join("|");F.match(/x-data/)&&V.push("data"),F.match(/x-on/)&&V.push("event"),F.match(/x-show|x-if/)&&V.push("show")}return V},[j]),P=(Z,V)=>{const U=m.contentDocument||m.contentWindow.document,$=U.querySelector(`[data-block-id=${Z}]`);$&&$.setAttribute("data-drop",V);const F=$.getBoundingClientRect(),H=m.getBoundingClientRect();F.top>=H.top&&F.left>=H.left&&F.bottom<=H.bottom&&F.right<=H.right||(U.documentElement.scrollTop=$.offsetTop-H.top)},L=Z=>{w();const V=lodashEs.get(a,"parent.id");V!=="__REACT_ARBORIST_INTERNAL_ROOT__"?pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{_id:V,position:Z}):pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{position:Z})};if(b===getSplitClasses.ROOT_TEMP_KEY)return jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer",children:[jsxRuntime.jsx("br",{}),h(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsx("div",{role:"button",onClick:()=>L(-1),className:"h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-2 w-2 stroke-[3]"})," ",d("Add block")]})}),jsxRuntime.jsx("br",{})]});const M=React.useMemo(()=>lodashEs.has(j,"_libBlockId"),[j]);return jsxRuntime.jsx("div",{className:"w-full",children:jsxRuntime.jsxs("div",{onMouseEnter:()=>f(b),onMouseLeave:()=>y(),onClick:E,style:l,"data-node-id":b,ref:u.includes(b)?null:c,onDragStart:()=>T(a),onDragEnd:()=>_(a),onDragOver:Z=>{Z.preventDefault(),P(b,"yes")},onDragLeave:Z=>{Z.preventDefault(),P(b,"no")},onDrop:Z=>{Z.preventDefault(),P(b,"no")},children:[h(PERMISSIONS.ADD_BLOCK)&&(a==null?void 0:a.rowIndex)>0&&(a.parent.isOpen&&canAddChildBlock(lodashEs.get(a,"parent.data._type"))||((O=a==null?void 0:a.parent)==null?void 0:O.id)==="__REACT_ARBORIST_INTERNAL_ROOT__")&&jsxRuntime.jsx("div",{className:"group relative ml-5 h-full w-full cursor-pointer",children:jsxRuntime.jsx("div",{onClick:Z=>{Z.stopPropagation(),L(a.childIndex)},onMouseEnter:D,onMouseLeave:w,className:"absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",children:jsxRuntime.jsx("div",{className:"absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500",children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-3 w-3 stroke-[4] text-white"})})})}),jsxRuntime.jsxs("div",{className:cn("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",R?"bg-blue-500 text-white":"hover:bg-slate-200 dark:hover:bg-gray-800",k&&canAcceptChildBlock(j._type,"Icon")?"bg-green-200":"",(a==null?void 0:a.id)===A?"bg-purple-100":"",v&&"opacity-20",u.includes(b)?"opacity-50":""),children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${a.isOpen?"rotate-90":""}`,children:x&&jsxRuntime.jsx("button",{onClick:I,type:"button",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:`h-3 w-3 stroke-[3] ${R?"text-slate-200":"text-slate-400"}`})})}),jsxRuntime.jsxs("div",{className:cn("leading-1 flex items-center",M&&"text-orange-400"),children:[jsxRuntime.jsx(TypeIcon,{type:j==null?void 0:j._type}),S?jsxRuntime.jsx(Input,{node:a}):jsxRuntime.jsxs("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",onDoubleClick:Z=>{Z.stopPropagation(),a.edit(),a.deselect()},children:[jsxRuntime.jsx("span",{children:(j==null?void 0:j._name)||(j==null?void 0:j._type.split("/").pop())}),N.includes("data")&&jsxRuntime.jsx(lucideReact.FileJson,{className:"h-3 w-3 text-orange-600"}),N.includes("event")&&jsxRuntime.jsx(lucideReact.Zap,{className:"h-3 w-3 text-yellow-500"}),N.includes("show")&&jsxRuntime.jsx(lucideReact.EyeOffIcon,{className:"h-3 w-3 text-orange-600"})]})]})]}),jsxRuntime.jsxs("div",{className:"invisible flex items-center space-x-1.5 pr-2 group-hover:visible",children:[canAddChildBlock(j==null?void 0:j._type)&&!u.includes(b)&&h(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(TooltipPrimitive.Tooltip,{children:[jsxRuntime.jsx(TooltipPrimitive.TooltipTrigger,{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{_id:b}),className:"cursor-pointer rounded bg-transparent hover:text-black",asChild:!0,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"h-3 w-3"})}),jsxRuntime.jsx(TooltipPrimitive.TooltipContent,{className:"isolate z-[9999]",side:"left",children:d("Add block")})]}):null,jsxRuntime.jsxs(TooltipPrimitive.Tooltip,{children:[jsxRuntime.jsx(TooltipPrimitive.TooltipTrigger,{onClick:Z=>{Z.stopPropagation(),p(b),a.isOpen&&a.toggle()},className:"cursor-pointer rounded bg-transparent hover:text-black",asChild:!0,children:jsxRuntime.jsx(lucideReact.EyeOffIcon,{size:"15"})}),jsxRuntime.jsx(TooltipPrimitive.TooltipContent,{className:"isolate z-[9999]",side:"left",children:d("Hide block")})]}),jsxRuntime.jsx(BlockMoreOptions,{node:a,id:b,children:jsxRuntime.jsx(lucideReact.MoreVertical,{size:"15"})})]})]})]})})}),r=(a,l,c)=>{if(a&&"reportValidity"in a){const d=tooltip.get(c,l);a.setCustomValidity(d&&d.message||""),a.reportValidity()}},o=(a,l)=>{for(const c in l.fields){const d=l.fields[c];d&&d.ref&&"reportValidity"in d.ref?r(d.ref,c,a):d&&d.refs&&d.refs.forEach(u=>r(u,c,a))}},s$1=(a,l)=>{l.shouldUseNativeValidation&&o(a,l);const c={};for(const d in a){const u=tooltip.get(l.fields,d),p=Object.assign(a[d]||{},{ref:u&&u.ref});if(i(l.names||Object.keys(a),d)){const m=Object.assign({},tooltip.get(c,d));tooltip.set(m,"root",p),tooltip.set(c,d,m)}else tooltip.set(c,d,p)}return c},i=(a,l)=>{const c=n$1(l);return a.some(d=>n$1(d).match(`^${c}\\.\\d+`))};function n$1(a){return a.replace(/\]|\[/g,"")}function n(a,l){for(var c={};a.length;){var d=a[0],u=d.code,p=d.message,m=d.path.join(".");if(!c[m])if("unionErrors"in d){var h=d.unionErrors[0].errors[0];c[m]={message:h.message,type:h.code}}else c[m]={message:p,type:u};if("unionErrors"in d&&d.unionErrors.forEach(function(f){return f.errors.forEach(function(y){return a.push(y)})}),l){var g=c[m].types,x=g&&g[d.code];c[m]=tooltip.appendErrors(m,l,c,u,x?[].concat(x,d.message):d.message)}a.shift()}return c}function s(a,l,c){return c===void 0&&(c={}),function(d,u,p){try{return Promise.resolve(function(m,h){try{var g=Promise.resolve(a[c.mode==="sync"?"parse":"parseAsync"](d,l)).then(function(x){return p.shouldUseNativeValidation&&o({},p),{errors:{},values:c.raw?Object.assign({},d):x}})}catch(x){return h(x)}return g&&g.then?g.then(void 0,h):g}(0,function(m){if(function(h){return Array.isArray(h==null?void 0:h.errors)}(m))return{values:{},errors:s$1(n(m.errors,!p.shouldUseNativeValidation&&p.criteriaMode==="all"),p)};throw m}))}catch(m){return Promise.reject(m)}}}var util;(function(a){a.assertEqual=u=>u;function l(u){}a.assertIs=l;function c(u){throw new Error}a.assertNever=c,a.arrayToEnum=u=>{const p={};for(const m of u)p[m]=m;return p},a.getValidEnumValues=u=>{const p=a.objectKeys(u).filter(h=>typeof u[u[h]]!="number"),m={};for(const h of p)m[h]=u[h];return a.objectValues(m)},a.objectValues=u=>a.objectKeys(u).map(function(p){return u[p]}),a.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{const p=[];for(const m in u)Object.prototype.hasOwnProperty.call(u,m)&&p.push(m);return p},a.find=(u,p)=>{for(const m of u)if(p(m))return m},a.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&isFinite(u)&&Math.floor(u)===u;function d(u,p=" | "){return u.map(m=>typeof m=="string"?`'${m}'`:m).join(p)}a.joinValues=d,a.jsonStringifyReplacer=(u,p)=>typeof p=="bigint"?p.toString():p})(util||(util={}));var objectUtil;(function(a){a.mergeShapes=(l,c)=>({...l,...c})})(objectUtil||(objectUtil={}));const ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=a=>{switch(typeof a){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(a)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(a)?ZodParsedType.array:a===null?ZodParsedType.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&a instanceof Map?ZodParsedType.map:typeof Set<"u"&&a instanceof Set?ZodParsedType.set:typeof Date<"u"&&a instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{get errors(){return this.issues}constructor(l){super(),this.issues=[],this.addIssue=d=>{this.issues=[...this.issues,d]},this.addIssues=(d=[])=>{this.issues=[...this.issues,...d]};const c=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,c):this.__proto__=c,this.name="ZodError",this.issues=l}format(l){const c=l||function(p){return p.message},d={_errors:[]},u=p=>{for(const m of p.issues)if(m.code==="invalid_union")m.unionErrors.map(u);else if(m.code==="invalid_return_type")u(m.returnTypeError);else if(m.code==="invalid_arguments")u(m.argumentsError);else if(m.path.length===0)d._errors.push(c(m));else{let h=d,g=0;for(;g<m.path.length;){const x=m.path[g];g===m.path.length-1?(h[x]=h[x]||{_errors:[]},h[x]._errors.push(c(m))):h[x]=h[x]||{_errors:[]},h=h[x],g++}}};return u(this),d}static assert(l){if(!(l instanceof ZodError))throw new Error(`Not a ZodError: ${l}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(l=c=>c.message){const c={},d=[];for(const u of this.issues)u.path.length>0?(c[u.path[0]]=c[u.path[0]]||[],c[u.path[0]].push(l(u))):d.push(l(u));return{formErrors:d,fieldErrors:c}}get formErrors(){return this.flatten()}}ZodError.create=a=>new ZodError(a);const errorMap=(a,l)=>{let c;switch(a.code){case ZodIssueCode.invalid_type:a.received===ZodParsedType.undefined?c="Required":c=`Expected ${a.expected}, received ${a.received}`;break;case ZodIssueCode.invalid_literal:c=`Invalid literal value, expected ${JSON.stringify(a.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:c=`Unrecognized key(s) in object: ${util.joinValues(a.keys,", ")}`;break;case ZodIssueCode.invalid_union:c="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:c=`Invalid discriminator value. Expected ${util.joinValues(a.options)}`;break;case ZodIssueCode.invalid_enum_value:c=`Invalid enum value. Expected ${util.joinValues(a.options)}, received '${a.received}'`;break;case ZodIssueCode.invalid_arguments:c="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:c="Invalid function return type";break;case ZodIssueCode.invalid_date:c="Invalid date";break;case ZodIssueCode.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(c=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(c=`${c} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?c=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?c=`Invalid input: must end with "${a.validation.endsWith}"`:util.assertNever(a.validation):a.validation!=="regex"?c=`Invalid ${a.validation}`:c="Invalid";break;case ZodIssueCode.too_small:a.type==="array"?c=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?c=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?c=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?c=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:c="Invalid input";break;case ZodIssueCode.too_big:a.type==="array"?c=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?c=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?c=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?c=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?c=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:c="Invalid input";break;case ZodIssueCode.custom:c="Invalid input";break;case ZodIssueCode.invalid_intersection_types:c="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:c=`Number must be a multiple of ${a.multipleOf}`;break;case ZodIssueCode.not_finite:c="Number must be finite";break;default:c=l.defaultError,util.assertNever(a)}return{message:c}};let overrideErrorMap=errorMap;function setErrorMap(a){overrideErrorMap=a}function getErrorMap(){return overrideErrorMap}const makeIssue=a=>{const{data:l,path:c,errorMaps:d,issueData:u}=a,p=[...c,...u.path||[]],m={...u,path:p};if(u.message!==void 0)return{...u,path:p,message:u.message};let h="";const g=d.filter(x=>!!x).slice().reverse();for(const x of g)h=x(m,{data:l,defaultError:h}).message;return{...u,path:p,message:h}},EMPTY_PATH=[];function addIssueToContext(a,l){const c=getErrorMap(),d=makeIssue({issueData:l,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,c,c===errorMap?void 0:errorMap].filter(u=>!!u)});a.common.issues.push(d)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(l,c){const d=[];for(const u of c){if(u.status==="aborted")return INVALID;u.status==="dirty"&&l.dirty(),d.push(u.value)}return{status:l.value,value:d}}static async mergeObjectAsync(l,c){const d=[];for(const u of c){const p=await u.key,m=await u.value;d.push({key:p,value:m})}return ParseStatus.mergeObjectSync(l,d)}static mergeObjectSync(l,c){const d={};for(const u of c){const{key:p,value:m}=u;if(p.status==="aborted"||m.status==="aborted")return INVALID;p.status==="dirty"&&l.dirty(),m.status==="dirty"&&l.dirty(),p.value!=="__proto__"&&(typeof m.value<"u"||u.alwaysSet)&&(d[p.value]=m.value)}return{status:l.value,value:d}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=a=>({status:"dirty",value:a}),OK=a=>({status:"valid",value:a}),isAborted=a=>a.status==="aborted",isDirty=a=>a.status==="dirty",isValid=a=>a.status==="valid",isAsync=a=>typeof Promise<"u"&&a instanceof Promise;function __classPrivateFieldGet(a,l,c,d){if(typeof l=="function"?a!==l||!d:!l.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return l.get(a)}function __classPrivateFieldSet(a,l,c,d,u){if(typeof l=="function"?a!==l||!u:!l.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return l.set(a,c),c}typeof SuppressedError=="function"&&SuppressedError;var errorUtil;(function(a){a.errToObj=l=>typeof l=="string"?{message:l}:l||{},a.toString=l=>typeof l=="string"?l:l==null?void 0:l.message})(errorUtil||(errorUtil={}));var _ZodEnum_cache,_ZodNativeEnum_cache;class ParseInputLazyPath{constructor(l,c,d,u){this._cachedPath=[],this.parent=l,this.data=c,this._path=d,this._key=u}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(a,l)=>{if(isValid(l))return{success:!0,data:l.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const c=new ZodError(a.common.issues);return this._error=c,this._error}}};function processCreateParams(a){if(!a)return{};const{errorMap:l,invalid_type_error:c,required_error:d,description:u}=a;if(l&&(c||d))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return l?{errorMap:l,description:u}:{errorMap:(m,h)=>{var g,x;const{message:f}=a;return m.code==="invalid_enum_value"?{message:f??h.defaultError}:typeof h.data>"u"?{message:(g=f??d)!==null&&g!==void 0?g:h.defaultError}:m.code!=="invalid_type"?{message:h.defaultError}:{message:(x=f??c)!==null&&x!==void 0?x:h.defaultError}},description:u}}class ZodType{get description(){return this._def.description}_getType(l){return getParsedType(l.data)}_getOrReturnCtx(l,c){return c||{common:l.parent.common,data:l.data,parsedType:getParsedType(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}_processInputParams(l){return{status:new ParseStatus,ctx:{common:l.parent.common,data:l.data,parsedType:getParsedType(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}}_parseSync(l){const c=this._parse(l);if(isAsync(c))throw new Error("Synchronous parse encountered promise.");return c}_parseAsync(l){const c=this._parse(l);return Promise.resolve(c)}parse(l,c){const d=this.safeParse(l,c);if(d.success)return d.data;throw d.error}safeParse(l,c){var d;const u={common:{issues:[],async:(d=c==null?void 0:c.async)!==null&&d!==void 0?d:!1,contextualErrorMap:c==null?void 0:c.errorMap},path:(c==null?void 0:c.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)},p=this._parseSync({data:l,path:u.path,parent:u});return handleResult(u,p)}"~validate"(l){var c,d;const u={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)};if(!this["~standard"].async)try{const p=this._parseSync({data:l,path:[],parent:u});return isValid(p)?{value:p.value}:{issues:u.common.issues}}catch(p){!((d=(c=p==null?void 0:p.message)===null||c===void 0?void 0:c.toLowerCase())===null||d===void 0)&&d.includes("encountered")&&(this["~standard"].async=!0),u.common={issues:[],async:!0}}return this._parseAsync({data:l,path:[],parent:u}).then(p=>isValid(p)?{value:p.value}:{issues:u.common.issues})}async parseAsync(l,c){const d=await this.safeParseAsync(l,c);if(d.success)return d.data;throw d.error}async safeParseAsync(l,c){const d={common:{issues:[],contextualErrorMap:c==null?void 0:c.errorMap,async:!0},path:(c==null?void 0:c.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:getParsedType(l)},u=this._parse({data:l,path:d.path,parent:d}),p=await(isAsync(u)?u:Promise.resolve(u));return handleResult(d,p)}refine(l,c){const d=u=>typeof c=="string"||typeof c>"u"?{message:c}:typeof c=="function"?c(u):c;return this._refinement((u,p)=>{const m=l(u),h=()=>p.addIssue({code:ZodIssueCode.custom,...d(u)});return typeof Promise<"u"&&m instanceof Promise?m.then(g=>g?!0:(h(),!1)):m?!0:(h(),!1)})}refinement(l,c){return this._refinement((d,u)=>l(d)?!0:(u.addIssue(typeof c=="function"?c(d,u):c),!1))}_refinement(l){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:l}})}superRefine(l){return this._refinement(l)}constructor(l){this.spa=this.safeParseAsync,this._def=l,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:c=>this["~validate"](c)}}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this)}promise(){return ZodPromise.create(this,this._def)}or(l){return ZodUnion.create([this,l],this._def)}and(l){return ZodIntersection.create(this,l,this._def)}transform(l){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:l}})}default(l){const c=typeof l=="function"?l:()=>l;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:c,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(l){const c=typeof l=="function"?l:()=>l;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:c,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(l){const c=this.constructor;return new c({...this._def,description:l})}pipe(l){return ZodPipeline.create(this,l)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/i,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nanoidRegex=/^[a-z0-9_-]{21}$/i,jwtRegex=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,durationRegex=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4CidrRegex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6Regex=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ipv6CidrRegex=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64urlRegex=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dateRegexSource="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dateRegex=new RegExp(`^${dateRegexSource}$`);function timeRegexSource(a){let l="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return a.precision?l=`${l}\\.\\d{${a.precision}}`:a.precision==null&&(l=`${l}(\\.\\d+)?`),l}function timeRegex(a){return new RegExp(`^${timeRegexSource(a)}$`)}function datetimeRegex(a){let l=`${dateRegexSource}T${timeRegexSource(a)}`;const c=[];return c.push(a.local?"Z?":"Z"),a.offset&&c.push("([+-]\\d{2}:?\\d{2})"),l=`${l}(${c.join("|")})`,new RegExp(`^${l}$`)}function isValidIP(a,l){return!!((l==="v4"||!l)&&ipv4Regex.test(a)||(l==="v6"||!l)&&ipv6Regex.test(a))}function isValidJWT(a,l){if(!jwtRegex.test(a))return!1;try{const[c]=a.split("."),d=c.replace(/-/g,"+").replace(/_/g,"/").padEnd(c.length+(4-c.length%4)%4,"="),u=JSON.parse(atob(d));return!(typeof u!="object"||u===null||!u.typ||!u.alg||l&&u.alg!==l)}catch{return!1}}function isValidCidr(a,l){return!!((l==="v4"||!l)&&ipv4CidrRegex.test(a)||(l==="v6"||!l)&&ipv6CidrRegex.test(a))}class ZodString extends ZodType{_parse(l){if(this._def.coerce&&(l.data=String(l.data)),this._getType(l)!==ZodParsedType.string){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:p.parsedType}),INVALID}const d=new ParseStatus;let u;for(const p of this._def.checks)if(p.kind==="min")l.data.length<p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_small,minimum:p.value,type:"string",inclusive:!0,exact:!1,message:p.message}),d.dirty());else if(p.kind==="max")l.data.length>p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_big,maximum:p.value,type:"string",inclusive:!0,exact:!1,message:p.message}),d.dirty());else if(p.kind==="length"){const m=l.data.length>p.value,h=l.data.length<p.value;(m||h)&&(u=this._getOrReturnCtx(l,u),m?addIssueToContext(u,{code:ZodIssueCode.too_big,maximum:p.value,type:"string",inclusive:!0,exact:!0,message:p.message}):h&&addIssueToContext(u,{code:ZodIssueCode.too_small,minimum:p.value,type:"string",inclusive:!0,exact:!0,message:p.message}),d.dirty())}else if(p.kind==="email")emailRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"email",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="emoji")emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"emoji",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="uuid")uuidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"uuid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="nanoid")nanoidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"nanoid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="cuid")cuidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cuid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="cuid2")cuid2Regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="ulid")ulidRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"ulid",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty());else if(p.kind==="url")try{new URL(l.data)}catch{u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"url",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()}else p.kind==="regex"?(p.regex.lastIndex=0,p.regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"regex",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty())):p.kind==="trim"?l.data=l.data.trim():p.kind==="includes"?l.data.includes(p.value,p.position)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{includes:p.value,position:p.position},message:p.message}),d.dirty()):p.kind==="toLowerCase"?l.data=l.data.toLowerCase():p.kind==="toUpperCase"?l.data=l.data.toUpperCase():p.kind==="startsWith"?l.data.startsWith(p.value)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{startsWith:p.value},message:p.message}),d.dirty()):p.kind==="endsWith"?l.data.endsWith(p.value)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:{endsWith:p.value},message:p.message}),d.dirty()):p.kind==="datetime"?datetimeRegex(p).test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"datetime",message:p.message}),d.dirty()):p.kind==="date"?dateRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"date",message:p.message}),d.dirty()):p.kind==="time"?timeRegex(p).test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.invalid_string,validation:"time",message:p.message}),d.dirty()):p.kind==="duration"?durationRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"duration",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="ip"?isValidIP(l.data,p.version)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"ip",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="jwt"?isValidJWT(l.data,p.alg)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"jwt",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="cidr"?isValidCidr(l.data,p.version)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"cidr",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="base64"?base64Regex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"base64",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):p.kind==="base64url"?base64urlRegex.test(l.data)||(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{validation:"base64url",code:ZodIssueCode.invalid_string,message:p.message}),d.dirty()):util.assertNever(p);return{status:d.value,value:l.data}}_regex(l,c,d){return this.refinement(u=>l.test(u),{validation:c,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(d)})}_addCheck(l){return new ZodString({...this._def,checks:[...this._def.checks,l]})}email(l){return this._addCheck({kind:"email",...errorUtil.errToObj(l)})}url(l){return this._addCheck({kind:"url",...errorUtil.errToObj(l)})}emoji(l){return this._addCheck({kind:"emoji",...errorUtil.errToObj(l)})}uuid(l){return this._addCheck({kind:"uuid",...errorUtil.errToObj(l)})}nanoid(l){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(l)})}cuid(l){return this._addCheck({kind:"cuid",...errorUtil.errToObj(l)})}cuid2(l){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(l)})}ulid(l){return this._addCheck({kind:"ulid",...errorUtil.errToObj(l)})}base64(l){return this._addCheck({kind:"base64",...errorUtil.errToObj(l)})}base64url(l){return this._addCheck({kind:"base64url",...errorUtil.errToObj(l)})}jwt(l){return this._addCheck({kind:"jwt",...errorUtil.errToObj(l)})}ip(l){return this._addCheck({kind:"ip",...errorUtil.errToObj(l)})}cidr(l){return this._addCheck({kind:"cidr",...errorUtil.errToObj(l)})}datetime(l){var c,d;return typeof l=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:l}):this._addCheck({kind:"datetime",precision:typeof(l==null?void 0:l.precision)>"u"?null:l==null?void 0:l.precision,offset:(c=l==null?void 0:l.offset)!==null&&c!==void 0?c:!1,local:(d=l==null?void 0:l.local)!==null&&d!==void 0?d:!1,...errorUtil.errToObj(l==null?void 0:l.message)})}date(l){return this._addCheck({kind:"date",message:l})}time(l){return typeof l=="string"?this._addCheck({kind:"time",precision:null,message:l}):this._addCheck({kind:"time",precision:typeof(l==null?void 0:l.precision)>"u"?null:l==null?void 0:l.precision,...errorUtil.errToObj(l==null?void 0:l.message)})}duration(l){return this._addCheck({kind:"duration",...errorUtil.errToObj(l)})}regex(l,c){return this._addCheck({kind:"regex",regex:l,...errorUtil.errToObj(c)})}includes(l,c){return this._addCheck({kind:"includes",value:l,position:c==null?void 0:c.position,...errorUtil.errToObj(c==null?void 0:c.message)})}startsWith(l,c){return this._addCheck({kind:"startsWith",value:l,...errorUtil.errToObj(c)})}endsWith(l,c){return this._addCheck({kind:"endsWith",value:l,...errorUtil.errToObj(c)})}min(l,c){return this._addCheck({kind:"min",value:l,...errorUtil.errToObj(c)})}max(l,c){return this._addCheck({kind:"max",value:l,...errorUtil.errToObj(c)})}length(l,c){return this._addCheck({kind:"length",value:l,...errorUtil.errToObj(c)})}nonempty(l){return this.min(1,errorUtil.errToObj(l))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(l=>l.kind==="datetime")}get isDate(){return!!this._def.checks.find(l=>l.kind==="date")}get isTime(){return!!this._def.checks.find(l=>l.kind==="time")}get isDuration(){return!!this._def.checks.find(l=>l.kind==="duration")}get isEmail(){return!!this._def.checks.find(l=>l.kind==="email")}get isURL(){return!!this._def.checks.find(l=>l.kind==="url")}get isEmoji(){return!!this._def.checks.find(l=>l.kind==="emoji")}get isUUID(){return!!this._def.checks.find(l=>l.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(l=>l.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(l=>l.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(l=>l.kind==="cuid2")}get isULID(){return!!this._def.checks.find(l=>l.kind==="ulid")}get isIP(){return!!this._def.checks.find(l=>l.kind==="ip")}get isCIDR(){return!!this._def.checks.find(l=>l.kind==="cidr")}get isBase64(){return!!this._def.checks.find(l=>l.kind==="base64")}get isBase64url(){return!!this._def.checks.find(l=>l.kind==="base64url")}get minLength(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxLength(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}}ZodString.create=a=>{var l;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(l=a==null?void 0:a.coerce)!==null&&l!==void 0?l:!1,...processCreateParams(a)})};function floatSafeRemainder(a,l){const c=(a.toString().split(".")[1]||"").length,d=(l.toString().split(".")[1]||"").length,u=c>d?c:d,p=parseInt(a.toFixed(u).replace(".","")),m=parseInt(l.toFixed(u).replace(".",""));return p%m/Math.pow(10,u)}class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(l){if(this._def.coerce&&(l.data=Number(l.data)),this._getType(l)!==ZodParsedType.number){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:p.parsedType}),INVALID}let d;const u=new ParseStatus;for(const p of this._def.checks)p.kind==="int"?util.isInteger(l.data)||(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:p.message}),u.dirty()):p.kind==="min"?(p.inclusive?l.data<p.value:l.data<=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:p.value,type:"number",inclusive:p.inclusive,exact:!1,message:p.message}),u.dirty()):p.kind==="max"?(p.inclusive?l.data>p.value:l.data>=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:p.value,type:"number",inclusive:p.inclusive,exact:!1,message:p.message}),u.dirty()):p.kind==="multipleOf"?floatSafeRemainder(l.data,p.value)!==0&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_multiple_of,multipleOf:p.value,message:p.message}),u.dirty()):p.kind==="finite"?Number.isFinite(l.data)||(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_finite,message:p.message}),u.dirty()):util.assertNever(p);return{status:u.value,value:l.data}}gte(l,c){return this.setLimit("min",l,!0,errorUtil.toString(c))}gt(l,c){return this.setLimit("min",l,!1,errorUtil.toString(c))}lte(l,c){return this.setLimit("max",l,!0,errorUtil.toString(c))}lt(l,c){return this.setLimit("max",l,!1,errorUtil.toString(c))}setLimit(l,c,d,u){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:l,value:c,inclusive:d,message:errorUtil.toString(u)}]})}_addCheck(l){return new ZodNumber({...this._def,checks:[...this._def.checks,l]})}int(l){return this._addCheck({kind:"int",message:errorUtil.toString(l)})}positive(l){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(l)})}negative(l){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(l)})}multipleOf(l,c){return this._addCheck({kind:"multipleOf",value:l,message:errorUtil.toString(c)})}finite(l){return this._addCheck({kind:"finite",message:errorUtil.toString(l)})}safe(l){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(l)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(l)})}get minValue(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxValue(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}get isInt(){return!!this._def.checks.find(l=>l.kind==="int"||l.kind==="multipleOf"&&util.isInteger(l.value))}get isFinite(){let l=null,c=null;for(const d of this._def.checks){if(d.kind==="finite"||d.kind==="int"||d.kind==="multipleOf")return!0;d.kind==="min"?(c===null||d.value>c)&&(c=d.value):d.kind==="max"&&(l===null||d.value<l)&&(l=d.value)}return Number.isFinite(c)&&Number.isFinite(l)}}ZodNumber.create=a=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(l){if(this._def.coerce)try{l.data=BigInt(l.data)}catch{return this._getInvalidInput(l)}if(this._getType(l)!==ZodParsedType.bigint)return this._getInvalidInput(l);let d;const u=new ParseStatus;for(const p of this._def.checks)p.kind==="min"?(p.inclusive?l.data<p.value:l.data<=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_small,type:"bigint",minimum:p.value,inclusive:p.inclusive,message:p.message}),u.dirty()):p.kind==="max"?(p.inclusive?l.data>p.value:l.data>=p.value)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.too_big,type:"bigint",maximum:p.value,inclusive:p.inclusive,message:p.message}),u.dirty()):p.kind==="multipleOf"?l.data%p.value!==BigInt(0)&&(d=this._getOrReturnCtx(l,d),addIssueToContext(d,{code:ZodIssueCode.not_multiple_of,multipleOf:p.value,message:p.message}),u.dirty()):util.assertNever(p);return{status:u.value,value:l.data}}_getInvalidInput(l){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:c.parsedType}),INVALID}gte(l,c){return this.setLimit("min",l,!0,errorUtil.toString(c))}gt(l,c){return this.setLimit("min",l,!1,errorUtil.toString(c))}lte(l,c){return this.setLimit("max",l,!0,errorUtil.toString(c))}lt(l,c){return this.setLimit("max",l,!1,errorUtil.toString(c))}setLimit(l,c,d,u){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:l,value:c,inclusive:d,message:errorUtil.toString(u)}]})}_addCheck(l){return new ZodBigInt({...this._def,checks:[...this._def.checks,l]})}positive(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(l)})}negative(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(l)})}multipleOf(l,c){return this._addCheck({kind:"multipleOf",value:l,message:errorUtil.toString(c)})}get minValue(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l}get maxValue(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l}}ZodBigInt.create=a=>{var l;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(l=a==null?void 0:a.coerce)!==null&&l!==void 0?l:!1,...processCreateParams(a)})};class ZodBoolean extends ZodType{_parse(l){if(this._def.coerce&&(l.data=!!l.data),this._getType(l)!==ZodParsedType.boolean){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:d.parsedType}),INVALID}return OK(l.data)}}ZodBoolean.create=a=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodDate extends ZodType{_parse(l){if(this._def.coerce&&(l.data=new Date(l.data)),this._getType(l)!==ZodParsedType.date){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:p.parsedType}),INVALID}if(isNaN(l.data.getTime())){const p=this._getOrReturnCtx(l);return addIssueToContext(p,{code:ZodIssueCode.invalid_date}),INVALID}const d=new ParseStatus;let u;for(const p of this._def.checks)p.kind==="min"?l.data.getTime()<p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_small,message:p.message,inclusive:!0,exact:!1,minimum:p.value,type:"date"}),d.dirty()):p.kind==="max"?l.data.getTime()>p.value&&(u=this._getOrReturnCtx(l,u),addIssueToContext(u,{code:ZodIssueCode.too_big,message:p.message,inclusive:!0,exact:!1,maximum:p.value,type:"date"}),d.dirty()):util.assertNever(p);return{status:d.value,value:new Date(l.data.getTime())}}_addCheck(l){return new ZodDate({...this._def,checks:[...this._def.checks,l]})}min(l,c){return this._addCheck({kind:"min",value:l.getTime(),message:errorUtil.toString(c)})}max(l,c){return this._addCheck({kind:"max",value:l.getTime(),message:errorUtil.toString(c)})}get minDate(){let l=null;for(const c of this._def.checks)c.kind==="min"&&(l===null||c.value>l)&&(l=c.value);return l!=null?new Date(l):null}get maxDate(){let l=null;for(const c of this._def.checks)c.kind==="max"&&(l===null||c.value<l)&&(l=c.value);return l!=null?new Date(l):null}}ZodDate.create=a=>new ZodDate({checks:[],coerce:(a==null?void 0:a.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(a)});class ZodSymbol extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.symbol){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:d.parsedType}),INVALID}return OK(l.data)}}ZodSymbol.create=a=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(a)});class ZodUndefined extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.undefined){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:d.parsedType}),INVALID}return OK(l.data)}}ZodUndefined.create=a=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(a)});class ZodNull extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.null){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:d.parsedType}),INVALID}return OK(l.data)}}ZodNull.create=a=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(a)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(l){return OK(l.data)}}ZodAny.create=a=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(a)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(l){return OK(l.data)}}ZodUnknown.create=a=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(a)});class ZodNever extends ZodType{_parse(l){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:c.parsedType}),INVALID}}ZodNever.create=a=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(a)});class ZodVoid extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.undefined){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:d.parsedType}),INVALID}return OK(l.data)}}ZodVoid.create=a=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(a)});class ZodArray extends ZodType{_parse(l){const{ctx:c,status:d}=this._processInputParams(l),u=this._def;if(c.parsedType!==ZodParsedType.array)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:c.parsedType}),INVALID;if(u.exactLength!==null){const m=c.data.length>u.exactLength.value,h=c.data.length<u.exactLength.value;(m||h)&&(addIssueToContext(c,{code:m?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:h?u.exactLength.value:void 0,maximum:m?u.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:u.exactLength.message}),d.dirty())}if(u.minLength!==null&&c.data.length<u.minLength.value&&(addIssueToContext(c,{code:ZodIssueCode.too_small,minimum:u.minLength.value,type:"array",inclusive:!0,exact:!1,message:u.minLength.message}),d.dirty()),u.maxLength!==null&&c.data.length>u.maxLength.value&&(addIssueToContext(c,{code:ZodIssueCode.too_big,maximum:u.maxLength.value,type:"array",inclusive:!0,exact:!1,message:u.maxLength.message}),d.dirty()),c.common.async)return Promise.all([...c.data].map((m,h)=>u.type._parseAsync(new ParseInputLazyPath(c,m,c.path,h)))).then(m=>ParseStatus.mergeArray(d,m));const p=[...c.data].map((m,h)=>u.type._parseSync(new ParseInputLazyPath(c,m,c.path,h)));return ParseStatus.mergeArray(d,p)}get element(){return this._def.type}min(l,c){return new ZodArray({...this._def,minLength:{value:l,message:errorUtil.toString(c)}})}max(l,c){return new ZodArray({...this._def,maxLength:{value:l,message:errorUtil.toString(c)}})}length(l,c){return new ZodArray({...this._def,exactLength:{value:l,message:errorUtil.toString(c)}})}nonempty(l){return this.min(1,l)}}ZodArray.create=(a,l)=>new ZodArray({type:a,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(l)});function deepPartialify(a){if(a instanceof ZodObject){const l={};for(const c in a.shape){const d=a.shape[c];l[c]=ZodOptional.create(deepPartialify(d))}return new ZodObject({...a._def,shape:()=>l})}else return a instanceof ZodArray?new ZodArray({...a._def,type:deepPartialify(a.element)}):a instanceof ZodOptional?ZodOptional.create(deepPartialify(a.unwrap())):a instanceof ZodNullable?ZodNullable.create(deepPartialify(a.unwrap())):a instanceof ZodTuple?ZodTuple.create(a.items.map(l=>deepPartialify(l))):a}class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const l=this._def.shape(),c=util.objectKeys(l);return this._cached={shape:l,keys:c}}_parse(l){if(this._getType(l)!==ZodParsedType.object){const x=this._getOrReturnCtx(l);return addIssueToContext(x,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:x.parsedType}),INVALID}const{status:d,ctx:u}=this._processInputParams(l),{shape:p,keys:m}=this._getCached(),h=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const x in u.data)m.includes(x)||h.push(x);const g=[];for(const x of m){const f=p[x],y=u.data[x];g.push({key:{status:"valid",value:x},value:f._parse(new ParseInputLazyPath(u,y,u.path,x)),alwaysSet:x in u.data})}if(this._def.catchall instanceof ZodNever){const x=this._def.unknownKeys;if(x==="passthrough")for(const f of h)g.push({key:{status:"valid",value:f},value:{status:"valid",value:u.data[f]}});else if(x==="strict")h.length>0&&(addIssueToContext(u,{code:ZodIssueCode.unrecognized_keys,keys:h}),d.dirty());else if(x!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const x=this._def.catchall;for(const f of h){const y=u.data[f];g.push({key:{status:"valid",value:f},value:x._parse(new ParseInputLazyPath(u,y,u.path,f)),alwaysSet:f in u.data})}}return u.common.async?Promise.resolve().then(async()=>{const x=[];for(const f of g){const y=await f.key,b=await f.value;x.push({key:y,value:b,alwaysSet:f.alwaysSet})}return x}).then(x=>ParseStatus.mergeObjectSync(d,x)):ParseStatus.mergeObjectSync(d,g)}get shape(){return this._def.shape()}strict(l){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...l!==void 0?{errorMap:(c,d)=>{var u,p,m,h;const g=(m=(p=(u=this._def).errorMap)===null||p===void 0?void 0:p.call(u,c,d).message)!==null&&m!==void 0?m:d.defaultError;return c.code==="unrecognized_keys"?{message:(h=errorUtil.errToObj(l).message)!==null&&h!==void 0?h:g}:{message:g}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(l){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...l})})}merge(l){return new ZodObject({unknownKeys:l._def.unknownKeys,catchall:l._def.catchall,shape:()=>({...this._def.shape(),...l._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(l,c){return this.augment({[l]:c})}catchall(l){return new ZodObject({...this._def,catchall:l})}pick(l){const c={};return util.objectKeys(l).forEach(d=>{l[d]&&this.shape[d]&&(c[d]=this.shape[d])}),new ZodObject({...this._def,shape:()=>c})}omit(l){const c={};return util.objectKeys(this.shape).forEach(d=>{l[d]||(c[d]=this.shape[d])}),new ZodObject({...this._def,shape:()=>c})}deepPartial(){return deepPartialify(this)}partial(l){const c={};return util.objectKeys(this.shape).forEach(d=>{const u=this.shape[d];l&&!l[d]?c[d]=u:c[d]=u.optional()}),new ZodObject({...this._def,shape:()=>c})}required(l){const c={};return util.objectKeys(this.shape).forEach(d=>{if(l&&!l[d])c[d]=this.shape[d];else{let p=this.shape[d];for(;p instanceof ZodOptional;)p=p._def.innerType;c[d]=p}}),new ZodObject({...this._def,shape:()=>c})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(a,l)=>new ZodObject({shape:()=>a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});ZodObject.strictCreate=(a,l)=>new ZodObject({shape:()=>a,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});ZodObject.lazycreate=(a,l)=>new ZodObject({shape:a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(l)});class ZodUnion extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d=this._def.options;function u(p){for(const h of p)if(h.result.status==="valid")return h.result;for(const h of p)if(h.result.status==="dirty")return c.common.issues.push(...h.ctx.common.issues),h.result;const m=p.map(h=>new ZodError(h.ctx.common.issues));return addIssueToContext(c,{code:ZodIssueCode.invalid_union,unionErrors:m}),INVALID}if(c.common.async)return Promise.all(d.map(async p=>{const m={...c,common:{...c.common,issues:[]},parent:null};return{result:await p._parseAsync({data:c.data,path:c.path,parent:m}),ctx:m}})).then(u);{let p;const m=[];for(const g of d){const x={...c,common:{...c.common,issues:[]},parent:null},f=g._parseSync({data:c.data,path:c.path,parent:x});if(f.status==="valid")return f;f.status==="dirty"&&!p&&(p={result:f,ctx:x}),x.common.issues.length&&m.push(x.common.issues)}if(p)return c.common.issues.push(...p.ctx.common.issues),p.result;const h=m.map(g=>new ZodError(g));return addIssueToContext(c,{code:ZodIssueCode.invalid_union,unionErrors:h}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(a,l)=>new ZodUnion({options:a,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(l)});const getDiscriminator=a=>a instanceof ZodLazy?getDiscriminator(a.schema):a instanceof ZodEffects?getDiscriminator(a.innerType()):a instanceof ZodLiteral?[a.value]:a instanceof ZodEnum?a.options:a instanceof ZodNativeEnum?util.objectValues(a.enum):a instanceof ZodDefault?getDiscriminator(a._def.innerType):a instanceof ZodUndefined?[void 0]:a instanceof ZodNull?[null]:a instanceof ZodOptional?[void 0,...getDiscriminator(a.unwrap())]:a instanceof ZodNullable?[null,...getDiscriminator(a.unwrap())]:a instanceof ZodBranded||a instanceof ZodReadonly?getDiscriminator(a.unwrap()):a instanceof ZodCatch?getDiscriminator(a._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.object)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:c.parsedType}),INVALID;const d=this.discriminator,u=c.data[d],p=this.optionsMap.get(u);return p?c.common.async?p._parseAsync({data:c.data,path:c.path,parent:c}):p._parseSync({data:c.data,path:c.path,parent:c}):(addIssueToContext(c,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[d]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(l,c,d){const u=new Map;for(const p of c){const m=getDiscriminator(p.shape[l]);if(!m.length)throw new Error(`A discriminator value for key \`${l}\` could not be extracted from all schema options`);for(const h of m){if(u.has(h))throw new Error(`Discriminator property ${String(l)} has duplicate value ${String(h)}`);u.set(h,p)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:l,options:c,optionsMap:u,...processCreateParams(d)})}}function mergeValues(a,l){const c=getParsedType(a),d=getParsedType(l);if(a===l)return{valid:!0,data:a};if(c===ZodParsedType.object&&d===ZodParsedType.object){const u=util.objectKeys(l),p=util.objectKeys(a).filter(h=>u.indexOf(h)!==-1),m={...a,...l};for(const h of p){const g=mergeValues(a[h],l[h]);if(!g.valid)return{valid:!1};m[h]=g.data}return{valid:!0,data:m}}else if(c===ZodParsedType.array&&d===ZodParsedType.array){if(a.length!==l.length)return{valid:!1};const u=[];for(let p=0;p<a.length;p++){const m=a[p],h=l[p],g=mergeValues(m,h);if(!g.valid)return{valid:!1};u.push(g.data)}return{valid:!0,data:u}}else return c===ZodParsedType.date&&d===ZodParsedType.date&&+a==+l?{valid:!0,data:a}:{valid:!1}}class ZodIntersection extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l),u=(p,m)=>{if(isAborted(p)||isAborted(m))return INVALID;const h=mergeValues(p.value,m.value);return h.valid?((isDirty(p)||isDirty(m))&&c.dirty(),{status:c.value,value:h.data}):(addIssueToContext(d,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return d.common.async?Promise.all([this._def.left._parseAsync({data:d.data,path:d.path,parent:d}),this._def.right._parseAsync({data:d.data,path:d.path,parent:d})]).then(([p,m])=>u(p,m)):u(this._def.left._parseSync({data:d.data,path:d.path,parent:d}),this._def.right._parseSync({data:d.data,path:d.path,parent:d}))}}ZodIntersection.create=(a,l,c)=>new ZodIntersection({left:a,right:l,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(c)});class ZodTuple extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.array)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:d.parsedType}),INVALID;if(d.data.length<this._def.items.length)return addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&d.data.length>this._def.items.length&&(addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),c.dirty());const p=[...d.data].map((m,h)=>{const g=this._def.items[h]||this._def.rest;return g?g._parse(new ParseInputLazyPath(d,m,d.path,h)):null}).filter(m=>!!m);return d.common.async?Promise.all(p).then(m=>ParseStatus.mergeArray(c,m)):ParseStatus.mergeArray(c,p)}get items(){return this._def.items}rest(l){return new ZodTuple({...this._def,rest:l})}}ZodTuple.create=(a,l)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:a,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(l)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.object)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:d.parsedType}),INVALID;const u=[],p=this._def.keyType,m=this._def.valueType;for(const h in d.data)u.push({key:p._parse(new ParseInputLazyPath(d,h,d.path,h)),value:m._parse(new ParseInputLazyPath(d,d.data[h],d.path,h)),alwaysSet:h in d.data});return d.common.async?ParseStatus.mergeObjectAsync(c,u):ParseStatus.mergeObjectSync(c,u)}get element(){return this._def.valueType}static create(l,c,d){return c instanceof ZodType?new ZodRecord({keyType:l,valueType:c,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(d)}):new ZodRecord({keyType:ZodString.create(),valueType:l,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(c)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.map)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:d.parsedType}),INVALID;const u=this._def.keyType,p=this._def.valueType,m=[...d.data.entries()].map(([h,g],x)=>({key:u._parse(new ParseInputLazyPath(d,h,d.path,[x,"key"])),value:p._parse(new ParseInputLazyPath(d,g,d.path,[x,"value"]))}));if(d.common.async){const h=new Map;return Promise.resolve().then(async()=>{for(const g of m){const x=await g.key,f=await g.value;if(x.status==="aborted"||f.status==="aborted")return INVALID;(x.status==="dirty"||f.status==="dirty")&&c.dirty(),h.set(x.value,f.value)}return{status:c.value,value:h}})}else{const h=new Map;for(const g of m){const x=g.key,f=g.value;if(x.status==="aborted"||f.status==="aborted")return INVALID;(x.status==="dirty"||f.status==="dirty")&&c.dirty(),h.set(x.value,f.value)}return{status:c.value,value:h}}}}ZodMap.create=(a,l,c)=>new ZodMap({valueType:l,keyType:a,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(c)});class ZodSet extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.parsedType!==ZodParsedType.set)return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:d.parsedType}),INVALID;const u=this._def;u.minSize!==null&&d.data.size<u.minSize.value&&(addIssueToContext(d,{code:ZodIssueCode.too_small,minimum:u.minSize.value,type:"set",inclusive:!0,exact:!1,message:u.minSize.message}),c.dirty()),u.maxSize!==null&&d.data.size>u.maxSize.value&&(addIssueToContext(d,{code:ZodIssueCode.too_big,maximum:u.maxSize.value,type:"set",inclusive:!0,exact:!1,message:u.maxSize.message}),c.dirty());const p=this._def.valueType;function m(g){const x=new Set;for(const f of g){if(f.status==="aborted")return INVALID;f.status==="dirty"&&c.dirty(),x.add(f.value)}return{status:c.value,value:x}}const h=[...d.data.values()].map((g,x)=>p._parse(new ParseInputLazyPath(d,g,d.path,x)));return d.common.async?Promise.all(h).then(g=>m(g)):m(h)}min(l,c){return new ZodSet({...this._def,minSize:{value:l,message:errorUtil.toString(c)}})}max(l,c){return new ZodSet({...this._def,maxSize:{value:l,message:errorUtil.toString(c)}})}size(l,c){return this.min(l,c).max(l,c)}nonempty(l){return this.min(1,l)}}ZodSet.create=(a,l)=>new ZodSet({valueType:a,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(l)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.function)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:c.parsedType}),INVALID;function d(h,g){return makeIssue({data:h,path:c.path,errorMaps:[c.common.contextualErrorMap,c.schemaErrorMap,getErrorMap(),errorMap].filter(x=>!!x),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:g}})}function u(h,g){return makeIssue({data:h,path:c.path,errorMaps:[c.common.contextualErrorMap,c.schemaErrorMap,getErrorMap(),errorMap].filter(x=>!!x),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:g}})}const p={errorMap:c.common.contextualErrorMap},m=c.data;if(this._def.returns instanceof ZodPromise){const h=this;return OK(async function(...g){const x=new ZodError([]),f=await h._def.args.parseAsync(g,p).catch(j=>{throw x.addIssue(d(g,j)),x}),y=await Reflect.apply(m,this,f);return await h._def.returns._def.type.parseAsync(y,p).catch(j=>{throw x.addIssue(u(y,j)),x})})}else{const h=this;return OK(function(...g){const x=h._def.args.safeParse(g,p);if(!x.success)throw new ZodError([d(g,x.error)]);const f=Reflect.apply(m,this,x.data),y=h._def.returns.safeParse(f,p);if(!y.success)throw new ZodError([u(f,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...l){return new ZodFunction({...this._def,args:ZodTuple.create(l).rest(ZodUnknown.create())})}returns(l){return new ZodFunction({...this._def,returns:l})}implement(l){return this.parse(l)}strictImplement(l){return this.parse(l)}static create(l,c,d){return new ZodFunction({args:l||ZodTuple.create([]).rest(ZodUnknown.create()),returns:c||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(d)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(l){const{ctx:c}=this._processInputParams(l);return this._def.getter()._parse({data:c.data,path:c.path,parent:c})}}ZodLazy.create=(a,l)=>new ZodLazy({getter:a,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(l)});class ZodLiteral extends ZodType{_parse(l){if(l.data!==this._def.value){const c=this._getOrReturnCtx(l);return addIssueToContext(c,{received:c.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:l.data}}get value(){return this._def.value}}ZodLiteral.create=(a,l)=>new ZodLiteral({value:a,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(l)});function createZodEnum(a,l){return new ZodEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(l)})}class ZodEnum extends ZodType{constructor(){super(...arguments),_ZodEnum_cache.set(this,void 0)}_parse(l){if(typeof l.data!="string"){const c=this._getOrReturnCtx(l),d=this._def.values;return addIssueToContext(c,{expected:util.joinValues(d),received:c.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodEnum_cache)||__classPrivateFieldSet(this,_ZodEnum_cache,new Set(this._def.values)),!__classPrivateFieldGet(this,_ZodEnum_cache).has(l.data)){const c=this._getOrReturnCtx(l),d=this._def.values;return addIssueToContext(c,{received:c.data,code:ZodIssueCode.invalid_enum_value,options:d}),INVALID}return OK(l.data)}get options(){return this._def.values}get enum(){const l={};for(const c of this._def.values)l[c]=c;return l}get Values(){const l={};for(const c of this._def.values)l[c]=c;return l}get Enum(){const l={};for(const c of this._def.values)l[c]=c;return l}extract(l,c=this._def){return ZodEnum.create(l,{...this._def,...c})}exclude(l,c=this._def){return ZodEnum.create(this.options.filter(d=>!l.includes(d)),{...this._def,...c})}}_ZodEnum_cache=new WeakMap;ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),_ZodNativeEnum_cache.set(this,void 0)}_parse(l){const c=util.getValidEnumValues(this._def.values),d=this._getOrReturnCtx(l);if(d.parsedType!==ZodParsedType.string&&d.parsedType!==ZodParsedType.number){const u=util.objectValues(c);return addIssueToContext(d,{expected:util.joinValues(u),received:d.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodNativeEnum_cache)||__classPrivateFieldSet(this,_ZodNativeEnum_cache,new Set(util.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,_ZodNativeEnum_cache).has(l.data)){const u=util.objectValues(c);return addIssueToContext(d,{received:d.data,code:ZodIssueCode.invalid_enum_value,options:u}),INVALID}return OK(l.data)}get enum(){return this._def.values}}_ZodNativeEnum_cache=new WeakMap;ZodNativeEnum.create=(a,l)=>new ZodNativeEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(l)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(l){const{ctx:c}=this._processInputParams(l);if(c.parsedType!==ZodParsedType.promise&&c.common.async===!1)return addIssueToContext(c,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:c.parsedType}),INVALID;const d=c.parsedType===ZodParsedType.promise?c.data:Promise.resolve(c.data);return OK(d.then(u=>this._def.type.parseAsync(u,{path:c.path,errorMap:c.common.contextualErrorMap})))}}ZodPromise.create=(a,l)=>new ZodPromise({type:a,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(l)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(l){const{status:c,ctx:d}=this._processInputParams(l),u=this._def.effect||null,p={addIssue:m=>{addIssueToContext(d,m),m.fatal?c.abort():c.dirty()},get path(){return d.path}};if(p.addIssue=p.addIssue.bind(p),u.type==="preprocess"){const m=u.transform(d.data,p);if(d.common.async)return Promise.resolve(m).then(async h=>{if(c.value==="aborted")return INVALID;const g=await this._def.schema._parseAsync({data:h,path:d.path,parent:d});return g.status==="aborted"?INVALID:g.status==="dirty"||c.value==="dirty"?DIRTY(g.value):g});{if(c.value==="aborted")return INVALID;const h=this._def.schema._parseSync({data:m,path:d.path,parent:d});return h.status==="aborted"?INVALID:h.status==="dirty"||c.value==="dirty"?DIRTY(h.value):h}}if(u.type==="refinement"){const m=h=>{const g=u.refinement(h,p);if(d.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return h};if(d.common.async===!1){const h=this._def.schema._parseSync({data:d.data,path:d.path,parent:d});return h.status==="aborted"?INVALID:(h.status==="dirty"&&c.dirty(),m(h.value),{status:c.value,value:h.value})}else return this._def.schema._parseAsync({data:d.data,path:d.path,parent:d}).then(h=>h.status==="aborted"?INVALID:(h.status==="dirty"&&c.dirty(),m(h.value).then(()=>({status:c.value,value:h.value}))))}if(u.type==="transform")if(d.common.async===!1){const m=this._def.schema._parseSync({data:d.data,path:d.path,parent:d});if(!isValid(m))return m;const h=u.transform(m.value,p);if(h instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:c.value,value:h}}else return this._def.schema._parseAsync({data:d.data,path:d.path,parent:d}).then(m=>isValid(m)?Promise.resolve(u.transform(m.value,p)).then(h=>({status:c.value,value:h})):m);util.assertNever(u)}}ZodEffects.create=(a,l,c)=>new ZodEffects({schema:a,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:l,...processCreateParams(c)});ZodEffects.createWithPreprocess=(a,l,c)=>new ZodEffects({schema:l,effect:{type:"preprocess",transform:a},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(c)});class ZodOptional extends ZodType{_parse(l){return this._getType(l)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(l)}unwrap(){return this._def.innerType}}ZodOptional.create=(a,l)=>new ZodOptional({innerType:a,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(l)});class ZodNullable extends ZodType{_parse(l){return this._getType(l)===ZodParsedType.null?OK(null):this._def.innerType._parse(l)}unwrap(){return this._def.innerType}}ZodNullable.create=(a,l)=>new ZodNullable({innerType:a,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(l)});class ZodDefault extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l);let d=c.data;return c.parsedType===ZodParsedType.undefined&&(d=this._def.defaultValue()),this._def.innerType._parse({data:d,path:c.path,parent:c})}removeDefault(){return this._def.innerType}}ZodDefault.create=(a,l)=>new ZodDefault({innerType:a,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof l.default=="function"?l.default:()=>l.default,...processCreateParams(l)});class ZodCatch extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d={...c,common:{...c.common,issues:[]}},u=this._def.innerType._parse({data:d.data,path:d.path,parent:{...d}});return isAsync(u)?u.then(p=>({status:"valid",value:p.status==="valid"?p.value:this._def.catchValue({get error(){return new ZodError(d.common.issues)},input:d.data})})):{status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new ZodError(d.common.issues)},input:d.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(a,l)=>new ZodCatch({innerType:a,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof l.catch=="function"?l.catch:()=>l.catch,...processCreateParams(l)});class ZodNaN extends ZodType{_parse(l){if(this._getType(l)!==ZodParsedType.nan){const d=this._getOrReturnCtx(l);return addIssueToContext(d,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:d.parsedType}),INVALID}return{status:"valid",value:l.data}}}ZodNaN.create=a=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(a)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(l){const{ctx:c}=this._processInputParams(l),d=c.data;return this._def.type._parse({data:d,path:c.path,parent:c})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(l){const{status:c,ctx:d}=this._processInputParams(l);if(d.common.async)return(async()=>{const p=await this._def.in._parseAsync({data:d.data,path:d.path,parent:d});return p.status==="aborted"?INVALID:p.status==="dirty"?(c.dirty(),DIRTY(p.value)):this._def.out._parseAsync({data:p.value,path:d.path,parent:d})})();{const u=this._def.in._parseSync({data:d.data,path:d.path,parent:d});return u.status==="aborted"?INVALID:u.status==="dirty"?(c.dirty(),{status:"dirty",value:u.value}):this._def.out._parseSync({data:u.value,path:d.path,parent:d})}}static create(l,c){return new ZodPipeline({in:l,out:c,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(l){const c=this._def.innerType._parse(l),d=u=>(isValid(u)&&(u.value=Object.freeze(u.value)),u);return isAsync(c)?c.then(u=>d(u)):d(c)}unwrap(){return this._def.innerType}}ZodReadonly.create=(a,l)=>new ZodReadonly({innerType:a,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(l)});function custom(a,l={},c){return a?ZodAny.create().superRefine((d,u)=>{var p,m;if(!a(d)){const h=typeof l=="function"?l(d):typeof l=="string"?{message:l}:l,g=(m=(p=h.fatal)!==null&&p!==void 0?p:c)!==null&&m!==void 0?m:!0,x=typeof h=="string"?{message:h}:h;u.addIssue({code:"custom",...x,fatal:g})}}):ZodAny.create()}const late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(a,l={message:`Input not instance of ${a.name}`})=>custom(c=>c instanceof a,l),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:a=>ZodString.create({...a,coerce:!0}),number:a=>ZodNumber.create({...a,coerce:!0}),boolean:a=>ZodBoolean.create({...a,coerce:!0}),bigint:a=>ZodBigInt.create({...a,coerce:!0}),date:a=>ZodDate.create({...a,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap,getErrorMap,makeIssue,EMPTY_PATH,addIssueToContext,ParseStatus,INVALID,DIRTY,OK,isAborted,isDirty,isValid,isAsync,get util(){return util},get objectUtil(){return objectUtil},ZodParsedType,getParsedType,ZodType,datetimeRegex,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodTransformer:ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,custom,Schema:ZodType,ZodSchema:ZodType,late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean,onumber,optional:optionalType,ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER,ZodIssueCode,quotelessJson,ZodError});const saveToLibraryModalAtom=jotai.atom({isOpen:!1,blockId:null}),SaveToLibraryModal=()=>{const[a,l]=jotai.useAtom(saveToLibraryModalAtom),{t:c}=reactI18next.useTranslation(),{hasPermission:d}=usePermissions(),[u]=useBlocksStore(),p=useBuilderProp("uiLibraries",[]),m=React.useMemo(()=>a.blockId?lodashEs.find(u,{_id:a.blockId}):null,[u,a.blockId]),h=!!(m!=null&&m._libBlockId),g=z.object({library:z.string().min(1,{message:c("Library is required")}),name:z.string().min(1,{message:c("Name is required")}),group:z.string().min(1,{message:c("Group is required")}),description:z.string().optional(),screenshot:z.any().optional()}),x=tooltip.useForm({resolver:s(g),defaultValues:{library:"",name:(m==null?void 0:m._name)||"",group:"",description:""},mode:"onChange"}),[f,y]=React.useState(null),b=React.useRef(null),j=P=>{var M;const L=(M=P.target.files)==null?void 0:M[0];if(L){x.setValue("screenshot",L);const O=new FileReader;O.onload=()=>{y(O.result)},O.readAsDataURL(L)}},R=()=>{y(null),x.setValue("screenshot",void 0),b.current&&(b.current.value="")},k=useUpdateBlocksPropsRealtime(),v=useBuilderProp("upsertLibraryBlock",null),S=async P=>{if(!v||typeof v!="function"){console.error("Something went wrong!!");return}try{const L=await v({...P,...(m==null?void 0:m._libBlockId)&&{id:m==null?void 0:m._libBlockId}});if(L instanceof Error){sonner.toast.error(L.message);return}const{id:M}=L;k([m==null?void 0:m._id],{_libBlockId:M}),sonner.toast.success(c(h?"Library block updated":"Added to library")),l({isOpen:!1,blockId:null})}catch(L){sonner.toast.error(c("Failed to save to library")),console.error("Error saving to library:",L)}},[C,I]=React.useState([]),[T,_]=React.useState(""),[A,B]=React.useState(!1),D=P=>{x.setValue("group",P)},w=()=>{B(!0)},E=()=>{if(T){const P=T.toLowerCase().replace(/\s+/g,"-");I([...C,{id:P,name:T}]),x.setValue("group",P),_(""),B(!1)}},N=()=>{_(""),B(!1)};return jsxRuntime.jsx(tooltip.Dialog,{open:a.isOpen,onOpenChange:P=>!P&&l({isOpen:!1,blockId:null}),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"p-4 sm:max-w-[450px]",children:[jsxRuntime.jsx(tooltip.DialogHeader,{className:"pb-2",children:jsxRuntime.jsx(tooltip.DialogTitle,{children:c(h?"Update Library Block":"Save to Library")})}),jsxRuntime.jsx(tooltip.Form,{...x,children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"library",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Library")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(ChaiSelect,{height:"h-8",options:p.map(L=>({value:L.id,label:L.name})),defaultValue:P.value,onValueChange:P.onChange,placeholder:c("Select a library")})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"name",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Name")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(tooltip.Input,{className:"h-8",placeholder:c("Enter name"),...P})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"group",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Group")}),A?jsxRuntime.jsxs("div",{className:"flex space-x-1",children:[jsxRuntime.jsx(tooltip.Input,{className:"h-8",placeholder:c("Enter new group name"),value:T,onChange:L=>_(L.target.value)}),jsxRuntime.jsx(tooltip.Button,{type:"button",onClick:E,disabled:!T,size:"sm",className:"h-8",children:c("Add")}),jsxRuntime.jsx(tooltip.Button,{type:"button",onClick:N,variant:"outline",size:"sm",className:"h-8",children:c("Cancel")})]}):jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("div",{className:"flex space-x-1",children:[jsxRuntime.jsx(tooltip.FormControl,{className:"flex-1",children:jsxRuntime.jsx(ChaiSelect,{height:"h-8",options:C.map(L=>({value:L.id,label:L.name})),defaultValue:P.value,onValueChange:D,placeholder:c("Select a group")})}),d(PERMISSIONS.CREATE_LIBRARY_GROUP)&&jsxRuntime.jsx(tooltip.Button,{type:"button",variant:"outline",className:"h-8 whitespace-nowrap text-xs",onClick:w,size:"sm",children:c("Create new")})]})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Screenshot")}),jsxRuntime.jsx("div",{className:"mt-0",children:f?jsxRuntime.jsxs("div",{className:"relative h-20 w-full",children:[jsxRuntime.jsx("img",{src:f,alt:"Screenshot preview",className:"h-full w-full rounded-md border border-gray-200 object-contain"}),jsxRuntime.jsx("button",{type:"button",onClick:R,className:"absolute -right-2 -top-2 rounded-full bg-background text-foreground hover:text-destructive","aria-label":"Remove image",children:jsxRuntime.jsx(lucideReact.XCircle,{size:20})})]}):jsxRuntime.jsxs(tooltip.Label,{htmlFor:"screenshot",className:"flex h-20 w-full cursor-pointer flex-col items-center justify-center rounded-md border border-dashed border-gray-300 bg-gray-50 hover:bg-gray-100",children:[jsxRuntime.jsx("div",{className:"flex flex-col items-center justify-center py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-gray-500",children:c("Drop your image here, or click to browse")})}),jsxRuntime.jsx(tooltip.Input,{id:"screenshot",ref:b,type:"file",accept:"image/*",className:"hidden",onChange:j})]})})]}),jsxRuntime.jsx(tooltip.FormField,{control:x.control,name:"description",render:({field:P})=>jsxRuntime.jsxs(tooltip.FormItem,{className:"space-y-1",children:[jsxRuntime.jsx(tooltip.FormLabel,{className:"text-xs",children:c("Description")}),jsxRuntime.jsx(tooltip.FormControl,{children:jsxRuntime.jsx(tooltip.Textarea,{placeholder:c("Enter description for AI"),className:"h-20 resize-none",...P})}),jsxRuntime.jsx(tooltip.FormMessage,{className:"text-xs"})]})}),jsxRuntime.jsxs(tooltip.DialogFooter,{className:"pt-2",children:[jsxRuntime.jsx(tooltip.Button,{type:"button",variant:"outline",onClick:()=>l({isOpen:!1,blockId:null}),size:"sm",children:c("Cancel")}),jsxRuntime.jsx(tooltip.Button,{type:"submit",onClick:x.handleSubmit(S),disabled:!x.formState.isValid||x.formState.isSubmitting,size:"sm",children:c(h?"Update":"Save")})]})]})})]})})},useCanMove=()=>{const[a]=useBlocksStore();return(l,c)=>{var p;const d=(p=lodashEs.find(a,{_id:c}))==null?void 0:p._type,u=lodashEs.first(l.map(m=>{var h;return(h=lodashEs.find(a,{_id:m}))==null?void 0:h._type}));return canAcceptChildBlock(d,u)}},ListTree=()=>{const[treeData]=jotai.useAtom(treeDSBlocks),[ids,setIds]=useSelectedBlockIds(),[cutBlocksIds]=useCutBlockIds(),[,setHiddenBlocks]=useHiddenBlockIds(),updateBlockProps=useUpdateBlocksProps(),[,setStyleBlocks]=useSelectedStylingBlocks(),{moveBlocks}=useBlocksStoreUndoableActions(),canMove=useCanMove(),treeRef=React.useRef(null),[,setTreeRef]=jotai.useAtom(treeRefAtom),{t}=reactI18next.useTranslation(),[parentContext,setParentContext]=React.useState(null),clearSelection=()=>{setIds([]),setStyleBlocks([])},filteredTreeData=React.useMemo(()=>{const a=(c,d)=>c.filter(u=>!d.includes(u._id)).map(u=>({...u,children:u.children?a(u.children,d):[]}));return[...a(treeData,cutBlocksIds),{_type:getSplitClasses.ROOT_TEMP_KEY,_id:getSplitClasses.ROOT_TEMP_KEY,children:[]}]},[treeData,cutBlocksIds]),onRename=({id:a,name:l,node:c})=>{updateBlockProps([a],{_name:l},c.data._name)},onMove=({dragIds:a,parentId:l,index:c})=>{canMove(a,l)&&moveBlocks(a,l,c)},onSelect=a=>{if(a.length===0)return;const l=a[0]?a[0].id:"";setStyleBlocks([]),setIds([l])},onContextMenu=a=>{var d;a.preventDefault(),parentContext&&setParentContext(null);const l=a.target,c=l.getAttribute("data-node-id")||((d=l.closest("[data-node-id]"))==null?void 0:d.getAttribute("data-node-id"));c?(setStyleBlocks([]),setIds([c])):(setStyleBlocks([]),setIds([]),setParentContext({x:a.clientX,y:a.clientY}))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:a,dragNodes:l})=>{var c;return(a==null?void 0:a.data._type)===getSplitClasses.ROOT_TEMP_KEY||!canAcceptChildBlock(a==null?void 0:a.data._type,(c=l[0])==null?void 0:c.data._type)},[],300),handleKeyDown=e=>{if(!treeRef.current)return;const tree=treeRef.current,selectedNode=tree.selectedNodes[0];if(!selectedNode)return;setIds[selectedNode.id],setStyleBlocks([]);const isLeaf=!selectedNode.isInternal,isClosed=!selectedNode.isOpen,isOpen=selectedNode.isOpen,shortcut=defaultShortcuts.find(s=>s.key===e.key&&(!s.when||eval(s.when)));if(shortcut)switch(e.preventDefault(),shortcut.command){case"selectNext":selectNext(tree);break;case"selectPrev":selectPrev(tree);break;case"selectParent":selectParent(tree,isLeaf||isClosed);break;case"close":close(tree,isOpen);break;case"open":open(tree,isClosed);break;case"selectFirst":selectFirst(tree);break;case"selectLast":selectLast(tree);break}};React.useEffect(()=>{const a=()=>{treeRef.current&&setTreeRef(treeRef.current)};a();const l=new MutationObserver(a);return l.observe(document.body,{childList:!0,subtree:!0}),()=>l.disconnect()},[setTreeRef]);const{hasPermission}=usePermissions();return lodashEs.isEmpty(treeData)?jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("This page is empty"),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),hasPermission(PERMISSIONS.ADD_BLOCK)&&jsxRuntime.jsxs(tooltip.Button,{disabled:!hasPermission(PERMISSIONS.ADD_BLOCK),onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),variant:"default",size:"sm",children:["+ ",t("Add Block")]})]})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:Functions.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxs("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto text-sm",onKeyDown:a=>{treeRef.current.isEditing||handleKeyDown(a)},children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground",children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{onClick:()=>setHiddenBlocks([]),variant:"outline",className:"h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",size:"sm",children:jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Show hidden blocks")})]}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"h-fit p-1",onClick:()=>{var a;return(a=treeRef==null?void 0:treeRef.current)==null?void 0:a.openAll()},variant:"outline",size:"sm",children:jsxRuntime.jsx(lucideReact.ChevronsDown,{size:14})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Expand all")})]}),jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"h-fit p-1",onClick:()=>{var a;return(a=treeRef==null?void 0:treeRef.current)==null?void 0:a.closeAll()},variant:"outline",size:"sm",children:jsxRuntime.jsx(lucideReact.ChevronsUp,{size:14})})}),jsxRuntime.jsx(tooltip.TooltipContent,{className:"isolate z-[9999]",children:t("Collapse all")})]})]}),jsxRuntime.jsx("div",{className:"group relative z-[9999] ml-5 w-full cursor-pointer",children:jsxRuntime.jsx("div",{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,{position:0}),className:"h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsx("div",{className:"absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500",children:jsxRuntime.jsx(lucideReact.PlusIcon,{className:"h-3 w-3 stroke-[3] text-white"})})})}),jsxRuntime.jsx(reactArborist.Tree,{ref:treeRef,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",rowClassName:"flex items-center h-full border-b border-transparent",selection:ids[0]||"",onRename,openByDefault:!1,onMove,data:[...filteredTreeData],renderCursor:DefaultCursor,onSelect,childrenAccessor:a=>a.children,width:"100%",rowHeight:28,renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})]})}),jsxRuntime.jsx(PasteAtRootContextMenu,{parentContext,setParentContext}),jsxRuntime.jsx(SaveToLibraryModal,{})]})},BorderRadiusInput=({value:a,onChange:l,disabled:c})=>{const d=lodashEs.debounce(u=>l(u),200);return jsxRuntime.jsx("input",{type:"range",min:"0",step:"1",max:"30",disabled:c,defaultValue:a.replace("px",""),onChange:u=>d(u.target.value),className:"flex-1 cursor-pointer"})},ColorPickerInput=({value:a,onChange:l})=>{const c=lodashEs.debounce(d=>l(d),200);return jsxRuntime.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:a},children:jsxRuntime.jsx("input",{type:"color",value:a.startsWith("#")?a:"#000000",onChange:d=>{const u=d.target.value;/^#[0-9A-F]{6}$/i.test(u)&&c(u)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},FontSelector=({label:a,value:l,onChange:c})=>{const d=runtime.useRegisteredFonts();return jsxRuntime.jsxs("div",{className:"space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:lodashEs.startCase(a)}),jsxRuntime.jsx("select",{className:"mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:l,onChange:u=>c(u.target.value),children:d.map(u=>jsxRuntime.jsx("option",{value:u.family,children:u.family},u.family))})]})},ThemeConfigPanel=React__namespace.memo(({className:a=""})=>{const[l]=useDarkMode(),[c,d]=React__namespace.useState(""),u=useBuilderProp("themePresets",[]),p=useBuilderProp("themePanelComponent",null),{hasPermission:m}=usePermissions(),[h,g]=useTheme(),x=useThemeOptions(),{t:f}=reactI18next.useTranslation(),y=S=>{d(S)},b=()=>{const S=u.find(C=>Object.keys(C)[0]===c);if(S){const C=Object.values(S)[0];C&&typeof C=="object"&&"fontFamily"in C&&"borderRadius"in C&&"colors"in C?g(C):console.error("Invalid preset structure:",C)}else console.error("Preset not found:",c)},j=web.useDebouncedCallback((S,C)=>{g(()=>({...h,fontFamily:{...h.fontFamily,[S.replace(/font-/g,"")]:C}}))},[h],200),R=web.useDebouncedCallback(S=>{g(()=>({...h,borderRadius:`${S}px`}))},[h],200),k=web.useDebouncedCallback((S,C)=>{g(()=>{const I=lodashEs.get(h,`colors.${S}`);return l?lodashEs.set(I,1,C):lodashEs.set(I,0,C),{...h,colors:{...h.colors,[S]:I}}})},[h],200),v=S=>jsxRuntime.jsx("div",{className:"grid grid-cols-1",children:Object.entries(S.items).map(([C])=>{const I=lodashEs.get(h,`colors.${C}.${l?1:0}`);return jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-x-2",children:[jsxRuntime.jsx(ColorPickerInput,{value:I,onChange:T=>k(C,T)}),jsxRuntime.jsx(tooltip.Label,{className:"text-xs font-normal leading-tight text-slate-600",children:C.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(T=>T.charAt(0).toUpperCase()+T.slice(1)).join(" ")+(!C.toLowerCase().includes("foreground")&&!C.toLowerCase().includes("border")&&!C.toLowerCase().includes("input")&&!C.toLowerCase().includes("ring")&&!C.toLowerCase().includes("background")?" Background":"")})]},C)})});return m("edit_theme")?jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsxs("div",{className:Functions.cn("no-scrollbar h-full w-full overflow-y-auto",a),children:[u.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-2 py-2",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Presets")}),jsxRuntime.jsxs("select",{value:c,onChange:S=>y(S.target.value),className:"w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[jsxRuntime.jsx("option",{value:"",children:"Select preset"}),Array.isArray(u)&&u.map(S=>jsxRuntime.jsx("option",{value:Object.keys(S)[0],children:lodashEs.capitalize(Object.keys(S)[0])},Object.keys(S)[0]))]})]}),jsxRuntime.jsx("div",{className:"flex w-[30%] items-end",children:jsxRuntime.jsx(tooltip.Button,{className:"w-full text-sm",disabled:c==="",variant:"default",onClick:b,children:f("Apply")})})]}),jsxRuntime.jsxs("div",{className:Functions.cn("space-y-2",a),children:[(x==null?void 0:x.fontFamily)&&jsxRuntime.jsx("div",{className:"grid gap-4",children:Object.entries(x.fontFamily).map(([S,C])=>jsxRuntime.jsx(FontSelector,{label:S,value:h.fontFamily[S.replace(/font-/g,"")]||C[Object.keys(C)[0]],onChange:I=>j(S,I)},S))}),(x==null?void 0:x.borderRadius)&&jsxRuntime.jsxs("div",{className:"space-y-0.5 py-3",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Border Radius")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 py-2",children:[jsxRuntime.jsx(BorderRadiusInput,{value:h.borderRadius,onChange:R}),jsxRuntime.jsx("span",{className:"w-12 text-sm",children:h.borderRadius})]})]}),(x==null?void 0:x.colors)&&jsxRuntime.jsxs("div",{className:"mt-4 space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:f("Colors")}),jsxRuntime.jsx("div",{className:"w-full space-y-4 pt-2",children:x.colors.map(S=>v(S))},l?"dark":"light")]})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),p&&jsxRuntime.jsx("div",{className:"absolute bottom-4 w-full",children:React__namespace.createElement(p)})]}):jsxRuntime.jsx("div",{className:"relative w-full",children:jsxRuntime.jsx("div",{className:Functions.cn("no-scrollbar h-full w-full overflow-y-auto text-center",a),children:jsxRuntime.jsx("div",{className:"mt-10 h-full items-center justify-center gap-2 text-muted-foreground",children:jsxRuntime.jsx("p",{className:"text-sm",children:"You don't have permission to edit the theme. Please contact your administrator to get access."})})})})}),Core="Core",Import="Import",Breakpoints="Breakpoints",Clear="Clear",Cancel="Cancel",Yes="Yes",Preview="Preview",Settings="Settings",Styling="Styling",Remove="Remove",Choose="Choose",Cut="Cut",Copy="Copy",Paste="Paste",Delete="Delete",classes="classes",Theme="Theme",Outline="Outline",Copied="Copied",Stop="Stop",Edit="Edit",Tag="Tag",Value="Value",Images="Images",Library="Library",Blocks="Blocks",Basic="Basic",Media="Media",Advanced="Advanced",Form="Form",Groups="Groups",Accordions="Accordions",Buttons="Buttons",Layouts="Layouts",FAQ="FAQ",Hero="Hero",Features="Features",Footer="Footer",Navbar="Navbar",Icons="Icons",Testimonials="Testimonials",Blog="Blog",Saved="Saved",Unsaved="Unsaved",Randomize="Randomize",theme_config={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},Undo="Undo",Redo="Redo",Duplicate="Duplicate",Close="Close",Selected="Selected",Select="Select",Attributes="Attributes",apply="apply",presets="presets",Orientation="Orientation",Color="Color",Upload="Upload",lngEn={"Add block":"Add Block","Add blocks":"Add blocks","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core,"Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import,"Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints,Clear,"Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel,Yes,Preview,Settings,Styling,"Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove,"You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose,"Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut,Copy,Paste,Delete,"Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes,Theme,Outline,"Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied,"Enter Classes":"Enter classes separated by space","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop,"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit,"Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag,Value,"Background Image":"Background Image","Enter image URL":"Enter image URL","Replace image":"Replace image","Choose image":"Choose image",Images,Library,Blocks,Basic,Media,Advanced,Form,"Choose Icon or SVG":"Choose an icon or enter SVG",Groups,"UI Libraries":"UI Libraries",Accordions,Buttons,Layouts,"Choose Library":"Choose library","No Library Found":"No library found.",FAQ,Hero,Features,Footer,Navbar,Icons,Testimonials,Blog,"Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved,Unsaved,"Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Fix grammar":"Fix grammar","Make longer":"Make longer","Make shorter":"Make shorter","Add emojis":"Add emojis",Randomize,"Edit Block":"Edit Block","AI Assistant":"AI Assistant","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)"},"flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config,web_blocks,"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo,Redo,Duplicate,"Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close,"Coming soon":"Coming soon",Selected,Select,"Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes,"Apply Presets":"Apply Presets",apply,presets,"Global presets":"Global presets",Orientation,Color,"Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload,"Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Clear search":"Clear search","No results found for":"No results found for","Search {pageTypeName}":"Search {pageTypeName}"};i18n.use(reactI18next.initReactI18next).init({resources:{en:{translation:lngEn}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const QUICK_PROMPTS=[{name:"Improve writing",icon:lucideReact.FileEdit,prompt:"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."},{name:"Replace placeholder content",icon:lucideReact.Recycle,prompt:"Discard current placeholder content and replace with meaningful relevant content."},{name:"Fix grammar",icon:reactIcons.CheckIcon,prompt:"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."},{name:"Make longer",icon:reactIcons.ArrowUpIcon,prompt:"Make all text elements longer."},{name:"Make shorter",icon:reactIcons.ArrowDownIcon,prompt:"Make all text elements shorter."},{name:"Add emojis",icon:lucideReact.SmileIcon,prompt:"Add emojis to text elements if relevant."},{name:"Randomize",icon:lucideReact.ShuffleIcon,prompt:"Randomize all text elements."}];function QuickPrompts({onClick:a}){const{loading:l}=useAskAi(),{t:c}=reactI18next.useTranslation(),{selectedLang:d,fallbackLang:u}=useLanguages(),p=[...QUICK_PROMPTS];return d&&d!==u&&p.splice(0,0,{name:`Translate to ${lodashEs.get(LANGUAGES,d,d)}`,icon:lucideReact.Languages,prompt:`Translate the content to ${lodashEs.get(LANGUAGES,d,d)}. Maintain same tone, style and length.`}),jsxRuntime.jsx("div",{className:l?"pointer-events-none opacity-50":"",children:jsxRuntime.jsx("ul",{className:"space-y-2",children:p.map(({name:m,icon:h,subMenus:g,prompt:x})=>g?jsxRuntime.jsxs(tooltip.Popover,{children:[jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsx(h,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:m})]},m)}),jsxRuntime.jsx(tooltip.PopoverContent,{side:"right",children:jsxRuntime.jsx("ul",{children:jsxRuntime.jsx("li",{children:"Happy"})})})]}):jsxRuntime.jsxs("li",{onClick:()=>a(x),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsx(h,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:c(m)})]},m))})})}const AIUserPrompt=({blockId:a})=>{const{t:l}=reactI18next.useTranslation(),{askAi:c,loading:d,error:u}=useAskAi(),[p,m]=React.useState(""),[h,g]=React.useState(!0),[x,f]=React.useState(),y=React.useRef(null),b=React.useRef(null);React.useEffect(()=>{var R;(R=y.current)==null||R.focus()},[]);const j=R=>{const{usage:k}=R||{};!u&&k&&f(k),b.current=setTimeout(()=>f(void 0),1e4),u||m("")};return jsxRuntime.jsxs("div",{className:"",children:[jsxRuntime.jsxs("div",{onClick:()=>g(!h),className:"flex cursor-pointer items-center justify-between border-t border-border py-2 text-sm font-medium hover:underline",children:[jsxRuntime.jsx("span",{children:l("Ask AI")}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(h?"rotate-180":"")})})]}),h&&a?jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsx(tooltip.Textarea,{ref:y,value:p,onChange:R=>m(R.target.value),placeholder:l("Ask AI to edit content"),className:"w-full",rows:3,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),b.current&&clearTimeout(b.current),f(void 0),c("content",a,p,j))}}),jsxRuntime.jsxs("div",{className:"my-2 flex items-center gap-2",children:[d?null:jsxRuntime.jsx(tooltip.Button,{disabled:p.trim().length<5||d,onClick:()=>{b.current&&clearTimeout(b.current),f(void 0),c("content",a,p,j)},variant:"default",className:"w-fit",size:"sm",children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),l("Generating... Please wait...")]}):l("Edit with AI")}),d?jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs(tooltip.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsx("p",{className:"text-xs",children:l("Generating... Please wait...")})]}),jsxRuntime.jsx(tooltip.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:l("Stop")})]}):null]}),x?jsxRuntime.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxs("span",{children:[l("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsx(Countdown,{})]})}):null,jsxRuntime.jsx("div",{className:"max-w-full",children:u&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx(QuickPrompts,{onClick:R=>{b.current&&clearTimeout(b.current),f(void 0),c("content",a,R,j)}})]}):h?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"mx-auto text-3xl text-muted-foreground"}),jsxRuntime.jsx("h1",{children:l("Please select a block to Ask AI")})]})}):null]})},AISetContext=()=>{const{t:a}=reactI18next.useTranslation(),l=useBuilderProp("aiContext",""),[c,d]=React.useState(l),u=React.useRef(null),p=useBuilderProp("saveAiContextCallback",lodashEs.noop),[m,h]=React.useState(!1),[g,x]=React.useState(null),[,f]=React.useState(!1),y=React.useRef(null);React.useEffect(()=>{l&&d(l)},[l]);const b=async()=>{try{h(!0),x(null),await p(c),sonner.toast.success(a("Updated AI Context")),y.current.click()}catch(j){x(j)}finally{h(!1)}};return jsxRuntime.jsx(tooltip.Accordion,{onValueChange:j=>{f(j!=="")},type:"single",collapsible:!0,children:jsxRuntime.jsxs(tooltip.AccordionItem,{value:"set-context",className:"border-none",children:[jsxRuntime.jsx(tooltip.AccordionTrigger,{ref:y,className:"border-0 border-border py-2",children:jsxRuntime.jsx("div",{className:"flex w-full items-center justify-between",children:jsxRuntime.jsx("span",{className:"font-medium",children:a("AI Context")})})}),jsxRuntime.jsxs(tooltip.AccordionContent,{children:[jsxRuntime.jsx(tooltip.Textarea,{ref:u,value:c,onChange:j=>d(j.target.value),placeholder:a("Tell about this page eg this page is about"),className:"mt-1 w-full",rows:10,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b())}}),l.trim().length===0?jsxRuntime.jsx("p",{className:"mt-2 text-xs text-gray-500",children:a("Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.")}):null,jsxRuntime.jsxs("div",{className:"mt-2 flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{disabled:c.trim().length<5,onClick:()=>b(),variant:"default",className:"w-fit",size:"sm",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),a("Saving... Please wait...")]}):a("Save")}),l.trim().length>0?jsxRuntime.jsxs(tooltip.AlertDialog,{children:[jsxRuntime.jsx(tooltip.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{disabled:l.trim().length===0,variant:"ghost",className:"w-fit",size:"sm",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),a("Deleting... Please wait...")]}):a("Delete")})}),jsxRuntime.jsxs(tooltip.AlertDialogContent,{children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{children:[jsxRuntime.jsxs(tooltip.AlertDialogTitle,{children:[a("Delete context")," ?"]}),jsxRuntime.jsx(tooltip.AlertDialogDescription,{})]}),jsxRuntime.jsxs(tooltip.AlertDialogFooter,{children:[jsxRuntime.jsx(tooltip.AlertDialogCancel,{children:a("Cancel")}),jsxRuntime.jsx(tooltip.AlertDialogAction,{onClick:()=>{d(""),b()},children:a("Yes, Delete")})]})]})]}):null]}),jsxRuntime.jsx("div",{className:"mt-2 max-w-full",children:g&&jsxRuntime.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:g.message})})]})]})})},AskAI=()=>{const[a]=useSelectedBlockIds();return jsxRuntime.jsxs("div",{className:"no-scrollbar mt-2 flex-1 overflow-y-auto",children:[jsxRuntime.jsx(AISetContext,{}),jsxRuntime.jsx(AIUserPrompt,{blockId:lodashEs.first(a)})]})};function DarkMode(){const[a,l]=useDarkMode();return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(reactIcons.SunIcon,{className:"size-4 shrink-0"}),jsxRuntime.jsx(tooltip.Switch,{id:"dark-mode-switch",checked:a,onCheckedChange:()=>{l(!a)},className:`${a?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:jsxRuntime.jsx("span",{"aria-hidden":"true",className:`${a?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})}),jsxRuntime.jsx(lucideReact.Moon,{className:"ml-3 size-4 shrink-0",size:16})]})}const UndoRedo=()=>{const{hasUndo:a,hasRedo:l,undo:c,redo:d}=useUndoManager();return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{disabled:!a(),size:"sm",onClick:c,className:"rounded-full",variant:"ghost",children:jsxRuntime.jsx(reactIcons.ResetIcon,{})}),jsxRuntime.jsx(tooltip.Button,{disabled:!l(),onClick:d,size:"sm",className:"rounded-full",variant:"ghost",children:jsxRuntime.jsx(reactIcons.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function getFromQueryParams(a){var c;return(c=new URLSearchParams(window.location.search).get("flags"))==null?void 0:c.includes(a)}const FEATURE_TOGGLES={dnd:getFromQueryParams("dnd"),aiChat:getFromQueryParams("ai-chat")},setDebugLogs=a=>{},getParentNodeIds=(a,l)=>{const c=[];let d=lodashEs.find(a,{_id:l}),u=lodashEs.get(d,"_parent","");for(;lodashEs.isString(u)&&!lodashEs.isEmpty(u);)c.push(d==null?void 0:d._parent),d=lodashEs.find(a,{_id:u}),u=d==null?void 0:d._parent;return lodashEs.flatten(c)},expandedIdsAtom=jotai.atom([]),useExpandTree=()=>{const[a]=useSelectedBlockIds(),l=jotai.useAtomValue(presentBlocksAtom),[,c]=jotai.useAtom(expandedIdsAtom);React.useEffect(()=>{let d=[];const u=lodashEs.first(a);lodashEs.isString(u)&&(d=[u,...getParentNodeIds(l,u)]),c(d)},[a,l,c])},CHAI_BUILDER_PANELS={},registerChaiSidebarPanel=(a,l)=>{lodashEs.has(CHAI_BUILDER_PANELS,a)&&console.warn(`Panel ${a} already registered. Overriding...`),lodashEs.set(CHAI_BUILDER_PANELS,a,{id:a,...l})},useChaiSidebarPanels=a=>React.useMemo(()=>lodashEs.filter(lodashEs.values(CHAI_BUILDER_PANELS),l=>l.position===a),[a]),DefaultTopBar=()=>jsxRuntime.jsx("div",{children:"TopBar"}),TOP_BAR={component:DefaultTopBar},registerChaiTopBar=a=>{TOP_BAR.component=a},useTopBarComponent=()=>React.useMemo(()=>TOP_BAR.component,[]);function usePubSub(a,l){React.useEffect(()=>{const c=pubsub.subscribe(a,l);return()=>c()},[a,l])}function AIChatPanel(){const[a,l]=React.useState([]),[c,d]=React.useState(""),[u,p]=React.useState(!1),[m,h]=React.useState(null),g=React.useRef(null),x=React.useRef(null),f=React.useRef(null);React.useEffect(()=>{var v;(v=x.current)==null||v.scrollIntoView({behavior:"smooth"})},[a]),React.useEffect(()=>{f.current&&(f.current.style.height="auto",f.current.style.height=`${Math.min(f.current.scrollHeight,120)}px`)},[c]);const y=async()=>{if(!c.trim()&&!m)return;const v={id:Date.now().toString(),role:"user",content:c,timestamp:new Date};l(S=>[...S,v]),d(""),p(!0),setTimeout(()=>{const S={id:(Date.now()+1).toString(),role:"assistant",content:"This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",timestamp:new Date};l(C=>[...C,S]),p(!1),h(null)},1500)},b=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),y())},j=v=>{var C;const S=(C=v.target.files)==null?void 0:C[0];if(S){const I=new FileReader;I.onload=T=>{var _;h((_=T.target)==null?void 0:_.result)},I.readAsDataURL(S)}},R=()=>{var v;(v=g.current)==null||v.click()},k=()=>{h(null),g.current&&(g.current.value="")};return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col rounded-lg bg-background shadow-sm",children:[jsxRuntime.jsx(tooltip.ScrollArea,{className:"flex-1 p-3",children:a.length===0?jsxRuntime.jsxs("div",{className:"mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Sparkles,{className:"mb-2 h-8 w-8 text-primary/50"}),jsxRuntime.jsx("p",{className:"text-sm",children:"Ask me anything to get started"})]}):jsxRuntime.jsxs("div",{className:"space-y-4",children:[a.map(v=>jsxRuntime.jsxs("div",{className:cn("flex max-w-full gap-2",v.role==="assistant"?"items-start":"items-start justify-end"),children:[v.role==="assistant"&&jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary/10",children:jsxRuntime.jsx(lucideReact.Sparkles,{className:"h-3 w-3 text-primary"})}),jsxRuntime.jsx("div",{className:cn("rounded-lg px-3 py-2 text-sm",v.role==="assistant"?"bg-muted text-foreground":"bg-primary text-primary-foreground"),children:v.content}),v.role==="user"&&jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary",children:jsxRuntime.jsx("span",{className:"text-xs text-primary-foreground",children:"You"})})]},v.id)),u&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(tooltip.Avatar,{className:"h-6 w-6 bg-primary/10",children:jsxRuntime.jsx(lucideReact.Sparkles,{className:"h-3 w-3 text-primary"})}),jsxRuntime.jsx("div",{className:"rounded-lg bg-muted px-3 py-2",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),jsxRuntime.jsx("div",{ref:x})]})}),m&&jsxRuntime.jsx("div",{className:"px-3 pt-2",children:jsxRuntime.jsxs("div",{className:"relative h-20 w-20 overflow-hidden rounded-md",children:[jsxRuntime.jsx("img",{src:m||"/placeholder.svg",alt:"Attachment",className:"h-full w-full object-cover"}),jsxRuntime.jsx(tooltip.Button,{size:"icon",variant:"destructive",className:"absolute right-0 top-0 h-5 w-5 rounded-full p-0",onClick:k,children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3",children:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsxs("div",{className:"relative flex-1",children:[jsxRuntime.jsx(tooltip.Textarea,{ref:f,value:c,onChange:v=>d(v.target.value),onKeyDown:b,placeholder:"Ask something...",className:"max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"}),jsxRuntime.jsx("input",{type:"file",ref:g,onChange:j,accept:"image/*",className:"hidden"}),jsxRuntime.jsx(tooltip.Button,{size:"icon",variant:"ghost",className:"absolute bottom-2 right-2 h-6 w-6",onClick:R,children:jsxRuntime.jsx(lucideReact.Image,{className:"h-4 w-4 text-muted-foreground"})})]}),jsxRuntime.jsxs(tooltip.Button,{size:"sm",className:"h-10 px-3",onClick:y,disabled:u||!c.trim()&&!m,children:[jsxRuntime.jsx(lucideReact.Send,{className:"mr-1 h-4 w-4"}),"Send"]})]})})]})}const AiAssistant=()=>{const a=useAiAssistant(),[l]=useRightPanel(),c=useBuilderProp("askAiCallBack",null),{t:d}=reactI18next.useTranslation(),{hasPermission:u}=usePermissions();return!c||!u(PERMISSIONS.EDIT_BLOCK)?null:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(tooltip.Label,{htmlFor:"ai-assistant",className:"flex items-center gap-x-1 text-sm text-yellow-600",children:[jsxRuntime.jsx(lucideReact.SparklesIcon,{className:"w-4"}),d("AI Assistant")]}),jsxRuntime.jsx(tooltip.Switch,{className:"scale-90",checked:l==="ai",onCheckedChange:p=>{a(p)},id:"ai-assistant"})]})},ClearCanvas=()=>{const{t:a}=reactI18next.useTranslation(),{setNewBlocks:l}=useBlocksStoreUndoableActions(),[,c]=useSelectedBlockIds(),[,d]=useSelectedStylingBlocks(),u=React.useCallback(()=>{l([]),c([]),d([])},[l]);return jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(tooltip.AlertDialog,{children:[jsxRuntime.jsx(tooltip.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(tooltip.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[jsxRuntime.jsx(reactIcons.EraserIcon,{})," ",a("Clear")]})}),jsxRuntime.jsxs(tooltip.AlertDialogContent,{className:"border-border",children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{children:[jsxRuntime.jsx(tooltip.AlertDialogTitle,{className:"text-foreground",children:a("Clear whole canvas? ")}),jsxRuntime.jsx(tooltip.AlertDialogDescription,{children:a("Are you sure you want to clear the page?")})]}),jsxRuntime.jsxs(tooltip.AlertDialogFooter,{children:[jsxRuntime.jsx(tooltip.AlertDialogCancel,{className:"text-foreground",children:a("Cancel")}),jsxRuntime.jsx(tooltip.AlertDialogAction,{onClick:u,children:a("Yes")})]})]})]})})},DataBinding=()=>{const a=usePageExternalData(),[l,c]=jotai.useAtom(dataBindingActiveAtom),{t:d}=reactI18next.useTranslation();return lodashEs.isEmpty(a)?null:jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{className:"rounded-full",variant:"ghost",onClick:()=>c(!l),children:jsxRuntime.jsx(lucideReact.DatabaseZapIcon,{className:Functions.cn("h-4 w-4",l?"text-green-500":"text-gray-500")})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:jsxRuntime.jsx("p",{children:d("Toggle Data Binding")})})]})})},CanvasTopBar=()=>{const a=useBuilderProp("darkMode",!0),l=flagged.useFeature("aiChat"),[c]=useCanvasZoom();return jsxRuntime.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2",children:[jsxRuntime.jsxs("div",{className:"flex h-full space-x-2",children:[jsxRuntime.jsx(Breakpoints$1,{canvas:!0,openDelay:400}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"}),a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(DarkMode,{}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"})]}):null,jsxRuntime.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[jsxRuntime.jsx(reactIcons.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",jsxRuntime.jsxs("div",{className:"text-xs leading-3",children:[lodashEs.round(c,0),"%"]})]}),jsxRuntime.jsx(tooltip.Separator,{orientation:"vertical"}),jsxRuntime.jsx(UndoRedo,{}),jsxRuntime.jsx(DataBinding,{})]}),jsxRuntime.jsxs("div",{className:"flex h-full items-center space-x-2",children:[jsxRuntime.jsx(ClearCanvas,{}),l?null:jsxRuntime.jsx(AiAssistant,{})]})]})},AddBlocksDialog=()=>{const{t:a}=reactI18next.useTranslation(),[l,c]=React.useState(""),[d,u]=React.useState(-1),[p,m]=React.useState(!1);return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,h=>{c(h?h._id:null),u(isNaN(h==null?void 0:h.position)?-1:h==null?void 0:h.position),m(!0)}),usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK,()=>{c(""),u(-1),m(!1)}),jsxRuntime.jsx(tooltip.AlertDialog,{open:p,onOpenChange:()=>p?m(!1):"",children:jsxRuntime.jsxs(tooltip.AlertDialogContent,{className:"max-w-5xl overflow-hidden border-border",children:[jsxRuntime.jsxs(tooltip.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsx(tooltip.AlertDialogTitle,{className:"text-foreground",children:a("Add blocks")}),jsxRuntime.jsx("button",{onClick:()=>m(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:jsxRuntime.jsx(AddBlocksPanel,{parentId:l,position:d,showHeading:!1})})]})})},AttrsEditor=React.memo(function a({preloadedAttributes:l=[],onAttributesChange:c}){const[d,u]=React.useState([]),[p,m]=React.useState(""),[h,g]=React.useState(""),[x,f]=React.useState(null),[y,b]=React.useState(""),j=React.useRef(null),R=React.useRef(null),k=usePageExternalData();React.useEffect(()=>{u(l)},[l]);const v=()=>{if(p.startsWith("@")){b("Attribute keys cannot start with '@'");return}if(p){const A=[...d,{key:p,value:h}];c(A),u(d),m(""),g(""),b("")}},S=A=>{const B=d.filter((D,w)=>w!==A);c(B),u(B)},C=A=>{f(A),m(d[A].key),g(d[A].value)},I=()=>{if(p.startsWith("@")){b("Attribute keys cannot start with '@'");return}if(x!==null&&p){const A=[...d];A[x]={key:p,value:h},c(A),u(A),f(null),m(""),g(""),b("")}},T=A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),x!==null?I():v())},_=React.useCallback(A=>{const B=E=>/[.,!?;:]/.test(E),D=(E,N,P)=>{let L="",M="";const O=N>0?E[N-1]:"",Z=N<E.length?E[N]:"";return N>0&&(O==="."||!B(O)&&O!==" ")&&(L=" "),N<E.length&&!B(Z)&&Z!==" "&&(M=" "),{text:L+P+M,prefixLength:L.length,suffixLength:M.length}},w=R.current;if(w){const E=w.selectionStart||0,N=w.value||"",P=w.selectionEnd||E;if(P>E){const V=`{{${A}}}`,{text:U}=D(N,E,V),$=N.slice(0,E)+U+N.slice(P);g($);return}const M=`{{${A}}}`,{text:O}=D(N,E,M),Z=N.slice(0,E)+O+N.slice(E);g(Z)}},[]);return jsxRuntime.jsxs("div",{className:"flex max-h-full flex-1 flex-col",children:[jsxRuntime.jsxs("form",{onSubmit:A=>{A.preventDefault(),x!==null?I():v()},className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"attrKey",className:"text-[11px] font-normal leading-tight text-slate-600",children:"Key"}),jsxRuntime.jsx(tooltip.Input,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:j,value:p,onChange:A=>m(A.target.value),placeholder:"Enter Key",className:"py-0 text-xs font-normal leading-tight placeholder:text-slate-400"})]}),jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(tooltip.Label,{htmlFor:"attrValue",className:"text-[11px] font-normal text-slate-600",children:"Value"}),!lodashEs.isEmpty(k)&&jsxRuntime.jsx(NestedPathSelector,{data:k,onSelect:_})]}),jsxRuntime.jsx(tooltip.Textarea,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",rows:2,ref:R,value:h,onChange:A=>g(A.target.value),onKeyDown:T,placeholder:"Enter Value",className:"text-xs font-normal leading-tight placeholder:text-slate-400"})]})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(tooltip.Button,{type:"submit",disabled:!p.length,variant:"default",size:"sm",className:"h-8 w-24 text-xs",children:x!==null?"Save":"Add"})}),y&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:y})]}),jsxRuntime.jsx("div",{className:"space-y-1 py-4",children:d.map((A,B)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[jsxRuntime.jsxs("div",{className:"flex flex-col text-xs leading-tight",children:[jsxRuntime.jsx("span",{className:"truncate text-[12px] font-light text-muted-foreground",children:A.key}),jsxRuntime.jsx("span",{className:"max-w-[200px] text-wrap font-normal",children:A.value.toString()})]}),jsxRuntime.jsxs("div",{className:"flex-shrink-0 text-slate-400",children:[jsxRuntime.jsx(tooltip.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(B),children:jsxRuntime.jsx(lucideReact.Edit2,{className:"h-3 w-3"})}),jsxRuntime.jsx(tooltip.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>S(B),children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})]},B))})]})}),BlockAttributesEditor=React__namespace.memo(()=>{const a=useSelectedBlock(),[l,c]=React.useState([]),[d]=useSelectedStylingBlocks(),u=useUpdateBlocksProps(),p=`${lodashEs.get(d,"0.prop")}_attrs`;React__namespace.useEffect(()=>{const h=lodashEs.map(lodashEs.get(a,p),(g,x)=>({key:x,value:g}));lodashEs.isEmpty(h)?c([]):c(h)},[lodashEs.get(a,p)]);const m=React__namespace.useCallback((h=[])=>{const g={};lodashEs.forEach(h,x=>{lodashEs.isEmpty(x.key)||lodashEs.set(g,x.key,x.value)}),u([lodashEs.get(a,"_id")],{[p]:g})},[a,u,p]);return jsxRuntime.jsx("div",{className:"flex-col gap-y-2",children:jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(AttrsEditor,{preloadedAttributes:l,onAttributesChange:m})})})})}),NoopComponent=()=>null;function BlockAttributesToggle(){const{t:a}=reactI18next.useTranslation(),[l,c]=React.useState(!0),[d]=useSelectedStylingBlocks();return lodashEs.isEmpty(d)?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{onClick:()=>c(!l),className:"flex cursor-pointer items-center justify-between border-t border-border py-3 text-xs font-medium hover:underline",children:[jsxRuntime.jsx("span",{children:a("Attributes")}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(l?"rotate-180":"")})})]}),l&&jsxRuntime.jsx(BlockAttributesEditor,{})]})}const SettingsPanel=()=>{const a=useSelectedBlock(),{t:l}=reactI18next.useTranslation(),c=useBuilderProp("onError",lodashEs.noop),{hasPermission:d}=usePermissions();let u=!d(PERMISSIONS.EDIT_BLOCK);const p=!d(PERMISSIONS.EDIT_STYLES);return lodashEs.isNull(a)?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsx("h1",{children:l("Please select a block to edit settings or styles")})]})}):u&&p?jsxRuntime.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsx("h1",{children:l("You don't have permission to edit settings or styles")}),jsxRuntime.jsx("p",{children:l("Please contact your administrator to get access")})]})}):p?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[jsxRuntime.jsx(BlockSettings,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}):u?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[jsxRuntime.jsx(BlockStyling,{}),jsxRuntime.jsx(BlockAttributesToggle,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}):jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:c,children:jsxRuntime.jsxs(tooltip.Tabs,{defaultValue:"settings",className:"flex flex-1 flex-col",children:[jsxRuntime.jsxs(tooltip.TabsList,{className:"grid h-auto w-full grid-cols-2 p-1 py-1",children:[jsxRuntime.jsx(tooltip.TabsTrigger,{value:"settings",className:"text-xs",children:"Settings"}),jsxRuntime.jsx(tooltip.TabsTrigger,{value:"styles",className:"text-xs",children:"Styles"})]}),jsxRuntime.jsxs(tooltip.TabsContent,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[jsxRuntime.jsx(BlockSettings,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsxs(tooltip.TabsContent,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[jsxRuntime.jsx(BlockStyling,{}),jsxRuntime.jsx(BlockAttributesToggle,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})]})})},DEFAULT_PANEL_WIDTH=280,OutlineButton=({isActive:a,show:l})=>jsxRuntime.jsx(tooltip.Button,{variant:a?"default":"ghost",size:"icon",onClick:l,children:jsxRuntime.jsx(lucideReact.Layers,{size:20})}),AiButton=({isActive:a,show:l})=>jsxRuntime.jsx(tooltip.Button,{variant:a?"default":"ghost",size:"icon",onClick:l,children:jsxRuntime.jsx(reactIcons.LightningBoltIcon,{className:"rtl:ml-2"})});function useSidebarMenuItems(){const a=useBuilderProp("askAiCallBack",null),l=flagged.useFeature("aiChat");return React.useMemo(()=>{const c=[];return c.push({id:"outline",label:"Outline",isInternal:!0,width:DEFAULT_PANEL_WIDTH,button:OutlineButton,panel:()=>jsxRuntime.jsx("div",{className:"-mt-8",children:jsxRuntime.jsx(ListTree,{})})}),a&&l&&c.unshift({id:"ai",button:AiButton,label:"AI Assistant",isInternal:!0,width:450,panel:()=>jsxRuntime.jsx("div",{className:"-mt-8 h-full max-h-full",children:jsxRuntime.jsx(AIChatPanel,{})})}),lodashEs.compact(c)},[a,l])}const RootLayout=()=>{const a=useTopBarComponent(),[l,c]=useSidebarActivePanel(),d=React.useRef("outline"),[u,p]=React.useState(DEFAULT_PANEL_WIDTH),[m,h]=useRightPanel();usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS,()=>{c("outline")});const g=useChaiSidebarPanels("top"),x=useChaiSidebarPanels("bottom"),f=_=>{_.preventDefault()},y=_=>{c(l===_?null:_)},b=useSidebarMenuItems(),{t:j}=reactI18next.useTranslation(),R=React.useMemo(()=>[...b,...g],[b,g]),k=useBuilderProp("htmlDir","ltr"),v=lodashEs.find(R,{id:l})??lodashEs.first(R),S=lodashEs.get(v,"width",DEFAULT_PANEL_WIDTH);React.useEffect(()=>{if(l!==null){const _=lodashEs.find(R,{id:l});_&&lodashEs.get(_,"view","standard")==="standard"&&(d.current=l,p(lodashEs.get(_,"width",DEFAULT_PANEL_WIDTH)))}},[l,R]);const C=React.useMemo(()=>{if(l===null)return 0;const _=lodashEs.find(R,{id:l});return lodashEs.get(_,"view","standard")==="standard"?S:u},[l,S,u,R]),I=()=>{c(d.current)};React.useEffect(()=>{lodashEs.find(R,{id:l})||c("outline")},[l,R]);const T=React.useCallback(_=>{y(_)},[y]);return jsxRuntime.jsx("div",{dir:k,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:jsxRuntime.jsxs(tooltip.TooltipProvider,{children:[jsxRuntime.jsxs("div",{onContextMenu:f,className:"flex h-screen max-h-full flex-col bg-background text-foreground",children:[jsxRuntime.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:jsxRuntime.jsx(React.Suspense,{children:jsxRuntime.jsx(a,{})})}),jsxRuntime.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[jsxRuntime.jsxs("div",{id:"sidebar",className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:R.map((_,A)=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:React.createElement(lodashEs.get(_,"button",NoopComponent),{position:"top",panelId:_.id,isActive:l===_.id,show:()=>T(_.id)})}),jsxRuntime.jsx(tooltip.TooltipContent,{side:"right",children:jsxRuntime.jsx("p",{children:j(_.label)})})]},"button-top-"+A))}),jsxRuntime.jsx("div",{className:"flex flex-col space-y-1"}),jsxRuntime.jsx("div",{className:"flex flex-col",children:x==null?void 0:x.map((_,A)=>jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:React.createElement(lodashEs.get(_,"button",NoopComponent),{position:"bottom",panelId:_.id,isActive:l===_.id,show:()=>T(_.id)})}),jsxRuntime.jsx(tooltip.TooltipContent,{side:"right",children:jsxRuntime.jsx("p",{children:j(_.label)})})]},"button-bottom-"+A))})]}),jsxRuntime.jsx(framerMotion.motion.div,{id:"left-panel",className:"h-full max-h-full border-r border-border",initial:{width:C},animate:{width:C},transition:{duration:.3,ease:"easeInOut"},children:l!==null&&lodashEs.get(v,"view","standard")==="standard"&&jsxRuntime.jsxs("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[jsxRuntime.jsx("div",{className:`absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${lodashEs.get(v,"isInternal",!1)?"":"w-64"}`,children:jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})}),jsxRuntime.jsx("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto pt-10",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"panel",NoopComponent),{})})})]})}),jsxRuntime.jsxs("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[jsxRuntime.jsx(CanvasTopBar,{}),jsxRuntime.jsx(React.Suspense,{children:jsxRuntime.jsx(CanvasArea,{})})]}),jsxRuntime.jsx(framerMotion.motion.div,{id:"right-panel",className:"h-full max-h-full border-l border-border",initial:{width:l==="ai"?0:DEFAULT_PANEL_WIDTH},animate:{width:l==="ai"?0:DEFAULT_PANEL_WIDTH},transition:{duration:.3,ease:"easeInOut"},children:jsxRuntime.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[jsxRuntime.jsx("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:jsxRuntime.jsx("div",{className:"flex grow items-center gap-2",children:jsxRuntime.jsx("div",{className:"flex w-full items-center justify-between gap-2",children:m==="ai"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(reactIcons.LightningBoltIcon,{className:"rtl:ml-2"})," ",j("AI Assistant")]})}):m==="theme"?jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Paintbrush,{className:"h-4 w-4 rtl:ml-2"}),j("Theme Settings")]}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>h("block"),variant:"ghost",size:"icon",className:"text-xs text-gray-400",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 rtl:ml-2"})})]}):null})})}),jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:m==="ai"?jsxRuntime.jsx(AskAI,{}):m==="theme"?jsxRuntime.jsx(ThemeConfigPanel,{}):jsxRuntime.jsx(SettingsPanel,{})})})]})})}),l!==null&&lodashEs.get(v,"view")==="drawer"&&jsxRuntime.jsx(tooltip.Sheet,{open:!0,onOpenChange:()=>I(),children:jsxRuntime.jsxs(tooltip.SheetContent,{side:"left",className:"p-0 sm:max-w-full",style:{width:`${S}px`},children:[jsxRuntime.jsx(tooltip.SheetHeader,{className:"border-b border-border p-4 pb-2",children:jsxRuntime.jsxs(tooltip.SheetTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]})}),jsxRuntime.jsx("div",{className:"h-full max-h-full overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"panel",NoopComponent),{})})})]})})," ",l!==null&&lodashEs.get(v,"view")==="modal"&&jsxRuntime.jsx(tooltip.Dialog,{open:!0,onOpenChange:()=>I(),children:jsxRuntime.jsxs(tooltip.DialogContent,{className:"p-0",style:{maxWidth:`${S}px`},children:[jsxRuntime.jsx(tooltip.DialogHeader,{className:"border-b border-border p-4 pb-2",children:jsxRuntime.jsxs(tooltip.DialogTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]})}),jsxRuntime.jsx("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"panel",NoopComponent),{})})})]})}),l!==null&&lodashEs.get(v,"view")==="overlay"&&jsxRuntime.jsx(framerMotion.motion.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:jsxRuntime.jsx("div",{className:"h-full w-full",children:jsxRuntime.jsxs(framerMotion.motion.div,{className:"flex h-full w-full flex-col bg-background",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-border p-4 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-lg font-bold",children:[jsxRuntime.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(v,"icon",null)}),jsxRuntime.jsx("span",{children:j(lodashEs.get(v,"label",""))})]}),jsxRuntime.jsx(tooltip.Button,{onClick:()=>I(),variant:"ghost",size:"icon",className:"text-gray-400",children:jsxRuntime.jsx(lucideReact.X,{className:"h-5 w-5"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(v,"panel",NoopComponent),{})})})]})})})]})]}),jsxRuntime.jsx(AddBlocksDialog,{})]})})},PreviewScreen=()=>{const[a,l]=usePreviewMode(),{t:c}=reactI18next.useTranslation(),d=useBuilderProp("previewComponent",null);return a?jsxRuntime.jsxs("div",{className:Functions.cn("fixed inset-0 z-[999] bg-background",a?"block":"hidden"),children:[jsxRuntime.jsxs(tooltip.Button,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>l(!1),children:[jsxRuntime.jsx(reactIcons.EyeClosedIcon,{}),jsxRuntime.jsx("span",{children:c("Close Preview")})]}),jsxRuntime.jsx("div",{children:d?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-96 w-full"}),children:React.createElement(d)}):null})]}):null},SmallScreenMessage=()=>jsxRuntime.jsx("section",{className:"h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden",children:jsxRuntime.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:jsxRuntime.jsxs("div",{className:"mx-auto max-w-md text-center",children:[jsxRuntime.jsx("img",{src:"https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/chaibuilder-blob-storage/175ac8d8-37fe-4707-bb4a-3c0cd6a6db75/gVH7O-Ir_400x400.png",alt:"Chai Builder",className:"mx-auto w-14 rounded-full"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("h2",{className:"text-4xl font-bold text-white",children:"Screen too small"}),jsxRuntime.jsx("p",{className:"mt-6 text-sm font-medium leading-6 text-white text-opacity-70",children:"Please view this page on greater than 1280px screen width."})]})})}),useAutoSave=()=>{const{savePage:a}=useSavePage(),l=useBuilderProp("autoSaveSupport",!0),c=useBuilderProp("autoSaveInterval",60);web.useIntervalEffect(()=>{l&&a(!0)},c*1e3)},ChaiBuilderComponent=a=>{const[,l]=useBlocksStore(),c=useBuilderReset(),[d]=useAtom(builderSaveStateAtom),u=React.useMemo(()=>a.layout||RootLayout,[a.layout]);useAtom(selectedLibraryAtom),useKeyEventWatcher(),useExpandTree(),useAutoSave(),useWatchPartailBlocks(),useUnmountBroadcastChannel();const{postMessage:p}=useBroadcastChannel();return React.useEffect(()=>{builderStore.set(chaiBuilderPropsAtom,lodashEs.omit(a,["blocks","translations","pageExternalData"]))},[a]),React.useEffect(()=>{builderStore.set(chaiPageExternalDataAtom,a.pageExternalData||{})},[a.pageExternalData]),React.useEffect(()=>{setTimeout(()=>{const m=runtime.syncBlocksWithDefaults(a.blocks||[]);l(m),m&&m.length>0&&p({type:"blocks-updated",blocks:m}),c()},400)},[a.blocks]),React.useEffect(()=>{i18n.changeLanguage(a.locale||"en")},[a.locale]),React.useEffect(()=>{setDebugLogs(a.debugLogs)},[a.debugLogs]),React.useEffect(()=>{a.translations&&lodashEs.each(a.translations,(m,h)=>{i18n.addResourceBundle(h,"translation",m,!0,!0)})},[a.translations]),React.useEffect(()=>(d!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[d]),jsxRuntime.jsx(u,{})},ChaiBuilderEditor=a=>{const l=a.onError||lodashEs.noop;return jsxRuntime.jsx("div",{className:"h-screen w-screen",children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsxs(flagged.FlagsProvider,{features:{...FEATURE_TOGGLES},children:[jsxRuntime.jsx(SmallScreenMessage,{}),jsxRuntime.jsx(ChaiBuilderComponent,{...a}),jsxRuntime.jsx(PreviewScreen,{}),jsxRuntime.jsx(tooltip.Toaster,{})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>reactI18next.useTranslation});exports.generateBlockId=Functions.generateUUID;exports.mergeClasses=Functions.cn;exports.i18n=i18n;exports.ChaiAddBlocksDialog=AddBlocksDialog;exports.ChaiAddBlocksPanel=AddBlocksPanel;exports.ChaiAskAiPanel=AISetContext;exports.ChaiAskAiUserPrompt=AIUserPrompt;exports.ChaiBlockAttributesEditor=BlockAttributesEditor;exports.ChaiBlockPropsEditor=BlockSettings;exports.ChaiBlockStyleEditor=BlockStyling;exports.ChaiBuilderCanvas=CanvasArea;exports.ChaiBuilderEditor=ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=DarkMode;exports.ChaiDefaultBlocks=DefaultChaiBlocks;exports.ChaiImportHTML=ImportHTML;exports.ChaiOutline=ListTree;exports.ChaiScreenSizes=Breakpoints$1;exports.ChaiThemeConfigPanel=ThemeConfigPanel;exports.ChaiUILibrariesPanel=UILibrariesPanel;exports.ChaiUndoRedo=UndoRedo;exports.PERMISSIONS=PERMISSIONS;exports.convertHTMLToChaiBlocks=getBlocksFromHTML;exports.getBlocksFromHTML=getBlocksFromHTML;exports.registerBlockSettingField=registerBlockSettingField;exports.registerBlockSettingTemplate=registerBlockSettingTemplate;exports.registerBlockSettingWidget=registerBlockSettingWidget;exports.registerChaiAddBlockTab=registerChaiAddBlockTab;exports.registerChaiMediaManager=registerChaiMediaManager;exports.registerChaiSidebarPanel=registerChaiSidebarPanel;exports.registerChaiTopBar=registerChaiTopBar;exports.useAddBlock=useAddBlock;exports.useAddClassesToBlocks=useAddClassesToBlocks;exports.useAskAi=useAskAi;exports.useBlockHighlight=useBlockHighlight;exports.useBlocksStore=useBlocksStore;exports.useBlocksStoreUndoableActions=useBlocksStoreUndoableActions;exports.useBrandingOptions=useBrandingOptions;exports.useBuilderProp=useBuilderProp;exports.useBuilderReset=useBuilderReset;exports.useCanvasDisplayWidth=useCanvasDisplayWidth;exports.useCanvasZoom=useCanvasZoom;exports.useCodeEditor=useCodeEditor;exports.useCopyBlockIds=useCopyBlockIds;exports.useCopyToClipboard=useCopyToClipboard;exports.useCurrentPage=useCurrentPage;exports.useCutBlockIds=useCutBlockIds;exports.useDarkMode=useDarkMode;exports.useDuplicateBlocks=useDuplicateBlocks;exports.useHiddenBlockIds=useHiddenBlockIds;exports.useHighlightBlockId=useHighlightBlockId;exports.useLanguages=useLanguages;exports.useLibraryBlocks=useLibraryBlocks;exports.useMediaManagerComponent=useMediaManagerComponent;exports.usePartailBlocksStore=usePartailBlocksStore;exports.usePartialBlocksList=usePartialBlocksList;exports.usePasteBlocks=usePasteBlocks;exports.usePermissions=usePermissions;exports.usePreviewMode=usePreviewMode;exports.useRemoveBlocks=useRemoveBlocks;exports.useRemoveClassesFromBlocks=useRemoveClassesFromBlocks;exports.useRightPanel=useRightPanel;exports.useSavePage=useSavePage;exports.useScreenSizeWidth=useScreenSizeWidth;exports.useSelectedBlock=useSelectedBlock;exports.useSelectedBlockAllClasses=useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=useSelectedBreakpoints;exports.useSelectedStylingBlocks=useSelectedStylingBlocks;exports.useSidebarActivePanel=useSidebarActivePanel;exports.useStylingBreakpoint=useStylingBreakpoint;exports.useStylingState=useStylingState;exports.useTheme=useTheme;exports.useThemeOptions=useThemeOptions;exports.useUILibraryBlocks=useUILibraryBlocks;exports.useUndoManager=useUndoManager;exports.useUpdateBlocksProps=useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=useUpdateBlocksPropsRealtime;exports.useWrapperBlock=useWrapperBlock;
|