@chaibuilder/sdk 1.1.1 → 1.1.3

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.
Files changed (33) hide show
  1. package/dist/CanvasArea-E0Mu1Cwe.cjs +58 -0
  2. package/dist/{CanvasArea-JzBGfXSp.js → CanvasArea-K9fOlyJl.js} +585 -578
  3. package/dist/{CurrentPage-v7RxefU-.cjs → CurrentPage--5VHTFmg.cjs} +1 -1
  4. package/dist/{CurrentPage-2Hqp8dwp.js → CurrentPage-ZjBcAU3o.js} +1 -1
  5. package/dist/{Layers-1H-MUoKM.cjs → Layers-Qv1k4eqT.cjs} +1 -1
  6. package/dist/{Layers-K_1pMZK5.js → Layers-RfOxPx_V.js} +1 -1
  7. package/dist/{PagesPanel-Qt66yy3K.cjs → PagesPanel-pQjl_qzS.cjs} +1 -1
  8. package/dist/{PagesPanel-uMZT46fo.js → PagesPanel-yOrHqpUR.js} +2 -2
  9. package/dist/{ProjectPanel-nhhdOgSP.js → ProjectPanel-64NTjmau.js} +2 -2
  10. package/dist/{ProjectPanel-g92sgZ-g.cjs → ProjectPanel-U4uQPSn8.cjs} +1 -1
  11. package/dist/{Settings-pYbQsClt.js → Settings-2b17z_GV.js} +126 -128
  12. package/dist/Settings-4XckYyzK.cjs +1 -0
  13. package/dist/{SidePanels-CBkl8HgT.cjs → SidePanels-auE-bKNc.cjs} +1 -1
  14. package/dist/{SidePanels-9AjWdvVI.js → SidePanels-gNBjhSWG.js} +2 -2
  15. package/dist/{add-page-modal-eahhWw2b.cjs → add-page-modal-BREwIMPz.cjs} +1 -1
  16. package/dist/{add-page-modal-Ny4uAvWB.js → add-page-modal-OukBwf5E.js} +1 -1
  17. package/dist/core.cjs +1 -1
  18. package/dist/core.js +1 -1
  19. package/dist/{delete-page-modal-4qrgJQ0x.js → delete-page-modal-RZXdqvje.js} +1 -1
  20. package/dist/{delete-page-modal-07nDpZpj.cjs → delete-page-modal-UWn_sHLC.cjs} +1 -1
  21. package/dist/{index-aDqFUJ8v.js → index-CMHxUxre.js} +2 -2
  22. package/dist/{index-Ua5E0Syv.cjs → index-yo8mH0u8.cjs} +1 -1
  23. package/dist/{page-viewer-1Eb7ypob.js → page-viewer-PZRWwKP6.js} +2 -2
  24. package/dist/{page-viewer-X8h3FMwb.cjs → page-viewer-rPTxX-Lu.cjs} +1 -1
  25. package/dist/{project-general-setting-I4z0C7PE.cjs → project-general-setting-FVlRHFpF.cjs} +1 -1
  26. package/dist/{project-general-setting-TCl_JNdl.js → project-general-setting-UzPhnhWp.js} +1 -1
  27. package/dist/{single-page-detail-sdTzXA5i.cjs → single-page-detail-Ftozh79X.cjs} +1 -1
  28. package/dist/{single-page-detail-W5sW6771.js → single-page-detail-Jb-S30JL.js} +2 -2
  29. package/dist/studio.cjs +1 -1
  30. package/dist/studio.js +1 -1
  31. package/package.json +1 -1
  32. package/dist/CanvasArea-rC2E_4eS.cjs +0 -58
  33. package/dist/Settings-IcmgBZm9.cjs +0 -1
@@ -0,0 +1,58 @@
1
+ "use strict";var We=Object.defineProperty;var Fe=(e,t,n)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>(Fe(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./jsx-runtime-WUGKV8jN.cjs"),m=require("react"),p=require("lodash"),P=require("@radix-ui/react-icons"),o=require("./index-zkc4SQCu.cjs"),$e=require("react-i18next"),F=require("jotai"),fe=require("react-dom"),V=require("./MODIFIERS-WFzDQfiT.cjs"),J=require("./index-yo8mH0u8.cjs"),He=require("react-quill"),Ue=require("./useAddBlockByDrop-DPV32UHP.cjs"),ze=require("flagged"),Ye=require("@floating-ui/dom"),xe=require("@floating-ui/react-dom"),Ke=require("react-dnd"),Ve=require("@react-hookz/web"),Xe=require("@bobthered/tailwindcss-palette-generator"),Je=require("react-wrap-balancer"),Ze=require("tailwind-merge"),Ge=require("@chaibuilder/runtime");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("clsx");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("flat-to-nested");require("redux-undo");require("i18next");require("react-textarea-autosize");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-KMQYiBHf.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("./tailwind-config-OxLD7oFU.cjs");require("react-hotkeys-hook");require("sonner");require("lucide-react");const Qe=()=>{const{undoCount:e,redoCount:t,undo:n,redo:i}=o.useCanvasHistory();return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.jsxRuntimeExports.jsx(o.Button,{disabled:!e,size:"sm",onClick:n,className:"rounded-full",variant:"ghost",children:s.jsxRuntimeExports.jsx(P.ResetIcon,{})}),s.jsxRuntimeExports.jsx(o.Button,{disabled:!t,onClick:i,size:"sm",className:"rounded-full",variant:"ghost",children:s.jsxRuntimeExports.jsx(P.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function et(){const[e,t]=o.useDarkMode(),{t:n}=$e.useTranslation();return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.jsxRuntimeExports.jsx(o.Label,{htmlFor:"dark-mode-switch",children:n("dark_mode")}),s.jsxRuntimeExports.jsxs(o.Switch,{id:"dark-mode-switch",checked:e,onCheckedChange:()=>{t(!e)},className:`${e?"bg-violet-600":"bg-violet-300"}
2
+ relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:[s.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Use setting"}),s.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${e?"translate-x-5":"translate-x-0"}
3
+ pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})]})]})}const he=({landscape:e=!1})=>s.jsxRuntimeExports.jsxs("svg",{className:e?"rotate-90":"",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 13 13",xmlSpace:"preserve",width:13,height:13,children:[s.jsxRuntimeExports.jsx("g",{strokeWidth:0}),s.jsxRuntimeExports.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round"}),s.jsxRuntimeExports.jsx("path",{d:"M10.65 0H2.349a.851.851 0 0 0-.851.852v11.299c0 .47.382.852.851.852h8.3a.851.851 0 0 0 .851-.852V.852A.851.851 0 0 0 10.65 0zM6.599 12.466a.367.367 0 1 1 0-.735.367.367 0 0 1 0 .735zm3.9-1.267H2.5V1h8.001v10.199z",style:{fill:"#000"}})]}),ge=[{title:"Mobile (XS)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:s.jsxRuntimeExports.jsx(P.MobileIcon,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:s.jsxRuntimeExports.jsx(P.MobileIcon,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:s.jsxRuntimeExports.jsx(he,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:s.jsxRuntimeExports.jsx(he,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:s.jsxRuntimeExports.jsx(P.LaptopIcon,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:s.jsxRuntimeExports.jsx(P.DesktopIcon,{}),width:1920}],tt=({title:e,content:t,currentBreakpoint:n,breakpoint:i,width:c,icon:r,onClick:a})=>s.jsxRuntimeExports.jsxs(o.HoverCard,{children:[s.jsxRuntimeExports.jsx(o.HoverCardTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsx(o.Button,{onClick:()=>a(c),size:"sm",variant:i===n?"secondary":"ghost",children:r})}),s.jsxRuntimeExports.jsx(o.HoverCardContent,{className:"w-52 border-border",children:s.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:s.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[s.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:e}),s.jsxRuntimeExports.jsx("p",{className:"text-xs",children:t})]})})})]}),nt=()=>{const[,e,t]=o.useCanvasWidth(),[n,i]=o.useSelectedBreakpoints(),c=r=>{n.includes(r)?n.length>2&&i(n.filter(a=>a!==r)):i(a=>[...a,r])};return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[p.map(ge.filter(r=>p.includes(n,p.toUpper(r.breakpoint))),r=>m.createElement(tt,{...r,onClick:t,key:r.breakpoint,currentBreakpoint:e})),s.jsxRuntimeExports.jsxs(o.DropdownMenu,{children:[s.jsxRuntimeExports.jsx(o.DropdownMenuTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:s.jsxRuntimeExports.jsx(P.DotsVerticalIcon,{className:"scale-90 transform"})})}),s.jsxRuntimeExports.jsxs(o.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[s.jsxRuntimeExports.jsx(o.DropdownMenuLabel,{children:"Breakpoints"}),s.jsxRuntimeExports.jsx(o.DropdownMenuSeparator,{}),p.map(ge,r=>s.jsxRuntimeExports.jsx(o.DropdownMenuCheckboxItem,{disabled:r.breakpoint==="xs",onCheckedChange:()=>c(p.toUpper(r.breakpoint)),checked:p.includes(n,p.toUpper(r.breakpoint)),children:r.title},r.breakpoint))]})]})]})},st=()=>{const[e]=o.useSetAllBlocks(),{createSnapshot:t}=o.useCanvasHistory(),[,n]=o.useSelectedBlockIds(),[,i]=o.useSelectedStylingBlocks(),c=m.useCallback(()=>{e([]),n([]),i([]),t()},[e,t]);return s.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:s.jsxRuntimeExports.jsxs(o.AlertDialog,{children:[s.jsxRuntimeExports.jsx(o.AlertDialogTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsxs(o.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[s.jsxRuntimeExports.jsx(P.EraserIcon,{})," Clear"]})}),s.jsxRuntimeExports.jsxs(o.AlertDialogContent,{className:"border-border",children:[s.jsxRuntimeExports.jsxs(o.AlertDialogHeader,{children:[s.jsxRuntimeExports.jsx(o.AlertDialogTitle,{children:"Clear whole canvas?"}),s.jsxRuntimeExports.jsx(o.AlertDialogDescription,{children:"Are you sure you want to clear the whole canvas?"})]}),s.jsxRuntimeExports.jsxs(o.AlertDialogFooter,{children:[s.jsxRuntimeExports.jsx(o.AlertDialogCancel,{children:"Cancel"}),s.jsxRuntimeExports.jsx(o.AlertDialogAction,{onClick:c,children:"Yes"})]})]})]})})},rt=()=>{const e=o.useFeatureSupport("darkMode",!1),[t]=o.useCanvasZoom();return s.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b bg-background/70 px-2",children:[s.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[e?s.jsxRuntimeExports.jsxs(s.jsxRuntimeExports.Fragment,{children:[s.jsxRuntimeExports.jsx(et,{}),s.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"})]}):null,s.jsxRuntimeExports.jsx(nt,{}),s.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),s.jsxRuntimeExports.jsxs("div",{className:"flex w-12 items-center justify-center gap-x-1 space-x-0 font-medium",children:[s.jsxRuntimeExports.jsx(P.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",s.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[p.round(t,0),"%"]})]}),s.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),s.jsxRuntimeExports.jsx(Qe,{})]}),s.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[s.jsxRuntimeExports.jsx(o.Separator,{orientation:"vertical"}),s.jsxRuntimeExports.jsx(st,{})]})]})},ot=`<!doctype html>
4
+ <html class="scroll-smooth h-full overflow-y-auto">
5
+ <head>
6
+ <meta charset="UTF-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <script src="https://old.chaibuilder.com/offline/tailwind.cdn.js"><\/script>
9
+ <style>
10
+ html { height: 100%; overflow:auto; }
11
+ body { height: 100%; }
12
+ .air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
13
+ .air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
14
+ body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
15
+ -moz-user-select: none;-ms-user-select: none; user-select: none; }
16
+ html{
17
+ -ms-overflow-style: none; /* IE and Edge */
18
+ scrollbar-width: none; /* Firefox */
19
+ }
20
+ /** IMPORTANT: Make fields content editable in SAFARI */
21
+ [contenteditable] {-webkit-user-select: text;user-select: text;}
22
+
23
+ html::-webkit-scrollbar { width: 0 !important }
24
+ .aspect-auto{aspect-ratio: auto;}
25
+ .aspect-square{aspect-ratio: 1/1;}
26
+ .aspect-video{aspect-ratio: 16/9;}
27
+ .dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
28
+ .dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
29
+ a{ pointer-events: none !important; }
30
+ [contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
31
+ [contenteditable="true"] {
32
+ outline: none;
33
+ box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
34
+ -webkit-user-select: text;
35
+ -moz-user-select: text;
36
+ user-select: text;
37
+ }
38
+ </style>
39
+ <style id="hidden-blocks"></style>
40
+ <style id="selected-block"></style>
41
+ <style id="selected-styling-block"></style>
42
+ <style id="highlighted-block"></style>
43
+
44
+ </head>
45
+ <body class="font-body antialiased h-full">
46
+ <div class="frame-root"></div>
47
+ <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
48
+ </body>
49
+ </html>`,it=e=>{const[t]=o.useCanvasWidth(),[,n]=o.useCanvasZoom(),[i,c]=m.useState({}),r=m.useCallback(()=>{const{width:a,height:d}=e;if(a<t){const x=parseFloat((a/t).toString());let f={};d&&(f={height:d+2*d*(1-x)}),c({transform:`scale(${x})`,transformOrigin:"top left",...f,maxWidth:"none"}),n(x*100)}else c({}),n(100)},[t,e,n]);return m.useEffect(()=>{r()},[t,e,n,r]),i};var G={exports:{}};/*
50
+ object-assign
51
+ (c) Sindre Sorhus
52
+ @license MIT
53
+ */var ne,me;function at(){if(me)return ne;me=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function c(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var a={},d=0;d<10;d++)a["_"+String.fromCharCode(d)]=d;var x=Object.getOwnPropertyNames(a).map(function(g){return a[g]});if(x.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(g){f[g]=g}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ne=c()?Object.assign:function(r,a){for(var d,x=i(r),f,g=1;g<arguments.length;g++){d=Object(arguments[g]);for(var h in d)t.call(d,h)&&(x[h]=d[h]);if(e){f=e(d);for(var b=0;b<f.length;b++)n.call(d,f[b])&&(x[f[b]]=d[f[b]])}}return x},ne}var se,ye;function de(){if(ye)return se;ye=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return se=e,se}var re,ve;function Re(){return ve||(ve=1,re=Function.call.bind(Object.prototype.hasOwnProperty)),re}var oe,je;function lt(){if(je)return oe;je=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=de(),n={},i=Re();e=function(r){var a="Warning: "+r;typeof console<"u"&&console.error(a);try{throw new Error(a)}catch{}}}function c(r,a,d,x,f){if(process.env.NODE_ENV!=="production"){for(var g in r)if(i(r,g)){var h;try{if(typeof r[g]!="function"){var b=Error((x||"React class")+": "+d+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}h=r[g](a,g,x,d,null,t)}catch(M){h=M}if(h&&!(h instanceof Error)&&e((x||"React class")+": type specification of "+d+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var R=f?f():"";e("Failed "+d+" type: "+h.message+(R??""))}}}}return c.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},oe=c,oe}var ie,be;function ct(){if(be)return ie;be=1;var e=J.reactIsExports,t=at(),n=de(),i=Re(),c=lt(),r=function(){};process.env.NODE_ENV!=="production"&&(r=function(d){var x="Warning: "+d;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function a(){return null}return ie=function(d,x){var f=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function h(l){var u=l&&(f&&l[f]||l[g]);if(typeof u=="function")return u}var b="<<anonymous>>",R={array:v("array"),bigint:v("bigint"),bool:v("boolean"),func:v("function"),number:v("number"),object:v("object"),string:v("string"),symbol:v("symbol"),any:z(),arrayOf:_,element:ee(),elementType:te(),instanceOf:A,node:qe(),objectOf:W,oneOf:N,oneOfType:Oe,shape:Pe,exact:Me};function M(l,u){return l===u?l!==0||1/l===1/u:l!==l&&u!==u}function S(l,u){this.message=l,this.data=u&&typeof u=="object"?u:{},this.stack=""}S.prototype=Error.prototype;function D(l){if(process.env.NODE_ENV!=="production")var u={},w=0;function E(C,j,k,T,I,B,L){if(T=T||b,B=B||k,L!==n){if(x){var O=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw O.name="Invariant Violation",O}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Y=T+":"+k;!u[Y]&&w<3&&(r("You are manually calling a React.PropTypes validation function for the `"+B+"` prop on `"+T+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),u[Y]=!0,w++)}}return j[k]==null?C?j[k]===null?new S("The "+I+" `"+B+"` is marked as required "+("in `"+T+"`, but its value is `null`.")):new S("The "+I+" `"+B+"` is marked as required in "+("`"+T+"`, but its value is `undefined`.")):null:l(j,k,T,I,B)}var y=E.bind(null,!1);return y.isRequired=E.bind(null,!0),y}function v(l){function u(w,E,y,C,j,k){var T=w[E],I=$(T);if(I!==l){var B=K(T);return new S("Invalid "+C+" `"+j+"` of type "+("`"+B+"` supplied to `"+y+"`, expected ")+("`"+l+"`."),{expectedType:l})}return null}return D(u)}function z(){return D(a)}function _(l){function u(w,E,y,C,j){if(typeof l!="function")return new S("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside arrayOf.");var k=w[E];if(!Array.isArray(k)){var T=$(k);return new S("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an array."))}for(var I=0;I<k.length;I++){var B=l(k,I,y,C,j+"["+I+"]",n);if(B instanceof Error)return B}return null}return D(u)}function ee(){function l(u,w,E,y,C){var j=u[w];if(!d(j)){var k=$(j);return new S("Invalid "+y+" `"+C+"` of type "+("`"+k+"` supplied to `"+E+"`, expected a single ReactElement."))}return null}return D(l)}function te(){function l(u,w,E,y,C){var j=u[w];if(!e.isValidElementType(j)){var k=$(j);return new S("Invalid "+y+" `"+C+"` of type "+("`"+k+"` supplied to `"+E+"`, expected a single ReactElement type."))}return null}return D(l)}function A(l){function u(w,E,y,C,j){if(!(w[E]instanceof l)){var k=l.name||b,T=Ne(w[E]);return new S("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected ")+("instance of `"+k+"`."))}return null}return D(u)}function N(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&(arguments.length>1?r("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):r("Invalid argument supplied to oneOf, expected an array.")),a;function u(w,E,y,C,j){for(var k=w[E],T=0;T<l.length;T++)if(M(k,l[T]))return null;var I=JSON.stringify(l,function(L,O){var Y=K(O);return Y==="symbol"?String(O):O});return new S("Invalid "+C+" `"+j+"` of value `"+String(k)+"` "+("supplied to `"+y+"`, expected one of "+I+"."))}return D(u)}function W(l){function u(w,E,y,C,j){if(typeof l!="function")return new S("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside objectOf.");var k=w[E],T=$(k);if(T!=="object")return new S("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an object."));for(var I in k)if(i(k,I)){var B=l(k,I,y,C,j+"."+I,n);if(B instanceof Error)return B}return null}return D(u)}function Oe(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var u=0;u<l.length;u++){var w=l[u];if(typeof w!="function")return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+_e(w)+" at index "+u+"."),a}function E(y,C,j,k,T){for(var I=[],B=0;B<l.length;B++){var L=l[B],O=L(y,C,j,k,T,n);if(O==null)return null;O.data&&i(O.data,"expectedType")&&I.push(O.data.expectedType)}var Y=I.length>0?", expected one of type ["+I.join(", ")+"]":"";return new S("Invalid "+k+" `"+T+"` supplied to "+("`"+j+"`"+Y+"."))}return D(E)}function qe(){function l(u,w,E,y,C){return Z(u[w])?null:new S("Invalid "+y+" `"+C+"` supplied to "+("`"+E+"`, expected a ReactNode."))}return D(l)}function pe(l,u,w,E,y){return new S((l||"React class")+": "+u+" type `"+w+"."+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+y+"`.")}function Pe(l){function u(w,E,y,C,j){var k=w[E],T=$(k);if(T!=="object")return new S("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));for(var I in l){var B=l[I];if(typeof B!="function")return pe(y,C,j,I,K(B));var L=B(k,I,y,C,j+"."+I,n);if(L)return L}return null}return D(u)}function Me(l){function u(w,E,y,C,j){var k=w[E],T=$(k);if(T!=="object")return new S("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));var I=t({},w[E],l);for(var B in I){var L=l[B];if(i(l,B)&&typeof L!="function")return pe(y,C,j,B,K(L));if(!L)return new S("Invalid "+C+" `"+j+"` key `"+B+"` supplied to `"+y+"`.\nBad object: "+JSON.stringify(w[E],null," ")+`
54
+ Valid keys: `+JSON.stringify(Object.keys(l),null," "));var O=L(k,B,y,C,j+"."+B,n);if(O)return O}return null}return D(u)}function Z(l){switch(typeof l){case"number":case"string":case"undefined":return!0;case"boolean":return!l;case"object":if(Array.isArray(l))return l.every(Z);if(l===null||d(l))return!0;var u=h(l);if(u){var w=u.call(l),E;if(u!==l.entries){for(;!(E=w.next()).done;)if(!Z(E.value))return!1}else for(;!(E=w.next()).done;){var y=E.value;if(y&&!Z(y[1]))return!1}}else return!1;return!0;default:return!1}}function Le(l,u){return l==="symbol"?!0:u?u["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&u instanceof Symbol:!1}function $(l){var u=typeof l;return Array.isArray(l)?"array":l instanceof RegExp?"object":Le(u,l)?"symbol":u}function K(l){if(typeof l>"u"||l===null)return""+l;var u=$(l);if(u==="object"){if(l instanceof Date)return"date";if(l instanceof RegExp)return"regexp"}return u}function _e(l){var u=K(l);switch(u){case"array":case"object":return"an "+u;case"boolean":case"date":case"regexp":return"a "+u;default:return u}}function Ne(l){return!l.constructor||!l.constructor.name?b:l.constructor.name}return R.checkPropTypes=c,R.resetWarningCache=c.resetWarningCache,R.PropTypes=R,R},ie}var ae,Ee;function dt(){if(Ee)return ae;Ee=1;var e=de();function t(){}function n(){}return n.resetWarningCache=t,ae=function(){function i(a,d,x,f,g,h){if(h!==e){var b=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw b.name="Invariant Violation",b}}i.isRequired=i;function c(){return i}var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:c,element:i,elementType:i,instanceOf:c,node:i,objectOf:c,oneOf:c,oneOfType:c,shape:c,exact:c,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r},ae}var $t=G.exports;if(process.env.NODE_ENV!=="production"){var ut=J.reactIsExports,pt=!0;G.exports=ct()(ut.isElement,pt)}else G.exports=dt()();var ft=G.exports;const q=V.getDefaultExportFromCjs(ft);let Se,Ce;typeof document<"u"&&(Se=document);typeof window<"u"&&(Ce=window);const Te=m.createContext({document:Se,window:Ce}),Q=()=>m.useContext(Te),{Provider:xt,Consumer:Ht}=Te;class Be extends m.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return m.Children.only(this.props.children)}}U(Be,"propTypes",{children:q.element.isRequired,contentDidMount:q.func.isRequired,contentDidUpdate:q.func.isRequired});class le extends m.Component{constructor(n,i){super(n,i);U(this,"setRef",n=>{this.nodeRef.current=n;const{forwardedRef:i}=this.props;typeof i=="function"?i(n):i&&(i.current=n)});U(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});U(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=m.createRef(),this.state={iframeLoaded:!1}}componentDidMount(){this._isMounted=!0,this.getDoc()&&this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded",this.handleLoad)}componentWillUnmount(){this._isMounted=!1,this.nodeRef.current.removeEventListener("DOMContentLoaded",this.handleLoad)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){const n=this.getDoc();return this.props.mountTarget?n.querySelector(this.props.mountTarget):n.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const n=this.getDoc();if(!n)return null;const i=this.props.contentDidMount,c=this.props.contentDidUpdate,r=n.defaultView||n.parentView,a=s.jsxRuntimeExports.jsx(Be,{contentDidMount:i,contentDidUpdate:c,children:s.jsxRuntimeExports.jsx(xt,{value:{document:n,window:r},children:s.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),d=this.getMountTarget();return[fe.createPortal(this.props.head,this.getDoc().head),fe.createPortal(a,d)]}render(){const n={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete n.head,delete n.initialContent,delete n.mountTarget,delete n.contentDidMount,delete n.contentDidUpdate,delete n.forwardedRef,s.jsxRuntimeExports.jsx("iframe",{...n,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}U(le,"propTypes",{style:q.object,head:q.node,initialContent:q.string,mountTarget:q.string,contentDidMount:q.func,contentDidUpdate:q.func,children:q.oneOfType([q.element,q.arrayOf(q.element)])}),U(le,"defaultProps",{style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'});const ht=m.forwardRef((e,t)=>s.jsxRuntimeExports.jsx(le,{...e,forwardedRef:t}));let H=null,X=[],Ie=null;function gt(e){const t=window.getComputedStyle(e),n=parseInt(t.paddingLeft,10),i=parseInt(t.paddingTop,10),c=parseInt(t.paddingRight,10),r=parseInt(t.paddingBottom,10);return{paddingLeft:n,paddingTop:i,paddingRight:c,paddingBottom:r}}const ke=(e,t,n)=>{if(!H)return;const i=e.getBoundingClientRect(),c=H==null?void 0:H.getElementById("placeholder"),{paddingLeft:r,paddingTop:a,paddingRight:d,paddingBottom:x}=gt(e);c.style.width=t==="vertical"?i.width-r-d+"px":"2px",c.style.height=t==="vertical"?"2px":i.height-a-x+"px",c.style.display="block";const f=X.reduce((g,h)=>Math.abs(h-n)<Math.abs(g-n)?h:g);Ie=X.indexOf(f),t==="vertical"?(c.style.top=e.offsetTop+f+"px",c.style.left=e.offsetLeft+r+"px"):(c.style.top=e.offsetTop+a+"px",c.style.left=e.offsetLeft+f+"px")},mt=e=>{const t=De(e),n=window.getComputedStyle(e),i=t==="horizontal",c=parseInt(n.paddingLeft),r=parseInt(n.paddingTop);let a=i?c:r;X=[a],Array.from(e.children).forEach(d=>{const x=window.getComputedStyle(d),f=parseInt(i?x.marginLeft+x.marginRight:x.marginTop+x.marginBottom),g=i?d.offsetWidth:d.offsetHeight;X.push(a+g+f),a+=g+f})};function De(e){const t=window.getComputedStyle(e).display,n=window.getComputedStyle(e).flexDirection;if(t==="flex")return n==="column"||n==="column-reverse"?"vertical":"horizontal";if(t==="grid"){const i=window.getComputedStyle(e).gridTemplateRows,c=window.getComputedStyle(e).gridTemplateColumns;if(i.includes("auto"))return"vertical";if(c.includes("auto"))return"horizontal"}return t==="block"?"vertical":"horizontal"}const yt=p.throttle(e=>{const t=e.target,n=De(t);if(n==="vertical"){const i=e.clientY-t.offsetTop;ke(t,n,i)}else{const i=e.clientX-t.offsetLeft;ke(t,n,i)}},200),vt=e=>{e.preventDefault(),e.stopPropagation(),yt(e)};function we(){const e=H==null?void 0:H.getElementById("placeholder");e.style.display="none"}const jt=()=>{const{document:e}=Q(),[t,n]=F.useAtom(o.draggingFlagAtom),i=Ue.useAddBlockByDrop(),c=ze.useFeature("dnd");return H=e,{isDragging:t,"data-dnd":"branch",onDragOver:c?vt:p.noop,onDrop:c?r=>{const a=JSON.parse(r.dataTransfer.getData("text/plain"));let d=r.target.getAttribute("data-block-id");d===null&&(d=r.target.parentElement.getAttribute("data-block-id")),i({block:a,dropTargetId:d||null,relativeIndex:Ie}),n(!1),setTimeout(()=>we(),300)}:p.noop,onDragEnter:c?r=>{const a=r;a.stopPropagation(),a.preventDefault(),X=[];const d=a.target;mt(d),d.classList.add("outline","outline-green-300","outline-2","-outline-offset-2"),n(!0)}:p.noop,onDragLeave:c?r=>{const a=r;a.stopPropagation(),a.preventDefault(),a.target.classList.remove("outline","outline-green-300","outline-2","-outline-offset-2")}:p.noop,onMouseOut:c?()=>{n(!1),we()}:p.noop}};function ue(e){return e.getAttribute("data-block-id")?e:e.closest("[data-block-id]")}function bt(e){e.container.innerHTML="",e.container.parentNode.removeChild(e.container);var t=document.querySelector(".ql-toolbar");t&&t.parentNode.removeChild(t),e=null}const Et=()=>{const e=["Heading","Paragraph","Text","Link","Span","Button"],t=o.useUpdateBlocksProps(),[,n]=o.useSelectedBlockIds(),[,i]=o.useHighlightBlockId(),[c,r]=F.useAtom(o.inlineEditingActiveAtom);return a=>{var b;if(c)return;const d=ue(a.target),x=d.getAttribute("data-block-type");if(!x||!e.includes(x))return;const f=d.cloneNode(!0);d.style.display="none",Array.from(f.attributes).forEach(R=>{R.name!=="class"&&f.removeAttribute(R.name)}),x==="Text"&&(f.style.display="inline-block"),d.parentNode.insertBefore(f,d.nextSibling);const g=new He.Quill(f,{placeholder:"Type here..."});function h(){const R=g.getText(0,g.getLength());t([d.getAttribute("data-block-id")],{content:R}),d.removeAttribute("style"),f.removeEventListener("blur",h,!0),bt(g),r(""),i("")}f.addEventListener("blur",h,!0),g.focus(),(b=f.querySelector(".ql-clipboard"))==null||b.remove(),n([]),r(d.getAttribute("data-block-id"))}},kt=()=>{const[,e]=o.useSelectedStylingBlocks(),[,t]=o.useSelectedBlockIds(),[n]=F.useAtom(o.inlineEditingActiveAtom);return i=>{if(n)return;i.stopPropagation();const c=ue(i.target);if(c.getAttribute("data-block-parent")){const r=c.getAttribute("data-style-prop"),a=c.getAttribute("data-style-id"),d=c.getAttribute("data-block-parent");e([{id:a,prop:r,blockId:d}]),t([d])}else c.getAttribute("data-block-id")&&t([c.getAttribute("data-block-id")])}},wt=p.throttle((e,t)=>{const n=ue(e.target);n.getAttribute("data-style-id")&&t(n.getAttribute("data-style-id"))},100),Rt=()=>{const[,e]=o.useHighlightBlockId(),[t]=F.useAtom(o.inlineEditingActiveAtom);return n=>{t||wt(n,e)}},St=({children:e})=>{const{document:t}=Q(),[n]=o.useSelectedBlockIds(),[i,c]=o.useSelectedStylingBlocks();m.useEffect(()=>{setTimeout(()=>{if(!p.isEmpty(i))return;const f=Ae(t,p.first(n));if(f){const g=f.getAttribute("data-style-prop");if(g){const h=f.getAttribute("data-style-id"),b=f.getAttribute("data-block-parent");c([{id:h,prop:g,blockId:b}])}}},100)},[t,n,c,i]);const r=Et(),a=kt(),d=Rt(),x=jt();return s.jsxRuntimeExports.jsx("div",{id:"canvas",onClick:a,onDoubleClick:r,onMouseMove:d,...p.omit(x,"isDragging"),className:"relative h-screen max-w-full "+(x.isDragging?"dragging":""),children:e})},Ae=(e,t)=>e.querySelector(`[data-block-id="${t}"]`),Ct=()=>{const{window:e}=Q(),[t,n]=o.useSelectedBlockIds(),[,i]=o.useSelectedStylingBlocks(),{undo:c,redo:r}=o.useCanvasHistory(),a=o.useDuplicateBlocks(),[,d]=o.useCutBlockIds(),[,x]=o.useCopyBlockIds(),{pasteBlocks:f}=o.usePasteBlocks(),[,g]=o.usePreviewMode(),h=o.useRemoveBlocks(),{savePage:b}=o.useSavePage(),[R]=F.useAtom(o.inlineEditingActiveAtom),[,M]=F.useAtom(o.editLayerNameAtom),S=D=>{D.key==="Enter"&&(D.preventDefault(),t.length===1&&M(p.first(t)))};return m.useEffect(()=>{const D=v=>{if(v.key==="Escape"){n([]),i([]);return}if(S(v),!R&&(v.key==="Delete"||v.key==="Backspace")&&(v.preventDefault(),h(t)),v.ctrlKey||v.metaKey){if(["z","y","d","x","c","p","s","v"].includes(v.key)){if(R&&["x","z","v"].includes(v.key))return!0;v.preventDefault()}v.key==="s"&&(v.stopPropagation(),v.preventDefault(),b()),v.key==="z"&&c(),v.key==="y"&&r(),v.key==="d"&&a(t),v.key==="x"&&d(t),v.key==="c"&&x(t),v.key==="v"&&t.length>0&&f(t[0])}};return e.removeEventListener("keydown",D),e.addEventListener("keydown",D),()=>{e.removeEventListener("keydown",D)}},[t,n,c,h,g,r,a,d,x,f,R,b,e]),null},Tt=({block:e,label:t})=>{const[,n]=Ke.useDrag(()=>({type:"CANVAS_BLOCK",item:e}));return s.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-grab items-center space-x-1 px-1",ref:n,onDragStart:()=>{console.log("drag start")},children:[s.jsxRuntimeExports.jsx(P.DragHandleDots2Icon,{}),t]})},Bt=({selectedBlockElement:e,block:t})=>{const n=o.useRemoveBlocks(),i=o.useDuplicateBlocks(),[,c]=o.useSelectedBlockIds(),[,r]=o.useSelectedStylingBlocks(),{floatingStyles:a,refs:d,update:x}=xe.useFloating({placement:"top-start",middleware:[xe.shift(),Ye.flip()],elements:{reference:e}});Ve.useResizeObserver(e,()=>x(),e!==null);const f=p.get(t,"_parent",null),g=p.isEmpty(p.get(t,"_name",""))?p.get(t,"_type",""):p.get(t,"_name","");return!e||!t?null:s.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:d.setFloating,style:a,onClick:h=>{h.stopPropagation(),h.preventDefault()},onKeyDown:h=>h.stopPropagation(),className:"z-50 flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[s.jsxRuntimeExports.jsx(Tt,{label:g,block:t}),s.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1 ",children:[f&&s.jsxRuntimeExports.jsx(P.ArrowUpIcon,{className:"hover:scale-105 ",onClick:()=>{r([]),c([f])}}),o.canDuplicateBlock(p.get(t,"_type",""))?s.jsxRuntimeExports.jsx(P.CopyIcon,{className:"hover:scale-105 ",onClick:()=>i([t==null?void 0:t._id])}):null,o.canDeleteBlock(p.get(t,"_type",""))?s.jsxRuntimeExports.jsx(P.TrashIcon,{className:"hover:scale-105 ",onClick:()=>n([t==null?void 0:t._id])}):null]})]})},It=({model:e})=>{const[t]=o.useBrandingOptions(),[n]=o.useSelectedBlockIds(),[i]=o.useDarkMode(),[c]=o.useHighlightBlockId(),[r]=o.useSelectedStylingBlocks(),{document:a,window:d}=Q(),[x]=m.useState(a==null?void 0:a.getElementById("highlighted-block")),[f]=m.useState(a==null?void 0:a.getElementById("selected-block")),[g]=m.useState(a==null?void 0:a.getElementById("selected-styling-block"));m.useEffect(()=>{i?a==null||a.documentElement.classList.add("dark"):a==null||a.documentElement.classList.remove("dark")},[i,a]);const h=p.get(t,"headingFont","DM Sans"),b=p.get(t,"bodyFont","DM Sans");return m.useEffect(()=>{const R=p.get(t,"primaryColor","#000"),M=p.get(t,"secondaryColor","#FFF"),S=Xe.tailwindcssPaletteGenerator({colors:[R,M],names:["primary","secondary"]});S.primary.DEFAULT=R,S.secondary.DEFAULT=M;const D=p.get(t,"roundedCorners","0");!d||!d.tailwind||(d.tailwind.config={darkMode:"class",theme:{fontFamily:{heading:[h],body:[b]},extend:{borderRadius:{global:`${D||"0"}px`},colors:S}},plugins:[d.tailwind.plugin.withOptions(({prefix:v="ui"}={})=>({addVariant:z})=>{for(const _ of["open","checked","selected","active","disabled"])z(`${v}-${_}`,[`&[data-headlessui-state~="${_}"]`,`:where([data-headlessui-state~="${_}"]) &`]),z(`${v}-not-${_}`,[`&[data-headlessui-state]:not([data-headlessui-state~="${_}"])`,`:where([data-headlessui-state]:not([data-headlessui-state~="${_}"])) &:not([data-headlessui-state])`])})]})},[t,d,h,b]),m.useEffect(()=>{f&&(f.textContent=`${p.map(n,R=>`[data-block-id="${R}"]`).join(",")}{
55
+ outline: 1px solid ${n.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
56
+ }`)},[n,f]),m.useEffect(()=>{x&&(x.textContent=c?`[data-style-id="${c}"]{ outline: 1px solid orange !important; outline-offset: -1px;}`:"")},[c,n,x]),m.useEffect(()=>{g&&(g.textContent=`${p.map(r,({id:R})=>`[data-style-id="${R}"]`).join(",")}{
57
+ outline: 1px solid orange !important; outline-offset: -1px;
58
+ }`)},[r,g]),m.useEffect(()=>{if(e==="section")return;const R=p.get(t,"bodyTextLightColor","#64748b"),M=p.get(t,"bodyTextDarkColor","#94a3b8"),S=p.get(t,"bodyBgLightColor","#FFFFFF"),D=p.get(t,"bodyBgDarkColor","#0f172a");a.body.className=`font-body antialiased text-[${R}] bg-[${S}] dark:text-[${M}] dark:bg-[${D}]`},[t,a,e]),e==="page"?s.jsxRuntimeExports.jsxs(s.jsxRuntimeExports.Fragment,{children:[h&&s.jsxRuntimeExports.jsx("link",{id:"heading-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${h.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),b&&h!==b&&s.jsxRuntimeExports.jsx("link",{id:"body-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${b.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),h&&s.jsxRuntimeExports.jsx("style",{children:`h1,h2,h3,h4,h5,h6{font-family: "${h}",ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";}`})]}):null},Dt=e=>{const t={};return Object.keys(e).forEach(n=>{p.isString(e[n])&&e[n].startsWith(V.SLOT_KEY)&&(t[n]=e[n].replace(V.SLOT_KEY,"").split(","))}),t},At=p.memoize(e=>{const t=e.replace(V.STYLES_KEY,"").split(",");return Ze.twMerge(t[0],t[1])});function Ot(e,t){return p.get(e,`${t}_attrs`,{})}function qt(e){const t={};return Object.keys(e).forEach(n=>{if(p.isString(e[n])&&e[n].startsWith(V.STYLES_KEY)){const i=At(e[n]);t[n]={className:i,"data-style-prop":n,"data-block-parent":e._id,"data-style-id":`${n}-${e._id}`,...Ot(e,n)}}}),t}function Pt(e,t){const n=p.get(e,"_bindings",{});return p.isEmpty(n)?{...e}:(p.each(n,(i,c)=>{p.isString(i)&&p.get(t,i,null)&&(e[c]=p.get(t,i,null))}),e)}function ce({blocks:e}){const t=o.useAllBlocks(),n=m.useCallback(r=>qt(r),[]),[i]=J.useChaiExternalData(),[c]=o.useAtom(o.inlineEditingActiveAtom);return s.jsxRuntimeExports.jsx(s.jsxRuntimeExports.Fragment,{children:m.Children.toArray(e.map((r,a)=>{if(c===r._id)return null;const d=Dt(r),x={};p.isEmpty(d)||Object.keys(d).forEach(b=>{x[b]=m.Children.toArray(d[b].map(R=>s.jsxRuntimeExports.jsx(ce,{blocks:[p.find(t,{_id:R})]})))});const f=p.filter(t,{_parent:r._id});x.children=f.length?s.jsxRuntimeExports.jsx(ce,{blocks:f}):null;const g=Ge.getBlockComponent(r._type),h=p.get(g,"component",null);return p.isNull(h)?s.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${r==null?void 0:r._type} not registered -->`}):s.jsxRuntimeExports.jsx(m.Suspense,{children:m.createElement(h,{blockProps:{"data-block-id":r._id,"data-block-type":r._type,"data-dnd":o.canAddChildBlock(r._type)?"branch":"leaf"},inBuilder:!0,index:a,...Pt(r,i),...n(r),...x})})}))})}const Mt=()=>{const e=o.useAllBlocks();return s.jsxRuntimeExports.jsx(Je.Provider,{children:p.isEmpty(e)?null:s.jsxRuntimeExports.jsx(J.BlocksExternalDataProvider,{children:s.jsxRuntimeExports.jsx(ce,{blocks:p.filter(e,t=>p.isEmpty(t._parent))})})})},Lt=(e,t)=>e.querySelector(`[data-style-id="${t}"]`),_t=()=>{const[e]=F.useAtom(o.networkModeAtom),[t]=o.usePreviewMode(),[n]=o.useCanvasWidth(),[,i]=o.useSelectedBlockIds(),c=o.useSelectedBlock(),[,r]=o.useHighlightBlockId(),a=m.useRef(null),d=m.useRef(null),[x,f]=m.useState({width:0,height:0}),g=it(x),[h,b]=m.useState(0),[R,M]=m.useState([]),[,S]=m.useState([]),[,D]=F.useAtom(o.canvasIframeAtom),[v,z]=o.useSelectedStylingBlocks(),_=o.useBuilderProp("loadingCanvas",!1);m.useEffect(()=>{const{clientWidth:A,clientHeight:N}=d.current;f({width:A,height:N}),h===0&&b(A)},[d,n,h]);const ee=(A,N=0)=>{const{top:W}=A.getBoundingClientRect();return W+N>=0&&W-N<=window.innerHeight};m.useEffect(()=>{var A,N;if(c&&c.type!=="Multiple"&&a.current){const W=Ae(a.current.contentDocument,c._id);W&&(ee(W)||(N=(A=a.current)==null?void 0:A.contentWindow)==null||N.scrollTo({top:W.offsetTop,behavior:"smooth"}),M([W]))}},[c]),m.useEffect(()=>{if(!p.isEmpty(v)&&a.current){const A=Lt(a.current.contentDocument,p.first(v).id);S(A?[A]:[null])}else S([null])},[v]);const te=m.useMemo(()=>{let A=ot;return e==="offline"&&(A=A.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),A=A.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),A=A.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),A},[e]);return s.jsxRuntimeExports.jsx("div",{onClick:()=>{i([]),z([])},onMouseLeave:()=>setTimeout(()=>r(""),300),className:"relative mx-auto h-full w-full",style:h>0&&!p.isEmpty(g)?{width:t?"100%":h}:{},ref:d,children:s.jsxRuntimeExports.jsxs(ht,{contentDidMount:()=>D(a.current),ref:a,id:"canvas-iframe",style:{width:`${n}px`,...g},className:"relative mx-auto box-content h-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:te,children:[s.jsxRuntimeExports.jsx(Ct,{}),s.jsxRuntimeExports.jsx(Bt,{block:c,selectedBlockElement:p.first(R)}),s.jsxRuntimeExports.jsx(It,{model:"page"}),s.jsxRuntimeExports.jsx(St,{children:_?s.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:s.jsxRuntimeExports.jsx(o.Skeleton,{className:"h-full"})}):s.jsxRuntimeExports.jsx(Mt,{})}),s.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"absolute bg-green-500 z-[99999] max-w-full transition-transform"})]})})},Nt=m.lazy(()=>Promise.resolve().then(()=>require("./AddBlocks-P3qHuE5J.cjs"))),Wt=()=>{const[e,t]=F.useAtom(o.addBlocksModalAtom);return s.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsxRuntimeExports.jsx(rt,{}),s.jsxRuntimeExports.jsxs("div",{className:"relative flex-1 overflow-hidden bg-slate-800/90 px-2 bg-[linear-gradient(to_right,#222_0.5px,transparent_0.5px),linear-gradient(to_bottom,#222_0.5px,transparent_0.5px)] bg-[size:12px_12px]",children:[s.jsxRuntimeExports.jsx(m.Suspense,{fallback:s.jsxRuntimeExports.jsx(o.Skeleton,{className:"h-full"}),children:s.jsxRuntimeExports.jsx(J.ErrorBoundary,{children:s.jsxRuntimeExports.jsx(_t,{})})}),e?s.jsxRuntimeExports.jsx("div",{onClick:()=>t(!1),className:"absolute inset-0 z-50 flex items-center bg-black/30 backdrop-blur-sm",children:s.jsxRuntimeExports.jsx("div",{onClick:n=>n.stopPropagation(),className:"mx-auto h-[90%] w-[90%] max-w-3xl rounded-md bg-white p-4 shadow-lg shadow-black/10 xl:w-[65%]",children:s.jsxRuntimeExports.jsx(Nt,{})})}):null]})]})};exports.default=Wt;