@chaibuilder/sdk 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,15 +1,15 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
3
  var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
4
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
7
7
  import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
8
- import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
- import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
8
+ import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
+ import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
- import { useTranslation as He } from "react-i18next";
12
+ import { useTranslation as Ve } from "react-i18next";
13
13
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -17,7 +17,7 @@ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, Plus
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
- import { registerChaiBlock as Ue } from "@chaibuilder/runtime";
20
+ import { registerChaiBlock as Fe } from "@chaibuilder/runtime";
21
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";
@@ -36,6 +36,7 @@ import { ErrorBoundary } from "react-error-boundary";
36
36
  import { Resizable } from "re-resizable";
37
37
  import RjForm from "@rjsf/core";
38
38
  import validator from "@rjsf/validator-ajv8";
39
+ import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
39
40
  import Link from "@tiptap/extension-link";
40
41
  import TextAlign from "@tiptap/extension-text-align";
41
42
  import Underline from "@tiptap/extension-underline";
@@ -45,7 +46,7 @@ import Fuse from "fuse.js";
45
46
  import { parse, stringify } from "himalaya";
46
47
  import { Tree } from "react-arborist";
47
48
  import i18n from "i18next";
48
- import { default as ze } from "i18next";
49
+ import { default as We } from "i18next";
49
50
  import { motion } from "framer-motion";
50
51
  const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
51
52
  if ("e" in o)
@@ -93,197 +94,197 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
93
94
  for (const i of n.p)
94
95
  l.add(i);
95
96
  return l;
96
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
97
- var x;
98
- return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
99
- }, g = (m, f) => {
100
- var x;
101
- return (x = m.onMount) == null ? void 0 : x.call(m, f);
102
- }, ...h) => {
103
- const m = h[0] || ((C) => {
104
- let L = o.get(C);
105
- return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
106
- }), f = h[1] || (() => {
107
- let C, L;
108
- const v = (k) => {
97
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (x, ...f) => x.read(...f), p = (x, ...f) => x.write(...f), u = (x, f) => {
98
+ var h;
99
+ return (h = x.unstable_onInit) == null ? void 0 : h.call(x, f);
100
+ }, g = (x, f) => {
101
+ var h;
102
+ return (h = x.onMount) == null ? void 0 : h.call(x, f);
103
+ }, ...m) => {
104
+ const x = m[0] || ((w) => {
105
+ let L = o.get(w);
106
+ return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, S)), L;
107
+ }), f = m[1] || (() => {
108
+ let w, L;
109
+ const v = (y) => {
109
110
  try {
110
- k();
111
- } catch (B) {
112
- C || (C = !0, L = B);
111
+ y();
112
+ } catch (E) {
113
+ w || (w = !0, L = E);
113
114
  }
114
115
  };
115
116
  do {
116
117
  c.f && v(c.f);
117
- const k = /* @__PURE__ */ new Set(), B = k.add.bind(k);
118
+ const y = /* @__PURE__ */ new Set(), E = y.add.bind(y);
118
119
  a.forEach((T) => {
119
120
  var I;
120
- return (I = n.get(T)) == null ? void 0 : I.l.forEach(B);
121
- }), a.clear(), i.forEach(B), i.clear(), l.forEach(B), l.clear(), k.forEach(v), a.size && x();
121
+ return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
122
+ }), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), y.forEach(v), a.size && h();
122
123
  } while (a.size || i.size || l.size);
123
- if (C)
124
+ if (w)
124
125
  throw L;
125
- }), x = h[2] || (() => {
126
- const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
127
- for (; k.length; ) {
128
- const B = k[k.length - 1], T = m(B);
129
- if (v.has(B)) {
130
- k.pop();
126
+ }), h = m[2] || (() => {
127
+ const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
128
+ for (; y.length; ) {
129
+ const E = y[y.length - 1], T = x(E);
130
+ if (v.has(E)) {
131
+ y.pop();
131
132
  continue;
132
133
  }
133
- if (L.has(B)) {
134
- r.get(B) === T.n && C.push([B, T]), v.add(B), k.pop();
134
+ if (L.has(E)) {
135
+ r.get(E) === T.n && w.push([E, T]), v.add(E), y.pop();
135
136
  continue;
136
137
  }
137
- L.add(B);
138
- for (const I of getMountedOrPendingDependents(B, T, n))
139
- L.has(I) || k.push(I);
138
+ L.add(E);
139
+ for (const I of getMountedOrPendingDependents(E, T, n))
140
+ L.has(I) || y.push(I);
140
141
  }
141
- for (let B = C.length - 1; B >= 0; --B) {
142
- const [T, I] = C[B];
143
- let P = !1;
144
- for (const N of I.d.keys())
145
- if (N !== T && a.has(N)) {
146
- P = !0;
142
+ for (let E = w.length - 1; E >= 0; --E) {
143
+ const [T, I] = w[E];
144
+ let R = !1;
145
+ for (const P of I.d.keys())
146
+ if (P !== T && a.has(P)) {
147
+ R = !0;
147
148
  break;
148
149
  }
149
- P && (b(T), E(T)), r.delete(T);
150
+ R && (b(T), B(T)), r.delete(T);
150
151
  }
151
- }), b = h[3] || ((C) => {
152
+ }), b = m[3] || ((w) => {
152
153
  var L, v;
153
- const k = m(C);
154
- if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
155
- ([R, O]) => (
154
+ const y = x(w);
155
+ if (isAtomStateInitialized(y) && (n.has(w) && r.get(w) !== y.n || Array.from(y.d).every(
156
+ ([D, O]) => (
156
157
  // Recursively, read the atom state of the dependency, and
157
158
  // check if the atom epoch number is unchanged
158
- b(R).n === O
159
+ b(D).n === O
159
160
  )
160
161
  )))
161
- return k;
162
- k.d.clear();
163
- let B = !0;
162
+ return y;
163
+ y.d.clear();
164
+ let E = !0;
164
165
  const T = () => {
165
- n.has(C) && (E(C), x(), f());
166
- }, I = (R) => {
166
+ n.has(w) && (B(w), h(), f());
167
+ }, I = (D) => {
167
168
  var O;
168
- if (isSelfAtom(C, R)) {
169
- const H = m(R);
169
+ if (isSelfAtom(w, D)) {
170
+ const H = x(D);
170
171
  if (!isAtomStateInitialized(H))
171
- if (hasInitialValue(R))
172
- setAtomStateValueOrPromise(R, R.init, m);
172
+ if (hasInitialValue(D))
173
+ setAtomStateValueOrPromise(D, D.init, x);
173
174
  else
174
175
  throw new Error("no atom init");
175
176
  return returnAtomValue(H);
176
177
  }
177
- const $ = b(R);
178
+ const $ = b(D);
178
179
  try {
179
180
  return returnAtomValue($);
180
181
  } finally {
181
- k.d.set(R, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, $), (O = n.get(R)) == null || O.t.add(C), B || T();
182
+ y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(w, y.v, $), (O = n.get(D)) == null || O.t.add(w), E || T();
182
183
  }
183
184
  };
184
- let P, N;
185
- const D = {
185
+ let R, P;
186
+ const N = {
186
187
  get signal() {
187
- return P || (P = new AbortController()), P.signal;
188
+ return R || (R = new AbortController()), R.signal;
188
189
  },
189
190
  get setSelf() {
190
- return !N && isActuallyWritableAtom(C) && (N = (...R) => {
191
- if (!B)
191
+ return !P && isActuallyWritableAtom(w) && (P = (...D) => {
192
+ if (!E)
192
193
  try {
193
- return A(C, ...R);
194
+ return A(w, ...D);
194
195
  } finally {
195
- x(), f();
196
+ h(), f();
196
197
  }
197
- }), N;
198
+ }), P;
198
199
  }
199
- }, M = k.n;
200
+ }, M = y.n;
200
201
  try {
201
- const R = d(C, I, D);
202
- return setAtomStateValueOrPromise(C, R, m), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
202
+ const D = d(w, I, N);
203
+ return setAtomStateValueOrPromise(w, D, x), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
203
204
  T,
204
205
  T
205
- )), k;
206
- } catch (R) {
207
- return delete k.v, k.e = R, ++k.n, k;
206
+ )), y;
207
+ } catch (D) {
208
+ return delete y.v, y.e = D, ++y.n, y;
208
209
  } finally {
209
- B = !1, M !== k.n && r.get(C) === M && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
210
+ E = !1, M !== y.n && r.get(w) === M && (r.set(w, y.n), a.add(w), (v = c.c) == null || v.call(c, w));
210
211
  }
211
- }), y = h[4] || ((C) => {
212
- const L = [C];
212
+ }), k = m[4] || ((w) => {
213
+ const L = [w];
213
214
  for (; L.length; ) {
214
- const v = L.pop(), k = m(v);
215
- for (const B of getMountedOrPendingDependents(v, k, n)) {
216
- const T = m(B);
217
- r.set(B, T.n), L.push(B);
215
+ const v = L.pop(), y = x(v);
216
+ for (const E of getMountedOrPendingDependents(v, y, n)) {
217
+ const T = x(E);
218
+ r.set(E, T.n), L.push(E);
218
219
  }
219
220
  }
220
- }), A = h[5] || ((C, ...L) => {
221
+ }), A = m[5] || ((w, ...L) => {
221
222
  let v = !0;
222
- const k = (T) => returnAtomValue(b(T)), B = (T, ...I) => {
223
- var P;
224
- const N = m(T);
223
+ const y = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
224
+ var R;
225
+ const P = x(T);
225
226
  try {
226
- if (isSelfAtom(C, T)) {
227
+ if (isSelfAtom(w, T)) {
227
228
  if (!hasInitialValue(T))
228
229
  throw new Error("atom not writable");
229
- const D = N.n, M = I[0];
230
- setAtomStateValueOrPromise(T, M, m), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
230
+ const N = P.n, M = I[0];
231
+ setAtomStateValueOrPromise(T, M, x), B(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
231
232
  return;
232
233
  } else
233
234
  return A(T, ...I);
234
235
  } finally {
235
- v || (x(), f());
236
+ v || (h(), f());
236
237
  }
237
238
  };
238
239
  try {
239
- return p(C, k, B, ...L);
240
+ return p(w, y, E, ...L);
240
241
  } finally {
241
242
  v = !1;
242
243
  }
243
- }), E = h[6] || ((C) => {
244
+ }), B = m[6] || ((w) => {
244
245
  var L;
245
- const v = m(C), k = n.get(C);
246
- if (k && !isPendingPromise(v.v)) {
247
- for (const [B, T] of v.d)
248
- if (!k.d.has(B)) {
249
- const I = m(B);
250
- w(B).t.add(C), k.d.add(B), T !== I.n && (a.add(B), (L = c.c) == null || L.call(c, B), y(B));
246
+ const v = x(w), y = n.get(w);
247
+ if (y && !isPendingPromise(v.v)) {
248
+ for (const [E, T] of v.d)
249
+ if (!y.d.has(E)) {
250
+ const I = x(E);
251
+ C(E).t.add(w), y.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), k(E));
251
252
  }
252
- for (const B of k.d || [])
253
- if (!v.d.has(B)) {
254
- k.d.delete(B);
255
- const T = _(B);
256
- T == null || T.t.delete(C);
253
+ for (const E of y.d || [])
254
+ if (!v.d.has(E)) {
255
+ y.d.delete(E);
256
+ const T = j(E);
257
+ T == null || T.t.delete(w);
257
258
  }
258
259
  }
259
- }), w = h[7] || ((C) => {
260
+ }), C = m[7] || ((w) => {
260
261
  var L;
261
- const v = m(C);
262
- let k = n.get(C);
263
- if (!k) {
264
- b(C);
265
- for (const B of v.d.keys())
266
- w(B).t.add(C);
267
- if (k = {
262
+ const v = x(w);
263
+ let y = n.get(w);
264
+ if (!y) {
265
+ b(w);
266
+ for (const E of v.d.keys())
267
+ C(E).t.add(w);
268
+ if (y = {
268
269
  l: /* @__PURE__ */ new Set(),
269
270
  d: new Set(v.d.keys()),
270
271
  t: /* @__PURE__ */ new Set()
271
- }, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
272
- const B = () => {
272
+ }, n.set(w, y), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
+ const E = () => {
273
274
  let T = !0;
274
- const I = (...P) => {
275
+ const I = (...R) => {
275
276
  try {
276
- return A(C, ...P);
277
+ return A(w, ...R);
277
278
  } finally {
278
- T || (x(), f());
279
+ T || (h(), f());
279
280
  }
280
281
  };
281
282
  try {
282
- const P = g(C, I);
283
- P && (k.u = () => {
283
+ const R = g(w, I);
284
+ R && (y.u = () => {
284
285
  T = !0;
285
286
  try {
286
- P();
287
+ R();
287
288
  } finally {
288
289
  T = !1;
289
290
  }
@@ -292,27 +293,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
292
293
  T = !1;
293
294
  }
294
295
  };
295
- l.add(B);
296
+ l.add(E);
296
297
  }
297
298
  }
298
- return k;
299
- }), _ = h[8] || ((C) => {
299
+ return y;
300
+ }), j = m[8] || ((w) => {
300
301
  var L;
301
- const v = m(C);
302
- let k = n.get(C);
303
- if (k && !k.l.size && !Array.from(k.t).some((B) => {
302
+ const v = x(w);
303
+ let y = n.get(w);
304
+ if (y && !y.l.size && !Array.from(y.t).some((E) => {
304
305
  var T;
305
- return (T = n.get(B)) == null ? void 0 : T.d.has(C);
306
+ return (T = n.get(E)) == null ? void 0 : T.d.has(w);
306
307
  })) {
307
- k.u && i.add(k.u), k = void 0, n.delete(C), (L = c.u) == null || L.call(c, C);
308
- for (const B of v.d.keys()) {
309
- const T = _(B);
310
- T == null || T.t.delete(C);
308
+ y.u && i.add(y.u), y = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
309
+ for (const E of v.d.keys()) {
310
+ const T = j(E);
311
+ T == null || T.t.delete(w);
311
312
  }
312
313
  return;
313
314
  }
314
- return k;
315
- }), j = [
315
+ return y;
316
+ }), _ = [
316
317
  // store state
317
318
  o,
318
319
  n,
@@ -327,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
327
328
  u,
328
329
  g,
329
330
  // building-block functions
330
- m,
331
- f,
332
331
  x,
332
+ f,
333
+ h,
333
334
  b,
334
- y,
335
+ k,
335
336
  A,
336
- E,
337
- w,
338
- _
337
+ B,
338
+ C,
339
+ j
339
340
  ], S = {
340
- get: (C) => returnAtomValue(b(C)),
341
- set: (C, ...L) => {
341
+ get: (w) => returnAtomValue(b(w)),
342
+ set: (w, ...L) => {
342
343
  try {
343
- return A(C, ...L);
344
+ return A(w, ...L);
344
345
  } finally {
345
- x(), f();
346
+ h(), f();
346
347
  }
347
348
  },
348
- sub: (C, L) => {
349
- const k = w(C).l;
350
- return k.add(L), f(), () => {
351
- k.delete(L), _(C), f();
349
+ sub: (w, L) => {
350
+ const y = C(w).l;
351
+ return y.add(L), f(), () => {
352
+ y.delete(L), j(w), f();
352
353
  };
353
354
  }
354
355
  };
355
- return Object.defineProperty(S, BUILDING_BLOCKS, { value: j }), S;
356
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
356
357
  }, INTERNAL_buildStoreRev1 = buildStore;
357
358
  let keyCount = 0;
358
359
  function atom(o, n) {
@@ -387,37 +388,37 @@ function splitAtom(o, n) {
387
388
  let p = r.get(c);
388
389
  if (p)
389
390
  return p;
390
- const u = d && r.get(d), g = [], h = [];
391
- return c.forEach((m, f) => {
392
- const x = f;
393
- h[f] = x;
394
- const b = u && u.atomList[u.keyList.indexOf(x)];
391
+ const u = d && r.get(d), g = [], m = [];
392
+ return c.forEach((x, f) => {
393
+ const h = f;
394
+ m[f] = h;
395
+ const b = u && u.atomList[u.keyList.indexOf(h)];
395
396
  if (b) {
396
397
  g[f] = b;
397
398
  return;
398
399
  }
399
- const y = (E) => {
400
- const w = E(l), _ = E(o), S = a(_, w == null ? void 0 : w.arr).keyList.indexOf(x);
401
- if (S < 0 || S >= _.length) {
402
- const C = c[a(c).keyList.indexOf(x)];
403
- if (C)
404
- return C;
400
+ const k = (B) => {
401
+ const C = B(l), j = B(o), S = a(j, C == null ? void 0 : C.arr).keyList.indexOf(h);
402
+ if (S < 0 || S >= j.length) {
403
+ const w = c[a(c).keyList.indexOf(h)];
404
+ if (w)
405
+ return w;
405
406
  throw new Error("splitAtom: index out of bounds for read");
406
407
  }
407
- return _[S];
408
- }, A = (E, w, _) => {
409
- const j = E(l), S = E(o), L = a(S, j == null ? void 0 : j.arr).keyList.indexOf(x);
408
+ return j[S];
409
+ }, A = (B, C, j) => {
410
+ const _ = B(l), S = B(o), L = a(S, _ == null ? void 0 : _.arr).keyList.indexOf(h);
410
411
  if (L < 0 || L >= S.length)
411
412
  throw new Error("splitAtom: index out of bounds for write");
412
- const v = isFunction(_) ? _(S[L]) : _;
413
- Object.is(S[L], v) || w(o, [
413
+ const v = isFunction(j) ? j(S[L]) : j;
414
+ Object.is(S[L], v) || C(o, [
414
415
  ...S.slice(0, L),
415
416
  v,
416
417
  ...S.slice(L + 1)
417
418
  ]);
418
419
  };
419
- g[f] = isWritable(o) ? atom(y, A) : atom(y);
420
- }), u && u.keyList.length === h.length && u.keyList.every((m, f) => m === h[f]) ? p = u : p = { arr: c, atomList: g, keyList: h }, r.set(c, p), p;
420
+ g[f] = isWritable(o) ? atom(k, A) : atom(k);
421
+ }), u && u.keyList.length === m.length && u.keyList.every((x, f) => x === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
421
422
  }, l = atom((c) => {
422
423
  const d = c(l), p = c(o);
423
424
  return a(p, d == null ? void 0 : d.arr);
@@ -453,17 +454,17 @@ function splitAtom(o, n) {
453
454
  case "move": {
454
455
  const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
455
456
  if (u >= 0 && g >= 0) {
456
- const h = c(o);
457
+ const m = c(o);
457
458
  u < g ? d(o, [
458
- ...h.slice(0, u),
459
- ...h.slice(u + 1, g),
460
- h[u],
461
- ...h.slice(g)
459
+ ...m.slice(0, u),
460
+ ...m.slice(u + 1, g),
461
+ m[u],
462
+ ...m.slice(g)
462
463
  ]) : d(o, [
463
- ...h.slice(0, g),
464
- h[u],
465
- ...h.slice(g, u),
466
- ...h.slice(u + 1)
464
+ ...m.slice(0, g),
465
+ m[u],
466
+ ...m.slice(g, u),
467
+ ...m.slice(u + 1)
467
468
  ]);
468
469
  }
469
470
  break;
@@ -489,19 +490,19 @@ function createJSONStorage(o = () => {
489
490
  let a, l;
490
491
  const i = {
491
492
  getItem: (p, u) => {
492
- var g, h;
493
- const m = (x) => {
494
- if (x = x || "", a !== x) {
493
+ var g, m;
494
+ const x = (h) => {
495
+ if (h = h || "", a !== h) {
495
496
  try {
496
- l = JSON.parse(x, n == null ? void 0 : n.reviver);
497
+ l = JSON.parse(h, n == null ? void 0 : n.reviver);
497
498
  } catch {
498
499
  return u;
499
500
  }
500
- a = x;
501
+ a = h;
501
502
  }
502
503
  return l;
503
- }, f = (h = (g = o()) == null ? void 0 : g.getItem(p)) != null ? h : null;
504
- return isPromiseLike$1(f) ? f.then(m) : m(f);
504
+ }, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
+ return isPromiseLike$1(f) ? f.then(x) : x(f);
505
506
  },
506
507
  setItem: (p, u) => {
507
508
  var g;
@@ -514,12 +515,12 @@ function createJSONStorage(o = () => {
514
515
  var u;
515
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
516
517
  }
517
- }, c = (p) => (u, g, h) => p(u, (m) => {
518
+ }, c = (p) => (u, g, m) => p(u, (x) => {
518
519
  let f;
519
520
  try {
520
- f = JSON.parse(m || "");
521
+ f = JSON.parse(x || "");
521
522
  } catch {
522
- f = h;
523
+ f = m;
523
524
  }
524
525
  g(f);
525
526
  });
@@ -532,8 +533,8 @@ function createJSONStorage(o = () => {
532
533
  if (!(o() instanceof window.Storage))
533
534
  return () => {
534
535
  };
535
- const g = (h) => {
536
- h.storageArea === o() && h.key === p && u(h.newValue);
536
+ const g = (m) => {
537
+ m.storageArea === o() && m.key === p && u(m.newValue);
537
538
  };
538
539
  return window.addEventListener("storage", g), () => {
539
540
  window.removeEventListener("storage", g);
@@ -652,8 +653,6 @@ const activePanelAtom = atom$1("outline");
652
653
  activePanelAtom.debugLabel = "activePanelAtom";
653
654
  const showPredefinedBlockCategoryAtom = atom$1("");
654
655
  showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
655
- const historyStatesAtom = atom$1({ undoCount: 0, redoCount: 0 });
656
- historyStatesAtom.debugLabel = "historyStatesAtom";
657
656
  const inlineEditingActiveAtom = atom$1("");
658
657
  inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
659
658
  const draggingFlagAtom = atom$1(!1);
@@ -929,7 +928,22 @@ function requireUndomanager() {
929
928
  }(undomanager)), undomanager.exports;
930
929
  }
931
930
  var undomanagerExports = requireUndomanager();
932
- const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), MODIFIERS = [
931
+ const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), chaiBuilderPropsAtom = atom$1(null);
932
+ chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
933
+ const chaiExternalDataAtom = atom$1({});
934
+ chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
935
+ const chaiRjsfFieldsAtom = atom$1({});
936
+ chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
937
+ const chaiRjsfWidgetsAtom = atom$1({});
938
+ chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
939
+ const chaiRjsfTemplatesAtom = atom$1({});
940
+ chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
941
+ const chaiPageExternalDataAtom = atom$1({});
942
+ chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
943
+ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
944
+ const r = useAtomValue$1(chaiBuilderPropsAtom);
945
+ return get(r, o, n);
946
+ }, MODIFIERS = [
933
947
  "hover",
934
948
  "focus",
935
949
  "focus-within",
@@ -1002,21 +1016,12 @@ const useBrandingOptions = () => {
1002
1016
  blocks: a
1003
1017
  };
1004
1018
  }, [o, n, r]);
1005
- }, chaiBuilderPropsAtom = atom$1(null);
1006
- chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
1007
- const chaiExternalDataAtom = atom$1({});
1008
- chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
1009
- const chaiRjsfFieldsAtom = atom$1({});
1010
- chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
1011
- const chaiRjsfWidgetsAtom = atom$1({});
1012
- chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
1013
- const chaiRjsfTemplatesAtom = atom$1({});
1014
- chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
1015
- const chaiPageExternalDataAtom = atom$1({});
1016
- chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
1017
- const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
1018
- const r = useAtomValue$1(chaiBuilderPropsAtom);
1019
- return get(r, o, n);
1019
+ }, usePermissions = () => {
1020
+ const o = useBuilderProp("permissions", void 0);
1021
+ return { hasPermission: useCallback(
1022
+ (r) => o ? o.includes(r) : !0,
1023
+ [o]
1024
+ ) };
1020
1025
  }, getDefaultThemeValues = (o = defaultThemeOptions) => {
1021
1026
  const n = {};
1022
1027
  return o.fontFamily && (n.fontFamily = Object.entries(o.fontFamily).reduce(
@@ -1043,15 +1048,17 @@ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useB
1043
1048
  }, rightPanelAtom = atom$1("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom$1("SAVED");
1044
1049
  builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
1045
1050
  const useSavePage = () => {
1046
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (d) => {
1047
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme();
1051
+ const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
1052
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
1048
1053
  return { savePage: useThrottledCallback(
1049
- async (d = !1) => {
1054
+ async (p = !1) => {
1055
+ if (!c("save_page"))
1056
+ return;
1050
1057
  n("SAVING"), a("SAVING");
1051
- const p = l();
1058
+ const u = l();
1052
1059
  return await r({
1053
- autoSave: d,
1054
- blocks: p.blocks,
1060
+ autoSave: p,
1061
+ blocks: u.blocks,
1055
1062
  theme: i
1056
1063
  }), setTimeout(() => {
1057
1064
  n("SAVED"), a("SAVED");
@@ -1147,36 +1154,37 @@ const useSelectedBlocksDisplayChild = () => ({
1147
1154
  }, removeNestedBlocks = (o, n) => {
1148
1155
  let r = [...o], a = [];
1149
1156
  n.forEach((d) => {
1150
- const p = r.find((h) => h._id === d);
1157
+ const p = r.find((m) => m._id === d);
1151
1158
  if (!p || !p._parent) return;
1152
- const u = p._parent, g = r.filter((h) => h._parent === u);
1159
+ const u = p._parent, g = r.filter((m) => m._parent === u);
1153
1160
  if (g.length === 2) {
1154
- const h = g.find((m) => m._id !== d);
1155
- if (h && h._type === "Text") {
1156
- const m = r.find((f) => f._id === u);
1157
- m && "content" in m && (r = r.map((f) => {
1161
+ const m = g.find((x) => x._id !== d);
1162
+ if (m && m._type === "Text") {
1163
+ const x = r.find((f) => f._id === u);
1164
+ x && "content" in x && (r = r.map((f) => {
1158
1165
  if (f._id === u) {
1159
- const x = { ...f, content: h.content };
1160
- return Object.keys(h).forEach((b) => {
1161
- b.startsWith("content-") && (x[b] = h[b]);
1162
- }), x;
1166
+ const h = { ...f, content: m.content };
1167
+ return Object.keys(m).forEach((b) => {
1168
+ b.startsWith("content-") && (h[b] = m[b]);
1169
+ }), h;
1163
1170
  }
1164
1171
  return f;
1165
- }), a.push(h._id));
1172
+ }), a.push(m._id));
1166
1173
  }
1167
1174
  }
1168
1175
  });
1169
1176
  const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
1170
1177
  return isEmpty(i) ? c : removeNestedBlocks(c, i);
1171
1178
  }, useRemoveBlocks = () => {
1172
- const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
1179
+ const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
1173
1180
  return useCallback(
1174
- (l) => {
1175
- var c;
1176
- const i = ((c = find(o, { _id: l[0] })) == null ? void 0 : c._parent) || null;
1177
- a(removeNestedBlocks(o, l)), setTimeout(() => r(i ? [i] : []), 200);
1181
+ (i) => {
1182
+ var d;
1183
+ if (!l(PERMISSIONS.DELETE_BLOCK)) return;
1184
+ const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
1185
+ a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
1178
1186
  },
1179
- [o, r, n]
1187
+ [o, r, n, l]
1180
1188
  );
1181
1189
  }, builderStore = getDefaultStore$1(), writeAtomValue = atom$1(
1182
1190
  null,
@@ -1225,21 +1233,21 @@ function insertBlocksAtPosition(o, n, r, a) {
1225
1233
  let i = [...o];
1226
1234
  if (r) {
1227
1235
  const u = o.find((g) => g._id === r);
1228
- if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
1229
- const m = {
1236
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
1237
+ const x = {
1230
1238
  _id: generateUUID(),
1231
1239
  _parent: r,
1232
1240
  _type: "Text",
1233
1241
  content: u.content
1234
1242
  };
1235
1243
  Object.keys(u).forEach((f) => {
1236
- f.startsWith("content-") && (m[f] = u[f]);
1237
- }), l.unshift(m), i = i.map((f) => {
1244
+ f.startsWith("content-") && (x[f] = u[f]);
1245
+ }), l.unshift(x), i = i.map((f) => {
1238
1246
  if (f._id === r) {
1239
- const x = { ...f, content: "" };
1240
- return Object.keys(x).forEach((b) => {
1241
- b.startsWith("content-") && (x[b] = "");
1242
- }), x;
1247
+ const h = { ...f, content: "" };
1248
+ return Object.keys(h).forEach((b) => {
1249
+ b.startsWith("content-") && (h[b] = "");
1250
+ }), h;
1243
1251
  }
1244
1252
  return f;
1245
1253
  });
@@ -1274,13 +1282,13 @@ function moveNode(o, n, r, a) {
1274
1282
  const l = findNodeById(o, n), i = findNodeById(o, r);
1275
1283
  if (!l || !i) return !1;
1276
1284
  i.children || (i.model.children = []);
1277
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
1285
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
1278
1286
  l.drop(), c = Math.max(c, 0);
1279
1287
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
1280
1288
  try {
1281
1289
  i.addChildAtIndex(l, p);
1282
- } catch (h) {
1283
- return console.error("Error adding child to parent:", h), !1;
1290
+ } catch (m) {
1291
+ return console.error("Error adding child to parent:", m), !1;
1284
1292
  }
1285
1293
  return !0;
1286
1294
  }
@@ -1321,8 +1329,8 @@ function handleNewParentTextBlock(o, n, r) {
1321
1329
  const d = o.map((u) => {
1322
1330
  if (u._id === r) {
1323
1331
  const g = { ...u, content: "" };
1324
- return Object.keys(g).forEach((h) => {
1325
- h.startsWith("content-") && (g[h] = "");
1332
+ return Object.keys(g).forEach((m) => {
1333
+ m.startsWith("content-") && (g[m] = "");
1326
1334
  }), g;
1327
1335
  }
1328
1336
  return u;
@@ -1339,7 +1347,7 @@ function moveBlocksWithChildren(o, n, r, a) {
1339
1347
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
1340
1348
  if (moveNode(p, n, c, a)) {
1341
1349
  let u = flattenTree(p);
1342
- const g = u.find((h) => h._id === n);
1350
+ const g = u.find((m) => m._id === n);
1343
1351
  return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
1344
1352
  }
1345
1353
  return i;
@@ -1389,65 +1397,65 @@ const useBlocksStoreManager = () => {
1389
1397
  updateBlocksProps: c
1390
1398
  } = useBlocksStoreManager();
1391
1399
  return {
1392
- moveBlocks: (x, b, y) => {
1393
- const A = map(x, (w) => {
1394
- const j = n.find((L) => L._id === w)._parent || null, C = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(w);
1395
- return { _id: w, oldParent: j, oldPosition: C };
1396
- }), E = A.find(({ _id: w }) => w === x[0]);
1397
- E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
1398
- undo: () => each(A, ({ _id: w, oldParent: _, oldPosition: j }) => {
1399
- i([w], _, j);
1400
+ moveBlocks: (h, b, k) => {
1401
+ const A = map(h, (C) => {
1402
+ const _ = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => _ ? L._parent === _ : !L._parent).map((L) => L._id).indexOf(C);
1403
+ return { _id: C, oldParent: _, oldPosition: w };
1404
+ }), B = A.find(({ _id: C }) => C === h[0]);
1405
+ B && B.oldParent === b && B.oldPosition === k || (i(h, b, k), o({
1406
+ undo: () => each(A, ({ _id: C, oldParent: j, oldPosition: _ }) => {
1407
+ i([C], j, _);
1400
1408
  }),
1401
- redo: () => i(x, b, y)
1409
+ redo: () => i(h, b, k)
1402
1410
  }));
1403
1411
  },
1404
- addBlocks: (x, b, y) => {
1405
- a(x, b, y), o({
1406
- undo: () => l(map(x, "_id")),
1407
- redo: () => a(x, b, y)
1412
+ addBlocks: (h, b, k) => {
1413
+ a(h, b, k), o({
1414
+ undo: () => l(map(h, "_id")),
1415
+ redo: () => a(h, b, k)
1408
1416
  });
1409
1417
  },
1410
- removeBlocks: (x) => {
1411
- var E;
1412
- const b = (E = first(x)) == null ? void 0 : E._parent, A = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1413
- l(map(x, "_id")), o({
1414
- undo: () => a(x, b, A),
1415
- redo: () => l(map(x, "_id"))
1418
+ removeBlocks: (h) => {
1419
+ var B;
1420
+ const b = (B = first(h)) == null ? void 0 : B._parent, A = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(h));
1421
+ l(map(h, "_id")), o({
1422
+ undo: () => a(h, b, A),
1423
+ redo: () => l(map(h, "_id"))
1416
1424
  });
1417
1425
  },
1418
- updateBlocks: (x, b, y) => {
1426
+ updateBlocks: (h, b, k) => {
1419
1427
  let A = [];
1420
- if (y)
1421
- A = map(x, (E) => ({ _id: E, ...y }));
1428
+ if (k)
1429
+ A = map(h, (B) => ({ _id: B, ...k }));
1422
1430
  else {
1423
- const E = keys(b);
1424
- A = map(x, (w) => {
1425
- const _ = n.find((S) => S._id === w), j = { _id: w };
1426
- return each(E, (S) => j[S] = _[S]), j;
1431
+ const B = keys(b);
1432
+ A = map(h, (C) => {
1433
+ const j = n.find((S) => S._id === C), _ = { _id: C };
1434
+ return each(B, (S) => _[S] = j[S]), _;
1427
1435
  });
1428
1436
  }
1429
- c(map(x, (E) => ({ _id: E, ...b }))), o({
1437
+ c(map(h, (B) => ({ _id: B, ...b }))), o({
1430
1438
  undo: () => c(A),
1431
- redo: () => c(map(x, (E) => ({ _id: E, ...b })))
1439
+ redo: () => c(map(h, (B) => ({ _id: B, ...b })))
1432
1440
  });
1433
1441
  },
1434
- updateBlocksRuntime: (x, b) => {
1435
- c(map(x, (y) => ({ _id: y, ...b })));
1442
+ updateBlocksRuntime: (h, b) => {
1443
+ c(map(h, (k) => ({ _id: k, ...b })));
1436
1444
  },
1437
- setNewBlocks: (x) => {
1438
- r(x), o({
1445
+ setNewBlocks: (h) => {
1446
+ r(h), o({
1439
1447
  undo: () => r(n),
1440
- redo: () => r(x)
1448
+ redo: () => r(h)
1441
1449
  });
1442
1450
  },
1443
- updateMultipleBlocksProps: (x) => {
1451
+ updateMultipleBlocksProps: (h) => {
1444
1452
  let b = [];
1445
- b = map(x, (y) => {
1446
- const A = keys(y), E = n.find((_) => _._id === y._id), w = {};
1447
- return each(A, (_) => w[_] = E[_]), w;
1448
- }), c(x), o({
1453
+ b = map(h, (k) => {
1454
+ const A = keys(k), B = n.find((j) => j._id === k._id), C = {};
1455
+ return each(A, (j) => C[j] = B[j]), C;
1456
+ }), c(h), o({
1449
1457
  undo: () => c(b),
1450
- redo: () => c(x)
1458
+ redo: () => c(h)
1451
1459
  });
1452
1460
  }
1453
1461
  };
@@ -1483,17 +1491,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1483
1491
  const useAddBlock = () => {
1484
1492
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1485
1493
  (i, c, d) => {
1486
- var m;
1494
+ var x;
1487
1495
  for (let f = 0; f < i.length; f++) {
1488
- const { _id: x } = i[f];
1496
+ const { _id: h } = i[f];
1489
1497
  i[f]._id = generateUUID();
1490
- const b = filter(i, { _parent: x });
1491
- for (let y = 0; y < b.length; y++)
1492
- b[y]._parent = i[f]._id;
1498
+ const b = filter(i, { _parent: h });
1499
+ for (let k = 0; k < b.length; k++)
1500
+ b[k]._parent = i[f]._id;
1493
1501
  }
1494
1502
  const p = first(i);
1495
1503
  let u, g;
1496
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
1504
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(x = first(i)) == null ? void 0 : x._id]), first(i);
1497
1505
  },
1498
1506
  [r, o, n]
1499
1507
  );
@@ -1510,8 +1518,8 @@ const useAddBlock = () => {
1510
1518
  ...has(i, "_name") && { _name: i._name },
1511
1519
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1512
1520
  };
1513
- let h, m;
1514
- return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
1521
+ let m, x;
1522
+ return c && (m = find(o, { _id: c }), g._parent = c, x = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, x = m._parent), r([g], x, d), n([g._id]), g;
1515
1523
  },
1516
1524
  [r, a, o, n]
1517
1525
  ), addPredefinedBlock: a };
@@ -2957,41 +2965,41 @@ const getBlockWithChildren = (o, n) => {
2957
2965
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2958
2966
  })
2959
2967
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2960
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
2961
- const x = cloneDeep(f.find((b) => b._id === m));
2962
- for (const b in x) {
2963
- const y = x[b];
2964
- if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2965
- const { baseClasses: A, classes: E } = getSplitChaiClasses(y);
2966
- x[b] = compact(flattenDeep([A, E])).join(" ");
2968
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (x, f) => {
2969
+ const h = cloneDeep(f.find((b) => b._id === x));
2970
+ for (const b in h) {
2971
+ const k = h[b];
2972
+ if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
2973
+ const { baseClasses: A, classes: B } = getSplitChaiClasses(k);
2974
+ h[b] = compact(flattenDeep([A, B])).join(" ");
2967
2975
  } else
2968
- b !== "_id" && delete x[b];
2976
+ b !== "_id" && delete h[b];
2969
2977
  }
2970
- return x;
2978
+ return h;
2971
2979
  };
2972
2980
  return {
2973
2981
  askAi: useCallback(
2974
- async (m, f, x, b) => {
2982
+ async (x, f, h, b) => {
2975
2983
  if (l) {
2976
2984
  n(!0), a(null);
2977
2985
  try {
2978
- const y = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], E = await l(m, addLangToPrompt(x, g, m), A, y), { blocks: w, error: _ } = E;
2979
- if (_) {
2980
- a(_);
2986
+ const k = p === u ? "" : p, A = x === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], B = await l(x, addLangToPrompt(h, g, x), A, k), { blocks: C, error: j } = B;
2987
+ if (j) {
2988
+ a(j);
2981
2989
  return;
2982
2990
  }
2983
- if (m === "styles") {
2984
- const j = w.map((S) => {
2985
- for (const C in S)
2986
- C !== "_id" && (S[C] = `${STYLES_KEY},${S[C]}`);
2991
+ if (x === "styles") {
2992
+ const _ = C.map((S) => {
2993
+ for (const w in S)
2994
+ w !== "_id" && (S[w] = `${STYLES_KEY},${S[w]}`);
2987
2995
  return S;
2988
2996
  });
2989
- c(j);
2997
+ c(_);
2990
2998
  } else
2991
- i(w);
2992
- b && b(E);
2993
- } catch (y) {
2994
- a(y);
2999
+ i(C);
3000
+ b && b(B);
3001
+ } catch (k) {
3002
+ a(k);
2995
3003
  } finally {
2996
3004
  n(!1), b && b();
2997
3005
  }
@@ -3082,9 +3090,9 @@ const useBlockHighlight = () => {
3082
3090
  d();
3083
3091
  }, []), { data: l, isLoading: o, refetch: d, error: r };
3084
3092
  }, useBuilderReset = () => {
3085
- const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = usePartailBlocksStore();
3093
+ const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: c } = useSavePage();
3086
3094
  return () => {
3087
- r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
3095
+ n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
3088
3096
  };
3089
3097
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
3090
3098
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -3130,13 +3138,13 @@ const useBlockHighlight = () => {
3130
3138
  (a, l = null) => {
3131
3139
  const i = [];
3132
3140
  each(a, (c) => {
3133
- const d = o.find((m) => m._id === c);
3141
+ const d = o.find((x) => x._id === c);
3134
3142
  l ? l === "root" && (l = null) : l = d._parent;
3135
3143
  const g = filter(
3136
3144
  o,
3137
- (m) => isString(l) ? m._parent === l : !m._parent
3138
- ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
3139
- r(h, l, g), i.push(get(h, "0._id", ""));
3145
+ (x) => isString(l) ? x._parent === l : !x._parent
3146
+ ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3147
+ r(m, l, g), i.push(get(m, "0._id", ""));
3140
3148
  }), n(i);
3141
3149
  },
3142
3150
  [o, n]
@@ -3229,13 +3237,13 @@ const useBlockHighlight = () => {
3229
3237
  return map(i, (c) => {
3230
3238
  const d = o(c), p = a;
3231
3239
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3232
- return each(p, (h) => {
3233
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3240
+ return each(p, (m) => {
3241
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3234
3242
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
3235
- const x = first(h.split(":"));
3236
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
3237
- }), each(p, (h) => {
3238
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3243
+ const h = first(m.split(":"));
3244
+ includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
3245
+ }), each(p, (m) => {
3246
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3239
3247
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
3240
3248
  }), {
3241
3249
  ids: [d._id],
@@ -3322,102 +3330,104 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
3322
3330
  const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3323
3331
  const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
3324
3332
  return [o || r, n];
3325
- }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
3326
- class PubSub {
3327
- constructor() {
3328
- V(this, "subscribers", /* @__PURE__ */ new Map());
3329
- }
3330
- subscribe(n, r) {
3331
- return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
3332
- const a = this.subscribers.get(n);
3333
- a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
3334
- };
3335
- }
3336
- publish(n, r) {
3337
- const a = this.subscribers.get(n);
3338
- a && a.forEach((l) => l(r));
3339
- }
3340
- }
3341
- const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3342
- const [r] = useBlocksStore(), a = get(o, "_id"), l = get(o, "_parent"), i = filter(r, (u) => l ? get(u, "_parent") === l : !get(u, "_parent")), c = canAddChildBlock(get(o, "_type", "")), d = findIndex(i, { _id: a }), p = (u) => {
3343
- if (u === "CHILD")
3344
- pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3345
- else {
3346
- const g = { _id: l || "", position: i == null ? void 0 : i.length };
3347
- u === "BEFORE" ? g.position = Math.max(d, 0) : u === "AFTER" && (g.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, g);
3348
- }
3349
- };
3350
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3351
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3352
- /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-200 shadow-2xl", children: [
3353
- c && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("CHILD"), children: "Add child block" }),
3354
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("BEFORE"), children: "Add block before" }),
3355
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("AFTER"), children: "Add block after" })
3356
- ] })
3357
- ] });
3358
3333
  };
3359
- function getOrientation(o) {
3360
- const n = window.getComputedStyle(o), r = n.display;
3361
- if (r === "flex" || r === "inline-flex") {
3362
- const a = n.flexDirection;
3363
- return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3364
- } else if (r === "grid") {
3365
- const a = n.gridAutoFlow, l = n.gridTemplateRows, i = n.gridTemplateColumns;
3366
- return a.includes("column") || l.split(" ").length > i.split(" ").length ? "vertical" : "horizontal";
3367
- } else if (r === "block" || r === "inline-block")
3368
- return "vertical";
3369
- return "horizontal";
3334
+ function getOrientation(o, n = null) {
3335
+ const r = window.getComputedStyle(o), a = n ? window.getComputedStyle(n) : null, l = r.display, i = a ? a.display : null;
3336
+ if (l === "flex" || l === "inline-flex") {
3337
+ const c = r.flexDirection;
3338
+ return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
3339
+ } else if (l === "grid") {
3340
+ const c = r.gridAutoFlow, d = r.gridTemplateColumns;
3341
+ return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
3342
+ d.split(" ").length <= 1 ? "vertical" : "horizontal";
3343
+ } else if (i === "inline-block" || i === "inline")
3344
+ return "horizontal";
3345
+ return "vertical";
3370
3346
  }
3371
3347
  const CONTROLS = [
3372
3348
  { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
3373
3349
  { ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
3374
3350
  { ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
3375
3351
  { ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
3376
- ], getParentBlockOrientation = (o, n) => {
3352
+ ], getParentBlockOrientation = (o, n, r) => {
3377
3353
  try {
3378
- if (!o || !n) return "VERTICAL";
3379
- const r = `[data-block-id='${o}']`, a = n == null ? void 0 : n.querySelector(r);
3380
- return a ? getOrientation(a).toUpperCase() : "VERTICAL";
3354
+ if (!o || !r) return "VERTICAL";
3355
+ const a = `[data-block-id='${o}']`, l = r == null ? void 0 : r.querySelector(a);
3356
+ if (l) {
3357
+ const i = r == null ? void 0 : r.querySelector(`[data-block-id='${n}']`);
3358
+ return getOrientation(l, i).toUpperCase();
3359
+ }
3360
+ return "VERTICAL";
3381
3361
  } catch {
3382
3362
  return "VERTICAL";
3383
3363
  }
3384
3364
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3385
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, a), f = useCallback(
3386
- (x) => {
3387
- isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3365
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), x = getParentBlockOrientation(c, i, a), f = useCallback(
3366
+ (h) => {
3367
+ isDisabledControl(g, m, h) || p || (h === "UP" || h === "LEFT" ? l([i], c || null, u - 1) : (h === "DOWN" || h === "RIGHT") && l([i], c || null, u + 2), n());
3388
3368
  },
3389
- [g, h, p, u, i, c, n]
3369
+ [g, m, p, u, i, c, n]
3390
3370
  );
3391
3371
  return useHotkeys(
3392
3372
  "shift+up, shift+down, shift+left, shift+right",
3393
- ({ key: x }) => {
3373
+ ({ key: h }) => {
3394
3374
  var b;
3395
- f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3375
+ f((b = h == null ? void 0 : h.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3396
3376
  },
3397
3377
  { document: a == null ? void 0 : a.contentDocument },
3398
3378
  [f]
3399
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
3379
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: x };
3400
3380
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3401
3381
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3402
3382
  o,
3403
3383
  n
3404
3384
  );
3405
- return r ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
3406
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-3 w-px bg-white/50" }),
3407
- CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
3408
- if (c !== p) return null;
3409
- const g = isDisabledControl(a, l, u);
3410
- return /* @__PURE__ */ jsx(
3411
- d,
3412
- {
3413
- onClick: () => i(u),
3414
- className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
3415
- },
3416
- u
3417
- );
3418
- })
3419
- ] });
3420
- }, BlockActionLabel = ({ block: o, label: n }) => {
3385
+ return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
3386
+ if (c !== p) return null;
3387
+ const g = isDisabledControl(a, l, u);
3388
+ return g ? null : /* @__PURE__ */ jsx(
3389
+ d,
3390
+ {
3391
+ onClick: () => i(u),
3392
+ className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
3393
+ },
3394
+ u
3395
+ );
3396
+ }) });
3397
+ };
3398
+ class PubSub {
3399
+ constructor() {
3400
+ V(this, "subscribers", /* @__PURE__ */ new Map());
3401
+ }
3402
+ subscribe(n, r) {
3403
+ return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
3404
+ const a = this.subscribers.get(n);
3405
+ a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
3406
+ };
3407
+ }
3408
+ publish(n, r) {
3409
+ const a = this.subscribers.get(n);
3410
+ a && a.forEach((l) => l(r));
3411
+ }
3412
+ }
3413
+ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3414
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
3415
+ if (m === "CHILD")
3416
+ pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3417
+ else {
3418
+ const x = { _id: c || "", position: d == null ? void 0 : d.length };
3419
+ m === "BEFORE" ? x.position = Math.max(u, 0) : m === "AFTER" && (x.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x);
3420
+ }
3421
+ };
3422
+ return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3423
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3424
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
3425
+ p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
3426
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
3427
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
3428
+ ] })
3429
+ ] }) : null;
3430
+ }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null), BlockActionLabel = ({ block: o, label: n }) => {
3421
3431
  const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
3422
3432
  return /* @__PURE__ */ jsxs(
3423
3433
  "div",
@@ -3436,46 +3446,46 @@ const CONTROLS = [
3436
3446
  }
3437
3447
  );
3438
3448
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
3439
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: h } = useFloating({
3449
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: x } = useFloating({
3440
3450
  placement: "top-start",
3441
3451
  middleware: [shift(), flip()],
3442
3452
  elements: {
3443
3453
  reference: o
3444
3454
  }
3445
3455
  });
3446
- useResizeObserver(o, () => h(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => h(), (p == null ? void 0 : p.body) !== null);
3447
- const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3448
- return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3456
+ useResizeObserver(o, () => x(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => x(), (u == null ? void 0 : u.body) !== null);
3457
+ const f = get(n, "_parent", null), h = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3458
+ return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3449
3459
  "div",
3450
3460
  {
3451
3461
  role: "button",
3452
3462
  tabIndex: 0,
3453
- ref: g.setFloating,
3454
- style: u,
3455
- onClick: (x) => {
3456
- x.stopPropagation(), x.preventDefault();
3463
+ ref: m.setFloating,
3464
+ style: g,
3465
+ onClick: (b) => {
3466
+ b.stopPropagation(), b.preventDefault();
3457
3467
  },
3458
- onMouseEnter: (x) => {
3459
- x.stopPropagation(), i(null);
3468
+ onMouseEnter: (b) => {
3469
+ b.stopPropagation(), i(null);
3460
3470
  },
3461
- onKeyDown: (x) => x.stopPropagation(),
3471
+ onKeyDown: (b) => b.stopPropagation(),
3462
3472
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3463
3473
  children: [
3464
- m && /* @__PURE__ */ jsx(
3474
+ f && /* @__PURE__ */ jsx(
3465
3475
  ArrowUpIcon,
3466
3476
  {
3467
3477
  className: "hover:scale-105",
3468
3478
  onClick: () => {
3469
- c([]), l([m]);
3479
+ c([]), l([f]);
3470
3480
  }
3471
3481
  }
3472
3482
  ),
3473
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3483
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: h, block: n }),
3474
3484
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3475
3485
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3476
- canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3477
- canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3478
- /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
3486
+ canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3487
+ canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3488
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: x })
3479
3489
  ] })
3480
3490
  ]
3481
3491
  }
@@ -3536,15 +3546,15 @@ const CONTROLS = [
3536
3546
  <div class="frame-root h-full"></div>
3537
3547
  </body>
3538
3548
  </html>`, useKeyEventWatcher = (o) => {
3539
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3549
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), x = o ? { document: o } : {};
3540
3550
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
3541
3551
  "ctrl+v,command+v",
3542
3552
  () => {
3543
- g(n[0]) && h(n);
3553
+ g(n[0]) && m(n);
3544
3554
  },
3545
- { ...m, preventDefault: !0 },
3546
- [n, g, h]
3547
- ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
3555
+ { ...x, preventDefault: !0 },
3556
+ [n, g, m]
3557
+ ), useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...x, preventDefault: !0 }, [
3548
3558
  n,
3549
3559
  i
3550
3560
  ]), useHotkeys(
@@ -3552,25 +3562,22 @@ const CONTROLS = [
3552
3562
  (f) => {
3553
3563
  f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3554
3564
  },
3555
- m,
3565
+ x,
3556
3566
  [n, l]
3557
3567
  );
3558
3568
  }, KeyboardHandler = () => {
3559
3569
  const { document: o } = useFrame();
3560
3570
  return useKeyEventWatcher(o), null;
3561
- }, CHAI_BUILDER_EVENTS = {
3562
- OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
3563
- CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
3564
- SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
3565
3571
  }, AddBlockAtBottom = () => {
3566
- const { t: o } = useTranslation();
3567
- return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
3572
+ const { t: o } = useTranslation(), { hasPermission: n } = usePermissions();
3573
+ return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
3568
3574
  /* @__PURE__ */ jsx("br", {}),
3569
3575
  /* @__PURE__ */ jsx(
3570
3576
  "div",
3571
3577
  {
3578
+ role: "button",
3572
3579
  onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
3573
- className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
3580
+ className: "block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
3574
3581
  children: /* @__PURE__ */ 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-xs leading-tight text-white hover:bg-purple-500", children: [
3575
3582
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "size-2.5 stroke-[3]" }),
3576
3583
  " ",
@@ -3579,7 +3586,7 @@ const CONTROLS = [
3579
3586
  }
3580
3587
  ),
3581
3588
  /* @__PURE__ */ jsx("br", {})
3582
- ] });
3589
+ ] }) : null;
3583
3590
  };
3584
3591
  let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
3585
3592
  const positionPlaceholder = (o, n, r) => {
@@ -3630,38 +3637,38 @@ function removeDataDrop() {
3630
3637
  const useDnd = () => {
3631
3638
  const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3632
3639
  if (!useFeature("dnd")) return {};
3633
- const h = () => {
3640
+ const m = () => {
3634
3641
  removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
3635
3642
  };
3636
3643
  return iframeDocument = o, {
3637
3644
  isDragging: n,
3638
- onDragOver: (m) => {
3639
- m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3645
+ onDragOver: (x) => {
3646
+ x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
3640
3647
  },
3641
- onDrop: (m) => {
3642
- var _;
3643
- const f = dropTarget, b = getOrientation(f) === "vertical" ? m.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : m.clientX;
3648
+ onDrop: (x) => {
3649
+ var j;
3650
+ const f = dropTarget, b = getOrientation(f) === "vertical" ? x.clientY + ((j = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : j.scrollY) : x.clientX;
3644
3651
  dropIndex = calculateDropIndex(b, possiblePositions);
3645
- const y = d, A = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3646
- if ((y == null ? void 0 : y._id) === A || !E) {
3647
- h();
3652
+ const k = d, A = f.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3653
+ if ((k == null ? void 0 : k._id) === A || !B) {
3654
+ m();
3648
3655
  return;
3649
3656
  }
3650
- if (!has(y, "_id")) {
3651
- a(y, A === "canvas" ? null : A, dropIndex), setTimeout(h, 300);
3657
+ if (!has(k, "_id")) {
3658
+ a(k, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3652
3659
  return;
3653
3660
  }
3654
- let w = f.getAttribute("data-block-id");
3655
- w === null && (w = m.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), h(), setTimeout(removePlaceholder, 300);
3661
+ let C = f.getAttribute("data-block-id");
3662
+ C === null && (C = x.target.parentElement.getAttribute("data-block-id")), c([k._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
3656
3663
  },
3657
- onDragEnter: (m) => {
3658
- const f = m, x = f.target;
3659
- dropTarget = x;
3660
- const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3661
- u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3664
+ onDragEnter: (x) => {
3665
+ const f = x, h = f.target;
3666
+ dropTarget = h;
3667
+ const b = h.getAttribute("data-block-id"), k = h.getAttribute("data-dnd-dragged") !== "yes";
3668
+ u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(h), r(!0), l(""), i([]);
3662
3669
  },
3663
- onDragLeave: (m) => {
3664
- m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3670
+ onDragLeave: (x) => {
3671
+ x.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3665
3672
  }
3666
3673
  };
3667
3674
  };
@@ -3683,17 +3690,17 @@ const useHandleCanvasDblClick = (o, n) => {
3683
3690
  const g = u.getAttribute("data-block-type");
3684
3691
  if (!g || !r.includes(g))
3685
3692
  return;
3686
- const h = u.getAttribute("data-block-id");
3687
- if (!h) return;
3693
+ const m = u.getAttribute("data-block-id");
3694
+ if (!m) return;
3688
3695
  o.on("update", ({ editor: f }) => {
3689
3696
  console.log(f.getHTML());
3690
3697
  }), o.on("blur", () => {
3691
3698
  console.log("blur");
3692
3699
  const f = o.getHTML();
3693
- a([h], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3694
- }), i(h);
3695
- const m = d(h).content;
3696
- o.commands.setContent(m), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3700
+ a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3701
+ }), i(m);
3702
+ const x = d(m).content;
3703
+ o.commands.setContent(x), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3697
3704
  },
3698
3705
  [l, c, d, i, a, o, n]
3699
3706
  );
@@ -3734,17 +3741,17 @@ const useHandleCanvasDblClick = (o, n) => {
3734
3741
  return;
3735
3742
  const f = getElementByDataBlockId(n, first(r));
3736
3743
  if (f) {
3737
- const x = f.getAttribute("data-style-prop");
3738
- if (x) {
3739
- const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
3740
- l([{ id: b, prop: x, blockId: y }]);
3744
+ const h = f.getAttribute("data-style-prop");
3745
+ if (h) {
3746
+ const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
3747
+ l([{ id: b, prop: h, blockId: k }]);
3741
3748
  }
3742
3749
  }
3743
3750
  }, 100);
3744
3751
  }, [n, r, l, a]);
3745
3752
  const c = useEditor({
3746
3753
  extensions: [StarterKit]
3747
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), h = useHandleMouseLeave(), m = useDnd();
3754
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), x = useDnd();
3748
3755
  return /* @__PURE__ */ jsx(
3749
3756
  "div",
3750
3757
  {
@@ -3753,18 +3760,18 @@ const useHandleCanvasDblClick = (o, n) => {
3753
3760
  onClick: u,
3754
3761
  onDoubleClick: p,
3755
3762
  onMouseMove: g,
3756
- onMouseLeave: h,
3757
- ...omit(m, "isDragging"),
3758
- className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3763
+ onMouseLeave: m,
3764
+ ...omit(x, "isDragging"),
3765
+ className: "relative h-full max-w-full p-px " + (x.isDragging ? "dragging" : ""),
3759
3766
  children: o
3760
3767
  }
3761
3768
  );
3762
3769
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
3763
3770
  const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3764
3771
  d == null ? void 0 : d.getElementById("selected-block")
3765
- ), [h] = useState(
3766
- d == null ? void 0 : d.getElementById("selected-styling-block")
3767
3772
  ), [m] = useState(
3773
+ d == null ? void 0 : d.getElementById("selected-styling-block")
3774
+ ), [x] = useState(
3768
3775
  d == null ? void 0 : d.getElementById("dragged-block")
3769
3776
  );
3770
3777
  useEffect(() => {
@@ -3789,15 +3796,15 @@ const useHandleCanvasDblClick = (o, n) => {
3789
3796
  forms,
3790
3797
  aspectRatio,
3791
3798
  containerQueries,
3792
- plugin(function({ addBase: b, theme: y }) {
3799
+ plugin(function({ addBase: b, theme: k }) {
3793
3800
  b({
3794
3801
  "h1,h2,h3,h4,h5,h6": {
3795
- fontFamily: y("fontFamily.heading")
3802
+ fontFamily: k("fontFamily.heading")
3796
3803
  },
3797
3804
  body: {
3798
- fontFamily: y("fontFamily.body"),
3799
- color: y("colors.foreground"),
3800
- backgroundColor: y("colors.background")
3805
+ fontFamily: k("fontFamily.body"),
3806
+ color: k("colors.foreground"),
3807
+ backgroundColor: k("colors.background")
3801
3808
  }
3802
3809
  });
3803
3810
  })
@@ -3808,23 +3815,23 @@ const useHandleCanvasDblClick = (o, n) => {
3808
3815
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3809
3816
  }`);
3810
3817
  }, [r, g]), useEffect(() => {
3811
- m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3812
- }, [i, m]), useEffect(() => {
3818
+ x.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3819
+ }, [i, x]), useEffect(() => {
3813
3820
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3814
3821
  }, [u]), useEffect(() => {
3815
- h && (h.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3822
+ m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3816
3823
  outline: 1px solid orange !important; outline-offset: -1px;
3817
3824
  }`);
3818
- }, [l, h]), useEffect(() => {
3825
+ }, [l, m]), useEffect(() => {
3819
3826
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3820
3827
  }, [c, d]);
3821
3828
  const f = useMemo(
3822
3829
  () => getChaiThemeCssVariables(o),
3823
3830
  [o]
3824
- ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3831
+ ), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3825
3832
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3826
3833
  /* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
3827
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3834
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
3828
3835
  ] });
3829
3836
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3830
3837
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3901,13 +3908,13 @@ const getBlockRuntimeProps = memoize((o) => {
3901
3908
  [o]
3902
3909
  );
3903
3910
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3904
- const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), h = useMemo(
3911
+ const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
3905
3912
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3906
3913
  [r, l, a, d, u]
3907
- ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3914
+ ), x = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3908
3915
  () => c(r._id, getBlockRuntimeProps(r._type)),
3909
3916
  [r._id, r._type, c, getBlockRuntimeProps]
3910
- ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3917
+ ), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3911
3918
  () => ({
3912
3919
  blockProps: {
3913
3920
  "data-block-id": r._id,
@@ -3915,20 +3922,20 @@ const getBlockRuntimeProps = memoize((o) => {
3915
3922
  },
3916
3923
  inBuilder: !0,
3917
3924
  lang: l || i,
3918
- ...h,
3919
3925
  ...m,
3926
+ ...x,
3920
3927
  ...f,
3921
- ...x
3928
+ ...h
3922
3929
  }),
3923
3930
  [
3924
3931
  r._id,
3925
3932
  r._type,
3926
3933
  l,
3927
3934
  i,
3928
- h,
3929
3935
  m,
3936
+ x,
3930
3937
  f,
3931
- x
3938
+ h
3932
3939
  ]
3933
3940
  );
3934
3941
  return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
@@ -3960,11 +3967,11 @@ const getBlockRuntimeProps = memoize((o) => {
3960
3967
  if (d < n) {
3961
3968
  const u = parseFloat((d / n).toFixed(2).toString());
3962
3969
  let g = {};
3963
- const h = p * u, m = d * u;
3970
+ const m = p * u, x = d * u;
3964
3971
  p && (g = {
3965
3972
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3966
- height: 100 + (p - h) / h * 100 + "%",
3967
- width: 100 + (d - m) / m * 100 + "%"
3973
+ height: 100 + (p - m) / m * 100 + "%",
3974
+ width: 100 + (d - x) / x * 100 + "%"
3968
3975
  }), i({
3969
3976
  position: "relative",
3970
3977
  top: 0,
@@ -3981,39 +3988,39 @@ const getBlockRuntimeProps = memoize((o) => {
3981
3988
  c();
3982
3989
  }, [n, o, r, c]), l;
3983
3990
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3984
- const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, h] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), E = (j) => {
3985
- p((S) => ({ ...S, width: j }));
3991
+ const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, x] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [h, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), B = (_) => {
3992
+ p((S) => ({ ...S, width: _ }));
3986
3993
  };
3987
3994
  useEffect(() => {
3988
3995
  if (!c.current) return;
3989
- const { clientWidth: j, clientHeight: S } = c.current;
3990
- p({ width: j, height: S });
3996
+ const { clientWidth: _, clientHeight: S } = c.current;
3997
+ p({ width: _, height: S });
3991
3998
  }, [c, n]);
3992
- const w = (j, S = 0) => {
3993
- const { top: C } = j.getBoundingClientRect();
3994
- return C + S >= 0 && C - S <= window.innerHeight;
3999
+ const C = (_, S = 0) => {
4000
+ const { top: w } = _.getBoundingClientRect();
4001
+ return w + S >= 0 && w - S <= window.innerHeight;
3995
4002
  };
3996
4003
  useEffect(() => {
3997
- var j, S;
4004
+ var _, S;
3998
4005
  if (a && a.type !== "Multiple" && i.current) {
3999
- const C = getElementByDataBlockId(i.current.contentDocument, a._id);
4000
- C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), h([C]));
4006
+ const w = getElementByDataBlockId(i.current.contentDocument, a._id);
4007
+ w && (C(w) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
4001
4008
  }
4002
4009
  }, [a]), useEffect(() => {
4003
- if (!isEmpty(x) && i.current) {
4004
- const j = getElementByStyleId(
4010
+ if (!isEmpty(h) && i.current) {
4011
+ const _ = getElementByStyleId(
4005
4012
  i.current.contentDocument,
4006
- first(x).id
4013
+ first(h).id
4007
4014
  );
4008
- m(j ? [j] : [null]);
4015
+ x(_ ? [_] : [null]);
4009
4016
  } else
4010
- m([null]);
4011
- }, [x]);
4012
- const _ = useMemo(() => {
4013
- let j = IframeInitialContent;
4014
- return j = j.replace("__HTML_DIR__", A), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4017
+ x([null]);
4018
+ }, [h]);
4019
+ const j = useMemo(() => {
4020
+ let _ = IframeInitialContent;
4021
+ return _ = _.replace("__HTML_DIR__", A), o === "offline" && (_ = _.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), _;
4015
4022
  }, [o, A]);
4016
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
4023
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsx(
4017
4024
  "div",
4018
4025
  {
4019
4026
  onClick: () => {
@@ -4030,7 +4037,7 @@ const getBlockRuntimeProps = memoize((o) => {
4030
4037
  id: "canvas-iframe",
4031
4038
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
4032
4039
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
4033
- initialContent: _,
4040
+ initialContent: j,
4034
4041
  children: [
4035
4042
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
4036
4043
  /* @__PURE__ */ jsx(
@@ -4042,7 +4049,7 @@ const getBlockRuntimeProps = memoize((o) => {
4042
4049
  ),
4043
4050
  /* @__PURE__ */ jsx(HeadTags, {}),
4044
4051
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
4045
- y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4052
+ k ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4046
4053
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
4047
4054
  /* @__PURE__ */ jsx("br", {}),
4048
4055
  /* @__PURE__ */ jsx("br", {}),
@@ -4203,78 +4210,78 @@ const getBlockRuntimeProps = memoize((o) => {
4203
4210
  }
4204
4211
  );
4205
4212
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4206
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4207
- a(y);
4208
- }, h = () => {
4209
- const y = l.find((A) => Object.keys(A)[0] === r);
4210
- if (y) {
4211
- const A = Object.values(y)[0];
4212
- A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4213
+ const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (A) => {
4214
+ a(A);
4215
+ }, x = () => {
4216
+ const A = l.find((B) => Object.keys(B)[0] === r);
4217
+ if (A) {
4218
+ const B = Object.values(A)[0];
4219
+ B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
4213
4220
  } else
4214
4221
  console.error("Preset not found:", r);
4215
- }, m = useDebouncedCallback(
4216
- (y, A) => {
4217
- d(() => ({
4218
- ...c,
4222
+ }, f = useDebouncedCallback(
4223
+ (A, B) => {
4224
+ p(() => ({
4225
+ ...d,
4219
4226
  fontFamily: {
4220
- ...c.fontFamily,
4221
- [y.replace(/font-/g, "")]: A
4227
+ ...d.fontFamily,
4228
+ [A.replace(/font-/g, "")]: B
4222
4229
  }
4223
4230
  }));
4224
4231
  },
4225
- [c],
4232
+ [d],
4226
4233
  200
4227
- ), f = useDebouncedCallback(
4228
- (y) => {
4229
- d(() => ({
4230
- ...c,
4231
- borderRadius: `${y}px`
4234
+ ), h = useDebouncedCallback(
4235
+ (A) => {
4236
+ p(() => ({
4237
+ ...d,
4238
+ borderRadius: `${A}px`
4232
4239
  }));
4233
4240
  },
4234
- [c],
4241
+ [d],
4235
4242
  200
4236
- ), x = useDebouncedCallback(
4237
- (y, A) => {
4238
- d(() => {
4239
- const E = get(c, `colors.${y}`);
4240
- return n ? set(E, 1, A) : set(E, 0, A), {
4241
- ...c,
4243
+ ), b = useDebouncedCallback(
4244
+ (A, B) => {
4245
+ p(() => {
4246
+ const C = get(d, `colors.${A}`);
4247
+ return n ? set(C, 1, B) : set(C, 0, B), {
4248
+ ...d,
4242
4249
  colors: {
4243
- ...c.colors,
4244
- [y]: E
4250
+ ...d.colors,
4251
+ [A]: C
4245
4252
  }
4246
4253
  };
4247
4254
  });
4248
4255
  },
4249
- [c],
4256
+ [d],
4250
4257
  200
4251
- ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4252
- const E = get(c, `colors.${A}.${n ? 1 : 0}`);
4258
+ ), k = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([B]) => {
4259
+ const C = get(d, `colors.${B}.${n ? 1 : 0}`);
4253
4260
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4254
4261
  /* @__PURE__ */ jsx(
4255
4262
  ColorPickerInput,
4256
4263
  {
4257
- value: E,
4258
- onChange: (w) => x(A, w)
4264
+ value: C,
4265
+ onChange: (j) => b(B, j)
4259
4266
  }
4260
4267
  ),
4261
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
4262
- ] }, A);
4268
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4269
+ ] }, B);
4263
4270
  }) });
4264
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4271
+ return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4265
4272
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4266
4273
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
4267
4274
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4268
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
4275
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
4269
4276
  /* @__PURE__ */ jsxs(
4270
4277
  "select",
4271
4278
  {
4272
4279
  value: r,
4273
- onChange: (y) => g(y.target.value),
4280
+ onChange: (A) => m(A.target.value),
4274
4281
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
4275
4282
  children: [
4276
4283
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
4277
- Array.isArray(l) && l.map((y) => /* @__PURE__ */ jsx("option", { value: Object.keys(y)[0], children: capitalize(Object.keys(y)[0]) }, Object.keys(y)[0]))
4284
+ Array.isArray(l) && l.map((A) => /* @__PURE__ */ jsx("option", { value: Object.keys(A)[0], children: capitalize(Object.keys(A)[0]) }, Object.keys(A)[0]))
4278
4285
  ]
4279
4286
  }
4280
4287
  )
@@ -4285,31 +4292,31 @@ const getBlockRuntimeProps = memoize((o) => {
4285
4292
  className: "w-full text-sm",
4286
4293
  disabled: r === "",
4287
4294
  variant: "default",
4288
- onClick: h,
4289
- children: u("Apply")
4295
+ onClick: x,
4296
+ children: g("Apply")
4290
4297
  }
4291
4298
  ) })
4292
4299
  ] }),
4293
4300
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4294
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4301
+ (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([A, B]) => /* @__PURE__ */ jsx(
4295
4302
  FontSelector,
4296
4303
  {
4297
- label: y,
4298
- value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4299
- onChange: (E) => m(y, E)
4304
+ label: A,
4305
+ value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4306
+ onChange: (C) => f(A, C)
4300
4307
  },
4301
- y
4308
+ A
4302
4309
  )) }),
4303
- (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4304
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
4310
+ (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4311
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
4305
4312
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4306
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: f }),
4307
- /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
4313
+ /* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: h }),
4314
+ /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
4308
4315
  ] })
4309
4316
  ] }),
4310
- (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4311
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4312
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4317
+ (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4318
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
4319
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((A) => k(A)) }, n ? "dark" : "light")
4313
4320
  ] })
4314
4321
  ] }),
4315
4322
  /* @__PURE__ */ jsx("br", {}),
@@ -4318,7 +4325,7 @@ const getBlockRuntimeProps = memoize((o) => {
4318
4325
  /* @__PURE__ */ jsx("br", {})
4319
4326
  ] }),
4320
4327
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
4321
- ] });
4328
+ ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
4322
4329
  }), removeSizeAttributes = (o) => {
4323
4330
  try {
4324
4331
  return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
@@ -4402,19 +4409,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4402
4409
  }, [a, o]);
4403
4410
  const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
4404
4411
  (f) => {
4405
- const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4406
- f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
4412
+ const h = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4413
+ f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : h(f.type) && (n([...i, f.key].join(".")), l(!1));
4407
4414
  },
4408
4415
  [i, n, r]
4409
- ), h = React.useCallback(() => {
4416
+ ), m = React.useCallback(() => {
4410
4417
  if (i.length > 0) {
4411
4418
  const f = i.slice(0, -1);
4412
- c(f), p(f.reduce((x, b) => x[b], o));
4419
+ c(f), p(f.reduce((h, b) => h[b], o));
4413
4420
  }
4414
- }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4421
+ }, [i, o]), x = React.useMemo(() => Object.entries(d).map(([f, h]) => ({
4415
4422
  key: f,
4416
- value: x,
4417
- type: u(x)
4423
+ value: h,
4424
+ type: u(h)
4418
4425
  })).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
4419
4426
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4420
4427
  /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -4436,11 +4443,11 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4436
4443
  /* @__PURE__ */ jsxs(CommandList, { children: [
4437
4444
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4438
4445
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4439
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: h, className: "flex items-center text-sm", children: [
4446
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4440
4447
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4441
4448
  "Back"
4442
4449
  ] }),
4443
- m.map((f) => /* @__PURE__ */ jsxs(
4450
+ x.map((f) => /* @__PURE__ */ jsxs(
4444
4451
  CommandItem,
4445
4452
  {
4446
4453
  value: f.key,
@@ -4456,8 +4463,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4456
4463
  size: "sm",
4457
4464
  variant: "ghost",
4458
4465
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4459
- onClick: (x) => {
4460
- x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4466
+ onClick: (h) => {
4467
+ h.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4461
4468
  },
4462
4469
  children: "Select"
4463
4470
  }
@@ -4625,16 +4632,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4625
4632
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4626
4633
  useEffect(() => {
4627
4634
  if (o) {
4628
- const h = document.createElement("style");
4629
- return h.id = "rte-modal-styles", h.innerHTML = `
4635
+ const m = document.createElement("style");
4636
+ return m.id = "rte-modal-styles", m.innerHTML = `
4630
4637
  /* Ensure the NestedPathSelector popover appears above the dialog */
4631
4638
  .rte-path-selector + [data-radix-popper-content-wrapper],
4632
4639
  [data-radix-popper-content-wrapper] {
4633
4640
  z-index: 9999 !important;
4634
4641
  }
4635
- `, document.head.appendChild(h), () => {
4636
- const m = document.getElementById("rte-modal-styles");
4637
- m && m.remove();
4642
+ `, document.head.appendChild(m), () => {
4643
+ const x = document.getElementById("rte-modal-styles");
4644
+ x && x.remove();
4638
4645
  };
4639
4646
  }
4640
4647
  }, [o]);
@@ -4655,13 +4662,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4655
4662
  Underline
4656
4663
  ],
4657
4664
  content: a || "",
4658
- onUpdate: ({ editor: h }) => {
4659
- const m = h.getHTML();
4660
- l(m);
4665
+ onUpdate: ({ editor: m }) => {
4666
+ const x = m.getHTML();
4667
+ l(x);
4661
4668
  },
4662
- onBlur: ({ editor: h }) => {
4663
- const m = h.getHTML();
4664
- i(r, m);
4669
+ onBlur: ({ editor: m }) => {
4670
+ const x = m.getHTML();
4671
+ i(r, x);
4665
4672
  },
4666
4673
  editorProps: {
4667
4674
  attributes: {
@@ -4676,22 +4683,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4676
4683
  }, [o, u]), useEffect(() => {
4677
4684
  c.current && u && (c.current.__chaiRTE = u);
4678
4685
  }, [u, o]);
4679
- const g = (h) => {
4686
+ const g = (m) => {
4680
4687
  if (!u) return;
4681
- const m = `{{${h}}}`;
4688
+ const x = `{{${m}}}`;
4682
4689
  u.commands.focus();
4683
- const { from: f, to: x } = u.state.selection;
4684
- if (f !== x)
4685
- u.chain().deleteSelection().insertContent(m).run();
4690
+ const { from: f, to: h } = u.state.selection;
4691
+ if (f !== h)
4692
+ u.chain().deleteSelection().insertContent(x).run();
4686
4693
  else {
4687
- const { state: y } = u, A = y.selection.from, E = y.doc.textBetween(Math.max(0, A - 1), A), w = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
4688
- let _ = "";
4689
- A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4694
+ const { state: k } = u, A = k.selection.from, B = k.doc.textBetween(Math.max(0, A - 1), A), C = k.doc.textBetween(A, Math.min(A + 1, k.doc.content.size));
4690
4695
  let j = "";
4691
- w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + m + j).run();
4696
+ A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (j = " ");
4697
+ let _ = "";
4698
+ C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
4692
4699
  }
4693
4700
  };
4694
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4701
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4695
4702
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4696
4703
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4697
4704
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4724,12 +4731,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4724
4731
  ],
4725
4732
  content: r || "",
4726
4733
  onUpdate: ({ editor: f }) => {
4727
- const x = f.getHTML();
4728
- a(x), c || u(x);
4734
+ const h = f.getHTML();
4735
+ a(h), c || u(h);
4729
4736
  },
4730
4737
  onBlur: ({ editor: f }) => {
4731
- const x = f.getHTML();
4732
- l(o, x);
4738
+ const h = f.getHTML();
4739
+ l(o, h);
4733
4740
  },
4734
4741
  editorProps: {
4735
4742
  attributes: {
@@ -4742,9 +4749,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4742
4749
  }, [g]), useEffect(() => {
4743
4750
  u(r || "");
4744
4751
  }, [r]);
4745
- const h = (f) => {
4752
+ const m = (f) => {
4746
4753
  a(f);
4747
- }, m = () => {
4754
+ }, x = () => {
4748
4755
  d(!1), g && g.commands.setContent(p);
4749
4756
  };
4750
4757
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4756,10 +4763,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4756
4763
  RTEModal,
4757
4764
  {
4758
4765
  isOpen: c,
4759
- onClose: m,
4766
+ onClose: x,
4760
4767
  id: o,
4761
4768
  value: p,
4762
- onChange: h,
4769
+ onChange: m,
4763
4770
  onBlur: l
4764
4771
  }
4765
4772
  )
@@ -4770,41 +4777,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4770
4777
  onChange: r
4771
4778
  }) => {
4772
4779
  var L;
4773
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), A = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4780
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, x] = useState(""), [f, h] = useState([]), [b, k] = useState(-1), A = useRef(null), B = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4774
4781
  useEffect(() => {
4775
- if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4776
- const v = split(o, ":"), k = get(v, 1, "page") || "page";
4777
- g(k), (async () => {
4778
- const B = await l(k, [get(v, 2, "page")]);
4779
- B && Array.isArray(B) && m(get(B, [0, "name"], ""));
4782
+ if (x(""), h([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4783
+ const v = split(o, ":"), y = get(v, 1, "page") || "page";
4784
+ g(y), (async () => {
4785
+ const E = await l(y, [get(v, 2, "page")]);
4786
+ E && Array.isArray(E) && x(get(E, [0, "name"], ""));
4780
4787
  })();
4781
4788
  }, [o]);
4782
- const w = useDebouncedCallback(
4789
+ const C = useDebouncedCallback(
4783
4790
  async (v) => {
4784
4791
  if (isEmpty(v))
4785
- x([]);
4792
+ h([]);
4786
4793
  else {
4787
- const k = await l(u, v);
4788
- x(k);
4794
+ const y = await l(u, v);
4795
+ h(y);
4789
4796
  }
4790
- c(!1), y(-1);
4797
+ c(!1), k(-1);
4791
4798
  },
4792
4799
  [u],
4793
4800
  300
4794
- ), _ = (v) => {
4795
- const k = ["pageType", u, v.id];
4796
- k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4797
- }, j = (v) => {
4801
+ ), j = (v) => {
4802
+ const y = ["pageType", u, v.id];
4803
+ y[1] && (r(y.join(":")), x(v.name), p(!1), h([]), k(-1));
4804
+ }, _ = (v) => {
4798
4805
  switch (v.key) {
4799
4806
  case "ArrowDown":
4800
- v.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
4807
+ v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
4801
4808
  break;
4802
4809
  case "ArrowUp":
4803
- v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4810
+ v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
4804
4811
  break;
4805
4812
  case "Enter":
4806
4813
  if (v.preventDefault(), f.length === 0) return;
4807
- b >= 0 && _(f[b]);
4814
+ b >= 0 && j(f[b]);
4808
4815
  break;
4809
4816
  case "Escape":
4810
4817
  v.preventDefault(), S();
@@ -4818,9 +4825,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4818
4825
  }
4819
4826
  }, [b]);
4820
4827
  const S = () => {
4821
- m(""), x([]), y(-1), p(!1), r("");
4822
- }, C = (v) => {
4823
- m(v), p(!isEmpty(v)), c(!0), w(v);
4828
+ x(""), h([]), k(-1), p(!1), r("");
4829
+ }, w = (v) => {
4830
+ x(v), p(!isEmpty(v)), c(!0), C(v);
4824
4831
  };
4825
4832
  return /* @__PURE__ */ jsxs("div", { children: [
4826
4833
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
@@ -4829,14 +4836,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4829
4836
  "input",
4830
4837
  {
4831
4838
  type: "text",
4832
- value: h,
4833
- onChange: (v) => C(v.target.value),
4834
- onKeyDown: j,
4835
- placeholder: a(`Search ${E ?? ""}`),
4839
+ value: m,
4840
+ onChange: (v) => w(v.target.value),
4841
+ onKeyDown: _,
4842
+ placeholder: a(`Search ${B ?? ""}`),
4836
4843
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4837
4844
  }
4838
4845
  ),
4839
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4846
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4840
4847
  ] }),
4841
4848
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4842
4849
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4844,13 +4851,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4844
4851
  ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4845
4852
  a("No results found for"),
4846
4853
  ' "',
4847
- h,
4854
+ m,
4848
4855
  '"'
4849
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4856
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
4850
4857
  "li",
4851
4858
  {
4852
- onClick: () => _(v),
4853
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4859
+ onClick: () => j(v),
4860
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4854
4861
  children: [
4855
4862
  v.name,
4856
4863
  " ",
@@ -4943,30 +4950,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4943
4950
  }, [a]), useEffect(() => {
4944
4951
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4945
4952
  }, [o, u]);
4946
- const h = () => {
4947
- const x = findIndex(u, { _id: g });
4948
- if (x > -1) {
4949
- const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4950
- if (!y) return;
4951
- n({ ...o, currentSlide: y }), c([y]);
4953
+ const m = () => {
4954
+ const h = findIndex(u, { _id: g });
4955
+ if (h > -1) {
4956
+ const b = (h + 1) % u.length, k = get(u, [b, "_id"]);
4957
+ if (!k) return;
4958
+ n({ ...o, currentSlide: k }), c([k]);
4952
4959
  }
4953
- }, m = () => {
4954
- const x = findIndex(u, { _id: g });
4955
- if (x > -1) {
4956
- const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4957
- if (!y) return;
4958
- n({ ...o, currentSlide: y }), c([y]);
4960
+ }, x = () => {
4961
+ const h = findIndex(u, { _id: g });
4962
+ if (h > -1) {
4963
+ const b = (h - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
4964
+ if (!k) return;
4965
+ n({ ...o, currentSlide: k }), c([k]);
4959
4966
  }
4960
4967
  }, f = () => {
4961
- const x = i(
4968
+ const h = i(
4962
4969
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4963
4970
  p == null ? void 0 : p._id
4964
- ), b = x == null ? void 0 : x._id;
4971
+ ), b = h == null ? void 0 : h._id;
4965
4972
  b && (n({ ...o, currentSlide: b }), c([b]));
4966
4973
  };
4967
4974
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4968
4975
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
4969
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4976
+ /* @__PURE__ */ jsx("button", { onClick: x, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4970
4977
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4971
4978
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4972
4979
  " ",
@@ -4975,7 +4982,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4975
4982
  "/",
4976
4983
  u.length
4977
4984
  ] }) : "-" }),
4978
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4985
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4979
4986
  /* @__PURE__ */ jsxs(
4980
4987
  "button",
4981
4988
  {
@@ -5040,8 +5047,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5040
5047
  value: o == null ? void 0 : o.autoplayInterval,
5041
5048
  className: "text-xs",
5042
5049
  pattern: "[0-9]*",
5043
- onChange: (x) => {
5044
- let b = x.target.value;
5050
+ onChange: (h) => {
5051
+ let b = h.target.value;
5045
5052
  b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5046
5053
  }
5047
5054
  }
@@ -5067,7 +5074,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5067
5074
  ),
5068
5075
  /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5069
5076
  ] });
5070
- }, CustomFieldTemplate = ({
5077
+ }, JSONFormFieldTemplate = ({
5071
5078
  id: o,
5072
5079
  classNames: n,
5073
5080
  label: r,
@@ -5079,67 +5086,67 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5079
5086
  required: p,
5080
5087
  schema: u,
5081
5088
  formData: g,
5082
- onChange: h
5089
+ onChange: m
5083
5090
  }) => {
5084
- const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? f : m, y = get(LANGUAGES, b, b), A = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5085
- (k) => {
5086
- const B = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5087
- let R = "", O = "";
5088
- const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5089
- return D > 0 && ($ === "." || !B($) && $ !== " ") && (R = " "), D < N.length && !B(H) && H !== " " && (O = " "), {
5090
- text: R + M + O,
5091
- prefixLength: R.length,
5091
+ const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty$1(h) ? "" : isEmpty$1(x) ? f : x, k = get$1(LANGUAGES, b, b), A = usePageExternalData(), B = useSelectedBlock(), C = useRegisteredChaiBlocks(), j = get$1(C, [B == null ? void 0 : B._type, "i18nProps"], []) || [], [_, S] = useState(null), w = useCallback(
5092
+ (y) => {
5093
+ const E = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
5094
+ let D = "", O = "";
5095
+ const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
5096
+ return N > 0 && ($ === "." || !E($) && $ !== " ") && (D = " "), N < P.length && !E(H) && H !== " " && (O = " "), {
5097
+ text: D + M + O,
5098
+ prefixLength: D.length,
5092
5099
  suffixLength: O.length
5093
5100
  };
5094
5101
  }, I = document.getElementById(o);
5095
5102
  if (!I) return;
5096
- const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5097
- if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5098
- const N = P.__chaiRTE;
5099
- if (N) {
5100
- const D = `{{${k}}}`;
5101
- N.commands.focus();
5102
- const { from: M, to: R } = N.state.selection;
5103
- if (M !== R)
5104
- N.chain().deleteSelection().insertContent(D).run();
5103
+ const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5104
+ if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
5105
+ const P = R.__chaiRTE;
5106
+ if (P) {
5107
+ const N = `{{${y}}}`;
5108
+ P.commands.focus();
5109
+ const { from: M, to: D } = P.state.selection;
5110
+ if (M !== D)
5111
+ P.chain().deleteSelection().insertContent(N).run();
5105
5112
  else {
5106
- const { state: $ } = N, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5113
+ const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5107
5114
  let z = "";
5108
- H > 0 && F !== " " && !B(F) && (z = " ");
5115
+ H > 0 && U !== " " && !E(U) && (z = " ");
5109
5116
  let W = "";
5110
- U && U !== " " && !B(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5117
+ F && F !== " " && !E(F) && (W = " "), P.chain().insertContent(z + N + W).run();
5111
5118
  }
5112
- setTimeout(() => h(N.getHTML(), {}, o), 100);
5119
+ setTimeout(() => m(P.getHTML(), {}, o), 100);
5113
5120
  return;
5114
5121
  }
5115
5122
  } else {
5116
- const N = I, D = N.selectionStart || 0, M = N.value || "", R = N.selectionEnd || D;
5117
- if (R > D) {
5118
- const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(R);
5119
- h(W, {}, o);
5123
+ const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
5124
+ if (D > N) {
5125
+ const F = `{{${y}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
5126
+ m(W, {}, o);
5120
5127
  return;
5121
5128
  }
5122
- const $ = `{{${k}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5123
- h(F, {}, o);
5129
+ const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
5130
+ m(U, {}, o);
5124
5131
  }
5125
5132
  },
5126
- [o, h, g, E == null ? void 0 : E._id]
5133
+ [o, m, g, B == null ? void 0 : B._id]
5127
5134
  );
5128
5135
  if (d)
5129
5136
  return null;
5130
5137
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5131
- const v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
5138
+ const v = j == null ? void 0 : j.includes(o.replace("root.", ""));
5132
5139
  if (u.type === "array") {
5133
- const k = j === o;
5140
+ const y = _ === o;
5134
5141
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5135
5142
  u.title && /* @__PURE__ */ jsxs(
5136
5143
  "label",
5137
5144
  {
5138
5145
  htmlFor: o,
5139
- onClick: () => S(k ? null : o),
5146
+ onClick: () => S(y ? null : o),
5140
5147
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5141
5148
  children: [
5142
- k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5149
+ y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5143
5150
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
5144
5151
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
5145
5152
  " ",
@@ -5147,7 +5154,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5147
5154
  ]
5148
5155
  }
5149
5156
  ),
5150
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${k ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5157
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${y ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5151
5158
  c,
5152
5159
  a,
5153
5160
  l,
@@ -5162,11 +5169,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5162
5169
  " ",
5163
5170
  v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5164
5171
  " ",
5165
- y
5172
+ k
5166
5173
  ] }),
5167
5174
  p && u.type !== "object" ? " *" : null
5168
5175
  ] }),
5169
- u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: C, dataType: "value" })
5176
+ u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
5170
5177
  ] }),
5171
5178
  c,
5172
5179
  a,
@@ -5179,8 +5186,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5179
5186
  /* @__PURE__ */ jsx("span", { children: "Add" })
5180
5187
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5181
5188
  const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
5182
- async ({ formData: g }, h) => {
5183
- l({ formData: g }, h);
5189
+ async ({ formData: g }, m) => {
5190
+ l({ formData: g }, m);
5184
5191
  },
5185
5192
  [l, i],
5186
5193
  400
@@ -5204,7 +5211,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5204
5211
  ...d
5205
5212
  },
5206
5213
  templates: {
5207
- FieldTemplate: CustomFieldTemplate,
5214
+ FieldTemplate: JSONFormFieldTemplate,
5208
5215
  ButtonTemplates: {
5209
5216
  AddButton: CustomAddButton
5210
5217
  },
@@ -5219,10 +5226,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5219
5226
  uiSchema: r,
5220
5227
  schema: n,
5221
5228
  formData: a,
5222
- onChange: ({ formData: g }, h) => {
5223
- if (!h || o !== (g == null ? void 0 : g._id)) return;
5224
- const m = take(h.split("."), 2).join(".").replace("root.", "");
5225
- u({ formData: g }, m);
5229
+ onChange: ({ formData: g }, m) => {
5230
+ if (!m || o !== (g == null ? void 0 : g._id)) return;
5231
+ const x = take(m.split("."), 2).join(".").replace("root.", "");
5232
+ u({ formData: g }, x);
5226
5233
  }
5227
5234
  },
5228
5235
  i
@@ -5265,35 +5272,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5265
5272
  }), a;
5266
5273
  };
5267
5274
  function BlockSettings() {
5268
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: j }, S, C) => {
5269
- S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5270
- }, x = useCallback(
5271
- debounce(({ formData: j }, S, C) => {
5272
- f({ formData: j }, S, C), d(j);
5275
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), x = formDataWithSelectedLang(g, o, m), f = ({ formData: _ }, S, w) => {
5276
+ S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(_, S) }, w);
5277
+ }, h = useCallback(
5278
+ debounce(({ formData: _ }, S, w) => {
5279
+ f({ formData: _ }, S, w), d(_);
5273
5280
  }, 1500),
5274
5281
  [n == null ? void 0 : n._id, o]
5275
- ), b = ({ formData: j }, S) => {
5276
- S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5277
- }, y = ({ formData: j }, S) => {
5278
- S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5282
+ ), b = ({ formData: _ }, S) => {
5283
+ S && (r([n._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
5284
+ }, k = ({ formData: _ }, S) => {
5285
+ S && (r([g._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
5279
5286
  };
5280
5287
  keys(get(i, "_bindings", {}));
5281
- const { schema: A, uiSchema: E } = useMemo(() => {
5282
- const j = n == null ? void 0 : n._type;
5283
- if (j)
5284
- return getBlockFormSchemas(j);
5285
- }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5288
+ const { schema: A, uiSchema: B } = useMemo(() => {
5289
+ const _ = n == null ? void 0 : n._type;
5290
+ if (_)
5291
+ return getBlockFormSchemas(_);
5292
+ }, [n]), { wrapperSchema: C, wrapperUiSchema: j } = useMemo(() => {
5286
5293
  if (!g || !(g != null && g._type))
5287
5294
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5288
- const j = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: C = {} } = getBlockFormSchemas(j);
5289
- return { wrapperSchema: S, wrapperUiSchema: C };
5295
+ const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: w = {} } = getBlockFormSchemas(_);
5296
+ return { wrapperSchema: S, wrapperUiSchema: w };
5290
5297
  }, [g]);
5291
5298
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5292
5299
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5293
5300
  /* @__PURE__ */ jsxs(
5294
5301
  "div",
5295
5302
  {
5296
- onClick: () => u((j) => !j),
5303
+ onClick: () => u((_) => !_),
5297
5304
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5298
5305
  children: [
5299
5306
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5312,10 +5319,10 @@ function BlockSettings() {
5312
5319
  JSONForm,
5313
5320
  {
5314
5321
  blockId: g == null ? void 0 : g._id,
5315
- onChange: y,
5316
- formData: m,
5317
- schema: w,
5318
- uiSchema: _
5322
+ onChange: k,
5323
+ formData: x,
5324
+ schema: C,
5325
+ uiSchema: j
5319
5326
  }
5320
5327
  ) })
5321
5328
  ] }),
@@ -5326,7 +5333,7 @@ function BlockSettings() {
5326
5333
  onChange: b,
5327
5334
  formData: i,
5328
5335
  schema: A,
5329
- uiSchema: E
5336
+ uiSchema: B
5330
5337
  }
5331
5338
  ),
5332
5339
  (n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
@@ -5431,32 +5438,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5431
5438
  canvas: n = !1,
5432
5439
  tooltip: r = !0
5433
5440
  }) => {
5434
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5435
- u.includes(y) ? u.length > 2 && g(u.filter((A) => A !== y)) : g((A) => [...A, y]);
5436
- }, x = (y) => {
5437
- n || l(y), c(y);
5441
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
5442
+ u.includes(k) ? u.length > 2 && g(u.filter((A) => A !== k)) : g((A) => [...A, k]);
5443
+ }, h = (k) => {
5444
+ n || l(k), c(k);
5438
5445
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
5439
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5446
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
5440
5447
  BreakpointCard,
5441
5448
  {
5442
5449
  canvas: n,
5443
- ...y,
5444
- onClick: x,
5445
- key: y.breakpoint,
5450
+ ...k,
5451
+ onClick: h,
5452
+ key: k.breakpoint,
5446
5453
  currentBreakpoint: b
5447
5454
  }
5448
5455
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5449
5456
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5450
- m.filter((y) => includes(u, toUpper(y.breakpoint))),
5451
- (y) => /* @__PURE__ */ createElement(
5457
+ x.filter((k) => includes(u, toUpper(k.breakpoint))),
5458
+ (k) => /* @__PURE__ */ createElement(
5452
5459
  BreakpointCard,
5453
5460
  {
5454
5461
  canvas: n,
5455
5462
  openDelay: o,
5456
5463
  tooltip: r,
5457
- ...y,
5458
- onClick: x,
5459
- key: y.breakpoint,
5464
+ ...k,
5465
+ onClick: h,
5466
+ key: k.breakpoint,
5460
5467
  currentBreakpoint: b
5461
5468
  }
5462
5469
  )
@@ -5464,17 +5471,17 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5464
5471
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5465
5472
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
5466
5473
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5467
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
5474
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
5468
5475
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5469
- map(m, (y) => /* @__PURE__ */ jsx(
5476
+ map(x, (k) => /* @__PURE__ */ jsx(
5470
5477
  DropdownMenuCheckboxItem,
5471
5478
  {
5472
- disabled: y.breakpoint === "xs",
5473
- onCheckedChange: () => f(toUpper(y.breakpoint)),
5474
- checked: includes(u, toUpper(y.breakpoint)),
5475
- children: h(y.title)
5479
+ disabled: k.breakpoint === "xs",
5480
+ onCheckedChange: () => f(toUpper(k.breakpoint)),
5481
+ checked: includes(u, toUpper(k.breakpoint)),
5482
+ children: m(k.title)
5476
5483
  },
5477
- y.breakpoint
5484
+ k.breakpoint
5478
5485
  ))
5479
5486
  ] })
5480
5487
  ] })
@@ -5551,11 +5558,11 @@ function Countdown() {
5551
5558
  const AskAIStyles = ({ blockId: o }) => {
5552
5559
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5553
5560
  useEffect(() => {
5554
- var m;
5555
- (m = d.current) == null || m.focus();
5561
+ var x;
5562
+ (x = d.current) == null || x.focus();
5556
5563
  }, []);
5557
- const h = (m) => {
5558
- const { usage: f } = m || {};
5564
+ const m = (x) => {
5565
+ const { usage: f } = x || {};
5559
5566
  !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5560
5567
  };
5561
5568
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5565,12 +5572,12 @@ const AskAIStyles = ({ blockId: o }) => {
5565
5572
  {
5566
5573
  ref: d,
5567
5574
  value: i,
5568
- onChange: (m) => c(m.target.value),
5575
+ onChange: (x) => c(x.target.value),
5569
5576
  placeholder: n("Ask AI to edit styles"),
5570
5577
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5571
5578
  rows: 4,
5572
- onKeyDown: (m) => {
5573
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
5579
+ onKeyDown: (x) => {
5580
+ x.key === "Enter" && (x.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5574
5581
  }
5575
5582
  }
5576
5583
  ),
@@ -5580,7 +5587,7 @@ const AskAIStyles = ({ blockId: o }) => {
5580
5587
  {
5581
5588
  disabled: i.trim().length < 5 || a,
5582
5589
  onClick: () => {
5583
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
5590
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
5584
5591
  },
5585
5592
  variant: "default",
5586
5593
  className: "w-fit",
@@ -5612,24 +5619,24 @@ const AskAIStyles = ({ blockId: o }) => {
5612
5619
  };
5613
5620
  function ManualClasses() {
5614
5621
  var T;
5615
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), A = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
5622
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), x = useBuilderProp("askAiCallBack", null), [f, h] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), A = k.split(" ").filter((I) => !isEmpty(I)), B = () => {
5616
5623
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5617
- u(h, I, !0), x("");
5618
- }, [w, _] = useState([]), j = ({ value: I }) => {
5619
- const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5620
- let D = [];
5621
- if (N && N.length > 0) {
5622
- const [M] = N, R = P.replace(M, "");
5623
- D = i.search(R).map(($) => ({
5624
+ u(m, I, !0), h("");
5625
+ }, [C, j] = useState([]), _ = ({ value: I }) => {
5626
+ const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
5627
+ let N = [];
5628
+ if (P && P.length > 0) {
5629
+ const [M] = P, D = R.replace(M, "");
5630
+ N = i.search(D).map(($) => ({
5624
5631
  ...$,
5625
5632
  item: { ...$.item, name: M + $.item.name }
5626
5633
  }));
5627
5634
  } else
5628
- D = i.search(P);
5629
- return _(map(D, "item"));
5635
+ N = i.search(R);
5636
+ return j(map(N, "item"));
5630
5637
  }, S = () => {
5631
- _([]);
5632
- }, C = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5638
+ j([]);
5639
+ }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5633
5640
  () => ({
5634
5641
  ref: o,
5635
5642
  autoComplete: "off",
@@ -5639,17 +5646,17 @@ function ManualClasses() {
5639
5646
  placeholder: c("Enter classes separated by space"),
5640
5647
  value: f,
5641
5648
  onKeyDown: (I) => {
5642
- I.key === "Enter" && f.trim() !== "" && E();
5649
+ I.key === "Enter" && f.trim() !== "" && B();
5643
5650
  },
5644
- onChange: (I, { newValue: P }) => x(P),
5651
+ onChange: (I, { newValue: R }) => h(R),
5645
5652
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5646
5653
  }),
5647
5654
  [f, c, o]
5648
- ), k = (I) => {
5655
+ ), y = (I) => {
5649
5656
  debugger;
5650
- const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5651
- g(h, [I]), u(h, P, !0), r(""), l(-1);
5652
- }, B = () => {
5657
+ const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5658
+ g(m, [I]), u(m, R, !0), r(""), l(-1);
5659
+ }, E = () => {
5653
5660
  if (navigator.clipboard === void 0) {
5654
5661
  toast.error(c("Clipboard not supported"));
5655
5662
  return;
@@ -5661,11 +5668,11 @@ function ManualClasses() {
5661
5668
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5662
5669
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5663
5670
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5664
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: B, className: "cursor-pointer" }) }),
5671
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5665
5672
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5666
5673
  ] })
5667
5674
  ] }),
5668
- m ? /* @__PURE__ */ jsxs(Popover, { children: [
5675
+ x ? /* @__PURE__ */ jsxs(Popover, { children: [
5669
5676
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5670
5677
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5671
5678
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5677,10 +5684,10 @@ function ManualClasses() {
5677
5684
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5678
5685
  Autosuggest,
5679
5686
  {
5680
- suggestions: w,
5681
- onSuggestionsFetchRequested: j,
5687
+ suggestions: C,
5688
+ onSuggestionsFetchRequested: _,
5682
5689
  onSuggestionsClearRequested: S,
5683
- getSuggestionValue: C,
5690
+ getSuggestionValue: w,
5684
5691
  renderSuggestion: L,
5685
5692
  inputProps: v,
5686
5693
  containerProps: {
@@ -5698,7 +5705,7 @@ function ManualClasses() {
5698
5705
  {
5699
5706
  variant: "outline",
5700
5707
  className: "h-6 border-border",
5701
- onClick: E,
5708
+ onClick: B,
5702
5709
  disabled: f.trim() === "",
5703
5710
  size: "sm",
5704
5711
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -5706,17 +5713,17 @@ function ManualClasses() {
5706
5713
  )
5707
5714
  ] }),
5708
5715
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5709
- (I, P) => a === P ? /* @__PURE__ */ jsx(
5716
+ (I, R) => a === R ? /* @__PURE__ */ jsx(
5710
5717
  "input",
5711
5718
  {
5712
5719
  ref: o,
5713
5720
  value: n,
5714
- onChange: (N) => r(N.target.value),
5721
+ onChange: (P) => r(P.target.value),
5715
5722
  onBlur: () => {
5716
- k(I);
5723
+ y(I);
5717
5724
  },
5718
- onKeyDown: (N) => {
5719
- N.key === "Enter" && k(I);
5725
+ onKeyDown: (P) => {
5726
+ P.key === "Enter" && y(I);
5720
5727
  },
5721
5728
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
5722
5729
  },
@@ -5730,7 +5737,7 @@ function ManualClasses() {
5730
5737
  n !== I && /* @__PURE__ */ jsx(
5731
5738
  Cross2Icon,
5732
5739
  {
5733
- onClick: () => g(h, [I], !0),
5740
+ onClick: () => g(m, [I], !0),
5734
5741
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5735
5742
  }
5736
5743
  )
@@ -6076,10 +6083,10 @@ const COLOR_PROP = {
6076
6083
  ringColor: "ring",
6077
6084
  ringOffsetColor: "ring-offset"
6078
6085
  }, ColorChoice = ({ property: o, onChange: n }) => {
6079
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
6086
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), x = useCallback(
6080
6087
  // eslint-disable-next-line no-shadow
6081
6088
  (b) => {
6082
- ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
6089
+ ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
6083
6090
  },
6084
6091
  [c, p]
6085
6092
  );
@@ -6098,18 +6105,18 @@ const COLOR_PROP = {
6098
6105
  useEffect(() => {
6099
6106
  p({ color: "", shade: "" });
6100
6107
  }, [r]);
6101
- const { match: x } = useTailwindClassList();
6108
+ const { match: h } = useTailwindClassList();
6102
6109
  return useEffect(() => {
6103
- const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6104
- x(o, y) && n(y, o);
6105
- }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6110
+ const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6111
+ h(o, k) && n(k, o);
6112
+ }, [h, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6106
6113
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6107
6114
  DropDown,
6108
6115
  {
6109
6116
  disabled: !l,
6110
6117
  rounded: !0,
6111
6118
  selected: g,
6112
- onChange: m,
6119
+ onChange: x,
6113
6120
  options: [
6114
6121
  "current",
6115
6122
  "transparent",
@@ -6142,7 +6149,7 @@ const COLOR_PROP = {
6142
6149
  ]
6143
6150
  }
6144
6151
  ) }),
6145
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
6152
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
6146
6153
  ] });
6147
6154
  }, IconChoices = ({ property: o, onChange: n }) => {
6148
6155
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6339,52 +6346,52 @@ const COLOR_PROP = {
6339
6346
  },
6340
6347
  a
6341
6348
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6342
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [A, E] = useState(!1), [w, _] = useState(!1);
6349
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, x] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, h] = useState(!1), [b, k] = useState(""), [A, B] = useState(!1), [C, j] = useState(!1);
6343
6350
  useEffect(() => {
6344
- const { value: v, unit: k } = getClassValueAndUnit(i);
6345
- if (k === "") {
6346
- l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6351
+ const { value: v, unit: y } = getClassValueAndUnit(i);
6352
+ if (y === "") {
6353
+ l(v), x(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6347
6354
  return;
6348
6355
  }
6349
- m(k), l(k === "class" || isEmpty(v) ? "" : v);
6356
+ x(y), l(y === "class" || isEmpty(v) ? "" : v);
6350
6357
  }, [i, p, u]);
6351
- const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
6358
+ const _ = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
6352
6359
  (v = !1) => {
6353
- const k = getUserInputValues(`${a}`, u);
6354
- if (get(k, "error", !1)) {
6355
- x(!0);
6360
+ const y = getUserInputValues(`${a}`, u);
6361
+ if (get(y, "error", !1)) {
6362
+ h(!0);
6356
6363
  return;
6357
6364
  }
6358
- const B = get(k, "unit") !== "" ? get(k, "unit") : h;
6359
- if (B === "auto" || B === "none") {
6360
- j(`${d}${B}`);
6365
+ const E = get(y, "unit") !== "" ? get(y, "unit") : m;
6366
+ if (E === "auto" || E === "none") {
6367
+ _(`${d}${E}`);
6361
6368
  return;
6362
6369
  }
6363
- if (get(k, "value") === "")
6370
+ if (get(y, "value") === "")
6364
6371
  return;
6365
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6366
- v ? S(I) : j(I);
6372
+ const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6373
+ v ? S(I) : _(I);
6367
6374
  },
6368
- [j, S, a, h, d, u]
6375
+ [_, S, a, m, d, u]
6369
6376
  ), L = useCallback(
6370
6377
  (v) => {
6371
- const k = getUserInputValues(`${a}`, u);
6372
- if (get(k, "error", !1)) {
6373
- x(!0);
6378
+ const y = getUserInputValues(`${a}`, u);
6379
+ if (get(y, "error", !1)) {
6380
+ h(!0);
6374
6381
  return;
6375
6382
  }
6376
6383
  if (v === "auto" || v === "none") {
6377
- j(`${d}${v}`);
6384
+ _(`${d}${v}`);
6378
6385
  return;
6379
6386
  }
6380
- if (get(k, "value") === "")
6387
+ if (get(y, "value") === "")
6381
6388
  return;
6382
- const B = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6383
- j(I);
6389
+ const E = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6390
+ _(I);
6384
6391
  },
6385
- [j, a, d, u]
6392
+ [_, a, d, u]
6386
6393
  );
6387
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6394
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6388
6395
  /* @__PURE__ */ jsx(
6389
6396
  "input",
6390
6397
  {
@@ -6399,33 +6406,33 @@ const COLOR_PROP = {
6399
6406
  ] })
6400
6407
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6401
6408
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6402
- ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
6409
+ ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6403
6410
  "input",
6404
6411
  {
6405
- readOnly: h === "class",
6412
+ readOnly: m === "class",
6406
6413
  onKeyPress: (v) => {
6407
- v.key === "Enter" && C();
6414
+ v.key === "Enter" && w();
6408
6415
  },
6409
6416
  onKeyDown: (v) => {
6410
6417
  if (v.keyCode !== 38 && v.keyCode !== 40)
6411
6418
  return;
6412
- v.preventDefault(), _(!0);
6413
- const k = parseInt$1(v.target.value);
6414
- let B = isNaN$1(k) ? 0 : k;
6415
- v.keyCode === 38 && (B += 1), v.keyCode === 40 && (B -= 1);
6416
- const T = `${B}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
6417
- S(P);
6419
+ v.preventDefault(), j(!0);
6420
+ const y = parseInt$1(v.target.value);
6421
+ let E = isNaN$1(y) ? 0 : y;
6422
+ v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
6423
+ const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6424
+ S(R);
6418
6425
  },
6419
6426
  onKeyUp: (v) => {
6420
- w && (v.preventDefault(), _(!1));
6427
+ C && (v.preventDefault(), j(!1));
6421
6428
  },
6422
- onBlur: () => C(),
6429
+ onBlur: () => w(),
6423
6430
  onChange: (v) => {
6424
- x(!1), l(v.target.value);
6431
+ h(!1), l(v.target.value);
6425
6432
  },
6426
6433
  onClick: (v) => {
6427
- var k;
6428
- (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6434
+ var y;
6435
+ (y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
6429
6436
  },
6430
6437
  value: A ? b : a,
6431
6438
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
@@ -6442,7 +6449,7 @@ const COLOR_PROP = {
6442
6449
  onClick: () => r(!n),
6443
6450
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6444
6451
  children: [
6445
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
6452
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
6446
6453
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6447
6454
  ]
6448
6455
  }
@@ -6451,33 +6458,33 @@ const COLOR_PROP = {
6451
6458
  UnitSelection,
6452
6459
  {
6453
6460
  units: u,
6454
- current: h,
6461
+ current: m,
6455
6462
  onSelect: (v) => {
6456
- r(!1), m(v), L(v);
6463
+ r(!1), x(v), L(v);
6457
6464
  }
6458
6465
  }
6459
6466
  ) }) })
6460
6467
  ] })
6461
6468
  ] }),
6462
- ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
6469
+ ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6463
6470
  DragStyleButton,
6464
6471
  {
6465
- onDragStart: () => E(!0),
6472
+ onDragStart: () => B(!0),
6466
6473
  onDragEnd: (v) => {
6467
- if (y(() => ""), E(!1), isEmpty(v))
6474
+ if (k(() => ""), B(!1), isEmpty(v))
6468
6475
  return;
6469
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6470
- j(T);
6476
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6477
+ _(T);
6471
6478
  },
6472
6479
  onDrag: (v) => {
6473
6480
  if (isEmpty(v))
6474
6481
  return;
6475
- y(v);
6476
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6482
+ k(v);
6483
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6477
6484
  S(T);
6478
6485
  },
6479
6486
  currentValue: a,
6480
- unit: h,
6487
+ unit: m,
6481
6488
  negative: g,
6482
6489
  cssProperty: p
6483
6490
  }
@@ -6571,23 +6578,23 @@ const COLOR_PROP = {
6571
6578
  "2xl": "1536px"
6572
6579
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6573
6580
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6574
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(h, "fullCls", ""), [h]), y = useCallback(
6575
- (S, C = !0) => {
6581
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), x = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
6582
+ (S, w = !0) => {
6576
6583
  const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6577
6584
  (p || u !== "") && (L.mq = "xs");
6578
6585
  const v = generateFullClsName(L);
6579
- m(x, [v], C);
6586
+ x(h, [v], w);
6580
6587
  },
6581
- [x, p, g, u, l, m]
6588
+ [h, p, g, u, l, x]
6582
6589
  ), A = useCallback(() => {
6583
- f(x, [b], !0);
6584
- }, [x, b, f]), E = useMemo(() => canChangeClass(h, g), [h, g]);
6590
+ f(h, [b], !0);
6591
+ }, [h, b, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
6585
6592
  useEffect(() => {
6586
- i(E, h);
6587
- }, [E, i, h]);
6588
- const [, , w] = useScreenSizeWidth(), _ = useCallback(
6593
+ i(B, m);
6594
+ }, [B, i, m]);
6595
+ const [, , C] = useScreenSizeWidth(), j = useCallback(
6589
6596
  (S) => {
6590
- w({
6597
+ C({
6591
6598
  xs: 400,
6592
6599
  sm: 640,
6593
6600
  md: 800,
@@ -6596,29 +6603,29 @@ const COLOR_PROP = {
6596
6603
  "2xl": 1920
6597
6604
  }[S]);
6598
6605
  },
6599
- [w]
6600
- ), j = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6601
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6602
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6606
+ [C]
6607
+ ), _ = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6608
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6609
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !_ ? "text-foreground" : ""}`, children: n(a) }) }),
6603
6610
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6604
6611
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6605
6612
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6606
6613
  AdvanceChoices,
6607
6614
  {
6608
- currentClass: get(h, "cls", ""),
6615
+ currentClass: get(m, "cls", ""),
6609
6616
  classPrefix: get(CLASS_PREFIXES, l, ""),
6610
6617
  units: c || [],
6611
- onChange: y,
6618
+ onChange: k,
6612
6619
  negative: d,
6613
6620
  cssProperty: l
6614
6621
  }
6615
6622
  ) : null,
6616
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6617
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6618
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6619
- r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6623
+ r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: k }),
6624
+ r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: k }),
6625
+ r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
6626
+ r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
6620
6627
  ] }),
6621
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6628
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6622
6629
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6623
6630
  "button",
6624
6631
  {
@@ -6630,19 +6637,19 @@ const COLOR_PROP = {
6630
6637
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6631
6638
  "Current style is set at  ",
6632
6639
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6633
- getBreakpoint(get(h, "mq")),
6634
- p && !h.dark ? "(Light mode)" : ""
6640
+ getBreakpoint(get(m, "mq")),
6641
+ p && !m.dark ? "(Light mode)" : ""
6635
6642
  ] }),
6636
6643
  /* @__PURE__ */ jsx("br", {}),
6637
6644
  /* @__PURE__ */ jsxs(
6638
6645
  "button",
6639
6646
  {
6640
6647
  type: "button",
6641
- onClick: () => _(get(h, "mq")),
6648
+ onClick: () => j(get(m, "mq")),
6642
6649
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6643
6650
  children: [
6644
6651
  "Switch to ",
6645
- get(h, "mq").toUpperCase()
6652
+ get(m, "mq").toUpperCase()
6646
6653
  ]
6647
6654
  }
6648
6655
  )
@@ -6659,7 +6666,7 @@ const COLOR_PROP = {
6659
6666
  units: i = basicUnits,
6660
6667
  negative: c = !1
6661
6668
  }) => {
6662
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
6669
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((x) => map(g, "property").includes(x), [g]);
6663
6670
  return /* @__PURE__ */ jsxs(
6664
6671
  "div",
6665
6672
  {
@@ -6668,7 +6675,7 @@ const COLOR_PROP = {
6668
6675
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6669
6676
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6670
6677
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6671
- n.map(({ label: m, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6678
+ n.map(({ label: x, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6672
6679
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6673
6680
  "button",
6674
6681
  {
@@ -6677,13 +6684,13 @@ const COLOR_PROP = {
6677
6684
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6678
6685
  children: [
6679
6686
  React__default.createElement("div", {
6680
- className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6687
+ className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6681
6688
  }),
6682
6689
  React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6683
6690
  ]
6684
6691
  }
6685
6692
  ) }),
6686
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6693
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(x)) })
6687
6694
  ] }) }))
6688
6695
  ) })
6689
6696
  ] }),
@@ -6822,13 +6829,13 @@ function BlockStyling() {
6822
6829
  cssProperty: ""
6823
6830
  }), d = useThrottledCallback(
6824
6831
  (u) => {
6825
- const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6826
- let m = parseFloat(i.dragStartValue);
6827
- m = isNaN(m) ? 0 : m;
6832
+ const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6833
+ let x = parseFloat(i.dragStartValue);
6834
+ x = isNaN(x) ? 0 : x;
6828
6835
  let f = MAPPER[i.dragUnit];
6829
- (startsWith(h, "scale") || h === "opacity") && (f = 10);
6830
- let b = (i.dragStartY - u.pageY) / f + m;
6831
- g && b < 0 && (b = 0), h === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6836
+ (startsWith(m, "scale") || m === "opacity") && (f = 10);
6837
+ let b = (i.dragStartY - u.pageY) / f + x;
6838
+ g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6832
6839
  },
6833
6840
  [i],
6834
6841
  50
@@ -6864,41 +6871,45 @@ function BlockStyling() {
6864
6871
  ] })
6865
6872
  ] });
6866
6873
  }
6867
- const CoreBlock = ({
6874
+ const CHAI_BUILDER_EVENTS = {
6875
+ OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
6876
+ CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
6877
+ SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
6878
+ }, CoreBlock = ({
6868
6879
  block: o,
6869
6880
  disabled: n,
6870
6881
  parentId: r,
6871
6882
  position: a
6872
6883
  }) => {
6873
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6884
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
6874
6885
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6875
6886
  const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6876
6887
  u(syncBlocksWithDefaults(b), r || null, a);
6877
6888
  } else
6878
6889
  p(o, r || null, a);
6879
6890
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6880
- }, f = useFeature("dnd"), { t: x } = useTranslation();
6891
+ }, f = useFeature("dnd"), { t: h } = useTranslation();
6881
6892
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6882
6893
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6883
6894
  "button",
6884
6895
  {
6885
6896
  disabled: n,
6886
- onClick: m,
6897
+ onClick: x,
6887
6898
  type: "button",
6888
6899
  onDragStart: (b) => {
6889
6900
  b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6890
- g([]), h();
6901
+ g([]), m();
6891
6902
  }, 200);
6892
6903
  },
6893
6904
  draggable: f ? "true" : "false",
6894
6905
  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",
6895
6906
  children: [
6896
6907
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6897
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6908
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(d || i)) })
6898
6909
  ]
6899
6910
  }
6900
6911
  ) }),
6901
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6912
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(d || i) }) })
6902
6913
  ] }) });
6903
6914
  }, DefaultChaiBlocks = ({
6904
6915
  parentId: o,
@@ -7086,22 +7097,22 @@ const CoreBlock = ({
7086
7097
  }
7087
7098
  }
7088
7099
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7089
- var h, m, f, x, b, y, A, E;
7100
+ var m, x, f, h, b, k, A, B;
7090
7101
  if (r.type === "comment") return [];
7091
7102
  console.log("node ===>", r);
7092
7103
  let a = { _id: generateUUID() };
7093
7104
  if (n && (a._parent = n.block._id), r.type === "text")
7094
7105
  return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
7095
7106
  const l = get(r, "attributes", []), i = l.find(
7096
- (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7107
+ (C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
7097
7108
  ), c = l.find(
7098
- (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7109
+ (C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
7099
7110
  ), d = l.find(
7100
- (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7111
+ (C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
7101
7112
  ), p = l.find(
7102
- (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
7113
+ (C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
7103
7114
  ), u = l.find(
7104
- (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
7115
+ (C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
7105
7116
  );
7106
7117
  if (a = {
7107
7118
  ...a,
@@ -7109,13 +7120,13 @@ const CoreBlock = ({
7109
7120
  ...getAttrs(r),
7110
7121
  ...getStyles(r)
7111
7122
  }, r.attributes) {
7112
- const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
7113
- w && (a._name = w.value);
7123
+ const C = r.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
7124
+ C && (a._name = C.value);
7114
7125
  }
7115
7126
  if (i)
7116
7127
  return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
7117
7128
  if (c) {
7118
- const w = [
7129
+ const C = [
7119
7130
  "data-chai-lightbox",
7120
7131
  "chai-lightbox",
7121
7132
  "data-vbtype",
@@ -7127,44 +7138,44 @@ const CoreBlock = ({
7127
7138
  ];
7128
7139
  a = {
7129
7140
  ...a,
7130
- href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
7131
- hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7132
- autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7133
- maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7134
- backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
7135
- galleryName: ((A = l.find((_) => _.key === "data-gall")) == null ? void 0 : A.value) || ""
7136
- }, forEach(w, (_) => {
7137
- has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
7141
+ href: ((m = l.find((j) => j.key === "href")) == null ? void 0 : m.value) || "",
7142
+ hrefType: ((x = l.find((j) => j.key === "data-vbtype")) == null ? void 0 : x.value) || "video",
7143
+ autoplay: ((f = l.find((j) => j.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7144
+ maxWidth: ((b = (h = l.find((j) => j.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : b.replace("px", "")) || "",
7145
+ backdropColor: ((k = l.find((j) => j.key === "data-overlay")) == null ? void 0 : k.value) || "",
7146
+ galleryName: ((A = l.find((j) => j.key === "data-gall")) == null ? void 0 : A.value) || ""
7147
+ }, forEach(C, (j) => {
7148
+ has(a, `styles_attrs.${j}`) && delete a.styles_attrs[j];
7138
7149
  });
7139
7150
  }
7140
7151
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7141
7152
  delete a.styles_attrs;
7142
- const w = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
7143
- a.content = getTextContent(w);
7144
- const _ = find(
7153
+ const C = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
7154
+ a.content = getTextContent(C);
7155
+ const j = find(
7145
7156
  r.children || [],
7146
- (j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
7157
+ (_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
7147
7158
  );
7148
- if (_) {
7149
- const j = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7150
- if (j) {
7151
- a.icon = stringify([j]);
7152
- const { height: S, width: C } = getSvgDimensions(j, "16px", "16px");
7153
- a.iconHeight = S, a.iconWidth = C;
7159
+ if (j) {
7160
+ const _ = find(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7161
+ if (_) {
7162
+ a.icon = stringify([_]);
7163
+ const { height: S, width: w } = getSvgDimensions(_, "16px", "16px");
7164
+ a.iconHeight = S, a.iconWidth = w;
7154
7165
  }
7155
7166
  }
7156
7167
  return [a];
7157
7168
  }
7158
7169
  if (a._type === "Input") {
7159
- const w = a.inputType || "text";
7160
- w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7170
+ const C = a.inputType || "text";
7171
+ C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
7161
7172
  } else if (r.tagName === "video" || r.tagName === "iframe") {
7162
- const w = stringify([r]);
7163
- return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7173
+ const C = stringify([r]);
7174
+ return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
7164
7175
  } else if (r.tagName === "svg") {
7165
- const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), j = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(_, "value") ? `[${get(_, "value")}px]` : "24px", C = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7166
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${j}`, C)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7167
- } else if (r.tagName == "option" && n && ((E = n.block) == null ? void 0 : E._type) === "Select")
7176
+ const C = find(r.attributes, { key: "height" }), j = find(r.attributes, { key: "width" }), _ = get(C, "value") ? `[${get(C, "value")}px]` : "24px", S = get(j, "value") ? `[${get(j, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7177
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7178
+ } else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
7168
7179
  return n.block.options.push({
7169
7180
  label: getTextContent(r.children),
7170
7181
  ...getAttrs(r)
@@ -7237,29 +7248,29 @@ const CoreBlock = ({
7237
7248
  error: c
7238
7249
  }), g(!0);
7239
7250
  else if (!l && Object.keys(a || {}).length > 0) {
7240
- const m = Object.entries(a).map(([x, b]) => {
7241
- const y = b, A = y.type || "partial", E = formatReadableName(A);
7251
+ const x = Object.entries(a).map(([h, b]) => {
7252
+ const k = b, A = k.type || "partial", B = formatReadableName(A);
7242
7253
  return {
7243
7254
  type: "PartialBlock",
7244
7255
  // Set the type to PartialBlock
7245
- label: formatReadableName(y.name || x),
7246
- description: y.description || "",
7256
+ label: formatReadableName(k.name || h),
7257
+ description: k.description || "",
7247
7258
  icon: Globe,
7248
- group: E,
7259
+ group: B,
7249
7260
  // Use formatted type as group
7250
7261
  category: "partial",
7251
- partialBlockId: x,
7262
+ partialBlockId: h,
7252
7263
  // Store the original ID as partialBlockId
7253
- _name: y.name
7264
+ _name: k.name
7254
7265
  };
7255
- }), f = uniq(map(m, "group"));
7266
+ }), f = uniq(map(x, "group"));
7256
7267
  p({
7257
- blocks: m,
7268
+ blocks: x,
7258
7269
  groups: f,
7259
7270
  isLoading: !1,
7260
7271
  error: null
7261
7272
  }), g(!0);
7262
- } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7273
+ } else l ? p((x) => ({ ...x, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7263
7274
  blocks: [],
7264
7275
  groups: [],
7265
7276
  isLoading: !1,
@@ -7274,15 +7285,15 @@ const CoreBlock = ({
7274
7285
  d.blocks,
7275
7286
  c
7276
7287
  ]);
7277
- const h = () => {
7278
- p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7288
+ const m = () => {
7289
+ p((x) => ({ ...x, isLoading: !0, error: null })), g(!1), i();
7279
7290
  };
7280
7291
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7281
7292
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7282
7293
  /* @__PURE__ */ jsx(
7283
7294
  "button",
7284
7295
  {
7285
- onClick: h,
7296
+ onClick: m,
7286
7297
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7287
7298
  children: "Refresh"
7288
7299
  }
@@ -7299,43 +7310,43 @@ const CoreBlock = ({
7299
7310
  );
7300
7311
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7301
7312
  var v;
7302
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7313
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [x, f] = useState("all"), [h, b] = useState(null), k = useRef(null);
7303
7314
  useEffect(() => {
7304
- const k = setTimeout(() => {
7305
- var B;
7306
- (B = u.current) == null || B.focus();
7315
+ const y = setTimeout(() => {
7316
+ var E;
7317
+ (E = u.current) == null || E.focus();
7307
7318
  }, 0);
7308
- return () => clearTimeout(k);
7319
+ return () => clearTimeout(y);
7309
7320
  }, [g]), useEffect(() => {
7310
7321
  d && (f("all"), b(null));
7311
- }, [d]), useEffect(() => (y.current = debounce((k) => {
7312
- f(k);
7322
+ }, [d]), useEffect(() => (k.current = debounce((y) => {
7323
+ f(y);
7313
7324
  }, 500), () => {
7314
- y.current && y.current.cancel();
7325
+ k.current && k.current.cancel();
7315
7326
  }), []);
7316
- const A = useCallback((k) => {
7317
- b(k), y.current && y.current(k);
7318
- }, []), E = useCallback(() => {
7319
- b(null), y.current && y.current.cancel();
7320
- }, []), w = useCallback((k) => {
7321
- y.current && y.current.cancel(), f(k), b(null);
7322
- }, []), _ = useMemo(
7327
+ const A = useCallback((y) => {
7328
+ b(y), k.current && k.current(y);
7329
+ }, []), B = useCallback(() => {
7330
+ b(null), k.current && k.current.cancel();
7331
+ }, []), C = useCallback((y) => {
7332
+ k.current && k.current.cancel(), f(y), b(null);
7333
+ }, []), j = useMemo(
7323
7334
  () => d ? values(n).filter(
7324
- (k) => {
7325
- var B, T;
7326
- return (((B = k.label) == null ? void 0 : B.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7335
+ (y) => {
7336
+ var E, T;
7337
+ return (((E = y.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7327
7338
  }
7328
7339
  ) : n,
7329
7340
  [n, d]
7330
- ), j = useMemo(
7341
+ ), _ = useMemo(
7331
7342
  () => d ? o.filter(
7332
- (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7333
- ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7334
- [n, _, o, d]
7343
+ (y) => reject(filter(values(j), { group: y }), { hidden: !0 }).length > 0
7344
+ ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7345
+ [n, j, o, d]
7335
7346
  ), S = useMemo(
7336
- () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7337
- [j]
7338
- ), C = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), L = useMemo(() => m === "all" ? S : [m], [S, m]);
7347
+ () => sortBy(_, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7348
+ [_]
7349
+ ), w = useMemo(() => x === "all" ? j : filter(values(j), { group: x }), [j, x]), L = useMemo(() => x === "all" ? S : [x], [S, x]);
7339
7350
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7340
7351
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7341
7352
  Input$1,
@@ -7345,7 +7356,7 @@ const CoreBlock = ({
7345
7356
  placeholder: i("Search blocks..."),
7346
7357
  value: d,
7347
7358
  className: "-ml-2",
7348
- onChange: (k) => p(k.target.value)
7359
+ onChange: (y) => p(y.target.value)
7349
7360
  }
7350
7361
  ) }),
7351
7362
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7353,49 +7364,49 @@ const CoreBlock = ({
7353
7364
  /* @__PURE__ */ jsx(
7354
7365
  "button",
7355
7366
  {
7356
- onClick: () => w("all"),
7367
+ onClick: () => C("all"),
7357
7368
  onMouseEnter: () => A("all"),
7358
- onMouseLeave: E,
7359
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7369
+ onMouseLeave: B,
7370
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${x === "all" || h === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7360
7371
  children: i("All")
7361
7372
  },
7362
7373
  "sidebar-all"
7363
7374
  ),
7364
- S.map((k) => /* @__PURE__ */ jsx(
7375
+ S.map((y) => /* @__PURE__ */ jsx(
7365
7376
  "button",
7366
7377
  {
7367
- onClick: () => w(k),
7368
- onMouseEnter: () => A(k),
7369
- onMouseLeave: E,
7370
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7371
- children: capitalize(i(k.toLowerCase()))
7378
+ onClick: () => C(y),
7379
+ onMouseEnter: () => A(y),
7380
+ onMouseLeave: B,
7381
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${x === y || h === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7382
+ children: capitalize(i(y.toLowerCase()))
7372
7383
  },
7373
- `sidebar-${k}`
7384
+ `sidebar-${y}`
7374
7385
  ))
7375
7386
  ] }) }) }),
7376
- /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: j.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7387
+ /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: _.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7377
7388
  i("No blocks found matching"),
7378
7389
  ' "',
7379
7390
  d,
7380
7391
  '"'
7381
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7382
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7392
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7393
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7383
7394
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7384
7395
  reject(
7385
- m === "all" ? filter(values(C), { group: k }) : values(C),
7396
+ x === "all" ? filter(values(w), { group: y }) : values(w),
7386
7397
  { hidden: !0 }
7387
- ).map((B) => /* @__PURE__ */ jsx(
7398
+ ).map((E) => /* @__PURE__ */ jsx(
7388
7399
  CoreBlock,
7389
7400
  {
7390
7401
  parentId: r,
7391
7402
  position: a,
7392
- block: B,
7393
- disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7403
+ block: E,
7404
+ disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
7394
7405
  },
7395
- B.type
7406
+ E.type
7396
7407
  ))
7397
7408
  ) })
7398
- ] }, k)) }) }) })
7409
+ ] }, y)) }) }) })
7399
7410
  ] })
7400
7411
  ] });
7401
7412
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7404,13 +7415,13 @@ const CoreBlock = ({
7404
7415
  parentId: r = void 0,
7405
7416
  position: a = -1
7406
7417
  }) => {
7407
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), h = Object.keys(g || {}).length > 0;
7418
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: x } = usePermissions();
7408
7419
  useEffect(() => {
7409
- i === "partials" && !h && c("library");
7410
- }, [i, h, c]);
7411
- const m = useCallback(() => {
7420
+ i === "partials" && !m && c("library");
7421
+ }, [i, m, c]);
7422
+ const f = useCallback(() => {
7412
7423
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7413
- }, []);
7424
+ }, []), h = p && x(PERMISSIONS.IMPORT_HTML);
7414
7425
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
7415
7426
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
7416
7427
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
@@ -7419,8 +7430,8 @@ const CoreBlock = ({
7419
7430
  /* @__PURE__ */ jsxs(
7420
7431
  Tabs,
7421
7432
  {
7422
- onValueChange: (f) => {
7423
- d(""), c(f);
7433
+ onValueChange: (b) => {
7434
+ d(""), c(b);
7424
7435
  },
7425
7436
  value: i,
7426
7437
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7428,15 +7439,15 @@ const CoreBlock = ({
7428
7439
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7429
7440
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7430
7441
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7431
- h && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7432
- p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7433
- map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
7442
+ m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7443
+ h ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7444
+ map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
7434
7445
  ] }),
7435
7446
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7436
7447
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7437
- h && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7438
- p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7439
- map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: m, parentId: r, position: a }) }))
7448
+ m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7449
+ h ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7450
+ map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
7440
7451
  ]
7441
7452
  }
7442
7453
  )
@@ -7493,9 +7504,9 @@ const BlockCard = ({
7493
7504
  parentId: r = void 0,
7494
7505
  position: a = -1
7495
7506
  }) => {
7496
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (A) => {
7497
- const E = has(A, "styles_attrs.data-page-section");
7498
- return A._type === "Box" && E;
7507
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), h = (A) => {
7508
+ const B = has(A, "styles_attrs.data-page-section");
7509
+ return A._type === "Box" && B;
7499
7510
  }, b = useCallback(
7500
7511
  async (A) => {
7501
7512
  if (A.stopPropagation(), has(o, "component")) {
@@ -7503,8 +7514,8 @@ const BlockCard = ({
7503
7514
  return;
7504
7515
  }
7505
7516
  i(!0);
7506
- const E = await c(n, o);
7507
- isEmpty(E) || p(syncBlocksWithDefaults(E), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7517
+ const B = await c(n, o);
7518
+ isEmpty(B) || p(syncBlocksWithDefaults(B), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7508
7519
  },
7509
7520
  [d, p, o, c, n, r, a]
7510
7521
  );
@@ -7514,20 +7525,20 @@ const BlockCard = ({
7514
7525
  {
7515
7526
  onClick: l ? () => {
7516
7527
  } : b,
7517
- draggable: m ? "true" : "false",
7528
+ draggable: x ? "true" : "false",
7518
7529
  onDragStart: async (A) => {
7519
- const E = await c(n, o);
7520
- let w = r;
7521
- if (x(first(E)) && (w = null), !isEmpty(E)) {
7522
- const _ = { blocks: E, uiLibrary: !0, parent: w };
7523
- if (A.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7524
- const j = new Image();
7525
- j.src = o.preview, j.onload = () => {
7526
- A.dataTransfer.setDragImage(j, 0, 0);
7530
+ const B = await c(n, o);
7531
+ let C = r;
7532
+ if (h(first(B)) && (C = null), !isEmpty(B)) {
7533
+ const j = { blocks: B, uiLibrary: !0, parent: C };
7534
+ if (A.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
7535
+ const _ = new Image();
7536
+ _.src = o.preview, _.onload = () => {
7537
+ A.dataTransfer.setDragImage(_, 0, 0);
7527
7538
  };
7528
7539
  } else
7529
7540
  A.dataTransfer.setDragImage(new Image(), 0, 0);
7530
- f(_), setTimeout(() => {
7541
+ f(j), setTimeout(() => {
7531
7542
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7532
7543
  }, 200);
7533
7544
  }
@@ -7540,11 +7551,11 @@ const BlockCard = ({
7540
7551
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7541
7552
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7542
7553
  ] }),
7543
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: h }) })
7554
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
7544
7555
  ]
7545
7556
  }
7546
7557
  ) }),
7547
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h }) })
7558
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
7548
7559
  ] });
7549
7560
  }, libraryBlocksAtom = atom$1(
7550
7561
  {}
@@ -7559,9 +7570,9 @@ const BlockCard = ({
7559
7570
  })();
7560
7571
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7561
7572
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7562
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [h, m] = useState("Hero"), f = get(g, h, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7563
- x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7564
- x.current && m(w);
7573
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, x] = useState("Hero"), f = get(g, m, []), h = useRef(null), { t: b } = useTranslation(), k = (C) => {
7574
+ h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
7575
+ h.current && x(C);
7565
7576
  }, 300);
7566
7577
  };
7567
7578
  if (u)
@@ -7569,7 +7580,7 @@ const BlockCard = ({
7569
7580
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7570
7581
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7571
7582
  ] });
7572
- const A = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
7583
+ const A = filter(f, (C, j) => j % 2 === 0), B = filter(f, (C, j) => j % 2 === 1);
7573
7584
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
7574
7585
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7575
7586
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
@@ -7577,22 +7588,22 @@ const BlockCard = ({
7577
7588
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7578
7589
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7579
7590
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7580
- map(g, (w, _) => /* @__PURE__ */ jsxs(
7591
+ map(g, (C, j) => /* @__PURE__ */ jsxs(
7581
7592
  "div",
7582
7593
  {
7583
- onMouseEnter: () => y(_),
7584
- onMouseLeave: () => clearTimeout(x.current),
7585
- onClick: () => m(_),
7594
+ onMouseEnter: () => k(j),
7595
+ onMouseLeave: () => clearTimeout(h.current),
7596
+ onClick: () => x(j),
7586
7597
  className: cn$1(
7587
7598
  "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",
7588
- _ === h ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7599
+ j === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7589
7600
  ),
7590
7601
  children: [
7591
- /* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
7602
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(j.toLowerCase())) }),
7592
7603
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7593
7604
  ]
7594
7605
  },
7595
- _
7606
+ j
7596
7607
  ))
7597
7608
  ) })
7598
7609
  ] })
@@ -7600,15 +7611,15 @@ const BlockCard = ({
7600
7611
  /* @__PURE__ */ jsxs(
7601
7612
  ScrollArea,
7602
7613
  {
7603
- onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7614
+ onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
7604
7615
  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",
7605
7616
  children: [
7606
7617
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7607
7618
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7608
- A.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7619
+ A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7609
7620
  ) }),
7610
7621
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7611
- E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7622
+ B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7612
7623
  ) })
7613
7624
  ] }),
7614
7625
  /* @__PURE__ */ jsx("br", {}),
@@ -7618,7 +7629,18 @@ const BlockCard = ({
7618
7629
  }
7619
7630
  )
7620
7631
  ] }) }) });
7621
- }, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
7632
+ }, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PERMISSIONS = {
7633
+ ADD_BLOCK: "add_block",
7634
+ DELETE_BLOCK: "delete_block",
7635
+ EDIT_BLOCK: "edit_block",
7636
+ MOVE_BLOCK: "move_block",
7637
+ EDIT_THEME: "edit_theme",
7638
+ SAVE_PAGE: "save_page",
7639
+ EDIT_STYLES: "edit_styles",
7640
+ IMPORT_HTML: "import_html"
7641
+ };
7642
+ Object.values(PERMISSIONS);
7643
+ const PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
7622
7644
  const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
7623
7645
  return useEffect(() => {
7624
7646
  a("root") || n(null);
@@ -7703,11 +7725,11 @@ const BlockCard = ({
7703
7725
  );
7704
7726
  }, RenameBlock = ({ node: o }) => {
7705
7727
  const { t: n } = useTranslation();
7706
- return console.log(o), /* @__PURE__ */ jsxs(
7728
+ return /* @__PURE__ */ jsxs(
7707
7729
  DropdownMenuItem,
7708
7730
  {
7709
7731
  onClick: (r) => {
7710
- r.stopPropagation(), console.log(o), o.edit(), o.deselect();
7732
+ r.stopPropagation(), o.edit(), o.deselect();
7711
7733
  },
7712
7734
  className: "flex items-center gap-x-4 text-xs",
7713
7735
  children: [
@@ -7718,40 +7740,43 @@ const BlockCard = ({
7718
7740
  }
7719
7741
  );
7720
7742
  }, BlockContextMenuContent = ({ node: o }) => {
7721
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useCallback(() => {
7743
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useBuilderProp("blockMoreOptions", []), d = useCallback(() => {
7722
7744
  a(r);
7723
7745
  }, [r, a]);
7724
7746
  return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
7725
- /* @__PURE__ */ jsxs(
7726
- DropdownMenuItem,
7727
- {
7728
- disabled: !canAddChildBlock(l == null ? void 0 : l._type),
7729
- className: "flex items-center gap-x-4 text-xs",
7730
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
7731
- children: [
7732
- /* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
7733
- " ",
7734
- n("Add block")
7735
- ]
7736
- }
7737
- ),
7738
- /* @__PURE__ */ jsxs(
7739
- DropdownMenuItem,
7740
- {
7741
- disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7742
- className: "flex items-center gap-x-4 text-xs",
7743
- onClick: i,
7744
- children: [
7745
- /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7746
- " ",
7747
- n("Duplicate")
7748
- ]
7749
- }
7750
- ),
7747
+ i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
7748
+ /* @__PURE__ */ jsxs(
7749
+ DropdownMenuItem,
7750
+ {
7751
+ disabled: !canAddChildBlock(l == null ? void 0 : l._type),
7752
+ className: "flex items-center gap-x-4 text-xs",
7753
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
7754
+ children: [
7755
+ /* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
7756
+ " ",
7757
+ n("Add block")
7758
+ ]
7759
+ }
7760
+ ),
7761
+ /* @__PURE__ */ jsxs(
7762
+ DropdownMenuItem,
7763
+ {
7764
+ disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7765
+ className: "flex items-center gap-x-4 text-xs",
7766
+ onClick: d,
7767
+ children: [
7768
+ /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7769
+ " ",
7770
+ n("Duplicate")
7771
+ ]
7772
+ }
7773
+ )
7774
+ ] }),
7751
7775
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
7752
- /* @__PURE__ */ jsx(CutBlocks, {}),
7753
- /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7754
- /* @__PURE__ */ jsx(RemoveBlocks, {})
7776
+ i(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
7777
+ i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7778
+ i(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {}),
7779
+ c.map((p, u) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(p, { block: l }) }, `more-${u}`))
7755
7780
  ] });
7756
7781
  }, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
7757
7782
  const [, a] = useSelectedBlockIds();
@@ -7836,52 +7861,53 @@ const selectParent = (o, n) => {
7836
7861
  r.isInternal && n && r.close();
7837
7862
  }, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7838
7863
  var P;
7839
- const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7840
- let p = null;
7841
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: A, handleClick: E } = o, w = (N) => {
7842
- N.stopPropagation(), !i.includes(m) && o.toggle();
7864
+ const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
7865
+ let u = null;
7866
+ const g = o.children.length > 0, { highlightBlock: m, clearHighlight: x } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: k, isDragging: A, isEditing: B, handleClick: C } = o, j = (N) => {
7867
+ N.stopPropagation(), !i.includes(f) && o.toggle();
7843
7868
  }, _ = (N) => {
7844
- N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7845
- }, j = (N) => {
7846
- N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7847
- }, [S, C] = useAtom$1(currentAddSelection), L = () => {
7869
+ N.isInternal && (u = N.isOpen, N.isOpen && N.close());
7870
+ }, S = (N) => {
7871
+ N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
7872
+ }, [w, L] = useAtom$1(currentAddSelection), v = () => {
7848
7873
  var N;
7849
- v(), o.parent.isSelected || C((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7850
- }, v = () => {
7851
- C(null);
7852
- }, k = (N) => {
7853
- v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), E(N);
7874
+ y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7875
+ }, y = () => {
7876
+ L(null);
7877
+ }, E = (N) => {
7878
+ y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), C(N);
7854
7879
  };
7855
7880
  useEffect(() => {
7856
7881
  const N = setTimeout(() => {
7857
- b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7882
+ k && !o.isOpen && !A && !i.includes(f) && o.toggle();
7858
7883
  }, 500);
7859
7884
  return () => clearTimeout(N);
7860
- }, [b, o, y]);
7861
- const B = useMemo(() => {
7862
- const N = Object.keys(f), D = [];
7863
- for (let M = 0; M < N.length; M++)
7864
- if (N[M].endsWith("_attrs")) {
7865
- const R = f[N[M]], O = Object.keys(R).join("|");
7866
- O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7885
+ }, [k, o, A]);
7886
+ const T = useMemo(() => {
7887
+ const N = Object.keys(h), M = [];
7888
+ for (let D = 0; D < N.length; D++)
7889
+ if (N[D].endsWith("_attrs")) {
7890
+ const O = h[N[D]], $ = Object.keys(O).join("|");
7891
+ $.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
7867
7892
  }
7868
- return D;
7869
- }, [f]), T = (N, D) => {
7870
- const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${N}]`);
7871
- R && R.setAttribute("data-drop", D);
7872
- const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7873
- O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7874
- }, I = (N) => {
7875
- v();
7876
- const D = get(o, "parent.id");
7877
- D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7893
+ return M;
7894
+ }, [h]), I = (N, M) => {
7895
+ const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
7896
+ O && O.setAttribute("data-drop", M);
7897
+ const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
7898
+ $.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
7899
+ }, R = (N) => {
7900
+ y();
7901
+ const M = get(o, "parent.id");
7902
+ M !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: M, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7878
7903
  };
7879
- return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7904
+ return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7880
7905
  /* @__PURE__ */ jsx("br", {}),
7881
- /* @__PURE__ */ jsx(
7906
+ p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7882
7907
  "div",
7883
7908
  {
7884
- onClick: () => I(-1),
7909
+ role: "button",
7910
+ onClick: () => R(-1),
7885
7911
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
7886
7912
  children: /* @__PURE__ */ 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: [
7887
7913
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -7894,32 +7920,32 @@ const selectParent = (o, n) => {
7894
7920
  ] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7895
7921
  "div",
7896
7922
  {
7897
- onMouseEnter: () => g(m),
7898
- onMouseLeave: () => h(),
7899
- onClick: k,
7923
+ onMouseEnter: () => m(f),
7924
+ onMouseLeave: () => x(),
7925
+ onClick: E,
7900
7926
  style: n,
7901
- "data-node-id": m,
7902
- ref: i.includes(m) ? null : r,
7927
+ "data-node-id": f,
7928
+ ref: i.includes(f) ? null : r,
7903
7929
  onDragStart: () => _(o),
7904
- onDragEnd: () => j(o),
7930
+ onDragEnd: () => S(o),
7905
7931
  onDragOver: (N) => {
7906
- N.preventDefault(), T(m, "yes");
7932
+ N.preventDefault(), I(f, "yes");
7907
7933
  },
7908
7934
  onDragLeave: (N) => {
7909
- N.preventDefault(), T(m, "no");
7935
+ N.preventDefault(), I(f, "no");
7910
7936
  },
7911
7937
  onDrop: (N) => {
7912
- N.preventDefault(), T(m, "no");
7938
+ N.preventDefault(), I(f, "no");
7913
7939
  },
7914
7940
  children: [
7915
- (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7941
+ p(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7916
7942
  "div",
7917
7943
  {
7918
7944
  onClick: (N) => {
7919
- N.stopPropagation(), I(o.childIndex);
7945
+ N.stopPropagation(), R(o.childIndex);
7920
7946
  },
7921
- onMouseEnter: L,
7922
- onMouseLeave: v,
7947
+ onMouseEnter: v,
7948
+ onMouseLeave: y,
7923
7949
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7924
7950
  children: /* @__PURE__ */ 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__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
7925
7951
  }
@@ -7929,11 +7955,11 @@ const selectParent = (o, n) => {
7929
7955
  {
7930
7956
  className: cn$1(
7931
7957
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7932
- x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7933
- b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7934
- (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7935
- y && "opacity-20",
7936
- i.includes(m) ? "opacity-50" : ""
7958
+ b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7959
+ k && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7960
+ (o == null ? void 0 : o.id) === w ? "bg-purple-100" : "",
7961
+ A && "opacity-20",
7962
+ i.includes(f) ? "opacity-50" : ""
7937
7963
  ),
7938
7964
  children: [
7939
7965
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7941,12 +7967,12 @@ const selectParent = (o, n) => {
7941
7967
  "div",
7942
7968
  {
7943
7969
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7944
- children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}` }) })
7970
+ children: g && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
7945
7971
  }
7946
7972
  ),
7947
7973
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7948
- /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7949
- A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7974
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7975
+ B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7950
7976
  "div",
7951
7977
  {
7952
7978
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -7954,32 +7980,32 @@ const selectParent = (o, n) => {
7954
7980
  N.stopPropagation(), o.edit(), o.deselect();
7955
7981
  },
7956
7982
  children: [
7957
- /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
7958
- B.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
7959
- B.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
7960
- B.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
7983
+ /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7984
+ T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
7985
+ T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
7986
+ T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
7961
7987
  ]
7962
7988
  }
7963
7989
  )
7964
7990
  ] })
7965
7991
  ] }),
7966
7992
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7967
- !i.includes(m) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7993
+ !i.includes(f) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7968
7994
  /* @__PURE__ */ jsx(
7969
7995
  TooltipTrigger,
7970
7996
  {
7971
7997
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
7972
7998
  asChild: !0,
7973
- children: React__default.createElement(N.item, { blockId: m })
7999
+ children: React__default.createElement(N.item, { blockId: f })
7974
8000
  }
7975
8001
  ),
7976
8002
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
7977
8003
  ] })),
7978
- canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8004
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7979
8005
  /* @__PURE__ */ jsx(
7980
8006
  TooltipTrigger,
7981
8007
  {
7982
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
8008
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
7983
8009
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7984
8010
  asChild: !0,
7985
8011
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -7992,7 +8018,7 @@ const selectParent = (o, n) => {
7992
8018
  TooltipTrigger,
7993
8019
  {
7994
8020
  onClick: (N) => {
7995
- N.stopPropagation(), c(m), o.isOpen && o.toggle();
8021
+ N.stopPropagation(), c(f), o.isOpen && o.toggle();
7996
8022
  },
7997
8023
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7998
8024
  asChild: !0,
@@ -8001,7 +8027,7 @@ const selectParent = (o, n) => {
8001
8027
  ),
8002
8028
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
8003
8029
  ] }),
8004
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8030
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: f, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8005
8031
  ] })
8006
8032
  ]
8007
8033
  }
@@ -8098,21 +8124,32 @@ const selectParent = (o, n) => {
8098
8124
  break;
8099
8125
  }
8100
8126
  };
8101
- return useEffect(() => {
8127
+ useEffect(() => {
8102
8128
  const o = () => {
8103
8129
  treeRef.current && setTreeRef(treeRef.current);
8104
8130
  };
8105
8131
  o();
8106
8132
  const n = new MutationObserver(o);
8107
8133
  return n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
8108
- }, [setTreeRef]), isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
8134
+ }, [setTreeRef]);
8135
+ const { hasPermission } = usePermissions();
8136
+ return isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
8109
8137
  t("This page is empty"),
8110
8138
  /* @__PURE__ */ jsx("br", {}),
8111
8139
  /* @__PURE__ */ jsx("br", {}),
8112
- /* @__PURE__ */ jsxs(Button, { onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK), variant: "default", size: "sm", children: [
8113
- "+ ",
8114
- t("Add Block")
8115
- ] })
8140
+ hasPermission(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(
8141
+ Button,
8142
+ {
8143
+ disabled: !hasPermission(PERMISSIONS.ADD_BLOCK),
8144
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
8145
+ variant: "default",
8146
+ size: "sm",
8147
+ children: [
8148
+ "+ ",
8149
+ t("Add Block")
8150
+ ]
8151
+ }
8152
+ )
8116
8153
  ] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
8117
8154
  /* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
8118
8155
  "div",
@@ -8650,14 +8687,14 @@ function QuickPrompts({ onClick: o }) {
8650
8687
  ) }) });
8651
8688
  }
8652
8689
  const AIUserPrompt = ({ blockId: o }) => {
8653
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8690
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), x = useRef(null);
8654
8691
  useEffect(() => {
8655
- var x;
8656
- (x = h.current) == null || x.focus();
8692
+ var h;
8693
+ (h = m.current) == null || h.focus();
8657
8694
  }, []);
8658
- const f = (x) => {
8659
- const { usage: b } = x || {};
8660
- !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8695
+ const f = (h) => {
8696
+ const { usage: b } = h || {};
8697
+ !l && b && g(b), x.current = setTimeout(() => g(void 0), 1e4), l || c("");
8661
8698
  };
8662
8699
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8663
8700
  /* @__PURE__ */ jsxs(
@@ -8675,14 +8712,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8675
8712
  /* @__PURE__ */ jsx(
8676
8713
  Textarea,
8677
8714
  {
8678
- ref: h,
8715
+ ref: m,
8679
8716
  value: i,
8680
- onChange: (x) => c(x.target.value),
8717
+ onChange: (h) => c(h.target.value),
8681
8718
  placeholder: n("Ask AI to edit content"),
8682
8719
  className: "w-full",
8683
8720
  rows: 3,
8684
- onKeyDown: (x) => {
8685
- x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f));
8721
+ onKeyDown: (h) => {
8722
+ h.key === "Enter" && (h.preventDefault(), x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f));
8686
8723
  }
8687
8724
  }
8688
8725
  ),
@@ -8692,7 +8729,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8692
8729
  {
8693
8730
  disabled: i.trim().length < 5 || a,
8694
8731
  onClick: () => {
8695
- m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f);
8732
+ x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f);
8696
8733
  },
8697
8734
  variant: "default",
8698
8735
  className: "w-fit",
@@ -8724,8 +8761,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8724
8761
  /* @__PURE__ */ jsx(
8725
8762
  QuickPrompts,
8726
8763
  {
8727
- onClick: (x) => {
8728
- m.current && clearTimeout(m.current), g(void 0), r("content", o, x, f);
8764
+ onClick: (h) => {
8765
+ x.current && clearTimeout(x.current), g(void 0), r("content", o, h, f);
8729
8766
  }
8730
8767
  }
8731
8768
  )
@@ -8735,13 +8772,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8735
8772
  ] }) }) : null
8736
8773
  ] });
8737
8774
  }, AISetContext = () => {
8738
- const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8775
+ const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
8739
8776
  useEffect(() => {
8740
8777
  n && a(n);
8741
8778
  }, [n]);
8742
- const m = async () => {
8779
+ const x = async () => {
8743
8780
  try {
8744
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
8781
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8745
8782
  } catch (f) {
8746
8783
  u(f);
8747
8784
  } finally {
@@ -8757,7 +8794,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8757
8794
  type: "single",
8758
8795
  collapsible: !0,
8759
8796
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8760
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8797
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8761
8798
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8762
8799
  /* @__PURE__ */ jsx(
8763
8800
  Textarea,
@@ -8769,7 +8806,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8769
8806
  className: "mt-1 w-full",
8770
8807
  rows: 10,
8771
8808
  onKeyDown: (f) => {
8772
- f.key === "Enter" && (f.preventDefault(), m());
8809
+ f.key === "Enter" && (f.preventDefault(), x());
8773
8810
  }
8774
8811
  }
8775
8812
  ),
@@ -8781,7 +8818,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8781
8818
  Button,
8782
8819
  {
8783
8820
  disabled: r.trim().length < 5,
8784
- onClick: () => m(),
8821
+ onClick: () => x(),
8785
8822
  variant: "default",
8786
8823
  className: "w-fit",
8787
8824
  size: "sm",
@@ -8810,7 +8847,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8810
8847
  AlertDialogAction,
8811
8848
  {
8812
8849
  onClick: () => {
8813
- a(""), m();
8850
+ a(""), x();
8814
8851
  },
8815
8852
  children: o("Yes, Delete")
8816
8853
  }
@@ -8891,8 +8928,8 @@ function usePubSub(o, n) {
8891
8928
  }, [o, n]);
8892
8929
  }
8893
8930
  const AiAssistant = () => {
8894
- const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation();
8895
- return r ? /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
8931
+ const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
8932
+ return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
8896
8933
  /* @__PURE__ */ jsxs(Label, { htmlFor: "ai-assistant", className: "flex items-center gap-x-1 text-sm text-yellow-600", children: [
8897
8934
  /* @__PURE__ */ jsx(SparklesIcon, { className: "w-4" }),
8898
8935
  a("AI Assistant")
@@ -8902,13 +8939,13 @@ const AiAssistant = () => {
8902
8939
  {
8903
8940
  className: "scale-90",
8904
8941
  checked: n === "ai",
8905
- onCheckedChange: (l) => {
8906
- o(l);
8942
+ onCheckedChange: (i) => {
8943
+ o(i);
8907
8944
  },
8908
8945
  id: "ai-assistant"
8909
8946
  }
8910
8947
  )
8911
- ] }) : null;
8948
+ ] });
8912
8949
  }, ClearCanvas = () => {
8913
8950
  const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
8914
8951
  n([]), r([]), a([]);
@@ -8967,54 +9004,54 @@ const AiAssistant = () => {
8967
9004
  preloadedAttributes: n = [],
8968
9005
  onAttributesChange: r
8969
9006
  }) {
8970
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
9007
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, x] = useState(""), f = useRef(null), h = useRef(null), b = usePageExternalData();
8971
9008
  useEffect(() => {
8972
9009
  l(n);
8973
9010
  }, [n]);
8974
- const y = () => {
9011
+ const k = () => {
8975
9012
  if (i.startsWith("@")) {
8976
- m("Attribute keys cannot start with '@'");
9013
+ x("Attribute keys cannot start with '@'");
8977
9014
  return;
8978
9015
  }
8979
9016
  if (i) {
8980
9017
  const S = [...a, { key: i, value: d }];
8981
- r(S), l(a), c(""), p(""), m("");
9018
+ r(S), l(a), c(""), p(""), x("");
8982
9019
  }
8983
9020
  }, A = (S) => {
8984
- const C = a.filter((L, v) => v !== S);
8985
- r(C), l(C);
8986
- }, E = (S) => {
9021
+ const w = a.filter((L, v) => v !== S);
9022
+ r(w), l(w);
9023
+ }, B = (S) => {
8987
9024
  g(S), c(a[S].key), p(a[S].value);
8988
- }, w = () => {
9025
+ }, C = () => {
8989
9026
  if (i.startsWith("@")) {
8990
- m("Attribute keys cannot start with '@'");
9027
+ x("Attribute keys cannot start with '@'");
8991
9028
  return;
8992
9029
  }
8993
9030
  if (u !== null && i) {
8994
9031
  const S = [...a];
8995
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
9032
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), x("");
8996
9033
  }
8997
- }, _ = (S) => {
8998
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
8999
- }, j = useCallback((S) => {
9000
- const C = (k) => /[.,!?;:]/.test(k), L = (k, B, T) => {
9001
- let I = "", P = "";
9002
- const N = B > 0 ? k[B - 1] : "", D = B < k.length ? k[B] : "";
9003
- return B > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), B < k.length && !C(D) && D !== " " && (P = " "), {
9004
- text: I + T + P,
9034
+ }, j = (S) => {
9035
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? C() : k());
9036
+ }, _ = useCallback((S) => {
9037
+ const w = (y) => /[.,!?;:]/.test(y), L = (y, E, T) => {
9038
+ let I = "", R = "";
9039
+ const P = E > 0 ? y[E - 1] : "", N = E < y.length ? y[E] : "";
9040
+ return E > 0 && (P === "." || !w(P) && P !== " ") && (I = " "), E < y.length && !w(N) && N !== " " && (R = " "), {
9041
+ text: I + T + R,
9005
9042
  prefixLength: I.length,
9006
- suffixLength: P.length
9043
+ suffixLength: R.length
9007
9044
  };
9008
- }, v = x.current;
9045
+ }, v = h.current;
9009
9046
  if (v) {
9010
- const k = v.selectionStart || 0, B = v.value || "", T = v.selectionEnd || k;
9011
- if (T > k) {
9012
- const M = `{{${S}}}`, { text: R } = L(B, k, M), O = B.slice(0, k) + R + B.slice(T);
9047
+ const y = v.selectionStart || 0, E = v.value || "", T = v.selectionEnd || y;
9048
+ if (T > y) {
9049
+ const M = `{{${S}}}`, { text: D } = L(E, y, M), O = E.slice(0, y) + D + E.slice(T);
9013
9050
  p(O);
9014
9051
  return;
9015
9052
  }
9016
- const P = `{{${S}}}`, { text: N } = L(B, k, P), D = B.slice(0, k) + N + B.slice(k);
9017
- p(D);
9053
+ const R = `{{${S}}}`, { text: P } = L(E, y, R), N = E.slice(0, y) + P + E.slice(y);
9054
+ p(N);
9018
9055
  }
9019
9056
  }, []);
9020
9057
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -9022,7 +9059,7 @@ const AiAssistant = () => {
9022
9059
  "form",
9023
9060
  {
9024
9061
  onSubmit: (S) => {
9025
- S.preventDefault(), u !== null ? w() : y();
9062
+ S.preventDefault(), u !== null ? C() : k();
9026
9063
  },
9027
9064
  className: "space-y-3",
9028
9065
  children: [
@@ -9047,7 +9084,7 @@ const AiAssistant = () => {
9047
9084
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9048
9085
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9049
9086
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9050
- !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
9087
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
9051
9088
  ] }),
9052
9089
  /* @__PURE__ */ jsx(
9053
9090
  Textarea,
@@ -9057,10 +9094,10 @@ const AiAssistant = () => {
9057
9094
  spellCheck: "false",
9058
9095
  id: "attrValue",
9059
9096
  rows: 2,
9060
- ref: x,
9097
+ ref: h,
9061
9098
  value: d,
9062
9099
  onChange: (S) => p(S.target.value),
9063
- onKeyDown: _,
9100
+ onKeyDown: j,
9064
9101
  placeholder: "Enter Value",
9065
9102
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9066
9103
  }
@@ -9068,20 +9105,20 @@ const AiAssistant = () => {
9068
9105
  ] })
9069
9106
  ] }),
9070
9107
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9071
- h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
9108
+ m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9072
9109
  ]
9073
9110
  }
9074
9111
  ),
9075
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, C) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9112
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9076
9113
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9077
9114
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9078
9115
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9079
9116
  ] }),
9080
9117
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9081
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9082
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9118
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9119
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(w), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9083
9120
  ] })
9084
- ] }, C)) })
9121
+ ] }, w)) })
9085
9122
  ] });
9086
9123
  }), BlockAttributesEditor = React.memo(() => {
9087
9124
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9118,10 +9155,26 @@ function BlockAttributesToggle() {
9118
9155
  ] });
9119
9156
  }
9120
9157
  const SettingsPanel = () => {
9121
- const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop);
9122
- return isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9158
+ const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop), { hasPermission: a } = usePermissions();
9159
+ let l = !a(PERMISSIONS.EDIT_BLOCK);
9160
+ const i = !a(PERMISSIONS.EDIT_STYLES), c = a("!" + PERMISSIONS.EDIT_BLOCK + "_" + (o == null ? void 0 : o._type));
9161
+ return l = l || c, isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9123
9162
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9124
9163
  /* @__PURE__ */ jsx("h1", { children: n("Please select a block to edit settings or styles") })
9164
+ ] }) }) : l && i ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9165
+ /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9166
+ /* @__PURE__ */ jsx("h1", { children: n("You don't have permission to edit settings or styles") }),
9167
+ /* @__PURE__ */ jsx("p", { children: n("Please contact your administrator to get access") })
9168
+ ] }) }) : i ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto", children: [
9169
+ /* @__PURE__ */ jsx(BlockSettings, {}),
9170
+ /* @__PURE__ */ jsx("br", {}),
9171
+ /* @__PURE__ */ jsx("br", {})
9172
+ ] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
9173
+ /* @__PURE__ */ jsx(BlockStyling, {}),
9174
+ /* @__PURE__ */ jsx(BlockAttributesToggle, {}),
9175
+ /* @__PURE__ */ jsx("br", {}),
9176
+ /* @__PURE__ */ jsx("br", {}),
9177
+ /* @__PURE__ */ jsx("br", {})
9125
9178
  ] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
9126
9179
  /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9127
9180
  /* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
@@ -9275,11 +9328,11 @@ const RootLayout = () => {
9275
9328
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9276
9329
  n(1);
9277
9330
  });
9278
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9279
- x.preventDefault();
9280
- }, u = (x) => {
9281
- n(o === x ? null : x);
9282
- }, g = useSidebarMenuItems(), { t: h } = useTranslation(), m = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9331
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (h) => {
9332
+ h.preventDefault();
9333
+ }, u = (h) => {
9334
+ n(o === h ? null : h);
9335
+ }, g = useSidebarMenuItems(), { t: m } = useTranslation(), x = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9283
9336
  return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9284
9337
  /* @__PURE__ */ jsxs(
9285
9338
  "div",
@@ -9290,21 +9343,21 @@ const RootLayout = () => {
9290
9343
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9291
9344
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9292
9345
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9293
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9346
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: x.map((h, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9294
9347
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9295
9348
  Button,
9296
9349
  {
9297
9350
  variant: o === b ? "default" : "ghost",
9298
9351
  className: "mb-2 rounded-lg p-2 transition-colors",
9299
9352
  onClick: () => u(b),
9300
- children: get(x, "icon", null)
9353
+ children: get(h, "icon", null)
9301
9354
  },
9302
9355
  b
9303
9356
  ) }),
9304
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(x.label) }) })
9357
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
9305
9358
  ] }, "button" + b)) }),
9306
9359
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9307
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
9360
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((h, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(h, {}) }, `sidebar-component-${b}`)) })
9308
9361
  ] }),
9309
9362
  /* @__PURE__ */ jsx(
9310
9363
  motion.div,
@@ -9317,14 +9370,14 @@ const RootLayout = () => {
9317
9370
  /* @__PURE__ */ jsxs(
9318
9371
  "div",
9319
9372
  {
9320
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(m, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9373
+ className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9321
9374
  children: [
9322
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
9323
- /* @__PURE__ */ jsx("span", { children: h(m[o].label) })
9375
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, `${o}.icon`, null) }),
9376
+ /* @__PURE__ */ jsx("span", { children: m(x[o].label) })
9324
9377
  ]
9325
9378
  }
9326
9379
  ),
9327
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
9380
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(x, `${o}.component`, null), {}) }) })
9328
9381
  ] })
9329
9382
  }
9330
9383
  ),
@@ -9343,11 +9396,11 @@ const RootLayout = () => {
9343
9396
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9344
9397
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9345
9398
  " ",
9346
- h("AI Assistant")
9399
+ m("AI Assistant")
9347
9400
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9348
9401
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9349
9402
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9350
- h("Theme Settings")
9403
+ m("Theme Settings")
9351
9404
  ] }),
9352
9405
  /* @__PURE__ */ jsx(
9353
9406
  Button,
@@ -9462,6 +9515,7 @@ export {
9462
9515
  DefaultChaiBlocks,
9463
9516
  ImportHTML,
9464
9517
  ListTree as Outline,
9518
+ PERMISSIONS,
9465
9519
  Breakpoints$1 as ScreenSizes,
9466
9520
  ThemeConfigPanel as ThemeOptions,
9467
9521
  UILibrariesPanel as UILibraries,
@@ -9469,9 +9523,9 @@ export {
9469
9523
  generateUUID as generateBlockId,
9470
9524
  getBlocksFromHTML,
9471
9525
  getClassValueAndUnit,
9472
- ze as i18n,
9526
+ We as i18n,
9473
9527
  cn$1 as mergeClasses,
9474
- Ue as registerChaiBlock,
9528
+ Fe as registerChaiBlock,
9475
9529
  useAddBlock,
9476
9530
  useAddClassesToBlocks,
9477
9531
  useAskAi,
@@ -9497,6 +9551,7 @@ export {
9497
9551
  usePartailBlocksStore,
9498
9552
  usePartialBlocksList,
9499
9553
  usePasteBlocks,
9554
+ usePermissions,
9500
9555
  usePreviewMode,
9501
9556
  useRemoveBlocks,
9502
9557
  useRemoveClassesFromBlocks,
@@ -9514,7 +9569,7 @@ export {
9514
9569
  useStylingState,
9515
9570
  useTheme,
9516
9571
  useThemeOptions,
9517
- He as useTranslation,
9572
+ Ve as useTranslation,
9518
9573
  useUILibraryBlocks,
9519
9574
  useUndoManager,
9520
9575
  useUpdateBlocksProps,