@chaibuilder/sdk 1.1.0 → 1.1.2
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/CanvasArea-UtFK5IS6.cjs +58 -0
- package/dist/CanvasArea-dkwSFbQA.js +1412 -0
- package/dist/{CurrentPage-_Em0U2gh.cjs → CurrentPage-hHwsHam-.cjs} +1 -1
- package/dist/{CurrentPage-pSsaLyEf.js → CurrentPage-uRwS0DQC.js} +1 -1
- package/dist/{Layers-RyVRzaUa.cjs → Layers--5nyqOjK.cjs} +1 -1
- package/dist/{Layers-wp2Uc2Y5.js → Layers-eXMT1ncm.js} +1 -1
- package/dist/{PagesPanel-ZuXc2610.cjs → PagesPanel-WZgw7xVs.cjs} +1 -1
- package/dist/{PagesPanel-L2VS8RyZ.js → PagesPanel-xRUnAMIb.js} +2 -2
- package/dist/{ProjectPanel-T3AXGe7O.js → ProjectPanel-8l4Bi3Kh.js} +2 -2
- package/dist/{ProjectPanel-SErKorHi.cjs → ProjectPanel-FC03TiyG.cjs} +1 -1
- package/dist/{Settings-xkL3U3Y-.js → Settings-4v3M1bRS.js} +507 -501
- package/dist/Settings-kcmKFymH.cjs +1 -0
- package/dist/{SidePanels-pd7HYv8I.js → SidePanels-0xaw3Td6.js} +45 -39
- package/dist/{SidePanels-5FNROZe7.cjs → SidePanels-5e5q3c7J.cjs} +1 -1
- package/dist/{add-page-modal-U8EH-GIa.cjs → add-page-modal-JRSQ_N56.cjs} +1 -1
- package/dist/{add-page-modal-Njd5M7E2.js → add-page-modal-K5isTZOT.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/{delete-page-modal-0LQiM0fX.cjs → delete-page-modal-c8nB2y7w.cjs} +1 -1
- package/dist/{delete-page-modal-NT7df4pk.js → delete-page-modal-x81Ed4jF.js} +1 -1
- package/dist/{index-pYZXf7hY.cjs → index-7NRFGya_.cjs} +10 -10
- package/dist/{index-N3mTbV2j.js → index-HjvZqhVh.js} +163 -160
- package/dist/{page-viewer-e3lOBAH3.js → page-viewer-fFaDQOOI.js} +2 -2
- package/dist/{page-viewer-UxwOwHCO.cjs → page-viewer-huD5B1om.cjs} +1 -1
- package/dist/{project-general-setting-el86II8N.js → project-general-setting-rH_1r38b.js} +1 -1
- package/dist/{project-general-setting-DrLwWE-6.cjs → project-general-setting-rNNI-K6l.cjs} +1 -1
- package/dist/{single-page-detail-fUh22jZE.cjs → single-page-detail-52_cuxNe.cjs} +1 -1
- package/dist/{single-page-detail-UFEXRI81.js → single-page-detail-CrgTQFUX.js} +2 -2
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +1 -1
- package/package.json +1 -1
- package/dist/CanvasArea-TzIgm_vh.cjs +0 -58
- package/dist/CanvasArea-dS2B20gv.js +0 -1421
- package/dist/Settings-GJHtwQaa.cjs +0 -1
|
@@ -2,7 +2,7 @@ import { j as t } from "./jsx-runtime-NV737rRe.js";
|
|
|
2
2
|
import s, { useState as n, Suspense as l } from "react";
|
|
3
3
|
import { ChevronRightIcon as c, GearIcon as u, HomeIcon as d, FileTextIcon as x } from "@radix-ui/react-icons";
|
|
4
4
|
import { b3 as g, b4 as h, b5 as f } from "./index-ORFlyrBx.js";
|
|
5
|
-
import { e as j, b, d as N } from "./index-
|
|
5
|
+
import { e as j, b, d as N } from "./index-HjvZqhVh.js";
|
|
6
6
|
import "./MODIFIERS-MLfpKQY1.js";
|
|
7
7
|
import "@radix-ui/react-toggle";
|
|
8
8
|
import "class-variance-authority";
|
|
@@ -56,7 +56,7 @@ import "./tailwind-config-d1VL1lzE.js";
|
|
|
56
56
|
import "react-hotkeys-hook";
|
|
57
57
|
import "sonner";
|
|
58
58
|
import "lucide-react";
|
|
59
|
-
const v = s.lazy(() => import("./single-page-detail-
|
|
59
|
+
const v = s.lazy(() => import("./single-page-detail-CrgTQFUX.js")), P = ({ pageData: r }) => {
|
|
60
60
|
const [e, i] = n("CLOSE");
|
|
61
61
|
return /* @__PURE__ */ t.jsxs(
|
|
62
62
|
g,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-WUGKV8jN.cjs"),t=require("react"),n=require("@radix-ui/react-icons"),o=require("./index-zkc4SQCu.cjs"),x=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-WUGKV8jN.cjs"),t=require("react"),n=require("@radix-ui/react-icons"),o=require("./index-zkc4SQCu.cjs"),x=require("./index-7NRFGya_.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("lodash");require("clsx");require("tailwind-merge");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("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-KMQYiBHf.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");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 q=t.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-52_cuxNe.cjs"))),m=({pageData:s})=>{const[r,i]=t.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:r==="OPEN"||r==="ALERT"||r==="PENDING",onOpenChange:u=>{i(r==="PENDING"?"ALERT":u?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:u=>{u.stopPropagation(),i("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:r==="OPEN"||r==="ALERT"||r==="PENDING"?e.jsxRuntimeExports.jsx(n.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(n.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(t.Suspense,{fallback:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full animate-pulse flex-col gap-y-3",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-6 w-1/2"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"})]}),children:e.jsxRuntimeExports.jsx(q,{pageData:s,open:r,setOpen:i})})})]})},j=s=>{const[r]=x.useCurrentPage(),{data:i}=x.useProject(),u=x.useChangePage(),l=(i==null?void 0:i.homepage)===s.uuid,a=r===s.uuid,c=()=>u(s);return i?e.jsxRuntimeExports.jsxs("button",{className:`group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${a?"bg-blue-200 ":""}`,onClick:c,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex text-sm items-center gap-x-1.5",children:[l?e.jsxRuntimeExports.jsx(n.HomeIcon,{}):e.jsxRuntimeExports.jsx(n.FileTextIcon,{})," ",s.name]}),e.jsxRuntimeExports.jsx(m,{pageData:s})]}):null},p=({pages:s,isLoading:r})=>r?e.jsxRuntimeExports.jsxs("div",{className:"flex animate-pulse flex-col gap-y-1 px-2.5 pt-2",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"})]}):s.length===0?e.jsxRuntimeExports.jsx("div",{className:"px-2.5 pb-2 pt-4",children:"No pages"}):e.jsxRuntimeExports.jsx("div",{className:"-mb-2",children:t.Children.toArray(s.map(i=>e.jsxRuntimeExports.jsx(j,{...i})))});exports.default=p;
|
|
@@ -3,7 +3,7 @@ import * as l from "react";
|
|
|
3
3
|
import { br as n } from "./index-ORFlyrBx.js";
|
|
4
4
|
import { u as c, o as u } from "./controls-G0puEH71.js";
|
|
5
5
|
import { F as d } from "./form-TQ7vwDYO.js";
|
|
6
|
-
import { b as x } from "./index-
|
|
6
|
+
import { b as x } from "./index-HjvZqhVh.js";
|
|
7
7
|
import "./MODIFIERS-MLfpKQY1.js";
|
|
8
8
|
import "@radix-ui/react-toggle";
|
|
9
9
|
import "class-variance-authority";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./jsx-runtime-WUGKV8jN.cjs"),a=require("react"),f=require("./index-zkc4SQCu.cjs"),o=require("./controls-aHZq-q4b.cjs"),d=require("./form-bSW-Pkw9.cjs"),m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./jsx-runtime-WUGKV8jN.cjs"),a=require("react"),f=require("./index-zkc4SQCu.cjs"),o=require("./controls-aHZq-q4b.cjs"),d=require("./form-bSW-Pkw9.cjs"),m=require("./index-7NRFGya_.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("lodash");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");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("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("@rjsf/core");require("@rjsf/validator-ajv8");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-KMQYiBHf.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");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");function j(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(i,e,u.get?u:{enumerable:!0,get:()=>r[e]})}}return i.default=r,Object.freeze(i)}const g=j(a),b=({_projectData:r,seany:i})=>{const{data:e,isLoading:u}=m.useProject();g.useEffect(()=>{e&&i(e)},[e,i]);const n=({formData:s},t)=>{i(l=>({...l,[t]:s[t]}))},c={name:o.u({title:"Project Name",default:e==null?void 0:e.name}),favicon:o.o({title:"Favicon",default:e==null?void 0:e.favicon})};return q.jsxRuntimeExports.jsx(f.ScrollArea,{className:"flex h-full select-none flex-col",children:q.jsxRuntimeExports.jsx(d.Form,{properties:c,disabled:u,formData:r,onChange:n})})};exports.default=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-WUGKV8jN.cjs"),f=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),y=require("./index-zkc4SQCu.cjs"),d=require("./controls-aHZq-q4b.cjs"),w=require("sonner"),p=require("./form-bSW-Pkw9.cjs"),P=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-WUGKV8jN.cjs"),f=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),y=require("./index-zkc4SQCu.cjs"),d=require("./controls-aHZq-q4b.cjs"),w=require("sonner"),p=require("./form-bSW-Pkw9.cjs"),P=require("./index-7NRFGya_.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("clsx");require("tailwind-merge");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("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("@rjsf/core");require("@rjsf/validator-ajv8");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-KMQYiBHf.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("./tailwind-config-OxLD7oFU.cjs");require("react-hotkeys-hook");require("lucide-react");const z=f.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-c8nB2y7w.cjs"))),L=f.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-mzlwOW9w.cjs"))),E=u=>{if(!c.isString(u)||!(u.includes("/[")&&u.includes("]")))return!1;const s=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,q=/^[a-zA-Z0-9_-]+$/;let e=!0;return u.split("/").forEach(n=>{e&&(n.includes("[[")&&n.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(n):n.includes("[")&&n.includes("]")?e=s.test(n):e=q.test(n))}),e},h=u=>u&&c.isEmpty(u.seoData)?{...u,seoData:{title:"",description:"",image:""}}:u,G=(u,o)=>{const s=!c.isEqual(c.omit(u,["seoData"]),c.omit(o,["seoData"])),q=!c.isEqual(h(o).seoData,h(u).seoData);return s||q},Y=({open:u,setOpen:o,pageData:s})=>{const q=P.useQueryClient(),{data:e}=P.useProject(),n=P.useUpdatePage(),m=P.useUpdateProject("Homepage updated successfully."),[i,b]=f.useState(h(s)),[a,A]=f.useState({isHomePage:(e==null?void 0:e.homepage)===s.uuid}),j=G(i,s);f.useEffect(()=>{const l=!c.isEqual(h(s),i),t=(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage;o(l||t?"PENDING":"OPEN")},[e,s,i,a,o]);const C=()=>{if(j){if(s.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||"")){u==="ALERT"&&o("PENDING");return}n.mutate(i,{onSuccess:()=>{q.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),w.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==s.uuid&&m.mutate({...e,homepage:s==null?void 0:s.uuid},{onSuccess:()=>o("CLOSE")})},R=({formData:l},t)=>{b(g=>{var S,N;if(!t)return g;const x={[t]:l[t]};return t==="name"?x.slug=c.kebabCase((S=l[t])==null?void 0:S.replace(/\d/g,"")):t==="slug"?x.slug=(N=l[t])==null?void 0:N.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):t==="seoData"&&(x.seoData={title:l[t].title||"",description:l[t].description||"",image:l[t].image||""}),{...g,...x}})},I=({formData:l},t)=>{A(g=>{const x={[t]:l[t]};return{...g,...x}})},v={name:d.u({title:"Page Name",default:i.name}),slug:d.u({title:"Page Slug",default:i.slug})},T={seoData:d.b({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.u({title:"Meta Title",default:i.name}),description:d.g({title:"Meta Description",default:i.slug}),image:d.o({title:"Social Media Image",default:""})}})},M={isHomePage:d.r({title:"Set as homepage",default:a.isHomePage})};return r.jsxRuntimeExports.jsxs(y.ScrollArea,{className:"flex h-full select-none flex-col",children:[r.jsxRuntimeExports.jsx(L,{open:u==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:C,disabled:m.isPending||n.isPending}),r.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:r.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),r.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:r.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[r.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:i,properties:v,onChange:R,disabled:n.isPending||m.isPending}),r.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),r.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:i,properties:T,onChange:R,disabled:n.isPending||m.isPending}),(e==null?void 0:e.homepage)!==s.uuid&&s.type==="STATIC"?r.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:n.isPending||m.isPending}):s.type==="STATIC"&&r.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[r.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),i.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||"")&&r.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",r.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),r.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[r.jsxRuntimeExports.jsx(y.Button,{className:"w-full",type:"submit",onClick:C,disabled:(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage?!1:c.isEmpty(i.name)||c.isEmpty(i.slug)||!j||n.isPending||m.isPending||i.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||""),children:"Save"}),r.jsxRuntimeExports.jsx(z,{pageData:s,projectData:e})]})]})})]})};exports.default=Y;
|
|
@@ -6,7 +6,7 @@ import { br as Y, B as q } from "./index-ORFlyrBx.js";
|
|
|
6
6
|
import { u as g, b as Z, g as $, o as F, r as Q } from "./controls-G0puEH71.js";
|
|
7
7
|
import { toast as U } from "sonner";
|
|
8
8
|
import { F as h } from "./form-TQ7vwDYO.js";
|
|
9
|
-
import { h as V, b as X, i as _, c as K } from "./index-
|
|
9
|
+
import { h as V, b as X, i as _, c as K } from "./index-HjvZqhVh.js";
|
|
10
10
|
import "./MODIFIERS-MLfpKQY1.js";
|
|
11
11
|
import "@radix-ui/react-toggle";
|
|
12
12
|
import "class-variance-authority";
|
|
@@ -60,7 +60,7 @@ import "@tailwindcss/line-clamp";
|
|
|
60
60
|
import "./tailwind-config-d1VL1lzE.js";
|
|
61
61
|
import "react-hotkeys-hook";
|
|
62
62
|
import "lucide-react";
|
|
63
|
-
const O = I.lazy(() => import("./delete-page-modal-
|
|
63
|
+
const O = I.lazy(() => import("./delete-page-modal-x81Ed4jF.js")), J = I.lazy(() => import("./confirm-alert-2JxcNf3T.js")), P = (r) => {
|
|
64
64
|
if (!L(r) || !(r.includes("/[") && r.includes("]")))
|
|
65
65
|
return !1;
|
|
66
66
|
const t = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, p = /^[a-zA-Z0-9_-]+$/;
|
package/dist/studio.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./jsx-runtime-WUGKV8jN.cjs");const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./jsx-runtime-WUGKV8jN.cjs");const e=require("./index-7NRFGya_.cjs");require("react");require("sonner");require("./MODIFIERS-WFzDQfiT.cjs");require("i18next");require("react-i18next");require("./index-zkc4SQCu.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("lodash");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");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("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-KMQYiBHf.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("./tailwind-config-OxLD7oFU.cjs");require("react-hotkeys-hook");require("lucide-react");exports.ChaiBuilderStudio=e.ChaiBuilderStudio;
|
package/dist/studio.js
CHANGED
package/package.json
CHANGED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";var We=Object.defineProperty;var $e=(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)=>($e(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"),f=require("lodash"),M=require("@radix-ui/react-icons"),r=require("./index-zkc4SQCu.cjs"),He=require("react-i18next"),W=require("jotai"),pe=require("react-dom"),X=require("./MODIFIERS-WFzDQfiT.cjs"),J=require("./index-pYZXf7hY.cjs"),Ue=require("react-quill"),ze=require("./useAddBlockByDrop-DPV32UHP.cjs"),Ye=require("flagged"),Ke=require("@floating-ui/dom"),fe=require("@floating-ui/react-dom"),Ve=require("react-dnd"),Xe=require("@react-hookz/web"),Je=require("@bobthered/tailwindcss-palette-generator"),Ze=require("react-wrap-balancer"),Ge=require("tailwind-merge"),Qe=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 et=()=>{const{undoCount:e,redoCount:t,undo:n,redo:o}=r.useCanvasHistory();return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.jsxRuntimeExports.jsx(r.Button,{disabled:!e,size:"sm",onClick:n,className:"rounded-full",variant:"ghost",children:s.jsxRuntimeExports.jsx(M.ResetIcon,{})}),s.jsxRuntimeExports.jsx(r.Button,{disabled:!t,onClick:o,size:"sm",className:"rounded-full",variant:"ghost",children:s.jsxRuntimeExports.jsx(M.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function tt(){const[e,t]=r.useDarkMode(),{t:n}=He.useTranslation();return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.jsxRuntimeExports.jsx(r.Label,{htmlFor:"dark-mode-switch",children:n("dark_mode")}),s.jsxRuntimeExports.jsxs(r.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 xe=({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"}})]}),he=[{title:"Mobile (XS)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:s.jsxRuntimeExports.jsx(M.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(M.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(xe,{}),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(xe,{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(M.LaptopIcon,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:s.jsxRuntimeExports.jsx(M.DesktopIcon,{}),width:1920}],nt=({title:e,content:t,currentBreakpoint:n,breakpoint:o,width:l,icon:i,onClick:c})=>s.jsxRuntimeExports.jsxs(r.HoverCard,{children:[s.jsxRuntimeExports.jsx(r.HoverCardTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsx(r.Button,{onClick:()=>c(l),size:"sm",variant:o===n?"secondary":"ghost",children:i})}),s.jsxRuntimeExports.jsx(r.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})]})})})]}),st=()=>{const[,e,t]=r.useCanvasWidth(),[n,o]=r.useSelectedBreakpoints(),l=i=>{n.includes(i)?n.length>2&&o(n.filter(c=>c!==i)):o(c=>[...c,i])};return s.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[f.map(he.filter(i=>f.includes(n,f.toUpper(i.breakpoint))),i=>m.createElement(nt,{...i,onClick:t,key:i.breakpoint,currentBreakpoint:e})),s.jsxRuntimeExports.jsxs(r.DropdownMenu,{children:[s.jsxRuntimeExports.jsx(r.DropdownMenuTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:s.jsxRuntimeExports.jsx(M.DotsVerticalIcon,{className:"scale-90 transform"})})}),s.jsxRuntimeExports.jsxs(r.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[s.jsxRuntimeExports.jsx(r.DropdownMenuLabel,{children:"Breakpoints"}),s.jsxRuntimeExports.jsx(r.DropdownMenuSeparator,{}),f.map(he,i=>s.jsxRuntimeExports.jsx(r.DropdownMenuCheckboxItem,{disabled:i.breakpoint==="xs",onCheckedChange:()=>l(f.toUpper(i.breakpoint)),checked:f.includes(n,f.toUpper(i.breakpoint)),children:i.title},i.breakpoint))]})]})]})},rt=()=>{const[e]=r.useSetAllBlocks(),{createSnapshot:t}=r.useCanvasHistory(),[,n]=r.useSelectedBlockIds(),[,o]=r.useSelectedStylingBlocks(),l=m.useCallback(()=>{e([]),n([]),o([]),t()},[e,t]);return s.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:s.jsxRuntimeExports.jsxs(r.AlertDialog,{children:[s.jsxRuntimeExports.jsx(r.AlertDialogTrigger,{asChild:!0,children:s.jsxRuntimeExports.jsxs(r.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[s.jsxRuntimeExports.jsx(M.EraserIcon,{})," Clear"]})}),s.jsxRuntimeExports.jsxs(r.AlertDialogContent,{className:"border-border",children:[s.jsxRuntimeExports.jsxs(r.AlertDialogHeader,{children:[s.jsxRuntimeExports.jsx(r.AlertDialogTitle,{children:"Clear whole canvas?"}),s.jsxRuntimeExports.jsx(r.AlertDialogDescription,{children:"Are you sure you want to clear the whole canvas?"})]}),s.jsxRuntimeExports.jsxs(r.AlertDialogFooter,{children:[s.jsxRuntimeExports.jsx(r.AlertDialogCancel,{children:"Cancel"}),s.jsxRuntimeExports.jsx(r.AlertDialogAction,{onClick:l,children:"Yes"})]})]})]})})},ot=()=>{const e=r.useFeatureSupport("darkMode",!1),[t]=r.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(tt,{}),s.jsxRuntimeExports.jsx(r.Separator,{orientation:"vertical"})]}):null,s.jsxRuntimeExports.jsx(st,{}),s.jsxRuntimeExports.jsx(r.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(M.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",s.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[f.round(t,0),"%"]})]}),s.jsxRuntimeExports.jsx(r.Separator,{orientation:"vertical"}),s.jsxRuntimeExports.jsx(et,{})]}),s.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[s.jsxRuntimeExports.jsx(r.Separator,{orientation:"vertical"}),s.jsxRuntimeExports.jsx(rt,{})]})]})},it=`<!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>`,at=e=>{const[t]=r.useCanvasWidth(),[,n]=r.useCanvasZoom(),[o,l]=m.useState({}),i=m.useCallback(()=>{const{width:c,height:d}=e;if(c<t){const u=parseFloat((c/t).toString());let x={};d&&(x={height:d+2*d*(1-u)}),l({transform:`scale(${u})`,transformOrigin:"top left",...x,maxWidth:"none"}),n(u*100)}else l({}),n(100)},[t,e,n]);return m.useEffect(()=>{i()},[t,e,n,i]),o};var G={exports:{}};/*
|
|
50
|
-
object-assign
|
|
51
|
-
(c) Sindre Sorhus
|
|
52
|
-
@license MIT
|
|
53
|
-
*/var ne,ge;function lt(){if(ge)return ne;ge=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function l(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var c={},d=0;d<10;d++)c["_"+String.fromCharCode(d)]=d;var u=Object.getOwnPropertyNames(c).map(function(g){return c[g]});if(u.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(g){x[g]=g}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ne=l()?Object.assign:function(i,c){for(var d,u=o(i),x,g=1;g<arguments.length;g++){d=Object(arguments[g]);for(var h in d)t.call(d,h)&&(u[h]=d[h]);if(e){x=e(d);for(var w=0;w<x.length;w++)n.call(d,x[w])&&(u[x[w]]=d[x[w]])}}return u},ne}var se,me;function de(){if(me)return se;me=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return se=e,se}var re,ye;function Re(){return ye||(ye=1,re=Function.call.bind(Object.prototype.hasOwnProperty)),re}var oe,ve;function ct(){if(ve)return oe;ve=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=de(),n={},o=Re();e=function(i){var c="Warning: "+i;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function l(i,c,d,u,x){if(process.env.NODE_ENV!=="production"){for(var g in i)if(o(i,g)){var h;try{if(typeof i[g]!="function"){var w=Error((u||"React class")+": "+d+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}h=i[g](c,g,u,d,null,t)}catch(O){h=O}if(h&&!(h instanceof Error)&&e((u||"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 S=x?x():"";e("Failed "+d+" type: "+h.message+(S??""))}}}}return l.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},oe=l,oe}var ie,je;function dt(){if(je)return ie;je=1;var e=J.reactIsExports,t=lt(),n=de(),o=Re(),l=ct(),i=function(){};process.env.NODE_ENV!=="production"&&(i=function(d){var u="Warning: "+d;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return ie=function(d,u){var x=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function h(a){var p=a&&(x&&a[x]||a[g]);if(typeof p=="function")return p}var w="<<anonymous>>",S={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:Pe(),objectOf:F,oneOf:N,oneOfType:qe,shape:Me,exact:Le};function O(a,p){return a===p?a!==0||1/a===1/p:a!==a&&p!==p}function k(a,p){this.message=a,this.data=p&&typeof p=="object"?p:{},this.stack=""}k.prototype=Error.prototype;function I(a){if(process.env.NODE_ENV!=="production")var p={},R=0;function b(C,j,E,T,D,B,L){if(T=T||w,B=B||E,L!==n){if(u){var q=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 q.name="Invariant Violation",q}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Y=T+":"+E;!p[Y]&&R<3&&(i("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."),p[Y]=!0,R++)}}return j[E]==null?C?j[E]===null?new k("The "+D+" `"+B+"` is marked as required "+("in `"+T+"`, but its value is `null`.")):new k("The "+D+" `"+B+"` is marked as required in "+("`"+T+"`, but its value is `undefined`.")):null:a(j,E,T,D,B)}var y=b.bind(null,!1);return y.isRequired=b.bind(null,!0),y}function v(a){function p(R,b,y,C,j,E){var T=R[b],D=$(T);if(D!==a){var B=V(T);return new k("Invalid "+C+" `"+j+"` of type "+("`"+B+"` supplied to `"+y+"`, expected ")+("`"+a+"`."),{expectedType:a})}return null}return I(p)}function z(){return I(c)}function _(a){function p(R,b,y,C,j){if(typeof a!="function")return new k("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside arrayOf.");var E=R[b];if(!Array.isArray(E)){var T=$(E);return new k("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an array."))}for(var D=0;D<E.length;D++){var B=a(E,D,y,C,j+"["+D+"]",n);if(B instanceof Error)return B}return null}return I(p)}function ee(){function a(p,R,b,y,C){var j=p[R];if(!d(j)){var E=$(j);return new k("Invalid "+y+" `"+C+"` of type "+("`"+E+"` supplied to `"+b+"`, expected a single ReactElement."))}return null}return I(a)}function te(){function a(p,R,b,y,C){var j=p[R];if(!e.isValidElementType(j)){var E=$(j);return new k("Invalid "+y+" `"+C+"` of type "+("`"+E+"` supplied to `"+b+"`, expected a single ReactElement type."))}return null}return I(a)}function A(a){function p(R,b,y,C,j){if(!(R[b]instanceof a)){var E=a.name||w,T=Fe(R[b]);return new k("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected ")+("instance of `"+E+"`."))}return null}return I(p)}function N(a){if(!Array.isArray(a))return process.env.NODE_ENV!=="production"&&(arguments.length>1?i("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])."):i("Invalid argument supplied to oneOf, expected an array.")),c;function p(R,b,y,C,j){for(var E=R[b],T=0;T<a.length;T++)if(O(E,a[T]))return null;var D=JSON.stringify(a,function(L,q){var Y=V(q);return Y==="symbol"?String(q):q});return new k("Invalid "+C+" `"+j+"` of value `"+String(E)+"` "+("supplied to `"+y+"`, expected one of "+D+"."))}return I(p)}function F(a){function p(R,b,y,C,j){if(typeof a!="function")return new k("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside objectOf.");var E=R[b],T=$(E);if(T!=="object")return new k("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an object."));for(var D in E)if(o(E,D)){var B=a(E,D,y,C,j+"."+D,n);if(B instanceof Error)return B}return null}return I(p)}function qe(a){if(!Array.isArray(a))return process.env.NODE_ENV!=="production"&&i("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var p=0;p<a.length;p++){var R=a[p];if(typeof R!="function")return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Ne(R)+" at index "+p+"."),c}function b(y,C,j,E,T){for(var D=[],B=0;B<a.length;B++){var L=a[B],q=L(y,C,j,E,T,n);if(q==null)return null;q.data&&o(q.data,"expectedType")&&D.push(q.data.expectedType)}var Y=D.length>0?", expected one of type ["+D.join(", ")+"]":"";return new k("Invalid "+E+" `"+T+"` supplied to "+("`"+j+"`"+Y+"."))}return I(b)}function Pe(){function a(p,R,b,y,C){return Z(p[R])?null:new k("Invalid "+y+" `"+C+"` supplied to "+("`"+b+"`, expected a ReactNode."))}return I(a)}function ue(a,p,R,b,y){return new k((a||"React class")+": "+p+" type `"+R+"."+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+y+"`.")}function Me(a){function p(R,b,y,C,j){var E=R[b],T=$(E);if(T!=="object")return new k("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));for(var D in a){var B=a[D];if(typeof B!="function")return ue(y,C,j,D,V(B));var L=B(E,D,y,C,j+"."+D,n);if(L)return L}return null}return I(p)}function Le(a){function p(R,b,y,C,j){var E=R[b],T=$(E);if(T!=="object")return new k("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));var D=t({},R[b],a);for(var B in D){var L=a[B];if(o(a,B)&&typeof L!="function")return ue(y,C,j,B,V(L));if(!L)return new k("Invalid "+C+" `"+j+"` key `"+B+"` supplied to `"+y+"`.\nBad object: "+JSON.stringify(R[b],null," ")+`
|
|
54
|
-
Valid keys: `+JSON.stringify(Object.keys(a),null," "));var q=L(E,B,y,C,j+"."+B,n);if(q)return q}return null}return I(p)}function Z(a){switch(typeof a){case"number":case"string":case"undefined":return!0;case"boolean":return!a;case"object":if(Array.isArray(a))return a.every(Z);if(a===null||d(a))return!0;var p=h(a);if(p){var R=p.call(a),b;if(p!==a.entries){for(;!(b=R.next()).done;)if(!Z(b.value))return!1}else for(;!(b=R.next()).done;){var y=b.value;if(y&&!Z(y[1]))return!1}}else return!1;return!0;default:return!1}}function _e(a,p){return a==="symbol"?!0:p?p["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&p instanceof Symbol:!1}function $(a){var p=typeof a;return Array.isArray(a)?"array":a instanceof RegExp?"object":_e(p,a)?"symbol":p}function V(a){if(typeof a>"u"||a===null)return""+a;var p=$(a);if(p==="object"){if(a instanceof Date)return"date";if(a instanceof RegExp)return"regexp"}return p}function Ne(a){var p=V(a);switch(p){case"array":case"object":return"an "+p;case"boolean":case"date":case"regexp":return"a "+p;default:return p}}function Fe(a){return!a.constructor||!a.constructor.name?w:a.constructor.name}return S.checkPropTypes=l,S.resetWarningCache=l.resetWarningCache,S.PropTypes=S,S},ie}var ae,be;function ut(){if(be)return ae;be=1;var e=de();function t(){}function n(){}return n.resetWarningCache=t,ae=function(){function o(c,d,u,x,g,h){if(h!==e){var w=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 w.name="Invariant Violation",w}}o.isRequired=o;function l(){return o}var i={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:l,element:o,elementType:o,instanceOf:l,node:o,objectOf:l,oneOf:l,oneOfType:l,shape:l,exact:l,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},ae}var Ft=G.exports;if(process.env.NODE_ENV!=="production"){var pt=J.reactIsExports,ft=!0;G.exports=dt()(pt.isElement,ft)}else G.exports=ut()();var xt=G.exports;const P=X.getDefaultExportFromCjs(xt);let we,Se;typeof document<"u"&&(we=document);typeof window<"u"&&(Se=window);const Ce=m.createContext({document:we,window:Se}),Q=()=>m.useContext(Ce),{Provider:ht,Consumer:Wt}=Ce;class Te extends m.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return m.Children.only(this.props.children)}}U(Te,"propTypes",{children:P.element.isRequired,contentDidMount:P.func.isRequired,contentDidUpdate:P.func.isRequired});class le extends m.Component{constructor(n,o){super(n,o);U(this,"setRef",n=>{this.nodeRef.current=n;const{forwardedRef:o}=this.props;typeof o=="function"?o(n):o&&(o.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 o=this.props.contentDidMount,l=this.props.contentDidUpdate,i=n.defaultView||n.parentView,c=s.jsxRuntimeExports.jsx(Te,{contentDidMount:o,contentDidUpdate:l,children:s.jsxRuntimeExports.jsx(ht,{value:{document:n,window:i},children:s.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),d=this.getMountTarget();return[pe.createPortal(this.props.head,this.getDoc().head),pe.createPortal(c,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:P.object,head:P.node,initialContent:P.string,mountTarget:P.string,contentDidMount:P.func,contentDidUpdate:P.func,children:P.oneOfType([P.element,P.arrayOf(P.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 gt=m.forwardRef((e,t)=>s.jsxRuntimeExports.jsx(le,{...e,forwardedRef:t}));let H=null,K=[],Be=null;function Ie(e){const t=window.getComputedStyle(e),n=parseInt(t.paddingLeft,10),o=parseInt(t.paddingTop,10),l=parseInt(t.paddingRight,10),i=parseInt(t.paddingBottom,10);return{paddingLeft:n,paddingTop:o,paddingRight:l,paddingBottom:i}}const Ee=(e,t,n)=>{if(!H)return;const o=e.getBoundingClientRect(),l=H==null?void 0:H.getElementById("placeholder"),{paddingLeft:i,paddingTop:c,paddingRight:d,paddingBottom:u}=Ie(e);l.style.width=t==="vertical"?o.width-i-d+"px":"2px",l.style.height=t==="vertical"?"5px":o.height-c-u+"px",l.style.display="block";const x=K.reduce((g,h)=>Math.abs(h-n)<Math.abs(g-n)?h:g);Be=K.indexOf(x),l.style.top=e.offsetTop+(t==="vertical"?x:0)+"px",l.style.left=e.offsetLeft+(t==="horizontal"?x:0)+"px"},mt=e=>{const t=De(e),n=e.getBoundingClientRect(),o=Array.from(e.children);o.filter(c=>c.getAttribute("data-dnd")!=="ignore");const{paddingLeft:l,paddingTop:i}=Ie(e);K=[t==="vertical"?l:i],K=[...K,...o.map(c=>{const d=c.getBoundingClientRect();return t==="vertical"?d.top-n.top+d.height:d.left-n.left+d.width})]};function De(e){const t=window.getComputedStyle(e).display,n=t==="block"?"vertical":"horizontal";return t==="flex"&&e.style.flexDirection==="column"?"vertical":n}const yt=f.throttle(e=>{const t=e.target,n=De(t);if(n==="vertical"){const o=e.clientY-t.offsetTop;Ee(t,n,o)}else{const o=e.clientX-t.offsetLeft;Ee(t,n,o)}},200),vt=e=>{e.preventDefault(),e.stopPropagation(),yt(e)};function ke(){const e=H==null?void 0:H.getElementById("placeholder");e.style.display="none"}const jt=()=>{const{document:e}=Q(),[t,n]=W.useAtom(r.draggingFlagAtom),o=ze.useAddBlockByDrop(),l=Ye.useFeature("dnd");return H=e,{isDragging:t,"data-dnd":"branch",onDragOver:l?vt:f.noop,onDrop:l?i=>{const c=JSON.parse(i.dataTransfer.getData("text/plain"));let d=i.target.getAttribute("data-block-id");d===null&&(d=i.target.parentElement.getAttribute("data-block-id")),o({block:c,dropTargetId:d||null,relativeIndex:Be}),n(!1),setTimeout(()=>ke(),300)}:f.noop,onDragEnter:l?i=>{const c=i;c.stopPropagation(),c.preventDefault(),K=[];const d=c.target;mt(d),d.classList.add("outline","outline-blue-500","outline-4","-outline-offset-4"),n(!0)}:f.noop,onDragLeave:l?i=>{const c=i;c.stopPropagation(),c.preventDefault(),c.target.classList.remove("outline","outline-blue-500","outline-4","-outline-offset-4")}:f.noop,onMouseOut:l?()=>{n(!1),ke()}:f.noop}};function Ae(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=r.useUpdateBlocksProps(),[,n]=r.useSelectedBlockIds(),[,o]=r.useHighlightBlockId(),[l,i]=W.useAtom(r.inlineEditingActiveAtom);return c=>{var w;if(l)return;const d=Ae(c.target),u=d.getAttribute("data-block-type");if(!u||!e.includes(u))return;i(d.getAttribute("data-block-id"));const x=d.cloneNode(!0);d.style.display="none",Array.from(x.attributes).forEach(S=>{S.name!=="class"&&x.removeAttribute(S.name)}),u==="Text"&&(x.style.display="inline-block"),d.parentNode.insertBefore(x,d.nextSibling);const g=new Ue.Quill(x);function h(){const S=g.getText(0,g.getLength());t([d.getAttribute("data-block-id")],{content:S}),d.removeAttribute("style"),x.removeEventListener("blur",h,!0),bt(g),i(""),o("")}x.addEventListener("blur",h,!0),g.focus(),(w=x.querySelector(".ql-clipboard"))==null||w.remove(),n([])}},kt=()=>{const[,e]=r.useSelectedStylingBlocks(),[,t]=r.useSelectedBlockIds(),[n]=W.useAtom(r.inlineEditingActiveAtom);return o=>{if(n)return;o.stopPropagation();const l=Ae(o.target);if(l.getAttribute("data-block-parent")){const i=l.getAttribute("data-style-prop"),c=l.getAttribute("data-style-id"),d=l.getAttribute("data-block-parent");e([{id:c,prop:i,blockId:d}]),t([d])}else l.getAttribute("data-block-id")&&t([l.getAttribute("data-block-id")])}},Rt=({children:e})=>{const{document:t}=Q(),[n]=r.useSelectedBlockIds(),[o,l]=r.useSelectedStylingBlocks();m.useEffect(()=>{setTimeout(()=>{if(!f.isEmpty(o))return;const u=Oe(t,f.first(n));if(u){const x=u.getAttribute("data-style-prop");if(x){const g=u.getAttribute("data-style-id"),h=u.getAttribute("data-block-parent");l([{id:g,prop:x,blockId:h}])}}},100)},[t,n,l,o]);const i=Et(),c=kt(),d=jt();return s.jsxRuntimeExports.jsx("div",{id:"canvas",onClick:c,onDoubleClick:i,...f.omit(d,"isDragging"),className:"relative h-screen max-w-full "+(d.isDragging?"dragging":""),children:e})},Oe=(e,t)=>e.querySelector(`[data-block-id="${t}"]`),wt=()=>{const{window:e}=Q(),[t,n]=r.useSelectedBlockIds(),[,o]=r.useSelectedStylingBlocks(),{undo:l,redo:i}=r.useCanvasHistory(),c=r.useDuplicateBlocks(),[,d]=r.useCutBlockIds(),[,u]=r.useCopyBlockIds(),{pasteBlocks:x}=r.usePasteBlocks(),[,g]=r.usePreviewMode(),h=r.useRemoveBlocks(),{savePage:w}=r.useSavePage(),[S]=W.useAtom(r.inlineEditingActiveAtom),[,O]=W.useAtom(r.editLayerNameAtom),k=I=>{I.key==="Enter"&&(I.preventDefault(),t.length===1&&O(f.first(t)))};return m.useEffect(()=>{const I=v=>{if(v.key==="Escape"){n([]),o([]);return}if(k(v),!S&&(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(S&&["x","z","v"].includes(v.key))return!0;v.preventDefault()}v.key==="s"&&(v.stopPropagation(),v.preventDefault(),w()),v.key==="z"&&l(),v.key==="y"&&i(),v.key==="d"&&c(t),v.key==="x"&&d(t),v.key==="c"&&u(t),v.key==="v"&&t.length>0&&x(t[0])}};return e.removeEventListener("keydown",I),e.addEventListener("keydown",I),()=>{e.removeEventListener("keydown",I)}},[t,n,l,h,g,i,c,d,u,x,S,w,e]),null},St=({block:e,label:t})=>{const[,n]=Ve.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(M.DragHandleDots2Icon,{}),t]})},Ct=({selectedBlockElement:e,block:t})=>{const n=r.useRemoveBlocks(),o=r.useDuplicateBlocks(),[,l]=r.useSelectedBlockIds(),[,i]=r.useSelectedStylingBlocks(),{floatingStyles:c,refs:d,update:u}=fe.useFloating({placement:"top-start",middleware:[fe.shift(),Ke.flip()],elements:{reference:e}});Xe.useResizeObserver(e,()=>u(),e!==null);const x=f.get(t,"_parent",null),g=f.isEmpty(f.get(t,"_name",""))?f.get(t,"_type",""):f.get(t,"_name","");return!e||!t?null:s.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:d.setFloating,style:c,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(St,{label:g,block:t}),s.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1 ",children:[x&&s.jsxRuntimeExports.jsx(M.ArrowUpIcon,{className:"hover:scale-105 ",onClick:()=>{i([]),l([x])}}),r.canDuplicateBlock(f.get(t,"_type",""))?s.jsxRuntimeExports.jsx(M.CopyIcon,{className:"hover:scale-105 ",onClick:()=>o([t==null?void 0:t._id])}):null,r.canDeleteBlock(f.get(t,"_type",""))?s.jsxRuntimeExports.jsx(M.TrashIcon,{className:"hover:scale-105 ",onClick:()=>n([t==null?void 0:t._id])}):null]})]})},Tt=({model:e})=>{const[t]=r.useBrandingOptions(),[n]=r.useSelectedBlockIds(),[o]=r.useDarkMode(),[l]=r.useHighlightBlockId(),[i]=r.useSelectedStylingBlocks(),{document:c,window:d}=Q(),[u]=m.useState(c==null?void 0:c.getElementById("highlighted-block")),[x]=m.useState(c==null?void 0:c.getElementById("selected-block")),[g]=m.useState(c==null?void 0:c.getElementById("selected-styling-block"));m.useEffect(()=>{o?c==null||c.documentElement.classList.add("dark"):c==null||c.documentElement.classList.remove("dark")},[o,c]);const h=f.get(t,"headingFont","DM Sans"),w=f.get(t,"bodyFont","DM Sans");return m.useEffect(()=>{const S=f.get(t,"primaryColor","#000"),O=f.get(t,"secondaryColor","#FFF"),k=Je.tailwindcssPaletteGenerator({colors:[S,O],names:["primary","secondary"]});k.primary.DEFAULT=S,k.secondary.DEFAULT=O;const I=f.get(t,"roundedCorners","0");!d||!d.tailwind||(d.tailwind.config={darkMode:"class",theme:{fontFamily:{heading:[h],body:[w]},extend:{borderRadius:{global:`${I||"0"}px`},colors:k}},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,w]),m.useEffect(()=>{x&&(x.textContent=`${f.map(n,S=>`[data-block-id="${S}"]`).join(",")}{
|
|
55
|
-
outline: 1px solid ${n.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
|
|
56
|
-
}`)},[n,x]),m.useEffect(()=>{u&&(u.textContent=l?`[data-style-id="${l}"]{ outline: 1px solid orange !important; outline-offset: -1px;}`:"")},[l,n,u]),m.useEffect(()=>{g&&(g.textContent=`${f.map(i,({id:S})=>`[data-style-id="${S}"]`).join(",")}{
|
|
57
|
-
outline: 1px solid orange !important; outline-offset: -1px;
|
|
58
|
-
}`)},[i,g]),m.useEffect(()=>{if(e==="section")return;const S=f.get(t,"bodyTextLightColor","#64748b"),O=f.get(t,"bodyTextDarkColor","#94a3b8"),k=f.get(t,"bodyBgLightColor","#FFFFFF"),I=f.get(t,"bodyBgDarkColor","#0f172a");c.body.className=`font-body antialiased text-[${S}] bg-[${k}] dark:text-[${O}] dark:bg-[${I}]`},[t,c,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"}),w&&h!==w&&s.jsxRuntimeExports.jsx("link",{id:"body-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${w.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},Bt=e=>{const t={};return Object.keys(e).forEach(n=>{f.isString(e[n])&&e[n].startsWith(X.SLOT_KEY)&&(t[n]=e[n].replace(X.SLOT_KEY,"").split(","))}),t},It=f.memoize(e=>{const t=e.replace(X.STYLES_KEY,"").split(",");return Ge.twMerge(t[0],t[1])});function Dt(e,t){return f.get(e,`${t}_attrs`,{})}function At(e,t,n){const o={};return Object.keys(e).forEach(l=>{if(f.isString(e[l])&&e[l].startsWith(X.STYLES_KEY)){const i=It(e[l]);o[l]={className:i,"data-style-prop":l,"data-block-parent":e._id,"data-style-id":`${l}-${e._id}`,onMouseEnter:t,onMouseLeave:n,...Dt(e,l)}}}),o}function Ot(e,t){const n=f.get(e,"_bindings",{});return f.isEmpty(n)?{...e}:(f.each(n,(o,l)=>{f.isString(o)&&f.get(t,o,null)&&(e[l]=f.get(t,o,null))}),e)}function ce({blocks:e}){const t=r.useAllBlocks(),[,n]=r.useHighlightBlockId(),[o]=W.useAtom(r.inlineEditingActiveAtom),l=m.useCallback(u=>{var g;if(o)return;const x=(g=u.currentTarget)==null?void 0:g.getAttribute("data-style-id");n(x||""),u.stopPropagation()},[n,o]),i=m.useCallback(u=>{o||(n(""),u.stopPropagation())},[n,o]),c=m.useCallback(u=>At(u,l,i),[l,i]),[d]=J.useChaiExternalData();return s.jsxRuntimeExports.jsx(s.jsxRuntimeExports.Fragment,{children:m.Children.toArray(e.map((u,x)=>{const g=Bt(u),h={};f.isEmpty(g)||Object.keys(g).forEach(k=>{h[k]=m.Children.toArray(g[k].map(I=>s.jsxRuntimeExports.jsx(ce,{blocks:[f.find(t,{_id:I})]})))});const w=f.filter(t,{_parent:u._id});h.children=w.length?s.jsxRuntimeExports.jsx(ce,{blocks:w}):null;const S=Qe.getBlockComponent(u._type),O=f.get(S,"component",null);return f.isNull(O)?s.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${u==null?void 0:u._type} not registered -->`}):s.jsxRuntimeExports.jsx(m.Suspense,{children:m.createElement(O,{blockProps:{"data-block-id":u._id,"data-block-type":u._type,"data-dnd":r.canAddChildBlock(u._type)?"branch":"leaf"},inBuilder:!0,index:x,...Ot(u,d),...c(u),...h})})}))})}const qt=()=>{const e=r.useAllBlocks();return s.jsxRuntimeExports.jsx(Ze.Provider,{children:f.isEmpty(e)?null:s.jsxRuntimeExports.jsx(J.BlocksExternalDataProvider,{children:s.jsxRuntimeExports.jsx(ce,{blocks:f.filter(e,t=>f.isEmpty(t._parent))})})})},Pt=(e,t)=>e.querySelector(`[data-style-id="${t}"]`),Mt=()=>{const[e]=W.useAtom(r.networkModeAtom),[t]=r.usePreviewMode(),[n]=r.useCanvasWidth(),[,o]=r.useSelectedBlockIds(),l=r.useSelectedBlock(),[,i]=r.useHighlightBlockId(),c=m.useRef(null),d=m.useRef(null),[u,x]=m.useState({width:0,height:0}),g=at(u),[h,w]=m.useState(0),[S,O]=m.useState([]),[,k]=m.useState([]),[,I]=W.useAtom(r.canvasIframeAtom),[v,z]=r.useSelectedStylingBlocks(),_=r.useBuilderProp("loadingCanvas",!1);m.useEffect(()=>{const{clientWidth:A,clientHeight:N}=d.current;x({width:A,height:N}),h===0&&w(A)},[d,n,h]);const ee=(A,N=0)=>{const{top:F}=A.getBoundingClientRect();return F+N>=0&&F-N<=window.innerHeight};m.useEffect(()=>{var A,N;if(l&&l.type!=="Multiple"&&c.current){const F=Oe(c.current.contentDocument,l._id);F&&(ee(F)||(N=(A=c.current)==null?void 0:A.contentWindow)==null||N.scrollTo({top:F.offsetTop,behavior:"smooth"}),O([F]))}},[l]),m.useEffect(()=>{if(!f.isEmpty(v)&&c.current){const A=Pt(c.current.contentDocument,f.first(v).id);k(A?[A]:[null])}else k([null])},[v]);const te=m.useMemo(()=>{let A=it;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:()=>{o([]),z([])},onMouseLeave:()=>setTimeout(()=>i(""),300),className:"relative mx-auto h-full w-full",style:h>0&&!f.isEmpty(g)?{width:t?"100%":h}:{},ref:d,children:s.jsxRuntimeExports.jsxs(gt,{contentDidMount:()=>I(c.current),ref:c,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(wt,{}),s.jsxRuntimeExports.jsx(Ct,{block:l,selectedBlockElement:f.first(S)}),s.jsxRuntimeExports.jsx(Tt,{model:"page"}),s.jsxRuntimeExports.jsx(Rt,{children:_?s.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:s.jsxRuntimeExports.jsx(r.Skeleton,{className:"h-full"})}):s.jsxRuntimeExports.jsx(qt,{})}),s.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"absolute bg-green-500 z-[99999] max-w-full transition-transform"})]})})},Lt=m.lazy(()=>Promise.resolve().then(()=>require("./AddBlocks-P3qHuE5J.cjs"))),_t=()=>{const[e,t]=W.useAtom(r.addBlocksModalAtom);return s.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsxRuntimeExports.jsx(ot,{}),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(r.Skeleton,{className:"h-full"}),children:s.jsxRuntimeExports.jsx(J.ErrorBoundary,{children:s.jsxRuntimeExports.jsx(Mt,{})})}),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(Lt,{})})}):null]})]})};exports.default=_t;
|