@chaibuilder/sdk 2.0.0-beta.111 → 2.0.0-beta.113

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
@@ -101,97 +101,97 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
101
101
  var x;
102
102
  return (x = m.onMount) == null ? void 0 : x.call(m, h);
103
103
  }, ...f) => {
104
- const m = f[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, _)), L;
104
+ const m = f[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;
107
107
  }), h = f[1] || (() => {
108
- let w, L;
108
+ let C, L;
109
109
  const v = (k) => {
110
110
  try {
111
111
  k();
112
- } catch (E) {
113
- w || (w = !0, L = E);
112
+ } catch (A) {
113
+ C || (C = !0, L = A);
114
114
  }
115
115
  };
116
116
  do {
117
117
  c.f && v(c.f);
118
- const k = /* @__PURE__ */ new Set(), E = k.add.bind(k);
118
+ const k = /* @__PURE__ */ new Set(), A = k.add.bind(k);
119
119
  a.forEach((T) => {
120
120
  var I;
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(), k.forEach(v), a.size && x();
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();
123
123
  } while (a.size || i.size || l.size);
124
- if (w)
124
+ if (C)
125
125
  throw L;
126
126
  }), x = f[2] || (() => {
127
- const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
127
+ const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
128
128
  for (; k.length; ) {
129
- const E = k[k.length - 1], T = m(E);
130
- if (v.has(E)) {
129
+ const A = k[k.length - 1], T = m(A);
130
+ if (v.has(A)) {
131
131
  k.pop();
132
132
  continue;
133
133
  }
134
- if (L.has(E)) {
135
- r.get(E) === T.n && w.push([E, T]), v.add(E), k.pop();
134
+ if (L.has(A)) {
135
+ r.get(A) === T.n && C.push([A, T]), v.add(A), k.pop();
136
136
  continue;
137
137
  }
138
- L.add(E);
139
- for (const I of getMountedOrPendingDependents(E, T, n))
138
+ L.add(A);
139
+ for (const I of getMountedOrPendingDependents(A, T, n))
140
140
  L.has(I) || k.push(I);
141
141
  }
142
- for (let E = w.length - 1; E >= 0; --E) {
143
- const [T, I] = w[E];
144
- let R = !1;
142
+ for (let A = C.length - 1; A >= 0; --A) {
143
+ const [T, I] = C[A];
144
+ let P = !1;
145
145
  for (const N of I.d.keys())
146
146
  if (N !== T && a.has(N)) {
147
- R = !0;
147
+ P = !0;
148
148
  break;
149
149
  }
150
- R && (b(T), j(T)), r.delete(T);
150
+ P && (y(T), E(T)), r.delete(T);
151
151
  }
152
- }), b = f[3] || ((w) => {
152
+ }), y = f[3] || ((C) => {
153
153
  var L, v;
154
- const k = m(w);
155
- if (isAtomStateInitialized(k) && (n.has(w) && r.get(w) !== k.n || Array.from(k.d).every(
156
- ([P, O]) => (
154
+ const k = m(C);
155
+ if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
156
+ ([R, O]) => (
157
157
  // Recursively, read the atom state of the dependency, and
158
158
  // check if the atom epoch number is unchanged
159
- b(P).n === O
159
+ y(R).n === O
160
160
  )
161
161
  )))
162
162
  return k;
163
163
  k.d.clear();
164
- let E = !0;
164
+ let A = !0;
165
165
  const T = () => {
166
- n.has(w) && (j(w), x(), h());
167
- }, I = (P) => {
166
+ n.has(C) && (E(C), x(), h());
167
+ }, I = (R) => {
168
168
  var O;
169
- if (isSelfAtom(w, P)) {
170
- const H = m(P);
169
+ if (isSelfAtom(C, R)) {
170
+ const H = m(R);
171
171
  if (!isAtomStateInitialized(H))
172
- if (hasInitialValue(P))
173
- setAtomStateValueOrPromise(P, P.init, m);
172
+ if (hasInitialValue(R))
173
+ setAtomStateValueOrPromise(R, R.init, m);
174
174
  else
175
175
  throw new Error("no atom init");
176
176
  return returnAtomValue(H);
177
177
  }
178
- const $ = b(P);
178
+ const $ = y(R);
179
179
  try {
180
180
  return returnAtomValue($);
181
181
  } finally {
182
- k.d.set(P, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(w, k.v, $), (O = n.get(P)) == null || O.t.add(w), E || T();
182
+ k.d.set(R, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, $), (O = n.get(R)) == null || O.t.add(C), A || T();
183
183
  }
184
184
  };
185
- let R, N;
185
+ let P, N;
186
186
  const D = {
187
187
  get signal() {
188
- return R || (R = new AbortController()), R.signal;
188
+ return P || (P = new AbortController()), P.signal;
189
189
  },
190
190
  get setSelf() {
191
- return !N && isActuallyWritableAtom(w) && (N = (...P) => {
192
- if (!E)
191
+ return !N && isActuallyWritableAtom(C) && (N = (...R) => {
192
+ if (!A)
193
193
  try {
194
- return B(w, ...P);
194
+ return B(C, ...R);
195
195
  } finally {
196
196
  x(), h();
197
197
  }
@@ -199,36 +199,36 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
199
199
  }
200
200
  }, M = k.n;
201
201
  try {
202
- const P = d(w, I, D);
203
- return setAtomStateValueOrPromise(w, P, m), isPromiseLike$2(P) && ((L = P.onCancel) == null || L.call(P, () => R == null ? void 0 : R.abort()), P.then(
202
+ const R = d(C, I, D);
203
+ return setAtomStateValueOrPromise(C, R, m), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
204
204
  T,
205
205
  T
206
206
  )), k;
207
- } catch (P) {
208
- return delete k.v, k.e = P, ++k.n, k;
207
+ } catch (R) {
208
+ return delete k.v, k.e = R, ++k.n, k;
209
209
  } finally {
210
- E = !1, M !== k.n && r.get(w) === M && (r.set(w, k.n), a.add(w), (v = c.c) == null || v.call(c, w));
210
+ A = !1, M !== k.n && r.get(C) === M && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
211
211
  }
212
- }), y = f[4] || ((w) => {
213
- const L = [w];
212
+ }), b = f[4] || ((C) => {
213
+ const L = [C];
214
214
  for (; L.length; ) {
215
215
  const v = L.pop(), k = m(v);
216
- for (const E of getMountedOrPendingDependents(v, k, n)) {
217
- const T = m(E);
218
- r.set(E, T.n), L.push(E);
216
+ for (const A of getMountedOrPendingDependents(v, k, n)) {
217
+ const T = m(A);
218
+ r.set(A, T.n), L.push(A);
219
219
  }
220
220
  }
221
- }), B = f[5] || ((w, ...L) => {
221
+ }), B = f[5] || ((C, ...L) => {
222
222
  let v = !0;
223
- const k = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
224
- var R;
223
+ const k = (T) => returnAtomValue(y(T)), A = (T, ...I) => {
224
+ var P;
225
225
  const N = m(T);
226
226
  try {
227
- if (isSelfAtom(w, T)) {
227
+ if (isSelfAtom(C, T)) {
228
228
  if (!hasInitialValue(T))
229
229
  throw new Error("atom not writable");
230
230
  const D = N.n, M = I[0];
231
- setAtomStateValueOrPromise(T, M, m), j(T), D !== N.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
231
+ setAtomStateValueOrPromise(T, M, m), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
232
232
  return;
233
233
  } else
234
234
  return B(T, ...I);
@@ -237,54 +237,54 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
237
237
  }
238
238
  };
239
239
  try {
240
- return p(w, k, E, ...L);
240
+ return p(C, k, A, ...L);
241
241
  } finally {
242
242
  v = !1;
243
243
  }
244
- }), j = f[6] || ((w) => {
244
+ }), E = f[6] || ((C) => {
245
245
  var L;
246
- const v = m(w), k = n.get(w);
246
+ const v = m(C), k = n.get(C);
247
247
  if (k && !isPendingPromise(v.v)) {
248
- for (const [E, T] of v.d)
249
- if (!k.d.has(E)) {
250
- const I = m(E);
251
- C(E).t.add(w), k.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), y(E));
248
+ for (const [A, T] of v.d)
249
+ if (!k.d.has(A)) {
250
+ const I = m(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), b(A));
252
252
  }
253
- for (const E of k.d || [])
254
- if (!v.d.has(E)) {
255
- k.d.delete(E);
256
- const T = S(E);
257
- T == null || T.t.delete(w);
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);
258
258
  }
259
259
  }
260
- }), C = f[7] || ((w) => {
260
+ }), w = f[7] || ((C) => {
261
261
  var L;
262
- const v = m(w);
263
- let k = n.get(w);
262
+ const v = m(C);
263
+ let k = n.get(C);
264
264
  if (!k) {
265
- b(w);
266
- for (const E of v.d.keys())
267
- C(E).t.add(w);
265
+ y(C);
266
+ for (const A of v.d.keys())
267
+ w(A).t.add(C);
268
268
  if (k = {
269
269
  l: /* @__PURE__ */ new Set(),
270
270
  d: new Set(v.d.keys()),
271
271
  t: /* @__PURE__ */ new Set()
272
- }, n.set(w, k), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
- const E = () => {
272
+ }, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
273
+ const A = () => {
274
274
  let T = !0;
275
- const I = (...R) => {
275
+ const I = (...P) => {
276
276
  try {
277
- return B(w, ...R);
277
+ return B(C, ...P);
278
278
  } finally {
279
279
  T || (x(), h());
280
280
  }
281
281
  };
282
282
  try {
283
- const R = g(w, I);
284
- R && (k.u = () => {
283
+ const P = g(C, I);
284
+ P && (k.u = () => {
285
285
  T = !0;
286
286
  try {
287
- R();
287
+ P();
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(E);
296
+ l.add(A);
297
297
  }
298
298
  }
299
299
  return k;
300
- }), S = f[8] || ((w) => {
300
+ }), _ = f[8] || ((C) => {
301
301
  var L;
302
- const v = m(w);
303
- let k = n.get(w);
304
- if (k && !k.l.size && !Array.from(k.t).some((E) => {
302
+ const v = m(C);
303
+ let k = n.get(C);
304
+ if (k && !k.l.size && !Array.from(k.t).some((A) => {
305
305
  var T;
306
- return (T = n.get(E)) == null ? void 0 : T.d.has(w);
306
+ return (T = n.get(A)) == null ? void 0 : T.d.has(C);
307
307
  })) {
308
- k.u && i.add(k.u), k = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
309
- for (const E of v.d.keys()) {
310
- const T = S(E);
311
- T == null || T.t.delete(w);
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);
312
312
  }
313
313
  return;
314
314
  }
315
315
  return k;
316
- }), A = [
316
+ }), j = [
317
317
  // store state
318
318
  o,
319
319
  n,
@@ -331,29 +331,29 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
331
331
  m,
332
332
  h,
333
333
  x,
334
- b,
335
334
  y,
335
+ b,
336
336
  B,
337
- j,
338
- C,
339
- S
340
- ], _ = {
341
- get: (w) => returnAtomValue(b(w)),
342
- set: (w, ...L) => {
337
+ E,
338
+ w,
339
+ _
340
+ ], S = {
341
+ get: (C) => returnAtomValue(y(C)),
342
+ set: (C, ...L) => {
343
343
  try {
344
- return B(w, ...L);
344
+ return B(C, ...L);
345
345
  } finally {
346
346
  x(), h();
347
347
  }
348
348
  },
349
- sub: (w, L) => {
350
- const k = C(w).l;
349
+ sub: (C, L) => {
350
+ const k = w(C).l;
351
351
  return k.add(L), h(), () => {
352
- k.delete(L), S(w), h();
352
+ k.delete(L), _(C), h();
353
353
  };
354
354
  }
355
355
  };
356
- return Object.defineProperty(_, BUILDING_BLOCKS, { value: A }), _;
356
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: j }), S;
357
357
  }, INTERNAL_buildStoreRev1 = buildStore;
358
358
  let keyCount = 0;
359
359
  function atom(o, n) {
@@ -392,32 +392,32 @@ function splitAtom(o, n) {
392
392
  return c.forEach((m, h) => {
393
393
  const x = h;
394
394
  f[h] = x;
395
- const b = u && u.atomList[u.keyList.indexOf(x)];
396
- if (b) {
397
- g[h] = b;
395
+ const y = u && u.atomList[u.keyList.indexOf(x)];
396
+ if (y) {
397
+ g[h] = y;
398
398
  return;
399
399
  }
400
- const y = (j) => {
401
- const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(x);
402
- if (_ < 0 || _ >= S.length) {
403
- const w = c[a(c).keyList.indexOf(x)];
404
- if (w)
405
- return w;
400
+ const b = (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;
406
406
  throw new Error("splitAtom: index out of bounds for read");
407
407
  }
408
- return S[_];
409
- }, B = (j, C, S) => {
410
- const A = j(l), _ = j(o), L = a(_, A == null ? void 0 : A.arr).keyList.indexOf(x);
411
- if (L < 0 || L >= _.length)
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);
411
+ if (L < 0 || L >= S.length)
412
412
  throw new Error("splitAtom: index out of bounds for write");
413
- const v = isFunction(S) ? S(_[L]) : S;
414
- Object.is(_[L], v) || C(o, [
415
- ..._.slice(0, L),
413
+ const v = isFunction(_) ? _(S[L]) : _;
414
+ Object.is(S[L], v) || w(o, [
415
+ ...S.slice(0, L),
416
416
  v,
417
- ..._.slice(L + 1)
417
+ ...S.slice(L + 1)
418
418
  ]);
419
419
  };
420
- g[h] = isWritable(o) ? atom(y, B) : atom(y);
420
+ g[h] = isWritable(o) ? atom(b, B) : atom(b);
421
421
  }), u && u.keyList.length === f.length && u.keyList.every((m, h) => m === f[h]) ? p = u : p = { arr: c, atomList: g, keyList: f }, r.set(c, p), p;
422
422
  }, l = atom((c) => {
423
423
  const d = c(l), p = c(o);
@@ -1158,8 +1158,8 @@ const useSelectedBlocksDisplayChild = () => ({
1158
1158
  m && "content" in m && (r = r.map((h) => {
1159
1159
  if (h._id === u) {
1160
1160
  const x = { ...h, content: f.content };
1161
- return Object.keys(f).forEach((b) => {
1162
- b.startsWith("content-") && (x[b] = f[b]);
1161
+ return Object.keys(f).forEach((y) => {
1162
+ y.startsWith("content-") && (x[y] = f[y]);
1163
1163
  }), x;
1164
1164
  }
1165
1165
  return h;
@@ -1238,8 +1238,8 @@ function insertBlocksAtPosition(o, n, r, a) {
1238
1238
  }), l.unshift(m), i = i.map((h) => {
1239
1239
  if (h._id === r) {
1240
1240
  const x = { ...h, content: "" };
1241
- return Object.keys(x).forEach((b) => {
1242
- b.startsWith("content-") && (x[b] = "");
1241
+ return Object.keys(x).forEach((y) => {
1242
+ y.startsWith("content-") && (x[y] = "");
1243
1243
  }), x;
1244
1244
  }
1245
1245
  return h;
@@ -1388,50 +1388,50 @@ const useBlocksStoreManager = () => {
1388
1388
  updateBlocksProps: c
1389
1389
  } = useBlocksStoreManager();
1390
1390
  return {
1391
- moveBlocks: (x, b, y) => {
1392
- const B = map(x, (C) => {
1393
- const A = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => A ? L._parent === A : !L._parent).map((L) => L._id).indexOf(C);
1394
- return { _id: C, oldParent: A, oldPosition: w };
1395
- }), j = B.find(({ _id: C }) => C === x[0]);
1396
- j && j.oldParent === b && j.oldPosition === y || (i(x, b, y), o({
1397
- undo: () => each(B, ({ _id: C, oldParent: S, oldPosition: A }) => {
1398
- i([C], S, A);
1391
+ moveBlocks: (x, y, b) => {
1392
+ const B = map(x, (w) => {
1393
+ 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);
1394
+ return { _id: w, oldParent: j, oldPosition: C };
1395
+ }), E = B.find(({ _id: w }) => w === x[0]);
1396
+ E && E.oldParent === y && E.oldPosition === b || (i(x, y, b), o({
1397
+ undo: () => each(B, ({ _id: w, oldParent: _, oldPosition: j }) => {
1398
+ i([w], _, j);
1399
1399
  }),
1400
- redo: () => i(x, b, y)
1400
+ redo: () => i(x, y, b)
1401
1401
  }));
1402
1402
  },
1403
- addBlocks: (x, b, y) => {
1404
- a(x, b, y), o({
1403
+ addBlocks: (x, y, b) => {
1404
+ a(x, y, b), o({
1405
1405
  undo: () => l(map(x, "_id")),
1406
- redo: () => a(x, b, y)
1406
+ redo: () => a(x, y, b)
1407
1407
  });
1408
1408
  },
1409
1409
  removeBlocks: (x) => {
1410
- var j;
1411
- const b = (j = first(x)) == null ? void 0 : j._parent, B = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(x));
1410
+ var E;
1411
+ const y = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(x));
1412
1412
  l(map(x, "_id")), o({
1413
- undo: () => a(x, b, B),
1413
+ undo: () => a(x, y, B),
1414
1414
  redo: () => l(map(x, "_id"))
1415
1415
  });
1416
1416
  },
1417
- updateBlocks: (x, b, y) => {
1417
+ updateBlocks: (x, y, b) => {
1418
1418
  let B = [];
1419
- if (y)
1420
- B = map(x, (j) => ({ _id: j, ...y }));
1419
+ if (b)
1420
+ B = map(x, (E) => ({ _id: E, ...b }));
1421
1421
  else {
1422
- const j = keys(b);
1423
- B = map(x, (C) => {
1424
- const S = n.find((_) => _._id === C), A = { _id: C };
1425
- return each(j, (_) => A[_] = S[_]), A;
1422
+ const E = keys(y);
1423
+ B = map(x, (w) => {
1424
+ const _ = n.find((S) => S._id === w), j = { _id: w };
1425
+ return each(E, (S) => j[S] = _[S]), j;
1426
1426
  });
1427
1427
  }
1428
- c(map(x, (j) => ({ _id: j, ...b }))), o({
1428
+ c(map(x, (E) => ({ _id: E, ...y }))), o({
1429
1429
  undo: () => c(B),
1430
- redo: () => c(map(x, (j) => ({ _id: j, ...b })))
1430
+ redo: () => c(map(x, (E) => ({ _id: E, ...y })))
1431
1431
  });
1432
1432
  },
1433
- updateBlocksRuntime: (x, b) => {
1434
- c(map(x, (y) => ({ _id: y, ...b })));
1433
+ updateBlocksRuntime: (x, y) => {
1434
+ c(map(x, (b) => ({ _id: b, ...y })));
1435
1435
  },
1436
1436
  setNewBlocks: (x) => {
1437
1437
  r(x), o({
@@ -1440,12 +1440,12 @@ const useBlocksStoreManager = () => {
1440
1440
  });
1441
1441
  },
1442
1442
  updateMultipleBlocksProps: (x) => {
1443
- let b = [];
1444
- b = map(x, (y) => {
1445
- const B = keys(y), j = n.find((S) => S._id === y._id), C = {};
1446
- return each(B, (S) => C[S] = j[S]), C;
1443
+ let y = [];
1444
+ y = map(x, (b) => {
1445
+ const B = keys(b), E = n.find((_) => _._id === b._id), w = {};
1446
+ return each(B, (_) => w[_] = E[_]), w;
1447
1447
  }), c(x), o({
1448
- undo: () => c(b),
1448
+ undo: () => c(y),
1449
1449
  redo: () => c(x)
1450
1450
  });
1451
1451
  }
@@ -1486,9 +1486,9 @@ const useAddBlock = () => {
1486
1486
  for (let h = 0; h < i.length; h++) {
1487
1487
  const { _id: x } = i[h];
1488
1488
  i[h]._id = generateUUID();
1489
- const b = filter(i, { _parent: x });
1490
- for (let y = 0; y < b.length; y++)
1491
- b[y]._parent = i[h]._id;
1489
+ const y = filter(i, { _parent: x });
1490
+ for (let b = 0; b < y.length; b++)
1491
+ y[b]._parent = i[h]._id;
1492
1492
  }
1493
1493
  const p = first(i);
1494
1494
  let u, g;
@@ -1499,8 +1499,8 @@ const useAddBlock = () => {
1499
1499
  return { addCoreBlock: useCallback(
1500
1500
  (i, c, d) => {
1501
1501
  if (has(i, "blocks")) {
1502
- const b = i.blocks;
1503
- return a(b, c, d);
1502
+ const y = i.blocks;
1503
+ return a(y, c, d);
1504
1504
  }
1505
1505
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
1506
1506
  _type: i.type,
@@ -2957,42 +2957,42 @@ const getBlockWithChildren = (o, n) => {
2957
2957
  })
2958
2958
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2959
2959
  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, f = (m, h) => {
2960
- const x = cloneDeep(h.find((b) => b._id === m));
2961
- for (const b in x) {
2962
- const y = x[b];
2963
- if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2964
- const { baseClasses: B, classes: j } = getSplitChaiClasses(y);
2965
- x[b] = compact(flattenDeep([B, j])).join(" ");
2960
+ const x = cloneDeep(h.find((y) => y._id === m));
2961
+ for (const y in x) {
2962
+ const b = x[y];
2963
+ if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2964
+ const { baseClasses: B, classes: E } = getSplitChaiClasses(b);
2965
+ x[y] = compact(flattenDeep([B, E])).join(" ");
2966
2966
  } else
2967
- b !== "_id" && delete x[b];
2967
+ y !== "_id" && delete x[y];
2968
2968
  }
2969
2969
  return x;
2970
2970
  };
2971
2971
  return {
2972
2972
  askAi: useCallback(
2973
- async (m, h, x, b) => {
2973
+ async (m, h, x, y) => {
2974
2974
  if (l) {
2975
2975
  n(!0), a(null);
2976
2976
  try {
2977
- const y = p === u ? "" : p, B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], j = await l(m, addLangToPrompt(x, g, m), B, y), { blocks: C, error: S } = j;
2978
- if (S) {
2979
- a(S);
2977
+ const b = p === u ? "" : p, B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], E = await l(m, addLangToPrompt(x, g, m), B, b), { blocks: w, error: _ } = E;
2978
+ if (_) {
2979
+ a(_);
2980
2980
  return;
2981
2981
  }
2982
2982
  if (m === "styles") {
2983
- const A = C.map((_) => {
2984
- for (const w in _)
2985
- w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
2986
- return _;
2983
+ const j = w.map((S) => {
2984
+ for (const C in S)
2985
+ C !== "_id" && (S[C] = `${STYLES_KEY},${S[C]}`);
2986
+ return S;
2987
2987
  });
2988
- c(A);
2988
+ c(j);
2989
2989
  } else
2990
- i(C);
2991
- b && b(j);
2992
- } catch (y) {
2993
- a(y);
2990
+ i(w);
2991
+ y && y(E);
2992
+ } catch (b) {
2993
+ a(b);
2994
2994
  } finally {
2995
- n(!1), b && b();
2995
+ n(!1), y && y();
2996
2996
  }
2997
2997
  }
2998
2998
  },
@@ -3576,26 +3576,26 @@ const useDnd = () => {
3576
3576
  m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3577
3577
  },
3578
3578
  onDrop: (m) => {
3579
- var S;
3580
- const h = dropTarget, b = getOrientation(h) === "vertical" ? m.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : m.clientX;
3581
- dropIndex = calculateDropIndex(b, possiblePositions);
3582
- const y = d, B = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3583
- if ((y == null ? void 0 : y._id) === B || !j) {
3579
+ var _;
3580
+ const h = dropTarget, y = getOrientation(h) === "vertical" ? m.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : m.clientX;
3581
+ dropIndex = calculateDropIndex(y, possiblePositions);
3582
+ const b = d, B = h.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3583
+ if ((b == null ? void 0 : b._id) === B || !E) {
3584
3584
  f();
3585
3585
  return;
3586
3586
  }
3587
- if (!has(y, "_id")) {
3588
- a(y, B === "canvas" ? null : B, dropIndex), setTimeout(f, 300);
3587
+ if (!has(b, "_id")) {
3588
+ a(b, B === "canvas" ? null : B, dropIndex), setTimeout(f, 300);
3589
3589
  return;
3590
3590
  }
3591
- let C = h.getAttribute("data-block-id");
3592
- C === null && (C = m.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), f(), setTimeout(removePlaceholder, 300);
3591
+ let w = h.getAttribute("data-block-id");
3592
+ w === null && (w = m.target.parentElement.getAttribute("data-block-id")), c([b._id], w === "canvas" ? null : w, dropIndex), f(), setTimeout(removePlaceholder, 300);
3593
3593
  },
3594
3594
  onDragEnter: (m) => {
3595
3595
  const h = m, x = h.target;
3596
3596
  dropTarget = x;
3597
- const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3598
- u(b), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3597
+ const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
3598
+ u(y), h.stopPropagation(), h.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), r(!0), l(""), i([]);
3599
3599
  },
3600
3600
  onDragLeave: (m) => {
3601
3601
  m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
@@ -3673,8 +3673,8 @@ const useHandleCanvasDblClick = (o, n) => {
3673
3673
  if (h) {
3674
3674
  const x = h.getAttribute("data-style-prop");
3675
3675
  if (x) {
3676
- const b = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3677
- l([{ id: b, prop: x, blockId: y }]);
3676
+ const y = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3677
+ l([{ id: y, prop: x, blockId: b }]);
3678
3678
  }
3679
3679
  }
3680
3680
  }, 100);
@@ -3726,22 +3726,22 @@ const useHandleCanvasDblClick = (o, n) => {
3726
3726
  forms,
3727
3727
  aspectRatio,
3728
3728
  containerQueries,
3729
- plugin(function({ addBase: b, theme: y }) {
3730
- b({
3729
+ plugin(function({ addBase: y, theme: b }) {
3730
+ y({
3731
3731
  "h1,h2,h3,h4,h5,h6": {
3732
- fontFamily: y("fontFamily.heading")
3732
+ fontFamily: b("fontFamily.heading")
3733
3733
  },
3734
3734
  body: {
3735
- fontFamily: y("fontFamily.body"),
3736
- color: y("colors.foreground"),
3737
- backgroundColor: y("colors.background")
3735
+ fontFamily: b("fontFamily.body"),
3736
+ color: b("colors.foreground"),
3737
+ backgroundColor: b("colors.background")
3738
3738
  }
3739
3739
  });
3740
3740
  })
3741
3741
  ]
3742
3742
  });
3743
3743
  }, [o, n, p]), useEffect(() => {
3744
- g && (g.textContent = `${map(r, (b) => `[data-block-id="${b}"]`).join(",")}{
3744
+ g && (g.textContent = `${map(r, (y) => `[data-block-id="${y}"]`).join(",")}{
3745
3745
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3746
3746
  }`);
3747
3747
  }, [r, g]), useEffect(() => {
@@ -3749,7 +3749,7 @@ const useHandleCanvasDblClick = (o, n) => {
3749
3749
  }, [i, m]), useEffect(() => {
3750
3750
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3751
3751
  }, [u]), useEffect(() => {
3752
- f && (f.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3752
+ f && (f.textContent = `${map(l, ({ id: y }) => `[data-style-id="${y}"]`).join(",")}{
3753
3753
  outline: 1px solid orange !important; outline-offset: -1px;
3754
3754
  }`);
3755
3755
  }, [l, f]), useEffect(() => {
@@ -3844,7 +3844,7 @@ const getBlockRuntimeProps = memoize((o) => {
3844
3844
  ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), h = useMemo(
3845
3845
  () => c(r._id, getBlockRuntimeProps(r._type)),
3846
3846
  [r._id, r._type, c, getBlockRuntimeProps]
3847
- ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3847
+ ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), y = useMemo(
3848
3848
  () => ({
3849
3849
  blockProps: {
3850
3850
  "data-block-id": r._id,
@@ -3868,7 +3868,7 @@ const getBlockRuntimeProps = memoize((o) => {
3868
3868
  x
3869
3869
  ]
3870
3870
  );
3871
- return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
3871
+ return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...y, children: n }) });
3872
3872
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3873
3873
  const { getPartailBlocks: n } = usePartailBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3874
3874
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
@@ -3918,43 +3918,43 @@ const getBlockRuntimeProps = memoize((o) => {
3918
3918
  c();
3919
3919
  }, [n, o, r, c]), l;
3920
3920
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3921
- 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, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), j = (A) => {
3922
- p((_) => ({ ..._, width: A }));
3921
+ 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, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (j) => {
3922
+ p((S) => ({ ...S, width: j }));
3923
3923
  };
3924
3924
  useEffect(() => {
3925
3925
  if (!c.current) return;
3926
- const { clientWidth: A, clientHeight: _ } = c.current;
3927
- p({ width: A, height: _ });
3926
+ const { clientWidth: j, clientHeight: S } = c.current;
3927
+ p({ width: j, height: S });
3928
3928
  }, [c, n]);
3929
- const C = (A, _ = 0) => {
3930
- const { top: w } = A.getBoundingClientRect();
3931
- return w + _ >= 0 && w - _ <= window.innerHeight;
3929
+ const w = (j, S = 0) => {
3930
+ const { top: C } = j.getBoundingClientRect();
3931
+ return C + S >= 0 && C - S <= window.innerHeight;
3932
3932
  };
3933
3933
  useEffect(() => {
3934
- var A, _;
3934
+ var j, S;
3935
3935
  if (a && a.type !== "Multiple" && i.current) {
3936
- const w = getElementByDataBlockId(i.current.contentDocument, a._id);
3937
- w && (C(w) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), f([w]));
3936
+ const C = getElementByDataBlockId(i.current.contentDocument, a._id);
3937
+ C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), f([C]));
3938
3938
  }
3939
3939
  }, [a]), useEffect(() => {
3940
3940
  if (!isEmpty(x) && i.current) {
3941
- const A = getElementByStyleId(
3941
+ const j = getElementByStyleId(
3942
3942
  i.current.contentDocument,
3943
3943
  first(x).id
3944
3944
  );
3945
- m(A ? [A] : [null]);
3945
+ m(j ? [j] : [null]);
3946
3946
  } else
3947
3947
  m([null]);
3948
3948
  }, [x]);
3949
- const S = useMemo(() => {
3950
- let A = IframeInitialContent;
3951
- return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
3949
+ const _ = useMemo(() => {
3950
+ let j = IframeInitialContent;
3951
+ return j = j.replace("__HTML_DIR__", B), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
3952
3952
  }, [o, B]);
3953
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
3953
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
3954
3954
  "div",
3955
3955
  {
3956
3956
  onClick: () => {
3957
- r([]), b([]);
3957
+ r([]), y([]);
3958
3958
  },
3959
3959
  onMouseLeave: () => setTimeout(() => l(""), 300),
3960
3960
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3967,7 +3967,7 @@ const getBlockRuntimeProps = memoize((o) => {
3967
3967
  id: "canvas-iframe",
3968
3968
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
3969
3969
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
3970
- initialContent: S,
3970
+ initialContent: _,
3971
3971
  children: [
3972
3972
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
3973
3973
  /* @__PURE__ */ jsx(
@@ -3979,7 +3979,7 @@ const getBlockRuntimeProps = memoize((o) => {
3979
3979
  ),
3980
3980
  /* @__PURE__ */ jsx(HeadTags, {}),
3981
3981
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
3982
- y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
3982
+ b ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
3983
3983
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
3984
3984
  /* @__PURE__ */ jsx("br", {}),
3985
3985
  /* @__PURE__ */ jsx("br", {}),
@@ -4140,62 +4140,62 @@ const getBlockRuntimeProps = memoize((o) => {
4140
4140
  }
4141
4141
  );
4142
4142
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4143
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4144
- a(y);
4143
+ const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (b) => {
4144
+ a(b);
4145
4145
  }, f = () => {
4146
- const y = l.find((B) => Object.keys(B)[0] === r);
4147
- if (y) {
4148
- const B = Object.values(y)[0];
4146
+ const b = l.find((B) => Object.keys(B)[0] === r);
4147
+ if (b) {
4148
+ const B = Object.values(b)[0];
4149
4149
  B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4150
4150
  } else
4151
4151
  console.error("Preset not found:", r);
4152
4152
  }, m = useDebouncedCallback(
4153
- (y, B) => {
4153
+ (b, B) => {
4154
4154
  d(() => ({
4155
4155
  ...c,
4156
4156
  fontFamily: {
4157
4157
  ...c.fontFamily,
4158
- [y.replace(/font-/g, "")]: B
4158
+ [b.replace(/font-/g, "")]: B
4159
4159
  }
4160
4160
  }));
4161
4161
  },
4162
4162
  [c],
4163
4163
  200
4164
4164
  ), h = useDebouncedCallback(
4165
- (y) => {
4165
+ (b) => {
4166
4166
  d(() => ({
4167
4167
  ...c,
4168
- borderRadius: `${y}px`
4168
+ borderRadius: `${b}px`
4169
4169
  }));
4170
4170
  },
4171
4171
  [c],
4172
4172
  200
4173
4173
  ), x = useDebouncedCallback(
4174
- (y, B) => {
4174
+ (b, B) => {
4175
4175
  d(() => {
4176
- const j = get(c, `colors.${y}`);
4177
- return n ? set(j, 1, B) : set(j, 0, B), {
4176
+ const E = get(c, `colors.${b}`);
4177
+ return n ? set(E, 1, B) : set(E, 0, B), {
4178
4178
  ...c,
4179
4179
  colors: {
4180
4180
  ...c.colors,
4181
- [y]: j
4181
+ [b]: E
4182
4182
  }
4183
4183
  };
4184
4184
  });
4185
4185
  },
4186
4186
  [c],
4187
4187
  200
4188
- ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4189
- const j = get(c, `colors.${B}.${n ? 1 : 0}`);
4188
+ ), y = (b) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(b.items).map(([B]) => {
4189
+ const E = get(c, `colors.${B}.${n ? 1 : 0}`);
4190
4190
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4191
4191
  /* @__PURE__ */ jsx(
4192
4192
  ColorPickerInput,
4193
4193
  {
4194
- value: j,
4195
- onChange: (C) => x(B, C)
4194
+ value: E,
4195
+ onChange: (w) => x(B, w)
4196
4196
  }
4197
4197
  ),
4198
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4198
+ /* @__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" : "") })
4199
4199
  ] }, B);
4200
4200
  }) });
4201
4201
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
@@ -4207,11 +4207,11 @@ const getBlockRuntimeProps = memoize((o) => {
4207
4207
  "select",
4208
4208
  {
4209
4209
  value: r,
4210
- onChange: (y) => g(y.target.value),
4210
+ onChange: (b) => g(b.target.value),
4211
4211
  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",
4212
4212
  children: [
4213
4213
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
4214
- Array.isArray(l) && l.map((y) => /* @__PURE__ */ jsx("option", { value: Object.keys(y)[0], children: capitalize(Object.keys(y)[0]) }, Object.keys(y)[0]))
4214
+ Array.isArray(l) && l.map((b) => /* @__PURE__ */ jsx("option", { value: Object.keys(b)[0], children: capitalize(Object.keys(b)[0]) }, Object.keys(b)[0]))
4215
4215
  ]
4216
4216
  }
4217
4217
  )
@@ -4228,14 +4228,14 @@ const getBlockRuntimeProps = memoize((o) => {
4228
4228
  ) })
4229
4229
  ] }),
4230
4230
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4231
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4231
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([b, B]) => /* @__PURE__ */ jsx(
4232
4232
  FontSelector,
4233
4233
  {
4234
- label: y,
4235
- value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4236
- onChange: (j) => m(y, j)
4234
+ label: b,
4235
+ value: c.fontFamily[b.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4236
+ onChange: (E) => m(b, E)
4237
4237
  },
4238
- y
4238
+ b
4239
4239
  )) }),
4240
4240
  (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4241
4241
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
@@ -4246,7 +4246,7 @@ const getBlockRuntimeProps = memoize((o) => {
4246
4246
  ] }),
4247
4247
  (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4248
4248
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4249
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4249
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((b) => y(b)) }, n ? "dark" : "light")
4250
4250
  ] })
4251
4251
  ] }),
4252
4252
  /* @__PURE__ */ jsx("br", {}),
@@ -4389,14 +4389,14 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4389
4389
  }, [a, o]);
4390
4390
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
4391
4391
  (h) => {
4392
- const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4393
- h.type === "object" ? (c((b) => [...b, h.key]), p(h.value)) : x(h.type) && (n([...i, h.key].join(".")), l(!1));
4392
+ const x = (y) => r === "value" ? y === "value" || y === "object" : r === "array" ? y === "array" : y === r;
4393
+ h.type === "object" ? (c((y) => [...y, h.key]), p(h.value)) : x(h.type) && (n([...i, h.key].join(".")), l(!1));
4394
4394
  },
4395
4395
  [i, n, r]
4396
4396
  ), f = React.useCallback(() => {
4397
4397
  if (i.length > 0) {
4398
4398
  const h = i.slice(0, -1);
4399
- c(h), p(h.reduce((x, b) => x[b], o));
4399
+ c(h), p(h.reduce((x, y) => x[y], o));
4400
4400
  }
4401
4401
  }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
4402
4402
  key: h,
@@ -4671,11 +4671,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4671
4671
  if (h !== x)
4672
4672
  u.chain().deleteSelection().insertContent(m).run();
4673
4673
  else {
4674
- const { state: y } = u, B = y.selection.from, j = y.doc.textBetween(Math.max(0, B - 1), B), C = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4675
- let S = "";
4676
- B > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4677
- let A = "";
4678
- C && C !== " " && !/[.,!?;:]/.test(C) && (A = " "), u.chain().insertContent(S + m + A).run();
4674
+ const { state: b } = u, B = b.selection.from, E = b.doc.textBetween(Math.max(0, B - 1), B), w = b.doc.textBetween(B, Math.min(B + 1, b.doc.content.size));
4675
+ let _ = "";
4676
+ B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4677
+ let j = "";
4678
+ w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + m + j).run();
4679
4679
  }
4680
4680
  };
4681
4681
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (f) => !f && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4757,16 +4757,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4757
4757
  onChange: r
4758
4758
  }) => {
4759
4759
  var L;
4760
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [b, y] = useState(-1), B = useRef(null), j = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4760
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [y, b] = useState(-1), B = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4761
4761
  useEffect(() => {
4762
- if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4762
+ if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4763
4763
  const v = split(o, ":"), k = get(v, 1, "page") || "page";
4764
4764
  g(k), (async () => {
4765
- const E = await l(k, [get(v, 2, "page")]);
4766
- E && Array.isArray(E) && m(get(E, [0, "name"], ""));
4765
+ const A = await l(k, [get(v, 2, "page")]);
4766
+ A && Array.isArray(A) && m(get(A, [0, "name"], ""));
4767
4767
  })();
4768
4768
  }, [o]);
4769
- const C = useDebouncedCallback(
4769
+ const w = useDebouncedCallback(
4770
4770
  async (v) => {
4771
4771
  if (isEmpty(v))
4772
4772
  x([]);
@@ -4774,40 +4774,40 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4774
4774
  const k = await l(u, v);
4775
4775
  x(k);
4776
4776
  }
4777
- c(!1), y(-1);
4777
+ c(!1), b(-1);
4778
4778
  },
4779
4779
  [u],
4780
4780
  300
4781
- ), S = (v) => {
4781
+ ), _ = (v) => {
4782
4782
  const k = ["pageType", u, v.id];
4783
- k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4784
- }, A = (v) => {
4783
+ k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), b(-1));
4784
+ }, j = (v) => {
4785
4785
  switch (v.key) {
4786
4786
  case "ArrowDown":
4787
- v.preventDefault(), y((k) => k < h.length - 1 ? k + 1 : k);
4787
+ v.preventDefault(), b((k) => k < h.length - 1 ? k + 1 : k);
4788
4788
  break;
4789
4789
  case "ArrowUp":
4790
- v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4790
+ v.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4791
4791
  break;
4792
4792
  case "Enter":
4793
4793
  if (v.preventDefault(), h.length === 0) return;
4794
- b >= 0 && S(h[b]);
4794
+ y >= 0 && _(h[y]);
4795
4795
  break;
4796
4796
  case "Escape":
4797
- v.preventDefault(), _();
4797
+ v.preventDefault(), S();
4798
4798
  break;
4799
4799
  }
4800
4800
  };
4801
4801
  useEffect(() => {
4802
- if (b >= 0 && B.current) {
4803
- const v = B.current.children[b];
4802
+ if (y >= 0 && B.current) {
4803
+ const v = B.current.children[y];
4804
4804
  v == null || v.scrollIntoView({ block: "nearest" });
4805
4805
  }
4806
- }, [b]);
4807
- const _ = () => {
4808
- m(""), x([]), y(-1), p(!1), r("");
4809
- }, w = (v) => {
4810
- m(v), p(!isEmpty(v)), c(!0), C(v);
4806
+ }, [y]);
4807
+ const S = () => {
4808
+ m(""), x([]), b(-1), p(!1), r("");
4809
+ }, C = (v) => {
4810
+ m(v), p(!isEmpty(v)), c(!0), w(v);
4811
4811
  };
4812
4812
  return /* @__PURE__ */ jsxs("div", { children: [
4813
4813
  /* @__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)) }),
@@ -4817,13 +4817,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4817
4817
  {
4818
4818
  type: "text",
4819
4819
  value: f,
4820
- onChange: (v) => w(v.target.value),
4821
- onKeyDown: A,
4822
- placeholder: a(`Search ${j ?? ""}`),
4820
+ onChange: (v) => C(v.target.value),
4821
+ onKeyDown: j,
4822
+ placeholder: a(`Search ${E ?? ""}`),
4823
4823
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4824
4824
  }
4825
4825
  ),
4826
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4826
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4827
4827
  ] }),
4828
4828
  (i || !isEmpty(h) || d && isEmpty(h)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4829
4829
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4836,8 +4836,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4836
4836
  ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(h == null ? void 0 : h.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4837
4837
  "li",
4838
4838
  {
4839
- onClick: () => S(v),
4840
- 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"}`,
4839
+ onClick: () => _(v),
4840
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4841
4841
  children: [
4842
4842
  v.name,
4843
4843
  " ",
@@ -4933,23 +4933,23 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4933
4933
  const f = () => {
4934
4934
  const x = findIndex(u, { _id: g });
4935
4935
  if (x > -1) {
4936
- const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4937
- if (!y) return;
4938
- n({ ...o, currentSlide: y }), c([y]);
4936
+ const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4937
+ if (!b) return;
4938
+ n({ ...o, currentSlide: b }), c([b]);
4939
4939
  }
4940
4940
  }, m = () => {
4941
4941
  const x = findIndex(u, { _id: g });
4942
4942
  if (x > -1) {
4943
- const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4944
- if (!y) return;
4945
- n({ ...o, currentSlide: y }), c([y]);
4943
+ const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4944
+ if (!b) return;
4945
+ n({ ...o, currentSlide: b }), c([b]);
4946
4946
  }
4947
4947
  }, h = () => {
4948
4948
  const x = i(
4949
4949
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4950
4950
  p == null ? void 0 : p._id
4951
- ), b = x == null ? void 0 : x._id;
4952
- b && (n({ ...o, currentSlide: b }), c([b]));
4951
+ ), y = x == null ? void 0 : x._id;
4952
+ y && (n({ ...o, currentSlide: y }), c([y]));
4953
4953
  };
4954
4954
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4955
4955
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -5028,8 +5028,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5028
5028
  className: "text-xs",
5029
5029
  pattern: "[0-9]*",
5030
5030
  onChange: (x) => {
5031
- let b = x.target.value;
5032
- b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5031
+ let y = x.target.value;
5032
+ y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
5033
5033
  }
5034
5034
  }
5035
5035
  )
@@ -5068,41 +5068,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5068
5068
  formData: g,
5069
5069
  onChange: f
5070
5070
  }) => {
5071
- const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? h : m, y = get(LANGUAGES, b, b), B = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [A, _] = useState(null), w = useCallback(
5071
+ const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? h : m, b = get(LANGUAGES, y, y), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5072
5072
  (k) => {
5073
- const E = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5074
- let P = "", O = "";
5073
+ const A = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5074
+ let R = "", O = "";
5075
5075
  const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5076
- return D > 0 && ($ === "." || !E($) && $ !== " ") && (P = " "), D < N.length && !E(H) && H !== " " && (O = " "), {
5077
- text: P + M + O,
5078
- prefixLength: P.length,
5076
+ return D > 0 && ($ === "." || !A($) && $ !== " ") && (R = " "), D < N.length && !A(H) && H !== " " && (O = " "), {
5077
+ text: R + M + O,
5078
+ prefixLength: R.length,
5079
5079
  suffixLength: O.length
5080
5080
  };
5081
5081
  }, I = document.getElementById(o);
5082
5082
  if (!I) return;
5083
- const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5084
- if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
5085
- const N = R.__chaiRTE;
5083
+ const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5084
+ if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5085
+ const N = P.__chaiRTE;
5086
5086
  if (N) {
5087
5087
  const D = `{{${k}}}`;
5088
5088
  N.commands.focus();
5089
- const { from: M, to: P } = N.state.selection;
5090
- if (M !== P)
5089
+ const { from: M, to: R } = N.state.selection;
5090
+ if (M !== R)
5091
5091
  N.chain().deleteSelection().insertContent(D).run();
5092
5092
  else {
5093
5093
  const { state: $ } = N, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5094
5094
  let z = "";
5095
- H > 0 && F !== " " && !E(F) && (z = " ");
5095
+ H > 0 && F !== " " && !A(F) && (z = " ");
5096
5096
  let W = "";
5097
- U && U !== " " && !E(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5097
+ U && U !== " " && !A(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5098
5098
  }
5099
5099
  setTimeout(() => f(N.getHTML(), {}, o), 100);
5100
5100
  return;
5101
5101
  }
5102
5102
  } else {
5103
- const N = I, D = N.selectionStart || 0, M = N.value || "", P = N.selectionEnd || D;
5104
- if (P > D) {
5105
- const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(P);
5103
+ const N = I, D = N.selectionStart || 0, M = N.value || "", R = N.selectionEnd || D;
5104
+ if (R > D) {
5105
+ const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(R);
5106
5106
  f(W, {}, o);
5107
5107
  return;
5108
5108
  }
@@ -5110,20 +5110,20 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5110
5110
  f(F, {}, o);
5111
5111
  }
5112
5112
  },
5113
- [o, f, g, j == null ? void 0 : j._id]
5113
+ [o, f, g, E == null ? void 0 : E._id]
5114
5114
  );
5115
5115
  if (d)
5116
5116
  return null;
5117
5117
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5118
- const v = S == null ? void 0 : S.includes(o.replace("root.", ""));
5118
+ const v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
5119
5119
  if (u.type === "array") {
5120
- const k = A === o;
5120
+ const k = j === o;
5121
5121
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5122
5122
  u.title && /* @__PURE__ */ jsxs(
5123
5123
  "label",
5124
5124
  {
5125
5125
  htmlFor: o,
5126
- onClick: () => _(k ? null : o),
5126
+ onClick: () => S(k ? null : o),
5127
5127
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5128
5128
  children: [
5129
5129
  k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
@@ -5149,11 +5149,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5149
5149
  " ",
5150
5150
  v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5151
5151
  " ",
5152
- y
5152
+ b
5153
5153
  ] }),
5154
5154
  p && u.type !== "object" ? " *" : null
5155
5155
  ] }),
5156
- u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: w, dataType: "value" })
5156
+ u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
5157
5157
  ] }),
5158
5158
  c,
5159
5159
  a,
@@ -5252,35 +5252,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5252
5252
  }), a;
5253
5253
  };
5254
5254
  function BlockSettings() {
5255
- 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(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: A }, _, w) => {
5256
- _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, w);
5255
+ 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(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: j }, S, C) => {
5256
+ S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5257
5257
  }, x = useCallback(
5258
- debounce(({ formData: A }, _, w) => {
5259
- h({ formData: A }, _, w), d(A);
5258
+ debounce(({ formData: j }, S, C) => {
5259
+ h({ formData: j }, S, C), d(j);
5260
5260
  }, 1500),
5261
5261
  [n == null ? void 0 : n._id, o]
5262
- ), b = ({ formData: A }, _) => {
5263
- _ && (r([n._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5264
- }, y = ({ formData: A }, _) => {
5265
- _ && (r([g._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5262
+ ), y = ({ formData: j }, S) => {
5263
+ S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5264
+ }, b = ({ formData: j }, S) => {
5265
+ S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5266
5266
  };
5267
5267
  keys(get(i, "_bindings", {}));
5268
- const { schema: B, uiSchema: j } = useMemo(() => {
5269
- const A = n == null ? void 0 : n._type;
5270
- if (A)
5271
- return getBlockFormSchemas(A);
5272
- }, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
5268
+ const { schema: B, uiSchema: E } = useMemo(() => {
5269
+ const j = n == null ? void 0 : n._type;
5270
+ if (j)
5271
+ return getBlockFormSchemas(j);
5272
+ }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5273
5273
  if (!g || !(g != null && g._type))
5274
5274
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5275
- const A = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(A);
5276
- return { wrapperSchema: _, wrapperUiSchema: w };
5275
+ const j = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: C = {} } = getBlockFormSchemas(j);
5276
+ return { wrapperSchema: S, wrapperUiSchema: C };
5277
5277
  }, [g]);
5278
5278
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5279
5279
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5280
5280
  /* @__PURE__ */ jsxs(
5281
5281
  "div",
5282
5282
  {
5283
- onClick: () => u((A) => !A),
5283
+ onClick: () => u((j) => !j),
5284
5284
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5285
5285
  children: [
5286
5286
  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" }),
@@ -5299,10 +5299,10 @@ function BlockSettings() {
5299
5299
  JSONForm,
5300
5300
  {
5301
5301
  blockId: g == null ? void 0 : g._id,
5302
- onChange: y,
5302
+ onChange: b,
5303
5303
  formData: m,
5304
- schema: C,
5305
- uiSchema: S
5304
+ schema: w,
5305
+ uiSchema: _
5306
5306
  }
5307
5307
  ) })
5308
5308
  ] }),
@@ -5310,10 +5310,10 @@ function BlockSettings() {
5310
5310
  JSONForm,
5311
5311
  {
5312
5312
  blockId: n == null ? void 0 : n._id,
5313
- onChange: b,
5313
+ onChange: y,
5314
5314
  formData: i,
5315
5315
  schema: B,
5316
- uiSchema: j
5316
+ uiSchema: E
5317
5317
  }
5318
5318
  ),
5319
5319
  (n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
@@ -5418,33 +5418,33 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5418
5418
  canvas: n = !1,
5419
5419
  tooltip: r = !0
5420
5420
  }) => {
5421
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (y) => {
5422
- u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5423
- }, x = (y) => {
5424
- n || l(y), c(y);
5425
- }, b = getBreakpointValue(n ? i : a).toLowerCase();
5426
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5421
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
5422
+ u.includes(b) ? u.length > 2 && g(u.filter((B) => B !== b)) : g((B) => [...B, b]);
5423
+ }, x = (b) => {
5424
+ n || l(b), c(b);
5425
+ }, y = getBreakpointValue(n ? i : a).toLowerCase();
5426
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
5427
5427
  BreakpointCard,
5428
5428
  {
5429
5429
  canvas: n,
5430
- ...y,
5430
+ ...b,
5431
5431
  onClick: x,
5432
- key: y.breakpoint,
5433
- currentBreakpoint: b
5432
+ key: b.breakpoint,
5433
+ currentBreakpoint: y
5434
5434
  }
5435
5435
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5436
5436
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5437
- m.filter((y) => includes(u, toUpper(y.breakpoint))),
5438
- (y) => /* @__PURE__ */ createElement(
5437
+ m.filter((b) => includes(u, toUpper(b.breakpoint))),
5438
+ (b) => /* @__PURE__ */ createElement(
5439
5439
  BreakpointCard,
5440
5440
  {
5441
5441
  canvas: n,
5442
5442
  openDelay: o,
5443
5443
  tooltip: r,
5444
- ...y,
5444
+ ...b,
5445
5445
  onClick: x,
5446
- key: y.breakpoint,
5447
- currentBreakpoint: b
5446
+ key: b.breakpoint,
5447
+ currentBreakpoint: y
5448
5448
  }
5449
5449
  )
5450
5450
  ) }),
@@ -5453,15 +5453,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5453
5453
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5454
5454
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
5455
5455
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5456
- map(m, (y) => /* @__PURE__ */ jsx(
5456
+ map(m, (b) => /* @__PURE__ */ jsx(
5457
5457
  DropdownMenuCheckboxItem,
5458
5458
  {
5459
- disabled: y.breakpoint === "xs",
5460
- onCheckedChange: () => h(toUpper(y.breakpoint)),
5461
- checked: includes(u, toUpper(y.breakpoint)),
5462
- children: f(y.title)
5459
+ disabled: b.breakpoint === "xs",
5460
+ onCheckedChange: () => h(toUpper(b.breakpoint)),
5461
+ checked: includes(u, toUpper(b.breakpoint)),
5462
+ children: f(b.title)
5463
5463
  },
5464
- y.breakpoint
5464
+ b.breakpoint
5465
5465
  ))
5466
5466
  ] })
5467
5467
  ] })
@@ -5611,24 +5611,24 @@ const AskAIStyles = ({ blockId: o }) => {
5611
5611
  };
5612
5612
  function ManualClasses() {
5613
5613
  var T;
5614
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = y.split(" ").filter((I) => !isEmpty(I)), j = () => {
5614
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), B = b.split(" ").filter((I) => !isEmpty(I)), E = () => {
5615
5615
  const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5616
5616
  u(f, I, !0), x("");
5617
- }, [C, S] = useState([]), A = ({ value: I }) => {
5618
- const R = I.trim().toLowerCase(), N = R.match(/.+:/g);
5617
+ }, [w, _] = useState([]), j = ({ value: I }) => {
5618
+ const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5619
5619
  let D = [];
5620
5620
  if (N && N.length > 0) {
5621
- const [M] = N, P = R.replace(M, "");
5622
- D = i.search(P).map(($) => ({
5621
+ const [M] = N, R = P.replace(M, "");
5622
+ D = i.search(R).map(($) => ({
5623
5623
  ...$,
5624
5624
  item: { ...$.item, name: M + $.item.name }
5625
5625
  }));
5626
5626
  } else
5627
- D = i.search(R);
5628
- return S(map(D, "item"));
5629
- }, _ = () => {
5630
- S([]);
5631
- }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5627
+ D = i.search(P);
5628
+ return _(map(D, "item"));
5629
+ }, S = () => {
5630
+ _([]);
5631
+ }, C = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5632
5632
  () => ({
5633
5633
  ref: o,
5634
5634
  autoComplete: "off",
@@ -5638,17 +5638,17 @@ function ManualClasses() {
5638
5638
  placeholder: c("Enter classes separated by space"),
5639
5639
  value: h,
5640
5640
  onKeyDown: (I) => {
5641
- I.key === "Enter" && h.trim() !== "" && j();
5641
+ I.key === "Enter" && h.trim() !== "" && E();
5642
5642
  },
5643
- onChange: (I, { newValue: R }) => x(R),
5643
+ onChange: (I, { newValue: P }) => x(P),
5644
5644
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5645
5645
  }),
5646
5646
  [h, c, o]
5647
5647
  ), k = (I) => {
5648
5648
  debugger;
5649
- const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5650
- g(f, [I]), u(f, R, !0), r(""), l(-1);
5651
- }, E = () => {
5649
+ const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5650
+ g(f, [I]), u(f, P, !0), r(""), l(-1);
5651
+ }, A = () => {
5652
5652
  if (navigator.clipboard === void 0) {
5653
5653
  toast.error(c("Clipboard not supported"));
5654
5654
  return;
@@ -5660,7 +5660,7 @@ function ManualClasses() {
5660
5660
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5661
5661
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5662
5662
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5663
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5663
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: A, className: "cursor-pointer" }) }),
5664
5664
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5665
5665
  ] })
5666
5666
  ] }),
@@ -5676,10 +5676,10 @@ function ManualClasses() {
5676
5676
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5677
5677
  Autosuggest,
5678
5678
  {
5679
- suggestions: C,
5680
- onSuggestionsFetchRequested: A,
5681
- onSuggestionsClearRequested: _,
5682
- getSuggestionValue: w,
5679
+ suggestions: w,
5680
+ onSuggestionsFetchRequested: j,
5681
+ onSuggestionsClearRequested: S,
5682
+ getSuggestionValue: C,
5683
5683
  renderSuggestion: L,
5684
5684
  inputProps: v,
5685
5685
  containerProps: {
@@ -5697,7 +5697,7 @@ function ManualClasses() {
5697
5697
  {
5698
5698
  variant: "outline",
5699
5699
  className: "h-6 border-border",
5700
- onClick: j,
5700
+ onClick: E,
5701
5701
  disabled: h.trim() === "",
5702
5702
  size: "sm",
5703
5703
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -5705,7 +5705,7 @@ function ManualClasses() {
5705
5705
  )
5706
5706
  ] }),
5707
5707
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5708
- (I, R) => a === R ? /* @__PURE__ */ jsx(
5708
+ (I, P) => a === P ? /* @__PURE__ */ jsx(
5709
5709
  "input",
5710
5710
  {
5711
5711
  ref: o,
@@ -6077,8 +6077,8 @@ const COLOR_PROP = {
6077
6077
  }, ColorChoice = ({ property: o, onChange: n }) => {
6078
6078
  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", ""), f = get(u, "2", ""), m = useCallback(
6079
6079
  // eslint-disable-next-line no-shadow
6080
- (b) => {
6081
- ["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" })));
6080
+ (y) => {
6081
+ ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
6082
6082
  },
6083
6083
  [c, p]
6084
6084
  );
@@ -6089,8 +6089,8 @@ const COLOR_PROP = {
6089
6089
  }, [g]);
6090
6090
  const h = useCallback(
6091
6091
  // eslint-disable-next-line no-shadow
6092
- (b) => {
6093
- p({ color: g, shade: b });
6092
+ (y) => {
6093
+ p({ color: g, shade: y });
6094
6094
  },
6095
6095
  [g]
6096
6096
  );
@@ -6099,8 +6099,8 @@ const COLOR_PROP = {
6099
6099
  }, [r]);
6100
6100
  const { match: x } = useTailwindClassList();
6101
6101
  return useEffect(() => {
6102
- const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6103
- x(o, y) && n(y, o);
6102
+ const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6103
+ x(o, b) && n(b, o);
6104
6104
  }, [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: [
6105
6105
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6106
6106
  DropDown,
@@ -6338,7 +6338,7 @@ const COLOR_PROP = {
6338
6338
  },
6339
6339
  a
6340
6340
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6341
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [b, y] = useState(""), [B, j] = useState(!1), [C, S] = useState(!1);
6341
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [y, b] = useState(""), [B, E] = useState(!1), [w, _] = useState(!1);
6342
6342
  useEffect(() => {
6343
6343
  const { value: v, unit: k } = getClassValueAndUnit(i);
6344
6344
  if (k === "") {
@@ -6347,24 +6347,24 @@ const COLOR_PROP = {
6347
6347
  }
6348
6348
  m(k), l(k === "class" || isEmpty(v) ? "" : v);
6349
6349
  }, [i, p, u]);
6350
- const A = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), _ = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
6350
+ const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
6351
6351
  (v = !1) => {
6352
6352
  const k = getUserInputValues(`${a}`, u);
6353
6353
  if (get(k, "error", !1)) {
6354
6354
  x(!0);
6355
6355
  return;
6356
6356
  }
6357
- const E = get(k, "unit") !== "" ? get(k, "unit") : f;
6358
- if (E === "auto" || E === "none") {
6359
- A(`${d}${E}`);
6357
+ const A = get(k, "unit") !== "" ? get(k, "unit") : f;
6358
+ if (A === "auto" || A === "none") {
6359
+ j(`${d}${A}`);
6360
6360
  return;
6361
6361
  }
6362
6362
  if (get(k, "value") === "")
6363
6363
  return;
6364
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6365
- v ? _(I) : A(I);
6364
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6365
+ v ? S(I) : j(I);
6366
6366
  },
6367
- [A, _, a, f, d, u]
6367
+ [j, S, a, f, d, u]
6368
6368
  ), L = useCallback(
6369
6369
  (v) => {
6370
6370
  const k = getUserInputValues(`${a}`, u);
@@ -6373,15 +6373,15 @@ const COLOR_PROP = {
6373
6373
  return;
6374
6374
  }
6375
6375
  if (v === "auto" || v === "none") {
6376
- A(`${d}${v}`);
6376
+ j(`${d}${v}`);
6377
6377
  return;
6378
6378
  }
6379
6379
  if (get(k, "value") === "")
6380
6380
  return;
6381
- const E = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6382
- A(I);
6381
+ const A = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6382
+ j(I);
6383
6383
  },
6384
- [A, a, d, u]
6384
+ [j, a, d, u]
6385
6385
  );
6386
6386
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6387
6387
  /* @__PURE__ */ jsx(
@@ -6403,22 +6403,22 @@ const COLOR_PROP = {
6403
6403
  {
6404
6404
  readOnly: f === "class",
6405
6405
  onKeyPress: (v) => {
6406
- v.key === "Enter" && w();
6406
+ v.key === "Enter" && C();
6407
6407
  },
6408
6408
  onKeyDown: (v) => {
6409
6409
  if (v.keyCode !== 38 && v.keyCode !== 40)
6410
6410
  return;
6411
- v.preventDefault(), S(!0);
6411
+ v.preventDefault(), _(!0);
6412
6412
  const k = parseInt$1(v.target.value);
6413
- let E = isNaN$1(k) ? 0 : k;
6414
- v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
6415
- const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
6416
- _(R);
6413
+ let A = isNaN$1(k) ? 0 : k;
6414
+ v.keyCode === 38 && (A += 1), v.keyCode === 40 && (A -= 1);
6415
+ const T = `${A}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
6416
+ S(P);
6417
6417
  },
6418
6418
  onKeyUp: (v) => {
6419
- C && (v.preventDefault(), S(!1));
6419
+ w && (v.preventDefault(), _(!1));
6420
6420
  },
6421
- onBlur: () => w(),
6421
+ onBlur: () => C(),
6422
6422
  onChange: (v) => {
6423
6423
  x(!1), l(v.target.value);
6424
6424
  },
@@ -6426,7 +6426,7 @@ const COLOR_PROP = {
6426
6426
  var k;
6427
6427
  (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6428
6428
  },
6429
- value: B ? b : a,
6429
+ value: B ? y : a,
6430
6430
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6431
6431
  " ",
6432
6432
  h ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6461,19 +6461,19 @@ const COLOR_PROP = {
6461
6461
  ["none", "auto"].indexOf(f) !== -1 || B ? null : /* @__PURE__ */ jsx(
6462
6462
  DragStyleButton,
6463
6463
  {
6464
- onDragStart: () => j(!0),
6464
+ onDragStart: () => E(!0),
6465
6465
  onDragEnd: (v) => {
6466
- if (y(() => ""), j(!1), isEmpty(v))
6466
+ if (b(() => ""), E(!1), isEmpty(v))
6467
6467
  return;
6468
6468
  const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6469
- A(T);
6469
+ j(T);
6470
6470
  },
6471
6471
  onDrag: (v) => {
6472
6472
  if (isEmpty(v))
6473
6473
  return;
6474
- y(v);
6474
+ b(v);
6475
6475
  const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6476
- _(T);
6476
+ S(T);
6477
6477
  },
6478
6478
  currentValue: a,
6479
6479
  unit: f,
@@ -6570,35 +6570,35 @@ const COLOR_PROP = {
6570
6570
  "2xl": "1536px"
6571
6571
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6572
6572
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6573
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
6574
- (_, w = !0) => {
6575
- const L = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
6573
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
6574
+ (S, C = !0) => {
6575
+ const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6576
6576
  (p || u !== "") && (L.mq = "xs");
6577
6577
  const v = generateFullClsName(L);
6578
- m(x, [v], w);
6578
+ m(x, [v], C);
6579
6579
  },
6580
6580
  [x, p, g, u, l, m]
6581
6581
  ), B = useCallback(() => {
6582
- h(x, [b], !0);
6583
- }, [x, b, h]), j = useMemo(() => canChangeClass(f, g), [f, g]);
6582
+ h(x, [y], !0);
6583
+ }, [x, y, h]), E = useMemo(() => canChangeClass(f, g), [f, g]);
6584
6584
  useEffect(() => {
6585
- i(j, f);
6586
- }, [j, i, f]);
6587
- const [, , C] = useScreenSizeWidth(), S = useCallback(
6588
- (_) => {
6589
- C({
6585
+ i(E, f);
6586
+ }, [E, i, f]);
6587
+ const [, , w] = useScreenSizeWidth(), _ = useCallback(
6588
+ (S) => {
6589
+ w({
6590
6590
  xs: 400,
6591
6591
  sm: 640,
6592
6592
  md: 800,
6593
6593
  lg: 1024,
6594
6594
  xl: 1420,
6595
6595
  "2xl": 1920
6596
- }[_]);
6596
+ }[S]);
6597
6597
  },
6598
- [C]
6599
- ), A = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
6600
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: f && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6601
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6598
+ [w]
6599
+ ), j = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
6600
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: f && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6601
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6602
6602
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6603
6603
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6604
6604
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6607,17 +6607,17 @@ const COLOR_PROP = {
6607
6607
  currentClass: get(f, "cls", ""),
6608
6608
  classPrefix: get(CLASS_PREFIXES, l, ""),
6609
6609
  units: c || [],
6610
- onChange: y,
6610
+ onChange: b,
6611
6611
  negative: d,
6612
6612
  cssProperty: l
6613
6613
  }
6614
6614
  ) : null,
6615
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6616
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6617
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6618
- r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6615
+ r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: b }),
6616
+ r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: b }),
6617
+ r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6618
+ r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6619
6619
  ] }),
6620
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: A ? /* @__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" }) }) : j && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6620
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "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 && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6621
6621
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6622
6622
  "button",
6623
6623
  {
@@ -6637,7 +6637,7 @@ const COLOR_PROP = {
6637
6637
  "button",
6638
6638
  {
6639
6639
  type: "button",
6640
- onClick: () => S(get(f, "mq")),
6640
+ onClick: () => _(get(f, "mq")),
6641
6641
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6642
6642
  children: [
6643
6643
  "Switch to ",
@@ -6826,8 +6826,8 @@ function BlockStyling() {
6826
6826
  m = isNaN(m) ? 0 : m;
6827
6827
  let h = MAPPER[i.dragUnit];
6828
6828
  (startsWith(f, "scale") || f === "opacity") && (h = 10);
6829
- let b = (i.dragStartY - u.pageY) / h + m;
6830
- g && b < 0 && (b = 0), f === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6829
+ let y = (i.dragStartY - u.pageY) / h + m;
6830
+ g && y < 0 && (y = 0), f === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6831
6831
  },
6832
6832
  [i],
6833
6833
  50
@@ -6871,8 +6871,8 @@ const CoreBlock = ({
6871
6871
  }) => {
6872
6872
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6873
6873
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6874
- const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6875
- u(syncBlocksWithDefaults(b), r || null, a);
6874
+ const y = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6875
+ u(syncBlocksWithDefaults(y), r || null, a);
6876
6876
  } else
6877
6877
  p(o, r || null, a);
6878
6878
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6884,8 +6884,8 @@ const CoreBlock = ({
6884
6884
  disabled: n,
6885
6885
  onClick: m,
6886
6886
  type: "button",
6887
- onDragStart: (b) => {
6888
- b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6887
+ onDragStart: (y) => {
6888
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6889
6889
  g([]), f();
6890
6890
  }, 200);
6891
6891
  },
@@ -7085,22 +7085,22 @@ const CoreBlock = ({
7085
7085
  }
7086
7086
  }
7087
7087
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7088
- var f, m, h, x, b, y, B, j;
7088
+ var f, m, h, x, y, b, B, E;
7089
7089
  if (r.type === "comment") return [];
7090
7090
  console.log("node ===>", r);
7091
7091
  let a = { _id: generateUUID() };
7092
7092
  if (n && (a._parent = n.block._id), r.type === "text")
7093
7093
  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", "") };
7094
7094
  const l = get(r, "attributes", []), i = l.find(
7095
- (C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
7095
+ (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7096
7096
  ), c = l.find(
7097
- (C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
7097
+ (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7098
7098
  ), d = l.find(
7099
- (C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
7099
+ (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7100
7100
  ), p = l.find(
7101
- (C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
7101
+ (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
7102
7102
  ), u = l.find(
7103
- (C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
7103
+ (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
7104
7104
  );
7105
7105
  if (a = {
7106
7106
  ...a,
@@ -7108,13 +7108,13 @@ const CoreBlock = ({
7108
7108
  ...getAttrs(r),
7109
7109
  ...getStyles(r)
7110
7110
  }, r.attributes) {
7111
- const C = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
7112
- C && (a._name = C.value);
7111
+ const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
7112
+ w && (a._name = w.value);
7113
7113
  }
7114
7114
  if (i)
7115
7115
  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];
7116
7116
  if (c) {
7117
- const C = [
7117
+ const w = [
7118
7118
  "data-chai-lightbox",
7119
7119
  "chai-lightbox",
7120
7120
  "data-vbtype",
@@ -7126,44 +7126,44 @@ const CoreBlock = ({
7126
7126
  ];
7127
7127
  a = {
7128
7128
  ...a,
7129
- href: ((f = l.find((S) => S.key === "href")) == null ? void 0 : f.value) || "",
7130
- hrefType: ((m = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7131
- autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7132
- maxWidth: ((b = (x = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7133
- backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
7134
- galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
7135
- }, forEach(C, (S) => {
7136
- has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
7129
+ href: ((f = l.find((_) => _.key === "href")) == null ? void 0 : f.value) || "",
7130
+ hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7131
+ autoplay: ((h = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7132
+ maxWidth: ((y = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
7133
+ backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
7134
+ galleryName: ((B = l.find((_) => _.key === "data-gall")) == null ? void 0 : B.value) || ""
7135
+ }, forEach(w, (_) => {
7136
+ has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
7137
7137
  });
7138
7138
  }
7139
7139
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7140
7140
  delete a.styles_attrs;
7141
- const C = filter(r.children || [], (A) => (A == null ? void 0 : A.tagName) !== "span");
7142
- a.content = getTextContent(C);
7143
- const S = find(
7141
+ const w = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
7142
+ a.content = getTextContent(w);
7143
+ const _ = find(
7144
7144
  r.children || [],
7145
- (A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7145
+ (j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
7146
7146
  );
7147
- if (S) {
7148
- const A = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7149
- if (A) {
7150
- a.icon = stringify([A]);
7151
- const { height: _, width: w } = getSvgDimensions(A, "16px", "16px");
7152
- a.iconHeight = _, a.iconWidth = w;
7147
+ if (_) {
7148
+ const j = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7149
+ if (j) {
7150
+ a.icon = stringify([j]);
7151
+ const { height: S, width: C } = getSvgDimensions(j, "16px", "16px");
7152
+ a.iconHeight = S, a.iconWidth = C;
7153
7153
  }
7154
7154
  }
7155
7155
  return [a];
7156
7156
  }
7157
7157
  if (a._type === "Input") {
7158
- const C = a.inputType || "text";
7159
- C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
7158
+ const w = a.inputType || "text";
7159
+ w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7160
7160
  } else if (r.tagName === "video" || r.tagName === "iframe") {
7161
- const C = stringify([r]);
7162
- 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];
7161
+ const w = stringify([r]);
7162
+ 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];
7163
7163
  } else if (r.tagName === "svg") {
7164
- const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = get(C, "value") ? `[${get(C, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7165
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${A}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7166
- } else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
7164
+ 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");
7165
+ 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];
7166
+ } else if (r.tagName == "option" && n && ((E = n.block) == null ? void 0 : E._type) === "Select")
7167
7167
  return n.block.options.push({
7168
7168
  label: getTextContent(r.children),
7169
7169
  ...getAttrs(r)
@@ -7236,20 +7236,20 @@ const CoreBlock = ({
7236
7236
  error: c
7237
7237
  }), g(!0);
7238
7238
  else if (!l && Object.keys(a || {}).length > 0) {
7239
- const m = Object.entries(a).map(([x, b]) => {
7240
- const y = b, B = y.type || "partial", j = formatReadableName(B);
7239
+ const m = Object.entries(a).map(([x, y]) => {
7240
+ const b = y, B = b.type || "partial", E = formatReadableName(B);
7241
7241
  return {
7242
7242
  type: "PartialBlock",
7243
7243
  // Set the type to PartialBlock
7244
- label: formatReadableName(y.name || x),
7245
- description: y.description || "",
7244
+ label: formatReadableName(b.name || x),
7245
+ description: b.description || "",
7246
7246
  icon: Globe,
7247
- group: j,
7247
+ group: E,
7248
7248
  // Use formatted type as group
7249
7249
  category: "partial",
7250
7250
  partialBlockId: x,
7251
7251
  // Store the original ID as partialBlockId
7252
- _name: y.name
7252
+ _name: b.name
7253
7253
  };
7254
7254
  }), h = uniq(map(m, "group"));
7255
7255
  p({
@@ -7298,43 +7298,43 @@ const CoreBlock = ({
7298
7298
  );
7299
7299
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7300
7300
  var v;
7301
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, b] = useState(null), y = useRef(null);
7301
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, y] = useState(null), b = useRef(null);
7302
7302
  useEffect(() => {
7303
7303
  const k = setTimeout(() => {
7304
- var E;
7305
- (E = u.current) == null || E.focus();
7304
+ var A;
7305
+ (A = u.current) == null || A.focus();
7306
7306
  }, 0);
7307
7307
  return () => clearTimeout(k);
7308
7308
  }, [g]), useEffect(() => {
7309
- d && (h("all"), b(null));
7310
- }, [d]), useEffect(() => (y.current = debounce((k) => {
7309
+ d && (h("all"), y(null));
7310
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7311
7311
  h(k);
7312
7312
  }, 500), () => {
7313
- y.current && y.current.cancel();
7313
+ b.current && b.current.cancel();
7314
7314
  }), []);
7315
7315
  const B = useCallback((k) => {
7316
- b(k), y.current && y.current(k);
7317
- }, []), j = useCallback(() => {
7318
- b(null), y.current && y.current.cancel();
7319
- }, []), C = useCallback((k) => {
7320
- y.current && y.current.cancel(), h(k), b(null);
7321
- }, []), S = useMemo(
7316
+ y(k), b.current && b.current(k);
7317
+ }, []), E = useCallback(() => {
7318
+ y(null), b.current && b.current.cancel();
7319
+ }, []), w = useCallback((k) => {
7320
+ b.current && b.current.cancel(), h(k), y(null);
7321
+ }, []), _ = useMemo(
7322
7322
  () => d ? values(n).filter(
7323
7323
  (k) => {
7324
- var E, T;
7325
- return (((E = k.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7324
+ var A, T;
7325
+ return (((A = k.label) == null ? void 0 : A.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7326
7326
  }
7327
7327
  ) : n,
7328
7328
  [n, d]
7329
- ), A = useMemo(
7329
+ ), j = useMemo(
7330
7330
  () => d ? o.filter(
7331
- (k) => reject(filter(values(S), { group: k }), { hidden: !0 }).length > 0
7331
+ (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7332
7332
  ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7333
- [n, S, o, d]
7334
- ), _ = useMemo(
7335
- () => sortBy(A, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7336
- [A]
7337
- ), w = useMemo(() => m === "all" ? S : filter(values(S), { group: m }), [S, m]), L = useMemo(() => m === "all" ? _ : [m], [_, m]);
7333
+ [n, _, o, d]
7334
+ ), S = useMemo(
7335
+ () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7336
+ [j]
7337
+ ), C = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), L = useMemo(() => m === "all" ? S : [m], [S, m]);
7338
7338
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7339
7339
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7340
7340
  Input$1,
@@ -7348,31 +7348,31 @@ const CoreBlock = ({
7348
7348
  }
7349
7349
  ) }),
7350
7350
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7351
- _.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7351
+ S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7352
7352
  /* @__PURE__ */ jsx(
7353
7353
  "button",
7354
7354
  {
7355
- onClick: () => C("all"),
7355
+ onClick: () => w("all"),
7356
7356
  onMouseEnter: () => B("all"),
7357
- onMouseLeave: j,
7357
+ onMouseLeave: E,
7358
7358
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7359
7359
  children: i("All")
7360
7360
  },
7361
7361
  "sidebar-all"
7362
7362
  ),
7363
- _.map((k) => /* @__PURE__ */ jsx(
7363
+ S.map((k) => /* @__PURE__ */ jsx(
7364
7364
  "button",
7365
7365
  {
7366
- onClick: () => C(k),
7366
+ onClick: () => w(k),
7367
7367
  onMouseEnter: () => B(k),
7368
- onMouseLeave: j,
7368
+ onMouseLeave: E,
7369
7369
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7370
7370
  children: capitalize(i(k.toLowerCase()))
7371
7371
  },
7372
7372
  `sidebar-${k}`
7373
7373
  ))
7374
7374
  ] }) }) }),
7375
- /* @__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: A.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: [
7375
+ /* @__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: [
7376
7376
  i("No blocks found matching"),
7377
7377
  ' "',
7378
7378
  d,
@@ -7381,17 +7381,17 @@ const CoreBlock = ({
7381
7381
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7382
7382
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7383
7383
  reject(
7384
- m === "all" ? filter(values(w), { group: k }) : values(w),
7384
+ m === "all" ? filter(values(C), { group: k }) : values(C),
7385
7385
  { hidden: !0 }
7386
- ).map((E) => /* @__PURE__ */ jsx(
7386
+ ).map((A) => /* @__PURE__ */ jsx(
7387
7387
  CoreBlock,
7388
7388
  {
7389
7389
  parentId: r,
7390
7390
  position: a,
7391
- block: E,
7392
- disabled: !canAcceptChildBlock(f, E.type) || !canBeNestedInside(f, E.type)
7391
+ block: A,
7392
+ disabled: !canAcceptChildBlock(f, A.type) || !canBeNestedInside(f, A.type)
7393
7393
  },
7394
- E.type
7394
+ A.type
7395
7395
  ))
7396
7396
  ) })
7397
7397
  ] }, k)) }) }) })
@@ -7493,17 +7493,17 @@ const BlockCard = ({
7493
7493
  position: a = -1
7494
7494
  }) => {
7495
7495
  const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), x = (B) => {
7496
- const j = has(B, "styles_attrs.data-page-section");
7497
- return B._type === "Box" && j;
7498
- }, b = useCallback(
7496
+ const E = has(B, "styles_attrs.data-page-section");
7497
+ return B._type === "Box" && E;
7498
+ }, y = useCallback(
7499
7499
  async (B) => {
7500
7500
  if (B.stopPropagation(), has(o, "component")) {
7501
7501
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7502
7502
  return;
7503
7503
  }
7504
7504
  i(!0);
7505
- const j = await c(n, o);
7506
- isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7505
+ const E = await c(n, o);
7506
+ isEmpty(E) || p(syncBlocksWithDefaults(E), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7507
7507
  },
7508
7508
  [d, p, o, c, n, r, a]
7509
7509
  );
@@ -7512,21 +7512,21 @@ const BlockCard = ({
7512
7512
  "div",
7513
7513
  {
7514
7514
  onClick: l ? () => {
7515
- } : b,
7515
+ } : y,
7516
7516
  draggable: m ? "true" : "false",
7517
7517
  onDragStart: async (B) => {
7518
- const j = await c(n, o);
7519
- let C = r;
7520
- if (x(first(j)) && (C = null), !isEmpty(j)) {
7521
- const S = { blocks: j, uiLibrary: !0, parent: C };
7522
- if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7523
- const A = new Image();
7524
- A.src = o.preview, A.onload = () => {
7525
- B.dataTransfer.setDragImage(A, 0, 0);
7518
+ const E = await c(n, o);
7519
+ let w = r;
7520
+ if (x(first(E)) && (w = null), !isEmpty(E)) {
7521
+ const _ = { blocks: E, uiLibrary: !0, parent: w };
7522
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7523
+ const j = new Image();
7524
+ j.src = o.preview, j.onload = () => {
7525
+ B.dataTransfer.setDragImage(j, 0, 0);
7526
7526
  };
7527
7527
  } else
7528
7528
  B.dataTransfer.setDragImage(new Image(), 0, 0);
7529
- h(S), setTimeout(() => {
7529
+ h(_), setTimeout(() => {
7530
7530
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7531
7531
  }, 200);
7532
7532
  }
@@ -7558,9 +7558,9 @@ const BlockCard = ({
7558
7558
  })();
7559
7559
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7560
7560
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7561
- 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"), [f, m] = useState("Hero"), h = get(g, f, []), x = useRef(null), { t: b } = useTranslation(), y = (C) => {
7561
+ 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"), [f, m] = useState("Hero"), h = get(g, f, []), x = useRef(null), { t: y } = useTranslation(), b = (w) => {
7562
7562
  x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7563
- x.current && m(C);
7563
+ x.current && m(w);
7564
7564
  }, 300);
7565
7565
  };
7566
7566
  if (u)
@@ -7568,30 +7568,30 @@ const BlockCard = ({
7568
7568
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7569
7569
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7570
7570
  ] });
7571
- const B = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7571
+ const B = filter(h, (w, _) => _ % 2 === 0), E = filter(h, (w, _) => _ % 2 === 1);
7572
7572
  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: [
7573
7573
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7574
7574
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7575
7575
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7576
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7576
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: y("Groups") }),
7577
7577
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7578
7578
  /* @__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(
7579
- map(g, (C, S) => /* @__PURE__ */ jsxs(
7579
+ map(g, (w, _) => /* @__PURE__ */ jsxs(
7580
7580
  "div",
7581
7581
  {
7582
- onMouseEnter: () => y(S),
7582
+ onMouseEnter: () => b(_),
7583
7583
  onMouseLeave: () => clearTimeout(x.current),
7584
- onClick: () => m(S),
7584
+ onClick: () => m(_),
7585
7585
  className: cn$1(
7586
7586
  "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",
7587
- S === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7587
+ _ === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7588
7588
  ),
7589
7589
  children: [
7590
- /* @__PURE__ */ jsx("span", { children: capitalize(b(S.toLowerCase())) }),
7590
+ /* @__PURE__ */ jsx("span", { children: capitalize(y(_.toLowerCase())) }),
7591
7591
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7592
7592
  ]
7593
7593
  },
7594
- S
7594
+ _
7595
7595
  ))
7596
7596
  ) })
7597
7597
  ] })
@@ -7604,10 +7604,10 @@ const BlockCard = ({
7604
7604
  children: [
7605
7605
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7606
7606
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7607
- B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7607
+ B.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7608
7608
  ) }),
7609
7609
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7610
- j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7610
+ E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7611
7611
  ) })
7612
7612
  ] }),
7613
7613
  /* @__PURE__ */ jsx("br", {}),
@@ -7853,42 +7853,42 @@ const selectParent = (o, n) => {
7853
7853
  const r = o.selectedNodes[0];
7854
7854
  r.isInternal && n && r.close();
7855
7855
  }, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7856
- var R;
7856
+ var P;
7857
7857
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7858
7858
  let p = null;
7859
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: j } = o, C = (N) => {
7859
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: B, handleClick: E } = o, w = (N) => {
7860
7860
  N.stopPropagation(), !i.includes(m) && o.toggle();
7861
- }, S = (N) => {
7861
+ }, _ = (N) => {
7862
7862
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7863
- }, A = (N) => {
7863
+ }, j = (N) => {
7864
7864
  N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7865
- }, [_, w] = useAtom$1(currentAddSelection), L = () => {
7865
+ }, [S, C] = useAtom$1(currentAddSelection), L = () => {
7866
7866
  var N;
7867
- v(), o.parent.isSelected || w((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7867
+ v(), o.parent.isSelected || C((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7868
7868
  }, v = () => {
7869
- w(null);
7869
+ C(null);
7870
7870
  }, k = (N) => {
7871
- v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), j(N);
7871
+ v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), E(N);
7872
7872
  };
7873
7873
  useEffect(() => {
7874
7874
  const N = setTimeout(() => {
7875
- b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7875
+ y && !o.isOpen && !b && !i.includes(m) && o.toggle();
7876
7876
  }, 500);
7877
7877
  return () => clearTimeout(N);
7878
- }, [b, o, y]);
7879
- const E = useMemo(() => {
7878
+ }, [y, o, b]);
7879
+ const A = useMemo(() => {
7880
7880
  const N = Object.keys(h), D = [];
7881
7881
  for (let M = 0; M < N.length; M++)
7882
7882
  if (N[M].endsWith("_attrs")) {
7883
- const P = h[N[M]], O = Object.keys(P).join("|");
7883
+ const R = h[N[M]], O = Object.keys(R).join("|");
7884
7884
  O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7885
7885
  }
7886
7886
  return D;
7887
7887
  }, [h]), T = (N, D) => {
7888
- const M = d.contentDocument || d.contentWindow.document, P = M.querySelector(`[data-block-id=${N}]`);
7889
- P && P.setAttribute("data-drop", D);
7890
- const O = P.getBoundingClientRect(), $ = d.getBoundingClientRect();
7891
- O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = P.offsetTop - $.top);
7888
+ const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${N}]`);
7889
+ R && R.setAttribute("data-drop", D);
7890
+ const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7891
+ O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7892
7892
  }, I = (N) => {
7893
7893
  v();
7894
7894
  const D = get(o, "parent.id");
@@ -7918,8 +7918,8 @@ const selectParent = (o, n) => {
7918
7918
  style: n,
7919
7919
  "data-node-id": m,
7920
7920
  ref: i.includes(m) ? null : r,
7921
- onDragStart: () => S(o),
7922
- onDragEnd: () => A(o),
7921
+ onDragStart: () => _(o),
7922
+ onDragEnd: () => j(o),
7923
7923
  onDragOver: (N) => {
7924
7924
  N.preventDefault(), T(m, "yes");
7925
7925
  },
@@ -7930,7 +7930,7 @@ const selectParent = (o, n) => {
7930
7930
  N.preventDefault(), T(m, "no");
7931
7931
  },
7932
7932
  children: [
7933
- (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7933
+ (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(
7934
7934
  "div",
7935
7935
  {
7936
7936
  onClick: (N) => {
@@ -7948,9 +7948,9 @@ const selectParent = (o, n) => {
7948
7948
  className: cn$1(
7949
7949
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7950
7950
  x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7951
- b && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7952
- (o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
7953
- y && "opacity-20",
7951
+ y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7952
+ (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7953
+ b && "opacity-20",
7954
7954
  i.includes(m) ? "opacity-50" : ""
7955
7955
  ),
7956
7956
  children: [
@@ -7959,7 +7959,7 @@ const selectParent = (o, n) => {
7959
7959
  "div",
7960
7960
  {
7961
7961
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7962
- children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}` }) })
7962
+ 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"}` }) })
7963
7963
  }
7964
7964
  ),
7965
7965
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
@@ -7973,9 +7973,9 @@ const selectParent = (o, n) => {
7973
7973
  },
7974
7974
  children: [
7975
7975
  /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7976
- E.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7977
- E.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7978
- E.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
7976
+ A.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7977
+ A.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7978
+ A.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
7979
7979
  ]
7980
7980
  }
7981
7981
  )
@@ -8677,8 +8677,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8677
8677
  (x = f.current) == null || x.focus();
8678
8678
  }, []);
8679
8679
  const h = (x) => {
8680
- const { usage: b } = x || {};
8681
- !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8680
+ const { usage: y } = x || {};
8681
+ !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8682
8682
  };
8683
8683
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8684
8684
  /* @__PURE__ */ jsxs(
@@ -8984,8 +8984,11 @@ const AiAssistant = () => {
8984
8984
  /* @__PURE__ */ jsx(AiAssistant, {})
8985
8985
  ] })
8986
8986
  ] });
8987
- }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
8988
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null);
8987
+ }, AttrsEditor = React__default.memo(function o({
8988
+ preloadedAttributes: n = [],
8989
+ onAttributesChange: r
8990
+ }) {
8991
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), y = usePageExternalData();
8989
8992
  useEffect(() => {
8990
8993
  l(n);
8991
8994
  }, [n]);
@@ -8998,12 +9001,12 @@ const AiAssistant = () => {
8998
9001
  const S = [...a, { key: i, value: d }];
8999
9002
  r(S), l(a), c(""), p(""), m("");
9000
9003
  }
9001
- }, y = (S) => {
9002
- const A = a.filter((_, w) => w !== S);
9003
- r(A), l(A);
9004
9004
  }, B = (S) => {
9005
+ const C = a.filter((L, v) => v !== S);
9006
+ r(C), l(C);
9007
+ }, E = (S) => {
9005
9008
  g(S), c(a[S].key), p(a[S].value);
9006
- }, j = () => {
9009
+ }, w = () => {
9007
9010
  if (i.startsWith("@")) {
9008
9011
  m("Attribute keys cannot start with '@'");
9009
9012
  return;
@@ -9012,13 +9015,35 @@ const AiAssistant = () => {
9012
9015
  const S = [...a];
9013
9016
  S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
9014
9017
  }
9015
- };
9018
+ }, _ = (S) => {
9019
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9020
+ }, j = useCallback((S) => {
9021
+ const C = (k) => /[.,!?;:]/.test(k), L = (k, A, T) => {
9022
+ let I = "", P = "";
9023
+ const N = A > 0 ? k[A - 1] : "", D = A < k.length ? k[A] : "";
9024
+ return A > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), A < k.length && !C(D) && D !== " " && (P = " "), {
9025
+ text: I + T + P,
9026
+ prefixLength: I.length,
9027
+ suffixLength: P.length
9028
+ };
9029
+ }, v = x.current;
9030
+ if (v) {
9031
+ const k = v.selectionStart || 0, A = v.value || "", T = v.selectionEnd || k;
9032
+ if (T > k) {
9033
+ const M = `{{${S}}}`, { text: R } = L(A, k, M), O = A.slice(0, k) + R + A.slice(T);
9034
+ p(O);
9035
+ return;
9036
+ }
9037
+ const P = `{{${S}}}`, { text: N } = L(A, k, P), D = A.slice(0, k) + N + A.slice(k);
9038
+ p(D);
9039
+ }
9040
+ }, []);
9016
9041
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
9017
9042
  /* @__PURE__ */ jsxs(
9018
9043
  "form",
9019
9044
  {
9020
9045
  onSubmit: (S) => {
9021
- S.preventDefault(), u !== null ? j() : b();
9046
+ S.preventDefault(), u !== null ? w() : b();
9022
9047
  },
9023
9048
  className: "space-y-3",
9024
9049
  children: [
@@ -9041,7 +9066,10 @@ const AiAssistant = () => {
9041
9066
  )
9042
9067
  ] }),
9043
9068
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9044
- /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9069
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9070
+ /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9071
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: j })
9072
+ ] }),
9045
9073
  /* @__PURE__ */ jsx(
9046
9074
  Textarea,
9047
9075
  {
@@ -9053,9 +9081,7 @@ const AiAssistant = () => {
9053
9081
  ref: x,
9054
9082
  value: d,
9055
9083
  onChange: (S) => p(S.target.value),
9056
- onKeyDown: (S) => {
9057
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : b());
9058
- },
9084
+ onKeyDown: _,
9059
9085
  placeholder: "Enter Value",
9060
9086
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9061
9087
  }
@@ -9067,16 +9093,16 @@ const AiAssistant = () => {
9067
9093
  ]
9068
9094
  }
9069
9095
  ),
9070
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9096
+ /* @__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: [
9071
9097
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9072
9098
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9073
- /* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
9099
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9074
9100
  ] }),
9075
9101
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9076
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9077
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9102
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9103
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9078
9104
  ] })
9079
- ] }, A)) })
9105
+ ] }, C)) })
9080
9106
  ] });
9081
9107
  }), BlockAttributesEditor = React.memo(() => {
9082
9108
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9285,21 +9311,21 @@ const RootLayout = () => {
9285
9311
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9286
9312
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9287
9313
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9288
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9314
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, y) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9289
9315
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9290
9316
  Button,
9291
9317
  {
9292
- variant: o === b ? "default" : "ghost",
9318
+ variant: o === y ? "default" : "ghost",
9293
9319
  className: "mb-2 rounded-lg p-2 transition-colors",
9294
- onClick: () => u(b),
9320
+ onClick: () => u(y),
9295
9321
  children: get(x, "icon", null)
9296
9322
  },
9297
- b
9323
+ y
9298
9324
  ) }),
9299
9325
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(x.label) }) })
9300
- ] }, "button" + b)) }),
9326
+ ] }, "button" + y)) }),
9301
9327
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9302
- /* @__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}`)) })
9328
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, y) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${y}`)) })
9303
9329
  ] }),
9304
9330
  /* @__PURE__ */ jsx(
9305
9331
  motion.div,