@chaibuilder/sdk 2.0.2 → 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,12 +1,12 @@
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
12
  import { useTranslation as Ve } from "react-i18next";
@@ -94,197 +94,197 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
94
94
  for (const i of n.p)
95
95
  l.add(i);
96
96
  return l;
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 = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
98
- var x;
99
- return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
100
- }, g = (h, f) => {
101
- var x;
102
- return (x = h.onMount) == null ? void 0 : x.call(h, f);
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
103
  }, ...m) => {
104
- const h = m[0] || ((C) => {
105
- let L = o.get(C);
106
- return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
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
107
  }), f = m[1] || (() => {
108
- let C, L;
109
- const v = (k) => {
108
+ let w, L;
109
+ const v = (y) => {
110
110
  try {
111
- k();
112
- } catch (A) {
113
- C || (C = !0, L = A);
111
+ y();
112
+ } catch (E) {
113
+ w || (w = !0, L = E);
114
114
  }
115
115
  };
116
116
  do {
117
117
  c.f && v(c.f);
118
- const k = /* @__PURE__ */ new Set(), A = k.add.bind(k);
118
+ const y = /* @__PURE__ */ new Set(), E = y.add.bind(y);
119
119
  a.forEach((T) => {
120
120
  var I;
121
- return (I = n.get(T)) == null ? void 0 : I.l.forEach(A);
122
- }), a.clear(), i.forEach(A), i.clear(), l.forEach(A), 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();
123
123
  } while (a.size || i.size || l.size);
124
- if (C)
124
+ if (w)
125
125
  throw L;
126
- }), x = m[2] || (() => {
127
- const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
128
- for (; k.length; ) {
129
- const A = k[k.length - 1], T = h(A);
130
- if (v.has(A)) {
131
- 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();
132
132
  continue;
133
133
  }
134
- if (L.has(A)) {
135
- r.get(A) === T.n && C.push([A, T]), v.add(A), k.pop();
134
+ if (L.has(E)) {
135
+ r.get(E) === T.n && w.push([E, T]), v.add(E), y.pop();
136
136
  continue;
137
137
  }
138
- L.add(A);
139
- for (const I of getMountedOrPendingDependents(A, T, n))
140
- 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);
141
141
  }
142
- for (let A = C.length - 1; A >= 0; --A) {
143
- const [T, I] = C[A];
144
- let P = !1;
145
- for (const N of I.d.keys())
146
- if (N !== T && a.has(N)) {
147
- 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;
148
148
  break;
149
149
  }
150
- P && (b(T), E(T)), r.delete(T);
150
+ R && (b(T), B(T)), r.delete(T);
151
151
  }
152
- }), b = m[3] || ((C) => {
152
+ }), b = m[3] || ((w) => {
153
153
  var L, v;
154
- const k = h(C);
155
- if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
156
- ([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]) => (
157
157
  // Recursively, read the atom state of the dependency, and
158
158
  // check if the atom epoch number is unchanged
159
- b(R).n === O
159
+ b(D).n === O
160
160
  )
161
161
  )))
162
- return k;
163
- k.d.clear();
164
- let A = !0;
162
+ return y;
163
+ y.d.clear();
164
+ let E = !0;
165
165
  const T = () => {
166
- n.has(C) && (E(C), x(), f());
167
- }, I = (R) => {
166
+ n.has(w) && (B(w), h(), f());
167
+ }, I = (D) => {
168
168
  var O;
169
- if (isSelfAtom(C, R)) {
170
- const H = h(R);
169
+ if (isSelfAtom(w, D)) {
170
+ const H = x(D);
171
171
  if (!isAtomStateInitialized(H))
172
- if (hasInitialValue(R))
173
- setAtomStateValueOrPromise(R, R.init, h);
172
+ if (hasInitialValue(D))
173
+ setAtomStateValueOrPromise(D, D.init, x);
174
174
  else
175
175
  throw new Error("no atom init");
176
176
  return returnAtomValue(H);
177
177
  }
178
- const M = b(R);
178
+ const $ = b(D);
179
179
  try {
180
- return returnAtomValue(M);
180
+ return returnAtomValue($);
181
181
  } finally {
182
- k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C), A || 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();
183
183
  }
184
184
  };
185
- let P, N;
186
- const D = {
185
+ let R, P;
186
+ const N = {
187
187
  get signal() {
188
- return P || (P = new AbortController()), P.signal;
188
+ return R || (R = new AbortController()), R.signal;
189
189
  },
190
190
  get setSelf() {
191
- return !N && isActuallyWritableAtom(C) && (N = (...R) => {
192
- if (!A)
191
+ return !P && isActuallyWritableAtom(w) && (P = (...D) => {
192
+ if (!E)
193
193
  try {
194
- return B(C, ...R);
194
+ return A(w, ...D);
195
195
  } finally {
196
- x(), f();
196
+ h(), f();
197
197
  }
198
- }), N;
198
+ }), P;
199
199
  }
200
- }, $ = k.n;
200
+ }, M = y.n;
201
201
  try {
202
- const R = d(C, I, D);
203
- return setAtomStateValueOrPromise(C, R, h), 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(
204
204
  T,
205
205
  T
206
- )), k;
207
- } catch (R) {
208
- 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;
209
209
  } finally {
210
- A = !1, $ !== k.n && r.get(C) === $ && (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));
211
211
  }
212
- }), y = m[4] || ((C) => {
213
- const L = [C];
212
+ }), k = m[4] || ((w) => {
213
+ const L = [w];
214
214
  for (; L.length; ) {
215
- const v = L.pop(), k = h(v);
216
- for (const A of getMountedOrPendingDependents(v, k, n)) {
217
- const T = h(A);
218
- r.set(A, T.n), L.push(A);
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);
219
219
  }
220
220
  }
221
- }), B = m[5] || ((C, ...L) => {
221
+ }), A = m[5] || ((w, ...L) => {
222
222
  let v = !0;
223
- const k = (T) => returnAtomValue(b(T)), A = (T, ...I) => {
224
- var P;
225
- const N = h(T);
223
+ const y = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
224
+ var R;
225
+ const P = x(T);
226
226
  try {
227
- if (isSelfAtom(C, T)) {
227
+ if (isSelfAtom(w, T)) {
228
228
  if (!hasInitialValue(T))
229
229
  throw new Error("atom not writable");
230
- const D = N.n, $ = I[0];
231
- setAtomStateValueOrPromise(T, $, h), 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));
232
232
  return;
233
233
  } else
234
- return B(T, ...I);
234
+ return A(T, ...I);
235
235
  } finally {
236
- v || (x(), f());
236
+ v || (h(), f());
237
237
  }
238
238
  };
239
239
  try {
240
- return p(C, k, A, ...L);
240
+ return p(w, y, E, ...L);
241
241
  } finally {
242
242
  v = !1;
243
243
  }
244
- }), E = m[6] || ((C) => {
244
+ }), B = m[6] || ((w) => {
245
245
  var L;
246
- const v = h(C), k = n.get(C);
247
- if (k && !isPendingPromise(v.v)) {
248
- for (const [A, T] of v.d)
249
- if (!k.d.has(A)) {
250
- const I = h(A);
251
- w(A).t.add(C), k.d.add(A), T !== I.n && (a.add(A), (L = c.c) == null || L.call(c, A), y(A));
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));
252
252
  }
253
- for (const A of k.d || [])
254
- if (!v.d.has(A)) {
255
- k.d.delete(A);
256
- const T = _(A);
257
- 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);
258
258
  }
259
259
  }
260
- }), w = m[7] || ((C) => {
260
+ }), C = m[7] || ((w) => {
261
261
  var L;
262
- const v = h(C);
263
- let k = n.get(C);
264
- if (!k) {
265
- b(C);
266
- for (const A of v.d.keys())
267
- w(A).t.add(C);
268
- 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 = {
269
269
  l: /* @__PURE__ */ new Set(),
270
270
  d: new Set(v.d.keys()),
271
271
  t: /* @__PURE__ */ new Set()
272
- }, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
273
- const A = () => {
272
+ }, n.set(w, y), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
+ const E = () => {
274
274
  let T = !0;
275
- const I = (...P) => {
275
+ const I = (...R) => {
276
276
  try {
277
- return B(C, ...P);
277
+ return A(w, ...R);
278
278
  } finally {
279
- T || (x(), f());
279
+ T || (h(), f());
280
280
  }
281
281
  };
282
282
  try {
283
- const P = g(C, I);
284
- P && (k.u = () => {
283
+ const R = g(w, I);
284
+ R && (y.u = () => {
285
285
  T = !0;
286
286
  try {
287
- P();
287
+ R();
288
288
  } finally {
289
289
  T = !1;
290
290
  }
@@ -293,27 +293,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
293
293
  T = !1;
294
294
  }
295
295
  };
296
- l.add(A);
296
+ l.add(E);
297
297
  }
298
298
  }
299
- return k;
300
- }), _ = m[8] || ((C) => {
299
+ return y;
300
+ }), j = m[8] || ((w) => {
301
301
  var L;
302
- const v = h(C);
303
- let k = n.get(C);
304
- if (k && !k.l.size && !Array.from(k.t).some((A) => {
302
+ const v = x(w);
303
+ let y = n.get(w);
304
+ if (y && !y.l.size && !Array.from(y.t).some((E) => {
305
305
  var T;
306
- return (T = n.get(A)) == null ? void 0 : T.d.has(C);
306
+ return (T = n.get(E)) == null ? void 0 : T.d.has(w);
307
307
  })) {
308
- k.u && i.add(k.u), k = void 0, n.delete(C), (L = c.u) == null || L.call(c, C);
309
- for (const A of v.d.keys()) {
310
- const T = _(A);
311
- 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);
312
312
  }
313
313
  return;
314
314
  }
315
- return k;
316
- }), j = [
315
+ return y;
316
+ }), _ = [
317
317
  // store state
318
318
  o,
319
319
  n,
@@ -328,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
328
328
  u,
329
329
  g,
330
330
  // building-block functions
331
- h,
332
- f,
333
331
  x,
332
+ f,
333
+ h,
334
334
  b,
335
- y,
335
+ k,
336
+ A,
336
337
  B,
337
- E,
338
- w,
339
- _
338
+ C,
339
+ j
340
340
  ], S = {
341
- get: (C) => returnAtomValue(b(C)),
342
- set: (C, ...L) => {
341
+ get: (w) => returnAtomValue(b(w)),
342
+ set: (w, ...L) => {
343
343
  try {
344
- return B(C, ...L);
344
+ return A(w, ...L);
345
345
  } finally {
346
- x(), f();
346
+ h(), f();
347
347
  }
348
348
  },
349
- sub: (C, L) => {
350
- const k = w(C).l;
351
- return k.add(L), f(), () => {
352
- 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();
353
353
  };
354
354
  }
355
355
  };
356
- return Object.defineProperty(S, BUILDING_BLOCKS, { value: j }), S;
356
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
357
357
  }, INTERNAL_buildStoreRev1 = buildStore;
358
358
  let keyCount = 0;
359
359
  function atom(o, n) {
@@ -389,36 +389,36 @@ function splitAtom(o, n) {
389
389
  if (p)
390
390
  return p;
391
391
  const u = d && r.get(d), g = [], m = [];
392
- return c.forEach((h, f) => {
393
- const x = f;
394
- m[f] = x;
395
- const b = u && u.atomList[u.keyList.indexOf(x)];
392
+ return c.forEach((x, f) => {
393
+ const h = f;
394
+ m[f] = h;
395
+ const b = u && u.atomList[u.keyList.indexOf(h)];
396
396
  if (b) {
397
397
  g[f] = b;
398
398
  return;
399
399
  }
400
- const y = (E) => {
401
- const w = E(l), _ = E(o), S = a(_, w == null ? void 0 : w.arr).keyList.indexOf(x);
402
- if (S < 0 || S >= _.length) {
403
- const C = c[a(c).keyList.indexOf(x)];
404
- if (C)
405
- 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;
406
406
  throw new Error("splitAtom: index out of bounds for read");
407
407
  }
408
- return _[S];
409
- }, B = (E, w, _) => {
410
- 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);
411
411
  if (L < 0 || L >= S.length)
412
412
  throw new Error("splitAtom: index out of bounds for write");
413
- const v = isFunction(_) ? _(S[L]) : _;
414
- Object.is(S[L], v) || w(o, [
413
+ const v = isFunction(j) ? j(S[L]) : j;
414
+ Object.is(S[L], v) || C(o, [
415
415
  ...S.slice(0, L),
416
416
  v,
417
417
  ...S.slice(L + 1)
418
418
  ]);
419
419
  };
420
- g[f] = isWritable(o) ? atom(y, B) : atom(y);
421
- }), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, 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;
422
422
  }, l = atom((c) => {
423
423
  const d = c(l), p = c(o);
424
424
  return a(p, d == null ? void 0 : d.arr);
@@ -491,18 +491,18 @@ function createJSONStorage(o = () => {
491
491
  const i = {
492
492
  getItem: (p, u) => {
493
493
  var g, m;
494
- const h = (x) => {
495
- if (x = x || "", a !== x) {
494
+ const x = (h) => {
495
+ if (h = h || "", a !== h) {
496
496
  try {
497
- l = JSON.parse(x, n == null ? void 0 : n.reviver);
497
+ l = JSON.parse(h, n == null ? void 0 : n.reviver);
498
498
  } catch {
499
499
  return u;
500
500
  }
501
- a = x;
501
+ a = h;
502
502
  }
503
503
  return l;
504
504
  }, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
- return isPromiseLike$1(f) ? f.then(h) : h(f);
505
+ return isPromiseLike$1(f) ? f.then(x) : x(f);
506
506
  },
507
507
  setItem: (p, u) => {
508
508
  var g;
@@ -515,10 +515,10 @@ function createJSONStorage(o = () => {
515
515
  var u;
516
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
517
517
  }
518
- }, c = (p) => (u, g, m) => p(u, (h) => {
518
+ }, c = (p) => (u, g, m) => p(u, (x) => {
519
519
  let f;
520
520
  try {
521
- f = JSON.parse(h || "");
521
+ f = JSON.parse(x || "");
522
522
  } catch {
523
523
  f = m;
524
524
  }
@@ -653,8 +653,6 @@ const activePanelAtom = atom$1("outline");
653
653
  activePanelAtom.debugLabel = "activePanelAtom";
654
654
  const showPredefinedBlockCategoryAtom = atom$1("");
655
655
  showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
656
- const historyStatesAtom = atom$1({ undoCount: 0, redoCount: 0 });
657
- historyStatesAtom.debugLabel = "historyStatesAtom";
658
656
  const inlineEditingActiveAtom = atom$1("");
659
657
  inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
660
658
  const draggingFlagAtom = atom$1(!1);
@@ -930,7 +928,22 @@ function requireUndomanager() {
930
928
  }(undomanager)), undomanager.exports;
931
929
  }
932
930
  var undomanagerExports = requireUndomanager();
933
- 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 = [
934
947
  "hover",
935
948
  "focus",
936
949
  "focus-within",
@@ -1003,21 +1016,12 @@ const useBrandingOptions = () => {
1003
1016
  blocks: a
1004
1017
  };
1005
1018
  }, [o, n, r]);
1006
- }, chaiBuilderPropsAtom = atom$1(null);
1007
- chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
1008
- const chaiExternalDataAtom = atom$1({});
1009
- chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
1010
- const chaiRjsfFieldsAtom = atom$1({});
1011
- chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
1012
- const chaiRjsfWidgetsAtom = atom$1({});
1013
- chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
1014
- const chaiRjsfTemplatesAtom = atom$1({});
1015
- chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
1016
- const chaiPageExternalDataAtom = atom$1({});
1017
- chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
1018
- const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
1019
- const r = useAtomValue$1(chaiBuilderPropsAtom);
1020
- 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
+ ) };
1021
1025
  }, getDefaultThemeValues = (o = defaultThemeOptions) => {
1022
1026
  const n = {};
1023
1027
  return o.fontFamily && (n.fontFamily = Object.entries(o.fontFamily).reduce(
@@ -1044,15 +1048,17 @@ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useB
1044
1048
  }, rightPanelAtom = atom$1("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom$1("SAVED");
1045
1049
  builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
1046
1050
  const useSavePage = () => {
1047
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (d) => {
1048
- }), 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();
1049
1053
  return { savePage: useThrottledCallback(
1050
- async (d = !1) => {
1054
+ async (p = !1) => {
1055
+ if (!c("save_page"))
1056
+ return;
1051
1057
  n("SAVING"), a("SAVING");
1052
- const p = l();
1058
+ const u = l();
1053
1059
  return await r({
1054
- autoSave: d,
1055
- blocks: p.blocks,
1060
+ autoSave: p,
1061
+ blocks: u.blocks,
1056
1062
  theme: i
1057
1063
  }), setTimeout(() => {
1058
1064
  n("SAVED"), a("SAVED");
@@ -1152,15 +1158,15 @@ const useSelectedBlocksDisplayChild = () => ({
1152
1158
  if (!p || !p._parent) return;
1153
1159
  const u = p._parent, g = r.filter((m) => m._parent === u);
1154
1160
  if (g.length === 2) {
1155
- const m = g.find((h) => h._id !== d);
1161
+ const m = g.find((x) => x._id !== d);
1156
1162
  if (m && m._type === "Text") {
1157
- const h = r.find((f) => f._id === u);
1158
- h && "content" in h && (r = r.map((f) => {
1163
+ const x = r.find((f) => f._id === u);
1164
+ x && "content" in x && (r = r.map((f) => {
1159
1165
  if (f._id === u) {
1160
- const x = { ...f, content: m.content };
1166
+ const h = { ...f, content: m.content };
1161
1167
  return Object.keys(m).forEach((b) => {
1162
- b.startsWith("content-") && (x[b] = m[b]);
1163
- }), x;
1168
+ b.startsWith("content-") && (h[b] = m[b]);
1169
+ }), h;
1164
1170
  }
1165
1171
  return f;
1166
1172
  }), a.push(m._id));
@@ -1170,14 +1176,15 @@ const useSelectedBlocksDisplayChild = () => ({
1170
1176
  const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
1171
1177
  return isEmpty(i) ? c : removeNestedBlocks(c, i);
1172
1178
  }, useRemoveBlocks = () => {
1173
- const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
1179
+ const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
1174
1180
  return useCallback(
1175
- (l) => {
1176
- var c;
1177
- const i = ((c = find(o, { _id: l[0] })) == null ? void 0 : c._parent) || null;
1178
- 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);
1179
1186
  },
1180
- [o, r, n]
1187
+ [o, r, n, l]
1181
1188
  );
1182
1189
  }, builderStore = getDefaultStore$1(), writeAtomValue = atom$1(
1183
1190
  null,
@@ -1227,20 +1234,20 @@ function insertBlocksAtPosition(o, n, r, a) {
1227
1234
  if (r) {
1228
1235
  const u = o.find((g) => g._id === r);
1229
1236
  if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
1230
- const h = {
1237
+ const x = {
1231
1238
  _id: generateUUID(),
1232
1239
  _parent: r,
1233
1240
  _type: "Text",
1234
1241
  content: u.content
1235
1242
  };
1236
1243
  Object.keys(u).forEach((f) => {
1237
- f.startsWith("content-") && (h[f] = u[f]);
1238
- }), l.unshift(h), i = i.map((f) => {
1244
+ f.startsWith("content-") && (x[f] = u[f]);
1245
+ }), l.unshift(x), i = i.map((f) => {
1239
1246
  if (f._id === r) {
1240
- const x = { ...f, content: "" };
1241
- return Object.keys(x).forEach((b) => {
1242
- b.startsWith("content-") && (x[b] = "");
1243
- }), x;
1247
+ const h = { ...f, content: "" };
1248
+ return Object.keys(h).forEach((b) => {
1249
+ b.startsWith("content-") && (h[b] = "");
1250
+ }), h;
1244
1251
  }
1245
1252
  return f;
1246
1253
  });
@@ -1390,65 +1397,65 @@ const useBlocksStoreManager = () => {
1390
1397
  updateBlocksProps: c
1391
1398
  } = useBlocksStoreManager();
1392
1399
  return {
1393
- moveBlocks: (x, b, y) => {
1394
- const B = map(x, (w) => {
1395
- 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);
1396
- return { _id: w, oldParent: j, oldPosition: C };
1397
- }), E = B.find(({ _id: w }) => w === x[0]);
1398
- E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
1399
- undo: () => each(B, ({ _id: w, oldParent: _, oldPosition: j }) => {
1400
- 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, _);
1401
1408
  }),
1402
- redo: () => i(x, b, y)
1409
+ redo: () => i(h, b, k)
1403
1410
  }));
1404
1411
  },
1405
- addBlocks: (x, b, y) => {
1406
- a(x, b, y), o({
1407
- undo: () => l(map(x, "_id")),
1408
- 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)
1409
1416
  });
1410
1417
  },
1411
- removeBlocks: (x) => {
1412
- var E;
1413
- const b = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1414
- l(map(x, "_id")), o({
1415
- undo: () => a(x, b, B),
1416
- 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"))
1417
1424
  });
1418
1425
  },
1419
- updateBlocks: (x, b, y) => {
1420
- let B = [];
1421
- if (y)
1422
- B = map(x, (E) => ({ _id: E, ...y }));
1426
+ updateBlocks: (h, b, k) => {
1427
+ let A = [];
1428
+ if (k)
1429
+ A = map(h, (B) => ({ _id: B, ...k }));
1423
1430
  else {
1424
- const E = keys(b);
1425
- B = map(x, (w) => {
1426
- const _ = n.find((S) => S._id === w), j = { _id: w };
1427
- 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]), _;
1428
1435
  });
1429
1436
  }
1430
- c(map(x, (E) => ({ _id: E, ...b }))), o({
1431
- undo: () => c(B),
1432
- redo: () => c(map(x, (E) => ({ _id: E, ...b })))
1437
+ c(map(h, (B) => ({ _id: B, ...b }))), o({
1438
+ undo: () => c(A),
1439
+ redo: () => c(map(h, (B) => ({ _id: B, ...b })))
1433
1440
  });
1434
1441
  },
1435
- updateBlocksRuntime: (x, b) => {
1436
- c(map(x, (y) => ({ _id: y, ...b })));
1442
+ updateBlocksRuntime: (h, b) => {
1443
+ c(map(h, (k) => ({ _id: k, ...b })));
1437
1444
  },
1438
- setNewBlocks: (x) => {
1439
- r(x), o({
1445
+ setNewBlocks: (h) => {
1446
+ r(h), o({
1440
1447
  undo: () => r(n),
1441
- redo: () => r(x)
1448
+ redo: () => r(h)
1442
1449
  });
1443
1450
  },
1444
- updateMultipleBlocksProps: (x) => {
1451
+ updateMultipleBlocksProps: (h) => {
1445
1452
  let b = [];
1446
- b = map(x, (y) => {
1447
- const B = keys(y), E = n.find((_) => _._id === y._id), w = {};
1448
- return each(B, (_) => w[_] = E[_]), w;
1449
- }), 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({
1450
1457
  undo: () => c(b),
1451
- redo: () => c(x)
1458
+ redo: () => c(h)
1452
1459
  });
1453
1460
  }
1454
1461
  };
@@ -1484,17 +1491,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1484
1491
  const useAddBlock = () => {
1485
1492
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1486
1493
  (i, c, d) => {
1487
- var h;
1494
+ var x;
1488
1495
  for (let f = 0; f < i.length; f++) {
1489
- const { _id: x } = i[f];
1496
+ const { _id: h } = i[f];
1490
1497
  i[f]._id = generateUUID();
1491
- const b = filter(i, { _parent: x });
1492
- for (let y = 0; y < b.length; y++)
1493
- 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;
1494
1501
  }
1495
1502
  const p = first(i);
1496
1503
  let u, g;
1497
- 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([(h = first(i)) == null ? void 0 : h._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);
1498
1505
  },
1499
1506
  [r, o, n]
1500
1507
  );
@@ -1511,8 +1518,8 @@ const useAddBlock = () => {
1511
1518
  ...has(i, "_name") && { _name: i._name },
1512
1519
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1513
1520
  };
1514
- let m, h;
1515
- return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, 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;
1516
1523
  },
1517
1524
  [r, a, o, n]
1518
1525
  ), addPredefinedBlock: a };
@@ -2958,41 +2965,41 @@ const getBlockWithChildren = (o, n) => {
2958
2965
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2959
2966
  })
2960
2967
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2961
- 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 = (h, f) => {
2962
- const x = cloneDeep(f.find((b) => b._id === h));
2963
- for (const b in x) {
2964
- const y = x[b];
2965
- if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2966
- const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
2967
- x[b] = compact(flattenDeep([B, 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(" ");
2968
2975
  } else
2969
- b !== "_id" && delete x[b];
2976
+ b !== "_id" && delete h[b];
2970
2977
  }
2971
- return x;
2978
+ return h;
2972
2979
  };
2973
2980
  return {
2974
2981
  askAi: useCallback(
2975
- async (h, f, x, b) => {
2982
+ async (x, f, h, b) => {
2976
2983
  if (l) {
2977
2984
  n(!0), a(null);
2978
2985
  try {
2979
- const y = p === u ? "" : p, B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], E = await l(h, addLangToPrompt(x, g, h), B, y), { blocks: w, error: _ } = E;
2980
- if (_) {
2981
- 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);
2982
2989
  return;
2983
2990
  }
2984
- if (h === "styles") {
2985
- const j = w.map((S) => {
2986
- for (const C in S)
2987
- 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]}`);
2988
2995
  return S;
2989
2996
  });
2990
- c(j);
2997
+ c(_);
2991
2998
  } else
2992
- i(w);
2993
- b && b(E);
2994
- } catch (y) {
2995
- a(y);
2999
+ i(C);
3000
+ b && b(B);
3001
+ } catch (k) {
3002
+ a(k);
2996
3003
  } finally {
2997
3004
  n(!1), b && b();
2998
3005
  }
@@ -3083,9 +3090,9 @@ const useBlockHighlight = () => {
3083
3090
  d();
3084
3091
  }, []), { data: l, isLoading: o, refetch: d, error: r };
3085
3092
  }, useBuilderReset = () => {
3086
- 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();
3087
3094
  return () => {
3088
- r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
3095
+ n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
3089
3096
  };
3090
3097
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
3091
3098
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -3131,11 +3138,11 @@ const useBlockHighlight = () => {
3131
3138
  (a, l = null) => {
3132
3139
  const i = [];
3133
3140
  each(a, (c) => {
3134
- const d = o.find((h) => h._id === c);
3141
+ const d = o.find((x) => x._id === c);
3135
3142
  l ? l === "root" && (l = null) : l = d._parent;
3136
3143
  const g = filter(
3137
3144
  o,
3138
- (h) => isString(l) ? h._parent === l : !h._parent
3145
+ (x) => isString(l) ? x._parent === l : !x._parent
3139
3146
  ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3140
3147
  r(m, l, g), i.push(get(m, "0._id", ""));
3141
3148
  }), n(i);
@@ -3231,12 +3238,12 @@ const useBlockHighlight = () => {
3231
3238
  const d = o(c), p = a;
3232
3239
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3233
3240
  return each(p, (m) => {
3234
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3241
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3235
3242
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
3236
- const x = first(m.split(":"));
3237
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
3243
+ const h = first(m.split(":"));
3244
+ includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
3238
3245
  }), each(p, (m) => {
3239
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3246
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3240
3247
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
3241
3248
  }), {
3242
3249
  ids: [d._id],
@@ -3323,136 +3330,53 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
3323
3330
  const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3324
3331
  const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
3325
3332
  return [o || r, n];
3326
- }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
3327
- class PubSub {
3328
- constructor() {
3329
- V(this, "subscribers", /* @__PURE__ */ new Map());
3330
- }
3331
- subscribe(n, r) {
3332
- return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
3333
- const a = this.subscribers.get(n);
3334
- a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
3335
- };
3336
- }
3337
- publish(n, r) {
3338
- const a = this.subscribers.get(n);
3339
- a && a.forEach((l) => l(r));
3340
- }
3341
- }
3342
- const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3343
- const { t: r } = useTranslation(), [a] = useBlocksStore(), l = get(o, "_id"), i = get(o, "_parent"), c = filter(a, (g) => i ? get(g, "_parent") === i : !get(g, "_parent")), d = canAddChildBlock(get(o, "_type", "")), p = findIndex(c, { _id: l }), u = (g) => {
3344
- if (g === "CHILD")
3345
- pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3346
- else {
3347
- const m = { _id: i || "", position: c == null ? void 0 : c.length };
3348
- g === "BEFORE" ? m.position = Math.max(p, 0) : g === "AFTER" && (m.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
3349
- }
3350
- };
3351
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3352
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3353
- /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
3354
- d && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("CHILD"), children: r("Add inside") }),
3355
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("BEFORE"), children: r("Add before") }),
3356
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("AFTER"), children: r("Add after") })
3357
- ] })
3358
- ] });
3359
3333
  };
3360
- function getOrientation(o) {
3361
- const n = window.getComputedStyle(o), r = n.display;
3362
- if (r === "flex" || r === "inline-flex") {
3363
- const a = n.flexDirection;
3364
- return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3365
- } else if (r === "grid") {
3366
- const a = n.gridAutoFlow, l = n.gridTemplateColumns;
3367
- return a.includes("column") || l && l !== "none" && l !== "" && !l.includes("calc") && // Handle calc expressions
3368
- l.split(" ").length <= 1 ? "vertical" : "horizontal";
3369
- } else if (r === "block" || r === "inline-block")
3370
- return "vertical";
3371
- return "horizontal";
3372
- }
3373
- if (import.meta.vitest) {
3374
- const { test: o, expect: n } = import.meta.vitest;
3375
- o("getOrientation default div should be vertical", () => {
3376
- n(getOrientation(document.createElement("div"))).toBe("vertical");
3377
- }), o("getOrientation flex with default direction should be horizontal", () => {
3378
- const r = document.createElement("div");
3379
- r.style.display = "flex", n(getOrientation(r)).toBe("horizontal");
3380
- }), o("getOrientation inline-flex with default direction should be horizontal", () => {
3381
- const r = document.createElement("div");
3382
- r.style.display = "inline-flex", n(getOrientation(r)).toBe("horizontal");
3383
- }), o("getOrientation flex with row direction should be horizontal", () => {
3384
- const r = document.createElement("div");
3385
- r.style.display = "flex", r.style.flexDirection = "row", n(getOrientation(r)).toBe("horizontal");
3386
- }), o("getOrientation flex with row-reverse direction should be horizontal", () => {
3387
- const r = document.createElement("div");
3388
- r.style.display = "flex", r.style.flexDirection = "row-reverse", n(getOrientation(r)).toBe("horizontal");
3389
- }), o("getOrientation flex with column direction should be vertical", () => {
3390
- const r = document.createElement("div");
3391
- r.style.display = "flex", r.style.flexDirection = "column", n(getOrientation(r)).toBe("vertical");
3392
- }), o("getOrientation flex with column-reverse direction should be vertical", () => {
3393
- const r = document.createElement("div");
3394
- r.style.display = "flex", r.style.flexDirection = "column-reverse", n(getOrientation(r)).toBe("vertical");
3395
- }), o("getOrientation grid with default settings should be horizontal", () => {
3396
- const r = document.createElement("div");
3397
- r.style.display = "grid", n(getOrientation(r)).toBe("horizontal");
3398
- }), o("getOrientation grid with row auto-flow should be horizontal", () => {
3399
- const r = document.createElement("div");
3400
- r.style.display = "grid", r.style.gridAutoFlow = "row", n(getOrientation(r)).toBe("horizontal");
3401
- }), o("getOrientation grid with column auto-flow should be vertical", () => {
3402
- const r = document.createElement("div");
3403
- r.style.display = "grid", r.style.gridAutoFlow = "column", n(getOrientation(r)).toBe("vertical");
3404
- }), o("getOrientation grid with dense column auto-flow should be vertical", () => {
3405
- const r = document.createElement("div");
3406
- r.style.display = "grid", r.style.gridAutoFlow = "column dense", n(getOrientation(r)).toBe("vertical");
3407
- }), o("getOrientation grid with single column should be vertical", () => {
3408
- const r = document.createElement("div");
3409
- r.style.display = "grid", r.style.gridTemplateColumns = "1fr", n(getOrientation(r)).toBe("vertical");
3410
- }), o("getOrientation grid with multiple columns should be horizontal", () => {
3411
- const r = document.createElement("div");
3412
- r.style.display = "grid", r.style.gridTemplateColumns = "1fr 1fr", n(getOrientation(r)).toBe("horizontal");
3413
- }), o("getOrientation block should be vertical", () => {
3414
- const r = document.createElement("div");
3415
- r.style.display = "block", n(getOrientation(r)).toBe("vertical");
3416
- }), o("getOrientation inline-block should be vertical", () => {
3417
- const r = document.createElement("div");
3418
- r.style.display = "inline-block", n(getOrientation(r)).toBe("vertical");
3419
- }), o("getOrientation inline should be horizontal", () => {
3420
- const r = document.createElement("div");
3421
- r.style.display = "inline", n(getOrientation(r)).toBe("horizontal");
3422
- }), o("getOrientation table should be horizontal", () => {
3423
- const r = document.createElement("div");
3424
- r.style.display = "table", n(getOrientation(r)).toBe("horizontal");
3425
- });
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";
3426
3346
  }
3427
3347
  const CONTROLS = [
3428
3348
  { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
3429
3349
  { ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
3430
3350
  { ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
3431
3351
  { ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
3432
- ], getParentBlockOrientation = (o, n) => {
3352
+ ], getParentBlockOrientation = (o, n, r) => {
3433
3353
  try {
3434
- if (!o || !n) return "VERTICAL";
3435
- const r = `[data-block-id='${o}']`, a = n == null ? void 0 : n.querySelector(r);
3436
- 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";
3437
3361
  } catch {
3438
3362
  return "VERTICAL";
3439
3363
  }
3440
3364
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3441
- 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, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, a), f = useCallback(
3442
- (x) => {
3443
- isDisabledControl(g, m, 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());
3444
3368
  },
3445
3369
  [g, m, p, u, i, c, n]
3446
3370
  );
3447
3371
  return useHotkeys(
3448
3372
  "shift+up, shift+down, shift+left, shift+right",
3449
- ({ key: x }) => {
3373
+ ({ key: h }) => {
3450
3374
  var b;
3451
- 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());
3452
3376
  },
3453
3377
  { document: a == null ? void 0 : a.contentDocument },
3454
3378
  [f]
3455
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
3379
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: x };
3456
3380
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3457
3381
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3458
3382
  o,
@@ -3470,7 +3394,40 @@ const CONTROLS = [
3470
3394
  u
3471
3395
  );
3472
3396
  }) });
3473
- }, BlockActionLabel = ({ block: o, label: n }) => {
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 }) => {
3474
3431
  const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
3475
3432
  return /* @__PURE__ */ jsxs(
3476
3433
  "div",
@@ -3489,46 +3446,46 @@ const CONTROLS = [
3489
3446
  }
3490
3447
  );
3491
3448
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
3492
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: m } = 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({
3493
3450
  placement: "top-start",
3494
3451
  middleware: [shift(), flip()],
3495
3452
  elements: {
3496
3453
  reference: o
3497
3454
  }
3498
3455
  });
3499
- useResizeObserver(o, () => m(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => m(), (p == null ? void 0 : p.body) !== null);
3500
- const h = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3501
- 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(
3502
3459
  "div",
3503
3460
  {
3504
3461
  role: "button",
3505
3462
  tabIndex: 0,
3506
- ref: g.setFloating,
3507
- style: u,
3508
- onClick: (x) => {
3509
- x.stopPropagation(), x.preventDefault();
3463
+ ref: m.setFloating,
3464
+ style: g,
3465
+ onClick: (b) => {
3466
+ b.stopPropagation(), b.preventDefault();
3510
3467
  },
3511
- onMouseEnter: (x) => {
3512
- x.stopPropagation(), i(null);
3468
+ onMouseEnter: (b) => {
3469
+ b.stopPropagation(), i(null);
3513
3470
  },
3514
- onKeyDown: (x) => x.stopPropagation(),
3471
+ onKeyDown: (b) => b.stopPropagation(),
3515
3472
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3516
3473
  children: [
3517
- h && /* @__PURE__ */ jsx(
3474
+ f && /* @__PURE__ */ jsx(
3518
3475
  ArrowUpIcon,
3519
3476
  {
3520
3477
  className: "hover:scale-105",
3521
3478
  onClick: () => {
3522
- c([]), l([h]);
3479
+ c([]), l([f]);
3523
3480
  }
3524
3481
  }
3525
3482
  ),
3526
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3483
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: h, block: n }),
3527
3484
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3528
3485
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3529
- canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3530
- canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3531
- /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: m })
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 })
3532
3489
  ] })
3533
3490
  ]
3534
3491
  }
@@ -3589,15 +3546,15 @@ const CONTROLS = [
3589
3546
  <div class="frame-root h-full"></div>
3590
3547
  </body>
3591
3548
  </html>`, useKeyEventWatcher = (o) => {
3592
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = 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 } : {};
3593
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(
3594
3551
  "ctrl+v,command+v",
3595
3552
  () => {
3596
3553
  g(n[0]) && m(n);
3597
3554
  },
3598
- { ...h, preventDefault: !0 },
3555
+ { ...x, preventDefault: !0 },
3599
3556
  [n, g, m]
3600
- ), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
3557
+ ), useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...x, preventDefault: !0 }, [
3601
3558
  n,
3602
3559
  i
3603
3560
  ]), useHotkeys(
@@ -3605,25 +3562,22 @@ const CONTROLS = [
3605
3562
  (f) => {
3606
3563
  f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3607
3564
  },
3608
- h,
3565
+ x,
3609
3566
  [n, l]
3610
3567
  );
3611
3568
  }, KeyboardHandler = () => {
3612
3569
  const { document: o } = useFrame();
3613
3570
  return useKeyEventWatcher(o), null;
3614
- }, CHAI_BUILDER_EVENTS = {
3615
- OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
3616
- CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
3617
- SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
3618
3571
  }, AddBlockAtBottom = () => {
3619
- const { t: o } = useTranslation();
3620
- 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: [
3621
3574
  /* @__PURE__ */ jsx("br", {}),
3622
3575
  /* @__PURE__ */ jsx(
3623
3576
  "div",
3624
3577
  {
3578
+ role: "button",
3625
3579
  onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
3626
- 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",
3627
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: [
3628
3582
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "size-2.5 stroke-[3]" }),
3629
3583
  " ",
@@ -3632,7 +3586,7 @@ const CONTROLS = [
3632
3586
  }
3633
3587
  ),
3634
3588
  /* @__PURE__ */ jsx("br", {})
3635
- ] });
3589
+ ] }) : null;
3636
3590
  };
3637
3591
  let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
3638
3592
  const positionPlaceholder = (o, n, r) => {
@@ -3688,33 +3642,33 @@ const useDnd = () => {
3688
3642
  };
3689
3643
  return iframeDocument = o, {
3690
3644
  isDragging: n,
3691
- onDragOver: (h) => {
3692
- h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
3645
+ onDragOver: (x) => {
3646
+ x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
3693
3647
  },
3694
- onDrop: (h) => {
3695
- var _;
3696
- const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : h.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;
3697
3651
  dropIndex = calculateDropIndex(b, possiblePositions);
3698
- const y = d, B = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3699
- if ((y == null ? void 0 : y._id) === B || !E) {
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) {
3700
3654
  m();
3701
3655
  return;
3702
3656
  }
3703
- if (!has(y, "_id")) {
3704
- a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
3657
+ if (!has(k, "_id")) {
3658
+ a(k, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3705
3659
  return;
3706
3660
  }
3707
- let w = f.getAttribute("data-block-id");
3708
- w === null && (w = h.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), 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);
3709
3663
  },
3710
- onDragEnter: (h) => {
3711
- const f = h, x = f.target;
3712
- dropTarget = x;
3713
- const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3714
- 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([]);
3715
3669
  },
3716
- onDragLeave: (h) => {
3717
- h.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 = []);
3718
3672
  }
3719
3673
  };
3720
3674
  };
@@ -3745,8 +3699,8 @@ const useHandleCanvasDblClick = (o, n) => {
3745
3699
  const f = o.getHTML();
3746
3700
  a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3747
3701
  }), i(m);
3748
- const h = d(m).content;
3749
- o.commands.setContent(h), 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);
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);
3750
3704
  },
3751
3705
  [l, c, d, i, a, o, n]
3752
3706
  );
@@ -3787,17 +3741,17 @@ const useHandleCanvasDblClick = (o, n) => {
3787
3741
  return;
3788
3742
  const f = getElementByDataBlockId(n, first(r));
3789
3743
  if (f) {
3790
- const x = f.getAttribute("data-style-prop");
3791
- if (x) {
3792
- const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
3793
- 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 }]);
3794
3748
  }
3795
3749
  }
3796
3750
  }, 100);
3797
3751
  }, [n, r, l, a]);
3798
3752
  const c = useEditor({
3799
3753
  extensions: [StarterKit]
3800
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
3754
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), x = useDnd();
3801
3755
  return /* @__PURE__ */ jsx(
3802
3756
  "div",
3803
3757
  {
@@ -3807,8 +3761,8 @@ const useHandleCanvasDblClick = (o, n) => {
3807
3761
  onDoubleClick: p,
3808
3762
  onMouseMove: g,
3809
3763
  onMouseLeave: m,
3810
- ...omit(h, "isDragging"),
3811
- className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
3764
+ ...omit(x, "isDragging"),
3765
+ className: "relative h-full max-w-full p-px " + (x.isDragging ? "dragging" : ""),
3812
3766
  children: o
3813
3767
  }
3814
3768
  );
@@ -3817,7 +3771,7 @@ const useHandleCanvasDblClick = (o, n) => {
3817
3771
  d == null ? void 0 : d.getElementById("selected-block")
3818
3772
  ), [m] = useState(
3819
3773
  d == null ? void 0 : d.getElementById("selected-styling-block")
3820
- ), [h] = useState(
3774
+ ), [x] = useState(
3821
3775
  d == null ? void 0 : d.getElementById("dragged-block")
3822
3776
  );
3823
3777
  useEffect(() => {
@@ -3842,15 +3796,15 @@ const useHandleCanvasDblClick = (o, n) => {
3842
3796
  forms,
3843
3797
  aspectRatio,
3844
3798
  containerQueries,
3845
- plugin(function({ addBase: b, theme: y }) {
3799
+ plugin(function({ addBase: b, theme: k }) {
3846
3800
  b({
3847
3801
  "h1,h2,h3,h4,h5,h6": {
3848
- fontFamily: y("fontFamily.heading")
3802
+ fontFamily: k("fontFamily.heading")
3849
3803
  },
3850
3804
  body: {
3851
- fontFamily: y("fontFamily.body"),
3852
- color: y("colors.foreground"),
3853
- backgroundColor: y("colors.background")
3805
+ fontFamily: k("fontFamily.body"),
3806
+ color: k("colors.foreground"),
3807
+ backgroundColor: k("colors.background")
3854
3808
  }
3855
3809
  });
3856
3810
  })
@@ -3861,8 +3815,8 @@ const useHandleCanvasDblClick = (o, n) => {
3861
3815
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3862
3816
  }`);
3863
3817
  }, [r, g]), useEffect(() => {
3864
- h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3865
- }, [i, h]), 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(() => {
3866
3820
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3867
3821
  }, [u]), useEffect(() => {
3868
3822
  m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
@@ -3874,10 +3828,10 @@ const useHandleCanvasDblClick = (o, n) => {
3874
3828
  const f = useMemo(
3875
3829
  () => getChaiThemeCssVariables(o),
3876
3830
  [o]
3877
- ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3831
+ ), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3878
3832
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3879
3833
  /* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
3880
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3834
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
3881
3835
  ] });
3882
3836
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3883
3837
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3957,10 +3911,10 @@ const getBlockRuntimeProps = memoize((o) => {
3957
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(
3958
3912
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3959
3913
  [r, l, a, d, u]
3960
- ), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3914
+ ), x = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3961
3915
  () => c(r._id, getBlockRuntimeProps(r._type)),
3962
3916
  [r._id, r._type, c, getBlockRuntimeProps]
3963
- ), 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(
3964
3918
  () => ({
3965
3919
  blockProps: {
3966
3920
  "data-block-id": r._id,
@@ -3969,9 +3923,9 @@ const getBlockRuntimeProps = memoize((o) => {
3969
3923
  inBuilder: !0,
3970
3924
  lang: l || i,
3971
3925
  ...m,
3972
- ...h,
3926
+ ...x,
3973
3927
  ...f,
3974
- ...x
3928
+ ...h
3975
3929
  }),
3976
3930
  [
3977
3931
  r._id,
@@ -3979,9 +3933,9 @@ const getBlockRuntimeProps = memoize((o) => {
3979
3933
  l,
3980
3934
  i,
3981
3935
  m,
3982
- h,
3936
+ x,
3983
3937
  f,
3984
- x
3938
+ h
3985
3939
  ]
3986
3940
  );
3987
3941
  return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
@@ -4013,11 +3967,11 @@ const getBlockRuntimeProps = memoize((o) => {
4013
3967
  if (d < n) {
4014
3968
  const u = parseFloat((d / n).toFixed(2).toString());
4015
3969
  let g = {};
4016
- const m = p * u, h = d * u;
3970
+ const m = p * u, x = d * u;
4017
3971
  p && (g = {
4018
3972
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
4019
3973
  height: 100 + (p - m) / m * 100 + "%",
4020
- width: 100 + (d - h) / h * 100 + "%"
3974
+ width: 100 + (d - x) / x * 100 + "%"
4021
3975
  }), i({
4022
3976
  position: "relative",
4023
3977
  top: 0,
@@ -4034,39 +3988,39 @@ const getBlockRuntimeProps = memoize((o) => {
4034
3988
  c();
4035
3989
  }, [n, o, r, c]), l;
4036
3990
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
4037
- 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([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (j) => {
4038
- 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: _ }));
4039
3993
  };
4040
3994
  useEffect(() => {
4041
3995
  if (!c.current) return;
4042
- const { clientWidth: j, clientHeight: S } = c.current;
4043
- p({ width: j, height: S });
3996
+ const { clientWidth: _, clientHeight: S } = c.current;
3997
+ p({ width: _, height: S });
4044
3998
  }, [c, n]);
4045
- const w = (j, S = 0) => {
4046
- const { top: C } = j.getBoundingClientRect();
4047
- 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;
4048
4002
  };
4049
4003
  useEffect(() => {
4050
- var j, S;
4004
+ var _, S;
4051
4005
  if (a && a.type !== "Multiple" && i.current) {
4052
- const C = getElementByDataBlockId(i.current.contentDocument, a._id);
4053
- C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([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]));
4054
4008
  }
4055
4009
  }, [a]), useEffect(() => {
4056
- if (!isEmpty(x) && i.current) {
4057
- const j = getElementByStyleId(
4010
+ if (!isEmpty(h) && i.current) {
4011
+ const _ = getElementByStyleId(
4058
4012
  i.current.contentDocument,
4059
- first(x).id
4013
+ first(h).id
4060
4014
  );
4061
- h(j ? [j] : [null]);
4015
+ x(_ ? [_] : [null]);
4062
4016
  } else
4063
- h([null]);
4064
- }, [x]);
4065
- const _ = useMemo(() => {
4066
- let j = IframeInitialContent;
4067
- return j = j.replace("__HTML_DIR__", B), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4068
- }, [o, B]);
4069
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
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")), _;
4022
+ }, [o, A]);
4023
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsx(
4070
4024
  "div",
4071
4025
  {
4072
4026
  onClick: () => {
@@ -4083,7 +4037,7 @@ const getBlockRuntimeProps = memoize((o) => {
4083
4037
  id: "canvas-iframe",
4084
4038
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
4085
4039
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
4086
- initialContent: _,
4040
+ initialContent: j,
4087
4041
  children: [
4088
4042
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
4089
4043
  /* @__PURE__ */ jsx(
@@ -4095,7 +4049,7 @@ const getBlockRuntimeProps = memoize((o) => {
4095
4049
  ),
4096
4050
  /* @__PURE__ */ jsx(HeadTags, {}),
4097
4051
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
4098
- 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, {}),
4099
4053
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
4100
4054
  /* @__PURE__ */ jsx("br", {}),
4101
4055
  /* @__PURE__ */ jsx("br", {}),
@@ -4256,78 +4210,78 @@ const getBlockRuntimeProps = memoize((o) => {
4256
4210
  }
4257
4211
  );
4258
4212
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4259
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4260
- a(y);
4261
- }, m = () => {
4262
- const y = l.find((B) => Object.keys(B)[0] === r);
4263
- if (y) {
4264
- const B = Object.values(y)[0];
4265
- B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
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);
4266
4220
  } else
4267
4221
  console.error("Preset not found:", r);
4268
- }, h = useDebouncedCallback(
4269
- (y, B) => {
4270
- d(() => ({
4271
- ...c,
4222
+ }, f = useDebouncedCallback(
4223
+ (A, B) => {
4224
+ p(() => ({
4225
+ ...d,
4272
4226
  fontFamily: {
4273
- ...c.fontFamily,
4274
- [y.replace(/font-/g, "")]: B
4227
+ ...d.fontFamily,
4228
+ [A.replace(/font-/g, "")]: B
4275
4229
  }
4276
4230
  }));
4277
4231
  },
4278
- [c],
4232
+ [d],
4279
4233
  200
4280
- ), f = useDebouncedCallback(
4281
- (y) => {
4282
- d(() => ({
4283
- ...c,
4284
- borderRadius: `${y}px`
4234
+ ), h = useDebouncedCallback(
4235
+ (A) => {
4236
+ p(() => ({
4237
+ ...d,
4238
+ borderRadius: `${A}px`
4285
4239
  }));
4286
4240
  },
4287
- [c],
4241
+ [d],
4288
4242
  200
4289
- ), x = useDebouncedCallback(
4290
- (y, B) => {
4291
- d(() => {
4292
- const E = get(c, `colors.${y}`);
4293
- return n ? set(E, 1, B) : set(E, 0, B), {
4294
- ...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,
4295
4249
  colors: {
4296
- ...c.colors,
4297
- [y]: E
4250
+ ...d.colors,
4251
+ [A]: C
4298
4252
  }
4299
4253
  };
4300
4254
  });
4301
4255
  },
4302
- [c],
4256
+ [d],
4303
4257
  200
4304
- ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4305
- const E = get(c, `colors.${B}.${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}`);
4306
4260
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4307
4261
  /* @__PURE__ */ jsx(
4308
4262
  ColorPickerInput,
4309
4263
  {
4310
- value: E,
4311
- onChange: (w) => x(B, w)
4264
+ value: C,
4265
+ onChange: (j) => b(B, j)
4312
4266
  }
4313
4267
  ),
4314
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
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" : "") })
4315
4269
  ] }, B);
4316
4270
  }) });
4317
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4271
+ return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4318
4272
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4319
4273
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
4320
4274
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4321
- /* @__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") }),
4322
4276
  /* @__PURE__ */ jsxs(
4323
4277
  "select",
4324
4278
  {
4325
4279
  value: r,
4326
- onChange: (y) => g(y.target.value),
4280
+ onChange: (A) => m(A.target.value),
4327
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",
4328
4282
  children: [
4329
4283
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
4330
- 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]))
4331
4285
  ]
4332
4286
  }
4333
4287
  )
@@ -4338,31 +4292,31 @@ const getBlockRuntimeProps = memoize((o) => {
4338
4292
  className: "w-full text-sm",
4339
4293
  disabled: r === "",
4340
4294
  variant: "default",
4341
- onClick: m,
4342
- children: u("Apply")
4295
+ onClick: x,
4296
+ children: g("Apply")
4343
4297
  }
4344
4298
  ) })
4345
4299
  ] }),
4346
4300
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4347
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__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(
4348
4302
  FontSelector,
4349
4303
  {
4350
- label: y,
4351
- value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4352
- onChange: (E) => h(y, E)
4304
+ label: A,
4305
+ value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4306
+ onChange: (C) => f(A, C)
4353
4307
  },
4354
- y
4308
+ A
4355
4309
  )) }),
4356
- (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4357
- /* @__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") }),
4358
4312
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4359
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: f }),
4360
- /* @__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 })
4361
4315
  ] })
4362
4316
  ] }),
4363
- (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4364
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4365
- /* @__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")
4366
4320
  ] })
4367
4321
  ] }),
4368
4322
  /* @__PURE__ */ jsx("br", {}),
@@ -4371,7 +4325,7 @@ const getBlockRuntimeProps = memoize((o) => {
4371
4325
  /* @__PURE__ */ jsx("br", {})
4372
4326
  ] }),
4373
4327
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
4374
- ] });
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." }) }) }) });
4375
4329
  }), removeSizeAttributes = (o) => {
4376
4330
  try {
4377
4331
  return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
@@ -4455,19 +4409,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4455
4409
  }, [a, o]);
4456
4410
  const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
4457
4411
  (f) => {
4458
- const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4459
- 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));
4460
4414
  },
4461
4415
  [i, n, r]
4462
4416
  ), m = React.useCallback(() => {
4463
4417
  if (i.length > 0) {
4464
4418
  const f = i.slice(0, -1);
4465
- c(f), p(f.reduce((x, b) => x[b], o));
4419
+ c(f), p(f.reduce((h, b) => h[b], o));
4466
4420
  }
4467
- }, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4421
+ }, [i, o]), x = React.useMemo(() => Object.entries(d).map(([f, h]) => ({
4468
4422
  key: f,
4469
- value: x,
4470
- type: u(x)
4423
+ value: h,
4424
+ type: u(h)
4471
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]);
4472
4426
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4473
4427
  /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -4493,7 +4447,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4493
4447
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4494
4448
  "Back"
4495
4449
  ] }),
4496
- h.map((f) => /* @__PURE__ */ jsxs(
4450
+ x.map((f) => /* @__PURE__ */ jsxs(
4497
4451
  CommandItem,
4498
4452
  {
4499
4453
  value: f.key,
@@ -4509,8 +4463,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4509
4463
  size: "sm",
4510
4464
  variant: "ghost",
4511
4465
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4512
- onClick: (x) => {
4513
- x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4466
+ onClick: (h) => {
4467
+ h.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4514
4468
  },
4515
4469
  children: "Select"
4516
4470
  }
@@ -4686,8 +4640,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4686
4640
  z-index: 9999 !important;
4687
4641
  }
4688
4642
  `, document.head.appendChild(m), () => {
4689
- const h = document.getElementById("rte-modal-styles");
4690
- h && h.remove();
4643
+ const x = document.getElementById("rte-modal-styles");
4644
+ x && x.remove();
4691
4645
  };
4692
4646
  }
4693
4647
  }, [o]);
@@ -4709,12 +4663,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4709
4663
  ],
4710
4664
  content: a || "",
4711
4665
  onUpdate: ({ editor: m }) => {
4712
- const h = m.getHTML();
4713
- l(h);
4666
+ const x = m.getHTML();
4667
+ l(x);
4714
4668
  },
4715
4669
  onBlur: ({ editor: m }) => {
4716
- const h = m.getHTML();
4717
- i(r, h);
4670
+ const x = m.getHTML();
4671
+ i(r, x);
4718
4672
  },
4719
4673
  editorProps: {
4720
4674
  attributes: {
@@ -4731,17 +4685,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4731
4685
  }, [u, o]);
4732
4686
  const g = (m) => {
4733
4687
  if (!u) return;
4734
- const h = `{{${m}}}`;
4688
+ const x = `{{${m}}}`;
4735
4689
  u.commands.focus();
4736
- const { from: f, to: x } = u.state.selection;
4737
- if (f !== x)
4738
- u.chain().deleteSelection().insertContent(h).run();
4690
+ const { from: f, to: h } = u.state.selection;
4691
+ if (f !== h)
4692
+ u.chain().deleteSelection().insertContent(x).run();
4739
4693
  else {
4740
- const { state: y } = u, B = y.selection.from, E = y.doc.textBetween(Math.max(0, B - 1), B), w = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4741
- let _ = "";
4742
- B > 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));
4743
4695
  let j = "";
4744
- w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + h + j).run();
4696
+ A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (j = " ");
4697
+ let _ = "";
4698
+ C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
4745
4699
  }
4746
4700
  };
4747
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: [
@@ -4777,12 +4731,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4777
4731
  ],
4778
4732
  content: r || "",
4779
4733
  onUpdate: ({ editor: f }) => {
4780
- const x = f.getHTML();
4781
- a(x), c || u(x);
4734
+ const h = f.getHTML();
4735
+ a(h), c || u(h);
4782
4736
  },
4783
4737
  onBlur: ({ editor: f }) => {
4784
- const x = f.getHTML();
4785
- l(o, x);
4738
+ const h = f.getHTML();
4739
+ l(o, h);
4786
4740
  },
4787
4741
  editorProps: {
4788
4742
  attributes: {
@@ -4797,7 +4751,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4797
4751
  }, [r]);
4798
4752
  const m = (f) => {
4799
4753
  a(f);
4800
- }, h = () => {
4754
+ }, x = () => {
4801
4755
  d(!1), g && g.commands.setContent(p);
4802
4756
  };
4803
4757
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4809,7 +4763,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4809
4763
  RTEModal,
4810
4764
  {
4811
4765
  isOpen: c,
4812
- onClose: h,
4766
+ onClose: x,
4813
4767
  id: o,
4814
4768
  value: p,
4815
4769
  onChange: m,
@@ -4823,41 +4777,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4823
4777
  onChange: r
4824
4778
  }) => {
4825
4779
  var L;
4826
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), B = 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;
4827
4781
  useEffect(() => {
4828
- if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4829
- const v = split(o, ":"), k = get(v, 1, "page") || "page";
4830
- g(k), (async () => {
4831
- const A = await l(k, [get(v, 2, "page")]);
4832
- A && Array.isArray(A) && h(get(A, [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"], ""));
4833
4787
  })();
4834
4788
  }, [o]);
4835
- const w = useDebouncedCallback(
4789
+ const C = useDebouncedCallback(
4836
4790
  async (v) => {
4837
4791
  if (isEmpty(v))
4838
- x([]);
4792
+ h([]);
4839
4793
  else {
4840
- const k = await l(u, v);
4841
- x(k);
4794
+ const y = await l(u, v);
4795
+ h(y);
4842
4796
  }
4843
- c(!1), y(-1);
4797
+ c(!1), k(-1);
4844
4798
  },
4845
4799
  [u],
4846
4800
  300
4847
- ), _ = (v) => {
4848
- const k = ["pageType", u, v.id];
4849
- k[1] && (r(k.join(":")), h(v.name), p(!1), x([]), y(-1));
4850
- }, 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) => {
4851
4805
  switch (v.key) {
4852
4806
  case "ArrowDown":
4853
- v.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
4807
+ v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
4854
4808
  break;
4855
4809
  case "ArrowUp":
4856
- v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4810
+ v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
4857
4811
  break;
4858
4812
  case "Enter":
4859
4813
  if (v.preventDefault(), f.length === 0) return;
4860
- b >= 0 && _(f[b]);
4814
+ b >= 0 && j(f[b]);
4861
4815
  break;
4862
4816
  case "Escape":
4863
4817
  v.preventDefault(), S();
@@ -4865,15 +4819,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4865
4819
  }
4866
4820
  };
4867
4821
  useEffect(() => {
4868
- if (b >= 0 && B.current) {
4869
- const v = B.current.children[b];
4822
+ if (b >= 0 && A.current) {
4823
+ const v = A.current.children[b];
4870
4824
  v == null || v.scrollIntoView({ block: "nearest" });
4871
4825
  }
4872
4826
  }, [b]);
4873
4827
  const S = () => {
4874
- h(""), x([]), y(-1), p(!1), r("");
4875
- }, C = (v) => {
4876
- h(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);
4877
4831
  };
4878
4832
  return /* @__PURE__ */ jsxs("div", { children: [
4879
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)) }),
@@ -4883,9 +4837,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4883
4837
  {
4884
4838
  type: "text",
4885
4839
  value: m,
4886
- onChange: (v) => C(v.target.value),
4887
- onKeyDown: j,
4888
- placeholder: a(`Search ${E ?? ""}`),
4840
+ onChange: (v) => w(v.target.value),
4841
+ onKeyDown: _,
4842
+ placeholder: a(`Search ${B ?? ""}`),
4889
4843
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4890
4844
  }
4891
4845
  ),
@@ -4899,11 +4853,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4899
4853
  ' "',
4900
4854
  m,
4901
4855
  '"'
4902
- ] }) : /* @__PURE__ */ jsx("ul", { ref: B, 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(
4903
4857
  "li",
4904
4858
  {
4905
- onClick: () => _(v),
4906
- 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"}`,
4907
4861
  children: [
4908
4862
  v.name,
4909
4863
  " ",
@@ -4997,29 +4951,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4997
4951
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4998
4952
  }, [o, u]);
4999
4953
  const m = () => {
5000
- const x = findIndex(u, { _id: g });
5001
- if (x > -1) {
5002
- const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
5003
- if (!y) return;
5004
- n({ ...o, currentSlide: y }), c([y]);
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]);
5005
4959
  }
5006
- }, h = () => {
5007
- const x = findIndex(u, { _id: g });
5008
- if (x > -1) {
5009
- const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
5010
- if (!y) return;
5011
- 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]);
5012
4966
  }
5013
4967
  }, f = () => {
5014
- const x = i(
4968
+ const h = i(
5015
4969
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
5016
4970
  p == null ? void 0 : p._id
5017
- ), b = x == null ? void 0 : x._id;
4971
+ ), b = h == null ? void 0 : h._id;
5018
4972
  b && (n({ ...o, currentSlide: b }), c([b]));
5019
4973
  };
5020
4974
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
5021
4975
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
5022
- /* @__PURE__ */ jsx("button", { onClick: h, 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]" }) }),
5023
4977
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
5024
4978
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
5025
4979
  " ",
@@ -5093,8 +5047,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5093
5047
  value: o == null ? void 0 : o.autoplayInterval,
5094
5048
  className: "text-xs",
5095
5049
  pattern: "[0-9]*",
5096
- onChange: (x) => {
5097
- let b = x.target.value;
5050
+ onChange: (h) => {
5051
+ let b = h.target.value;
5098
5052
  b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5099
5053
  }
5100
5054
  }
@@ -5134,65 +5088,65 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5134
5088
  formData: g,
5135
5089
  onChange: m
5136
5090
  }) => {
5137
- const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty$1(x) ? "" : isEmpty$1(h) ? f : h, y = get$1(LANGUAGES, b, b), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get$1(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5138
- (k) => {
5139
- const A = (N) => /[.,!?;:]/.test(N), T = (N, D, $) => {
5140
- let R = "", O = "";
5141
- const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5142
- return D > 0 && (M === "." || !A(M) && M !== " ") && (R = " "), D < N.length && !A(H) && H !== " " && (O = " "), {
5143
- text: R + $ + O,
5144
- 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,
5145
5099
  suffixLength: O.length
5146
5100
  };
5147
5101
  }, I = document.getElementById(o);
5148
5102
  if (!I) return;
5149
- const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5150
- if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5151
- const N = P.__chaiRTE;
5152
- if (N) {
5153
- const D = `{{${k}}}`;
5154
- N.commands.focus();
5155
- const { from: $, to: R } = N.state.selection;
5156
- if ($ !== R)
5157
- 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();
5158
5112
  else {
5159
- const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.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));
5160
5114
  let z = "";
5161
- H > 0 && F !== " " && !A(F) && (z = " ");
5115
+ H > 0 && U !== " " && !E(U) && (z = " ");
5162
5116
  let W = "";
5163
- U && U !== " " && !A(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5117
+ F && F !== " " && !E(F) && (W = " "), P.chain().insertContent(z + N + W).run();
5164
5118
  }
5165
- setTimeout(() => m(N.getHTML(), {}, o), 100);
5119
+ setTimeout(() => m(P.getHTML(), {}, o), 100);
5166
5120
  return;
5167
5121
  }
5168
5122
  } else {
5169
- const N = I, D = N.selectionStart || 0, $ = N.value || "", R = N.selectionEnd || D;
5170
- if (R > D) {
5171
- const U = `{{${k}}}`, { text: z } = T($, D, U), W = $.slice(0, D) + z + $.slice(R);
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);
5172
5126
  m(W, {}, o);
5173
5127
  return;
5174
5128
  }
5175
- const M = `{{${k}}}`, { text: H } = T($, D, M), F = $.slice(0, D) + H + $.slice(D);
5176
- m(F, {}, o);
5129
+ const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
5130
+ m(U, {}, o);
5177
5131
  }
5178
5132
  },
5179
- [o, m, g, E == null ? void 0 : E._id]
5133
+ [o, m, g, B == null ? void 0 : B._id]
5180
5134
  );
5181
5135
  if (d)
5182
5136
  return null;
5183
5137
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5184
- const v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
5138
+ const v = j == null ? void 0 : j.includes(o.replace("root.", ""));
5185
5139
  if (u.type === "array") {
5186
- const k = j === o;
5140
+ const y = _ === o;
5187
5141
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5188
5142
  u.title && /* @__PURE__ */ jsxs(
5189
5143
  "label",
5190
5144
  {
5191
5145
  htmlFor: o,
5192
- onClick: () => S(k ? null : o),
5146
+ onClick: () => S(y ? null : o),
5193
5147
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5194
5148
  children: [
5195
- 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" }),
5196
5150
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
5197
5151
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
5198
5152
  " ",
@@ -5200,7 +5154,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5200
5154
  ]
5201
5155
  }
5202
5156
  ),
5203
- (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: [
5204
5158
  c,
5205
5159
  a,
5206
5160
  l,
@@ -5215,11 +5169,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5215
5169
  " ",
5216
5170
  v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5217
5171
  " ",
5218
- y
5172
+ k
5219
5173
  ] }),
5220
5174
  p && u.type !== "object" ? " *" : null
5221
5175
  ] }),
5222
- u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
5176
+ u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
5223
5177
  ] }),
5224
5178
  c,
5225
5179
  a,
@@ -5274,8 +5228,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5274
5228
  formData: a,
5275
5229
  onChange: ({ formData: g }, m) => {
5276
5230
  if (!m || o !== (g == null ? void 0 : g._id)) return;
5277
- const h = take(m.split("."), 2).join(".").replace("root.", "");
5278
- u({ formData: g }, h);
5231
+ const x = take(m.split("."), 2).join(".").replace("root.", "");
5232
+ u({ formData: g }, x);
5279
5233
  }
5280
5234
  },
5281
5235
  i
@@ -5318,35 +5272,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5318
5272
  }), a;
5319
5273
  };
5320
5274
  function BlockSettings() {
5321
- 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), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, S, C) => {
5322
- S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5323
- }, x = useCallback(
5324
- debounce(({ formData: j }, S, C) => {
5325
- 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(_);
5326
5280
  }, 1500),
5327
5281
  [n == null ? void 0 : n._id, o]
5328
- ), b = ({ formData: j }, S) => {
5329
- S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5330
- }, y = ({ formData: j }, S) => {
5331
- 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) }));
5332
5286
  };
5333
5287
  keys(get(i, "_bindings", {}));
5334
- const { schema: B, uiSchema: E } = useMemo(() => {
5335
- const j = n == null ? void 0 : n._type;
5336
- if (j)
5337
- return getBlockFormSchemas(j);
5338
- }, [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(() => {
5339
5293
  if (!g || !(g != null && g._type))
5340
5294
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5341
- const j = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: C = {} } = getBlockFormSchemas(j);
5342
- return { wrapperSchema: S, wrapperUiSchema: C };
5295
+ const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: w = {} } = getBlockFormSchemas(_);
5296
+ return { wrapperSchema: S, wrapperUiSchema: w };
5343
5297
  }, [g]);
5344
5298
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5345
5299
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5346
5300
  /* @__PURE__ */ jsxs(
5347
5301
  "div",
5348
5302
  {
5349
- onClick: () => u((j) => !j),
5303
+ onClick: () => u((_) => !_),
5350
5304
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5351
5305
  children: [
5352
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" }),
@@ -5365,21 +5319,21 @@ function BlockSettings() {
5365
5319
  JSONForm,
5366
5320
  {
5367
5321
  blockId: g == null ? void 0 : g._id,
5368
- onChange: y,
5369
- formData: h,
5370
- schema: w,
5371
- uiSchema: _
5322
+ onChange: k,
5323
+ formData: x,
5324
+ schema: C,
5325
+ uiSchema: j
5372
5326
  }
5373
5327
  ) })
5374
5328
  ] }),
5375
- isEmpty(B) ? null : /* @__PURE__ */ jsx(
5329
+ isEmpty(A) ? null : /* @__PURE__ */ jsx(
5376
5330
  JSONForm,
5377
5331
  {
5378
5332
  blockId: n == null ? void 0 : n._id,
5379
5333
  onChange: b,
5380
5334
  formData: i,
5381
- schema: B,
5382
- uiSchema: E
5335
+ schema: A,
5336
+ uiSchema: B
5383
5337
  }
5384
5338
  ),
5385
5339
  (n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
@@ -5484,32 +5438,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5484
5438
  canvas: n = !1,
5485
5439
  tooltip: r = !0
5486
5440
  }) => {
5487
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5488
- u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5489
- }, x = (y) => {
5490
- 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);
5491
5445
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
5492
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
5446
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
5493
5447
  BreakpointCard,
5494
5448
  {
5495
5449
  canvas: n,
5496
- ...y,
5497
- onClick: x,
5498
- key: y.breakpoint,
5450
+ ...k,
5451
+ onClick: h,
5452
+ key: k.breakpoint,
5499
5453
  currentBreakpoint: b
5500
5454
  }
5501
5455
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5502
5456
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5503
- h.filter((y) => includes(u, toUpper(y.breakpoint))),
5504
- (y) => /* @__PURE__ */ createElement(
5457
+ x.filter((k) => includes(u, toUpper(k.breakpoint))),
5458
+ (k) => /* @__PURE__ */ createElement(
5505
5459
  BreakpointCard,
5506
5460
  {
5507
5461
  canvas: n,
5508
5462
  openDelay: o,
5509
5463
  tooltip: r,
5510
- ...y,
5511
- onClick: x,
5512
- key: y.breakpoint,
5464
+ ...k,
5465
+ onClick: h,
5466
+ key: k.breakpoint,
5513
5467
  currentBreakpoint: b
5514
5468
  }
5515
5469
  )
@@ -5519,15 +5473,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5519
5473
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5520
5474
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
5521
5475
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5522
- map(h, (y) => /* @__PURE__ */ jsx(
5476
+ map(x, (k) => /* @__PURE__ */ jsx(
5523
5477
  DropdownMenuCheckboxItem,
5524
5478
  {
5525
- disabled: y.breakpoint === "xs",
5526
- onCheckedChange: () => f(toUpper(y.breakpoint)),
5527
- checked: includes(u, toUpper(y.breakpoint)),
5528
- children: m(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)
5529
5483
  },
5530
- y.breakpoint
5484
+ k.breakpoint
5531
5485
  ))
5532
5486
  ] })
5533
5487
  ] })
@@ -5604,11 +5558,11 @@ function Countdown() {
5604
5558
  const AskAIStyles = ({ blockId: o }) => {
5605
5559
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5606
5560
  useEffect(() => {
5607
- var h;
5608
- (h = d.current) == null || h.focus();
5561
+ var x;
5562
+ (x = d.current) == null || x.focus();
5609
5563
  }, []);
5610
- const m = (h) => {
5611
- const { usage: f } = h || {};
5564
+ const m = (x) => {
5565
+ const { usage: f } = x || {};
5612
5566
  !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5613
5567
  };
5614
5568
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5618,12 +5572,12 @@ const AskAIStyles = ({ blockId: o }) => {
5618
5572
  {
5619
5573
  ref: d,
5620
5574
  value: i,
5621
- onChange: (h) => c(h.target.value),
5575
+ onChange: (x) => c(x.target.value),
5622
5576
  placeholder: n("Ask AI to edit styles"),
5623
5577
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5624
5578
  rows: 4,
5625
- onKeyDown: (h) => {
5626
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5579
+ onKeyDown: (x) => {
5580
+ x.key === "Enter" && (x.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5627
5581
  }
5628
5582
  }
5629
5583
  ),
@@ -5665,24 +5619,24 @@ const AskAIStyles = ({ blockId: o }) => {
5665
5619
  };
5666
5620
  function ManualClasses() {
5667
5621
  var T;
5668
- 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(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = 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 = () => {
5669
5623
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5670
- u(m, I, !0), x("");
5671
- }, [w, _] = useState([]), j = ({ value: I }) => {
5672
- const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5673
- let D = [];
5674
- if (N && N.length > 0) {
5675
- const [$] = N, R = P.replace($, "");
5676
- D = i.search(R).map((M) => ({
5677
- ...M,
5678
- item: { ...M.item, name: $ + M.item.name }
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(($) => ({
5631
+ ...$,
5632
+ item: { ...$.item, name: M + $.item.name }
5679
5633
  }));
5680
5634
  } else
5681
- D = i.search(P);
5682
- return _(map(D, "item"));
5635
+ N = i.search(R);
5636
+ return j(map(N, "item"));
5683
5637
  }, S = () => {
5684
- _([]);
5685
- }, 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(
5686
5640
  () => ({
5687
5641
  ref: o,
5688
5642
  autoComplete: "off",
@@ -5692,33 +5646,33 @@ function ManualClasses() {
5692
5646
  placeholder: c("Enter classes separated by space"),
5693
5647
  value: f,
5694
5648
  onKeyDown: (I) => {
5695
- I.key === "Enter" && f.trim() !== "" && E();
5649
+ I.key === "Enter" && f.trim() !== "" && B();
5696
5650
  },
5697
- onChange: (I, { newValue: P }) => x(P),
5651
+ onChange: (I, { newValue: R }) => h(R),
5698
5652
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5699
5653
  }),
5700
5654
  [f, c, o]
5701
- ), k = (I) => {
5655
+ ), y = (I) => {
5702
5656
  debugger;
5703
- const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5704
- g(m, [I]), u(m, P, !0), r(""), l(-1);
5705
- }, A = () => {
5657
+ const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5658
+ g(m, [I]), u(m, R, !0), r(""), l(-1);
5659
+ }, E = () => {
5706
5660
  if (navigator.clipboard === void 0) {
5707
5661
  toast.error(c("Clipboard not supported"));
5708
5662
  return;
5709
5663
  }
5710
- navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
5664
+ navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5711
5665
  };
5712
5666
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5713
5667
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5714
5668
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5715
5669
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5716
5670
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5717
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: A, className: "cursor-pointer" }) }),
5671
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5718
5672
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5719
5673
  ] })
5720
5674
  ] }),
5721
- h ? /* @__PURE__ */ jsxs(Popover, { children: [
5675
+ x ? /* @__PURE__ */ jsxs(Popover, { children: [
5722
5676
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5723
5677
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5724
5678
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5730,10 +5684,10 @@ function ManualClasses() {
5730
5684
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5731
5685
  Autosuggest,
5732
5686
  {
5733
- suggestions: w,
5734
- onSuggestionsFetchRequested: j,
5687
+ suggestions: C,
5688
+ onSuggestionsFetchRequested: _,
5735
5689
  onSuggestionsClearRequested: S,
5736
- getSuggestionValue: C,
5690
+ getSuggestionValue: w,
5737
5691
  renderSuggestion: L,
5738
5692
  inputProps: v,
5739
5693
  containerProps: {
@@ -5751,25 +5705,25 @@ function ManualClasses() {
5751
5705
  {
5752
5706
  variant: "outline",
5753
5707
  className: "h-6 border-border",
5754
- onClick: E,
5708
+ onClick: B,
5755
5709
  disabled: f.trim() === "",
5756
5710
  size: "sm",
5757
5711
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5758
5712
  }
5759
5713
  )
5760
5714
  ] }),
5761
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5762
- (I, P) => a === P ? /* @__PURE__ */ jsx(
5715
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5716
+ (I, R) => a === R ? /* @__PURE__ */ jsx(
5763
5717
  "input",
5764
5718
  {
5765
5719
  ref: o,
5766
5720
  value: n,
5767
- onChange: (N) => r(N.target.value),
5721
+ onChange: (P) => r(P.target.value),
5768
5722
  onBlur: () => {
5769
- k(I);
5723
+ y(I);
5770
5724
  },
5771
- onKeyDown: (N) => {
5772
- N.key === "Enter" && k(I);
5725
+ onKeyDown: (P) => {
5726
+ P.key === "Enter" && y(I);
5773
5727
  },
5774
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"
5775
5729
  },
@@ -6129,10 +6083,10 @@ const COLOR_PROP = {
6129
6083
  ringColor: "ring",
6130
6084
  ringOffsetColor: "ring-offset"
6131
6085
  }, ColorChoice = ({ property: o, onChange: n }) => {
6132
- 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", ""), h = 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(
6133
6087
  // eslint-disable-next-line no-shadow
6134
6088
  (b) => {
6135
- ["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" })));
6136
6090
  },
6137
6091
  [c, p]
6138
6092
  );
@@ -6151,18 +6105,18 @@ const COLOR_PROP = {
6151
6105
  useEffect(() => {
6152
6106
  p({ color: "", shade: "" });
6153
6107
  }, [r]);
6154
- const { match: x } = useTailwindClassList();
6108
+ const { match: h } = useTailwindClassList();
6155
6109
  return useEffect(() => {
6156
- const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6157
- x(o, y) && n(y, o);
6158
- }, [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: [
6159
6113
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6160
6114
  DropDown,
6161
6115
  {
6162
6116
  disabled: !l,
6163
6117
  rounded: !0,
6164
6118
  selected: g,
6165
- onChange: h,
6119
+ onChange: x,
6166
6120
  options: [
6167
6121
  "current",
6168
6122
  "transparent",
@@ -6392,50 +6346,50 @@ const COLOR_PROP = {
6392
6346
  },
6393
6347
  a
6394
6348
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6395
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [B, 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);
6396
6350
  useEffect(() => {
6397
- const { value: v, unit: k } = getClassValueAndUnit(i);
6398
- if (k === "") {
6399
- l(v), h(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));
6400
6354
  return;
6401
6355
  }
6402
- h(k), l(k === "class" || isEmpty(v) ? "" : v);
6356
+ x(y), l(y === "class" || isEmpty(v) ? "" : v);
6403
6357
  }, [i, p, u]);
6404
- 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(
6405
6359
  (v = !1) => {
6406
- const k = getUserInputValues(`${a}`, u);
6407
- if (get(k, "error", !1)) {
6408
- x(!0);
6360
+ const y = getUserInputValues(`${a}`, u);
6361
+ if (get(y, "error", !1)) {
6362
+ h(!0);
6409
6363
  return;
6410
6364
  }
6411
- const A = get(k, "unit") !== "" ? get(k, "unit") : m;
6412
- if (A === "auto" || A === "none") {
6413
- j(`${d}${A}`);
6365
+ const E = get(y, "unit") !== "" ? get(y, "unit") : m;
6366
+ if (E === "auto" || E === "none") {
6367
+ _(`${d}${E}`);
6414
6368
  return;
6415
6369
  }
6416
- if (get(k, "value") === "")
6370
+ if (get(y, "value") === "")
6417
6371
  return;
6418
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6419
- v ? S(I) : j(I);
6372
+ const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6373
+ v ? S(I) : _(I);
6420
6374
  },
6421
- [j, S, a, m, d, u]
6375
+ [_, S, a, m, d, u]
6422
6376
  ), L = useCallback(
6423
6377
  (v) => {
6424
- const k = getUserInputValues(`${a}`, u);
6425
- if (get(k, "error", !1)) {
6426
- x(!0);
6378
+ const y = getUserInputValues(`${a}`, u);
6379
+ if (get(y, "error", !1)) {
6380
+ h(!0);
6427
6381
  return;
6428
6382
  }
6429
6383
  if (v === "auto" || v === "none") {
6430
- j(`${d}${v}`);
6384
+ _(`${d}${v}`);
6431
6385
  return;
6432
6386
  }
6433
- if (get(k, "value") === "")
6387
+ if (get(y, "value") === "")
6434
6388
  return;
6435
- const A = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6436
- 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);
6437
6391
  },
6438
- [j, a, d, u]
6392
+ [_, a, d, u]
6439
6393
  );
6440
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: [
6441
6395
  /* @__PURE__ */ jsx(
@@ -6450,37 +6404,37 @@ const COLOR_PROP = {
6450
6404
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
6451
6405
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6452
6406
  ] })
6453
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6407
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6454
6408
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6455
6409
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6456
6410
  "input",
6457
6411
  {
6458
6412
  readOnly: m === "class",
6459
6413
  onKeyPress: (v) => {
6460
- v.key === "Enter" && C();
6414
+ v.key === "Enter" && w();
6461
6415
  },
6462
6416
  onKeyDown: (v) => {
6463
6417
  if (v.keyCode !== 38 && v.keyCode !== 40)
6464
6418
  return;
6465
- v.preventDefault(), _(!0);
6466
- const k = parseInt$1(v.target.value);
6467
- let A = isNaN$1(k) ? 0 : k;
6468
- v.keyCode === 38 && (A += 1), v.keyCode === 40 && (A -= 1);
6469
- const T = `${A}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6470
- 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);
6471
6425
  },
6472
6426
  onKeyUp: (v) => {
6473
- w && (v.preventDefault(), _(!1));
6427
+ C && (v.preventDefault(), j(!1));
6474
6428
  },
6475
- onBlur: () => C(),
6429
+ onBlur: () => w(),
6476
6430
  onChange: (v) => {
6477
- x(!1), l(v.target.value);
6431
+ h(!1), l(v.target.value);
6478
6432
  },
6479
6433
  onClick: (v) => {
6480
- var k;
6481
- (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);
6482
6436
  },
6483
- value: B ? b : a,
6437
+ value: A ? b : a,
6484
6438
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6485
6439
  " ",
6486
6440
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6506,27 +6460,27 @@ const COLOR_PROP = {
6506
6460
  units: u,
6507
6461
  current: m,
6508
6462
  onSelect: (v) => {
6509
- r(!1), h(v), L(v);
6463
+ r(!1), x(v), L(v);
6510
6464
  }
6511
6465
  }
6512
6466
  ) }) })
6513
6467
  ] })
6514
6468
  ] }),
6515
- ["none", "auto"].indexOf(m) !== -1 || B ? null : /* @__PURE__ */ jsx(
6469
+ ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6516
6470
  DragStyleButton,
6517
6471
  {
6518
- onDragStart: () => E(!0),
6472
+ onDragStart: () => B(!0),
6519
6473
  onDragEnd: (v) => {
6520
- if (y(() => ""), E(!1), isEmpty(v))
6474
+ if (k(() => ""), B(!1), isEmpty(v))
6521
6475
  return;
6522
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6523
- j(T);
6476
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6477
+ _(T);
6524
6478
  },
6525
6479
  onDrag: (v) => {
6526
6480
  if (isEmpty(v))
6527
6481
  return;
6528
- y(v);
6529
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6482
+ k(v);
6483
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6530
6484
  S(T);
6531
6485
  },
6532
6486
  currentValue: a,
@@ -6624,23 +6578,23 @@ const COLOR_PROP = {
6624
6578
  "2xl": "1536px"
6625
6579
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6626
6580
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6627
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6628
- (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) => {
6629
6583
  const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6630
6584
  (p || u !== "") && (L.mq = "xs");
6631
6585
  const v = generateFullClsName(L);
6632
- h(x, [v], C);
6586
+ x(h, [v], w);
6633
6587
  },
6634
- [x, p, g, u, l, h]
6635
- ), B = useCallback(() => {
6636
- f(x, [b], !0);
6637
- }, [x, b, f]), E = useMemo(() => canChangeClass(m, g), [m, g]);
6588
+ [h, p, g, u, l, x]
6589
+ ), A = useCallback(() => {
6590
+ f(h, [b], !0);
6591
+ }, [h, b, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
6638
6592
  useEffect(() => {
6639
- i(E, m);
6640
- }, [E, i, m]);
6641
- const [, , w] = useScreenSizeWidth(), _ = useCallback(
6593
+ i(B, m);
6594
+ }, [B, i, m]);
6595
+ const [, , C] = useScreenSizeWidth(), j = useCallback(
6642
6596
  (S) => {
6643
- w({
6597
+ C({
6644
6598
  xs: 400,
6645
6599
  sm: 640,
6646
6600
  md: 800,
@@ -6649,10 +6603,10 @@ const COLOR_PROP = {
6649
6603
  "2xl": 1920
6650
6604
  }[S]);
6651
6605
  },
6652
- [w]
6653
- ), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6654
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6655
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !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) }) }),
6656
6610
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6657
6611
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6658
6612
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6661,17 +6615,17 @@ const COLOR_PROP = {
6661
6615
  currentClass: get(m, "cls", ""),
6662
6616
  classPrefix: get(CLASS_PREFIXES, l, ""),
6663
6617
  units: c || [],
6664
- onChange: y,
6618
+ onChange: k,
6665
6619
  negative: d,
6666
6620
  cssProperty: l
6667
6621
  }
6668
6622
  ) : null,
6669
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6670
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6671
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6672
- 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 })
6673
6627
  ] }),
6674
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), 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 && m ? /* @__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: [
6675
6629
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6676
6630
  "button",
6677
6631
  {
@@ -6691,7 +6645,7 @@ const COLOR_PROP = {
6691
6645
  "button",
6692
6646
  {
6693
6647
  type: "button",
6694
- onClick: () => _(get(m, "mq")),
6648
+ onClick: () => j(get(m, "mq")),
6695
6649
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6696
6650
  children: [
6697
6651
  "Switch to ",
@@ -6712,7 +6666,7 @@ const COLOR_PROP = {
6712
6666
  units: i = basicUnits,
6713
6667
  negative: c = !1
6714
6668
  }) => {
6715
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6669
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((x) => map(g, "property").includes(x), [g]);
6716
6670
  return /* @__PURE__ */ jsxs(
6717
6671
  "div",
6718
6672
  {
@@ -6721,7 +6675,7 @@ const COLOR_PROP = {
6721
6675
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6722
6676
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6723
6677
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6724
- n.map(({ label: h, 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: [
6725
6679
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6726
6680
  "button",
6727
6681
  {
@@ -6736,7 +6690,7 @@ const COLOR_PROP = {
6736
6690
  ]
6737
6691
  }
6738
6692
  ) }),
6739
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
6693
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(x)) })
6740
6694
  ] }) }))
6741
6695
  ) })
6742
6696
  ] }),
@@ -6876,11 +6830,11 @@ function BlockStyling() {
6876
6830
  }), d = useThrottledCallback(
6877
6831
  (u) => {
6878
6832
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6879
- let h = parseFloat(i.dragStartValue);
6880
- h = isNaN(h) ? 0 : h;
6833
+ let x = parseFloat(i.dragStartValue);
6834
+ x = isNaN(x) ? 0 : x;
6881
6835
  let f = MAPPER[i.dragUnit];
6882
6836
  (startsWith(m, "scale") || m === "opacity") && (f = 10);
6883
- let b = (i.dragStartY - u.pageY) / f + h;
6837
+ let b = (i.dragStartY - u.pageY) / f + x;
6884
6838
  g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6885
6839
  },
6886
6840
  [i],
@@ -6917,26 +6871,30 @@ function BlockStyling() {
6917
6871
  ] })
6918
6872
  ] });
6919
6873
  }
6920
- 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 = ({
6921
6879
  block: o,
6922
6880
  disabled: n,
6923
6881
  parentId: r,
6924
6882
  position: a
6925
6883
  }) => {
6926
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6884
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
6927
6885
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6928
6886
  const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6929
6887
  u(syncBlocksWithDefaults(b), r || null, a);
6930
6888
  } else
6931
6889
  p(o, r || null, a);
6932
6890
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6933
- }, f = useFeature("dnd"), { t: x } = useTranslation();
6891
+ }, f = useFeature("dnd"), { t: h } = useTranslation();
6934
6892
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6935
6893
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6936
6894
  "button",
6937
6895
  {
6938
6896
  disabled: n,
6939
- onClick: h,
6897
+ onClick: x,
6940
6898
  type: "button",
6941
6899
  onDragStart: (b) => {
6942
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(() => {
@@ -6947,11 +6905,11 @@ const CoreBlock = ({
6947
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",
6948
6906
  children: [
6949
6907
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6950
- /* @__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)) })
6951
6909
  ]
6952
6910
  }
6953
6911
  ) }),
6954
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6912
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(d || i) }) })
6955
6913
  ] }) });
6956
6914
  }, DefaultChaiBlocks = ({
6957
6915
  parentId: o,
@@ -7139,22 +7097,22 @@ const CoreBlock = ({
7139
7097
  }
7140
7098
  }
7141
7099
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7142
- var m, h, f, x, b, y, B, E;
7100
+ var m, x, f, h, b, k, A, B;
7143
7101
  if (r.type === "comment") return [];
7144
7102
  console.log("node ===>", r);
7145
7103
  let a = { _id: generateUUID() };
7146
7104
  if (n && (a._parent = n.block._id), r.type === "text")
7147
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", "") };
7148
7106
  const l = get(r, "attributes", []), i = l.find(
7149
- (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7107
+ (C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
7150
7108
  ), c = l.find(
7151
- (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7109
+ (C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
7152
7110
  ), d = l.find(
7153
- (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7111
+ (C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
7154
7112
  ), p = l.find(
7155
- (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"
7156
7114
  ), u = l.find(
7157
- (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"
7158
7116
  );
7159
7117
  if (a = {
7160
7118
  ...a,
@@ -7162,13 +7120,13 @@ const CoreBlock = ({
7162
7120
  ...getAttrs(r),
7163
7121
  ...getStyles(r)
7164
7122
  }, r.attributes) {
7165
- const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
7166
- w && (a._name = w.value);
7123
+ const C = r.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
7124
+ C && (a._name = C.value);
7167
7125
  }
7168
7126
  if (i)
7169
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];
7170
7128
  if (c) {
7171
- const w = [
7129
+ const C = [
7172
7130
  "data-chai-lightbox",
7173
7131
  "chai-lightbox",
7174
7132
  "data-vbtype",
@@ -7180,44 +7138,44 @@ const CoreBlock = ({
7180
7138
  ];
7181
7139
  a = {
7182
7140
  ...a,
7183
- href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
7184
- hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
7185
- autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7186
- maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7187
- backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
7188
- galleryName: ((B = l.find((_) => _.key === "data-gall")) == null ? void 0 : B.value) || ""
7189
- }, forEach(w, (_) => {
7190
- 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];
7191
7149
  });
7192
7150
  }
7193
7151
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7194
7152
  delete a.styles_attrs;
7195
- const w = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
7196
- a.content = getTextContent(w);
7197
- const _ = find(
7153
+ const C = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
7154
+ a.content = getTextContent(C);
7155
+ const j = find(
7198
7156
  r.children || [],
7199
- (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")
7200
7158
  );
7201
- if (_) {
7202
- const j = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7203
- if (j) {
7204
- a.icon = stringify([j]);
7205
- const { height: S, width: C } = getSvgDimensions(j, "16px", "16px");
7206
- 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;
7207
7165
  }
7208
7166
  }
7209
7167
  return [a];
7210
7168
  }
7211
7169
  if (a._type === "Input") {
7212
- const w = a.inputType || "text";
7213
- 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");
7214
7172
  } else if (r.tagName === "video" || r.tagName === "iframe") {
7215
- const w = stringify([r]);
7216
- 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];
7217
7175
  } else if (r.tagName === "svg") {
7218
- 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");
7219
- 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];
7220
- } 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")
7221
7179
  return n.block.options.push({
7222
7180
  label: getTextContent(r.children),
7223
7181
  ...getAttrs(r)
@@ -7290,29 +7248,29 @@ const CoreBlock = ({
7290
7248
  error: c
7291
7249
  }), g(!0);
7292
7250
  else if (!l && Object.keys(a || {}).length > 0) {
7293
- const h = Object.entries(a).map(([x, b]) => {
7294
- const y = b, B = y.type || "partial", E = formatReadableName(B);
7251
+ const x = Object.entries(a).map(([h, b]) => {
7252
+ const k = b, A = k.type || "partial", B = formatReadableName(A);
7295
7253
  return {
7296
7254
  type: "PartialBlock",
7297
7255
  // Set the type to PartialBlock
7298
- label: formatReadableName(y.name || x),
7299
- description: y.description || "",
7256
+ label: formatReadableName(k.name || h),
7257
+ description: k.description || "",
7300
7258
  icon: Globe,
7301
- group: E,
7259
+ group: B,
7302
7260
  // Use formatted type as group
7303
7261
  category: "partial",
7304
- partialBlockId: x,
7262
+ partialBlockId: h,
7305
7263
  // Store the original ID as partialBlockId
7306
- _name: y.name
7264
+ _name: k.name
7307
7265
  };
7308
- }), f = uniq(map(h, "group"));
7266
+ }), f = uniq(map(x, "group"));
7309
7267
  p({
7310
- blocks: h,
7268
+ blocks: x,
7311
7269
  groups: f,
7312
7270
  isLoading: !1,
7313
7271
  error: null
7314
7272
  }), g(!0);
7315
- } else l ? p((h) => ({ ...h, 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({
7316
7274
  blocks: [],
7317
7275
  groups: [],
7318
7276
  isLoading: !1,
@@ -7328,7 +7286,7 @@ const CoreBlock = ({
7328
7286
  c
7329
7287
  ]);
7330
7288
  const m = () => {
7331
- p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7289
+ p((x) => ({ ...x, isLoading: !0, error: null })), g(!1), i();
7332
7290
  };
7333
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: [
7334
7292
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
@@ -7352,43 +7310,43 @@ const CoreBlock = ({
7352
7310
  );
7353
7311
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7354
7312
  var v;
7355
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [h, 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);
7356
7314
  useEffect(() => {
7357
- const k = setTimeout(() => {
7358
- var A;
7359
- (A = u.current) == null || A.focus();
7315
+ const y = setTimeout(() => {
7316
+ var E;
7317
+ (E = u.current) == null || E.focus();
7360
7318
  }, 0);
7361
- return () => clearTimeout(k);
7319
+ return () => clearTimeout(y);
7362
7320
  }, [g]), useEffect(() => {
7363
7321
  d && (f("all"), b(null));
7364
- }, [d]), useEffect(() => (y.current = debounce((k) => {
7365
- f(k);
7322
+ }, [d]), useEffect(() => (k.current = debounce((y) => {
7323
+ f(y);
7366
7324
  }, 500), () => {
7367
- y.current && y.current.cancel();
7325
+ k.current && k.current.cancel();
7368
7326
  }), []);
7369
- const B = useCallback((k) => {
7370
- b(k), y.current && y.current(k);
7371
- }, []), E = useCallback(() => {
7372
- b(null), y.current && y.current.cancel();
7373
- }, []), w = useCallback((k) => {
7374
- y.current && y.current.cancel(), f(k), b(null);
7375
- }, []), _ = 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(
7376
7334
  () => d ? values(n).filter(
7377
- (k) => {
7378
- var A, T;
7379
- return (((A = k.label) == null ? void 0 : A.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());
7380
7338
  }
7381
7339
  ) : n,
7382
7340
  [n, d]
7383
- ), j = useMemo(
7341
+ ), _ = useMemo(
7384
7342
  () => d ? o.filter(
7385
- (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7386
- ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7387
- [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]
7388
7346
  ), S = useMemo(
7389
- () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7390
- [j]
7391
- ), C = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), L = useMemo(() => h === "all" ? S : [h], [S, h]);
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]);
7392
7350
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7393
7351
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7394
7352
  Input$1,
@@ -7398,7 +7356,7 @@ const CoreBlock = ({
7398
7356
  placeholder: i("Search blocks..."),
7399
7357
  value: d,
7400
7358
  className: "-ml-2",
7401
- onChange: (k) => p(k.target.value)
7359
+ onChange: (y) => p(y.target.value)
7402
7360
  }
7403
7361
  ) }),
7404
7362
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7406,49 +7364,49 @@ const CoreBlock = ({
7406
7364
  /* @__PURE__ */ jsx(
7407
7365
  "button",
7408
7366
  {
7409
- onClick: () => w("all"),
7410
- onMouseEnter: () => B("all"),
7411
- onMouseLeave: E,
7412
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7367
+ onClick: () => C("all"),
7368
+ onMouseEnter: () => A("all"),
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"}`,
7413
7371
  children: i("All")
7414
7372
  },
7415
7373
  "sidebar-all"
7416
7374
  ),
7417
- S.map((k) => /* @__PURE__ */ jsx(
7375
+ S.map((y) => /* @__PURE__ */ jsx(
7418
7376
  "button",
7419
7377
  {
7420
- onClick: () => w(k),
7421
- onMouseEnter: () => B(k),
7422
- onMouseLeave: E,
7423
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7424
- 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()))
7425
7383
  },
7426
- `sidebar-${k}`
7384
+ `sidebar-${y}`
7427
7385
  ))
7428
7386
  ] }) }) }),
7429
- /* @__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: [
7430
7388
  i("No blocks found matching"),
7431
7389
  ' "',
7432
7390
  d,
7433
7391
  '"'
7434
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7435
- /* @__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())) }),
7436
7394
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7437
7395
  reject(
7438
- h === "all" ? filter(values(C), { group: k }) : values(C),
7396
+ x === "all" ? filter(values(w), { group: y }) : values(w),
7439
7397
  { hidden: !0 }
7440
- ).map((A) => /* @__PURE__ */ jsx(
7398
+ ).map((E) => /* @__PURE__ */ jsx(
7441
7399
  CoreBlock,
7442
7400
  {
7443
7401
  parentId: r,
7444
7402
  position: a,
7445
- block: A,
7446
- disabled: !canAcceptChildBlock(m, A.type) || !canBeNestedInside(m, A.type)
7403
+ block: E,
7404
+ disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
7447
7405
  },
7448
- A.type
7406
+ E.type
7449
7407
  ))
7450
7408
  ) })
7451
- ] }, k)) }) }) })
7409
+ ] }, y)) }) }) })
7452
7410
  ] })
7453
7411
  ] });
7454
7412
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7457,13 +7415,13 @@ const CoreBlock = ({
7457
7415
  parentId: r = void 0,
7458
7416
  position: a = -1
7459
7417
  }) => {
7460
- 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;
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();
7461
7419
  useEffect(() => {
7462
7420
  i === "partials" && !m && c("library");
7463
7421
  }, [i, m, c]);
7464
- const h = useCallback(() => {
7422
+ const f = useCallback(() => {
7465
7423
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7466
- }, []);
7424
+ }, []), h = p && x(PERMISSIONS.IMPORT_HTML);
7467
7425
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
7468
7426
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
7469
7427
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
@@ -7472,8 +7430,8 @@ const CoreBlock = ({
7472
7430
  /* @__PURE__ */ jsxs(
7473
7431
  Tabs,
7474
7432
  {
7475
- onValueChange: (f) => {
7476
- d(""), c(f);
7433
+ onValueChange: (b) => {
7434
+ d(""), c(b);
7477
7435
  },
7478
7436
  value: i,
7479
7437
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7482,14 +7440,14 @@ const CoreBlock = ({
7482
7440
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7483
7441
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7484
7442
  m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7485
- p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7486
- map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
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) }))
7487
7445
  ] }),
7488
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 }) }) }) }),
7489
7447
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7490
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 }) }) }) }),
7491
- 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,
7492
- map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: h, 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 }) }))
7493
7451
  ]
7494
7452
  }
7495
7453
  )
@@ -7546,18 +7504,18 @@ const BlockCard = ({
7546
7504
  parentId: r = void 0,
7547
7505
  position: a = -1
7548
7506
  }) => {
7549
- 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")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (B) => {
7550
- const E = has(B, "styles_attrs.data-page-section");
7551
- return B._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;
7552
7510
  }, b = useCallback(
7553
- async (B) => {
7554
- if (B.stopPropagation(), has(o, "component")) {
7511
+ async (A) => {
7512
+ if (A.stopPropagation(), has(o, "component")) {
7555
7513
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7556
7514
  return;
7557
7515
  }
7558
7516
  i(!0);
7559
- const E = await c(n, o);
7560
- 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);
7561
7519
  },
7562
7520
  [d, p, o, c, n, r, a]
7563
7521
  );
@@ -7567,20 +7525,20 @@ const BlockCard = ({
7567
7525
  {
7568
7526
  onClick: l ? () => {
7569
7527
  } : b,
7570
- draggable: h ? "true" : "false",
7571
- onDragStart: async (B) => {
7572
- const E = await c(n, o);
7573
- let w = r;
7574
- if (x(first(E)) && (w = null), !isEmpty(E)) {
7575
- const _ = { blocks: E, uiLibrary: !0, parent: w };
7576
- if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7577
- const j = new Image();
7578
- j.src = o.preview, j.onload = () => {
7579
- B.dataTransfer.setDragImage(j, 0, 0);
7528
+ draggable: x ? "true" : "false",
7529
+ onDragStart: async (A) => {
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);
7580
7538
  };
7581
7539
  } else
7582
- B.dataTransfer.setDragImage(new Image(), 0, 0);
7583
- f(_), setTimeout(() => {
7540
+ A.dataTransfer.setDragImage(new Image(), 0, 0);
7541
+ f(j), setTimeout(() => {
7584
7542
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7585
7543
  }, 200);
7586
7544
  }
@@ -7612,9 +7570,9 @@ const BlockCard = ({
7612
7570
  })();
7613
7571
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7614
7572
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7615
- 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"), [m, h] = useState("Hero"), f = get(g, m, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7616
- x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7617
- x.current && h(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);
7618
7576
  }, 300);
7619
7577
  };
7620
7578
  if (u)
@@ -7622,7 +7580,7 @@ const BlockCard = ({
7622
7580
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7623
7581
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7624
7582
  ] });
7625
- const B = 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);
7626
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: [
7627
7585
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7628
7586
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
@@ -7630,22 +7588,22 @@ const BlockCard = ({
7630
7588
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7631
7589
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7632
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(
7633
- map(g, (w, _) => /* @__PURE__ */ jsxs(
7591
+ map(g, (C, j) => /* @__PURE__ */ jsxs(
7634
7592
  "div",
7635
7593
  {
7636
- onMouseEnter: () => y(_),
7637
- onMouseLeave: () => clearTimeout(x.current),
7638
- onClick: () => h(_),
7594
+ onMouseEnter: () => k(j),
7595
+ onMouseLeave: () => clearTimeout(h.current),
7596
+ onClick: () => x(j),
7639
7597
  className: cn$1(
7640
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",
7641
- _ === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7599
+ j === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7642
7600
  ),
7643
7601
  children: [
7644
- /* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
7602
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(j.toLowerCase())) }),
7645
7603
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7646
7604
  ]
7647
7605
  },
7648
- _
7606
+ j
7649
7607
  ))
7650
7608
  ) })
7651
7609
  ] })
@@ -7653,15 +7611,15 @@ const BlockCard = ({
7653
7611
  /* @__PURE__ */ jsxs(
7654
7612
  ScrollArea,
7655
7613
  {
7656
- onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7614
+ onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
7657
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",
7658
7616
  children: [
7659
7617
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7660
7618
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7661
- B.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 }))
7662
7620
  ) }),
7663
7621
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7664
- 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 }))
7665
7623
  ) })
7666
7624
  ] }),
7667
7625
  /* @__PURE__ */ jsx("br", {}),
@@ -7671,7 +7629,18 @@ const BlockCard = ({
7671
7629
  }
7672
7630
  )
7673
7631
  ] }) }) });
7674
- }, 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 }) => {
7675
7644
  const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
7676
7645
  return useEffect(() => {
7677
7646
  a("root") || n(null);
@@ -7771,41 +7740,43 @@ const BlockCard = ({
7771
7740
  }
7772
7741
  );
7773
7742
  }, BlockContextMenuContent = ({ node: o }) => {
7774
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useBuilderProp("blockMoreOptions", []), c = useCallback(() => {
7743
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useBuilderProp("blockMoreOptions", []), d = useCallback(() => {
7775
7744
  a(r);
7776
7745
  }, [r, a]);
7777
7746
  return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
7778
- /* @__PURE__ */ jsxs(
7779
- DropdownMenuItem,
7780
- {
7781
- disabled: !canAddChildBlock(l == null ? void 0 : l._type),
7782
- className: "flex items-center gap-x-4 text-xs",
7783
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
7784
- children: [
7785
- /* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
7786
- " ",
7787
- n("Add block")
7788
- ]
7789
- }
7790
- ),
7791
- /* @__PURE__ */ jsxs(
7792
- DropdownMenuItem,
7793
- {
7794
- disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7795
- className: "flex items-center gap-x-4 text-xs",
7796
- onClick: c,
7797
- children: [
7798
- /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7799
- " ",
7800
- n("Duplicate")
7801
- ]
7802
- }
7803
- ),
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
+ ] }),
7804
7775
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
7805
- /* @__PURE__ */ jsx(CutBlocks, {}),
7806
- /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7807
- /* @__PURE__ */ jsx(RemoveBlocks, {}),
7808
- i.map((d, p) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(d, { block: l }) }, `more-${p}`))
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}`))
7809
7780
  ] });
7810
7781
  }, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
7811
7782
  const [, a] = useSelectedBlockIds();
@@ -7890,52 +7861,53 @@ const selectParent = (o, n) => {
7890
7861
  r.isInternal && n && r.close();
7891
7862
  }, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7892
7863
  var P;
7893
- const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7894
- let p = null;
7895
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: E } = o, w = (N) => {
7896
- N.stopPropagation(), !i.includes(h) && 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();
7897
7868
  }, _ = (N) => {
7898
- N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7899
- }, j = (N) => {
7900
- N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7901
- }, [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 = () => {
7902
7873
  var N;
7903
- v(), o.parent.isSelected || C((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7904
- }, v = () => {
7905
- C(null);
7906
- }, k = (N) => {
7907
- v(), N.stopPropagation(), !o.isOpen && !i.includes(h) && 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);
7908
7879
  };
7909
7880
  useEffect(() => {
7910
7881
  const N = setTimeout(() => {
7911
- b && !o.isOpen && !y && !i.includes(h) && o.toggle();
7882
+ k && !o.isOpen && !A && !i.includes(f) && o.toggle();
7912
7883
  }, 500);
7913
7884
  return () => clearTimeout(N);
7914
- }, [b, o, y]);
7915
- const A = useMemo(() => {
7916
- const N = Object.keys(f), D = [];
7917
- for (let $ = 0; $ < N.length; $++)
7918
- if (N[$].endsWith("_attrs")) {
7919
- const R = f[N[$]], O = Object.keys(R).join("|");
7920
- 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");
7921
7892
  }
7922
- return D;
7923
- }, [f]), T = (N, D) => {
7924
- const $ = d.contentDocument || d.contentWindow.document, R = $.querySelector(`[data-block-id=${N}]`);
7925
- R && R.setAttribute("data-drop", D);
7926
- const O = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7927
- O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || ($.documentElement.scrollTop = R.offsetTop - M.top);
7928
- }, I = (N) => {
7929
- v();
7930
- const D = get(o, "parent.id");
7931
- 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 });
7932
7903
  };
7933
- return h === 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: [
7934
7905
  /* @__PURE__ */ jsx("br", {}),
7935
- /* @__PURE__ */ jsx(
7906
+ p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7936
7907
  "div",
7937
7908
  {
7938
- onClick: () => I(-1),
7909
+ role: "button",
7910
+ onClick: () => R(-1),
7939
7911
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
7940
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: [
7941
7913
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -7948,32 +7920,32 @@ const selectParent = (o, n) => {
7948
7920
  ] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7949
7921
  "div",
7950
7922
  {
7951
- onMouseEnter: () => g(h),
7952
- onMouseLeave: () => m(),
7953
- onClick: k,
7923
+ onMouseEnter: () => m(f),
7924
+ onMouseLeave: () => x(),
7925
+ onClick: E,
7954
7926
  style: n,
7955
- "data-node-id": h,
7956
- ref: i.includes(h) ? null : r,
7927
+ "data-node-id": f,
7928
+ ref: i.includes(f) ? null : r,
7957
7929
  onDragStart: () => _(o),
7958
- onDragEnd: () => j(o),
7930
+ onDragEnd: () => S(o),
7959
7931
  onDragOver: (N) => {
7960
- N.preventDefault(), T(h, "yes");
7932
+ N.preventDefault(), I(f, "yes");
7961
7933
  },
7962
7934
  onDragLeave: (N) => {
7963
- N.preventDefault(), T(h, "no");
7935
+ N.preventDefault(), I(f, "no");
7964
7936
  },
7965
7937
  onDrop: (N) => {
7966
- N.preventDefault(), T(h, "no");
7938
+ N.preventDefault(), I(f, "no");
7967
7939
  },
7968
7940
  children: [
7969
- (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(
7970
7942
  "div",
7971
7943
  {
7972
7944
  onClick: (N) => {
7973
- N.stopPropagation(), I(o.childIndex);
7945
+ N.stopPropagation(), R(o.childIndex);
7974
7946
  },
7975
- onMouseEnter: L,
7976
- onMouseLeave: v,
7947
+ onMouseEnter: v,
7948
+ onMouseLeave: y,
7977
7949
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7978
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" }) })
7979
7951
  }
@@ -7983,11 +7955,11 @@ const selectParent = (o, n) => {
7983
7955
  {
7984
7956
  className: cn$1(
7985
7957
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7986
- x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7987
- b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7988
- (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7989
- y && "opacity-20",
7990
- i.includes(h) ? "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" : ""
7991
7963
  ),
7992
7964
  children: [
7993
7965
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7995,11 +7967,11 @@ const selectParent = (o, n) => {
7995
7967
  "div",
7996
7968
  {
7997
7969
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7998
- 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"}` }) })
7999
7971
  }
8000
7972
  ),
8001
7973
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
8002
- /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7974
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
8003
7975
  B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
8004
7976
  "div",
8005
7977
  {
@@ -8008,32 +7980,32 @@ const selectParent = (o, n) => {
8008
7980
  N.stopPropagation(), o.edit(), o.deselect();
8009
7981
  },
8010
7982
  children: [
8011
- /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
8012
- A.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
8013
- A.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
8014
- A.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" })
8015
7987
  ]
8016
7988
  }
8017
7989
  )
8018
7990
  ] })
8019
7991
  ] }),
8020
7992
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
8021
- !i.includes(h) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7993
+ !i.includes(f) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8022
7994
  /* @__PURE__ */ jsx(
8023
7995
  TooltipTrigger,
8024
7996
  {
8025
7997
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
8026
7998
  asChild: !0,
8027
- children: React__default.createElement(N.item, { blockId: h })
7999
+ children: React__default.createElement(N.item, { blockId: f })
8028
8000
  }
8029
8001
  ),
8030
8002
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
8031
8003
  ] })),
8032
- canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(h) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8004
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8033
8005
  /* @__PURE__ */ jsx(
8034
8006
  TooltipTrigger,
8035
8007
  {
8036
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
8008
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
8037
8009
  className: "cursor-pointer rounded bg-transparent hover:text-black",
8038
8010
  asChild: !0,
8039
8011
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -8046,7 +8018,7 @@ const selectParent = (o, n) => {
8046
8018
  TooltipTrigger,
8047
8019
  {
8048
8020
  onClick: (N) => {
8049
- N.stopPropagation(), c(h), o.isOpen && o.toggle();
8021
+ N.stopPropagation(), c(f), o.isOpen && o.toggle();
8050
8022
  },
8051
8023
  className: "cursor-pointer rounded bg-transparent hover:text-black",
8052
8024
  asChild: !0,
@@ -8055,7 +8027,7 @@ const selectParent = (o, n) => {
8055
8027
  ),
8056
8028
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
8057
8029
  ] }),
8058
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8030
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: f, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8059
8031
  ] })
8060
8032
  ]
8061
8033
  }
@@ -8152,21 +8124,32 @@ const selectParent = (o, n) => {
8152
8124
  break;
8153
8125
  }
8154
8126
  };
8155
- return useEffect(() => {
8127
+ useEffect(() => {
8156
8128
  const o = () => {
8157
8129
  treeRef.current && setTreeRef(treeRef.current);
8158
8130
  };
8159
8131
  o();
8160
8132
  const n = new MutationObserver(o);
8161
8133
  return n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
8162
- }, [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: [
8163
8137
  t("This page is empty"),
8164
8138
  /* @__PURE__ */ jsx("br", {}),
8165
8139
  /* @__PURE__ */ jsx("br", {}),
8166
- /* @__PURE__ */ jsxs(Button, { onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK), variant: "default", size: "sm", children: [
8167
- "+ ",
8168
- t("Add Block")
8169
- ] })
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
+ )
8170
8153
  ] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
8171
8154
  /* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
8172
8155
  "div",
@@ -8704,14 +8687,14 @@ function QuickPrompts({ onClick: o }) {
8704
8687
  ) }) });
8705
8688
  }
8706
8689
  const AIUserPrompt = ({ blockId: o }) => {
8707
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = 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);
8708
8691
  useEffect(() => {
8709
- var x;
8710
- (x = m.current) == null || x.focus();
8692
+ var h;
8693
+ (h = m.current) == null || h.focus();
8711
8694
  }, []);
8712
- const f = (x) => {
8713
- const { usage: b } = x || {};
8714
- !l && b && g(b), h.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("");
8715
8698
  };
8716
8699
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8717
8700
  /* @__PURE__ */ jsxs(
@@ -8731,12 +8714,12 @@ const AIUserPrompt = ({ blockId: o }) => {
8731
8714
  {
8732
8715
  ref: m,
8733
8716
  value: i,
8734
- onChange: (x) => c(x.target.value),
8717
+ onChange: (h) => c(h.target.value),
8735
8718
  placeholder: n("Ask AI to edit content"),
8736
8719
  className: "w-full",
8737
8720
  rows: 3,
8738
- onKeyDown: (x) => {
8739
- x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.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));
8740
8723
  }
8741
8724
  }
8742
8725
  ),
@@ -8746,7 +8729,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8746
8729
  {
8747
8730
  disabled: i.trim().length < 5 || a,
8748
8731
  onClick: () => {
8749
- h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
8732
+ x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f);
8750
8733
  },
8751
8734
  variant: "default",
8752
8735
  className: "w-fit",
@@ -8778,8 +8761,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8778
8761
  /* @__PURE__ */ jsx(
8779
8762
  QuickPrompts,
8780
8763
  {
8781
- onClick: (x) => {
8782
- h.current && clearTimeout(h.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);
8783
8766
  }
8784
8767
  }
8785
8768
  )
@@ -8793,7 +8776,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8793
8776
  useEffect(() => {
8794
8777
  n && a(n);
8795
8778
  }, [n]);
8796
- const h = async () => {
8779
+ const x = async () => {
8797
8780
  try {
8798
8781
  d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8799
8782
  } catch (f) {
@@ -8823,7 +8806,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8823
8806
  className: "mt-1 w-full",
8824
8807
  rows: 10,
8825
8808
  onKeyDown: (f) => {
8826
- f.key === "Enter" && (f.preventDefault(), h());
8809
+ f.key === "Enter" && (f.preventDefault(), x());
8827
8810
  }
8828
8811
  }
8829
8812
  ),
@@ -8835,7 +8818,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8835
8818
  Button,
8836
8819
  {
8837
8820
  disabled: r.trim().length < 5,
8838
- onClick: () => h(),
8821
+ onClick: () => x(),
8839
8822
  variant: "default",
8840
8823
  className: "w-fit",
8841
8824
  size: "sm",
@@ -8864,7 +8847,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8864
8847
  AlertDialogAction,
8865
8848
  {
8866
8849
  onClick: () => {
8867
- a(""), h();
8850
+ a(""), x();
8868
8851
  },
8869
8852
  children: o("Yes, Delete")
8870
8853
  }
@@ -8945,8 +8928,8 @@ function usePubSub(o, n) {
8945
8928
  }, [o, n]);
8946
8929
  }
8947
8930
  const AiAssistant = () => {
8948
- const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation();
8949
- 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: [
8950
8933
  /* @__PURE__ */ jsxs(Label, { htmlFor: "ai-assistant", className: "flex items-center gap-x-1 text-sm text-yellow-600", children: [
8951
8934
  /* @__PURE__ */ jsx(SparklesIcon, { className: "w-4" }),
8952
8935
  a("AI Assistant")
@@ -8956,13 +8939,13 @@ const AiAssistant = () => {
8956
8939
  {
8957
8940
  className: "scale-90",
8958
8941
  checked: n === "ai",
8959
- onCheckedChange: (l) => {
8960
- o(l);
8942
+ onCheckedChange: (i) => {
8943
+ o(i);
8961
8944
  },
8962
8945
  id: "ai-assistant"
8963
8946
  }
8964
8947
  )
8965
- ] }) : null;
8948
+ ] });
8966
8949
  }, ClearCanvas = () => {
8967
8950
  const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
8968
8951
  n([]), r([]), a([]);
@@ -9021,54 +9004,54 @@ const AiAssistant = () => {
9021
9004
  preloadedAttributes: n = [],
9022
9005
  onAttributesChange: r
9023
9006
  }) {
9024
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = 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();
9025
9008
  useEffect(() => {
9026
9009
  l(n);
9027
9010
  }, [n]);
9028
- const y = () => {
9011
+ const k = () => {
9029
9012
  if (i.startsWith("@")) {
9030
- h("Attribute keys cannot start with '@'");
9013
+ x("Attribute keys cannot start with '@'");
9031
9014
  return;
9032
9015
  }
9033
9016
  if (i) {
9034
9017
  const S = [...a, { key: i, value: d }];
9035
- r(S), l(a), c(""), p(""), h("");
9018
+ r(S), l(a), c(""), p(""), x("");
9036
9019
  }
9020
+ }, A = (S) => {
9021
+ const w = a.filter((L, v) => v !== S);
9022
+ r(w), l(w);
9037
9023
  }, B = (S) => {
9038
- const C = a.filter((L, v) => v !== S);
9039
- r(C), l(C);
9040
- }, E = (S) => {
9041
9024
  g(S), c(a[S].key), p(a[S].value);
9042
- }, w = () => {
9025
+ }, C = () => {
9043
9026
  if (i.startsWith("@")) {
9044
- h("Attribute keys cannot start with '@'");
9027
+ x("Attribute keys cannot start with '@'");
9045
9028
  return;
9046
9029
  }
9047
9030
  if (u !== null && i) {
9048
9031
  const S = [...a];
9049
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
9032
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), x("");
9050
9033
  }
9051
- }, _ = (S) => {
9052
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
9053
- }, j = useCallback((S) => {
9054
- const C = (k) => /[.,!?;:]/.test(k), L = (k, A, T) => {
9055
- let I = "", P = "";
9056
- const N = A > 0 ? k[A - 1] : "", D = A < k.length ? k[A] : "";
9057
- return A > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), A < k.length && !C(D) && D !== " " && (P = " "), {
9058
- 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,
9059
9042
  prefixLength: I.length,
9060
- suffixLength: P.length
9043
+ suffixLength: R.length
9061
9044
  };
9062
- }, v = x.current;
9045
+ }, v = h.current;
9063
9046
  if (v) {
9064
- const k = v.selectionStart || 0, A = v.value || "", T = v.selectionEnd || k;
9065
- if (T > k) {
9066
- const $ = `{{${S}}}`, { text: R } = L(A, k, $), O = A.slice(0, k) + R + A.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);
9067
9050
  p(O);
9068
9051
  return;
9069
9052
  }
9070
- const P = `{{${S}}}`, { text: N } = L(A, k, P), D = A.slice(0, k) + N + A.slice(k);
9071
- p(D);
9053
+ const R = `{{${S}}}`, { text: P } = L(E, y, R), N = E.slice(0, y) + P + E.slice(y);
9054
+ p(N);
9072
9055
  }
9073
9056
  }, []);
9074
9057
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -9076,7 +9059,7 @@ const AiAssistant = () => {
9076
9059
  "form",
9077
9060
  {
9078
9061
  onSubmit: (S) => {
9079
- S.preventDefault(), u !== null ? w() : y();
9062
+ S.preventDefault(), u !== null ? C() : k();
9080
9063
  },
9081
9064
  className: "space-y-3",
9082
9065
  children: [
@@ -9101,7 +9084,7 @@ const AiAssistant = () => {
9101
9084
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9102
9085
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9103
9086
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9104
- !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
9087
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
9105
9088
  ] }),
9106
9089
  /* @__PURE__ */ jsx(
9107
9090
  Textarea,
@@ -9111,10 +9094,10 @@ const AiAssistant = () => {
9111
9094
  spellCheck: "false",
9112
9095
  id: "attrValue",
9113
9096
  rows: 2,
9114
- ref: x,
9097
+ ref: h,
9115
9098
  value: d,
9116
9099
  onChange: (S) => p(S.target.value),
9117
- onKeyDown: _,
9100
+ onKeyDown: j,
9118
9101
  placeholder: "Enter Value",
9119
9102
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9120
9103
  }
@@ -9126,16 +9109,16 @@ const AiAssistant = () => {
9126
9109
  ]
9127
9110
  }
9128
9111
  ),
9129
- /* @__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: [
9130
9113
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9131
9114
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9132
9115
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9133
9116
  ] }),
9134
9117
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9135
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9136
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(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" }) })
9137
9120
  ] })
9138
- ] }, C)) })
9121
+ ] }, w)) })
9139
9122
  ] });
9140
9123
  }), BlockAttributesEditor = React.memo(() => {
9141
9124
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9172,10 +9155,26 @@ function BlockAttributesToggle() {
9172
9155
  ] });
9173
9156
  }
9174
9157
  const SettingsPanel = () => {
9175
- const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop);
9176
- 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: [
9177
9162
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9178
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", {})
9179
9178
  ] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
9180
9179
  /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9181
9180
  /* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
@@ -9329,11 +9328,11 @@ const RootLayout = () => {
9329
9328
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9330
9329
  n(1);
9331
9330
  });
9332
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9333
- x.preventDefault();
9334
- }, u = (x) => {
9335
- n(o === x ? null : x);
9336
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...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");
9337
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: [
9338
9337
  /* @__PURE__ */ jsxs(
9339
9338
  "div",
@@ -9344,21 +9343,21 @@ const RootLayout = () => {
9344
9343
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9345
9344
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9346
9345
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9347
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9346
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: x.map((h, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9348
9347
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9349
9348
  Button,
9350
9349
  {
9351
9350
  variant: o === b ? "default" : "ghost",
9352
9351
  className: "mb-2 rounded-lg p-2 transition-colors",
9353
9352
  onClick: () => u(b),
9354
- children: get(x, "icon", null)
9353
+ children: get(h, "icon", null)
9355
9354
  },
9356
9355
  b
9357
9356
  ) }),
9358
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
9357
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
9359
9358
  ] }, "button" + b)) }),
9360
9359
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9361
- /* @__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}`)) })
9362
9361
  ] }),
9363
9362
  /* @__PURE__ */ jsx(
9364
9363
  motion.div,
@@ -9371,14 +9370,14 @@ const RootLayout = () => {
9371
9370
  /* @__PURE__ */ jsxs(
9372
9371
  "div",
9373
9372
  {
9374
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${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"}`,
9375
9374
  children: [
9376
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
9377
- /* @__PURE__ */ jsx("span", { children: m(h[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) })
9378
9377
  ]
9379
9378
  }
9380
9379
  ),
9381
- /* @__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(h, `${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), {}) }) })
9382
9381
  ] })
9383
9382
  }
9384
9383
  ),
@@ -9516,6 +9515,7 @@ export {
9516
9515
  DefaultChaiBlocks,
9517
9516
  ImportHTML,
9518
9517
  ListTree as Outline,
9518
+ PERMISSIONS,
9519
9519
  Breakpoints$1 as ScreenSizes,
9520
9520
  ThemeConfigPanel as ThemeOptions,
9521
9521
  UILibrariesPanel as UILibraries,
@@ -9551,6 +9551,7 @@ export {
9551
9551
  usePartailBlocksStore,
9552
9552
  usePartialBlocksList,
9553
9553
  usePasteBlocks,
9554
+ usePermissions,
9554
9555
  usePreviewMode,
9555
9556
  useRemoveBlocks,
9556
9557
  useRemoveClassesFromBlocks,