@chaibuilder/sdk 1.2.98 → 1.2.99

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.
@@ -1,61 +0,0 @@
1
- "use strict";var U=Object.defineProperty;var F=(o,n,r)=>n in o?U(o,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[n]=r;var H=(o,n,r)=>(F(o,typeof n!="symbol"?n+"":n,r),r);const jsxRuntime=require("./jsx-runtime-JYMCiFoE.cjs"),React=require("react"),contextMenu=require("./context-menu-sQn7ryJ6.cjs"),lodashEs=require("lodash-es"),jotai=require("jotai"),iconBase=require("./iconBase-5hdsfZ0z.cjs"),runtime=require("@chaibuilder/runtime"),reactI18next=require("react-i18next"),plugin=require("./plugin-KIpT3NWi.cjs"),web=require("@react-hookz/web"),TreeModel=require("tree-model"),ReactQuill=require("react-quill"),STRINGS=require("./STRINGS-Yl7cSWDc.cjs"),flagged=require("flagged"),reactHotkeysHook=require("react-hotkeys-hook"),dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),reactIcons=require("@radix-ui/react-icons"),reactEventHook=require("react-event-hook"),typography$1=require("@tailwindcss/typography"),forms=require("@tailwindcss/forms"),aspectRatio=require("@tailwindcss/aspect-ratio"),getPalette=require("tailwindcss-palette-generator"),tailwindMerge=require("tailwind-merge"),reactWrapBalancer=require("react-wrap-balancer"),ReactDOM=require("react-dom"),PropTypes=require("prop-types"),reactErrorBoundary=require("react-error-boundary"),reResizable=require("re-resizable"),lucideReact=require("lucide-react"),validator=require("@rjsf/validator-ajv8"),Form=require("@rjsf/core"),reactArborist=require("react-arborist"),himalaya=require("himalaya"),IconPicker=require("react-icons-picker"),Autosuggest=require("react-autosuggest"),Fuse=require("fuse.js"),clsx=require("clsx"),i18n=require("i18next"),framerMotion=require("framer-motion");function _interopNamespaceDefault(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>o[r]})}}return n.default=o,Object.freeze(n)}const React__namespace=_interopNamespaceDefault(React),canAcceptChildBlock=(o,n)=>{if(!o)return!0;const r=runtime.getBlockComponent(o);return r&&lodashEs.has(r,"canAcceptBlock")?r.canAcceptBlock(n):!1},canAddChildBlock=o=>{const n=runtime.getBlockComponent(o);return n?lodashEs.has(n,"canAcceptBlock"):!1},canBeNestedInside=(o,n)=>{const r=runtime.getBlockComponent(n);return r&&lodashEs.has(r,"canBeNested")?r.canBeNested(o):!0},canDuplicateBlock=o=>{const n=runtime.getBlockComponent(o);return n&&lodashEs.has(n,"canDuplicate")?n.canDuplicate():!0},canDeleteBlock=o=>{const n=runtime.getBlockComponent(o);return n&&lodashEs.has(n,"canDelete")?n.canDelete():!0};var define_import_meta_env_default$2={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",VITE_JOTAI_DEVTOOL_ENABLED:"true",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};let keyCount=0;function atom(o,n){const r=`atom${++keyCount}`,a={toString:()=>r};return typeof o=="function"?a.read=o:(a.init=o,a.read=i=>i(a),a.write=(i,l,c)=>l(a,typeof c=="function"?c(i(a)):c)),n&&(a.write=n),a}const hasInitialValue=o=>"init"in o,isActuallyWritableAtom=o=>!!o.write,cancelPromiseMap=new WeakMap,registerCancelPromise=(o,n)=>{cancelPromiseMap.set(o,n),o.catch(()=>{}).finally(()=>cancelPromiseMap.delete(o))},cancelPromise=(o,n)=>{const r=cancelPromiseMap.get(o);r&&(cancelPromiseMap.delete(o),r(n))},resolvePromise=(o,n)=>{o.status="fulfilled",o.value=n},rejectPromise=(o,n)=>{o.status="rejected",o.reason=n},isPromiseLike$2=o=>typeof(o==null?void 0:o.then)=="function",isEqualAtomValue=(o,n)=>"v"in o&&"v"in n&&Object.is(o.v,n.v),isEqualAtomError=(o,n)=>"e"in o&&"e"in n&&Object.is(o.e,n.e),hasPromiseAtomValue=o=>"v"in o&&o.v instanceof Promise,isEqualPromiseAtomValue=(o,n)=>"v"in o&&"v"in n&&o.v.orig&&o.v.orig===n.v.orig,returnAtomValue=o=>{if("e"in o)throw o.e;return o.v},createStore=()=>{const o=new WeakMap,n=new WeakMap,r=new Map;let a,i,l;(define_import_meta_env_default$2?"production":void 0)!=="production"&&(a=new Set,i=new Set,l=new Set);const c=j=>o.get(j),d=(j,E)=>{(define_import_meta_env_default$2?"production":void 0)!=="production"&&Object.freeze(E);const k=o.get(j);if(o.set(j,E),r.has(j)||r.set(j,k),k&&hasPromiseAtomValue(k)){const y="v"in E?E.v instanceof Promise?E.v:Promise.resolve(E.v):Promise.reject(E.e);cancelPromise(k.v,y)}},u=(j,E,k)=>{const y=new Map;let B=!1;k.forEach((N,L)=>{!N&&L===j&&(N=E),N?(y.set(L,N),E.d.get(L)!==N&&(B=!0)):(define_import_meta_env_default$2?"production":void 0)!=="production"&&console.warn("[Bug] atom state not found")}),(B||E.d.size!==y.size)&&(E.d=y)},x=(j,E,k)=>{const y=c(j),B={d:(y==null?void 0:y.d)||new Map,v:E};if(k&&u(j,B,k),y&&isEqualAtomValue(y,B)&&y.d===B.d)return y;if(y&&hasPromiseAtomValue(y)&&hasPromiseAtomValue(B)&&isEqualPromiseAtomValue(y,B)){if(y.d===B.d)return y;B.v=y.v}return d(j,B),B},m=(j,E,k,y)=>{if(isPromiseLike$2(E)){let B;const N=new Promise((L,O)=>{let M=!1;E.then(P=>{if(!M){M=!0;const D=c(j),V=x(j,N,k);resolvePromise(N,P),L(P),(D==null?void 0:D.d)!==V.d&&A(j,V,D==null?void 0:D.d)}},P=>{if(!M){M=!0;const D=c(j),V=x(j,N,k);rejectPromise(N,P),O(P),(D==null?void 0:D.d)!==V.d&&A(j,V,D==null?void 0:D.d)}}),B=P=>{M||(M=!0,P.then(D=>resolvePromise(N,D),D=>rejectPromise(N,D)),L(P))}});return N.orig=E,N.status="pending",registerCancelPromise(N,L=>{L&&B(L),y==null||y()}),x(j,N,k)}return x(j,E,k)},p=(j,E,k)=>{const y=c(j),B={d:(y==null?void 0:y.d)||new Map,e:E};return k&&u(j,B,k),y&&isEqualAtomError(y,B)&&y.d===B.d?y:(d(j,B),B)},g=j=>{const E=c(j);if(E&&(E.d.forEach((M,P)=>{P!==j&&!n.has(P)&&g(P)}),Array.from(E.d).every(([M,P])=>{const D=c(M);return M===j||D===P||D&&!hasPromiseAtomValue(D)&&isEqualAtomValue(D,P)})))return E;const k=new Map;let y=!0;const B=M=>{if(M===j){const D=c(M);if(D)return k.set(M,D),returnAtomValue(D);if(hasInitialValue(M))return k.set(M,void 0),M.init;throw new Error("no atom init")}const P=g(M);return k.set(M,P),returnAtomValue(P)};let N,L;const O={get signal(){return N||(N=new AbortController),N.signal},get setSelf(){return(define_import_meta_env_default$2?"production":void 0)!=="production"&&!isActuallyWritableAtom(j)&&console.warn("setSelf function cannot be used with read-only atom"),!L&&isActuallyWritableAtom(j)&&(L=(...M)=>{if((define_import_meta_env_default$2?"production":void 0)!=="production"&&y&&console.warn("setSelf function cannot be called in sync"),!y)return w(j,...M)}),L}};try{const M=j.read(B,O);return m(j,M,k,()=>N==null?void 0:N.abort())}catch(M){return p(j,M,k)}finally{y=!1}},R=j=>returnAtomValue(g(j)),h=j=>{let E=n.get(j);return E||(E=v(j)),E},f=(j,E)=>!E.l.size&&(!E.t.size||E.t.size===1&&E.t.has(j)),b=j=>{const E=n.get(j);E&&f(j,E)&&S(j)},C=j=>{const E=new Map,k=new WeakMap,y=N=>{const L=n.get(N);L==null||L.t.forEach(O=>{O!==N&&(E.set(O,(E.get(O)||new Set).add(N)),k.set(O,(k.get(O)||0)+1),y(O))})};y(j);const B=N=>{const L=n.get(N);L==null||L.t.forEach(O=>{var M;if(O!==N){let P=k.get(O);if(P&&k.set(O,--P),!P){let D=!!((M=E.get(O))!=null&&M.size);if(D){const V=c(O),$=g(O);D=!V||!isEqualAtomValue(V,$)}D||E.forEach(V=>V.delete(O))}B(O)}})};B(j)},_=(j,...E)=>{let k=!0;const y=L=>returnAtomValue(g(L)),B=(L,...O)=>{let M;if(L===j){if(!hasInitialValue(L))throw new Error("atom not writable");const P=c(L),D=m(L,O[0]);(!P||!isEqualAtomValue(P,D))&&C(L)}else M=_(L,...O);if(!k){const P=T();(define_import_meta_env_default$2?"production":void 0)!=="production"&&i.forEach(D=>D({type:"async-write",flushed:P}))}return M},N=j.write(y,B,...E);return k=!1,N},w=(j,...E)=>{const k=_(j,...E),y=T();return(define_import_meta_env_default$2?"production":void 0)!=="production"&&i.forEach(B=>B({type:"write",flushed:y})),k},v=(j,E)=>{const k={t:new Set(E&&[E]),l:new Set};if(n.set(j,k),(define_import_meta_env_default$2?"production":void 0)!=="production"&&l.add(j),g(j).d.forEach((y,B)=>{const N=n.get(B);N?N.t.add(j):B!==j&&v(B,j)}),g(j),isActuallyWritableAtom(j)&&j.onMount){const y=j.onMount((...B)=>w(j,...B));y&&(k.u=y)}return k},S=j=>{var E;const k=(E=n.get(j))==null?void 0:E.u;k&&k(),n.delete(j),(define_import_meta_env_default$2?"production":void 0)!=="production"&&l.delete(j);const y=c(j);y?(hasPromiseAtomValue(y)&&cancelPromise(y.v),y.d.forEach((B,N)=>{if(N!==j){const L=n.get(N);L&&(L.t.delete(j),f(N,L)&&S(N))}})):(define_import_meta_env_default$2?"production":void 0)!=="production"&&console.warn("[Bug] could not find atom state to unmount",j)},A=(j,E,k)=>{const y=new Set(E.d.keys());k==null||k.forEach((B,N)=>{if(y.has(N)){y.delete(N);return}const L=n.get(N);L&&(L.t.delete(j),f(N,L)&&S(N))}),y.forEach(B=>{const N=n.get(B);N?N.t.add(j):n.has(j)&&v(B,j)})},T=()=>{let j;for((define_import_meta_env_default$2?"production":void 0)!=="production"&&(j=new Set);r.size;){const E=Array.from(r);r.clear(),E.forEach(([k,y])=>{const B=c(k);if(B){B.d!==(y==null?void 0:y.d)&&A(k,B,y==null?void 0:y.d);const N=n.get(k);N&&!(y&&!hasPromiseAtomValue(y)&&(isEqualAtomValue(y,B)||isEqualAtomError(y,B)))&&(N.l.forEach(L=>L()),(define_import_meta_env_default$2?"production":void 0)!=="production"&&j.add(k))}else(define_import_meta_env_default$2?"production":void 0)!=="production"&&console.warn("[Bug] no atom state to flush")})}if((define_import_meta_env_default$2?"production":void 0)!=="production")return a.forEach(E=>E("state")),j},I=(j,E)=>{const k=h(j),y=T(),B=k.l;return B.add(E),(define_import_meta_env_default$2?"production":void 0)!=="production"&&(a.forEach(N=>N("sub")),i.forEach(N=>N({type:"sub",flushed:y}))),()=>{B.delete(E),b(j),(define_import_meta_env_default$2?"production":void 0)!=="production"&&(a.forEach(N=>N("unsub")),i.forEach(N=>N({type:"unsub"})))}};return(define_import_meta_env_default$2?"production":void 0)!=="production"?{get:R,set:w,sub:I,dev_subscribe_store:(j,E)=>E!==2?(console.warn("The current StoreListener revision is 2. The older ones are deprecated."),a.add(j),()=>{a.delete(j)}):(i.add(j),()=>{i.delete(j)}),dev_get_mounted_atoms:()=>l.values(),dev_get_atom_state:j=>o.get(j),dev_get_mounted:j=>n.get(j),dev_restore_atoms:j=>{for(const[k,y]of j)hasInitialValue(k)&&(m(k,y),C(k));const E=T();i.forEach(k=>k({type:"restore",flushed:E}))}}:{get:R,set:w,sub:I}};let defaultStore;const getDefaultStore=()=>(defaultStore||(defaultStore=createStore()),defaultStore);var define_import_meta_env_default$1={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",VITE_JOTAI_DEVTOOL_ENABLED:"true",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const RESET=Symbol(),getCached$1=(o,n,r)=>(n.has(r)?n:n.set(r,o())).get(r),cache1$2=new WeakMap,memo2$1=(o,n,r)=>{const a=getCached$1(()=>new WeakMap,cache1$2,n);return getCached$1(o,a,r)},cacheKeyForEmptyKeyExtractor={},isWritable=o=>!!o.write,isFunction=o=>typeof o=="function";function splitAtom(o,n){return memo2$1(()=>{const r=new WeakMap,a=(c,d)=>{let u=r.get(c);if(u)return u;const x=d&&r.get(d),m=[],p=[];return c.forEach((g,R)=>{const h=n?n(g):R;p[R]=h;const f=x&&x.atomList[x.keyList.indexOf(h)];if(f){m[R]=f;return}const b=_=>{const w=_(i),v=_(o),A=a(v,w==null?void 0:w.arr).keyList.indexOf(h);if(A<0||A>=v.length){const T=c[a(c).keyList.indexOf(h)];if(T)return T;throw new Error("splitAtom: index out of bounds for read")}return v[A]},C=(_,w,v)=>{const S=_(i),A=_(o),I=a(A,S==null?void 0:S.arr).keyList.indexOf(h);if(I<0||I>=A.length)throw new Error("splitAtom: index out of bounds for write");const j=isFunction(v)?v(A[I]):v;w(o,[...A.slice(0,I),j,...A.slice(I+1)])};m[R]=isWritable(o)?atom(b,C):atom(b)}),x&&x.keyList.length===p.length&&x.keyList.every((g,R)=>g===p[R])?u=x:u={arr:c,atomList:m,keyList:p},r.set(c,u),u},i=atom(c=>{const d=c(i),u=c(o);return a(u,d==null?void 0:d.arr)});(define_import_meta_env_default$1?"production":void 0)!=="production"&&(i.debugPrivate=!0),i.init=void 0;const l=isWritable(o)?atom(c=>c(i).atomList,(c,d,u)=>{switch(u.type){case"remove":{const x=c(l).indexOf(u.atom);if(x>=0){const m=c(o);d(o,[...m.slice(0,x),...m.slice(x+1)])}break}case"insert":{const x=u.before?c(l).indexOf(u.before):c(l).length;if(x>=0){const m=c(o);d(o,[...m.slice(0,x),u.value,...m.slice(x)])}break}case"move":{const x=c(l).indexOf(u.atom),m=u.before?c(l).indexOf(u.before):c(l).length;if(x>=0&&m>=0){const p=c(o);x<m?d(o,[...p.slice(0,x),...p.slice(x+1,m),p[x],...p.slice(m)]):d(o,[...p.slice(0,m),p[x],...p.slice(m,x),...p.slice(x+1)])}break}}}):atom(c=>c(i).atomList);return l},o,n||cacheKeyForEmptyKeyExtractor)}const isPromiseLike$1=o=>typeof(o==null?void 0:o.then)=="function";function createJSONStorage(o){let n,r;const a={getItem:(i,l)=>{var c,d;const u=m=>{if(m=m||"",n!==m){try{r=JSON.parse(m)}catch{return l}n=m}return r},x=(d=(c=o())==null?void 0:c.getItem(i))!=null?d:null;return isPromiseLike$1(x)?x.then(u):u(x)},setItem:(i,l)=>{var c;return(c=o())==null?void 0:c.setItem(i,JSON.stringify(l))},removeItem:i=>{var l;return(l=o())==null?void 0:l.removeItem(i)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(a.subscribe=(i,l,c)=>{if(!(o()instanceof window.Storage))return()=>{};const d=u=>{if(u.storageArea===o()&&u.key===i){let x;try{x=JSON.parse(u.newValue||"")}catch{x=c}l(x)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),a}const defaultStorage=createJSONStorage(()=>typeof window<"u"?window.localStorage:void 0);function atomWithStorage(o,n,r=defaultStorage,a){const i=a==null?void 0:a.unstable_getOnInit,l=atom(i?r.getItem(o,n):n);return(define_import_meta_env_default$1?"production":void 0)!=="production"&&(l.debugPrivate=!0),l.onMount=d=>{i||d(r.getItem(o,n));let u;return r.subscribe&&(u=r.subscribe(o,d,n)),u},atom(d=>d(l),(d,u,x)=>{const m=typeof x=="function"?x(d(l)):x;return m===RESET?(u(l,n),r.removeItem(o)):m instanceof Promise?m.then(p=>(u(l,p),r.setItem(o,p))):(u(l,m),r.setItem(o,m))})}var define_import_meta_env_default={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",VITE_JOTAI_DEVTOOL_ENABLED:"true",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const StoreContext=React.createContext(void 0),useStore=o=>{const n=React.useContext(StoreContext);return(o==null?void 0:o.store)||n||getDefaultStore()},isPromiseLike=o=>typeof(o==null?void 0:o.then)=="function",use=React.use||(o=>{if(o.status==="pending")throw o;if(o.status==="fulfilled")return o.value;throw o.status==="rejected"?o.reason:(o.status="pending",o.then(n=>{o.status="fulfilled",o.value=n},n=>{o.status="rejected",o.reason=n}),o)});function useAtomValue(o,n){const r=useStore(n),[[a,i,l],c]=React.useReducer(x=>{const m=r.get(o);return Object.is(x[0],m)&&x[1]===r&&x[2]===o?x:[m,r,o]},void 0,()=>[r.get(o),r,o]);let d=a;(i!==r||l!==o)&&(c(),d=r.get(o));const u=n==null?void 0:n.delay;return React.useEffect(()=>{const x=r.sub(o,()=>{if(typeof u=="number"){setTimeout(c,u);return}c()});return c(),x},[r,o,u]),React.useDebugValue(d),isPromiseLike(d)?use(d):d}function useSetAtom(o,n){const r=useStore(n);return React.useCallback((...i)=>{if((define_import_meta_env_default?"production":void 0)!=="production"&&!("write"in o))throw new Error("not writable atom");return r.set(o,...i)},[r,o])}function useAtom(o,n){return[useAtomValue(o,n),useSetAtom(o,n)]}function duplicateBlocks(o,n,r){const a=lodashEs.filter(o,l=>l._parent===n),i=[];for(let l=0;l<a.length;l++){const c=getSlots(a[l]);if(Object.keys(c).length>0&&Object.keys(c).forEach(d=>{a[l][d]=`slot:${iconBase.generateUUID()}`}),lodashEs.filter(o,{_parent:a[l]._id}).length>0){const d=iconBase.generateUUID();i.push({...a[l],oldId:a[l]._id,_id:d,_parent:r}),i.push(lodashEs.flatten(duplicateBlocks(o,a[l]._id,d)))}else i.push({...a[l],oldId:a[l]._id,_id:iconBase.generateUUID(),_parent:r})}return lodashEs.flatten(i)}function convertToBlocksTree(o){const n={};o.forEach(a=>{n[a._id]={...a,children:[]}});const r=[];return o.forEach(a=>{if(a._parent){const i=n[a._parent];i&&i.children.push(n[a._id])}else r.push(n[a._id])}),r}const getSlots=o=>{const n={};return Object.keys(o).forEach(r=>{lodashEs.isString(o[r])&&o[r].startsWith("slot")&&(n[r]=o[r].replace("slot:",""))}),n},getDuplicatedBlocks=(o,n,r=null)=>{let a=lodashEs.find(o,{_id:n});a={...a,oldId:a._id,_id:iconBase.generateUUID()},r&&(a={...a,_parent:r});const i=[a];lodashEs.filter(o,{_parent:n}).length>0&&i.push(lodashEs.flatten(duplicateBlocks(o,n,a._id)));const l=lodashEs.flatten(i);return lodashEs.map(l,c=>{const d=c,u=getSlots(d);return Object.keys(u).length>0&&Object.keys(u).forEach(x=>{const m=lodashEs.find(l,{oldId:u[x].replace("slot:","")});d[x]=`slot:${m._id}`}),lodashEs.omit(d,["global","oldId"])})},presentBlocksAtom=jotai.atom([]);presentBlocksAtom.debugLabel="presentBlocksAtom";const treeDSBlocks=jotai.atom(o=>{const n=o(presentBlocksAtom);return convertToBlocksTree([...n])});treeDSBlocks.debugLabel="treeDSBlocks";presentBlocksAtom.debugLabel="presentBlocksAtom";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(o=>{const n=o(buildingBlocksAtom);return lodashEs.filter(n,r=>lodashEs.has(r,"blockId"))});globalBlocksAtom.debugLabel="globalBlocksAtom";const selectedBlockIdsAtom=jotai.atom([]);selectedBlockIdsAtom.debugLabel="selectedBlockIdsAtom";const selectedBlocksAtom=jotai.atom(o=>{const n=o(presentBlocksAtom),r=o(selectedBlockIdsAtom);return lodashEs.map(lodashEs.filter(n,({_id:a})=>lodashEs.includes(r,a)),a=>({...a}))});selectedBlocksAtom.debugLabel="selectedBlocksAtom";const selectedBlockAtom=jotai.atom(o=>{const n=o(selectedBlocksAtom);if(n.length===0)return null;if(n.length===1)return n[0]});selectedBlockAtom.debugLabel="selectedBlockAtom";const getParentId=o=>lodashEs.get(o,"_parent",null),selectedBlocksParentsAtom=jotai.atom(o=>{const n=o(selectedBlocksAtom),r=lodashEs.map(n,getParentId);return lodashEs.filter(o(presentBlocksAtom),a=>lodashEs.includes(r,a._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(o=>{const n=o(selectedBlockAtom),r=o(presentBlocksAtom);let a=n;const i=[n];do{const l=r.find(({_id:c})=>c===(a==null?void 0:a._parent));a=l,l&&i.push(l)}while(a!=null&&a._parent);return i}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[o,n]=jotai.useAtom(selectedBlockIdsAtom),r=React.useCallback(a=>{n(i=>lodashEs.includes(i,a)?lodashEs.without(i,a):[...i,a])},[n]);return[o,n,r]},getBlockJSONFromUISchemas=o=>{switch(o.type){case"singular":return o.uiSchema;case"model":const{properties:n}=o,r={};return Object.keys(n).forEach(l=>{const c=n[l];if(lodashEs.includes(["slot","styles"],c.type))return;const d=l;r[d]=getBlockJSONFromUISchemas(c)}),r;case"list":const{itemProperties:a}=o,i={items:{}};return Object.keys(a).forEach(l=>{const c=a[l];if(lodashEs.includes(["slot","styles"],c.type))return;const d=l;i.items[d]=getBlockJSONFromUISchemas(c)}),i;default:return{}}},getBlockJSONFromSchemas=(o,n)=>{switch(o.type){case"singular":{const u=o.schema;return u.title&&(u.title=n(u.title)),u.oneOf&&Array.isArray(u.oneOf)&&(u.oneOf=u.oneOf.map(x=>(x.title&&(x.title=n(x.title)),x))),u}case"model":const{properties:r,title:a}=o,i={title:n(a),type:"object",properties:{}};return Object.keys(r).forEach(u=>{const x=r[u];if(lodashEs.includes(["slot","styles"],x.type))return;const m=u;i.properties[m]=getBlockJSONFromSchemas(x,n)}),i;case"list":const{itemProperties:l,title:c}=o,d={title:n(c),type:"array",items:{type:"object",properties:{}}};return Object.keys(l).forEach(u=>{const x=l[u];if(lodashEs.includes(["slot","styles"],x.type))return;const m=u;d.items.properties[m]=getBlockJSONFromSchemas(x,n),lodashEs.set(d.items,"title",lodashEs.get(x,"itemTitle",`${n(c)} item`))}),d;default:return{}}},getBlockDefaultProps=o=>{if(!o)return{};const n={};return Object.keys(o).forEach(r=>{n[r]=getBlockDefaultProp(o[r])}),n},getListDefaults=o=>{if(lodashEs.isEmpty(o.default))return[];const{itemProperties:n}=o;return lodashEs.map(o.default,r=>{const a={...r};return lodashEs.forIn(r,(i,l)=>{lodashEs.has(n,l)&&lodashEs.get(n[l],"i18n",!1)&&(a[l]=STRINGS.I18N_KEY)}),a})},getBlockDefaultProp=o=>{switch(o.type){case"styles":return o.default;case"slot":return`${STRINGS.SLOT_KEY}${iconBase.generateUUID()}`;case"singular":const{schema:n}=o;return lodashEs.get(n,"default","");case"model":return getBlockDefaultProps(o.properties);case"list":return getListDefaults(o);default:return""}},convertDotNotationToObject=(o,n)=>{const r={};return lodashEs.set(r,o,n),r};var undomanager={exports:{}};(function(o){(function(){function n(a,i,l){return a.splice(i,!l||1+l-i+(!(l<0^i>=0)&&(l<0||-1)*a.length)),a.length}let r=function(){let a=[],i=-1,l=0,c=!1,d;function u(x,m){return!x||typeof x[m]!="function"?this:(c=!0,x[m](),c=!1,this)}return{add:function(x){return c?this:(a.splice(i+1,a.length-i),a.push(x),l&&a.length>l&&n(a,0,-(l+1)),i=a.length-1,d&&d(),this)},setCallback:function(x){d=x},undo:function(){let x=a[i];if(!x)return this;const m=x.groupId;for(;x.groupId===m&&(u(x,"undo"),i-=1,x=a[i],!(!x||!x.groupId)););return d&&d(),this},redo:function(){let x=a[i+1];if(!x)return this;const m=x.groupId;for(;x.groupId===m&&(u(x,"redo"),i+=1,x=a[i+1],!(!x||!x.groupId)););return d&&d(),this},clear:function(){let x=a.length;a=[],i=-1,d&&x>0&&d()},hasUndo:function(){return i!==-1},hasRedo:function(){return i<a.length-1},getCommands:function(x){return x?a.filter(m=>m.groupId===x):a},getIndex:function(){return i},setLimit:function(x){l=x}}};o.exports?o.exports=r:window.UndoManager=r})()})(undomanager);var undomanagerExports=undomanager.exports;const UndoManager=plugin.getDefaultExportFromCjs(undomanagerExports),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),blocksContainerAtom=jotai.atom(null),useBrandingOptions=()=>{const[o,n]=jotai.useAtom(brandingOptionsAtom);return[lodashEs.isObject(o)?{...BRANDING_OPTIONS_DEFAULTS,...o}:BRANDING_OPTIONS_DEFAULTS,n]},useBlocksContainer=()=>jotai.useAtom(blocksContainerAtom),currentPageAtom=jotai.atom(null),useCurrentPage=()=>({currentPage:jotai.useAtomValue(currentPageAtom)});function getBlocksTree(o){return convertToBlocksTree(o)}const nestedToFlatArray=(o,n)=>lodashEs.flatten(o.map(r=>{if(r=n?{...r,_parent:n}:{...r},r.children){const a=[...r.children];return delete r.children,lodashEs.flatten([r,...nestedToFlatArray(a,r._id)])}return r}));function setProjectBlocksInMemory(o,n=!1){for(let r=0;r<o.length;r++){const a=o[r];a.global&&!n?o[r]={type:"GlobalBlock",blockId:a.blockId,_parent:lodashEs.get(a,"_parent",null),_id:a._id}:a.children&&a.children.length&&setProjectBlocksInMemory(a.children)}}function getInnerBlocks(o){let n=[],r=lodashEs.filter(o,{type:"GlobalBlock"});return r.length>0&&(r=lodashEs.map(r,getPBlocks),lodashEs.each(r,a=>{n=[...n,...getSingleBlock(a)]})),n}function getSingleBlock(o){let n=[];const r=lodashEs.get(lodashEs.first(o),"_parent",null);lodashEs.set(lodashEs.first(o),"_parent",null);const a=[flatToNestedInstance.convert(clone(o))];setProjectBlocksInMemory(a,!0);let i=nestedToFlatArray(a,o[0]._id);return i=lodashEs.set(i,"0._parent",r),n=[...n,i,...getInnerBlocks(i)],n}function getPBlocks(o){const n=lodashEs.find(FLAT_ARRAY,{_id:o._id});if(!n)return[];const r=[n],a=lodashEs.filter(FLAT_ARRAY,{_parent:o._id});return a.length?lodashEs.flatten([...r,...lodashEs.flatten(lodashEs.map(a,getPBlocks))]):lodashEs.flatten(r)}const clone=o=>JSON.parse(JSON.stringify(o));let FLAT_ARRAY=[];function splitPageBlocks(o){FLAT_ARRAY=o;const n=getBlocksTree(clone(o));setProjectBlocksInMemory(n);const r=nestedToFlatArray(n,null),a=getInnerBlocks(r),i={};return lodashEs.each(a,l=>lodashEs.set(i,lodashEs.first(l).blockId,l)),[r,i]}const useGetPageData=()=>{const[o]=useBrandingOptions(),{currentPage:n}=useCurrentPage(),[r]=useBlocksStore();return React.useCallback(()=>{const a=lodashEs.map(r,l=>lodashEs.omit(l,["expanded","order","title","siblings","tempClasses"])),[i=[]]=splitPageBlocks(a);return{currentPage:n,blocks:i}},[o,n,r])},chaiBuilderPropsAtom=jotai.atom(null);chaiBuilderPropsAtom.debugLabel="chaiBuilderPropsAtom";const chaiExternalDataAtom=jotai.atom({});chaiExternalDataAtom.debugLabel="chaiExternalDataAtom";const useBuilderProp=(o,n=void 0)=>{const r=jotai.useAtomValue(chaiBuilderPropsAtom);return lodashEs.get(r,o,n)},dataProvidersAtom=jotai.atom([]);dataProvidersAtom.debugLabel="dataProvidersAtom";const usePageDataProviders=()=>jotai.useAtom(dataProvidersAtom),builderSaveStateAtom=jotai.atom("SAVED");builderSaveStateAtom.debugLabel="builderSaveStateAtom";const useSavePage=()=>{const[o,n]=jotai.useAtom(builderSaveStateAtom),r=useBuilderProp("onSave",async u=>{}),a=useBuilderProp("onSaveStateChange",lodashEs.noop),i=useGetPageData(),[l]=usePageDataProviders(),[c]=useBrandingOptions();return{savePage:web.useThrottledCallback(async()=>{n("SAVING"),a("SAVING");const u=i();return await r({blocks:u.blocks,providers:l,brandingOptions:c,themeConfiguration:c}),setTimeout(()=>{n("SAVED"),a("SAVED")},100),!0},[i,n,c,r,a],3e3),saveState:o,setSaveState:n}},undoManager=new UndoManager;undoManager.setLimit(50);const useUndoManager=()=>{const[,o]=jotai.useAtom(builderSaveStateAtom),n=useBuilderProp("onSaveStateChange",lodashEs.noop);return React.useEffect(()=>(undoManager.setCallback(()=>{o("UNSAVED"),n("UNSAVED")}),()=>{undoManager.setCallback(lodashEs.noop)}),[]),{add:undoManager.add,undo:undoManager.undo,redo:undoManager.redo,hasRedo:undoManager.hasRedo,hasUndo:undoManager.hasUndo,clear:undoManager.clear}},removeNestedBlocks=(o,n)=>{const r=[],a=lodashEs.filter(o,i=>lodashEs.includes(n,i._id)||lodashEs.includes(n,i._parent)?(r.push(i._id),!1):!0);return lodashEs.isEmpty(r)?a:removeNestedBlocks(a,r)},useRemoveBlocks=()=>{const[o]=useBlocksStore(),[n,r]=useSelectedBlockIds(),{setNewBlocks:a}=useBlocksStoreUndoableActions();return React.useCallback(i=>{var c;const l=((c=lodashEs.find(o,{_id:i[0]}))==null?void 0:c._parent)||null;a(removeNestedBlocks(o,i)),setTimeout(()=>r(l?[l]:[]),200)},[o,r,n])};function insertBlocksAtPosition(o,n,r,a){let i=o.filter(d=>!d._parent);r&&(i=o.filter(d=>d._parent===r));const l=a!==void 0?a:i.length;let c=o.length;for(let d=0,u=0;d<o.length;d++)if(o[d]._parent===r){if(u===l){c=d;break}u++}return!r&&a!==void 0&&a>=i.length&&(c=o.length),[...o.slice(0,c),...n,...o.slice(c)]}function flattenTree(o){let n=[];return o.walk(r=>(delete r.model.children,n.push(r.model),!0)),n}function findNodeById(o,n){return o.first(r=>r.model._id===n)||null}function moveNode(o,n,r,a){const i=findNodeById(o,n),l=findNodeById(o,r);if(i&&l){i.drop(),l.children||(l.model.children=[]);try{l.addChildAtIndex(i,a)}catch(c){return console.error("Error adding child to parent:",c),!1}return!0}return!1}function moveBlocksWithChildren(o,n,r,a){if(!n)return o;r=r||"root";const l=new TreeModel().parse({_id:"root",children:getBlocksTree(o)});if(moveNode(l,n,r,a)){const c=flattenTree(l),d=c.find(u=>u._id===n);return d&&(d._parent=r==="root"?null:r),c.shift(),c}return o}const useBlocksStoreManager=()=>{const[,o]=useBlocksStore();return{setNewBlocks:n=>{o(n)},addBlocks:(n,r,a)=>{o(i=>insertBlocksAtPosition(i,n,r,a))},removeBlocks:n=>{o(r=>removeNestedBlocks(r,n))},moveBlocks:(n,r,a)=>{o(i=>{let l=i;for(let c=0;c<n.length;c++)l=moveBlocksWithChildren(l,n[c],r,a);return l})},updateBlocksProps:n=>{o(r=>{const a=n.map(i=>i._id);return r.map(i=>{if(a.includes(i._id)){const l=lodashEs.find(n,{_id:i._id});return{...i,...lodashEs.omit(l,"_id")}}return i})})}}},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:o}=useUndoManager(),[n]=useBlocksStore(),{setNewBlocks:r,addBlocks:a,removeBlocks:i,moveBlocks:l,updateBlocksProps:c}=useBlocksStoreManager();return{moveBlocks:(h,f,b)=>{const C=lodashEs.map(h,w=>{const S=n.find(I=>I._id===w)._parent||null,T=n.filter(I=>S?I._parent===S:!I._parent).map(I=>I._id).indexOf(w);return{_id:w,oldParent:S,oldPosition:T}}),_=C.find(({_id:w})=>w===h[0]);_&&_.oldParent===f&&_.oldPosition===b||(l(h,f,b),o({undo:()=>lodashEs.each(C,({_id:w,oldParent:v,oldPosition:S})=>{l([w],v,S)}),redo:()=>l(h,f,b)}))},addBlocks:(h,f,b)=>{a(h,f,b),o({undo:()=>i(lodashEs.map(h,"_id")),redo:()=>a(h,f,b)})},removeBlocks:h=>{var _;const f=(_=lodashEs.first(h))==null?void 0:_._parent,C=n.filter(w=>f?w._parent===f:!w._parent).indexOf(lodashEs.first(h));i(lodashEs.map(h,"_id")),o({undo:()=>a(h,f,C),redo:()=>i(lodashEs.map(h,"_id"))})},updateBlocks:(h,f,b)=>{let C=[];if(b)C=lodashEs.map(h,_=>({_id:_,...b}));else{const _=lodashEs.keys(f);C=lodashEs.map(h,w=>{const v=n.find(A=>A._id===w),S={_id:w};return lodashEs.each(_,A=>S[A]=v[A]),S})}c(lodashEs.map(h,_=>({_id:_,...f}))),o({undo:()=>c(C),redo:()=>c(lodashEs.map(h,_=>({_id:_,...f})))})},updateBlocksRuntime:(h,f)=>{c(lodashEs.map(h,b=>({_id:b,...f})))},setNewBlocks:h=>{r(h),o({undo:()=>r(n),redo:()=>r(h)})},updateMultipleBlocksProps:h=>{let f=[];f=lodashEs.map(h,b=>{const C=lodashEs.keys(b),_=n.find(v=>v._id===b._id),w={};return lodashEs.each(C,v=>w[v]=_[v]),w}),c(h),o({undo:()=>c(f),redo:()=>c(h)})}}},useAddBlock=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:r}=useBlocksStoreUndoableActions(),a=React.useCallback((l,c,d)=>{var g;for(let R=0;R<l.length;R++){const{_id:h}=l[R];l[R]._id=iconBase.generateUUID();const f=lodashEs.filter(l,{_parent:h});for(let b=0;b<f.length;b++)f[b]._parent=l[R]._id}const u=lodashEs.first(l);let x,m;return c&&(x=lodashEs.find(o,{_id:c}),l[0]._parent=c,m=c),!(x?canAcceptChildBlock(x==null?void 0:x._type,u._type):!0)&&x&&(l[0]._parent=x._parent,m=x._parent),r(l,m,d),n([(g=lodashEs.first(l))==null?void 0:g._id]),lodashEs.first(l)},[o,n]);return{addCoreBlock:React.useCallback((l,c,d)=>{if(lodashEs.has(l,"blocks")){const b=l.blocks;return a(b,c,d)}const u=iconBase.generateUUID(),x=getBlockDefaultProps(l.props),m=[];lodashEs.forIn(x,(b,C)=>{if(lodashEs.startsWith(b,STRINGS.SLOT_KEY)){const _=b.replace(STRINGS.SLOT_KEY,"");m.push({_id:_,_type:"Slot",_parent:u,_name:l.props[C].name,_styles:l.props[C].styles,_emptyStyles:l.props[C].emptyStyles})}});const p={_type:l.type,_id:u,...x};let g,R;c&&(g=lodashEs.find(o,{_id:c}),p._parent=c,R=c),!canAcceptChildBlock(g==null?void 0:g._type,p._type)&&g&&(p._parent=g._parent,R=g._parent);const f=[p,...m];return r(f,R,d),n([p._id]),p},[a,o,n]),addPredefinedBlock:a}},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),o=>`${o}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|primary(-\\d+)?|secondary(-\\d+)?|\\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,o=>`columns-${o}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:lodashEs.map(CLASS_VALUES.breakAfter,o=>`break-after-${o}`),regExp:"break-after-\\S+"},breakBefore:{classes:lodashEs.map(CLASS_VALUES.breakAfter,o=>`break-before-${o}`),regExp:"break-before-\\S+"},breakInside:{classes:lodashEs.map(CLASS_VALUES.breakInside,o=>`break-inside-${o}`),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"],o=>`grid-cols-${o}`),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"],o=>`outline-${o}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","hidden","none"],o=>`border-${o}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:lodashEs.map(CLASS_VALUES.overflow,o=>`overflow-${o}`),regExp:`overflow-(${CLASS_VALUES.overflow.join("|")})`},overflowX:{classes:lodashEs.map(CLASS_VALUES.overflow,o=>`overflow-x-${o}`),regExp:`overflow-x-(${CLASS_VALUES.overflow.join("|")})`},overflowY:{classes:lodashEs.map(CLASS_VALUES.overflow,o=>`overflow-y-${o}`),regExp:`overflow-y-(${CLASS_VALUES.overflow.join("|")})`},gridRows:{classes:lodashEs.map([1,2,3,4,5,6,"none"],o=>`grid-rows-${o}`),regExp:"grid-rows-(\\d|none)"},display:{classes:lodashEs.map(CLASS_VALUES.display,o=>o.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,o=>`object-${o}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:lodashEs.map(CLASS_VALUES.objectPosition,o=>`object-${o}`),regExp:`object-(${CLASS_VALUES.objectPosition.join("|")})`},overscroll:{classes:lodashEs.map(CLASS_VALUES.overscroll,o=>`overscroll-${o}`),regExp:`overscroll-(${CLASS_VALUES.overscroll.join("|")})`},overscrollX:{classes:lodashEs.map(CLASS_VALUES.overscroll,o=>`overscroll-x-${o}`),regExp:`overscroll-x-(${CLASS_VALUES.overscroll.join("|")})`},overscrollY:{classes:lodashEs.map(CLASS_VALUES.overscroll,o=>`overscroll-y-${o}`),regExp:`overscroll-y-(${CLASS_VALUES.overscroll.join("|")})`},inset:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`inset-${o}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`inset-x-${o}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`inset-y-${o}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`top-${o}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`top-x-${o}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`top-y-${o}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`right-${o}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`right-x-${o}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`right-y-${o}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`bottom-${o}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`bottom-x-${o}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`bottom-y-${o}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`left-${o}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`left-x-${o}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:lodashEs.map(CLASS_VALUES.trbl,o=>`left-y-${o}`),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"],o=>`z-${o}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:lodashEs.map(CLASS_VALUES.flexBasis,o=>`basis-${o}`),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),o=>`col-span-${o}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...lodashEs.map(lodashEs.range(1,14),o=>`col-start-${o}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...lodashEs.map(lodashEs.range(1,14),o=>`col-end-${o}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...lodashEs.map(lodashEs.range(1,7),o=>`row-span-${o}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...lodashEs.map(lodashEs.range(1,8),o=>`row-start-${o}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...lodashEs.map(lodashEs.range(1,8),o=>`row-end-${o}`),"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,o=>`gap-${o}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:lodashEs.map(CLASS_VALUES.indent,o=>`gap-x-${o}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:lodashEs.map(CLASS_VALUES.indent,o=>`gap-y-${o}`),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"],o=>`drop-shadow-${o}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],o=>`backdrop-blur-${o}`),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],o=>`backdrop-brightness-${o}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:lodashEs.map([0,50,75,100,125,150,200],o=>`backdrop-contrast-${o}`),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],o=>`backdrop-hue-rotate-${o}`),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],o=>`backdrop-opacity-${o}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:lodashEs.map([0,50,100,150,200],o=>`backdrop-saturate-${o}`),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,o=>`origin-${o}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`p-${o}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`px-${o}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`py-${o}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`pt-${o}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`pr-${o}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`pb-${o}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:lodashEs.map(CLASS_VALUES.padding,o=>`pl-${o}`),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],o=>`decoration-${o}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},margin:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`m-${o}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`mx-${o}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`my-${o}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`mt-${o}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`mr-${o}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`mb-${o}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:lodashEs.map(CLASS_VALUES.margin,o=>`ml-${o}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:lodashEs.map(CLASS_VALUES.space,o=>`space-x-${o}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:lodashEs.map(CLASS_VALUES.space,o=>`space-y-${o}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:lodashEs.map(["sm","md","lg","xl","2xl","inner","none"],o=>`shadow-${o}`),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,o=>`max-w-${o}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:lodashEs.map([...CLASS_VALUES.width,"full","screen","min","max","fit"],o=>`w-${o}`),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,o=>`max-h-${o}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:lodashEs.map(CLASS_VALUES.height,o=>`h-${o}`),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|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:lodashEs.map(CLASS_VALUES.indent,o=>`indent-${o}`),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"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},backgroundAttachment:{classes:["bg-fixed","bg-local","bg-scroll"],regExp:"bg-(fixed|local|scroll)"},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|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-tl-${o}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-tr-${o}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-br-${o}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-bl-${o}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-t-${o}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-r-${o}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-b-${o}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-l-${o}`)],regExp:`(rounded-l-(${CLASS_VALUES.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...lodashEs.map(CLASS_VALUES.borderRadius,o=>`rounded-${o}`)],regExp:`(rounded-(${CLASS_VALUES.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-x-${o}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-y-${o}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-t-${o}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-r-${o}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-b-${o}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-l-${o}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"border-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},border:{classes:["border",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-${o}`)],regExp:"border-?(\\d+|\\S+|\\[.*\\])?"},order:{classes:lodashEs.map([...lodashEs.range(0,13),"first","last","none"],o=>`order-${o}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:lodashEs.map(["0",2,4,8],o=>`divide-x-${o}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:lodashEs.map(["0",2,4,8],o=>`divide-y-${o}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},divideStyle:{classes:lodashEs.map(["solid","dashed","dotted","double","none"],o=>`divide-${o}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:lodashEs.map([0,1,2,4,8],o=>`outline-${o}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:lodashEs.map([0,1,2,4,8],o=>`outline-offset-${o}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},ringWidth:{classes:lodashEs.map([0,1,2,4,8,"inset"],o=>`ring-${o}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:lodashEs.map([0,1,2,4,8],o=>`ring-offset-${o}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},opacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],o=>`opacity-${o}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,o=>`mix-blend-${o}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:lodashEs.map(CLASS_VALUES.blendEffect,o=>`bg-blend-${o}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:lodashEs.map(["none","sm","md","lg","xl","2xl","3xl"],o=>`blur-${o}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:lodashEs.map([0,50,75,90,95,100,105,110,125,150,200],o=>`brightness-${o}`),regExp:"brightness-(\\d+)"},contrast:{classes:lodashEs.map([0,50,75,100,125,150,200],o=>`contrast-${o}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:lodashEs.map([0,15,30,60,90,180],o=>`hue-rotate-${o}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:lodashEs.map([0,50,100,150,200],o=>`saturate-${o}`),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],o=>`duration-${o}`),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],o=>`delay-${o}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animation-none","animation-spin","animation-ping"],regExp:"animation-(none|spin|ping)"},scaleX:{classes:lodashEs.map(CLASS_VALUES.scale,o=>`scale-x-${o}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:lodashEs.map(CLASS_VALUES.scale,o=>`scale-y-${o}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:lodashEs.map(CLASS_VALUES.scale,o=>`scale-${o}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:lodashEs.map([0,1,2,3,6,12,45,90,180],o=>`rotate-${o}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:lodashEs.map([0,"px","0.5",1],o=>`translate-x-${o}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:lodashEs.map([0,"px","0.5",1],o=>`translate-y-${o}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:lodashEs.map([0,1,2,3,6,12],o=>`skew-x-${o}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:lodashEs.map([0,1,2,3,6,12],o=>`skew-y-${o}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\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|primary(-\\d+)?|secondary(-\\d+)?|\\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|primary(-\\d+)?|secondary(-\\d+)?|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|primary(-\\d+)?|secondary(-\\d+)?|\\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","primary","secondary"],chaiColors=["primary","secondary"],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),o=>o),ALL_COLORS=lodashEs.flattenDeep([...lodashEs.map(soloColors,o=>lodashEs.flatten(lodashEs.map(colorKeys,n=>`${n}-${o}`))),...lodashEs.map(chaiColors,o=>lodashEs.flattenDeep(lodashEs.map(colorKeys,n=>lodashEs.flattenDeep(lodashEs.map(shades,r=>`${n}-${o}-${r}`))))),...lodashEs.map(shadedColors,o=>lodashEs.flattenDeep(lodashEs.map(colorKeys,n=>lodashEs.flattenDeep(lodashEs.map(shades,r=>`${n}-${o}-${r}`)))))]),ALL_TW_CLASSES=lodashEs.map(lodashEs.flattenDeep(lodashEs.values(CLASSES_LIST).map(o=>o.classes).concat(ALL_COLORS)),o=>({name:o}));function getMqForCls(o){if(lodashEs.isEmpty(o.trim()))return"";const n=o.match(/sm:|md:|lg:|xl:|2xl:/g);return lodashEs.get(n,0,"xs").replace(":","")}function getModForCls(o){const n=lodashEs.map(MODIFIERS,a=>`${a}:`).join("|"),r=new RegExp(n,"g");return lodashEs.get(r.exec(o.trim()),0,"").replace(":","")}function getPureClsName(o){return o.trim().split(":").pop()||""}const memoizedProps={};function getPropertyForClass(o){if(lodashEs.isEmpty(o))return"";if(memoizedProps[o])return memoizedProps[o];let n="";for(const r in CLASSES_LIST){const a=lodashEs.get(CLASSES_LIST,`${r}.regExp`,"");if(new RegExp(a,"g").test(o)){n=r,memoizedProps[o]=n;break}}return n}function constructClassObject(o){return lodashEs.isEmpty(o)?null:{dark:lodashEs.startsWith(o,"dark:"),mq:getMqForCls(o),mod:getModForCls(o),cls:getPureClsName(o),fullCls:o,property:getPropertyForClass(o)}}function generateFullClsName(o){let n="";return o.dark&&(n+="dark:"),o.mq.toLowerCase()!=="xs"&&(n+=`${o.mq}:`),o.mod&&(n+=`${o.mod}:`),n+=o.cls,n}const MEDIA_QUERIES={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},breakpoints=["xs","sm","md","lg","xl","2xl"];function getBelongsToForClass(o,n){if(n===null)return"baseClasses";const r=n.mq;if(r==="xs"||n.dark||n.mod!=="")return"classes";let a="baseClasses",i=breakpoints.indexOf(r);for(;i>0;){const l=breakpoints[i-1];if(lodashEs.find(o,{mq:l,property:n.property})){a="classes";break}i--}return a}const IGNORED_BASES_CLASSES_PROPERTIES=[];function getNewClasses(o="",n="",r=[]){o=o.trim().replace(/ +/g,"");let a=lodashEs.filter(lodashEs.map(o.split(" "),constructClassObject),x=>!lodashEs.isNull(x)),i=lodashEs.filter(lodashEs.map(n.split(" "),constructClassObject),x=>!lodashEs.isNull(x));i=lodashEs.filter(i,x=>!lodashEs.includes(IGNORED_BASES_CLASSES_PROPERTIES,x.property));const l=[],c=[];lodashEs.each(r,x=>{const m=constructClassObject(x),p=lodashEs.find(a,lodashEs.pick(m,["dark","mq","mod","property"]));if(p&&(a=lodashEs.filter(a,g=>g.fullCls!==(p==null?void 0:p.fullCls))),l.push(m),m.mq==="xs"&&!m.dark&&m.mod===""&&(i=lodashEs.filter(i,g=>g.property!==m.property)),getBelongsToForClass(a,m)==="baseClasses"&&!lodashEs.includes(IGNORED_BASES_CLASSES_PROPERTIES,m.property)){const g=lodashEs.find(i,lodashEs.pick(m,["property"]));p&&(i=lodashEs.filter(i,R=>R.fullCls!==(g==null?void 0:g.fullCls))),c.push({...m,fullCls:m.cls,mq:"xs"})}});const d=lodashEs.map(lodashEs.sortBy([...a,...l],x=>MEDIA_QUERIES[x.mq]),"fullCls").join(" ");return`${lodashEs.map(lodashEs.sortBy([...i,...c],x=>MEDIA_QUERIES[x.mq]),"fullCls").join(" ").trim()},${d.trim()}`.trim().replace(/ +/g,"")}const selectedStylingBlocksAtom=jotai.atom([]);selectedStylingBlocksAtom.debugLabel="selectedStylingBlocksAtom";const useSelectedStylingBlocks=()=>jotai.useAtom(selectedStylingBlocksAtom),getSplitClasses$1=o=>{const n=o.replace(STRINGS.STYLES_KEY,"").split(",");return{baseClasses:n[0],classes:n[1]}},addClassesToBlocksAtom=jotai.atom(null,(o,n,{blockIds:r,newClasses:a})=>{const i=lodashEs.filter(o(pageBlocksAtomsAtom),c=>r.includes(o(c)._id)),l=lodashEs.first(o(selectedStylingBlocksAtom));return lodashEs.map(i,c=>{const d=o(c),u=lodashEs.get(d,l.prop,`${STRINGS.STYLES_KEY},`),{baseClasses:x,classes:m}=getSplitClasses$1(u);return{ids:[d._id],props:{[l.prop]:`${STRINGS.STYLES_KEY}${getNewClasses(m,x,a)}`}}})}),useAddClassesToBlocks=()=>{const o=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:n,updateBlocksRuntime:r}=useBlocksStoreUndoableActions();return React.useCallback((a,i,l=!1)=>{const c=o({blockIds:a,newClasses:i});if(!l){r(a,c[0].props);return}n(a,c[0].props)},[o])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=atomWithStorage("canvasWidth",800),canvasBreakpointAtom=jotai.atom(o=>{const n=o(canvasWidthAtom);return iconBase.getBreakpointValue(n).toLowerCase()}),useCanvasWidth=()=>{const[o,n]=jotai.useAtom(canvasWidthAtom),r=jotai.useAtomValue(canvasBreakpointAtom),[a,i]=useStylingBreakpoint();return React.useEffect(()=>{a!=="xs"&&i(r)},[r,a,i]),[o,r,n]},canvasZoomAtom=atomWithStorage("canvasZoom",100),useCanvasZoom=()=>jotai.useAtom(canvasZoomAtom),cutBlockIdsAtom=jotai.atom([]),useCutBlockIds=()=>{const[o,n]=jotai.useAtom(cutBlockIdsAtom),r=jotai.useSetAtom(copiedBlockIdsAtom),a=React.useCallback(i=>{n(i),r([])},[n,r]);return[o,a]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlockIds=()=>{const[o,n]=jotai.useAtom(copiedBlockIdsAtom),r=jotai.useSetAtom(cutBlockIdsAtom),a=React.useCallback(i=>{n(i),r([])},[n,r]);return[o,a]},darkModeAtom=atomWithStorage("darkMode",!1),useDarkMode=()=>{const[o,n]=jotai.useAtom(darkModeAtom);return[o,n]},useDuplicateBlocks=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:r}=useBlocksStoreUndoableActions();return React.useCallback((a,i=null)=>{const l=[];lodashEs.each(a,c=>{const d=o.find(g=>g._id===c);i||(i=d._parent);const m=lodashEs.filter(o,g=>lodashEs.isString(i)?g._parent===i:!d._parent).indexOf(d)+1,p=getDuplicatedBlocks(o,c,i);r(p,i,m),l.push(lodashEs.get(p,"0._id",""))}),n(l)},[o,n])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[o,n]=jotai.useAtom(hiddenBlockIdsAtom),r=React.useCallback(a=>{n(i=>lodashEs.includes(i,a)?lodashEs.without(i,a):[...i,a])},[n]);return[o,n,r]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),useCanPaste=()=>{const[o]=useBlocksStore();return(n,r)=>{var l;const a=(l=lodashEs.find(o,{_id:r}))==null?void 0:l._type,i=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(a,i)}},useMoveCutBlocks=()=>{const o=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:n}=useBlocksStoreUndoableActions();return React.useCallback((r,a)=>{const i=a[0],l=o.find(d=>d._id===a),c=l?l.children.length:0;n(r,i,c)},[n,o])},usePasteBlocks=()=>{const o=jotai.useAtomValue(copiedBlockIdsAtom),[n,r]=useCutBlockIds(),a=useDuplicateBlocks(),i=useMoveCutBlocks(),l=useCanPaste();return{canPaste:React.useCallback(d=>o.length>0?l(o,d):n.length>0?l(n,d):!1,[l,o,n]),pasteBlocks:React.useCallback(d=>{const u=Array.isArray(d)?d[0]:d;lodashEs.isEmpty(o)?i(n,d):a(o,u),r([])},[n,o,a,i,r])}},previewModeAtom=jotai.atom(!1),usePreviewMode=()=>{const[o,n]=jotai.useAtom(previewModeAtom);return[o,n]},getSplitClasses=o=>{const n=o.replace(STRINGS.STYLES_KEY,"").split(",");return{baseClasses:n[0],classes:n[1]}},removeClassFromBlocksAtom=jotai.atom(null,(o,n,{blockIds:r,fullClasses:a})=>{const i=lodashEs.first(o(selectedStylingBlocksAtom)),l=lodashEs.filter(o(pageBlocksAtomsAtom),c=>r.includes(o(c)._id));return lodashEs.map(l,c=>{const d=o(c),u=a;let{classes:x,baseClasses:m}=getSplitClasses(lodashEs.get(d,i.prop,"styles:,"));return lodashEs.each(u,p=>{const g=p.replace(/[\[\]\/\\{}()*+?.^$|]/g,"\\$&"),R=new RegExp(`(^| )${g}($| )`,"g");x=x.replace(R," ").replace(/ +/g," ").trim();const h=lodashEs.first(p.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],h)&&u.push(p.split(":").pop().trim())}),lodashEs.each(u,p=>{const g=new RegExp(`(^| )${p.replace("[","\\[").replace("]","\\]")}($| )`,"g");m=m.replace(g," ").replace(/ +/g," ").trim()}),{ids:[d._id],props:{[i.prop]:`${STRINGS.STYLES_KEY}${m},${x}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions(),n=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((r,a)=>{const i=n({blockIds:r,fullClasses:a});o(r,i[0].props)},[n])},selectedBlockAllClassesAtom=jotai.atom(o=>{const n=lodashEs.first(o(selectedStylingBlocksAtom)),r=o(selectedBlockAtom);if(!n||n.blockId!==lodashEs.get(r,"_id",null))return[];const i=lodashEs.get(r,n.prop,`${STRINGS.STYLES_KEY},`).replace(STRINGS.STYLES_KEY,"").split(",").join(" ");return lodashEs.filter(lodashEs.map(i.trim().split(" "),constructClassObject),l=>!lodashEs.isNull(l))}),useSelectedBlockAllClasses=()=>jotai.useAtomValue(selectedBlockAllClassesAtom),MQ={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},selectedBlockCurrentClassesAtom=jotai.atom(o=>{const n=o(canvasBreakpointAtom),r=o(styleStateAtom),a=o(darkModeAtom),i=getQueries(n);let l=lodashEs.filter(o(selectedBlockAllClassesAtom),{mod:r});return lodashEs.startsWith(r,"_")||(l=lodashEs.filter(l,c=>i.includes(c.mq))),l=l.sort((c,d)=>MQ[c.mq]-MQ[d.mq]),a||(l=lodashEs.filter(l,{dark:!1})),l}),getQueries=o=>{let n=[];switch(o){case"xs":n=["xs"];break;case"sm":n=["xs","sm"];break;case"md":n=["xs","sm","md"];break;case"lg":n=["xs","sm","md","lg"];break;case"xl":n=["xs","sm","md","lg","xl"];break;case"2xl":n=["xs","sm","md","lg","xl","2xl"];break;default:n=["xs"];break}return n},useSelectedBlockCurrentClasses=()=>jotai.useAtomValue(selectedBlockCurrentClassesAtom),useStylingState=()=>jotai.useAtom(styleStateAtom),useUpdateBlocksProps=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions();return React.useCallback((n,r,a)=>{o(n,r,a)},[o])},useUpdateMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions();return React.useCallback(n=>{o(n)},[o])},useFakeStreamEffect=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions();return React.useCallback(async(n,r,a=30)=>{const i=lodashEs.keys(lodashEs.omit(r,["_id"]));for(const l of i){const c=r[l];if(lodashEs.isString(c)){const d=lodashEs.chunk(c.split(""),12);let u="";o([n],{[l]:""});for(let x=0;x<d.length;x++)u+=d[x].join(""),o([n],{[l]:u}),await new Promise(m=>setTimeout(m,a))}}},[o])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions(),n=useFakeStreamEffect();return React.useCallback(async r=>{for(const a of r)await n(a._id,a);o(r)},[o])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions();return React.useCallback((n,r)=>{o(n,r)},[o])},selectedBreakpointsAtom=atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),useSelectedBreakpoints=()=>{const[o,n]=jotai.useAtom(selectedBreakpointsAtom);return[o,n]},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 historyStatesAtom=jotai.atom({undoCount:0,redoCount:0});historyStatesAtom.debugLabel="historyStatesAtom";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="askAiActiveBlockAtom";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 globalBlocksStoreAtom=atom({}),globalBlocksLoadingStateAtom=atom({}),useGlobalBlocksStore=()=>{const[o,n]=useAtom(globalBlocksStoreAtom),r=React.useCallback(i=>lodashEs.get(o,i==null?void 0:i.globalBlock,[]),[o]),a=React.useCallback(()=>{n({})},[n]);return{getGlobalBlocks:r,reset:a}},useWatchGlobalBlocks=()=>{const[o]=useBlocksStore(),[n,r]=useAtom(globalBlocksStoreAtom),[a,i]=useAtom(globalBlocksLoadingStateAtom),l=useBuilderProp("getGlobalBlockBlocks",async d=>[]),c=React.useMemo(()=>o.filter(u=>u._type==="GlobalBlock").filter(u=>u._type==="GlobalBlock").map(u=>u.globalBlock),[o]);React.useEffect(()=>{lodashEs.forEach(c,d=>{lodashEs.has(n,d)||lodashEs.get(a,`${d}.loading`,!1)||(i(u=>({...u,[d]:{loading:!0,error:null}})),l(d).then(u=>{r(x=>({...x,[d]:u})),i(x=>({...x,[d]:{loading:!1,error:null}}))}).catch(u=>{i(x=>({...x,[d]:{loading:!1,error:u.message}}))}))})},[l,n,c,a,r,i])},globalBlocksListAtom=atom({}),useGlobalBlocksList=()=>{const[o,n]=React.useState(!1),[r,a]=useAtom(globalBlocksListAtom),i=useBuilderProp("getGlobalBlocks",async()=>[]),l=React.useCallback(async()=>{n(!0);const c=await i();a(c),n(!1)},[i,a]);return React.useEffect(()=>{l()},[]),{data:r,isLoading:o,refetch:l}},useBuilderReset=()=>{const o=jotai.useSetAtom(historyStatesAtom),{clear:n}=useUndoManager(),[,r]=useSelectedBlockIds(),[,a]=useHighlightBlockId(),[,i]=useSelectedStylingBlocks(),[,l]=useAtom(aiAssistantActiveAtom),{reset:c}=useGlobalBlocksStore();return()=>{r([]),i([]),a(""),n(),l(!1),o({undoCount:0,redoCount:0}),c()}},useUILibraryBlocks=()=>({data:useBuilderProp("uiLibraries",[]),isLoading:!1}),useCopyToClipboard=()=>{const[o,n]=React.useState(null),r=React.useCallback(async a=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(a),n(a),!0}catch(i){return console.warn("Copy failed",i),n(null),!1}},[]);return[o,r]},codeEditorAtom=jotai.atom(null),useCodeEditor=()=>jotai.useAtom(codeEditorAtom),layoutVariantAtom=atomWithStorage("_layout_variant_mode","DUAL_SIDE_PANEL"),useLayoutVariant=()=>{const[o,n]=jotai.useAtom(layoutVariantAtom),r=useBuilderProp("layoutVariant","DUAL_SIDE_PANEL");return[o||r,n]},IframeInitialContent=`<!doctype html>
2
- <html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"><\/script>
7
- <style>
8
- html { height: 100%; overflow:auto; }
9
- body { height: 100%; }
10
- .air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
11
- .air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
12
- body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
13
- -moz-user-select: none;-ms-user-select: none; user-select: none; }
14
- html{
15
- -ms-overflow-style: none; /* IE and Edge */
16
- scrollbar-width: none; /* Firefox */
17
- }
18
- /** IMPORTANT: Make fields content editable in SAFARI */
19
- [contenteditable] {-webkit-user-select: text;user-select: text;}
20
-
21
- html::-webkit-scrollbar { width: 0 !important }
22
- .aspect-auto{aspect-ratio: auto;}
23
- .aspect-square{aspect-ratio: 1/1;}
24
- .aspect-video{aspect-ratio: 16/9;}
25
- .dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
26
- .dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
27
- a{ pointer-events: none !important; }
28
- [contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
29
- [contenteditable="true"] {
30
- outline: none;
31
- box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
32
- -webkit-user-select: text;
33
- -moz-user-select: text;
34
- user-select: text;
35
- }
36
- .frame-root .frame-content { height: 100%; }
37
- [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
38
- [data-dnd="yes"] { pointer-events: auto !important}
39
- [data-dnd="no"],[data-block-type="GlobalBlock"] > * { pointer-events: none !important; }
40
- [data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
41
- [data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
42
- [force-show] { display: block !important; }
43
- [data-cut-block="yes"] { pointer-events: none !important; display: none !important; }
44
- </style>
45
- <style id="hidden-blocks"></style>
46
- <style id="selected-block"></style>
47
- <style id="selected-styling-block"></style>
48
- <style id="highlighted-block"></style>
49
- <style id="dragged-block"></style>
50
- <style id="drop-target-block"></style>
51
-
52
- </head>
53
- <body class="font-body antialiased h-full">
54
- <div class="frame-root h-full"></div>
55
- <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
56
- </body>
57
- </html>`,useCanvasScale=o=>{const[n]=useCanvasWidth(),[,r]=useCanvasZoom(),[a,i]=React.useState({}),l=React.useCallback(()=>{const{width:c,height:d}=o;if(c<n){const u=parseFloat((c/n).toFixed(2).toString());let x={};const m=d*u,p=c*u;d&&(x={height:100+(d-m)/m*100+"%",width:100+(c-p)/p*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:"top left",...x,maxWidth:"none"}),r(u*100)}else i({}),r(100)},[n,o,r]);return React.useEffect(()=>{l()},[n,o,r,l]),a};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 Content extends React.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return React.Children.only(this.props.children)}}H(Content,"propTypes",{children:PropTypes.element.isRequired,contentDidMount:PropTypes.func.isRequired,contentDidUpdate:PropTypes.func.isRequired});class Frame extends React.Component{constructor(r,a){super(r,a);H(this,"setRef",r=>{this.nodeRef.current=r;const{forwardedRef:a}=this.props;typeof a=="function"?a(r):a&&(a.current=r)});H(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});H(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 r=this.getDoc();return this.props.mountTarget?r.querySelector(this.props.mountTarget):r.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const r=this.getDoc();if(!r)return null;const a=this.props.contentDidMount,i=this.props.contentDidUpdate,l=r.defaultView||r.parentView,c=jsxRuntime.jsxRuntimeExports.jsx(Content,{contentDidMount:a,contentDidUpdate:i,children:jsxRuntime.jsxRuntimeExports.jsx(FrameContextProvider,{value:{document:r,window:l},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),d=this.getMountTarget();return[ReactDOM.createPortal(this.props.head,this.getDoc().head),ReactDOM.createPortal(c,d)]}render(){const r={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete r.head,delete r.initialContent,delete r.mountTarget,delete r.contentDidMount,delete r.contentDidUpdate,delete r.forwardedRef,jsxRuntime.jsxRuntimeExports.jsx("iframe",{...r,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}H(Frame,"propTypes",{style:PropTypes.object,head:PropTypes.node,initialContent:PropTypes.string,mountTarget:PropTypes.string,className:PropTypes.string,contentDidMount:PropTypes.func,contentDidUpdate:PropTypes.func,children:PropTypes.oneOfType([PropTypes.element,PropTypes.arrayOf(PropTypes.element)])}),H(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((o,n)=>jsxRuntime.jsxRuntimeExports.jsx(Frame,{...o,forwardedRef:n}));function getOrientation(o){const n=window.getComputedStyle(o),r=n.display;if(r==="flex"||r==="inline-flex"){const a=n.flexDirection;return a==="column"||a==="column-reverse"?"vertical":"horizontal"}else if(r==="grid"){const a=n.gridAutoFlow,i=n.gridTemplateRows,l=n.gridTemplateColumns;return a.includes("column")||i.split(" ").length>l.split(" ").length?"vertical":"horizontal"}else if(r==="block"||r==="inline-block")return"vertical";return"horizontal"}const draggedBlockAtom=jotai.atom(null),dropTargetBlockIdAtom=jotai.atom(null);let iframeDocument=null,possiblePositions=[],dropTarget=null,dropIndex=null;const positionPlaceholder=(o,n,r)=>{if(!iframeDocument||!o)return;const a=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder"),i=possiblePositions.map(([u])=>u),l=i.reduce((u,x)=>Math.abs(x-r)<Math.abs(u-r)?x:u,0),c=i.indexOf(l);if(!possiblePositions[c])return;const d=possiblePositions[c];a.style.width=n==="vertical"?d[2]+"px":"2px",a.style.height=n==="vertical"?"2px":d[2]+"px",a.style.display="block",n==="vertical"?(a.style.top=d[0]+"px",a.style.left=d[1]+"px"):(a.style.top=d[1]+"px",a.style.left=d[0]+"px")};function calculateDropIndex(o,n){let r=0,a=1/0;return n.forEach((i,l)=>{const c=Math.abs(i[0]-o);c<a&&(a=c,r=l)}),r}const calculatePossiblePositions=o=>{const r=getOrientation(o)==="horizontal";possiblePositions=[],Array.from(o.children).forEach((a,i)=>{if(a.classList.contains("pointer-events-none"))return;const l=r?a.offsetLeft:a.offsetTop,c=r?[a.offsetTop,a.clientHeight]:[a.offsetLeft,a.clientWidth];if(possiblePositions.push([l,c[0],c[1]]),i===o.children.length-1){const d=r?a.offsetLeft+a.clientWidth:a.offsetTop+a.clientHeight;possiblePositions.push([d,c[0],c[1]])}})},throttledDragOver=lodashEs.throttle(o=>{var i;const n=o.target,r=getOrientation(n),a=(i=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:i.scrollY;r==="vertical"?positionPlaceholder(n,r,o.clientY+a):positionPlaceholder(n,r,o.clientX)},0);function removePlaceholder(){const o=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder");o.style.display="none",removeClassFromElements("pointer-none"),removeDataDrop()}function removeClassFromElements(o){(iframeDocument==null?void 0:iframeDocument.querySelectorAll(`.${o}`)).forEach(r=>{r.classList.remove(o)})}function removeDataDrop(){const o=iframeDocument==null?void 0:iframeDocument.querySelector('[data-drop="yes"]');o&&o.removeAttribute("data-drop")}const useDnd=()=>{const{document:o}=useFrame(),[n,r]=jotai.useAtom(draggingFlagAtom),{addCoreBlock:a}=useAddBlock(),[,i]=useHighlightBlockId(),[,l]=useSelectedBlockIds(),{moveBlocks:c}=useBlocksStoreUndoableActions(),[d,u]=jotai.useAtom(draggedBlockAtom),[,x]=jotai.useAtom(dropTargetBlockIdAtom);if(!flagged.useFeature("dnd"))return{};const p=()=>{removePlaceholder(),r(!1),u(null),x(null),possiblePositions=[]};return iframeDocument=o,{isDragging:n,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),throttledDragOver(g)},onDrop:g=>{var v;const R=dropTarget,f=getOrientation(R)==="vertical"?g.clientY+((v=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:v.scrollY):g.clientX;dropIndex=calculateDropIndex(f,possiblePositions);const b=d,C=R.getAttribute("data-block-id"),_=dropTarget.getAttribute("data-dnd-dragged")!=="yes";if((b==null?void 0:b._id)===C||!_){p();return}if(!lodashEs.has(b,"_id")){a(b,C==="canvas"?null:C,dropIndex),setTimeout(p,300);return}let w=R.getAttribute("data-block-id");w===null&&(w=g.target.parentElement.getAttribute("data-block-id")),c([b._id],w==="canvas"?null:w,dropIndex),p(),setTimeout(removePlaceholder,300)},onDragEnter:g=>{const R=g,h=R.target;dropTarget=h;const f=h.getAttribute("data-block-id"),b=h.getAttribute("data-dnd-dragged")!=="yes";x(f),R.stopPropagation(),R.preventDefault(),possiblePositions=[],b&&calculatePossiblePositions(h),r(!0),i(""),l([])},onDragLeave:g=>{g.target.getAttribute("data-block-id")==="canvas"&&(x(null),r(!1),removePlaceholder(),possiblePositions=[])}}};function getTargetedBlock(o){return o.getAttribute("data-block-id")?o:o.closest("[data-block-id]")}function destroyQuill(o){o.container.innerHTML="",o.container.parentNode.removeChild(o.container);var n=document.querySelector(".ql-toolbar");n&&n.parentNode.removeChild(n),o=null}const useHandleCanvasDblClick=()=>{const o=["Heading","Paragraph","Text","Link","Span","Button"],n=useUpdateBlocksProps(),[,r]=useHighlightBlockId(),[a,i]=jotai.useAtom(inlineEditingActiveAtom);return l=>{var p;if(a)return;const c=getTargetedBlock(l.target),d=c.getAttribute("data-block-type");if(!d||!o.includes(d))return;const u=c.cloneNode(!0);c.style.display="none",Array.from(u.attributes).forEach(g=>{g.name!=="class"&&u.removeAttribute(g.name)}),d==="Text"&&(u.style.display="inline-block"),c.parentNode.insertBefore(u,c.nextSibling);const x=new ReactQuill.Quill(u,{placeholder:"Type here..."});function m(){const g=x.getText(0,x.getLength());n([c.getAttribute("data-block-id")],{content:g}),c.removeAttribute("style"),u.removeEventListener("blur",m,!0),destroyQuill(x),i(""),r("")}u.addEventListener("blur",m,!0),u.addEventListener("keydown",g=>{(g.key==="Enter"||g.key==="Escape")&&m()}),x.focus(),(p=u.querySelector(".ql-clipboard"))==null||p.remove(),i(c.getAttribute("data-block-id"))}},useHandleCanvasClick=()=>{const[,o]=useSelectedStylingBlocks(),[n,r]=useSelectedBlockIds(),[,a]=useHighlightBlockId(),[i]=jotai.useAtom(inlineEditingActiveAtom),[l]=jotai.useAtom(treeRefAtom);return c=>{if(i)return;c.stopPropagation();const d=getTargetedBlock(c.target);if(d!=null&&d.getAttribute("data-block-id")&&(d==null?void 0:d.getAttribute("data-block-id"))==="container"){r([]),o([]),a("");return}if(d!=null&&d.getAttribute("data-block-parent")){const u=d.getAttribute("data-style-prop"),x=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");n.includes(m)||l==null||l.closeAll(),o([{id:x,prop:u,blockId:m}]),r([m])}else if(d!=null&&d.getAttribute("data-block-id")){let u=d.getAttribute("data-block-id");n.includes(u)||l==null||l.closeAll(),o([]),r(u==="canvas"?[]:[u])}a("")}},handleMouseMove=lodashEs.throttle((o,n)=>{const r=getTargetedBlock(o.target);r!=null&&r.getAttribute("data-style-id")&&n(r.getAttribute("data-style-id"))},100),useHandleMouseMove=()=>{const[,o]=useHighlightBlockId(),[n]=jotai.useAtom(inlineEditingActiveAtom);return r=>{n||handleMouseMove(r,o)}},Canvas=({children:o})=>{const{document:n}=useFrame(),[r]=useSelectedBlockIds(),[a,i]=useSelectedStylingBlocks();React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(a))return;const x=getElementByDataBlockId(n,lodashEs.first(r));if(x){const m=x.getAttribute("data-style-prop");if(m){const p=x.getAttribute("data-style-id"),g=x.getAttribute("data-block-parent");i([{id:p,prop:m,blockId:g}])}}},100)},[n,r,i,a]);const l=useHandleCanvasDblClick(),c=useHandleCanvasClick(),d=useHandleMouseMove(),u=useDnd();return jsxRuntime.jsxRuntimeExports.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:c,onDoubleClick:l,onMouseMove:d,...lodashEs.omit(u,"isDragging"),className:"relative h-full max-w-full p-px "+(u.isDragging?"dragging":""),children:o})},getElementByDataBlockId=(o,n)=>o.querySelector(`[data-block-id="${n}"]`),useKeyEventWatcher=o=>{const[n,r]=useSelectedBlockIds(),a=useRemoveBlocks(),i=useDuplicateBlocks(),{undo:l,redo:c}=useUndoManager(),[,d]=useCutBlockIds(),[,u]=useCopyBlockIds(),{canPaste:x,pasteBlocks:m}=usePasteBlocks();reactHotkeysHook.useHotkeys("ctrl+z,command+z",()=>l(),{},[l]),reactHotkeysHook.useHotkeys("ctrl+y,command+y",()=>c(),{},[c]),reactHotkeysHook.useHotkeys("ctrl+x,command+x",()=>d(n),{},[n,d]),reactHotkeysHook.useHotkeys("ctrl+c,command+c",()=>u(n),{},[n,u]),reactHotkeysHook.useHotkeys("ctrl+v,command+v",()=>{x(n[0])&&m(n)},{},[n,x,m]);const p=o?{document:o}:{};reactHotkeysHook.useHotkeys("esc",()=>r([]),p,[r]),reactHotkeysHook.useHotkeys("ctrl+d,command+d",()=>i(n),{...p,preventDefault:!0},[n,i]),reactHotkeysHook.useHotkeys("del, backspace",g=>{g.preventDefault(),a(n)},p,[n,a])},KeyboardHandler=()=>{const{document:o}=useFrame();return useKeyEventWatcher(o),null},{useChaiBuilderMsgListener,emitChaiBuilderMsg}=reactEventHook.createEvent("chaiBuilderMsg")(),CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS"},BlockActionLabel=({block:o,label:n})=>{const[,r]=useSelectedBlockIds(),[,a]=useHighlightBlockId(),[,i]=jotai.useAtom(draggedBlockAtom),l=flagged.useFeature("dnd");return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-default items-center space-x-1 px-1",draggable:l?"true":"false",onDragStart:c=>{c.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.pick(o,["_id","_type","_name"]))),i(o),setTimeout(()=>{r([]),a(null)},200)},children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DragHandleDots2Icon,{}),n]})},BlockActionsStatic=({selectedBlockElement:o,block:n})=>{const r=useRemoveBlocks(),a=useDuplicateBlocks(),[,i]=useSelectedBlockIds(),[,l]=useHighlightBlockId(),[,c]=useSelectedStylingBlocks(),[d]=jotai.useAtom(inlineEditingActiveAtom),{floatingStyles:u,refs:x,update:m}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:o}});web.useResizeObserver(o,()=>m(),o!==null);const p=lodashEs.get(n,"_parent",null),g=lodashEs.isEmpty(lodashEs.get(n,"_name",""))?lodashEs.get(n,"_type",""):lodashEs.get(n,"_name","");return!o||!n||d?null:jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:x.setFloating,style:u,onClick:R=>{R.stopPropagation(),R.preventDefault()},onMouseEnter:R=>{R.stopPropagation(),l(null)},onKeyDown:R=>R.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[p&&jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{c([]),i([p])}}),jsxRuntime.jsxRuntimeExports.jsx(BlockActionLabel,{label:g,block:n}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1",children:[canAddChildBlock(lodashEs.get(n,"_type",""))&&jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{className:"hover:scale-105",onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:n})}),canDuplicateBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>a([n==null?void 0:n._id])}):null,jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GearIcon,{className:"text-white hover:scale-105",onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS,data:n})}),canDeleteBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>r([n==null?void 0:n._id])}):null]})]})})},HeadTags=({model:o})=>{const[n]=useBrandingOptions(),[r]=useSelectedBlockIds(),[a]=useDarkMode(),[i]=useHighlightBlockId(),[l]=useSelectedStylingBlocks(),[c]=jotai.useAtom(draggedBlockAtom),[d]=jotai.useAtom(dropTargetBlockIdAtom),{document:u,window:x}=useFrame(),[m]=React.useState(u==null?void 0:u.getElementById("highlighted-block")),[p]=React.useState(u==null?void 0:u.getElementById("selected-block")),[g]=React.useState(u==null?void 0:u.getElementById("selected-styling-block")),[R]=React.useState(u==null?void 0:u.getElementById("dragged-block"));React.useEffect(()=>{a?u==null||u.documentElement.classList.add("dark"):u==null||u.documentElement.classList.remove("dark")},[a,u]);const h=lodashEs.get(n,"headingFont","DM Sans"),f=lodashEs.get(n,"bodyFont","DM Sans");return React.useEffect(()=>{const b=lodashEs.get(n,"primaryColor","#000"),C=lodashEs.get(n,"secondaryColor","#FFF"),_=lodashEs.get(n,"bodyBgLightColor","#fff"),w=lodashEs.get(n,"bodyBgDarkColor","#000"),v=lodashEs.get(n,"bodyTextDarkColor","#000"),S=lodashEs.get(n,"bodyTextLightColor","#fff"),A=getPalette([{color:b,name:"primary"},{color:C,name:"secondary"}]),T={"bg-light":_,"bg-dark":w,"text-dark":v,"text-light":S},I=lodashEs.get(n,"roundedCorners","0");!x||!x.tailwind||(x.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[h],body:[f]},borderRadius:{DEFAULT:`${I||"0"}px`},colors:{...T,...A}}},plugins:[typography$1,forms,aspectRatio,plugin.plugin(function({addBase:j,theme:E}){j({"h1,h2,h3,h4,h5,h6":{fontFamily:E("fontFamily.heading")},body:{fontFamily:E("fontFamily.body"),color:E("colors.text-light"),backgroundColor:E("colors.bg-light")},".dark body":{color:E("colors.text-dark"),backgroundColor:E("colors.bg-dark")}})})]})},[n,x,h,f]),React.useEffect(()=>{p&&(p.textContent=`${lodashEs.map(r,b=>`[data-block-id="${b}"]`).join(",")}{
58
- outline: 1px solid ${r.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
59
- }`)},[r,p]),React.useEffect(()=>{R.textContent=c?`[data-block-id="${c._id}"], [data-block-id="${c._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}`:""},[c,R]),React.useEffect(()=>{m&&(m.textContent=i?`[data-style-id="${i}"], [data-block-id="${i}"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}`:"")},[i,r,m]),React.useEffect(()=>{g&&(g.textContent=`${lodashEs.map(l,({id:b})=>`[data-style-id="${b}"]`).join(",")}{
60
- outline: 1px solid #42a1fc !important; outline-offset: -1px;
61
- }`)},[l,g]),React.useEffect(()=>{u.querySelector("#drop-target-block").innerHTML=d?`[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[d]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:(h||f)&&jsxRuntime.jsxRuntimeExports.jsx("link",{rel:"stylesheet",href:`https://fonts.googleapis.com/css2?family=${h?`${h.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}${h&&f&&h!==f?"&":""}${f&&f!==h?`family=${f.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}&display=swap`})})},useChaiExternalData=()=>jotai.useAtom(chaiExternalDataAtom),useCanvasSettings=()=>jotai.useAtom(canvasSettingsAtom),isVisibleAtBreakpoint=(o,n)=>{const r=["xs","sm","md","lg","xl","2xl"],a=r.indexOf(n),i=o.split(" ");let l=new Array(r.length).fill(!1);for(const c of i){let[d,u]=c.split(":");u||(u=d,d="xs");const x=r.indexOf(d);if(x<=a){const m=["block","flex","inline","inline-block","inline-flex","grid","table"],p=["hidden"];if(m.includes(u))for(let g=x;g<r.length;g++)l[g]=!0;else if(p.includes(u))for(let g=x;g<r.length;g++)l[g]=!1}}return l[a]},rscBlocksStoreAtom=atom({}),rscBlocksLoadingStateAtom=atom({}),useRSCBlocksStore=()=>{const[o,n]=useAtom(rscBlocksStoreAtom),[r]=useAtom(rscBlocksLoadingStateAtom),a=React.useCallback(c=>lodashEs.get(o,c==null?void 0:c._id,null),[o]),i=React.useCallback(c=>lodashEs.get(r,`${c}`,{loading:!1,error:null}),[r]),l=React.useCallback(c=>{n(d=>({...d,[c]:""}))},[n]);return{getRSCBlockMarkup:a,getRSCBlockState:i,reset:l}},useWatchRSCBlocks=()=>{const[o]=useBlocksStore(),[n,r]=useAtom(rscBlocksStoreAtom),[a,i]=useAtom(rscBlocksLoadingStateAtom),l=runtime.useChaiBlocks(),c=useBuilderProp("getRSCBlock",async u=>""),d=React.useMemo(()=>o.filter(x=>{var p;return(p=lodashEs.get(l,x._type))==null?void 0:p.server}).map(x=>x._id),[l,o]);React.useEffect(()=>{lodashEs.forEach(d,u=>{if(lodashEs.get(n,u,"")||lodashEs.get(a,`${u}.loading`,!1))return;const x=o.find(m=>m._id===u);i(m=>({...m,[u]:{loading:!0,error:null}})),c(x).then(m=>{r(p=>({...p,[u]:m})),i(p=>({...p,[u]:{loading:!1,error:null}}))}).catch(m=>{i(p=>({...p,[u]:{loading:!1,error:m.message}}))})})},[o,c,n,d,a,r,i])},RSCBlock=({blockProps:o,block:n})=>{const{getRSCBlockMarkup:r,getRSCBlockState:a}=useRSCBlocksStore(),i=r(n),{loading:l,error:c}=a(n._id);return l?jsxRuntime.jsxRuntimeExports.jsx("div",{...o,className:"h-10 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full w-full rounded-md border"})}):c?jsxRuntime.jsxRuntimeExports.jsxs("div",{...o,children:["Error: ",c]}):jsxRuntime.jsxRuntimeExports.jsx("div",{...o,dangerouslySetInnerHTML:{__html:i}})},generateClassNames=lodashEs.memoize(o=>{const n=o.replace(STRINGS.STYLES_KEY,"").split(",");return tailwindMerge.twMerge(n[0],n[1])});function getElementAttrs(o,n){return lodashEs.get(o,`${n}_attrs`,{})}function getStyleAttrs(o,n){const r={};return Object.keys(o).forEach(a=>{if(lodashEs.isString(o[a])&&o[a].startsWith(STRINGS.STYLES_KEY)){const i=generateClassNames(o[a]),l=getElementAttrs(o,a);r[a]={className:i,"data-style-prop":a,"data-block-parent":o._id,"data-style-id":`${a}-${o._id}`,...l};const c=lodashEs.has(l,"x-show")||lodashEs.has(l,"x-if");c&&(r.__isHidden=c&&!isVisibleAtBreakpoint(i,n))}}),r}function applyBindings(o,n){const r=lodashEs.get(o,"_bindings",{});return lodashEs.isEmpty(r)?{...o}:(lodashEs.each(r,(a,i)=>{lodashEs.isString(a)&&lodashEs.get(n,a,null)&&(o[i]=lodashEs.get(n,a,null))}),o)}function isDescendant(o,n,r){if(!lodashEs.find(r,{_id:o}))return!1;const i=lodashEs.filter(r,{_parent:o});return i.some(l=>l._id===n)?!0:i.some(l=>isDescendant(l._id,n,r))}const RenderGlobalBlock=({blocks:o,allBlocks:n})=>jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:o});function BlocksRendererStatic({blocks:o,allBlocks:n}){const[r]=jotai.useAtom(xShowBlocksAtom),[a]=useCutBlockIds(),[i]=jotai.useAtom(draggedBlockAtom),[l]=jotai.useAtom(dropTargetBlockIdAtom),[,c]=useCanvasWidth(),[d]=useCanvasSettings(),[u]=useHiddenBlockIds(),{getGlobalBlocks:x}=useGlobalBlocksStore(),m=React.useCallback(h=>getStyleAttrs(h,c),[c]),[p]=useChaiExternalData(),[g]=jotai.useAtom(inlineEditingActiveAtom),R=React.useCallback(h=>h.reduce((f,b)=>{const C=lodashEs.get(d,b,{});return{...f,...C}},{}),[d]);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:React.Children.toArray(o.map((h,f)=>{if(g===h._id||u.includes(h._id))return null;const b={},C=lodashEs.filter(n,{_parent:h._id});if(b.children=C.length>0?jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:C}):null,h._type==="GlobalBlock"){const E=x(h);b.children=jsxRuntime.jsxRuntimeExports.jsx(RenderGlobalBlock,{blocks:lodashEs.filter(E,k=>!k._parent),allBlocks:E})}const _=runtime.getBlockComponent(h._type),w=lodashEs.get(_,"server",!1),v=w?RSCBlock:lodashEs.get(_,"builderComponent",lodashEs.get(_,"component",null));if(lodashEs.isNull(v))return jsxRuntime.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${h==null?void 0:h._type} not registered -->`});const S=lodashEs.has(_,"getBlockStateFrom")?_==null?void 0:_.getBlockStateFrom(h,n):[],A=R(S),T=m(h);if(lodashEs.get(T,"__isHidden",!1)&&!lodashEs.includes(r,h._id))return null;const I=i&&isDescendant(i._id,h._id,n),j={...lodashEs.includes(r,h._id)?{"force-show":""}:{},"data-block-id":h._id,"data-block-type":h._type,...i?{"data-dnd":canAcceptChildBlock(h._type,i==null?void 0:i._type)?"yes":"no","data-dnd-dragged":i._id===h._id||I?"yes":"no"}:{},...l===h._id&&!I?{"data-drop":"yes"}:{},...lodashEs.includes(a,h._id)?{"data-cut-block":"yes"}:{}};return w?jsxRuntime.jsxRuntimeExports.jsx(RSCBlock,{block:h,blockProps:j}):jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:React.createElement(v,{blockProps:j,index:f,...applyBindings(h,p),...lodashEs.omit(T,["__isHidden"]),...b,inBuilder:!0,blockState:A})})}))})}const useAllDataProviders=()=>React.useMemo(()=>runtime.getChaiDataProviders(),[]),BlocksExternalDataProvider=({children:o})=>{const[,n]=useChaiExternalData(),[r]=usePageDataProviders(),a=useAllDataProviders();return React.useEffect(()=>(n({}),lodashEs.each(r,i=>{const l=lodashEs.find(a,{providerKey:i.providerKey});if(l){const c=(l==null?void 0:l.mockFn)||(l==null?void 0:l.dataFn);c&&c(i.args).then(d=>n(u=>({...u,[i.providerKey]:d})))}}),()=>{lodashEs.each(r,i=>{n(l=>(delete l[i.providerKey],l))})}),[a,r,n]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsxRuntimeExports.jsx(BlocksExternalDataProvider,{children:jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:o,blocks:lodashEs.filter(o,r=>lodashEs.isEmpty(r._parent))})});return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:n})},AddBlockAtBottom=()=>{const{t:o}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mt-1 block w-full rounded-md bg-gray-100 p-2 text-black hover:bg-gray-200 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-700",children:["+ ",o("add_block")]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:r})=>{const a=React.useRef(null),i=web.useDebouncedCallback(()=>{const{clientWidth:l}=a.current;r(l)},[a.current],100);return web.useResizeObserver(a.current,i,a.current!==null),React.useEffect(()=>{const{clientWidth:l}=a.current;n(l)},[]),jsxRuntime.jsxRuntimeExports.jsx("div",{id:"main-content",className:"h-full w-full p-8 pb-0",ref:a,children:o})},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasWidth(),[,r]=useSelectedBlockIds(),a=useSelectedBlock(),[,i]=useHighlightBlockId(),l=React.useRef(null),c=React.useRef(null),[d,u]=React.useState({width:0,height:0}),x=useCanvasScale(d),[m,p]=React.useState([]),[,g]=React.useState([]),[,R]=jotai.useAtom(canvasIframeAtom),[h,f]=useSelectedStylingBlocks(),b=useBuilderProp("loading",!1),C=useBuilderProp("htmlDir","ltr"),_=S=>{u(A=>({...A,width:S}))};React.useEffect(()=>{if(!c.current)return;const{clientWidth:S,clientHeight:A}=c.current;u({width:S,height:A})},[c,n]);const w=(S,A=0)=>{const{top:T}=S.getBoundingClientRect();return T+A>=0&&T-A<=window.innerHeight};React.useEffect(()=>{var S,A;if(a&&a.type!=="Multiple"&&l.current){const T=getElementByDataBlockId(l.current.contentDocument,a._id);T&&(w(T)||(A=(S=l.current)==null?void 0:S.contentWindow)==null||A.scrollTo({top:T.offsetTop,behavior:"smooth"}),p([T]))}},[a]),React.useEffect(()=>{if(!lodashEs.isEmpty(h)&&l.current){const S=getElementByStyleId(l.current.contentDocument,lodashEs.first(h).id);g(S?[S]:[null])}else g([null])},[h]);const v=React.useMemo(()=>{let S=IframeInitialContent;return S=S.replace("__HTML_DIR__",C),o==="offline"&&(S=S.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),S=S.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),S=S.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),S},[o,C]);return jsxRuntime.jsxRuntimeExports.jsx(ResizableCanvasWrapper,{onMount:_,onResize:_,children:jsxRuntime.jsxRuntimeExports.jsx("div",{onClick:()=>{r([]),f([])},onMouseLeave:()=>setTimeout(()=>i(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:c,children:jsxRuntime.jsxRuntimeExports.jsxs(ChaiFrame,{contentDidMount:()=>R(l.current),ref:l,id:"canvas-iframe",style:{...x,...lodashEs.isEmpty(x)?{width:`${n}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:v,children:[jsxRuntime.jsxRuntimeExports.jsx(KeyboardHandler,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockActionsStatic,{block:a,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsxRuntimeExports.jsx(HeadTags,{model:"page"}),jsxRuntime.jsxRuntimeExports.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxRuntimeExports.jsxs(Canvas,{children:[b?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"})}):jsxRuntime.jsxRuntimeExports.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsxRuntimeExports.jsx(AddBlockAtBottom,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},StaticCanvas$1=StaticCanvas,FallbackError=()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsxRuntimeExports.jsx("p",{children:"Please try again."})]})}),TypeIcon=o=>{switch(o.type){case"GlobalBlock":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.GlobeIcon,{className:"h-4 w-4"});case"Image":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ImageIcon,{});case"Heading":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.HeadingIcon,{});case"Text":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Link":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Link1Icon,{});case"Video":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.VideoIcon,{});case"RichText":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CursorTextIcon,{});case"Button":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"CustomHTML":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CodeIcon,{});case"Divider":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DividerHorizontalIcon,{});case"Icon":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SketchLogoIcon,{});case"List":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"Paragraph":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Row":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"ListItem":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ColumnsIcon,{});case"LineBreak":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SpaceBetweenVerticallyIcon,{});case"Form":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GroupIcon,{});case"Checkbox":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckboxIcon,{});case"FormButton":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"Input":case"TextArea":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InputIcon,{});case"Radio":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RadiobuttonIcon,{});case"Select":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DropdownMenuIcon,{});case"Table":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TableIcon,{});case"TableHead":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderTopIcon,{});case"TableBody":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderAllIcon,{});case"TableRow":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ViewHorizontalIcon,{});case"TableCell":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DragHandleHorizontalIcon,{});case"DataProvider":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.DatabaseIcon,{size:16});case"Box":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxIcon,{});default:return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxModelIcon,{})}},Breadcrumb=()=>{const o=useSelectedBlockHierarchy(),[,n]=useSelectedBlockIds(),[,r]=useHighlightBlockId();return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>n([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{size:16})]}),lodashEs.reverse(o).map((a,i)=>jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onMouseEnter:()=>{r(a==null?void 0:a._id)},onClick:()=>n([a==null?void 0:a._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:a==null?void 0:a._type}),a._name||a._type]}),i!==o.length-1&&jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{size:16})]},i))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-v6e1cv9g.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsxRuntimeExports.jsx(StaticCanvas$1,{})})}),o?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsxRuntimeExports.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsxRuntimeExports.jsx(Breadcrumb,{})]})})},CanvasArea$1=CanvasArea,ColorField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=lodashEs.debounce(n,200),l=c=>i(c.target.value);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-1.5 flex items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-3/5 flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("input",{type:"color",className:"text-xs p-0",value:o,onBlur:({target:{value:c}})=>a(r,c),onChange:l})})})},FONTS=[{title:"Roboto",value:"Roboto"},{title:"Open Sans",value:"Open Sans"},{title:"Montserrat",value:"Montserrat"},{title:"Lato",value:"Lato"},{title:"Poppins",value:"Poppins"},{title:"Oswald",value:"Oswald"},{title:"Raleway",value:"Raleway"},{title:"Ubuntu",value:"Ubuntu"},{title:"Nunito",value:"Nunito"},{title:"Merriweather",value:"Merriweather"},{title:"Nunito Sans",value:"Nunito Sans"},{title:"Playfair Display",value:"Playfair Display"},{title:"Rubik",value:"Rubik"},{title:"Inter",value:"Inter"},{title:"Lora",value:"Lora"},{title:"Kanit",value:"Kanit"},{title:"Fira Sans",value:"Fira Sans"},{title:"Hind",value:"Hind"},{title:"Quicksand",value:"Quicksand"},{title:"Mulish",value:"Mulish"},{title:"Barlow",value:"Barlow"},{title:"Inconsolata",value:"Inconsolata"},{title:"Titillium Web",value:"Titillium Web"},{title:"Heebo",value:"Heebo"},{title:"IBM Plex Sans",value:"IBM Plex Sans"},{title:"DM Sans",value:"DM Sans"},{title:"Nanum Gothic",value:"Nanum Gothic"},{title:"Karla",value:"Karla"},{title:"Arimo",value:"Arimo"},{title:"Cabin",value:"Cabin"},{title:"Oxygen",value:"Oxygen"},{title:"Overpass",value:"Overpass"},{title:"Assistant",value:"Assistant"},{title:"Tajawal",value:"Tajawal"},{title:"Play",value:"Play"},{title:"Exo",value:"Exo"},{title:"Cinzel",value:"Cinzel"},{title:"Faustina",value:"Faustina"},{title:"Philosopher",value:"Philosopher"},{title:"Gelasio",value:"Gelasio"},{title:"Sofia Sans Condensed",value:"Sofia Sans Condensed"},{title:"Noto Sans Devanagari",value:"Noto Sans Devanagari"},{title:"Actor",value:"Actor"},{title:"Epilogue",value:"Epilogue"},{title:"Glegoo",value:"Glegoo"},{title:"Overlock",value:"Overlock"},{title:"Lustria",value:"Lustria"},{title:"Ovo",value:"Ovo"},{title:"Suranna",value:"Suranna"},{title:"Bebas Neue",value:"Bebas Neue"},{title:"Manrope",value:"Manrope"}],ThemeConfigPanel=({showHeading:o=!0,className:n=""})=>{const[r,a]=useBrandingOptions(),[i]=useBlocksContainer(),l=React__namespace.useRef(r),{t:c}=reactI18next.useTranslation(),d=({formData:v},S)=>{S&&(a(v),l.current=v)},{bodyFont:u,headingFont:x,primaryColor:m,bodyTextDarkColor:p,bodyTextLightColor:g,bodyBgDarkColor:R,secondaryColor:h,bodyBgLightColor:f,roundedCorners:b}=r;let C={headingFont:iconBase.y({title:c("theme_config.heading_font"),default:x,options:FONTS}),bodyFont:iconBase.y({title:c("theme_config.body_font"),default:u,options:FONTS}),roundedCorners:iconBase.s({title:c("theme_config.rounded_corner"),default:parseInt(b||5,10)}),primaryColor:iconBase.h({title:c("theme_config.primary"),default:m}),secondaryColor:iconBase.h({title:c("theme_config.secondary"),default:h})};i||(C={...C,bodyBgLightColor:iconBase.h({title:c("theme_config.background"),default:f}),bodyTextLightColor:iconBase.h({title:c("theme_config.text_color"),default:p}),bodyBgDarkColor:iconBase.h({title:c("theme_config.background_dark_mode"),default:R}),bodyTextDarkColor:iconBase.h({title:c("theme_config.text_color_dark_mode"),default:g})});const _={type:"object",properties:{}},w={};return Object.keys(C).forEach(v=>{const S=C[v];return _.properties||(_.properties={}),_.properties[v]=S.schema,w[v]=S.uiSchema,!0}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full select-none flex-col",n),children:[o?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:c("Theme Configuration")})}):null,jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{color:ColorField},idSeparator:".",autoComplete:"off",omitExtraData:!0,liveOmit:!0,liveValidate:!0,uiSchema:w,schema:_,formData:r,validator,onChange:d})]})},ThemeOptions=ThemeConfigPanel,placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:n,left:r}){const a={position:"absolute",pointerEvents:"none",top:n+"px",left:r+"px",right:0};return jsxRuntime.jsxRuntimeExports.jsx("div",{style:{...placeholderStyle,...a},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:n,isDragging:r}){return r?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:n}):null}),DefaultDragPreview=React.memo(({id:o,isDragging:n,mouse:r})=>{const[a]=useBlocksStore(),i=React.useMemo(()=>a.find(c=>c._id===o),[a,o]),l=React.useMemo(()=>({transform:`translate(${(r==null?void 0:r.x)-10}px, ${(r==null?void 0:r.y)-10}px)`}),[r]);return r?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(Overlay,{isDragging:n,children:jsxRuntime.jsxRuntimeExports.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:l,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${i==null?void 0:i._type}`,children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:i==null?void 0:i._type})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:(i==null?void 0:i._name)||(i==null?void 0:i._type)})]})})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"hidden"})}),CopyPasteBlocks=()=>{const[o]=useSelectedBlockIds(),{canPaste:n,pasteBlocks:r}=usePasteBlocks(),[,a]=useCopyBlockIds(),{t:i}=reactI18next.useTranslation(),l=useSelectedBlock();return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(l==null?void 0:l._type),onClick:()=>a(o),className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{})," Copy"]}),n(o[0])&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{r(o)},children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackIcon,{})," ",i("Paste")]})]})},CutBlocks=()=>{const[o]=useSelectedBlockIds(),[,n]=useCutBlockIds(),{t:r}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ScissorsIcon,{})," ",r("Cut")]})},RemoveBlocks=()=>{const[o]=useSelectedBlockIds(),n=useRemoveBlocks(),r=useSelectedBlock(),{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDeleteBlock(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TrashIcon,{})," ",a("Remove")]})},BlockContextMenuContent=()=>{const{t:o}=reactI18next.useTranslation(),[n]=useSelectedBlockIds(),r=useDuplicateBlocks(),a=useSelectedBlock(),i=React.useCallback(()=>{r(n)},[n,r]);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuContent,{className:"border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canAddChildBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:a}),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"14"})," ",o("Add block")]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:i,children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackPlusIcon,{})," ",o("Duplicate")]}),jsxRuntime.jsxRuntimeExports.jsx(CutBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(CopyPasteBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(RemoveBlocks,{})]})},BlockContextMenu=({children:o})=>jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ContextMenuTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenuContent,{})]})}),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(o){o.firstNode&&o.select(o.firstNode.id)}function selectLast(o){o.lastNode&&o.select(o.lastNode.id)}function selectNext(o){const n=o.selectedNodes[0].next||o.firstNode;o.select(n.id)}function selectPrev(o){const n=o.selectedNodes[0].prev||o.lastNode;o.select(n.id)}const selectParent=(o,n)=>{var a;const r=((a=o.selectedIds[0])==null?void 0:a.parent)||null;r&&n&&o.select(r.id)},open=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.open()},close=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.close()};function VscJson(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(o)}function BsLightningFill(o){return iconBase.GenIcon({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z"},child:[]}]})(o)}function TbEyeDown(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"},child:[]},{tag:"path",attr:{d:"M19 16v6"},child:[]},{tag:"path",attr:{d:"M22 19l-3 3l-3 -3"},child:[]}]})(o)}function BiCollapseVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 7.59 7.05 2.64 5.64 4.05 12 10.41l6.36-6.36-1.41-1.41L12 7.59zM5.64 19.95l1.41 1.41L12 16.41l4.95 4.95 1.41-1.41L12 13.59l-6.36 6.36z"},child:[]}]})(o)}function BiExpandVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z"},child:[]}]})(o)}const Node=React.memo(({node:o,style:n,dragHandle:r})=>{const a=useBuilderProp("outlineMenuItems",[]),{t:i}=reactI18next.useTranslation(),[l,,c]=useHiddenBlockIds(),[,d]=useHighlightBlockId(),[u]=jotai.useAtom(canvasIframeAtom);let x=null;const m=o.children.length>0,{id:p,data:g,isSelected:R,willReceiveDrop:h,isDragging:f,isEditing:b,handleClick:C}=o,_=I=>{I.stopPropagation(),!l.includes(p)&&o.toggle()},w=I=>{I.isInternal&&(x=I.isOpen,I.isOpen&&I.close())},v=I=>{I.isInternal&&x!==null&&(x?I.open():I.close(),x=null)},S=I=>{I.stopPropagation(),!o.isOpen&&!l.includes(p)&&o.toggle(),C(I)};React.useEffect(()=>{const I=setTimeout(()=>{h&&!o.isOpen&&!f&&!l.includes(p)&&o.toggle()},500);return()=>clearTimeout(I)},[h,o,f]);const A=React.useMemo(()=>{const I=Object.keys(g),j=[];for(let E=0;E<I.length;E++)if(I[E].endsWith("_attrs")){const k=g[I[E]],y=Object.keys(k).join("|");y.match(/x-data/)&&j.push("data"),y.match(/x-on/)&&j.push("event"),y.match(/x-show|x-if/)&&j.push("show")}return j},[g]),T=(I,j)=>{const E=u.contentDocument||u.contentWindow.document,k=E.querySelector(`[data-block-id=${I}]`);k&&k.setAttribute("data-drop",j);const y=k.getBoundingClientRect(),B=u.getBoundingClientRect();y.top>=B.top&&y.left>=B.left&&y.bottom<=B.bottom&&y.right<=B.right||(E.documentElement.scrollTop=k.offsetTop-B.top)};return p===STRINGS.ROOT_TEMP_KEY?jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mb-10 mt-5 w-full rounded bg-gray-100 p-1 hover:bg-gray-200 dark:bg-gray-800",children:["+ ",i("add_block")]}):jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenu,{id:p,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>d(p),onClick:S,style:n,"data-node-id":p,ref:l.includes(p)?null:r,onDragStart:()=>w(o),onDragEnd:()=>v(o),onDragOver:I=>{I.preventDefault(),T(p,"yes")},onDragLeave:I=>{I.preventDefault(),T(p,"no")},onDrop:I=>{I.preventDefault(),T(p,"no")},className:iconBase.cn("group flex !h-full w-full items-center justify-between space-x-px !rounded py-px text-foreground/80 outline-none",R?"bg-blue-500 text-white":"hover:bg-gray-200 dark:hover:bg-gray-800",h&&canAcceptChildBlock(g._type,"Icon")?"bg-green-200":"",f&&"opacity-20",l.includes(p)?"opacity-50":""),children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${o.isOpen?"rotate-90":""}`,children:m&&jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:_,type:"button",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleRightIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:g==null?void 0:g._type})}),b?jsxRuntime.jsxRuntimeExports.jsx(Input,{node:o}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"ml-2 flex items-center gap-x-1 truncate text-[11px]",onDoubleClick:I=>{I.stopPropagation(),o.edit(),o.deselect()},children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:(g==null?void 0:g._name)||(g==null?void 0:g._type.split("/").pop())}),A.includes("data")&&jsxRuntime.jsxRuntimeExports.jsx(VscJson,{className:"h-3 w-3 text-orange-600"}),A.includes("event")&&jsxRuntime.jsxRuntimeExports.jsx(BsLightningFill,{className:"h-3 w-3 text-yellow-500"}),A.includes("show")&&jsxRuntime.jsxRuntimeExports.jsx(TbEyeDown,{className:"h-3 w-3 text-orange-600"})]})]})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"invisible flex items-center space-x-1 pr-2 group-hover:visible",children:[!l.includes(p)&&a.map(I=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:React.createElement(I.item,{blockId:p})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-10",children:I.tooltip})]})),canAddChildBlock(g==null?void 0:g._type)&&!l.includes(p)?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:{_id:p}}),className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"18"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]}):null,jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:I=>{I.stopPropagation(),c(p),o.isOpen&&o.toggle()},className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EyeOff,{size:"15"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]})]})]})})}),Input=({node:o})=>{var n,r;return jsxRuntime.jsxRuntimeExports.jsx("input",{autoFocus:!0,className:"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] outline-none",type:"text",defaultValue:((n=o.data)==null?void 0:n._name)||((r=o.data)==null?void 0:r._type),onFocus:a=>a.currentTarget.select(),onBlur:a=>o.submit(a.currentTarget.value),onKeyDown:a=>{a.key==="Enter"&&o.submit(a.currentTarget.value)}})},useCanMove=()=>{const[o]=useBlocksStore();return(n,r)=>{var l;const a=(l=lodashEs.find(o,{_id:r}))==null?void 0:l._type,i=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(a,i)}},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(),clearSelection=()=>{setIds([]),setStyleBlocks([])},filteredTreeData=React.useMemo(()=>{const o=(r,a)=>r.filter(i=>!a.includes(i._id)).map(i=>({...i,children:i.children?o(i.children,a):[]}));return[...o(treeData,cutBlocksIds),{_type:STRINGS.ROOT_TEMP_KEY,_id:STRINGS.ROOT_TEMP_KEY,children:[]}]},[treeData,cutBlocksIds]);React.useEffect(()=>{setTreeRef(treeRef.current)},[treeRef.current]);const onRename=({id:o,name:n,node:r})=>{updateBlockProps([o],{_name:n},r.data._name)},onMove=({dragIds:o,parentId:n,index:r})=>{canMove(o,n)&&moveBlocks(o,n,r)},onSelect=o=>{if(o.length===0)return;const n=o[0]?o[0].id:"";setStyleBlocks([]),setIds([n])},onContextMenu=o=>{var a;o.preventDefault();const n=o.target,r=n.getAttribute("data-node-id")||((a=n.closest("[data-node-id]"))==null?void 0:a.getAttribute("data-node-id"));r&&(setStyleBlocks([]),setIds([r]))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:o,dragNodes:n})=>{var r;return(o==null?void 0:o.data._type)===STRINGS.ROOT_TEMP_KEY||!canAcceptChildBlock(o==null?void 0:o.data._type,(r=n[0])==null?void 0:r.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}};return lodashEs.isEmpty(treeData)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("This page is empty"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),variant:"default",size:"sm",children:["+ ",t("add_block")]})]})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto text-xs",onKeyDown:o=>{treeRef.current.isEditing||handleKeyDown(o)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-2 pb-2 text-xs text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>setHiddenBlocks([]),variant:"outline",className:"h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeOpenIcon,{className:"h-4 w-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Show hidden blocks")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.openAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiExpandVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Expand all")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.closeAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiCollapseVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Collapse all")})]})]}),jsxRuntime.jsxRuntimeExports.jsx(reactArborist.Tree,{ref:treeRef,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full !overflow-y-auto !overflow-x-hidden",selection:ids[0]||"",onRename,openByDefault:!1,onMove,rowHeight:25,data:[...filteredTreeData],renderCursor:DefaultCursor,onSelect,childrenAccessor:o=>o.children,width:"100%",renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})]})})},Outline$1=ListTree,hasVideoEmbed=o=>{const n=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return n.test(o)||r.test(o)},getVideoURLFromHTML=o=>{if(lodashEs.isEmpty(o))return o;const n=/<video[^>]+src=['"]([^'">]+)['"]/,r=/<iframe[^>]+src=['"]([^'">]+)['"]/,a=o.match(n),i=o.match(r),l=a?a[1]:i?i[1]:null,c=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,d=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return l&&(c.test(l)||d.test(l))?l:o},NAME_ATTRIBUTE="$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"}},shouldAddText=(o,n)=>o.children.length===1&&lodashEs.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link"],n._type),getTextContent=o=>o.map(n=>n.type==="text"?lodashEs.get(n,"content",""):lodashEs.isEmpty(n.children)?"":getTextContent(n.children)).join(""),getSanitizedValue=o=>o===null?"":o,getAttrs=o=>{if(o.tagName==="svg")return{};const n={},r=ATTRIBUTE_MAP[o.tagName]||{},a=o.attributes;return lodashEs.forEach(a,({key:i,value:l})=>{if(i!==NAME_ATTRIBUTE)if(r[i]){if(o.tagName==="img"&&i==="src"&&!l.startsWith("http")){const c=lodashEs.find(o.attributes,{key:"width"}),d=lodashEs.find(o.attributes,{key:"height"});c&&d?l=`https://via.placeholder.com/${c==null?void 0:c.value}x${d==null?void 0:d.value}`:l="https://via.placeholder.com/150x150"}lodashEs.set(n,r[i],getSanitizedValue(l))}else lodashEs.includes(["style","class","srcset"],i)||(lodashEs.has(n,"styles_attrs")||(n.styles_attrs={}),lodashEs.startsWith(i,"@")&&(i=i.replace("@","x-on:")),n.styles_attrs[`${i}`]=getSanitizedValue(l))}),delete n.class,n},getStyles=(o,n="styles")=>{if(!o.attributes)return{[n]:`${STRINGS.STYLES_KEY},`};const r=lodashEs.find(o.attributes,{key:"class"});if(r){const a=r.value;return{[n]:`${STRINGS.STYLES_KEY},${a}`}}return{[n]:`${STRINGS.STYLES_KEY},`}},getBlockProps=o=>{switch(o.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:o.tagName,_listType:o.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:o.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:o.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:o.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:o.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:const n=lodashEs.get(o,"children",[]).length>0?"Box":"EmptyBox";return{_type:n,tag:o.tagName,_name:n=="EmptyBox"||o.tagName==="div"?n:lodashEs.capitalize(o.tagName)}}},traverseNodes=(o,n=null)=>lodashEs.flatMapDeep(o,r=>{var l;if(r.type==="comment")return[];let a={_id:iconBase.generateUUID()};if(n&&(a._parent=n.block._id),r.type==="text")return lodashEs.isEmpty(lodashEs.get(r,"content",""))?[]:n&&shouldAddText(n.node,n.block)?(lodashEs.set(n,"block.content",lodashEs.get(r,"content","")),[]):{...a,_type:"Text",content:lodashEs.get(r,"content","")};if(a={...a,...getBlockProps(r),...getAttrs(r),...getStyles(r)},r.attributes){const c=r.attributes.find(d=>d.key===NAME_ATTRIBUTE);c&&(a._name=c.value)}if(a._type==="Input"){const c=a.inputType||"text";c==="checkbox"?lodashEs.set(a,"_type","Checkbox"):c==="radio"&&lodashEs.set(a,"_type","Radio")}else if(r.tagName==="video"||r.tagName==="iframe"){const c=himalaya.stringify([r]);return hasVideoEmbed(c)&&(lodashEs.set(a,"_type","Video"),lodashEs.set(a,"url",getVideoURLFromHTML(c)),lodashEs.set(a,"styles",`${STRINGS.STYLES_KEY},absolute top-0 left-0 w-full h-full`),lodashEs.set(a,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),a.content=c,[a]}else if(r.tagName==="svg"){const c=lodashEs.find(r.attributes,{key:"height"}),d=lodashEs.find(r.attributes,{key:"width"}),u=lodashEs.get(c,"value")?`[${lodashEs.get(c,"value")}px]`:"24px",x=lodashEs.get(d,"value")?`[${lodashEs.get(d,"value")}px]`:"24px",m=lodashEs.get(lodashEs.find(r.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${STRINGS.STYLES_KEY}, ${iconBase.cn(`w-${x} h-${u}`,m)}`.trim(),r.attributes=lodashEs.filter(r.attributes,p=>!lodashEs.includes(["style","width","height","class"],p.key)),a.icon=himalaya.stringify([r]),[a]}else if(r.tagName=="option"&&n&&((l=n.block)==null?void 0:l._type)==="Select")return n.block.options.push({label:getTextContent(r.children),...getAttrs(r)}),[];const i=traverseNodes(r.children,{block:a,node:r});return[a,...i]}),getSanitizedHTML=o=>{const n=o.match(/<body[^>]*>[\s\S]*?<\/body>/);return(n&&n.length>0?n[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):o).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},getBlocksFromHTML=o=>{const n=himalaya.parse(getSanitizedHTML(o));return lodashEs.isEmpty(o)?[]:lodashEs.flatten(traverseNodes(n))},ImportHTML=({parentId:o})=>{const{t:n}=reactI18next.useTranslation(),[r,a]=React.useState(""),{addPredefinedBlock:i}=useAddBlock(),l=()=>{const c=getBlocksFromHTML(r);i([...c],o),a(""),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Card,{className:"border-border/0 p-0 shadow-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardHeader,{className:"p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardDescription,{children:n("html_snippet_description")})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardContent,{className:"space-y-2 px-3 py-0",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"current",className:"text-sm",children:n("tailwind_html_snippet")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoFocus:!0,tabIndex:1,ref:c=>c&&c.focus(),onChange:c=>a(c.target.value),rows:12,value:r,placeholder:n("enter_code_snippet"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardFooter,{className:"flex flex-col justify-end p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim()==="",onClick:()=>l(),size:"sm",className:"w-fit",children:n("Import HTML")})})]})},ImportHTML$1=ImportHTML,isBoolean=o=>typeof o=="boolean"||o instanceof Boolean,isNumber=o=>typeof o=="number"||o instanceof Number,isBigInt=o=>typeof o=="bigint"||o instanceof BigInt,isDate=o=>!!o&&o instanceof Date,isString=o=>typeof o=="string"||o instanceof String,isArray=o=>Array.isArray(o),isObject=o=>o instanceof Object&&o!==null;function useBool(o){const[n,r]=React.useState(o());return[n,()=>r(i=>!i),r]}let componentId=1;const generateNextId=()=>componentId++;function useComponentId(){const o=React.useRef();return o.current===void 0&&(o.current=`:jsnvw:${generateNextId()}:`),o.current}function ExpandableObject(o){let{field:n,value:r,data:a,lastElement:i,openBracket:l,closeBracket:c,level:d,style:u,shouldExpandNode:x,clickToExpandNode:m}=o;const p=React.useRef(!1),[g,R,h]=useBool(()=>x(d,r,n));React.useEffect(()=>{p.current?h(x(d,r,n)):p.current=!0},[x]);const f=g?u.collapseIcon:u.expandIcon,b=g?"collapse JSON":"expand JSON",C=useComponentId(),_=d+1,w=a.length-1,v=S=>{S.key===" "&&(S.preventDefault(),R())};return React.createElement("div",{className:u.basicChildStyle,role:"list"},React.createElement("span",{className:f,onClick:R,onKeyDown:v,role:"button",tabIndex:0,"aria-label":b,"aria-expanded":g,"aria-controls":g?C:void 0}),n&&(m?React.createElement("span",{className:u.clickableLabel,onClick:R,onKeyDown:v,role:"button",tabIndex:-1},n,":"):React.createElement("span",{className:u.label},n,":")),React.createElement("span",{className:u.punctuation},l),g?React.createElement("div",{id:C},a.map((S,A)=>React.createElement(DataRender,{key:S[0]||A,field:S[0],value:S[1],style:u,lastElement:A===w,level:_,shouldExpandNode:x,clickToExpandNode:m}))):React.createElement("span",{className:u.collapsedContent,onClick:R,onKeyDown:v,role:"button",tabIndex:-1,"aria-hidden":!0,"aria-label":b,"aria-expanded":g}),React.createElement("span",{className:u.punctuation},c),!i&&React.createElement("span",{className:u.punctuation},","))}function JsonObject(o){let{field:n,value:r,style:a,lastElement:i,shouldExpandNode:l,clickToExpandNode:c,level:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:d,openBracket:"{",closeBracket:"}",style:a,shouldExpandNode:l,clickToExpandNode:c,data:Object.keys(r).map(u=>[u,r[u]])})}function JsonArray(o){let{field:n,value:r,style:a,lastElement:i,level:l,shouldExpandNode:c,clickToExpandNode:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:l,openBracket:"[",closeBracket:"]",style:a,shouldExpandNode:c,clickToExpandNode:d,data:r.map(u=>[void 0,u])})}function JsonPrimitiveValue(o){let{field:n,value:r,style:a,lastElement:i}=o,l=r,c=a.otherValue;return r===null?(l="null",c=a.nullValue):r===void 0?(l="undefined",c=a.undefinedValue):isString(r)?(l=a.noQuotesForStringValues?r:`"${r}"`,c=a.stringValue):isBoolean(r)?(l=r?"true":"false",c=a.booleanValue):isNumber(r)?(l=r.toString(),c=a.numberValue):isBigInt(r)?(l=`${r.toString()}n`,c=a.numberValue):isDate(r)?l=r.toISOString():l=r.toString(),n===""&&(n='""'),React.createElement("div",{className:a.basicChildStyle,role:"listitem"},n&&React.createElement("span",{className:a.label},n,":"),React.createElement("span",{className:c},l),!i&&React.createElement("span",{className:a.punctuation},","))}function DataRender(o){const n=o.value;return isArray(n)?React.createElement(JsonArray,Object.assign({},o)):isObject(n)&&!isDate(n)?React.createElement(JsonObject,Object.assign({},o)):React.createElement(JsonPrimitiveValue,Object.assign({},o))}var styles={"container-base":"_GzYRV","punctuation-base":"_3eOF8",pointer:"_1MFti","expander-base":"_f10Tu _1MFti","expand-icon":"_1UmXx","collapse-icon":"_1LId0","collapsed-content-base":"_1pNG9 _1MFti","container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const defaultStyles={container:styles["container-light"],basicChildStyle:styles["basic-element-style"],label:styles["label-light"],clickableLabel:styles["clickable-label-light"],nullValue:styles["value-null-light"],undefinedValue:styles["value-undefined-light"],stringValue:styles["value-string-light"],booleanValue:styles["value-boolean-light"],numberValue:styles["value-number-light"],otherValue:styles["value-other-light"],punctuation:styles["punctuation-light"],collapseIcon:styles["collapse-icon-light"],expandIcon:styles["expand-icon-light"],collapsedContent:styles["collapsed-content-light"],noQuotesForStringValues:!1},allExpanded=()=>!0,JsonView=o=>{let{data:n,style:r=defaultStyles,shouldExpandNode:a=allExpanded,clickToExpandNode:i=!1}=o;return React.createElement("div",{className:r.container},React.createElement(DataRender,{value:n,style:r,lastElement:!0,level:0,shouldExpandNode:a,clickToExpandNode:i}))};function getPathAndTypes(o){const n=[],r={};function a(i,l){lodashEs.forEach(l,(c,d)=>{const u=i?`${i}.${d}`:d,x=lodashEs.isArray(c)?"list":typeof c;n.push(u),r[u]=x==="string"?"text":x==="object"?"model":x,x==="object"&&!lodashEs.isArray(c)&&a(u,c)})}return a("",lodashEs.omit(o,["styles","_type","_id","_name","_bindings"])),{paths:n,pathsType:r}}const ViewData=({data:o,fullView:n})=>{const r=useBuilderProp("onError",lodashEs.noop);if(!o)return null;const a=typeof o;return n?typeof o=="object"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-3"}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:o,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[40vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-h-36 w-full overflow-y-auto overflow-x-hidden text-[12px] leading-4 text-gray-800/50",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-medium text-gray-800/80",children:"Content: "}),o]}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-full overflow-hidden whitespace-nowrap text-[10px] leading-3 text-gray-800/50",children:lodashEs.truncate(a==="object"?JSON.stringify(o):o,{length:40})})},DataProvidersSuggester=({type:o,value:n="",setValue:r,data:a,onChange:i,dataType:l,appliedBindings:c})=>{const{paths:d,pathsType:u}=getPathAndTypes(a),x=o==="PROP"?runtime.getBlockComponent(a==null?void 0:a._type):{},m=o==="PROP",[p,g]=React.useState(!1),R=React.useMemo(()=>o==="PROP"?d.filter(h=>!lodashEs.includes(c,h)&&lodashEs.get(x,`props.${lodashEs.first(lodashEs.split(h,"."))}.binding`)):d.filter(h=>l===lodashEs.get(u,h,"")),[o,d,c,l,x]);return React.useEffect(()=>{n&&i(n)},[n,o]),jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:lodashEs.startCase(lodashEs.toLower(o))}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{open:p,onOpenChange:g,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",size:"sm",className:` ${lodashEs.isEmpty(n)?"w-44 justify-center bg-blue-500 text-gray-100 hover:bg-blue-400 hover:text-white":"min-w-[350px] items-center justify-between"}`,children:n?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"pr-8 text-sm",children:[m&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"mr-2 rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(l)}),n]}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer text-[9px] text-blue-400 underline hover:text-blue-700",children:"Change"})]}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:["+ Set ",lodashEs.startCase(lodashEs.toLower(o))]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{className:"z-[999] min-w-[300px] p-0",side:"right",align:"start",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Command,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandInput,{placeholder:`Choose ${lodashEs.toLower(o)}...`}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandList,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandEmpty,{children:"No results found."}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandGroup,{children:lodashEs.map(R,h=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandItem,{value:h,className:`cursor-pointer ${m?"flex items-center justify-between":"flex flex-col items-start justify-start"}`,onSelect:f=>{r(lodashEs.find(R,b=>b===f)||null),g(!1)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Check,{className:`h-4 w-4 text-green-500 ${n===h?"":"opacity-0"}`}),h]}),m?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(lodashEs.get(u,h,""))})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pl-6",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,h)})})]},h))})]})]})})]})]}),!m&&!lodashEs.isEmpty(n)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pt-2",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,n,""),fullView:!0})})]})},AddBindingModalContent=({appliedBindings:o=[],onAddBinding:n,editMode:r,item:a})=>{const[i,l]=React.useState(r?a.key:""),[c,d]=React.useState(r?a.value:""),u=useSelectedBlock(),[x]=useChaiExternalData(),m=React.useCallback((R,h)=>{if(lodashEs.isEmpty(R))return"";{const f=lodashEs.get(h==="PROP"?u:x,R,"");if(lodashEs.isArray(f))return"list";const b=typeof f;return b==="string"?"text":b==="object"?"model":b}},[u,x]),[p,g]=React.useState(r?m(a.key,"PROP"):"");return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{children:"Add Data Binding"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{className:"text-xs",children:"Add prop and path of binding. Click save when you're done."})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col gap-1",children:[jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PROP",isDisabled:!1,placeholder:"Enter prop key",value:i,setValue:l,onChange:R=>{const h=m(R,"PROP");l(R),p!==h&&d(""),g(h)},data:u,dataType:p,appliedBindings:o}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-2"}),jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PATH",isDisabled:lodashEs.isEmpty(i),placeholder:"Enter data path",value:c,setValue:d,onChange:R=>{const h=m(R,"PATH");d(p===h?R:"")},data:x,dataType:p,appliedBindings:o})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogFooter,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",className:"mt-4",disabled:lodashEs.isEmpty(i)&&lodashEs.isEmpty(c),onClick:()=>n({key:i,value:c}),children:"Save"})})]})},AddBindingModal=({disabled:o,children:n,onAddBinding:r,appliedBindings:a,editMode:i=!0,item:l={}})=>{const[c,d]=React.useState(!1);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{disabled:o,asChild:!0,onClick:()=>d(!0),children:n}),c&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModalContent,{item:l,editMode:i,appliedBindings:a,onAddBinding:u=>{r(u),d(!1)}})})]})},NewDataBindingPair=({item:o,onAddBinding:n,onRemove:r,selectedBlock:a,dataProvider:i,appliedBindings:l})=>{const[c,d]=React.useState("string"),u=(x,m)=>{if(lodashEs.isEmpty(x))return"";{const p=lodashEs.get(m==="PROP"?a:i,x,"");if(lodashEs.isArray(p))return"list";const g=typeof p;return g==="string"?"text":g==="object"?"model":g}};return React.useEffect(()=>d(()=>u(o.key,"PROP")),[o.key]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col rounded-md border border-border p-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-sm font-normal text-gray-500",children:o.key}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"font-medium leading-5",children:o.value}),jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(i,o.value,"")}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{editMode:!0,onAddBinding:n,appliedBindings:l,item:o,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{className:"mt-1 h-6 w-6 cursor-pointer rounded border border-blue-400 p-1 text-blue-400 duration-200 hover:scale-105 hover:bg-blue-400 hover:text-white"})}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.TrashIcon,{onClick:()=>r(),className:"mt-1 h-6 w-6 cursor-pointer rounded border border-red-400 p-1 text-red-400 duration-200 hover:scale-105 hover:bg-red-400 hover:text-white"})]}),!lodashEs.isEmpty(c)&&!lodashEs.isEmpty(o.key)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute right-0 top-1 mt-px flex h-4 items-center rounded-full px-2 text-[10px] font-medium text-purple-600",children:lodashEs.startCase(c)})]})},DataBindingSetting=({bindingData:o,onChange:n})=>{const r=useSelectedBlock(),[a]=useChaiExternalData(),i=runtime.getChaiDataProviders(),[l,c]=React.useState(lodashEs.map(o,(p,g)=>({key:g,value:p})));React.useEffect(()=>{c(lodashEs.map(o,(p,g)=>({key:g,value:p})))},[r==null?void 0:r._id,o]);const d=React.useMemo(()=>{if(lodashEs.isEmpty(a))return!0;if(lodashEs.isEmpty(l))return!1;const p=lodashEs.last(l);return lodashEs.isEmpty(p==null?void 0:p.key)||lodashEs.isEmpty(p==null?void 0:p.value)},[a,l]),u=p=>{const g=lodashEs.filter(l,R=>R.key!==p.key);c([...g,p]),m([...g,p])},x=p=>{const g=lodashEs.filter(l,(R,h)=>p!==h);m([...g])},m=React.useCallback((p=[])=>{if(c(p),lodashEs.isEmpty(p)){n({});return}const g={};lodashEs.forEach(p,R=>{!lodashEs.isEmpty(R==null?void 0:R.key)&&!lodashEs.isEmpty(R==null?void 0:R.value)&&lodashEs.set(g,R.key,R.value)}),n(g)},[n]);return lodashEs.isEmpty(i)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-xs text-gray-500",children:["You have no data providers registered. Please add a data provider to your project. ",jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:"Learn more"})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[lodashEs.map(l,(p,g)=>jsxRuntime.jsxRuntimeExports.jsx(NewDataBindingPair,{item:p,onAddBinding:u,onRemove:()=>x(g),selectedBlock:r,dataProvider:a,appliedBindings:lodashEs.map(l,"key")},p.key)),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:200,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{disabled:lodashEs.isEmpty(a),className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{disabled:d,appliedBindings:lodashEs.map(l,"key"),onAddBinding:u,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`w-full rounded-md px-5 py-1.5 text-xs font-medium duration-200 ${d?"cursor-not-allowed bg-gray-200 text-gray-400":"bg-blue-700/20 text-blue-800 hover:bg-blue-700/30"}`,children:lodashEs.isEmpty(a)?jsxRuntime.jsxRuntimeExports.jsx("small",{className:"text-[9.5px] text-gray-500",children:"No data provider has been set up for this page"}):"+ Add Data Binding"})})}),d&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{sideOffset:-55,className:"text-[11px]",children:lodashEs.isEmpty(a)?"No data provider has been set up for this page.":"Complete last added data binding to add more"})]})]})},DataBindingSetting$1=DataBindingSetting,BindingWidget=()=>jsxRuntime.jsxRuntimeExports.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"}),getSvgMarkup=o=>{try{const n=document.getElementById("icon-picker-field"),r=document.createElement("div");ReactDOM.render(jsxRuntime.jsxRuntimeExports.jsx(IconPicker.IconPickerItem,{value:o}),r),n.appendChild(r),r.hidden=!0;let a=r.innerHTML;setTimeout(()=>n.removeChild(r),100);const l=new DOMParser().parseFromString(a,"image/svg+xml"),c=l.querySelector("svg");return c&&(c.removeAttribute("width"),c.removeAttribute("height")),new XMLSerializer().serializeToString(l)}catch(n){return console.error(n),""}},IconPickerField=({value:o,onChange:n})=>{const{t:r}=reactI18next.useTranslation(),a=i=>{n("<svg />");const l=getSvgMarkup(i);n(l)};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative h-12 w-12",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:o?o.replace("<svg",'<svg class="h-5 w-5"'):"<svg class='h-5 w-5' />"},className:"absolute left-1/2 top-1/2 z-0 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer bg-white"}),jsxRuntime.jsxRuntimeExports.jsx(IconPicker,{value:o?"BiSolidGrid":null,onChange:a,pickButtonStyle:{position:"relative",height:"48px",width:"48px",border:"1px solid #999",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",zIndex:1},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),jsxRuntime.jsxRuntimeExports.jsx("textarea",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:o,onChange:i=>n(i.target.value),placeholder:r("choose_icon_or_enter_svg"),className:"no-scrollbar disabled:opacity-50; mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed"})]})},UnsplashImages=React.lazy(()=>Promise.resolve().then(()=>require("./UnsplashImages-Xfn4852d.cjs"))),UploadImages=React.lazy(()=>Promise.resolve().then(()=>require("./UploadImages-Yl-90dxh.cjs"))),ImagesPanel=({isModalView:o=!1,onSelect:n=()=>{}})=>{const r=useBuilderProp("uploadMediaCallback"),a=useBuilderProp("unsplashAccessKey"),i=r===void 0,l=a===void 0,[c,d]=React.useState(l?"upload":i?"unsplash":"upload");return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:o&&i?"Unsplash images":o?"Select or upload images":"Images"})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tabs,{value:c,onValueChange:u=>d(u),className:"flex h-full w-full flex-col py-2",children:[!(i||l)&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"upload",className:"w-full",children:"Upload"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"unsplash",className:"w-full",children:"Unsplash"})]}),c==="unsplash"?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"unsplash",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UnsplashImages,{isModalView:o,onSelect:n})})}):jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"upload",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UploadImages,{isModalView:o,onSelect:n})})})]})]})},ImagesPanel$1=ImagesPanel,ImagePickerModal=({children:o,onSelect:n})=>{const[r,a]=React.useState(!1),i=(...l)=>{n.call(void 0,...l),a(!1)};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{open:r,onOpenChange:l=>a(l),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{className:"flex h-3/4 max-w-5xl border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full",children:jsxRuntime.jsxRuntimeExports.jsx(ImagesPanel$1,{isModalView:!0,onSelect:i})})})]})},ImagePickerModal$1=ImagePickerModal,ImagePickerField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=useBuilderProp("uploadMediaCallback"),l=useBuilderProp("unsplashAccessKey"),{t:c}=reactI18next.useTranslation(),d=i===void 0,u=l===void 0;return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{className:"flex w-3/5 flex-col",children:[!(d&&u)&&jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.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:o||!lodashEs.isEmpty(o)?c("Replace image"):c("Choose image")})}),jsxRuntime.jsxRuntimeExports.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:c("enter_image_url"),value:o,onBlur:({target:{value:x}})=>a(r,x),onChange:x=>n(x.target.value)})]})]})},RichTextEditorField=({id:o,placeholder:n,value:r,onChange:a,onBlur:i})=>{const l={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]},{align:[]}],["link","clean"]]},c=["header","font","list","bold","italic","underline","strike","blockquote","color","background","align","link","image"];return typeof window>"u"?null:jsxRuntime.jsxRuntimeExports.jsx(ReactQuill,{id:o,value:r,onBlur:d=>i(o,d),onChange:d=>a(d),modules:l,formats:c,placeholder:n,className:"mt-1 rounded-md"})},LinkField=({schema:o,formData:n,onChange:r})=>{const[a,i]=React.useState([]),l=useBuilderProp("getPages",()=>[]),{type:c="page",href:d="",target:u="self"}=n;return React.useEffect(()=>{(async()=>{const x=await l();i(x||[])})()},[]),jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium",children:(o==null?void 0:o.title)??"Link"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxRuntimeExports.jsx("select",{name:"type",value:c,onChange:x=>r({...n,type:x.target.value}),children:[{const:"page",title:"Open Page"},{const:"url",title:"Open URL"},{const:"email",title:"Compose Email"},{const:"telephone",title:"Call Phone"},{const:"scroll",title:"Scroll to element"}].map(x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.const,children:x.title},x.const))}),c==="page"?jsxRuntime.jsxRuntimeExports.jsxs("select",{name:"href",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Choose page"}),lodashEs.map(a,x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.slug,children:x.name},x.uuid))]}):jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),placeholder:c==="page"||c==="url"?"Enter URL":c==="scroll"?"#ElementID":"Enter detail"}),(c==="page"||c==="url")&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:u==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>r({...n,target:u==="_blank"?"_self":"_blank"})}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pt-1 text-xs",children:"Open in new tab"})]})]})]})},CodeEditor=({id:o,placeholder:n})=>{const{t:r}=reactI18next.useTranslation(),[,a]=useCodeEditor(),i=useSelectedBlock();if(typeof window>"u")return null;const l=o.replace("root.",""),c=lodashEs.get(i,l,""),d=()=>{const u=i==null?void 0:i._id;a({blockId:u,blockProp:l,placeholder:n,initialCode:lodashEs.get(i,l,c)})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:d,className:"text-pretty w-[90%] max-w-full cursor-default truncate rounded border border-border bg-background p-2 text-left text-[10px]",children:c.trim().length>0?c.substring(0,46):n||"Eg: <script>console.log('Hello, world!');<\/script>"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:d,size:"sm",variant:"outline",className:"w-fit",children:r("Open code editor")})]})},JSONForm=React.memo(({id:o,properties:n,formData:r,onChange:a})=>{const[i,l]=React.useState(r),c={type:"object",properties:{}},d={},{t:u}=reactI18next.useTranslation();Object.keys(n).forEach(m=>{const p=n[m];if(lodashEs.includes(["slot","styles"],p.type))return;const g=m;c.properties[g]=getBlockJSONFromSchemas(p,u),d[g]=getBlockJSONFromUISchemas(p)}),React.useEffect(()=>{l(r)},[o]);const x=web.useThrottledCallback(async({formData:m},p)=>{a({formData:m},p)},[a],1e3);return jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{binding:BindingWidget,richtext:RichTextEditorField,icon:IconPickerField,image:ImagePickerField,code:CodeEditor},fields:{link:LinkField},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator,uiSchema:d,schema:c,formData:i,onChange:({formData:m},p)=>{p&&(l(m),x({formData:m},p))}})}),CanvasSettings=()=>{const[o,n]=jotai.useAtom(xShowBlocksAtom),r=useSelectedBlock(),[,a]=useSelectedBlockIds(),{t:i}=reactI18next.useTranslation(),l=React.useMemo(()=>(r?JSON.stringify(r):"").includes('"x-show"'),[r]);if(!r||!l)return null;const c=o.includes(r._id);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"py-2 text-xs hover:no-underline",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border bg-background py-2 font-normal text-muted-foreground",children:[r._name||r._type," ",i("visibility settings")]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"show-on-canvas",checked:c,onCheckedChange:d=>{d?(n(u=>[...u,r._id]),a([r._id])):n(u=>u.filter(x=>x!==r._id))}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"show-on-canvas",children:i("Show on canvas")})]})]})},GlobalBlockSettings=()=>{const o=useSelectedBlock(),{data:n,refetch:r,isLoading:a}=useGlobalBlocksList(),i=useUpdateBlocksProps();return jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxRuntimeExports.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:(o==null?void 0:o.globalBlock)||"",onChange:l=>{i([o._id],{globalBlock:l.target.value,_name:`Global: ${lodashEs.startCase(l.target.value)}`})},children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Select a global block"}),Object.keys(n).map(l=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:l,children:n[l].name||l},l))]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:r,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:a?"Loading...":"Refresh List"})})]})},ResetRSCBlockButton=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{reset:r}=useRSCBlocksStore();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{size:"sm",variant:"outline",onClick:()=>r(o),children:n("Reload")})};function BlockSettings(){const o=useSelectedBlock(),n=useUpdateBlocksPropsRealtime(),r=useUpdateBlocksProps(),a=runtime.getBlockComponent(o==null?void 0:o._type),i={...o},[l,c]=React.useState(i),d=useBuilderProp("dataBindingSupport",!1),u=({formData:h},f,b)=>{if(f&&(l==null?void 0:l._id)===o._id){const C=f.replace("root.","");r([o._id],{[C]:lodashEs.get(h,C)},b)}},x=React.useCallback(lodashEs.debounce(({formData:h},f,b)=>{u({formData:h},f,b),c(h)},1500),[o==null?void 0:o._id]),m=({formData:h},f)=>{if(f){const b=f.replace("root.","");n([o._id],convertDotNotationToObject(b,lodashEs.get(h,b.split(".")))),x({formData:h},f,{[b]:lodashEs.get(l,b)})}},p=lodashEs.keys(lodashEs.get(i,"_bindings",{})),g=React.useMemo(()=>{const h=lodashEs.cloneDeep(lodashEs.get(a,"props",{}));return lodashEs.each(h,(f,b)=>{lodashEs.get(f,"hidden",!1)&&delete h[b]}),d&&lodashEs.each(p,f=>delete h[f]),h},[a,p,d]),R=lodashEs.get(a,"server",!1);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"overflow-x-hidden px-px",children:[d?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{type:"multiple",defaultValue:["STATIC","BINDING"],className:"mt-4 h-full w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"BINDING",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`h-[8px] w-[8px] rounded-full ${lodashEs.isEmpty(lodashEs.get(o,"_bindings",{}))?"bg-gray-300":"bg-blue-500"}`}),"Data Binding"]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"pt-4",children:jsxRuntime.jsxRuntimeExports.jsx(DataBindingSetting$1,{bindingData:lodashEs.get(o,"_bindings",{}),onChange:h=>{u({formData:{_bindings:h}},"root._bindings")}})})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"STATIC",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-[8px] w-[8px] rounded-full bg-blue-500"}),"Static Content"]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{className:"pt-4",children:[lodashEs.isEmpty(p)?null:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-1 mt-0 rounded-sm border border-orange-500 bg-orange-100 p-1 text-xs text-orange-500",children:["Data binding is set for ",jsxRuntime.jsxRuntimeExports.jsx("b",{children:lodashEs.map(p,lodashEs.capitalize).join(", ")})," ",p.length===1?"property":"properties",". Remove data binding to edit static content."]}),jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:o==null?void 0:o._id,onChange:m,formData:i,properties:g})]})]})]}):lodashEs.isEmpty(g)?null:jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:o==null?void 0:o._id,onChange:m,formData:i,properties:g}),(o==null?void 0:o._type)==="GlobalBlock"?jsxRuntime.jsxRuntimeExports.jsx(GlobalBlockSettings,{}):null,R?jsxRuntime.jsxRuntimeExports.jsx(ResetRSCBlockButton,{blockId:o==null?void 0:o._id}):null,jsxRuntime.jsxRuntimeExports.jsx(CanvasSettings,{})]})}function getChildBlocks(o,n,r){r.push(lodashEs.find(o,{_id:n}));const a=lodashEs.filter(o,{_parent:n});for(const i of a)r.push(...getBlockWithChildren(i._id,o));return r}const getBlockWithChildren=(o,n)=>{let r=[];return r=lodashEs.flattenDeep([...r,...getChildBlocks(n,o,r)]),r},askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[o,n]=jotai.useAtom(askAiProcessingAtom),[r,a]=React.useState(null),i=useBuilderProp("askAiCallBack",null),l=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore();return{askAi:React.useCallback(async(u,x,m,p)=>{if(i){n(!0),a(null);try{const g=u==="content"?lodashEs.cloneDeep(getBlockWithChildren(x,d)):[lodashEs.cloneDeep(d.find(b=>b._id===x))];lodashEs.set(g,"0._parent",null);const R=await i(u,m,g),{blocks:h,error:f}=R;if(f){a(f);return}u==="styles"?c(h):l(h),p&&p(R)}catch(g){a(g)}finally{n(!1),p&&p()}}},[i,n,d,c,l]),loading:o,error:r}};function FaMoon(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"},child:[]}]})(o)}function FaRecycle(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M184.561 261.903c3.232 13.997-12.123 24.635-24.068 17.168l-40.736-25.455-50.867 81.402C55.606 356.273 70.96 384 96.012 384H148c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12H96.115c-75.334 0-121.302-83.048-81.408-146.88l50.822-81.388-40.725-25.448c-12.081-7.547-8.966-25.961 4.879-29.158l110.237-25.45c8.611-1.988 17.201 3.381 19.189 11.99l25.452 110.237zm98.561-182.915l41.289 66.076-40.74 25.457c-12.051 7.528-9 25.953 4.879 29.158l110.237 25.45c8.672 1.999 17.215-3.438 19.189-11.99l25.45-110.237c3.197-13.844-11.99-24.719-24.068-17.168l-40.687 25.424-41.263-66.082c-37.521-60.033-125.209-60.171-162.816 0l-17.963 28.766c-3.51 5.62-1.8 13.021 3.82 16.533l33.919 21.195c5.62 3.512 13.024 1.803 16.536-3.817l17.961-28.743c12.712-20.341 41.973-19.676 54.257-.022zM497.288 301.12l-27.515-44.065c-3.511-5.623-10.916-7.334-16.538-3.821l-33.861 21.159c-5.62 3.512-7.33 10.915-3.818 16.536l27.564 44.112c13.257 21.211-2.057 48.96-27.136 48.96H320V336.02c0-14.213-17.242-21.383-27.313-11.313l-80 79.981c-6.249 6.248-6.249 16.379 0 22.627l80 79.989C302.689 517.308 320 510.3 320 495.989V448h95.88c75.274 0 121.335-82.997 81.408-146.88z"},child:[]}]})(o)}function FaSpinner(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(o)}const SECONDS=10;function Countdown(){const[o,n]=React.useState(SECONDS),[r,a]=React.useState(!1);React.useEffect(()=>{if(r&&o>0){const u=setTimeout(()=>{n(o-.1)},100);return()=>clearTimeout(u)}else o<=0&&(a(!1),n(SECONDS))},[r,o]);const i=()=>{a(!0),n(SECONDS)};React.useEffect(()=>{o===SECONDS&&i()},[o]);const l=18,c=2*Math.PI*l,d=c*(1-(SECONDS-o)/SECONDS);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{className:"h-full w-full",viewBox:"0 0 40 40",children:[jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-gray-300",strokeWidth:"4",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-blue-600",strokeWidth:"4",strokeDasharray:c,strokeDashoffset:d,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-semibold",children:" "})})]})}const AskAIStyles=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),d=React.useRef(null),u=React.useRef(null),[x,m]=React.useState();React.useEffect(()=>{var g;(g=d.current)==null||g.focus()},[]);const p=g=>{const{usage:R}=g||{};!i&&R&&m(R),u.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"mb-1 text-sm font-semibold leading-none tracking-tight",children:n("ask_ai")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:d,value:l,onChange:g=>c(g.target.value),placeholder:n("ask_ai_to_edit_styles"),className:"w-full border border-border focus:border-0",rows:3,onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,p))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,p)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("generating_please_wait")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})})]})},fuse=new Fuse(ALL_TW_CLASSES,{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]});function ManualClasses(){var S;const{t:o}=reactI18next.useTranslation(),[n]=useSelectedStylingBlocks(),r=useSelectedBlock(),a=useAddClassesToBlocks(),i=useRemoveClassesFromBlocks(),[l]=useSelectedBlockIds(),c=useBuilderProp("askAiCallBack",null),[d,u]=React.useState(""),{toast:x}=contextMenu.useToast(),m=(S=lodashEs.first(n))==null?void 0:S.prop,p=lodashEs.reject((lodashEs.get(r,m,"").replace(STRINGS.STYLES_KEY,"").split(",").pop()||"").split(" "),lodashEs.isEmpty),g=()=>{const A=d.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");a(l,A,!0),u("")},[R,h]=React.useState([]),f=({value:A})=>{const T=A.trim().toLowerCase(),I=T.match(/.+:/g);let j=[];if(I&&I.length>0){const[E]=I,k=T.replace(E,"");j=fuse.search(k).map(B=>({...B,item:{...B.item,name:E+B.item.name}}))}else j=fuse.search(T);return h(lodashEs.map(j,"item"))},b=()=>{h([])},C=A=>A.name,_=A=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md p-1",children:A.name}),w={autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:o("enter_classes_separated_by_space"),value:d,onKeyDown:A=>{A.key==="Enter"&&d.trim()!==""&&g()},onChange:(A,{newValue:T})=>u(T),className:"w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"},v=()=>{if(navigator.clipboard===void 0){x({title:o("clipboard_not_supported"),description:o("please_use_chrome_firefox_or_safari"),variant:"destructive"});return}navigator.clipboard.writeText(p.join(" ")),x({title:o("copied"),description:o("classes_copied_to_clipboard")})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`flex ${R.length>0?"min-h-[300px]":"min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("classes")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{onClick:v,className:"cursor-pointer"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("copy_classes_to_clipboard")})})]})]}),c?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"h-6 w-fit",size:"sm",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"ml-2",children:o("Ask AI")})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"left",className:"p-2",children:jsxRuntime.jsxRuntimeExports.jsx(AskAIStyles,{blockId:r==null?void 0:r._id})})]}):null]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex items-center gap-x-3",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx(Autosuggest,{suggestions:R,onSuggestionsFetchRequested:f,onSuggestionsClearRequested:b,getSuggestionValue:C,renderSuggestion:_,inputProps:w,containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border"},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.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",className:"h-6 border-border",onClick:g,disabled:d.trim()==="",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:React__namespace.Children.toArray(p.map(A=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[A,jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{onClick:()=>i(l,[A]),className:"invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"})]},A)))})]})}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},{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 EDITOR_ICONS={"not-italic":()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":reactIcons.Cross2Icon,fixed:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.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},StyleContext=React.createContext({canReset:!1,canChange:!0}),BlockStyleProvider=({children:o,canReset:n=!1,canChange:r=!0})=>jsxRuntime.jsxRuntimeExports.jsx(StyleContext.Provider,{value:{canReset:n,canChange:r},children:o}),DropDownChoices=({label:o,property:n,onChange:r})=>{const a=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${n}.classes`,[""]),[n]),i=useCurrentClassByProperty(n),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),{canChange:c}=React.useContext(StyleContext),d=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:o?"w-full rounded":"grow",children:d?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{className:"w-[70%] rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind arbitrary value."})]})]}):jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:o,onChange:u=>r(u,n),selected:l,options:a,disabled:!c})})};function DropDown({selected:o,onChange:n,rounded:r=!1,options:a,disabled:i=!1}){const l=o.replace(/.*:/g,"").trim(),{undo:c,redo:d}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("select",{disabled:!a.length||i,className:`${r?"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:u=>n(u.target.value),onKeyDown:u=>{u.ctrlKey&&(u.key==="z"&&c(),u.key==="y"&&d())},value:l,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:""}),React.Children.toArray(a.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:u,children:u})))]})}const RangeChoices=({property:o,onChange:n})=>{const{canReset:r,canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),c=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),d=c.indexOf(l)>-1?c.indexOf(l):0,u=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:u?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"py-[5px] px-2",children:l}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"box-border w-2/12 rounded-tl rounded-bl bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d-1<0),onClick:()=>n(lodashEs.nth(c,d-1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MinusIcon,{className:!a&&(!r||d-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-8/12 text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:!1,property:o,onChange:n})}),jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"w-2/12 rounded-tr rounded-br bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d+1>=c.length),onClick:()=>n(lodashEs.nth(c,d+1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{className:!a&&(!r||d+1>=c.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})},IconChoices=({property:o,onChange:n})=>{const r=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),{canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex grow flex-wrap gap-1",children:lodashEs.map(r,c=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",disabled:!a,onClick:()=>n(c,o),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${l===c?"bg-blue-500 text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:React.createElement(lodashEs.get(EDITOR_ICONS,c,reactIcons.BoxIcon))})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(c))})]}))})},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:o,onChange:n})=>{const r=useCurrentClassByProperty(o),a=React.useMemo(()=>lodashEs.get(r,"cls",""),[r]),{canChange:i}=React.useContext(StyleContext),[l,c]=React.useState([]),[d,u]=React.useState({color:"",shade:""}),x=a.split("-"),m=lodashEs.get(x,"1",""),p=lodashEs.get(x,"2",""),g=React.useCallback(h=>{["current","inherit","transparent","black","white"].includes(h)?(c([]),u({color:h})):(c(["50","100","200","300","400","500","600","700","800","900"]),u(f=>({...f,color:h,shade:f.shade?f.shade:"500"})))},[c,u]);React.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(m))return c([]);c(["50","100","200","300","400","500","600","700","800","900"])},[m]);const R=React.useCallback(h=>{u({color:m,shade:h})},[m]);return React.useEffect(()=>{u({color:"",shade:""})},[r]),React.useEffect(()=>{const f=`${lodashEs.get(COLOR_PROP,o,"")}-${d.color}${d.shade?`-${d.shade}`:""}`;f.match(new RegExp(lodashEs.get(CLASSES_LIST,`${o}.regExp`,"")))&&n(f,o)},[d,n,o]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{disabled:!i,rounded:!0,selected:m,onChange:g,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.jsxRuntimeExports.jsx("button",{type:"button",className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:!0,selected:p,disabled:!m||!i,onChange:R,options:l})})]})},getUserInputValues=(o,n)=>{o=o.toLowerCase();let r=o.trim().replace(/ |\+/g,"");if((r==="auto"||r==="none")&&n.includes(r))return{value:"",unit:r};const a=n.length?new RegExp(n.join("|"),"g"):/XXXXXX/g;r=r.replace(a,"");const i=o.match(a),l=i&&i.length>1,c=!lodashEs.isEmpty(r)&&Number.isNaN(Number(r));return l||c?{error:"Invalid value"}:i&&(i[0]==="auto"||i[0]==="none")?{value:i[0],unit:""}:{value:r,unit:i?i[0]:""}},getTwClassValue=o=>{const n=o.startsWith("-")?"-":"",r=o.split("-").pop();if(["auto","none"].includes(r))return{value:"",unit:r};if(r==="px")return{value:"1",unit:"px"};if(r==="screen")return{value:"100",unit:o.indexOf("w-")!==-1?"vw":"vh"};if(r==="full")return{value:"100",unit:"%"};if(lodashEs.includes(o,"skew-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"rotate-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"opacity-"))return{value:`${r/100}`,unit:"-"};if(lodashEs.includes(o,"duration-")||lodashEs.includes(o,"delay-"))return{value:`${r}`,unit:"ms"};if(lodashEs.includes(o,"translate-")&&!r.includes("/"))return{value:`${n}${`${r/4}`}`,unit:"rem"};if(lodashEs.includes(o,"scale-"))return{value:`${n}${`${r/100}`}`,unit:"-"};if(lodashEs.startsWith(o,"border")){const a=o.match(/border-?(x|y|t|r|b|l)?\d+/g);if(a)return{value:a[0].split("-").pop(),unit:"px"};if(o.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(lodashEs.startsWith(o,"max-w-")){if(o==="max-w-screen-sm")return{value:"640",unit:"px"};if(o==="max-w-screen-md")return{value:"768",unit:"px"};if(o==="max-w-screen-lg")return{value:"1024",unit:"px"};if(o==="max-w-screen-xl")return{value:"1280",unit:"px"};if(o==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(r==="xs")return{value:"320",unit:"px"};if(r==="sm")return{value:"384",unit:"px"};if(r==="md")return{value:"448",unit:"px"};if(r==="lg")return{value:"512",unit:"px"};if(r==="xl")return{value:"576",unit:"px"};if(r==="2xl")return{value:"672",unit:"px"};if(r==="3xl")return{value:"768",unit:"px"};if(r==="4xl")return{value:"896",unit:"px"};if(r==="5xl")return{value:"1024",unit:"px"};if(r==="6xl")return{value:"1152",unit:"px"};if(r==="7xl")return{value:"1280",unit:"px"};if(r==="prose")return{value:"65",unit:"ch"}}if(lodashEs.startsWith(o,"text-")){if(r==="xs")return{value:"12",unit:"px"};if(r==="sm")return{value:"14",unit:"px"};if(r==="base")return{value:"16",unit:"px"};if(r==="lg")return{value:"18",unit:"px"};if(r==="xl")return{value:"20",unit:"px"};if(r==="2xl")return{value:"24",unit:"px"};if(r==="3xl")return{value:"30",unit:"px"};if(r==="4xl")return{value:"36",unit:"px"};if(r==="5xl")return{value:"48",unit:"px"};if(r==="6xl")return{value:"60",unit:"px"};if(r==="7xl")return{value:"72",unit:"px"};if(r==="8xl")return{value:"96",unit:"px"};if(r==="9xl")return{value:"128",unit:"px"}}if(lodashEs.startsWith(o,"leading-")){if(r==="none")return{value:"1",unit:"-"};if(r==="tight")return{value:"1.25",unit:"-"};if(r==="snug")return{value:"1.375",unit:"-"};if(r==="normal")return{value:"1.5",unit:"-"};if(r==="relaxed")return{value:"1.625",unit:"-"};if(r==="loose")return{value:"2",unit:"-"}}if(lodashEs.startsWith(o,"tracking-")){if(r==="tighter")return{value:"-0.05",unit:"em"};if(r==="tight")return{value:"-0.025",unit:"em"};if(r==="normal")return{value:"0",unit:"em"};if(r==="wide")return{value:"0.025",unit:"em"};if(r==="wider")return{value:"0.05",unit:"em"};if(r==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(r))return{value:o,unit:"class"};if(r.includes("/")){const[a,i]=lodashEs.map(r.split("/"),l=>parseInt(l,10));return{value:n+(a/i*100).toFixed(2).replace(".00",""),unit:"%"}}return lodashEs.isNumber(parseFloat(r))?{value:`${n+parseFloat(r)*4}`,unit:"px"}:{value:r,unit:"class"}},getClassValueAndUnit=o=>{if(lodashEs.isEmpty(o))return{value:"",unit:""};const n=o.match(/\[.*\]/g);if(n===null)return getValueAndUnitForTWClass(o);const r=lodashEs.get(n,"0","").replace(/\[|\]/g,""),a=o.startsWith("-")?"-":"",i=lodashEs.first(r.match(/\d+.\d+|\d+/g));return{value:`${a}${i}`,unit:r.replace(i,"")}},getValueAndUnitForTWClass=o=>lodashEs.isEmpty(o)?{value:"",unit:""}:getTwClassValue(o),BlockSettingsContext=React.createContext({setDragData:()=>{}}),DragStyleButton=({unit:o,currentValue:n,onDrag:r,onDragEnd:a,onDragStart:i,negative:l,cssProperty:c})=>{const{setDragData:d}=React.useContext(BlockSettingsContext);return jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onMouseDown:u=>{const x={onDrag:r,onDragEnd:a,dragging:!0,dragStartY:u.pageY,dragStartValue:`${n}`,dragUnit:o,negative:l,cssProperty:c};i(x),d(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.jsxRuntimeExports.jsx(reactIcons.RowSpacingIcon,{})})},UnitSelection=({onSelect:o,current:n,units:r})=>jsxRuntime.jsxRuntimeExports.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:r.map(a=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:n===a?"primary":void 0,size:"sm",onClick:i=>{i.stopPropagation(),o(a)},children:a},a))}),THROTTLE_TIME=50,AdvanceChoices=o=>{const[n,r]=React.useState(!1),[a,i]=React.useState(""),{currentClass:l,onChange:c,classPrefix:d,cssProperty:u,units:x,negative:m}=o,[p,g]=React.useState(u!=null&&u.toLowerCase().includes("width")?"%":x[0]),[R,h]=React.useState(!1),[f,b]=React.useState(""),[C,_]=React.useState(!1),[w,v]=React.useState(!1);React.useEffect(()=>{const{value:j,unit:E}=getClassValueAndUnit(l);if(E===""){i(j),g(u!=null&&u.toLowerCase().includes("width")?"%":lodashEs.first(x));return}g(E),i(E==="class"||lodashEs.isEmpty(j)?"":j)},[l,u,x]);const S=web.useThrottledCallback(j=>c(j),[c],THROTTLE_TIME),A=web.useThrottledCallback(j=>c(j,!1),[c],THROTTLE_TIME),T=React.useCallback((j=!1)=>{const E=getUserInputValues(`${a}`,x);if(lodashEs.get(E,"error",!1)){h(!0);return}const k=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):p;if(k==="auto"||k==="none"){S(`${d}${k}`);return}if(lodashEs.get(E,"value")==="")return;const B=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(E,"value","").replace("-","")}${k==="-"?"":k}]`;j?A(B):S(B)},[S,A,a,p,d,x]),I=React.useCallback(j=>{const E=getUserInputValues(`${a}`,x);if(lodashEs.get(E,"error",!1)){h(!0);return}if(j==="auto"||j==="none"){S(`${d}${j}`);return}if(lodashEs.get(E,"value")==="")return;const k=lodashEs.get(E,"unit")!==""?lodashEs.get(E,"unit"):j,B=`${lodashEs.get(E,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(E,"value","").replace("-","")}${k==="-"?"":k}]`;S(B)},[S,a,d,x]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-start",children:p==="class"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("input",{className:"w-20 rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind preset class."})]})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`group relative flex items-center ${C?"z-auto":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(p)!==-1?null:jsxRuntime.jsxRuntimeExports.jsx("input",{readOnly:p==="class",onKeyPress:j=>{j.key==="Enter"&&T()},onKeyDown:j=>{if(j.keyCode!==38&&j.keyCode!==40)return;j.preventDefault(),v(!0);const E=lodashEs.parseInt(j.target.value);let k=lodashEs.isNaN(E)?0:E;j.keyCode===38&&(k+=1),j.keyCode===40&&(k-=1);const y=`${k}`,N=`${y.startsWith("-")?"-":""}${d}[${y.replace("-","")}${p==="-"?"":p}]`;A(N)},onKeyUp:j=>{w&&(j.preventDefault(),v(!1))},onBlur:()=>T(),onChange:j=>{h(!1),i(j.target.value)},onClick:j=>{var E;(E=j==null?void 0:j.target)==null||E.select(),r(!1)},value:C?f:a,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",R?"border-red-500 text-red-500":"border-foreground/20")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{open:n,delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>r(!n),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.jsxRuntimeExports.jsx("span",{className:`inline-block ${x.length===1?"px-2 font-semibold":""}`,children:p}),x.length>1?jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleDownIcon,{}):null]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipPortal,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"bg-background",children:jsxRuntime.jsxRuntimeExports.jsx(UnitSelection,{units:x,current:p,onSelect:j=>{r(!1),g(j),I(j)}})})})]})]}),["none","auto"].indexOf(p)!==-1||C?null:jsxRuntime.jsxRuntimeExports.jsx(DragStyleButton,{onDragStart:()=>_(!0),onDragEnd:j=>{if(b(()=>""),_(!1),lodashEs.isEmpty(j))return;const E=`${j}`,y=`${E.startsWith("-")?"-":""}${d}[${E.replace("-","")}${p==="-"?"":p}]`;S(y)},onDrag:j=>{if(lodashEs.isEmpty(j))return;b(j);const E=`${j}`,y=`${E.startsWith("-")?"-":""}${d}[${E.replace("-","")}${p==="-"?"":p}]`;A(y)},currentValue:a,unit:p,negative:m,cssProperty:u})]})})})},useCurrentClassByProperty=o=>{const n=useSelectedBlockCurrentClasses();return lodashEs.findLast(n,{property:o})},canChangeClass=(o,n)=>{const r={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return r[lodashEs.get(o,"mq","xs")]<=r[n]},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=o=>`${o.toUpperCase()} ${BREAKPOINTS[o]?`(${BREAKPOINTS[o]} & up)`:""}`,BlockStyle=o=>{const{t:n}=reactI18next.useTranslation(),{type:r="icons",label:a,property:i,onEmitChange:l=()=>{},units:c,negative:d=!1}=o,[u]=useDarkMode(),[x]=useStylingState(),[,m]=useCanvasWidth(),p=useCurrentClassByProperty(i),g=useAddClassesToBlocks(),R=useRemoveClassesFromBlocks(),[h]=useSelectedBlockIds(),f=React.useMemo(()=>lodashEs.get(p,"fullCls",""),[p]),b=React.useCallback((A,T=!0)=>{const I={dark:u,mq:m,mod:x,cls:A,property:i,fullCls:""};(u||x!=="")&&(I.mq="xs");const j=generateFullClsName(I);g(h,[j],T)},[h,u,m,x,i,g]),C=React.useCallback(()=>{R(h,[f])},[h,f,R]),_=React.useMemo(()=>canChangeClass(p,m),[p,m]);React.useEffect(()=>{l(_,p)},[_,l,p]);const[,,w]=useCanvasWidth(),v=React.useCallback(A=>{w({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[A])},[w]),S=lodashEs.get(p,"dark",null)===u&&lodashEs.get(p,"mod",null)===x&&lodashEs.get(p,"mq",null)===m;return jsxRuntime.jsxRuntimeExports.jsx(BlockStyleProvider,{canChange:_,canReset:p&&S,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`text-[11px] ${p&&!S?"text-foreground":""}`,children:n(a)})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-[150px]",children:[r==="arbitrary"?jsxRuntime.jsxRuntimeExports.jsx(AdvanceChoices,{currentClass:lodashEs.get(p,"cls",""),classPrefix:lodashEs.get(CLASS_PREFIXES,i,""),units:c||[],onChange:b,negative:d,cssProperty:i}):null,r==="icons"&&jsxRuntime.jsxRuntimeExports.jsx(IconChoices,{property:i,onChange:b}),r==="range"&&jsxRuntime.jsxRuntimeExports.jsx(RangeChoices,{property:i,onChange:b}),r==="color"&&jsxRuntime.jsxRuntimeExports.jsx(ColorChoice,{property:i,onChange:b}),r==="dropdown"&&jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:a,property:i,onChange:b})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:`w-[30px] cursor-pointer ${f?"visible":"invisible"}`,children:S?jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>C(),title:"Reset",className:"flex px-1.5 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):_&&p?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-right",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:["Current style is set at  ",jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"font-bold",children:[getBreakpoint(lodashEs.get(p,"mq")),u&&!p.dark?"(Light mode)":""]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>v(lodashEs.get(p,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",lodashEs.get(p,"mq").toUpperCase()]})]})})})]}):null})]})]})})},basicUnits=["px","%","em","rem","ch","vh","vw"],MultipleChoices=({label:o,options:n,borderB:r=!1,borderT:a=!1,type:i="arbitrary",units:l=basicUnits,negative:c=!1})=>{const{t:d}=reactI18next.useTranslation(),[u,x]=React.useState(n[0].key),m=useSelectedBlockCurrentClasses(),p=React.useCallback(g=>lodashEs.map(m,"property").includes(g),[m]);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${r?"border-b":""} ${a?"border-t":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row text-xs",children:[o&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:React.Children.toArray(n.map(({label:g,key:R})=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"first:rounded-l last:rounded-r",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>x(R),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${R===u?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[React.createElement("div",{className:p(R)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),React.createElement(lodashEs.get(EDITOR_ICONS,R,reactIcons.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(g))})]})})))})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-0 flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{type:i,units:[...l],label:"",property:u,negative:c})})]})},NestedOptions=({heading:o,items:n})=>{const{t:r}=reactI18next.useTranslation(),a=useSelectedBlockCurrentClasses(),i=React.useMemo(()=>{const l=u=>lodashEs.flatten(u.map(x=>x.styleType==="multiple"?lodashEs.map(x.options,"key"):x.property)),c=lodashEs.flatten(n.map(u=>u.styleType==="accordion"?l(u.items):u.styleType==="multiple"?lodashEs.map(u.options,"key"):u.property)),d=lodashEs.map(a,"property");return lodashEs.intersection(c,d).length>0},[a,n]);return jsxRuntime.jsxRuntimeExports.jsxs("details",{children:[jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{className:"inline",children:[r(o.toLowerCase()),i?jsxRuntime.jsxRuntimeExports.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${i?"bg-blue-500":"bg-gray-300"}`}):null]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-2",children:n.map(l=>l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label))})]})},SectionContext=React.createContext({}),StylingGroup=({section:o})=>{const{t:n}=reactI18next.useTranslation(),r=useSelectedBlockCurrentClasses(),a=React.useCallback((l=[])=>{const c={};for(let u=0;u<r.length;u++)c[r[u].property]=r[u].cls;let d=!0;for(const u in l)if(!lodashEs.has(c,u)||c[u]!==l[u]){d=!1;break}return d},[r]),i=React.useMemo(()=>({}),[]);return jsxRuntime.jsxRuntimeExports.jsx(SectionContext.Provider,{value:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:o.heading,className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"border-b border-border py-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-x-2 text-sm font-bold",children:n(o.heading)})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"py-2",children:React.Children.toArray(o.items.map(l=>lodashEs.has(l,"component")?React.createElement(l.component,{key:l.label}):lodashEs.has(l,"styleType")?l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):l.styleType==="accordion"&&a(l==null?void 0:l.conditions)?jsxRuntime.jsxRuntimeExports.jsx(NestedOptions,{...l},l.label):null:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label)))})]})})},StylingHelpers=()=>{const o=useSelectedBlock(),[n]=useSelectedStylingBlocks(),{t:r}=reactI18next.useTranslation(),a=runtime.useGlobalStylingPresets(),i=useAddClassesToBlocks(),l=runtime.getBlockComponent(o._type),c=lodashEs.get(lodashEs.first(n),"prop"),d=lodashEs.get(l.props,`${c}.presets`,{});if(lodashEs.isEmpty(a)&&(!lodashEs.has(l,"props")||lodashEs.isEmpty(d)))return null;const u=x=>{const m=x.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");i([o._id],m,!0)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-10",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"px-4",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"w-full",size:"sm",children:[r("Apply Presets"),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretDownIcon,{})]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuContent,{className:"max-h-80 w-56",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{className:"no-scrollbar h-full",children:[lodashEs.isEmpty(d)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuLabel,{children:[l.type," ",r("presets")]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(d).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(d[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]}),lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:r("Global presets")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(a).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(a[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]})]})})]})})},MAPPER={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function BlockStyling(){const{flexChild:o,gridChild:n}=useSelectedBlocksDisplayChild(),[r]=useSelectedStylingBlocks(),[a,i]=React.useState(""),[l,c]=React.useState({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),d=web.useThrottledCallback(x=>{const m=!lodashEs.get(l,"negative",!1),p=lodashEs.get(l,"cssProperty","");let g=parseFloat(l.dragStartValue);g=isNaN(g)?0:g;let R=MAPPER[l.dragUnit];(lodashEs.startsWith(p,"scale")||p==="opacity")&&(R=10);let f=(l.dragStartY-x.pageY)/R+g;m&&f<0&&(f=0),p==="opacity"&&f>1&&(f=1),l.onDrag(`${f}`),i(`${f}`)},[l],50),u=React.useCallback(()=>{setTimeout(()=>l.onDragEnd(`${a}`),100),c({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[l,a,c]);return lodashEs.isEmpty(r)?null:jsxRuntime.jsxRuntimeExports.jsxs(BlockSettingsContext.Provider,{value:{setDragData:c},children:[l.dragging?jsxRuntime.jsxRuntimeExports.jsx("div",{onMouseMove:d,onMouseUp:()=>u(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(StylingHelpers,{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[o&&jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:FLEX_CHILD_SECTION}),n?jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:GRID_CHILD_SECTION}):null,SETTINGS_SECTIONS.map(x=>jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:x},x.heading))]})]})]})}const ChaiSelect=({defaultValue:o="",onValueChange:n,options:r,placeholder:a="Select",className:i=""})=>{const[l,c]=React.useState(o),d=u=>{const x=u.target.value;c(x),n(x)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("relative inline-block w-full",i),children:jsxRuntime.jsxRuntimeExports.jsxs("select",{className:"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",value:l,onChange:d,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:a}),r.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:u.value,children:u.label},u.value))]})})},ChaiSelect$1=ChaiSelect;function UILibrariesSelect({uiLibraries:o,library:n,setLibrary:r}){const{t:a}=reactI18next.useTranslation();return n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"h-12",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs font-bold text-gray-500",children:a("choose_library")}),jsxRuntime.jsxRuntimeExports.jsx(ChaiSelect$1,{className:"mt-1",options:o.map(i=>({value:i.uuid,label:i.name})),defaultValue:n,onValueChange:i=>r(i)})]}):null}const BlockCard=({block:o,library:n,parentId:r=void 0})=>{const[a,i]=React.useState(!1),l=useBuilderProp("getUILibraryBlock",lodashEs.noop),{addCoreBlock:c,addPredefinedBlock:d}=useAddBlock(),[,u]=useSelectedBlockIds(),[,x]=useHighlightBlockId(),m=lodashEs.get(o,"name",lodashEs.get(o,"label")),p=flagged.useFeature("dnd"),[,g]=jotai.useAtom(draggedBlockAtom),R=b=>{const C=lodashEs.has(b,"styles_attrs.data-page-section");return b._type==="Box"&&C},h=React.useCallback(async b=>{if(b.stopPropagation(),lodashEs.has(o,"component")){c(o,r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK});return}i(!0);const C=await l(n,o);lodashEs.isEmpty(C)||d(runtime.syncBlocksWithDefaults(C),r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},[o]),f=async b=>{const C=await l(n,o);let _=r;if(R(lodashEs.first(C))&&(_=null),!lodashEs.isEmpty(C)){const w={blocks:C,uiLibrary:!0,parent:_};if(b.dataTransfer.setData("text/plain",JSON.stringify(w)),o.preview){const v=new Image;v.src=o.preview,v.onload=()=>{b.dataTransfer.setDragImage(v,0,0)}}else b.dataTransfer.setDragImage(new Image,0,0);g(w),setTimeout(()=>{u([]),x(null),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},200)}};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:a?()=>{}:h,draggable:p?"true":"false",onDragStart:f,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:[a&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"animate-spin",size:15,color:"white"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),o.preview?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o.preview,className:"min-h-[45px] w-full rounded-md",alt:m}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border bg-gray-200",children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:m})})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:m})})]})},libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=o=>{const[n,r]=jotai.useAtom(libraryBlocksAtom),a=useBuilderProp("getUILibraryBlocks",lodashEs.noop),i=lodashEs.get(n,`${o==null?void 0:o.uuid}.blocks`,null),l=lodashEs.get(n,`${o==null?void 0:o.uuid}.loading`,"idle"),c=React.useRef("idle");return React.useEffect(()=>{(async()=>{if(l==="complete"||c.current==="loading")return;c.current="loading",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"loading",blocks:[]}}));const d=await a(o);c.current="idle",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"complete",blocks:d||[]}}))})()},[o,i,l,c]),{data:i||[],isLoading:l==="loading"}},UILibrarySection=({parentId:o})=>{const[n,r]=jotai.useAtom(selectedLibraryAtom),a=useBuilderProp("uiLibraries",[]),i=runtime.useChaiBlocks(),l=lodashEs.values(i).filter(_=>_.category==="custom"),c=a.find(_=>_.uuid===n)||lodashEs.first(a),{data:d,isLoading:u}=useLibraryBlocks(c),x=lodashEs.groupBy([...d,...l],"group"),[m,p]=React.useState("Hero"),g=lodashEs.get(x,m,[]),R=React.useRef(null),{t:h}=reactI18next.useTranslation(),f=_=>{R.current&&(clearTimeout(R.current),R.current=null),R.current=setTimeout(()=>{R.current&&p(_)},300)};if(u)return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-3 h-full"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-9 h-full"})]});const b=lodashEs.filter(g,(_,w)=>w%2===0),C=lodashEs.filter(g,(_,w)=>w%2===1);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative mt-2 flex h-full max-h-full overflow-hidden bg-background",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full pt-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2",children:[jsxRuntime.jsxRuntimeExports.jsx(UILibrariesSelect,{library:c==null?void 0:c.uuid,setLibrary:r,uiLibraries:a}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-bold text-gray-500",children:h("groups")}),jsxRuntime.jsxRuntimeExports.jsx("hr",{className:"mt-1 border-border"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20",children:React.Children.toArray(lodashEs.map(x,(_,w)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>f(w),onMouseLeave:()=>clearTimeout(R.current),onClick:()=>p(w),className:iconBase.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",w===m?"bg-blue-500 text-white hover:bg-blue-600":""),children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:lodashEs.capitalize(h(w.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},w)))})]})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{onMouseEnter:()=>R.current?clearTimeout(R.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.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-2 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(b.map(_=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:_,library:c})))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(C.map(_=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:_,library:c})))})]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})]})})})},UILibrariesPanel=({parentId:o})=>jsxRuntime.jsxRuntimeExports.jsx(UILibrarySection,{parentId:o}),UILibraries=UILibrariesPanel,add_block="Add block",enter_paste_tailwind_html="(Enter or paste TailwindCSS HTML snippet)",click_to_add_block="(Click to add block to page)",core="Core",custom_blocks="Custom Blocks",ui_library="UI Library",html_snippet_description="Use HTML snippets from Tailwind CSS component libraries etc. or just copy paste your own HTML code.",tailwind_html_snippet="Tailwind HTML snippet:",enter_code_snippet="Enter your code snippet here...",import_html="Import HTML",note_imported_html="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",tree_view_no_blocks="This page has no blocks. Add a block by clicking the + button",canvas_empty="This page is empty",no_block_selected_for_styling="Please select a block to edit settings or styles",no_block_selected_for_ask_ai="Please select a block to ask AI",no_styling_block_selected="Please select a styling block",drop_here_message="Drop your block here",use_setting="Use setting",mobile_xs_title="Mobile (XS)",mobile_xs_content="Styles set here are applied to all screen unless edited at higher breakpoint",mobile_sm_title="Mobile landscape (SM)",mobile_sm_content="Styles set here are applied at 640px and up unless edited at higher breakpoint",tablet_md_title="Tablet (MD)",tablet_md_content="Styles set here are applied at 768px and up",tablet_lg_title="Tablet Landscape (LG)",tablet_lg_content="Styles set here are applied at 1024px and up unless edited at higher breakpoint",desktop_xl_title="Desktop (XL)",desktop_xl_content="Styles set here are applied at 1280px and up unless edited at higher breakpoint",large_desktop_2xl_title="Large Desktop (2XL)",large_desktop_2xl_content="Styles set here are applied at 1536px and up",Breakpoints$1="Breakpoints",clear="Clear",clear_canvas_title="Clear whole canvas?",clear_canvas_description="Are you sure you want to clear the whole canvas?",cancel="Cancel",yes="Yes",preview="Preview",settings="Settings",styling="Styling",data_provider="Data Provider",remove_provider_confirmation="Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?",remove_provider_warning="Your data provider will be removed from this page and all added data binding will be not visible on blocks.",remove="Remove",no_data_providers="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_provider="Select a provider",choose="Choose",page_data_providers="Page data providers:",view_data="View Data",mark_as_global="Mark as Global",global_block_note="Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.",global_block_indicator="Global blocks are indicated with",global_block_category="Global blocks are available under 'Global' category",enter_global_block_name="Enter global block name",eg_header_footer="Eg: Header, Footer",blocks_selected="{{length}} blocks selected.",cut="Cut",copy="Copy",clear_selection="Clear Selection",dev_mode_message="This is dev mode. Visit",to_see_page_preview="to see page preview",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"},ai_assistant="AI Assistant",close_preview="Close Preview",saved="Saved",unsaved="Unsaved",saving="Saving...",page_is_empty="This page is empty.",Theme="Theme",Outline="Outline",clipboard_not_supported="Not supported",please_use_chrome_firefox_or_safari="Please use Chrome, Firefox or Safari",classes_copied_to_clipboard="Classes copied to clipboard",download_complete="Download complete",copied="Copied",enter_classes_separated_by_space="Enter classes separated by space",copy_classes_to_clipboard="Copy classes to clipboard",classes="Classes",ask_ai="Ask AI",edit_with_ai="Edit with AI",generating_please_wait="Generating... Please wait",stop$1="Stop",eg_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",please_select_a_block_to_ask_ai="Select a block to edit with AI",please_select_a_block_to_edit="Please select a block to edit",edit="Edit",tell_about_this_page_eg_this_page_is_about="Describe this page. E.g.: This page is about...",tag="Tag",value="Value",background_image="Background Image",enter_image_url="Enter image URL",replace_image="Replace image",choose_image="Choose image",images="Images",typography="Typography",background="Background",library="Library",blocks="Blocks",basic="Basic",media="Media",advanced="Advanced",form="Form",choose_icon_or_enter_svg="Choose an icon or enter SVG",groups="Groups",ui_libraries="UI Libraries",accordions="Accordions",buttons="Buttons",layouts="Layouts",choose_library="Choose library",no_library_found="No library found.",faq="FAQ",hero="Hero",features="Features",footer="Footer",navbar="Navbar",icons="Icons",testimonials="Testimonials",blog="Blog",ai_quick_prompts={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:"Randomize"},sidebar={outline:"Outline",edit_block:"Edit Block",ai_assistant:"AI Assistant",theme:"Theme"},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.",lngEn={add_block,enter_paste_tailwind_html,click_to_add_block,core,custom_blocks,ui_library,import:"Import",html_snippet_description,tailwind_html_snippet,enter_code_snippet,import_html,note_imported_html,dark_mode,tree_view_no_blocks,canvas_empty,no_block_selected_for_styling,no_block_selected_for_ask_ai,no_styling_block_selected,drop_here_message,use_setting,mobile_xs_title,mobile_xs_content,mobile_sm_title,mobile_sm_content,tablet_md_title,tablet_md_content,tablet_lg_title,tablet_lg_content,desktop_xl_title,desktop_xl_content,large_desktop_2xl_title,large_desktop_2xl_content,Breakpoints:Breakpoints$1,clear,clear_canvas_title,clear_canvas_description,cancel,yes,preview,settings,styling,data_provider,remove_provider_confirmation,remove_provider_warning,remove,no_data_providers,learn_more,add_data_providers,select_provider,choose,page_data_providers,view_data,mark_as_global,global_block_note,global_block_indicator,global_block_category,enter_global_block_name,eg_header_footer,blocks_selected,cut,copy,delete:"Delete",clear_selection,dev_mode_message,to_see_page_preview,"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,ai_assistant,close_preview,saved,unsaved,saving,page_is_empty,Theme,Outline,clipboard_not_supported,please_use_chrome_firefox_or_safari,classes_copied_to_clipboard,download_complete,copied,enter_classes_separated_by_space,copy_classes_to_clipboard,classes,ask_ai,edit_with_ai,generating_please_wait,stop:stop$1,eg_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_content,ai_context,please_select_a_block_to_ask_ai,please_select_a_block_to_edit,edit,tell_about_this_page_eg_this_page_is_about,tag,value,background_image,enter_image_url,replace_image,choose_image,images,typography,background,library,blocks,basic,media,advanced,form,choose_icon_or_enter_svg,groups,ui_libraries,accordions,buttons,layouts,choose_library,no_library_found,faq,hero,features,footer,navbar,icons,testimonials,blog,ai_quick_prompts,sidebar,remove_context,yes_delete,ai_context_updated,you_can_now_ask_ai_to_edit_your_content};i18n.use(reactI18next.initReactI18next).init({resources:{en:{translation:lngEn}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const CoreBlock=({block:o,disabled:n,parentId:r})=>{const[,a]=jotai.useAtom(draggedBlockAtom),{type:i,icon:l,label:c}=o,{addCoreBlock:d,addPredefinedBlock:u}=useAddBlock(),[,x]=useSelectedBlockIds(),[,m]=useHighlightBlockId(),p=()=>{if(console.log("addBlockToPage",o,r),lodashEs.has(o,"blocks")){const h=lodashEs.isFunction(o.blocks)?o.blocks():o.blocks;u(runtime.syncBlocksWithDefaults(h),r||null)}else d(o,r||null);emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},g=flagged.useFeature("dnd"),{t:R}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{disabled:n,onClick:p,type:"button",onDragStart:h=>{h.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.omit(o,["component","icon"]))),h.dataTransfer.setDragImage(new Image,0,0),a(lodashEs.omit(o,["component","icon"])),setTimeout(()=>{x([]),m(null)},200)},draggable:g?"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(l||reactIcons.BoxIcon,{className:"w-4 h-4 mx-auto"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"truncate text-xs",children:lodashEs.capitalize(R(c||i))})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:R(c||i)})})]})})},DefaultChaiBlocks=({parentId:o,gridCols:n="grid-cols-2"})=>{const r=runtime.useChaiBlocks(),a=useBuilderProp("filterChaiBlock",()=>!0),i=lodashEs.filter(r,a),l=lodashEs.groupBy(i,"category"),c=lodashEs.uniq(lodashEs.map(l.core,"group"));return jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderBlocks,{gridCols:n,parentId:o,groups:c,blocks:l.core})},CORE_GROUPS=["basic","typography","media","layout","form","advanced","other"],ChaiBuilderBlocks=({groups:o,blocks:n,parentId:r,gridCols:a="grid-cols-4"})=>{var d;const{t:i}=reactI18next.useTranslation(),[l]=useBlocksStore(),c=(d=lodashEs.find(l,u=>u._id===r))==null?void 0:d._type;return React.Children.toArray(lodashEs.map(lodashEs.sortBy(o,u=>CORE_GROUPS.indexOf(u)===-1?99:CORE_GROUPS.indexOf(u)),u=>lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).length?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{type:"single",value:u,collapsible:!0,className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:u,className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline",children:lodashEs.capitalize(i(u.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"mx-auto max-w-xl p-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grid gap-2 "+a,children:React.Children.toArray(lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).map(x=>jsxRuntime.jsxRuntimeExports.jsx(CoreBlock,{parentId:r,block:x,disabled:!canAcceptChildBlock(c,x.type)||!canBeNestedInside(c,x.type)})))})})]})}):null))},addBlockTabAtom=atomWithStorage("__add_block_tab","library"),AddBlocksPanel=({className:o,showHeading:n=!0,parentId:r=void 0})=>{const{t:a}=reactI18next.useTranslation(),[i,l]=jotai.useAtom(addBlockTabAtom),[,c]=jotai.useAtom(showPredefinedBlockCategoryAtom),d=useBuilderProp("importHTMLSupport",!0);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full flex-col overflow-hidden",o),children:[n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:a("Add block")}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:a(i==="html"?"enter_paste_tailwind_html":"click_to_add_block")})]}):null,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Tabs,{onValueChange:u=>{c(""),l(u)},value:i,className:iconBase.cn("h-max"),children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"grid w-full "+(d?"grid-cols-3":"grid-cols-2"),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"library",children:a("library")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"core",children:a("blocks")}),d?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"html",children:a("import")}):null]})}),i==="core"&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ScrollArea,{className:"-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(DefaultChaiBlocks,{gridCols:"grid-cols-4",parentId:r})})}),i==="library"&&jsxRuntime.jsxRuntimeExports.jsx(UILibraries,{parentId:r}),i==="html"&&d?jsxRuntime.jsxRuntimeExports.jsx(ImportHTML$1,{parentId:r}):null]})},AddBlocksPanel$1=AddBlocksPanel,AddBlocksDialog=()=>{const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(""),[a,i]=React.useState(!1);return useChaiBuilderMsgListener(({name:l,data:c=void 0})=>{l===CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK&&(r(c==null?void 0:c._id),i(!0)),l===CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK&&(r(""),i(!1))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:a,onOpenChange:()=>a?i(!1):"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-5xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Add blocks")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>i(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(AddBlocksPanel$1,{parentId:n,showHeading:!1})})]})})};function FaCheck(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(o)}function FaFilePen(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V299.6l-94.7 94.7c-8.2 8.2-14 18.5-16.8 29.7l-15 60.1c-2.3 9.4-1.8 19 1.4 27.8H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128zM549.8 235.7l14.4 14.4c15.6 15.6 15.6 40.9 0 56.6l-29.4 29.4-71-71 29.4-29.4c15.6-15.6 40.9-15.6 56.6 0zM311.9 417L441.1 287.8l71 71L382.9 487.9c-4.1 4.1-9.2 7-14.9 8.4l-60.1 15c-5.5 1.4-11.2-.2-15.2-4.2s-5.6-9.7-4.2-15.2l15-60.1c1.4-5.6 4.3-10.8 8.4-14.9z"},child:[]}]})(o)}const QUICK_PROMPTS=[{name:"Improve writing",icon:FaFilePen,prompt:"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."},{name:"Replace placeholder content",icon:FaRecycle,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:o}){const{loading:n}=useAskAi(),{t:r}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx("div",{className:n?"pointer-events-none opacity-50":"",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{className:"space-y-2",children:QUICK_PROMPTS.map(({name:a,icon:i,subMenus:l,prompt:c})=>l?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsx(i,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:a})]},a)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{children:jsxRuntime.jsxRuntimeExports.jsx("li",{children:"Happy"})})})]}):jsxRuntime.jsxRuntimeExports.jsxs("li",{onClick:()=>o(c),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.jsxRuntimeExports.jsx(i,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r(a)})]},a))})})}const AIUserPrompt=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),[d,u]=React.useState(!0),[x,m]=React.useState(),p=React.useRef(null),g=React.useRef(null);React.useEffect(()=>{var h;(h=p.current)==null||h.focus()},[]);const R=h=>{const{usage:f}=h||{};!i&&f&&m(f),g.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>u(!d),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:n("Ask AI")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(d?"rotate-180":"")})})]}),d&&o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:p,value:l,onChange:h=>c(h.target.value),placeholder:n("Ask AI to edit content"),className:"w-full",rows:3,onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),g.current&&clearTimeout(g.current),m(void 0),r("content",o,l,R))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{g.current&&clearTimeout(g.current),m(void 0),r("content",o,l,R)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("Generating... Please wait...")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("Stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(QuickPrompts,{onClick:h=>{g.current&&clearTimeout(g.current),m(void 0),r("content",o,h,R)}})]}):d?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"mx-auto text-3xl text-muted-foreground"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("Please select a block to Ask AI")})]})}):null]})},AISetContext=()=>{const{t:o}=reactI18next.useTranslation(),n=useBuilderProp("aiContext",""),[r,a]=React.useState(n),i=React.useRef(null),l=useBuilderProp("saveAiContextCallback",lodashEs.noop),[c,d]=React.useState(!1),[u,x]=React.useState(null),[,m]=React.useState(!1),{toast:p}=contextMenu.useToast(),g=React.useRef(null);React.useEffect(()=>{n&&a(n)},[n]);const R=async()=>{try{d(!0),x(null),await l(r),p({title:o("Updated AI Context"),description:o("You can now Ask AI to edit your content"),variant:"default"}),g.current.click()}catch(h){x(h)}finally{d(!1)}};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{onValueChange:h=>{m(h!=="")},type:"single",collapsible:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"set-context",className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{ref:g,className:"border-b border-border py-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-bold text-muted-foreground",children:o("AI Context")})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:i,value:r,onChange:h=>a(h.target.value),placeholder:o("Tell about this page eg this page is about"),className:"mt-1 w-full",rows:10,onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),R())}}),n.trim().length===0?jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mt-2 text-xs text-gray-500",children:o("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.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim().length<5,onClick:()=>R(),variant:"default",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Generating... Please wait...")]}):o("Save")}),n.trim().length>0?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:n.trim().length===0,variant:"ghost",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Generating... Please wait...")]}):o("Delete")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogTitle,{children:[o("Delete context")," ?"]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:()=>{a(""),R()},children:o("Yes, Delete")})]})]})]}):null]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 max-w-full",children:u&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})})]})]})})},AskAI=()=>{const[o]=useSelectedBlockIds();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AISetContext,{}),jsxRuntime.jsxRuntimeExports.jsx(AIUserPrompt,{blockId:lodashEs.first(o)})]})},AttrsEditor=React.memo(function o({preloadedAttributes:n=[],onAttributesChange:r}){const[a,i]=React.useState([]),[l,c]=React.useState(""),[d,u]=React.useState(""),[x,m]=React.useState(null),[p,g]=React.useState(""),R=React.useRef(null),h=React.useRef(null);React.useEffect(()=>{i(n)},[n]);const f=()=>{if(l.startsWith("@")){g("Attribute keys cannot start with '@'");return}if(l){const v=[...a,{key:l,value:d}];r(v),i(a),c(""),u(""),g("")}},b=v=>{const S=a.filter((A,T)=>T!==v);r(S),i(S)},C=v=>{m(v),c(a[v].key),u(a[v].value)},_=()=>{if(l.startsWith("@")){g("Attribute keys cannot start with '@'");return}if(x!==null&&l){const v=[...a];v[x]={key:l,value:d},r(v),i(v),m(null),c(""),u(""),g("")}},w=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),x!==null?_():f())};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs("form",{onSubmit:v=>{v.preventDefault(),x!==null?_():f()},className:"space-y-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrKey",className:"text-xs",children:"Key"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:R,value:l,onChange:v=>c(v.target.value),placeholder:"Key",className:"h-8 text-sm"})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrValue",className:"text-xs",children:"Value"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",rows:2,ref:h,value:d,onChange:v=>u(v.target.value),onKeyDown:w,placeholder:"Value",className:"bg-background text-sm"})]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",variant:"secondary",className:"h-8 w-fit text-sm",children:x!==null?"Save":"Add"}),p&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs text-red-500",children:p})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-4 space-y-1 overflow-y-auto",children:a.map((v,S)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between rounded bg-muted p-1.5 text-sm",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mr-2 flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"truncate font-semibold",children:v.key}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-wrap max-w-[200px] text-muted-foreground",children:v.value.toString()})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex-shrink-0",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(S),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Edit2,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Edit attribute"})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>b(S),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.X,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Remove attribute"})]})]})]},S))})]})}),BlockAttributesEditor=React__namespace.memo(()=>{const o=useSelectedBlock(),[n,r]=React.useState([]),[a]=useSelectedStylingBlocks(),i=useUpdateBlocksProps(),l=`${lodashEs.get(a,"0.prop")}_attrs`;React__namespace.useEffect(()=>{const d=lodashEs.map(lodashEs.get(o,l),(u,x)=>({key:x,value:u}));lodashEs.isEmpty(d)?r([]):r(d)},[lodashEs.get(o,l)]);const c=React__namespace.useCallback((d=[])=>{const u={};lodashEs.forEach(d,x=>{lodashEs.isEmpty(x.key)||lodashEs.set(u,x.key,x.value)}),i([lodashEs.get(o,"_id")],{[l]:u})},[o,i,l]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-col gap-y-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(AttrsEditor,{preloadedAttributes:n,onAttributesChange:c})})})})});function getDNDSupport(){return new URLSearchParams(window.location.search).has("dnd")}const FEATURE_TOGGLES={dnd:getDNDSupport()},UndoRedo=()=>{const{hasUndo:o,hasRedo:n,undo:r,redo:a}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!o(),size:"sm",onClick:r,className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!n(),onClick:a,size:"sm",className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function DarkMode(){const[o,n]=useDarkMode();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SunIcon,{className:"size-4 shrink-0"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"dark-mode-switch",checked:o,onCheckedChange:()=>{n(!o)},className:`${o?"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.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${o?"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.jsxRuntimeExports.jsx(FaMoon,{className:"size-4 ml-3 shrink-0"})]})}const TabletIcon=({landscape:o=!1})=>jsxRuntime.jsxRuntimeExports.jsx("svg",{className:o?"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.jsxRuntimeExports.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_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DesktopIcon,{}),width:1920}],BreakpointCard=({title:o,content:n,currentBreakpoint:r,breakpoint:a,width:i,icon:l,onClick:c})=>{const{t:d}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.HoverCard,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>c(i),size:"sm",variant:a===r?"secondary":"ghost",children:l})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardContent,{className:"w-52 border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:d(n)})]})})})]})},Breakpoints=()=>{const[,o,n]=useCanvasWidth(),[r,a]=useSelectedBreakpoints(),{t:i}=reactI18next.useTranslation(),l=useBuilderProp("breakpoints",WEB_BREAKPOINTS),c=d=>{r.includes(d)?r.length>2&&a(r.filter(u=>u!==d)):a(u=>[...u,d])};return l.length<4?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:lodashEs.map(l,d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o}))}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[lodashEs.map(l.filter(d=>lodashEs.includes(r,lodashEs.toUpper(d.breakpoint))),d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o})),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DotsVerticalIcon,{className:"scale-90 transform"})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:i("Breakpoints")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),lodashEs.map(l,d=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuCheckboxItem,{disabled:d.breakpoint==="xs",onCheckedChange:()=>c(lodashEs.toUpper(d.breakpoint)),checked:lodashEs.includes(r,lodashEs.toUpper(d.breakpoint)),children:i(d.title)},d.breakpoint))]})]})]})},ClearCanvas=()=>{const{t:o}=reactI18next.useTranslation(),{setNewBlocks:n}=useBlocksStoreUndoableActions(),[,r]=useSelectedBlockIds(),[,a]=useSelectedStylingBlocks(),i=React.useCallback(()=>{n([]),r([]),a([])},[n]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EraserIcon,{})," ",o("Clear")]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Clear Canvas")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:o("Are you sure you want to clear the page?")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{className:"text-foreground",children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:i,children:o("Yes")})]})]})]})})},CanvasTopBar=()=>{const o=useBuilderProp("darkMode",!0),[n]=useCanvasZoom();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(Breakpoints,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),o?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(DarkMode,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"})]}):null,jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsx(reactIcons.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[lodashEs.round(n,0),"%"]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),jsxRuntime.jsxRuntimeExports.jsx(UndoRedo,{})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center space-x-2",children:jsxRuntime.jsxRuntimeExports.jsx(ClearCanvas,{})})]})};function BlockAttributesToggle(){const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(!0),[a]=useSelectedStylingBlocks();return lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>r(!n),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("Attributes")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(n?"rotate-180":"")})})]}),n&&jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesEditor,{})]})}const SettingsPanel=()=>{const o=useSelectedBlock(),{t:n}=reactI18next.useTranslation(),r=useBuilderProp("onError",lodashEs.noop);return lodashEs.isNull(o)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("please_select_a_block_to_edit")})]})}):jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex max-h-full w-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(BlockSettings,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(BlockStyling,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesToggle,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})})},SettingsPanel$1=SettingsPanel;function LayoutCard({disabled:o=!1,description:n,title:r,selected:a,onSelect:i,children:l}){const{t:c}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Card,{"aria-disabled":o,className:`cursor-pointer border-border transition-all ${a?"ring-2 ring-secondary":""} ${o?"cursor-not-allowed opacity-50":""}`,onClick:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CardContent,{className:"p-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"text-lg font-semibold",children:r}),a&&jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckIcon,{className:"h-6 w-6 rounded-full bg-background p-px text-foreground"})]}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n}),l,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:o,className:"mt-4 w-full",variant:a?"default":"outline",children:c(o?"Coming soon":a?"Selected":"Select")})]})})}const ChooseLayout=({open:o,close:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=useLayoutVariant(),l=c=>{i(c),n()};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:o,onOpenChange:()=>o?n():"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-4xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:r("Choose Builder Layout")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>n(),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Single side panel"),description:r("Suitable for smaller screens. Bigger canvas size."),selected:a==="SINGLE_SIDE_PANEL",onSelect:()=>l("SINGLE_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-3/4 border-l border-border bg-background"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Dual side panel"),description:r("Suitable for larger screens. Blocks settings is always visible."),selected:a==="DUAL_SIDE_PANEL",onSelect:()=>l("DUAL_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{disabled:!0,title:r("Dual side panel advanced"),description:r("Suitable for heavy styling & block editing. Setting are always visible."),selected:!1,onSelect:()=>{},children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})})]})})]})})},HotKeys=()=>{const{t:o}=reactI18next.useTranslation(),n={"ctrl + Z":"Undo","ctrl + Y":"Redo","ctrl + D":"Duplicate"},r={"ctrl + S":"Save page",esc:"Deselect blocks",del:"Delete block"};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"mb-2 rounded-lg p-2 transition-colors",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.KeyboardIcon,{className:"size-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("Keyboard shortcuts")})})]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border sm:max-w-[525px]",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogHeader,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{className:"text-foreground",children:o("Keyboard shortcuts")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mr-8 flex flex-col space-y-2 border-r border-border",children:Object.keys(n).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(n[a])})]},a))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-2",children:Object.keys(r).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(r[a])})]},a))})]})})]})]})},ViewProviderData=({provider:o,onClose:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=React.useState(null),l=useBuilderProp("onError",lodashEs.noop);return React.useEffect(()=>{o&&(o.mockFn?o.mockFn:o.dataFn)().then(d=>i(d))},[o]),o?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Dialog,{onOpenChange:c=>c?"":n(),defaultOpen:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogTitle,{className:"text-foreground",children:[r("data_provider"),": ",o.name]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{children:o.description})]}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:a,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[80vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]})}):null};function RemoveProviderConfirmation({children:o,name:n,onRemove:r}){const{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{dangerouslySetInnerHTML:{__html:a("remove_provider_confirmation").replace("{name}",n)}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:a("remove_provider_warning")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:a("cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:r,className:"bg-red-600 hover:bg-red-700",children:a("remove")})]})]})]})}const PageDataProviders=()=>{const{t:o}=reactI18next.useTranslation(),n=React.useMemo(()=>runtime.getChaiDataProviders(),[]),[r,a]=usePageDataProviders(),[,i]=jotai.useAtom(builderSaveStateAtom),[l,c]=React.useState(lodashEs.filter(n,f=>lodashEs.map(r,"providerKey").includes(f.providerKey))),[d,u]=React.useState(""),[x,m]=React.useState(null),p=lodashEs.filter(n.map(f=>lodashEs.map(l,"providerKey").includes(f.providerKey)?null:{value:f.providerKey,label:f.name}),f=>!lodashEs.isNull(f)),g=f=>{const b=lodashEs.find(n,{providerKey:f});c(C=>[...C,b]),a(C=>[...C,{providerKey:b.providerKey,args:{}}]),u(""),i("UNSAVED")},R=f=>{c(b=>lodashEs.filter(b,C=>C.providerKey!==f.providerKey)),a(b=>lodashEs.filter(b,C=>C.providerKey!==f.providerKey)),i("UNSAVED")},h=f=>m(f);return lodashEs.isEmpty(n)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 p-4 text-xs text-gray-500",children:[o("no_data_providers"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:o("learn_more")})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"px-1",children:[jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("label",{children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-1.5 text-xs text-gray-500",children:o("add_data_providers")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-1",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Select,{value:d,onValueChange:f=>g(f),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectTrigger,{className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectValue,{placeholder:o("select_provider")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.SelectContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:"",children:o("choose")}),p.map(f=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:f.value,children:f.label},f.value))]})]})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`border-t border-border ${l.length?"block":"hidden"}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"flex-1 pb-1.5 pt-4 text-xs font-medium text-gray-500",children:[o("page_data_providers"),":"]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:l.map(f=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full rounded-lg border border-border bg-card text-card-foreground shadow-sm","data-v0-t":"card",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-1.5 px-4 pt-4",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"font-medium leading-4",children:f.name}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"pt-1 text-xs text-gray-400",children:f.description})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between p-2 py-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>h(f),className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-blue-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),o("view_data")]}),jsxRuntime.jsxRuntimeExports.jsx(RemoveProviderConfirmation,{onRemove:()=>R(f),name:f.name,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-red-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M3 6h18"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),o("remove")]})})]})]},f.providerKey))}),jsxRuntime.jsxRuntimeExports.jsx(ViewProviderData,{onClose:()=>m(null),provider:x})]})]})};function AiFillDatabase(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M832 64H192c-17.7 0-32 14.3-32 32v224h704V96c0-17.7-14.3-32-32-32zM288 232c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zM160 928c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V704H160v224zm128-136c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40zM160 640h704V384H160v256zm128-168c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40z"},child:[]}]})(o)}const TopBar=React.lazy(()=>Promise.resolve().then(()=>require("./Topbar--bKmw8Qf.cjs")));function useSidebarMenuItems(o){const n=o==="SINGLE_SIDE_PANEL",{t:r}=reactI18next.useTranslation(),a=useBuilderProp("dataBindingSupport",!1),i=useBuilderProp("askAiCallBack",null);return React.useMemo(()=>{const l=[{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Layers,{size:20}),label:"sidebar.outline",component:()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-8",children:jsxRuntime.jsxRuntimeExports.jsx(Outline$1,{})})},n?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GearIcon,{className:"size-5"}),label:"sidebar.edit_block",component:SettingsPanel$1}:null,a?{icon:jsxRuntime.jsxRuntimeExports.jsx(AiFillDatabase,{className:"size-3"}),label:r("Data Providers"),component:PageDataProviders}:null,i?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LightningBoltIcon,{className:"size-5"}),label:"sidebar.ai_assistant",component:AskAI}:null,{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PaintBucketIcon,{size:20}),label:"sidebar.theme",component:()=>jsxRuntime.jsxRuntimeExports.jsx(ThemeOptions,{showHeading:!1})}];return lodashEs.compact(l)},[n,a,r,i])}function isDualLayout(o){return o!=="SINGLE_SIDE_PANEL"}const RootLayout=()=>{const[o,n]=React.useState(0),[r]=useLayoutVariant(),[a,i]=React.useState(!1);useChaiBuilderMsgListener(({name:g})=>{g===CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS&&n(1)});const l=useBuilderProp("sideBarComponents.top",[]),c=g=>{g.preventDefault()},d=g=>{n(o===g?null:g)},u=useSidebarMenuItems(r),{t:x}=reactI18next.useTranslation(),m=[...u,...l],p=useBuilderProp("htmlDir","ltr");return jsxRuntime.jsxRuntimeExports.jsx("div",{dir:p,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TooltipProvider,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onContextMenu:c,className:"flex h-screen max-h-full flex-col bg-background text-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(TopBar,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:m.map((g,R)=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:o===R?"default":"ghost",className:"mb-2 rounded-lg p-2 transition-colors",onClick:()=>d(R),children:lodashEs.get(g,"icon",null)},R)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x(g.label)})})]},"button"+R))}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"ghost",onClick:()=>i(!0),children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.LayoutTemplate,{size:20})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x("Choose Builder Layout")})})]}),jsxRuntime.jsxRuntimeExports.jsx(HotKeys,{})]})]}),jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-r border-border",initial:{width:280},animate:{width:o!==null?280:0},transition:{duration:.3,ease:"easeInOut"},children:o!==null&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[lodashEs.get(m,`${o}.icon`,null),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x(m[o].label)})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(m,`${o}.component`,null),{})})})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[jsxRuntime.jsxRuntimeExports.jsx(CanvasTopBar,{}),jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(CanvasArea$1,{})})]}),isDualLayout(r)?jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-l border-border",initial:{width:280},animate:{width:280},transition:{duration:.3,ease:"easeInOut"},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex max-h-full flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{size:"16"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x("Block Settings")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:jsxRuntime.jsxRuntimeExports.jsx(SettingsPanel$1,{})})})]})})}):null]})]}),jsxRuntime.jsxRuntimeExports.jsx(AddBlocksDialog,{}),jsxRuntime.jsxRuntimeExports.jsx(ChooseLayout,{open:a,close:()=>i(!1)})]})})},builderStore=jotai.getDefaultStore(),SmallScreenMessage=()=>jsxRuntime.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mx-auto max-w-md text-center",children:[jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"text-4xl font-bold text-white",children:"Screen too small"}),jsxRuntime.jsxRuntimeExports.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."})]})})}),setDebugLogs=o=>{},PreviewScreen=()=>{const[o,n]=usePreviewMode(),{t:r}=reactI18next.useTranslation(),a=useBuilderProp("previewComponent",null);return o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("fixed inset-0 z-[999] bg-background",o?"block":"hidden"),children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>n(!1),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeClosedIcon,{}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r("close_preview")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:a?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-96 w-full"}),children:React.createElement(a)}):null})]}):null},getParentNodeIds=(o,n)=>{const r=[];let a=lodashEs.find(o,{_id:n}),i=lodashEs.get(a,"_parent","");for(;lodashEs.isString(i)&&!lodashEs.isEmpty(i);)r.push(a==null?void 0:a._parent),a=lodashEs.find(o,{_id:i}),i=a==null?void 0:a._parent;return lodashEs.flatten(r)},expandedIdsAtom=jotai.atom([]),useExpandTree=()=>{const[o]=useSelectedBlockIds(),n=jotai.useAtomValue(presentBlocksAtom),[,r]=jotai.useAtom(expandedIdsAtom);React.useEffect(()=>{let a=[];const i=lodashEs.first(o);lodashEs.isString(i)&&(a=[i,...getParentNodeIds(n,i)]),r(a)},[o,n,r])},useAutoSave=()=>{const{savePage:o}=useSavePage(),n=useBuilderProp("autoSaveSupport",!0),r=useBuilderProp("autoSaveInterval",60);web.useIntervalEffect(()=>{n&&o()},r*1e3)},ChaiBuilderComponent=o=>{const[,n]=useBlocksStore(),[,r]=useBrandingOptions(),a=useBuilderReset(),[i]=useAtom(builderSaveStateAtom),l=React.useMemo(()=>o.layout||RootLayout,[o.layout]);return useAtom(selectedLibraryAtom),useKeyEventWatcher(),useExpandTree(),useAutoSave(),useWatchGlobalBlocks(),useWatchRSCBlocks(),React.useEffect(()=>{builderStore.set(chaiBuilderPropsAtom,lodashEs.omit(o,["blocks","subPages","brandingOptions","dataProviders","customRootLayout","translations"]))},[o]),React.useEffect(()=>{builderStore.set(dataProvidersAtom,o.dataProviders||[])},[o.dataProviders]),React.useEffect(()=>{n(runtime.syncBlocksWithDefaults(o.blocks||[])),a()},[o.blocks]),React.useEffect(()=>{i18n.changeLanguage(o.locale||"en")},[o.locale]),React.useEffect(()=>{setDebugLogs(o.showDebugLogs)},[o.showDebugLogs]),React.useEffect(()=>{o.translations&&lodashEs.each(o.translations,(c,d)=>{i18n.addResourceBundle(d,"translation",c,!0,!0)})},[o.translations]),React.useEffect(()=>{r(o.brandingOptions)},[o.brandingOptions,r]),React.useEffect(()=>(i!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[i]),jsxRuntime.jsxRuntimeExports.jsx(l,{})},ChaiBuilderEditor=o=>{const n=o._flags||{},r=o.onError||lodashEs.noop;return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs(flagged.FlagsProvider,{features:{...FEATURE_TOGGLES,...n},children:[jsxRuntime.jsxRuntimeExports.jsx(SmallScreenMessage,{}),jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderComponent,{...o}),jsxRuntime.jsxRuntimeExports.jsx(PreviewScreen,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Toaster,{})]})})})};exports.AISetContext=AISetContext;exports.AIUserPrompt=AIUserPrompt;exports.AddBlocksDialog=AddBlocksDialog;exports.AddBlocksPanel=AddBlocksPanel$1;exports.BlockAttributesEditor=BlockAttributesEditor;exports.BlockSettings=BlockSettings;exports.BlockStyling=BlockStyling;exports.Breakpoints=Breakpoints;exports.CHAI_BUILDER_EVENTS=CHAI_BUILDER_EVENTS;exports.CanvasArea=CanvasArea$1;exports.ChaiBuilderEditor=ChaiBuilderEditor;exports.ChaiSelect=ChaiSelect$1;exports.DarkMode=DarkMode;exports.DefaultChaiBlocks=DefaultChaiBlocks;exports.FaCheck=FaCheck;exports.ImportHTML=ImportHTML$1;exports.Outline=Outline$1;exports.ThemeOptions=ThemeOptions;exports.UILibraries=UILibraries;exports.UndoRedo=UndoRedo;exports.emitChaiBuilderMsg=emitChaiBuilderMsg;exports.getBlocksFromHTML=getBlocksFromHTML;exports.getClassValueAndUnit=getClassValueAndUnit;exports.useAddBlock=useAddBlock;exports.useAddClassesToBlocks=useAddClassesToBlocks;exports.useBlocksStore=useBlocksStore;exports.useBlocksStoreUndoableActions=useBlocksStoreUndoableActions;exports.useBrandingOptions=useBrandingOptions;exports.useBuilderProp=useBuilderProp;exports.useBuilderReset=useBuilderReset;exports.useCanvasWidth=useCanvasWidth;exports.useCanvasZoom=useCanvasZoom;exports.useChaiBuilderMsgListener=useChaiBuilderMsgListener;exports.useCodeEditor=useCodeEditor;exports.useCopyBlockIds=useCopyBlockIds;exports.useCopyToClipboard=useCopyToClipboard;exports.useCurrentPage=useCurrentPage;exports.useCutBlockIds=useCutBlockIds;exports.useDarkMode=useDarkMode;exports.useDuplicateBlocks=useDuplicateBlocks;exports.useGlobalBlocksList=useGlobalBlocksList;exports.useGlobalBlocksStore=useGlobalBlocksStore;exports.useHiddenBlockIds=useHiddenBlockIds;exports.useHighlightBlockId=useHighlightBlockId;exports.useLayoutVariant=useLayoutVariant;exports.usePasteBlocks=usePasteBlocks;exports.usePreviewMode=usePreviewMode;exports.useRemoveBlocks=useRemoveBlocks;exports.useRemoveClassesFromBlocks=useRemoveClassesFromBlocks;exports.useSavePage=useSavePage;exports.useSelectedBlock=useSelectedBlock;exports.useSelectedBlockAllClasses=useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=useSelectedBreakpoints;exports.useSelectedStylingBlocks=useSelectedStylingBlocks;exports.useStylingBreakpoint=useStylingBreakpoint;exports.useStylingState=useStylingState;exports.useUILibraryBlocks=useUILibraryBlocks;exports.useUndoManager=useUndoManager;exports.useUpdateBlocksProps=useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=useUpdateBlocksPropsRealtime;