@chaibuilder/sdk 1.2.49 → 1.2.51
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/{AddBlocks-JCSA6hLF.js → AddBlocks-LyEjf6h0.js} +18 -18
- package/dist/AddBlocks-hOFqmmXZ.cjs +1 -0
- package/dist/CanvasArea-luy5nUGR.cjs +56 -0
- package/dist/{CanvasArea-c3xbVSoY.js → CanvasArea-mhINqS0c.js} +279 -263
- package/dist/{ChaiBuilderEditor-lqHQcnh3.cjs → ChaiBuilderEditor-H173PF4T.cjs} +50 -50
- package/dist/{ChaiBuilderEditor-F2yUJQdt.js → ChaiBuilderEditor-KEwDa8Bl.js} +8553 -8619
- package/dist/CodeEditor-XaHQMfpT.js +97 -0
- package/dist/CodeEditor-jh9xwRXT.cjs +1 -0
- package/dist/CurrentPage-RUx7wvBt.cjs +1 -0
- package/dist/{CurrentPage--lDu6fB9.js → CurrentPage-UzajS1xZ.js} +10 -10
- package/dist/{ListTree-7DWSal1i.js → ListTree-BWBPjCzR.js} +6 -6
- package/dist/ListTree-S6pMJlmj.cjs +1 -0
- package/dist/{MODIFIERS-cBT31iqE.js → MODIFIERS-fd5XOmum.js} +8 -4
- package/dist/MODIFIERS-mVmfEGgo.cjs +1 -0
- package/dist/PagesPanel-LBW-4mVM.cjs +1 -0
- package/dist/{PagesPanel-D1TOGyVE.js → PagesPanel-p-h6o26u.js} +7 -7
- package/dist/ProjectPanel-PQv2uVj2.cjs +1 -0
- package/dist/{ProjectPanel-PdvQsrbk.js → ProjectPanel-o0OWWnYQ.js} +7 -7
- package/dist/Settings-DclX-cDC.cjs +1 -0
- package/dist/{Settings-aEcWAB0x.js → Settings-zm-cF9rZ.js} +466 -449
- package/dist/SidePanels-0w036NaZ.cjs +1 -0
- package/dist/{SidePanels-uym8wfA0.js → SidePanels-TOHaLWC6.js} +40 -40
- package/dist/ThemeConfiguration-MBuJmbDn.cjs +1 -0
- package/dist/{ThemeConfiguration-7J_Qt53c.js → ThemeConfiguration-wJA_aBly.js} +9 -9
- package/dist/{Topbar-DkbE0ccQ.js → Topbar-Rh7dWuJD.js} +8 -8
- package/dist/Topbar-u5HAh7Mg.cjs +1 -0
- package/dist/{UILibrariesPanel-3cSqwsMi.js → UILibrariesPanel-3-cWabRt.js} +8 -8
- package/dist/UILibrariesPanel-xOys8g8A.cjs +1 -0
- package/dist/UnsplashImages-Kymq8i6b.cjs +1 -0
- package/dist/{UnsplashImages-owPv8UfV.js → UnsplashImages-dhU2-pHY.js} +6 -6
- package/dist/UploadImages-WpaiIEbj.cjs +1 -0
- package/dist/{UploadImages-zGp0fN1z.js → UploadImages-dr_gpAea.js} +4 -4
- package/dist/add-page-modal-vmUMNu7F.cjs +1 -0
- package/dist/{add-page-modal-pOnhQNMH.js → add-page-modal-zwq1hL_o.js} +12 -12
- package/dist/{confirm-alert-lbkop3bB.js → confirm-alert-73tjkqtD.js} +4 -4
- package/dist/confirm-alert-fK62IiTF.cjs +1 -0
- package/dist/controls-rRZhz0vu.cjs +1 -0
- package/dist/{controls-VTdJhdSz.js → controls-yjgoZzB6.js} +31 -18
- package/dist/core.cjs +1 -1
- package/dist/core.js +6 -6
- package/dist/{delete-page-modal-3OWHRhV4.js → delete-page-modal-DPNxHWfi.js} +6 -6
- package/dist/delete-page-modal-G_aMq7K4.cjs +1 -0
- package/dist/email-blocks.cjs +1 -1
- package/dist/email-blocks.js +1 -1
- package/dist/email.cjs +1 -1
- package/dist/email.js +4 -4
- package/dist/{form-Rqiu0P7V.cjs → form-YMuxx9Ju.cjs} +1 -1
- package/dist/{form-CetbKOxf.js → form-_tKI6ugY.js} +5 -5
- package/dist/{functions-WB3m-mfN.js → functions-JO0EW8GX.js} +1 -1
- package/dist/functions-ZZVUnIjD.cjs +1 -0
- package/dist/html-to-json-9uiQ2Dp2.cjs +1 -0
- package/dist/html-to-json-ofq1N3tB.js +186 -0
- package/dist/index-9gfJqJ6E.cjs +1 -0
- package/dist/index-YpnaudSM.js +63 -0
- package/dist/index-ecnGWzh9.cjs +1 -0
- package/dist/{index-Mzvi8sMV.js → index-vpfLlP7N.js} +15 -14
- package/dist/lib.cjs +2 -2
- package/dist/lib.js +19 -20
- package/dist/{page-viewer-7iyxGntn.js → page-viewer-UZMtWQDj.js} +12 -12
- package/dist/page-viewer-WQgFhgp5.cjs +1 -0
- package/dist/project-general-setting-Yh4fQsQH.cjs +1 -0
- package/dist/{project-general-setting-tHdsXTwH.js → project-general-setting-Zz7qcIW7.js} +12 -12
- package/dist/project-seo-setting-_gNPOTsp.cjs +1 -0
- package/dist/{project-seo-setting-zEBZ91Xk.js → project-seo-setting-wFOVAoC2.js} +6 -6
- package/dist/render.cjs +1 -1
- package/dist/render.js +44 -45
- package/dist/{single-page-detail-RBfdbTs3.js → single-page-detail-1Vveonuh.js} +21 -21
- package/dist/single-page-detail-EMxzuAe1.cjs +1 -0
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +6 -6
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +100 -100
- package/dist/useCodeEditor-2KOfsFsx.js +7 -0
- package/dist/useCodeEditor-gE1NWoNH.cjs +1 -0
- package/dist/{utils-K3Zk762G.cjs → utils-D_vtk3zK.cjs} +1 -1
- package/dist/{utils-iMv3T4WT.js → utils-VpVqnC9m.js} +1 -1
- package/dist/web-blocks.cjs +1 -33
- package/dist/web-blocks.js +471 -619
- package/package.json +4 -2
- package/dist/AddBlocks-JiIeMTE-.cjs +0 -1
- package/dist/CanvasArea-K_d6ORTZ.cjs +0 -55
- package/dist/CurrentPage-DnQKF1wT.cjs +0 -1
- package/dist/ListTree-HVFqaM0-.cjs +0 -1
- package/dist/MODIFIERS-YPHRtwrM.cjs +0 -1
- package/dist/PagesPanel-pIFhxLGC.cjs +0 -1
- package/dist/ProjectPanel-t7s3-URx.cjs +0 -1
- package/dist/STRINGS--j49GZJP.js +0 -7
- package/dist/STRINGS-gPz7CUOk.cjs +0 -1
- package/dist/Settings-WevLeOpk.cjs +0 -1
- package/dist/SidePanels-mavyE3q_.cjs +0 -1
- package/dist/ThemeConfiguration-F-_ieF8J.cjs +0 -1
- package/dist/Topbar-FjX_5927.cjs +0 -1
- package/dist/UILibrariesPanel-qsjCsv10.cjs +0 -1
- package/dist/UnsplashImages-5skIflMr.cjs +0 -1
- package/dist/UploadImages-olCKp-66.cjs +0 -1
- package/dist/add-page-modal-JE2NTOKQ.cjs +0 -1
- package/dist/confirm-alert-GTawvuT8.cjs +0 -1
- package/dist/controls-jWJDao88.cjs +0 -1
- package/dist/delete-page-modal-S42VXCGh.cjs +0 -1
- package/dist/functions-fujiWLsg.cjs +0 -1
- package/dist/html-to-json-VPWiWWGH.cjs +0 -1
- package/dist/html-to-json-Z6R2o_fA.js +0 -221
- package/dist/index-SZn6KcOd.cjs +0 -1
- package/dist/page-viewer-fFmRhZs3.cjs +0 -1
- package/dist/project-general-setting-0HJ_qyW3.cjs +0 -1
- package/dist/project-seo-setting-Ln9aX7b5.cjs +0 -1
- package/dist/single-page-detail-H0heOB33.cjs +0 -1
- package/dist/useCanvasSettings-2YhM5XKu.js +0 -6
- package/dist/useCanvasSettings-tDzAqXUt.cjs +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
|
-
import k, { createElement as
|
|
3
|
-
import { has as
|
|
2
|
+
import k, { createElement as S, useState as b, useEffect as E } from "react";
|
|
3
|
+
import { has as F, isFunction as H, first as h, omit as N, filter as g, groupBy as L, uniq as D, map as B, includes as z, isEmpty as C, reject as y, values as v } from "lodash-es";
|
|
4
4
|
import { useAtom as x } from "jotai";
|
|
5
5
|
import { useTranslation as A } from "react-i18next";
|
|
6
|
-
import { m as w,
|
|
6
|
+
import { m as w, K as I, z as M, af as P, ab as q, ac as O, ad as K, bk as R, bl as G, bm as J, bn as U, aC as V, ba as W, bo as Y, B as Q, bp as X, bq as Z, br as $, h as T, ah as ee, ai as te, aj as _, bf as se, b5 as oe, b6 as re, b7 as ae, b8 as le } from "./ChaiBuilderEditor-KEwDa8Bl.js";
|
|
7
7
|
import { BoxIcon as ie } from "@radix-ui/react-icons";
|
|
8
8
|
import { syncBlocksWithDefaults as ce, useChaiBlocks as ne } from "@chaibuilder/runtime";
|
|
9
9
|
import { useFeature as de } from "flagged";
|
|
10
|
-
import { O as j } from "./
|
|
10
|
+
import { O as j } from "./MODIFIERS-fd5XOmum.js";
|
|
11
11
|
import { d as me } from "./atoms-ZOWyNoiC.js";
|
|
12
|
-
import { g as pe } from "./html-to-json-
|
|
12
|
+
import { g as pe } from "./html-to-json-ofq1N3tB.js";
|
|
13
13
|
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
14
14
|
import "clsx";
|
|
15
15
|
import "react-dom";
|
|
@@ -19,9 +19,8 @@ import "i18next";
|
|
|
19
19
|
import "./Functions-7jnEwJyw.js";
|
|
20
20
|
import "tailwind-merge";
|
|
21
21
|
import "@react-hookz/web";
|
|
22
|
-
import "./MODIFIERS-cBT31iqE.js";
|
|
23
22
|
import "tree-model";
|
|
24
|
-
import "./utils-
|
|
23
|
+
import "./utils-VpVqnC9m.js";
|
|
25
24
|
import "@radix-ui/react-toggle";
|
|
26
25
|
import "class-variance-authority";
|
|
27
26
|
import "@radix-ui/react-switch";
|
|
@@ -45,11 +44,12 @@ import "react-icons-picker";
|
|
|
45
44
|
import "react-quill";
|
|
46
45
|
import "react-hotkeys-hook";
|
|
47
46
|
import "lucide-react";
|
|
47
|
+
import "./index-YpnaudSM.js";
|
|
48
48
|
import "himalaya";
|
|
49
49
|
const he = ({ block: t }) => {
|
|
50
50
|
const [, o] = x(me), { type: a, icon: l, label: c } = t, { addCoreBlock: m, addPredefinedBlock: p } = w(), [s, u] = I(), [, f] = M(), [, n] = x(P), i = () => {
|
|
51
|
-
if (
|
|
52
|
-
const d =
|
|
51
|
+
if (F(t, "blocks")) {
|
|
52
|
+
const d = H(t.blocks) ? t.blocks() : t.blocks;
|
|
53
53
|
p(ce(d), h(s));
|
|
54
54
|
} else
|
|
55
55
|
m(t, h(s));
|
|
@@ -69,20 +69,20 @@ const he = ({ block: t }) => {
|
|
|
69
69
|
draggable: "true",
|
|
70
70
|
className: "space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 " + (r ? "cursor-grab" : "cursor-pointer"),
|
|
71
71
|
children: [
|
|
72
|
-
|
|
72
|
+
S(l || ie, { className: "w-4 h-4 mx-auto" }),
|
|
73
73
|
/* @__PURE__ */ e.jsx("p", { className: "text-xs", children: c || a })
|
|
74
74
|
]
|
|
75
75
|
}
|
|
76
76
|
) }),
|
|
77
|
-
/* @__PURE__ */ e.jsx(
|
|
77
|
+
/* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsx("p", { children: c || a }) })
|
|
78
78
|
] }) });
|
|
79
79
|
}, xe = () => {
|
|
80
80
|
const { t } = A(), [o, a] = b(""), { addPredefinedBlock: l } = w(), [c] = I(), [, m] = x(P), p = () => {
|
|
81
81
|
const s = pe(o);
|
|
82
82
|
l([...s], h(c) || null), a(""), m(j);
|
|
83
83
|
};
|
|
84
|
-
return /* @__PURE__ */ e.jsxs(
|
|
85
|
-
/* @__PURE__ */ e.jsx(
|
|
84
|
+
return /* @__PURE__ */ e.jsxs(R, { className: "border-border/0 p-0 shadow-none", children: [
|
|
85
|
+
/* @__PURE__ */ e.jsx(G, { className: "p-3", children: /* @__PURE__ */ e.jsx(J, { children: t("html_snippet_description") }) }),
|
|
86
86
|
/* @__PURE__ */ e.jsx(U, { className: "space-y-2 px-3 py-0", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
|
|
87
87
|
/* @__PURE__ */ e.jsx(V, { htmlFor: "current", className: "text-sm", children: t("tailwind_html_snippet") }),
|
|
88
88
|
/* @__PURE__ */ e.jsx(
|
|
@@ -105,9 +105,9 @@ const he = ({ block: t }) => {
|
|
|
105
105
|
] })
|
|
106
106
|
] });
|
|
107
107
|
}, nt = () => {
|
|
108
|
-
const { t } = A(), [o, a] = b("core"), [l, c] = b("basic"), m = ne(), [, p] = x($), s = T("importHTMLSupport", !0), u = T("filterChaiBlock", () => !0), f = g(m, u), n =
|
|
109
|
-
return
|
|
110
|
-
!z(i, l) && !
|
|
108
|
+
const { t } = A(), [o, a] = b("core"), [l, c] = b("basic"), m = ne(), [, p] = x($), s = T("importHTMLSupport", !0), u = T("filterChaiBlock", () => !0), f = g(m, u), n = L(f, "category"), i = D(B(n.core, "group"));
|
|
109
|
+
return E(() => {
|
|
110
|
+
!z(i, l) && !C(i) && !C(l) && c(h(i));
|
|
111
111
|
}, [i, l]), /* @__PURE__ */ e.jsxs("div", { className: "flex h-full w-72 flex-col overflow-hidden", children: [
|
|
112
112
|
/* @__PURE__ */ e.jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
113
113
|
/* @__PURE__ */ e.jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: t("add_block") }),
|
|
@@ -130,10 +130,10 @@ const he = ({ block: t }) => {
|
|
|
130
130
|
o === "core" && /* @__PURE__ */ e.jsx(se, { className: "-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto", children: /* @__PURE__ */ e.jsx("div", { className: "mt-2 w-full", children: k.Children.toArray(
|
|
131
131
|
B(
|
|
132
132
|
i,
|
|
133
|
-
(r) =>
|
|
133
|
+
(r) => y(g(v(n.core), { group: r }), { hidden: !0 }).length ? /* @__PURE__ */ e.jsx(oe, { type: "single", value: r, collapsible: !0, className: "w-full", children: /* @__PURE__ */ e.jsxs(re, { value: r, children: [
|
|
134
134
|
/* @__PURE__ */ e.jsx(ae, { className: "rounded-md bg-gray-100 px-4 py-2 capitalize", children: r }),
|
|
135
135
|
/* @__PURE__ */ e.jsx(le, { className: "p-3", children: /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-3 gap-2", children: k.Children.toArray(
|
|
136
|
-
|
|
136
|
+
y(g(v(n.core), { group: r }), { hidden: !0 }).map((d) => /* @__PURE__ */ e.jsx(he, { block: d }))
|
|
137
137
|
) }) })
|
|
138
138
|
] }) }) : null
|
|
139
139
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),u=require("react"),t=require("lodash-es"),h=require("jotai"),E=require("react-i18next"),s=require("./ChaiBuilderEditor-H173PF4T.cjs"),b=require("@radix-ui/react-icons"),R=require("@chaibuilder/runtime"),T=require("flagged"),q=require("./MODIFIERS-mVmfEGgo.cjs"),N=require("./atoms-a0H_593V.cjs"),k=require("./html-to-json-9uiQ2Dp2.cjs");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("clsx");require("react-dom");require("@radix-ui/react-scroll-area");require("@floating-ui/react-dom");require("i18next");require("./Functions-N3yhPYKY.cjs");require("tailwind-merge");require("@react-hookz/web");require("tree-model");require("./utils-D_vtk3zK.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");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-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-quill");require("react-hotkeys-hook");require("lucide-react");require("./index-ecnGWzh9.cjs");require("himalaya");const y=({block:r})=>{const[,i]=h.useAtom(N.draggedBlockAtom),{type:l,icon:c,label:d}=r,{addCoreBlock:p,addPredefinedBlock:j}=s.useAddBlock(),[o,g]=s.useSelectedBlockIds(),[,f]=s.useHighlightBlockId(),[,x]=h.useAtom(s.activePanelAtom),a=()=>{if(t.has(r,"blocks")){const m=t.isFunction(r.blocks)?r.blocks():r.blocks;j(R.syncBlocksWithDefaults(m),t.first(o))}else p(r,t.first(o));x(q.OUTLINE_KEY)},n=T.useFeature("dnd");return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(s.Tooltip,{children:[e.jsxRuntimeExports.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs("button",{onClick:a,type:"button",onDragStart:m=>{m.dataTransfer.setData("text/plain",JSON.stringify(t.omit(r,["component","icon"]))),m.dataTransfer.setDragImage(new Image,0,0),i(t.omit(r,["component","icon"])),setTimeout(()=>{g([]),f(null),x(q.OUTLINE_KEY)},200)},draggable:"true",className:"space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 "+(n?"cursor-grab":"cursor-pointer"),children:[u.createElement(c||b.BoxIcon,{className:"w-4 h-4 mx-auto"}),e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:d||l})]})}),e.jsxRuntimeExports.jsx(s.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{children:d||l})})]})})},B=()=>{const{t:r}=E.useTranslation(),[i,l]=u.useState(""),{addPredefinedBlock:c}=s.useAddBlock(),[d]=s.useSelectedBlockIds(),[,p]=h.useAtom(s.activePanelAtom),j=()=>{const o=k.getBlocksFromHTML(i);c([...o],t.first(d)||null),l(""),p(q.OUTLINE_KEY)};return e.jsxRuntimeExports.jsxs(s.Card,{className:"border-border/0 p-0 shadow-none",children:[e.jsxRuntimeExports.jsx(s.CardHeader,{className:"p-3",children:e.jsxRuntimeExports.jsx(s.CardDescription,{children:r("html_snippet_description")})}),e.jsxRuntimeExports.jsx(s.CardContent,{className:"space-y-2 px-3 py-0",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(s.Label,{htmlFor:"current",className:"text-sm",children:r("tailwind_html_snippet")}),e.jsxRuntimeExports.jsx(s.Textarea,{autoFocus:!0,tabIndex:1,ref:o=>o&&o.focus(),onChange:o=>l(o.target.value),rows:12,value:i,placeholder:r("enter_code_snippet"),className:"resize-none overflow-x-auto whitespace-pre bg-gray-100 font-mono text-xs font-normal"})]})}),e.jsxRuntimeExports.jsxs(s.CardFooter,{className:"flex flex-col justify-end p-3",children:[e.jsxRuntimeExports.jsx(s.Button,{disabled:i.trim()==="",onClick:()=>j(),size:"sm",className:"w-full",children:r("import_html")}),e.jsxRuntimeExports.jsx(s.Alert,{variant:"default",className:"mt-2 border-none p-1 text-gray-400",children:e.jsxRuntimeExports.jsx(s.AlertTitle,{className:"text-xs font-normal leading-4",children:r("note_imported_html")})})]})]})},v=()=>{const{t:r}=E.useTranslation(),[i,l]=u.useState("core"),[c,d]=u.useState("basic"),p=R.useChaiBlocks(),[,j]=h.useAtom(s.showPredefinedBlockCategoryAtom),o=s.useBuilderProp("importHTMLSupport",!0),g=s.useBuilderProp("filterChaiBlock",()=>!0),f=t.filter(p,g),x=t.groupBy(f,"category"),a=t.uniq(t.map(x.core,"group"));return u.useEffect(()=>{!t.includes(a,c)&&!t.isEmpty(a)&&!t.isEmpty(c)&&d(t.first(a))},[a,c]),e.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-72 flex-col overflow-hidden",children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[e.jsxRuntimeExports.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:r("add_block")}),e.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:r(i==="html"?"enter_paste_tailwind_html":"click_to_add_block")})]}),e.jsxRuntimeExports.jsx(s.Tabs,{onValueChange:n=>{j(""),l(n)},value:i,className:"h-max",children:e.jsxRuntimeExports.jsxs(s.TabsList,{className:"grid w-full "+(o?"grid-cols-2":"grid-cols-1"),children:[e.jsxRuntimeExports.jsx(s.TabsTrigger,{value:"core",children:r("Blocks")}),o?e.jsxRuntimeExports.jsx(s.TabsTrigger,{value:"html",children:r("import")}):null]})}),i==="core"&&e.jsxRuntimeExports.jsx(s.ScrollArea,{className:"-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto",children:e.jsxRuntimeExports.jsx("div",{className:"mt-2 w-full",children:u.Children.toArray(t.map(a,n=>t.reject(t.filter(t.values(x.core),{group:n}),{hidden:!0}).length?e.jsxRuntimeExports.jsx(s.Accordion,{type:"single",value:n,collapsible:!0,className:"w-full",children:e.jsxRuntimeExports.jsxs(s.AccordionItem,{value:n,children:[e.jsxRuntimeExports.jsx(s.AccordionTrigger,{className:"rounded-md bg-gray-100 px-4 py-2 capitalize",children:n}),e.jsxRuntimeExports.jsx(s.AccordionContent,{className:"p-3",children:e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3 gap-2",children:u.Children.toArray(t.reject(t.filter(t.values(x.core),{group:n}),{hidden:!0}).map(m=>e.jsxRuntimeExports.jsx(y,{block:m})))})})]})}):null))})}),i==="html"&&o?e.jsxRuntimeExports.jsx(B,{}):null]})};exports.default=v;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";var oe=Object.defineProperty;var re=(o,s,e)=>s in o?oe(o,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[s]=e;var I=(o,s,e)=>(re(o,typeof s!="symbol"?s+"":s,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-Z_BpKhVy.cjs"),x=require("react"),c=require("lodash-es"),R=require("@radix-ui/react-icons"),i=require("./ChaiBuilderEditor-H173PF4T.cjs"),U=require("react-i18next"),k=require("jotai"),ie=require("lucide-react"),Y=require("react-dom"),w=require("prop-types"),le=require("react-quill"),M=require("./atoms-a0H_593V.cjs"),ce=require("@floating-ui/dom"),G=require("@floating-ui/react-dom"),ae=require("@react-hookz/web"),de=require("flagged"),ue=require("@tailwindcss/typography"),pe=require("@tailwindcss/forms"),xe=require("@tailwindcss/aspect-ratio"),he=require("tailwindcss-palette-generator"),me=require("tailwind-merge"),T=require("./MODIFIERS-mVmfEGgo.cjs"),ge=require("@chaibuilder/runtime"),J=require("./useCodeEditor-gE1NWoNH.cjs"),fe=require("react-wrap-balancer"),je=require("re-resizable");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("clsx");require("@radix-ui/react-scroll-area");require("i18next");require("./Functions-N3yhPYKY.cjs");require("tree-model");require("./utils-D_vtk3zK.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");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-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-hotkeys-hook");require("./index-ecnGWzh9.cjs");const ve=()=>{const{hasUndo:o,hasRedo:s,undo:e,redo:t}=i.useUndoManager();return r.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[r.jsxRuntimeExports.jsx(i.Button,{disabled:!o(),size:"sm",onClick:e,className:"rounded-full",variant:"ghost",children:r.jsxRuntimeExports.jsx(R.ResetIcon,{})}),r.jsxRuntimeExports.jsx(i.Button,{disabled:!s(),onClick:t,size:"sm",className:"rounded-full",variant:"ghost",children:r.jsxRuntimeExports.jsx(R.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function ye(){const[o,s]=i.useDarkMode();return r.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[r.jsxRuntimeExports.jsx(R.SunIcon,{className:"size-4 shrink-0"}),r.jsxRuntimeExports.jsx(i.Switch,{id:"dark-mode-switch",checked:o,onCheckedChange:()=>{s(!o)},className:`${o?"bg-violet-600":"bg-violet-300"} 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:r.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${o?"translate-x-5":"translate-x-0"} 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`})}),r.jsxRuntimeExports.jsx(i.FaMoon,{className:"size-4 ml-3 shrink-0"})]})}const X=({landscape:o=!1})=>r.jsxRuntimeExports.jsxs("svg",{className:o?"rotate-90":"",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 13 13",xmlSpace:"preserve",width:13,height:13,children:[r.jsxRuntimeExports.jsx("g",{strokeWidth:0}),r.jsxRuntimeExports.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round"}),r.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"}})]}),$e=[{title:"mobile_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:r.jsxRuntimeExports.jsx(R.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:r.jsxRuntimeExports.jsx(R.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:r.jsxRuntimeExports.jsx(X,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:r.jsxRuntimeExports.jsx(X,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:r.jsxRuntimeExports.jsx(R.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:r.jsxRuntimeExports.jsx(R.DesktopIcon,{}),width:1920}],Z=({title:o,content:s,currentBreakpoint:e,breakpoint:t,width:n,icon:u,onClick:a})=>{const{t:l}=U.useTranslation();return r.jsxRuntimeExports.jsxs(i.HoverCard,{children:[r.jsxRuntimeExports.jsx(i.HoverCardTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsx(i.Button,{onClick:()=>a(n),size:"sm",variant:t===e?"secondary":"ghost",children:u})}),r.jsxRuntimeExports.jsx(i.HoverCardContent,{className:"w-52 border-border",children:r.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:r.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[r.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:l(o)}),r.jsxRuntimeExports.jsx("p",{className:"text-xs",children:l(s)})]})})})]})},be=()=>{const[,o,s]=i.useCanvasWidth(),[e,t]=i.useSelectedBreakpoints(),{t:n}=U.useTranslation(),u=i.useBuilderProp("breakpoints",$e),a=l=>{e.includes(l)?e.length>2&&t(e.filter(p=>p!==l)):t(p=>[...p,l])};return u.length<4?r.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:c.map(u,l=>x.createElement(Z,{...l,onClick:s,key:l.breakpoint,currentBreakpoint:o}))}):r.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[c.map(u.filter(l=>c.includes(e,c.toUpper(l.breakpoint))),l=>x.createElement(Z,{...l,onClick:s,key:l.breakpoint,currentBreakpoint:o})),r.jsxRuntimeExports.jsxs(i.DropdownMenu,{children:[r.jsxRuntimeExports.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:r.jsxRuntimeExports.jsx(R.DotsVerticalIcon,{className:"scale-90 transform"})})}),r.jsxRuntimeExports.jsxs(i.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[r.jsxRuntimeExports.jsx(i.DropdownMenuLabel,{children:n("Breakpoints")}),r.jsxRuntimeExports.jsx(i.DropdownMenuSeparator,{}),c.map(u,l=>r.jsxRuntimeExports.jsx(i.DropdownMenuCheckboxItem,{disabled:l.breakpoint==="xs",onCheckedChange:()=>a(c.toUpper(l.breakpoint)),checked:c.includes(e,c.toUpper(l.breakpoint)),children:n(l.title)},l.breakpoint))]})]})]})},ke=()=>{const{t:o}=U.useTranslation(),{setNewBlocks:s}=i.useBlocksStoreUndoableActions(),[,e]=i.useSelectedBlockIds(),[,t]=i.useSelectedStylingBlocks(),n=x.useCallback(()=>{s([]),e([]),t([])},[s]);return r.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:r.jsxRuntimeExports.jsxs(i.AlertDialog,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsxs(i.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[r.jsxRuntimeExports.jsx(R.EraserIcon,{})," ",o("clear")]})}),r.jsxRuntimeExports.jsxs(i.AlertDialogContent,{className:"border-border",children:[r.jsxRuntimeExports.jsxs(i.AlertDialogHeader,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogTitle,{children:o("clear_canvas_title")}),r.jsxRuntimeExports.jsx(i.AlertDialogDescription,{children:o("clear_canvas_description")})]}),r.jsxRuntimeExports.jsxs(i.AlertDialogFooter,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogCancel,{children:o("cancel")}),r.jsxRuntimeExports.jsx(i.AlertDialogAction,{onClick:n,children:o("yes")})]})]})]})})},Ee=()=>{const[o,s]=k.useAtom(i.aiAssistantActiveAtom);return i.useBuilderProp("askAiCallBack",null)?r.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxRuntimeExports.jsxs(i.Label,{htmlFor:"ai-assistant",className:"flex items-center gap-x-1 text-sm text-yellow-600",children:[r.jsxRuntimeExports.jsx(ie.SparklesIcon,{className:"w-4"}),"AI Assistant"]}),r.jsxRuntimeExports.jsx(i.Switch,{className:"scale-90",checked:o,onCheckedChange:t=>{s(t)},id:"ai-assitantt"})]}):null},Re=()=>{const o=i.useBuilderProp("darkMode",!0),[s]=i.useCanvasZoom();return r.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b bg-background/70 px-2",children:[r.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[r.jsxRuntimeExports.jsx(be,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),o?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[r.jsxRuntimeExports.jsx(ye,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"})]}):null,r.jsxRuntimeExports.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[r.jsxRuntimeExports.jsx(R.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",r.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[c.round(s,0),"%"]})]}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),r.jsxRuntimeExports.jsx(ve,{})]}),r.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[r.jsxRuntimeExports.jsx(ke,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),r.jsxRuntimeExports.jsx(Ee,{})]})]})},we=`<!doctype html>
|
|
2
|
+
<html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"><\/script>
|
|
7
|
+
<style>
|
|
8
|
+
html { height: 100%; overflow:auto; }
|
|
9
|
+
body { height: 100%; }
|
|
10
|
+
.air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
|
|
11
|
+
.air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
|
|
12
|
+
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
|
|
13
|
+
-moz-user-select: none;-ms-user-select: none; user-select: none; }
|
|
14
|
+
html{
|
|
15
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
16
|
+
scrollbar-width: none; /* Firefox */
|
|
17
|
+
}
|
|
18
|
+
/** IMPORTANT: Make fields content editable in SAFARI */
|
|
19
|
+
[contenteditable] {-webkit-user-select: text;user-select: text;}
|
|
20
|
+
|
|
21
|
+
html::-webkit-scrollbar { width: 0 !important }
|
|
22
|
+
.aspect-auto{aspect-ratio: auto;}
|
|
23
|
+
.aspect-square{aspect-ratio: 1/1;}
|
|
24
|
+
.aspect-video{aspect-ratio: 16/9;}
|
|
25
|
+
.dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
|
|
26
|
+
.dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
|
|
27
|
+
a{ pointer-events: none !important; }
|
|
28
|
+
[contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
|
|
29
|
+
[contenteditable="true"] {
|
|
30
|
+
outline: none;
|
|
31
|
+
box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
|
|
32
|
+
-webkit-user-select: text;
|
|
33
|
+
-moz-user-select: text;
|
|
34
|
+
user-select: text;
|
|
35
|
+
}
|
|
36
|
+
.frame-root .frame-content { height: 100%; }
|
|
37
|
+
[data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
|
|
38
|
+
[data-dnd="yes"] { pointer-events: auto !important}
|
|
39
|
+
[data-dnd="no"] { pointer-events: none !important; }
|
|
40
|
+
</style>
|
|
41
|
+
<style id="hidden-blocks"></style>
|
|
42
|
+
<style id="selected-block"></style>
|
|
43
|
+
<style id="selected-styling-block"></style>
|
|
44
|
+
<style id="highlighted-block"></style>
|
|
45
|
+
<style id="dragged-block"></style>
|
|
46
|
+
|
|
47
|
+
</head>
|
|
48
|
+
<body class="font-body antialiased h-full">
|
|
49
|
+
<div class="frame-root h-full"></div>
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
51
|
+
</body>
|
|
52
|
+
</html>`,Se=o=>{const[s]=i.useCanvasWidth(),[,e]=i.useCanvasZoom(),[t,n]=x.useState({}),u=x.useCallback(()=>{const{width:a,height:l}=o;if(a<s){const p=parseFloat((a/s).toFixed(2).toString());let d={};const g=l*p;l&&(d={height:100+(l-g)/g*100+"%"}),n({position:"relative",top:0,transform:`scale(${p})`,transformOrigin:"top left",...d,maxWidth:"none"}),e(p*100)}else n({}),e(100)},[s,o,e]);return x.useEffect(()=>{u()},[s,o,e,u]),t};let V,ee;typeof document<"u"&&(V=document);typeof window<"u"&&(ee=window);const te=x.createContext({document:V,window:ee}),N=()=>x.useContext(te),{Provider:Be,Consumer:ot}=te;class se extends x.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return x.Children.only(this.props.children)}}I(se,"propTypes",{children:w.element.isRequired,contentDidMount:w.func.isRequired,contentDidUpdate:w.func.isRequired});class O extends x.Component{constructor(e,t){super(e,t);I(this,"setRef",e=>{this.nodeRef.current=e;const{forwardedRef:t}=this.props;typeof t=="function"?t(e):t&&(t.current=e)});I(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});I(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=x.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 e=this.getDoc();return this.props.mountTarget?e.querySelector(this.props.mountTarget):e.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const e=this.getDoc();if(!e)return null;const t=this.props.contentDidMount,n=this.props.contentDidUpdate,u=e.defaultView||e.parentView,a=r.jsxRuntimeExports.jsx(se,{contentDidMount:t,contentDidUpdate:n,children:r.jsxRuntimeExports.jsx(Be,{value:{document:e,window:u},children:r.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),l=this.getMountTarget();return[Y.createPortal(this.props.head,this.getDoc().head),Y.createPortal(a,l)]}render(){const e={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete e.head,delete e.initialContent,delete e.mountTarget,delete e.contentDidMount,delete e.contentDidUpdate,delete e.forwardedRef,r.jsxRuntimeExports.jsx("iframe",{...e,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}I(O,"propTypes",{style:w.object,head:w.node,initialContent:w.string,mountTarget:w.string,contentDidMount:w.func,contentDidUpdate:w.func,children:w.oneOfType([w.element,w.arrayOf(w.element)])}),I(O,"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 Ce=x.forwardRef((o,s)=>r.jsxRuntimeExports.jsx(O,{...o,forwardedRef:s}));function W(o){const s=window.getComputedStyle(o),e=s.display;if(e==="flex"||e==="inline-flex"){const t=s.flexDirection;return t==="column"||t==="column-reverse"?"vertical":"horizontal"}else if(e==="grid"){const t=s.gridAutoFlow,n=s.gridTemplateRows,u=s.gridTemplateColumns;return t.includes("column")||n.split(" ").length>u.split(" ").length?"vertical":"horizontal"}else if(e==="block"||e==="inline-block")return"vertical";return"horizontal"}let y=null,B=[],_=null,P=null;const Q=(o,s,e)=>{if(!y||!o)return;const t=y==null?void 0:y.getElementById("placeholder"),n=B.map(([p])=>p),u=n.reduce((p,d)=>Math.abs(d-e)<Math.abs(p-e)?d:p,0),a=n.indexOf(u);if(!B[a])return;const l=B[a];t.style.width=s==="vertical"?l[2]+"px":"2px",t.style.height=s==="vertical"?"2px":l[2]+"px",t.style.display="block",s==="vertical"?(t.style.top=l[0]+"px",t.style.left=l[1]+"px"):(t.style.top=l[1]+"px",t.style.left=l[0]+"px")};function Ae(o,s){let e=0,t=1/0;return s.forEach((n,u)=>{const a=Math.abs(n[0]-o);a<t&&(t=a,e=u)}),e}const Ie=o=>{const e=W(o)==="horizontal";B=[],Array.from(o.children).forEach((t,n)=>{if(t.classList.contains("pointer-events-none"))return;const u=e?t.offsetLeft:t.offsetTop,a=e?[t.offsetTop,t.clientHeight]:[t.offsetLeft,t.clientWidth];if(B.push([u,a[0],a[1]]),n===o.children.length-1){const l=e?t.offsetLeft+t.clientWidth:t.offsetTop+t.clientHeight;B.push([l,a[0],a[1]])}})},De=c.throttle(o=>{var n;const s=o.target,e=W(s),t=(n=y==null?void 0:y.defaultView)==null?void 0:n.scrollY;e==="vertical"?Q(s,e,o.clientY+t):Q(s,e,o.clientX)},0);function H(){const o=y==null?void 0:y.getElementById("placeholder");o.style.display="none",_e("pointer-none"),Me()}function _e(o){(y==null?void 0:y.querySelectorAll(`.${o}`)).forEach(e=>{e.classList.remove(o)})}function Me(){const o=y==null?void 0:y.querySelector('[data-drop="yes"]');o&&o.removeAttribute("data-drop")}const Te=()=>{const{document:o}=N(),[s,e]=k.useAtom(i.draggingFlagAtom),{addCoreBlock:t}=i.useAddBlock(),[,n]=i.useHighlightBlockId(),[,u]=i.useSelectedBlockIds(),{moveBlocks:a}=i.useBlocksStoreUndoableActions(),[,l]=k.useAtom(i.draggedBlockIdAtom),[p,d]=k.useAtom(M.draggedBlockAtom),[,g]=k.useAtom(M.dropTargetAtom);return y=o,{isDragging:s,onDragOver:h=>{h.preventDefault(),h.stopPropagation(),De(h)},onDrop:h=>{var S;_==null||_.classList.remove("drop-target");const m=_,b=W(m)==="vertical"?h.clientY+((S=y==null?void 0:y.defaultView)==null?void 0:S.scrollY):h.clientX;P=Ae(b,B);const j=p,f=m.getAttribute("data-block-id");if(!c.has(j,"_id")){t(j,f==="canvas"?null:f,P),setTimeout(()=>{H()},300),B=[],e(!1),l(""),d(null),g(null);return}let E=m.getAttribute("data-block-id");E===null&&(E=h.target.parentElement.getAttribute("data-block-id")),a([j._id],E,P),H(),e(!1),l(""),B=[],setTimeout(()=>H(),300)},onDragEnter:h=>{const m=h,$=m.target;_=$;const b=$.getAttribute("data-block-id");g(b),m.stopPropagation(),m.preventDefault(),B=[],Ie($),console.log(B,h.clientY,y.defaultView.scrollY),$.classList.add("drop-target"),e(!0),n(""),u([])}}};function K(o){return o.getAttribute("data-block-id")?o:o.closest("[data-block-id]")}function Ne(o){o.container.innerHTML="",o.container.parentNode.removeChild(o.container);var s=document.querySelector(".ql-toolbar");s&&s.parentNode.removeChild(s),o=null}const qe=()=>{const o=["Heading","Paragraph","Text","Link","Span","Button"],s=i.useUpdateBlocksProps(),[,e]=i.useHighlightBlockId(),[t,n]=k.useAtom(i.inlineEditingActiveAtom);return u=>{var h;if(t)return;const a=K(u.target),l=a.getAttribute("data-block-type");if(!l||!o.includes(l))return;const p=a.cloneNode(!0);a.style.display="none",Array.from(p.attributes).forEach(m=>{m.name!=="class"&&p.removeAttribute(m.name)}),l==="Text"&&(p.style.display="inline-block"),a.parentNode.insertBefore(p,a.nextSibling);const d=new le.Quill(p,{placeholder:"Type here..."});function g(){const m=d.getText(0,d.getLength());s([a.getAttribute("data-block-id")],{content:m}),a.removeAttribute("style"),p.removeEventListener("blur",g,!0),Ne(d),n(""),e("")}p.addEventListener("blur",g,!0),p.addEventListener("keydown",m=>{(m.key==="Enter"||m.key==="Escape")&&g()}),d.focus(),(h=p.querySelector(".ql-clipboard"))==null||h.remove(),n(a.getAttribute("data-block-id"))}},Le=()=>{const[,o]=i.useSelectedStylingBlocks(),[s,e]=i.useSelectedBlockIds(),[,t]=i.useHighlightBlockId(),[n]=k.useAtom(i.inlineEditingActiveAtom),[u]=k.useAtom(i.treeRefAtom);return a=>{if(n)return;a.stopPropagation();const l=K(a.target);if(l!=null&&l.getAttribute("data-block-id")&&(l==null?void 0:l.getAttribute("data-block-id"))==="container"){e([]),o([]),t("");return}if(l!=null&&l.getAttribute("data-block-parent")){const p=l.getAttribute("data-style-prop"),d=l.getAttribute("data-style-id"),g=l.getAttribute("data-block-parent");s.includes(g)||u==null||u.closeAll(),o([{id:d,prop:p,blockId:g}]),e([g])}else if(l!=null&&l.getAttribute("data-block-id")){let p=l.getAttribute("data-block-id");s.includes(p)||u==null||u.closeAll(),e([p])}t("")}},Fe=c.throttle((o,s)=>{const e=K(o.target);e!=null&&e.getAttribute("data-style-id")&&s(e.getAttribute("data-style-id"))},100),Pe=()=>{const[,o]=i.useHighlightBlockId(),[s]=k.useAtom(i.inlineEditingActiveAtom);return e=>{s||Fe(e,o)}},He=({children:o})=>{const{document:s}=N(),[e]=i.useSelectedBlockIds(),[t,n]=i.useSelectedStylingBlocks();x.useEffect(()=>{setTimeout(()=>{if(!c.isEmpty(t))return;const d=ne(s,c.first(e));if(d){const g=d.getAttribute("data-style-prop");if(g){const h=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");n([{id:h,prop:g,blockId:m}])}}},100)},[s,e,n,t]);const u=qe(),a=Le(),l=Pe(),p=Te();return r.jsxRuntimeExports.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:a,onDoubleClick:u,onMouseMove:l,...c.omit(p,"isDragging"),className:"relative mb-5 h-full max-w-full "+(p.isDragging?"dragging":""),children:o})},ne=(o,s)=>o.querySelector(`[data-block-id="${s}"]`),Oe=()=>{const{window:o}=N(),[s,e]=i.useSelectedBlockIds(),[t]=i.useBlocksStore(),[,n]=i.useSelectedStylingBlocks(),{undo:u,redo:a}=i.useUndoManager(),l=i.useDuplicateBlocks(),[,p]=i.usePreviewMode(),d=i.useRemoveBlocks(),{savePage:g}=i.useSavePage(),[h]=k.useAtom(i.inlineEditingActiveAtom),[,m]=k.useAtom(i.editLayerNameAtom),$=j=>{j.key==="Enter"&&(j.preventDefault(),s.length===1&&m(c.first(s)))},b=j=>{const f=t.find(E=>E._id===j);return f?f._parent:null};return x.useEffect(()=>{const j=f=>{if(f.key==="Escape"){e([]),n([]);return}if($(f),!h&&(f.key==="Delete"||f.key==="Backspace")&&(f.preventDefault(),d(s)),f.ctrlKey||f.metaKey){if(f.key==="ArrowUp"){f.preventDefault();const E=s.length>0?b(s[0]):null;E&&e([E])}if(["z","y","d","x","c","p","s","v"].includes(f.key)){if(h&&["x","z","v"].includes(f.key))return!0;f.preventDefault()}f.key==="s"&&(f.stopPropagation(),f.preventDefault(),g()),f.key==="z"&&u(),f.key==="y"&&a(),f.key==="d"&&l(s)}};return o.removeEventListener("keydown",j),o.addEventListener("keydown",j),()=>{o.removeEventListener("keydown",j)}},[s,e,u,d,p,a,l,h,g,o]),null},ze=({block:o,label:s})=>{const[,e]=i.useSelectedBlockIds(),[,t]=i.useHighlightBlockId(),[,n]=k.useAtom(M.draggedBlockAtom),u=de.useFeature("dnd");return r.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-grab items-center space-x-1 px-1",draggable:u?"true":"false",onDragStart:a=>{a.dataTransfer.setData("text/plain",JSON.stringify(c.pick(o,["_id","_type","_name"]))),n(o),setTimeout(()=>{e([]),t(null)},200)},children:[r.jsxRuntimeExports.jsx(R.DragHandleDots2Icon,{}),s]})},Ue=({selectedBlockElement:o,block:s})=>{const e=i.useRemoveBlocks(),t=i.useDuplicateBlocks(),[,n]=i.useSelectedBlockIds(),[,u]=i.useSelectedStylingBlocks(),[a]=k.useAtom(i.inlineEditingActiveAtom),{floatingStyles:l,refs:p,update:d}=G.useFloating({placement:"top-start",middleware:[G.shift(),ce.flip()],elements:{reference:o}});ae.useResizeObserver(o,()=>d(),o!==null);const g=c.get(s,"_parent",null),h=c.isEmpty(c.get(s,"_name",""))?c.get(s,"_type",""):c.get(s,"_name","");return!o||!s||a?null:r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:r.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:p.setFloating,style:l,onClick:m=>{m.stopPropagation(),m.preventDefault()},onKeyDown:m=>m.stopPropagation(),className:"z-[99999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[r.jsxRuntimeExports.jsx(ze,{label:h,block:s}),r.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1",children:[g&&r.jsxRuntimeExports.jsx(R.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{u([]),n([g])}}),i.canDuplicateBlock(c.get(s,"_type",""))?r.jsxRuntimeExports.jsx(R.CopyIcon,{className:"hover:scale-105",onClick:()=>t([s==null?void 0:s._id])}):null,i.canDeleteBlock(c.get(s,"_type",""))?r.jsxRuntimeExports.jsx(R.TrashIcon,{className:"hover:scale-105",onClick:()=>e([s==null?void 0:s._id])}):null]})]})})},We=({addVariant:o,e:s})=>{o("hs-dropdown-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open > .${s(`hs-dropdown-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open .hs-dropdown-toggle .${s(`hs-dropdown-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open > .hs-dropdown-menu > .${s(`hs-dropdown-open${t}${n}`)}`)}]),o("hs-removing",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-removing.${s(`hs-removing${t}${n}`)}`)}),o("hs-tooltip-shown",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-tooltip.show .${s(`hs-tooltip-shown${t}${n}`)}`)}),o("hs-accordion-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active.${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-toggle .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-heading > .hs-accordion-toggle .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-toggle.${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-heading > .hs-accordion-toggle.${s(`hs-accordion-active${t}${n}`)}`)}]),o("hs-accordion-selected",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion .selected.${s(`hs-accordion-selected${t}${n}`)}`)}),o("hs-collapse-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse.open .${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse.open.${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse-toggle.open .${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse-toggle.open.${s(`hs-collapse-open${t}${n}`)}`)}]),o("hs-tab-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`[data-hs-tab].active.${s(`hs-tab-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`[data-hs-tab].active .${s(`hs-tab-active${t}${n}`)}`)}]),o("hs-overlay-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.open.${s(`hs-overlay-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.open .${s(`hs-overlay-open${t}${n}`)}`)}]),o("hs-overlay-layout-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-body-open.${s(`hs-overlay-layout-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-body-open .${s(`hs-overlay-layout-open${t}${n}`)}`)}]),o("hs-overlay-backdrop-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-backdrop.${s(`hs-overlay-backdrop-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-backdrop .${s(`hs-overlay-backdrop-open${t}${n}`)}`)}]),o("hs-scrollspy-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-scrollspy-active${t}${n}`)}`)}),o("hs-carousel-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-carousel-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-carousel-active${t}${n}`)}`)}]),o("hs-carousel-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-carousel${t}disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-carousel${t}disabled${t}${n}`)}`)}]),o("hs-selected",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected.${s(`hs-selected${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected .${s(`hs-selected${t}${n}`)}`)}]),o("hs-select-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-select-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-select-disabled${t}${n}`)}`)}]),o("hs-select-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-select-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-select-active${t}${n}`)}`)}]),o("hs-input-number-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-input-number-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-input-number-disabled${t}${n}`)}`)}]),o("hs-pin-input-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-pin-input-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-pin-input-active${t}${n}`)}`)}]),o("hs-select-opened",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.opened.${s(`hs-select-opened${t}${n}`)}`)}]),o("hs-password-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-password-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-password-active${t}${n}`)}`)}]),o("hs-stepper-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-stepper-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-stepper-active${t}${n}`)}`)}]),o("hs-stepper-success",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success.${s(`hs-stepper-success${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success .${s(`hs-stepper-success${t}${n}`)}`)}]),o("hs-stepper-completed",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.completed.${s(`hs-stepper-completed${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.completed .${s(`hs-stepper-completed${t}${n}`)}`)}]),o("hs-stepper-error",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error.${s(`hs-stepper-error${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error .${s(`hs-stepper-error${t}${n}`)}`)}]),o("hs-stepper-processed",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.processed.${s(`hs-stepper-processed${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.processed .${s(`hs-stepper-processed${t}${n}`)}`)}]),o("hs-stepper-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-stepper-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-stepper-disabled${t}${n}`)}`)}]),o("hs-stepper-skipped",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.skipped.${s(`hs-stepper-skipped${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.skipped .${s(`hs-stepper-skipped${t}${n}`)}`)}]),o("hs-strong-password",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.passed.${s(`hs-strong-password${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.passed .${s(`hs-strong-password${t}${n}`)}`)}]),o("hs-strong-password-accepted",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.accepted.${s(`hs-strong-password-accepted${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.accepted .${s(`hs-strong-password-accepted${t}${n}`)}`)}]),o("hs-strong-password-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-strong-password-active${t}${n}`)}`)}]),o("hs-combo-box-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-combo-box-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-combo-box-active${t}${n}`)}`)}]),o("hs-combo-box-selected",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected .${s(`hs-combo-box-selected${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected.${s(`hs-combo-box-selected${t}${n}`)}`)}]),o("hs-combo-box-tab-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-combo-box-tab-active${t}${n}`)}`)}]),o("hs-apexcharts-tooltip-dark",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.dark.${s(`hs-apexcharts-tooltip-dark${t}${n}`)}`)}]),o("hs-success",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success .${s(`hs-success${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success.${s(`hs-success${t}${n}`)}`)}]),o("hs-error",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error .${s(`hs-error${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error.${s(`hs-error${t}${n}`)}`)}]),o("hs-default-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.default .${s(`hs-default-mode-active${t}${n}`)}`)}),o("hs-dark-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.dark .${s(`hs-dark-mode-active${t}${n}`)}`)}),o("hs-auto-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.auto .${s(`hs-auto-mode-active${t}${n}`)}`)})},Ke=({model:o})=>{const[s]=i.useBrandingOptions(),[e]=i.useSelectedBlockIds(),[t]=i.useDarkMode(),[n]=i.useHighlightBlockId(),[u]=i.useSelectedStylingBlocks(),[a]=k.useAtom(i.draggedBlockIdAtom),{document:l,window:p}=N(),[d]=x.useState(l==null?void 0:l.getElementById("highlighted-block")),[g]=x.useState(l==null?void 0:l.getElementById("selected-block")),[h]=x.useState(l==null?void 0:l.getElementById("selected-styling-block")),[m]=x.useState(l==null?void 0:l.getElementById("dragged-block"));x.useEffect(()=>{t?l==null||l.documentElement.classList.add("dark"):l==null||l.documentElement.classList.remove("dark")},[t,l]);const $=c.get(s,"headingFont","DM Sans"),b=c.get(s,"bodyFont","DM Sans");return x.useEffect(()=>{const j=c.get(s,"primaryColor","#000"),f=c.get(s,"secondaryColor","#FFF"),E=c.get(s,"bodyBgLightColor","#fff"),S=c.get(s,"bodyBgDarkColor","#000"),D=c.get(s,"bodyTextDarkColor","#000"),q=c.get(s,"bodyTextLightColor","#fff"),L=he([{color:j,name:"primary"},{color:f,name:"secondary"}]),F={"bg-light":E,"bg-dark":S,"text-dark":D,"text-light":q},v=c.get(s,"roundedCorners","0");!p||!p.tailwind||(p.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[$],body:[b]},borderRadius:{DEFAULT:`${v||"0"}px`},colors:{...F,...L}}},plugins:[ue,pe,xe,p.tailwind.plugin.withOptions(()=>We)]})},[s,p,$,b]),x.useEffect(()=>{g&&(g.textContent=`${c.map(e,j=>`[data-block-id="${j}"]`).join(",")}{
|
|
53
|
+
outline: 1px solid ${e.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
|
|
54
|
+
}`)},[e,g]),x.useEffect(()=>{if(!a){m.textContent="";return}m.textContent=`[data-block-id="${a}"]{ pointer-events: none !important; opacity: 0.2 !important}`},[a]),x.useEffect(()=>{d&&(d.textContent=n?`[data-style-id="${n}"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}`:"")},[n,e,d]),x.useEffect(()=>{h&&(h.textContent=`${c.map(u,({id:j})=>`[data-style-id="${j}"]`).join(",")}{
|
|
55
|
+
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
56
|
+
}`)},[u,h]),x.useEffect(()=>{const j=c.get(s,"bodyTextLightColor","#64748b"),f=c.get(s,"bodyTextDarkColor","#94a3b8"),E=c.get(s,"bodyBgLightColor","#FFFFFF"),S=c.get(s,"bodyBgDarkColor","#0f172a");l.body.className=`font-body antialiased text-[${j}] bg-[${E}] dark:text-[${f}] dark:bg-[${S}]`},[s,l,o]),o==="page"?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[$&&r.jsxRuntimeExports.jsx("link",{id:"heading-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${$.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),b&&$!==b&&r.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"}),$&&r.jsxRuntimeExports.jsx("style",{children:`h1,h2,h3,h4,h5,h6{font-family: "${$}",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},Ye=o=>{const s={};return Object.keys(o).forEach(e=>{c.isString(o[e])&&o[e].startsWith(T.SLOT_KEY)&&(s[e]=o[e].replace(T.SLOT_KEY,"").split(","))}),s},Ge=c.memoize(o=>{const s=o.replace(T.STYLES_KEY,"").split(",");return me.twMerge(s[0],s[1])});function Xe(o,s){return c.get(o,`${s}_attrs`,{})}function Ze(o){const s={};return Object.keys(o).forEach(e=>{if(c.isString(o[e])&&o[e].startsWith(T.STYLES_KEY)){const t=Ge(o[e]);s[e]={className:t,"data-style-prop":e,"data-block-parent":o._id,"data-style-id":`${e}-${o._id}`,...Xe(o,e)}}}),s}function Qe(o,s){const e=c.get(o,"_bindings",{});return c.isEmpty(e)?{...o}:(c.each(e,(t,n)=>{c.isString(t)&&c.get(s,t,null)&&(o[n]=c.get(s,t,null))}),o)}function z({blocks:o}){const[s]=i.useBlocksStore(),[e]=k.useAtom(M.draggedBlockAtom),[t]=k.useAtom(M.dropTargetAtom),[n]=J.useCanvasSettings(),u=x.useCallback(d=>Ze(d),[]),[a]=i.useChaiExternalData(),[l]=k.useAtom(i.inlineEditingActiveAtom),p=x.useCallback(d=>d.reduce((g,h)=>{const m=c.get(n,h,{});return{...g,...m}},{}),[n,s]);return r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:x.Children.toArray(o.map((d,g)=>{if(l===d._id)return null;const h=Ye(d),m={};c.isEmpty(h)||Object.keys(h).forEach(S=>{m[S]=x.Children.toArray(h[S].map(D=>r.jsxRuntimeExports.jsx(z,{blocks:[c.find(s,{_id:D})]})))});const $=c.filter(s,{_parent:d._id});m.children=$.length?r.jsxRuntimeExports.jsx(z,{blocks:$}):null;const b=ge.getBlockComponent(d._type),j=c.get(b,"builderComponent",c.get(b,"component",null));if(c.isNull(j))return r.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${d==null?void 0:d._type} not registered -->`});const f=c.has(b,"getBlockStateFrom")?b==null?void 0:b.getBlockStateFrom(d,s):[],E=p(f);return r.jsxRuntimeExports.jsx(x.Suspense,{children:x.createElement(j,{blockProps:{"data-block-id":d._id,"data-block-type":d._type,...e?{"data-dnd":i.canAcceptChildBlock(d._type,e==null?void 0:e._type)?"yes":"no"}:{},...t===d._id?{"data-drop":"yes"}:{}},index:g,...Qe(d,a),...u(d),...m,inBuilder:!0,blockState:E})})}))})}const Je=()=>{const[o]=i.useBlocksStore(),s=c.isEmpty(o)?null:r.jsxRuntimeExports.jsx(i.BlocksExternalDataProvider,{children:r.jsxRuntimeExports.jsx(z,{blocks:c.filter(o,e=>c.isEmpty(e._parent))})});return r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:s})},Ve=(o,s)=>o.querySelector(`[data-style-id="${s}"]`),et=()=>{const[o]=k.useAtom(i.networkModeAtom),[s]=i.usePreviewMode(),[e]=i.useCanvasWidth(),[,t]=i.useSelectedBlockIds(),n=i.useSelectedBlock(),[,u]=i.useHighlightBlockId(),a=x.useRef(null),l=x.useRef(null),[p,d]=x.useState({width:0,height:0}),g=Se(p),[h,m]=x.useState(0),[$,b]=x.useState([]),[,j]=x.useState([]),[,f]=k.useAtom(i.canvasIframeAtom),[E,S]=i.useSelectedStylingBlocks(),D=i.useBuilderProp("loading",!1),q=i.useBuilderProp("htmlDir","ltr");x.useEffect(()=>{const{clientWidth:v,clientHeight:C}=l.current;d({width:v,height:C}),h===0&&m(v)},[l,e,h]);const L=(v,C=0)=>{const{top:A}=v.getBoundingClientRect();return A+C>=0&&A-C<=window.innerHeight};x.useEffect(()=>{var v,C;if(n&&n.type!=="Multiple"&&a.current){const A=ne(a.current.contentDocument,n._id);A&&(L(A)||(C=(v=a.current)==null?void 0:v.contentWindow)==null||C.scrollTo({top:A.offsetTop,behavior:"smooth"}),b([A]))}},[n]),x.useEffect(()=>{if(!c.isEmpty(E)&&a.current){const v=Ve(a.current.contentDocument,c.first(E).id);j(v?[v]:[null])}else j([null])},[E]);const F=x.useMemo(()=>{let v=we;return v=v.replace("__HTML_DIR__",q),o==="offline"&&(v=v.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),v=v.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),v=v.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),v},[o]);return r.jsxRuntimeExports.jsx("div",{onClick:()=>{t([]),S([])},onMouseLeave:()=>setTimeout(()=>u(""),300),className:"relative mx-auto h-full w-full overflow-hidden",style:h>0&&!c.isEmpty(g)?{width:s?"100%":h}:{},ref:l,children:r.jsxRuntimeExports.jsxs(Ce,{contentDidMount:()=>f(a.current),ref:a,id:"canvas-iframe",style:{width:`${e}px`,...g},className:"relative mx-auto box-content h-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:F,children:[r.jsxRuntimeExports.jsx(Oe,{}),r.jsxRuntimeExports.jsx(Ue,{block:n,selectedBlockElement:c.first($)}),r.jsxRuntimeExports.jsx(Ke,{model:"page"}),r.jsxRuntimeExports.jsx(fe.Provider,{children:r.jsxRuntimeExports.jsx(He,{children:D?r.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:r.jsxRuntimeExports.jsx(i.Skeleton,{className:"h-full"})}):r.jsxRuntimeExports.jsx(Je,{})})}),r.jsxRuntimeExports.jsx("br",{}),r.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})},tt=x.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-jh9xwRXT.cjs"))),st=()=>{const[o]=J.useCodeEditor();return r.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[r.jsxRuntimeExports.jsx(Re,{}),r.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col overflow-hidden bg-slate-800/90 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] px-2",children:[r.jsxRuntimeExports.jsx(x.Suspense,{fallback:r.jsxRuntimeExports.jsx(i.Skeleton,{className:"h-full"}),children:r.jsxRuntimeExports.jsx(i.ErrorBoundary,{children:r.jsxRuntimeExports.jsx(et,{})})}),o?r.jsxRuntimeExports.jsx(x.Suspense,{fallback:r.jsxRuntimeExports.jsx(i.Skeleton,{className:"h-full"}),children:r.jsxRuntimeExports.jsx(je.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:r.jsxRuntimeExports.jsx(tt,{})})}):null]})]})};exports.default=st;
|