@chaibuilder/sdk 2.2.20 → 2.2.22

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var F=Object.defineProperty;var $=(o,n,a)=>n in o?F(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a;var U=(o,n,a)=>$(o,typeof n!="symbol"?n+"":n,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),runtime=require("@chaibuilder/runtime"),reactIcons=require("@radix-ui/react-icons"),lodashEs=require("lodash-es"),React=require("react"),jotai=require("jotai"),utils=require("jotai/utils"),commonFunctions=require("./common-functions-BZmyleS1.cjs"),sooner=require("./sooner-CPeN3CGR.cjs"),lucideReact=require("lucide-react"),clsx=require("clsx"),tailwindMerge=require("tailwind-merge"),TreeModel=require("tree-model"),applyBinding=require("./apply-binding-DpBwzIf9.cjs"),plugin=require("./plugin-CSgw-f78.cjs"),utils$1=require("@rjsf/utils"),web=require("@react-hookz/web"),sonner=require("sonner"),reactI18next=require("react-i18next"),Fuse=require("fuse.js"),UndoManager=require("undo-manager"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),Placeholder=require("@tiptap/extension-placeholder"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Autosuggest=require("react-autosuggest"),flagged=require("flagged"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),i18n=require("i18next"),tailwindAspectRatio=require("@tailwindcss/aspect-ratio"),tailwindForms=require("@tailwindcss/forms"),tailwindTypography=require("@tailwindcss/typography");require("tailwindcss-animate");require("@mhsdesign/jit-browser-tailwindcss");const twContainer=require("@tailwindcss/container-queries"),reactErrorBoundary=require("react-error-boundary"),framerMotion=require("framer-motion"),reactHotkeysHook=require("react-hotkeys-hook");require("next-themes");const dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),ReactDOM=require("react-dom"),reactWrapBalancer=require("react-wrap-balancer"),reResizable=require("re-resizable");function _interopNamespaceDefault(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>o[a]})}}return n.default=o,Object.freeze(n)}const React__namespace=_interopNamespaceDefault(React),ICON_CLASS="h-3 w-3 stroke-[2]",TypeIcon=o=>{const n=runtime.useRegisteredChaiBlocks(),a=lodashEs.get(n,[o==null?void 0:o.type,"icon"]);return a?React.createElement(a,{className:ICON_CLASS}):jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:ICON_CLASS})},readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const inlineEditingActiveAtom=jotai.atom("");inlineEditingActiveAtom.debugLabel="inlineEditingActiveAtom";const draggingFlagAtom=jotai.atom(!1);draggingFlagAtom.debugLabel="draggingFlagAtom";const treeRefAtom=jotai.atom(null);treeRefAtom.debugLabel="treeRefAtom";const canvasSettingsAtom=jotai.atom({});canvasSettingsAtom.debugLabel="canvasSettingsAtom";const aiAssistantActiveAtom=jotai.atom(!1);aiAssistantActiveAtom.debugLabel="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=utils.atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=utils.atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";let lastHighlighted=null;const useBlockHighlight=()=>{const[o]=jotai.useAtom(canvasIframeAtom),n=React.useMemo(()=>{var l;return(o==null?void 0:o.contentDocument)||((l=o==null?void 0:o.contentWindow)==null?void 0:l.document)},[o]),a=React.useCallback(l=>{if(n)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof l!="string")l.setAttribute("data-highlighted","true"),lastHighlighted=l;else if(typeof l=="string"){const i=n.querySelector(`[data-block-id="${l}"]`);i&&(i.setAttribute("data-highlighted","true"),lastHighlighted=i)}else lastHighlighted=null},[n]),r=React.useCallback(()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},[]);return{highlightBlock:a,clearHighlight:r,lastHighlighted}};function duplicateBlocks(o,n,a){const r=lodashEs.filter(o,i=>i._parent===n),l=[];for(let i=0;i<r.length;i++)if(lodashEs.filter(o,{_parent:r[i]._id}).length>0){const c=commonFunctions.generateUUID();l.push({...r[i],oldId:r[i]._id,_id:c,_parent:a}),l.push(lodashEs.flatten(duplicateBlocks(o,r[i]._id,c)))}else l.push({...r[i],oldId:r[i]._id,_id:commonFunctions.generateUUID(),_parent:a});return lodashEs.flatten(l)}function convertToBlocksTree(o){const n={};o.forEach(r=>{n[r._id]={...r,children:[]}});const a=[];return o.forEach(r=>{if(r._parent){const l=n[r._parent];l&&l.children.push(n[r._id])}else a.push(n[r._id])}),a}const getDuplicatedBlocks=(o,n,a=null)=>{let r=lodashEs.find(o,{_id:n});r={...r,oldId:r._id,_id:commonFunctions.generateUUID()},a!==(r==null?void 0:r._parent)&&(r={...r,_parent:a});const l=[r];return lodashEs.filter(o,{_parent:n}).length>0&&l.push(lodashEs.flatten(duplicateBlocks(o,n,r._id))),lodashEs.flatten(l)},presentBlocksAtom=jotai.atom([]);presentBlocksAtom.debugLabel="presentBlocksAtom";const treeDSBlocks=jotai.atom(o=>{const n=o(presentBlocksAtom);return convertToBlocksTree([...n])});treeDSBlocks.debugLabel="treeDSBlocks";const pageBlocksAtomsAtom=utils.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";const 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:r})=>lodashEs.includes(a,r)),r=>({...r}))});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 useSelectedBlock=()=>jotai.useAtomValue(selectedBlockAtom),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),r=>lodashEs.includes(a,r._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=utils.atomWithStorage("styleBreakpoint","xs");styleBreakpointAtom.debugLabel="styleBreakpointAtom";const useSelectedBlocksDisplayChild=()=>({flexChild:jotai.useAtomValue(selectedBlockFlexChildAtom),gridChild:jotai.useAtomValue(selectedBlockGridChildAtom)}),selectedBlockHierarchy=jotai.atom(o=>{const n=o(selectedBlockAtom),a=o(presentBlocksAtom);let r=n;const l=[n];do{const i=a.find(({_id:c})=>c===(r==null?void 0:r._parent));r=i,i&&l.push(i)}while(r!=null&&r._parent);return l}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[o,n]=jotai.useAtom(selectedBlockIdsAtom),a=React.useCallback(r=>{n(l=>lodashEs.includes(l,r)?lodashEs.without(l,r):[...l,r])},[n]);return[o,n,a]},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(sooner.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((r,l)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(sooner.Button,{onMouseEnter:()=>{a(r==null?void 0:r._id)},onClick:()=>n([r==null?void 0:r._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:r==null?void 0:r._type}),r._name||r._type]}),l!==o.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},l))]})})},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS",CLEAR_CANVAS_SELECTION:"CLEAR_CANVAS_SELECTION",CANVAS_BLOCK_SELECTED:"CANVAS_BLOCK_SELECTED",CANVAS_BLOCK_STYLE_SELECTED:"CANVAS_BLOCK_STYLE_SELECTED"},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 r=lodashEs.get(n,"data._type",""),l=lodashEs.get(a,"data._type","");return canAcceptChildBlock(l,r)};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 r=this.subscribers.get(n);r&&(r.delete(a),r.size===0&&this.subscribers.delete(n))}}publish(n,a){const r=this.subscribers.get(n);r&&r.forEach(l=>l(a))}}const pubsub=new PubSub,AddBlockDropdown=({block:o,children:n})=>{const{t:a}=reactI18next.useTranslation(),[r]=useBlocksStore(),{hasPermission:l}=usePermissions(),i=lodashEs.get(o,"_id"),c=lodashEs.get(o,"_parent"),d=lodashEs.filter(r,m=>c?lodashEs.get(m,"_parent")===c:!lodashEs.get(m,"_parent")),p=canAddChildBlock(lodashEs.get(o,"_type","")),u=lodashEs.findIndex(d,{_id:i}),x=m=>{if(m==="CHILD")pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,o);else{const h={_id:c||"",position:d==null?void 0:d.length};m==="BEFORE"?h.position=Math.max(u,0):m==="AFTER"&&(h.position=u+1),pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,h)}};return l(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(sooner.DropdownMenu,{children:[jsxRuntime.jsx(sooner.DropdownMenuTrigger,{children:n}),jsxRuntime.jsxs(sooner.DropdownMenuContent,{className:"border border-blue-500 bg-primary text-white shadow-2xl",children:[p&&jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("CHILD"),children:a("Add inside")}),jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("BEFORE"),children:a("Add before")}),jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("AFTER"),children:a("Add after")})]})]}):null},draggedBlockAtom=jotai.atom(null);jotai.atom(null);function getOrientation(o,n=null){const a=window.getComputedStyle(o),r=n?window.getComputedStyle(n):null,l=a.display,i=r?r.display:null;if(l==="flex"||l==="inline-flex"){const c=a.flexDirection;return c==="column"||c==="column-reverse"?"vertical":"horizontal"}else if(l==="grid"){const c=a.gridAutoFlow,d=a.gridTemplateColumns;return c.includes("column")||d&&d!=="none"&&d!==""&&!d.includes("calc")&&d.split(" ").length<=1?"vertical":"horizontal"}else if(i==="inline-block"||i==="inline")return"horizontal";return"vertical"}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;function insertBlocksAtPosition(o,n,a,r){const l=[...n];let i=[...o];if(a){const u=o.find(x=>x._id===a);if(u&&u.content!==void 0&&u.content!==""&&!o.some(m=>m._parent===a)){const h={_id:commonFunctions.generateUUID(),_parent:a,_type:"Text",content:u.content};Object.keys(u).forEach(g=>{g.startsWith("content-")&&(h[g]=u[g])}),l.unshift(h),i=i.map(g=>{if(g._id===a){const f={...g,content:""};return Object.keys(f).forEach(j=>{j.startsWith("content-")&&(f[j]="")}),f}return g})}}let c=i.filter(u=>!u._parent);a&&(c=i.filter(u=>u._parent===a));const d=!isNaN(r)||r>-1?Math.min(r,c.length):c.length;let p=i.length;for(let u=0,x=0;u<i.length;u++)if(a!==void 0?i[u]._parent===a:!i[u]._parent){if(x===d){p=u;break}x++}return!a&&r!==void 0&&r>=c.length&&(p=i.length),[...i.slice(0,p),...l,...i.slice(p)]}function getBlocksTree(o){return convertToBlocksTree(o)}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,r){var u,x;const l=findNodeById(o,n),i=findNodeById(o,a);if(!l||!i)return!1;i.children||(i.model.children=[]);let c=(u=i==null?void 0:i.children)==null?void 0:u.findIndex(m=>m.model._id===n);l.drop(),c=Math.max(c,0);const p=(((x=l==null?void 0:l.model)==null?void 0:x._parent)||"root")===a&&c<=r?r-1:r;try{i.addChildAtIndex(l,p)}catch(m){return console.error("Error adding child to parent:",m),!1}return!0}function handleOldParentTextBlock(o,n){if(!n||!n._parent)return o;const a=n._parent,r=o.find(i=>i._id===a);if(!r)return o;const l=o.filter(i=>i._parent===a);if(l.length===2){const i=l.find(c=>c._id!==n._id);if(i&&i._type==="Text"&&"content"in r)return o.map(d=>{if(d._id===a){const p={...d,content:i.content};return Object.keys(i).forEach(u=>{u.startsWith("content-")&&(p[u]=i[u])}),p}return d}).filter(d=>d._id!==i._id)}return o}function handleNewParentTextBlock(o,n,a){if(!a||a==="root")return o;const r=o.find(l=>l._id===a);if(!r)return o;if(r.content!==void 0&&r.content!==""&&!o.some(i=>i._parent===a&&i._id!==n._id)){const c={_id:commonFunctions.generateUUID(),_parent:a,_type:"Text",content:r.content};Object.keys(r).forEach(u=>{u.startsWith("content-")&&(c[u]=r[u])});const d=o.map(u=>{if(u._id===a){const x={...u,content:""};return Object.keys(x).forEach(m=>{m.startsWith("content-")&&(x[m]="")}),x}return u}),p=d.findIndex(u=>u._id===n._id);return p!==-1?[...d.slice(0,p),c,...d.slice(p)]:[c,...d]}return o}function moveBlocksWithChildren(o,n,a,r){if(!n)return o;const l=o.find(u=>u._id===n);if(!l)return o;let i=handleOldParentTextBlock(o,l);const c=a||"root",p=new TreeModel().parse({_id:"root",children:getBlocksTree(i)});if(moveNode(p,n,c,r)){let u=flattenTree(p);const x=u.find(m=>m._id===n);return x&&(x._parent=c==="root"?null:c),u.shift(),a&&(u=handleNewParentTextBlock(u,l,a)),u}return i}const 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=r=>{console.log("error",r)},broadcastChannel.onmessage=r=>{r.data.type==="blocks-updated"&&r.data.pageId===n&&o(r.data.blocks),r.data.type==="blocks-props-updated"&&r.data.pageId===n&&a(r.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[o,n])},removeNestedBlocks=(o,n)=>{let a=[...o],r=[];n.forEach(d=>{const p=a.find(m=>m._id===d);if(!p||!p._parent)return;const u=p._parent,x=a.filter(m=>m._parent===u);if(x.length===2){const m=x.find(h=>h._id!==d);if(m&&m._type==="Text"){const h=a.find(g=>g._id===u);h&&"content"in h&&(a=a.map(g=>{if(g._id===u){const f={...g,content:m.content};return Object.keys(m).forEach(j=>{j.startsWith("content-")&&(f[j]=m[j])}),f}return g}),r.push(m._id))}}});const l=[...n,...r],i=[],c=lodashEs.filter(a,d=>lodashEs.includes(l,d._id)||lodashEs.includes(l,d._parent)?(i.push(d._id),!1):!0);return lodashEs.isEmpty(i)?c:removeNestedBlocks(c,i)},useRemoveBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useSelectedBlockIds(),{setNewBlocks:r}=useBlocksStoreUndoableActions(),{hasPermission:l}=usePermissions();return React.useCallback(i=>{var d;if(!l(PERMISSIONS.DELETE_BLOCK))return;const c=((d=lodashEs.find(o,{_id:i[0]}))==null?void 0:d._parent)||null;r(removeNestedBlocks(o,i)),setTimeout(()=>a(c?[c]:[]),200)},[o,a,n,l])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(o,n,{id:a,props:r})=>{const l=o(pageBlocksAtomsAtom),i=lodashEs.find(l,c=>o(c)._id===a);return i?n(i,{...o(i),...r}):null}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtom=o=>utils.useAtomCallback(React.useCallback((n,a,r)=>{const l=n(o);if(!l||!l.length)return console.warn("No blocks available in splitAtoms"),null;const i=lodashEs.find(l,c=>n(c)._id===(lodashEs.isString(r)?r:n(r)._id));return i||(console.warn(`Block with id ${r} not found`),null)},[o]),{store:builderStore}),useBlocksStoreManager=()=>{const[,o]=useBlocksStore(),{postMessage:n}=useBroadcastChannel(),a=useUpdateBlockAtom();return{setNewBlocks:r=>{o(r),n({type:"blocks-updated",blocks:r})},addBlocks:(r,l,i)=>{o(c=>{const d=insertBlocksAtPosition(c,r,l,i);return n({type:"blocks-updated",blocks:d}),d})},removeBlocks:r=>{o(l=>{const i=removeNestedBlocks(l,r);return n({type:"blocks-updated",blocks:i}),i})},moveBlocks:(r,l,i)=>{o(c=>{let d=[...c];for(let p=0;p<r.length;p++)d=moveBlocksWithChildren(d,r[p],l,i);return lodashEs.each(r,p=>{const u=lodashEs.find(d,x=>x._id===p);u&&a({id:p,props:{_parent:u._parent||null}})}),n({type:"blocks-updated",blocks:d}),d})},updateBlocksProps:r=>{r.forEach(l=>{const i=lodashEs.omit(l,"_id");a({id:l._id,props:i})}),n({type:"blocks-props-updated",blocks:r})}}},blockRepeaterDataAtom=jotai.atom({});blockRepeaterDataAtom.debugLabel="blockRepeaterDataAtom";const useBlockRepeaterDataAtom=()=>jotai.useAtom(blockRepeaterDataAtom),useAsyncProps=(o,n,a)=>{const[r,l]=React.useState({status:"idle",props:{},error:void 0}),i=useBuilderProp("getBlockAsyncProps",async m=>({})),c=jotai.useSetAtom(blockRepeaterDataAtom),d=JSON.stringify([o==null?void 0:o._id,...lodashEs.values(lodashEs.pick(o,n))]),p=lodashEs.get(r,"status"),u=(o==null?void 0:o._type)==="Repeater"&&lodashEs.startsWith(o.repeaterItems,`{{${applyBinding.COLLECTION_PREFIX}`),x=(o==null?void 0:o._type)!=="Repeater"&&!lodashEs.isEmpty(n);return React.useEffect(()=>{if(o){if(lodashEs.isFunction(a)){l(h=>({...h,status:"loading",props:{}}));const m=a({block:o});if(!utils$1.isObject(m))throw new Error("mockDataProvider should return an object");l(h=>({...h,status:"loaded",props:m}));return}!u&&!x||(l(m=>({...m,status:"loading",props:{}})),i({block:o}).then((m={})=>{console.log("Returned Props",u,m),u?(c(h=>({...h,[o._id]:{status:"loaded",props:lodashEs.isArray(m)?m:{},repeaterItems:o.repeaterItems}})),l(h=>({...h,status:"loaded"}))):l(h=>({...h,status:"loaded",props:utils$1.isObject(m)?m:{}}))}).catch(m=>{u?(c(h=>({...h,[o._id]:{status:"error",error:m,props:{}}})),l(h=>({...h,status:"error",error:m}))):l(h=>({...h,status:"error",error:m,props:{}}))}))}},[o==null?void 0:o._id,d,u,x,a]),{$loading:p==="loading",...o?lodashEs.get(r,"props",{}):{}}},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=()=>{const[o]=useBlockRepeaterDataAtom(),n=React.useMemo(()=>{const r={};return Object.entries(o).forEach(([l,i])=>{i.status==="loaded"&&(r[i.repeaterItems.replace("}}",`/${l}`).replace("{{","")]=i.props)}),r},[o]);return{...jotai.useAtomValue(chaiPageExternalDataAtom),...n}},useBuilderProp=(o,n=void 0)=>{const a=jotai.useAtomValue(chaiBuilderPropsAtom);return React.useMemo(()=>lodashEs.get(a,o,n),[a,o,n])},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(r=>lodashEs.get(a[r],"builderProp",!1)||lodashEs.get(a[r],"runtime",!1)?r:null))}),useGetPageData=()=>{const[o]=useBrandingOptions(),{currentPage:n}=useCurrentPage(),[a]=useBlocksStore();return React.useCallback(()=>{const r=lodashEs.map(a,l=>lodashEs.omit(l,getBlockBuilderProps(l._type)));return{currentPage:n,blocks:r}},[o,n,a])},usePermissions=()=>{const o=useBuilderProp("permissions",void 0);return{hasPermission:React.useCallback(a=>o?o.includes(a):!0,[o])}},getDefaultThemeValues=(o=plugin.defaultThemeOptions)=>{const n=plugin.defaultThemeValues;return o.fontFamily&&(n.fontFamily=Object.entries(o.fontFamily).reduce((a,[r,l])=>({...a,[r.replace("font-","")]:l}),n.fontFamily)),n.borderRadius=o.borderRadius,o.colors&&(n.colors=o.colors.reduce((a,r)=>(Object.entries(r.items).forEach(([l,i])=>{a[l]=i}),a),n.colors)),n},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const o=useThemeOptions(),n=React.useMemo(()=>getDefaultThemeValues(o),[o]),a=useBuilderProp("theme",{}),[r,l]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...n,...!lodashEs.isEmpty(a)&&a,...!lodashEs.isEmpty(r)&&r}),[n,a,r]),l]},useThemeOptions=()=>{const o=useBuilderProp("themeOptions",a=>a);return React.useMemo(()=>o(plugin.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 p=>{}),r=useBuilderProp("onSaveStateChange",lodashEs.noop),l=useGetPageData(),[i]=useTheme(),{hasPermission:c}=usePermissions();return{savePage:web.useThrottledCallback(async(p=!1)=>{if(!c("save_page"))return;n("SAVING"),r("SAVING");const u=l();return await a({autoSave:p,blocks:u.blocks,theme:i}),setTimeout(()=>{n("SAVED"),r("SAVED")},100),!0},[l,n,i,a,r],3e3),saveState:o,setSaveState:n}},undoManager=new UndoManager;undoManager.setLimit(50);const undoRedoStateAtom=jotai.atom({canUndo:!1,canRedo:!1}),useUndoManager=()=>{const[,o]=jotai.useAtom(builderSaveStateAtom),[n,a]=jotai.useAtom(undoRedoStateAtom),r=useBuilderProp("onSaveStateChange",lodashEs.noop),l=React.useCallback(()=>{const u={canUndo:undoManager.hasUndo(),canRedo:undoManager.hasRedo()};a(u),o("UNSAVED"),r("UNSAVED")},[a,o,r]);React.useEffect(()=>(undoManager.setCallback(l),()=>{undoManager.setCallback(lodashEs.noop)}),[l]);const i=React.useCallback(u=>{undoManager.add(u),l()},[l]),c=React.useCallback(()=>{undoManager.undo(),l()},[l]),d=React.useCallback(()=>{undoManager.redo(),l()},[l]),p=React.useCallback(()=>{undoManager.clear(),a({canUndo:!1,canRedo:!1})},[a]);return React.useMemo(()=>({add:i,undo:c,redo:d,hasUndo:()=>n.canUndo,hasRedo:()=>n.canRedo,clear:p}),[i,c,d,n.canUndo,n.canRedo,p])},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:o}=useUndoManager(),[n]=useBlocksStore(),{setNewBlocks:a,addBlocks:r,removeBlocks:l,moveBlocks:i,updateBlocksProps:c}=useBlocksStoreManager();return{moveBlocks:(f,j,b)=>{const k=lodashEs.map(f,S=>{const w=n.find(_=>_._id===S)._parent||null,v=n.filter(_=>w?_._parent===w:!_._parent).map(_=>_._id).indexOf(S);return{_id:S,oldParent:w,oldPosition:v}}),C=k.find(({_id:S})=>S===f[0]);C&&C.oldParent===j&&C.oldPosition===b||(i(f,j,b),o({undo:()=>lodashEs.each(k,({_id:S,oldParent:A,oldPosition:w})=>{i([S],A,w)}),redo:()=>i(f,j,b)}))},addBlocks:(f,j,b)=>{r(f,j,b),o({undo:()=>l(lodashEs.map(f,"_id")),redo:()=>r(f,j,b)})},removeBlocks:f=>{var C;const j=(C=lodashEs.first(f))==null?void 0:C._parent,k=n.filter(S=>j?S._parent===j:!S._parent).indexOf(lodashEs.first(f));l(lodashEs.map(f,"_id")),o({undo:()=>r(f,j,k),redo:()=>l(lodashEs.map(f,"_id"))})},updateBlocks:(f,j,b)=>{let k=[];if(b)k=lodashEs.map(f,C=>({_id:C,...b}));else{const C=lodashEs.keys(j);k=lodashEs.map(f,S=>{const A=n.find(R=>R._id===S),w={_id:S};return lodashEs.each(C,R=>w[R]=A[R]),w})}c(lodashEs.map(f,C=>({_id:C,...j}))),o({undo:()=>c(k),redo:()=>c(lodashEs.map(f,C=>({_id:C,...j})))})},updateBlocksRuntime:(f,j)=>{c(lodashEs.map(f,b=>({_id:b,...j})))},setNewBlocks:f=>{a(f),o({undo:()=>a(n),redo:()=>a(f)})},updateMultipleBlocksProps:f=>{let j=[];j=lodashEs.map(f,b=>{const k=lodashEs.keys(b),C=n.find(A=>A._id===b._id),S={};return lodashEs.each(k,A=>S[A]=C[A]),S}),c(f),o({undo:()=>c(j),redo:()=>c(f)})}}},useAddBlock=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions(),r=React.useCallback((i,c,d)=>{var h;for(let g=0;g<i.length;g++){const{_id:f}=i[g];i[g]._id=commonFunctions.generateUUID();const j=lodashEs.filter(i,{_parent:f});for(let b=0;b<j.length;b++)j[b]._parent=i[g]._id}const p=lodashEs.first(i);let u,x;return c&&(u=lodashEs.find(o,{_id:c}),i[0]._parent=c,x=c),!(u?canAcceptChildBlock(u==null?void 0:u._type,p._type):!0)&&u&&(i[0]._parent=u._parent,x=u._parent),a(i,x,d),n([(h=lodashEs.first(i))==null?void 0:h._id]),lodashEs.first(i)},[a,o,n]);return{addCoreBlock:React.useCallback((i,c,d)=>{if(lodashEs.has(i,"blocks")){const j=i.blocks;return r(j,c,d)}const p=commonFunctions.generateUUID(),u=runtime.getDefaultBlockProps(i.type),x={_type:i.type,_id:p,...u,...lodashEs.has(i,"_name")&&{_name:i._name},...lodashEs.has(i,"partialBlockId")&&{partialBlockId:i.partialBlockId}};let m,h;return c&&(m=lodashEs.find(o,{_id:c}),x._parent=c,h=c),!canAcceptChildBlock(m==null?void 0:m._type,x._type)&&m&&(x._parent=m._parent,h=m._parent),a([x],h,d),n([x._id]),x},[a,r,o,n]),addPredefinedBlock:r}},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 r=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:l})=>lodashEs.keys(l)));a=lodashEs.flattenDeep(lodashEs.map(r,l=>lodashEs.flatten(lodashEs.map(colorKeys,i=>`${i}-${l}`))))}return o.fontFamily&&(a=[...a,...lodashEs.map(lodashEs.keys(o.fontFamily),r=>`${r}`)]),lodashEs.map(a,r=>({name:r}))},[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 l=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__",l.join("|")))})}return CLASSES_LIST},[o]),a=React.useCallback((l,i)=>{const c=lodashEs.get(n,`${l}.regExp`,"");return i.match(new RegExp(c))},[n]),r=React.useCallback((l,i=[])=>lodashEs.get(n,`${l}.classes`,i),[n]);return{match:a,getClasses:r}};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,r=>`${r}:`).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 r=lodashEs.get(CLASSES_LIST,`${a}.regExp`,"");if(new RegExp(r,"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((r,l)=>a.indexOf(r.mq)-a.indexOf(l.mq)).map(r=>r.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 r=o;if(a.length===1)return a[0].fullCls;for(const l of a){const i=l.property,c=n.indexOf(l.mq);for(let d=c+1;d<n.length;d++){const p=n[d],u=a.find(x=>x.property===i&&x.mq===p);if(u&&u.cls===l.cls)r=r.replace(u.fullCls,"");else if(u&&u.cls!==l.cls)break}}return r.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:r})=>{const l=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id)),i=lodashEs.first(o(selectedStylingBlocksAtom));return lodashEs.map(l,c=>{const d=o(c),p=lodashEs.get(d,i.prop,`${applyBinding.STYLES_KEY},`),{classes:u}=applyBinding.getSplitChaiClasses(p);return{ids:[d._id],props:{[i.prop]:`${applyBinding.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(u,r)))}`}}})}),useAddClassesToBlocks=()=>{const o=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:n,updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback((r,l,i=!1)=>{const c=o({blockIds:r,newClasses:l});if(!i){a(r,c[0].props);return}n(r,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,r]=jotai.useAtom(languageAtom),l=i=>{r(n===i?"":i)};return{languages:o==null?void 0:o.filter(i=>i!==n),fallbackLang:n,selectedLang:a,setSelectedLang:l}},updatePropsForLanguage=(o,n,a)=>{const r=runtime.getRegisteredChaiBlock(lodashEs.get(a,"_type"));if(!r)return o;const l={...o};return lodashEs.forEach(lodashEs.keys(o),i=>{if(lodashEs.includes(lodashEs.get(r,"i18nProps",[]),i)&&!lodashEs.isEmpty(n)){const c=`${i}-${n}`;lodashEs.set(l,c,o[i]),lodashEs.unset(l,i)}}),l},useUpdateBlocksProps=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((r,l,i)=>{const c=updatePropsForLanguage(l,n,a);o(r,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,r=30)=>{const l=lodashEs.keys(lodashEs.omit(a,["_id"]));for(const i of l){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(x=>setTimeout(x,r))}}},[o])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions(),n=useFakeStreamEffect();return React.useCallback(async a=>{for(const r of a)await n(r._id,r);o(a)},[n,o])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((r,l)=>{const i=updatePropsForLanguage(l,n,a);o(r,i)},[n,a,o])};function getChildBlocks(o,n,a){a.push(lodashEs.find(o,{_id:n}));const r=lodashEs.filter(o,{_parent:n});for(const l of r)a.push(...getBlockWithChildren(l._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 r=["_id","_type","_parent"],l=lodashEs.pick(a,r),i=runtime.getRegisteredChaiBlock(a._type),c={},d=lodashEs.get(i,"aiProps",[]);for(const p in a)r.includes(p)||d.includes(p)&&(c[p]=lodashEs.get(a,`${p}-${n}`,a[p]));return lodashEs.isEmpty(c)?!1:(lodashEs.has(l,"_parent")&&lodashEs.isEmpty(l._parent)&&delete l._parent,{...l,...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,r]=React.useState(null),l=useBuilderProp("askAiCallBack",null),i=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:p,fallbackLang:u}=useLanguages(),x=p.length?p:u,m=(h,g)=>{const f=lodashEs.cloneDeep(g.find(j=>j._id===h));for(const j in f){const b=f[j];if(typeof b=="string"&&lodashEs.startsWith(b,applyBinding.STYLES_KEY)){const{baseClasses:k,classes:C}=applyBinding.getSplitChaiClasses(b);f[j]=lodashEs.compact(lodashEs.flattenDeep([k,C])).join(" ")}else j!=="_id"&&delete f[j]}return f};return{askAi:React.useCallback(async(h,g,f,j)=>{if(l){n(!0),r(null);try{const b=p===u?"":p,k=h==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(g,d)),p):[m(g,d)],C=await l(h,addLangToPrompt(f,x,h),k,b),{blocks:S,error:A}=C;if(A){r(A);return}if(h==="styles"){const w=S.map(R=>{for(const v in R)v!=="_id"&&(R[v]=`${applyBinding.STYLES_KEY},${R[v]}`);return R});c(w)}else i(S);j&&j(C)}catch(b){r(b)}finally{n(!1),j&&j()}}},[l,n,p,u,d,x,c,i]),loading:o,error:a}},useAiAssistant=()=>{const[,o]=useRightPanel();return React.useCallback(n=>{o(n?"ai":"block")},[o])},partialBlocksStoreAtom=jotai.atom({}),partialBlocksLoadingStateAtom=jotai.atom({}),usePartialBlocksStore=()=>{const[o,n]=jotai.useAtom(partialBlocksStoreAtom),a=React.useCallback(l=>lodashEs.get(o,l,[]),[o]),r=React.useCallback(()=>n({}),[n]);return{getPartailBlocks:a,reset:r}},useWatchPartailBlocks=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(partialBlocksStoreAtom),[r,l]=jotai.useAtom(partialBlocksLoadingStateAtom),i=useBuilderProp("getPartialBlockBlocks",async d=>[]),c=React.useMemo(()=>o.filter(d=>d._type==="PartialBlock"||d._type==="GlobalBlock").map(d=>lodashEs.get(d,"partialBlockId",lodashEs.get(d,"globalBlock",""))),[o]);React.useEffect(()=>{lodashEs.forEach(c,d=>{lodashEs.has(n,d)||lodashEs.get(r,`${d}.loading`,!1)||(l(p=>({...p,[d]:{loading:!0,error:null}})),i(d).then(p=>{a(u=>({...u,[d]:p})),l(u=>({...u,[d]:{loading:!1,error:null}}))}).catch(p=>{l(u=>({...u,[d]:{loading:!1,error:p.message}}))}))})},[i,n,r,a,l,c])},partialBlocksListAtom=jotai.atom({}),usePartialBlocksList=()=>{const[o,n]=React.useState(!1),[a,r]=React.useState(null),[l,i]=jotai.useAtom(partialBlocksListAtom),c=useBuilderProp("getPartialBlocks",async()=>[]),d=React.useCallback(async()=>{n(!0),r(null);try{const p=await c();i(p),n(!1)}catch(p){r(p instanceof Error?p.message:"Failed to fetch partial blocks"),n(!1)}},[c,i]);return React.useEffect(()=>{d()},[]),{data:l,isLoading:o,refetch:d,error:a}},useBuilderReset=()=>{const{clear:o}=useUndoManager(),[,n]=useSelectedBlockIds(),{clearHighlight:a}=useBlockHighlight(),[,r]=useSelectedStylingBlocks(),[,l]=jotai.useAtom(aiAssistantActiveAtom),{reset:i}=usePartialBlocksStore(),{setSaveState:c}=useSavePage(),[,d]=useBlockRepeaterDataAtom();return()=>{d({}),n([]),r([]),a(),o(),l(!1),i(),c("SAVED")}},canvasZoomAtom=utils.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),r=React.useCallback(l=>{n(l),a([])},[n,a]);return[o,r]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlocks=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(copiedBlockIdsAtom),r=jotai.useSetAtom(cutBlockIdsAtom),{getPartailBlocks:l}=usePartialBlocksStore(),i=React.useCallback(d=>d.some(p=>getDuplicatedBlocks(o,p,null).some(x=>x._type==="PartialBlock"||x._type==="GlobalBlock")),[o]),c=React.useCallback(async(d,p=!1)=>{try{a(d),r([]);const u={_chai_copied_blocks:d.flatMap(x=>{const m=getDuplicatedBlocks(o,x,null);if(!p)return m;let h=[];for(const g of m)if(g._type==="PartialBlock"||g._type==="GlobalBlock"){let f=l(g.partialBlockId);g._parent&&(f==null?void 0:f.length)>0&&(f=f.map(j=>(lodashEs.isEmpty(j._parent)&&lodashEs.set(j,"_parent",g._parent),j))),h=[...h,...f]}else h.push(g);return h})};if(!navigator.clipboard){sonner.toast.error("Clipboard not available.");return}sonner.toast.promise(navigator.clipboard.writeText(JSON.stringify(u)),{success:"Blocks copied successfully",error:"Failed to copy blocks to clipboard"})}catch(u){sonner.toast.error("Failed to copy blocks to clipboard"),console.error("Failed to copy blocks to clipboard:",u)}},[a,r]);return[n,c,i]},useCopyToClipboard=()=>{const[o,n]=React.useState(null),a=React.useCallback(async r=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),n(r),!0}catch(l){return console.warn("Copy failed",l),n(null),!1}},[]);return[o,a]},darkModeAtom=utils.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((r,l=null)=>{const i=[];lodashEs.each(r,c=>{const d=o.find(h=>h._id===c);l?l==="root"&&(l=null):l=d._parent;const x=lodashEs.filter(o,h=>lodashEs.isString(l)?h._parent===l:!h._parent).indexOf(d)+1,m=getDuplicatedBlocks(o,c,l);a(m,l,x),i.push(lodashEs.get(m,"0._id",""))}),n(i)},[o,n])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[o,n]=jotai.useAtom(hiddenBlockIdsAtom),a=React.useCallback(r=>{n(l=>lodashEs.includes(l,r)?lodashEs.without(l,r):[...l,r])},[n]);return[o,n,a]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=o=>{const[n,a]=jotai.useAtom(libraryBlocksAtom),r=useBuilderProp("getUILibraryBlocks",lodashEs.noop),l=lodashEs.get(n,`${o==null?void 0:o.id}.blocks`,null),i=lodashEs.get(n,`${o==null?void 0:o.id}.loading`,"idle"),c=React.useRef("idle");React.useEffect(()=>{(async()=>{if(!(i==="complete"||c.current==="loading")){c.current="loading",a(p=>({...p,[o==null?void 0:o.id]:{loading:"loading",blocks:[]}}));try{const p=await r(o);c.current="idle",a(u=>({...u,[o==null?void 0:o.id]:{loading:"complete",blocks:p||[]}}))}catch{c.current="idle",a(u=>({...u,[o==null?void 0:o.id]:{loading:"complete",blocks:[]}}))}}})()},[o,l,i,c,a,r]);const d=React.useCallback(p=>{a(u=>({...u,[p]:{loading:"idle",blocks:[]}}))},[a]);return{data:l||[],isLoading:i==="loading",resetLibrary:d}},useCanPaste=()=>{const[o]=useBlocksStore();return(n,a)=>{var i;const r=((i=lodashEs.find(o,{_id:a}))==null?void 0:i._type)||null,l=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(r,l)}},useMoveCutBlocks=()=>{const o=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:n}=useBlocksStoreUndoableActions();return React.useCallback((a,r)=>{const l=Array.isArray(r)?r[0]:r;if(r==="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===l);n(a,l,(i==null?void 0:i.length)||0)}},[n,o])},usePasteBlocks=()=>{const[o,n]=useCutBlockIds(),a=useMoveCutBlocks(),{addPredefinedBlock:r}=useAddBlock(),l=useCanPaste();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(!(navigator!=null&&navigator.permissions)){sonner.toast.error("Cannot check clipboard permissions.");return}try{if((await navigator.permissions.query({name:"clipboard-read"})).state==="denied"){sonner.toast.error("Clipboard paste permission denied. Please allow clipboard access.");return}}catch{sonner.toast.error("Failed to check clipboard permissions. Please allow clipboard access.");return}if(!lodashEs.isEmpty(o)){a(o,c),n([]),await navigator.clipboard.writeText("");return}sonner.toast.promise(async()=>{const p=await navigator.clipboard.readText();if(p){const u=JSON.parse(p);if(lodashEs.has(u,"_chai_copied_blocks"))r(u._chai_copied_blocks,d==="root"?null:d);else throw new Error("Nothing to paste")}else throw new Error("Nothing to paste")},{success:()=>"Blocks pasted successfully",error:()=>"Nothing to paste"})},[o,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:r})=>{const l=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=r;let{classes:u,baseClasses:x}=applyBinding.getSplitChaiClasses(lodashEs.get(d,l.prop,`${applyBinding.STYLES_KEY},`));return lodashEs.each(p,m=>{const h=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${h}(?=\\s|$)`,"g");u=u.replace(g," ").replace(/\s+/g," ").trim();const f=lodashEs.first(m.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],f)&&p.push(m.split(":").pop().trim())}),lodashEs.each(p,m=>{const h=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${h}(?=\\s|$)`,"g");x=x.replace(g," ").replace(/\s+/g," ").trim()}),{ids:[d._id],props:{[l.prop]:`${applyBinding.STYLES_KEY}${x},${u}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:o,updateBlocksRuntime:n}=useBlocksStoreUndoableActions(),a=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((r,l,i=!1)=>{const c=a({blockIds:r,fullClasses:l});i?o(r,c[0].props):n(r,c[0].props)},[a])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=utils.atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=utils.atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(o=>{const n=o(canvasWidthAtom);return commonFunctions.getBreakpointValue(n).toLowerCase()}),useScreenSizeWidth=()=>{const[o,n]=jotai.useAtom(canvasWidthAtom),a=jotai.useAtomValue(canvasBreakpointAtom),[r,l]=useStylingBreakpoint();return React.useEffect(()=>{r!=="xs"&&l(a)},[a,r,l]),[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 r=lodashEs.get(a,n.prop,`${applyBinding.STYLES_KEY},`),{classes:l}=applyBinding.getSplitChaiClasses(r);return lodashEs.filter(lodashEs.map(l.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),r=o(darkModeAtom),l=getQueries(n);let i=lodashEs.filter(o(selectedBlockAllClassesAtom),{mod:a});return lodashEs.startsWith(a,"_")||(i=lodashEs.filter(i,c=>l.includes(c.mq))),i=i.sort((c,d)=>MQ[c.mq]-MQ[d.mq]),r||(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=utils.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),r=a.length===1?a[0]:null;if(!r)return null;const l=lodashEs.find(n,{_id:r});if(!l)return null;let i=l._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),useSelectedLibrary=()=>jotai.useAtom(selectedLibraryAtom),sidebarActivePanelAtom=jotai.atom("outline");sidebarActivePanelAtom.debugLabel="sidebarActivePanelAtom";const useSidebarActivePanel=()=>jotai.useAtom(sidebarActivePanelAtom),CONTROLS=[{ControlIcon:reactIcons.PinTopIcon,dir:"VERTICAL",key:"UP"},{ControlIcon:reactIcons.PinBottomIcon,dir:"VERTICAL",key:"DOWN"},{ControlIcon:reactIcons.PinLeftIcon,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:reactIcons.PinRightIcon,dir:"HORIZONTAL",key:"RIGHT"}],getParentBlockOrientation=(o,n,a)=>{try{if(!o||!a)return"VERTICAL";const r=`[data-block-id='${o}']`,l=a==null?void 0:a.querySelector(r);if(l){const i=a==null?void 0:a.querySelector(`[data-block-id='${n}']`);return getOrientation(l,i).toUpperCase()}return"VERTICAL"}catch{return"VERTICAL"}},isDisabledControl=(o,n,a)=>!!(o&&(a==="UP"||a==="LEFT")||n&&(a==="DOWN"||a==="RIGHT")),useBlockController=(o,n)=>{const[a]=useBlocksStore(),{document:r}=useFrame(),{moveBlocks:l}=useBlocksStoreUndoableActions(),i=lodashEs.get(o,"_id"),c=lodashEs.get(o,"_parent"),d=lodashEs.filter(a,f=>c?lodashEs.get(f,"_parent")===c:!lodashEs.get(f,"_parent")),p=(d==null?void 0:d.length)<=1,u=lodashEs.findIndex(d,{_id:i}),x=u<=0,m=u+1===(d==null?void 0:d.length),h=getParentBlockOrientation(c,i,r),g=React.useCallback(f=>{isDisabledControl(x,m,f)||p||(f==="UP"||f==="LEFT"?l([i],c||null,u-1):(f==="DOWN"||f==="RIGHT")&&l([i],c||null,u+2),n())},[x,m,p,u,i,c,n]);return reactHotkeysHook.useHotkeys("shift+up, shift+down, shift+left, shift+right",({key:f})=>{var j;g((j=f==null?void 0:f.replace("Arrow",""))==null?void 0:j.toUpperCase())},{document:r==null?void 0:r.contentDocument},[g]),{isOnlyChild:p,isFirstBlock:x,isLastBlock:m,moveBlock:g,orientation:h}},BlockController=({block:o,updateFloatingBar:n})=>{const{isOnlyChild:a,isFirstBlock:r,isLastBlock:l,moveBlock:i,orientation:c}=useBlockController(o,n);return a?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:CONTROLS.map(({ControlIcon:d,dir:p,key:u})=>{if(c!==p)return null;const x=isDisabledControl(r,l,u);return x?null:jsxRuntime.jsx(d,{onClick:()=>i(u),className:`${x?"pointer-events-none cursor-not-allowed opacity-50":"duration-300 hover:scale-95 hover:opacity-80"}`},u)})})};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 INLINE_EDITABLE_BLOCKS=["Heading","Paragraph","Text","Link","Span"],isRichTextParent=o=>{var n;return(o==null?void 0:o.getAttribute("data-block-type"))==="RichText"||((n=o==null?void 0:o.parentElement)==null?void 0:n.getAttribute("data-block-type"))==="RichText"},isInlineEditable=(o,n)=>{if(isRichTextParent(o))return!0;const a=o==null?void 0:o.getAttribute("data-block-type");return!a||o&&o.children.length>0||a==="Button"?!1:INLINE_EDITABLE_BLOCKS.includes(a)},useHandleCanvasDblClick=()=>{const[o,n]=jotai.useAtom(inlineEditingActiveAtom);return React.useCallback(a=>{if(a==null||a.preventDefault(),a==null||a.stopPropagation(),o)return;const r=getTargetedBlock(a.target);if(!isInlineEditable(r))return;const l=r.getAttribute("data-block-id");l&&n(l)},[o,n])},useHandleCanvasClick=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{clearHighlight:n}=useBlockHighlight(),a=React.useRef(0);return React.useCallback(r=>{const l=new Date().getTime();if(o||(r.stopPropagation(),l-a.current<400))return;const c=getTargetedBlock(r.target);if(c!=null&&c.getAttribute("data-block-id")&&(c==null?void 0:c.getAttribute("data-block-id"))==="container"){pubsub.publish(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION);return}if(c!=null&&c.getAttribute("data-block-parent")){const d=c.getAttribute("data-style-prop"),p=c.getAttribute("data-style-id"),u=c.getAttribute("data-block-parent");pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,{blockId:u,styleId:p,styleProp:d})}else if(c!=null&&c.getAttribute("data-block-id")){const d=c.getAttribute("data-block-id");pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,{blockId:d==="canvas"?[]:[d]})}n(),a.current=new Date().getTime()},[o])},useHandleMouseMove=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{highlightBlock:n}=useBlockHighlight();return web.useThrottledCallback(a=>{if(o)return;const r=getTargetedBlock(a.target);r&&n(r)},[o,n],100)},useHandleMouseLeave=()=>{const{clearHighlight:o}=useBlockHighlight();return React.useCallback(()=>o(),[o])},Canvas=({children:o})=>{const n=useHandleCanvasDblClick(),a=useHandleCanvasClick(),r=useHandleMouseMove(),l=useHandleMouseLeave();return jsxRuntime.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:a,onDoubleClick:n,onMouseMove:r,onMouseLeave:l,className:"relative h-full max-w-full p-px",children:o})},getElementByDataBlockId=(o,n)=>o.querySelector(`[data-block-id="${n}"]`),BlockActionLabel=({block:o,label:n})=>{const[,a]=useSelectedBlockIds(),[,r]=useHighlightBlockId(),[,l]=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"]))),l(o),setTimeout(()=>{a([]),r(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),n]})},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),BlockSelectionHighlighter=()=>{const o=useSelectedBlock(),{document:n}=useFrame(),[a]=useSelectedStylingBlocks(),[r,l]=React.useState([]),[,i]=React.useState([]),c=(d,p=0)=>{const{top:u}=d.getBoundingClientRect();return u+p>=0&&u-p<=window.innerHeight};return React.useEffect(()=>{var d;if(o!=null&&o._id&&o.type!=="Multiple"&&n){const p=getElementByDataBlockId(n,o._id);p&&(c(p)||(d=n.defaultView)==null||d.scrollTo({top:p.offsetTop,behavior:"smooth"}),l([p]))}},[o==null?void 0:o._id,o==null?void 0:o.type,n]),React.useEffect(()=>{if(!lodashEs.isEmpty(a)&&n){const d=getElementByStyleId(n,lodashEs.first(a).id);i(d?[d]:[null])}else i([null])},[a,n]),jsxRuntime.jsx(BlockFloatingSelector,{block:o,selectedBlockElement:r[0]})},BlockFloatingSelector=({block:o,selectedBlockElement:n})=>{const a=useRemoveBlocks(),r=useDuplicateBlocks(),[,l]=useSelectedBlockIds(),[,i]=useHighlightBlockId(),[,c]=useSelectedStylingBlocks(),{hasPermission:d}=usePermissions(),[p]=jotai.useAtom(inlineEditingActiveAtom),{document:u}=useFrame(),{floatingStyles:x,refs:m,update:h}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:n}});web.useResizeObserver(n,()=>h(),n!==null),web.useResizeObserver(u==null?void 0:u.body,()=>h(),(u==null?void 0:u.body)!==null);const g=lodashEs.get(o,"_parent",null),f=lodashEs.isEmpty(lodashEs.get(o,"_name",""))?lodashEs.get(o,"_type",""):lodashEs.get(o,"_name","");return!n||!o||p?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:m.setFloating,style:x,onClick:j=>{j.stopPropagation(),j.preventDefault()},onMouseEnter:j=>{j.stopPropagation(),i(null)},onKeyDown:j=>j.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[g&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{c([]),l([g])}}),jsxRuntime.jsx(BlockActionLabel,{label:f,block:o}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1.5",children:[jsxRuntime.jsx(AddBlockDropdown,{block:o,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105"})}),canDuplicateBlock(lodashEs.get(o,"_type",""))&&d(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>r([o==null?void 0:o._id])}):null,canDeleteBlock(lodashEs.get(o,"_type",""))&&d(PERMISSIONS.DELETE_BLOCK)?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>a([o==null?void 0:o._id])}):null,d(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(BlockController,{block:o,updateFloatingBar:h})]})]})})},IframeInitialContent=`<!doctype html>
1
+ "use strict";var F=Object.defineProperty;var $=(o,n,a)=>n in o?F(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a;var U=(o,n,a)=>$(o,typeof n!="symbol"?n+"":n,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),runtime=require("@chaibuilder/runtime"),reactIcons=require("@radix-ui/react-icons"),lodashEs=require("lodash-es"),React=require("react"),jotai=require("jotai"),utils=require("jotai/utils"),commonFunctions=require("./common-functions-BZmyleS1.cjs"),sooner=require("./sooner-CPeN3CGR.cjs"),lucideReact=require("lucide-react"),clsx=require("clsx"),tailwindMerge=require("tailwind-merge"),TreeModel=require("tree-model"),applyBinding=require("./apply-binding-DpBwzIf9.cjs"),plugin=require("./plugin-CSgw-f78.cjs"),utils$1=require("@rjsf/utils"),web=require("@react-hookz/web"),sonner=require("sonner"),reactI18next=require("react-i18next"),Fuse=require("fuse.js"),UndoManager=require("undo-manager"),Link=require("@tiptap/extension-link"),TextAlign=require("@tiptap/extension-text-align"),Underline=require("@tiptap/extension-underline"),Placeholder=require("@tiptap/extension-placeholder"),react=require("@tiptap/react"),StarterKit=require("@tiptap/starter-kit"),RjForm=require("@rjsf/core"),validator=require("@rjsf/validator-ajv8"),Autosuggest=require("react-autosuggest"),flagged=require("flagged"),himalaya=require("himalaya"),reactArborist=require("react-arborist"),i18n=require("i18next"),tailwindAspectRatio=require("@tailwindcss/aspect-ratio"),tailwindForms=require("@tailwindcss/forms"),tailwindTypography=require("@tailwindcss/typography");require("tailwindcss-animate");require("@mhsdesign/jit-browser-tailwindcss");const twContainer=require("@tailwindcss/container-queries"),reactErrorBoundary=require("react-error-boundary"),framerMotion=require("framer-motion"),reactHotkeysHook=require("react-hotkeys-hook");require("next-themes");const dom=require("@floating-ui/dom"),reactDom=require("@floating-ui/react-dom"),ReactDOM=require("react-dom"),reactWrapBalancer=require("react-wrap-balancer"),reResizable=require("re-resizable");function _interopNamespaceDefault(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>o[a]})}}return n.default=o,Object.freeze(n)}const React__namespace=_interopNamespaceDefault(React),ICON_CLASS="h-3 w-3 stroke-[2]",TypeIcon=o=>{const n=runtime.useRegisteredChaiBlocks(),a=lodashEs.get(n,[o==null?void 0:o.type,"icon"]);return a?React.createElement(a,{className:ICON_CLASS}):jsxRuntime.jsx(reactIcons.BoxModelIcon,{className:ICON_CLASS})},readOnlyModeAtom=jotai.atom(!1);readOnlyModeAtom.debugLabel="readOnlyModeAtom";const networkModeAtom=jotai.atom("online");networkModeAtom.debugLabel="networkModeAtom";jotai.atom("");const editLayerNameAtom=jotai.atom(!1);editLayerNameAtom.debugLabel="editLayerNameAtom";const activeLanguageAtom=jotai.atom("");activeLanguageAtom.debugLabel="activeLanguageAtom";const primaryLanguageAtom=jotai.atom("");primaryLanguageAtom.debugLabel="primaryLanguageAtom";const canvasIframeAtom=jotai.atom(null);canvasIframeAtom.debugLabel="canvasIframeAtom";const activePanelAtom=jotai.atom("outline");activePanelAtom.debugLabel="activePanelAtom";const showPredefinedBlockCategoryAtom=jotai.atom("");showPredefinedBlockCategoryAtom.debugLabel="showPredefinedBlockCategoryAtom";const inlineEditingActiveAtom=jotai.atom("");inlineEditingActiveAtom.debugLabel="inlineEditingActiveAtom";const draggingFlagAtom=jotai.atom(!1);draggingFlagAtom.debugLabel="draggingFlagAtom";const treeRefAtom=jotai.atom(null);treeRefAtom.debugLabel="treeRefAtom";const canvasSettingsAtom=jotai.atom({});canvasSettingsAtom.debugLabel="canvasSettingsAtom";const aiAssistantActiveAtom=jotai.atom(!1);aiAssistantActiveAtom.debugLabel="aiAssistantActiveAtom";const codeEditorOpenAtom=jotai.atom(!1);codeEditorOpenAtom.debugLabel="codeEditorOpenAtom";const codeEditorHeightAtom=utils.atomWithStorage("codeEditorHeight",500);codeEditorHeightAtom.debugLabel="codeEditorHeightAtom";const xShowBlocksAtom=jotai.atom([]);xShowBlocksAtom.debugLabel="xShowBlocksAtom";const selectedLibraryAtom=utils.atomWithStorage("_selectedLibrary",null);selectedLibraryAtom.debugLabel="selectedLibraryAtom";const dataBindingActiveAtom=jotai.atom(!0);dataBindingActiveAtom.debugLabel="dataBindingActiveAtom";let lastHighlighted=null;const useBlockHighlight=()=>{const[o]=jotai.useAtom(canvasIframeAtom),n=React.useMemo(()=>{var l;return(o==null?void 0:o.contentDocument)||((l=o==null?void 0:o.contentWindow)==null?void 0:l.document)},[o]),a=React.useCallback(l=>{if(n)if(lastHighlighted&&lastHighlighted.removeAttribute("data-highlighted"),typeof l!="string")l.setAttribute("data-highlighted","true"),lastHighlighted=l;else if(typeof l=="string"){const i=n.querySelector(`[data-block-id="${l}"]`);i&&(i.setAttribute("data-highlighted","true"),lastHighlighted=i)}else lastHighlighted=null},[n]),r=React.useCallback(()=>{lastHighlighted&&(lastHighlighted.removeAttribute("data-highlighted"),lastHighlighted=null)},[]);return{highlightBlock:a,clearHighlight:r,lastHighlighted}};function duplicateBlocks(o,n,a){const r=lodashEs.filter(o,i=>i._parent===n),l=[];for(let i=0;i<r.length;i++)if(lodashEs.filter(o,{_parent:r[i]._id}).length>0){const c=commonFunctions.generateUUID();l.push({...r[i],oldId:r[i]._id,_id:c,_parent:a}),l.push(lodashEs.flatten(duplicateBlocks(o,r[i]._id,c)))}else l.push({...r[i],oldId:r[i]._id,_id:commonFunctions.generateUUID(),_parent:a});return lodashEs.flatten(l)}function convertToBlocksTree(o){const n={};o.forEach(r=>{n[r._id]={...r,children:[]}});const a=[];return o.forEach(r=>{if(r._parent){const l=n[r._parent];l&&l.children.push(n[r._id])}else a.push(n[r._id])}),a}const getDuplicatedBlocks=(o,n,a=null)=>{let r=lodashEs.find(o,{_id:n});r={...r,oldId:r._id,_id:commonFunctions.generateUUID()},a!==(r==null?void 0:r._parent)&&(r={...r,_parent:a});const l=[r];return lodashEs.filter(o,{_parent:n}).length>0&&l.push(lodashEs.flatten(duplicateBlocks(o,n,r._id))),lodashEs.flatten(l)},presentBlocksAtom=jotai.atom([]);presentBlocksAtom.debugLabel="presentBlocksAtom";const treeDSBlocks=jotai.atom(o=>{const n=o(presentBlocksAtom);return convertToBlocksTree([...n])});treeDSBlocks.debugLabel="treeDSBlocks";const pageBlocksAtomsAtom=utils.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";const 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:r})=>lodashEs.includes(a,r)),r=>({...r}))});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 useSelectedBlock=()=>jotai.useAtomValue(selectedBlockAtom),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),r=>lodashEs.includes(a,r._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=utils.atomWithStorage("styleBreakpoint","xs");styleBreakpointAtom.debugLabel="styleBreakpointAtom";const useSelectedBlocksDisplayChild=()=>({flexChild:jotai.useAtomValue(selectedBlockFlexChildAtom),gridChild:jotai.useAtomValue(selectedBlockGridChildAtom)}),selectedBlockHierarchy=jotai.atom(o=>{const n=o(selectedBlockAtom),a=o(presentBlocksAtom);let r=n;const l=[n];do{const i=a.find(({_id:c})=>c===(r==null?void 0:r._parent));r=i,i&&l.push(i)}while(r!=null&&r._parent);return l}),useSelectedBlockHierarchy=()=>lodashEs.compact(jotai.useAtomValue(selectedBlockHierarchy)),useSelectedBlockIds=()=>{const[o,n]=jotai.useAtom(selectedBlockIdsAtom),a=React.useCallback(r=>{n(l=>lodashEs.includes(l,r)?lodashEs.without(l,r):[...l,r])},[n]);return[o,n,a]},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(sooner.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((r,l)=>jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxs(sooner.Button,{onMouseEnter:()=>{a(r==null?void 0:r._id)},onClick:()=>n([r==null?void 0:r._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsx(TypeIcon,{type:r==null?void 0:r._type}),r._name||r._type]}),l!==o.length-1&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},l))]})})},CHAI_BUILDER_EVENTS={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS",CLEAR_CANVAS_SELECTION:"CLEAR_CANVAS_SELECTION",CANVAS_BLOCK_SELECTED:"CANVAS_BLOCK_SELECTED",CANVAS_BLOCK_STYLE_SELECTED:"CANVAS_BLOCK_STYLE_SELECTED"},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 r=lodashEs.get(n,"data._type",""),l=lodashEs.get(a,"data._type","");return canAcceptChildBlock(l,r)};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 r=this.subscribers.get(n);r&&(r.delete(a),r.size===0&&this.subscribers.delete(n))}}publish(n,a){const r=this.subscribers.get(n);r&&r.forEach(l=>l(a))}}const pubsub=new PubSub,AddBlockDropdown=({block:o,children:n})=>{const{t:a}=reactI18next.useTranslation(),[r]=useBlocksStore(),{hasPermission:l}=usePermissions(),i=lodashEs.get(o,"_id"),c=lodashEs.get(o,"_parent"),d=lodashEs.filter(r,m=>c?lodashEs.get(m,"_parent")===c:!lodashEs.get(m,"_parent")),p=canAddChildBlock(lodashEs.get(o,"_type","")),u=lodashEs.findIndex(d,{_id:i}),x=m=>{if(m==="CHILD")pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,o);else{const h={_id:c||"",position:d==null?void 0:d.length};m==="BEFORE"?h.position=Math.max(u,0):m==="AFTER"&&(h.position=u+1),pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,h)}};return l(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsxs(sooner.DropdownMenu,{children:[jsxRuntime.jsx(sooner.DropdownMenuTrigger,{children:n}),jsxRuntime.jsxs(sooner.DropdownMenuContent,{className:"border border-blue-500 bg-primary text-white shadow-2xl",children:[p&&jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("CHILD"),children:a("Add inside")}),jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("BEFORE"),children:a("Add before")}),jsxRuntime.jsx(sooner.DropdownMenuItem,{className:"cursor-pointer text-xs",onClick:()=>x("AFTER"),children:a("Add after")})]})]}):null},draggedBlockAtom=jotai.atom(null);jotai.atom(null);function getOrientation(o,n=null){const a=window.getComputedStyle(o),r=n?window.getComputedStyle(n):null,l=a.display,i=r?r.display:null;if(l==="flex"||l==="inline-flex"){const c=a.flexDirection;return c==="column"||c==="column-reverse"?"vertical":"horizontal"}else if(l==="grid"){const c=a.gridAutoFlow,d=a.gridTemplateColumns;return c.includes("column")||d&&d!=="none"&&d!==""&&!d.includes("calc")&&d.split(" ").length<=1?"vertical":"horizontal"}else if(i==="inline-block"||i==="inline")return"horizontal";return"vertical"}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;function insertBlocksAtPosition(o,n,a,r){const l=[...n];let i=[...o];if(a){const u=o.find(x=>x._id===a);if(u&&u.content!==void 0&&u.content!==""&&!o.some(m=>m._parent===a)){const h={_id:commonFunctions.generateUUID(),_parent:a,_type:"Text",content:u.content};Object.keys(u).forEach(g=>{g.startsWith("content-")&&(h[g]=u[g])}),l.unshift(h),i=i.map(g=>{if(g._id===a){const f={...g,content:""};return Object.keys(f).forEach(j=>{j.startsWith("content-")&&(f[j]="")}),f}return g})}}let c=i.filter(u=>!u._parent);a&&(c=i.filter(u=>u._parent===a));const d=!isNaN(r)||r>-1?Math.min(r,c.length):c.length;let p=i.length;for(let u=0,x=0;u<i.length;u++)if(a!==void 0?i[u]._parent===a:!i[u]._parent){if(x===d){p=u;break}x++}return!a&&r!==void 0&&r>=c.length&&(p=i.length),[...i.slice(0,p),...l,...i.slice(p)]}function getBlocksTree(o){return convertToBlocksTree(o)}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,r){var u,x;const l=findNodeById(o,n),i=findNodeById(o,a);if(!l||!i)return!1;i.children||(i.model.children=[]);let c=(u=i==null?void 0:i.children)==null?void 0:u.findIndex(m=>m.model._id===n);l.drop(),c=Math.max(c,0);const p=(((x=l==null?void 0:l.model)==null?void 0:x._parent)||"root")===a&&c<=r?r-1:r;try{i.addChildAtIndex(l,p)}catch(m){return console.error("Error adding child to parent:",m),!1}return!0}function handleOldParentTextBlock(o,n){if(!n||!n._parent)return o;const a=n._parent,r=o.find(i=>i._id===a);if(!r)return o;const l=o.filter(i=>i._parent===a);if(l.length===2){const i=l.find(c=>c._id!==n._id);if(i&&i._type==="Text"&&"content"in r)return o.map(d=>{if(d._id===a){const p={...d,content:i.content};return Object.keys(i).forEach(u=>{u.startsWith("content-")&&(p[u]=i[u])}),p}return d}).filter(d=>d._id!==i._id)}return o}function handleNewParentTextBlock(o,n,a){if(!a||a==="root")return o;const r=o.find(l=>l._id===a);if(!r)return o;if(r.content!==void 0&&r.content!==""&&!o.some(i=>i._parent===a&&i._id!==n._id)){const c={_id:commonFunctions.generateUUID(),_parent:a,_type:"Text",content:r.content};Object.keys(r).forEach(u=>{u.startsWith("content-")&&(c[u]=r[u])});const d=o.map(u=>{if(u._id===a){const x={...u,content:""};return Object.keys(x).forEach(m=>{m.startsWith("content-")&&(x[m]="")}),x}return u}),p=d.findIndex(u=>u._id===n._id);return p!==-1?[...d.slice(0,p),c,...d.slice(p)]:[c,...d]}return o}function moveBlocksWithChildren(o,n,a,r){if(!n)return o;const l=o.find(u=>u._id===n);if(!l)return o;let i=handleOldParentTextBlock(o,l);const c=a||"root",p=new TreeModel().parse({_id:"root",children:getBlocksTree(i)});if(moveNode(p,n,c,r)){let u=flattenTree(p);const x=u.find(m=>m._id===n);return x&&(x._parent=c==="root"?null:c),u.shift(),a&&(u=handleNewParentTextBlock(u,l,a)),u}return i}const 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=r=>{console.log("error",r)},broadcastChannel.onmessage=r=>{r.data.type==="blocks-updated"&&r.data.pageId===n&&o(r.data.blocks),r.data.type==="blocks-props-updated"&&r.data.pageId===n&&a(r.data.blocks)},()=>{broadcastChannel.onmessage=null,broadcastChannel.onmessageerror=null}),[o,n])},removeNestedBlocks=(o,n)=>{let a=[...o],r=[];n.forEach(d=>{const p=a.find(m=>m._id===d);if(!p||!p._parent)return;const u=p._parent,x=a.filter(m=>m._parent===u);if(x.length===2){const m=x.find(h=>h._id!==d);if(m&&m._type==="Text"){const h=a.find(g=>g._id===u);h&&"content"in h&&(a=a.map(g=>{if(g._id===u){const f={...g,content:m.content};return Object.keys(m).forEach(j=>{j.startsWith("content-")&&(f[j]=m[j])}),f}return g}),r.push(m._id))}}});const l=[...n,...r],i=[],c=lodashEs.filter(a,d=>lodashEs.includes(l,d._id)||lodashEs.includes(l,d._parent)?(i.push(d._id),!1):!0);return lodashEs.isEmpty(i)?c:removeNestedBlocks(c,i)},useRemoveBlocks=()=>{const[o]=useBlocksStore(),[n,a]=useSelectedBlockIds(),{setNewBlocks:r}=useBlocksStoreUndoableActions(),{hasPermission:l}=usePermissions();return React.useCallback(i=>{var d;if(!l(PERMISSIONS.DELETE_BLOCK))return;const c=((d=lodashEs.find(o,{_id:i[0]}))==null?void 0:d._parent)||null;r(removeNestedBlocks(o,i)),setTimeout(()=>a(c?[c]:[]),200)},[o,a,n,l])},builderStore=jotai.getDefaultStore(),writeAtomValue=jotai.atom(null,(o,n,{id:a,props:r})=>{const l=o(pageBlocksAtomsAtom),i=lodashEs.find(l,c=>o(c)._id===a);return i?n(i,{...o(i),...r}):null}),useUpdateBlockAtom=()=>jotai.useSetAtom(writeAtomValue),useGetBlockAtom=o=>utils.useAtomCallback(React.useCallback((n,a,r)=>{const l=n(o);if(!l||!l.length)return console.warn("No blocks available in splitAtoms"),null;const i=lodashEs.find(l,c=>n(c)._id===(lodashEs.isString(r)?r:n(r)._id));return i||(console.warn(`Block with id ${r} not found`),null)},[o]),{store:builderStore}),useBlocksStoreManager=()=>{const[,o]=useBlocksStore(),{postMessage:n}=useBroadcastChannel(),a=useUpdateBlockAtom();return{setNewBlocks:r=>{o(r),n({type:"blocks-updated",blocks:r})},addBlocks:(r,l,i)=>{o(c=>{const d=insertBlocksAtPosition(c,r,l,i);return n({type:"blocks-updated",blocks:d}),d})},removeBlocks:r=>{o(l=>{const i=removeNestedBlocks(l,r);return n({type:"blocks-updated",blocks:i}),i})},moveBlocks:(r,l,i)=>{o(c=>{let d=[...c];for(let p=0;p<r.length;p++)d=moveBlocksWithChildren(d,r[p],l,i);return lodashEs.each(r,p=>{const u=lodashEs.find(d,x=>x._id===p);u&&a({id:p,props:{_parent:u._parent||null}})}),n({type:"blocks-updated",blocks:d}),d})},updateBlocksProps:r=>{r.forEach(l=>{const i=lodashEs.omit(l,"_id");a({id:l._id,props:i})}),n({type:"blocks-props-updated",blocks:r})}}},blockRepeaterDataAtom=jotai.atom({});blockRepeaterDataAtom.debugLabel="blockRepeaterDataAtom";const useBlockRepeaterDataAtom=()=>jotai.useAtom(blockRepeaterDataAtom),useAsyncProps=(o,n,a)=>{const[r,l]=React.useState({status:"idle",props:{},error:void 0}),i=useBuilderProp("getBlockAsyncProps",async m=>({})),c=jotai.useSetAtom(blockRepeaterDataAtom),d=JSON.stringify([o==null?void 0:o._id,...lodashEs.values(lodashEs.pick(o,n??[]))]),p=(o==null?void 0:o._type)==="Repeater"&&lodashEs.startsWith(o.repeaterItems,`{{${applyBinding.COLLECTION_PREFIX}`),u=(o==null?void 0:o._type)!=="Repeater"&&!lodashEs.isUndefined(n);return React.useEffect(()=>{if(o){if(lodashEs.isFunction(a)){l(h=>({...h,status:"loading",props:{}}));const m=a({block:o});if(!utils$1.isObject(m))throw new Error("mockDataProvider should return an object");l(h=>({...h,status:"loaded",props:m}));return}!p&&!u||(l(m=>({...m,status:"loading",props:{}})),i({block:o}).then((m={})=>{p?(c(h=>({...h,[o._id]:{status:"loaded",props:lodashEs.isArray(m)?m:[],repeaterItems:o.repeaterItems}})),l(h=>({...h,status:"loaded"}))):l(h=>({...h,status:"loaded",props:utils$1.isObject(m)?m:{}}))}).catch(m=>{p?(c(h=>({...h,[o._id]:{status:"error",error:m,props:[]}})),l(h=>({...h,status:"error",error:m}))):l(h=>({...h,status:"error",error:m,props:{}}))}))}},[o==null?void 0:o._id,d,p,u,a]),{$loading:lodashEs.get(r,"status")==="loading",...o?lodashEs.get(r,"props",{}):{}}},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=()=>{const[o]=useBlockRepeaterDataAtom(),n=React.useMemo(()=>{const r={};return Object.entries(o).forEach(([l,i])=>{i.status==="loaded"&&(r[i.repeaterItems.replace("}}",`/${l}`).replace("{{","")]=i.props)}),r},[o]);return{...jotai.useAtomValue(chaiPageExternalDataAtom),...n}},useBuilderProp=(o,n=void 0)=>{const a=jotai.useAtomValue(chaiBuilderPropsAtom);return React.useMemo(()=>lodashEs.get(a,o,n),[a,o,n])},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(r=>lodashEs.get(a[r],"builderProp",!1)||lodashEs.get(a[r],"runtime",!1)?r:null))}),useGetPageData=()=>{const[o]=useBrandingOptions(),{currentPage:n}=useCurrentPage(),[a]=useBlocksStore();return React.useCallback(()=>{const r=lodashEs.map(a,l=>lodashEs.omit(l,getBlockBuilderProps(l._type)));return{currentPage:n,blocks:r}},[o,n,a])},usePermissions=()=>{const o=useBuilderProp("permissions",void 0);return{hasPermission:React.useCallback(a=>o?o.includes(a):!0,[o])}},getDefaultThemeValues=(o=plugin.defaultThemeOptions)=>{const n=plugin.defaultThemeValues;return o.fontFamily&&(n.fontFamily=Object.entries(o.fontFamily).reduce((a,[r,l])=>({...a,[r.replace("font-","")]:l}),n.fontFamily)),n.borderRadius=o.borderRadius,o.colors&&(n.colors=o.colors.reduce((a,r)=>(Object.entries(r.items).forEach(([l,i])=>{a[l]=i}),a),n.colors)),n},chaiThemeValuesAtom=jotai.atom({}),useTheme=()=>{const o=useThemeOptions(),n=React.useMemo(()=>getDefaultThemeValues(o),[o]),a=useBuilderProp("theme",{}),[r,l]=jotai.useAtom(chaiThemeValuesAtom);return[React.useMemo(()=>({...n,...!lodashEs.isEmpty(a)&&a,...!lodashEs.isEmpty(r)&&r}),[n,a,r]),l]},useThemeOptions=()=>{const o=useBuilderProp("themeOptions",a=>a);return React.useMemo(()=>o(plugin.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 p=>{}),r=useBuilderProp("onSaveStateChange",lodashEs.noop),l=useGetPageData(),[i]=useTheme(),{hasPermission:c}=usePermissions();return{savePage:web.useThrottledCallback(async(p=!1)=>{if(!c("save_page"))return;n("SAVING"),r("SAVING");const u=l();return await a({autoSave:p,blocks:u.blocks,theme:i}),setTimeout(()=>{n("SAVED"),r("SAVED")},100),!0},[l,n,i,a,r],3e3),saveState:o,setSaveState:n}},undoManager=new UndoManager;undoManager.setLimit(50);const undoRedoStateAtom=jotai.atom({canUndo:!1,canRedo:!1}),useUndoManager=()=>{const[,o]=jotai.useAtom(builderSaveStateAtom),[n,a]=jotai.useAtom(undoRedoStateAtom),r=useBuilderProp("onSaveStateChange",lodashEs.noop),l=React.useCallback(()=>{const u={canUndo:undoManager.hasUndo(),canRedo:undoManager.hasRedo()};a(u),o("UNSAVED"),r("UNSAVED")},[a,o,r]);React.useEffect(()=>(undoManager.setCallback(l),()=>{undoManager.setCallback(lodashEs.noop)}),[l]);const i=React.useCallback(u=>{undoManager.add(u),l()},[l]),c=React.useCallback(()=>{undoManager.undo(),l()},[l]),d=React.useCallback(()=>{undoManager.redo(),l()},[l]),p=React.useCallback(()=>{undoManager.clear(),a({canUndo:!1,canRedo:!1})},[a]);return React.useMemo(()=>({add:i,undo:c,redo:d,hasUndo:()=>n.canUndo,hasRedo:()=>n.canRedo,clear:p}),[i,c,d,n.canUndo,n.canRedo,p])},useBlocksStore=()=>jotai.useAtom(presentBlocksAtom),useBlocksStoreUndoableActions=()=>{const{add:o}=useUndoManager(),[n]=useBlocksStore(),{setNewBlocks:a,addBlocks:r,removeBlocks:l,moveBlocks:i,updateBlocksProps:c}=useBlocksStoreManager();return{moveBlocks:(f,j,b)=>{const k=lodashEs.map(f,S=>{const w=n.find(_=>_._id===S)._parent||null,v=n.filter(_=>w?_._parent===w:!_._parent).map(_=>_._id).indexOf(S);return{_id:S,oldParent:w,oldPosition:v}}),C=k.find(({_id:S})=>S===f[0]);C&&C.oldParent===j&&C.oldPosition===b||(i(f,j,b),o({undo:()=>lodashEs.each(k,({_id:S,oldParent:A,oldPosition:w})=>{i([S],A,w)}),redo:()=>i(f,j,b)}))},addBlocks:(f,j,b)=>{r(f,j,b),o({undo:()=>l(lodashEs.map(f,"_id")),redo:()=>r(f,j,b)})},removeBlocks:f=>{var C;const j=(C=lodashEs.first(f))==null?void 0:C._parent,k=n.filter(S=>j?S._parent===j:!S._parent).indexOf(lodashEs.first(f));l(lodashEs.map(f,"_id")),o({undo:()=>r(f,j,k),redo:()=>l(lodashEs.map(f,"_id"))})},updateBlocks:(f,j,b)=>{let k=[];if(b)k=lodashEs.map(f,C=>({_id:C,...b}));else{const C=lodashEs.keys(j);k=lodashEs.map(f,S=>{const A=n.find(R=>R._id===S),w={_id:S};return lodashEs.each(C,R=>w[R]=A[R]),w})}c(lodashEs.map(f,C=>({_id:C,...j}))),o({undo:()=>c(k),redo:()=>c(lodashEs.map(f,C=>({_id:C,...j})))})},updateBlocksRuntime:(f,j)=>{c(lodashEs.map(f,b=>({_id:b,...j})))},setNewBlocks:f=>{a(f),o({undo:()=>a(n),redo:()=>a(f)})},updateMultipleBlocksProps:f=>{let j=[];j=lodashEs.map(f,b=>{const k=lodashEs.keys(b),C=n.find(A=>A._id===b._id),S={};return lodashEs.each(k,A=>S[A]=C[A]),S}),c(f),o({undo:()=>c(j),redo:()=>c(f)})}}},useAddBlock=()=>{const[o]=useBlocksStore(),[,n]=useSelectedBlockIds(),{addBlocks:a}=useBlocksStoreUndoableActions(),r=React.useCallback((i,c,d)=>{var h;for(let g=0;g<i.length;g++){const{_id:f}=i[g];i[g]._id=commonFunctions.generateUUID();const j=lodashEs.filter(i,{_parent:f});for(let b=0;b<j.length;b++)j[b]._parent=i[g]._id}const p=lodashEs.first(i);let u,x;return c&&(u=lodashEs.find(o,{_id:c}),i[0]._parent=c,x=c),!(u?canAcceptChildBlock(u==null?void 0:u._type,p._type):!0)&&u&&(i[0]._parent=u._parent,x=u._parent),a(i,x,d),n([(h=lodashEs.first(i))==null?void 0:h._id]),lodashEs.first(i)},[a,o,n]);return{addCoreBlock:React.useCallback((i,c,d)=>{if(lodashEs.has(i,"blocks")){const j=i.blocks;return r(j,c,d)}const p=commonFunctions.generateUUID(),u=runtime.getDefaultBlockProps(i.type),x={_type:i.type,_id:p,...u,...lodashEs.has(i,"_name")&&{_name:i._name},...lodashEs.has(i,"partialBlockId")&&{partialBlockId:i.partialBlockId}};let m,h;return c&&(m=lodashEs.find(o,{_id:c}),x._parent=c,h=c),!canAcceptChildBlock(m==null?void 0:m._type,x._type)&&m&&(x._parent=m._parent,h=m._parent),a([x],h,d),n([x._id]),x},[a,r,o,n]),addPredefinedBlock:r}},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 r=lodashEs.flattenDeep(lodashEs.map(o.colors,({items:l})=>lodashEs.keys(l)));a=lodashEs.flattenDeep(lodashEs.map(r,l=>lodashEs.flatten(lodashEs.map(colorKeys,i=>`${i}-${l}`))))}return o.fontFamily&&(a=[...a,...lodashEs.map(lodashEs.keys(o.fontFamily),r=>`${r}`)]),lodashEs.map(a,r=>({name:r}))},[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 l=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__",l.join("|")))})}return CLASSES_LIST},[o]),a=React.useCallback((l,i)=>{const c=lodashEs.get(n,`${l}.regExp`,"");return i.match(new RegExp(c))},[n]),r=React.useCallback((l,i=[])=>lodashEs.get(n,`${l}.classes`,i),[n]);return{match:a,getClasses:r}};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,r=>`${r}:`).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 r=lodashEs.get(CLASSES_LIST,`${a}.regExp`,"");if(new RegExp(r,"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((r,l)=>a.indexOf(r.mq)-a.indexOf(l.mq)).map(r=>r.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 r=o;if(a.length===1)return a[0].fullCls;for(const l of a){const i=l.property,c=n.indexOf(l.mq);for(let d=c+1;d<n.length;d++){const p=n[d],u=a.find(x=>x.property===i&&x.mq===p);if(u&&u.cls===l.cls)r=r.replace(u.fullCls,"");else if(u&&u.cls!==l.cls)break}}return r.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:r})=>{const l=lodashEs.filter(o(pageBlocksAtomsAtom),c=>a.includes(o(c)._id)),i=lodashEs.first(o(selectedStylingBlocksAtom));return lodashEs.map(l,c=>{const d=o(c),p=lodashEs.get(d,i.prop,`${applyBinding.STYLES_KEY},`),{classes:u}=applyBinding.getSplitChaiClasses(p);return{ids:[d._id],props:{[i.prop]:`${applyBinding.STYLES_KEY},${orderClassesByBreakpoint(removeDuplicateClasses(tailwindMerge.twMerge(u,r)))}`}}})}),useAddClassesToBlocks=()=>{const o=jotai.useSetAtom(addClassesToBlocksAtom),{updateBlocks:n,updateBlocksRuntime:a}=useBlocksStoreUndoableActions();return React.useCallback((r,l,i=!1)=>{const c=o({blockIds:r,newClasses:l});if(!i){a(r,c[0].props);return}n(r,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,r]=jotai.useAtom(languageAtom),l=i=>{r(n===i?"":i)};return{languages:o==null?void 0:o.filter(i=>i!==n),fallbackLang:n,selectedLang:a,setSelectedLang:l}},updatePropsForLanguage=(o,n,a)=>{const r=runtime.getRegisteredChaiBlock(lodashEs.get(a,"_type"));if(!r)return o;const l={...o};return lodashEs.forEach(lodashEs.keys(o),i=>{if(lodashEs.includes(lodashEs.get(r,"i18nProps",[]),i)&&!lodashEs.isEmpty(n)){const c=`${i}-${n}`;lodashEs.set(l,c,o[i]),lodashEs.unset(l,i)}}),l},useUpdateBlocksProps=()=>{const{updateBlocks:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((r,l,i)=>{const c=updatePropsForLanguage(l,n,a);o(r,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,r=30)=>{const l=lodashEs.keys(lodashEs.omit(a,["_id"]));for(const i of l){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(x=>setTimeout(x,r))}}},[o])},useStreamMultipleBlocksProps=()=>{const{updateMultipleBlocksProps:o}=useBlocksStoreUndoableActions(),n=useFakeStreamEffect();return React.useCallback(async a=>{for(const r of a)await n(r._id,r);o(a)},[n,o])},useUpdateBlocksPropsRealtime=()=>{const{updateBlocksRuntime:o}=useBlocksStoreUndoableActions(),{selectedLang:n}=useLanguages(),a=useSelectedBlock();return React.useCallback((r,l)=>{const i=updatePropsForLanguage(l,n,a);o(r,i)},[n,a,o])};function getChildBlocks(o,n,a){a.push(lodashEs.find(o,{_id:n}));const r=lodashEs.filter(o,{_parent:n});for(const l of r)a.push(...getBlockWithChildren(l._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 r=["_id","_type","_parent"],l=lodashEs.pick(a,r),i=runtime.getRegisteredChaiBlock(a._type),c={},d=lodashEs.get(i,"aiProps",[]);for(const p in a)r.includes(p)||d.includes(p)&&(c[p]=lodashEs.get(a,`${p}-${n}`,a[p]));return lodashEs.isEmpty(c)?!1:(lodashEs.has(l,"_parent")&&lodashEs.isEmpty(l._parent)&&delete l._parent,{...l,...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,r]=React.useState(null),l=useBuilderProp("askAiCallBack",null),i=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:p,fallbackLang:u}=useLanguages(),x=p.length?p:u,m=(h,g)=>{const f=lodashEs.cloneDeep(g.find(j=>j._id===h));for(const j in f){const b=f[j];if(typeof b=="string"&&lodashEs.startsWith(b,applyBinding.STYLES_KEY)){const{baseClasses:k,classes:C}=applyBinding.getSplitChaiClasses(b);f[j]=lodashEs.compact(lodashEs.flattenDeep([k,C])).join(" ")}else j!=="_id"&&delete f[j]}return f};return{askAi:React.useCallback(async(h,g,f,j)=>{if(l){n(!0),r(null);try{const b=p===u?"":p,k=h==="content"?pickOnlyAIProps(lodashEs.cloneDeep(getBlockWithChildren(g,d)),p):[m(g,d)],C=await l(h,addLangToPrompt(f,x,h),k,b),{blocks:S,error:A}=C;if(A){r(A);return}if(h==="styles"){const w=S.map(R=>{for(const v in R)v!=="_id"&&(R[v]=`${applyBinding.STYLES_KEY},${R[v]}`);return R});c(w)}else i(S);j&&j(C)}catch(b){r(b)}finally{n(!1),j&&j()}}},[l,n,p,u,d,x,c,i]),loading:o,error:a}},useAiAssistant=()=>{const[,o]=useRightPanel();return React.useCallback(n=>{o(n?"ai":"block")},[o])},partialBlocksStoreAtom=jotai.atom({}),partialBlocksLoadingStateAtom=jotai.atom({}),usePartialBlocksStore=()=>{const[o,n]=jotai.useAtom(partialBlocksStoreAtom),a=React.useCallback(l=>lodashEs.get(o,l,[]),[o]),r=React.useCallback(()=>n({}),[n]);return{getPartailBlocks:a,reset:r}},useWatchPartailBlocks=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(partialBlocksStoreAtom),[r,l]=jotai.useAtom(partialBlocksLoadingStateAtom),i=useBuilderProp("getPartialBlockBlocks",async d=>[]),c=React.useMemo(()=>o.filter(d=>d._type==="PartialBlock"||d._type==="GlobalBlock").map(d=>lodashEs.get(d,"partialBlockId",lodashEs.get(d,"globalBlock",""))),[o]);React.useEffect(()=>{lodashEs.forEach(c,d=>{lodashEs.has(n,d)||lodashEs.get(r,`${d}.loading`,!1)||(l(p=>({...p,[d]:{loading:!0,error:null}})),i(d).then(p=>{a(u=>({...u,[d]:p})),l(u=>({...u,[d]:{loading:!1,error:null}}))}).catch(p=>{l(u=>({...u,[d]:{loading:!1,error:p.message}}))}))})},[i,n,r,a,l,c])},partialBlocksListAtom=jotai.atom({}),usePartialBlocksList=()=>{const[o,n]=React.useState(!1),[a,r]=React.useState(null),[l,i]=jotai.useAtom(partialBlocksListAtom),c=useBuilderProp("getPartialBlocks",async()=>[]),d=React.useCallback(async()=>{n(!0),r(null);try{const p=await c();i(p),n(!1)}catch(p){r(p instanceof Error?p.message:"Failed to fetch partial blocks"),n(!1)}},[c,i]);return React.useEffect(()=>{d()},[]),{data:l,isLoading:o,refetch:d,error:a}},useBuilderReset=()=>{const{clear:o}=useUndoManager(),[,n]=useSelectedBlockIds(),{clearHighlight:a}=useBlockHighlight(),[,r]=useSelectedStylingBlocks(),[,l]=jotai.useAtom(aiAssistantActiveAtom),{reset:i}=usePartialBlocksStore(),{setSaveState:c}=useSavePage(),[,d]=useBlockRepeaterDataAtom();return()=>{d({}),n([]),r([]),a(),o(),l(!1),i(),c("SAVED")}},canvasZoomAtom=utils.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),r=React.useCallback(l=>{n(l),a([])},[n,a]);return[o,r]},copiedBlockIdsAtom=jotai.atom([]),useCopyBlocks=()=>{const[o]=useBlocksStore(),[n,a]=jotai.useAtom(copiedBlockIdsAtom),r=jotai.useSetAtom(cutBlockIdsAtom),{getPartailBlocks:l}=usePartialBlocksStore(),i=React.useCallback(d=>d.some(p=>getDuplicatedBlocks(o,p,null).some(x=>x._type==="PartialBlock"||x._type==="GlobalBlock")),[o]),c=React.useCallback(async(d,p=!1)=>{try{a(d),r([]);const u={_chai_copied_blocks:d.flatMap(x=>{const m=getDuplicatedBlocks(o,x,null);if(!p)return m;let h=[];for(const g of m)if(g._type==="PartialBlock"||g._type==="GlobalBlock"){let f=l(g.partialBlockId);g._parent&&(f==null?void 0:f.length)>0&&(f=f.map(j=>(lodashEs.isEmpty(j._parent)&&lodashEs.set(j,"_parent",g._parent),j))),h=[...h,...f]}else h.push(g);return h})};if(!navigator.clipboard){sonner.toast.error("Clipboard not available.");return}sonner.toast.promise(navigator.clipboard.writeText(JSON.stringify(u)),{success:"Blocks copied successfully",error:"Failed to copy blocks to clipboard"})}catch(u){sonner.toast.error("Failed to copy blocks to clipboard"),console.error("Failed to copy blocks to clipboard:",u)}},[a,r]);return[n,c,i]},useCopyToClipboard=()=>{const[o,n]=React.useState(null),a=React.useCallback(async r=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),n(r),!0}catch(l){return console.warn("Copy failed",l),n(null),!1}},[]);return[o,a]},darkModeAtom=utils.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((r,l=null)=>{const i=[];lodashEs.each(r,c=>{const d=o.find(h=>h._id===c);l?l==="root"&&(l=null):l=d._parent;const x=lodashEs.filter(o,h=>lodashEs.isString(l)?h._parent===l:!h._parent).indexOf(d)+1,m=getDuplicatedBlocks(o,c,l);a(m,l,x),i.push(lodashEs.get(m,"0._id",""))}),n(i)},[o,n])},hiddenBlockIdsAtom=jotai.atom([]),useHiddenBlockIds=()=>{const[o,n]=jotai.useAtom(hiddenBlockIdsAtom),a=React.useCallback(r=>{n(l=>lodashEs.includes(l,r)?lodashEs.without(l,r):[...l,r])},[n]);return[o,n,a]},highlightBlockIdAtom=jotai.atom(""),useHighlightBlockId=()=>jotai.useAtom(highlightBlockIdAtom),libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=o=>{const[n,a]=jotai.useAtom(libraryBlocksAtom),r=useBuilderProp("getUILibraryBlocks",lodashEs.noop),l=lodashEs.get(n,`${o==null?void 0:o.id}.blocks`,null),i=lodashEs.get(n,`${o==null?void 0:o.id}.loading`,"idle"),c=React.useRef("idle");React.useEffect(()=>{(async()=>{if(!(i==="complete"||c.current==="loading")){c.current="loading",a(p=>({...p,[o==null?void 0:o.id]:{loading:"loading",blocks:[]}}));try{const p=await r(o);c.current="idle",a(u=>({...u,[o==null?void 0:o.id]:{loading:"complete",blocks:p||[]}}))}catch{c.current="idle",a(u=>({...u,[o==null?void 0:o.id]:{loading:"complete",blocks:[]}}))}}})()},[o,l,i,c,a,r]);const d=React.useCallback(p=>{a(u=>({...u,[p]:{loading:"idle",blocks:[]}}))},[a]);return{data:l||[],isLoading:i==="loading",resetLibrary:d}},useCanPaste=()=>{const[o]=useBlocksStore();return(n,a)=>{var i;const r=((i=lodashEs.find(o,{_id:a}))==null?void 0:i._type)||null,l=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(r,l)}},useMoveCutBlocks=()=>{const o=jotai.useAtomValue(presentBlocksAtom),{moveBlocks:n}=useBlocksStoreUndoableActions();return React.useCallback((a,r)=>{const l=Array.isArray(r)?r[0]:r;if(r==="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===l);n(a,l,(i==null?void 0:i.length)||0)}},[n,o])},usePasteBlocks=()=>{const[o,n]=useCutBlockIds(),a=useMoveCutBlocks(),{addPredefinedBlock:r}=useAddBlock(),l=useCanPaste();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(!(navigator!=null&&navigator.permissions)){sonner.toast.error("Cannot check clipboard permissions.");return}try{if((await navigator.permissions.query({name:"clipboard-read"})).state==="denied"){sonner.toast.error("Clipboard paste permission denied. Please allow clipboard access.");return}}catch{sonner.toast.error("Failed to check clipboard permissions. Please allow clipboard access.");return}if(!lodashEs.isEmpty(o)){a(o,c),n([]),await navigator.clipboard.writeText("");return}sonner.toast.promise(async()=>{const p=await navigator.clipboard.readText();if(p){const u=JSON.parse(p);if(lodashEs.has(u,"_chai_copied_blocks"))r(u._chai_copied_blocks,d==="root"?null:d);else throw new Error("Nothing to paste")}else throw new Error("Nothing to paste")},{success:()=>"Blocks pasted successfully",error:()=>"Nothing to paste"})},[o,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:r})=>{const l=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=r;let{classes:u,baseClasses:x}=applyBinding.getSplitChaiClasses(lodashEs.get(d,l.prop,`${applyBinding.STYLES_KEY},`));return lodashEs.each(p,m=>{const h=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${h}(?=\\s|$)`,"g");u=u.replace(g," ").replace(/\s+/g," ").trim();const f=lodashEs.first(m.split(":"));lodashEs.includes(["2xl","xl","lg","md","sm"],f)&&p.push(m.split(":").pop().trim())}),lodashEs.each(p,m=>{const h=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${h}(?=\\s|$)`,"g");x=x.replace(g," ").replace(/\s+/g," ").trim()}),{ids:[d._id],props:{[l.prop]:`${applyBinding.STYLES_KEY}${x},${u}`}}})}),useRemoveClassesFromBlocks=()=>{const{updateBlocks:o,updateBlocksRuntime:n}=useBlocksStoreUndoableActions(),a=jotai.useSetAtom(removeClassFromBlocksAtom);return React.useCallback((r,l,i=!1)=>{const c=a({blockIds:r,fullClasses:l});i?o(r,c[0].props):n(r,c[0].props)},[a])},useStylingBreakpoint=()=>jotai.useAtom(styleBreakpointAtom),canvasWidthAtom=utils.atomWithStorage("canvasWidth",800),canvasDisplayWidthAtom=utils.atomWithStorage("canvasDisplayWidth",800),canvasBreakpointAtom=jotai.atom(o=>{const n=o(canvasWidthAtom);return commonFunctions.getBreakpointValue(n).toLowerCase()}),useScreenSizeWidth=()=>{const[o,n]=jotai.useAtom(canvasWidthAtom),a=jotai.useAtomValue(canvasBreakpointAtom),[r,l]=useStylingBreakpoint();return React.useEffect(()=>{r!=="xs"&&l(a)},[a,r,l]),[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 r=lodashEs.get(a,n.prop,`${applyBinding.STYLES_KEY},`),{classes:l}=applyBinding.getSplitChaiClasses(r);return lodashEs.filter(lodashEs.map(l.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),r=o(darkModeAtom),l=getQueries(n);let i=lodashEs.filter(o(selectedBlockAllClassesAtom),{mod:a});return lodashEs.startsWith(a,"_")||(i=lodashEs.filter(i,c=>l.includes(c.mq))),i=i.sort((c,d)=>MQ[c.mq]-MQ[d.mq]),r||(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=utils.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),r=a.length===1?a[0]:null;if(!r)return null;const l=lodashEs.find(n,{_id:r});if(!l)return null;let i=l._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),useSelectedLibrary=()=>jotai.useAtom(selectedLibraryAtom),sidebarActivePanelAtom=jotai.atom("outline");sidebarActivePanelAtom.debugLabel="sidebarActivePanelAtom";const useSidebarActivePanel=()=>jotai.useAtom(sidebarActivePanelAtom),CONTROLS=[{ControlIcon:reactIcons.PinTopIcon,dir:"VERTICAL",key:"UP"},{ControlIcon:reactIcons.PinBottomIcon,dir:"VERTICAL",key:"DOWN"},{ControlIcon:reactIcons.PinLeftIcon,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:reactIcons.PinRightIcon,dir:"HORIZONTAL",key:"RIGHT"}],getParentBlockOrientation=(o,n,a)=>{try{if(!o||!a)return"VERTICAL";const r=`[data-block-id='${o}']`,l=a==null?void 0:a.querySelector(r);if(l){const i=a==null?void 0:a.querySelector(`[data-block-id='${n}']`);return getOrientation(l,i).toUpperCase()}return"VERTICAL"}catch{return"VERTICAL"}},isDisabledControl=(o,n,a)=>!!(o&&(a==="UP"||a==="LEFT")||n&&(a==="DOWN"||a==="RIGHT")),useBlockController=(o,n)=>{const[a]=useBlocksStore(),{document:r}=useFrame(),{moveBlocks:l}=useBlocksStoreUndoableActions(),i=lodashEs.get(o,"_id"),c=lodashEs.get(o,"_parent"),d=lodashEs.filter(a,f=>c?lodashEs.get(f,"_parent")===c:!lodashEs.get(f,"_parent")),p=(d==null?void 0:d.length)<=1,u=lodashEs.findIndex(d,{_id:i}),x=u<=0,m=u+1===(d==null?void 0:d.length),h=getParentBlockOrientation(c,i,r),g=React.useCallback(f=>{isDisabledControl(x,m,f)||p||(f==="UP"||f==="LEFT"?l([i],c||null,u-1):(f==="DOWN"||f==="RIGHT")&&l([i],c||null,u+2),n())},[x,m,p,u,i,c,n]);return reactHotkeysHook.useHotkeys("shift+up, shift+down, shift+left, shift+right",({key:f})=>{var j;g((j=f==null?void 0:f.replace("Arrow",""))==null?void 0:j.toUpperCase())},{document:r==null?void 0:r.contentDocument},[g]),{isOnlyChild:p,isFirstBlock:x,isLastBlock:m,moveBlock:g,orientation:h}},BlockController=({block:o,updateFloatingBar:n})=>{const{isOnlyChild:a,isFirstBlock:r,isLastBlock:l,moveBlock:i,orientation:c}=useBlockController(o,n);return a?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:CONTROLS.map(({ControlIcon:d,dir:p,key:u})=>{if(c!==p)return null;const x=isDisabledControl(r,l,u);return x?null:jsxRuntime.jsx(d,{onClick:()=>i(u),className:`${x?"pointer-events-none cursor-not-allowed opacity-50":"duration-300 hover:scale-95 hover:opacity-80"}`},u)})})};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 INLINE_EDITABLE_BLOCKS=["Heading","Paragraph","Text","Link","Span"],isRichTextParent=o=>{var n;return(o==null?void 0:o.getAttribute("data-block-type"))==="RichText"||((n=o==null?void 0:o.parentElement)==null?void 0:n.getAttribute("data-block-type"))==="RichText"},isInlineEditable=(o,n)=>{if(isRichTextParent(o))return!0;const a=o==null?void 0:o.getAttribute("data-block-type");return!a||o&&o.children.length>0||a==="Button"?!1:INLINE_EDITABLE_BLOCKS.includes(a)},useHandleCanvasDblClick=()=>{const[o,n]=jotai.useAtom(inlineEditingActiveAtom);return React.useCallback(a=>{if(a==null||a.preventDefault(),a==null||a.stopPropagation(),o)return;const r=getTargetedBlock(a.target);if(!isInlineEditable(r))return;const l=r.getAttribute("data-block-id");l&&n(l)},[o,n])},useHandleCanvasClick=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{clearHighlight:n}=useBlockHighlight(),a=React.useRef(0);return React.useCallback(r=>{const l=new Date().getTime();if(o||(r.stopPropagation(),l-a.current<400))return;const c=getTargetedBlock(r.target);if(c!=null&&c.getAttribute("data-block-id")&&(c==null?void 0:c.getAttribute("data-block-id"))==="container"){pubsub.publish(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION);return}if(c!=null&&c.getAttribute("data-block-parent")){const d=c.getAttribute("data-style-prop"),p=c.getAttribute("data-style-id"),u=c.getAttribute("data-block-parent");pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,{blockId:u,styleId:p,styleProp:d})}else if(c!=null&&c.getAttribute("data-block-id")){const d=c.getAttribute("data-block-id");pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,d==="canvas"?[]:[d])}n(),a.current=new Date().getTime()},[o])},useHandleMouseMove=()=>{const[o]=jotai.useAtom(inlineEditingActiveAtom),{highlightBlock:n}=useBlockHighlight();return web.useThrottledCallback(a=>{if(o)return;const r=getTargetedBlock(a.target);r&&n(r)},[o,n],100)},useHandleMouseLeave=()=>{const{clearHighlight:o}=useBlockHighlight();return React.useCallback(()=>o(),[o])},Canvas=({children:o})=>{const n=useHandleCanvasDblClick(),a=useHandleCanvasClick(),r=useHandleMouseMove(),l=useHandleMouseLeave();return jsxRuntime.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:a,onDoubleClick:n,onMouseMove:r,onMouseLeave:l,className:"relative h-full max-w-full p-px",children:o})},getElementByDataBlockId=(o,n)=>o.querySelector(`[data-block-id="${n}"]`),BlockActionLabel=({block:o,label:n})=>{const[,a]=useSelectedBlockIds(),[,r]=useHighlightBlockId(),[,l]=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"]))),l(o),setTimeout(()=>{a([]),r(null)},200)},children:[jsxRuntime.jsx(reactIcons.DragHandleDots2Icon,{}),n]})},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),BlockSelectionHighlighter=()=>{const o=useSelectedBlock(),{document:n}=useFrame(),[a]=useSelectedStylingBlocks(),[r,l]=React.useState([]),[,i]=React.useState([]),c=(d,p=0)=>{const{top:u}=d.getBoundingClientRect();return u+p>=0&&u-p<=window.innerHeight};return React.useEffect(()=>{var d;if(o!=null&&o._id&&o.type!=="Multiple"&&n){const p=getElementByDataBlockId(n,o._id);p&&(c(p)||(d=n.defaultView)==null||d.scrollTo({top:p.offsetTop,behavior:"smooth"}),l([p]))}},[o==null?void 0:o._id,o==null?void 0:o.type,n]),React.useEffect(()=>{if(!lodashEs.isEmpty(a)&&n){const d=getElementByStyleId(n,lodashEs.first(a).id);i(d?[d]:[null])}else i([null])},[a,n]),jsxRuntime.jsx(BlockFloatingSelector,{block:o,selectedBlockElement:r[0]})},BlockFloatingSelector=({block:o,selectedBlockElement:n})=>{const a=useRemoveBlocks(),r=useDuplicateBlocks(),[,l]=useSelectedBlockIds(),[,i]=useHighlightBlockId(),[,c]=useSelectedStylingBlocks(),{hasPermission:d}=usePermissions(),[p]=jotai.useAtom(inlineEditingActiveAtom),{document:u}=useFrame(),{floatingStyles:x,refs:m,update:h}=reactDom.useFloating({placement:"top-start",middleware:[reactDom.shift(),dom.flip()],elements:{reference:n}});web.useResizeObserver(n,()=>h(),n!==null),web.useResizeObserver(u==null?void 0:u.body,()=>h(),(u==null?void 0:u.body)!==null);const g=lodashEs.get(o,"_parent",null),f=lodashEs.isEmpty(lodashEs.get(o,"_name",""))?lodashEs.get(o,"_type",""):lodashEs.get(o,"_name","");return!n||!o||p?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{role:"button",tabIndex:0,ref:m.setFloating,style:x,onClick:j=>{j.stopPropagation(),j.preventDefault()},onMouseEnter:j=>{j.stopPropagation(),i(null)},onKeyDown:j=>j.stopPropagation(),className:"isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[g&&jsxRuntime.jsx(reactIcons.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{c([]),l([g])}}),jsxRuntime.jsx(BlockActionLabel,{label:f,block:o}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1.5",children:[jsxRuntime.jsx(AddBlockDropdown,{block:o,children:jsxRuntime.jsx(reactIcons.PlusIcon,{className:"hover:scale-105"})}),canDuplicateBlock(lodashEs.get(o,"_type",""))&&d(PERMISSIONS.ADD_BLOCK)?jsxRuntime.jsx(reactIcons.CopyIcon,{className:"hover:scale-105",onClick:()=>r([o==null?void 0:o._id])}):null,canDeleteBlock(lodashEs.get(o,"_type",""))&&d(PERMISSIONS.DELETE_BLOCK)?jsxRuntime.jsx(reactIcons.TrashIcon,{className:"hover:scale-105",onClick:()=>a([o==null?void 0:o._id])}):null,d(PERMISSIONS.MOVE_BLOCK)&&jsxRuntime.jsx(BlockController,{block:o,updateFloatingBar:h})]})]})})},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">
@@ -56,7 +56,7 @@
56
56
  outline: 1px solid ${n.length>0?"#42a1fc":"#de8f09"} !important; outline-offset: -1px;
57
57
  }`,[o,n]);return jsxRuntime.jsx("style",{id:"selected-styling-blocks",dangerouslySetInnerHTML:{__html:a}})},SelectedBlocks=()=>{const[o]=useSelectedBlockIds(),n=React.useMemo(()=>`${lodashEs.map(o,a=>`[data-block-id="${a}"]`).join(",")}{
58
58
  outline: 1px solid #42a1fc !important; outline-offset: -1px;
59
- }`,[o]);return jsxRuntime.jsx("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:n}})},Fonts=()=>{const[o]=useTheme(),n=runtime.useRegisteredFonts(),a=React.useMemo(()=>{const{heading:i,body:c}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return n.filter(d=>d.family===i||d.family===c)},[o==null?void 0:o.fontFamily,n]),r=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),l=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:l}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=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=React.useCallback(()=>{r([]),l([])},[r,l]);return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})},MayBeAsyncPropsWrapper=({children:o,block:n})=>{const a=React.useMemo(()=>runtime.getRegisteredChaiBlock(n._type),[n._type]),r=lodashEs.has(a,"dataProviderDependencies"),l=lodashEs.get(a,"dataProvider"),i=useAsyncProps(r?n:void 0,lodashEs.get(a,"dataProviderDependencies"),l??void 0);return o(i)},ErrorFallback=()=>jsxRuntime.jsx("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,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&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},BUBBLE_MENU_ICONS={bold:reactIcons.FontBoldIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,strikethrough:reactIcons.StrikethroughIcon,code:reactIcons.CodeIcon,link:reactIcons.Link1Icon,bulletList:reactIcons.ListBulletIcon,orderedList:reactIcons.ListBulletIcon,heading1:reactIcons.HeadingIcon,heading2:reactIcons.HeadingIcon,heading3:reactIcons.HeadingIcon,quote:reactIcons.QuoteIcon,alignLeft:reactIcons.TextAlignLeftIcon,alignCenter:reactIcons.TextAlignCenterIcon,alignRight:reactIcons.TextAlignRightIcon},BubbleMenuButton=({icon:o,title:n,onClick:a,isActive:r})=>{const l=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:sooner.cn("rounded-md p-1.5 transition-colors duration-200",r?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(l,{className:"h-4 w-4"})})},BubbleMenu=({editor:o})=>{if(!o)return null;const n=()=>{const a=window.prompt("Enter URL");a&&o.chain().focus().setLink({href:a}).run()};return jsxRuntime.jsx("div",{className:"flex items-center overflow-hidden rounded-lg border border-blue-500/20 bg-blue-600 text-white shadow-lg",children:jsxRuntime.jsxs("div",{className:"flex items-center p-1",children:[jsxRuntime.jsx(BubbleMenuButton,{icon:"bold",title:"Bold",onClick:()=>o.chain().focus().toggleBold().run(),isActive:o.isActive("bold")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"italic",title:"Italic",onClick:()=>o.chain().focus().toggleItalic().run(),isActive:o.isActive("italic")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"underline",title:"Underline",onClick:()=>o.chain().focus().toggleUnderline().run(),isActive:o.isActive("underline")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"strikethrough",title:"Strikethrough",onClick:()=>o.chain().focus().toggleStrike().run(),isActive:o.isActive("strike")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"link",title:o.isActive("link")?"Remove link":"Add link",onClick:()=>{o.isActive("link")?o.chain().focus().unsetLink().run():n()},isActive:o.isActive("link")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"bulletList",title:"Bullet list",onClick:()=>o.chain().focus().toggleBulletList().run(),isActive:o.isActive("bulletList")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"orderedList",title:"Numbered list",onClick:()=>o.chain().focus().toggleOrderedList().run(),isActive:o.isActive("orderedList")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignLeft",title:"Align left",onClick:()=>o.chain().focus().setTextAlign("left").run(),isActive:o.isActive({textAlign:"left"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignCenter",title:"Align center",onClick:()=>o.chain().focus().setTextAlign("center").run(),isActive:o.isActive({textAlign:"center"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignRight",title:"Align right",onClick:()=>o.chain().focus().setTextAlign("right").run(),isActive:o.isActive({textAlign:"right"})})]})})},RichTextEditor=React.memo(({blockContent:o,editingElement:n,onClose:a,onChange:r,onEscape:l})=>{const{document:i}=useFrame(),c=react.useEditor({editable:!0,content:o,extensions:[StarterKit,Underline,TextAlign.configure({types:["heading","paragraph"]}),Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-blue-500 hover:text-blue-600 underline"}}),Placeholder.configure({placeholder:"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],onUpdate:({editor:u})=>r((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:x})=>{const m=x.relatedTarget,h=i.querySelector(".ProseMirror"),g=i.querySelector(".tippy-box"),f=h==null?void 0:h.contains(m),j=g==null?void 0:g.contains(m);if(!f&&!j){const b=(u==null?void 0:u.getHTML())||"";a(b)}}},[]);React.useEffect(()=>{var u;(u=c==null?void 0:c.commands)==null||u.focus(),c==null||c.emit("focus",{editor:c,event:new FocusEvent("focus"),transaction:[]})},[c]);const d=React.useMemo(()=>{var m;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const x=((m=n==null?void 0:n.className)==null?void 0:m.replace("sr-only",""))||"";return`${u} ${x}`},[n]),p=React.useCallback(u=>{u.key==="Escape"&&l(u)},[l]);return jsxRuntime.jsxs("div",{onKeyDown:p,onClick:u=>u.stopPropagation(),children:[c&&jsxRuntime.jsx(react.BubbleMenu,{editor:c,tippyOptions:{duration:100},children:jsxRuntime.jsx(BubbleMenu,{editor:c})}),jsxRuntime.jsx(react.EditorContent,{editor:c,className:d})]})}),MemoizedEditor=React.memo(({editingElement:o,blockContent:n,onClose:a,editorRef:r,onChange:l,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(r.current){r.current.innerText=n,r.current.focus();const h=c.createRange(),g=d.getSelection();h.selectNodeContents(r.current),h.collapse(!1),g==null||g.removeAllRanges(),g==null||g.addRange(h),r.current.focus()}else a()},[c,d]);const p=React.useMemo(()=>{var g;const h=((g=o==null?void 0:o.tagName)==null?void 0:g.toLowerCase())||"div";return h==="button"?"div":h},[o]),u=React.useCallback(h=>{(h.key==="Enter"||h.key==="Escape")&&i(h)},[i]),x=React.useCallback(()=>{a()},[a]),m=React.useMemo(()=>{var h;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((h=o==null?void 0:o.className)==null?void 0:h.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:lodashEs.cloneDeep(o==null?void 0:o.style)||{},onInput:g=>{const f=g.target;f&&(f.innerText.trim()===""?(f.setAttribute("data-placeholder","Enter text here"),f.children.length>0&&f.children[0].remove()):g.target.removeAttribute("data-placeholder"),l(g.target.innerText))},onClick:g=>{g.stopPropagation(),g.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(p,{ref:r,onBlur:x,onKeyDown:u,...m})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:r}=useFrame(),[l,i]=jotai.useAtom(inlineEditingActiveAtom),[c,d]=React.useState(null),p=React.useRef(null),{clearHighlight:u}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:m}=useLanguages(),[,h]=useSelectedBlockIds(),g=React.useRef(null),f=l,{blockContent:j,blockType:b}=React.useMemo(()=>{var E;const w=o._type;let R=o[a];const v=runtime.getRegisteredChaiBlock(o._type);return m&&((E=v==null?void 0:v.i18nProps)==null?void 0:E.includes(a))&&lodashEs.has(o,`${a}-${m}`)&&(R=lodashEs.get(o,`${a}-${m}`)),{blockContent:R,blockType:w}},[o,m]),k=React.useCallback(w=>{var v;const R=w||((v=p.current)==null?void 0:v.innerText);x([f],{[a]:R}),d(null),i(null),h([])},[f,x,i,h,m]),C=web.useDebouncedCallback(w=>{x([f],{[a]:w})},[f,o,x,m],1e3),S=React.useCallback(w=>{w.preventDefault(),f&&(g.current=f),k(),setTimeout(()=>{const R=g.current;g.current=null,h([R])},100)},[h,f,m]);React.useEffect(()=>{var R;if(!f)return;const w=getElementByDataBlockId(r,f);(R=w==null?void 0:w.classList)==null||R.add("sr-only"),d(w)},[f,b,r]);const A=React.useMemo(()=>c?(u(),b==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:j,editingElement:c,onChange:C,onClose:k,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:j,editingElement:c,onClose:k,onChange:C,onEscape:S})):null,[c,f,b,j,k,m]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A,n]})},(o,n)=>o.block._id===n.block._id&&o.block.content===n.block.content),RepeaterContext=React.createContext({index:-1,key:""}),CORE_BLOCKS=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],BlockRenderer=({asyncProps:o,blockAtom:n,children:a})=>{const[r]=jotai.useAtom(inlineEditingActiveAtom),[l]=jotai.useAtom(n),i=React.useMemo(()=>runtime.getRegisteredChaiBlock(l._type),[l._type]),{selectedLang:c,fallbackLang:d}=useLanguages(),p=useBlockRuntimeProps(),u=usePageExternalData(),[x]=useHiddenBlockIds(),[m]=jotai.useAtom(dataBindingActiveAtom),h=lodashEs.get(i,"component",null),{index:g,key:f}=React.useContext(RepeaterContext),j=React.useMemo(()=>m?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(l,c,i),u,{index:g,key:f}):applyBinding.applyLanguage(l,c,i),[l,c,i,u,m,g,f]),b=React.useMemo(()=>applyBinding.getBlockTagAttributes(l),[l,applyBinding.getBlockTagAttributes]),k=React.useMemo(()=>p(l._id,applyBinding.getBlockRuntimeProps(l._type)),[l._id,l._type,p,applyBinding.getBlockRuntimeProps]),C=React.useMemo(()=>({blockProps:{"data-block-id":l._id,"data-block-type":l._type},inBuilder:!0,lang:c||d,...j,...b,...k,...o}),[l._id,l._type,c,d,j,b,k,o]),S=React.useMemo(()=>!CORE_BLOCKS.includes(l._type),[l._type]);if(lodashEs.isNull(h)||x.includes(l._id))return null;let A=jsxRuntime.jsx(React.Suspense,{children:React.createElement(h,{...C,children:a({_id:l._id,_type:l._type,...lodashEs.isArray(j.repeaterItems)?{repeaterItems:applyBinding.applyLimit(j.repeaterItems,l),$repeaterItemsKey:j.$repeaterItemsKey}:{},...l.partialBlockId?{partialBlockId:l.partialBlockId}:"",...l.globalBlock?{partialBlockId:l.globalBlock}:""})})});const w=r===l._id?jsxRuntime.jsx(WithBlockTextEditor,{block:l,children:A}):A;return S?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:w}):w},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=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).length>0,[o]);return lodashEs.map(l,c=>{const d=r(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:p=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:p,children:({_id:u,_type:x,partialBlockId:m,repeaterItems:h,$repeaterItemsKey:g})=>x==="Repeater"?lodashEs.isArray(h)&&h.map((f,j)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:j,key:g},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${j}`)):x==="GlobalBlock"||x==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:m})}):i(u)?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(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let x={};const m=p*u,h=d*u;p&&(x={height:100+(p-m)/m*100+"%",width:100+(d-h)/h*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...x,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{c()},[n,o,a,c]),l};function usePubSub(o,n){React.useEffect(()=>{const a=pubsub.subscribe(o,n);return()=>a()},[o,n])}const CanvasEventsWatcher=()=>{const[,o]=useSelectedBlockIds(),[n,a]=useSelectedStylingBlocks(),{document:r}=useFrame(),{clearHighlight:l}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(r,lodashEs.first(i));if(d){const p=d.getAttribute("data-style-prop");if(p){const u=d.getAttribute("data-style-id"),x=d.getAttribute("data-block-parent");a([{id:u,prop:p,blockId:x}])}}},100)},[r,i,a,n]),React.useEffect(()=>()=>l(),[l]),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,d=>{if(!d)return;const{blockId:p}=d;i.includes(p)||c==null||c.closeAll(),o([p])}),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,d=>{if(!d)return;const{blockId:p,styleId:u,styleProp:x}=d;p&&(i.includes(p)||c==null||c.closeAll(),a([{id:u,prop:x,blockId:p}]),o([p]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{l(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),r=React.useRef(null),[l,i]=React.useState({width:0,height:0}),c=useCanvasScale(l),[,d]=jotai.useAtom(canvasIframeAtom),p=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),x=React.useCallback(h=>{i(g=>({...g,width:h}))},[i]);React.useEffect(()=>{if(!r.current)return;const{clientWidth:h,clientHeight:g}=r.current;i({width:h,height:g})},[r,o]);const m=React.useMemo(()=>{let h=IframeInitialContent;return h=h.replace("__HTML_DIR__",u),h},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:x,onResize:x,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:r,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>d(a.current),ref:a,id:"canvas-iframe",style:{...c,...lodashEs.isEmpty(c)?{width:`${o}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:m,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[p?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsx(CanvasEventsWatcher,{})]}),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."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-DydX0A0c.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(sooner.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(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const p=removeSizeAttributes(d);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:d=>c(d.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,x]=React.useState(null),m=async g=>{if(!g.trim()){p(!1),x("Please enter a URL");return}try{c(!0),x(null),p(!0),x(null)}catch{p(!1),x("Error validating URL")}finally{c(!1)}},{t:h}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:h(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:h(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>m(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:h("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!d||i,children:h("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:c?jsxRuntime.jsx(c,{close:()=>i(!1),onSelect:d,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),c=useUpdateBlocksProps(),d=x=>{const m=lodashEs.isArray(x)?lodashEs.first(x):x;if(m){n(m==null?void 0:m.url);const h=m==null?void 0:m.width,g=m==null?void 0:m.height;if(i!=null&&i._id){const f={...h&&{width:h},...g&&{height:g},...m.description&&{alt:m.description},...m.id&&{assetId:m.id}};if(lodashEs.isEmpty(f))return;c([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&c([i._id],{assetId:""})},[n,i==null?void 0:i._id,c]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:d,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:d,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:x}})=>r(a,x),onChange:x=>n(x.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[r,l]=React.useState([]),[i,c]=React.useState(o),d=m=>Array.isArray(m)?"array":typeof m=="object"&&m!==null?"object":"value",p=React.useCallback(m=>{const h=g=>a==="value"?g==="value"||g==="object":a==="array"?g==="array":g===a;m.type==="object"?(l(g=>[...g,m.key]),c(m.value)):h(m.type)&&n([...r,m.key].join("."),a)},[r,n,a]),u=React.useCallback(()=>{if(r.length>0){const m=r.slice(0,-1);l(m),c(m.reduce((h,g)=>h[g],o))}},[r,o]),x=React.useMemo(()=>i?Object.entries(i).map(([m,h])=>({key:m,value:h,type:d(h)})).filter(m=>!lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)&&m.key.includes("/")?!1:a==="value"?m.type==="value"||m.type==="object":a==="array"?m.type==="array"||m.type==="object":a==="object"?m.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[r.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),x.map(m=>jsxRuntime.jsxs(sooner.CommandItem,{value:m.key,disabled:!1,onSelect:()=>p(m),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(m.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(m.key,applyBinding.COLLECTION_PREFIX)?m.key.replace(applyBinding.COLLECTION_PREFIX,""):m.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&m.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:h=>{h.stopPropagation(),n([...r,m.key].join("."),a)},children:"Select"}),m.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},m.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(p=>p.id).reduce((p,u)=>({...p,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,p)=>{n(d,p),l(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:r})=>{const l=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const x=i.find(g=>g._type==="Repeater"),h=lodashEs.get(x,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(h,applyBinding.COLLECTION_PREFIX)?`${h}/${x._id}`:h}`},[i]),p=React.useMemo(()=>lodashEs.first(lodashEs.get(l,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,l]),u=React.useCallback((x,m)=>{if(x=lodashEs.isEmpty(d)?x:x.replace(`${d}`,"$index"),m==="array"||m==="object"){n(`{{${x}}}`,{},a);return}const h=b=>/[.,!?;:]/.test(b),g=(b,k,C)=>{let S="",A="";const w=k>0?b[k-1]:"",R=k<b.length?b[k]:"";return k>0&&(w==="."||!h(w)&&w!==" ")&&(S=" "),k<b.length&&!h(R)&&R!==" "&&(A=" "),{text:S+C+A,prefixLength:S.length,suffixLength:A.length}},f=document.getElementById(a);if(!f)return;const j=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(j&&(j.querySelector(".ProseMirror")||j.__chaiRTE)){const b=j.__chaiRTE;if(b){const k=`{{${x}}}`;b.commands.focus();const{from:C,to:S}=b.state.selection;if(C!==S)b.chain().deleteSelection().insertContent(k).run();else{const{state:w}=b,R=w.selection.from,v=w.doc.textBetween(Math.max(0,R-1),R),_=w.doc.textBetween(R,Math.min(R+1,w.doc.content.size));let E="";R>0&&v!==" "&&!h(v)&&(E=" ");let y="";_&&_!==" "&&!h(_)&&(y=" "),b.chain().insertContent(E+k+y).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=f,k=b.selectionStart||0,C=b.value||"",S=b.selectionEnd||k;if(S>k){const _=`{{${x}}}`,{text:E}=g(C,k,_),y=C.slice(0,k)+E+C.slice(S);n(y,{},a);return}const w=`{{${x}}}`,{text:R}=g(C,k,w),v=C.slice(0,k)+R+C.slice(k);n(v,{},a)}},[a,n,r,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...p&&{[d]:p},...l},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var _;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(E,y)=>[]),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,x]=React.useState("page"),[m,h]=React.useState(""),[g,f]=React.useState([]),[j,b]=React.useState(-1),k=React.useRef(null),C=(_=n==null?void 0:n.find(E=>E.key===u))==null?void 0:_.name;React.useEffect(()=>{if(h(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const E=lodashEs.split(o,":"),y=lodashEs.get(E,1,"page")||"page";x(y),(async()=>{const B=await l(y,[lodashEs.get(E,2,"page")]);B&&Array.isArray(B)&&h(lodashEs.get(B,[0,"name"],""))})()},[o]);const S=web.useDebouncedCallback(async E=>{if(lodashEs.isEmpty(E))f([]);else{const y=await l(u,E);f(y)}c(!1),b(-1)},[u],300),A=E=>{const y=["pageType",u,E.id];y[1]&&(a(y.join(":")),h(E.name),p(!1),f([]),b(-1))},w=E=>{switch(E.key){case"ArrowDown":E.preventDefault(),b(y=>y<g.length-1?y+1:y);break;case"ArrowUp":E.preventDefault(),b(y=>y>0?y-1:y);break;case"Enter":if(E.preventDefault(),g.length===0)return;j>=0&&A(g[j]);break;case"Escape":E.preventDefault(),R();break}};React.useEffect(()=>{if(j>=0&&k.current){const E=k.current.children[j];E==null||E.scrollIntoView({block:"nearest"})}},[j]);const R=()=>{h(""),f([]),b(-1),p(!1),a("")},v=E=>{h(E),p(!lodashEs.isEmpty(E)),c(!0),S(E)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:E=>x(E.target.value),children:lodashEs.map(n,E=>jsxRuntime.jsx("option",{value:E.key,children:E.name},E.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:m,onChange:E=>v(E.target.value),onKeyDown:w,placeholder:r(`Search ${C??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:m&&jsxRuntime.jsx("button",{onClick:R,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||d&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):d&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',m,'"']}):jsxRuntime.jsx("ul",{ref:k,children:lodashEs.map(g==null?void 0:g.slice(0,20),(E,y)=>jsxRuntime.jsxs("li",{onClick:()=>A(E),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(E.id)?"bg-blue-200":y===j?"bg-gray-100":"hover:bg-gray-100"}`,children:[E.name," ",E.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",E.slug," )"]})]},E.id))})})]})},LinkField=({schema:o,formData:n,onChange:a,name:r})=>{const{t:l}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,p=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(p)?"url":i;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[(o==null?void 0:o.title)??"Link",jsxRuntime.jsx(DataBindingSelector,{schema:o,onChange:x=>{console.log("value",n,x),a({...n,href:x,...u==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:x=>a({...n,type:x.target.value}),children:lodashEs.map([...lodashEs.isEmpty(p)?[]:[{const:"pageType",title:l("Goto Page")}],{const:"url",title:l("Open URL")},{const:"email",title:l("Compose Email")},{const:"telephone",title:l("Call Phone")},{const:"scroll",title:l("Scroll to element")}],x=>jsxRuntime.jsx("option",{value:x.const,children:x.title},x.const))}),u==="pageType"&&!lodashEs.isEmpty(p)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:p,onChange:x=>a({...n,href:x})}):null,jsxRuntime.jsx("input",{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:x=>a({...n,href:x.target.value}),placeholder:l(i==="url"?"Enter URL":i==="scroll"?"#ElementID":"Enter details")}),u==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{id:`root.${r}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:l("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{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:r,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:r,onChange:l,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const m=document.createElement("style");return m.id="rte-modal-styles",m.innerHTML=`
59
+ }`,[o]);return jsxRuntime.jsx("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:n}})},Fonts=()=>{const[o]=useTheme(),n=runtime.useRegisteredFonts(),a=React.useMemo(()=>{const{heading:i,body:c}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return n.filter(d=>d.family===i||d.family===c)},[o==null?void 0:o.fontFamily,n]),r=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),l=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:l}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=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=React.useCallback(()=>{r([]),l([])},[r,l]);return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})},MayBeAsyncPropsWrapper=({children:o,block:n})=>{const a=React.useMemo(()=>runtime.getRegisteredChaiBlock(n._type),[n._type]),r=lodashEs.has(a,"dataProviderDependencies"),l=lodashEs.get(a,"dataProvider"),i=useAsyncProps(r?n:void 0,lodashEs.get(a,"dataProviderDependencies"),l??void 0);return o(i)},ErrorFallback=()=>jsxRuntime.jsx("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,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&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},BUBBLE_MENU_ICONS={bold:reactIcons.FontBoldIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,strikethrough:reactIcons.StrikethroughIcon,code:reactIcons.CodeIcon,link:reactIcons.Link1Icon,bulletList:reactIcons.ListBulletIcon,orderedList:reactIcons.ListBulletIcon,heading1:reactIcons.HeadingIcon,heading2:reactIcons.HeadingIcon,heading3:reactIcons.HeadingIcon,quote:reactIcons.QuoteIcon,alignLeft:reactIcons.TextAlignLeftIcon,alignCenter:reactIcons.TextAlignCenterIcon,alignRight:reactIcons.TextAlignRightIcon},BubbleMenuButton=({icon:o,title:n,onClick:a,isActive:r})=>{const l=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:sooner.cn("rounded-md p-1.5 transition-colors duration-200",r?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(l,{className:"h-4 w-4"})})},BubbleMenu=({editor:o})=>{if(!o)return null;const n=()=>{const a=window.prompt("Enter URL");a&&o.chain().focus().setLink({href:a}).run()};return jsxRuntime.jsx("div",{className:"flex items-center overflow-hidden rounded-lg border border-blue-500/20 bg-blue-600 text-white shadow-lg",children:jsxRuntime.jsxs("div",{className:"flex items-center p-1",children:[jsxRuntime.jsx(BubbleMenuButton,{icon:"bold",title:"Bold",onClick:()=>o.chain().focus().toggleBold().run(),isActive:o.isActive("bold")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"italic",title:"Italic",onClick:()=>o.chain().focus().toggleItalic().run(),isActive:o.isActive("italic")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"underline",title:"Underline",onClick:()=>o.chain().focus().toggleUnderline().run(),isActive:o.isActive("underline")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"strikethrough",title:"Strikethrough",onClick:()=>o.chain().focus().toggleStrike().run(),isActive:o.isActive("strike")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"link",title:o.isActive("link")?"Remove link":"Add link",onClick:()=>{o.isActive("link")?o.chain().focus().unsetLink().run():n()},isActive:o.isActive("link")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"bulletList",title:"Bullet list",onClick:()=>o.chain().focus().toggleBulletList().run(),isActive:o.isActive("bulletList")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"orderedList",title:"Numbered list",onClick:()=>o.chain().focus().toggleOrderedList().run(),isActive:o.isActive("orderedList")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignLeft",title:"Align left",onClick:()=>o.chain().focus().setTextAlign("left").run(),isActive:o.isActive({textAlign:"left"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignCenter",title:"Align center",onClick:()=>o.chain().focus().setTextAlign("center").run(),isActive:o.isActive({textAlign:"center"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignRight",title:"Align right",onClick:()=>o.chain().focus().setTextAlign("right").run(),isActive:o.isActive({textAlign:"right"})})]})})},RichTextEditor=React.memo(({blockContent:o,editingElement:n,onClose:a,onChange:r,onEscape:l})=>{const{document:i}=useFrame(),c=react.useEditor({editable:!0,content:o,extensions:[StarterKit,Underline,TextAlign.configure({types:["heading","paragraph"]}),Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-blue-500 hover:text-blue-600 underline"}}),Placeholder.configure({placeholder:"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],onUpdate:({editor:u})=>r((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:x})=>{const m=x.relatedTarget,h=i.querySelector(".ProseMirror"),g=i.querySelector(".tippy-box"),f=h==null?void 0:h.contains(m),j=g==null?void 0:g.contains(m);if(!f&&!j){const b=(u==null?void 0:u.getHTML())||"";a(b)}}},[]);React.useEffect(()=>{var u;(u=c==null?void 0:c.commands)==null||u.focus(),c==null||c.emit("focus",{editor:c,event:new FocusEvent("focus"),transaction:[]})},[c]);const d=React.useMemo(()=>{var m;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const x=((m=n==null?void 0:n.className)==null?void 0:m.replace("sr-only",""))||"";return`${u} ${x}`},[n]),p=React.useCallback(u=>{u.key==="Escape"&&l(u)},[l]);return jsxRuntime.jsxs("div",{onKeyDown:p,onClick:u=>u.stopPropagation(),children:[c&&jsxRuntime.jsx(react.BubbleMenu,{editor:c,tippyOptions:{duration:100},children:jsxRuntime.jsx(BubbleMenu,{editor:c})}),jsxRuntime.jsx(react.EditorContent,{editor:c,className:d})]})}),MemoizedEditor=React.memo(({editingElement:o,blockContent:n,onClose:a,editorRef:r,onChange:l,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(r.current){r.current.innerText=n,r.current.focus();const h=c.createRange(),g=d.getSelection();h.selectNodeContents(r.current),h.collapse(!1),g==null||g.removeAllRanges(),g==null||g.addRange(h),r.current.focus()}else a()},[c,d]);const p=React.useMemo(()=>{var g;const h=((g=o==null?void 0:o.tagName)==null?void 0:g.toLowerCase())||"div";return h==="button"?"div":h},[o]),u=React.useCallback(h=>{(h.key==="Enter"||h.key==="Escape")&&i(h)},[i]),x=React.useCallback(()=>{a()},[a]),m=React.useMemo(()=>{var h;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((h=o==null?void 0:o.className)==null?void 0:h.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:lodashEs.cloneDeep(o==null?void 0:o.style)||{},onInput:g=>{const f=g.target;f&&(f.innerText.trim()===""?(f.setAttribute("data-placeholder","Enter text here"),f.children.length>0&&f.children[0].remove()):g.target.removeAttribute("data-placeholder"),l(g.target.innerText))},onClick:g=>{g.stopPropagation(),g.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(p,{ref:r,onBlur:x,onKeyDown:u,...m})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:r}=useFrame(),[l,i]=jotai.useAtom(inlineEditingActiveAtom),[c,d]=React.useState(null),p=React.useRef(null),{clearHighlight:u}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:m}=useLanguages(),[,h]=useSelectedBlockIds(),g=React.useRef(null),f=l,{blockContent:j,blockType:b}=React.useMemo(()=>{var E;const w=o._type;let R=o[a];const v=runtime.getRegisteredChaiBlock(o._type);return m&&((E=v==null?void 0:v.i18nProps)==null?void 0:E.includes(a))&&lodashEs.has(o,`${a}-${m}`)&&(R=lodashEs.get(o,`${a}-${m}`)),{blockContent:R,blockType:w}},[o,m]),k=React.useCallback(w=>{var v;const R=w||((v=p.current)==null?void 0:v.innerText);x([f],{[a]:R}),d(null),i(null),h([])},[f,x,i,h,m]),C=web.useDebouncedCallback(w=>{x([f],{[a]:w})},[f,o,x,m],1e3),S=React.useCallback(w=>{w.preventDefault(),f&&(g.current=f),k(),setTimeout(()=>{const R=g.current;g.current=null,h([R])},100)},[h,f,m]);React.useEffect(()=>{var R;if(!f)return;const w=getElementByDataBlockId(r,f);(R=w==null?void 0:w.classList)==null||R.add("sr-only"),d(w)},[f,b,r]);const A=React.useMemo(()=>c?(u(),b==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:j,editingElement:c,onChange:C,onClose:k,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:j,editingElement:c,onClose:k,onChange:C,onEscape:S})):null,[c,f,b,j,k,m]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A,n]})},(o,n)=>o.block._id===n.block._id&&o.block.content===n.block.content),RepeaterContext=React.createContext({index:-1,key:""}),CORE_BLOCKS=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],BlockRenderer=({asyncProps:o,blockAtom:n,children:a})=>{const[r]=jotai.useAtom(inlineEditingActiveAtom),[l]=jotai.useAtom(n),i=React.useMemo(()=>runtime.getRegisteredChaiBlock(l._type),[l._type]),{selectedLang:c,fallbackLang:d}=useLanguages(),p=useBlockRuntimeProps(),u=usePageExternalData(),[x]=useHiddenBlockIds(),[m]=jotai.useAtom(dataBindingActiveAtom),h=lodashEs.get(i,"component",null),{index:g,key:f}=React.useContext(RepeaterContext),j=React.useMemo(()=>m?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(l,c,i),u,{index:g,key:f}):applyBinding.applyLanguage(l,c,i),[l,c,i,u,m,g,f]),b=React.useMemo(()=>applyBinding.getBlockTagAttributes(l),[l,applyBinding.getBlockTagAttributes]),k=React.useMemo(()=>p(l._id,applyBinding.getBlockRuntimeProps(l._type)),[l._id,l._type,p,applyBinding.getBlockRuntimeProps]),C=React.useMemo(()=>({blockProps:{"data-block-id":l._id,"data-block-type":l._type},inBuilder:!0,lang:c||d,...j,...b,...k,...o}),[l._id,l._type,c,d,j,b,k,o]),S=React.useMemo(()=>!CORE_BLOCKS.includes(l._type),[l._type]);if(lodashEs.isNull(h)||x.includes(l._id))return null;let A=jsxRuntime.jsx(React.Suspense,{children:React.createElement(h,{...C,children:a({_id:l._id,_type:l._type,...lodashEs.isArray(j.repeaterItems)?{repeaterItems:applyBinding.applyLimit(j.repeaterItems,l),$repeaterItemsKey:j.$repeaterItemsKey}:{},...l.partialBlockId?{partialBlockId:l.partialBlockId}:"",...l.globalBlock?{partialBlockId:l.globalBlock}:""})})});const w=r===l._id?jsxRuntime.jsx(WithBlockTextEditor,{block:l,children:A}):A;return S?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:w}):w},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=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).length>0,[o]);return lodashEs.map(l,c=>{const d=r(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:p=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:p,children:({_id:u,_type:x,partialBlockId:m,repeaterItems:h,$repeaterItemsKey:g})=>x==="Repeater"?lodashEs.isArray(h)&&h.map((f,j)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:j,key:g},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${j}`)):x==="GlobalBlock"||x==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:m})}):i(u)?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(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let x={};const m=p*u,h=d*u;p&&(x={height:100+(p-m)/m*100+"%",width:100+(d-h)/h*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...x,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{c()},[n,o,a,c]),l};function usePubSub(o,n){React.useEffect(()=>{const a=pubsub.subscribe(o,n);return()=>a()},[o,n])}const CanvasEventsWatcher=()=>{const[,o]=useSelectedBlockIds(),[n,a]=useSelectedStylingBlocks(),{document:r}=useFrame(),{clearHighlight:l}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(r,lodashEs.first(i));if(d){const p=d.getAttribute("data-style-prop");if(p){const u=d.getAttribute("data-style-id"),x=d.getAttribute("data-block-parent");a([{id:u,prop:p,blockId:x}])}}},100)},[r,i,a,n]),React.useEffect(()=>()=>l(),[l]),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,d=>{d&&(!lodashEs.isEmpty(d)&&!lodashEs.includes(i,lodashEs.first(d))&&(c==null||c.closeAll()),o(d))}),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,d=>{if(!d)return;const{blockId:p,styleId:u,styleProp:x}=d;p&&(lodashEs.includes(i,p)||c==null||c.closeAll(),a([{id:u,prop:x,blockId:p}]),o([p]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{l(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),r=React.useRef(null),[l,i]=React.useState({width:0,height:0}),c=useCanvasScale(l),[,d]=jotai.useAtom(canvasIframeAtom),p=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),x=React.useCallback(h=>{i(g=>({...g,width:h}))},[i]);React.useEffect(()=>{if(!r.current)return;const{clientWidth:h,clientHeight:g}=r.current;i({width:h,height:g})},[r,o]);const m=React.useMemo(()=>{let h=IframeInitialContent;return h=h.replace("__HTML_DIR__",u),h},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:x,onResize:x,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:r,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>d(a.current),ref:a,id:"canvas-iframe",style:{...c,...lodashEs.isEmpty(c)?{width:`${o}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:m,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[p?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsx(CanvasEventsWatcher,{})]}),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."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-DydX0A0c.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(sooner.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(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const p=removeSizeAttributes(d);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:d=>c(d.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,x]=React.useState(null),m=async g=>{if(!g.trim()){p(!1),x("Please enter a URL");return}try{c(!0),x(null),p(!0),x(null)}catch{p(!1),x("Error validating URL")}finally{c(!1)}},{t:h}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:h(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:h(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>m(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:h("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!d||i,children:h("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:c?jsxRuntime.jsx(c,{close:()=>i(!1),onSelect:d,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),c=useUpdateBlocksProps(),d=x=>{const m=lodashEs.isArray(x)?lodashEs.first(x):x;if(m){n(m==null?void 0:m.url);const h=m==null?void 0:m.width,g=m==null?void 0:m.height;if(i!=null&&i._id){const f={...h&&{width:h},...g&&{height:g},...m.description&&{alt:m.description},...m.id&&{assetId:m.id}};if(lodashEs.isEmpty(f))return;c([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&c([i._id],{assetId:""})},[n,i==null?void 0:i._id,c]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:d,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:d,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:x}})=>r(a,x),onChange:x=>n(x.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[r,l]=React.useState([]),[i,c]=React.useState(o),d=m=>Array.isArray(m)?"array":typeof m=="object"&&m!==null?"object":"value",p=React.useCallback(m=>{const h=g=>a==="value"?g==="value"||g==="object":a==="array"?g==="array":g===a;m.type==="object"?(l(g=>[...g,m.key]),c(m.value)):h(m.type)&&n([...r,m.key].join("."),a)},[r,n,a]),u=React.useCallback(()=>{if(r.length>0){const m=r.slice(0,-1);l(m),c(m.reduce((h,g)=>h[g],o))}},[r,o]),x=React.useMemo(()=>i?Object.entries(i).map(([m,h])=>({key:m,value:h,type:d(h)})).filter(m=>!lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)&&m.key.includes("/")?!1:a==="value"?m.type==="value"||m.type==="object":a==="array"?m.type==="array"||m.type==="object":a==="object"?m.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[r.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),x.map(m=>jsxRuntime.jsxs(sooner.CommandItem,{value:m.key,disabled:!1,onSelect:()=>p(m),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(m.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(m.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(m.key,applyBinding.COLLECTION_PREFIX)?m.key.replace(applyBinding.COLLECTION_PREFIX,""):m.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&m.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:h=>{h.stopPropagation(),n([...r,m.key].join("."),a)},children:"Select"}),m.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},m.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(p=>p.id).reduce((p,u)=>({...p,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,p)=>{n(d,p),l(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:r})=>{const l=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const x=i.find(g=>g._type==="Repeater"),h=lodashEs.get(x,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(h,applyBinding.COLLECTION_PREFIX)?`${h}/${x._id}`:h}`},[i]),p=React.useMemo(()=>lodashEs.first(lodashEs.get(l,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,l]),u=React.useCallback((x,m)=>{if(x=lodashEs.isEmpty(d)?x:x.replace(`${d}`,"$index"),m==="array"||m==="object"){n(`{{${x}}}`,{},a);return}const h=b=>/[.,!?;:]/.test(b),g=(b,k,C)=>{let S="",A="";const w=k>0?b[k-1]:"",R=k<b.length?b[k]:"";return k>0&&(w==="."||!h(w)&&w!==" ")&&(S=" "),k<b.length&&!h(R)&&R!==" "&&(A=" "),{text:S+C+A,prefixLength:S.length,suffixLength:A.length}},f=document.getElementById(a);if(!f)return;const j=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(j&&(j.querySelector(".ProseMirror")||j.__chaiRTE)){const b=j.__chaiRTE;if(b){const k=`{{${x}}}`;b.commands.focus();const{from:C,to:S}=b.state.selection;if(C!==S)b.chain().deleteSelection().insertContent(k).run();else{const{state:w}=b,R=w.selection.from,v=w.doc.textBetween(Math.max(0,R-1),R),_=w.doc.textBetween(R,Math.min(R+1,w.doc.content.size));let E="";R>0&&v!==" "&&!h(v)&&(E=" ");let y="";_&&_!==" "&&!h(_)&&(y=" "),b.chain().insertContent(E+k+y).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=f,k=b.selectionStart||0,C=b.value||"",S=b.selectionEnd||k;if(S>k){const _=`{{${x}}}`,{text:E}=g(C,k,_),y=C.slice(0,k)+E+C.slice(S);n(y,{},a);return}const w=`{{${x}}}`,{text:R}=g(C,k,w),v=C.slice(0,k)+R+C.slice(k);n(v,{},a)}},[a,n,r,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...p&&{[d]:p},...l},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var _;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(E,y)=>[]),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,x]=React.useState("page"),[m,h]=React.useState(""),[g,f]=React.useState([]),[j,b]=React.useState(-1),k=React.useRef(null),C=(_=n==null?void 0:n.find(E=>E.key===u))==null?void 0:_.name;React.useEffect(()=>{if(h(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const E=lodashEs.split(o,":"),y=lodashEs.get(E,1,"page")||"page";x(y),(async()=>{const B=await l(y,[lodashEs.get(E,2,"page")]);B&&Array.isArray(B)&&h(lodashEs.get(B,[0,"name"],""))})()},[o]);const S=web.useDebouncedCallback(async E=>{if(lodashEs.isEmpty(E))f([]);else{const y=await l(u,E);f(y)}c(!1),b(-1)},[u],300),A=E=>{const y=["pageType",u,E.id];y[1]&&(a(y.join(":")),h(E.name),p(!1),f([]),b(-1))},w=E=>{switch(E.key){case"ArrowDown":E.preventDefault(),b(y=>y<g.length-1?y+1:y);break;case"ArrowUp":E.preventDefault(),b(y=>y>0?y-1:y);break;case"Enter":if(E.preventDefault(),g.length===0)return;j>=0&&A(g[j]);break;case"Escape":E.preventDefault(),R();break}};React.useEffect(()=>{if(j>=0&&k.current){const E=k.current.children[j];E==null||E.scrollIntoView({block:"nearest"})}},[j]);const R=()=>{h(""),f([]),b(-1),p(!1),a("")},v=E=>{h(E),p(!lodashEs.isEmpty(E)),c(!0),S(E)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:E=>x(E.target.value),children:lodashEs.map(n,E=>jsxRuntime.jsx("option",{value:E.key,children:E.name},E.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:m,onChange:E=>v(E.target.value),onKeyDown:w,placeholder:r(`Search ${C??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:m&&jsxRuntime.jsx("button",{onClick:R,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||d&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):d&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',m,'"']}):jsxRuntime.jsx("ul",{ref:k,children:lodashEs.map(g==null?void 0:g.slice(0,20),(E,y)=>jsxRuntime.jsxs("li",{onClick:()=>A(E),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(E.id)?"bg-blue-200":y===j?"bg-gray-100":"hover:bg-gray-100"}`,children:[E.name," ",E.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",E.slug," )"]})]},E.id))})})]})},LinkField=({schema:o,formData:n,onChange:a,name:r})=>{const{t:l}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,p=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(p)?"url":i;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[(o==null?void 0:o.title)??"Link",jsxRuntime.jsx(DataBindingSelector,{schema:o,onChange:x=>{console.log("value",n,x),a({...n,href:x,...u==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:x=>a({...n,type:x.target.value}),children:lodashEs.map([...lodashEs.isEmpty(p)?[]:[{const:"pageType",title:l("Goto Page")}],{const:"url",title:l("Open URL")},{const:"email",title:l("Compose Email")},{const:"telephone",title:l("Call Phone")},{const:"scroll",title:l("Scroll to element")}],x=>jsxRuntime.jsx("option",{value:x.const,children:x.title},x.const))}),u==="pageType"&&!lodashEs.isEmpty(p)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:p,onChange:x=>a({...n,href:x})}):null,jsxRuntime.jsx("input",{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:x=>a({...n,href:x.target.value}),placeholder:l(i==="url"?"Enter URL":i==="scroll"?"#ElementID":"Enter details")}),u==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{id:`root.${r}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:l("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{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:r,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:r,onChange:l,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const m=document.createElement("style");return m.id="rte-modal-styles",m.innerHTML=`
60
60
  /* Ensure the NestedPathSelector popover appears above the dialog */
61
61
  .rte-path-selector + [data-radix-popper-content-wrapper],
62
62
  [data-radix-popper-content-wrapper] {
package/dist/core.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var V = Object.defineProperty;
2
2
  var F = (o, r, n) => r in o ? V(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var H = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
3
+ var U = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
- import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
7
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isUndefined, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
@@ -285,7 +285,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
285
285
  });
286
286
  class PubSub {
287
287
  constructor() {
288
- H(this, "subscribers", /* @__PURE__ */ new Map());
288
+ U(this, "subscribers", /* @__PURE__ */ new Map());
289
289
  }
290
290
  subscribe(r, n) {
291
291
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -574,7 +574,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
574
574
  status: "idle",
575
575
  props: {},
576
576
  error: void 0
577
- }), i = useBuilderProp("getBlockAsyncProps", async (g) => ({})), c = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r))]), p = get(a, "status"), u = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && !isEmpty(r);
577
+ }), i = useBuilderProp("getBlockAsyncProps", async (g) => ({})), c = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), p = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), u = (o == null ? void 0 : o._type) !== "Repeater" && !isUndefined(r);
578
578
  return useEffect(() => {
579
579
  if (o) {
580
580
  if (isFunction(n)) {
@@ -585,20 +585,20 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
585
585
  l((h) => ({ ...h, status: "loaded", props: g }));
586
586
  return;
587
587
  }
588
- !u && !m || (l((g) => ({ ...g, status: "loading", props: {} })), i({ block: o }).then((g = {}) => {
589
- console.log("Returned Props", u, g), u ? (c((h) => ({
588
+ !p && !u || (l((g) => ({ ...g, status: "loading", props: {} })), i({ block: o }).then((g = {}) => {
589
+ p ? (c((h) => ({
590
590
  ...h,
591
- [o._id]: { status: "loaded", props: isArray(g) ? g : {}, repeaterItems: o.repeaterItems }
591
+ [o._id]: { status: "loaded", props: isArray(g) ? g : [], repeaterItems: o.repeaterItems }
592
592
  })), l((h) => ({ ...h, status: "loaded" }))) : l((h) => ({ ...h, status: "loaded", props: isObject(g) ? g : {} }));
593
593
  }).catch((g) => {
594
- u ? (c((h) => ({
594
+ p ? (c((h) => ({
595
595
  ...h,
596
- [o._id]: { status: "error", error: g, props: {} }
596
+ [o._id]: { status: "error", error: g, props: [] }
597
597
  })), l((h) => ({ ...h, status: "error", error: g }))) : l((h) => ({ ...h, status: "error", error: g, props: {} }));
598
598
  }));
599
599
  }
600
- }, [o == null ? void 0 : o._id, d, u, m, n]), {
601
- $loading: p === "loading",
600
+ }, [o == null ? void 0 : o._id, d, p, u, n]), {
601
+ $loading: get(a, "status") === "loading",
602
602
  ...o ? get(a, "props", {}) : {}
603
603
  };
604
604
  }, chaiBuilderPropsAtom = atom(null);
@@ -2839,7 +2839,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2839
2839
  pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
2840
2840
  } else if (c != null && c.getAttribute("data-block-id")) {
2841
2841
  const d = c.getAttribute("data-block-id");
2842
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, { blockId: d === "canvas" ? [] : [d] });
2842
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, d === "canvas" ? [] : [d]);
2843
2843
  }
2844
2844
  r(), n.current = (/* @__PURE__ */ new Date()).getTime();
2845
2845
  },
@@ -3022,17 +3022,17 @@ class Content extends Component {
3022
3022
  class Frame extends Component {
3023
3023
  constructor(n, a) {
3024
3024
  super(n, a);
3025
- H(this, "setRef", (n) => {
3025
+ U(this, "setRef", (n) => {
3026
3026
  this.nodeRef.current = n;
3027
3027
  const { forwardedRef: a } = this.props;
3028
3028
  typeof a == "function" ? a(n) : a && (a.current = n);
3029
3029
  });
3030
- H(this, "handleLoad", () => {
3030
+ U(this, "handleLoad", () => {
3031
3031
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3032
3032
  });
3033
3033
  // In certain situations on a cold cache DOMContentLoaded never gets called
3034
3034
  // fallback to an interval to check if that's the case
3035
- H(this, "loadCheck", () => setInterval(() => {
3035
+ U(this, "loadCheck", () => setInterval(() => {
3036
3036
  this.handleLoad();
3037
3037
  }, 500));
3038
3038
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3069,7 +3069,7 @@ class Frame extends Component {
3069
3069
  return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3070
3070
  }
3071
3071
  }
3072
- H(Frame, "defaultProps", {
3072
+ U(Frame, "defaultProps", {
3073
3073
  style: {},
3074
3074
  head: null,
3075
3075
  children: void 0,
@@ -3697,13 +3697,11 @@ const CanvasEventsWatcher = () => {
3697
3697
  }
3698
3698
  }, 100);
3699
3699
  }, [a, i, n, r]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
3700
- if (!d) return;
3701
- const { blockId: p } = d;
3702
- i.includes(p) || c == null || c.closeAll(), o([p]);
3700
+ d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
3703
3701
  }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
3704
3702
  if (!d) return;
3705
3703
  const { blockId: p, styleId: u, styleProp: m } = d;
3706
- p && (i.includes(p) || c == null || c.closeAll(), n([{ id: u, prop: m, blockId: p }]), o([p]));
3704
+ p && (includes(i, p) || c == null || c.closeAll(), n([{ id: u, prop: m, blockId: p }]), o([p]));
3707
3705
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
3708
3706
  l(), o([]), n([]);
3709
3707
  }), null;
@@ -9654,13 +9652,13 @@ const FEATURE_TOGGLES = {
9654
9652
  }, I = (R) => {
9655
9653
  var $;
9656
9654
  if (isSelfAtom(B, R)) {
9657
- const U = h(R);
9658
- if (!isAtomStateInitialized(U))
9655
+ const H = h(R);
9656
+ if (!isAtomStateInitialized(H))
9659
9657
  if (hasInitialValue(R))
9660
9658
  setAtomStateValueOrPromise(R, R.init, h);
9661
9659
  else
9662
9660
  throw new Error("no atom init");
9663
- return returnAtomValue(U);
9661
+ return returnAtomValue(H);
9664
9662
  }
9665
9663
  const M = y(R);
9666
9664
  try {
@@ -1,3 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),u=require("lodash-es"),x=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 r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{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:f.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,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(C,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",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},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:d}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return u.isEmpty(u.get(p,"href"))?m:d?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:u.get(p,"href")||"/",target:u.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.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"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.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{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.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}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:x.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.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"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,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"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...d,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:x.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"},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},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,d=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:d,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.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"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.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"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.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"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.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"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:d}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:d})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:d})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.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},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?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 - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:x.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.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"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={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},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(C,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(C,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(C,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(C,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&u.isEmpty(r)?i.jsx(C,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(ue,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(de,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const I=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(u.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:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.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"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return u.isEmpty(t)?i.jsx(C,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.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"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&u.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},Ce={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.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"},xe=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(u.get(s,"className",""),r);return!t&&u.isEmpty(s==null?void 0:s.className)?i.jsx(C,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.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"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.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"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return u.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.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
- 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"},ve=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?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:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:x.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},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"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[u.get(r,"className",""),u.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?u.get(S,["MEDIUM",n||s],""):"",a?u.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...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"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:x.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]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[u.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:x.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}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=I(r,"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,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.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"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",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},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},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}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=u.get(l,"autoplay",!1),r=u.get(l,"controls",!1),s=u.get(l,"loop",!1),n=t||u.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,d=t?"autoplay=1":"";return d+=s?`&loop=1&playlist=${c}`:"",d+=n?"&mute=1&muted=1":"",d+=r?"&controls=1":"&controls=0",`${p}?${d}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...u.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:u.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...u.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...u.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const d=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!u.isEmpty(y.url)&&!u.isEmpty(y.width));d.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=u.get(r,"autoplay",!1)||u.get(r,"muted",!0);return(c||!u.isEmpty(d))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(d),controls:u.get(r,"controls",!1),autoPlay:u.get(r,"autoplay",!1),loop:u.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},d.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=({children:e,tag:l,blockProps:t,styles:r,inBuilder:s,$loading:n})=>{let a=e;return u.isEmpty(a)&&s&&(a=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5",children:"No items found"})),h.createElement(l,{...t,...r},n?Array.from({length:2}).map((c,p)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},p)):a)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Items",type:"string",binding:"array",default:"",ui:{"ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r})=>{let s="li";switch(r){case"ul":s="li";break;case"ol":s="li";break;default:s="div"}return h.createElement(s,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,Ce),o.registerChaiBlock(xe,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(ve,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),u=require("lodash-es"),x=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 r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{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:f.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,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(C,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",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},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:d}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return u.isEmpty(u.get(p,"href"))?m:d?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:u.get(p,"href")||"/",target:u.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.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"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.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{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.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}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:x.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.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"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,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"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...d,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:x.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"},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},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,d=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:d,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.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"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.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"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.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"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.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"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:d}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:d})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:d})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.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},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?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 - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:x.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.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"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={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},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(C,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(C,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(C,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(C,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&u.isEmpty(r)?i.jsx(C,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(ue,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(de,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const I=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(u.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:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.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"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return u.isEmpty(t)?i.jsx(C,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.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"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&u.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},Ce={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.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"},xe=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(u.get(s,"className",""),r);return!t&&u.isEmpty(s==null?void 0:s.className)?i.jsx(C,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.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"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.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"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return u.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.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. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus 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"},ve=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?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:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:x.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},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"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[u.get(r,"className",""),u.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?u.get(S,["MEDIUM",n||s],""):"",a?u.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...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"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:x.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]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[u.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:x.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}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=I(r,"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,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.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"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",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},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},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}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=u.get(l,"autoplay",!1),r=u.get(l,"controls",!1),s=u.get(l,"loop",!1),n=t||u.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,d=t?"autoplay=1":"";return d+=s?`&loop=1&playlist=${c}`:"",d+=n?"&mute=1&muted=1":"",d+=r?"&controls=1":"&controls=0",`${p}?${d}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...u.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:u.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...u.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...u.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const d=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!u.isEmpty(y.url)&&!u.isEmpty(y.width));d.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=u.get(r,"autoplay",!1)||u.get(r,"muted",!0);return(c||!u.isEmpty(d))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(d),controls:u.get(r,"controls",!1),autoPlay:u.get(r,"autoplay",!1),loop:u.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},d.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=({children:e,tag:l,blockProps:t,styles:r,inBuilder:s,$loading:n})=>{let a=e;return u.isEmpty(a)&&s&&(a=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5",children:"No items found"})),h.createElement(l,{...t,...r},n?Array.from({length:2}).map((c,p)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},p)):a)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Items",type:"string",binding:"array",default:"",ui:{"ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r})=>{let s="li";switch(r){case"ul":s="li";break;case"ol":s="li";break;default:s="div"}return h.createElement(s,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,Ce),o.registerChaiBlock(xe,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(ve,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
@@ -1301,9 +1301,7 @@ const A = (e, ...o) => ({
1301
1301
  content: {
1302
1302
  type: "string",
1303
1303
  title: "Content",
1304
- default: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.
1305
- Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus
1306
- nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.`,
1304
+ default: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",
1307
1305
  ui: { "ui:widget": "textarea", "ui:autosize": !0, "ui:rows": 5 }
1308
1306
  }
1309
1307
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "2.2.20",
8
+ "version": "2.2.22",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",