@chaibuilder/sdk 2.2.32 → 2.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -3
- package/dist/core.js +13 -7
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +442 -344
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -11,7 +11,7 @@ import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultS
|
|
|
11
11
|
import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
|
|
12
12
|
import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
|
|
13
13
|
import { B as Button, Z as DropdownMenu, ab as DropdownMenuTrigger, $ as DropdownMenuContent, a1 as DropdownMenuItem, c as cn$1, ay as Skeleton, e as Alert, f as AlertDescription, af as Input$1, P as Dialog, Y as DialogTrigger, R as DialogContent, ah as Popover, aG as Tooltip, aJ as TooltipTrigger, ak as PopoverTrigger, aH as TooltipContent, aj as PopoverContent, G as Command, I as CommandInput, J as CommandList, K as CommandEmpty, L as CommandGroup, M as CommandItem, U as DialogHeader, X as DialogTitle, v as Badge, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, a2 as DropdownMenuLabel, a6 as DropdownMenuSeparator, _ as DropdownMenuCheckboxItem, ac as HoverCard, ae as HoverCardTrigger, ad as HoverCardContent, aF as Textarea, A as Accordion, C as Card, E as CardHeader, z as CardDescription, y as CardContent, ag as Label, D as CardFooter, al as ScrollArea, aB as Tabs, aD as TabsList, aE as TabsTrigger, aC as TabsContent, h as AlertDialog, r as AlertDialogTrigger, k as AlertDialogContent, n as AlertDialogHeader, q as AlertDialogTitle, l as AlertDialogDescription, m as AlertDialogFooter, j as AlertDialogCancel, i as AlertDialogAction, aA as Switch, s as Avatar, an as Separator, aI as TooltipProvider, ao as Sheet, aq as SheetContent, at as SheetHeader, aw as SheetTitle, az as Toaster } from "./sooner-H65duPYc.js";
|
|
14
|
-
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye,
|
|
14
|
+
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
15
15
|
import clsx$1, { clsx } from "clsx";
|
|
16
16
|
import { twMerge } from "tailwind-merge";
|
|
17
17
|
import TreeModel from "tree-model";
|
|
@@ -2454,6 +2454,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2454
2454
|
), c = useCallback(
|
|
2455
2455
|
async (d, p = !1) => {
|
|
2456
2456
|
try {
|
|
2457
|
+
if (isEmpty(d)) return;
|
|
2457
2458
|
r(d), a([]);
|
|
2458
2459
|
const u = {
|
|
2459
2460
|
_chai_copied_blocks: d.flatMap((g) => {
|
|
@@ -2482,7 +2483,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2482
2483
|
toast.error("Failed to copy blocks to clipboard"), console.error("Failed to copy blocks to clipboard:", u);
|
|
2483
2484
|
}
|
|
2484
2485
|
},
|
|
2485
|
-
[r, a]
|
|
2486
|
+
[r, a, o]
|
|
2486
2487
|
);
|
|
2487
2488
|
return [n, c, i];
|
|
2488
2489
|
}, useCopyToClipboard = () => {
|
|
@@ -3097,14 +3098,19 @@ H(Frame, "defaultProps", {
|
|
|
3097
3098
|
});
|
|
3098
3099
|
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
|
|
3099
3100
|
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
|
|
3100
|
-
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
|
|
3101
|
+
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
|
|
3102
|
+
"ctrl+c,command+c",
|
|
3103
|
+
() => u(n),
|
|
3104
|
+
{ ...m, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3105
|
+
[n, u]
|
|
3106
|
+
), useHotkeys(
|
|
3101
3107
|
"ctrl+v,command+v",
|
|
3102
3108
|
() => {
|
|
3103
3109
|
g(n[0]) && h(n);
|
|
3104
3110
|
},
|
|
3105
|
-
{ ...m, preventDefault: !0 },
|
|
3111
|
+
{ ...m, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3106
3112
|
[n, g, h]
|
|
3107
|
-
), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
|
|
3113
|
+
), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, enabled: !isEmpty(n), preventDefault: !0 }, [
|
|
3108
3114
|
n,
|
|
3109
3115
|
i
|
|
3110
3116
|
]), useHotkeys(
|
|
@@ -8032,14 +8038,14 @@ const Input = ({ node: o }) => {
|
|
|
8032
8038
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "h-fit p-1", onClick: () => {
|
|
8033
8039
|
var o;
|
|
8034
8040
|
return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.openAll();
|
|
8035
|
-
}, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(
|
|
8041
|
+
}, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(ChevronsUpDown, { size: 14 }) }) }),
|
|
8036
8042
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Expand all") })
|
|
8037
8043
|
] }),
|
|
8038
8044
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8039
8045
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "h-fit p-1", onClick: () => {
|
|
8040
8046
|
var o;
|
|
8041
8047
|
return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.closeAll();
|
|
8042
|
-
}, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(
|
|
8048
|
+
}, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(ChevronsDownUp, { size: 14 }) }) }),
|
|
8043
8049
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Collapse all") })
|
|
8044
8050
|
] })
|
|
8045
8051
|
] }),
|
package/dist/web-blocks.cjs
CHANGED
|
@@ -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"),C=require("lucide-react");function I(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=I(k),x=({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(x,{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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch 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"}}}}),i18nProps:["htmlCode"]},$=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:C.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(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,"}],...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:C.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(x,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&u.isEmpty(r)?i.jsx(x,{}):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(de,{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(ue,{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 v=(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=v(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",{...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(x,{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)},xe={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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Ce=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(x,{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}})},Pe={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"},we=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)},ve={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"},Ie=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:C.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:C.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: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",...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=v(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}}},P=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,w=/(?: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(P.test(e)){const a=e.match(P);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(w.test(e)){const a=e.match(w);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=e=>{const{children:l,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=l;return u.isEmpty(c)&&n&&(c=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),t==="none"?a&&n?Array.from({length:2}).map((p,d)=>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"})]},d)):c:h.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,d)=>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"})]},d)):c)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderMode:"live",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:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["none","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,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?h.createElement(n,{...l,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):h.createElement(n,{...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(we,ve),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(Se,Pe),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(Ie,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"),y=require("@radix-ui/react-icons"),u=require("lodash-es"),C=require("lucide-react");function I(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 g=I(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,L=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})`}),g.createElement(n,{...o,...a,style:p},c)},j={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,h=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},h);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:y.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch 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:y.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,g.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):g.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:y.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"}}}}),i18nProps:["htmlCode"]},A=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}})},$={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:y.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})`}),g.createElement("div",{...o,...t,style:s})},z={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"}}}})},q=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:y.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"]},O=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]})},V={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:y.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 o={type:"text",autocomplete:"on"};return e?["text","password","number","hidden","range","color","date","time"].includes(e)?{type:e,autocomplete:"on"}:e==="email"?{type:"email",autocomplete:"email"}:e==="tel"?{type:"tel",autocomplete:"tel"}:e==="url"?{type:"url",autocomplete:"url"}:{off:{type:"text",autocomplete:"off"},on:{type:"text",autocomplete:"on"},name:{type:"text",autocomplete:"name"},"honorific-prefix":{type:"text",autocomplete:"honorific-prefix"},"given-name":{type:"text",autocomplete:"given-name"},"additional-name":{type:"text",autocomplete:"additional-name"},"family-name":{type:"text",autocomplete:"family-name"},"honorific-suffix":{type:"text",autocomplete:"honorific-suffix"},nickname:{type:"text",autocomplete:"nickname"},email:{type:"email",autocomplete:"email"},tel:{type:"tel",autocomplete:"tel"},"tel-country-code":{type:"tel",autocomplete:"tel-country-code"},"tel-national":{type:"tel",autocomplete:"tel-national"},"tel-area-code":{type:"tel",autocomplete:"tel-area-code"},"tel-local":{type:"tel",autocomplete:"tel-local"},"tel-extension":{type:"tel",autocomplete:"tel-extension"},"street-address":{type:"text",autocomplete:"street-address"},"address-line1":{type:"text",autocomplete:"address-line1"},"address-line2":{type:"text",autocomplete:"address-line2"},"address-line3":{type:"text",autocomplete:"address-line3"},"address-level1":{type:"text",autocomplete:"address-level1"},"address-level2":{type:"text",autocomplete:"address-level2"},"address-level3":{type:"text",autocomplete:"address-level3"},"address-level4":{type:"text",autocomplete:"address-level4"},country:{type:"text",autocomplete:"country"},"country-name":{type:"text",autocomplete:"country-name"},"postal-code":{type:"text",autocomplete:"postal-code"},"cc-name":{type:"text",autocomplete:"cc-name"},"cc-given-name":{type:"text",autocomplete:"cc-given-name"},"cc-additional-name":{type:"text",autocomplete:"cc-additional-name"},"cc-family-name":{type:"text",autocomplete:"cc-family-name"},"cc-number":{type:"text",autocomplete:"cc-number"},"cc-exp":{type:"text",autocomplete:"cc-exp"},"cc-exp-month":{type:"number",autocomplete:"cc-exp-month"},"cc-exp-year":{type:"number",autocomplete:"cc-exp-year"},"cc-csc":{type:"text",autocomplete:"cc-csc"},"cc-type":{type:"text",autocomplete:"cc-type"},bday:{type:"date",autocomplete:"bday"},"bday-day":{type:"number",autocomplete:"bday-day"},"bday-month":{type:"number",autocomplete:"bday-month"},"bday-year":{type:"number",autocomplete:"bday-year"},username:{type:"text",autocomplete:"username"},"new-password":{type:"password",autocomplete:"new-password"},"current-password":{type:"password",autocomplete:"current-password"},"one-time-code":{type:"text",autocomplete:"one-time-code"},"transaction-currency":{type:"text",autocomplete:"transaction-currency"},"transaction-amount":{type:"number",autocomplete:"transaction-amount"},url:{type:"url",autocomplete:"url"},photo:{type:"url",autocomplete:"photo"},sex:{type:"text",autocomplete:"sex"},"organization-title":{type:"text",autocomplete:"organization-title"},organization:{type:"text",autocomplete:"organization"},language:{type:"text",autocomplete:"language"}}[e]||o:o},X=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d}=e,b=f.generateUUID(),{type:h,autocomplete:m}=W(d);return c?i.jsxs("div",{...n,...o,children:[c&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("input",{name:t,...a,id:b,type:h,placeholder:s,required:p,autoComplete:m})]}):i.jsx("input",{id:b,name:t,...o,...a,...n,type:h,placeholder:s,required:p,autoComplete:m})},J={type:"Input",label:"web_blocks.input",category:"core",icon:y.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},inputType:{type:"string",title:"Type",default:"email",oneOf:[{const:"text",title:"Text"},{const:"email",title:"Email"},{const:"password",title:"Password"},{const:"number",title:"Number"},{const:"tel",title:"Telephone"},{const:"hidden",title:"Hidden"},{const:"range",title:"Range"},{const:"color",title:"Color"},{const:"date",title:"Date"},{const:"time",title:"Time"},{const:"url",title:"URL"},{const:"name",title:"Name"},{const:"tel-country-code",title:"Telephone Country Code"},{const:"tel-national",title:"Telephone National"},{const:"tel-area-code",title:"Telephone Area Code"},{const:"tel-local",title:"Telephone Local"},{const:"tel-extension",title:"Telephone Extension"},{const:"street-address",title:"Street Address"},{const:"address-line1",title:"Address Line 1"},{const:"address-line2",title:"Address Line 2"},{const:"address-line3",title:"Address Line 3"},{const:"address-level1",title:"Address Level 1"},{const:"address-level2",title:"Address Level 2"},{const:"address-level3",title:"Address Level 3"},{const:"address-level4",title:"Address Level 4"},{const:"country",title:"Country"},{const:"country-name",title:"Country Name"},{const:"postal-code",title:"Postal Code"},{const:"cc-name",title:"Credit Card Name"},{const:"cc-number",title:"Credit Card Number"},{const:"cc-exp",title:"Credit Card Expiry"},{const:"cc-exp-month",title:"Credit Card Expiry Month"},{const:"cc-exp-year",title:"Credit Card Expiry Year"},{const:"cc-csc",title:"Credit Card CSC"},{const:"cc-type",title:"Credit Card Type"},{const:"bday",title:"Birthday"},{const:"bday-day",title:"Birthday Day"},{const:"bday-month",title:"Birthday Month"},{const:"bday-year",title:"Birthday Year"},{const:"username",title:"Username"},{const:"new-password",title:"New Password"},{const:"current-password",title:"Current Password"},{const:"one-time-code",title:"One Time Code"},{const:"transaction-currency",title:"Transaction Currency"},{const:"transaction-amount",title:"Transaction Amount"},{const:"url",title:"URL"},{const:"photo",title:"Photo"},{const:"sex",title:"Sex"},{const:"organization-title",title:"Organization Title"},{const:"organization",title:"Organization"},{const:"language",title:"Language"}]},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},Q=e=>{const{blockProps:o,content:t,styles:r,children:s}=e,n={...r,...o};return s?g.createElement("label",n,s):g.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Z={type:"Label",label:"Label",category:"core",icon:y.LetterCaseToggleIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},K=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})},ee={type:"Radio",label:"web_blocks.radio",category:"core",icon:y.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"]},te=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:b}=e,h=f.generateUUID();return p?i.jsxs("div",{...n,...o,children:[p&&i.jsx("label",{htmlFor:h,children:r}),i.jsxs("select",{...a,id:h,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:h,...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))]})},oe={type:"Select",label:"web_blocks.select",category:"core",icon:y.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})},re={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:y.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"]},se=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."})]}):g.createElement("span",{...o},r)},ie={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"}}}})},ne=e=>{const{blockProps:o,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?g.createElement(s,{...t,...o},n):g.createElement(s,{...t,...o,dangerouslySetInnerHTML:{__html:r}})},ae={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:y.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"},ce=e=>{const{blockProps:o,styles:t}=e;return k.createElement("br",{...o,...t})},pe={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},de=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,{})},me=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("tbody",{...o,...r},t):i.jsx(x,{})},ye=e=>{const{blockProps:o,children:t,styles:r}=e;return t?k.createElement("tr",{...o,...r},t):i.jsx(x,{})},ge=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(de,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:y.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:y.BorderTopIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableHead")});l.registerChaiBlock(me,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:y.BorderAllIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableBody")});l.registerChaiBlock(ye,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:y.ViewHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:B("TableRow")});l.registerChaiBlock(ge,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:y.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 v=(e,...o)=>({...e,className:f.cn(e.className,...o)}),he=e=>{const{blockProps:o,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=v(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 g.createElement("span",{...o,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},be={type:"Icon",label:"web_blocks.icon",category:"core",icon:y.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"}}})},fe=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})]})},ke={type:"Image",description:"A image component",label:"Image",category:"core",icon:y.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"]},xe=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)},Ce={type:"Link",description:"A link component",label:"Link",category:"core",icon:y.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Be=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}):g.createElement(n||(r==="list-decimal"?"ol":"ul"),{...o,...s,className:c},t)},Se={type:"List",description:"A list component",label:"List",icon:y.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"}]},we=e=>{const{blockProps:o,content:t,styles:r,children:s,tag:n}=e;return s?g.createElement(n||"li",{...r,...o},s):g.createElement(n||"li",{...r,...o,dangerouslySetInnerHTML:{__html:t}})},Pe={type:"ListItem",description:"A list item component",label:"List Item",icon:y.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"},ve=e=>{const{blockProps:o,styles:t,content:r}=e;return u.isNull(e.children)?g.createElement("p",{...t,...o,dangerouslySetInnerHTML:{__html:r}}):g.createElement("p",{...t,...o},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:y.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"},Le=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."})]}):g.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"}},_e=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"})})},Te={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]}}})},Ee=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})},Ne={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}}})},Re=e=>{const{blockProps:o,content:t,styles:r}=e,s=v(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}})},Me={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:y.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"]},Ae=e=>{const{blockProps:o,styles:t,content:r,children:s=null,tag:n}=e;return s?g.createElement("span",{...t,...o},s):g.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},He=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,Ue={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:y.SpaceBetweenVerticallyIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},De={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+)/,ze=(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=ze(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"})]})},Fe=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((h,m)=>parseInt(h.width)-parseInt(m.width)).filter(h=>!u.isEmpty(h.url)&&!u.isEmpty(h.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(h=>{if(!h.url||h.url.length<4||isNaN(h.width))return null;const m=`(max-width: ${h.width}px)`;return i.jsx("source",{src:h.url,media:m,type:h.type},h.url)}),"Your browser does not support the video tag.")})},Oe=e=>{const{videoSource:o}=e;return o==="Custom"?i.jsx(Fe,{...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:y.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:{...De}}}},{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"]},Ge=e=>{const{children:o,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=o;return u.isEmpty(c)&&n&&(c=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),t==="none"?a&&n?Array.from({length:2}).map((p,d)=>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"})]},d)):c:g.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,d)=>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"})]},d)):c)},Ye={type:"Repeater",label:"Repeater",icon:y.LoopIcon,group:"basic",dataProviderMode:"live",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:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["none","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"}}}})},We=({children:e,blockProps:o,styles:t,parentTag:r,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?g.createElement(n,{...o,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):g.createElement(n,{...o,...t},e)},Xe={type:"RepeaterItem",label:"Repeater Item",icon:y.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},Je=({children:e,blockProps:o,styles:t})=>g.createElement("div",{...o,...t},e),Qe={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},Ze=()=>{l.registerChaiBlock(L,j),l.registerChaiBlock(D,z),l.registerChaiBlock(_,T),l.registerChaiBlock(ne,ae),l.registerChaiBlock(ve,Ie),l.registerChaiBlock(Ae,$e),l.registerChaiBlock(Re,Me),l.registerChaiBlock(xe,Ce),l.registerChaiBlock(Be,Se),l.registerChaiBlock(we,Pe),l.registerChaiBlock(he,be),l.registerChaiBlock(fe,ke),l.registerChaiBlock(Oe,Ve),l.registerChaiBlock(R,M),l.registerChaiBlock(A,$),l.registerChaiBlock(He,Ue),l.registerChaiBlock(O,V),l.registerChaiBlock(G,Y),l.registerChaiBlock(X,J),l.registerChaiBlock(q,F),l.registerChaiBlock(K,ee),l.registerChaiBlock(te,oe),l.registerChaiBlock(le,re),l.registerChaiBlock(Q,Z),l.registerChaiBlock(ce,pe),l.registerChaiBlock(H,U),l.registerChaiBlock(se,ie),l.registerChaiBlock(Le,je),l.registerChaiBlock(Ee,Ne),l.registerChaiBlock(_e,Te),l.registerChaiBlock(E,N),l.registerChaiBlock(Ge,Ye),l.registerChaiBlock(We,Xe),l.registerChaiBlock(Je,Qe)};exports.loadWebBlocks=Ze;
|