@chaibuilder/sdk 2.0.0-beta.106 → 2.0.0-beta.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -3
- package/dist/core.js +9 -41
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var G=Object.defineProperty;var K=(o,n,a)=>n in o?G(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a;var U=(o,n,a)=>K(o,typeof n!="symbol"?n+"":n,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),React=require("react"),tooltip=require("./tooltip-DHlrjqh8.cjs"),jotai=require("jotai"),lodashEs=require("lodash-es"),reactWrapBalancer=require("react-wrap-balancer"),reactI18next=require("react-i18next"),iconBase=require("./iconBase-Cn2BsTrq.cjs"),dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),reactIcons=require("@radix-ui/react-icons"),web=require("@react-hookz/web"),flagged=require("flagged"),runtime=require("@chaibuilder/runtime"),ChaiThemeFn=require("./ChaiThemeFn-DQu-2Eh9.cjs"),TreeModel=require("tree-model"),reactHotkeysHook=require("react-hotkeys-hook"),sonner=require("sonner"),lucideReact=require("lucide-react"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),clsx=require("clsx"),tailwindMerge=require("tailwind-merge"),typography=require("@tailwindcss/typography"),forms=require("@tailwindcss/forms"),aspectRatio=require("@tailwindcss/aspect-ratio"),containerQueries=require("@tailwindcss/container-queries"),getSplitClasses=require("./getSplitClasses-DodqA_KW.cjs"),ReactDOM=require("react-dom"),reactErrorBoundary=require("react-error-boundary"),reResizable=require("re-resizable"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),IconPicker=require("react-icons-picker"),Autosuggest=require("react-autosuggest"),Fuse=require("fuse.js"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),i18n=require("i18next"),framerMotion=require("framer-motion");function _interopNamespaceDefault(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(n,a,l.get?l:{enumerable:!0,get:()=>o[a]})}}return n.default=o,Object.freeze(n)}const React__namespace=_interopNamespaceDefault(React),isSelfAtom=(o,n)=>o.unstable_is?o.unstable_is(n):n===o,hasInitialValue=o=>"init"in o,isActuallyWritableAtom=o=>!!o.write,isAtomStateInitialized=o=>"v"in o||"e"in o,returnAtomValue=o=>{if("e"in o)throw o.e;return o.v},PROMISE_STATE=Symbol(),getPromiseState=o=>o[PROMISE_STATE],isPendingPromise=o=>{var n;return isPromiseLike$2(o)&&!((n=getPromiseState(o))!=null&&n[1])},cancelPromise=(o,n)=>{const a=getPromiseState(o);a&&(a[1]=!0,a[0].forEach(l=>l(n)))},patchPromiseForCancelability=o=>{if(getPromiseState(o))return;const n=[new Set,!1];o[PROMISE_STATE]=n;const a=()=>{n[1]=!0};o.then(a,a),o.onCancel=l=>{n[0].add(l)}},isPromiseLike$2=o=>typeof(o==null?void 0:o.then)=="function",addPendingPromiseToDependency=(o,n,a)=>{a.p.has(o)||(a.p.add(o),n.then(()=>{a.p.delete(o)},()=>{a.p.delete(o)}))},setAtomStateValueOrPromise=(o,n,a)=>{const l=a(o),r="v"in l,i=l.v,c=isPendingPromise(l.v)?l.v:null;if(isPromiseLike$2(n)){patchPromiseForCancelability(n);for(const d of l.d.keys())addPendingPromiseToDependency(o,n,a(d))}l.v=n,delete l.e,(!r||!Object.is(i,l.v))&&(++l.n,c&&cancelPromise(c,n))},getMountedOrPendingDependents=(o,n,a)=>{var l;const r=new Set;for(const i of((l=a.get(o))==null?void 0:l.t)||[])a.has(i)&&r.add(i);for(const i of n.p)r.add(i);return r},BUILDING_BLOCKS=Symbol(),buildStore=(o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new Set,r=new Set,i=new Set,c={},d=(g,...x)=>g.read(...x),p=(g,...x)=>g.write(...x),u=(g,x)=>{var b;return(b=g.unstable_onInit)==null?void 0:b.call(g,x)},m=(g,x)=>{var b;return(b=g.onMount)==null?void 0:b.call(g,x)},...h)=>{const g=h[0]||(E=>{let N=o.get(E);return N||(N={d:new Map,p:new Set,n:0},o.set(E,N),u==null||u(E,B)),N}),x=h[1]||(()=>{let E,N;const y=R=>{try{R()}catch(_){E||(E=!0,N=_)}};do{c.f&&y(c.f);const R=new Set,_=R.add.bind(R);l.forEach(I=>{var T;return(T=n.get(I))==null?void 0:T.l.forEach(_)}),l.clear(),i.forEach(_),i.clear(),r.forEach(_),r.clear(),R.forEach(y),l.size&&b()}while(l.size||i.size||r.size);if(E)throw N}),b=h[2]||(()=>{const E=[],N=new WeakSet,y=new WeakSet,R=Array.from(l);for(;R.length;){const _=R[R.length-1],I=g(_);if(y.has(_)){R.pop();continue}if(N.has(_)){a.get(_)===I.n&&E.push([_,I]),y.add(_),R.pop();continue}N.add(_);for(const T of getMountedOrPendingDependents(_,I,n))N.has(T)||R.push(T)}for(let _=E.length-1;_>=0;--_){const[I,T]=E[_];let P=!1;for(const A of T.d.keys())if(A!==I&&l.has(A)){P=!0;break}P&&(f(I),w(I)),a.delete(I)}}),f=h[3]||(E=>{var N,y;const R=g(E);if(isAtomStateInitialized(R)&&(n.has(E)&&a.get(E)!==R.n||Array.from(R.d).every(([L,H])=>f(L).n===H)))return R;R.d.clear();let _=!0;const I=()=>{n.has(E)&&(w(E),b(),x())},T=L=>{var H;if(isSelfAtom(E,L)){const V=g(L);if(!isAtomStateInitialized(V))if(hasInitialValue(L))setAtomStateValueOrPromise(L,L.init,g);else throw new Error("no atom init");return returnAtomValue(V)}const O=f(L);try{return returnAtomValue(O)}finally{R.d.set(L,O.n),isPendingPromise(R.v)&&addPendingPromiseToDependency(E,R.v,O),(H=n.get(L))==null||H.t.add(E),_||I()}};let P,A;const D={get signal(){return P||(P=new AbortController),P.signal},get setSelf(){return!A&&isActuallyWritableAtom(E)&&(A=(...L)=>{if(!_)try{return S(E,...L)}finally{b(),x()}}),A}},M=R.n;try{const L=d(E,T,D);return setAtomStateValueOrPromise(E,L,g),isPromiseLike$2(L)&&((N=L.onCancel)==null||N.call(L,()=>P==null?void 0:P.abort()),L.then(I,I)),R}catch(L){return delete R.v,R.e=L,++R.n,R}finally{_=!1,M!==R.n&&a.get(E)===M&&(a.set(E,R.n),l.add(E),(y=c.c)==null||y.call(c,E))}}),j=h[4]||(E=>{const N=[E];for(;N.length;){const y=N.pop(),R=g(y);for(const _ of getMountedOrPendingDependents(y,R,n)){const I=g(_);a.set(_,I.n),N.push(_)}}}),S=h[5]||((E,...N)=>{let y=!0;const R=I=>returnAtomValue(f(I)),_=(I,...T)=>{var P;const A=g(I);try{if(isSelfAtom(E,I)){if(!hasInitialValue(I))throw new Error("atom not writable");const D=A.n,M=T[0];setAtomStateValueOrPromise(I,M,g),w(I),D!==A.n&&(l.add(I),(P=c.c)==null||P.call(c,I),j(I));return}else return S(I,...T)}finally{y||(b(),x())}};try{return p(E,R,_,...N)}finally{y=!1}}),w=h[6]||(E=>{var N;const y=g(E),R=n.get(E);if(R&&!isPendingPromise(y.v)){for(const[_,I]of y.d)if(!R.d.has(_)){const T=g(_);v(_).t.add(E),R.d.add(_),I!==T.n&&(l.add(_),(N=c.c)==null||N.call(c,_),j(_))}for(const _ of R.d||[])if(!y.d.has(_)){R.d.delete(_);const I=k(_);I==null||I.t.delete(E)}}}),v=h[7]||(E=>{var N;const y=g(E);let R=n.get(E);if(!R){f(E);for(const _ of y.d.keys())v(_).t.add(E);if(R={l:new Set,d:new Set(y.d.keys()),t:new Set},n.set(E,R),(N=c.m)==null||N.call(c,E),isActuallyWritableAtom(E)){const _=()=>{let I=!0;const T=(...P)=>{try{return S(E,...P)}finally{I||(b(),x())}};try{const P=m(E,T);P&&(R.u=()=>{I=!0;try{P()}finally{I=!1}})}finally{I=!1}};r.add(_)}}return R}),k=h[8]||(E=>{var N;const y=g(E);let R=n.get(E);if(R&&!R.l.size&&!Array.from(R.t).some(_=>{var I;return(I=n.get(_))==null?void 0:I.d.has(E)})){R.u&&i.add(R.u),R=void 0,n.delete(E),(N=c.u)==null||N.call(c,E);for(const _ of y.d.keys()){const I=k(_);I==null||I.t.delete(E)}return}return R}),C=[o,n,a,l,r,i,c,d,p,u,m,g,x,b,f,j,S,w,v,k],B={get:E=>returnAtomValue(f(E)),set:(E,...N)=>{try{return S(E,...N)}finally{b(),x()}},sub:(E,N)=>{const R=v(E).l;return R.add(N),x(),()=>{R.delete(N),k(E),x()}}};return Object.defineProperty(B,BUILDING_BLOCKS,{value:C}),B},INTERNAL_buildStoreRev1=buildStore;let keyCount=0;function atom(o,n){const a=`atom${++keyCount}`,l={toString(){return a}};return typeof o=="function"?l.read=o:(l.init=o,l.read=defaultRead,l.write=defaultWrite),n&&(l.write=n),l}function defaultRead(o){return o(this)}function defaultWrite(o,n,a){return n(this,typeof a=="function"?a(o(this)):a)}const createStore=()=>INTERNAL_buildStoreRev1();let defaultStore;const getDefaultStore=()=>(defaultStore||(defaultStore=createStore()),defaultStore),RESET=Symbol(""),getCached$1=(o,n,a)=>(n.has(a)?n:n.set(a,o())).get(a),cache1$2=new WeakMap,memo2$1=(o,n,a)=>{const l=getCached$1(()=>new WeakMap,cache1$2,n);return getCached$1(o,l,a)},cacheKeyForEmptyKeyExtractor={},isWritable=o=>!!o.write,isFunction=o=>typeof o=="function";function splitAtom(o,n){return memo2$1(()=>{const a=new WeakMap,l=(c,d)=>{let p=a.get(c);if(p)return p;const u=d&&a.get(d),m=[],h=[];return c.forEach((g,x)=>{const b=x;h[x]=b;const f=u&&u.atomList[u.keyList.indexOf(b)];if(f){m[x]=f;return}const j=w=>{const v=w(r),k=w(o),B=l(k,v==null?void 0:v.arr).keyList.indexOf(b);if(B<0||B>=k.length){const E=c[l(c).keyList.indexOf(b)];if(E)return E;throw new Error("splitAtom: index out of bounds for read")}return k[B]},S=(w,v,k)=>{const C=w(r),B=w(o),N=l(B,C==null?void 0:C.arr).keyList.indexOf(b);if(N<0||N>=B.length)throw new Error("splitAtom: index out of bounds for write");const y=isFunction(k)?k(B[N]):k;Object.is(B[N],y)||v(o,[...B.slice(0,N),y,...B.slice(N+1)])};m[x]=isWritable(o)?atom(j,S):atom(j)}),u&&u.keyList.length===h.length&&u.keyList.every((g,x)=>g===h[x])?p=u:p={arr:c,atomList:m,keyList:h},a.set(c,p),p},r=atom(c=>{const d=c(r),p=c(o);return l(p,d==null?void 0:d.arr)});r.init=void 0;const i=isWritable(o)?atom(c=>c(r).atomList,(c,d,p)=>{switch(p.type){case"remove":{const u=c(i).indexOf(p.atom);if(u>=0){const m=c(o);d(o,[...m.slice(0,u),...m.slice(u+1)])}break}case"insert":{const u=p.before?c(i).indexOf(p.before):c(i).length;if(u>=0){const m=c(o);d(o,[...m.slice(0,u),p.value,...m.slice(u)])}break}case"move":{const u=c(i).indexOf(p.atom),m=p.before?c(i).indexOf(p.before):c(i).length;if(u>=0&&m>=0){const h=c(o);u<m?d(o,[...h.slice(0,u),...h.slice(u+1,m),h[u],...h.slice(m)]):d(o,[...h.slice(0,m),h[u],...h.slice(m,u),...h.slice(u+1)])}break}}}):atom(c=>c(r).atomList);return i},o,cacheKeyForEmptyKeyExtractor)}const isPromiseLike$1=o=>typeof(o==null?void 0:o.then)=="function";function createJSONStorage(o=()=>{try{return window.localStorage}catch{return}},n){var a;let l,r;const i={getItem:(p,u)=>{var m,h;const g=b=>{if(b=b||"",l!==b){try{r=JSON.parse(b,n==null?void 0:n.reviver)}catch{return u}l=b}return r},x=(h=(m=o())==null?void 0:m.getItem(p))!=null?h:null;return isPromiseLike$1(x)?x.then(g):g(x)},setItem:(p,u)=>{var m;return(m=o())==null?void 0:m.setItem(p,JSON.stringify(u,void 0))},removeItem:p=>{var u;return(u=o())==null?void 0:u.removeItem(p)}},c=p=>(u,m,h)=>p(u,g=>{let x;try{x=JSON.parse(g||"")}catch{x=h}m(x)});let d;try{d=(a=o())==null?void 0:a.subscribe}catch{}return!d&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(d=(p,u)=>{if(!(o()instanceof window.Storage))return()=>{};const m=h=>{h.storageArea===o()&&h.key===p&&u(h.newValue)};return window.addEventListener("storage",m),()=>{window.removeEventListener("storage",m)}}),d&&(i.subscribe=c(d)),i}const defaultStorage=createJSONStorage();function atomWithStorage(o,n,a=defaultStorage,l){const r=atom(n);return r.onMount=c=>{c(a.getItem(o,n));let d;return a.subscribe&&(d=a.subscribe(o,c,n)),d},atom(c=>c(r),(c,d,p)=>{const u=typeof p=="function"?p(c(r)):p;return u===RESET?(d(r,n),a.removeItem(o)):u instanceof Promise?u.then(m=>(d(r,m),a.setItem(o,m))):(d(r,u),a.setItem(o,u))})}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",attachPromiseMeta=o=>{o.status="pending",o.then(n=>{o.status="fulfilled",o.value=n},n=>{o.status="rejected",o.reason=n})},use=React.use||(o=>{if(o.status==="pending")throw o;if(o.status==="fulfilled")return o.value;throw o.status==="rejected"?o.reason:(attachPromiseMeta(o),o)}),continuablePromiseMap=new WeakMap,createContinuablePromise=o=>{let n=continuablePromiseMap.get(o);return n||(n=new Promise((a,l)=>{let r=o;const i=p=>u=>{r===p&&a(u)},c=p=>u=>{r===p&&l(u)},d=p=>{"onCancel"in p&&typeof p.onCancel=="function"&&p.onCancel(u=>{isPromiseLike(u)?(continuablePromiseMap.set(u,n),r=u,u.then(i(u),c(u)),d(u)):a(u)})};o.then(i(o),c(o)),d(o)}),continuablePromiseMap.set(o,n)),n};function useAtomValue(o,n){const a=useStore(n),[[l,r,i],c]=React.useReducer(u=>{const m=a.get(o);return Object.is(u[0],m)&&u[1]===a&&u[2]===o?u:[m,a,o]},void 0,()=>[a.get(o),a,o]);let d=l;if((r!==a||i!==o)&&(c(),d=a.get(o)),React.useEffect(()=>{const u=a.sub(o,()=>{c()});return c(),u},[a,o,void 0]),React.useDebugValue(d),isPromiseLike(d)){const u=createContinuablePromise(d);return use(u)}return d}function useSetAtom(o,n){const a=useStore(n);return React.useCallback((...r)=>a.set(o,...r),[a,o])}function useAtom(o,n){return[useAtomValue(o,n),useSetAtom(o,n)]}function useAtomCallback(o,n){const a=React.useMemo(()=>atom(null,(l,r,...i)=>o(l,r,...i)),[o]);return useSetAtom(a,n)}const readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const 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="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";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)}}class Frame extends React.Component{constructor(a,l){super(a,l);U(this,"setRef",a=>{this.nodeRef.current=a;const{forwardedRef:l}=this.props;typeof l=="function"?l(a):l&&(l.current=a)});U(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});U(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 a=this.getDoc();return this.props.mountTarget?a.querySelector(this.props.mountTarget):a.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const a=this.getDoc();if(!a)return null;const l=this.props.contentDidMount,r=this.props.contentDidUpdate,i=a.defaultView||a.parentView,c=jsxRuntime.jsx(Content,{contentDidMount:l,contentDidUpdate:r,children:jsxRuntime.jsx(FrameContextProvider,{value:{document:a,window:i},children:jsxRuntime.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 a={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete a.head,delete a.initialContent,delete a.mountTarget,delete a.contentDidMount,delete a.contentDidUpdate,delete a.forwardedRef,jsxRuntime.jsx("iframe",{...a,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}U(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.jsx(Frame,{...o,forwardedRef:n}));function duplicateBlocks(o,n,a){const l=lodashEs.filter(o,i=>i._parent===n),r=[];for(let i=0;i<l.length;i++){const c=getSlots(l[i]);if(Object.keys(c).length>0&&Object.keys(c).forEach(d=>{l[i][d]=`slot:${iconBase.generateUUID()}`}),lodashEs.filter(o,{_parent:l[i]._id}).length>0){const d=iconBase.generateUUID();r.push({...l[i],oldId:l[i]._id,_id:d,_parent:a}),r.push(lodashEs.flatten(duplicateBlocks(o,l[i]._id,d)))}else r.push({...l[i],oldId:l[i]._id,_id:iconBase.generateUUID(),_parent:a})}return lodashEs.flatten(r)}function convertToBlocksTree(o){const n={};o.forEach(l=>{n[l._id]={...l,children:[]}});const a=[];return o.forEach(l=>{if(l._parent){const r=n[l._parent];r&&r.children.push(n[l._id])}else a.push(n[l._id])}),a}const getSlots=o=>{const n={};return Object.keys(o).forEach(a=>{lodashEs.isString(o[a])&&o[a].startsWith("slot")&&(n[a]=o[a].replace("slot:",""))}),n},getDuplicatedBlocks=(o,n,a=null)=>{let l=lodashEs.find(o,{_id:n});l={...l,oldId:l._id,_id:iconBase.generateUUID()},a!==(l==null?void 0:l._parent)&&(l={...l,_parent:a});const r=[l];lodashEs.filter(o,{_parent:n}).length>0&&r.push(lodashEs.flatten(duplicateBlocks(o,n,l._id)));const i=lodashEs.flatten(r);return lodashEs.map(i,c=>{const d=c,p=getSlots(d);return Object.keys(p).length>0&&Object.keys(p).forEach(u=>{const m=lodashEs.find(i,{oldId:p[u].replace("slot:","")});d[u]=`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";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,a=>lodashEs.has(a,"blockId"))});globalBlocksAtom.debugLabel="globalBlocksAtom";var undomanager={exports:{}},hasRequiredUndomanager;function requireUndomanager(){return hasRequiredUndomanager||(hasRequiredUndomanager=1,function(o){(function(){function n(l,r,i){return l.splice(r,!i||1+i-r+(!(i<0^r>=0)&&(i<0||-1)*l.length)),l.length}let a=function(){let l=[],r=-1,i=0,c=!1,d;function p(u,m){return!u||typeof u[m]!="function"?this:(c=!0,u[m](),c=!1,this)}return{add:function(u){return c?this:(l.splice(r+1,l.length-r),l.push(u),i&&l.length>i&&n(l,0,-(i+1)),r=l.length-1,d&&d(),this)},setCallback:function(u){d=u},undo:function(){let u=l[r];if(!u)return this;const m=u.groupId;for(;u.groupId===m&&(p(u,"undo"),r-=1,u=l[r],!(!u||!u.groupId)););return d&&d(),this},redo:function(){let u=l[r+1];if(!u)return this;const m=u.groupId;for(;u.groupId===m&&(p(u,"redo"),r+=1,u=l[r+1],!(!u||!u.groupId)););return d&&d(),this},clear:function(){let u=l.length;l=[],r=-1,d&&u>0&&d()},hasUndo:function(){return r!==-1},hasRedo:function(){return r<l.length-1},getCommands:function(u){return u?l.filter(m=>m.groupId===u):l},getIndex:function(){return r},setLimit:function(u){i=u}}};o.exports?o.exports=a:window.UndoManager=a})()}(undomanager)),undomanager.exports}var undomanagerExports=requireUndomanager();const UndoManager=ChaiThemeFn.getDefaultExportFromCjs(undomanagerExports);function getBlocksTree(o){return convertToBlocksTree(o)}const nestedToFlatArray=(o,n)=>lodashEs.flatten(o.map(a=>{if(a=n?{...a,_parent:n}:{...a},a.children){const l=[...a.children];return delete a.children,lodashEs.flatten([a,...nestedToFlatArray(l,a._id)])}return a}));function setProjectBlocksInMemory(o,n=!1){for(let a=0;a<o.length;a++){const l=o[a];l.global&&!n?o[a]={type:"GlobalBlock",blockId:l.blockId,_parent:lodashEs.get(l,"_parent",null),_id:l._id}:l.children&&l.children.length&&setProjectBlocksInMemory(l.children)}}function getInnerBlocks(o){let n=[],a=lodashEs.filter(o,{type:"GlobalBlock"});return a.length>0&&(a=lodashEs.map(a,getPBlocks),lodashEs.each(a,l=>{n=[...n,...getSingleBlock(l)]})),n}function getSingleBlock(o){let n=[];const a=lodashEs.get(lodashEs.first(o),"_parent",null);lodashEs.set(lodashEs.first(o),"_parent",null);const l=[flatToNestedInstance.convert(clone(o))];setProjectBlocksInMemory(l,!0);let r=nestedToFlatArray(l,o[0]._id);return r=lodashEs.set(r,"0._parent",a),n=[...n,r,...getInnerBlocks(r)],n}function getPBlocks(o){const n=lodashEs.find(FLAT_ARRAY,{_id:o._id});if(!n)return[];const a=[n],l=lodashEs.filter(FLAT_ARRAY,{_parent:o._id});return l.length?lodashEs.flatten([...a,...lodashEs.flatten(lodashEs.map(l,getPBlocks))]):lodashEs.flatten(a)}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 a=nestedToFlatArray(n,null),l=getInnerBlocks(a),r={};return lodashEs.each(l,i=>lodashEs.set(r,lodashEs.first(i).blockId,i)),[a,r]}const MODIFIERS=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"],BRANDING_OPTIONS_DEFAULTS={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"},brandingOptionsAtom=jotai.atom(BRANDING_OPTIONS_DEFAULTS);jotai.atom(null);const useBrandingOptions=()=>{const[o,n]=jotai.useAtom(brandingOptionsAtom);return[lodashEs.isObject(o)?{...BRANDING_OPTIONS_DEFAULTS,...o}:BRANDING_OPTIONS_DEFAULTS,n]},currentPageAtom=jotai.atom(null),useCurrentPage=()=>({currentPage:jotai.useAtomValue(currentPageAtom)}),getBlockBuilderProps=lodashEs.memoize(o=>{const n=runtime.getRegisteredChaiBlock(o),a=lodashEs.get(n,"schema.properties",{});return lodashEs.compact(Object.keys(a).map(l=>lodashEs.get(a[l],"builderProp",!1)||lodashEs.get(a[l],"runtime",!1)?l:null))}),useGetPageData=()=>{const[o]=useBrandingOptions(),{currentPage:n}=useCurrentPage(),[a]=useBlocksStore();return React.useCallback(()=>{const l=lodashEs.map(a,i=>lodashEs.omit(i,getBlockBuilderProps(i._type))),[r=[]]=splitPageBlocks(l);return{currentPage:n,blocks:r}},[o,n,a])},chaiBuilderPropsAtom=jotai.atom(null);chaiBuilderPropsAtom.debugLabel="chaiBuilderPropsAtom";const chaiExternalDataAtom=jotai.atom({});chaiExternalDataAtom.debugLabel="chaiExternalDataAtom";const chaiRjsfFieldsAtom=jotai.atom({});chaiRjsfFieldsAtom.debugLabel="chaiRjsfFieldsAtom";const chaiRjsfWidgetsAtom=jotai.atom({});chaiRjsfWidgetsAtom.debugLabel="chaiRjsfWidgetsAtom";const chaiRjsfTemplatesAtom=jotai.atom({});chaiRjsfTemplatesAtom.debugLabel="chaiRjsfTemplatesAtom";const chaiPageExternalDataAtom=jotai.atom({});chaiPageExternalDataAtom.debugLabel="chaiPageExternalDataAtom";const usePageExternalData=()=>jotai.useAtomValue(chaiPageExternalDataAtom),useBuilderProp=(o,n=void 0)=>{const a=jotai.useAtomValue(chaiBuilderPropsAtom);return lodashEs.get(a,o,n)},getDefaultThemeValues=(o=ChaiThemeFn.defaultThemeOptions)=>{const n={};return o.fontFamily&&(n.fontFamily=Object.entries(o.fontFamily).reduce((a,[l,r])=>({...a,[l.replace("font-","")]:r}),{})),n.borderRadius=o.borderRadius,o.colors&&(n.colors=o.colors.reduce((a,l)=>(Object.entries(l.items).forEach(([r,i])=>{a[r]=i}),a),{})),n},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const o=useThemeOptions(),n=React.useMemo(()=>getDefaultThemeValues(o),[o]),a=useBuilderProp("theme",{}),[l,r]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...n,...!lodashEs.isEmpty(a)&&a,...!lodashEs.isEmpty(l)&&l}),[n,a,l]),r]},useThemeOptions=()=>{const o=useBuilderProp("themeOptions",a=>a);return React.useMemo(()=>o(ChaiThemeFn.defaultThemeOptions),[o])},rightPanelAtom=jotai.atom("block"),useRightPanel=()=>jotai.useAtom(rightPanelAtom),builderSaveStateAtom=jotai.atom("SAVED");builderSaveStateAtom.debugLabel="builderSaveStateAtom";const useSavePage=()=>{const[o,n]=jotai.useAtom(builderSaveStateAtom),a=useBuilderProp("onSave",async d=>{}),l=useBuilderProp("onSaveStateChange",lodashEs.noop),r=useGetPageData(),[i]=useTheme();return{savePage:web.useThrottledCallback(async(d=!1)=>{n("SAVING"),l("SAVING");const p=r();return await a({autoSave:d,blocks:p.blocks,theme:i}),setTimeout(()=>{n("SAVED"),l("SAVED")},100),!0},[r,n,i,a,l],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}},broadcastChannel=new BroadcastChannel("chaibuilder"),useBroadcastChannel=()=>{const o=useBuilderProp("pageId","chaibuilder_page");return{postMessage:web.useDebouncedCallback(a=>broadcastChannel.postMessage({...a,pageId:o}),[o],200)}},useUnmountBroadcastChannel=()=>{const[,o]=useBlocksStore(),n=useBuilderProp("pageId","chaibuilder_page"),{updateBlocksProps:a}=useBlocksStoreManager();React.useEffect(()=>(broadcastChannel.onmessageerror=l=>{console.log("error",l)},broadcastChannel.onmessage=l=>{l.data.type==="blocks-updated"&&l.data.pageId===n&&o(l.data.blocks),l.data.type==="blocks-props-updated"&&l.data.pageId===n&&a(l.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[o,n])},selectedBlockIdsAtom=jotai.atom([]);selectedBlockIdsAtom.debugLabel="selectedBlockIdsAtom";const selectedBlocksAtom=jotai.atom(o=>{const n=o(presentBlocksAtom),a=o(selectedBlockIdsAtom);return lodashEs.map(lodashEs.filter(n,({_id:l})=>lodashEs.includes(a,l)),l=>({...l}))});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),a=lodashEs.map(n,getParentId);return lodashEs.filter(o(presentBlocksAtom),l=>lodashEs.includes(a,l._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),a=o(presentBlocksAtom);let l=n;const r=[n];do{const i=a.find(({_id:c})=>c===(l==null?void 0:l._parent));l=i,i&&r.push(i)}while(l!=null&&l._parent);return r}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[o,n]=jotai.useAtom(selectedBlockIdsAtom),a=React.useCallback(l=>{n(r=>lodashEs.includes(r,l)?lodashEs.without(r,l):[...r,l])},[n]);return[o,n,a]},removeNestedBlocks=(o,n)=>{const a=[],l=lodashEs.filter(o,r=>lodashEs.includes(n,r._id)||lodashEs.includes(n,r._parent)?(a.push(r._id),!1):!0);return lodashEs.isEmpty(a)?l:removeNestedBlocks(l,a)},useRemoveBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useSelectedBlockIds(),{setNewBlocks:l}=useBlocksStoreUndoableActions();return React.useCallback(r=>{var c;const i=((c=lodashEs.find(o,{_id:r[0]}))==null?void 0:c._parent)||null;l(removeNestedBlocks(o,r)),setTimeout(()=>a(i?[i]:[]),200)},[o,a,n])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(o,n,{id:a,props:l})=>{const r=o(pageBlocksAtomsAtom),i=lodashEs.find(r,c=>o(c)._id===a);if(!i)throw new Error(`Block with id ${a} not found`);return n(i,{...o(i),...l})}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtomValue=o=>useAtomCallback(React.useCallback((n,a,l)=>{const r=n(o);if(!r||!r.length)throw new Error("No blocks available");const i=lodashEs.find(r,c=>n(c)._id===(lodashEs.isString(l)?l:n(l)._id));if(!i)throw new Error(`Block with id ${l} not found`);return n(i)},[o]),{store:builderStore}),useGetBlockAtom=o=>useAtomCallback(React.useCallback((n,a,l)=>{const r=n(o);if(!r||!r.length)return console.warn("No blocks available in splitAtoms"),null;const i=lodashEs.find(r,c=>n(c)._id===(lodashEs.isString(l)?l:n(l)._id));return i||(console.warn(`Block with id ${l} not found`),null)},[o]),{store:builderStore});function insertBlocksAtPosition(o,n,a,l){let r=o.filter(d=>!d._parent);a&&(r=o.filter(d=>d._parent===a));const i=!isNaN(l)||l>-1?Math.min(l,r.length):r.length;let c=o.length;for(let d=0,p=0;d<o.length;d++)if(o[d]._parent===a){if(p===i){c=d;break}p++}return!a&&l!==void 0&&l>=r.length&&(c=o.length),[...o.slice(0,c),...n,...o.slice(c)]}function flattenTree(o){let n=[];return o.walk(a=>(delete a.model.children,n.push(a.model),!0)),n}function findNodeById(o,n){return o.first(a=>a.model._id===n)||null}function moveNode(o,n,a,l){const r=findNodeById(o,n),i=findNodeById(o,a);if(r&&i){r.drop(),i.children||(i.model.children=[]);try{i.addChildAtIndex(r,l)}catch(c){return console.error("Error adding child to parent:",c),!1}return!0}return!1}function moveBlocksWithChildren(o,n,a,l){if(!n)return o;a=a||"root";const i=new TreeModel().parse({_id:"root",children:getBlocksTree(o)});if(moveNode(i,n,a,l)){const c=flattenTree(i),d=c.find(p=>p._id===n);return d&&(d._parent=a==="root"?null:a),c.shift(),c}return o}const useBlocksStoreManager=()=>{const[,o]=useBlocksStore(),{postMessage:n}=useBroadcastChannel(),a=useUpdateBlockAtom();return{setNewBlocks:l=>{o(l),n({type:"blocks-updated",blocks:l})},addBlocks:(l,r,i)=>{o(c=>{const d=insertBlocksAtPosition(c,l,r,i);return n({type:"blocks-updated",blocks:d}),d})},removeBlocks:l=>{o(r=>{const i=removeNestedBlocks(r,l);return n({type:"blocks-updated",blocks:i}),i})},moveBlocks:(l,r,i)=>{o(c=>{let d=[...c];for(let p=0;p<l.length;p++)d=moveBlocksWithChildren(d,l[p],r,i);return lodashEs.each(l,p=>{const u=lodashEs.find(d,m=>m._id===p);u&&a({id:p,props:{_parent:u._parent||null}})}),n({type:"blocks-updated",blocks:d}),d})},updateBlocksProps:l=>{l.forEach(r=>{const i=lodashEs.omit(r,"_id");a({id:r._id,props:i})}),n({type:"blocks-props-updated",blocks:l})}}},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:o}=useUndoManager(),[n]=useBlocksStore(),{setNewBlocks:a,addBlocks:l,removeBlocks:r,moveBlocks:i,updateBlocksProps:c}=useBlocksStoreManager();return{moveBlocks:(b,f,j)=>{const S=lodashEs.map(b,v=>{const C=n.find(N=>N._id===v)._parent||null,E=n.filter(N=>C?N._parent===C:!N._parent).map(N=>N._id).indexOf(v);return{_id:v,oldParent:C,oldPosition:E}}),w=S.find(({_id:v})=>v===b[0]);w&&w.oldParent===f&&w.oldPosition===j||(i(b,f,j),o({undo:()=>lodashEs.each(S,({_id:v,oldParent:k,oldPosition:C})=>{i([v],k,C)}),redo:()=>i(b,f,j)}))},addBlocks:(b,f,j)=>{l(b,f,j),o({undo:()=>r(lodashEs.map(b,"_id")),redo:()=>l(b,f,j)})},removeBlocks:b=>{var w;const f=(w=lodashEs.first(b))==null?void 0:w._parent,S=n.filter(v=>f?v._parent===f:!v._parent).indexOf(lodashEs.first(b));r(lodashEs.map(b,"_id")),o({undo:()=>l(b,f,S),redo:()=>r(lodashEs.map(b,"_id"))})},updateBlocks:(b,f,j)=>{let S=[];if(j)S=lodashEs.map(b,w=>({_id:w,...j}));else{const w=lodashEs.keys(f);S=lodashEs.map(b,v=>{const k=n.find(B=>B._id===v),C={_id:v};return lodashEs.each(w,B=>C[B]=k[B]),C})}c(lodashEs.map(b,w=>({_id:w,...f}))),o({undo:()=>c(S),redo:()=>c(lodashEs.map(b,w=>({_id:w,...f})))})},updateBlocksRuntime:(b,f)=>{c(lodashEs.map(b,j=>({_id:j,...f})))},setNewBlocks:b=>{a(b),o({undo:()=>a(n),redo:()=>a(b)})},updateMultipleBlocksProps:b=>{let f=[];f=lodashEs.map(b,j=>{const S=lodashEs.keys(j),w=n.find(k=>k._id===j._id),v={};return lodashEs.each(S,k=>v[k]=w[k]),v}),c(b),o({undo:()=>c(f),redo:()=>c(b)})}}},canAcceptChildBlock=(o,n)=>{if(!o)return!0;const a=runtime.getRegisteredChaiBlock(o);return a&&lodashEs.has(a,"canAcceptBlock")?a.canAcceptBlock(n):!1},canAddChildBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n?lodashEs.has(n,"canAcceptBlock"):!1},canBeNestedInside=(o,n)=>{const a=runtime.getRegisteredChaiBlock(n);return a&&lodashEs.has(a,"canBeNested")?a.canBeNested(o):!0},canDuplicateBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n&&lodashEs.has(n,"canDuplicate")?n.canDuplicate():!0},canDeleteBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n&&lodashEs.has(n,"canDelete")?n.canDelete():!0},canDropBlock=(o,{dragSource:n,dropTarget:a})=>{const l=lodashEs.get(n,"data._type",""),r=lodashEs.get(a,"data._type","");return canAcceptChildBlock(r,l)},useAddBlock=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions(),l=React.useCallback((i,c,d)=>{var g;for(let x=0;x<i.length;x++){const{_id:b}=i[x];i[x]._id=iconBase.generateUUID();const f=lodashEs.filter(i,{_parent:b});for(let j=0;j<f.length;j++)f[j]._parent=i[x]._id}const p=lodashEs.first(i);let u,m;return c&&(u=lodashEs.find(o,{_id:c}),i[0]._parent=c,m=c),!(u?canAcceptChildBlock(u==null?void 0:u._type,p._type):!0)&&u&&(i[0]._parent=u._parent,m=u._parent),a(i,m,d),n([(g=lodashEs.first(i))==null?void 0:g._id]),lodashEs.first(i)},[a,o,n]);return{addCoreBlock:React.useCallback((i,c,d)=>{if(lodashEs.has(i,"blocks")){const f=i.blocks;return l(f,c,d)}const p=iconBase.generateUUID(),u=runtime.getDefaultBlockProps(i.type),m={_type:i.type,_id:p,...u};let h,g;return c&&(h=lodashEs.find(o,{_id:c}),m._parent=c,g=c),!canAcceptChildBlock(h==null?void 0:h._type,m._type)&&h&&(m._parent=h._parent,g=h._parent),a([m],g,d),n([m._id]),m},[a,l,o,n]),addPredefinedBlock:l}},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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:lodashEs.map(CLASS_VALUES.columns,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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:lodashEs.map(CLASS_VALUES.indent,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"},backgroundAttachment:{classes:lodashEs.map(["fixed","local","scroll"],o=>`bg-${o}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...lodashEs.map(CLASS_VALUES.borderRadius,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|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-${o}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},colorOptions={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},soloColors=["current","inherit","transparent","black","white"],shadedColors=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],shades=["50","100","200","300","400","500","600","700","800","900"],colorKeys=lodashEs.map(lodashEs.values(colorOptions),o=>o),ALL_COLORS=lodashEs.flattenDeep([...lodashEs.map(soloColors,o=>lodashEs.flatten(lodashEs.map(colorKeys,n=>`${n}-${o}`))),...lodashEs.map(shadedColors,o=>lodashEs.flattenDeep(lodashEs.map(colorKeys,n=>lodashEs.flattenDeep(lodashEs.map(shades,a=>`${n}-${o}-${a}`)))))]),ALL_TW_CLASSES=lodashEs.map(lodashEs.flattenDeep(lodashEs.values(CLASSES_LIST).map(o=>o.classes).concat(ALL_COLORS)),o=>({name:o})),useFuseSearch=()=>{const o=useThemeOptions(),n=React.useMemo(()=>{let a=[];if(o.colors){const l=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:r})=>lodashEs.keys(r)));a=lodashEs.flattenDeep(lodashEs.map(l,r=>lodashEs.flatten(lodashEs.map(colorKeys,i=>`${i}-${r}`))))}return o.fontFamily&&(a=[...a,...lodashEs.map(lodashEs.keys(o.fontFamily),l=>`${l}`)]),lodashEs.map(a,l=>({name:l}))},[o]);return React.useMemo(()=>new Fuse([...ALL_TW_CLASSES,...n],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[n])},useTailwindClassList=()=>{const o=useThemeOptions(),n=React.useMemo(()=>{if(o.colors){const r=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:i})=>lodashEs.keys(i)));lodashEs.each(CLASSES_LIST,(i,c)=>{lodashEs.set(CLASSES_LIST,`${c}.regExp`,i.regExp.replace("__THEME_COLORS_REGEXP__",r.join("|")))})}return CLASSES_LIST},[o]),a=React.useCallback((r,i)=>{const c=lodashEs.get(n,`${r}.regExp`,"");return i.match(new RegExp(c))},[n]),l=React.useCallback((r,i=[])=>lodashEs.get(n,`${r}.classes`,i),[n]);return{match:a,getClasses:l}};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,l=>`${l}:`).join("|"),a=new RegExp(n,"g");return lodashEs.get(a.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 a in CLASSES_LIST){const l=lodashEs.get(CLASSES_LIST,`${a}.regExp`,"");if(new RegExp(l,"g").test(o)){n=a,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}function orderClassesByBreakpoint(o){o=o.replace(/\s+/g," ");const n=o.split(" ").map(constructClassObject),a=["xs","sm","md","lg","xl","2xl"];return n.sort((l,r)=>a.indexOf(l.mq)-a.indexOf(r.mq)).map(l=>l.fullCls).join(" ")}function removeDuplicateClasses(o){if(o=o.replace(/\s+/g," "),!o)return"";const n=["xs","sm","md","lg","xl","2xl"],a=o.split(" ").map(constructClassObject);let l=o;if(a.length===1)return a[0].fullCls;for(const r of a){const i=r.property,c=n.indexOf(r.mq);for(let d=c+1;d<n.length;d++){const p=n[d],u=a.find(m=>m.property===i&&m.mq===p);if(u&&u.cls===r.cls)l=l.replace(u.fullCls,"");else if(u&&u.cls!==r.cls)break}}return l.replace(/\s+/g," ").trim()}const selectedStylingBlocksAtom=jotai.atom([]);selectedStylingBlocksAtom.debugLabel="selectedStylingBlocksAtom";const useSelectedStylingBlocks=()=>jotai.useAtom(selectedStylingBlocksAtom),addClassesToBlocksAtom=jotai.atom(null,(o,n,{blockIds:a,newClasses:l})=>{const r=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id)),i=lodashEs.first(o(selectedStylingBlocksAtom));return lodashEs.map(r,c=>{const d=o(c),p=lodashEs.get(d,i.prop,`${getSplitClasses.STYLES_KEY},`),{classes:u}=getSplitClasses.getSplitChaiClasses(p);return{ids:[d._id],props:{[i.prop]:`${getSplitClasses.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(u,l)))}`}}})}),useAddClassesToBlocks=()=>{const o=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:n,updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback((l,r,i=!1)=>{const c=o({blockIds:l,newClasses:r});if(!i){a(l,c[0].props);return}n(l,c[0].props)},[o,n,a])},LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},languageAtom=jotai.atom("");languageAtom.debugLabel="selectedLanguageAtom";const useLanguages=()=>{const o=useBuilderProp("languages",[]),n=useBuilderProp("fallbackLang","en"),[a,l]=jotai.useAtom(languageAtom),r=i=>{l(n===i?"":i)};return{languages:o==null?void 0:o.filter(i=>i!==n),fallbackLang:n,selectedLang:a,setSelectedLang:r}},updatePropsForLanguage=(o,n,a)=>{const l=runtime.getRegisteredChaiBlock(lodashEs.get(a,"_type"));if(!l)return o;const r={...o};return lodashEs.forEach(lodashEs.keys(o),i=>{if(lodashEs.includes(lodashEs.get(l,"i18nProps",[]),i)&&!lodashEs.isEmpty(n)){const c=`${i}-${n}`;lodashEs.set(r,c,o[i]),lodashEs.unset(r,i)}}),r},useUpdateBlocksProps=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((l,r,i)=>{const c=updatePropsForLanguage(r,n,a);o(l,c,i)},[n,a,o])},useUpdateMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions();return React.useCallback(n=>{o(n)},[o])},useFakeStreamEffect=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions();return React.useCallback(async(n,a,l=30)=>{const r=lodashEs.keys(lodashEs.omit(a,["_id"]));for(const i of r){const c=a[i];if(lodashEs.isString(c)){const d=lodashEs.chunk(c.split(""),12);let p="";o([n],{[i]:""});for(let u=0;u<d.length;u++)p+=d[u].join(""),o([n],{[i]:p}),await new Promise(m=>setTimeout(m,l))}}},[o])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions(),n=useFakeStreamEffect();return React.useCallback(async a=>{for(const l of a)await n(l._id,l);o(a)},[n,o])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((l,r)=>{const i=updatePropsForLanguage(r,n,a);o(l,i)},[n,a,o])};function getChildBlocks(o,n,a){a.push(lodashEs.find(o,{_id:n}));const l=lodashEs.filter(o,{_parent:n});for(const r of l)a.push(...getBlockWithChildren(r._id,o));return a}const getBlockWithChildren=(o,n)=>{let a=[];return a=lodashEs.flattenDeep([...a,...getChildBlocks(n,o,a)]),a},pickOnlyAIProps=(o,n)=>lodashEs.compact(o.map(a=>{const l=["_id","_type","_parent"],r=lodashEs.pick(a,l),i=runtime.getRegisteredChaiBlock(a._type),c={},d=lodashEs.get(i,"aiProps",[]);for(const p in a)l.includes(p)||d.includes(p)&&(c[p]=lodashEs.get(a,`${p}-${n}`,a[p]));return lodashEs.isEmpty(c)?!1:(lodashEs.has(r,"_parent")&&lodashEs.isEmpty(r._parent)&&delete r._parent,{...r,...c})})),addLangToPrompt=(o,n,a)=>!n||a!=="content"?o:`${o}. Generate content in ${lodashEs.get(LANGUAGES,n,n)} language.`,askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[o,n]=jotai.useAtom(askAiProcessingAtom),[a,l]=React.useState(null),r=useBuilderProp("askAiCallBack",null),i=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:p,fallbackLang:u}=useLanguages(),m=p.length?p:u,h=(g,x)=>{const b=lodashEs.cloneDeep(x.find(f=>f._id===g));for(const f in b){const j=b[f];if(typeof j=="string"&&lodashEs.startsWith(j,getSplitClasses.STYLES_KEY)){const{baseClasses:S,classes:w}=getSplitClasses.getSplitChaiClasses(j);b[f]=lodashEs.compact(lodashEs.flattenDeep([S,w])).join(" ")}else f!=="_id"&&delete b[f]}return b};return{askAi:React.useCallback(async(g,x,b,f)=>{if(r){n(!0),l(null);try{const j=p===u?"":p,S=g==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(x,d)),p):[h(x,d)],w=await r(g,addLangToPrompt(b,m,g),S,j),{blocks:v,error:k}=w;if(k){l(k);return}if(g==="styles"){const C=v.map(B=>{for(const E in B)E!=="_id"&&(B[E]=`${getSplitClasses.STYLES_KEY},${B[E]}`);return B});c(C)}else i(v);f&&f(w)}catch(j){l(j)}finally{n(!1),f&&f()}}},[r,n,p,u,d,m,c,i]),loading:o,error:a}},useAiAssistant=()=>{const[,o]=useRightPanel();return React.useCallback(n=>{o(n?"ai":"block")},[o])};let lastHighlighted=null;const useBlockHighlight=()=>{const[o]=jotai.useAtom(canvasIframeAtom),n=React.useMemo(()=>{var r;return(o==null?void 0:o.contentDocument)||((r=o==null?void 0:o.contentWindow)==null?void 0:r.document)},[o]);return{highlightBlock:React.useCallback(r=>{if(n)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof r!="string")r.setAttribute("data-highlighted","true"),lastHighlighted=r;else if(typeof r=="string"){const i=n.querySelector(`[data-block-id="${r}"]`);i&&(i.setAttribute("data-highlighted","true"),lastHighlighted=i)}else lastHighlighted=null},[n]),clearHighlight:()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},lastHighlighted}},globalBlocksStoreAtom=atom({}),globalBlocksLoadingStateAtom=atom({}),useGlobalBlocksStore=()=>{const[o,n]=useAtom(globalBlocksStoreAtom),a=React.useCallback(r=>lodashEs.get(o,r,[]),[o]),l=React.useCallback(()=>n({}),[n]);return{getGlobalBlocks:a,reset:l}},useWatchGlobalBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useAtom(globalBlocksStoreAtom),[l,r]=useAtom(globalBlocksLoadingStateAtom),i=useBuilderProp("getGlobalBlockBlocks",async d=>[]),c=React.useMemo(()=>o.filter(p=>p._type==="GlobalBlock").filter(p=>p._type==="GlobalBlock").map(p=>p.globalBlock),[o]);React.useEffect(()=>{lodashEs.forEach(c,d=>{lodashEs.has(n,d)||lodashEs.get(l,`${d}.loading`,!1)||(r(p=>({...p,[d]:{loading:!0,error:null}})),i(d).then(p=>{a(u=>({...u,[d]:p})),r(u=>({...u,[d]:{loading:!1,error:null}}))}).catch(p=>{r(u=>({...u,[d]:{loading:!1,error:p.message}}))}))})},[i,n,c,l,a,r])},globalBlocksListAtom=atom({}),useGlobalBlocksList=()=>{const[o,n]=React.useState(!1),[a,l]=useAtom(globalBlocksListAtom),r=useBuilderProp("getGlobalBlocks",async()=>[]),i=React.useCallback(async()=>{n(!0);const c=await r();l(c),n(!1)},[r,l]);return React.useEffect(()=>{i()},[]),{data:a,isLoading:o,refetch:i}},useBuilderReset=()=>{const o=jotai.useSetAtom(historyStatesAtom),{clear:n}=useUndoManager(),[,a]=useSelectedBlockIds(),{clearHighlight:l}=useBlockHighlight(),[,r]=useSelectedStylingBlocks(),[,i]=useAtom(aiAssistantActiveAtom),{reset:c}=useGlobalBlocksStore();return()=>{a([]),r([]),l(),n(),i(!1),o({undoCount:0,redoCount:0}),c()}},canvasZoomAtom=atomWithStorage("canvasZoom",100),useCanvasZoom=()=>jotai.useAtom(canvasZoomAtom),codeEditorAtom=jotai.atom(null),useCodeEditor=()=>jotai.useAtom(codeEditorAtom),cutBlockIdsAtom=jotai.atom([]),useCutBlockIds=()=>{const[o,n]=jotai.useAtom(cutBlockIdsAtom),a=jotai.useSetAtom(copiedBlockIdsAtom),l=React.useCallback(r=>{n(r),a([])},[n,a]);return[o,l]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlockIds=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(copiedBlockIdsAtom),l=jotai.useSetAtom(cutBlockIdsAtom),r=React.useCallback(async i=>{try{a(i),l([]);const c={_chai_copied_blocks:i.flatMap(d=>getDuplicatedBlocks(o,d,null))};await navigator.clipboard.writeText(JSON.stringify(c))}catch(c){console.error("Failed to copy blocks to clipboard:",c)}},[a,l,o]);return[n,r]},useCopyToClipboard=()=>{const[o,n]=React.useState(null),a=React.useCallback(async l=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(l),n(l),!0}catch(r){return console.warn("Copy failed",r),n(null),!1}},[]);return[o,a]},darkModeAtom=atomWithStorage("darkMode",!1),useDarkMode=()=>{const[o,n]=jotai.useAtom(darkModeAtom);return[o,n]},useDuplicateBlocks=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions();return React.useCallback((l,r=null)=>{const i=[];lodashEs.each(l,c=>{const d=o.find(g=>g._id===c);r?r==="root"&&(r=null):r=d._parent;const m=lodashEs.filter(o,g=>lodashEs.isString(r)?g._parent===r:!g._parent).indexOf(d)+1,h=getDuplicatedBlocks(o,c,r);a(h,r,m),i.push(lodashEs.get(h,"0._id",""))}),n(i)},[o,n])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[o,n]=jotai.useAtom(hiddenBlockIdsAtom),a=React.useCallback(l=>{n(r=>lodashEs.includes(r,l)?lodashEs.without(r,l):[...r,l])},[n]);return[o,n,a]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),useCanPaste=()=>{const[o]=useBlocksStore();return(n,a)=>{var i;const l=((i=lodashEs.find(o,{_id:a}))==null?void 0:i._type)||null,r=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(l,r)}},useMoveCutBlocks=()=>{const o=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:n}=useBlocksStoreUndoableActions();return React.useCallback((a,l)=>{const r=Array.isArray(l)?l[0]:l;if(l==="root"){const i=o==null?void 0:o.filter(c=>!c._parent);n(a,null,(i==null?void 0:i.length)||0)}else{const i=o==null?void 0:o.filter(c=>c._parent===r);n(a,r,(i==null?void 0:i.length)||0)}},[n,o])},usePasteBlocks=()=>{const[o,n]=useCutBlockIds(),a=useMoveCutBlocks(),l=useCanPaste(),{addPredefinedBlock:r}=useAddBlock();return{canPaste:React.useCallback(async c=>{if(o.length>0)return l(o,c);try{const d=await navigator.clipboard.readText();if(d){const p=JSON.parse(d);return lodashEs.has(p,"_chai_copied_blocks")}}catch{return!1}return!1},[l,o]),pasteBlocks:React.useCallback(async c=>{const d=Array.isArray(c)?c[0]:c;if(!lodashEs.isEmpty(o)){a(o,c),n([]),await navigator.clipboard.writeText("");return}try{const p=await navigator.clipboard.readText();if(p){const u=JSON.parse(p);lodashEs.has(u,"_chai_copied_blocks")?r(u._chai_copied_blocks,d==="root"?null:d):sonner.toast.error("Nothing to paste")}else sonner.toast.error("Nothing to paste")}catch{sonner.toast.error("Failed to paste blocks from clipboard")}},[o,r,a,n])}},previewModeAtom=jotai.atom(!1),usePreviewMode=()=>{const[o,n]=jotai.useAtom(previewModeAtom);return[o,n]},removeClassFromBlocksAtom=jotai.atom(null,(o,n,{blockIds:a,fullClasses:l})=>{const r=lodashEs.first(o(selectedStylingBlocksAtom)),i=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id));return lodashEs.map(i,c=>{const d=o(c),p=l;let{classes:u,baseClasses:m}=getSplitClasses.getSplitChaiClasses(lodashEs.get(d,r.prop,`${getSplitClasses.STYLES_KEY},`));return lodashEs.each(p,h=>{const g=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`(^|\\s)${g}(?=\\s|$)`,"g");u=u.replace(x," ").replace(/\s+/g," ").trim();const b=lodashEs.first(h.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],b)&&p.push(h.split(":").pop().trim())}),lodashEs.each(p,h=>{const g=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`(^|\\s)${g}(?=\\s|$)`,"g");m=m.replace(x," ").replace(/\s+/g," ").trim()}),{ids:[d._id],props:{[r.prop]:`${getSplitClasses.STYLES_KEY}${m},${u}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:o,updateBlocksRuntime:n}=useBlocksStoreUndoableActions(),a=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((l,r,i=!1)=>{const c=a({blockIds:l,fullClasses:r});i?o(l,c[0].props):n(l,c[0].props)},[a])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(o=>{const n=o(canvasWidthAtom);return iconBase.getBreakpointValue(n).toLowerCase()}),useScreenSizeWidth=()=>{const[o,n]=jotai.useAtom(canvasWidthAtom),a=jotai.useAtomValue(canvasBreakpointAtom),[l,r]=useStylingBreakpoint();return React.useEffect(()=>{l!=="xs"&&r(a)},[a,l,r]),[o,a,n]},useCanvasDisplayWidth=()=>{const[o,n]=jotai.useAtom(canvasDisplayWidthAtom);return[o,n]},selectedBlockAllClassesAtom=jotai.atom(o=>{const n=lodashEs.first(o(selectedStylingBlocksAtom)),a=o(selectedBlockAtom);if(!n||n.blockId!==lodashEs.get(a,"_id",null))return[];const l=lodashEs.get(a,n.prop,`${getSplitClasses.STYLES_KEY},`),{classes:r}=getSplitClasses.getSplitChaiClasses(l);return lodashEs.filter(lodashEs.map(r.trim().split(" "),constructClassObject),i=>!lodashEs.isNull(i))}),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),a=o(styleStateAtom),l=o(darkModeAtom),r=getQueries(n);let i=lodashEs.filter(o(selectedBlockAllClassesAtom),{mod:a});return lodashEs.startsWith(a,"_")||(i=lodashEs.filter(i,c=>r.includes(c.mq))),i=i.sort((c,d)=>MQ[c.mq]-MQ[d.mq]),l||(i=lodashEs.filter(i,{dark:!1})),i}),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),selectedBreakpointsAtom=atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),useSelectedBreakpoints=()=>{const[o,n]=jotai.useAtom(selectedBreakpointsAtom);return[o,n]},useStylingState=()=>jotai.useAtom(styleStateAtom),useUILibraryBlocks=()=>({data:useBuilderProp("uiLibraries",[]),isLoading:!1}),wrapperBlockAtom=jotai.atom(o=>{var c;const n=o(presentBlocksAtom),a=o(selectedBlockIdsAtom),l=a.length===1?a[0]:null;if(!l)return null;const r=lodashEs.find(n,{_id:l});if(!r)return null;let i=r._parent;for(;i;){const d=lodashEs.find(n,{_id:i});if(!d)return null;if((c=runtime.getRegisteredChaiBlock(d._type))!=null&&c.wrapper)return d;i=d._parent}return null});wrapperBlockAtom.debugLabel="wrapperBlockAtom";const useWrapperBlock=()=>jotai.useAtomValue(wrapperBlockAtom),layoutVariantAtom=atomWithStorage("_layout_variant_mode","DUAL_SIDE_PANEL"),useLayoutVariant=()=>{const[o,n]=jotai.useAtom(layoutVariantAtom),a=useBuilderProp("layoutVariant","DUAL_SIDE_PANEL");return[o||a,n]},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS"};class PubSub{constructor(){U(this,"subscribers",new Map)}subscribe(n,a){return this.subscribers.has(n)||this.subscribers.set(n,new Set),this.subscribers.get(n).add(a),()=>{const l=this.subscribers.get(n);l&&(l.delete(a),l.size===0&&this.subscribers.delete(n))}}publish(n,a){const l=this.subscribers.get(n);l&&l.forEach(r=>r(a))}}const pubsub=new PubSub,draggedBlockAtom=jotai.atom(null),dropTargetBlockIdAtom=jotai.atom(null),BlockActionLabel=({block:o,label:n})=>{const[,a]=useSelectedBlockIds(),[,l]=useHighlightBlockId(),[,r]=jotai.useAtom(draggedBlockAtom),i=flagged.useFeature("dnd");return jsxRuntime.jsxs("div",{className:"mr-10 flex cursor-default items-center space-x-1 px-1",draggable:i?"true":"false",onDragStart:c=>{c.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.pick(o,["_id","_type","_name"]))),r(o),setTimeout(()=>{a([]),l(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),n]})},BlockFloatingSelector=({selectedBlockElement:o,block:n})=>{const a=useRemoveBlocks(),l=useDuplicateBlocks(),[,r]=useSelectedBlockIds(),[,i]=useHighlightBlockId(),[,c]=useSelectedStylingBlocks(),[d]=jotai.useAtom(inlineEditingActiveAtom),{floatingStyles:p,refs:u,update:m}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:o}});web.useResizeObserver(o,()=>m(),o!==null);const h=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.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:u.setFloating,style:p,onClick:x=>{x.stopPropagation(),x.preventDefault()},onMouseEnter:x=>{x.stopPropagation(),i(null)},onKeyDown:x=>x.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[h&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{c([]),r([h])}}),jsxRuntime.jsx(BlockActionLabel,{label:g,block:n}),jsxRuntime.jsxs("div",{className:"flex gap-2 px-1",children:[canAddChildBlock(lodashEs.get(n,"_type",""))&&jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,n)}),canDuplicateBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>l([n==null?void 0:n._id])}):null,canDeleteBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>a([n==null?void 0:n._id])}):null]})]})})},IframeInitialContent=`<!doctype html>
|
|
1
|
+
"use strict";var G=Object.defineProperty;var K=(o,n,a)=>n in o?G(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a;var U=(o,n,a)=>K(o,typeof n!="symbol"?n+"":n,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),React=require("react"),tooltip=require("./tooltip-DHlrjqh8.cjs"),jotai=require("jotai"),lodashEs=require("lodash-es"),reactWrapBalancer=require("react-wrap-balancer"),reactI18next=require("react-i18next"),iconBase=require("./iconBase-Cn2BsTrq.cjs"),dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),reactIcons=require("@radix-ui/react-icons"),web=require("@react-hookz/web"),flagged=require("flagged"),runtime=require("@chaibuilder/runtime"),ChaiThemeFn=require("./ChaiThemeFn-DQu-2Eh9.cjs"),TreeModel=require("tree-model"),reactHotkeysHook=require("react-hotkeys-hook"),sonner=require("sonner"),lucideReact=require("lucide-react"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),typography=require("@tailwindcss/typography"),forms=require("@tailwindcss/forms"),aspectRatio=require("@tailwindcss/aspect-ratio"),containerQueries=require("@tailwindcss/container-queries"),tailwindMerge=require("tailwind-merge"),getSplitClasses=require("./getSplitClasses-DodqA_KW.cjs"),ReactDOM=require("react-dom"),reactErrorBoundary=require("react-error-boundary"),reResizable=require("re-resizable"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),clsx=require("clsx"),IconPicker=require("react-icons-picker"),Autosuggest=require("react-autosuggest"),Fuse=require("fuse.js"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),i18n=require("i18next"),framerMotion=require("framer-motion");function _interopNamespaceDefault(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(n,a,l.get?l:{enumerable:!0,get:()=>o[a]})}}return n.default=o,Object.freeze(n)}const React__namespace=_interopNamespaceDefault(React),isSelfAtom=(o,n)=>o.unstable_is?o.unstable_is(n):n===o,hasInitialValue=o=>"init"in o,isActuallyWritableAtom=o=>!!o.write,isAtomStateInitialized=o=>"v"in o||"e"in o,returnAtomValue=o=>{if("e"in o)throw o.e;return o.v},PROMISE_STATE=Symbol(),getPromiseState=o=>o[PROMISE_STATE],isPendingPromise=o=>{var n;return isPromiseLike$2(o)&&!((n=getPromiseState(o))!=null&&n[1])},cancelPromise=(o,n)=>{const a=getPromiseState(o);a&&(a[1]=!0,a[0].forEach(l=>l(n)))},patchPromiseForCancelability=o=>{if(getPromiseState(o))return;const n=[new Set,!1];o[PROMISE_STATE]=n;const a=()=>{n[1]=!0};o.then(a,a),o.onCancel=l=>{n[0].add(l)}},isPromiseLike$2=o=>typeof(o==null?void 0:o.then)=="function",addPendingPromiseToDependency=(o,n,a)=>{a.p.has(o)||(a.p.add(o),n.then(()=>{a.p.delete(o)},()=>{a.p.delete(o)}))},setAtomStateValueOrPromise=(o,n,a)=>{const l=a(o),r="v"in l,i=l.v,c=isPendingPromise(l.v)?l.v:null;if(isPromiseLike$2(n)){patchPromiseForCancelability(n);for(const d of l.d.keys())addPendingPromiseToDependency(o,n,a(d))}l.v=n,delete l.e,(!r||!Object.is(i,l.v))&&(++l.n,c&&cancelPromise(c,n))},getMountedOrPendingDependents=(o,n,a)=>{var l;const r=new Set;for(const i of((l=a.get(o))==null?void 0:l.t)||[])a.has(i)&&r.add(i);for(const i of n.p)r.add(i);return r},BUILDING_BLOCKS=Symbol(),buildStore=(o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new Set,r=new Set,i=new Set,c={},d=(g,...x)=>g.read(...x),p=(g,...x)=>g.write(...x),u=(g,x)=>{var b;return(b=g.unstable_onInit)==null?void 0:b.call(g,x)},m=(g,x)=>{var b;return(b=g.onMount)==null?void 0:b.call(g,x)},...h)=>{const g=h[0]||(E=>{let N=o.get(E);return N||(N={d:new Map,p:new Set,n:0},o.set(E,N),u==null||u(E,B)),N}),x=h[1]||(()=>{let E,N;const y=R=>{try{R()}catch(_){E||(E=!0,N=_)}};do{c.f&&y(c.f);const R=new Set,_=R.add.bind(R);l.forEach(I=>{var T;return(T=n.get(I))==null?void 0:T.l.forEach(_)}),l.clear(),i.forEach(_),i.clear(),r.forEach(_),r.clear(),R.forEach(y),l.size&&b()}while(l.size||i.size||r.size);if(E)throw N}),b=h[2]||(()=>{const E=[],N=new WeakSet,y=new WeakSet,R=Array.from(l);for(;R.length;){const _=R[R.length-1],I=g(_);if(y.has(_)){R.pop();continue}if(N.has(_)){a.get(_)===I.n&&E.push([_,I]),y.add(_),R.pop();continue}N.add(_);for(const T of getMountedOrPendingDependents(_,I,n))N.has(T)||R.push(T)}for(let _=E.length-1;_>=0;--_){const[I,T]=E[_];let P=!1;for(const A of T.d.keys())if(A!==I&&l.has(A)){P=!0;break}P&&(f(I),w(I)),a.delete(I)}}),f=h[3]||(E=>{var N,y;const R=g(E);if(isAtomStateInitialized(R)&&(n.has(E)&&a.get(E)!==R.n||Array.from(R.d).every(([L,H])=>f(L).n===H)))return R;R.d.clear();let _=!0;const I=()=>{n.has(E)&&(w(E),b(),x())},T=L=>{var H;if(isSelfAtom(E,L)){const V=g(L);if(!isAtomStateInitialized(V))if(hasInitialValue(L))setAtomStateValueOrPromise(L,L.init,g);else throw new Error("no atom init");return returnAtomValue(V)}const O=f(L);try{return returnAtomValue(O)}finally{R.d.set(L,O.n),isPendingPromise(R.v)&&addPendingPromiseToDependency(E,R.v,O),(H=n.get(L))==null||H.t.add(E),_||I()}};let P,A;const D={get signal(){return P||(P=new AbortController),P.signal},get setSelf(){return!A&&isActuallyWritableAtom(E)&&(A=(...L)=>{if(!_)try{return S(E,...L)}finally{b(),x()}}),A}},M=R.n;try{const L=d(E,T,D);return setAtomStateValueOrPromise(E,L,g),isPromiseLike$2(L)&&((N=L.onCancel)==null||N.call(L,()=>P==null?void 0:P.abort()),L.then(I,I)),R}catch(L){return delete R.v,R.e=L,++R.n,R}finally{_=!1,M!==R.n&&a.get(E)===M&&(a.set(E,R.n),l.add(E),(y=c.c)==null||y.call(c,E))}}),j=h[4]||(E=>{const N=[E];for(;N.length;){const y=N.pop(),R=g(y);for(const _ of getMountedOrPendingDependents(y,R,n)){const I=g(_);a.set(_,I.n),N.push(_)}}}),S=h[5]||((E,...N)=>{let y=!0;const R=I=>returnAtomValue(f(I)),_=(I,...T)=>{var P;const A=g(I);try{if(isSelfAtom(E,I)){if(!hasInitialValue(I))throw new Error("atom not writable");const D=A.n,M=T[0];setAtomStateValueOrPromise(I,M,g),w(I),D!==A.n&&(l.add(I),(P=c.c)==null||P.call(c,I),j(I));return}else return S(I,...T)}finally{y||(b(),x())}};try{return p(E,R,_,...N)}finally{y=!1}}),w=h[6]||(E=>{var N;const y=g(E),R=n.get(E);if(R&&!isPendingPromise(y.v)){for(const[_,I]of y.d)if(!R.d.has(_)){const T=g(_);v(_).t.add(E),R.d.add(_),I!==T.n&&(l.add(_),(N=c.c)==null||N.call(c,_),j(_))}for(const _ of R.d||[])if(!y.d.has(_)){R.d.delete(_);const I=k(_);I==null||I.t.delete(E)}}}),v=h[7]||(E=>{var N;const y=g(E);let R=n.get(E);if(!R){f(E);for(const _ of y.d.keys())v(_).t.add(E);if(R={l:new Set,d:new Set(y.d.keys()),t:new Set},n.set(E,R),(N=c.m)==null||N.call(c,E),isActuallyWritableAtom(E)){const _=()=>{let I=!0;const T=(...P)=>{try{return S(E,...P)}finally{I||(b(),x())}};try{const P=m(E,T);P&&(R.u=()=>{I=!0;try{P()}finally{I=!1}})}finally{I=!1}};r.add(_)}}return R}),k=h[8]||(E=>{var N;const y=g(E);let R=n.get(E);if(R&&!R.l.size&&!Array.from(R.t).some(_=>{var I;return(I=n.get(_))==null?void 0:I.d.has(E)})){R.u&&i.add(R.u),R=void 0,n.delete(E),(N=c.u)==null||N.call(c,E);for(const _ of y.d.keys()){const I=k(_);I==null||I.t.delete(E)}return}return R}),C=[o,n,a,l,r,i,c,d,p,u,m,g,x,b,f,j,S,w,v,k],B={get:E=>returnAtomValue(f(E)),set:(E,...N)=>{try{return S(E,...N)}finally{b(),x()}},sub:(E,N)=>{const R=v(E).l;return R.add(N),x(),()=>{R.delete(N),k(E),x()}}};return Object.defineProperty(B,BUILDING_BLOCKS,{value:C}),B},INTERNAL_buildStoreRev1=buildStore;let keyCount=0;function atom(o,n){const a=`atom${++keyCount}`,l={toString(){return a}};return typeof o=="function"?l.read=o:(l.init=o,l.read=defaultRead,l.write=defaultWrite),n&&(l.write=n),l}function defaultRead(o){return o(this)}function defaultWrite(o,n,a){return n(this,typeof a=="function"?a(o(this)):a)}const createStore=()=>INTERNAL_buildStoreRev1();let defaultStore;const getDefaultStore=()=>(defaultStore||(defaultStore=createStore()),defaultStore),RESET=Symbol(""),getCached$1=(o,n,a)=>(n.has(a)?n:n.set(a,o())).get(a),cache1$2=new WeakMap,memo2$1=(o,n,a)=>{const l=getCached$1(()=>new WeakMap,cache1$2,n);return getCached$1(o,l,a)},cacheKeyForEmptyKeyExtractor={},isWritable=o=>!!o.write,isFunction=o=>typeof o=="function";function splitAtom(o,n){return memo2$1(()=>{const a=new WeakMap,l=(c,d)=>{let p=a.get(c);if(p)return p;const u=d&&a.get(d),m=[],h=[];return c.forEach((g,x)=>{const b=x;h[x]=b;const f=u&&u.atomList[u.keyList.indexOf(b)];if(f){m[x]=f;return}const j=w=>{const v=w(r),k=w(o),B=l(k,v==null?void 0:v.arr).keyList.indexOf(b);if(B<0||B>=k.length){const E=c[l(c).keyList.indexOf(b)];if(E)return E;throw new Error("splitAtom: index out of bounds for read")}return k[B]},S=(w,v,k)=>{const C=w(r),B=w(o),N=l(B,C==null?void 0:C.arr).keyList.indexOf(b);if(N<0||N>=B.length)throw new Error("splitAtom: index out of bounds for write");const y=isFunction(k)?k(B[N]):k;Object.is(B[N],y)||v(o,[...B.slice(0,N),y,...B.slice(N+1)])};m[x]=isWritable(o)?atom(j,S):atom(j)}),u&&u.keyList.length===h.length&&u.keyList.every((g,x)=>g===h[x])?p=u:p={arr:c,atomList:m,keyList:h},a.set(c,p),p},r=atom(c=>{const d=c(r),p=c(o);return l(p,d==null?void 0:d.arr)});r.init=void 0;const i=isWritable(o)?atom(c=>c(r).atomList,(c,d,p)=>{switch(p.type){case"remove":{const u=c(i).indexOf(p.atom);if(u>=0){const m=c(o);d(o,[...m.slice(0,u),...m.slice(u+1)])}break}case"insert":{const u=p.before?c(i).indexOf(p.before):c(i).length;if(u>=0){const m=c(o);d(o,[...m.slice(0,u),p.value,...m.slice(u)])}break}case"move":{const u=c(i).indexOf(p.atom),m=p.before?c(i).indexOf(p.before):c(i).length;if(u>=0&&m>=0){const h=c(o);u<m?d(o,[...h.slice(0,u),...h.slice(u+1,m),h[u],...h.slice(m)]):d(o,[...h.slice(0,m),h[u],...h.slice(m,u),...h.slice(u+1)])}break}}}):atom(c=>c(r).atomList);return i},o,cacheKeyForEmptyKeyExtractor)}const isPromiseLike$1=o=>typeof(o==null?void 0:o.then)=="function";function createJSONStorage(o=()=>{try{return window.localStorage}catch{return}},n){var a;let l,r;const i={getItem:(p,u)=>{var m,h;const g=b=>{if(b=b||"",l!==b){try{r=JSON.parse(b,n==null?void 0:n.reviver)}catch{return u}l=b}return r},x=(h=(m=o())==null?void 0:m.getItem(p))!=null?h:null;return isPromiseLike$1(x)?x.then(g):g(x)},setItem:(p,u)=>{var m;return(m=o())==null?void 0:m.setItem(p,JSON.stringify(u,void 0))},removeItem:p=>{var u;return(u=o())==null?void 0:u.removeItem(p)}},c=p=>(u,m,h)=>p(u,g=>{let x;try{x=JSON.parse(g||"")}catch{x=h}m(x)});let d;try{d=(a=o())==null?void 0:a.subscribe}catch{}return!d&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(d=(p,u)=>{if(!(o()instanceof window.Storage))return()=>{};const m=h=>{h.storageArea===o()&&h.key===p&&u(h.newValue)};return window.addEventListener("storage",m),()=>{window.removeEventListener("storage",m)}}),d&&(i.subscribe=c(d)),i}const defaultStorage=createJSONStorage();function atomWithStorage(o,n,a=defaultStorage,l){const r=atom(n);return r.onMount=c=>{c(a.getItem(o,n));let d;return a.subscribe&&(d=a.subscribe(o,c,n)),d},atom(c=>c(r),(c,d,p)=>{const u=typeof p=="function"?p(c(r)):p;return u===RESET?(d(r,n),a.removeItem(o)):u instanceof Promise?u.then(m=>(d(r,m),a.setItem(o,m))):(d(r,u),a.setItem(o,u))})}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",attachPromiseMeta=o=>{o.status="pending",o.then(n=>{o.status="fulfilled",o.value=n},n=>{o.status="rejected",o.reason=n})},use=React.use||(o=>{if(o.status==="pending")throw o;if(o.status==="fulfilled")return o.value;throw o.status==="rejected"?o.reason:(attachPromiseMeta(o),o)}),continuablePromiseMap=new WeakMap,createContinuablePromise=o=>{let n=continuablePromiseMap.get(o);return n||(n=new Promise((a,l)=>{let r=o;const i=p=>u=>{r===p&&a(u)},c=p=>u=>{r===p&&l(u)},d=p=>{"onCancel"in p&&typeof p.onCancel=="function"&&p.onCancel(u=>{isPromiseLike(u)?(continuablePromiseMap.set(u,n),r=u,u.then(i(u),c(u)),d(u)):a(u)})};o.then(i(o),c(o)),d(o)}),continuablePromiseMap.set(o,n)),n};function useAtomValue(o,n){const a=useStore(n),[[l,r,i],c]=React.useReducer(u=>{const m=a.get(o);return Object.is(u[0],m)&&u[1]===a&&u[2]===o?u:[m,a,o]},void 0,()=>[a.get(o),a,o]);let d=l;if((r!==a||i!==o)&&(c(),d=a.get(o)),React.useEffect(()=>{const u=a.sub(o,()=>{c()});return c(),u},[a,o,void 0]),React.useDebugValue(d),isPromiseLike(d)){const u=createContinuablePromise(d);return use(u)}return d}function useSetAtom(o,n){const a=useStore(n);return React.useCallback((...r)=>a.set(o,...r),[a,o])}function useAtom(o,n){return[useAtomValue(o,n),useSetAtom(o,n)]}function useAtomCallback(o,n){const a=React.useMemo(()=>atom(null,(l,r,...i)=>o(l,r,...i)),[o]);return useSetAtom(a,n)}const readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const 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="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";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)}}class Frame extends React.Component{constructor(a,l){super(a,l);U(this,"setRef",a=>{this.nodeRef.current=a;const{forwardedRef:l}=this.props;typeof l=="function"?l(a):l&&(l.current=a)});U(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});U(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 a=this.getDoc();return this.props.mountTarget?a.querySelector(this.props.mountTarget):a.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const a=this.getDoc();if(!a)return null;const l=this.props.contentDidMount,r=this.props.contentDidUpdate,i=a.defaultView||a.parentView,c=jsxRuntime.jsx(Content,{contentDidMount:l,contentDidUpdate:r,children:jsxRuntime.jsx(FrameContextProvider,{value:{document:a,window:i},children:jsxRuntime.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 a={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete a.head,delete a.initialContent,delete a.mountTarget,delete a.contentDidMount,delete a.contentDidUpdate,delete a.forwardedRef,jsxRuntime.jsx("iframe",{...a,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}U(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.jsx(Frame,{...o,forwardedRef:n}));function duplicateBlocks(o,n,a){const l=lodashEs.filter(o,i=>i._parent===n),r=[];for(let i=0;i<l.length;i++){const c=getSlots(l[i]);if(Object.keys(c).length>0&&Object.keys(c).forEach(d=>{l[i][d]=`slot:${iconBase.generateUUID()}`}),lodashEs.filter(o,{_parent:l[i]._id}).length>0){const d=iconBase.generateUUID();r.push({...l[i],oldId:l[i]._id,_id:d,_parent:a}),r.push(lodashEs.flatten(duplicateBlocks(o,l[i]._id,d)))}else r.push({...l[i],oldId:l[i]._id,_id:iconBase.generateUUID(),_parent:a})}return lodashEs.flatten(r)}function convertToBlocksTree(o){const n={};o.forEach(l=>{n[l._id]={...l,children:[]}});const a=[];return o.forEach(l=>{if(l._parent){const r=n[l._parent];r&&r.children.push(n[l._id])}else a.push(n[l._id])}),a}const getSlots=o=>{const n={};return Object.keys(o).forEach(a=>{lodashEs.isString(o[a])&&o[a].startsWith("slot")&&(n[a]=o[a].replace("slot:",""))}),n},getDuplicatedBlocks=(o,n,a=null)=>{let l=lodashEs.find(o,{_id:n});l={...l,oldId:l._id,_id:iconBase.generateUUID()},a!==(l==null?void 0:l._parent)&&(l={...l,_parent:a});const r=[l];lodashEs.filter(o,{_parent:n}).length>0&&r.push(lodashEs.flatten(duplicateBlocks(o,n,l._id)));const i=lodashEs.flatten(r);return lodashEs.map(i,c=>{const d=c,p=getSlots(d);return Object.keys(p).length>0&&Object.keys(p).forEach(u=>{const m=lodashEs.find(i,{oldId:p[u].replace("slot:","")});d[u]=`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";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,a=>lodashEs.has(a,"blockId"))});globalBlocksAtom.debugLabel="globalBlocksAtom";var undomanager={exports:{}},hasRequiredUndomanager;function requireUndomanager(){return hasRequiredUndomanager||(hasRequiredUndomanager=1,function(o){(function(){function n(l,r,i){return l.splice(r,!i||1+i-r+(!(i<0^r>=0)&&(i<0||-1)*l.length)),l.length}let a=function(){let l=[],r=-1,i=0,c=!1,d;function p(u,m){return!u||typeof u[m]!="function"?this:(c=!0,u[m](),c=!1,this)}return{add:function(u){return c?this:(l.splice(r+1,l.length-r),l.push(u),i&&l.length>i&&n(l,0,-(i+1)),r=l.length-1,d&&d(),this)},setCallback:function(u){d=u},undo:function(){let u=l[r];if(!u)return this;const m=u.groupId;for(;u.groupId===m&&(p(u,"undo"),r-=1,u=l[r],!(!u||!u.groupId)););return d&&d(),this},redo:function(){let u=l[r+1];if(!u)return this;const m=u.groupId;for(;u.groupId===m&&(p(u,"redo"),r+=1,u=l[r+1],!(!u||!u.groupId)););return d&&d(),this},clear:function(){let u=l.length;l=[],r=-1,d&&u>0&&d()},hasUndo:function(){return r!==-1},hasRedo:function(){return r<l.length-1},getCommands:function(u){return u?l.filter(m=>m.groupId===u):l},getIndex:function(){return r},setLimit:function(u){i=u}}};o.exports?o.exports=a:window.UndoManager=a})()}(undomanager)),undomanager.exports}var undomanagerExports=requireUndomanager();const UndoManager=ChaiThemeFn.getDefaultExportFromCjs(undomanagerExports);function getBlocksTree(o){return convertToBlocksTree(o)}const nestedToFlatArray=(o,n)=>lodashEs.flatten(o.map(a=>{if(a=n?{...a,_parent:n}:{...a},a.children){const l=[...a.children];return delete a.children,lodashEs.flatten([a,...nestedToFlatArray(l,a._id)])}return a}));function setProjectBlocksInMemory(o,n=!1){for(let a=0;a<o.length;a++){const l=o[a];l.global&&!n?o[a]={type:"GlobalBlock",blockId:l.blockId,_parent:lodashEs.get(l,"_parent",null),_id:l._id}:l.children&&l.children.length&&setProjectBlocksInMemory(l.children)}}function getInnerBlocks(o){let n=[],a=lodashEs.filter(o,{type:"GlobalBlock"});return a.length>0&&(a=lodashEs.map(a,getPBlocks),lodashEs.each(a,l=>{n=[...n,...getSingleBlock(l)]})),n}function getSingleBlock(o){let n=[];const a=lodashEs.get(lodashEs.first(o),"_parent",null);lodashEs.set(lodashEs.first(o),"_parent",null);const l=[flatToNestedInstance.convert(clone(o))];setProjectBlocksInMemory(l,!0);let r=nestedToFlatArray(l,o[0]._id);return r=lodashEs.set(r,"0._parent",a),n=[...n,r,...getInnerBlocks(r)],n}function getPBlocks(o){const n=lodashEs.find(FLAT_ARRAY,{_id:o._id});if(!n)return[];const a=[n],l=lodashEs.filter(FLAT_ARRAY,{_parent:o._id});return l.length?lodashEs.flatten([...a,...lodashEs.flatten(lodashEs.map(l,getPBlocks))]):lodashEs.flatten(a)}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 a=nestedToFlatArray(n,null),l=getInnerBlocks(a),r={};return lodashEs.each(l,i=>lodashEs.set(r,lodashEs.first(i).blockId,i)),[a,r]}const MODIFIERS=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"],BRANDING_OPTIONS_DEFAULTS={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"},brandingOptionsAtom=jotai.atom(BRANDING_OPTIONS_DEFAULTS);jotai.atom(null);const useBrandingOptions=()=>{const[o,n]=jotai.useAtom(brandingOptionsAtom);return[lodashEs.isObject(o)?{...BRANDING_OPTIONS_DEFAULTS,...o}:BRANDING_OPTIONS_DEFAULTS,n]},currentPageAtom=jotai.atom(null),useCurrentPage=()=>({currentPage:jotai.useAtomValue(currentPageAtom)}),getBlockBuilderProps=lodashEs.memoize(o=>{const n=runtime.getRegisteredChaiBlock(o),a=lodashEs.get(n,"schema.properties",{});return lodashEs.compact(Object.keys(a).map(l=>lodashEs.get(a[l],"builderProp",!1)||lodashEs.get(a[l],"runtime",!1)?l:null))}),useGetPageData=()=>{const[o]=useBrandingOptions(),{currentPage:n}=useCurrentPage(),[a]=useBlocksStore();return React.useCallback(()=>{const l=lodashEs.map(a,i=>lodashEs.omit(i,getBlockBuilderProps(i._type))),[r=[]]=splitPageBlocks(l);return{currentPage:n,blocks:r}},[o,n,a])},chaiBuilderPropsAtom=jotai.atom(null);chaiBuilderPropsAtom.debugLabel="chaiBuilderPropsAtom";const chaiExternalDataAtom=jotai.atom({});chaiExternalDataAtom.debugLabel="chaiExternalDataAtom";const chaiRjsfFieldsAtom=jotai.atom({});chaiRjsfFieldsAtom.debugLabel="chaiRjsfFieldsAtom";const chaiRjsfWidgetsAtom=jotai.atom({});chaiRjsfWidgetsAtom.debugLabel="chaiRjsfWidgetsAtom";const chaiRjsfTemplatesAtom=jotai.atom({});chaiRjsfTemplatesAtom.debugLabel="chaiRjsfTemplatesAtom";const chaiPageExternalDataAtom=jotai.atom({});chaiPageExternalDataAtom.debugLabel="chaiPageExternalDataAtom";const usePageExternalData=()=>jotai.useAtomValue(chaiPageExternalDataAtom),useBuilderProp=(o,n=void 0)=>{const a=jotai.useAtomValue(chaiBuilderPropsAtom);return lodashEs.get(a,o,n)},getDefaultThemeValues=(o=ChaiThemeFn.defaultThemeOptions)=>{const n={};return o.fontFamily&&(n.fontFamily=Object.entries(o.fontFamily).reduce((a,[l,r])=>({...a,[l.replace("font-","")]:r}),{})),n.borderRadius=o.borderRadius,o.colors&&(n.colors=o.colors.reduce((a,l)=>(Object.entries(l.items).forEach(([r,i])=>{a[r]=i}),a),{})),n},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const o=useThemeOptions(),n=React.useMemo(()=>getDefaultThemeValues(o),[o]),a=useBuilderProp("theme",{}),[l,r]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...n,...!lodashEs.isEmpty(a)&&a,...!lodashEs.isEmpty(l)&&l}),[n,a,l]),r]},useThemeOptions=()=>{const o=useBuilderProp("themeOptions",a=>a);return React.useMemo(()=>o(ChaiThemeFn.defaultThemeOptions),[o])},rightPanelAtom=jotai.atom("block"),useRightPanel=()=>jotai.useAtom(rightPanelAtom),builderSaveStateAtom=jotai.atom("SAVED");builderSaveStateAtom.debugLabel="builderSaveStateAtom";const useSavePage=()=>{const[o,n]=jotai.useAtom(builderSaveStateAtom),a=useBuilderProp("onSave",async d=>{}),l=useBuilderProp("onSaveStateChange",lodashEs.noop),r=useGetPageData(),[i]=useTheme();return{savePage:web.useThrottledCallback(async(d=!1)=>{n("SAVING"),l("SAVING");const p=r();return await a({autoSave:d,blocks:p.blocks,theme:i}),setTimeout(()=>{n("SAVED"),l("SAVED")},100),!0},[r,n,i,a,l],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}},broadcastChannel=new BroadcastChannel("chaibuilder"),useBroadcastChannel=()=>{const o=useBuilderProp("pageId","chaibuilder_page");return{postMessage:web.useDebouncedCallback(a=>broadcastChannel.postMessage({...a,pageId:o}),[o],200)}},useUnmountBroadcastChannel=()=>{const[,o]=useBlocksStore(),n=useBuilderProp("pageId","chaibuilder_page"),{updateBlocksProps:a}=useBlocksStoreManager();React.useEffect(()=>(broadcastChannel.onmessageerror=l=>{console.log("error",l)},broadcastChannel.onmessage=l=>{l.data.type==="blocks-updated"&&l.data.pageId===n&&o(l.data.blocks),l.data.type==="blocks-props-updated"&&l.data.pageId===n&&a(l.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[o,n])},selectedBlockIdsAtom=jotai.atom([]);selectedBlockIdsAtom.debugLabel="selectedBlockIdsAtom";const selectedBlocksAtom=jotai.atom(o=>{const n=o(presentBlocksAtom),a=o(selectedBlockIdsAtom);return lodashEs.map(lodashEs.filter(n,({_id:l})=>lodashEs.includes(a,l)),l=>({...l}))});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),a=lodashEs.map(n,getParentId);return lodashEs.filter(o(presentBlocksAtom),l=>lodashEs.includes(a,l._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),a=o(presentBlocksAtom);let l=n;const r=[n];do{const i=a.find(({_id:c})=>c===(l==null?void 0:l._parent));l=i,i&&r.push(i)}while(l!=null&&l._parent);return r}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[o,n]=jotai.useAtom(selectedBlockIdsAtom),a=React.useCallback(l=>{n(r=>lodashEs.includes(r,l)?lodashEs.without(r,l):[...r,l])},[n]);return[o,n,a]},removeNestedBlocks=(o,n)=>{const a=[],l=lodashEs.filter(o,r=>lodashEs.includes(n,r._id)||lodashEs.includes(n,r._parent)?(a.push(r._id),!1):!0);return lodashEs.isEmpty(a)?l:removeNestedBlocks(l,a)},useRemoveBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useSelectedBlockIds(),{setNewBlocks:l}=useBlocksStoreUndoableActions();return React.useCallback(r=>{var c;const i=((c=lodashEs.find(o,{_id:r[0]}))==null?void 0:c._parent)||null;l(removeNestedBlocks(o,r)),setTimeout(()=>a(i?[i]:[]),200)},[o,a,n])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(o,n,{id:a,props:l})=>{const r=o(pageBlocksAtomsAtom),i=lodashEs.find(r,c=>o(c)._id===a);if(!i)throw new Error(`Block with id ${a} not found`);return n(i,{...o(i),...l})}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtomValue=o=>useAtomCallback(React.useCallback((n,a,l)=>{const r=n(o);if(!r||!r.length)throw new Error("No blocks available");const i=lodashEs.find(r,c=>n(c)._id===(lodashEs.isString(l)?l:n(l)._id));if(!i)throw new Error(`Block with id ${l} not found`);return n(i)},[o]),{store:builderStore}),useGetBlockAtom=o=>useAtomCallback(React.useCallback((n,a,l)=>{const r=n(o);if(!r||!r.length)return console.warn("No blocks available in splitAtoms"),null;const i=lodashEs.find(r,c=>n(c)._id===(lodashEs.isString(l)?l:n(l)._id));return i||(console.warn(`Block with id ${l} not found`),null)},[o]),{store:builderStore});function insertBlocksAtPosition(o,n,a,l){let r=o.filter(d=>!d._parent);a&&(r=o.filter(d=>d._parent===a));const i=!isNaN(l)||l>-1?Math.min(l,r.length):r.length;let c=o.length;for(let d=0,p=0;d<o.length;d++)if(o[d]._parent===a){if(p===i){c=d;break}p++}return!a&&l!==void 0&&l>=r.length&&(c=o.length),[...o.slice(0,c),...n,...o.slice(c)]}function flattenTree(o){let n=[];return o.walk(a=>(delete a.model.children,n.push(a.model),!0)),n}function findNodeById(o,n){return o.first(a=>a.model._id===n)||null}function moveNode(o,n,a,l){const r=findNodeById(o,n),i=findNodeById(o,a);if(r&&i){r.drop(),i.children||(i.model.children=[]);try{i.addChildAtIndex(r,l)}catch(c){return console.error("Error adding child to parent:",c),!1}return!0}return!1}function moveBlocksWithChildren(o,n,a,l){if(!n)return o;a=a||"root";const i=new TreeModel().parse({_id:"root",children:getBlocksTree(o)});if(moveNode(i,n,a,l)){const c=flattenTree(i),d=c.find(p=>p._id===n);return d&&(d._parent=a==="root"?null:a),c.shift(),c}return o}const useBlocksStoreManager=()=>{const[,o]=useBlocksStore(),{postMessage:n}=useBroadcastChannel(),a=useUpdateBlockAtom();return{setNewBlocks:l=>{o(l),n({type:"blocks-updated",blocks:l})},addBlocks:(l,r,i)=>{o(c=>{const d=insertBlocksAtPosition(c,l,r,i);return n({type:"blocks-updated",blocks:d}),d})},removeBlocks:l=>{o(r=>{const i=removeNestedBlocks(r,l);return n({type:"blocks-updated",blocks:i}),i})},moveBlocks:(l,r,i)=>{o(c=>{let d=[...c];for(let p=0;p<l.length;p++)d=moveBlocksWithChildren(d,l[p],r,i);return lodashEs.each(l,p=>{const u=lodashEs.find(d,m=>m._id===p);u&&a({id:p,props:{_parent:u._parent||null}})}),n({type:"blocks-updated",blocks:d}),d})},updateBlocksProps:l=>{l.forEach(r=>{const i=lodashEs.omit(r,"_id");a({id:r._id,props:i})}),n({type:"blocks-props-updated",blocks:l})}}},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:o}=useUndoManager(),[n]=useBlocksStore(),{setNewBlocks:a,addBlocks:l,removeBlocks:r,moveBlocks:i,updateBlocksProps:c}=useBlocksStoreManager();return{moveBlocks:(b,f,j)=>{const S=lodashEs.map(b,v=>{const C=n.find(N=>N._id===v)._parent||null,E=n.filter(N=>C?N._parent===C:!N._parent).map(N=>N._id).indexOf(v);return{_id:v,oldParent:C,oldPosition:E}}),w=S.find(({_id:v})=>v===b[0]);w&&w.oldParent===f&&w.oldPosition===j||(i(b,f,j),o({undo:()=>lodashEs.each(S,({_id:v,oldParent:k,oldPosition:C})=>{i([v],k,C)}),redo:()=>i(b,f,j)}))},addBlocks:(b,f,j)=>{l(b,f,j),o({undo:()=>r(lodashEs.map(b,"_id")),redo:()=>l(b,f,j)})},removeBlocks:b=>{var w;const f=(w=lodashEs.first(b))==null?void 0:w._parent,S=n.filter(v=>f?v._parent===f:!v._parent).indexOf(lodashEs.first(b));r(lodashEs.map(b,"_id")),o({undo:()=>l(b,f,S),redo:()=>r(lodashEs.map(b,"_id"))})},updateBlocks:(b,f,j)=>{let S=[];if(j)S=lodashEs.map(b,w=>({_id:w,...j}));else{const w=lodashEs.keys(f);S=lodashEs.map(b,v=>{const k=n.find(B=>B._id===v),C={_id:v};return lodashEs.each(w,B=>C[B]=k[B]),C})}c(lodashEs.map(b,w=>({_id:w,...f}))),o({undo:()=>c(S),redo:()=>c(lodashEs.map(b,w=>({_id:w,...f})))})},updateBlocksRuntime:(b,f)=>{c(lodashEs.map(b,j=>({_id:j,...f})))},setNewBlocks:b=>{a(b),o({undo:()=>a(n),redo:()=>a(b)})},updateMultipleBlocksProps:b=>{let f=[];f=lodashEs.map(b,j=>{const S=lodashEs.keys(j),w=n.find(k=>k._id===j._id),v={};return lodashEs.each(S,k=>v[k]=w[k]),v}),c(b),o({undo:()=>c(f),redo:()=>c(b)})}}},canAcceptChildBlock=(o,n)=>{if(!o)return!0;const a=runtime.getRegisteredChaiBlock(o);return a&&lodashEs.has(a,"canAcceptBlock")?a.canAcceptBlock(n):!1},canAddChildBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n?lodashEs.has(n,"canAcceptBlock"):!1},canBeNestedInside=(o,n)=>{const a=runtime.getRegisteredChaiBlock(n);return a&&lodashEs.has(a,"canBeNested")?a.canBeNested(o):!0},canDuplicateBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n&&lodashEs.has(n,"canDuplicate")?n.canDuplicate():!0},canDeleteBlock=o=>{const n=runtime.getRegisteredChaiBlock(o);return n&&lodashEs.has(n,"canDelete")?n.canDelete():!0},canDropBlock=(o,{dragSource:n,dropTarget:a})=>{const l=lodashEs.get(n,"data._type",""),r=lodashEs.get(a,"data._type","");return canAcceptChildBlock(r,l)},useAddBlock=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions(),l=React.useCallback((i,c,d)=>{var g;for(let x=0;x<i.length;x++){const{_id:b}=i[x];i[x]._id=iconBase.generateUUID();const f=lodashEs.filter(i,{_parent:b});for(let j=0;j<f.length;j++)f[j]._parent=i[x]._id}const p=lodashEs.first(i);let u,m;return c&&(u=lodashEs.find(o,{_id:c}),i[0]._parent=c,m=c),!(u?canAcceptChildBlock(u==null?void 0:u._type,p._type):!0)&&u&&(i[0]._parent=u._parent,m=u._parent),a(i,m,d),n([(g=lodashEs.first(i))==null?void 0:g._id]),lodashEs.first(i)},[a,o,n]);return{addCoreBlock:React.useCallback((i,c,d)=>{if(lodashEs.has(i,"blocks")){const f=i.blocks;return l(f,c,d)}const p=iconBase.generateUUID(),u=runtime.getDefaultBlockProps(i.type),m={_type:i.type,_id:p,...u};let h,g;return c&&(h=lodashEs.find(o,{_id:c}),m._parent=c,g=c),!canAcceptChildBlock(h==null?void 0:h._type,m._type)&&h&&(m._parent=h._parent,g=h._parent),a([m],g,d),n([m._id]),m},[a,l,o,n]),addPredefinedBlock:l}},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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:lodashEs.map(CLASS_VALUES.columns,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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:lodashEs.map(CLASS_VALUES.indent,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"},backgroundAttachment:{classes:lodashEs.map(["fixed","local","scroll"],o=>`bg-${o}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...lodashEs.map(CLASS_VALUES.borderRadius,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|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...lodashEs.map(CLASS_VALUES.borderWidth,o=>`border-${o}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:lodashEs.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],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|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},colorOptions={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},soloColors=["current","inherit","transparent","black","white"],shadedColors=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],shades=["50","100","200","300","400","500","600","700","800","900"],colorKeys=lodashEs.map(lodashEs.values(colorOptions),o=>o),ALL_COLORS=lodashEs.flattenDeep([...lodashEs.map(soloColors,o=>lodashEs.flatten(lodashEs.map(colorKeys,n=>`${n}-${o}`))),...lodashEs.map(shadedColors,o=>lodashEs.flattenDeep(lodashEs.map(colorKeys,n=>lodashEs.flattenDeep(lodashEs.map(shades,a=>`${n}-${o}-${a}`)))))]),ALL_TW_CLASSES=lodashEs.map(lodashEs.flattenDeep(lodashEs.values(CLASSES_LIST).map(o=>o.classes).concat(ALL_COLORS)),o=>({name:o})),useFuseSearch=()=>{const o=useThemeOptions(),n=React.useMemo(()=>{let a=[];if(o.colors){const l=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:r})=>lodashEs.keys(r)));a=lodashEs.flattenDeep(lodashEs.map(l,r=>lodashEs.flatten(lodashEs.map(colorKeys,i=>`${i}-${r}`))))}return o.fontFamily&&(a=[...a,...lodashEs.map(lodashEs.keys(o.fontFamily),l=>`${l}`)]),lodashEs.map(a,l=>({name:l}))},[o]);return React.useMemo(()=>new Fuse([...ALL_TW_CLASSES,...n],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[n])},useTailwindClassList=()=>{const o=useThemeOptions(),n=React.useMemo(()=>{if(o.colors){const r=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:i})=>lodashEs.keys(i)));lodashEs.each(CLASSES_LIST,(i,c)=>{lodashEs.set(CLASSES_LIST,`${c}.regExp`,i.regExp.replace("__THEME_COLORS_REGEXP__",r.join("|")))})}return CLASSES_LIST},[o]),a=React.useCallback((r,i)=>{const c=lodashEs.get(n,`${r}.regExp`,"");return i.match(new RegExp(c))},[n]),l=React.useCallback((r,i=[])=>lodashEs.get(n,`${r}.classes`,i),[n]);return{match:a,getClasses:l}};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,l=>`${l}:`).join("|"),a=new RegExp(n,"g");return lodashEs.get(a.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 a in CLASSES_LIST){const l=lodashEs.get(CLASSES_LIST,`${a}.regExp`,"");if(new RegExp(l,"g").test(o)){n=a,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}function orderClassesByBreakpoint(o){o=o.replace(/\s+/g," ");const n=o.split(" ").map(constructClassObject),a=["xs","sm","md","lg","xl","2xl"];return n.sort((l,r)=>a.indexOf(l.mq)-a.indexOf(r.mq)).map(l=>l.fullCls).join(" ")}function removeDuplicateClasses(o){if(o=o.replace(/\s+/g," "),!o)return"";const n=["xs","sm","md","lg","xl","2xl"],a=o.split(" ").map(constructClassObject);let l=o;if(a.length===1)return a[0].fullCls;for(const r of a){const i=r.property,c=n.indexOf(r.mq);for(let d=c+1;d<n.length;d++){const p=n[d],u=a.find(m=>m.property===i&&m.mq===p);if(u&&u.cls===r.cls)l=l.replace(u.fullCls,"");else if(u&&u.cls!==r.cls)break}}return l.replace(/\s+/g," ").trim()}const selectedStylingBlocksAtom=jotai.atom([]);selectedStylingBlocksAtom.debugLabel="selectedStylingBlocksAtom";const useSelectedStylingBlocks=()=>jotai.useAtom(selectedStylingBlocksAtom),addClassesToBlocksAtom=jotai.atom(null,(o,n,{blockIds:a,newClasses:l})=>{const r=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id)),i=lodashEs.first(o(selectedStylingBlocksAtom));return lodashEs.map(r,c=>{const d=o(c),p=lodashEs.get(d,i.prop,`${getSplitClasses.STYLES_KEY},`),{classes:u}=getSplitClasses.getSplitChaiClasses(p);return{ids:[d._id],props:{[i.prop]:`${getSplitClasses.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(u,l)))}`}}})}),useAddClassesToBlocks=()=>{const o=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:n,updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback((l,r,i=!1)=>{const c=o({blockIds:l,newClasses:r});if(!i){a(l,c[0].props);return}n(l,c[0].props)},[o,n,a])},LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},languageAtom=jotai.atom("");languageAtom.debugLabel="selectedLanguageAtom";const useLanguages=()=>{const o=useBuilderProp("languages",[]),n=useBuilderProp("fallbackLang","en"),[a,l]=jotai.useAtom(languageAtom),r=i=>{l(n===i?"":i)};return{languages:o==null?void 0:o.filter(i=>i!==n),fallbackLang:n,selectedLang:a,setSelectedLang:r}},updatePropsForLanguage=(o,n,a)=>{const l=runtime.getRegisteredChaiBlock(lodashEs.get(a,"_type"));if(!l)return o;const r={...o};return lodashEs.forEach(lodashEs.keys(o),i=>{if(lodashEs.includes(lodashEs.get(l,"i18nProps",[]),i)&&!lodashEs.isEmpty(n)){const c=`${i}-${n}`;lodashEs.set(r,c,o[i]),lodashEs.unset(r,i)}}),r},useUpdateBlocksProps=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((l,r,i)=>{const c=updatePropsForLanguage(r,n,a);o(l,c,i)},[n,a,o])},useUpdateMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions();return React.useCallback(n=>{o(n)},[o])},useFakeStreamEffect=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions();return React.useCallback(async(n,a,l=30)=>{const r=lodashEs.keys(lodashEs.omit(a,["_id"]));for(const i of r){const c=a[i];if(lodashEs.isString(c)){const d=lodashEs.chunk(c.split(""),12);let p="";o([n],{[i]:""});for(let u=0;u<d.length;u++)p+=d[u].join(""),o([n],{[i]:p}),await new Promise(m=>setTimeout(m,l))}}},[o])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions(),n=useFakeStreamEffect();return React.useCallback(async a=>{for(const l of a)await n(l._id,l);o(a)},[n,o])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((l,r)=>{const i=updatePropsForLanguage(r,n,a);o(l,i)},[n,a,o])};function getChildBlocks(o,n,a){a.push(lodashEs.find(o,{_id:n}));const l=lodashEs.filter(o,{_parent:n});for(const r of l)a.push(...getBlockWithChildren(r._id,o));return a}const getBlockWithChildren=(o,n)=>{let a=[];return a=lodashEs.flattenDeep([...a,...getChildBlocks(n,o,a)]),a},pickOnlyAIProps=(o,n)=>lodashEs.compact(o.map(a=>{const l=["_id","_type","_parent"],r=lodashEs.pick(a,l),i=runtime.getRegisteredChaiBlock(a._type),c={},d=lodashEs.get(i,"aiProps",[]);for(const p in a)l.includes(p)||d.includes(p)&&(c[p]=lodashEs.get(a,`${p}-${n}`,a[p]));return lodashEs.isEmpty(c)?!1:(lodashEs.has(r,"_parent")&&lodashEs.isEmpty(r._parent)&&delete r._parent,{...r,...c})})),addLangToPrompt=(o,n,a)=>!n||a!=="content"?o:`${o}. Generate content in ${lodashEs.get(LANGUAGES,n,n)} language.`,askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[o,n]=jotai.useAtom(askAiProcessingAtom),[a,l]=React.useState(null),r=useBuilderProp("askAiCallBack",null),i=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:p,fallbackLang:u}=useLanguages(),m=p.length?p:u,h=(g,x)=>{const b=lodashEs.cloneDeep(x.find(f=>f._id===g));for(const f in b){const j=b[f];if(typeof j=="string"&&lodashEs.startsWith(j,getSplitClasses.STYLES_KEY)){const{baseClasses:S,classes:w}=getSplitClasses.getSplitChaiClasses(j);b[f]=lodashEs.compact(lodashEs.flattenDeep([S,w])).join(" ")}else f!=="_id"&&delete b[f]}return b};return{askAi:React.useCallback(async(g,x,b,f)=>{if(r){n(!0),l(null);try{const j=p===u?"":p,S=g==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(x,d)),p):[h(x,d)],w=await r(g,addLangToPrompt(b,m,g),S,j),{blocks:v,error:k}=w;if(k){l(k);return}if(g==="styles"){const C=v.map(B=>{for(const E in B)E!=="_id"&&(B[E]=`${getSplitClasses.STYLES_KEY},${B[E]}`);return B});c(C)}else i(v);f&&f(w)}catch(j){l(j)}finally{n(!1),f&&f()}}},[r,n,p,u,d,m,c,i]),loading:o,error:a}},useAiAssistant=()=>{const[,o]=useRightPanel();return React.useCallback(n=>{o(n?"ai":"block")},[o])};let lastHighlighted=null;const useBlockHighlight=()=>{const[o]=jotai.useAtom(canvasIframeAtom),n=React.useMemo(()=>{var r;return(o==null?void 0:o.contentDocument)||((r=o==null?void 0:o.contentWindow)==null?void 0:r.document)},[o]);return{highlightBlock:React.useCallback(r=>{if(n)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof r!="string")r.setAttribute("data-highlighted","true"),lastHighlighted=r;else if(typeof r=="string"){const i=n.querySelector(`[data-block-id="${r}"]`);i&&(i.setAttribute("data-highlighted","true"),lastHighlighted=i)}else lastHighlighted=null},[n]),clearHighlight:()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},lastHighlighted}},globalBlocksStoreAtom=atom({}),globalBlocksLoadingStateAtom=atom({}),useGlobalBlocksStore=()=>{const[o,n]=useAtom(globalBlocksStoreAtom),a=React.useCallback(r=>lodashEs.get(o,r,[]),[o]),l=React.useCallback(()=>n({}),[n]);return{getGlobalBlocks:a,reset:l}},useWatchGlobalBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useAtom(globalBlocksStoreAtom),[l,r]=useAtom(globalBlocksLoadingStateAtom),i=useBuilderProp("getGlobalBlockBlocks",async d=>[]),c=React.useMemo(()=>o.filter(p=>p._type==="GlobalBlock").filter(p=>p._type==="GlobalBlock").map(p=>p.globalBlock),[o]);React.useEffect(()=>{lodashEs.forEach(c,d=>{lodashEs.has(n,d)||lodashEs.get(l,`${d}.loading`,!1)||(r(p=>({...p,[d]:{loading:!0,error:null}})),i(d).then(p=>{a(u=>({...u,[d]:p})),r(u=>({...u,[d]:{loading:!1,error:null}}))}).catch(p=>{r(u=>({...u,[d]:{loading:!1,error:p.message}}))}))})},[i,n,c,l,a,r])},globalBlocksListAtom=atom({}),useGlobalBlocksList=()=>{const[o,n]=React.useState(!1),[a,l]=useAtom(globalBlocksListAtom),r=useBuilderProp("getGlobalBlocks",async()=>[]),i=React.useCallback(async()=>{n(!0);const c=await r();l(c),n(!1)},[r,l]);return React.useEffect(()=>{i()},[]),{data:a,isLoading:o,refetch:i}},useBuilderReset=()=>{const o=jotai.useSetAtom(historyStatesAtom),{clear:n}=useUndoManager(),[,a]=useSelectedBlockIds(),{clearHighlight:l}=useBlockHighlight(),[,r]=useSelectedStylingBlocks(),[,i]=useAtom(aiAssistantActiveAtom),{reset:c}=useGlobalBlocksStore();return()=>{a([]),r([]),l(),n(),i(!1),o({undoCount:0,redoCount:0}),c()}},canvasZoomAtom=atomWithStorage("canvasZoom",100),useCanvasZoom=()=>jotai.useAtom(canvasZoomAtom),codeEditorAtom=jotai.atom(null),useCodeEditor=()=>jotai.useAtom(codeEditorAtom),cutBlockIdsAtom=jotai.atom([]),useCutBlockIds=()=>{const[o,n]=jotai.useAtom(cutBlockIdsAtom),a=jotai.useSetAtom(copiedBlockIdsAtom),l=React.useCallback(r=>{n(r),a([])},[n,a]);return[o,l]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlockIds=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(copiedBlockIdsAtom),l=jotai.useSetAtom(cutBlockIdsAtom),r=React.useCallback(async i=>{try{a(i),l([]);const c={_chai_copied_blocks:i.flatMap(d=>getDuplicatedBlocks(o,d,null))};await navigator.clipboard.writeText(JSON.stringify(c))}catch(c){console.error("Failed to copy blocks to clipboard:",c)}},[a,l,o]);return[n,r]},useCopyToClipboard=()=>{const[o,n]=React.useState(null),a=React.useCallback(async l=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(l),n(l),!0}catch(r){return console.warn("Copy failed",r),n(null),!1}},[]);return[o,a]},darkModeAtom=atomWithStorage("darkMode",!1),useDarkMode=()=>{const[o,n]=jotai.useAtom(darkModeAtom);return[o,n]},useDuplicateBlocks=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions();return React.useCallback((l,r=null)=>{const i=[];lodashEs.each(l,c=>{const d=o.find(g=>g._id===c);r?r==="root"&&(r=null):r=d._parent;const m=lodashEs.filter(o,g=>lodashEs.isString(r)?g._parent===r:!g._parent).indexOf(d)+1,h=getDuplicatedBlocks(o,c,r);a(h,r,m),i.push(lodashEs.get(h,"0._id",""))}),n(i)},[o,n])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[o,n]=jotai.useAtom(hiddenBlockIdsAtom),a=React.useCallback(l=>{n(r=>lodashEs.includes(r,l)?lodashEs.without(r,l):[...r,l])},[n]);return[o,n,a]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),useCanPaste=()=>{const[o]=useBlocksStore();return(n,a)=>{var i;const l=((i=lodashEs.find(o,{_id:a}))==null?void 0:i._type)||null,r=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(l,r)}},useMoveCutBlocks=()=>{const o=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:n}=useBlocksStoreUndoableActions();return React.useCallback((a,l)=>{const r=Array.isArray(l)?l[0]:l;if(l==="root"){const i=o==null?void 0:o.filter(c=>!c._parent);n(a,null,(i==null?void 0:i.length)||0)}else{const i=o==null?void 0:o.filter(c=>c._parent===r);n(a,r,(i==null?void 0:i.length)||0)}},[n,o])},usePasteBlocks=()=>{const[o,n]=useCutBlockIds(),a=useMoveCutBlocks(),l=useCanPaste(),{addPredefinedBlock:r}=useAddBlock();return{canPaste:React.useCallback(async c=>{if(o.length>0)return l(o,c);try{const d=await navigator.clipboard.readText();if(d){const p=JSON.parse(d);return lodashEs.has(p,"_chai_copied_blocks")}}catch{return!1}return!1},[l,o]),pasteBlocks:React.useCallback(async c=>{const d=Array.isArray(c)?c[0]:c;if(!lodashEs.isEmpty(o)){a(o,c),n([]),await navigator.clipboard.writeText("");return}try{const p=await navigator.clipboard.readText();if(p){const u=JSON.parse(p);lodashEs.has(u,"_chai_copied_blocks")?r(u._chai_copied_blocks,d==="root"?null:d):sonner.toast.error("Nothing to paste")}else sonner.toast.error("Nothing to paste")}catch{sonner.toast.error("Failed to paste blocks from clipboard")}},[o,r,a,n])}},previewModeAtom=jotai.atom(!1),usePreviewMode=()=>{const[o,n]=jotai.useAtom(previewModeAtom);return[o,n]},removeClassFromBlocksAtom=jotai.atom(null,(o,n,{blockIds:a,fullClasses:l})=>{const r=lodashEs.first(o(selectedStylingBlocksAtom)),i=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id));return lodashEs.map(i,c=>{const d=o(c),p=l;let{classes:u,baseClasses:m}=getSplitClasses.getSplitChaiClasses(lodashEs.get(d,r.prop,`${getSplitClasses.STYLES_KEY},`));return lodashEs.each(p,h=>{const g=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`(^|\\s)${g}(?=\\s|$)`,"g");u=u.replace(x," ").replace(/\s+/g," ").trim();const b=lodashEs.first(h.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],b)&&p.push(h.split(":").pop().trim())}),lodashEs.each(p,h=>{const g=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`(^|\\s)${g}(?=\\s|$)`,"g");m=m.replace(x," ").replace(/\s+/g," ").trim()}),{ids:[d._id],props:{[r.prop]:`${getSplitClasses.STYLES_KEY}${m},${u}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:o,updateBlocksRuntime:n}=useBlocksStoreUndoableActions(),a=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((l,r,i=!1)=>{const c=a({blockIds:l,fullClasses:r});i?o(l,c[0].props):n(l,c[0].props)},[a])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(o=>{const n=o(canvasWidthAtom);return iconBase.getBreakpointValue(n).toLowerCase()}),useScreenSizeWidth=()=>{const[o,n]=jotai.useAtom(canvasWidthAtom),a=jotai.useAtomValue(canvasBreakpointAtom),[l,r]=useStylingBreakpoint();return React.useEffect(()=>{l!=="xs"&&r(a)},[a,l,r]),[o,a,n]},useCanvasDisplayWidth=()=>{const[o,n]=jotai.useAtom(canvasDisplayWidthAtom);return[o,n]},selectedBlockAllClassesAtom=jotai.atom(o=>{const n=lodashEs.first(o(selectedStylingBlocksAtom)),a=o(selectedBlockAtom);if(!n||n.blockId!==lodashEs.get(a,"_id",null))return[];const l=lodashEs.get(a,n.prop,`${getSplitClasses.STYLES_KEY},`),{classes:r}=getSplitClasses.getSplitChaiClasses(l);return lodashEs.filter(lodashEs.map(r.trim().split(" "),constructClassObject),i=>!lodashEs.isNull(i))}),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),a=o(styleStateAtom),l=o(darkModeAtom),r=getQueries(n);let i=lodashEs.filter(o(selectedBlockAllClassesAtom),{mod:a});return lodashEs.startsWith(a,"_")||(i=lodashEs.filter(i,c=>r.includes(c.mq))),i=i.sort((c,d)=>MQ[c.mq]-MQ[d.mq]),l||(i=lodashEs.filter(i,{dark:!1})),i}),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),selectedBreakpointsAtom=atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),useSelectedBreakpoints=()=>{const[o,n]=jotai.useAtom(selectedBreakpointsAtom);return[o,n]},useStylingState=()=>jotai.useAtom(styleStateAtom),useUILibraryBlocks=()=>({data:useBuilderProp("uiLibraries",[]),isLoading:!1}),wrapperBlockAtom=jotai.atom(o=>{var c;const n=o(presentBlocksAtom),a=o(selectedBlockIdsAtom),l=a.length===1?a[0]:null;if(!l)return null;const r=lodashEs.find(n,{_id:l});if(!r)return null;let i=r._parent;for(;i;){const d=lodashEs.find(n,{_id:i});if(!d)return null;if((c=runtime.getRegisteredChaiBlock(d._type))!=null&&c.wrapper)return d;i=d._parent}return null});wrapperBlockAtom.debugLabel="wrapperBlockAtom";const useWrapperBlock=()=>jotai.useAtomValue(wrapperBlockAtom),layoutVariantAtom=atomWithStorage("_layout_variant_mode","DUAL_SIDE_PANEL"),useLayoutVariant=()=>{const[o,n]=jotai.useAtom(layoutVariantAtom),a=useBuilderProp("layoutVariant","DUAL_SIDE_PANEL");return[o||a,n]},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS"};class PubSub{constructor(){U(this,"subscribers",new Map)}subscribe(n,a){return this.subscribers.has(n)||this.subscribers.set(n,new Set),this.subscribers.get(n).add(a),()=>{const l=this.subscribers.get(n);l&&(l.delete(a),l.size===0&&this.subscribers.delete(n))}}publish(n,a){const l=this.subscribers.get(n);l&&l.forEach(r=>r(a))}}const pubsub=new PubSub,draggedBlockAtom=jotai.atom(null),dropTargetBlockIdAtom=jotai.atom(null),BlockActionLabel=({block:o,label:n})=>{const[,a]=useSelectedBlockIds(),[,l]=useHighlightBlockId(),[,r]=jotai.useAtom(draggedBlockAtom),i=flagged.useFeature("dnd");return jsxRuntime.jsxs("div",{className:"mr-10 flex cursor-default items-center space-x-1 px-1",draggable:i?"true":"false",onDragStart:c=>{c.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.pick(o,["_id","_type","_name"]))),r(o),setTimeout(()=>{a([]),l(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),n]})},BlockFloatingSelector=({selectedBlockElement:o,block:n})=>{const a=useRemoveBlocks(),l=useDuplicateBlocks(),[,r]=useSelectedBlockIds(),[,i]=useHighlightBlockId(),[,c]=useSelectedStylingBlocks(),[d]=jotai.useAtom(inlineEditingActiveAtom),{floatingStyles:p,refs:u,update:m}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:o}});web.useResizeObserver(o,()=>m(),o!==null);const h=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.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:u.setFloating,style:p,onClick:x=>{x.stopPropagation(),x.preventDefault()},onMouseEnter:x=>{x.stopPropagation(),i(null)},onKeyDown:x=>x.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[h&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{c([]),r([h])}}),jsxRuntime.jsx(BlockActionLabel,{label:g,block:n}),jsxRuntime.jsxs("div",{className:"flex gap-2 px-1",children:[canAddChildBlock(lodashEs.get(n,"_type",""))&&jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105",onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,n)}),canDuplicateBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>l([n==null?void 0:n._id])}):null,canDeleteBlock(lodashEs.get(n,"_type",""))?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>a([n==null?void 0:n._id])}):null]})]})})},IframeInitialContent=`<!doctype html>
|
|
2
2
|
<html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
<body class="font-body antialiased h-full">
|
|
54
54
|
<div class="frame-root h-full"></div>
|
|
55
55
|
</body>
|
|
56
|
-
</html>`,useKeyEventWatcher=o=>{const[n,a]=useSelectedBlockIds(),l=useSelectedBlock(),r=useRemoveBlocks(),i=useDuplicateBlocks(),{undo:c,redo:d}=useUndoManager(),[,p]=useCutBlockIds(),[,u]=useCopyBlockIds(),{canPaste:m,pasteBlocks:h}=usePasteBlocks(),g=o?{document:o}:{};reactHotkeysHook.useHotkeys("ctrl+z,command+z",()=>c(),{},[c]),reactHotkeysHook.useHotkeys("ctrl+y,command+y",()=>d(),{},[d]),reactHotkeysHook.useHotkeys("ctrl+x,command+x",()=>p(n),{},[n,p]),reactHotkeysHook.useHotkeys("ctrl+c,command+c",()=>u(n),{},[n,u]),reactHotkeysHook.useHotkeys("ctrl+v,command+v",()=>{m(n[0])&&h(n)},{...g,preventDefault:!0},[n,m,h]),reactHotkeysHook.useHotkeys("esc",()=>a([]),g,[a]),reactHotkeysHook.useHotkeys("ctrl+d,command+d",()=>i(n),{...g,preventDefault:!0},[n,i]),reactHotkeysHook.useHotkeys("del, backspace",x=>{x.preventDefault(),canDeleteBlock(lodashEs.get(l,"_type",""))&&r(n)},g,[n,r])},KeyboardHandler=()=>{const{document:o}=useFrame();return useKeyEventWatcher(o),null},AddBlockAtBottom=()=>{const{t:o}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer py-2",children:[jsxRuntime.jsx("br",{}),jsxRuntime.jsx("div",{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),className:"h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(lucideReact.PlusIcon,{className:"size-2.5 stroke-[3]"})," ",o("Add block")]})}),jsxRuntime.jsx("br",{})]})};function getOrientation(o){const n=window.getComputedStyle(o),a=n.display;if(a==="flex"||a==="inline-flex"){const l=n.flexDirection;return l==="column"||l==="column-reverse"?"vertical":"horizontal"}else if(a==="grid"){const l=n.gridAutoFlow,r=n.gridTemplateRows,i=n.gridTemplateColumns;return l.includes("column")||r.split(" ").length>i.split(" ").length?"vertical":"horizontal"}else if(a==="block"||a==="inline-block")return"vertical";return"horizontal"}let iframeDocument=null,possiblePositions=[],dropTarget=null,dropIndex=null;const positionPlaceholder=(o,n,a)=>{if(!iframeDocument||!o)return;const l=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder"),r=possiblePositions.map(([p])=>p),i=r.reduce((p,u)=>Math.abs(u-a)<Math.abs(p-a)?u:p,0),c=r.indexOf(i);if(!possiblePositions[c])return;const d=possiblePositions[c];l.style.width=n==="vertical"?d[2]+"px":"2px",l.style.height=n==="vertical"?"2px":d[2]+"px",l.style.display="block",n==="vertical"?(l.style.top=d[0]+"px",l.style.left=d[1]+"px"):(l.style.top=d[1]+"px",l.style.left=d[0]+"px")};function calculateDropIndex(o,n){let a=0,l=1/0;return n.forEach((r,i)=>{const c=Math.abs(r[0]-o);c<l&&(l=c,a=i)}),a}const calculatePossiblePositions=o=>{const a=getOrientation(o)==="horizontal";possiblePositions=[],Array.from(o.children).forEach((l,r)=>{if(l.classList.contains("pointer-events-none"))return;const i=a?l.offsetLeft:l.offsetTop,c=a?[l.offsetTop,l.clientHeight]:[l.offsetLeft,l.clientWidth];if(possiblePositions.push([i,c[0],c[1]]),r===o.children.length-1){const d=a?l.offsetLeft+l.clientWidth:l.offsetTop+l.clientHeight;possiblePositions.push([d,c[0],c[1]])}})},throttledDragOver=lodashEs.throttle(o=>{var r;const n=o.target,a=getOrientation(n),l=(r=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:r.scrollY;a==="vertical"?positionPlaceholder(n,a,o.clientY+l):positionPlaceholder(n,a,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(a=>{a.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,a]=jotai.useAtom(draggingFlagAtom),{addCoreBlock:l}=useAddBlock(),[,r]=useHighlightBlockId(),[,i]=useSelectedBlockIds(),{moveBlocks:c}=useBlocksStoreUndoableActions(),[d,p]=jotai.useAtom(draggedBlockAtom),[,u]=jotai.useAtom(dropTargetBlockIdAtom);if(!flagged.useFeature("dnd"))return{};const h=()=>{removePlaceholder(),a(!1),p(null),u(null),possiblePositions=[]};return iframeDocument=o,{isDragging:n,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),throttledDragOver(g)},onDrop:g=>{var k;const x=dropTarget,f=getOrientation(x)==="vertical"?g.clientY+((k=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:k.scrollY):g.clientX;dropIndex=calculateDropIndex(f,possiblePositions);const j=d,S=x.getAttribute("data-block-id"),w=dropTarget.getAttribute("data-dnd-dragged")!=="yes";if((j==null?void 0:j._id)===S||!w){h();return}if(!lodashEs.has(j,"_id")){l(j,S==="canvas"?null:S,dropIndex),setTimeout(h,300);return}let v=x.getAttribute("data-block-id");v===null&&(v=g.target.parentElement.getAttribute("data-block-id")),c([j._id],v==="canvas"?null:v,dropIndex),h(),setTimeout(removePlaceholder,300)},onDragEnter:g=>{const x=g,b=x.target;dropTarget=b;const f=b.getAttribute("data-block-id"),j=b.getAttribute("data-dnd-dragged")!=="yes";u(f),x.stopPropagation(),x.preventDefault(),possiblePositions=[],j&&calculatePossiblePositions(b),a(!0),r(""),i([])},onDragLeave:g=>{g.target.getAttribute("data-block-id")==="canvas"&&(u(null),a(!1),removePlaceholder(),possiblePositions=[])}}};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const TiptapBubbleMenu=({editor:o})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(react.BubbleMenu,{editor:o,tippyOptions:{duration:100},children:jsxRuntime.jsxs("div",{className:"bubble-menu space-x-2",children:[jsxRuntime.jsx("button",{onClick:()=>o.chain().focus().toggleBold().run(),className:cn(o.isActive("bold")?"bg-gray-100":"","h-3 w-3"),children:jsxRuntime.jsx(lucideReact.Bold,{})}),jsxRuntime.jsx("button",{onClick:()=>o.chain().focus().toggleItalic().run(),className:cn(o.isActive("italic")?"bg-gray-100":"","h-3 w-3"),children:jsxRuntime.jsx(lucideReact.Italic,{})}),jsxRuntime.jsx("button",{onClick:()=>o.chain().focus().toggleStrike().run(),className:cn(o.isActive("strike")?"bg-gray-100":"","h-3 w-3"),children:jsxRuntime.jsx(lucideReact.Strikethrough,{})})]})}),jsxRuntime.jsx(react.EditorContent,{editor:o})]});function getTargetedBlock(o){if(o.getAttribute("data-block-id")==="canvas")return null;if(o.getAttribute("data-block-id")||o.getAttribute("data-block-parent"))return o;const n=o.closest("[data-block-id]");return(n==null?void 0:n.getAttribute("data-block-id"))==="canvas"?null:n}const useHandleCanvasDblClick=(o,n)=>{const a=[],l=useUpdateBlocksProps(),[r,i]=jotai.useAtom(inlineEditingActiveAtom),{clearHighlight:c}=useBlockHighlight(),d=useGetBlockAtomValue(pageBlocksAtomsAtom);return React.useCallback(p=>{if(r)return;const u=getTargetedBlock(p.target);if(!u)return;const m=u.getAttribute("data-block-type");if(!m||!a.includes(m))return;const h=u.getAttribute("data-block-id");if(!h)return;o.on("update",({editor:x})=>{console.log(x.getHTML())}),o.on("blur",()=>{console.log("blur");const x=o.getHTML();l([h],{content:x}),n.style.display="none",u.style.visibility="visible"}),i(h);const g=d(h).content;o.commands.setContent(g),n.style.display="block",u.style.visibility="hidden",n.style.position="absolute",n.style.top=`${u.offsetTop}px`,n.style.left=`${u.offsetLeft}px`,n.style.width=`${u.offsetWidth}px`,n.style.height=`${u.offsetHeight}px`,n.classList.add(...u.classList)},[r,c,d,i,l,o,n])},useHandleCanvasClick=()=>{const[,o]=useSelectedStylingBlocks(),[n,a]=useSelectedBlockIds(),[l]=jotai.useAtom(inlineEditingActiveAtom),[r]=jotai.useAtom(treeRefAtom),{clearHighlight:i}=useBlockHighlight();return c=>{if(l)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"){a([]),o([]),i();return}if(d!=null&&d.getAttribute("data-block-parent")){const p=d.getAttribute("data-style-prop"),u=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");n.includes(m)||r==null||r.closeAll(),o([{id:u,prop:p,blockId:m}]),a([m])}else if(d!=null&&d.getAttribute("data-block-id")){const p=d.getAttribute("data-block-id");n.includes(p)||r==null||r.closeAll(),o([]),a(p==="canvas"?[]:[p])}i()}},useHandleMouseMove=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{highlightBlock:n}=useBlockHighlight();return lodashEs.throttle(a=>{if(o)return;const l=getTargetedBlock(a.target);l&&n(l)},20)},useHandleMouseLeave=()=>{const{clearHighlight:o}=useBlockHighlight();return o},Canvas=({children:o})=>{const{document:n}=useFrame(),[a]=useSelectedBlockIds(),[l,r]=useSelectedStylingBlocks(),{clearHighlight:i}=useBlockHighlight();React.useEffect(()=>i,[i]),React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(l))return;const x=getElementByDataBlockId(n,lodashEs.first(a));if(x){const b=x.getAttribute("data-style-prop");if(b){const f=x.getAttribute("data-style-id"),j=x.getAttribute("data-block-parent");r([{id:f,prop:b,blockId:j}])}}},100)},[n,a,r,l]);const c=react.useEditor({extensions:[StarterKit]}),d=React.useRef(null),p=useHandleCanvasDblClick(c,d.current),u=useHandleCanvasClick(),m=useHandleMouseMove(),h=useHandleMouseLeave(),g=useDnd();return jsxRuntime.jsxs("div",{"data-block-id":"canvas",id:"canvas",onClick:u,onDoubleClick:p,onMouseMove:m,onMouseLeave:h,...lodashEs.omit(g,"isDragging"),className:"relative h-full max-w-full p-px "+(g.isDragging?"dragging":""),children:[o,jsxRuntime.jsx("div",{ref:d,style:{display:"none"},children:jsxRuntime.jsx(TiptapBubbleMenu,{editor:c})})]})},getElementByDataBlockId=(o,n)=>o.querySelector(`[data-block-id="${n}"]`),HeadTags=()=>{const[o]=useTheme(),n=useThemeOptions(),[a]=useSelectedBlockIds(),[l]=useDarkMode(),[r]=useSelectedStylingBlocks(),[i]=jotai.useAtom(draggedBlockAtom),[c]=jotai.useAtom(dropTargetBlockIdAtom),{document:d,window:p}=useFrame(),[u]=React.useState(d==null?void 0:d.getElementById("highlighted-block")),[m]=React.useState(d==null?void 0:d.getElementById("selected-block")),[h]=React.useState(d==null?void 0:d.getElementById("selected-styling-block")),[g]=React.useState(d==null?void 0:d.getElementById("dragged-block"));React.useEffect(()=>{l?d==null||d.documentElement.classList.add("dark"):d==null||d.documentElement.classList.remove("dark")},[l,d]),React.useEffect(()=>{!p||!p.tailwind||(p.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...ChaiThemeFn.getChaiThemeOptions(n)}},plugins:[typography,forms,aspectRatio,containerQueries,ChaiThemeFn.plugin(function({addBase:f,theme:j}){f({"h1,h2,h3,h4,h5,h6":{fontFamily:j("fontFamily.heading")},body:{fontFamily:j("fontFamily.body"),color:j("colors.foreground"),backgroundColor:j("colors.background")}})})]})},[o,n,p]),React.useEffect(()=>{m&&(m.textContent=`${lodashEs.map(a,f=>`[data-block-id="${f}"]`).join(",")}{
|
|
56
|
+
</html>`,useKeyEventWatcher=o=>{const[n,a]=useSelectedBlockIds(),l=useSelectedBlock(),r=useRemoveBlocks(),i=useDuplicateBlocks(),{undo:c,redo:d}=useUndoManager(),[,p]=useCutBlockIds(),[,u]=useCopyBlockIds(),{canPaste:m,pasteBlocks:h}=usePasteBlocks(),g=o?{document:o}:{};reactHotkeysHook.useHotkeys("ctrl+z,command+z",()=>c(),{},[c]),reactHotkeysHook.useHotkeys("ctrl+y,command+y",()=>d(),{},[d]),reactHotkeysHook.useHotkeys("ctrl+x,command+x",()=>p(n),{},[n,p]),reactHotkeysHook.useHotkeys("ctrl+c,command+c",()=>u(n),{},[n,u]),reactHotkeysHook.useHotkeys("ctrl+v,command+v",()=>{m(n[0])&&h(n)},{...g,preventDefault:!0},[n,m,h]),reactHotkeysHook.useHotkeys("esc",()=>a([]),g,[a]),reactHotkeysHook.useHotkeys("ctrl+d,command+d",()=>i(n),{...g,preventDefault:!0},[n,i]),reactHotkeysHook.useHotkeys("del, backspace",x=>{x.preventDefault(),canDeleteBlock(lodashEs.get(l,"_type",""))&&r(n)},g,[n,r])},KeyboardHandler=()=>{const{document:o}=useFrame();return useKeyEventWatcher(o),null},AddBlockAtBottom=()=>{const{t:o}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"group relative w-full cursor-pointer py-2",children:[jsxRuntime.jsx("br",{}),jsxRuntime.jsx("div",{onClick:()=>pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),className:"h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",children:jsxRuntime.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500",children:[jsxRuntime.jsx(lucideReact.PlusIcon,{className:"size-2.5 stroke-[3]"})," ",o("Add block")]})}),jsxRuntime.jsx("br",{})]})};function getOrientation(o){const n=window.getComputedStyle(o),a=n.display;if(a==="flex"||a==="inline-flex"){const l=n.flexDirection;return l==="column"||l==="column-reverse"?"vertical":"horizontal"}else if(a==="grid"){const l=n.gridAutoFlow,r=n.gridTemplateRows,i=n.gridTemplateColumns;return l.includes("column")||r.split(" ").length>i.split(" ").length?"vertical":"horizontal"}else if(a==="block"||a==="inline-block")return"vertical";return"horizontal"}let iframeDocument=null,possiblePositions=[],dropTarget=null,dropIndex=null;const positionPlaceholder=(o,n,a)=>{if(!iframeDocument||!o)return;const l=iframeDocument==null?void 0:iframeDocument.getElementById("placeholder"),r=possiblePositions.map(([p])=>p),i=r.reduce((p,u)=>Math.abs(u-a)<Math.abs(p-a)?u:p,0),c=r.indexOf(i);if(!possiblePositions[c])return;const d=possiblePositions[c];l.style.width=n==="vertical"?d[2]+"px":"2px",l.style.height=n==="vertical"?"2px":d[2]+"px",l.style.display="block",n==="vertical"?(l.style.top=d[0]+"px",l.style.left=d[1]+"px"):(l.style.top=d[1]+"px",l.style.left=d[0]+"px")};function calculateDropIndex(o,n){let a=0,l=1/0;return n.forEach((r,i)=>{const c=Math.abs(r[0]-o);c<l&&(l=c,a=i)}),a}const calculatePossiblePositions=o=>{const a=getOrientation(o)==="horizontal";possiblePositions=[],Array.from(o.children).forEach((l,r)=>{if(l.classList.contains("pointer-events-none"))return;const i=a?l.offsetLeft:l.offsetTop,c=a?[l.offsetTop,l.clientHeight]:[l.offsetLeft,l.clientWidth];if(possiblePositions.push([i,c[0],c[1]]),r===o.children.length-1){const d=a?l.offsetLeft+l.clientWidth:l.offsetTop+l.clientHeight;possiblePositions.push([d,c[0],c[1]])}})},throttledDragOver=lodashEs.throttle(o=>{var r;const n=o.target,a=getOrientation(n),l=(r=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:r.scrollY;a==="vertical"?positionPlaceholder(n,a,o.clientY+l):positionPlaceholder(n,a,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(a=>{a.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,a]=jotai.useAtom(draggingFlagAtom),{addCoreBlock:l}=useAddBlock(),[,r]=useHighlightBlockId(),[,i]=useSelectedBlockIds(),{moveBlocks:c}=useBlocksStoreUndoableActions(),[d,p]=jotai.useAtom(draggedBlockAtom),[,u]=jotai.useAtom(dropTargetBlockIdAtom);if(!flagged.useFeature("dnd"))return{};const h=()=>{removePlaceholder(),a(!1),p(null),u(null),possiblePositions=[]};return iframeDocument=o,{isDragging:n,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),throttledDragOver(g)},onDrop:g=>{var k;const x=dropTarget,f=getOrientation(x)==="vertical"?g.clientY+((k=iframeDocument==null?void 0:iframeDocument.defaultView)==null?void 0:k.scrollY):g.clientX;dropIndex=calculateDropIndex(f,possiblePositions);const j=d,S=x.getAttribute("data-block-id"),w=dropTarget.getAttribute("data-dnd-dragged")!=="yes";if((j==null?void 0:j._id)===S||!w){h();return}if(!lodashEs.has(j,"_id")){l(j,S==="canvas"?null:S,dropIndex),setTimeout(h,300);return}let v=x.getAttribute("data-block-id");v===null&&(v=g.target.parentElement.getAttribute("data-block-id")),c([j._id],v==="canvas"?null:v,dropIndex),h(),setTimeout(removePlaceholder,300)},onDragEnter:g=>{const x=g,b=x.target;dropTarget=b;const f=b.getAttribute("data-block-id"),j=b.getAttribute("data-dnd-dragged")!=="yes";u(f),x.stopPropagation(),x.preventDefault(),possiblePositions=[],j&&calculatePossiblePositions(b),a(!0),r(""),i([])},onDragLeave:g=>{g.target.getAttribute("data-block-id")==="canvas"&&(u(null),a(!1),removePlaceholder(),possiblePositions=[])}}};function getTargetedBlock(o){if(o.getAttribute("data-block-id")==="canvas")return null;if(o.getAttribute("data-block-id")||o.getAttribute("data-block-parent"))return o;const n=o.closest("[data-block-id]");return(n==null?void 0:n.getAttribute("data-block-id"))==="canvas"?null:n}const useHandleCanvasDblClick=(o,n)=>{const a=[],l=useUpdateBlocksProps(),[r,i]=jotai.useAtom(inlineEditingActiveAtom),{clearHighlight:c}=useBlockHighlight(),d=useGetBlockAtomValue(pageBlocksAtomsAtom);return React.useCallback(p=>{if(r)return;const u=getTargetedBlock(p.target);if(!u)return;const m=u.getAttribute("data-block-type");if(!m||!a.includes(m))return;const h=u.getAttribute("data-block-id");if(!h)return;o.on("update",({editor:x})=>{console.log(x.getHTML())}),o.on("blur",()=>{console.log("blur");const x=o.getHTML();l([h],{content:x}),n.style.display="none",u.style.visibility="visible"}),i(h);const g=d(h).content;o.commands.setContent(g),n.style.display="block",u.style.visibility="hidden",n.style.position="absolute",n.style.top=`${u.offsetTop}px`,n.style.left=`${u.offsetLeft}px`,n.style.width=`${u.offsetWidth}px`,n.style.height=`${u.offsetHeight}px`,n.classList.add(...u.classList)},[r,c,d,i,l,o,n])},useHandleCanvasClick=()=>{const[,o]=useSelectedStylingBlocks(),[n,a]=useSelectedBlockIds(),[l]=jotai.useAtom(inlineEditingActiveAtom),[r]=jotai.useAtom(treeRefAtom),{clearHighlight:i}=useBlockHighlight();return c=>{if(l)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"){a([]),o([]),i();return}if(d!=null&&d.getAttribute("data-block-parent")){const p=d.getAttribute("data-style-prop"),u=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");n.includes(m)||r==null||r.closeAll(),o([{id:u,prop:p,blockId:m}]),a([m])}else if(d!=null&&d.getAttribute("data-block-id")){const p=d.getAttribute("data-block-id");n.includes(p)||r==null||r.closeAll(),o([]),a(p==="canvas"?[]:[p])}i()}},useHandleMouseMove=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{highlightBlock:n}=useBlockHighlight();return lodashEs.throttle(a=>{if(o)return;const l=getTargetedBlock(a.target);l&&n(l)},20)},useHandleMouseLeave=()=>{const{clearHighlight:o}=useBlockHighlight();return o},Canvas=({children:o})=>{const{document:n}=useFrame(),[a]=useSelectedBlockIds(),[l,r]=useSelectedStylingBlocks(),{clearHighlight:i}=useBlockHighlight();React.useEffect(()=>i,[i]),React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(l))return;const x=getElementByDataBlockId(n,lodashEs.first(a));if(x){const b=x.getAttribute("data-style-prop");if(b){const f=x.getAttribute("data-style-id"),j=x.getAttribute("data-block-parent");r([{id:f,prop:b,blockId:j}])}}},100)},[n,a,r,l]);const c=react.useEditor({extensions:[StarterKit]}),d=React.useRef(null),p=useHandleCanvasDblClick(c,d.current),u=useHandleCanvasClick(),m=useHandleMouseMove(),h=useHandleMouseLeave(),g=useDnd();return jsxRuntime.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:u,onDoubleClick:p,onMouseMove:m,onMouseLeave:h,...lodashEs.omit(g,"isDragging"),className:"relative h-full max-w-full p-px "+(g.isDragging?"dragging":""),children:o})},getElementByDataBlockId=(o,n)=>o.querySelector(`[data-block-id="${n}"]`),HeadTags=()=>{const[o]=useTheme(),n=useThemeOptions(),[a]=useSelectedBlockIds(),[l]=useDarkMode(),[r]=useSelectedStylingBlocks(),[i]=jotai.useAtom(draggedBlockAtom),[c]=jotai.useAtom(dropTargetBlockIdAtom),{document:d,window:p}=useFrame(),[u]=React.useState(d==null?void 0:d.getElementById("highlighted-block")),[m]=React.useState(d==null?void 0:d.getElementById("selected-block")),[h]=React.useState(d==null?void 0:d.getElementById("selected-styling-block")),[g]=React.useState(d==null?void 0:d.getElementById("dragged-block"));React.useEffect(()=>{l?d==null||d.documentElement.classList.add("dark"):d==null||d.documentElement.classList.remove("dark")},[l,d]),React.useEffect(()=>{!p||!p.tailwind||(p.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...ChaiThemeFn.getChaiThemeOptions(n)}},plugins:[typography,forms,aspectRatio,containerQueries,ChaiThemeFn.plugin(function({addBase:f,theme:j}){f({"h1,h2,h3,h4,h5,h6":{fontFamily:j("fontFamily.heading")},body:{fontFamily:j("fontFamily.body"),color:j("colors.foreground"),backgroundColor:j("colors.background")}})})]})},[o,n,p]),React.useEffect(()=>{m&&(m.textContent=`${lodashEs.map(a,f=>`[data-block-id="${f}"]`).join(",")}{
|
|
57
57
|
outline: 1px solid ${a.length===1?"#42a1fc !important":"orange !important"}; outline-offset: -1px;
|
|
58
58
|
}`)},[a,m]),React.useEffect(()=>{g.textContent=i?`[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}`:""},[i,g]),React.useEffect(()=>{u&&(u.textContent='[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}')},[u]),React.useEffect(()=>{h&&(h.textContent=`${lodashEs.map(r,({id:f})=>`[data-style-id="${f}"]`).join(",")}{
|
|
59
59
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
60
|
-
}`)},[r,h]),React.useEffect(()=>{d.querySelector("#drop-target-block").innerHTML=c?`[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[c,d]);const x=React.useMemo(()=>ChaiThemeFn.getChaiThemeCssVariables(o),[o]),b=React.useMemo(()=>ChaiThemeFn.getThemeFontsLinkMarkup(lodashEs.pick(o,["fontFamily"])),[o]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{id:"chai-theme",children:x}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:b}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,l]=useSelectedBlockIds(),[,r]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const d=()=>{l([]),r([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})};function applyLanguage(o,n,a){const l=lodashEs.get(a,"i18nProps",[]);if(lodashEs.isEmpty(n)||lodashEs.isEmpty(l))return o;const r=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(r),i=>{lodashEs.includes(l,i)&&!lodashEs.isEmpty(n)&&(r[i]=lodashEs.get(r,`${i}-${n}`,r[i]))}),r}const applyBinding=(o,n)=>{const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(a),l=>{if(lodashEs.isString(a[l])&&!lodashEs.startsWith(l,"_")){let r=a[l];const i=/\{\{(.*?)\}\}/g,c=r.match(i);c&&c.forEach(d=>{const p=d.slice(2,-2),u=lodashEs.get(n,p,d);r=r.replace(d,u)}),a[l]=r}}),a},generateClassNames=lodashEs.memoize(o=>{const{baseClasses:n,classes:a}=getSplitClasses.getSplitChaiClasses(o);return tailwindMerge.twMerge(n,a)});function getElementAttrs(o,n){return lodashEs.get(o,`${n}_attrs`,{})}function getBlockTagAttributes(o){const n={};return Object.keys(o).forEach(a=>{if(lodashEs.isString(o[a])&&o[a].startsWith(getSplitClasses.STYLES_KEY)){const l=generateClassNames(o[a]),r=getElementAttrs(o,a);n[a]={className:l,"data-style-prop":a,"data-block-parent":o._id,"data-style-id":`${a}-${o._id}`,...r}}}),n}const getBlockRuntimeProps=lodashEs.memoize(o=>{const n=runtime.getRegisteredChaiBlock(o),a=lodashEs.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,l])=>lodashEs.get(l,"runtime",!1)))}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((l,[r,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const p=lodashEs.find(c,{_type:i.block});return p&&(l[r]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),l},{}),[o])},BlockRenderer=({blockAtom:o,children:n})=>{const[a]=jotai.useAtom(o),l=React.useMemo(()=>runtime.getRegisteredChaiBlock(a._type),[a._type]),{selectedLang:r,fallbackLang:i}=useLanguages(),c=useBlockRuntimeProps(),d=usePageExternalData(),[p]=useHiddenBlockIds(),[u]=jotai.useAtom(dataBindingActiveAtom),m=lodashEs.get(l,"component",null),h=React.useMemo(()=>u?applyBinding(applyLanguage(a,r,l),d):applyLanguage(a,r,l),[a,r,l,d,u]),g=React.useMemo(()=>getBlockTagAttributes(a),[a]),x=React.useMemo(()=>c(a._id,getBlockRuntimeProps(a._type)),[a]),b=React.useMemo(()=>!lodashEs.has(l,"dataProvider")||!lodashEs.isFunction(l.dataProvider)?{}:l.dataProvider(a,r),[a,r,l]),f=React.useMemo(()=>({blockProps:{"data-block-id":a._id,"data-block-type":a._type},inBuilder:!0,lang:r||i,...h,...g,...x,...b}),[a,r,i,h,g,x,b]);return lodashEs.isNull(m)||p.includes(a._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(m,{...f,children:n})})},GlobalBlocksRenderer=({globalBlockId:o})=>{const{getGlobalBlocks:n}=useGlobalBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),l=React.useMemo(()=>splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:l,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const l=useGetBlockAtom(a),r=React.useMemo(()=>lodashEs.filter(o,c=>lodashEs.has(c,"_id")&&(lodashEs.isEmpty(n)?!c._parent:c._parent===n)),[o,n]),i=React.useCallback(c=>lodashEs.filter(o,d=>d._parent===c._id).length>0,[o]);return lodashEs.map(r,c=>{const d=l(c._id);return d?jsxRuntime.jsx(BlockRenderer,{blockAtom:d,children:c._type==="GlobalBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(GlobalBlocksRenderer,{globalBlockId:lodashEs.get(c,"globalBlock","")})}):i(c)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id}):null},c._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),l=useBuilderProp("htmlDir","ltr"),[r,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let m={};const h=p*u,g=d*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(d-g)/g*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:l==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,l,a]);return React.useEffect(()=>{c()},[n,o,a,c]),r},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasDisplayWidth(),[,a]=useSelectedBlockIds(),l=useSelectedBlock(),[,r]=useHighlightBlockId(),i=React.useRef(null),c=React.useRef(null),[d,p]=React.useState({width:0,height:0}),u=useCanvasScale(d),[m,h]=React.useState([]),[,g]=React.useState([]),[,x]=jotai.useAtom(canvasIframeAtom),[b,f]=useSelectedStylingBlocks(),j=useBuilderProp("loading",!1),S=useBuilderProp("htmlDir","ltr"),w=C=>{p(B=>({...B,width:C}))};React.useEffect(()=>{if(!c.current)return;const{clientWidth:C,clientHeight:B}=c.current;p({width:C,height:B})},[c,n]);const v=(C,B=0)=>{const{top:E}=C.getBoundingClientRect();return E+B>=0&&E-B<=window.innerHeight};React.useEffect(()=>{var C,B;if(l&&l.type!=="Multiple"&&i.current){const E=getElementByDataBlockId(i.current.contentDocument,l._id);E&&(v(E)||(B=(C=i.current)==null?void 0:C.contentWindow)==null||B.scrollTo({top:E.offsetTop,behavior:"smooth"}),h([E]))}},[l]),React.useEffect(()=>{if(!lodashEs.isEmpty(b)&&i.current){const C=getElementByStyleId(i.current.contentDocument,lodashEs.first(b).id);g(C?[C]:[null])}else g([null])},[b]);const k=React.useMemo(()=>{let C=IframeInitialContent;return C=C.replace("__HTML_DIR__",S),o==="offline"&&(C=C.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),C},[o,S]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:w,onResize:w,children:jsxRuntime.jsx("div",{onClick:()=>{a([]),f([])},onMouseLeave:()=>setTimeout(()=>r(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:c,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>x(i.current),ref:i,id:"canvas-iframe",style:{...u,...lodashEs.isEmpty(u)?{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:k,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:l,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[j?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),TypeIcon=o=>{switch(o.type){case"GlobalBlock":return jsxRuntime.jsx(lucideReact.GlobeIcon,{className:"h-3 w-3 stroke-[2]"});case"Image":return jsxRuntime.jsx(reactIcons.ImageIcon,{className:"h-3 w-3 stroke-[2]"});case"Heading":return jsxRuntime.jsx(reactIcons.HeadingIcon,{className:"h-3 w-3 stroke-[2]"});case"Text":return jsxRuntime.jsx(reactIcons.TextIcon,{className:"h-3 w-3 stroke-[2]"});case"Link":return jsxRuntime.jsx(reactIcons.Link1Icon,{className:"h-3 w-3 stroke-[2]"});case"Video":return jsxRuntime.jsx(reactIcons.VideoIcon,{className:"h-3 w-3 stroke-[2]"});case"RichText":return jsxRuntime.jsx(reactIcons.CursorTextIcon,{className:"h-3 w-3 stroke-[2]"});case"Button":case"DropdownButton":return jsxRuntime.jsx(reactIcons.ButtonIcon,{className:"h-3 w-3 stroke-[2]"});case"CustomHTML":return jsxRuntime.jsx(reactIcons.CodeIcon,{className:"h-3 w-3 stroke-[2]"});case"Divider":return jsxRuntime.jsx(reactIcons.DividerHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"Icon":return jsxRuntime.jsx(reactIcons.SketchLogoIcon,{className:"h-3 w-3 stroke-[2]"});case"List":return jsxRuntime.jsx(reactIcons.RowsIcon,{className:"h-3 w-3 stroke-[2]"});case"Paragraph":return jsxRuntime.jsx(reactIcons.TextIcon,{className:"h-3 w-3 stroke-[2]"});case"Row":return jsxRuntime.jsx(lucideReact.Rows,{className:"h-3 w-3 stroke-[2]"});case"Column":return jsxRuntime.jsx(lucideReact.Columns,{className:"h-3 w-3 stroke-[2]"});case"ListItem":return jsxRuntime.jsx(reactIcons.ColumnsIcon,{className:"h-3 w-3 stroke-[2]"});case"LineBreak":return jsxRuntime.jsx(reactIcons.SpaceBetweenVerticallyIcon,{className:"h-3 w-3 stroke-[2]"});case"Form":return jsxRuntime.jsx(reactIcons.GroupIcon,{className:"h-3 w-3 stroke-[2]"});case"Checkbox":return jsxRuntime.jsx(reactIcons.CheckboxIcon,{className:"h-3 w-3 stroke-[2]"});case"FormButton":return jsxRuntime.jsx(reactIcons.ButtonIcon,{className:"h-3 w-3 stroke-[2]"});case"Input":case"TextArea":return jsxRuntime.jsx(reactIcons.InputIcon,{className:"h-3 w-3 stroke-[2]"});case"Radio":return jsxRuntime.jsx(reactIcons.RadiobuttonIcon,{className:"h-3 w-3 stroke-[2]"});case"Select":return jsxRuntime.jsx(reactIcons.DropdownMenuIcon,{className:"h-3 w-3 stroke-[2]"});case"Table":return jsxRuntime.jsx(reactIcons.TableIcon,{className:"h-3 w-3 stroke-[2]"});case"TableHead":return jsxRuntime.jsx(reactIcons.BorderTopIcon,{className:"h-3 w-3 stroke-[2]"});case"TableBody":return jsxRuntime.jsx(reactIcons.BorderAllIcon,{className:"h-3 w-3 stroke-[2]"});case"TableRow":return jsxRuntime.jsx(reactIcons.ViewHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"TableCell":return jsxRuntime.jsx(reactIcons.DragHandleHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"DataProvider":return jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3 stroke-[2]"});case"Box":return jsxRuntime.jsx(reactIcons.BoxIcon,{className:"h-3 w-3 stroke-[2]"});case"Dropdown":return jsxRuntime.jsx(reactIcons.DropdownMenuIcon,{className:"h-3 w-3 stroke-[2]"});case"DropdownContent":return jsxRuntime.jsx(reactIcons.ReaderIcon,{className:"h-3 w-3 stroke-[2]"});case"Slider":return jsxRuntime.jsx(lucideReact.UnfoldHorizontal,{className:"h-3 w-3 stroke-[2]"});case"Slides":return jsxRuntime.jsx(lucideReact.AlignHorizontalJustifyStart,{className:"h-3 w-3 stroke-[2]"});case"Slide":return jsxRuntime.jsx(lucideReact.AppWindowIcon,{className:"h-3 w-3 stroke-[2]"});case"SlidePreviousButton":return jsxRuntime.jsx(lucideReact.PanelRightOpen,{className:"h-3 w-3 stroke-[2]"});case"SlideNextButton":return jsxRuntime.jsx(lucideReact.PanelRightClose,{className:"h-3 w-3 stroke-[2]"});default:return jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:"h-3 w-3 stroke-[2]"})}},Breadcrumb=()=>{const o=useSelectedBlockHierarchy(),[,n]=useSelectedBlockIds(),{highlightBlock:a}=useBlockHighlight();return jsxRuntime.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{onClick:()=>n([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(o).map((l,r)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(tooltip.Button,{onMouseEnter:()=>{a(l==null?void 0:l._id)},onClick:()=>n([l==null?void 0:l._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:l==null?void 0:l._type}),l._name||l._type]}),r!==o.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},r))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-ol63c03C.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},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"}],FontSelector=({label:o,value:n,onChange:a})=>jsxRuntime.jsxs("div",{className:"space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:lodashEs.startCase(o)}),jsxRuntime.jsx("select",{className:"mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:l=>a(l.target.value),children:FONTS.map(l=>jsxRuntime.jsx("option",{value:l.value,children:l.title},l.value))})]}),ColorPickerInput=({value:o,onChange:n})=>{const a=lodashEs.debounce(l=>n(l),200);return jsxRuntime.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:o},children:jsxRuntime.jsx("input",{type:"color",value:o.startsWith("#")?o:"#000000",onChange:l=>{const r=l.target.value;/^#[0-9A-F]{6}$/i.test(r)&&a(r)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},BorderRadiusInput=({value:o,onChange:n,disabled:a})=>{const l=lodashEs.debounce(r=>n(r),200);return jsxRuntime.jsx("input",{type:"range",min:"0",step:"1",max:"30",disabled:a,defaultValue:o.replace("px",""),onChange:r=>l(r.target.value),className:"flex-1 cursor-pointer"})},ThemeConfigPanel=React__namespace.memo(({className:o=""})=>{const[n]=useDarkMode(),[a,l]=React__namespace.useState(""),r=useBuilderProp("themePresets",[]),i=useBuilderProp("themePanelComponent",null),[c,d]=useTheme(),p=useThemeOptions(),{t:u}=reactI18next.useTranslation(),m=j=>{l(j)},h=()=>{const j=r.find(S=>Object.keys(S)[0]===a);if(j){const S=Object.values(j)[0];S&&typeof S=="object"&&"fontFamily"in S&&"borderRadius"in S&&"colors"in S?d(S):console.error("Invalid preset structure:",S)}else console.error("Preset not found:",a)},g=web.useDebouncedCallback((j,S)=>{d(()=>({...c,fontFamily:{...c.fontFamily,[j.replace(/font-/g,"")]:S}}))},[c],200),x=web.useDebouncedCallback(j=>{d(()=>({...c,borderRadius:`${j}px`}))},[c],200),b=web.useDebouncedCallback((j,S)=>{d(()=>{const w=lodashEs.get(c,`colors.${j}`);return n?lodashEs.set(w,1,S):lodashEs.set(w,0,S),{...c,colors:{...c.colors,[j]:w}}})},[c],200),f=j=>jsxRuntime.jsx("div",{className:"grid grid-cols-1",children:Object.entries(j.items).map(([S])=>{const w=lodashEs.get(c,`colors.${S}.${n?1:0}`);return jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-x-2",children:[jsxRuntime.jsx(ColorPickerInput,{value:w,onChange:v=>b(S,v)}),jsxRuntime.jsx(tooltip.Label,{className:"text-xs font-normal leading-tight text-slate-600",children:S.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join(" ")+(!S.toLowerCase().includes("foreground")&&!S.toLowerCase().includes("border")&&!S.toLowerCase().includes("input")&&!S.toLowerCase().includes("ring")&&!S.toLowerCase().includes("background")?" Background":"")})]},S)})});return jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsxs("div",{className:iconBase.cn("no-scrollbar h-full w-full overflow-y-auto",o),children:[r.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-2 py-2",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Presets")}),jsxRuntime.jsxs("select",{value:a,onChange:j=>m(j.target.value),className:"w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[jsxRuntime.jsx("option",{value:"",children:"Select preset"}),Array.isArray(r)&&r.map(j=>jsxRuntime.jsx("option",{value:Object.keys(j)[0],children:lodashEs.capitalize(Object.keys(j)[0])},Object.keys(j)[0]))]})]}),jsxRuntime.jsx("div",{className:"flex w-[30%] items-end",children:jsxRuntime.jsx(tooltip.Button,{className:"w-full text-sm",disabled:a==="",variant:"default",onClick:h,children:u("Apply")})})]}),jsxRuntime.jsxs("div",{className:iconBase.cn("space-y-2",o),children:[(p==null?void 0:p.fontFamily)&&jsxRuntime.jsx("div",{className:"grid gap-4",children:Object.entries(p.fontFamily).map(([j,S])=>jsxRuntime.jsx(FontSelector,{label:j,value:c.fontFamily[j.replace(/font-/g,"")]||S[Object.keys(S)[0]],onChange:w=>g(j,w)},j))}),(p==null?void 0:p.borderRadius)&&jsxRuntime.jsxs("div",{className:"space-y-0.5 py-3",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Border Radius")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 py-2",children:[jsxRuntime.jsx(BorderRadiusInput,{value:c.borderRadius,onChange:x}),jsxRuntime.jsx("span",{className:"w-12 text-sm",children:c.borderRadius})]})]}),(p==null?void 0:p.colors)&&jsxRuntime.jsxs("div",{className:"mt-4 space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Colors")}),jsxRuntime.jsx("div",{className:"w-full space-y-4 pt-2",children:p.colors.map(j=>f(j))},n?"dark":"light")]})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),i&&jsxRuntime.jsx("div",{className:"absolute bottom-4 w-full",children:React__namespace.createElement(i)})]})}),GlobalBlockSettings=()=>{const o=useSelectedBlock(),{data:n,refetch:a,isLoading:l}=useGlobalBlocksList(),r=useUpdateBlocksProps();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(o==null?void 0:o.globalBlock)||"",onChange:i=>{var c;r([o._id],{globalBlock:i.target.value,_name:`Global: ${lodashEs.startCase((c=lodashEs.get(n,i.target.value,""))==null?void 0:c.name)}`})},children:[jsxRuntime.jsx("option",{value:"",children:"Select a global block"}),Object.keys(n).map(i=>jsxRuntime.jsx("option",{value:i,children:n[i].name||i},i))]}),jsxRuntime.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsx("button",{onClick:a,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:l?"Loading...":"Refresh List"})})]})},ICON_PICKER_CONTAINER_ID="icon-picker-item-container",removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},getSvgMarkup=()=>new Promise((o,n)=>{setTimeout(()=>{try{const a=document.getElementById(ICON_PICKER_CONTAINER_ID);let l=(a==null?void 0:a.innerHTML)||"";l=removeSizeAttributes(l),o(l)}catch(a){n(a)}},300)}),IconPickerField=({value:o,onChange:n,id:a})=>{const{t:l}=reactI18next.useTranslation(),[r,i]=React.useState(null);React.useEffect(()=>{i(null)},[o]);const c=async d=>{const p=r;try{i(d);const u=await getSvgMarkup();n(u)}catch{i(p)}};return jsxRuntime.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"relative h-12 w-12 cursor-pointer overflow-hidden rounded-lg border duration-300 hover:bg-gray-100",children:[r?jsxRuntime.jsx("div",{id:ICON_PICKER_CONTAINER_ID,className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform",children:jsxRuntime.jsx(IconPicker.IconPickerItem,{value:r})}):o?jsxRuntime.jsx("div",{className:"absolute left-1/2 top-1/2 h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform",dangerouslySetInnerHTML:{__html:o}}):jsxRuntime.jsx("div",{id:"icon-picker-item-container",className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform",children:jsxRuntime.jsx(IconPicker.IconPickerItem,{value:"BiSolidGrid"})}),jsxRuntime.jsx(IconPicker,{value:r||o,onChange:c,pickButtonStyle:{height:"48px",width:"48px",opacity:0},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:o,onChange:d=>n(d.target.value),placeholder:l("Choose Icon or SVG"),className:"no-scrollbar flex w-full rounded-md border border-border bg-background px-3 py-1.5 text-[10px] leading-4 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"})]})},MediaManagerModal=({children:o,onSelect:n})=>{const[a,l]=React.useState(!1),r=useBuilderProp("mediaManagerComponent",null),i=(...c)=>{n.call(void 0,...c),l(!1)};return jsxRuntime.jsxs(tooltip.Dialog,{open:a,onOpenChange:c=>l(c),children:[jsxRuntime.jsx(tooltip.DialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsx(tooltip.DialogContent,{className:"flex h-3/4 max-w-5xl border-border",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:r?jsxRuntime.jsx(r,{onSelect:i}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:l})=>{const r=useBuilderProp("mediaManagerComponent",null),{t:i}=reactI18next.useTranslation(),c=!lodashEs.isEmpty(r);return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsx(MediaManagerModal,{onSelect:n,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:n,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:o||!lodashEs.isEmpty(o)?i("Replace image"):i("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:i("Enter image URL"),value:o,onBlur:({target:{value:d}})=>l(a,d),onChange:d=>n(d.target.value)})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[l,r]=React__namespace.useState(!1),[i,c]=React__namespace.useState([]),[d,p]=React__namespace.useState(o);React.useEffect(()=>{l||c([]),p(o)},[l,o]);const u=x=>Array.isArray(x)?"array":typeof x=="object"&&x!==null?"object":"value",m=React__namespace.useCallback(x=>{const b=f=>a==="value"?f==="value"||f==="object":a==="array"?f==="array":f===a;x.type==="object"?(c(f=>[...f,x.key]),p(x.value)):b(x.type)&&(n([...i,x.key].join(".")),r(!1))},[i,n,a]),h=React__namespace.useCallback(()=>{if(i.length>0){const x=i.slice(0,-1);c(x),p(x.reduce((b,f)=>b[f],o))}},[i,o]),g=React__namespace.useMemo(()=>Object.entries(d).map(([x,b])=>({key:x,value:b,type:u(b)})).filter(x=>a==="value"?x.type==="value"||x.type==="object":a==="array"?x.type==="array"||x.type==="object":a==="object"?x.type==="object":!0),[d,a]);return jsxRuntime.jsxs(tooltip.Popover,{open:l,onOpenChange:r,children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"outline",className:"h-5 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":l,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3"})})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(tooltip.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(tooltip.Command,{className:"fields-command",children:[jsxRuntime.jsx(tooltip.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(tooltip.CommandList,{children:[jsxRuntime.jsx(tooltip.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(tooltip.CommandGroup,{children:[i.length>0&&jsxRuntime.jsxs(tooltip.CommandItem,{onSelect:h,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),g.map(x=>jsxRuntime.jsxs(tooltip.CommandItem,{value:x.key,disabled:!1,onSelect:()=>m(x),className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:x.key}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&x.type==="object"&&jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:b=>{b.stopPropagation(),n([...i,x.key].join(".")),r(!1)},children:"Select"}),(x.type==="object"||x.type==="array")&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},x.key))]})]})]})})]})}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const r=window.prompt("URL");r&&o.chain().focus().extendMarkRange("link").setLink({href:r}).run()},l=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:l,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:l,onChange:r,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(l||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
|
|
60
|
+
}`)},[r,h]),React.useEffect(()=>{d.querySelector("#drop-target-block").innerHTML=c?`[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[c,d]);const x=React.useMemo(()=>ChaiThemeFn.getChaiThemeCssVariables(o),[o]),b=React.useMemo(()=>ChaiThemeFn.getThemeFontsLinkMarkup(lodashEs.pick(o,["fontFamily"])),[o]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{id:"chai-theme",children:x}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:b}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,l]=useSelectedBlockIds(),[,r]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const d=()=>{l([]),r([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})};function applyLanguage(o,n,a){const l=lodashEs.get(a,"i18nProps",[]);if(lodashEs.isEmpty(n)||lodashEs.isEmpty(l))return o;const r=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(r),i=>{lodashEs.includes(l,i)&&!lodashEs.isEmpty(n)&&(r[i]=lodashEs.get(r,`${i}-${n}`,r[i]))}),r}const applyBinding=(o,n)=>{const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(a),l=>{if(lodashEs.isString(a[l])&&!lodashEs.startsWith(l,"_")){let r=a[l];const i=/\{\{(.*?)\}\}/g,c=r.match(i);c&&c.forEach(d=>{const p=d.slice(2,-2),u=lodashEs.get(n,p,d);r=r.replace(d,u)}),a[l]=r}}),a},generateClassNames=lodashEs.memoize(o=>{const{baseClasses:n,classes:a}=getSplitClasses.getSplitChaiClasses(o);return tailwindMerge.twMerge(n,a)});function getElementAttrs(o,n){return lodashEs.get(o,`${n}_attrs`,{})}function getBlockTagAttributes(o){const n={};return Object.keys(o).forEach(a=>{if(lodashEs.isString(o[a])&&o[a].startsWith(getSplitClasses.STYLES_KEY)){const l=generateClassNames(o[a]),r=getElementAttrs(o,a);n[a]={className:l,"data-style-prop":a,"data-block-parent":o._id,"data-style-id":`${a}-${o._id}`,...r}}}),n}const getBlockRuntimeProps=lodashEs.memoize(o=>{const n=runtime.getRegisteredChaiBlock(o),a=lodashEs.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,l])=>lodashEs.get(l,"runtime",!1)))}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((l,[r,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const p=lodashEs.find(c,{_type:i.block});return p&&(l[r]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),l},{}),[o])},BlockRenderer=({blockAtom:o,children:n})=>{const[a]=jotai.useAtom(o),l=React.useMemo(()=>runtime.getRegisteredChaiBlock(a._type),[a._type]),{selectedLang:r,fallbackLang:i}=useLanguages(),c=useBlockRuntimeProps(),d=usePageExternalData(),[p]=useHiddenBlockIds(),[u]=jotai.useAtom(dataBindingActiveAtom),m=lodashEs.get(l,"component",null),h=React.useMemo(()=>u?applyBinding(applyLanguage(a,r,l),d):applyLanguage(a,r,l),[a,r,l,d,u]),g=React.useMemo(()=>getBlockTagAttributes(a),[a]),x=React.useMemo(()=>c(a._id,getBlockRuntimeProps(a._type)),[a]),b=React.useMemo(()=>!lodashEs.has(l,"dataProvider")||!lodashEs.isFunction(l.dataProvider)?{}:l.dataProvider(a,r),[a,r,l]),f=React.useMemo(()=>({blockProps:{"data-block-id":a._id,"data-block-type":a._type},inBuilder:!0,lang:r||i,...h,...g,...x,...b}),[a,r,i,h,g,x,b]);return lodashEs.isNull(m)||p.includes(a._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(m,{...f,children:n})})},GlobalBlocksRenderer=({globalBlockId:o})=>{const{getGlobalBlocks:n}=useGlobalBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),l=React.useMemo(()=>splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:l,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const l=useGetBlockAtom(a),r=React.useMemo(()=>lodashEs.filter(o,c=>lodashEs.has(c,"_id")&&(lodashEs.isEmpty(n)?!c._parent:c._parent===n)),[o,n]),i=React.useCallback(c=>lodashEs.filter(o,d=>d._parent===c._id).length>0,[o]);return lodashEs.map(r,c=>{const d=l(c._id);return d?jsxRuntime.jsx(BlockRenderer,{blockAtom:d,children:c._type==="GlobalBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(GlobalBlocksRenderer,{globalBlockId:lodashEs.get(c,"globalBlock","")})}):i(c)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id}):null},c._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),l=useBuilderProp("htmlDir","ltr"),[r,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let m={};const h=p*u,g=d*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(d-g)/g*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:l==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,l,a]);return React.useEffect(()=>{c()},[n,o,a,c]),r},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasDisplayWidth(),[,a]=useSelectedBlockIds(),l=useSelectedBlock(),[,r]=useHighlightBlockId(),i=React.useRef(null),c=React.useRef(null),[d,p]=React.useState({width:0,height:0}),u=useCanvasScale(d),[m,h]=React.useState([]),[,g]=React.useState([]),[,x]=jotai.useAtom(canvasIframeAtom),[b,f]=useSelectedStylingBlocks(),j=useBuilderProp("loading",!1),S=useBuilderProp("htmlDir","ltr"),w=C=>{p(B=>({...B,width:C}))};React.useEffect(()=>{if(!c.current)return;const{clientWidth:C,clientHeight:B}=c.current;p({width:C,height:B})},[c,n]);const v=(C,B=0)=>{const{top:E}=C.getBoundingClientRect();return E+B>=0&&E-B<=window.innerHeight};React.useEffect(()=>{var C,B;if(l&&l.type!=="Multiple"&&i.current){const E=getElementByDataBlockId(i.current.contentDocument,l._id);E&&(v(E)||(B=(C=i.current)==null?void 0:C.contentWindow)==null||B.scrollTo({top:E.offsetTop,behavior:"smooth"}),h([E]))}},[l]),React.useEffect(()=>{if(!lodashEs.isEmpty(b)&&i.current){const C=getElementByStyleId(i.current.contentDocument,lodashEs.first(b).id);g(C?[C]:[null])}else g([null])},[b]);const k=React.useMemo(()=>{let C=IframeInitialContent;return C=C.replace("__HTML_DIR__",S),o==="offline"&&(C=C.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),C},[o,S]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:w,onResize:w,children:jsxRuntime.jsx("div",{onClick:()=>{a([]),f([])},onMouseLeave:()=>setTimeout(()=>r(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:c,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>x(i.current),ref:i,id:"canvas-iframe",style:{...u,...lodashEs.isEmpty(u)?{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:k,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:l,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[j?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),TypeIcon=o=>{switch(o.type){case"GlobalBlock":return jsxRuntime.jsx(lucideReact.GlobeIcon,{className:"h-3 w-3 stroke-[2]"});case"Image":return jsxRuntime.jsx(reactIcons.ImageIcon,{className:"h-3 w-3 stroke-[2]"});case"Heading":return jsxRuntime.jsx(reactIcons.HeadingIcon,{className:"h-3 w-3 stroke-[2]"});case"Text":return jsxRuntime.jsx(reactIcons.TextIcon,{className:"h-3 w-3 stroke-[2]"});case"Link":return jsxRuntime.jsx(reactIcons.Link1Icon,{className:"h-3 w-3 stroke-[2]"});case"Video":return jsxRuntime.jsx(reactIcons.VideoIcon,{className:"h-3 w-3 stroke-[2]"});case"RichText":return jsxRuntime.jsx(reactIcons.CursorTextIcon,{className:"h-3 w-3 stroke-[2]"});case"Button":case"DropdownButton":return jsxRuntime.jsx(reactIcons.ButtonIcon,{className:"h-3 w-3 stroke-[2]"});case"CustomHTML":return jsxRuntime.jsx(reactIcons.CodeIcon,{className:"h-3 w-3 stroke-[2]"});case"Divider":return jsxRuntime.jsx(reactIcons.DividerHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"Icon":return jsxRuntime.jsx(reactIcons.SketchLogoIcon,{className:"h-3 w-3 stroke-[2]"});case"List":return jsxRuntime.jsx(reactIcons.RowsIcon,{className:"h-3 w-3 stroke-[2]"});case"Paragraph":return jsxRuntime.jsx(reactIcons.TextIcon,{className:"h-3 w-3 stroke-[2]"});case"Row":return jsxRuntime.jsx(lucideReact.Rows,{className:"h-3 w-3 stroke-[2]"});case"Column":return jsxRuntime.jsx(lucideReact.Columns,{className:"h-3 w-3 stroke-[2]"});case"ListItem":return jsxRuntime.jsx(reactIcons.ColumnsIcon,{className:"h-3 w-3 stroke-[2]"});case"LineBreak":return jsxRuntime.jsx(reactIcons.SpaceBetweenVerticallyIcon,{className:"h-3 w-3 stroke-[2]"});case"Form":return jsxRuntime.jsx(reactIcons.GroupIcon,{className:"h-3 w-3 stroke-[2]"});case"Checkbox":return jsxRuntime.jsx(reactIcons.CheckboxIcon,{className:"h-3 w-3 stroke-[2]"});case"FormButton":return jsxRuntime.jsx(reactIcons.ButtonIcon,{className:"h-3 w-3 stroke-[2]"});case"Input":case"TextArea":return jsxRuntime.jsx(reactIcons.InputIcon,{className:"h-3 w-3 stroke-[2]"});case"Radio":return jsxRuntime.jsx(reactIcons.RadiobuttonIcon,{className:"h-3 w-3 stroke-[2]"});case"Select":return jsxRuntime.jsx(reactIcons.DropdownMenuIcon,{className:"h-3 w-3 stroke-[2]"});case"Table":return jsxRuntime.jsx(reactIcons.TableIcon,{className:"h-3 w-3 stroke-[2]"});case"TableHead":return jsxRuntime.jsx(reactIcons.BorderTopIcon,{className:"h-3 w-3 stroke-[2]"});case"TableBody":return jsxRuntime.jsx(reactIcons.BorderAllIcon,{className:"h-3 w-3 stroke-[2]"});case"TableRow":return jsxRuntime.jsx(reactIcons.ViewHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"TableCell":return jsxRuntime.jsx(reactIcons.DragHandleHorizontalIcon,{className:"h-3 w-3 stroke-[2]"});case"DataProvider":return jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3 stroke-[2]"});case"Box":return jsxRuntime.jsx(reactIcons.BoxIcon,{className:"h-3 w-3 stroke-[2]"});case"Dropdown":return jsxRuntime.jsx(reactIcons.DropdownMenuIcon,{className:"h-3 w-3 stroke-[2]"});case"DropdownContent":return jsxRuntime.jsx(reactIcons.ReaderIcon,{className:"h-3 w-3 stroke-[2]"});case"Slider":return jsxRuntime.jsx(lucideReact.UnfoldHorizontal,{className:"h-3 w-3 stroke-[2]"});case"Slides":return jsxRuntime.jsx(lucideReact.AlignHorizontalJustifyStart,{className:"h-3 w-3 stroke-[2]"});case"Slide":return jsxRuntime.jsx(lucideReact.AppWindowIcon,{className:"h-3 w-3 stroke-[2]"});case"SlidePreviousButton":return jsxRuntime.jsx(lucideReact.PanelRightOpen,{className:"h-3 w-3 stroke-[2]"});case"SlideNextButton":return jsxRuntime.jsx(lucideReact.PanelRightClose,{className:"h-3 w-3 stroke-[2]"});default:return jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:"h-3 w-3 stroke-[2]"})}},Breadcrumb=()=>{const o=useSelectedBlockHierarchy(),[,n]=useSelectedBlockIds(),{highlightBlock:a}=useBlockHighlight();return jsxRuntime.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsx(tooltip.Button,{onClick:()=>n([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(o).map((l,r)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(tooltip.Button,{onMouseEnter:()=>{a(l==null?void 0:l._id)},onClick:()=>n([l==null?void 0:l._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:l==null?void 0:l._type}),l._name||l._type]}),r!==o.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},r))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-ol63c03C.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(tooltip.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},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"}],FontSelector=({label:o,value:n,onChange:a})=>jsxRuntime.jsxs("div",{className:"space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:lodashEs.startCase(o)}),jsxRuntime.jsx("select",{className:"mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:l=>a(l.target.value),children:FONTS.map(l=>jsxRuntime.jsx("option",{value:l.value,children:l.title},l.value))})]}),ColorPickerInput=({value:o,onChange:n})=>{const a=lodashEs.debounce(l=>n(l),200);return jsxRuntime.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:o},children:jsxRuntime.jsx("input",{type:"color",value:o.startsWith("#")?o:"#000000",onChange:l=>{const r=l.target.value;/^#[0-9A-F]{6}$/i.test(r)&&a(r)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},BorderRadiusInput=({value:o,onChange:n,disabled:a})=>{const l=lodashEs.debounce(r=>n(r),200);return jsxRuntime.jsx("input",{type:"range",min:"0",step:"1",max:"30",disabled:a,defaultValue:o.replace("px",""),onChange:r=>l(r.target.value),className:"flex-1 cursor-pointer"})},ThemeConfigPanel=React__namespace.memo(({className:o=""})=>{const[n]=useDarkMode(),[a,l]=React__namespace.useState(""),r=useBuilderProp("themePresets",[]),i=useBuilderProp("themePanelComponent",null),[c,d]=useTheme(),p=useThemeOptions(),{t:u}=reactI18next.useTranslation(),m=j=>{l(j)},h=()=>{const j=r.find(S=>Object.keys(S)[0]===a);if(j){const S=Object.values(j)[0];S&&typeof S=="object"&&"fontFamily"in S&&"borderRadius"in S&&"colors"in S?d(S):console.error("Invalid preset structure:",S)}else console.error("Preset not found:",a)},g=web.useDebouncedCallback((j,S)=>{d(()=>({...c,fontFamily:{...c.fontFamily,[j.replace(/font-/g,"")]:S}}))},[c],200),x=web.useDebouncedCallback(j=>{d(()=>({...c,borderRadius:`${j}px`}))},[c],200),b=web.useDebouncedCallback((j,S)=>{d(()=>{const w=lodashEs.get(c,`colors.${j}`);return n?lodashEs.set(w,1,S):lodashEs.set(w,0,S),{...c,colors:{...c.colors,[j]:w}}})},[c],200),f=j=>jsxRuntime.jsx("div",{className:"grid grid-cols-1",children:Object.entries(j.items).map(([S])=>{const w=lodashEs.get(c,`colors.${S}.${n?1:0}`);return jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-x-2",children:[jsxRuntime.jsx(ColorPickerInput,{value:w,onChange:v=>b(S,v)}),jsxRuntime.jsx(tooltip.Label,{className:"text-xs font-normal leading-tight text-slate-600",children:S.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join(" ")+(!S.toLowerCase().includes("foreground")&&!S.toLowerCase().includes("border")&&!S.toLowerCase().includes("input")&&!S.toLowerCase().includes("ring")&&!S.toLowerCase().includes("background")?" Background":"")})]},S)})});return jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsxs("div",{className:iconBase.cn("no-scrollbar h-full w-full overflow-y-auto",o),children:[r.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-2 py-2",children:[jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Presets")}),jsxRuntime.jsxs("select",{value:a,onChange:j=>m(j.target.value),className:"w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[jsxRuntime.jsx("option",{value:"",children:"Select preset"}),Array.isArray(r)&&r.map(j=>jsxRuntime.jsx("option",{value:Object.keys(j)[0],children:lodashEs.capitalize(Object.keys(j)[0])},Object.keys(j)[0]))]})]}),jsxRuntime.jsx("div",{className:"flex w-[30%] items-end",children:jsxRuntime.jsx(tooltip.Button,{className:"w-full text-sm",disabled:a==="",variant:"default",onClick:h,children:u("Apply")})})]}),jsxRuntime.jsxs("div",{className:iconBase.cn("space-y-2",o),children:[(p==null?void 0:p.fontFamily)&&jsxRuntime.jsx("div",{className:"grid gap-4",children:Object.entries(p.fontFamily).map(([j,S])=>jsxRuntime.jsx(FontSelector,{label:j,value:c.fontFamily[j.replace(/font-/g,"")]||S[Object.keys(S)[0]],onChange:w=>g(j,w)},j))}),(p==null?void 0:p.borderRadius)&&jsxRuntime.jsxs("div",{className:"space-y-0.5 py-3",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Border Radius")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 py-2",children:[jsxRuntime.jsx(BorderRadiusInput,{value:c.borderRadius,onChange:x}),jsxRuntime.jsx("span",{className:"w-12 text-sm",children:c.borderRadius})]})]}),(p==null?void 0:p.colors)&&jsxRuntime.jsxs("div",{className:"mt-4 space-y-0.5",children:[jsxRuntime.jsx(tooltip.Label,{className:"text-sm text-slate-800",children:u("Colors")}),jsxRuntime.jsx("div",{className:"w-full space-y-4 pt-2",children:p.colors.map(j=>f(j))},n?"dark":"light")]})]}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),i&&jsxRuntime.jsx("div",{className:"absolute bottom-4 w-full",children:React__namespace.createElement(i)})]})}),GlobalBlockSettings=()=>{const o=useSelectedBlock(),{data:n,refetch:a,isLoading:l}=useGlobalBlocksList(),r=useUpdateBlocksProps();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(o==null?void 0:o.globalBlock)||"",onChange:i=>{var c;r([o._id],{globalBlock:i.target.value,_name:`Global: ${lodashEs.startCase((c=lodashEs.get(n,i.target.value,""))==null?void 0:c.name)}`})},children:[jsxRuntime.jsx("option",{value:"",children:"Select a global block"}),Object.keys(n).map(i=>jsxRuntime.jsx("option",{value:i,children:n[i].name||i},i))]}),jsxRuntime.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsx("button",{onClick:a,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:l?"Loading...":"Refresh List"})})]})},ICON_PICKER_CONTAINER_ID="icon-picker-item-container",removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},getSvgMarkup=()=>new Promise((o,n)=>{setTimeout(()=>{try{const a=document.getElementById(ICON_PICKER_CONTAINER_ID);let l=(a==null?void 0:a.innerHTML)||"";l=removeSizeAttributes(l),o(l)}catch(a){n(a)}},300)}),IconPickerField=({value:o,onChange:n,id:a})=>{const{t:l}=reactI18next.useTranslation(),[r,i]=React.useState(null);React.useEffect(()=>{i(null)},[o]);const c=async d=>{const p=r;try{i(d);const u=await getSvgMarkup();n(u)}catch{i(p)}};return jsxRuntime.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"relative h-12 w-12 cursor-pointer overflow-hidden rounded-lg border duration-300 hover:bg-gray-100",children:[r?jsxRuntime.jsx("div",{id:ICON_PICKER_CONTAINER_ID,className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform",children:jsxRuntime.jsx(IconPicker.IconPickerItem,{value:r})}):o?jsxRuntime.jsx("div",{className:"absolute left-1/2 top-1/2 h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform",dangerouslySetInnerHTML:{__html:o}}):jsxRuntime.jsx("div",{id:"icon-picker-item-container",className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform",children:jsxRuntime.jsx(IconPicker.IconPickerItem,{value:"BiSolidGrid"})}),jsxRuntime.jsx(IconPicker,{value:r||o,onChange:c,pickButtonStyle:{height:"48px",width:"48px",opacity:0},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:o,onChange:d=>n(d.target.value),placeholder:l("Choose Icon or SVG"),className:"no-scrollbar flex w-full rounded-md border border-border bg-background px-3 py-1.5 text-[10px] leading-4 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"})]})},MediaManagerModal=({children:o,onSelect:n})=>{const[a,l]=React.useState(!1),r=useBuilderProp("mediaManagerComponent",null),i=(...c)=>{n.call(void 0,...c),l(!1)};return jsxRuntime.jsxs(tooltip.Dialog,{open:a,onOpenChange:c=>l(c),children:[jsxRuntime.jsx(tooltip.DialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsx(tooltip.DialogContent,{className:"flex h-3/4 max-w-5xl border-border",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:r?jsxRuntime.jsx(r,{onSelect:i}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:l})=>{const r=useBuilderProp("mediaManagerComponent",null),{t:i}=reactI18next.useTranslation(),c=!lodashEs.isEmpty(r);return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsx(MediaManagerModal,{onSelect:n,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:n,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:o||!lodashEs.isEmpty(o)?i("Replace image"):i("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:i("Enter image URL"),value:o,onBlur:({target:{value:d}})=>l(a,d),onChange:d=>n(d.target.value)})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[l,r]=React__namespace.useState(!1),[i,c]=React__namespace.useState([]),[d,p]=React__namespace.useState(o);React.useEffect(()=>{l||c([]),p(o)},[l,o]);const u=x=>Array.isArray(x)?"array":typeof x=="object"&&x!==null?"object":"value",m=React__namespace.useCallback(x=>{const b=f=>a==="value"?f==="value"||f==="object":a==="array"?f==="array":f===a;x.type==="object"?(c(f=>[...f,x.key]),p(x.value)):b(x.type)&&(n([...i,x.key].join(".")),r(!1))},[i,n,a]),h=React__namespace.useCallback(()=>{if(i.length>0){const x=i.slice(0,-1);c(x),p(x.reduce((b,f)=>b[f],o))}},[i,o]),g=React__namespace.useMemo(()=>Object.entries(d).map(([x,b])=>({key:x,value:b,type:u(b)})).filter(x=>a==="value"?x.type==="value"||x.type==="object":a==="array"?x.type==="array"||x.type==="object":a==="object"?x.type==="object":!0),[d,a]);return jsxRuntime.jsxs(tooltip.Popover,{open:l,onOpenChange:r,children:[jsxRuntime.jsxs(tooltip.Tooltip,{children:[jsxRuntime.jsx(tooltip.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"outline",className:"h-5 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":l,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-3 w-3"})})})}),jsxRuntime.jsx(tooltip.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(tooltip.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(tooltip.Command,{className:"fields-command",children:[jsxRuntime.jsx(tooltip.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(tooltip.CommandList,{children:[jsxRuntime.jsx(tooltip.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(tooltip.CommandGroup,{children:[i.length>0&&jsxRuntime.jsxs(tooltip.CommandItem,{onSelect:h,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),g.map(x=>jsxRuntime.jsxs(tooltip.CommandItem,{value:x.key,disabled:!1,onSelect:()=>m(x),className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:x.key}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&x.type==="object"&&jsxRuntime.jsx(tooltip.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:b=>{b.stopPropagation(),n([...i,x.key].join(".")),r(!1)},children:"Select"}),(x.type==="object"||x.type==="array")&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},x.key))]})]})]})})]})}function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const r=window.prompt("URL");r&&o.chain().focus().extendMarkRange("link").setLink({href:r}).run()},l=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:l,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:l,onChange:r,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(l||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
|
|
61
61
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
62
62
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
63
63
|
[data-radix-popper-content-wrapper] {
|
package/dist/core.js
CHANGED
|
@@ -22,15 +22,14 @@ import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThe
|
|
|
22
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
24
24
|
import { toast } from "sonner";
|
|
25
|
-
import { PlusIcon as PlusIcon$1,
|
|
26
|
-
import {
|
|
25
|
+
import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
26
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
27
27
|
import StarterKit from "@tiptap/starter-kit";
|
|
28
|
-
import clsx$1, { clsx } from "clsx";
|
|
29
|
-
import { twMerge } from "tailwind-merge";
|
|
30
28
|
import typography from "@tailwindcss/typography";
|
|
31
29
|
import forms from "@tailwindcss/forms";
|
|
32
30
|
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
33
31
|
import containerQueries from "@tailwindcss/container-queries";
|
|
32
|
+
import { twMerge } from "tailwind-merge";
|
|
34
33
|
import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
|
|
35
34
|
import ReactDOM from "react-dom";
|
|
36
35
|
import { ErrorBoundary } from "react-error-boundary";
|
|
@@ -40,6 +39,7 @@ import validator from "@rjsf/validator-ajv8";
|
|
|
40
39
|
import Link from "@tiptap/extension-link";
|
|
41
40
|
import TextAlign from "@tiptap/extension-text-align";
|
|
42
41
|
import Underline from "@tiptap/extension-underline";
|
|
42
|
+
import clsx$1, { clsx } from "clsx";
|
|
43
43
|
import IconPicker, { IconPickerItem } from "react-icons-picker";
|
|
44
44
|
import Autosuggest from "react-autosuggest";
|
|
45
45
|
import Fuse from "fuse.js";
|
|
@@ -3552,38 +3552,6 @@ const useDnd = () => {
|
|
|
3552
3552
|
}
|
|
3553
3553
|
};
|
|
3554
3554
|
};
|
|
3555
|
-
function cn(...o) {
|
|
3556
|
-
return twMerge(clsx(o));
|
|
3557
|
-
}
|
|
3558
|
-
const TiptapBubbleMenu = ({ editor: o }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3559
|
-
/* @__PURE__ */ jsx(BubbleMenu, { editor: o, tippyOptions: { duration: 100 }, children: /* @__PURE__ */ jsxs("div", { className: "bubble-menu space-x-2", children: [
|
|
3560
|
-
/* @__PURE__ */ jsx(
|
|
3561
|
-
"button",
|
|
3562
|
-
{
|
|
3563
|
-
onClick: () => o.chain().focus().toggleBold().run(),
|
|
3564
|
-
className: cn(o.isActive("bold") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3565
|
-
children: /* @__PURE__ */ jsx(Bold, {})
|
|
3566
|
-
}
|
|
3567
|
-
),
|
|
3568
|
-
/* @__PURE__ */ jsx(
|
|
3569
|
-
"button",
|
|
3570
|
-
{
|
|
3571
|
-
onClick: () => o.chain().focus().toggleItalic().run(),
|
|
3572
|
-
className: cn(o.isActive("italic") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3573
|
-
children: /* @__PURE__ */ jsx(Italic, {})
|
|
3574
|
-
}
|
|
3575
|
-
),
|
|
3576
|
-
/* @__PURE__ */ jsx(
|
|
3577
|
-
"button",
|
|
3578
|
-
{
|
|
3579
|
-
onClick: () => o.chain().focus().toggleStrike().run(),
|
|
3580
|
-
className: cn(o.isActive("strike") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3581
|
-
children: /* @__PURE__ */ jsx(Strikethrough, {})
|
|
3582
|
-
}
|
|
3583
|
-
)
|
|
3584
|
-
] }) }),
|
|
3585
|
-
/* @__PURE__ */ jsx(EditorContent, { editor: o })
|
|
3586
|
-
] });
|
|
3587
3555
|
function getTargetedBlock(o) {
|
|
3588
3556
|
if (o.getAttribute("data-block-id") === "canvas")
|
|
3589
3557
|
return null;
|
|
@@ -3664,7 +3632,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3664
3632
|
const c = useEditor({
|
|
3665
3633
|
extensions: [StarterKit]
|
|
3666
3634
|
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
|
|
3667
|
-
return /* @__PURE__ */
|
|
3635
|
+
return /* @__PURE__ */ jsx(
|
|
3668
3636
|
"div",
|
|
3669
3637
|
{
|
|
3670
3638
|
"data-block-id": "canvas",
|
|
@@ -3675,10 +3643,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3675
3643
|
onMouseLeave: m,
|
|
3676
3644
|
...omit(f, "isDragging"),
|
|
3677
3645
|
className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
|
|
3678
|
-
children:
|
|
3679
|
-
o,
|
|
3680
|
-
/* @__PURE__ */ jsx("div", { ref: d, style: { display: "none" }, children: /* @__PURE__ */ jsx(TiptapBubbleMenu, { editor: c }) })
|
|
3681
|
-
]
|
|
3646
|
+
children: o
|
|
3682
3647
|
}
|
|
3683
3648
|
);
|
|
3684
3649
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
@@ -4542,6 +4507,9 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4542
4507
|
] }) })
|
|
4543
4508
|
] });
|
|
4544
4509
|
}
|
|
4510
|
+
function cn(...o) {
|
|
4511
|
+
return twMerge(clsx(o));
|
|
4512
|
+
}
|
|
4545
4513
|
const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
4546
4514
|
if (!o)
|
|
4547
4515
|
return null;
|
package/dist/web-blocks.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),k=require("react"),b=require("./iconBase-Cn2BsTrq.cjs"),y=require("@radix-ui/react-icons"),g=require("lodash-es"),B=require("lucide-react");function v(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const h=v(k),C=({className:e="",inBuilder:l})=>l?i.jsx("div",{className:b.cn("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,_=e=>{const{blockProps:l,inBuilder:t,backgroundImage:s,children:r,tag:n="div",styles:a}=e;let c=r;r||(c=i.jsx(C,{inBuilder:t}));let p={};return s&&(p={backgroundImage:`url(${s})`}),h.createElement(n,{...l,...a,style:p},c)},j={type:"Box",label:"Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image"}},tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]}}}),canAcceptBlock:()=>!0},N=e=>{const{blockProps:l,iconSize:t,icon:s,content:r,styles:n,children:a,iconPos:c,link:p,inBuilder:d}=e,m=s,f=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:r}),m&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:m}})]}),u=k.createElement("button",{...l,...n,type:"button","aria-label":r},f);return g.isEmpty(g.get(p,"href"))?u:d?i.jsx("span",{children:u}):i.jsx("a",{"aria-label":r,href:g.get(p,"href")||"/",target:g.get(p,"target","_self"),children:u})},E={type:"Button",label:"Button",category:"core",icon:y.ButtonIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-primary-foreground bg-primary px-4 py-2 rounded-lg flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),i18nProps:["content"],aiProps:["content"]},M=e=>{const{blockProps:l,styles:t,htmlCode:s,inBuilder:r}=e;return r?i.jsxs("div",{className:"relative",children:[r?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:s.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:s}})},T={type:"CustomHTML",label:"web_blocks.custom_html",category:"core",icon:y.CodeIcon,group:"advanced",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{blockProps:l,styles:t,backgroundImage:s}=e;let r={};return s&&(r={backgroundImage:`url(${s})`}),h.createElement("div",{...l,...t,style:r})},R={type:"EmptyBox",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},A=e=>{const{blockProps:l,styles:t,content:s,tag:r="h1",children:n=null}=e;return n?h.createElement(r,{...t,...l},n):h.createElement(r,{...t,...l,dangerouslySetInnerHTML:{__html:s}})},z={type:"Heading",label:"web_blocks.heading",category:"core",icon:y.HeadingIcon,group:"typography",...o.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:o.StylesProp("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Text"},H=e=>{const{blockProps:l,styles:t,content:s}=e;return g.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:s}}):h.createElement("p",{...t,...l},e.children)},D={type:"Paragraph",label:"Paragraph",category:"core",icon:y.TextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.
|
|
2
2
|
Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus
|
|
3
|
-
nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.`,ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},w=(e,...l)=>({...e,className:b.cn(e.className,...l)}),q=e=>{const{blockProps:l,content:t,styles:s}=e,r=w(s,"prose dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...r,dangerouslySetInnerHTML:{__html:t}})},U={type:"RichText",label:"Rich Text",category:"core",icon:y.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},F=e=>{const{blockProps:l,styles:t,content:s,children:r=null,tag:n}=e;return r?h.createElement("span",{...t,...l},r):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:s||""}})},O={type:"Span",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0};function G(e){return b.GenIcon({tag:"svg",attr:{version:"1.1",viewBox:"0 0 32 32"},child:[{tag:"path",attr:{d:"M4.698 3.419l2.057 23.073 9.231 2.563 9.256-2.566 2.059-23.069h-22.604zM13.226 9.394l-0.409 4.441 9.671 0.001-0.069 0.76-0.665 7.45-0.042 0.478-5.804 1.609-5.796-1.609-0.396-4.443h2.84l0.202 2.257 3.154 0.85 3.156-0.852 0.328-3.67-9.671-0.001 0.069-0.76 0.665-7.45 0.209-2.086h11.287l0.131 1.598 0.403 4.453h-2.841l-0.262-2.922-2.889-0.174h-0.515v-0.004l-2.755 0.074z"},child:[]}]})(e)}const V=e=>{const{scripts:l,inBuilder:t,blockProps:s}=e;return t?i.jsx("div",{...s,children:i.jsx("div",{className:b.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},W={type:"CustomScript",label:"web_blocks.custom_script",category:"core",icon:G,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},X=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},Y={type:"Divider",label:"web_blocks.divider",category:"core",icon:y.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},Z=e=>{const{blockProps:l,inBuilder:t,children:s,globalBlock:r}=e;return t&&!r?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",r]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},s)},J={type:"GlobalBlock",label:"Global Block",icon:B.GlobeIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},K=e=>{const{blockProps:l,icon:t,styles:s,width:r,inBuilder:n,height:a}=e,c=w(s,"");if(g.isEmpty(t))return i.jsx(C,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:r?`${r}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},Q={type:"Icon",label:"web_blocks.icon",category:"core",icon:y.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},ee=e=>{const{blockProps:l,image:t,mobileImage:s,styles:r,alt:n,height:a,width:c,lazyLoading:p}=e;return g.isEmpty(t)?i.jsx(C,{className:"h-36"}):i.jsxs("picture",{children:[s&&i.jsx("source",{srcSet:s,media:"(max-width: 480px)"}),i.jsx("img",{...l,...r,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},te={type:"Image",label:"Image",category:"core",icon:y.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}}}}),aiProps:["alt"],i18nProps:["alt"]},le=e=>{const{blockProps:l,children:t,styles:s,inBuilder:r,content:n,href:a}=e,{hrefType:c,autoplay:p,maxWidth:d,backdropColor:m,galleryName:f}=e,u=w(s,"cb-lightbox vbox-item");if(!t&&g.isEmpty(s==null?void 0:s.className)&&g.isEmpty(n))return i.jsx(C,{inBuilder:r});if(r)return t?i.jsx("span",{...l,...u,children:t}):k.createElement("span",{...l,...u,dangerouslySetInnerHTML:{__html:n}});const x={};return c!=="image"&&(x["data-vbtype"]=c),p&&(x["data-autoplay"]="true"),d&&(x["data-maxwidth"]=d+"px"),m&&(x["data-overlay"]=m),f&&(x["data-gall"]=f),t?i.jsx("a",{"aria-label":n,...x,href:a||"#/",...l,...u,children:t}):k.createElement("a",{...l,...u,...x,href:a||"#",dangerouslySetInnerHTML:{__html:n},"aria-label":n})},oe={type:"LightBoxLink",label:"Lightbox Link",category:"core",icon:y.ImageIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Link text or drop blocks inside"},hrefType:{type:"string",title:"Type",default:"image",enum:["image","video","iframe","inline","ajax"],enumNames:["Image","Video","Iframe","Inline","Ajax"]},href:{type:"string",title:"Href",default:""},autoplay:{type:"boolean",title:"Autoplay (Video only)",default:!1},maxWidth:{type:"number",title:"Max Width",default:""},backdropColor:{type:"string",title:"Backdrop Color",default:""},galleryName:{type:"string",title:"Gallery Name",default:""}},dependencies:{autoplay:["hrefType","video"]}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="Link"&&e!=="LightBoxLink"},re=e=>{const{blockProps:l,link:t,children:s,styles:r,inBuilder:n,content:a}=e;let c={};return!s&&g.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?s?i.jsx("span",{...l,style:c,...r,children:s}):k.createElement("span",{...l,...r,style:c},a):s?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...r,children:s}):k.createElement("a",{...l,...r,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},se={type:"Link",label:"Link",category:"core",icon:y.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},ie=e=>{const{blockProps:l,children:t,listType:s,styles:r,tag:n,inBuilder:a}=e,c=b.cn(g.get(r,"className",""),s);return!t&&g.isEmpty(r==null?void 0:r.className)?i.jsx(C,{inBuilder:a}):h.createElement(n||(s==="list-decimal"?"ol":"ul"),{...l,...r,className:c},t)},ne={type:"List",label:"web_blocks.list",icon:y.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},ae=e=>{const{blockProps:l,content:t,styles:s,children:r,tag:n}=e;return r?h.createElement(n||"li",{...s,...l},r):h.createElement(n||"li",{...s,...l,dangerouslySetInnerHTML:{__html:t}})},ce={type:"ListItem",label:"List Item",icon:y.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"},pe=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,ue={type:"Text",label:"Text",hidden:!0,category:"core",group:"typography",icon:y.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},P=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,I=/^(https?:\/\/)?(www\.)?player.vimeo\.com/,L=/^(https?:\/\/)?(www\.)?dailymotion\.com\/(video|embed\/video)\/([a-zA-Z0-9_-]+)/,de=e=>{if(P.test(e)){const l=e.match(P);return l?`https://www.youtube.com/embed/${l[4]}`:e}if(I.test(e)){const l=e.match(I);return l?`https://player.vimeo.com/video/${l[3]}`:e}if(L.test(e)){const l=e.match(L);return l?`https://www.dailymotion.com/embed/video/${l[4]}`:e}return null},ge=h.memo(e=>{const{blockProps:l,inBuilder:t,styles:s,url:r,controls:n}=e,a=g.get(n,"autoPlay",!1),c=g.get(n,"controls",!1),p=a||g.get(n,"muted",!0),d=g.get(n,"loop",!1);if(g.isEmpty(r))return i.jsx(C,{inBuilder:t,className:"h-36"});let m=de(r),f=null;if(m){if(!g.isEmpty(m)){const u=[];u.push(`autoplay=${a?1:0}`),u.push(`controls=${n?1:0}`),u.push(`mute=${p?1:0}&muted=${p?1:0}`),u.push(`loop=${d?1:0}`),m=`${m}?${u.join("&")}`}f=h.createElement("iframe",{...l,className:"absolute inset-0 w-full h-full",src:m,allow:t?"":"autoplay *; fullscreen *",allowFullScreen:!0,frameBorder:0})}else f=h.createElement("video",{...l,className:"absolute inset-0 w-full h-full",src:r,controls:c,muted:p,autoPlay:t?!1:a,loop:d});return i.jsx("div",{...g.pick(s,["className"]),children:i.jsxs("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[t?i.jsx("div",{...l,...g.omit(s,["className"]),className:"absolute inset-0 z-20 h-full w-full"}):null,f]})})}),me={type:"Video",label:"Video",category:"core",icon:y.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),url:{type:"string",title:"Video URL",default:"https://www.youtube.com/watch?v=9xwazD5SyVg&ab_channel=MaximilianMustermann"},controls:{type:"object",title:"Controls",default:{autoplay:!1,controls:!0,loop:!1,muted:!1},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}}}}),i18nProps:["url"]},ye=e=>{const{blockProps:l,fieldName:t,label:s,styles:r,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=b.generateUUID();return p?i.jsxs("div",{...r,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"checkbox",required:a,defaultChecked:c}),s&&i.jsx("label",{htmlFor:d,children:s})]}):i.jsx("input",{id:d,...l,...n,...r,type:"checkbox",required:a,name:t})},he={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:y.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},fe=e=>{const{children:l,blockProps:t,errorMessage:s,successMessage:r,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(C,{inBuilder:c}));const d={"x-data":"{}","x-on:submit.prevent":"post"},m={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...d,"data-error":s,"data-success":r,method:"post",action:n,...t,...a,children:[i.jsx("div",{...m}),p]})},be={type:"Form",label:"Form",category:"core",icon:B.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form/submit"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},ke=e=>{const{blockProps:l,inBuilder:t,label:s,styles:r,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,d=b.generateUUID(),m={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:d,...m,...n,...r,...l||{},type:t?"button":"submit","aria-label":s,children:[s,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},xe={type:"FormButton",label:"Submit Button",category:"core",icon:y.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},Ce=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d}=e,m=b.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:m,children:s}),i.jsx("input",{name:t,...a,id:m,type:d,placeholder:r,required:p})]}):i.jsx("input",{id:m,name:t,...l,...a,...n,type:d,placeholder:r,required:p})},Be={type:"Input",label:"web_blocks.input",category:"core",icon:y.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","file","hidden","range","submit","color","date","time"]}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},Se=e=>{const{blockProps:l,content:t,styles:s,children:r}=e,n={...s,...l};return r?h.createElement("label",n,r):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},we={type:"Label",label:"Label",category:"core",icon:y.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Pe=e=>{const{blockProps:l,fieldName:t,label:s,styles:r,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=b.generateUUID();return p?i.jsxs("div",{...r,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"radio",required:a,defaultChecked:c}),s&&i.jsx("label",{htmlFor:d,children:s})]}):i.jsx("input",{id:d,...l,...n,...r,type:"radio",required:a,checked:c,name:t})},Ie={type:"Radio",label:"web_blocks.radio",category:"core",icon:y.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},Le=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:m}=e,f=b.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:f,children:s}),i.jsxs("select",{...a,id:f,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:r}),g.map(m,u=>i.jsx("option",{value:u==null?void 0:u.value,children:u==null?void 0:u.label},u==null?void 0:u.value))]})]}):i.jsxs("select",{id:f,...n,...l,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:r}),g.map(m,u=>i.jsx("option",{value:u==null?void 0:u.value,children:u==null?void 0:u.label},u==null?void 0:u.value))]})},ve={type:"Select",label:"web_blocks.select",category:"core",icon:y.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},_e=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,_rows:c,showLabel:p}=e,d=b.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:d,children:s}),i.jsx("textarea",{name:t,...a,id:d,placeholder:r,rows:c})]}):i.jsx("textarea",{id:d,name:t,...l,...a,...n,placeholder:r,rows:c})},je={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:y.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},_rows:{type:"number",title:"Rows",default:3}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},Ne=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},Ee={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Me=e=>{const{blockProps:l,children:t,styles:s,colSpan:r,tabletColSpan:n,desktopColSpan:a}=e,p={className:[g.get(s,"className",""),g.get(S,["SMALL",isNaN(r)||!r?6:r],""),n?g.get(S,["MEDIUM",n||r],""):"",a?g.get(S,["LARGE",n||r],""):""].join(" ")};return i.jsx("div",{...l,...s,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},Te={type:"Column",label:"Column",group:"basic",category:"core",icon:B.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},$e=e=>{const{blockProps:l,children:t,styles:s,gutter:r}=e,a={className:[g.get(s,"className","")," grid grid-cols-12"].join()};return typeof(s==null?void 0:s.style)=="object"?s.style.gap=`${r}px`:a.style={gap:`${r}px`},i.jsx("div",{...l,...s,...a,children:t})},Re={type:"Row",label:"Row",group:"basic",icon:B.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ae=()=>{o.registerChaiBlock(_,j),o.registerChaiBlock($,R),o.registerChaiBlock(N,E),o.registerChaiBlock(A,z),o.registerChaiBlock(H,D),o.registerChaiBlock(F,O),o.registerChaiBlock(q,U),o.registerChaiBlock(re,se),o.registerChaiBlock(le,oe),o.registerChaiBlock(ie,ne),o.registerChaiBlock(ae,ce),o.registerChaiBlock(K,Q),o.registerChaiBlock(ee,te),o.registerChaiBlock(ge,me),o.registerChaiBlock(M,T),o.registerChaiBlock(V,W),o.registerChaiBlock(pe,ue),o.registerChaiBlock(fe,be),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(ye,he),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Le,ve),o.registerChaiBlock(_e,je),o.registerChaiBlock(Se,we),o.registerChaiBlock(Ne,Ee),o.registerChaiBlock(X,Y),o.registerChaiBlock(Z,J),o.registerChaiBlock($e,Re),o.registerChaiBlock(Me,Te)};exports.loadWebBlocks=Ae;
|
|
3
|
+
nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.`,ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},w=(e,...l)=>({...e,className:b.cn(e.className,...l)}),q=e=>{const{blockProps:l,content:t,styles:s}=e,r=w(s,"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...r,dangerouslySetInnerHTML:{__html:t}})},U={type:"RichText",label:"Rich Text",category:"core",icon:y.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},F=e=>{const{blockProps:l,styles:t,content:s,children:r=null,tag:n}=e;return r?h.createElement("span",{...t,...l},r):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:s||""}})},O={type:"Span",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0};function G(e){return b.GenIcon({tag:"svg",attr:{version:"1.1",viewBox:"0 0 32 32"},child:[{tag:"path",attr:{d:"M4.698 3.419l2.057 23.073 9.231 2.563 9.256-2.566 2.059-23.069h-22.604zM13.226 9.394l-0.409 4.441 9.671 0.001-0.069 0.76-0.665 7.45-0.042 0.478-5.804 1.609-5.796-1.609-0.396-4.443h2.84l0.202 2.257 3.154 0.85 3.156-0.852 0.328-3.67-9.671-0.001 0.069-0.76 0.665-7.45 0.209-2.086h11.287l0.131 1.598 0.403 4.453h-2.841l-0.262-2.922-2.889-0.174h-0.515v-0.004l-2.755 0.074z"},child:[]}]})(e)}const V=e=>{const{scripts:l,inBuilder:t,blockProps:s}=e;return t?i.jsx("div",{...s,children:i.jsx("div",{className:b.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},W={type:"CustomScript",label:"web_blocks.custom_script",category:"core",icon:G,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},X=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},Y={type:"Divider",label:"web_blocks.divider",category:"core",icon:y.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},Z=e=>{const{blockProps:l,inBuilder:t,children:s,globalBlock:r}=e;return t&&!r?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",r]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},s)},J={type:"GlobalBlock",label:"Global Block",icon:B.GlobeIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},K=e=>{const{blockProps:l,icon:t,styles:s,width:r,inBuilder:n,height:a}=e,c=w(s,"");if(g.isEmpty(t))return i.jsx(C,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:r?`${r}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},Q={type:"Icon",label:"web_blocks.icon",category:"core",icon:y.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},ee=e=>{const{blockProps:l,image:t,mobileImage:s,styles:r,alt:n,height:a,width:c,lazyLoading:p}=e;return g.isEmpty(t)?i.jsx(C,{className:"h-36"}):i.jsxs("picture",{children:[s&&i.jsx("source",{srcSet:s,media:"(max-width: 480px)"}),i.jsx("img",{...l,...r,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},te={type:"Image",label:"Image",category:"core",icon:y.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}}}}),aiProps:["alt"],i18nProps:["alt"]},le=e=>{const{blockProps:l,children:t,styles:s,inBuilder:r,content:n,href:a}=e,{hrefType:c,autoplay:p,maxWidth:d,backdropColor:m,galleryName:f}=e,u=w(s,"cb-lightbox vbox-item");if(!t&&g.isEmpty(s==null?void 0:s.className)&&g.isEmpty(n))return i.jsx(C,{inBuilder:r});if(r)return t?i.jsx("span",{...l,...u,children:t}):k.createElement("span",{...l,...u,dangerouslySetInnerHTML:{__html:n}});const x={};return c!=="image"&&(x["data-vbtype"]=c),p&&(x["data-autoplay"]="true"),d&&(x["data-maxwidth"]=d+"px"),m&&(x["data-overlay"]=m),f&&(x["data-gall"]=f),t?i.jsx("a",{"aria-label":n,...x,href:a||"#/",...l,...u,children:t}):k.createElement("a",{...l,...u,...x,href:a||"#",dangerouslySetInnerHTML:{__html:n},"aria-label":n})},oe={type:"LightBoxLink",label:"Lightbox Link",category:"core",icon:y.ImageIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Link text or drop blocks inside"},hrefType:{type:"string",title:"Type",default:"image",enum:["image","video","iframe","inline","ajax"],enumNames:["Image","Video","Iframe","Inline","Ajax"]},href:{type:"string",title:"Href",default:""},autoplay:{type:"boolean",title:"Autoplay (Video only)",default:!1},maxWidth:{type:"number",title:"Max Width",default:""},backdropColor:{type:"string",title:"Backdrop Color",default:""},galleryName:{type:"string",title:"Gallery Name",default:""}},dependencies:{autoplay:["hrefType","video"]}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="Link"&&e!=="LightBoxLink"},re=e=>{const{blockProps:l,link:t,children:s,styles:r,inBuilder:n,content:a}=e;let c={};return!s&&g.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?s?i.jsx("span",{...l,style:c,...r,children:s}):k.createElement("span",{...l,...r,style:c},a):s?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...r,children:s}):k.createElement("a",{...l,...r,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},se={type:"Link",label:"Link",category:"core",icon:y.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},ie=e=>{const{blockProps:l,children:t,listType:s,styles:r,tag:n,inBuilder:a}=e,c=b.cn(g.get(r,"className",""),s);return!t&&g.isEmpty(r==null?void 0:r.className)?i.jsx(C,{inBuilder:a}):h.createElement(n||(s==="list-decimal"?"ol":"ul"),{...l,...r,className:c},t)},ne={type:"List",label:"web_blocks.list",icon:y.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},ae=e=>{const{blockProps:l,content:t,styles:s,children:r,tag:n}=e;return r?h.createElement(n||"li",{...s,...l},r):h.createElement(n||"li",{...s,...l,dangerouslySetInnerHTML:{__html:t}})},ce={type:"ListItem",label:"List Item",icon:y.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"},pe=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,ue={type:"Text",label:"Text",hidden:!0,category:"core",group:"typography",icon:y.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},P=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,I=/^(https?:\/\/)?(www\.)?player.vimeo\.com/,L=/^(https?:\/\/)?(www\.)?dailymotion\.com\/(video|embed\/video)\/([a-zA-Z0-9_-]+)/,de=e=>{if(P.test(e)){const l=e.match(P);return l?`https://www.youtube.com/embed/${l[4]}`:e}if(I.test(e)){const l=e.match(I);return l?`https://player.vimeo.com/video/${l[3]}`:e}if(L.test(e)){const l=e.match(L);return l?`https://www.dailymotion.com/embed/video/${l[4]}`:e}return null},ge=h.memo(e=>{const{blockProps:l,inBuilder:t,styles:s,url:r,controls:n}=e,a=g.get(n,"autoPlay",!1),c=g.get(n,"controls",!1),p=a||g.get(n,"muted",!0),d=g.get(n,"loop",!1);if(g.isEmpty(r))return i.jsx(C,{inBuilder:t,className:"h-36"});let m=de(r),f=null;if(m){if(!g.isEmpty(m)){const u=[];u.push(`autoplay=${a?1:0}`),u.push(`controls=${n?1:0}`),u.push(`mute=${p?1:0}&muted=${p?1:0}`),u.push(`loop=${d?1:0}`),m=`${m}?${u.join("&")}`}f=h.createElement("iframe",{...l,className:"absolute inset-0 w-full h-full",src:m,allow:t?"":"autoplay *; fullscreen *",allowFullScreen:!0,frameBorder:0})}else f=h.createElement("video",{...l,className:"absolute inset-0 w-full h-full",src:r,controls:c,muted:p,autoPlay:t?!1:a,loop:d});return i.jsx("div",{...g.pick(s,["className"]),children:i.jsxs("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[t?i.jsx("div",{...l,...g.omit(s,["className"]),className:"absolute inset-0 z-20 h-full w-full"}):null,f]})})}),me={type:"Video",label:"Video",category:"core",icon:y.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),url:{type:"string",title:"Video URL",default:"https://www.youtube.com/watch?v=9xwazD5SyVg&ab_channel=MaximilianMustermann"},controls:{type:"object",title:"Controls",default:{autoplay:!1,controls:!0,loop:!1,muted:!1},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}}}}),i18nProps:["url"]},ye=e=>{const{blockProps:l,fieldName:t,label:s,styles:r,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=b.generateUUID();return p?i.jsxs("div",{...r,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"checkbox",required:a,defaultChecked:c}),s&&i.jsx("label",{htmlFor:d,children:s})]}):i.jsx("input",{id:d,...l,...n,...r,type:"checkbox",required:a,name:t})},he={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:y.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},fe=e=>{const{children:l,blockProps:t,errorMessage:s,successMessage:r,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(C,{inBuilder:c}));const d={"x-data":"{}","x-on:submit.prevent":"post"},m={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...d,"data-error":s,"data-success":r,method:"post",action:n,...t,...a,children:[i.jsx("div",{...m}),p]})},be={type:"Form",label:"Form",category:"core",icon:B.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form/submit"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},ke=e=>{const{blockProps:l,inBuilder:t,label:s,styles:r,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,d=b.generateUUID(),m={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:d,...m,...n,...r,...l||{},type:t?"button":"submit","aria-label":s,children:[s,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},xe={type:"FormButton",label:"Submit Button",category:"core",icon:y.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},Ce=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d}=e,m=b.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:m,children:s}),i.jsx("input",{name:t,...a,id:m,type:d,placeholder:r,required:p})]}):i.jsx("input",{id:m,name:t,...l,...a,...n,type:d,placeholder:r,required:p})},Be={type:"Input",label:"web_blocks.input",category:"core",icon:y.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","file","hidden","range","submit","color","date","time"]}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},Se=e=>{const{blockProps:l,content:t,styles:s,children:r}=e,n={...s,...l};return r?h.createElement("label",n,r):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},we={type:"Label",label:"Label",category:"core",icon:y.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Pe=e=>{const{blockProps:l,fieldName:t,label:s,styles:r,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=b.generateUUID();return p?i.jsxs("div",{...r,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"radio",required:a,defaultChecked:c}),s&&i.jsx("label",{htmlFor:d,children:s})]}):i.jsx("input",{id:d,...l,...n,...r,type:"radio",required:a,checked:c,name:t})},Ie={type:"Radio",label:"web_blocks.radio",category:"core",icon:y.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},Le=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:m}=e,f=b.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:f,children:s}),i.jsxs("select",{...a,id:f,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:r}),g.map(m,u=>i.jsx("option",{value:u==null?void 0:u.value,children:u==null?void 0:u.label},u==null?void 0:u.value))]})]}):i.jsxs("select",{id:f,...n,...l,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:r}),g.map(m,u=>i.jsx("option",{value:u==null?void 0:u.value,children:u==null?void 0:u.label},u==null?void 0:u.value))]})},ve={type:"Select",label:"web_blocks.select",category:"core",icon:y.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},_e=e=>{const{blockProps:l,fieldName:t,label:s,placeholder:r,styles:n,inputStyles:a,_rows:c,showLabel:p}=e,d=b.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:d,children:s}),i.jsx("textarea",{name:t,...a,id:d,placeholder:r,rows:c})]}):i.jsx("textarea",{id:d,name:t,...l,...a,...n,placeholder:r,rows:c})},je={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:y.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},_rows:{type:"number",title:"Rows",default:3}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},Ne=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},Ee={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Me=e=>{const{blockProps:l,children:t,styles:s,colSpan:r,tabletColSpan:n,desktopColSpan:a}=e,p={className:[g.get(s,"className",""),g.get(S,["SMALL",isNaN(r)||!r?6:r],""),n?g.get(S,["MEDIUM",n||r],""):"",a?g.get(S,["LARGE",n||r],""):""].join(" ")};return i.jsx("div",{...l,...s,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},Te={type:"Column",label:"Column",group:"basic",category:"core",icon:B.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},$e=e=>{const{blockProps:l,children:t,styles:s,gutter:r}=e,a={className:[g.get(s,"className","")," grid grid-cols-12"].join()};return typeof(s==null?void 0:s.style)=="object"?s.style.gap=`${r}px`:a.style={gap:`${r}px`},i.jsx("div",{...l,...s,...a,children:t})},Re={type:"Row",label:"Row",group:"basic",icon:B.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ae=()=>{o.registerChaiBlock(_,j),o.registerChaiBlock($,R),o.registerChaiBlock(N,E),o.registerChaiBlock(A,z),o.registerChaiBlock(H,D),o.registerChaiBlock(F,O),o.registerChaiBlock(q,U),o.registerChaiBlock(re,se),o.registerChaiBlock(le,oe),o.registerChaiBlock(ie,ne),o.registerChaiBlock(ae,ce),o.registerChaiBlock(K,Q),o.registerChaiBlock(ee,te),o.registerChaiBlock(ge,me),o.registerChaiBlock(M,T),o.registerChaiBlock(V,W),o.registerChaiBlock(pe,ue),o.registerChaiBlock(fe,be),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(ye,he),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Le,ve),o.registerChaiBlock(_e,je),o.registerChaiBlock(Se,we),o.registerChaiBlock(Ne,Ee),o.registerChaiBlock(X,Y),o.registerChaiBlock(Z,J),o.registerChaiBlock($e,Re),o.registerChaiBlock(Me,Te)};exports.loadWebBlocks=Ae;
|
package/dist/web-blocks.js
CHANGED
|
@@ -243,7 +243,7 @@ const v = ({ className: e = "", inBuilder: l }) => l ? /* @__PURE__ */ i("div",
|
|
|
243
243
|
}), be = (e) => {
|
|
244
244
|
const { blockProps: l, content: t, styles: r } = e, o = _(
|
|
245
245
|
r,
|
|
246
|
-
"prose dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0",
|
|
246
|
+
"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0",
|
|
247
247
|
"max-w-full"
|
|
248
248
|
);
|
|
249
249
|
return /* @__PURE__ */ i("div", { ...l, ...o, dangerouslySetInnerHTML: { __html: t } });
|