@chaibuilder/sdk 2.2.23 → 2.2.24

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
@@ -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 C=runtime.getRegisteredChaiBlock(o._type);return m&&((E=C==null?void 0:C.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 C;const R=w||((C=p.current)==null?void 0:C.innerText);x([f],{[a]:R}),d(null),i(null),h([])},[f,x,i,h,m]),v=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:v,onClose:k,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:j,editingElement:c,onClose:k,onChange:v,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]),v=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,{...v,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,v)=>{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+v+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:v,to:S}=b.state.selection;if(v!==S)b.chain().deleteSelection().insertContent(k).run();else{const{state:w}=b,R=w.selection.from,C=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&&C!==" "&&!h(C)&&(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,v=b.value||"",S=b.selectionEnd||k;if(S>k){const _=`{{${x}}}`,{text:E}=g(v,k,_),y=v.slice(0,k)+E+v.slice(S);n(y,{},a);return}const w=`{{${x}}}`,{text:R}=g(v,k,w),C=v.slice(0,k)+R+v.slice(k);n(C,{},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),v=(_=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("")},C=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=>C(E.target.value),onKeyDown:w,placeholder:r(`Search ${v??""}`),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||l?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 C=runtime.getRegisteredChaiBlock(o._type);return m&&((E=C==null?void 0:C.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 C;const R=w||((C=p.current)==null?void 0:C.innerText);x([f],{[a]:R}),d(null),i(null),h([])},[f,x,i,h,m]),v=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:v,onClose:k,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:j,editingElement:c,onClose:k,onChange:v,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]),v=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,{...v,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,v)=>{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+v+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:v,to:S}=b.state.selection;if(v!==S)b.chain().deleteSelection().insertContent(k).run();else{const{state:w}=b,R=w.selection.from,C=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&&C!==" "&&!h(C)&&(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,v=b.value||"",S=b.selectionEnd||k;if(S>k){const _=`{{${x}}}`,{text:E}=g(v,k,_),y=v.slice(0,k)+E+v.slice(S);n(y,{},a);return}const w=`{{${x}}}`,{text:R}=g(v,k,w),C=v.slice(0,k)+R+v.slice(k);n(C,{},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),v=(_=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("")},C=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=>C(E.target.value),onKeyDown:w,placeholder:r(`Search ${v??""}`),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
@@ -3213,7 +3213,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3213
3213
  return /* @__PURE__ */ jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
3214
3214
  }, MayBeAsyncPropsWrapper = ({ children: o, block: r }) => {
3215
3215
  const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = has(n, "dataProviderDependencies"), l = get(n, "dataProvider"), i = useAsyncProps(
3216
- a ? r : void 0,
3216
+ a || l ? r : void 0,
3217
3217
  get(n, "dataProviderDependencies"),
3218
3218
  l ?? void 0
3219
3219
  );
@@ -1 +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. 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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=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"),C=require("lucide-react");function v(e){const o=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(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const h=v(k),x=({className:e="",inBuilder:o})=>o?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:o,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(x,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...o,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",{...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",{...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.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:o,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...o,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{scripts:o,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:o}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:C.FileCode,group:"advanced",...l.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:o,styles:t}=e;return k.createElement("hr",{...t,...o})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:o,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...o,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:o,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,...o,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,...o,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.CheckboxIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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:o,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=o;o||(p=i.jsx(x,{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:C.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,"}],...l.registerChaiBlockSchema({properties:{styles:l.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:o,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,...o||{},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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:l.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:o,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,...o,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,...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.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:o,content:t,styles:r,children:s}=e,n={...r,...o};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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:o,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,...o,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,...o,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.RadiobuttonIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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:o,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,...o,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,...o,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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.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"]},le=e=>{const{blockProps:o,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,...o,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,...o,...a,...n,placeholder:s,rows:c,required:d})},oe={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:l.StylesProp(""),inputStyles:l.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:o,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",...o,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",{...o},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:o,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...o},n):h.createElement(s,{...t,...o,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",...l.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:l.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:o,styles:t}=e;return k.createElement("br",{...o,...t})},ce={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},pe=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("table",{...o,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("thead",{...o,...r},t):i.jsx(x,{})},de=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("tbody",{...o,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("tr",{...o,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:o,children:t,content:r,styles:s}=e;return!t&&u.isEmpty(r)?i.jsx(x,{}):t?k.createElement("td",{...o,...s},t):k.createElement("td",{...o,...s,dangerouslySetInnerHTML:{__html:r}})};l.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("Table")});l.registerChaiBlock(ue,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableHead")});l.registerChaiBlock(de,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableBody")});l.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableRow")});l.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.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 o=(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,o(a,"1"),o(a,"2"),o(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,...o)=>({...e,className:f.cn(e.className,...o)}),ye=e=>{const{blockProps:o,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(u.isEmpty(t))return i.jsx(x,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.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:o,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return u.isEmpty(t)?i.jsx(x,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...o,...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",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",{...o,style:c,...s,children:r}):k.createElement("span",{...o,...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,...o,...s,children:r}):k.createElement("a",{...o,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},xe={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.Link1Icon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"},Ce=e=>{const{blockProps:o,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(x,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...o,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.RowsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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:o,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...o},s):h.createElement(n||"li",{...r,...o,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.ColumnsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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:o,styles:t,content:r}=e;return u.isNull(e.children)?h.createElement("p",{...t,...o,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...o},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.TextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",...o,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",{...o},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.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:o,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",{...o,...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:C.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",{...o,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:C.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",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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",{...o,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.CursorTextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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:o,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...o},s):h.createElement(n||"span",{...t,...o,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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,...l.registerChaiBlockSchema({properties:{styles:l.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,o)=>{const t=u.get(o,"autoplay",!1),r=u.get(o,"controls",!1),s=u.get(o,"loop",!1),n=t||u.get(o,"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:o,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(o,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(o)?`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:o,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...u.get(s,"srcsets",[])||[]];o&&typeof o=="string"&&p.push({url:o,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:o}=e;return o==="Custom"?i.jsx(ze,{...e}):o==="Youtube"||o==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",o]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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:o,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(o,{...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"}],...l.registerChaiBlockSchema({properties:{styles:l.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:o,styles:t,parentTag:r})=>{let s="li";switch(r){case"ul":s="li";break;case"ol":s="li";break;default:s="div"}return e?h.createElement(s,{...o,...t},e):i.jsx("div",{...o,className:"flex min-h-[80px] items-center justify-center bg-gray-100 text-sm text-gray-500",children:"Add block"})},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp(""),parentTag:l.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:o,styles:t})=>h.createElement("div",{...o,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{l.registerChaiBlock(j,L),l.registerChaiBlock(D,q),l.registerChaiBlock(_,T),l.registerChaiBlock(ie,ne),l.registerChaiBlock(Pe,Ie),l.registerChaiBlock(Me,$e),l.registerChaiBlock(Ne,Re),l.registerChaiBlock(ke,xe),l.registerChaiBlock(Ce,Be),l.registerChaiBlock(Se,we),l.registerChaiBlock(ye,he),l.registerChaiBlock(be,fe),l.registerChaiBlock(Fe,Ve),l.registerChaiBlock(R,M),l.registerChaiBlock($,A),l.registerChaiBlock(Ae,He),l.registerChaiBlock(V,O),l.registerChaiBlock(G,Y),l.registerChaiBlock(W,X),l.registerChaiBlock(z,F),l.registerChaiBlock(Z,K),l.registerChaiBlock(ee,te),l.registerChaiBlock(le,oe),l.registerChaiBlock(J,Q),l.registerChaiBlock(ae,ce),l.registerChaiBlock(H,U),l.registerChaiBlock(re,se),l.registerChaiBlock(ve,je),l.registerChaiBlock(Te,Ee),l.registerChaiBlock(Le,_e),l.registerChaiBlock(E,N),l.registerChaiBlock(Oe,Ge),l.registerChaiBlock(Ye,We),l.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;