@chaibuilder/sdk 2.0.0-beta.41 → 2.0.0-beta.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -4,24 +4,24 @@ var bp = (r, h, g) => ev(r, typeof h != "symbol" ? h + "" : h, g);
4
4
  import { j as jsxRuntimeExports } from "./jsx-runtime-Dx-03ztt.js";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, Component, Children, useMemo, useState, useRef, Suspense, memo, createElement, lazy } from "react";
7
- import { ag as useToast, S as Skeleton, B as Button, L as Label, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, C as Card, x as CardHeader, E as CardDescription, F as CardContent, T as Textarea, y as CardFooter, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, j as AlertDialog, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, k as AlertDialogTrigger, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, b as Switch, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-BsI3Hqio.js";
7
+ import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, T as Textarea, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, C as Card, x as CardHeader, E as CardDescription, F as CardContent, y as CardFooter, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, j as AlertDialog, k as AlertDialogTrigger, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, b as Switch, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-BsI3Hqio.js";
8
8
  import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, useSetAtom as useSetAtom$1, getDefaultStore as getDefaultStore$1 } from "jotai";
9
- import { has, get, find, filter, flatten, map, omit, isString, includes, without, compact, isObject, each, set, first, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, pick, sortBy, memoize, forEach, unset, chunk, cloneDeep, throttle, reverse, startCase, debounce, capitalize, flatMapDeep, some, split, reject, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, isFunction as isFunction$1, uniq, toUpper, round } from "lodash-es";
9
+ import { has, get, find, filter, flatten, map, omit, isString, includes, without, compact, isObject, each, set, first, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, pick, sortBy, memoize, forEach, unset, chunk, cloneDeep, throttle, reverse, startCase, debounce, capitalize, split, reject, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, isFunction as isFunction$1, flatMapDeep, some, groupBy, uniq, toUpper, round } from "lodash-es";
10
10
  import { Provider } from "react-wrap-balancer";
11
11
  import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
12
12
  import { useTranslation, initReactI18next } from "react-i18next";
13
13
  import { useTranslation as Yv } from "react-i18next";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
16
- import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CheckIcon, ResetIcon, SunIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
16
+ import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
17
17
  import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
18
18
  import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
20
20
  import { registerChaiBlock as Xv } from "@chaibuilder/runtime";
21
- import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, b as getChaiThemeCssVariables, a as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Ba9O-eBT.js";
21
+ import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
22
22
  import TreeModel from "tree-model";
23
23
  import { useHotkeys } from "react-hotkeys-hook";
24
- import { PlusIcon as PlusIcon$1, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, EyeOff, Eye, X, Plus, ChevronDown, List, Loader, SparklesIcon, SmileIcon, ShuffleIcon, Edit2, Paintbrush, Layers } from "lucide-react";
24
+ import { PlusIcon as PlusIcon$1, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, X, Plus, ChevronDown, List, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, Edit2, Paintbrush, Layers } from "lucide-react";
25
25
  import ReactQuill, { Quill } from "react-quill";
26
26
  import typography from "@tailwindcss/typography";
27
27
  import forms from "@tailwindcss/forms";
@@ -32,14 +32,14 @@ import { S as STYLES_KEY, R as ROOT_TEMP_KEY } from "./STRINGS-DtEft2kY.js";
32
32
  import ReactDOM from "react-dom";
33
33
  import { ErrorBoundary } from "react-error-boundary";
34
34
  import { Resizable } from "re-resizable";
35
- import { Tree } from "react-arborist";
36
- import { parse, stringify } from "himalaya";
37
35
  import RjForm from "@rjsf/core";
38
36
  import validator from "@rjsf/validator-ajv8";
39
37
  import IconPicker, { IconPickerItem } from "react-icons-picker";
40
38
  import Autosuggest from "react-autosuggest";
41
39
  import Fuse from "fuse.js";
40
+ import { parse, stringify } from "himalaya";
42
41
  import clsx from "clsx";
42
+ import { Tree } from "react-arborist";
43
43
  import i18n from "i18next";
44
44
  import { default as Qv } from "i18next";
45
45
  import { motion } from "framer-motion";
@@ -4236,965 +4236,103 @@ const StaticBlocksRenderer = () => {
4236
4236
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4237
4237
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
4238
4238
  ] });
4239
- }), placeholderStyle = {
4240
- display: "flex",
4241
- alignItems: "center",
4242
- zIndex: 1
4243
- }, DefaultCursor = React__default.memo(function({ top: h, left: g }) {
4244
- const x = {
4245
- position: "absolute",
4246
- pointerEvents: "none",
4247
- top: h + "px",
4248
- left: g + "px",
4249
- right: 0
4250
- };
4251
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { ...placeholderStyle, ...x }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0.5 flex-1 rounded-[1px] bg-green-500" }) });
4252
- }), Overlay = memo(function({ children: h, isDragging: g }) {
4253
- return g ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pointer-events-none fixed left-0 top-0 z-[100] h-full w-full", children: h }) : null;
4254
- }), DefaultDragPreview = memo(({ id: r, isDragging: h, mouse: g }) => {
4255
- const [x] = useBlocksStore(), v = useMemo(() => x.find((C) => C._id === r), [x, r]), S = useMemo(
4256
- () => ({
4257
- transform: `translate(${(g == null ? void 0 : g.x) - 10}px, ${(g == null ? void 0 : g.y) - 10}px)`
4258
- }),
4259
- [g]
4260
- );
4261
- return g ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { isDragging: h, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4262
- "div",
4263
- {
4264
- className: "pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",
4265
- style: S,
4266
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { type: "button", className: "flex !cursor-grab items-center p-0.5", "aria-label": `Type: ${v == null ? void 0 : v._type}`, children: [
4267
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: v == null ? void 0 : v._type }) }),
4268
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ml-2 truncate text-[11px]", children: (v == null ? void 0 : v._name) || (v == null ? void 0 : v._type) })
4269
- ] })
4270
- }
4271
- ) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden" });
4272
- }), PasteAtRootContextMenu = ({ parentContext: r, setParentContext: h }) => {
4273
- const { t: g } = useTranslation(), { canPaste: x, pasteBlocks: v } = usePasteBlocks();
4274
- return useEffect(() => {
4275
- x("root") || h(null);
4276
- }, [x("root")]), r && x("root") && /* @__PURE__ */ jsxRuntimeExports.jsx(
4277
- "div",
4278
- {
4279
- style: { position: "absolute", top: r.y - 75, left: r.x - 56 },
4280
- onMouseLeave: () => h(null),
4281
- className: "w-28 rounded-md border bg-white p-1 shadow-xl",
4282
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4283
- "div",
4284
- {
4285
- className: "flex cursor-pointer items-center gap-x-4 rounded px-2 py-1 text-xs hover:bg-blue-50",
4286
- onClick: () => {
4287
- v("root"), h(null);
4288
- },
4289
- children: [
4290
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackIcon, {}),
4291
- " ",
4292
- g("Paste")
4293
- ]
4294
- }
4295
- )
4296
- }
4297
- );
4298
- }, CopyPasteBlocks = () => {
4299
- const [r] = useBlocksStore(), [h] = useSelectedBlockIds(), { pasteBlocks: g } = usePasteBlocks(), [, x] = useCopyBlockIds(), { t: v } = useTranslation(), S = useSelectedBlock(), C = useCallback(() => {
4300
- const R = h.map((A) => {
4301
- const T = r.find((_) => _._id === A);
4302
- return {
4303
- id: A,
4304
- data: T
4305
- };
4306
- });
4307
- x(R.map((A) => A.id));
4308
- }, [h, r, x]);
4309
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4310
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
4311
- ContextMenuItem,
4312
- {
4313
- disabled: !canDuplicateBlock(S == null ? void 0 : S._type),
4314
- onClick: C,
4315
- className: "flex items-center gap-x-4 text-xs",
4316
- children: [
4317
- /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}),
4318
- " ",
4319
- v("Copy")
4320
- ]
4321
- }
4322
- ),
4239
+ }), GlobalBlockSettings = () => {
4240
+ const r = useSelectedBlock(), { data: h, refetch: g, isLoading: x } = useGlobalBlocksList(), v = useUpdateBlocksProps();
4241
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4242
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-sm", children: "Choose a global block" }),
4323
4243
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
4324
- ContextMenuItem,
4244
+ "select",
4325
4245
  {
4326
- className: "flex items-center gap-x-4 text-xs",
4327
- onClick: () => {
4328
- g(h);
4246
+ className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
4247
+ value: (r == null ? void 0 : r.globalBlock) || "",
4248
+ onChange: (S) => {
4249
+ var C;
4250
+ v([r._id], {
4251
+ globalBlock: S.target.value,
4252
+ _name: `Global: ${startCase((C = get(h, S.target.value, "")) == null ? void 0 : C.name)}`
4253
+ });
4329
4254
  },
4330
4255
  children: [
4331
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackIcon, {}),
4332
- " ",
4333
- v("Paste")
4334
- ]
4335
- }
4336
- )
4337
- ] });
4338
- }, CutBlocks = () => {
4339
- const [r] = useSelectedBlockIds(), [, h] = useCutBlockIds(), { t: g } = useTranslation();
4340
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenuItem, { className: "flex items-center gap-x-4 text-xs", onClick: () => h(r), children: [
4341
- /* @__PURE__ */ jsxRuntimeExports.jsx(ScissorsIcon, {}),
4342
- " ",
4343
- g("Cut")
4344
- ] });
4345
- }, RemoveBlocks = () => {
4346
- const [r] = useSelectedBlockIds(), h = useRemoveBlocks(), g = useSelectedBlock(), { t: x } = useTranslation();
4347
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4348
- ContextMenuItem,
4349
- {
4350
- disabled: !canDeleteBlock(g == null ? void 0 : g._type),
4351
- className: "flex items-center gap-x-4 text-xs",
4352
- onClick: () => h(r),
4353
- children: [
4354
- /* @__PURE__ */ jsxRuntimeExports.jsx(TrashIcon, {}),
4355
- " ",
4356
- x("Remove")
4357
- ]
4358
- }
4359
- );
4360
- }, BlockContextMenuContent = () => {
4361
- const { t: r } = useTranslation(), [h] = useSelectedBlockIds(), g = useDuplicateBlocks(), x = useSelectedBlock(), v = useCallback(() => {
4362
- g(h);
4363
- }, [h, g]);
4364
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenuContent, { className: "border-border text-xs", children: [
4365
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
4366
- ContextMenuItem,
4367
- {
4368
- disabled: !canAddChildBlock(x == null ? void 0 : x._type),
4369
- className: "flex items-center gap-x-4 text-xs",
4370
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x),
4371
- children: [
4372
- /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "14" }),
4373
- " ",
4374
- r("Add block")
4256
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select a global block" }),
4257
+ Object.keys(h).map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: S, children: h[S].name || S }, S))
4375
4258
  ]
4376
4259
  }
4377
4260
  ),
4378
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
4379
- ContextMenuItem,
4261
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4262
+ "button",
4380
4263
  {
4381
- disabled: !canDuplicateBlock(x == null ? void 0 : x._type),
4382
- className: "flex items-center gap-x-4 text-xs",
4383
- onClick: v,
4384
- children: [
4385
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackPlusIcon, {}),
4386
- " ",
4387
- r("Duplicate")
4388
- ]
4264
+ onClick: g,
4265
+ className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
4266
+ children: x ? "Loading..." : "Refresh List"
4389
4267
  }
4390
- ),
4391
- /* @__PURE__ */ jsxRuntimeExports.jsx(CutBlocks, {}),
4392
- /* @__PURE__ */ jsxRuntimeExports.jsx(CopyPasteBlocks, {}),
4393
- /* @__PURE__ */ jsxRuntimeExports.jsx(RemoveBlocks, {})
4268
+ ) })
4394
4269
  ] });
4395
- }, BlockContextMenu = ({ children: r }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenu, { children: [
4396
- /* @__PURE__ */ jsxRuntimeExports.jsx(ContextMenuTrigger, { asChild: !0, children: r }),
4397
- /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenuContent, {})
4398
- ] }) }), defaultShortcuts = [
4399
- { key: "ArrowDown", command: "selectNext" },
4400
- { key: "ArrowUp", command: "selectPrev" },
4401
- { key: "ArrowLeft", command: "selectParent", when: "isLeaf || isClosed" },
4402
- { key: "ArrowLeft", command: "close", when: "isOpen" },
4403
- { key: "ArrowRight", command: "open", when: "isClosed" },
4404
- { key: "ArrowRight", command: "selectNext", when: "isOpen" },
4405
- { key: "Home", command: "selectFirst" },
4406
- { key: "End", command: "selectLast" }
4407
- ];
4408
- function selectFirst(r) {
4409
- r.firstNode && r.select(r.firstNode.id);
4410
- }
4411
- function selectLast(r) {
4412
- r.lastNode && r.select(r.lastNode.id);
4413
- }
4414
- function selectNext(r) {
4415
- const h = r.selectedNodes[0].next || r.firstNode;
4416
- r.select(h.id);
4417
- }
4418
- function selectPrev(r) {
4419
- const h = r.selectedNodes[0].prev || r.lastNode;
4420
- r.select(h.id);
4421
- }
4422
- const selectParent = (r, h) => {
4423
- var x;
4424
- const g = ((x = r.selectedIds[0]) == null ? void 0 : x.parent) || null;
4425
- g && h && r.select(g.id);
4426
- }, open = (r, h) => {
4427
- const g = r.selectedNodes[0];
4428
- g.isInternal && h && g.open();
4429
- }, close = (r, h) => {
4430
- const g = r.selectedNodes[0];
4431
- g.isInternal && h && g.close();
4432
- };
4433
- function VscJson(r) {
4434
- return GenIcon({ tag: "svg", attr: { viewBox: "0 0 16 16", fill: "currentColor" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z" }, child: [] }] })(r);
4435
- }
4436
- function BsLightningFill(r) {
4437
- return GenIcon({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z" }, child: [] }] })(r);
4438
- }
4439
- function TbEyeDown(r) {
4440
- return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" }, child: [] }, { tag: "path", attr: { d: "M12 18c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" }, child: [] }, { tag: "path", attr: { d: "M19 16v6" }, child: [] }, { tag: "path", attr: { d: "M22 19l-3 3l-3 -3" }, child: [] }] })(r);
4441
- }
4442
- function BiCollapseVertical(r) {
4443
- return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 7.59 7.05 2.64 5.64 4.05 12 10.41l6.36-6.36-1.41-1.41L12 7.59zM5.64 19.95l1.41 1.41L12 16.41l4.95 4.95 1.41-1.41L12 13.59l-6.36 6.36z" }, child: [] }] })(r);
4444
- }
4445
- function BiExpandVertical(r) {
4446
- return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(r);
4447
- }
4448
- const currentAddSelection = atom$1(null), Node = memo(({ node: r, style: h, dragHandle: g }) => {
4449
- var se;
4450
- const x = useBuilderProp("outlineMenuItems", []), { t: v } = useTranslation(), [S, , C] = useHiddenBlockIds(), [R] = useAtom$1(canvasIframeAtom);
4451
- let A = null;
4452
- const T = r.children.length > 0, { highlightBlock: _, clearHighlight: O } = useBlockHighlight(), { id: z, data: Z, isSelected: G, willReceiveDrop: q, isDragging: ee, isEditing: ge, handleClick: le } = r, ce = (me) => {
4453
- me.stopPropagation(), !S.includes(z) && r.toggle();
4454
- }, $ = (me) => {
4455
- me.isInternal && (A = me.isOpen, me.isOpen && me.close());
4456
- }, ie = (me) => {
4457
- me.isInternal && A !== null && (A ? me.open() : me.close(), A = null);
4458
- }, [he, Se] = useAtom$1(currentAddSelection), Me = () => {
4459
- var me;
4460
- W(), r.parent.isSelected || Se((me = r == null ? void 0 : r.parent) == null ? void 0 : me.id);
4461
- }, W = () => {
4462
- Se(null);
4463
- }, xe = (me) => {
4464
- W(), me.stopPropagation(), !r.isOpen && !S.includes(z) && r.toggle(), le(me);
4465
- };
4466
- useEffect(() => {
4467
- const me = setTimeout(() => {
4468
- q && !r.isOpen && !ee && !S.includes(z) && r.toggle();
4469
- }, 500);
4470
- return () => clearTimeout(me);
4471
- }, [q, r, ee]);
4472
- const ve = useMemo(() => {
4473
- const me = Object.keys(Z), V = [];
4474
- for (let ue = 0; ue < me.length; ue++)
4475
- if (me[ue].endsWith("_attrs")) {
4476
- const de = Z[me[ue]], Ae = Object.keys(de).join("|");
4477
- Ae.match(/x-data/) && V.push("data"), Ae.match(/x-on/) && V.push("event"), Ae.match(/x-show|x-if/) && V.push("show");
4270
+ }, BindingWidget = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" });
4271
+ var client = { exports: {} }, reactDomClient_production = {}, scheduler = { exports: {} }, scheduler_production = {};
4272
+ /**
4273
+ * @license React
4274
+ * scheduler.production.js
4275
+ *
4276
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4277
+ *
4278
+ * This source code is licensed under the MIT license found in the
4279
+ * LICENSE file in the root directory of this source tree.
4280
+ */
4281
+ var hasRequiredScheduler_production;
4282
+ function requireScheduler_production() {
4283
+ return hasRequiredScheduler_production || (hasRequiredScheduler_production = 1, function(r) {
4284
+ function h(V, ue) {
4285
+ var de = V.length;
4286
+ V.push(ue);
4287
+ e: for (; 0 < de; ) {
4288
+ var Ae = de - 1 >>> 1, Ee = V[Ae];
4289
+ if (0 < v(Ee, ue))
4290
+ V[Ae] = ue, V[de] = Ee, de = Ae;
4291
+ else break e;
4478
4292
  }
4479
- return V;
4480
- }, [Z]), ye = (me, V) => {
4481
- const ue = R.contentDocument || R.contentWindow.document, de = ue.querySelector(`[data-block-id=${me}]`);
4482
- de && de.setAttribute("data-drop", V);
4483
- const Ae = de.getBoundingClientRect(), Ee = R.getBoundingClientRect();
4484
- Ae.top >= Ee.top && Ae.left >= Ee.left && Ae.bottom <= Ee.bottom && Ae.right <= Ee.right || (ue.documentElement.scrollTop = de.offsetTop - Ee.top);
4485
- }, je = (me) => {
4486
- W();
4487
- const V = get(r, "parent.id");
4488
- V !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: V, position: me }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: me });
4489
- };
4490
- return z === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
4491
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4492
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4493
- "div",
4494
- {
4495
- onClick: () => je(-1),
4496
- className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4497
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
4498
- /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
4499
- " ",
4500
- v("Add block")
4501
- ] })
4293
+ }
4294
+ function g(V) {
4295
+ return V.length === 0 ? null : V[0];
4296
+ }
4297
+ function x(V) {
4298
+ if (V.length === 0) return null;
4299
+ var ue = V[0], de = V.pop();
4300
+ if (de !== ue) {
4301
+ V[0] = de;
4302
+ e: for (var Ae = 0, Ee = V.length, Ge = Ee >>> 1; Ae < Ge; ) {
4303
+ var Ye = 2 * (Ae + 1) - 1, Qt = V[Ye], Oe = Ye + 1, Mt = V[Oe];
4304
+ if (0 > v(Qt, de))
4305
+ Oe < Ee && 0 > v(Mt, Qt) ? (V[Ae] = Mt, V[Oe] = de, Ae = Oe) : (V[Ae] = Qt, V[Ye] = de, Ae = Ye);
4306
+ else if (Oe < Ee && 0 > v(Mt, de))
4307
+ V[Ae] = Mt, V[Oe] = de, Ae = Oe;
4308
+ else break e;
4309
+ }
4502
4310
  }
4503
- ),
4504
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
4505
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: z, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4506
- "div",
4507
- {
4508
- onMouseEnter: () => _(z),
4509
- onMouseLeave: () => O(),
4510
- onClick: xe,
4511
- style: h,
4512
- "data-node-id": z,
4513
- ref: S.includes(z) ? null : g,
4514
- onDragStart: () => $(r),
4515
- onDragEnd: () => ie(r),
4516
- onDragOver: (me) => {
4517
- me.preventDefault(), ye(z, "yes");
4518
- },
4519
- onDragLeave: (me) => {
4520
- me.preventDefault(), ye(z, "no");
4521
- },
4522
- onDrop: (me) => {
4523
- me.preventDefault(), ye(z, "no");
4524
- },
4525
- children: [
4526
- (r == null ? void 0 : r.rowIndex) > 0 && (r.parent.isOpen && canAddChildBlock(get(r, "parent.data._type")) || ((se = r == null ? void 0 : r.parent) == null ? void 0 : se.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4527
- "div",
4528
- {
4529
- onClick: (me) => {
4530
- me.stopPropagation(), je(r.childIndex);
4531
- },
4532
- onMouseEnter: Me,
4533
- onMouseLeave: W,
4534
- className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
4535
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
4536
- }
4537
- ) }),
4538
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
4539
- "div",
4540
- {
4541
- className: cn(
4542
- "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
4543
- G ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
4544
- q && canAcceptChildBlock(Z._type, "Icon") ? "bg-green-200" : "",
4545
- (r == null ? void 0 : r.id) === he ? "bg-purple-100" : "",
4546
- ee && "opacity-20",
4547
- S.includes(z) ? "opacity-50" : ""
4548
- ),
4549
- children: [
4550
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
4551
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4552
- "div",
4553
- {
4554
- className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${r.isOpen ? "rotate-90" : ""}`,
4555
- children: T && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: ce, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4556
- ChevronRight,
4557
- {
4558
- className: `h-3 w-3 stroke-[3] ${G ? "text-slate-200" : "text-slate-400"}`
4559
- }
4560
- ) })
4561
- }
4562
- ),
4563
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "leading-1 flex items-center", children: [
4564
- /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: Z == null ? void 0 : Z._type }),
4565
- ge ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: r }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4566
- "div",
4567
- {
4568
- className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
4569
- onDoubleClick: (me) => {
4570
- me.stopPropagation(), r.edit(), r.deselect();
4571
- },
4572
- children: [
4573
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (Z == null ? void 0 : Z._name) || (Z == null ? void 0 : Z._type.split("/").pop()) }),
4574
- ve.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
4575
- ve.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
4576
- ve.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
4577
- ]
4578
- }
4579
- )
4580
- ] })
4581
- ] }),
4582
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
4583
- !S.includes(z) && x.map((me) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4584
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4585
- TooltipTrigger,
4586
- {
4587
- className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
4588
- asChild: !0,
4589
- children: React__default.createElement(me.item, { blockId: z })
4590
- }
4591
- ),
4592
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: me.tooltip })
4593
- ] })),
4594
- canAddChildBlock(Z == null ? void 0 : Z._type) && !S.includes(z) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4595
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4596
- TooltipTrigger,
4597
- {
4598
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: z }),
4599
- className: "cursor-pointer rounded bg-transparent hover:text-black",
4600
- asChild: !0,
4601
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "15" })
4602
- }
4603
- ),
4604
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: v("Add block") })
4605
- ] }) : null,
4606
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4607
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4608
- TooltipTrigger,
4609
- {
4610
- onClick: (me) => {
4611
- me.stopPropagation(), C(z), r.isOpen && r.toggle();
4612
- },
4613
- className: "cursor-pointer rounded bg-transparent hover:text-black",
4614
- asChild: !0,
4615
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { size: "15" })
4616
- }
4617
- ),
4618
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: v("Hide block") })
4619
- ] })
4620
- ] })
4621
- ]
4622
- }
4623
- )
4624
- ]
4311
+ return ue;
4625
4312
  }
4626
- ) }) });
4627
- }), Input = ({ node: r }) => {
4628
- var h, g;
4629
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4630
- "input",
4631
- {
4632
- autoFocus: !0,
4633
- className: cn(
4634
- "ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
4635
- r.isSelected ? "text-black dark:text-white" : ""
4636
- ),
4637
- type: "text",
4638
- defaultValue: ((h = r.data) == null ? void 0 : h._name) || ((g = r.data) == null ? void 0 : g._type),
4639
- onFocus: (x) => x.currentTarget.select(),
4640
- onBlur: (x) => r.submit(x.currentTarget.value),
4641
- onKeyDown: (x) => {
4642
- x.key === "Enter" && r.submit(x.currentTarget.value);
4643
- }
4644
- }
4645
- );
4646
- }, useCanMove = () => {
4647
- const [r] = useBlocksStore();
4648
- return (h, g) => {
4649
- var S;
4650
- const x = (S = find(r, { _id: g })) == null ? void 0 : S._type, v = first(h.map((C) => {
4651
- var R;
4652
- return (R = find(r, { _id: C })) == null ? void 0 : R._type;
4653
- }));
4654
- return canAcceptChildBlock(x, v);
4655
- };
4656
- }, ListTree = () => {
4657
- const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), [, setHiddenBlocks] = useHiddenBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), [parentContext, setParentContext] = useState(null), clearSelection = () => {
4658
- setIds([]), setStyleBlocks([]);
4659
- }, filteredTreeData = useMemo(() => {
4660
- const r = (g, x) => g.filter((v) => !x.includes(v._id)).map((v) => ({
4661
- ...v,
4662
- children: v.children ? r(v.children, x) : []
4663
- }));
4664
- return [...r(treeData, cutBlocksIds), { _type: ROOT_TEMP_KEY, _id: ROOT_TEMP_KEY, children: [] }];
4665
- }, [treeData, cutBlocksIds]), onRename = ({ id: r, name: h, node: g }) => {
4666
- updateBlockProps([r], { _name: h }, g.data._name);
4667
- }, onMove = ({ dragIds: r, parentId: h, index: g }) => {
4668
- canMove(r, h) && moveBlocks(r, h, g);
4669
- }, onSelect = (r) => {
4670
- if (r.length === 0) return;
4671
- const h = r[0] ? r[0].id : "";
4672
- setStyleBlocks([]), setIds([h]);
4673
- }, onContextMenu = (r) => {
4674
- var x;
4675
- r.preventDefault(), parentContext && setParentContext(null);
4676
- const h = r.target, g = h.getAttribute("data-node-id") || ((x = h.closest("[data-node-id]")) == null ? void 0 : x.getAttribute("data-node-id"));
4677
- g ? (setStyleBlocks([]), setIds([g])) : (setStyleBlocks([]), setIds([]), setParentContext({ x: r.clientX, y: r.clientY }));
4678
- }, debouncedDisableDrop = useDebouncedCallback(
4679
- ({ parentNode: r, dragNodes: h }) => {
4680
- var g;
4681
- return (r == null ? void 0 : r.data._type) === ROOT_TEMP_KEY || !canAcceptChildBlock(r == null ? void 0 : r.data._type, (g = h[0]) == null ? void 0 : g.data._type);
4682
- },
4683
- [],
4684
- 300
4685
- ), handleKeyDown = (e) => {
4686
- if (!treeRef.current) return;
4687
- const tree = treeRef.current, selectedNode = tree.selectedNodes[0];
4688
- if (!selectedNode) return;
4689
- setIds[selectedNode.id], setStyleBlocks([]);
4690
- const isLeaf = !selectedNode.isInternal, isClosed = !selectedNode.isOpen, isOpen = selectedNode.isOpen, shortcut = defaultShortcuts.find((s) => s.key === e.key && (!s.when || eval(s.when)));
4691
- if (shortcut)
4692
- switch (e.preventDefault(), shortcut.command) {
4693
- case "selectNext":
4694
- selectNext(tree);
4695
- break;
4696
- case "selectPrev":
4697
- selectPrev(tree);
4698
- break;
4699
- case "selectParent":
4700
- selectParent(tree, isLeaf || isClosed);
4701
- break;
4702
- case "close":
4703
- close(tree, isOpen);
4704
- break;
4705
- case "open":
4706
- open(tree, isClosed);
4707
- break;
4708
- case "selectFirst":
4709
- selectFirst(tree);
4710
- break;
4711
- case "selectLast":
4712
- selectLast(tree);
4713
- break;
4714
- }
4715
- };
4716
- return useEffect(() => {
4717
- const r = () => {
4718
- treeRef.current && setTreeRef(treeRef.current);
4719
- };
4720
- r();
4721
- const h = new MutationObserver(r);
4722
- return h.observe(document.body, { childList: !0, subtree: !0 }), () => h.disconnect();
4723
- }, [setTreeRef]), isEmpty(treeData) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
4724
- t("This page is empty"),
4725
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4726
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4727
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK), variant: "default", size: "sm", children: [
4728
- "+ ",
4729
- t("Add Block")
4730
- ] })
4731
- ] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4732
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4733
- "div",
4734
- {
4735
- id: "outline-view",
4736
- className: "no-scrollbar h-full overflow-y-auto text-sm",
4737
- onKeyDown: (r) => {
4738
- treeRef.current.isEditing || handleKeyDown(r);
4739
- },
4740
- children: [
4741
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground", children: [
4742
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4743
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4744
- Button,
4745
- {
4746
- onClick: () => setHiddenBlocks([]),
4747
- variant: "outline",
4748
- className: "h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",
4749
- size: "sm",
4750
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })
4751
- }
4752
- ) }),
4753
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Show hidden blocks") })
4754
- ] }),
4755
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4756
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4757
- var r;
4758
- return (r = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : r.openAll();
4759
- }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiExpandVertical, { size: "14" }) }) }),
4760
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Expand all") })
4761
- ] }),
4762
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4763
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4764
- var r;
4765
- return (r = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : r.closeAll();
4766
- }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiCollapseVertical, { size: "14" }) }) }),
4767
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Collapse all") })
4768
- ] })
4769
- ] }),
4770
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative z-[9999] ml-5 w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4771
- "div",
4772
- {
4773
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: 0 }),
4774
- className: "h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4775
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[3] text-white" }) })
4776
- }
4777
- ) }),
4778
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4779
- Tree,
4780
- {
4781
- ref: treeRef,
4782
- height: window.innerHeight - 160,
4783
- className: "no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",
4784
- rowClassName: "flex items-center h-full border-b border-transparent",
4785
- selection: ids[0] || "",
4786
- onRename,
4787
- openByDefault: !1,
4788
- onMove,
4789
- data: [...filteredTreeData],
4790
- renderCursor: DefaultCursor,
4791
- onSelect,
4792
- childrenAccessor: (r) => r.children,
4793
- width: "100%",
4794
- rowHeight: 28,
4795
- renderDragPreview: DefaultDragPreview,
4796
- indent: 10,
4797
- onContextMenu,
4798
- disableDrop: debouncedDisableDrop,
4799
- idAccessor: "_id",
4800
- children: Node
4801
- }
4802
- )
4803
- ]
4804
- }
4805
- ) }),
4806
- /* @__PURE__ */ jsxRuntimeExports.jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
4807
- ] });
4808
- }, hasVideoEmbed = (r) => {
4809
- const h = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, g = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
4810
- return h.test(r) || g.test(r);
4811
- }, getVideoURLFromHTML = (r) => {
4812
- if (isEmpty(r)) return r;
4813
- const h = /<video[^>]+src=['"]([^'">]+)['"]/, g = /<iframe[^>]+src=['"]([^'">]+)['"]/, x = r.match(h), v = r.match(g), S = x ? x[1] : v ? v[1] : null, C = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, R = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
4814
- return S && (C.test(S) || R.test(S)) ? S : r;
4815
- }, NAME_ATTRIBUTES = ["chai-name", "data-chai-name"], ATTRIBUTE_MAP = {
4816
- img: { alt: "alt", width: "width", height: "height", src: "image" },
4817
- video: {
4818
- src: "url",
4819
- autoplay: "controls.autoPlay",
4820
- muted: "controls.muted",
4821
- loop: "controls.loop",
4822
- controls: "controls.widgets"
4823
- },
4824
- a: {
4825
- href: "link.href",
4826
- target: "link.target",
4827
- type: ""
4828
- // @TODO: Detect here what to url, email, phone, elementId
4829
- },
4830
- input: {
4831
- placeholder: "placeholder",
4832
- required: "required",
4833
- type: "inputType",
4834
- name: "fieldName"
4835
- },
4836
- textarea: {
4837
- placeholder: "placeholder",
4838
- required: "required",
4839
- type: "inputType",
4840
- name: "fieldName"
4841
- },
4842
- select: {
4843
- placeholder: "placeholder",
4844
- required: "required",
4845
- multiple: "multiple",
4846
- name: "fieldName"
4847
- }
4848
- }, shouldAddText = (r, h) => r.children.length === 1 && includes(
4849
- ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
4850
- h._type
4851
- ), getTextContent = (r) => r.map((h) => h.type === "text" ? get(h, "content", "") : isEmpty(h.children) ? "" : getTextContent(h.children)).join(""), getSanitizedValue = (r) => r === null ? "" : r, getAttrs = (r) => {
4852
- if (r.tagName === "svg") return {};
4853
- const h = {}, g = ATTRIBUTE_MAP[r.tagName] || {}, x = r.attributes;
4854
- return forEach(x, ({ key: v, value: S }) => {
4855
- if (!includes(NAME_ATTRIBUTES, v))
4856
- if (g[v]) {
4857
- if (r.tagName === "img" && v === "src" && !S.startsWith("http")) {
4858
- const C = find(r.attributes, { key: "width" }), R = find(r.attributes, { key: "height" });
4859
- C && R ? S = `https://via.placeholder.com/${C == null ? void 0 : C.value}x${R == null ? void 0 : R.value}` : S = "https://via.placeholder.com/150x150";
4860
- }
4861
- set(h, g[v], getSanitizedValue(S));
4862
- } else includes(["style", "class", "srcset"], v) || (has(h, "styles_attrs") || (h.styles_attrs = {}), startsWith(v, "@") && (v = v.replace("@", "x-on:")), h.styles_attrs[`${v}`] = getSanitizedValue(S));
4863
- }), delete h.class, h;
4864
- }, getStyles = (r, h = "styles") => {
4865
- if (!r.attributes) return { [h]: `${STYLES_KEY},` };
4866
- const g = find(r.attributes, { key: "class" });
4867
- if (g) {
4868
- const x = g.value;
4869
- return { [h]: `${STYLES_KEY},${x}` };
4870
- }
4871
- return { [h]: `${STYLES_KEY},` };
4872
- }, getBlockProps = (r) => {
4873
- const h = get(r, "attributes", []), g = h.find((R) => R.key === "data-chai-richtext" || R.key === "chai-richtext"), x = h.find((R) => R.key === "data-chai-lightbox" || R.key === "chai-lightbox"), v = h.find((R) => R.key === "data-chai-dropdown" || R.key === "chai-dropdown"), S = h.find(
4874
- (R) => R.key === "data-chai-dropdown-button" || R.key === "chai-dropdown-button"
4875
- ), C = h.find(
4876
- (R) => R.key === "data-chai-dropdown-content" || R.key === "chai-dropdown-content"
4877
- );
4878
- if (v)
4879
- return { _type: "Dropdown" };
4880
- if (S)
4881
- return { _type: "DropdownButton" };
4882
- if (C)
4883
- return { _type: "DropdownContent" };
4884
- if (g)
4885
- return { _type: "RichText" };
4886
- if (x)
4887
- return { _type: "LightBoxLink" };
4888
- switch (r.tagName) {
4889
- // self closing tags
4890
- case "img":
4891
- return { _type: "Image" };
4892
- case "input":
4893
- return { _type: "Input", showLabel: !1 };
4894
- // showLabel: hiding default block label
4895
- case "hr":
4896
- return { _type: "Divider" };
4897
- case "br":
4898
- return { _type: "LineBreak" };
4899
- case "textarea":
4900
- return { _type: "TextArea", showLabel: !1 };
4901
- case "audio":
4902
- return { _type: "Audio" };
4903
- case "canvas":
4904
- return { _type: "Canvas" };
4905
- case "video":
4906
- case "iframe":
4907
- return { _type: "CustomHTML" };
4908
- case "svg":
4909
- return { _type: "Icon" };
4910
- // non self closing tags
4911
- // fixed structure
4912
- case "select":
4913
- return { _type: "Select", options: [] };
4914
- case "option":
4915
- return { _type: "Option" };
4916
- case "ul":
4917
- case "ol":
4918
- case "dl":
4919
- return {
4920
- _type: "List",
4921
- tag: r.tagName,
4922
- _listType: r.tagName === "ol" ? "list-decimal" : "list-none"
4923
- };
4924
- case "li":
4925
- case "dt":
4926
- return { _type: "ListItem", tag: r.tagName };
4927
- // non self closing tags
4928
- // free flow structure
4929
- case "span":
4930
- case "figcaption":
4931
- case "legend":
4932
- return { _type: "Span", tag: r.tagName };
4933
- case "p":
4934
- return { _type: "Paragraph", content: "" };
4935
- case "a":
4936
- return { _type: "Link" };
4937
- case "form":
4938
- return { _type: "Form" };
4939
- case "label":
4940
- return { _type: "Label" };
4941
- case "button":
4942
- return { _type: "Button" };
4943
- case "code":
4944
- return { _type: "Code" };
4945
- case "h1":
4946
- case "h2":
4947
- case "h3":
4948
- case "h4":
4949
- case "h5":
4950
- case "h6":
4951
- return { _type: "Heading", tag: r.tagName };
4952
- case "table":
4953
- return { _type: "Table" };
4954
- case "tr":
4955
- return { _type: "TableRow" };
4956
- case "td":
4957
- case "th":
4958
- return { _type: "TableCell", tag: r.tagName };
4959
- case "thead":
4960
- return { _type: "TableHead" };
4961
- case "tbody":
4962
- return { _type: "TableBody" };
4963
- case "tfoot":
4964
- return { _type: "TableFooter" };
4965
- default: {
4966
- const R = get(r, "children", []).length > 0 ? "Box" : "EmptyBox";
4967
- return {
4968
- _type: R,
4969
- tag: r.tagName,
4970
- _name: R == "EmptyBox" || r.tagName === "div" ? R : capitalize(r.tagName)
4971
- };
4972
- }
4973
- }
4974
- }, traverseNodes = (r, h = null) => flatMapDeep(r, (g) => {
4975
- var O, z, Z, G, q, ee, ge, le;
4976
- if (g.type === "comment") return [];
4977
- console.log("node ===>", g);
4978
- let x = { _id: generateUUID() };
4979
- if (h && (x._parent = h.block._id), g.type === "text")
4980
- return isEmpty(get(g, "content", "")) ? [] : h && shouldAddText(h.node, h.block) ? (set(h, "block.content", get(g, "content", "")), []) : { ...x, _type: "Text", content: get(g, "content", "") };
4981
- const v = get(g, "attributes", []), S = v.find(
4982
- (ce) => ce.key === "data-chai-richtext" || ce.key === "chai-richtext"
4983
- ), C = v.find(
4984
- (ce) => ce.key === "data-chai-lightbox" || ce.key === "chai-lightbox"
4985
- ), R = v.find(
4986
- (ce) => ce.key === "data-chai-dropdown" || ce.key === "chai-dropdown"
4987
- ), A = v.find(
4988
- (ce) => ce.key === "data-chai-dropdown-button" || ce.key === "chai-dropdown-button"
4989
- ), T = v.find(
4990
- (ce) => ce.key === "data-chai-dropdown-content" || ce.key === "chai-dropdown-content"
4991
- );
4992
- if (x = {
4993
- ...x,
4994
- ...getBlockProps(g),
4995
- ...getAttrs(g),
4996
- ...getStyles(g)
4997
- }, g.attributes) {
4998
- const ce = g.attributes.find(($) => includes(NAME_ATTRIBUTES, $.key));
4999
- ce && (x._name = ce.value);
5000
- }
5001
- if (S)
5002
- return x.content = stringify(g.children), has(x, "styles_attrs.data-chai-richtext") && delete x.styles_attrs["data-chai-richtext"], has(x, "styles_attrs.chai-richtext") && delete x.styles_attrs["chai-richtext"], [x];
5003
- if (C) {
5004
- const ce = [
5005
- "data-chai-lightbox",
5006
- "chai-lightbox",
5007
- "data-vbtype",
5008
- "data-autoplay",
5009
- "data-maxwidth",
5010
- "data-overlay",
5011
- "data-gall",
5012
- "href"
5013
- ];
5014
- x = {
5015
- ...x,
5016
- href: ((O = v.find(($) => $.key === "href")) == null ? void 0 : O.value) || "",
5017
- hrefType: ((z = v.find(($) => $.key === "data-vbtype")) == null ? void 0 : z.value) || "video",
5018
- autoplay: ((Z = v.find(($) => $.key === "data-autoplay")) == null ? void 0 : Z.value) === "true" ? "true" : "false",
5019
- maxWidth: ((q = (G = v.find(($) => $.key === "data-maxwidth")) == null ? void 0 : G.value) == null ? void 0 : q.replace("px", "")) || "",
5020
- backdropColor: ((ee = v.find(($) => $.key === "data-overlay")) == null ? void 0 : ee.value) || "",
5021
- galleryName: ((ge = v.find(($) => $.key === "data-gall")) == null ? void 0 : ge.value) || ""
5022
- }, forEach(ce, ($) => {
5023
- has(x, `styles_attrs.${$}`) && delete x.styles_attrs[$];
5024
- });
5025
- }
5026
- if (R && (delete x.styles_attrs, x.showDropdown = !1), T && delete x.styles_attrs, A) {
5027
- delete x.styles_attrs;
5028
- const ce = filter(g.children || [], (ie) => (ie == null ? void 0 : ie.tagName) !== "span");
5029
- x.content = getTextContent(ce);
5030
- const $ = find(
5031
- g.children || [],
5032
- (ie) => (ie == null ? void 0 : ie.tagName) === "span" && some(ie.children || [], (he) => (he == null ? void 0 : he.tagName) === "svg")
5033
- );
5034
- if ($) {
5035
- const ie = find($.children || [], (he) => (he == null ? void 0 : he.tagName) === "svg");
5036
- if (ie) {
5037
- x.icon = stringify([ie]);
5038
- const { height: he, width: Se } = getSvgDimensions(ie, "16px", "16px");
5039
- x.iconHeight = he, x.iconWidth = Se;
5040
- }
5041
- }
5042
- return [x];
5043
- }
5044
- if (x._type === "Input") {
5045
- const ce = x.inputType || "text";
5046
- ce === "checkbox" ? set(x, "_type", "Checkbox") : ce === "radio" && set(x, "_type", "Radio");
5047
- } else if (g.tagName === "video" || g.tagName === "iframe") {
5048
- const ce = stringify([g]);
5049
- return hasVideoEmbed(ce) && (set(x, "_type", "Video"), set(x, "url", getVideoURLFromHTML(ce)), set(x, "styles", `${STYLES_KEY},`), set(x, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), x.content = ce, [x];
5050
- } else if (g.tagName === "svg") {
5051
- const ce = find(g.attributes, { key: "height" }), $ = find(g.attributes, { key: "width" }), ie = get(ce, "value") ? `[${get(ce, "value")}px]` : "24px", he = get($, "value") ? `[${get($, "value")}px]` : "24px", Se = get(find(g.attributes, { key: "class" }), "value", "w-full h-full");
5052
- return x.styles = `${STYLES_KEY}, ${cn(`w-${he} h-${ie}`, Se)}`.trim(), g.attributes = filter(g.attributes, (Me) => !includes(["style", "width", "height", "class"], Me.key)), x.icon = stringify([g]), [x];
5053
- } else if (g.tagName == "option" && h && ((le = h.block) == null ? void 0 : le._type) === "Select")
5054
- return h.block.options.push({
5055
- label: getTextContent(g.children),
5056
- ...getAttrs(g)
5057
- }), [];
5058
- const _ = traverseNodes(g.children, { block: x, node: g });
5059
- return [x, ..._];
5060
- }), getSvgDimensions = (r, h, g) => {
5061
- const x = get(r, "attributes", []), v = find(x, { key: "height" }), S = find(x, { key: "width" });
5062
- return {
5063
- height: get(v, "value") ? `[${get(v, "value")}px]` : g,
5064
- width: get(S, "value") ? `[${get(S, "value")}px]` : h
5065
- };
5066
- }, getSanitizedHTML = (r) => {
5067
- r = r.replace(/(\w+)=\\?"(.*?)\\?"/g, (x, v, S) => {
5068
- let C = S.replace(/\\"/g, '"');
5069
- return C = C.replace(/{([^}]+)}/g, (R) => R.replace(/"/g, '\\"')), `${v}="${C.replace(/\\"/g, '"')}"`;
5070
- }), r = r.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, "");
5071
- const h = r.match(/<body[^>]*>[\s\S]*?<\/body>/);
5072
- return (h && h.length > 0 ? h[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : r).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
5073
- }, getBlocksFromHTML = (r) => {
5074
- const h = parse(getSanitizedHTML(r));
5075
- return isEmpty(r) ? [] : flatten(traverseNodes(h));
5076
- }, ImportHTML = ({ parentId: r, position: h }) => {
5077
- const { t: g } = useTranslation(), [x, v] = useState(""), { addPredefinedBlock: S } = useAddBlock(), C = () => {
5078
- const R = getBlocksFromHTML(x);
5079
- S([...R], r, h), v(""), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
5080
- };
5081
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
5082
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardDescription, { children: g("Use HTML snippets from Tailwind CSS component libraries") }) }),
5083
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-2 px-3 py-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
5084
- /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "current", className: "text-sm", children: g("Tailwind HTML snippet") }),
5085
- /* @__PURE__ */ jsxRuntimeExports.jsx(
5086
- Textarea,
5087
- {
5088
- autoFocus: !0,
5089
- tabIndex: 1,
5090
- ref: (R) => R && R.focus(),
5091
- onChange: (R) => v(R.target.value),
5092
- rows: 12,
5093
- value: x,
5094
- placeholder: g("Enter your code snippet here"),
5095
- className: "resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"
5096
- }
5097
- )
5098
- ] }) }),
5099
- /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: x.trim() === "", onClick: () => C(), size: "sm", className: "w-fit", children: g("Import HTML") }) })
5100
- ] });
5101
- }, GlobalBlockSettings = () => {
5102
- const r = useSelectedBlock(), { data: h, refetch: g, isLoading: x } = useGlobalBlocksList(), v = useUpdateBlocksProps();
5103
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5104
- /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-sm", children: "Choose a global block" }),
5105
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
5106
- "select",
5107
- {
5108
- className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
5109
- value: (r == null ? void 0 : r.globalBlock) || "",
5110
- onChange: (S) => {
5111
- var C;
5112
- v([r._id], {
5113
- globalBlock: S.target.value,
5114
- _name: `Global: ${startCase((C = get(h, S.target.value, "")) == null ? void 0 : C.name)}`
5115
- });
5116
- },
5117
- children: [
5118
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select a global block" }),
5119
- Object.keys(h).map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: S, children: h[S].name || S }, S))
5120
- ]
5121
- }
5122
- ),
5123
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5124
- "button",
5125
- {
5126
- onClick: g,
5127
- className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
5128
- children: x ? "Loading..." : "Refresh List"
5129
- }
5130
- ) })
5131
- ] });
5132
- }, BindingWidget = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" });
5133
- var client = { exports: {} }, reactDomClient_production = {}, scheduler = { exports: {} }, scheduler_production = {};
5134
- /**
5135
- * @license React
5136
- * scheduler.production.js
5137
- *
5138
- * Copyright (c) Meta Platforms, Inc. and affiliates.
5139
- *
5140
- * This source code is licensed under the MIT license found in the
5141
- * LICENSE file in the root directory of this source tree.
5142
- */
5143
- var hasRequiredScheduler_production;
5144
- function requireScheduler_production() {
5145
- return hasRequiredScheduler_production || (hasRequiredScheduler_production = 1, function(r) {
5146
- function h(V, ue) {
5147
- var de = V.length;
5148
- V.push(ue);
5149
- e: for (; 0 < de; ) {
5150
- var Ae = de - 1 >>> 1, Ee = V[Ae];
5151
- if (0 < v(Ee, ue))
5152
- V[Ae] = ue, V[de] = Ee, de = Ae;
5153
- else break e;
5154
- }
5155
- }
5156
- function g(V) {
5157
- return V.length === 0 ? null : V[0];
5158
- }
5159
- function x(V) {
5160
- if (V.length === 0) return null;
5161
- var ue = V[0], de = V.pop();
5162
- if (de !== ue) {
5163
- V[0] = de;
5164
- e: for (var Ae = 0, Ee = V.length, Ge = Ee >>> 1; Ae < Ge; ) {
5165
- var Ye = 2 * (Ae + 1) - 1, Qt = V[Ye], Oe = Ye + 1, Mt = V[Oe];
5166
- if (0 > v(Qt, de))
5167
- Oe < Ee && 0 > v(Mt, Qt) ? (V[Ae] = Mt, V[Oe] = de, Ae = Oe) : (V[Ae] = Qt, V[Ye] = de, Ae = Ye);
5168
- else if (Oe < Ee && 0 > v(Mt, de))
5169
- V[Ae] = Mt, V[Oe] = de, Ae = Oe;
5170
- else break e;
5171
- }
5172
- }
5173
- return ue;
5174
- }
5175
- function v(V, ue) {
5176
- var de = V.sortIndex - ue.sortIndex;
5177
- return de !== 0 ? de : V.id - ue.id;
5178
- }
5179
- if (r.unstable_now = void 0, typeof performance == "object" && typeof performance.now == "function") {
5180
- var S = performance;
5181
- r.unstable_now = function() {
5182
- return S.now();
5183
- };
5184
- } else {
5185
- var C = Date, R = C.now();
5186
- r.unstable_now = function() {
5187
- return C.now() - R;
5188
- };
5189
- }
5190
- var A = [], T = [], _ = 1, O = null, z = 3, Z = !1, G = !1, q = !1, ee = typeof setTimeout == "function" ? setTimeout : null, ge = typeof clearTimeout == "function" ? clearTimeout : null, le = typeof setImmediate < "u" ? setImmediate : null;
5191
- function ce(V) {
5192
- for (var ue = g(T); ue !== null; ) {
5193
- if (ue.callback === null) x(T);
5194
- else if (ue.startTime <= V)
5195
- x(T), ue.sortIndex = ue.expirationTime, h(A, ue);
5196
- else break;
5197
- ue = g(T);
4313
+ function v(V, ue) {
4314
+ var de = V.sortIndex - ue.sortIndex;
4315
+ return de !== 0 ? de : V.id - ue.id;
4316
+ }
4317
+ if (r.unstable_now = void 0, typeof performance == "object" && typeof performance.now == "function") {
4318
+ var S = performance;
4319
+ r.unstable_now = function() {
4320
+ return S.now();
4321
+ };
4322
+ } else {
4323
+ var C = Date, R = C.now();
4324
+ r.unstable_now = function() {
4325
+ return C.now() - R;
4326
+ };
4327
+ }
4328
+ var A = [], T = [], _ = 1, O = null, z = 3, Z = !1, G = !1, q = !1, ee = typeof setTimeout == "function" ? setTimeout : null, ge = typeof clearTimeout == "function" ? clearTimeout : null, le = typeof setImmediate < "u" ? setImmediate : null;
4329
+ function ce(V) {
4330
+ for (var ue = g(T); ue !== null; ) {
4331
+ if (ue.callback === null) x(T);
4332
+ else if (ue.startTime <= V)
4333
+ x(T), ue.sortIndex = ue.expirationTime, h(A, ue);
4334
+ else break;
4335
+ ue = g(T);
5198
4336
  }
5199
4337
  }
5200
4338
  function $(V) {
@@ -31002,1068 +30140,2041 @@ const EDITOR_ICONS = {
31002
30140
  d: "M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",
31003
30141
  fill: "currentColor"
31004
30142
  }
31005
- ),
31006
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31007
- "path",
31008
- {
31009
- fillRule: "evenodd",
31010
- clipRule: "evenodd",
31011
- d: "M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",
31012
- fill: "currentColor"
30143
+ ),
30144
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30145
+ "path",
30146
+ {
30147
+ fillRule: "evenodd",
30148
+ clipRule: "evenodd",
30149
+ d: "M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",
30150
+ fill: "currentColor"
30151
+ }
30152
+ )
30153
+ ] }),
30154
+ relative: () => /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30155
+ "path",
30156
+ {
30157
+ fillRule: "evenodd",
30158
+ clipRule: "evenodd",
30159
+ d: "M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",
30160
+ fill: "currentColor"
30161
+ }
30162
+ ) }),
30163
+ sticky: () => /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
30164
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30165
+ "path",
30166
+ {
30167
+ d: "M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",
30168
+ fill: "currentColor"
30169
+ }
30170
+ ),
30171
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30172
+ "path",
30173
+ {
30174
+ opacity: "0.6",
30175
+ fillRule: "evenodd",
30176
+ clipRule: "evenodd",
30177
+ d: "M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",
30178
+ fill: "currentColor"
30179
+ }
30180
+ )
30181
+ ] }),
30182
+ static: Cross1Icon
30183
+ }, StyleContext = createContext({ canReset: !1, canChange: !0 }), BlockStyleProvider = ({ children: r, canReset: h = !1, canChange: g = !0 }) => (
30184
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
30185
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StyleContext.Provider, { value: { canReset: h, canChange: g }, children: r })
30186
+ ), DropDownChoices = ({ label: r, property: h, onChange: g }) => {
30187
+ const { getClasses: x } = useTailwindClassList(), v = x(h), S = useCurrentClassByProperty(h), C = useMemo(() => get(S, "cls", ""), [S]), { canChange: R } = useContext(StyleContext), A = /\[.*\]/g.test(C);
30188
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r ? "w-full rounded" : "grow", children: A ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
30189
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: C }),
30190
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
30191
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
30192
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind arbitrary value." })
30193
+ ] })
30194
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
30195
+ DropDown,
30196
+ {
30197
+ rounded: r,
30198
+ onChange: (T) => g(T, h),
30199
+ selected: C,
30200
+ options: v,
30201
+ disabled: !R
30202
+ }
30203
+ ) });
30204
+ };
30205
+ function DropDown({ selected: r, onChange: h, rounded: g = !1, options: x, disabled: v = !1 }) {
30206
+ const S = r.replace(/.*:/g, "").trim(), { undo: C, redo: R } = useUndoManager();
30207
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
30208
+ "select",
30209
+ {
30210
+ disabled: !x.length || v,
30211
+ className: `${g ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
30212
+ onChange: (A) => h(A.target.value),
30213
+ onKeyDown: (A) => {
30214
+ A.ctrlKey && (A.key === "z" && C(), A.key === "y" && R());
30215
+ },
30216
+ value: S,
30217
+ children: [
30218
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: "" }),
30219
+ React__default.Children.toArray(
30220
+ x.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: A, children: A }))
30221
+ )
30222
+ ]
30223
+ }
30224
+ );
30225
+ }
30226
+ const RangeChoices = ({ property: r, onChange: h }) => {
30227
+ const { canReset: g, canChange: x } = useContext(StyleContext), v = useCurrentClassByProperty(r), S = useMemo(() => get(v, "cls", ""), [v]), { getClasses: C } = useTailwindClassList(), R = C(r, [""]), A = R.indexOf(S) > -1 ? R.indexOf(S) : 0, T = /\[.*\]/g.test(S);
30228
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: T ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2 py-[5px]", children: S }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
30229
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30230
+ "button",
30231
+ {
30232
+ type: "button",
30233
+ className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
30234
+ disabled: !x && (!g || A - 1 < 0),
30235
+ onClick: () => h(nth(R, A - 1), r),
30236
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30237
+ MinusIcon,
30238
+ {
30239
+ className: !x && (!g || A - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
30240
+ }
30241
+ ) })
30242
+ }
30243
+ ),
30244
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8/12 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: !1, property: r, onChange: h }) }),
30245
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30246
+ "button",
30247
+ {
30248
+ type: "button",
30249
+ className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
30250
+ disabled: !x && (!g || A + 1 >= R.length),
30251
+ onClick: () => h(nth(R, A + 1), r),
30252
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30253
+ PlusIcon,
30254
+ {
30255
+ className: !x && (!g || A + 1 >= R.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
30256
+ }
30257
+ ) })
30258
+ }
30259
+ )
30260
+ ] }) });
30261
+ }, IconChoices = ({ property: r, onChange: h }) => {
30262
+ const { getClasses: g } = useTailwindClassList(), x = g(r), { canChange: v } = useContext(StyleContext), S = useCurrentClassByProperty(r), C = useMemo(() => get(S, "cls", ""), [S]);
30263
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex grow flex-wrap gap-1", children: map(x, (R) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
30264
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30265
+ "button",
30266
+ {
30267
+ type: "button",
30268
+ disabled: !v,
30269
+ onClick: () => h(R, r),
30270
+ className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${C === R ? "bg-blue-500 text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
30271
+ children: React__default.createElement(get(EDITOR_ICONS, R, BoxIcon))
30272
+ }
30273
+ ) }),
30274
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(R)) })
30275
+ ] })) });
30276
+ }, COLOR_PROP = {
30277
+ backgroundColor: "bg",
30278
+ textColor: "text",
30279
+ borderColor: "border",
30280
+ boxShadowColor: "shadow",
30281
+ outlineColor: "outline",
30282
+ divideColor: "divide",
30283
+ fromColor: "from",
30284
+ viaColor: "via",
30285
+ toColor: "to",
30286
+ ringColor: "ring",
30287
+ ringOffsetColor: "ring-offset"
30288
+ }, ColorChoice = ({ property: r, onChange: h }) => {
30289
+ const g = useCurrentClassByProperty(r), x = useMemo(() => get(g, "cls", ""), [g]), { canChange: v } = useContext(StyleContext), [S, C] = useState([]), [R, A] = useState({ color: "", shade: "" }), T = x.split("-"), _ = get(T, "1", ""), O = get(T, "2", ""), z = useCallback(
30290
+ // eslint-disable-next-line no-shadow
30291
+ (q) => {
30292
+ ["current", "inherit", "transparent", "black", "white"].includes(q) ? (C([]), A({ color: q })) : (C(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), A((ee) => ({ ...ee, color: q, shade: ee.shade ? ee.shade : "500" })));
30293
+ },
30294
+ [C, A]
30295
+ );
30296
+ useEffect(() => {
30297
+ if (["current", "inherit", "transparent", "black", "white"].includes(_))
30298
+ return C([]);
30299
+ C(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
30300
+ }, [_]);
30301
+ const Z = useCallback(
30302
+ // eslint-disable-next-line no-shadow
30303
+ (q) => {
30304
+ A({ color: _, shade: q });
30305
+ },
30306
+ [_]
30307
+ );
30308
+ useEffect(() => {
30309
+ A({ color: "", shade: "" });
30310
+ }, [g]);
30311
+ const { match: G } = useTailwindClassList();
30312
+ return useEffect(() => {
30313
+ const ee = `${get(COLOR_PROP, r, "")}-${R.color}${R.shade ? `-${R.shade}` : ""}`;
30314
+ G(r, ee) && h(ee, r);
30315
+ }, [G, R, h, r]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
30316
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30317
+ DropDown,
30318
+ {
30319
+ disabled: !v,
30320
+ rounded: !0,
30321
+ selected: _,
30322
+ onChange: z,
30323
+ options: [
30324
+ "current",
30325
+ "transparent",
30326
+ "primary",
30327
+ "secondary",
30328
+ "black",
30329
+ "white",
30330
+ "slate",
30331
+ "gray",
30332
+ "zinc",
30333
+ "neutral",
30334
+ "stone",
30335
+ "red",
30336
+ "orange",
30337
+ "amber",
30338
+ "yellow",
30339
+ "lime",
30340
+ "green",
30341
+ "emerald",
30342
+ "teal",
30343
+ "cyan",
30344
+ "sky",
30345
+ "blue",
30346
+ "indigo",
30347
+ "violet",
30348
+ "purple",
30349
+ "fuchsia",
30350
+ "pink",
30351
+ "rose"
30352
+ ]
30353
+ }
30354
+ ) }),
30355
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: O, disabled: !_ || !v, onChange: Z, options: S }) })
30356
+ ] });
30357
+ }, getUserInputValues = (r, h) => {
30358
+ r = r.toLowerCase();
30359
+ let g = r.trim().replace(/ |\+/g, "");
30360
+ if ((g === "auto" || g === "none") && h.includes(g))
30361
+ return { value: "", unit: g };
30362
+ const x = h.length ? new RegExp(h.join("|"), "g") : /XXXXXX/g;
30363
+ g = g.replace(x, "");
30364
+ const v = r.match(x), S = v && v.length > 1, C = !isEmpty(g) && Number.isNaN(Number(g));
30365
+ return S || C ? { error: "Invalid value" } : v && (v[0] === "auto" || v[0] === "none") ? { value: v[0], unit: "" } : { value: g, unit: v ? v[0] : "" };
30366
+ }, getTwClassValue = (r) => {
30367
+ const h = r.startsWith("-") ? "-" : "", g = r.split("-").pop();
30368
+ if (["auto", "none"].includes(g))
30369
+ return { value: "", unit: g };
30370
+ if (g === "px") return { value: "1", unit: "px" };
30371
+ if (g === "screen") return { value: "100", unit: r.indexOf("w-") !== -1 ? "vw" : "vh" };
30372
+ if (g === "full") return { value: "100", unit: "%" };
30373
+ if (includes(r, "skew-"))
30374
+ return { value: `${h}${g}`, unit: "deg" };
30375
+ if (includes(r, "rotate-"))
30376
+ return { value: `${h}${g}`, unit: "deg" };
30377
+ if (includes(r, "opacity-"))
30378
+ return { value: `${g / 100}`, unit: "-" };
30379
+ if (includes(r, "duration-") || includes(r, "delay-"))
30380
+ return { value: `${g}`, unit: "ms" };
30381
+ if (includes(r, "translate-") && !g.includes("/"))
30382
+ return { value: `${h}${`${g / 4}`}`, unit: "rem" };
30383
+ if (includes(r, "scale-"))
30384
+ return { value: `${h}${`${g / 100}`}`, unit: "-" };
30385
+ if (startsWith(r, "border")) {
30386
+ const x = r.match(/border-?(x|y|t|r|b|l)?\d+/g);
30387
+ if (x) return { value: x[0].split("-").pop(), unit: "px" };
30388
+ if (r.match(/border-?(x|y|t|r|b|l)?/g)) return { value: "1", unit: "px" };
30389
+ }
30390
+ if (startsWith(r, "max-w-")) {
30391
+ if (r === "max-w-screen-sm") return { value: "640", unit: "px" };
30392
+ if (r === "max-w-screen-md") return { value: "768", unit: "px" };
30393
+ if (r === "max-w-screen-lg") return { value: "1024", unit: "px" };
30394
+ if (r === "max-w-screen-xl") return { value: "1280", unit: "px" };
30395
+ if (r === "max-w-screen-2xl") return { value: "1536", unit: "px" };
30396
+ if (g === "xs") return { value: "320", unit: "px" };
30397
+ if (g === "sm") return { value: "384", unit: "px" };
30398
+ if (g === "md") return { value: "448", unit: "px" };
30399
+ if (g === "lg") return { value: "512", unit: "px" };
30400
+ if (g === "xl") return { value: "576", unit: "px" };
30401
+ if (g === "2xl") return { value: "672", unit: "px" };
30402
+ if (g === "3xl") return { value: "768", unit: "px" };
30403
+ if (g === "4xl") return { value: "896", unit: "px" };
30404
+ if (g === "5xl") return { value: "1024", unit: "px" };
30405
+ if (g === "6xl") return { value: "1152", unit: "px" };
30406
+ if (g === "7xl") return { value: "1280", unit: "px" };
30407
+ if (g === "prose") return { value: "65", unit: "ch" };
30408
+ }
30409
+ if (startsWith(r, "text-")) {
30410
+ if (g === "xs") return { value: "12", unit: "px" };
30411
+ if (g === "sm") return { value: "14", unit: "px" };
30412
+ if (g === "base") return { value: "16", unit: "px" };
30413
+ if (g === "lg") return { value: "18", unit: "px" };
30414
+ if (g === "xl") return { value: "20", unit: "px" };
30415
+ if (g === "2xl") return { value: "24", unit: "px" };
30416
+ if (g === "3xl") return { value: "30", unit: "px" };
30417
+ if (g === "4xl") return { value: "36", unit: "px" };
30418
+ if (g === "5xl") return { value: "48", unit: "px" };
30419
+ if (g === "6xl") return { value: "60", unit: "px" };
30420
+ if (g === "7xl") return { value: "72", unit: "px" };
30421
+ if (g === "8xl") return { value: "96", unit: "px" };
30422
+ if (g === "9xl") return { value: "128", unit: "px" };
30423
+ }
30424
+ if (startsWith(r, "leading-")) {
30425
+ if (g === "none") return { value: "1", unit: "-" };
30426
+ if (g === "tight") return { value: "1.25", unit: "-" };
30427
+ if (g === "snug") return { value: "1.375", unit: "-" };
30428
+ if (g === "normal") return { value: "1.5", unit: "-" };
30429
+ if (g === "relaxed") return { value: "1.625", unit: "-" };
30430
+ if (g === "loose") return { value: "2", unit: "-" };
30431
+ }
30432
+ if (startsWith(r, "tracking-")) {
30433
+ if (g === "tighter") return { value: "-0.05", unit: "em" };
30434
+ if (g === "tight") return { value: "-0.025", unit: "em" };
30435
+ if (g === "normal") return { value: "0", unit: "em" };
30436
+ if (g === "wide") return { value: "0.025", unit: "em" };
30437
+ if (g === "wider") return { value: "0.05", unit: "em" };
30438
+ if (g === "widest") return { value: "0.1", unit: "em" };
30439
+ }
30440
+ if (["max", "min", "fit"].includes(g)) return { value: r, unit: "class" };
30441
+ if (g.includes("/")) {
30442
+ const [x, v] = map(g.split("/"), (S) => parseInt(S, 10));
30443
+ return { value: h + (x / v * 100).toFixed(2).replace(".00", ""), unit: "%" };
30444
+ }
30445
+ return isNumber(parseFloat(g)) ? { value: `${h + parseFloat(g) * 4}`, unit: "px" } : { value: g, unit: "class" };
30446
+ }, getClassValueAndUnit = (r) => {
30447
+ if (isEmpty(r))
30448
+ return { value: "", unit: "" };
30449
+ const h = r.match(/\[.*\]/g);
30450
+ if (h === null)
30451
+ return getValueAndUnitForTWClass(r);
30452
+ const g = get(h, "0", "").replace(/\[|\]/g, ""), x = r.startsWith("-") ? "-" : "", v = first(g.match(/\d+.\d+|\d+/g));
30453
+ return { value: `${x}${v}`, unit: g.replace(v, "") };
30454
+ }, getValueAndUnitForTWClass = (r) => isEmpty(r) ? { value: "", unit: "" } : getTwClassValue(r), BlockSettingsContext = React__default.createContext({
30455
+ setDragData: () => {
30456
+ }
30457
+ }), DragStyleButton = ({
30458
+ unit: r,
30459
+ currentValue: h,
30460
+ onDrag: g,
30461
+ onDragEnd: x,
30462
+ onDragStart: v,
30463
+ negative: S,
30464
+ cssProperty: C
30465
+ }) => {
30466
+ const { setDragData: R } = useContext(BlockSettingsContext);
30467
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30468
+ "button",
30469
+ {
30470
+ type: "button",
30471
+ onMouseDown: (A) => {
30472
+ const T = {
30473
+ onDrag: g,
30474
+ onDragEnd: x,
30475
+ dragging: !0,
30476
+ dragStartY: A.pageY,
30477
+ dragStartValue: `${h}`,
30478
+ dragUnit: r,
30479
+ negative: S,
30480
+ cssProperty: C
30481
+ };
30482
+ v(T), R(T);
30483
+ },
30484
+ color: void 0,
30485
+ className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
30486
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(RowSpacingIcon, {})
30487
+ }
30488
+ );
30489
+ }, UnitSelection = ({ onSelect: r, current: h, units: g }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-theme": "light", className: "-m-[7px] -mx-[13px] flex w-9 flex-col", children: g.map((x) => /* @__PURE__ */ jsxRuntimeExports.jsx(
30490
+ Button,
30491
+ {
30492
+ className: "h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",
30493
+ color: h === x ? "primary" : void 0,
30494
+ size: "sm",
30495
+ onClick: (v) => {
30496
+ v.stopPropagation(), r(x);
30497
+ },
30498
+ children: x
30499
+ },
30500
+ x
30501
+ )) }), THROTTLE_TIME = 50, AdvanceChoices = (r) => {
30502
+ const [h, g] = useState(!1), [x, v] = useState(""), { currentClass: S, onChange: C, classPrefix: R, cssProperty: A, units: T, negative: _ } = r, [O, z] = useState(A != null && A.toLowerCase().includes("width") ? "%" : T[0]), [Z, G] = useState(!1), [q, ee] = useState(""), [ge, le] = useState(!1), [ce, $] = useState(!1);
30503
+ useEffect(() => {
30504
+ const { value: W, unit: xe } = getClassValueAndUnit(S);
30505
+ if (xe === "") {
30506
+ v(W), z(A != null && A.toLowerCase().includes("width") ? "%" : first(T));
30507
+ return;
30508
+ }
30509
+ z(xe), v(xe === "class" || isEmpty(W) ? "" : W);
30510
+ }, [S, A, T]);
30511
+ const ie = useThrottledCallback((W) => C(W), [C], THROTTLE_TIME), he = useThrottledCallback((W) => C(W, !1), [C], THROTTLE_TIME), Se = useCallback(
30512
+ (W = !1) => {
30513
+ const xe = getUserInputValues(`${x}`, T);
30514
+ if (get(xe, "error", !1)) {
30515
+ G(!0);
30516
+ return;
30517
+ }
30518
+ const ve = get(xe, "unit") !== "" ? get(xe, "unit") : O;
30519
+ if (ve === "auto" || ve === "none") {
30520
+ ie(`${R}${ve}`);
30521
+ return;
30522
+ }
30523
+ if (get(xe, "value") === "")
30524
+ return;
30525
+ const je = `${get(xe, "value", "").startsWith("-") ? "-" : ""}${R}[${get(xe, "value", "").replace("-", "")}${ve === "-" ? "" : ve}]`;
30526
+ W ? he(je) : ie(je);
30527
+ },
30528
+ [ie, he, x, O, R, T]
30529
+ ), Me = useCallback(
30530
+ (W) => {
30531
+ const xe = getUserInputValues(`${x}`, T);
30532
+ if (get(xe, "error", !1)) {
30533
+ G(!0);
30534
+ return;
30535
+ }
30536
+ if (W === "auto" || W === "none") {
30537
+ ie(`${R}${W}`);
30538
+ return;
31013
30539
  }
31014
- )
31015
- ] }),
31016
- relative: () => /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31017
- "path",
31018
- {
31019
- fillRule: "evenodd",
31020
- clipRule: "evenodd",
31021
- d: "M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",
31022
- fill: "currentColor"
31023
- }
31024
- ) }),
31025
- sticky: () => /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
30540
+ if (get(xe, "value") === "")
30541
+ return;
30542
+ const ve = get(xe, "unit") !== "" ? get(xe, "unit") : W, je = `${get(xe, "value", "").startsWith("-") ? "-" : ""}${R}[${get(xe, "value", "").replace("-", "")}${ve === "-" ? "" : ve}]`;
30543
+ ie(je);
30544
+ },
30545
+ [ie, x, R, T]
30546
+ );
30547
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: O === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
31026
30548
  /* @__PURE__ */ jsxRuntimeExports.jsx(
31027
- "path",
30549
+ "input",
31028
30550
  {
31029
- d: "M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",
31030
- fill: "currentColor"
30551
+ className: "h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",
30552
+ readOnly: !0,
30553
+ value: S
31031
30554
  }
31032
30555
  ),
31033
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31034
- "path",
30556
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
30557
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
30558
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
30559
+ ] })
30560
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${ge ? "z-auto" : ""}`, children: [
30561
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
30562
+ ["none", "auto"].indexOf(O) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
30563
+ "input",
30564
+ {
30565
+ readOnly: O === "class",
30566
+ onKeyPress: (W) => {
30567
+ W.key === "Enter" && Se();
30568
+ },
30569
+ onKeyDown: (W) => {
30570
+ if (W.keyCode !== 38 && W.keyCode !== 40)
30571
+ return;
30572
+ W.preventDefault(), $(!0);
30573
+ const xe = parseInt$1(W.target.value);
30574
+ let ve = isNaN$1(xe) ? 0 : xe;
30575
+ W.keyCode === 38 && (ve += 1), W.keyCode === 40 && (ve -= 1);
30576
+ const ye = `${ve}`, se = `${ye.startsWith("-") ? "-" : ""}${R}[${ye.replace("-", "")}${O === "-" ? "" : O}]`;
30577
+ he(se);
30578
+ },
30579
+ onKeyUp: (W) => {
30580
+ ce && (W.preventDefault(), $(!1));
30581
+ },
30582
+ onBlur: () => Se(),
30583
+ onChange: (W) => {
30584
+ G(!1), v(W.target.value);
30585
+ },
30586
+ onClick: (W) => {
30587
+ var xe;
30588
+ (xe = W == null ? void 0 : W.target) == null || xe.select(), g(!1);
30589
+ },
30590
+ value: ge ? q : x,
30591
+ className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
30592
+ " ",
30593
+ Z ? "border-red-500 text-red-500" : "border-foreground/20"
30594
+ )
30595
+ }
30596
+ ),
30597
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { open: h, delayDuration: 100, children: [
30598
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
30599
+ "button",
30600
+ {
30601
+ type: "button",
30602
+ onClick: () => g(!h),
30603
+ className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
30604
+ children: [
30605
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${T.length === 1 ? "px-2 font-semibold" : ""}`, children: O }),
30606
+ T.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
30607
+ ]
30608
+ }
30609
+ ) }),
30610
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30611
+ UnitSelection,
30612
+ {
30613
+ units: T,
30614
+ current: O,
30615
+ onSelect: (W) => {
30616
+ g(!1), z(W), Me(W);
30617
+ }
30618
+ }
30619
+ ) }) })
30620
+ ] })
30621
+ ] }),
30622
+ ["none", "auto"].indexOf(O) !== -1 || ge ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
30623
+ DragStyleButton,
31035
30624
  {
31036
- opacity: "0.6",
31037
- fillRule: "evenodd",
31038
- clipRule: "evenodd",
31039
- d: "M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",
31040
- fill: "currentColor"
30625
+ onDragStart: () => le(!0),
30626
+ onDragEnd: (W) => {
30627
+ if (ee(() => ""), le(!1), isEmpty(W))
30628
+ return;
30629
+ const xe = `${W}`, ye = `${xe.startsWith("-") ? "-" : ""}${R}[${xe.replace("-", "")}${O === "-" ? "" : O}]`;
30630
+ ie(ye);
30631
+ },
30632
+ onDrag: (W) => {
30633
+ if (isEmpty(W))
30634
+ return;
30635
+ ee(W);
30636
+ const xe = `${W}`, ye = `${xe.startsWith("-") ? "-" : ""}${R}[${xe.replace("-", "")}${O === "-" ? "" : O}]`;
30637
+ he(ye);
30638
+ },
30639
+ currentValue: x,
30640
+ unit: O,
30641
+ negative: _,
30642
+ cssProperty: A
31041
30643
  }
31042
30644
  )
31043
- ] }),
31044
- static: Cross1Icon
31045
- }, StyleContext = createContext({ canReset: !1, canChange: !0 }), BlockStyleProvider = ({ children: r, canReset: h = !1, canChange: g = !0 }) => (
31046
- // eslint-disable-next-line react/jsx-no-constructed-context-values
31047
- /* @__PURE__ */ jsxRuntimeExports.jsx(StyleContext.Provider, { value: { canReset: h, canChange: g }, children: r })
31048
- ), DropDownChoices = ({ label: r, property: h, onChange: g }) => {
31049
- const { getClasses: x } = useTailwindClassList(), v = x(h), S = useCurrentClassByProperty(h), C = useMemo(() => get(S, "cls", ""), [S]), { canChange: R } = useContext(StyleContext), A = /\[.*\]/g.test(C);
31050
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r ? "w-full rounded" : "grow", children: A ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
31051
- /* @__PURE__ */ jsxRuntimeExports.jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: C }),
31052
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
31053
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
31054
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind arbitrary value." })
30645
+ ] }) }) });
30646
+ }, useCurrentClassByProperty = (r) => {
30647
+ const h = useSelectedBlockCurrentClasses();
30648
+ return findLast(h, { property: r });
30649
+ }, canChangeClass = (r, h) => {
30650
+ const g = {
30651
+ xs: 0,
30652
+ sm: 1,
30653
+ md: 2,
30654
+ lg: 3,
30655
+ xl: 4,
30656
+ "2xl": 5
30657
+ };
30658
+ return g[get(r, "mq", "xs")] <= g[h];
30659
+ }, CLASS_PREFIXES = {
30660
+ width: "w-",
30661
+ height: "h-",
30662
+ minWidth: "min-w-",
30663
+ minHeight: "min-h-",
30664
+ maxWidth: "max-w-",
30665
+ maxHeight: "max-h-",
30666
+ zIndex: "z-",
30667
+ gap: "gap-",
30668
+ gapX: "gap-x-",
30669
+ gapY: "gap-y-",
30670
+ margin: "m-",
30671
+ marginX: "mx-",
30672
+ marginY: "my-",
30673
+ marginTop: "mt-",
30674
+ marginBottom: "mb-",
30675
+ marginLeft: "ml-",
30676
+ marginRight: "mr-",
30677
+ padding: "p-",
30678
+ paddingX: "px-",
30679
+ paddingY: "py-",
30680
+ paddingTop: "pt-",
30681
+ paddingBottom: "pb-",
30682
+ paddingLeft: "pl-",
30683
+ paddingRight: "pr-",
30684
+ spaceX: "space-x-",
30685
+ spaceY: "space-y-",
30686
+ border: "border-",
30687
+ borderTop: "border-t-",
30688
+ borderBottom: "border-b-",
30689
+ borderLeft: "border-l-",
30690
+ borderRight: "border-r-",
30691
+ borderX: "border-x-",
30692
+ borderY: "border-y-",
30693
+ borderRadius: "rounded-",
30694
+ borderRadiusTop: "rounded-t-",
30695
+ borderRadiusRight: "rounded-r-",
30696
+ borderRadiusBottom: "rounded-b-",
30697
+ borderRadiusLeft: "rounded-l-",
30698
+ borderRadiusTopLeft: "rounded-tl-",
30699
+ borderRadiusTopRight: "rounded-tr-",
30700
+ borderRadiusBottomRight: "rounded-br-",
30701
+ borderRadiusBottomLeft: "rounded-bl-",
30702
+ fontSize: "text-",
30703
+ lineHeight: "leading-",
30704
+ letterSpacing: "tracking-",
30705
+ textIndent: "indent-",
30706
+ rotate: "rotate-",
30707
+ duration: "duration-",
30708
+ transitionDelay: "delay-",
30709
+ scale: "scale-",
30710
+ scaleX: "scale-x-",
30711
+ scaleY: "scale-y-",
30712
+ translateX: "translate-x-",
30713
+ translateY: "translate-y-",
30714
+ skewX: "skew-x-",
30715
+ skewY: "skew-y-",
30716
+ top: "top-",
30717
+ bottom: "bottom-",
30718
+ left: "left-",
30719
+ right: "right-",
30720
+ inset: "inset-",
30721
+ insetX: "inset-x-",
30722
+ insetY: "inset-y-",
30723
+ opacity: "opacity-",
30724
+ flexBasis: "basis-"
30725
+ }, BREAKPOINTS = {
30726
+ xs: "",
30727
+ sm: "640px",
30728
+ md: "768px",
30729
+ lg: "1024px",
30730
+ xl: "1280px",
30731
+ "2xl": "1536px"
30732
+ }, getBreakpoint = (r) => `${r.toUpperCase()} ${BREAKPOINTS[r] ? `(${BREAKPOINTS[r]} & up)` : ""}`, BlockStyle = (r) => {
30733
+ const { t: h } = useTranslation(), { type: g = "icons", label: x, property: v, onEmitChange: S = () => {
30734
+ }, units: C, negative: R = !1 } = r, [A] = useDarkMode(), [T] = useStylingState(), [, _] = useCanvasWidth(), O = useCurrentClassByProperty(v), z = useAddClassesToBlocks(), Z = useRemoveClassesFromBlocks(), [G] = useSelectedBlockIds(), q = useMemo(() => get(O, "fullCls", ""), [O]), ee = useCallback(
30735
+ (he, Se = !0) => {
30736
+ const Me = { dark: A, mq: _, mod: T, cls: he, property: v, fullCls: "" };
30737
+ (A || T !== "") && (Me.mq = "xs");
30738
+ const W = generateFullClsName(Me);
30739
+ z(G, [W], Se);
30740
+ },
30741
+ [G, A, _, T, v, z]
30742
+ ), ge = useCallback(() => {
30743
+ Z(G, [q]);
30744
+ }, [G, q, Z]), le = useMemo(() => canChangeClass(O, _), [O, _]);
30745
+ useEffect(() => {
30746
+ S(le, O);
30747
+ }, [le, S, O]);
30748
+ const [, , ce] = useCanvasWidth(), $ = useCallback(
30749
+ (he) => {
30750
+ ce({
30751
+ xs: 400,
30752
+ sm: 640,
30753
+ md: 800,
30754
+ lg: 1024,
30755
+ xl: 1420,
30756
+ "2xl": 1920
30757
+ }[he]);
30758
+ },
30759
+ [ce]
30760
+ ), ie = get(O, "dark", null) === A && get(O, "mod", null) === T && get(O, "mq", null) === _;
30761
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: le, canReset: O && ie, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
30762
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${O && !ie ? "text-foreground" : ""}`, children: h(x) }) }),
30763
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
30764
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
30765
+ g === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
30766
+ AdvanceChoices,
30767
+ {
30768
+ currentClass: get(O, "cls", ""),
30769
+ classPrefix: get(CLASS_PREFIXES, v, ""),
30770
+ units: C || [],
30771
+ onChange: ee,
30772
+ negative: R,
30773
+ cssProperty: v
30774
+ }
30775
+ ) : null,
30776
+ g === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: v, onChange: ee }),
30777
+ g === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: v, onChange: ee }),
30778
+ g === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: v, onChange: ee }),
30779
+ g === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: x, property: v, onChange: ee })
30780
+ ] }),
30781
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${q ? "visible" : "invisible"}`, children: ie ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => ge(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : le && O ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
30782
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30783
+ "button",
30784
+ {
30785
+ type: "button",
30786
+ className: "invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",
30787
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {})
30788
+ }
30789
+ ) }),
30790
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
30791
+ "Current style is set at  ",
30792
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
30793
+ getBreakpoint(get(O, "mq")),
30794
+ A && !O.dark ? "(Light mode)" : ""
30795
+ ] }),
30796
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
30797
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
30798
+ "button",
30799
+ {
30800
+ type: "button",
30801
+ onClick: () => $(get(O, "mq")),
30802
+ className: "block w-full cursor-default text-right font-semibold text-blue-500",
30803
+ children: [
30804
+ "Switch to ",
30805
+ get(O, "mq").toUpperCase()
30806
+ ]
30807
+ }
30808
+ )
30809
+ ] }) }) })
30810
+ ] }) : null })
31055
30811
  ] })
31056
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
31057
- DropDown,
31058
- {
31059
- rounded: r,
31060
- onChange: (T) => g(T, h),
31061
- selected: C,
31062
- options: v,
31063
- disabled: !R
31064
- }
31065
- ) });
31066
- };
31067
- function DropDown({ selected: r, onChange: h, rounded: g = !1, options: x, disabled: v = !1 }) {
31068
- const S = r.replace(/.*:/g, "").trim(), { undo: C, redo: R } = useUndoManager();
30812
+ ] }) });
30813
+ }, basicUnits = ["px", "%", "em", "rem", "ch", "vh", "vw"], MultipleChoices = ({
30814
+ label: r,
30815
+ options: h,
30816
+ borderB: g = !1,
30817
+ borderT: x = !1,
30818
+ type: v = "arbitrary",
30819
+ units: S = basicUnits,
30820
+ negative: C = !1
30821
+ }) => {
30822
+ const { t: R } = useTranslation(), [A, T] = useState(h[0].key), _ = useSelectedBlockCurrentClasses(), O = useCallback((z) => map(_, "property").includes(z), [_]);
31069
30823
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
31070
- "select",
30824
+ "div",
31071
30825
  {
31072
- disabled: !x.length || v,
31073
- className: `${g ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
31074
- onChange: (A) => h(A.target.value),
31075
- onKeyDown: (A) => {
31076
- A.ctrlKey && (A.key === "z" && C(), A.key === "y" && R());
31077
- },
31078
- value: S,
30826
+ className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${g ? "border-b" : ""} ${x ? "border-t" : ""}`,
31079
30827
  children: [
31080
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: "" }),
31081
- React__default.Children.toArray(
31082
- x.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: A, children: A }))
31083
- )
30828
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
30829
+ r && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: R(r) }),
30830
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
30831
+ h.map(({ label: z, key: Z }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
30832
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
30833
+ "button",
30834
+ {
30835
+ type: "button",
30836
+ onClick: () => T(Z),
30837
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${Z === A ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
30838
+ children: [
30839
+ React__default.createElement("div", {
30840
+ className: O(Z) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
30841
+ }),
30842
+ React__default.createElement(get(EDITOR_ICONS, Z, BoxIcon), { className: "text-inherit w-3 h-3" })
30843
+ ]
30844
+ }
30845
+ ) }),
30846
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(z)) })
30847
+ ] }) }))
30848
+ ) })
30849
+ ] }),
30850
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30851
+ BlockStyle,
30852
+ {
30853
+ type: v,
30854
+ units: [...S],
30855
+ label: "",
30856
+ property: A,
30857
+ negative: C
30858
+ }
30859
+ ) })
31084
30860
  ]
31085
30861
  }
31086
30862
  );
31087
- }
31088
- const RangeChoices = ({ property: r, onChange: h }) => {
31089
- const { canReset: g, canChange: x } = useContext(StyleContext), v = useCurrentClassByProperty(r), S = useMemo(() => get(v, "cls", ""), [v]), { getClasses: C } = useTailwindClassList(), R = C(r, [""]), A = R.indexOf(S) > -1 ? R.indexOf(S) : 0, T = /\[.*\]/g.test(S);
31090
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: T ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2 py-[5px]", children: S }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
31091
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31092
- "button",
30863
+ }, NestedOptions = ({ heading: r, items: h }) => {
30864
+ const { t: g } = useTranslation(), x = useSelectedBlockCurrentClasses(), v = useMemo(() => {
30865
+ const S = (A) => flatten(
30866
+ A.map((T) => T.styleType === "multiple" ? map(T.options, "key") : T.property)
30867
+ ), C = flatten(
30868
+ h.map((A) => A.styleType === "accordion" ? S(A.items) : A.styleType === "multiple" ? map(A.options, "key") : A.property)
30869
+ ), R = map(x, "property");
30870
+ return intersection(C, R).length > 0;
30871
+ }, [x, h]);
30872
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { children: [
30873
+ /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline", children: [
30874
+ startCase(g(r.toLowerCase())),
30875
+ v ? /* @__PURE__ */ jsxRuntimeExports.jsx(
30876
+ "span",
30877
+ {
30878
+ className: `ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${v ? "bg-blue-500" : "bg-gray-300"}`
30879
+ }
30880
+ ) : null
30881
+ ] }) }),
30882
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2", children: h.map((S) => S.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...S }, S.label) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...S }, S.label)) })
30883
+ ] });
30884
+ }, SectionContext = createContext({}), StylingGroup = ({ section: r, showAccordian: h }) => {
30885
+ const { t: g } = useTranslation(), x = useSelectedBlockCurrentClasses(), v = useCallback(
30886
+ (C = []) => {
30887
+ const R = {};
30888
+ for (let T = 0; T < x.length; T++)
30889
+ R[x[T].property] = x[T].cls;
30890
+ let A = !0;
30891
+ for (const T in C)
30892
+ if (!has(R, T) || R[T] !== C[T]) {
30893
+ A = !1;
30894
+ break;
30895
+ }
30896
+ return A;
30897
+ },
30898
+ [x]
30899
+ ), S = useMemo(() => ({}), []);
30900
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(SectionContext.Provider, { value: S, children: h ? /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: r.heading, className: "border-none", children: [
30901
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(g(r.heading)) }) }) }),
30902
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionContent, { className: "py-2", children: React__default.Children.toArray(
30903
+ r.items.map((C) => has(C, "component") ? React__default.createElement(C.component, { key: C.label }) : has(C, "styleType") ? C.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...C }, C.label) : C.styleType === "accordion" && v(C == null ? void 0 : C.conditions) ? /* @__PURE__ */ jsxRuntimeExports.jsx(NestedOptions, { ...C }, C.label) : null : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...C }, C.label))
30904
+ ) })
30905
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-2", children: React__default.Children.toArray(
30906
+ r.items.map((C) => has(C, "component") ? React__default.createElement(C.component, { key: C.label }) : has(C, "styleType") ? C.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...C }, C.label) : C.styleType === "accordion" && v(C == null ? void 0 : C.conditions) ? /* @__PURE__ */ jsxRuntimeExports.jsx(NestedOptions, { ...C }, C.label) : null : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...C }, C.label))
30907
+ ) }) });
30908
+ }, StylingHelpers = () => {
30909
+ const r = useSelectedBlock(), [h] = useSelectedStylingBlocks(), { t: g } = useTranslation(), x = useAddClassesToBlocks(), v = getRegisteredChaiBlock(r._type), S = get(first(h), "prop"), C = get(v.props, `${S}.presets`, {});
30910
+ if (!has(v, "props") || isEmpty(C))
30911
+ return null;
30912
+ const R = (A) => {
30913
+ const T = A.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
30914
+ x([r._id], T, !0);
30915
+ };
30916
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
30917
+ /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "default", className: "w-full", size: "sm", children: [
30918
+ g("Apply Presets"),
30919
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CaretDownIcon, {})
30920
+ ] }) }) }),
30921
+ /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuContent, { className: "max-h-80 w-56", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "no-scrollbar h-full", children: isEmpty(C) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
30922
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuLabel, { children: [
30923
+ v.type,
30924
+ " ",
30925
+ g("presets")
30926
+ ] }),
30927
+ /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
30928
+ /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(C).map((A) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => R(C[A]), children: [
30929
+ capitalize(startCase(g(A))),
30930
+ /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: g("apply") })
30931
+ ] })) })
30932
+ ] }) }) })
30933
+ ] }) });
30934
+ }, BlockStylingProps = () => {
30935
+ const r = useSelectedBlock(), [h, g] = useSelectedStylingBlocks(), { t: x } = useTranslation();
30936
+ if (!r) return null;
30937
+ const v = Object.keys(r).filter(
30938
+ (C) => typeof r[C] == "string" && r[C].startsWith("#styles:")
30939
+ );
30940
+ if (isEmpty(v) || v.length <= 1) return null;
30941
+ const S = (C) => find(h, (R) => R.prop === C);
30942
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-1", children: [
30943
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
30944
+ x("Style element"),
30945
+ ":"
30946
+ ] }),
30947
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-2", children: map(v, (C) => /* @__PURE__ */ jsxRuntimeExports.jsx(
30948
+ Badge,
31093
30949
  {
31094
- type: "button",
31095
- className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
31096
- disabled: !x && (!g || A - 1 < 0),
31097
- onClick: () => h(nth(R, A - 1), r),
31098
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31099
- MinusIcon,
31100
- {
31101
- className: !x && (!g || A - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
31102
- }
31103
- ) })
31104
- }
31105
- ),
31106
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8/12 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: !1, property: r, onChange: h }) }),
31107
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31108
- "button",
30950
+ className: "cursor-pointer",
30951
+ onClick: () => {
30952
+ g([{ id: `${C}-${r._id}`, blockId: r._id, prop: C }]);
30953
+ },
30954
+ variant: S(C) ? "default" : "secondary",
30955
+ children: startCase(C)
30956
+ },
30957
+ C
30958
+ )) }),
30959
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
30960
+ ] });
30961
+ }, MAPPER = {
30962
+ px: 1,
30963
+ "%": 1,
30964
+ em: 100,
30965
+ rem: 100,
30966
+ ch: 1,
30967
+ vw: 1,
30968
+ vh: 1,
30969
+ "-": 1,
30970
+ deg: 1,
30971
+ ms: 0.1
30972
+ };
30973
+ function BlockStyling() {
30974
+ const { flexChild: r, gridChild: h } = useSelectedBlocksDisplayChild(), [g] = useSelectedStylingBlocks(), [x, v] = React__default.useState(""), [S, C] = React__default.useState({
30975
+ onDrag: (T) => T,
30976
+ onDragEnd: (T) => T,
30977
+ dragStartY: 0,
30978
+ dragging: !1,
30979
+ dragStartValue: 0,
30980
+ dragUnit: "",
30981
+ negative: !1,
30982
+ cssProperty: ""
30983
+ }), R = useThrottledCallback(
30984
+ (T) => {
30985
+ const _ = !get(S, "negative", !1), O = get(S, "cssProperty", "");
30986
+ let z = parseFloat(S.dragStartValue);
30987
+ z = isNaN(z) ? 0 : z;
30988
+ let Z = MAPPER[S.dragUnit];
30989
+ (startsWith(O, "scale") || O === "opacity") && (Z = 10);
30990
+ let q = (S.dragStartY - T.pageY) / Z + z;
30991
+ _ && q < 0 && (q = 0), O === "opacity" && q > 1 && (q = 1), S.onDrag(`${q}`), v(`${q}`);
30992
+ },
30993
+ [S],
30994
+ 50
30995
+ ), A = useCallback(() => {
30996
+ setTimeout(() => S.onDragEnd(`${x}`), 100), C({
30997
+ onDrag: (T) => T,
30998
+ onDragEnd: (T) => T,
30999
+ dragStartY: 0,
31000
+ dragging: !1,
31001
+ dragStartValue: 0,
31002
+ dragUnit: "",
31003
+ negative: !1,
31004
+ cssProperty: ""
31005
+ });
31006
+ }, [S, x, C]);
31007
+ return isEmpty(g) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(BlockSettingsContext.Provider, { value: { setDragData: C }, children: [
31008
+ S.dragging ? /* @__PURE__ */ jsxRuntimeExports.jsx(
31009
+ "div",
31109
31010
  {
31110
- type: "button",
31111
- className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
31112
- disabled: !x && (!g || A + 1 >= R.length),
31113
- onClick: () => h(nth(R, A + 1), r),
31114
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31115
- PlusIcon,
31116
- {
31117
- className: !x && (!g || A + 1 >= R.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
31118
- }
31119
- ) })
31011
+ onMouseMove: R,
31012
+ onMouseUp: () => A(),
31013
+ className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
31120
31014
  }
31121
- )
31122
- ] }) });
31123
- }, IconChoices = ({ property: r, onChange: h }) => {
31124
- const { getClasses: g } = useTailwindClassList(), x = g(r), { canChange: v } = useContext(StyleContext), S = useCurrentClassByProperty(r), C = useMemo(() => get(S, "cls", ""), [S]);
31125
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex grow flex-wrap gap-1", children: map(x, (R) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31126
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31015
+ ) : null,
31016
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [
31017
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStylingProps, {}),
31018
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StylingHelpers, {}),
31019
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
31020
+ r && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: r || h }),
31021
+ h && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: r || h }),
31022
+ SETTINGS_SECTIONS.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: T, showAccordian: r || h }, T.heading))
31023
+ ] })
31024
+ ] })
31025
+ ] });
31026
+ }
31027
+ const CoreBlock = ({
31028
+ block: r,
31029
+ disabled: h,
31030
+ parentId: g,
31031
+ position: x
31032
+ }) => {
31033
+ const [, v] = useAtom$1(draggedBlockAtom), { type: S, icon: C, label: R } = r, { addCoreBlock: A, addPredefinedBlock: T } = useAddBlock(), [, _] = useSelectedBlockIds(), { clearHighlight: O } = useBlockHighlight(), z = () => {
31034
+ if (has(r, "blocks")) {
31035
+ const q = isFunction$1(r.blocks) ? r.blocks() : r.blocks;
31036
+ T(syncBlocksWithDefaults(q), g || null, x);
31037
+ } else
31038
+ A(r, g || null, x);
31039
+ pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31040
+ }, Z = useFeature("dnd"), { t: G } = useTranslation();
31041
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31042
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31127
31043
  "button",
31128
31044
  {
31045
+ disabled: h,
31046
+ onClick: z,
31129
31047
  type: "button",
31130
- disabled: !v,
31131
- onClick: () => h(R, r),
31132
- className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${C === R ? "bg-blue-500 text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
31133
- children: React__default.createElement(get(EDITOR_ICONS, R, BoxIcon))
31134
- }
31135
- ) }),
31136
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(R)) })
31137
- ] })) });
31138
- }, COLOR_PROP = {
31139
- backgroundColor: "bg",
31140
- textColor: "text",
31141
- borderColor: "border",
31142
- boxShadowColor: "shadow",
31143
- outlineColor: "outline",
31144
- divideColor: "divide",
31145
- fromColor: "from",
31146
- viaColor: "via",
31147
- toColor: "to",
31148
- ringColor: "ring",
31149
- ringOffsetColor: "ring-offset"
31150
- }, ColorChoice = ({ property: r, onChange: h }) => {
31151
- const g = useCurrentClassByProperty(r), x = useMemo(() => get(g, "cls", ""), [g]), { canChange: v } = useContext(StyleContext), [S, C] = useState([]), [R, A] = useState({ color: "", shade: "" }), T = x.split("-"), _ = get(T, "1", ""), O = get(T, "2", ""), z = useCallback(
31152
- // eslint-disable-next-line no-shadow
31153
- (q) => {
31154
- ["current", "inherit", "transparent", "black", "white"].includes(q) ? (C([]), A({ color: q })) : (C(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), A((ee) => ({ ...ee, color: q, shade: ee.shade ? ee.shade : "500" })));
31155
- },
31156
- [C, A]
31157
- );
31158
- useEffect(() => {
31159
- if (["current", "inherit", "transparent", "black", "white"].includes(_))
31160
- return C([]);
31161
- C(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
31162
- }, [_]);
31163
- const Z = useCallback(
31164
- // eslint-disable-next-line no-shadow
31165
- (q) => {
31166
- A({ color: _, shade: q });
31167
- },
31168
- [_]
31169
- );
31170
- useEffect(() => {
31171
- A({ color: "", shade: "" });
31172
- }, [g]);
31173
- const { match: G } = useTailwindClassList();
31174
- return useEffect(() => {
31175
- const ee = `${get(COLOR_PROP, r, "")}-${R.color}${R.shade ? `-${R.shade}` : ""}`;
31176
- G(r, ee) && h(ee, r);
31177
- }, [G, R, h, r]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
31178
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31179
- DropDown,
31180
- {
31181
- disabled: !v,
31182
- rounded: !0,
31183
- selected: _,
31184
- onChange: z,
31185
- options: [
31186
- "current",
31187
- "transparent",
31188
- "primary",
31189
- "secondary",
31190
- "black",
31191
- "white",
31192
- "slate",
31193
- "gray",
31194
- "zinc",
31195
- "neutral",
31196
- "stone",
31197
- "red",
31198
- "orange",
31199
- "amber",
31200
- "yellow",
31201
- "lime",
31202
- "green",
31203
- "emerald",
31204
- "teal",
31205
- "cyan",
31206
- "sky",
31207
- "blue",
31208
- "indigo",
31209
- "violet",
31210
- "purple",
31211
- "fuchsia",
31212
- "pink",
31213
- "rose"
31048
+ onDragStart: (q) => {
31049
+ q.dataTransfer.setData("text/plain", JSON.stringify(omit(r, ["component", "icon"]))), q.dataTransfer.setDragImage(new Image(), 0, 0), v(omit(r, ["component", "icon"])), setTimeout(() => {
31050
+ _([]), O();
31051
+ }, 200);
31052
+ },
31053
+ draggable: Z ? "true" : "false",
31054
+ className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
31055
+ children: [
31056
+ createElement(C || BoxIcon, { className: "w-4 h-4 mx-auto" }),
31057
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(G(R || S)) })
31214
31058
  ]
31215
31059
  }
31216
31060
  ) }),
31217
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: O, disabled: !_ || !v, onChange: Z, options: S }) })
31218
- ] });
31219
- }, getUserInputValues = (r, h) => {
31220
- r = r.toLowerCase();
31221
- let g = r.trim().replace(/ |\+/g, "");
31222
- if ((g === "auto" || g === "none") && h.includes(g))
31223
- return { value: "", unit: g };
31224
- const x = h.length ? new RegExp(h.join("|"), "g") : /XXXXXX/g;
31225
- g = g.replace(x, "");
31226
- const v = r.match(x), S = v && v.length > 1, C = !isEmpty(g) && Number.isNaN(Number(g));
31227
- return S || C ? { error: "Invalid value" } : v && (v[0] === "auto" || v[0] === "none") ? { value: v[0], unit: "" } : { value: g, unit: v ? v[0] : "" };
31228
- }, getTwClassValue = (r) => {
31229
- const h = r.startsWith("-") ? "-" : "", g = r.split("-").pop();
31230
- if (["auto", "none"].includes(g))
31231
- return { value: "", unit: g };
31232
- if (g === "px") return { value: "1", unit: "px" };
31233
- if (g === "screen") return { value: "100", unit: r.indexOf("w-") !== -1 ? "vw" : "vh" };
31234
- if (g === "full") return { value: "100", unit: "%" };
31235
- if (includes(r, "skew-"))
31236
- return { value: `${h}${g}`, unit: "deg" };
31237
- if (includes(r, "rotate-"))
31238
- return { value: `${h}${g}`, unit: "deg" };
31239
- if (includes(r, "opacity-"))
31240
- return { value: `${g / 100}`, unit: "-" };
31241
- if (includes(r, "duration-") || includes(r, "delay-"))
31242
- return { value: `${g}`, unit: "ms" };
31243
- if (includes(r, "translate-") && !g.includes("/"))
31244
- return { value: `${h}${`${g / 4}`}`, unit: "rem" };
31245
- if (includes(r, "scale-"))
31246
- return { value: `${h}${`${g / 100}`}`, unit: "-" };
31247
- if (startsWith(r, "border")) {
31248
- const x = r.match(/border-?(x|y|t|r|b|l)?\d+/g);
31249
- if (x) return { value: x[0].split("-").pop(), unit: "px" };
31250
- if (r.match(/border-?(x|y|t|r|b|l)?/g)) return { value: "1", unit: "px" };
31251
- }
31252
- if (startsWith(r, "max-w-")) {
31253
- if (r === "max-w-screen-sm") return { value: "640", unit: "px" };
31254
- if (r === "max-w-screen-md") return { value: "768", unit: "px" };
31255
- if (r === "max-w-screen-lg") return { value: "1024", unit: "px" };
31256
- if (r === "max-w-screen-xl") return { value: "1280", unit: "px" };
31257
- if (r === "max-w-screen-2xl") return { value: "1536", unit: "px" };
31258
- if (g === "xs") return { value: "320", unit: "px" };
31259
- if (g === "sm") return { value: "384", unit: "px" };
31260
- if (g === "md") return { value: "448", unit: "px" };
31261
- if (g === "lg") return { value: "512", unit: "px" };
31262
- if (g === "xl") return { value: "576", unit: "px" };
31263
- if (g === "2xl") return { value: "672", unit: "px" };
31264
- if (g === "3xl") return { value: "768", unit: "px" };
31265
- if (g === "4xl") return { value: "896", unit: "px" };
31266
- if (g === "5xl") return { value: "1024", unit: "px" };
31267
- if (g === "6xl") return { value: "1152", unit: "px" };
31268
- if (g === "7xl") return { value: "1280", unit: "px" };
31269
- if (g === "prose") return { value: "65", unit: "ch" };
31061
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: G(R || S) }) })
31062
+ ] }) });
31063
+ }, hasVideoEmbed = (r) => {
31064
+ const h = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, g = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
31065
+ return h.test(r) || g.test(r);
31066
+ }, getVideoURLFromHTML = (r) => {
31067
+ if (isEmpty(r)) return r;
31068
+ const h = /<video[^>]+src=['"]([^'">]+)['"]/, g = /<iframe[^>]+src=['"]([^'">]+)['"]/, x = r.match(h), v = r.match(g), S = x ? x[1] : v ? v[1] : null, C = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, R = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
31069
+ return S && (C.test(S) || R.test(S)) ? S : r;
31070
+ }, NAME_ATTRIBUTES = ["chai-name", "data-chai-name"], ATTRIBUTE_MAP = {
31071
+ img: { alt: "alt", width: "width", height: "height", src: "image" },
31072
+ video: {
31073
+ src: "url",
31074
+ autoplay: "controls.autoPlay",
31075
+ muted: "controls.muted",
31076
+ loop: "controls.loop",
31077
+ controls: "controls.widgets"
31078
+ },
31079
+ a: {
31080
+ href: "link.href",
31081
+ target: "link.target",
31082
+ type: ""
31083
+ // @TODO: Detect here what to url, email, phone, elementId
31084
+ },
31085
+ input: {
31086
+ placeholder: "placeholder",
31087
+ required: "required",
31088
+ type: "inputType",
31089
+ name: "fieldName"
31090
+ },
31091
+ textarea: {
31092
+ placeholder: "placeholder",
31093
+ required: "required",
31094
+ type: "inputType",
31095
+ name: "fieldName"
31096
+ },
31097
+ select: {
31098
+ placeholder: "placeholder",
31099
+ required: "required",
31100
+ multiple: "multiple",
31101
+ name: "fieldName"
31270
31102
  }
31271
- if (startsWith(r, "text-")) {
31272
- if (g === "xs") return { value: "12", unit: "px" };
31273
- if (g === "sm") return { value: "14", unit: "px" };
31274
- if (g === "base") return { value: "16", unit: "px" };
31275
- if (g === "lg") return { value: "18", unit: "px" };
31276
- if (g === "xl") return { value: "20", unit: "px" };
31277
- if (g === "2xl") return { value: "24", unit: "px" };
31278
- if (g === "3xl") return { value: "30", unit: "px" };
31279
- if (g === "4xl") return { value: "36", unit: "px" };
31280
- if (g === "5xl") return { value: "48", unit: "px" };
31281
- if (g === "6xl") return { value: "60", unit: "px" };
31282
- if (g === "7xl") return { value: "72", unit: "px" };
31283
- if (g === "8xl") return { value: "96", unit: "px" };
31284
- if (g === "9xl") return { value: "128", unit: "px" };
31103
+ }, shouldAddText = (r, h) => r.children.length === 1 && includes(
31104
+ ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
31105
+ h._type
31106
+ ), getTextContent = (r) => r.map((h) => h.type === "text" ? get(h, "content", "") : isEmpty(h.children) ? "" : getTextContent(h.children)).join(""), getSanitizedValue = (r) => r === null ? "" : r, getAttrs = (r) => {
31107
+ if (r.tagName === "svg") return {};
31108
+ const h = {}, g = ATTRIBUTE_MAP[r.tagName] || {}, x = r.attributes;
31109
+ return forEach(x, ({ key: v, value: S }) => {
31110
+ if (!includes(NAME_ATTRIBUTES, v))
31111
+ if (g[v]) {
31112
+ if (r.tagName === "img" && v === "src" && !S.startsWith("http")) {
31113
+ const C = find(r.attributes, { key: "width" }), R = find(r.attributes, { key: "height" });
31114
+ C && R ? S = `https://via.placeholder.com/${C == null ? void 0 : C.value}x${R == null ? void 0 : R.value}` : S = "https://via.placeholder.com/150x150";
31115
+ }
31116
+ set(h, g[v], getSanitizedValue(S));
31117
+ } else includes(["style", "class", "srcset"], v) || (has(h, "styles_attrs") || (h.styles_attrs = {}), startsWith(v, "@") && (v = v.replace("@", "x-on:")), h.styles_attrs[`${v}`] = getSanitizedValue(S));
31118
+ }), delete h.class, h;
31119
+ }, getStyles = (r, h = "styles") => {
31120
+ if (!r.attributes) return { [h]: `${STYLES_KEY},` };
31121
+ const g = find(r.attributes, { key: "class" });
31122
+ if (g) {
31123
+ const x = g.value;
31124
+ return { [h]: `${STYLES_KEY},${x}` };
31285
31125
  }
31286
- if (startsWith(r, "leading-")) {
31287
- if (g === "none") return { value: "1", unit: "-" };
31288
- if (g === "tight") return { value: "1.25", unit: "-" };
31289
- if (g === "snug") return { value: "1.375", unit: "-" };
31290
- if (g === "normal") return { value: "1.5", unit: "-" };
31291
- if (g === "relaxed") return { value: "1.625", unit: "-" };
31292
- if (g === "loose") return { value: "2", unit: "-" };
31126
+ return { [h]: `${STYLES_KEY},` };
31127
+ }, getBlockProps = (r) => {
31128
+ const h = get(r, "attributes", []), g = h.find((R) => R.key === "data-chai-richtext" || R.key === "chai-richtext"), x = h.find((R) => R.key === "data-chai-lightbox" || R.key === "chai-lightbox"), v = h.find((R) => R.key === "data-chai-dropdown" || R.key === "chai-dropdown"), S = h.find(
31129
+ (R) => R.key === "data-chai-dropdown-button" || R.key === "chai-dropdown-button"
31130
+ ), C = h.find(
31131
+ (R) => R.key === "data-chai-dropdown-content" || R.key === "chai-dropdown-content"
31132
+ );
31133
+ if (v)
31134
+ return { _type: "Dropdown" };
31135
+ if (S)
31136
+ return { _type: "DropdownButton" };
31137
+ if (C)
31138
+ return { _type: "DropdownContent" };
31139
+ if (g)
31140
+ return { _type: "RichText" };
31141
+ if (x)
31142
+ return { _type: "LightBoxLink" };
31143
+ switch (r.tagName) {
31144
+ // self closing tags
31145
+ case "img":
31146
+ return { _type: "Image" };
31147
+ case "input":
31148
+ return { _type: "Input", showLabel: !1 };
31149
+ // showLabel: hiding default block label
31150
+ case "hr":
31151
+ return { _type: "Divider" };
31152
+ case "br":
31153
+ return { _type: "LineBreak" };
31154
+ case "textarea":
31155
+ return { _type: "TextArea", showLabel: !1 };
31156
+ case "audio":
31157
+ return { _type: "Audio" };
31158
+ case "canvas":
31159
+ return { _type: "Canvas" };
31160
+ case "video":
31161
+ case "iframe":
31162
+ return { _type: "CustomHTML" };
31163
+ case "svg":
31164
+ return { _type: "Icon" };
31165
+ // non self closing tags
31166
+ // fixed structure
31167
+ case "select":
31168
+ return { _type: "Select", options: [] };
31169
+ case "option":
31170
+ return { _type: "Option" };
31171
+ case "ul":
31172
+ case "ol":
31173
+ case "dl":
31174
+ return {
31175
+ _type: "List",
31176
+ tag: r.tagName,
31177
+ _listType: r.tagName === "ol" ? "list-decimal" : "list-none"
31178
+ };
31179
+ case "li":
31180
+ case "dt":
31181
+ return { _type: "ListItem", tag: r.tagName };
31182
+ // non self closing tags
31183
+ // free flow structure
31184
+ case "span":
31185
+ case "figcaption":
31186
+ case "legend":
31187
+ return { _type: "Span", tag: r.tagName };
31188
+ case "p":
31189
+ return { _type: "Paragraph", content: "" };
31190
+ case "a":
31191
+ return { _type: "Link" };
31192
+ case "form":
31193
+ return { _type: "Form" };
31194
+ case "label":
31195
+ return { _type: "Label" };
31196
+ case "button":
31197
+ return { _type: "Button" };
31198
+ case "code":
31199
+ return { _type: "Code" };
31200
+ case "h1":
31201
+ case "h2":
31202
+ case "h3":
31203
+ case "h4":
31204
+ case "h5":
31205
+ case "h6":
31206
+ return { _type: "Heading", tag: r.tagName };
31207
+ case "table":
31208
+ return { _type: "Table" };
31209
+ case "tr":
31210
+ return { _type: "TableRow" };
31211
+ case "td":
31212
+ case "th":
31213
+ return { _type: "TableCell", tag: r.tagName };
31214
+ case "thead":
31215
+ return { _type: "TableHead" };
31216
+ case "tbody":
31217
+ return { _type: "TableBody" };
31218
+ case "tfoot":
31219
+ return { _type: "TableFooter" };
31220
+ default: {
31221
+ const R = get(r, "children", []).length > 0 ? "Box" : "EmptyBox";
31222
+ return {
31223
+ _type: R,
31224
+ tag: r.tagName,
31225
+ _name: R == "EmptyBox" || r.tagName === "div" ? R : capitalize(r.tagName)
31226
+ };
31227
+ }
31293
31228
  }
31294
- if (startsWith(r, "tracking-")) {
31295
- if (g === "tighter") return { value: "-0.05", unit: "em" };
31296
- if (g === "tight") return { value: "-0.025", unit: "em" };
31297
- if (g === "normal") return { value: "0", unit: "em" };
31298
- if (g === "wide") return { value: "0.025", unit: "em" };
31299
- if (g === "wider") return { value: "0.05", unit: "em" };
31300
- if (g === "widest") return { value: "0.1", unit: "em" };
31229
+ }, traverseNodes = (r, h = null) => flatMapDeep(r, (g) => {
31230
+ var O, z, Z, G, q, ee, ge, le;
31231
+ if (g.type === "comment") return [];
31232
+ console.log("node ===>", g);
31233
+ let x = { _id: generateUUID() };
31234
+ if (h && (x._parent = h.block._id), g.type === "text")
31235
+ return isEmpty(get(g, "content", "")) ? [] : h && shouldAddText(h.node, h.block) ? (set(h, "block.content", get(g, "content", "")), []) : { ...x, _type: "Text", content: get(g, "content", "") };
31236
+ const v = get(g, "attributes", []), S = v.find(
31237
+ (ce) => ce.key === "data-chai-richtext" || ce.key === "chai-richtext"
31238
+ ), C = v.find(
31239
+ (ce) => ce.key === "data-chai-lightbox" || ce.key === "chai-lightbox"
31240
+ ), R = v.find(
31241
+ (ce) => ce.key === "data-chai-dropdown" || ce.key === "chai-dropdown"
31242
+ ), A = v.find(
31243
+ (ce) => ce.key === "data-chai-dropdown-button" || ce.key === "chai-dropdown-button"
31244
+ ), T = v.find(
31245
+ (ce) => ce.key === "data-chai-dropdown-content" || ce.key === "chai-dropdown-content"
31246
+ );
31247
+ if (x = {
31248
+ ...x,
31249
+ ...getBlockProps(g),
31250
+ ...getAttrs(g),
31251
+ ...getStyles(g)
31252
+ }, g.attributes) {
31253
+ const ce = g.attributes.find(($) => includes(NAME_ATTRIBUTES, $.key));
31254
+ ce && (x._name = ce.value);
31301
31255
  }
31302
- if (["max", "min", "fit"].includes(g)) return { value: r, unit: "class" };
31303
- if (g.includes("/")) {
31304
- const [x, v] = map(g.split("/"), (S) => parseInt(S, 10));
31305
- return { value: h + (x / v * 100).toFixed(2).replace(".00", ""), unit: "%" };
31256
+ if (S)
31257
+ return x.content = stringify(g.children), has(x, "styles_attrs.data-chai-richtext") && delete x.styles_attrs["data-chai-richtext"], has(x, "styles_attrs.chai-richtext") && delete x.styles_attrs["chai-richtext"], [x];
31258
+ if (C) {
31259
+ const ce = [
31260
+ "data-chai-lightbox",
31261
+ "chai-lightbox",
31262
+ "data-vbtype",
31263
+ "data-autoplay",
31264
+ "data-maxwidth",
31265
+ "data-overlay",
31266
+ "data-gall",
31267
+ "href"
31268
+ ];
31269
+ x = {
31270
+ ...x,
31271
+ href: ((O = v.find(($) => $.key === "href")) == null ? void 0 : O.value) || "",
31272
+ hrefType: ((z = v.find(($) => $.key === "data-vbtype")) == null ? void 0 : z.value) || "video",
31273
+ autoplay: ((Z = v.find(($) => $.key === "data-autoplay")) == null ? void 0 : Z.value) === "true" ? "true" : "false",
31274
+ maxWidth: ((q = (G = v.find(($) => $.key === "data-maxwidth")) == null ? void 0 : G.value) == null ? void 0 : q.replace("px", "")) || "",
31275
+ backdropColor: ((ee = v.find(($) => $.key === "data-overlay")) == null ? void 0 : ee.value) || "",
31276
+ galleryName: ((ge = v.find(($) => $.key === "data-gall")) == null ? void 0 : ge.value) || ""
31277
+ }, forEach(ce, ($) => {
31278
+ has(x, `styles_attrs.${$}`) && delete x.styles_attrs[$];
31279
+ });
31306
31280
  }
31307
- return isNumber(parseFloat(g)) ? { value: `${h + parseFloat(g) * 4}`, unit: "px" } : { value: g, unit: "class" };
31308
- }, getClassValueAndUnit = (r) => {
31309
- if (isEmpty(r))
31310
- return { value: "", unit: "" };
31311
- const h = r.match(/\[.*\]/g);
31312
- if (h === null)
31313
- return getValueAndUnitForTWClass(r);
31314
- const g = get(h, "0", "").replace(/\[|\]/g, ""), x = r.startsWith("-") ? "-" : "", v = first(g.match(/\d+.\d+|\d+/g));
31315
- return { value: `${x}${v}`, unit: g.replace(v, "") };
31316
- }, getValueAndUnitForTWClass = (r) => isEmpty(r) ? { value: "", unit: "" } : getTwClassValue(r), BlockSettingsContext = React__default.createContext({
31317
- setDragData: () => {
31281
+ if (R && (delete x.styles_attrs, x.showDropdown = !1), T && delete x.styles_attrs, A) {
31282
+ delete x.styles_attrs;
31283
+ const ce = filter(g.children || [], (ie) => (ie == null ? void 0 : ie.tagName) !== "span");
31284
+ x.content = getTextContent(ce);
31285
+ const $ = find(
31286
+ g.children || [],
31287
+ (ie) => (ie == null ? void 0 : ie.tagName) === "span" && some(ie.children || [], (he) => (he == null ? void 0 : he.tagName) === "svg")
31288
+ );
31289
+ if ($) {
31290
+ const ie = find($.children || [], (he) => (he == null ? void 0 : he.tagName) === "svg");
31291
+ if (ie) {
31292
+ x.icon = stringify([ie]);
31293
+ const { height: he, width: Se } = getSvgDimensions(ie, "16px", "16px");
31294
+ x.iconHeight = he, x.iconWidth = Se;
31295
+ }
31296
+ }
31297
+ return [x];
31318
31298
  }
31319
- }), DragStyleButton = ({
31320
- unit: r,
31321
- currentValue: h,
31322
- onDrag: g,
31323
- onDragEnd: x,
31324
- onDragStart: v,
31325
- negative: S,
31326
- cssProperty: C
31299
+ if (x._type === "Input") {
31300
+ const ce = x.inputType || "text";
31301
+ ce === "checkbox" ? set(x, "_type", "Checkbox") : ce === "radio" && set(x, "_type", "Radio");
31302
+ } else if (g.tagName === "video" || g.tagName === "iframe") {
31303
+ const ce = stringify([g]);
31304
+ return hasVideoEmbed(ce) && (set(x, "_type", "Video"), set(x, "url", getVideoURLFromHTML(ce)), set(x, "styles", `${STYLES_KEY},`), set(x, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), x.content = ce, [x];
31305
+ } else if (g.tagName === "svg") {
31306
+ const ce = find(g.attributes, { key: "height" }), $ = find(g.attributes, { key: "width" }), ie = get(ce, "value") ? `[${get(ce, "value")}px]` : "24px", he = get($, "value") ? `[${get($, "value")}px]` : "24px", Se = get(find(g.attributes, { key: "class" }), "value", "w-full h-full");
31307
+ return x.styles = `${STYLES_KEY}, ${cn(`w-${he} h-${ie}`, Se)}`.trim(), g.attributes = filter(g.attributes, (Me) => !includes(["style", "width", "height", "class"], Me.key)), x.icon = stringify([g]), [x];
31308
+ } else if (g.tagName == "option" && h && ((le = h.block) == null ? void 0 : le._type) === "Select")
31309
+ return h.block.options.push({
31310
+ label: getTextContent(g.children),
31311
+ ...getAttrs(g)
31312
+ }), [];
31313
+ const _ = traverseNodes(g.children, { block: x, node: g });
31314
+ return [x, ..._];
31315
+ }), getSvgDimensions = (r, h, g) => {
31316
+ const x = get(r, "attributes", []), v = find(x, { key: "height" }), S = find(x, { key: "width" });
31317
+ return {
31318
+ height: get(v, "value") ? `[${get(v, "value")}px]` : g,
31319
+ width: get(S, "value") ? `[${get(S, "value")}px]` : h
31320
+ };
31321
+ }, getSanitizedHTML = (r) => {
31322
+ r = r.replace(/(\w+)=\\?"(.*?)\\?"/g, (x, v, S) => {
31323
+ let C = S.replace(/\\"/g, '"');
31324
+ return C = C.replace(/{([^}]+)}/g, (R) => R.replace(/"/g, '\\"')), `${v}="${C.replace(/\\"/g, '"')}"`;
31325
+ }), r = r.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, "");
31326
+ const h = r.match(/<body[^>]*>[\s\S]*?<\/body>/);
31327
+ return (h && h.length > 0 ? h[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : r).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
31328
+ }, getBlocksFromHTML = (r) => {
31329
+ const h = parse(getSanitizedHTML(r));
31330
+ return isEmpty(r) ? [] : flatten(traverseNodes(h));
31331
+ }, ImportHTML = ({ parentId: r, position: h }) => {
31332
+ const { t: g } = useTranslation(), [x, v] = useState(""), { addPredefinedBlock: S } = useAddBlock(), C = () => {
31333
+ const R = getBlocksFromHTML(x);
31334
+ S([...R], r, h), v(""), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31335
+ };
31336
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
31337
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardDescription, { children: g("Use HTML snippets from Tailwind CSS component libraries") }) }),
31338
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-2 px-3 py-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
31339
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "current", className: "text-sm", children: g("Tailwind HTML snippet") }),
31340
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31341
+ Textarea,
31342
+ {
31343
+ autoFocus: !0,
31344
+ tabIndex: 1,
31345
+ ref: (R) => R && R.focus(),
31346
+ onChange: (R) => v(R.target.value),
31347
+ rows: 12,
31348
+ value: x,
31349
+ placeholder: g("Enter your code snippet here"),
31350
+ className: "resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"
31351
+ }
31352
+ )
31353
+ ] }) }),
31354
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: x.trim() === "", onClick: () => C(), size: "sm", className: "w-fit", children: g("Import HTML") }) })
31355
+ ] });
31356
+ }, DefaultChaiBlocks = ({
31357
+ parentId: r,
31358
+ position: h,
31359
+ gridCols: g = "grid-cols-2"
31327
31360
  }) => {
31328
- const { setDragData: R } = useContext(BlockSettingsContext);
31361
+ const x = useRegisteredChaiBlocks(), v = useBuilderProp("filterChaiBlock", () => !0), S = filter(x, v), C = groupBy(S, "category"), R = uniq(map(C.core, "group"));
31329
31362
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
31330
- "button",
31363
+ ChaiBuilderBlocks,
31331
31364
  {
31332
- type: "button",
31333
- onMouseDown: (A) => {
31334
- const T = {
31335
- onDrag: g,
31336
- onDragEnd: x,
31337
- dragging: !0,
31338
- dragStartY: A.pageY,
31339
- dragStartValue: `${h}`,
31340
- dragUnit: r,
31341
- negative: S,
31342
- cssProperty: C
31343
- };
31344
- v(T), R(T);
31345
- },
31346
- color: void 0,
31347
- className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
31348
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(RowSpacingIcon, {})
31349
- }
31350
- );
31351
- }, UnitSelection = ({ onSelect: r, current: h, units: g }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-theme": "light", className: "-m-[7px] -mx-[13px] flex w-9 flex-col", children: g.map((x) => /* @__PURE__ */ jsxRuntimeExports.jsx(
31352
- Button,
31353
- {
31354
- className: "h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",
31355
- color: h === x ? "primary" : void 0,
31356
- size: "sm",
31357
- onClick: (v) => {
31358
- v.stopPropagation(), r(x);
31359
- },
31360
- children: x
31361
- },
31362
- x
31363
- )) }), THROTTLE_TIME = 50, AdvanceChoices = (r) => {
31364
- const [h, g] = useState(!1), [x, v] = useState(""), { currentClass: S, onChange: C, classPrefix: R, cssProperty: A, units: T, negative: _ } = r, [O, z] = useState(A != null && A.toLowerCase().includes("width") ? "%" : T[0]), [Z, G] = useState(!1), [q, ee] = useState(""), [ge, le] = useState(!1), [ce, $] = useState(!1);
31365
- useEffect(() => {
31366
- const { value: W, unit: xe } = getClassValueAndUnit(S);
31367
- if (xe === "") {
31368
- v(W), z(A != null && A.toLowerCase().includes("width") ? "%" : first(T));
31369
- return;
31365
+ gridCols: g,
31366
+ parentId: r,
31367
+ position: h,
31368
+ groups: R,
31369
+ blocks: C.core
31370
31370
  }
31371
- z(xe), v(xe === "class" || isEmpty(W) ? "" : W);
31372
- }, [S, A, T]);
31373
- const ie = useThrottledCallback((W) => C(W), [C], THROTTLE_TIME), he = useThrottledCallback((W) => C(W, !1), [C], THROTTLE_TIME), Se = useCallback(
31374
- (W = !1) => {
31375
- const xe = getUserInputValues(`${x}`, T);
31376
- if (get(xe, "error", !1)) {
31377
- G(!0);
31378
- return;
31379
- }
31380
- const ve = get(xe, "unit") !== "" ? get(xe, "unit") : O;
31381
- if (ve === "auto" || ve === "none") {
31382
- ie(`${R}${ve}`);
31383
- return;
31384
- }
31385
- if (get(xe, "value") === "")
31386
- return;
31387
- const je = `${get(xe, "value", "").startsWith("-") ? "-" : ""}${R}[${get(xe, "value", "").replace("-", "")}${ve === "-" ? "" : ve}]`;
31388
- W ? he(je) : ie(je);
31389
- },
31390
- [ie, he, x, O, R, T]
31391
- ), Me = useCallback(
31392
- (W) => {
31393
- const xe = getUserInputValues(`${x}`, T);
31394
- if (get(xe, "error", !1)) {
31395
- G(!0);
31396
- return;
31397
- }
31398
- if (W === "auto" || W === "none") {
31399
- ie(`${R}${W}`);
31400
- return;
31401
- }
31402
- if (get(xe, "value") === "")
31403
- return;
31404
- const ve = get(xe, "unit") !== "" ? get(xe, "unit") : W, je = `${get(xe, "value", "").startsWith("-") ? "-" : ""}${R}[${get(xe, "value", "").replace("-", "")}${ve === "-" ? "" : ve}]`;
31405
- ie(je);
31406
- },
31407
- [ie, x, R, T]
31408
31371
  );
31409
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: O === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
31410
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31411
- "input",
31412
- {
31413
- className: "h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",
31414
- readOnly: !0,
31415
- value: S
31416
- }
31417
- ),
31418
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31419
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
31420
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
31421
- ] })
31422
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${ge ? "z-auto" : ""}`, children: [
31423
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
31424
- ["none", "auto"].indexOf(O) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
31425
- "input",
31426
- {
31427
- readOnly: O === "class",
31428
- onKeyPress: (W) => {
31429
- W.key === "Enter" && Se();
31430
- },
31431
- onKeyDown: (W) => {
31432
- if (W.keyCode !== 38 && W.keyCode !== 40)
31433
- return;
31434
- W.preventDefault(), $(!0);
31435
- const xe = parseInt$1(W.target.value);
31436
- let ve = isNaN$1(xe) ? 0 : xe;
31437
- W.keyCode === 38 && (ve += 1), W.keyCode === 40 && (ve -= 1);
31438
- const ye = `${ve}`, se = `${ye.startsWith("-") ? "-" : ""}${R}[${ye.replace("-", "")}${O === "-" ? "" : O}]`;
31439
- he(se);
31440
- },
31441
- onKeyUp: (W) => {
31442
- ce && (W.preventDefault(), $(!1));
31443
- },
31444
- onBlur: () => Se(),
31445
- onChange: (W) => {
31446
- G(!1), v(W.target.value);
31447
- },
31448
- onClick: (W) => {
31449
- var xe;
31450
- (xe = W == null ? void 0 : W.target) == null || xe.select(), g(!1);
31451
- },
31452
- value: ge ? q : x,
31453
- className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
31454
- " ",
31455
- Z ? "border-red-500 text-red-500" : "border-foreground/20"
31456
- )
31457
- }
31458
- ),
31459
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { open: h, delayDuration: 100, children: [
31460
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31461
- "button",
31462
- {
31463
- type: "button",
31464
- onClick: () => g(!h),
31465
- className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
31466
- children: [
31467
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${T.length === 1 ? "px-2 font-semibold" : ""}`, children: O }),
31468
- T.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
31469
- ]
31470
- }
31471
- ) }),
31472
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31473
- UnitSelection,
31474
- {
31475
- units: T,
31476
- current: O,
31477
- onSelect: (W) => {
31478
- g(!1), z(W), Me(W);
31372
+ }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: r, blocks: h, parentId: g, position: x, gridCols: v = "grid-cols-4" }) => {
31373
+ var A;
31374
+ const { t: S } = useTranslation(), [C] = useBlocksStore(), R = (A = find(C, (T) => T._id === g)) == null ? void 0 : A._type;
31375
+ return React__default.Children.toArray(
31376
+ map(
31377
+ sortBy(r, (T) => CORE_GROUPS.indexOf(T) === -1 ? 99 : CORE_GROUPS.indexOf(T)),
31378
+ (T) => reject(filter(values(h), { group: T }), { hidden: !0 }).length ? /* @__PURE__ */ jsxRuntimeExports.jsx(Accordion, { type: "single", value: T, collapsible: !0, className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: T, className: "border-border", children: [
31379
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(S(T.toLowerCase())) }),
31380
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionContent, { className: "mx-auto max-w-xl p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-2 " + v, children: React__default.Children.toArray(
31381
+ reject(filter(values(h), { group: T }), { hidden: !0 }).map((_) => /* @__PURE__ */ jsxRuntimeExports.jsx(
31382
+ CoreBlock,
31383
+ {
31384
+ parentId: g,
31385
+ position: x,
31386
+ block: _,
31387
+ disabled: !canAcceptChildBlock(R, _.type) || !canBeNestedInside(R, _.type)
31479
31388
  }
31480
- }
31389
+ ))
31481
31390
  ) }) })
31482
- ] })
31483
- ] }),
31484
- ["none", "auto"].indexOf(O) !== -1 || ge ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
31485
- DragStyleButton,
31391
+ ] }) }) : null
31392
+ )
31393
+ );
31394
+ }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
31395
+ className: r,
31396
+ showHeading: h = !0,
31397
+ parentId: g = void 0,
31398
+ position: x = -1
31399
+ }) => {
31400
+ const { t: v } = useTranslation(), [S, C] = useAtom$1(addBlockTabAtom), [, R] = useAtom$1(showPredefinedBlockCategoryAtom), A = useBuilderProp("importHTMLSupport", !0), T = useBuilderProp("addBlocksDialogTabs", []), _ = useCallback(() => {
31401
+ pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31402
+ }, []);
31403
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex h-full w-full flex-col overflow-hidden", r), children: [
31404
+ h ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
31405
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: v("Add block") }),
31406
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: v(S === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
31407
+ ] }) : null,
31408
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31409
+ Tabs,
31486
31410
  {
31487
- onDragStart: () => le(!0),
31488
- onDragEnd: (W) => {
31489
- if (ee(() => ""), le(!1), isEmpty(W))
31490
- return;
31491
- const xe = `${W}`, ye = `${xe.startsWith("-") ? "-" : ""}${R}[${xe.replace("-", "")}${O === "-" ? "" : O}]`;
31492
- ie(ye);
31493
- },
31494
- onDrag: (W) => {
31495
- if (isEmpty(W))
31496
- return;
31497
- ee(W);
31498
- const xe = `${W}`, ye = `${xe.startsWith("-") ? "-" : ""}${R}[${xe.replace("-", "")}${O === "-" ? "" : O}]`;
31499
- he(ye);
31411
+ onValueChange: (O) => {
31412
+ R(""), C(O);
31500
31413
  },
31501
- currentValue: x,
31502
- unit: O,
31503
- negative: _,
31504
- cssProperty: A
31414
+ value: S,
31415
+ className: "flex h-full max-h-full flex-col overflow-hidden",
31416
+ children: [
31417
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "flex w-full items-center", children: [
31418
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "library", children: v("Library") }),
31419
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "core", children: v("Blocks") }),
31420
+ A ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "html", children: v("Import") }) : null,
31421
+ map(T, (O) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: O.key, children: React__default.createElement(O.tab) }))
31422
+ ] }),
31423
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: g, position: x }) }) }) }),
31424
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesPanel, { parentId: g, position: x }) }),
31425
+ A ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML, { parentId: g, position: x }) }) : null,
31426
+ map(T, (O) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: O.key, children: React__default.createElement(O.tabContent, { close: _, parentId: g, position: x }) }))
31427
+ ]
31505
31428
  }
31506
31429
  )
31507
- ] }) }) });
31508
- }, useCurrentClassByProperty = (r) => {
31509
- const h = useSelectedBlockCurrentClasses();
31510
- return findLast(h, { property: r });
31511
- }, canChangeClass = (r, h) => {
31512
- const g = {
31513
- xs: 0,
31514
- sm: 1,
31515
- md: 2,
31516
- lg: 3,
31517
- xl: 4,
31518
- "2xl": 5
31430
+ ] });
31431
+ }, ChaiSelect = ({
31432
+ defaultValue: r = "",
31433
+ onValueChange: h,
31434
+ options: g,
31435
+ placeholder: x = "Select",
31436
+ className: v = ""
31437
+ }) => {
31438
+ const [S, C] = useState(r), R = (A) => {
31439
+ const T = A.target.value;
31440
+ C(T), h(T);
31519
31441
  };
31520
- return g[get(r, "mq", "xs")] <= g[h];
31521
- }, CLASS_PREFIXES = {
31522
- width: "w-",
31523
- height: "h-",
31524
- minWidth: "min-w-",
31525
- minHeight: "min-h-",
31526
- maxWidth: "max-w-",
31527
- maxHeight: "max-h-",
31528
- zIndex: "z-",
31529
- gap: "gap-",
31530
- gapX: "gap-x-",
31531
- gapY: "gap-y-",
31532
- margin: "m-",
31533
- marginX: "mx-",
31534
- marginY: "my-",
31535
- marginTop: "mt-",
31536
- marginBottom: "mb-",
31537
- marginLeft: "ml-",
31538
- marginRight: "mr-",
31539
- padding: "p-",
31540
- paddingX: "px-",
31541
- paddingY: "py-",
31542
- paddingTop: "pt-",
31543
- paddingBottom: "pb-",
31544
- paddingLeft: "pl-",
31545
- paddingRight: "pr-",
31546
- spaceX: "space-x-",
31547
- spaceY: "space-y-",
31548
- border: "border-",
31549
- borderTop: "border-t-",
31550
- borderBottom: "border-b-",
31551
- borderLeft: "border-l-",
31552
- borderRight: "border-r-",
31553
- borderX: "border-x-",
31554
- borderY: "border-y-",
31555
- borderRadius: "rounded-",
31556
- borderRadiusTop: "rounded-t-",
31557
- borderRadiusRight: "rounded-r-",
31558
- borderRadiusBottom: "rounded-b-",
31559
- borderRadiusLeft: "rounded-l-",
31560
- borderRadiusTopLeft: "rounded-tl-",
31561
- borderRadiusTopRight: "rounded-tr-",
31562
- borderRadiusBottomRight: "rounded-br-",
31563
- borderRadiusBottomLeft: "rounded-bl-",
31564
- fontSize: "text-",
31565
- lineHeight: "leading-",
31566
- letterSpacing: "tracking-",
31567
- textIndent: "indent-",
31568
- rotate: "rotate-",
31569
- duration: "duration-",
31570
- transitionDelay: "delay-",
31571
- scale: "scale-",
31572
- scaleX: "scale-x-",
31573
- scaleY: "scale-y-",
31574
- translateX: "translate-x-",
31575
- translateY: "translate-y-",
31576
- skewX: "skew-x-",
31577
- skewY: "skew-y-",
31578
- top: "top-",
31579
- bottom: "bottom-",
31580
- left: "left-",
31581
- right: "right-",
31582
- inset: "inset-",
31583
- insetX: "inset-x-",
31584
- insetY: "inset-y-",
31585
- opacity: "opacity-",
31586
- flexBasis: "basis-"
31587
- }, BREAKPOINTS = {
31588
- xs: "",
31589
- sm: "640px",
31590
- md: "768px",
31591
- lg: "1024px",
31592
- xl: "1280px",
31593
- "2xl": "1536px"
31594
- }, getBreakpoint = (r) => `${r.toUpperCase()} ${BREAKPOINTS[r] ? `(${BREAKPOINTS[r]} & up)` : ""}`, BlockStyle = (r) => {
31595
- const { t: h } = useTranslation(), { type: g = "icons", label: x, property: v, onEmitChange: S = () => {
31596
- }, units: C, negative: R = !1 } = r, [A] = useDarkMode(), [T] = useStylingState(), [, _] = useCanvasWidth(), O = useCurrentClassByProperty(v), z = useAddClassesToBlocks(), Z = useRemoveClassesFromBlocks(), [G] = useSelectedBlockIds(), q = useMemo(() => get(O, "fullCls", ""), [O]), ee = useCallback(
31597
- (he, Se = !0) => {
31598
- const Me = { dark: A, mq: _, mod: T, cls: he, property: v, fullCls: "" };
31599
- (A || T !== "") && (Me.mq = "xs");
31600
- const W = generateFullClsName(Me);
31601
- z(G, [W], Se);
31602
- },
31603
- [G, A, _, T, v, z]
31604
- ), ge = useCallback(() => {
31605
- Z(G, [q]);
31606
- }, [G, q, Z]), le = useMemo(() => canChangeClass(O, _), [O, _]);
31607
- useEffect(() => {
31608
- S(le, O);
31609
- }, [le, S, O]);
31610
- const [, , ce] = useCanvasWidth(), $ = useCallback(
31611
- (he) => {
31612
- ce({
31613
- xs: 400,
31614
- sm: 640,
31615
- md: 800,
31616
- lg: 1024,
31617
- xl: 1420,
31618
- "2xl": 1920
31619
- }[he]);
31620
- },
31621
- [ce]
31622
- ), ie = get(O, "dark", null) === A && get(O, "mod", null) === T && get(O, "mq", null) === _;
31623
- return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: le, canReset: O && ie, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
31624
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${O && !ie ? "text-foreground" : ""}`, children: h(x) }) }),
31625
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
31626
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
31627
- g === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
31628
- AdvanceChoices,
31629
- {
31630
- currentClass: get(O, "cls", ""),
31631
- classPrefix: get(CLASS_PREFIXES, v, ""),
31632
- units: C || [],
31633
- onChange: ee,
31634
- negative: R,
31635
- cssProperty: v
31636
- }
31637
- ) : null,
31638
- g === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: v, onChange: ee }),
31639
- g === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: v, onChange: ee }),
31640
- g === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: v, onChange: ee }),
31641
- g === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: x, property: v, onChange: ee })
31642
- ] }),
31643
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${q ? "visible" : "invisible"}`, children: ie ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => ge(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : le && O ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
31644
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31645
- "button",
31646
- {
31647
- type: "button",
31648
- className: "invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",
31649
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {})
31650
- }
31651
- ) }),
31652
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
31653
- "Current style is set at  ",
31654
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
31655
- getBreakpoint(get(O, "mq")),
31656
- A && !O.dark ? "(Light mode)" : ""
31442
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("relative inline-block w-full", v), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31443
+ "select",
31444
+ {
31445
+ className: "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
31446
+ value: S,
31447
+ onChange: R,
31448
+ children: [
31449
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", disabled: !0, children: x }),
31450
+ g.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: A.value, children: A.label }, A.value))
31451
+ ]
31452
+ }
31453
+ ) });
31454
+ };
31455
+ function UILibrariesSelect({
31456
+ uiLibraries: r,
31457
+ library: h,
31458
+ setLibrary: g
31459
+ }) {
31460
+ const { t: x } = useTranslation();
31461
+ return h ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-12", children: [
31462
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-bold text-gray-500", children: x("Choose library") }),
31463
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31464
+ ChaiSelect,
31465
+ {
31466
+ className: "mt-1",
31467
+ options: r.map((v) => ({
31468
+ value: v.uuid,
31469
+ label: v.name
31470
+ })),
31471
+ defaultValue: h,
31472
+ onValueChange: (v) => g(v)
31473
+ }
31474
+ )
31475
+ ] }) : null;
31476
+ }
31477
+ const BlockCard = ({
31478
+ block: r,
31479
+ library: h,
31480
+ parentId: g = void 0,
31481
+ position: x = -1
31482
+ }) => {
31483
+ const [v, S] = useState(!1), C = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: R, addPredefinedBlock: A } = useAddBlock(), [, T] = useSelectedBlockIds(), { clearHighlight: _ } = useBlockHighlight(), O = get(r, "name", get(r, "label")), z = useFeature("dnd"), [, Z] = useAtom$1(draggedBlockAtom), G = (ge) => {
31484
+ const le = has(ge, "styles_attrs.data-page-section");
31485
+ return ge._type === "Box" && le;
31486
+ }, q = useCallback(
31487
+ async (ge) => {
31488
+ if (ge.stopPropagation(), has(r, "component")) {
31489
+ R(r, g, x), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31490
+ return;
31491
+ }
31492
+ S(!0);
31493
+ const le = await C(h, r);
31494
+ isEmpty(le) || A(syncBlocksWithDefaults(le), g, x), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31495
+ },
31496
+ [R, A, r, C, h, g, x]
31497
+ ), ee = async (ge) => {
31498
+ const le = await C(h, r);
31499
+ let ce = g;
31500
+ if (G(first(le)) && (ce = null), !isEmpty(le)) {
31501
+ const $ = { blocks: le, uiLibrary: !0, parent: ce };
31502
+ if (ge.dataTransfer.setData("text/plain", JSON.stringify($)), r.preview) {
31503
+ const ie = new Image();
31504
+ ie.src = r.preview, ie.onload = () => {
31505
+ ge.dataTransfer.setDragImage(ie, 0, 0);
31506
+ };
31507
+ } else
31508
+ ge.dataTransfer.setDragImage(new Image(), 0, 0);
31509
+ Z($), setTimeout(() => {
31510
+ T([]), _(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31511
+ }, 200);
31512
+ }
31513
+ };
31514
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31515
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31516
+ "div",
31517
+ {
31518
+ onClick: v ? () => {
31519
+ } : q,
31520
+ draggable: z ? "true" : "false",
31521
+ onDragStart: ee,
31522
+ className: clsx(
31523
+ "relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
31524
+ ),
31525
+ children: [
31526
+ v && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute flex h-full w-full items-center justify-center bg-black/70", children: [
31527
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
31528
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
31657
31529
  ] }),
31658
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
31659
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
31660
- "button",
31530
+ r.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: r.preview, className: "min-h-[45px] w-full rounded-md", alt: O }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: O }) })
31531
+ ]
31532
+ }
31533
+ ) }),
31534
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: O }) })
31535
+ ] });
31536
+ }, libraryBlocksAtom = atom$1(
31537
+ {}
31538
+ ), useLibraryBlocks = (r) => {
31539
+ const [h, g] = useAtom$1(libraryBlocksAtom), x = useBuilderProp("getUILibraryBlocks", noop), v = get(h, `${r == null ? void 0 : r.uuid}.blocks`, null), S = get(h, `${r == null ? void 0 : r.uuid}.loading`, "idle"), C = useRef("idle");
31540
+ return useEffect(() => {
31541
+ (async () => {
31542
+ if (S === "complete" || C.current === "loading") return;
31543
+ C.current = "loading", g((A) => ({ ...A, [r == null ? void 0 : r.uuid]: { loading: "loading", blocks: [] } }));
31544
+ const R = await x(r);
31545
+ C.current = "idle", g((A) => ({ ...A, [r == null ? void 0 : r.uuid]: { loading: "complete", blocks: R || [] } }));
31546
+ })();
31547
+ }, [r, v, S, C, g, x]), { data: v || [], isLoading: S === "loading" };
31548
+ }, UILibrarySection = ({ parentId: r, position: h }) => {
31549
+ const [g, x] = useAtom$1(selectedLibraryAtom), v = useBuilderProp("uiLibraries", []), S = useRegisteredChaiBlocks(), C = values(S).filter((ce) => ce.category === "custom"), R = v.find((ce) => ce.uuid === g) || first(v), { data: A, isLoading: T } = useLibraryBlocks(R), _ = groupBy([...A, ...C], "group"), [O, z] = useState("Hero"), Z = get(_, O, []), G = useRef(null), { t: q } = useTranslation(), ee = (ce) => {
31550
+ G.current && (clearTimeout(G.current), G.current = null), G.current = setTimeout(() => {
31551
+ G.current && z(ce);
31552
+ }, 300);
31553
+ };
31554
+ if (T)
31555
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
31556
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
31557
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
31558
+ ] });
31559
+ const ge = filter(Z, (ce, $) => $ % 2 === 0), le = filter(Z, (ce, $) => $ % 2 === 1);
31560
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
31561
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
31562
+ /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: R == null ? void 0 : R.uuid, setLibrary: x, uiLibraries: v }),
31563
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
31564
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: q("Groups") }),
31565
+ /* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
31566
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
31567
+ map(_, (ce, $) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
31568
+ "div",
31661
31569
  {
31662
- type: "button",
31663
- onClick: () => $(get(O, "mq")),
31664
- className: "block w-full cursor-default text-right font-semibold text-blue-500",
31570
+ onMouseEnter: () => ee($),
31571
+ onMouseLeave: () => clearTimeout(G.current),
31572
+ onClick: () => z($),
31573
+ className: cn(
31574
+ "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
31575
+ $ === O ? "bg-blue-500 text-white hover:bg-blue-600" : ""
31576
+ ),
31665
31577
  children: [
31666
- "Switch to ",
31667
- get(O, "mq").toUpperCase()
31578
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(q($.toLowerCase())) }),
31579
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
31668
31580
  ]
31669
- }
31670
- )
31671
- ] }) }) })
31672
- ] }) : null })
31673
- ] })
31674
- ] }) });
31675
- }, basicUnits = ["px", "%", "em", "rem", "ch", "vh", "vw"], MultipleChoices = ({
31676
- label: r,
31677
- options: h,
31678
- borderB: g = !1,
31679
- borderT: x = !1,
31680
- type: v = "arbitrary",
31681
- units: S = basicUnits,
31682
- negative: C = !1
31683
- }) => {
31684
- const { t: R } = useTranslation(), [A, T] = useState(h[0].key), _ = useSelectedBlockCurrentClasses(), O = useCallback((z) => map(_, "property").includes(z), [_]);
31685
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
31581
+ },
31582
+ $
31583
+ ))
31584
+ ) })
31585
+ ] })
31586
+ ] }),
31587
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31588
+ ScrollArea,
31589
+ {
31590
+ onMouseEnter: () => G.current ? clearTimeout(G.current) : null,
31591
+ className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
31592
+ children: [
31593
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
31594
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
31595
+ ge.map((ce) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: r, position: h, block: ce, library: R }))
31596
+ ) }),
31597
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
31598
+ le.map((ce) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: r, position: h, block: ce, library: R }))
31599
+ ) })
31600
+ ] }),
31601
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
31602
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
31603
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
31604
+ ]
31605
+ }
31606
+ )
31607
+ ] }) }) });
31608
+ }, UILibrariesPanel = ({ parentId: r, position: h }) => /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrarySection, { parentId: r, position: h }), placeholderStyle = {
31609
+ display: "flex",
31610
+ alignItems: "center",
31611
+ zIndex: 1
31612
+ }, DefaultCursor = React__default.memo(function({ top: h, left: g }) {
31613
+ const x = {
31614
+ position: "absolute",
31615
+ pointerEvents: "none",
31616
+ top: h + "px",
31617
+ left: g + "px",
31618
+ right: 0
31619
+ };
31620
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { ...placeholderStyle, ...x }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0.5 flex-1 rounded-[1px] bg-green-500" }) });
31621
+ }), Overlay = memo(function({ children: h, isDragging: g }) {
31622
+ return g ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pointer-events-none fixed left-0 top-0 z-[100] h-full w-full", children: h }) : null;
31623
+ }), DefaultDragPreview = memo(({ id: r, isDragging: h, mouse: g }) => {
31624
+ const [x] = useBlocksStore(), v = useMemo(() => x.find((C) => C._id === r), [x, r]), S = useMemo(
31625
+ () => ({
31626
+ transform: `translate(${(g == null ? void 0 : g.x) - 10}px, ${(g == null ? void 0 : g.y) - 10}px)`
31627
+ }),
31628
+ [g]
31629
+ );
31630
+ return g ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { isDragging: h, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31686
31631
  "div",
31687
31632
  {
31688
- className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${g ? "border-b" : ""} ${x ? "border-t" : ""}`,
31689
- children: [
31690
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
31691
- r && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: R(r) }),
31692
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
31693
- h.map(({ label: z, key: Z }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31694
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31695
- "button",
31696
- {
31697
- type: "button",
31698
- onClick: () => T(Z),
31699
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${Z === A ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
31700
- children: [
31701
- React__default.createElement("div", {
31702
- className: O(Z) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
31703
- }),
31704
- React__default.createElement(get(EDITOR_ICONS, Z, BoxIcon), { className: "text-inherit w-3 h-3" })
31705
- ]
31706
- }
31707
- ) }),
31708
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(z)) })
31709
- ] }) }))
31710
- ) })
31711
- ] }),
31712
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31713
- BlockStyle,
31714
- {
31715
- type: v,
31716
- units: [...S],
31717
- label: "",
31718
- property: A,
31719
- negative: C
31720
- }
31721
- ) })
31722
- ]
31633
+ className: "pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",
31634
+ style: S,
31635
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { type: "button", className: "flex !cursor-grab items-center p-0.5", "aria-label": `Type: ${v == null ? void 0 : v._type}`, children: [
31636
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: v == null ? void 0 : v._type }) }),
31637
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ml-2 truncate text-[11px]", children: (v == null ? void 0 : v._name) || (v == null ? void 0 : v._type) })
31638
+ ] })
31723
31639
  }
31724
- );
31725
- }, NestedOptions = ({ heading: r, items: h }) => {
31726
- const { t: g } = useTranslation(), x = useSelectedBlockCurrentClasses(), v = useMemo(() => {
31727
- const S = (A) => flatten(
31728
- A.map((T) => T.styleType === "multiple" ? map(T.options, "key") : T.property)
31729
- ), C = flatten(
31730
- h.map((A) => A.styleType === "accordion" ? S(A.items) : A.styleType === "multiple" ? map(A.options, "key") : A.property)
31731
- ), R = map(x, "property");
31732
- return intersection(C, R).length > 0;
31733
- }, [x, h]);
31734
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("details", { children: [
31735
- /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline", children: [
31736
- startCase(g(r.toLowerCase())),
31737
- v ? /* @__PURE__ */ jsxRuntimeExports.jsx(
31738
- "span",
31640
+ ) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden" });
31641
+ }), PasteAtRootContextMenu = ({ parentContext: r, setParentContext: h }) => {
31642
+ const { t: g } = useTranslation(), { canPaste: x, pasteBlocks: v } = usePasteBlocks();
31643
+ return useEffect(() => {
31644
+ x("root") || h(null);
31645
+ }, [x("root")]), r && x("root") && /* @__PURE__ */ jsxRuntimeExports.jsx(
31646
+ "div",
31647
+ {
31648
+ style: { position: "absolute", top: r.y - 75, left: r.x - 56 },
31649
+ onMouseLeave: () => h(null),
31650
+ className: "w-28 rounded-md border bg-white p-1 shadow-xl",
31651
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31652
+ "div",
31739
31653
  {
31740
- className: `ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${v ? "bg-blue-500" : "bg-gray-300"}`
31741
- }
31742
- ) : null
31743
- ] }) }),
31744
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2", children: h.map((S) => S.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...S }, S.label) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...S }, S.label)) })
31745
- ] });
31746
- }, SectionContext = createContext({}), StylingGroup = ({ section: r, showAccordian: h }) => {
31747
- const { t: g } = useTranslation(), x = useSelectedBlockCurrentClasses(), v = useCallback(
31748
- (C = []) => {
31749
- const R = {};
31750
- for (let T = 0; T < x.length; T++)
31751
- R[x[T].property] = x[T].cls;
31752
- let A = !0;
31753
- for (const T in C)
31754
- if (!has(R, T) || R[T] !== C[T]) {
31755
- A = !1;
31756
- break;
31654
+ className: "flex cursor-pointer items-center gap-x-4 rounded px-2 py-1 text-xs hover:bg-blue-50",
31655
+ onClick: () => {
31656
+ v("root"), h(null);
31657
+ },
31658
+ children: [
31659
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackIcon, {}),
31660
+ " ",
31661
+ g("Paste")
31662
+ ]
31757
31663
  }
31758
- return A;
31759
- },
31760
- [x]
31761
- ), S = useMemo(() => ({}), []);
31762
- return /* @__PURE__ */ jsxRuntimeExports.jsx(SectionContext.Provider, { value: S, children: h ? /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: r.heading, className: "border-none", children: [
31763
- /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(g(r.heading)) }) }) }),
31764
- /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionContent, { className: "py-2", children: React__default.Children.toArray(
31765
- r.items.map((C) => has(C, "component") ? React__default.createElement(C.component, { key: C.label }) : has(C, "styleType") ? C.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...C }, C.label) : C.styleType === "accordion" && v(C == null ? void 0 : C.conditions) ? /* @__PURE__ */ jsxRuntimeExports.jsx(NestedOptions, { ...C }, C.label) : null : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...C }, C.label))
31766
- ) })
31767
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-2", children: React__default.Children.toArray(
31768
- r.items.map((C) => has(C, "component") ? React__default.createElement(C.component, { key: C.label }) : has(C, "styleType") ? C.styleType === "multiple" ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultipleChoices, { ...C }, C.label) : C.styleType === "accordion" && v(C == null ? void 0 : C.conditions) ? /* @__PURE__ */ jsxRuntimeExports.jsx(NestedOptions, { ...C }, C.label) : null : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyle, { ...C }, C.label))
31769
- ) }) });
31770
- }, StylingHelpers = () => {
31771
- const r = useSelectedBlock(), [h] = useSelectedStylingBlocks(), { t: g } = useTranslation(), x = useAddClassesToBlocks(), v = getRegisteredChaiBlock(r._type), S = get(first(h), "prop"), C = get(v.props, `${S}.presets`, {});
31772
- if (!has(v, "props") || isEmpty(C))
31773
- return null;
31774
- const R = (A) => {
31775
- const T = A.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
31776
- x([r._id], T, !0);
31777
- };
31778
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
31779
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "default", className: "w-full", size: "sm", children: [
31780
- g("Apply Presets"),
31781
- /* @__PURE__ */ jsxRuntimeExports.jsx(CaretDownIcon, {})
31782
- ] }) }) }),
31783
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuContent, { className: "max-h-80 w-56", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "no-scrollbar h-full", children: isEmpty(C) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
31784
- /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuLabel, { children: [
31785
- v.type,
31786
- " ",
31787
- g("presets")
31788
- ] }),
31789
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
31790
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(C).map((A) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => R(C[A]), children: [
31791
- capitalize(startCase(g(A))),
31792
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: g("apply") })
31793
- ] })) })
31794
- ] }) }) })
31795
- ] }) });
31796
- }, BlockStylingProps = () => {
31797
- const r = useSelectedBlock(), [h, g] = useSelectedStylingBlocks(), { t: x } = useTranslation();
31798
- if (!r) return null;
31799
- const v = Object.keys(r).filter(
31800
- (C) => typeof r[C] == "string" && r[C].startsWith("#styles:")
31664
+ )
31665
+ }
31801
31666
  );
31802
- if (isEmpty(v) || v.length <= 1) return null;
31803
- const S = (C) => find(h, (R) => R.prop === C);
31804
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-1", children: [
31805
- /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
31806
- x("Style element"),
31807
- ":"
31808
- ] }),
31809
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-2", children: map(v, (C) => /* @__PURE__ */ jsxRuntimeExports.jsx(
31810
- Badge,
31667
+ }, CopyPasteBlocks = () => {
31668
+ const [r] = useBlocksStore(), [h] = useSelectedBlockIds(), { pasteBlocks: g } = usePasteBlocks(), [, x] = useCopyBlockIds(), { t: v } = useTranslation(), S = useSelectedBlock(), C = useCallback(() => {
31669
+ const R = h.map((A) => {
31670
+ const T = r.find((_) => _._id === A);
31671
+ return {
31672
+ id: A,
31673
+ data: T
31674
+ };
31675
+ });
31676
+ x(R.map((A) => A.id));
31677
+ }, [h, r, x]);
31678
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
31679
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31680
+ ContextMenuItem,
31811
31681
  {
31812
- className: "cursor-pointer",
31682
+ disabled: !canDuplicateBlock(S == null ? void 0 : S._type),
31683
+ onClick: C,
31684
+ className: "flex items-center gap-x-4 text-xs",
31685
+ children: [
31686
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}),
31687
+ " ",
31688
+ v("Copy")
31689
+ ]
31690
+ }
31691
+ ),
31692
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31693
+ ContextMenuItem,
31694
+ {
31695
+ className: "flex items-center gap-x-4 text-xs",
31813
31696
  onClick: () => {
31814
- g([{ id: `${C}-${r._id}`, blockId: r._id, prop: C }]);
31697
+ g(h);
31815
31698
  },
31816
- variant: S(C) ? "default" : "secondary",
31817
- children: startCase(C)
31818
- },
31819
- C
31820
- )) }),
31821
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
31699
+ children: [
31700
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackIcon, {}),
31701
+ " ",
31702
+ v("Paste")
31703
+ ]
31704
+ }
31705
+ )
31822
31706
  ] });
31823
- }, MAPPER = {
31824
- px: 1,
31825
- "%": 1,
31826
- em: 100,
31827
- rem: 100,
31828
- ch: 1,
31829
- vw: 1,
31830
- vh: 1,
31831
- "-": 1,
31832
- deg: 1,
31833
- ms: 0.1
31707
+ }, CutBlocks = () => {
31708
+ const [r] = useSelectedBlockIds(), [, h] = useCutBlockIds(), { t: g } = useTranslation();
31709
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenuItem, { className: "flex items-center gap-x-4 text-xs", onClick: () => h(r), children: [
31710
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ScissorsIcon, {}),
31711
+ " ",
31712
+ g("Cut")
31713
+ ] });
31714
+ }, RemoveBlocks = () => {
31715
+ const [r] = useSelectedBlockIds(), h = useRemoveBlocks(), g = useSelectedBlock(), { t: x } = useTranslation();
31716
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
31717
+ ContextMenuItem,
31718
+ {
31719
+ disabled: !canDeleteBlock(g == null ? void 0 : g._type),
31720
+ className: "flex items-center gap-x-4 text-xs",
31721
+ onClick: () => h(r),
31722
+ children: [
31723
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TrashIcon, {}),
31724
+ " ",
31725
+ x("Remove")
31726
+ ]
31727
+ }
31728
+ );
31729
+ }, BlockContextMenuContent = () => {
31730
+ const { t: r } = useTranslation(), [h] = useSelectedBlockIds(), g = useDuplicateBlocks(), x = useSelectedBlock(), v = useCallback(() => {
31731
+ g(h);
31732
+ }, [h, g]);
31733
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenuContent, { className: "border-border text-xs", children: [
31734
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31735
+ ContextMenuItem,
31736
+ {
31737
+ disabled: !canAddChildBlock(x == null ? void 0 : x._type),
31738
+ className: "flex items-center gap-x-4 text-xs",
31739
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x),
31740
+ children: [
31741
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "14" }),
31742
+ " ",
31743
+ r("Add block")
31744
+ ]
31745
+ }
31746
+ ),
31747
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31748
+ ContextMenuItem,
31749
+ {
31750
+ disabled: !canDuplicateBlock(x == null ? void 0 : x._type),
31751
+ className: "flex items-center gap-x-4 text-xs",
31752
+ onClick: v,
31753
+ children: [
31754
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackPlusIcon, {}),
31755
+ " ",
31756
+ r("Duplicate")
31757
+ ]
31758
+ }
31759
+ ),
31760
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CutBlocks, {}),
31761
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CopyPasteBlocks, {}),
31762
+ /* @__PURE__ */ jsxRuntimeExports.jsx(RemoveBlocks, {})
31763
+ ] });
31764
+ }, BlockContextMenu = ({ children: r }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(ContextMenu, { children: [
31765
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ContextMenuTrigger, { asChild: !0, children: r }),
31766
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenuContent, {})
31767
+ ] }) }), defaultShortcuts = [
31768
+ { key: "ArrowDown", command: "selectNext" },
31769
+ { key: "ArrowUp", command: "selectPrev" },
31770
+ { key: "ArrowLeft", command: "selectParent", when: "isLeaf || isClosed" },
31771
+ { key: "ArrowLeft", command: "close", when: "isOpen" },
31772
+ { key: "ArrowRight", command: "open", when: "isClosed" },
31773
+ { key: "ArrowRight", command: "selectNext", when: "isOpen" },
31774
+ { key: "Home", command: "selectFirst" },
31775
+ { key: "End", command: "selectLast" }
31776
+ ];
31777
+ function selectFirst(r) {
31778
+ r.firstNode && r.select(r.firstNode.id);
31779
+ }
31780
+ function selectLast(r) {
31781
+ r.lastNode && r.select(r.lastNode.id);
31782
+ }
31783
+ function selectNext(r) {
31784
+ const h = r.selectedNodes[0].next || r.firstNode;
31785
+ r.select(h.id);
31786
+ }
31787
+ function selectPrev(r) {
31788
+ const h = r.selectedNodes[0].prev || r.lastNode;
31789
+ r.select(h.id);
31790
+ }
31791
+ const selectParent = (r, h) => {
31792
+ var x;
31793
+ const g = ((x = r.selectedIds[0]) == null ? void 0 : x.parent) || null;
31794
+ g && h && r.select(g.id);
31795
+ }, open = (r, h) => {
31796
+ const g = r.selectedNodes[0];
31797
+ g.isInternal && h && g.open();
31798
+ }, close = (r, h) => {
31799
+ const g = r.selectedNodes[0];
31800
+ g.isInternal && h && g.close();
31834
31801
  };
31835
- function BlockStyling() {
31836
- const { flexChild: r, gridChild: h } = useSelectedBlocksDisplayChild(), [g] = useSelectedStylingBlocks(), [x, v] = React__default.useState(""), [S, C] = React__default.useState({
31837
- onDrag: (T) => T,
31838
- onDragEnd: (T) => T,
31839
- dragStartY: 0,
31840
- dragging: !1,
31841
- dragStartValue: 0,
31842
- dragUnit: "",
31843
- negative: !1,
31844
- cssProperty: ""
31845
- }), R = useThrottledCallback(
31846
- (T) => {
31847
- const _ = !get(S, "negative", !1), O = get(S, "cssProperty", "");
31848
- let z = parseFloat(S.dragStartValue);
31849
- z = isNaN(z) ? 0 : z;
31850
- let Z = MAPPER[S.dragUnit];
31851
- (startsWith(O, "scale") || O === "opacity") && (Z = 10);
31852
- let q = (S.dragStartY - T.pageY) / Z + z;
31853
- _ && q < 0 && (q = 0), O === "opacity" && q > 1 && (q = 1), S.onDrag(`${q}`), v(`${q}`);
31854
- },
31855
- [S],
31856
- 50
31857
- ), A = useCallback(() => {
31858
- setTimeout(() => S.onDragEnd(`${x}`), 100), C({
31859
- onDrag: (T) => T,
31860
- onDragEnd: (T) => T,
31861
- dragStartY: 0,
31862
- dragging: !1,
31863
- dragStartValue: 0,
31864
- dragUnit: "",
31865
- negative: !1,
31866
- cssProperty: ""
31867
- });
31868
- }, [S, x, C]);
31869
- return isEmpty(g) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(BlockSettingsContext.Provider, { value: { setDragData: C }, children: [
31870
- S.dragging ? /* @__PURE__ */ jsxRuntimeExports.jsx(
31802
+ function VscJson(r) {
31803
+ return GenIcon({ tag: "svg", attr: { viewBox: "0 0 16 16", fill: "currentColor" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z" }, child: [] }] })(r);
31804
+ }
31805
+ function BsLightningFill(r) {
31806
+ return GenIcon({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z" }, child: [] }] })(r);
31807
+ }
31808
+ function TbEyeDown(r) {
31809
+ return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" }, child: [] }, { tag: "path", attr: { d: "M12 18c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" }, child: [] }, { tag: "path", attr: { d: "M19 16v6" }, child: [] }, { tag: "path", attr: { d: "M22 19l-3 3l-3 -3" }, child: [] }] })(r);
31810
+ }
31811
+ function BiCollapseVertical(r) {
31812
+ return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 7.59 7.05 2.64 5.64 4.05 12 10.41l6.36-6.36-1.41-1.41L12 7.59zM5.64 19.95l1.41 1.41L12 16.41l4.95 4.95 1.41-1.41L12 13.59l-6.36 6.36z" }, child: [] }] })(r);
31813
+ }
31814
+ function BiExpandVertical(r) {
31815
+ return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(r);
31816
+ }
31817
+ const currentAddSelection = atom$1(null), Node = memo(({ node: r, style: h, dragHandle: g }) => {
31818
+ var se;
31819
+ const x = useBuilderProp("outlineMenuItems", []), { t: v } = useTranslation(), [S, , C] = useHiddenBlockIds(), [R] = useAtom$1(canvasIframeAtom);
31820
+ let A = null;
31821
+ const T = r.children.length > 0, { highlightBlock: _, clearHighlight: O } = useBlockHighlight(), { id: z, data: Z, isSelected: G, willReceiveDrop: q, isDragging: ee, isEditing: ge, handleClick: le } = r, ce = (me) => {
31822
+ me.stopPropagation(), !S.includes(z) && r.toggle();
31823
+ }, $ = (me) => {
31824
+ me.isInternal && (A = me.isOpen, me.isOpen && me.close());
31825
+ }, ie = (me) => {
31826
+ me.isInternal && A !== null && (A ? me.open() : me.close(), A = null);
31827
+ }, [he, Se] = useAtom$1(currentAddSelection), Me = () => {
31828
+ var me;
31829
+ W(), r.parent.isSelected || Se((me = r == null ? void 0 : r.parent) == null ? void 0 : me.id);
31830
+ }, W = () => {
31831
+ Se(null);
31832
+ }, xe = (me) => {
31833
+ W(), me.stopPropagation(), !r.isOpen && !S.includes(z) && r.toggle(), le(me);
31834
+ };
31835
+ useEffect(() => {
31836
+ const me = setTimeout(() => {
31837
+ q && !r.isOpen && !ee && !S.includes(z) && r.toggle();
31838
+ }, 500);
31839
+ return () => clearTimeout(me);
31840
+ }, [q, r, ee]);
31841
+ const ve = useMemo(() => {
31842
+ const me = Object.keys(Z), V = [];
31843
+ for (let ue = 0; ue < me.length; ue++)
31844
+ if (me[ue].endsWith("_attrs")) {
31845
+ const de = Z[me[ue]], Ae = Object.keys(de).join("|");
31846
+ Ae.match(/x-data/) && V.push("data"), Ae.match(/x-on/) && V.push("event"), Ae.match(/x-show|x-if/) && V.push("show");
31847
+ }
31848
+ return V;
31849
+ }, [Z]), ye = (me, V) => {
31850
+ const ue = R.contentDocument || R.contentWindow.document, de = ue.querySelector(`[data-block-id=${me}]`);
31851
+ de && de.setAttribute("data-drop", V);
31852
+ const Ae = de.getBoundingClientRect(), Ee = R.getBoundingClientRect();
31853
+ Ae.top >= Ee.top && Ae.left >= Ee.left && Ae.bottom <= Ee.bottom && Ae.right <= Ee.right || (ue.documentElement.scrollTop = de.offsetTop - Ee.top);
31854
+ }, je = (me) => {
31855
+ W();
31856
+ const V = get(r, "parent.id");
31857
+ V !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: V, position: me }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: me });
31858
+ };
31859
+ return z === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
31860
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
31861
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31871
31862
  "div",
31872
31863
  {
31873
- onMouseMove: R,
31874
- onMouseUp: () => A(),
31875
- className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
31864
+ onClick: () => je(-1),
31865
+ className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
31866
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
31867
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
31868
+ " ",
31869
+ v("Add block")
31870
+ ] })
31876
31871
  }
31877
- ) : null,
31878
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [
31879
- /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStylingProps, {}),
31880
- /* @__PURE__ */ jsxRuntimeExports.jsx(StylingHelpers, {}),
31881
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
31882
- r && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: r || h }),
31883
- h && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: r || h }),
31884
- SETTINGS_SECTIONS.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: T, showAccordian: r || h }, T.heading))
31885
- ] })
31886
- ] })
31887
- ] });
31888
- }
31889
- const ChaiSelect = ({
31890
- defaultValue: r = "",
31891
- onValueChange: h,
31892
- options: g,
31893
- placeholder: x = "Select",
31894
- className: v = ""
31895
- }) => {
31896
- const [S, C] = useState(r), R = (A) => {
31897
- const T = A.target.value;
31898
- C(T), h(T);
31899
- };
31900
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("relative inline-block w-full", v), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31901
- "select",
31872
+ ),
31873
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
31874
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: z, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31875
+ "div",
31902
31876
  {
31903
- className: "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
31904
- value: S,
31905
- onChange: R,
31877
+ onMouseEnter: () => _(z),
31878
+ onMouseLeave: () => O(),
31879
+ onClick: xe,
31880
+ style: h,
31881
+ "data-node-id": z,
31882
+ ref: S.includes(z) ? null : g,
31883
+ onDragStart: () => $(r),
31884
+ onDragEnd: () => ie(r),
31885
+ onDragOver: (me) => {
31886
+ me.preventDefault(), ye(z, "yes");
31887
+ },
31888
+ onDragLeave: (me) => {
31889
+ me.preventDefault(), ye(z, "no");
31890
+ },
31891
+ onDrop: (me) => {
31892
+ me.preventDefault(), ye(z, "no");
31893
+ },
31906
31894
  children: [
31907
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", disabled: !0, children: x }),
31908
- g.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: A.value, children: A.label }, A.value))
31895
+ (r == null ? void 0 : r.rowIndex) > 0 && (r.parent.isOpen && canAddChildBlock(get(r, "parent.data._type")) || ((se = r == null ? void 0 : r.parent) == null ? void 0 : se.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31896
+ "div",
31897
+ {
31898
+ onClick: (me) => {
31899
+ me.stopPropagation(), je(r.childIndex);
31900
+ },
31901
+ onMouseEnter: Me,
31902
+ onMouseLeave: W,
31903
+ className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
31904
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
31905
+ }
31906
+ ) }),
31907
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
31908
+ "div",
31909
+ {
31910
+ className: cn(
31911
+ "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
31912
+ G ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
31913
+ q && canAcceptChildBlock(Z._type, "Icon") ? "bg-green-200" : "",
31914
+ (r == null ? void 0 : r.id) === he ? "bg-purple-100" : "",
31915
+ ee && "opacity-20",
31916
+ S.includes(z) ? "opacity-50" : ""
31917
+ ),
31918
+ children: [
31919
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
31920
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31921
+ "div",
31922
+ {
31923
+ className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${r.isOpen ? "rotate-90" : ""}`,
31924
+ children: T && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: ce, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
31925
+ ChevronRight,
31926
+ {
31927
+ className: `h-3 w-3 stroke-[3] ${G ? "text-slate-200" : "text-slate-400"}`
31928
+ }
31929
+ ) })
31930
+ }
31931
+ ),
31932
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "leading-1 flex items-center", children: [
31933
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: Z == null ? void 0 : Z._type }),
31934
+ ge ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: r }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
31935
+ "div",
31936
+ {
31937
+ className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
31938
+ onDoubleClick: (me) => {
31939
+ me.stopPropagation(), r.edit(), r.deselect();
31940
+ },
31941
+ children: [
31942
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (Z == null ? void 0 : Z._name) || (Z == null ? void 0 : Z._type.split("/").pop()) }),
31943
+ ve.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
31944
+ ve.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
31945
+ ve.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
31946
+ ]
31947
+ }
31948
+ )
31949
+ ] })
31950
+ ] }),
31951
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
31952
+ !S.includes(z) && x.map((me) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31953
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31954
+ TooltipTrigger,
31955
+ {
31956
+ className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
31957
+ asChild: !0,
31958
+ children: React__default.createElement(me.item, { blockId: z })
31959
+ }
31960
+ ),
31961
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: me.tooltip })
31962
+ ] })),
31963
+ canAddChildBlock(Z == null ? void 0 : Z._type) && !S.includes(z) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31964
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31965
+ TooltipTrigger,
31966
+ {
31967
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: z }),
31968
+ className: "cursor-pointer rounded bg-transparent hover:text-black",
31969
+ asChild: !0,
31970
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "15" })
31971
+ }
31972
+ ),
31973
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: v("Add block") })
31974
+ ] }) : null,
31975
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31976
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
31977
+ TooltipTrigger,
31978
+ {
31979
+ onClick: (me) => {
31980
+ me.stopPropagation(), C(z), r.isOpen && r.toggle();
31981
+ },
31982
+ className: "cursor-pointer rounded bg-transparent hover:text-black",
31983
+ asChild: !0,
31984
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { size: "15" })
31985
+ }
31986
+ ),
31987
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: v("Hide block") })
31988
+ ] })
31989
+ ] })
31990
+ ]
31991
+ }
31992
+ )
31909
31993
  ]
31910
31994
  }
31911
- ) });
31912
- };
31913
- function UILibrariesSelect({
31914
- uiLibraries: r,
31915
- library: h,
31916
- setLibrary: g
31917
- }) {
31918
- const { t: x } = useTranslation();
31919
- return h ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-12", children: [
31920
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-bold text-gray-500", children: x("Choose library") }),
31921
- /* @__PURE__ */ jsxRuntimeExports.jsx(
31922
- ChaiSelect,
31923
- {
31924
- className: "mt-1",
31925
- options: r.map((v) => ({
31926
- value: v.uuid,
31927
- label: v.name
31928
- })),
31929
- defaultValue: h,
31930
- onValueChange: (v) => g(v)
31931
- }
31932
- )
31933
- ] }) : null;
31934
- }
31935
- const BlockCard = ({
31936
- block: r,
31937
- library: h,
31938
- parentId: g = void 0,
31939
- position: x = -1
31940
- }) => {
31941
- const [v, S] = useState(!1), C = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: R, addPredefinedBlock: A } = useAddBlock(), [, T] = useSelectedBlockIds(), { clearHighlight: _ } = useBlockHighlight(), O = get(r, "name", get(r, "label")), z = useFeature("dnd"), [, Z] = useAtom$1(draggedBlockAtom), G = (ge) => {
31942
- const le = has(ge, "styles_attrs.data-page-section");
31943
- return ge._type === "Box" && le;
31944
- }, q = useCallback(
31945
- async (ge) => {
31946
- if (ge.stopPropagation(), has(r, "component")) {
31947
- R(r, g, x), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31948
- return;
31995
+ ) }) });
31996
+ }), Input = ({ node: r }) => {
31997
+ var h, g;
31998
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
31999
+ "input",
32000
+ {
32001
+ autoFocus: !0,
32002
+ className: cn(
32003
+ "ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
32004
+ r.isSelected ? "text-black dark:text-white" : ""
32005
+ ),
32006
+ type: "text",
32007
+ defaultValue: ((h = r.data) == null ? void 0 : h._name) || ((g = r.data) == null ? void 0 : g._type),
32008
+ onFocus: (x) => x.currentTarget.select(),
32009
+ onBlur: (x) => r.submit(x.currentTarget.value),
32010
+ onKeyDown: (x) => {
32011
+ x.key === "Enter" && r.submit(x.currentTarget.value);
31949
32012
  }
31950
- S(!0);
31951
- const le = await C(h, r);
31952
- isEmpty(le) || A(syncBlocksWithDefaults(le), g, x), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31953
- },
31954
- [R, A, r, C, h, g, x]
31955
- ), ee = async (ge) => {
31956
- const le = await C(h, r);
31957
- let ce = g;
31958
- if (G(first(le)) && (ce = null), !isEmpty(le)) {
31959
- const $ = { blocks: le, uiLibrary: !0, parent: ce };
31960
- if (ge.dataTransfer.setData("text/plain", JSON.stringify($)), r.preview) {
31961
- const ie = new Image();
31962
- ie.src = r.preview, ie.onload = () => {
31963
- ge.dataTransfer.setDragImage(ie, 0, 0);
31964
- };
31965
- } else
31966
- ge.dataTransfer.setDragImage(new Image(), 0, 0);
31967
- Z($), setTimeout(() => {
31968
- T([]), _(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
31969
- }, 200);
31970
32013
  }
32014
+ );
32015
+ }, useCanMove = () => {
32016
+ const [r] = useBlocksStore();
32017
+ return (h, g) => {
32018
+ var S;
32019
+ const x = (S = find(r, { _id: g })) == null ? void 0 : S._type, v = first(h.map((C) => {
32020
+ var R;
32021
+ return (R = find(r, { _id: C })) == null ? void 0 : R._type;
32022
+ }));
32023
+ return canAcceptChildBlock(x, v);
31971
32024
  };
31972
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
31973
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
32025
+ }, ListTree = () => {
32026
+ const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), [, setHiddenBlocks] = useHiddenBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), [parentContext, setParentContext] = useState(null), clearSelection = () => {
32027
+ setIds([]), setStyleBlocks([]);
32028
+ }, filteredTreeData = useMemo(() => {
32029
+ const r = (g, x) => g.filter((v) => !x.includes(v._id)).map((v) => ({
32030
+ ...v,
32031
+ children: v.children ? r(v.children, x) : []
32032
+ }));
32033
+ return [...r(treeData, cutBlocksIds), { _type: ROOT_TEMP_KEY, _id: ROOT_TEMP_KEY, children: [] }];
32034
+ }, [treeData, cutBlocksIds]), onRename = ({ id: r, name: h, node: g }) => {
32035
+ updateBlockProps([r], { _name: h }, g.data._name);
32036
+ }, onMove = ({ dragIds: r, parentId: h, index: g }) => {
32037
+ canMove(r, h) && moveBlocks(r, h, g);
32038
+ }, onSelect = (r) => {
32039
+ if (r.length === 0) return;
32040
+ const h = r[0] ? r[0].id : "";
32041
+ setStyleBlocks([]), setIds([h]);
32042
+ }, onContextMenu = (r) => {
32043
+ var x;
32044
+ r.preventDefault(), parentContext && setParentContext(null);
32045
+ const h = r.target, g = h.getAttribute("data-node-id") || ((x = h.closest("[data-node-id]")) == null ? void 0 : x.getAttribute("data-node-id"));
32046
+ g ? (setStyleBlocks([]), setIds([g])) : (setStyleBlocks([]), setIds([]), setParentContext({ x: r.clientX, y: r.clientY }));
32047
+ }, debouncedDisableDrop = useDebouncedCallback(
32048
+ ({ parentNode: r, dragNodes: h }) => {
32049
+ var g;
32050
+ return (r == null ? void 0 : r.data._type) === ROOT_TEMP_KEY || !canAcceptChildBlock(r == null ? void 0 : r.data._type, (g = h[0]) == null ? void 0 : g.data._type);
32051
+ },
32052
+ [],
32053
+ 300
32054
+ ), handleKeyDown = (e) => {
32055
+ if (!treeRef.current) return;
32056
+ const tree = treeRef.current, selectedNode = tree.selectedNodes[0];
32057
+ if (!selectedNode) return;
32058
+ setIds[selectedNode.id], setStyleBlocks([]);
32059
+ const isLeaf = !selectedNode.isInternal, isClosed = !selectedNode.isOpen, isOpen = selectedNode.isOpen, shortcut = defaultShortcuts.find((s) => s.key === e.key && (!s.when || eval(s.when)));
32060
+ if (shortcut)
32061
+ switch (e.preventDefault(), shortcut.command) {
32062
+ case "selectNext":
32063
+ selectNext(tree);
32064
+ break;
32065
+ case "selectPrev":
32066
+ selectPrev(tree);
32067
+ break;
32068
+ case "selectParent":
32069
+ selectParent(tree, isLeaf || isClosed);
32070
+ break;
32071
+ case "close":
32072
+ close(tree, isOpen);
32073
+ break;
32074
+ case "open":
32075
+ open(tree, isClosed);
32076
+ break;
32077
+ case "selectFirst":
32078
+ selectFirst(tree);
32079
+ break;
32080
+ case "selectLast":
32081
+ selectLast(tree);
32082
+ break;
32083
+ }
32084
+ };
32085
+ return useEffect(() => {
32086
+ const r = () => {
32087
+ treeRef.current && setTreeRef(treeRef.current);
32088
+ };
32089
+ r();
32090
+ const h = new MutationObserver(r);
32091
+ return h.observe(document.body, { childList: !0, subtree: !0 }), () => h.disconnect();
32092
+ }, [setTreeRef]), isEmpty(treeData) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
32093
+ t("This page is empty"),
32094
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
32095
+ /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
32096
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK), variant: "default", size: "sm", children: [
32097
+ "+ ",
32098
+ t("Add Block")
32099
+ ] })
32100
+ ] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
32101
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
31974
32102
  "div",
31975
32103
  {
31976
- onClick: v ? () => {
31977
- } : q,
31978
- draggable: z ? "true" : "false",
31979
- onDragStart: ee,
31980
- className: clsx(
31981
- "relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
31982
- ),
32104
+ id: "outline-view",
32105
+ className: "no-scrollbar h-full overflow-y-auto text-sm",
32106
+ onKeyDown: (r) => {
32107
+ treeRef.current.isEditing || handleKeyDown(r);
32108
+ },
31983
32109
  children: [
31984
- v && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute flex h-full w-full items-center justify-center bg-black/70", children: [
31985
- /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
31986
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
32110
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground", children: [
32111
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
32112
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
32113
+ Button,
32114
+ {
32115
+ onClick: () => setHiddenBlocks([]),
32116
+ variant: "outline",
32117
+ className: "h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",
32118
+ size: "sm",
32119
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })
32120
+ }
32121
+ ) }),
32122
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Show hidden blocks") })
32123
+ ] }),
32124
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
32125
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
32126
+ var r;
32127
+ return (r = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : r.openAll();
32128
+ }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiExpandVertical, { size: "14" }) }) }),
32129
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Expand all") })
32130
+ ] }),
32131
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
32132
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
32133
+ var r;
32134
+ return (r = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : r.closeAll();
32135
+ }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiCollapseVertical, { size: "14" }) }) }),
32136
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Collapse all") })
32137
+ ] })
31987
32138
  ] }),
31988
- r.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: r.preview, className: "min-h-[45px] w-full rounded-md", alt: O }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: O }) })
31989
- ]
31990
- }
31991
- ) }),
31992
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: O }) })
31993
- ] });
31994
- }, libraryBlocksAtom = atom$1(
31995
- {}
31996
- ), useLibraryBlocks = (r) => {
31997
- const [h, g] = useAtom$1(libraryBlocksAtom), x = useBuilderProp("getUILibraryBlocks", noop), v = get(h, `${r == null ? void 0 : r.uuid}.blocks`, null), S = get(h, `${r == null ? void 0 : r.uuid}.loading`, "idle"), C = useRef("idle");
31998
- return useEffect(() => {
31999
- (async () => {
32000
- if (S === "complete" || C.current === "loading") return;
32001
- C.current = "loading", g((A) => ({ ...A, [r == null ? void 0 : r.uuid]: { loading: "loading", blocks: [] } }));
32002
- const R = await x(r);
32003
- C.current = "idle", g((A) => ({ ...A, [r == null ? void 0 : r.uuid]: { loading: "complete", blocks: R || [] } }));
32004
- })();
32005
- }, [r, v, S, C, g, x]), { data: v || [], isLoading: S === "loading" };
32006
- }, UILibrarySection = ({ parentId: r, position: h }) => {
32007
- const [g, x] = useAtom$1(selectedLibraryAtom), v = useBuilderProp("uiLibraries", []), S = useRegisteredChaiBlocks(), C = values(S).filter((ce) => ce.category === "custom"), R = v.find((ce) => ce.uuid === g) || first(v), { data: A, isLoading: T } = useLibraryBlocks(R), _ = groupBy([...A, ...C], "group"), [O, z] = useState("Hero"), Z = get(_, O, []), G = useRef(null), { t: q } = useTranslation(), ee = (ce) => {
32008
- G.current && (clearTimeout(G.current), G.current = null), G.current = setTimeout(() => {
32009
- G.current && z(ce);
32010
- }, 300);
32011
- };
32012
- if (T)
32013
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
32014
- /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
32015
- /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
32016
- ] });
32017
- const ge = filter(Z, (ce, $) => $ % 2 === 0), le = filter(Z, (ce, $) => $ % 2 === 1);
32018
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
32019
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
32020
- /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: R == null ? void 0 : R.uuid, setLibrary: x, uiLibraries: v }),
32021
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
32022
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: q("Groups") }),
32023
- /* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
32024
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
32025
- map(_, (ce, $) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
32139
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative z-[9999] ml-5 w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
32026
32140
  "div",
32027
32141
  {
32028
- onMouseEnter: () => ee($),
32029
- onMouseLeave: () => clearTimeout(G.current),
32030
- onClick: () => z($),
32031
- className: cn(
32032
- "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
32033
- $ === O ? "bg-blue-500 text-white hover:bg-blue-600" : ""
32034
- ),
32035
- children: [
32036
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(q($.toLowerCase())) }),
32037
- /* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
32038
- ]
32039
- },
32040
- $
32041
- ))
32042
- ) })
32043
- ] })
32044
- ] }),
32045
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
32046
- ScrollArea,
32047
- {
32048
- onMouseEnter: () => G.current ? clearTimeout(G.current) : null,
32049
- className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
32050
- children: [
32051
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
32052
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
32053
- ge.map((ce) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: r, position: h, block: ce, library: R }))
32054
- ) }),
32055
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
32056
- le.map((ce) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: r, position: h, block: ce, library: R }))
32057
- ) })
32058
- ] }),
32059
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
32060
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
32061
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
32142
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: 0 }),
32143
+ className: "h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
32144
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[3] text-white" }) })
32145
+ }
32146
+ ) }),
32147
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
32148
+ Tree,
32149
+ {
32150
+ ref: treeRef,
32151
+ height: window.innerHeight - 160,
32152
+ className: "no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",
32153
+ rowClassName: "flex items-center h-full border-b border-transparent",
32154
+ selection: ids[0] || "",
32155
+ onRename,
32156
+ openByDefault: !1,
32157
+ onMove,
32158
+ data: [...filteredTreeData],
32159
+ renderCursor: DefaultCursor,
32160
+ onSelect,
32161
+ childrenAccessor: (r) => r.children,
32162
+ width: "100%",
32163
+ rowHeight: 28,
32164
+ renderDragPreview: DefaultDragPreview,
32165
+ indent: 10,
32166
+ onContextMenu,
32167
+ disableDrop: debouncedDisableDrop,
32168
+ idAccessor: "_id",
32169
+ children: Node
32170
+ }
32171
+ )
32062
32172
  ]
32063
32173
  }
32064
- )
32065
- ] }) }) });
32066
- }, UILibrariesPanel = ({ parentId: r, position: h }) => /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrarySection, { parentId: r, position: h }), Core = "Core", Import = "Import", Breakpoints$1 = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
32174
+ ) }),
32175
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
32176
+ ] });
32177
+ }, Core = "Core", Import = "Import", Breakpoints$1 = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
32067
32178
  "Add block": "Add Block",
32068
32179
  "Add blocks": "Add blocks",
32069
32180
  "Enter or paste TailwindCSS HTML snippet": "Enter or paste TailwindCSS HTML snippet",
@@ -32444,145 +32555,6 @@ i18n.use(initReactI18next).init({
32444
32555
  // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
32445
32556
  }
32446
32557
  });
32447
- const CoreBlock = ({
32448
- block: r,
32449
- disabled: h,
32450
- parentId: g,
32451
- position: x
32452
- }) => {
32453
- const [, v] = useAtom$1(draggedBlockAtom), { type: S, icon: C, label: R } = r, { addCoreBlock: A, addPredefinedBlock: T } = useAddBlock(), [, _] = useSelectedBlockIds(), { clearHighlight: O } = useBlockHighlight(), z = () => {
32454
- if (has(r, "blocks")) {
32455
- const q = isFunction$1(r.blocks) ? r.blocks() : r.blocks;
32456
- T(syncBlocksWithDefaults(q), g || null, x);
32457
- } else
32458
- A(r, g || null, x);
32459
- pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
32460
- }, Z = useFeature("dnd"), { t: G } = useTranslation();
32461
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
32462
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
32463
- "button",
32464
- {
32465
- disabled: h,
32466
- onClick: z,
32467
- type: "button",
32468
- onDragStart: (q) => {
32469
- q.dataTransfer.setData("text/plain", JSON.stringify(omit(r, ["component", "icon"]))), q.dataTransfer.setDragImage(new Image(), 0, 0), v(omit(r, ["component", "icon"])), setTimeout(() => {
32470
- _([]), O();
32471
- }, 200);
32472
- },
32473
- draggable: Z ? "true" : "false",
32474
- className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
32475
- children: [
32476
- createElement(C || BoxIcon, { className: "w-4 h-4 mx-auto" }),
32477
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(G(R || S)) })
32478
- ]
32479
- }
32480
- ) }),
32481
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: G(R || S) }) })
32482
- ] }) });
32483
- }, DefaultChaiBlocks = ({
32484
- parentId: r,
32485
- position: h,
32486
- gridCols: g = "grid-cols-2"
32487
- }) => {
32488
- const x = useRegisteredChaiBlocks(), v = useBuilderProp("filterChaiBlock", () => !0), S = filter(x, v), C = groupBy(S, "category"), R = uniq(map(C.core, "group"));
32489
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
32490
- ChaiBuilderBlocks,
32491
- {
32492
- gridCols: g,
32493
- parentId: r,
32494
- position: h,
32495
- groups: R,
32496
- blocks: C.core
32497
- }
32498
- );
32499
- }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: r, blocks: h, parentId: g, position: x, gridCols: v = "grid-cols-4" }) => {
32500
- var A;
32501
- const { t: S } = useTranslation(), [C] = useBlocksStore(), R = (A = find(C, (T) => T._id === g)) == null ? void 0 : A._type;
32502
- return React__default.Children.toArray(
32503
- map(
32504
- sortBy(r, (T) => CORE_GROUPS.indexOf(T) === -1 ? 99 : CORE_GROUPS.indexOf(T)),
32505
- (T) => reject(filter(values(h), { group: T }), { hidden: !0 }).length ? /* @__PURE__ */ jsxRuntimeExports.jsx(Accordion, { type: "single", value: T, collapsible: !0, className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: T, className: "border-border", children: [
32506
- /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(S(T.toLowerCase())) }),
32507
- /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionContent, { className: "mx-auto max-w-xl p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-2 " + v, children: React__default.Children.toArray(
32508
- reject(filter(values(h), { group: T }), { hidden: !0 }).map((_) => /* @__PURE__ */ jsxRuntimeExports.jsx(
32509
- CoreBlock,
32510
- {
32511
- parentId: g,
32512
- position: x,
32513
- block: _,
32514
- disabled: !canAcceptChildBlock(R, _.type) || !canBeNestedInside(R, _.type)
32515
- }
32516
- ))
32517
- ) }) })
32518
- ] }) }) : null
32519
- )
32520
- );
32521
- }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
32522
- className: r,
32523
- showHeading: h = !0,
32524
- parentId: g = void 0,
32525
- position: x = -1
32526
- }) => {
32527
- const { t: v } = useTranslation(), [S, C] = useAtom$1(addBlockTabAtom), [, R] = useAtom$1(showPredefinedBlockCategoryAtom), A = useBuilderProp("importHTMLSupport", !0), T = useBuilderProp("addBlocksDialogTabs", []), _ = useCallback(() => {
32528
- pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
32529
- }, []);
32530
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex h-full w-full flex-col overflow-hidden", r), children: [
32531
- h ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
32532
- /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: v("Add block") }),
32533
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: v(S === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
32534
- ] }) : null,
32535
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
32536
- Tabs,
32537
- {
32538
- onValueChange: (O) => {
32539
- R(""), C(O);
32540
- },
32541
- value: S,
32542
- className: "flex h-full max-h-full flex-col overflow-hidden",
32543
- children: [
32544
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "flex w-full items-center", children: [
32545
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "library", children: v("Library") }),
32546
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "core", children: v("Blocks") }),
32547
- A ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "html", children: v("Import") }) : null,
32548
- map(T, (O) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: O.key, children: React__default.createElement(O.tab) }))
32549
- ] }),
32550
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: g, position: x }) }) }) }),
32551
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesPanel, { parentId: g, position: x }) }),
32552
- A ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML, { parentId: g, position: x }) }) : null,
32553
- map(T, (O) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: O.key, children: React__default.createElement(O.tabContent, { close: _, parentId: g, position: x }) }))
32554
- ]
32555
- }
32556
- )
32557
- ] });
32558
- };
32559
- function usePubSub(r, h) {
32560
- useEffect(() => {
32561
- const g = pubsub.subscribe(r, h);
32562
- return () => g();
32563
- }, [r, h]);
32564
- }
32565
- const AddBlocksDialog = () => {
32566
- const { t: r } = useTranslation(), [h, g] = useState(""), [x, v] = useState(-1), [S, C] = useState(!1);
32567
- return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (R) => {
32568
- g(R ? R._id : null), v(isNaN(R == null ? void 0 : R.position) ? -1 : R == null ? void 0 : R.position), C(!0);
32569
- }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
32570
- g(""), v(-1), C(!1);
32571
- }), /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialog, { open: S, onOpenChange: () => S ? C(!1) : "", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
32572
- /* @__PURE__ */ jsxRuntimeExports.jsxs(AlertDialogHeader, { className: "flex flex-row items-center justify-between", children: [
32573
- /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialogTitle, { className: "text-foreground", children: r("Add blocks") }),
32574
- /* @__PURE__ */ jsxRuntimeExports.jsx(
32575
- "button",
32576
- {
32577
- onClick: () => C(!1),
32578
- className: "text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",
32579
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Cross2Icon, { className: "h-6 w-6" })
32580
- }
32581
- )
32582
- ] }),
32583
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar h-[500px] max-h-full overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlocksPanel, { parentId: h, position: x, showHeading: !1 }) })
32584
- ] }) });
32585
- };
32586
32558
  function FaFilePen(r) {
32587
32559
  return GenIcon({ tag: "svg", attr: { viewBox: "0 0 576 512" }, child: [{ tag: "path", attr: { d: "M0 64C0 28.7 28.7 0 64 0L224 0l0 128c0 17.7 14.3 32 32 32l128 0 0 125.7-86.8 86.8c-10.3 10.3-17.5 23.1-21 37.2l-18.7 74.9c-2.3 9.2-1.8 18.8 1.3 27.5L64 512c-35.3 0-64-28.7-64-64L0 64zm384 64l-128 0L256 0 384 128zM549.8 235.7l14.4 14.4c15.6 15.6 15.6 40.9 0 56.6l-29.4 29.4-71-71 29.4-29.4c15.6-15.6 40.9-15.6 56.6 0zM311.9 417L441.1 287.8l71 71L382.9 487.9c-4.1 4.1-9.2 7-14.9 8.4l-60.1 15c-5.5 1.4-11.2-.2-15.2-4.2s-5.6-9.7-4.2-15.2l15-60.1c1.4-5.6 4.3-10.8 8.4-14.9z" }, child: [] }] })(r);
32588
32560
  }
@@ -32849,169 +32821,7 @@ const AIUserPrompt = ({ blockId: r }) => {
32849
32821
  /* @__PURE__ */ jsxRuntimeExports.jsx(AISetContext, {}),
32850
32822
  /* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(r) })
32851
32823
  ] });
32852
- }, AttrsEditor = React__default.memo(function r({ preloadedAttributes: h = [], onAttributesChange: g }) {
32853
- const [x, v] = useState([]), [S, C] = useState(""), [R, A] = useState(""), [T, _] = useState(null), [O, z] = useState(""), Z = useRef(null), G = useRef(null);
32854
- useEffect(() => {
32855
- v(h);
32856
- }, [h]);
32857
- const q = () => {
32858
- if (S.startsWith("@")) {
32859
- z("Attribute keys cannot start with '@'");
32860
- return;
32861
- }
32862
- if (S) {
32863
- const $ = [...x, { key: S, value: R }];
32864
- g($), v(x), C(""), A(""), z("");
32865
- }
32866
- }, ee = ($) => {
32867
- const ie = x.filter((he, Se) => Se !== $);
32868
- g(ie), v(ie);
32869
- }, ge = ($) => {
32870
- _($), C(x[$].key), A(x[$].value);
32871
- }, le = () => {
32872
- if (S.startsWith("@")) {
32873
- z("Attribute keys cannot start with '@'");
32874
- return;
32875
- }
32876
- if (T !== null && S) {
32877
- const $ = [...x];
32878
- $[T] = { key: S, value: R }, g($), v($), _(null), C(""), A(""), z("");
32879
- }
32880
- }, ce = ($) => {
32881
- $.key === "Enter" && !$.shiftKey && ($.preventDefault(), T !== null ? le() : q());
32882
- };
32883
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
32884
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
32885
- "form",
32886
- {
32887
- onSubmit: ($) => {
32888
- $.preventDefault(), T !== null ? le() : q();
32889
- },
32890
- className: "space-y-3",
32891
- children: [
32892
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-1", children: [
32893
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
32894
- /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "attrKey", className: "text-[11px] font-normal leading-tight text-slate-600", children: "Key" }),
32895
- /* @__PURE__ */ jsxRuntimeExports.jsx(
32896
- Input$1,
32897
- {
32898
- autoCapitalize: "off",
32899
- autoCorrect: "off",
32900
- spellCheck: "false",
32901
- id: "attrKey",
32902
- ref: Z,
32903
- value: S,
32904
- onChange: ($) => C($.target.value),
32905
- placeholder: "Enter Key",
32906
- className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
32907
- }
32908
- )
32909
- ] }),
32910
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
32911
- /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
32912
- /* @__PURE__ */ jsxRuntimeExports.jsx(
32913
- Textarea,
32914
- {
32915
- autoCapitalize: "off",
32916
- autoCorrect: "off",
32917
- spellCheck: "false",
32918
- id: "attrValue",
32919
- rows: 2,
32920
- ref: G,
32921
- value: R,
32922
- onChange: ($) => A($.target.value),
32923
- onKeyDown: ce,
32924
- placeholder: "Enter Value",
32925
- className: "text-xs font-normal leading-tight placeholder:text-slate-400"
32926
- }
32927
- )
32928
- ] })
32929
- ] }),
32930
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", disabled: !S.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: T !== null ? "Save" : "Add" }) }),
32931
- O && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: O })
32932
- ]
32933
- }
32934
- ),
32935
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: x.map(($, ie) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
32936
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
32937
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: $.key }),
32938
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: $.value.toString() })
32939
- ] }),
32940
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
32941
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => ge(ie), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
32942
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => ee(ie), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
32943
- ] })
32944
- ] }, ie)) })
32945
- ] });
32946
- }), BlockAttributesEditor = React.memo(() => {
32947
- const r = useSelectedBlock(), [h, g] = useState([]), [x] = useSelectedStylingBlocks(), v = useUpdateBlocksProps(), S = `${get(x, "0.prop")}_attrs`;
32948
- React.useEffect(() => {
32949
- const R = map(get(r, S), (A, T) => ({ key: T, value: A }));
32950
- isEmpty(R) ? g([]) : g(R);
32951
- }, [get(r, S)]);
32952
- const C = React.useCallback(
32953
- (R = []) => {
32954
- const A = {};
32955
- forEach(R, (T) => {
32956
- isEmpty(T.key) || set(A, T.key, T.value);
32957
- }), v([get(r, "_id")], { [S]: A });
32958
- },
32959
- [r, v, S]
32960
- );
32961
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AttrsEditor, { preloadedAttributes: h, onAttributesChange: C }) }) }) });
32962
- });
32963
- function getDNDSupport() {
32964
- return new URLSearchParams(window.location.search).has("dnd");
32965
- }
32966
- const FEATURE_TOGGLES = {
32967
- dnd: getDNDSupport()
32968
- }, builderStore = getDefaultStore$1(), setDebugLogs = (r) => {
32969
- }, getParentNodeIds = (r, h) => {
32970
- const g = [];
32971
- let x = find(r, { _id: h }), v = get(x, "_parent", "");
32972
- for (; isString(v) && !isEmpty(v); )
32973
- g.push(x == null ? void 0 : x._parent), x = find(r, { _id: v }), v = x == null ? void 0 : x._parent;
32974
- return flatten(g);
32975
- }, expandedIdsAtom = atom$1([]), useExpandTree = () => {
32976
- const [r] = useSelectedBlockIds(), h = useAtomValue$1(presentBlocksAtom), [, g] = useAtom$1(expandedIdsAtom);
32977
- useEffect(() => {
32978
- let x = [];
32979
- const v = first(r);
32980
- isString(v) && (x = [v, ...getParentNodeIds(h, v)]), g(x);
32981
- }, [r, h, g]);
32982
- }, UndoRedo = () => {
32983
- const { hasUndo: r, hasRedo: h, undo: g, redo: x } = useUndoManager();
32984
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
32985
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: !r(), size: "sm", onClick: g, className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetIcon, {}) }),
32986
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: !h(), onClick: x, size: "sm", className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetIcon, { className: "rotate-180 scale-y-[-1] transform" }) })
32987
- ] });
32988
- };
32989
- function DarkMode() {
32990
- const [r, h] = useDarkMode();
32991
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
32992
- /* @__PURE__ */ jsxRuntimeExports.jsx(SunIcon, { className: "size-4 shrink-0" }),
32993
- /* @__PURE__ */ jsxRuntimeExports.jsx(
32994
- Switch,
32995
- {
32996
- id: "dark-mode-switch",
32997
- checked: r,
32998
- onCheckedChange: () => {
32999
- h(!r);
33000
- },
33001
- className: `${r ? "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`,
33002
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
33003
- "span",
33004
- {
33005
- "aria-hidden": "true",
33006
- className: `${r ? "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`
33007
- }
33008
- )
33009
- }
33010
- ),
33011
- /* @__PURE__ */ jsxRuntimeExports.jsx(FaMoon, { className: "size-4 ml-3 shrink-0" })
33012
- ] });
33013
- }
33014
- const TabletIcon = ({ landscape: r = !1 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
32824
+ }, TabletIcon = ({ landscape: r = !1 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
33015
32825
  "svg",
33016
32826
  {
33017
32827
  className: r ? "rotate-90" : "",
@@ -33119,7 +32929,66 @@ const TabletIcon = ({ landscape: r = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
33119
32929
  ] })
33120
32930
  ] })
33121
32931
  ] });
33122
- }, ClearCanvas = () => {
32932
+ };
32933
+ function DarkMode() {
32934
+ const [r, h] = useDarkMode();
32935
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
32936
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SunIcon, { className: "size-4 shrink-0" }),
32937
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
32938
+ Switch,
32939
+ {
32940
+ id: "dark-mode-switch",
32941
+ checked: r,
32942
+ onCheckedChange: () => {
32943
+ h(!r);
32944
+ },
32945
+ className: `${r ? "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`,
32946
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
32947
+ "span",
32948
+ {
32949
+ "aria-hidden": "true",
32950
+ className: `${r ? "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`
32951
+ }
32952
+ )
32953
+ }
32954
+ ),
32955
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FaMoon, { className: "size-4 ml-3 shrink-0" })
32956
+ ] });
32957
+ }
32958
+ const UndoRedo = () => {
32959
+ const { hasUndo: r, hasRedo: h, undo: g, redo: x } = useUndoManager();
32960
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
32961
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: !r(), size: "sm", onClick: g, className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetIcon, {}) }),
32962
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: !h(), onClick: x, size: "sm", className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetIcon, { className: "rotate-180 scale-y-[-1] transform" }) })
32963
+ ] });
32964
+ };
32965
+ function getDNDSupport() {
32966
+ return new URLSearchParams(window.location.search).has("dnd");
32967
+ }
32968
+ const FEATURE_TOGGLES = {
32969
+ dnd: getDNDSupport()
32970
+ }, builderStore = getDefaultStore$1(), setDebugLogs = (r) => {
32971
+ }, getParentNodeIds = (r, h) => {
32972
+ const g = [];
32973
+ let x = find(r, { _id: h }), v = get(x, "_parent", "");
32974
+ for (; isString(v) && !isEmpty(v); )
32975
+ g.push(x == null ? void 0 : x._parent), x = find(r, { _id: v }), v = x == null ? void 0 : x._parent;
32976
+ return flatten(g);
32977
+ }, expandedIdsAtom = atom$1([]), useExpandTree = () => {
32978
+ const [r] = useSelectedBlockIds(), h = useAtomValue$1(presentBlocksAtom), [, g] = useAtom$1(expandedIdsAtom);
32979
+ useEffect(() => {
32980
+ let x = [];
32981
+ const v = first(r);
32982
+ isString(v) && (x = [v, ...getParentNodeIds(h, v)]), g(x);
32983
+ }, [r, h, g]);
32984
+ };
32985
+ function usePubSub(r, h) {
32986
+ useEffect(() => {
32987
+ const g = pubsub.subscribe(r, h);
32988
+ return () => g();
32989
+ }, [r, h]);
32990
+ }
32991
+ const ClearCanvas = () => {
33123
32992
  const { t: r } = useTranslation(), { setNewBlocks: h } = useBlocksStoreUndoableActions(), [, g] = useSelectedBlockIds(), [, x] = useSelectedStylingBlocks(), v = useCallback(() => {
33124
32993
  h([]), g([]), x([]);
33125
32994
  }, [h]);
@@ -33185,7 +33054,117 @@ const TabletIcon = ({ landscape: r = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
33185
33054
  /* @__PURE__ */ jsxRuntimeExports.jsx(AiAssistant, {})
33186
33055
  ] })
33187
33056
  ] });
33188
- };
33057
+ }, AttrsEditor = React__default.memo(function r({ preloadedAttributes: h = [], onAttributesChange: g }) {
33058
+ const [x, v] = useState([]), [S, C] = useState(""), [R, A] = useState(""), [T, _] = useState(null), [O, z] = useState(""), Z = useRef(null), G = useRef(null);
33059
+ useEffect(() => {
33060
+ v(h);
33061
+ }, [h]);
33062
+ const q = () => {
33063
+ if (S.startsWith("@")) {
33064
+ z("Attribute keys cannot start with '@'");
33065
+ return;
33066
+ }
33067
+ if (S) {
33068
+ const $ = [...x, { key: S, value: R }];
33069
+ g($), v(x), C(""), A(""), z("");
33070
+ }
33071
+ }, ee = ($) => {
33072
+ const ie = x.filter((he, Se) => Se !== $);
33073
+ g(ie), v(ie);
33074
+ }, ge = ($) => {
33075
+ _($), C(x[$].key), A(x[$].value);
33076
+ }, le = () => {
33077
+ if (S.startsWith("@")) {
33078
+ z("Attribute keys cannot start with '@'");
33079
+ return;
33080
+ }
33081
+ if (T !== null && S) {
33082
+ const $ = [...x];
33083
+ $[T] = { key: S, value: R }, g($), v($), _(null), C(""), A(""), z("");
33084
+ }
33085
+ }, ce = ($) => {
33086
+ $.key === "Enter" && !$.shiftKey && ($.preventDefault(), T !== null ? le() : q());
33087
+ };
33088
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
33089
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
33090
+ "form",
33091
+ {
33092
+ onSubmit: ($) => {
33093
+ $.preventDefault(), T !== null ? le() : q();
33094
+ },
33095
+ className: "space-y-3",
33096
+ children: [
33097
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-1", children: [
33098
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
33099
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "attrKey", className: "text-[11px] font-normal leading-tight text-slate-600", children: "Key" }),
33100
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
33101
+ Input$1,
33102
+ {
33103
+ autoCapitalize: "off",
33104
+ autoCorrect: "off",
33105
+ spellCheck: "false",
33106
+ id: "attrKey",
33107
+ ref: Z,
33108
+ value: S,
33109
+ onChange: ($) => C($.target.value),
33110
+ placeholder: "Enter Key",
33111
+ className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
33112
+ }
33113
+ )
33114
+ ] }),
33115
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
33116
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
33117
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
33118
+ Textarea,
33119
+ {
33120
+ autoCapitalize: "off",
33121
+ autoCorrect: "off",
33122
+ spellCheck: "false",
33123
+ id: "attrValue",
33124
+ rows: 2,
33125
+ ref: G,
33126
+ value: R,
33127
+ onChange: ($) => A($.target.value),
33128
+ onKeyDown: ce,
33129
+ placeholder: "Enter Value",
33130
+ className: "text-xs font-normal leading-tight placeholder:text-slate-400"
33131
+ }
33132
+ )
33133
+ ] })
33134
+ ] }),
33135
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", disabled: !S.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: T !== null ? "Save" : "Add" }) }),
33136
+ O && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: O })
33137
+ ]
33138
+ }
33139
+ ),
33140
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: x.map(($, ie) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
33141
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
33142
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: $.key }),
33143
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: $.value.toString() })
33144
+ ] }),
33145
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
33146
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => ge(ie), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
33147
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => ee(ie), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
33148
+ ] })
33149
+ ] }, ie)) })
33150
+ ] });
33151
+ }), BlockAttributesEditor = React.memo(() => {
33152
+ const r = useSelectedBlock(), [h, g] = useState([]), [x] = useSelectedStylingBlocks(), v = useUpdateBlocksProps(), S = `${get(x, "0.prop")}_attrs`;
33153
+ React.useEffect(() => {
33154
+ const R = map(get(r, S), (A, T) => ({ key: T, value: A }));
33155
+ isEmpty(R) ? g([]) : g(R);
33156
+ }, [get(r, S)]);
33157
+ const C = React.useCallback(
33158
+ (R = []) => {
33159
+ const A = {};
33160
+ forEach(R, (T) => {
33161
+ isEmpty(T.key) || set(A, T.key, T.value);
33162
+ }), v([get(r, "_id")], { [S]: A });
33163
+ },
33164
+ [r, v, S]
33165
+ );
33166
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AttrsEditor, { preloadedAttributes: h, onAttributesChange: C }) }) }) });
33167
+ });
33189
33168
  function BlockAttributesToggle() {
33190
33169
  const { t: r } = useTranslation(), [h, g] = useState(!0), [x] = useSelectedStylingBlocks();
33191
33170
  return isEmpty(x) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -33233,6 +33212,26 @@ const SettingsPanel = () => {
33233
33212
  }
33234
33213
  )
33235
33214
  ] }) });
33215
+ }, AddBlocksDialog = () => {
33216
+ const { t: r } = useTranslation(), [h, g] = useState(""), [x, v] = useState(-1), [S, C] = useState(!1);
33217
+ return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (R) => {
33218
+ g(R ? R._id : null), v(isNaN(R == null ? void 0 : R.position) ? -1 : R == null ? void 0 : R.position), C(!0);
33219
+ }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
33220
+ g(""), v(-1), C(!1);
33221
+ }), /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialog, { open: S, onOpenChange: () => S ? C(!1) : "", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
33222
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(AlertDialogHeader, { className: "flex flex-row items-center justify-between", children: [
33223
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialogTitle, { className: "text-foreground", children: r("Add blocks") }),
33224
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
33225
+ "button",
33226
+ {
33227
+ onClick: () => C(!1),
33228
+ className: "text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",
33229
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Cross2Icon, { className: "h-6 w-6" })
33230
+ }
33231
+ )
33232
+ ] }),
33233
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar h-[500px] max-h-full overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlocksPanel, { parentId: h, position: x, showHeading: !1 }) })
33234
+ ] }) });
33236
33235
  };
33237
33236
  function LayoutCard({ disabled: r = !1, description: h, title: g, selected: x, onSelect: v, children: S }) {
33238
33237
  const { t: C } = useTranslation();