@chaibuilder/sdk 2.0.0-beta.24 → 2.0.0-beta.26

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
@@ -108,99 +108,99 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
108
108
  (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set());
109
109
  const c = (m) => o.get(m), d = (m, E) => {
110
110
  (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(E);
111
- const C = o.get(m);
112
- if (o.set(m, E), n.has(m) || n.set(m, C), C && hasPromiseAtomValue(C)) {
113
- const R = "v" in E ? E.v instanceof Promise ? E.v : Promise.resolve(E.v) : Promise.reject(E.e);
114
- cancelPromise(C.v, R);
111
+ const R = o.get(m);
112
+ if (o.set(m, E), n.has(m) || n.set(m, R), R && hasPromiseAtomValue(R)) {
113
+ const w = "v" in E ? E.v instanceof Promise ? E.v : Promise.resolve(E.v) : Promise.reject(E.e);
114
+ cancelPromise(R.v, w);
115
115
  }
116
- }, p = (m, E, C) => {
117
- const R = /* @__PURE__ */ new Map();
118
- let _ = !1;
119
- C.forEach((k, N) => {
120
- !k && N === m && (k = E), k ? (R.set(N, k), E.d.get(N) !== k && (_ = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
121
- }), (_ || E.d.size !== R.size) && (E.d = R);
122
- }, u = (m, E, C) => {
123
- const R = c(m), _ = {
124
- d: (R == null ? void 0 : R.d) || /* @__PURE__ */ new Map(),
116
+ }, p = (m, E, R) => {
117
+ const w = /* @__PURE__ */ new Map();
118
+ let T = !1;
119
+ R.forEach((k, N) => {
120
+ !k && N === m && (k = E), k ? (w.set(N, k), E.d.get(N) !== k && (T = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
121
+ }), (T || E.d.size !== w.size) && (E.d = w);
122
+ }, u = (m, E, R) => {
123
+ const w = c(m), T = {
124
+ d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
125
125
  v: E
126
126
  };
127
- if (C && p(m, _, C), R && isEqualAtomValue(R, _) && R.d === _.d)
128
- return R;
129
- if (R && hasPromiseAtomValue(R) && hasPromiseAtomValue(_) && isEqualPromiseAtomValue(R, _)) {
130
- if (R.d === _.d)
131
- return R;
132
- _.v = R.v;
127
+ if (R && p(m, T, R), w && isEqualAtomValue(w, T) && w.d === T.d)
128
+ return w;
129
+ if (w && hasPromiseAtomValue(w) && hasPromiseAtomValue(T) && isEqualPromiseAtomValue(w, T)) {
130
+ if (w.d === T.d)
131
+ return w;
132
+ T.v = w.v;
133
133
  }
134
- return d(m, _), _;
135
- }, x = (m, E, C, R) => {
134
+ return d(m, T), T;
135
+ }, x = (m, E, R, w) => {
136
136
  if (isPromiseLike$2(E)) {
137
- let _;
137
+ let T;
138
138
  const k = new Promise((N, $) => {
139
139
  let L = !1;
140
140
  E.then(
141
- (D) => {
141
+ (P) => {
142
142
  if (!L) {
143
143
  L = !0;
144
- const P = c(m), O = u(
144
+ const M = c(m), O = u(
145
145
  m,
146
146
  k,
147
- C
147
+ R
148
148
  );
149
- resolvePromise(k, D), N(D), (P == null ? void 0 : P.d) !== O.d && I(m, O, P == null ? void 0 : P.d);
149
+ resolvePromise(k, P), N(P), (M == null ? void 0 : M.d) !== O.d && _(m, O, M == null ? void 0 : M.d);
150
150
  }
151
151
  },
152
- (D) => {
152
+ (P) => {
153
153
  if (!L) {
154
154
  L = !0;
155
- const P = c(m), O = u(
155
+ const M = c(m), O = u(
156
156
  m,
157
157
  k,
158
- C
158
+ R
159
159
  );
160
- rejectPromise(k, D), $(D), (P == null ? void 0 : P.d) !== O.d && I(m, O, P == null ? void 0 : P.d);
160
+ rejectPromise(k, P), $(P), (M == null ? void 0 : M.d) !== O.d && _(m, O, M == null ? void 0 : M.d);
161
161
  }
162
162
  }
163
- ), _ = (D) => {
164
- L || (L = !0, D.then(
165
- (P) => resolvePromise(k, P),
166
- (P) => rejectPromise(k, P)
167
- ), N(D));
163
+ ), T = (P) => {
164
+ L || (L = !0, P.then(
165
+ (M) => resolvePromise(k, M),
166
+ (M) => rejectPromise(k, M)
167
+ ), N(P));
168
168
  };
169
169
  });
170
170
  return k.orig = E, k.status = "pending", registerCancelPromise(k, (N) => {
171
- N && _(N), R == null || R();
172
- }), u(m, k, C);
171
+ N && T(N), w == null || w();
172
+ }), u(m, k, R);
173
173
  }
174
- return u(m, E, C);
175
- }, f = (m, E, C) => {
176
- const R = c(m), _ = {
177
- d: (R == null ? void 0 : R.d) || /* @__PURE__ */ new Map(),
174
+ return u(m, E, R);
175
+ }, f = (m, E, R) => {
176
+ const w = c(m), T = {
177
+ d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
178
178
  e: E
179
179
  };
180
- return C && p(m, _, C), R && isEqualAtomError(R, _) && R.d === _.d ? R : (d(m, _), _);
180
+ return R && p(m, T, R), w && isEqualAtomError(w, T) && w.d === T.d ? w : (d(m, T), T);
181
181
  }, g = (m) => {
182
182
  const E = c(m);
183
- if (E && (E.d.forEach((L, D) => {
184
- D !== m && !r.has(D) && g(D);
185
- }), Array.from(E.d).every(([L, D]) => {
186
- const P = c(L);
187
- return L === m || P === D || // TODO This is a hack, we should find a better solution.
188
- P && !hasPromiseAtomValue(P) && isEqualAtomValue(P, D);
183
+ if (E && (E.d.forEach((L, P) => {
184
+ P !== m && !r.has(P) && g(P);
185
+ }), Array.from(E.d).every(([L, P]) => {
186
+ const M = c(L);
187
+ return L === m || M === P || // TODO This is a hack, we should find a better solution.
188
+ M && !hasPromiseAtomValue(M) && isEqualAtomValue(M, P);
189
189
  })))
190
190
  return E;
191
- const C = /* @__PURE__ */ new Map();
192
- let R = !0;
193
- const _ = (L) => {
191
+ const R = /* @__PURE__ */ new Map();
192
+ let w = !0;
193
+ const T = (L) => {
194
194
  if (L === m) {
195
- const P = c(L);
196
- if (P)
197
- return C.set(L, P), returnAtomValue(P);
195
+ const M = c(L);
196
+ if (M)
197
+ return R.set(L, M), returnAtomValue(M);
198
198
  if (hasInitialValue(L))
199
- return C.set(L, void 0), L.init;
199
+ return R.set(L, void 0), L.init;
200
200
  throw new Error("no atom init");
201
201
  }
202
- const D = g(L);
203
- return C.set(L, D), returnAtomValue(D);
202
+ const P = g(L);
203
+ return R.set(L, P), returnAtomValue(P);
204
204
  };
205
205
  let k, N;
206
206
  const $ = {
@@ -209,152 +209,152 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
209
209
  },
210
210
  get setSelf() {
211
211
  return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(m) && console.warn("setSelf function cannot be used with read-only atom"), !N && isActuallyWritableAtom(m) && (N = (...L) => {
212
- if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && R && console.warn("setSelf function cannot be called in sync"), !R)
213
- return w(m, ...L);
212
+ if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
213
+ return A(m, ...L);
214
214
  }), N;
215
215
  }
216
216
  };
217
217
  try {
218
- const L = m.read(_, $);
218
+ const L = m.read(T, $);
219
219
  return x(
220
220
  m,
221
221
  L,
222
- C,
222
+ R,
223
223
  () => k == null ? void 0 : k.abort()
224
224
  );
225
225
  } catch (L) {
226
- return f(m, L, C);
226
+ return f(m, L, R);
227
227
  } finally {
228
- R = !1;
228
+ w = !1;
229
229
  }
230
- }, y = (m) => returnAtomValue(g(m)), b = (m) => {
230
+ }, j = (m) => returnAtomValue(g(m)), b = (m) => {
231
231
  let E = r.get(m);
232
- return E || (E = S(m)), E;
233
- }, h = (m, E) => !E.l.size && (!E.t.size || E.t.size === 1 && E.t.has(m)), j = (m) => {
232
+ return E || (E = C(m)), E;
233
+ }, h = (m, E) => !E.l.size && (!E.t.size || E.t.size === 1 && E.t.has(m)), y = (m) => {
234
234
  const E = r.get(m);
235
- E && h(m, E) && B(m);
236
- }, v = (m) => {
237
- const E = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new WeakMap(), R = (k) => {
235
+ E && h(m, E) && v(m);
236
+ }, S = (m) => {
237
+ const E = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new WeakMap(), w = (k) => {
238
238
  const N = r.get(k);
239
239
  N == null || N.t.forEach(($) => {
240
240
  $ !== k && (E.set(
241
241
  $,
242
242
  (E.get($) || /* @__PURE__ */ new Set()).add(k)
243
- ), C.set($, (C.get($) || 0) + 1), R($));
243
+ ), R.set($, (R.get($) || 0) + 1), w($));
244
244
  });
245
245
  };
246
- R(m);
247
- const _ = (k) => {
246
+ w(m);
247
+ const T = (k) => {
248
248
  const N = r.get(k);
249
249
  N == null || N.t.forEach(($) => {
250
250
  var L;
251
251
  if ($ !== k) {
252
- let D = C.get($);
253
- if (D && C.set($, --D), !D) {
254
- let P = !!((L = E.get($)) != null && L.size);
255
- if (P) {
252
+ let P = R.get($);
253
+ if (P && R.set($, --P), !P) {
254
+ let M = !!((L = E.get($)) != null && L.size);
255
+ if (M) {
256
256
  const O = c($), V = g($);
257
- P = !O || !isEqualAtomValue(O, V);
257
+ M = !O || !isEqualAtomValue(O, V);
258
258
  }
259
- P || E.forEach((O) => O.delete($));
259
+ M || E.forEach((O) => O.delete($));
260
260
  }
261
- _($);
261
+ T($);
262
262
  }
263
263
  });
264
264
  };
265
- _(m);
266
- }, A = (m, ...E) => {
267
- let C = !0;
268
- const R = (N) => returnAtomValue(g(N)), _ = (N, ...$) => {
265
+ T(m);
266
+ }, B = (m, ...E) => {
267
+ let R = !0;
268
+ const w = (N) => returnAtomValue(g(N)), T = (N, ...$) => {
269
269
  let L;
270
270
  if (N === m) {
271
271
  if (!hasInitialValue(N))
272
272
  throw new Error("atom not writable");
273
- const D = c(N), P = x(N, $[0]);
274
- (!D || !isEqualAtomValue(D, P)) && v(N);
273
+ const P = c(N), M = x(N, $[0]);
274
+ (!P || !isEqualAtomValue(P, M)) && S(N);
275
275
  } else
276
- L = A(N, ...$);
277
- if (!C) {
278
- const D = T();
276
+ L = B(N, ...$);
277
+ if (!R) {
278
+ const P = I();
279
279
  (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
280
- (P) => P({ type: "async-write", flushed: D })
280
+ (M) => M({ type: "async-write", flushed: P })
281
281
  );
282
282
  }
283
283
  return L;
284
- }, k = m.write(R, _, ...E);
285
- return C = !1, k;
286
- }, w = (m, ...E) => {
287
- const C = A(m, ...E), R = T();
284
+ }, k = m.write(w, T, ...E);
285
+ return R = !1, k;
286
+ }, A = (m, ...E) => {
287
+ const R = B(m, ...E), w = I();
288
288
  return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
289
- (_) => _({ type: "write", flushed: R })
290
- ), C;
291
- }, S = (m, E) => {
292
- const C = {
289
+ (T) => T({ type: "write", flushed: w })
290
+ ), R;
291
+ }, C = (m, E) => {
292
+ const R = {
293
293
  t: new Set(E && [E]),
294
294
  l: /* @__PURE__ */ new Set()
295
295
  };
296
- if (r.set(m, C), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(m), g(m).d.forEach((R, _) => {
297
- const k = r.get(_);
298
- k ? k.t.add(m) : _ !== m && S(_, m);
296
+ if (r.set(m, R), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(m), g(m).d.forEach((w, T) => {
297
+ const k = r.get(T);
298
+ k ? k.t.add(m) : T !== m && C(T, m);
299
299
  }), g(m), isActuallyWritableAtom(m) && m.onMount) {
300
- const R = m.onMount((..._) => w(m, ..._));
301
- R && (C.u = R);
300
+ const w = m.onMount((...T) => A(m, ...T));
301
+ w && (R.u = w);
302
302
  }
303
- return C;
304
- }, B = (m) => {
303
+ return R;
304
+ }, v = (m) => {
305
305
  var E;
306
- const C = (E = r.get(m)) == null ? void 0 : E.u;
307
- C && C(), r.delete(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(m);
308
- const R = c(m);
309
- R ? (hasPromiseAtomValue(R) && cancelPromise(R.v), R.d.forEach((_, k) => {
306
+ const R = (E = r.get(m)) == null ? void 0 : E.u;
307
+ R && R(), r.delete(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(m);
308
+ const w = c(m);
309
+ w ? (hasPromiseAtomValue(w) && cancelPromise(w.v), w.d.forEach((T, k) => {
310
310
  if (k !== m) {
311
311
  const N = r.get(k);
312
- N && (N.t.delete(m), h(k, N) && B(k));
312
+ N && (N.t.delete(m), h(k, N) && v(k));
313
313
  }
314
314
  })) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount", m);
315
- }, I = (m, E, C) => {
316
- const R = new Set(E.d.keys());
317
- C == null || C.forEach((_, k) => {
318
- if (R.has(k)) {
319
- R.delete(k);
315
+ }, _ = (m, E, R) => {
316
+ const w = new Set(E.d.keys());
317
+ R == null || R.forEach((T, k) => {
318
+ if (w.has(k)) {
319
+ w.delete(k);
320
320
  return;
321
321
  }
322
322
  const N = r.get(k);
323
- N && (N.t.delete(m), h(k, N) && B(k));
324
- }), R.forEach((_) => {
325
- const k = r.get(_);
326
- k ? k.t.add(m) : r.has(m) && S(_, m);
323
+ N && (N.t.delete(m), h(k, N) && v(k));
324
+ }), w.forEach((T) => {
325
+ const k = r.get(T);
326
+ k ? k.t.add(m) : r.has(m) && C(T, m);
327
327
  });
328
- }, T = () => {
328
+ }, I = () => {
329
329
  let m;
330
330
  for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (m = /* @__PURE__ */ new Set()); n.size; ) {
331
331
  const E = Array.from(n);
332
- n.clear(), E.forEach(([C, R]) => {
333
- const _ = c(C);
334
- if (_) {
335
- _.d !== (R == null ? void 0 : R.d) && I(C, _, R == null ? void 0 : R.d);
336
- const k = r.get(C);
332
+ n.clear(), E.forEach(([R, w]) => {
333
+ const T = c(R);
334
+ if (T) {
335
+ T.d !== (w == null ? void 0 : w.d) && _(R, T, w == null ? void 0 : w.d);
336
+ const k = r.get(R);
337
337
  k && !// TODO This seems pretty hacky. Hope to fix it.
338
338
  // Maybe we could `mountDependencies` in `setAtomState`?
339
- (R && !hasPromiseAtomValue(R) && (isEqualAtomValue(R, _) || isEqualAtomError(R, _))) && (k.l.forEach((N) => N()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && m.add(C));
339
+ (w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w, T) || isEqualAtomError(w, T))) && (k.l.forEach((N) => N()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && m.add(R));
340
340
  } else
341
341
  (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] no atom state to flush");
342
342
  });
343
343
  }
344
344
  if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production")
345
345
  return a.forEach((E) => E("state")), m;
346
- }, M = (m, E) => {
347
- const C = b(m), R = T(), _ = C.l;
348
- return _.add(E), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("sub")), l.forEach(
349
- (k) => k({ type: "sub", flushed: R })
346
+ }, D = (m, E) => {
347
+ const R = b(m), w = I(), T = R.l;
348
+ return T.add(E), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("sub")), l.forEach(
349
+ (k) => k({ type: "sub", flushed: w })
350
350
  )), () => {
351
- _.delete(E), j(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("unsub")), l.forEach((k) => k({ type: "unsub" })));
351
+ T.delete(E), y(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("unsub")), l.forEach((k) => k({ type: "unsub" })));
352
352
  };
353
353
  };
354
354
  return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" ? {
355
- get: y,
356
- set: w,
357
- sub: M,
355
+ get: j,
356
+ set: A,
357
+ sub: D,
358
358
  // store dev methods (these are tentative and subject to change without notice)
359
359
  dev_subscribe_store: (m, E) => E !== 2 ? (console.warn(
360
360
  "The current StoreListener revision is 2. The older ones are deprecated."
@@ -367,17 +367,17 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
367
367
  dev_get_atom_state: (m) => o.get(m),
368
368
  dev_get_mounted: (m) => r.get(m),
369
369
  dev_restore_atoms: (m) => {
370
- for (const [C, R] of m)
371
- hasInitialValue(C) && (x(C, R), v(C));
372
- const E = T();
370
+ for (const [R, w] of m)
371
+ hasInitialValue(R) && (x(R, w), S(R));
372
+ const E = I();
373
373
  l.forEach(
374
- (C) => C({ type: "restore", flushed: E })
374
+ (R) => R({ type: "restore", flushed: E })
375
375
  );
376
376
  }
377
377
  } : {
378
- get: y,
379
- set: w,
380
- sub: M
378
+ get: j,
379
+ set: A,
380
+ sub: D
381
381
  };
382
382
  };
383
383
  let defaultStore;
@@ -395,36 +395,36 @@ function splitAtom(o, r) {
395
395
  if (p)
396
396
  return p;
397
397
  const u = d && n.get(d), x = [], f = [];
398
- return c.forEach((g, y) => {
399
- const b = r ? r(g) : y;
400
- f[y] = b;
398
+ return c.forEach((g, j) => {
399
+ const b = r ? r(g) : j;
400
+ f[j] = b;
401
401
  const h = u && u.atomList[u.keyList.indexOf(b)];
402
402
  if (h) {
403
- x[y] = h;
403
+ x[j] = h;
404
404
  return;
405
405
  }
406
- const j = (A) => {
407
- const w = A(l), S = A(o), I = a(S, w == null ? void 0 : w.arr).keyList.indexOf(b);
408
- if (I < 0 || I >= S.length) {
409
- const T = c[a(c).keyList.indexOf(b)];
410
- if (T)
411
- return T;
406
+ const y = (B) => {
407
+ const A = B(l), C = B(o), _ = a(C, A == null ? void 0 : A.arr).keyList.indexOf(b);
408
+ if (_ < 0 || _ >= C.length) {
409
+ const I = c[a(c).keyList.indexOf(b)];
410
+ if (I)
411
+ return I;
412
412
  throw new Error("splitAtom: index out of bounds for read");
413
413
  }
414
- return S[I];
415
- }, v = (A, w, S) => {
416
- const B = A(l), I = A(o), M = a(I, B == null ? void 0 : B.arr).keyList.indexOf(b);
417
- if (M < 0 || M >= I.length)
414
+ return C[_];
415
+ }, S = (B, A, C) => {
416
+ const v = B(l), _ = B(o), D = a(_, v == null ? void 0 : v.arr).keyList.indexOf(b);
417
+ if (D < 0 || D >= _.length)
418
418
  throw new Error("splitAtom: index out of bounds for write");
419
- const m = isFunction(S) ? S(I[M]) : S;
420
- w(o, [
421
- ...I.slice(0, M),
419
+ const m = isFunction(C) ? C(_[D]) : C;
420
+ A(o, [
421
+ ..._.slice(0, D),
422
422
  m,
423
- ...I.slice(M + 1)
423
+ ..._.slice(D + 1)
424
424
  ]);
425
425
  };
426
- x[y] = isWritable(o) ? atom(j, v) : atom(j);
427
- }), u && u.keyList.length === f.length && u.keyList.every((g, y) => g === f[y]) ? p = u : p = { arr: c, atomList: x, keyList: f }, n.set(c, p), p;
426
+ x[j] = isWritable(o) ? atom(y, S) : atom(y);
427
+ }), u && u.keyList.length === f.length && u.keyList.every((g, j) => g === f[j]) ? p = u : p = { arr: c, atomList: x, keyList: f }, n.set(c, p), p;
428
428
  }, l = atom((c) => {
429
429
  const d = c(l), p = c(o);
430
430
  return a(p, d == null ? void 0 : d.arr);
@@ -1134,50 +1134,50 @@ const useBlocksStoreManager = () => {
1134
1134
  updateBlocksProps: c
1135
1135
  } = useBlocksStoreManager();
1136
1136
  return {
1137
- moveBlocks: (b, h, j) => {
1138
- const v = map(b, (w) => {
1139
- const B = r.find((M) => M._id === w)._parent || null, T = r.filter((M) => B ? M._parent === B : !M._parent).map((M) => M._id).indexOf(w);
1140
- return { _id: w, oldParent: B, oldPosition: T };
1141
- }), A = v.find(({ _id: w }) => w === b[0]);
1142
- A && A.oldParent === h && A.oldPosition === j || (i(b, h, j), o({
1143
- undo: () => each(v, ({ _id: w, oldParent: S, oldPosition: B }) => {
1144
- i([w], S, B);
1137
+ moveBlocks: (b, h, y) => {
1138
+ const S = map(b, (A) => {
1139
+ const v = r.find((D) => D._id === A)._parent || null, I = r.filter((D) => v ? D._parent === v : !D._parent).map((D) => D._id).indexOf(A);
1140
+ return { _id: A, oldParent: v, oldPosition: I };
1141
+ }), B = S.find(({ _id: A }) => A === b[0]);
1142
+ B && B.oldParent === h && B.oldPosition === y || (i(b, h, y), o({
1143
+ undo: () => each(S, ({ _id: A, oldParent: C, oldPosition: v }) => {
1144
+ i([A], C, v);
1145
1145
  }),
1146
- redo: () => i(b, h, j)
1146
+ redo: () => i(b, h, y)
1147
1147
  }));
1148
1148
  },
1149
- addBlocks: (b, h, j) => {
1150
- a(b, h, j), o({
1149
+ addBlocks: (b, h, y) => {
1150
+ a(b, h, y), o({
1151
1151
  undo: () => l(map(b, "_id")),
1152
- redo: () => a(b, h, j)
1152
+ redo: () => a(b, h, y)
1153
1153
  });
1154
1154
  },
1155
1155
  removeBlocks: (b) => {
1156
- var A;
1157
- const h = (A = first(b)) == null ? void 0 : A._parent, v = r.filter((w) => h ? w._parent === h : !w._parent).indexOf(first(b));
1156
+ var B;
1157
+ const h = (B = first(b)) == null ? void 0 : B._parent, S = r.filter((A) => h ? A._parent === h : !A._parent).indexOf(first(b));
1158
1158
  l(map(b, "_id")), o({
1159
- undo: () => a(b, h, v),
1159
+ undo: () => a(b, h, S),
1160
1160
  redo: () => l(map(b, "_id"))
1161
1161
  });
1162
1162
  },
1163
- updateBlocks: (b, h, j) => {
1164
- let v = [];
1165
- if (j)
1166
- v = map(b, (A) => ({ _id: A, ...j }));
1163
+ updateBlocks: (b, h, y) => {
1164
+ let S = [];
1165
+ if (y)
1166
+ S = map(b, (B) => ({ _id: B, ...y }));
1167
1167
  else {
1168
- const A = keys(h);
1169
- v = map(b, (w) => {
1170
- const S = r.find((I) => I._id === w), B = { _id: w };
1171
- return each(A, (I) => B[I] = S[I]), B;
1168
+ const B = keys(h);
1169
+ S = map(b, (A) => {
1170
+ const C = r.find((_) => _._id === A), v = { _id: A };
1171
+ return each(B, (_) => v[_] = C[_]), v;
1172
1172
  });
1173
1173
  }
1174
- c(map(b, (A) => ({ _id: A, ...h }))), o({
1175
- undo: () => c(v),
1176
- redo: () => c(map(b, (A) => ({ _id: A, ...h })))
1174
+ c(map(b, (B) => ({ _id: B, ...h }))), o({
1175
+ undo: () => c(S),
1176
+ redo: () => c(map(b, (B) => ({ _id: B, ...h })))
1177
1177
  });
1178
1178
  },
1179
1179
  updateBlocksRuntime: (b, h) => {
1180
- c(map(b, (j) => ({ _id: j, ...h })));
1180
+ c(map(b, (y) => ({ _id: y, ...h })));
1181
1181
  },
1182
1182
  setNewBlocks: (b) => {
1183
1183
  n(b), o({
@@ -1187,9 +1187,9 @@ const useBlocksStoreManager = () => {
1187
1187
  },
1188
1188
  updateMultipleBlocksProps: (b) => {
1189
1189
  let h = [];
1190
- h = map(b, (j) => {
1191
- const v = keys(j), A = r.find((S) => S._id === j._id), w = {};
1192
- return each(v, (S) => w[S] = A[S]), w;
1190
+ h = map(b, (y) => {
1191
+ const S = keys(y), B = r.find((C) => C._id === y._id), A = {};
1192
+ return each(S, (C) => A[C] = B[C]), A;
1193
1193
  }), c(b), o({
1194
1194
  undo: () => c(h),
1195
1195
  redo: () => c(b)
@@ -1200,12 +1200,12 @@ const useBlocksStoreManager = () => {
1200
1200
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
1201
1201
  (i, c, d) => {
1202
1202
  var g;
1203
- for (let y = 0; y < i.length; y++) {
1204
- const { _id: b } = i[y];
1205
- i[y]._id = generateUUID();
1203
+ for (let j = 0; j < i.length; j++) {
1204
+ const { _id: b } = i[j];
1205
+ i[j]._id = generateUUID();
1206
1206
  const h = filter(i, { _parent: b });
1207
- for (let j = 0; j < h.length; j++)
1208
- h[j]._parent = i[y]._id;
1207
+ for (let y = 0; y < h.length; y++)
1208
+ h[y]._parent = i[j]._id;
1209
1209
  }
1210
1210
  const p = first(i);
1211
1211
  let u, x;
@@ -2375,7 +2375,7 @@ function getNewClasses(o = "", r = "", n = []) {
2375
2375
  const g = find(l, pick(x, ["property"]));
2376
2376
  f && (l = filter(
2377
2377
  l,
2378
- (y) => y.fullCls !== (g == null ? void 0 : g.fullCls)
2378
+ (j) => j.fullCls !== (g == null ? void 0 : g.fullCls)
2379
2379
  )), c.push({
2380
2380
  ...x,
2381
2381
  fullCls: x.cls,
@@ -2564,8 +2564,8 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2564
2564
  const d = o(c), p = a;
2565
2565
  let { classes: u, baseClasses: x } = getSplitClasses(get(d, l.prop, "styles:,"));
2566
2566
  return each(p, (f) => {
2567
- const g = f.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), y = new RegExp(`(^| )${g}($| )`, "g");
2568
- u = u.replace(y, " ").replace(/ +/g, " ").trim();
2567
+ const g = f.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), j = new RegExp(`(^| )${g}($| )`, "g");
2568
+ u = u.replace(j, " ").replace(/ +/g, " ").trim();
2569
2569
  const b = first(f.split(":"));
2570
2570
  includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(f.split(":").pop().trim());
2571
2571
  }), each(p, (f) => {
@@ -3021,37 +3021,37 @@ const getBlockWithChildren = (o, r) => {
3021
3021
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
3022
3022
  })
3023
3023
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
3024
- const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, f = (g, y) => {
3025
- const b = cloneDeep(y.find((h) => h._id === g));
3024
+ const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, f = (g, j) => {
3025
+ const b = cloneDeep(j.find((h) => h._id === g));
3026
3026
  for (const h in b) {
3027
- const j = b[h];
3028
- typeof j == "string" && startsWith(j, STYLES_KEY) ? b[h] = compact(flattenDeep(j.replace(STYLES_KEY, "").split(","))).join(" ") : h !== "_id" && delete b[h];
3027
+ const y = b[h];
3028
+ typeof y == "string" && startsWith(y, STYLES_KEY) ? b[h] = compact(flattenDeep(y.replace(STYLES_KEY, "").split(","))).join(" ") : h !== "_id" && delete b[h];
3029
3029
  }
3030
3030
  return b;
3031
3031
  };
3032
3032
  return {
3033
3033
  askAi: useCallback(
3034
- async (g, y, b, h) => {
3034
+ async (g, j, b, h) => {
3035
3035
  if (l) {
3036
3036
  r(!0), a(null);
3037
3037
  try {
3038
- const j = p === u ? "" : p, v = g === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(y, d)), p) : [f(y, d)], A = await l(g, addLangToPrompt(b, x, g), v, j), { blocks: w, error: S } = A;
3039
- if (S) {
3040
- a(S);
3038
+ const y = p === u ? "" : p, S = g === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(j, d)), p) : [f(j, d)], B = await l(g, addLangToPrompt(b, x, g), S, y), { blocks: A, error: C } = B;
3039
+ if (C) {
3040
+ a(C);
3041
3041
  return;
3042
3042
  }
3043
3043
  if (g === "styles") {
3044
- const B = w.map((I) => {
3045
- for (const T in I)
3046
- T !== "_id" && (I[T] = `${STYLES_KEY},${I[T]}`);
3047
- return I;
3044
+ const v = A.map((_) => {
3045
+ for (const I in _)
3046
+ I !== "_id" && (_[I] = `${STYLES_KEY},${_[I]}`);
3047
+ return _;
3048
3048
  });
3049
- c(B);
3049
+ c(v);
3050
3050
  } else
3051
- i(w);
3052
- h && h(A);
3053
- } catch (j) {
3054
- a(j);
3051
+ i(A);
3052
+ h && h(B);
3053
+ } catch (y) {
3054
+ a(y);
3055
3055
  } finally {
3056
3056
  r(!1), h && h();
3057
3057
  }
@@ -3079,7 +3079,27 @@ const getBlockWithChildren = (o, r) => {
3079
3079
  },
3080
3080
  [o]
3081
3081
  );
3082
- }, layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3082
+ }, wrapperBlockAtom = atom$1((o) => {
3083
+ var c;
3084
+ const r = o(presentBlocksAtom), n = o(selectedBlockIdsAtom), a = n.length === 1 ? n[0] : null;
3085
+ if (!a)
3086
+ return null;
3087
+ const l = find(r, { _id: a });
3088
+ if (!l)
3089
+ return null;
3090
+ let i = l._parent;
3091
+ for (; i; ) {
3092
+ const d = find(r, { _id: i });
3093
+ if (!d)
3094
+ return null;
3095
+ if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
3096
+ return d;
3097
+ i = d._parent;
3098
+ }
3099
+ return null;
3100
+ });
3101
+ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
3102
+ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3083
3103
  const [o, r] = useAtom$1(layoutVariantAtom), n = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
3084
3104
  return [o || n, r];
3085
3105
  }, IframeInitialContent = `<!doctype html>
@@ -3336,26 +3356,26 @@ const useDnd = () => {
3336
3356
  g.preventDefault(), g.stopPropagation(), throttledDragOver(g);
3337
3357
  },
3338
3358
  onDrop: (g) => {
3339
- var S;
3340
- const y = dropTarget, h = getOrientation(y) === "vertical" ? g.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : g.clientX;
3359
+ var C;
3360
+ const j = dropTarget, h = getOrientation(j) === "vertical" ? g.clientY + ((C = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : C.scrollY) : g.clientX;
3341
3361
  dropIndex = calculateDropIndex(h, possiblePositions);
3342
- const j = d, v = y.getAttribute("data-block-id"), A = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3343
- if ((j == null ? void 0 : j._id) === v || !A) {
3362
+ const y = d, S = j.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3363
+ if ((y == null ? void 0 : y._id) === S || !B) {
3344
3364
  f();
3345
3365
  return;
3346
3366
  }
3347
- if (!has(j, "_id")) {
3348
- a(j, v === "canvas" ? null : v, dropIndex), setTimeout(f, 300);
3367
+ if (!has(y, "_id")) {
3368
+ a(y, S === "canvas" ? null : S, dropIndex), setTimeout(f, 300);
3349
3369
  return;
3350
3370
  }
3351
- let w = y.getAttribute("data-block-id");
3352
- w === null && (w = g.target.parentElement.getAttribute("data-block-id")), c([j._id], w === "canvas" ? null : w, dropIndex), f(), setTimeout(removePlaceholder, 300);
3371
+ let A = j.getAttribute("data-block-id");
3372
+ A === null && (A = g.target.parentElement.getAttribute("data-block-id")), c([y._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
3353
3373
  },
3354
3374
  onDragEnter: (g) => {
3355
- const y = g, b = y.target;
3375
+ const j = g, b = j.target;
3356
3376
  dropTarget = b;
3357
- const h = b.getAttribute("data-block-id"), j = b.getAttribute("data-dnd-dragged") !== "yes";
3358
- u(h), y.stopPropagation(), y.preventDefault(), possiblePositions = [], j && calculatePossiblePositions(b), n(!0), l(""), i([]);
3377
+ const h = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
3378
+ u(h), j.stopPropagation(), j.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), n(!0), l(""), i([]);
3359
3379
  },
3360
3380
  onDragLeave: (g) => {
3361
3381
  g.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
@@ -3440,8 +3460,8 @@ const useHandleCanvasDblClick = () => {
3440
3460
  if (f) {
3441
3461
  const g = f.getAttribute("data-style-prop");
3442
3462
  if (g) {
3443
- const y = f.getAttribute("data-style-id"), b = f.getAttribute("data-block-parent");
3444
- l([{ id: y, prop: g, blockId: b }]);
3463
+ const j = f.getAttribute("data-style-id"), b = f.getAttribute("data-block-parent");
3464
+ l([{ id: j, prop: g, blockId: b }]);
3445
3465
  }
3446
3466
  }
3447
3467
  }, 100);
@@ -3477,8 +3497,8 @@ const useHandleCanvasDblClick = () => {
3477
3497
  i
3478
3498
  ]), useHotkeys(
3479
3499
  "del, backspace",
3480
- (y) => {
3481
- y.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3500
+ (j) => {
3501
+ j.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3482
3502
  },
3483
3503
  g,
3484
3504
  [r, l]
@@ -3541,13 +3561,13 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3541
3561
  tabIndex: 0,
3542
3562
  ref: u.setFloating,
3543
3563
  style: p,
3544
- onClick: (y) => {
3545
- y.stopPropagation(), y.preventDefault();
3564
+ onClick: (j) => {
3565
+ j.stopPropagation(), j.preventDefault();
3546
3566
  },
3547
- onMouseEnter: (y) => {
3548
- y.stopPropagation(), i(null);
3567
+ onMouseEnter: (j) => {
3568
+ j.stopPropagation(), i(null);
3549
3569
  },
3550
- onKeyDown: (y) => y.stopPropagation(),
3570
+ onKeyDown: (j) => j.stopPropagation(),
3551
3571
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3552
3572
  children: [
3553
3573
  f && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3603,15 +3623,15 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3603
3623
  typography,
3604
3624
  forms,
3605
3625
  aspectRatio,
3606
- plugin(function({ addBase: h, theme: j }) {
3626
+ plugin(function({ addBase: h, theme: y }) {
3607
3627
  h({
3608
3628
  "h1,h2,h3,h4,h5,h6": {
3609
- fontFamily: j("fontFamily.heading")
3629
+ fontFamily: y("fontFamily.heading")
3610
3630
  },
3611
3631
  body: {
3612
- fontFamily: j("fontFamily.body"),
3613
- color: j("colors.foreground"),
3614
- backgroundColor: j("colors.background")
3632
+ fontFamily: y("fontFamily.body"),
3633
+ color: y("colors.foreground"),
3634
+ backgroundColor: y("colors.background")
3615
3635
  }
3616
3636
  });
3617
3637
  })
@@ -3632,12 +3652,12 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3632
3652
  }, [l, f]), useEffect(() => {
3633
3653
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3634
3654
  }, [c, d]);
3635
- const y = useMemo(
3655
+ const j = useMemo(
3636
3656
  () => getChaiThemeCssVariables(o),
3637
3657
  [o]
3638
3658
  ), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3639
3659
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3640
- /* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: y }),
3660
+ /* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: j }),
3641
3661
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
3642
3662
  ] });
3643
3663
  }, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, r) => {
@@ -3720,29 +3740,29 @@ function applyLanguage(o, r, n) {
3720
3740
  }), a;
3721
3741
  }
3722
3742
  function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
3723
- const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), f = useCallback((h) => getStyleAttrs(h, d), [d]), [g] = useChaiExternalData(), [y] = useAtom$1(inlineEditingActiveAtom), b = useCallback(
3724
- (h) => h.reduce((j, v) => {
3725
- const A = get(p, v, {});
3726
- return { ...j, ...A };
3743
+ const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), f = useCallback((h) => getStyleAttrs(h, d), [d]), [g] = useChaiExternalData(), [j] = useAtom$1(inlineEditingActiveAtom), b = useCallback(
3744
+ (h) => h.reduce((y, S) => {
3745
+ const B = get(p, S, {});
3746
+ return { ...y, ...B };
3727
3747
  }, {}),
3728
3748
  [p]
3729
3749
  );
3730
3750
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
3731
- o.map((h, j) => {
3732
- if (y === h._id || u.includes(h._id))
3751
+ o.map((h, y) => {
3752
+ if (j === h._id || u.includes(h._id))
3733
3753
  return null;
3734
- const v = {}, A = filter(r, { _parent: h._id });
3735
- if (v.children = A.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: A }) : null, h._type === "GlobalBlock") {
3736
- const R = x(h);
3737
- v.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(R, (_) => !_._parent), allBlocks: R });
3754
+ const S = {}, B = filter(r, { _parent: h._id });
3755
+ if (S.children = B.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: B }) : null, h._type === "GlobalBlock") {
3756
+ const w = x(h);
3757
+ S.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(w, (T) => !T._parent), allBlocks: w });
3738
3758
  }
3739
- const w = getRegisteredChaiBlock(h._type), S = get(w, "component", null);
3740
- if (isNull(S))
3759
+ const A = getRegisteredChaiBlock(h._type), C = get(A, "component", null);
3760
+ if (isNull(C))
3741
3761
  return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${h == null ? void 0 : h._type} not registered -->` });
3742
- const B = has(w, "getBlockStateFrom") ? w == null ? void 0 : w.getBlockStateFrom(h, r) : [], I = b(B), T = f(h);
3743
- if (get(T, "__isHidden", !1) && !includes(a, h._id))
3762
+ const v = has(A, "getBlockStateFrom") ? A == null ? void 0 : A.getBlockStateFrom(h, r) : [], _ = b(v), I = f(h);
3763
+ if (get(I, "__isHidden", !1) && !includes(a, h._id))
3744
3764
  return null;
3745
- const M = i && isDescendant(i._id, h._id, r), E = {
3765
+ const D = i && isDescendant(i._id, h._id, r), E = {
3746
3766
  blockProps: {
3747
3767
  ...includes(a, h._id) ? { "force-show": "" } : {},
3748
3768
  "data-block-id": h._id,
@@ -3751,31 +3771,31 @@ function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
3751
3771
  // @ts-ignore
3752
3772
  {
3753
3773
  "data-dnd": canAcceptChildBlock(h._type, i == null ? void 0 : i._type) ? "yes" : "no",
3754
- "data-dnd-dragged": i._id === h._id || M ? "yes" : "no"
3774
+ "data-dnd-dragged": i._id === h._id || D ? "yes" : "no"
3755
3775
  }
3756
3776
  ) : {},
3757
- ...c === h._id && !M ? { "data-drop": "yes" } : {},
3777
+ ...c === h._id && !D ? { "data-drop": "yes" } : {},
3758
3778
  ...includes(l, h._id) ? { "data-cut-block": "yes" } : {}
3759
3779
  },
3760
- index: j,
3761
- ...applyBindings(applyLanguage(h, n, w), g),
3762
- ...omit(T, ["__isHidden"]),
3763
- ...v,
3780
+ index: y,
3781
+ ...applyBindings(applyLanguage(h, n, A), g),
3782
+ ...omit(I, ["__isHidden"]),
3783
+ ...S,
3764
3784
  inBuilder: !0,
3765
- blockState: I
3785
+ blockState: _
3766
3786
  };
3767
- if (has(w, "dataProvider"))
3787
+ if (has(A, "dataProvider"))
3768
3788
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3769
3789
  AsyncPropsBlock,
3770
3790
  {
3771
- dataProvider: w.dataProvider,
3791
+ dataProvider: A.dataProvider,
3772
3792
  block: h,
3773
- component: S,
3793
+ component: C,
3774
3794
  props: E
3775
3795
  }
3776
3796
  ) });
3777
- const C = getRuntimeProps(h._type);
3778
- return C ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: C, block: h, component: S, props: E }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(S, E) });
3797
+ const R = getRuntimeProps(h._type);
3798
+ return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: R, block: h, component: C, props: E }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(C, E) });
3779
3799
  })
3780
3800
  ) });
3781
3801
  }
@@ -3830,43 +3850,43 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3830
3850
  };
3831
3851
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
3832
3852
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3833
- const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, f] = useState([]), [, g] = useState([]), [, y] = useAtom$1(canvasIframeAtom), [b, h] = useSelectedStylingBlocks(), j = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), A = (B) => {
3834
- p((I) => ({ ...I, width: B }));
3853
+ const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, f] = useState([]), [, g] = useState([]), [, j] = useAtom$1(canvasIframeAtom), [b, h] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), S = useBuilderProp("htmlDir", "ltr"), B = (v) => {
3854
+ p((_) => ({ ..._, width: v }));
3835
3855
  };
3836
3856
  useEffect(() => {
3837
3857
  if (!c.current)
3838
3858
  return;
3839
- const { clientWidth: B, clientHeight: I } = c.current;
3840
- p({ width: B, height: I });
3859
+ const { clientWidth: v, clientHeight: _ } = c.current;
3860
+ p({ width: v, height: _ });
3841
3861
  }, [c, r]);
3842
- const w = (B, I = 0) => {
3843
- const { top: T } = B.getBoundingClientRect();
3844
- return T + I >= 0 && T - I <= window.innerHeight;
3862
+ const A = (v, _ = 0) => {
3863
+ const { top: I } = v.getBoundingClientRect();
3864
+ return I + _ >= 0 && I - _ <= window.innerHeight;
3845
3865
  };
3846
3866
  useEffect(() => {
3847
- var B, I;
3867
+ var v, _;
3848
3868
  if (a && a.type !== "Multiple" && i.current) {
3849
- const T = getElementByDataBlockId(i.current.contentDocument, a._id);
3850
- T && (w(T) || (I = (B = i.current) == null ? void 0 : B.contentWindow) == null || I.scrollTo({ top: T.offsetTop, behavior: "smooth" }), f([T]));
3869
+ const I = getElementByDataBlockId(i.current.contentDocument, a._id);
3870
+ I && (A(I) || (_ = (v = i.current) == null ? void 0 : v.contentWindow) == null || _.scrollTo({ top: I.offsetTop, behavior: "smooth" }), f([I]));
3851
3871
  }
3852
3872
  }, [a]), useEffect(() => {
3853
3873
  if (!isEmpty(b) && i.current) {
3854
- const B = getElementByStyleId(
3874
+ const v = getElementByStyleId(
3855
3875
  i.current.contentDocument,
3856
3876
  first(b).id
3857
3877
  );
3858
- g(B ? [B] : [null]);
3878
+ g(v ? [v] : [null]);
3859
3879
  } else
3860
3880
  g([null]);
3861
3881
  }, [b]);
3862
- const S = useMemo(() => {
3863
- let B = IframeInitialContent;
3864
- return B = B.replace("__HTML_DIR__", v), o === "offline" && (B = B.replace(
3882
+ const C = useMemo(() => {
3883
+ let v = IframeInitialContent;
3884
+ return v = v.replace("__HTML_DIR__", S), o === "offline" && (v = v.replace(
3865
3885
  "https://old.chaibuilder.com/offline/tailwind.cdn.js",
3866
3886
  "/offline/tailwind.cdn.js"
3867
- ), B = B.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), B = B.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), B;
3868
- }, [o, v]);
3869
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: A, onResize: A, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3887
+ ), v = v.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), v = v.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), v;
3888
+ }, [o, S]);
3889
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3870
3890
  "div",
3871
3891
  {
3872
3892
  onClick: () => {
@@ -3878,12 +3898,12 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3878
3898
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3879
3899
  ChaiFrame,
3880
3900
  {
3881
- contentDidMount: () => y(i.current),
3901
+ contentDidMount: () => j(i.current),
3882
3902
  ref: i,
3883
3903
  id: "canvas-iframe",
3884
3904
  style: { ...u, ...isEmpty(u) ? { width: `${r}px` } : {} },
3885
3905
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
3886
- initialContent: S,
3906
+ initialContent: C,
3887
3907
  children: [
3888
3908
  /* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
3889
3909
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3895,7 +3915,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3895
3915
  ),
3896
3916
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeadTags, {}),
3897
3917
  /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Canvas, { children: [
3898
- j ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
3918
+ y ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
3899
3919
  /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlockAtBottom, {}),
3900
3920
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
3901
3921
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
@@ -4125,19 +4145,19 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4125
4145
  const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (h) => {
4126
4146
  a(h);
4127
4147
  }, x = () => {
4128
- const h = l.find((j) => Object.keys(j)[0] === n);
4148
+ const h = l.find((y) => Object.keys(y)[0] === n);
4129
4149
  if (h) {
4130
- const j = Object.values(h)[0];
4131
- j && typeof j == "object" && "fontFamily" in j && "borderRadius" in j && "colors" in j ? c(j) : console.error("Invalid preset structure:", j);
4150
+ const y = Object.values(h)[0];
4151
+ y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? c(y) : console.error("Invalid preset structure:", y);
4132
4152
  } else
4133
4153
  console.error("Preset not found:", n);
4134
4154
  }, f = useDebouncedCallback(
4135
- (h, j) => {
4155
+ (h, y) => {
4136
4156
  c(() => ({
4137
4157
  ...i,
4138
4158
  fontFamily: {
4139
4159
  ...i.fontFamily,
4140
- [h.replace(/font-/g, "")]: j
4160
+ [h.replace(/font-/g, "")]: y
4141
4161
  }
4142
4162
  }));
4143
4163
  },
@@ -4152,33 +4172,33 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4152
4172
  },
4153
4173
  [i],
4154
4174
  200
4155
- ), y = useDebouncedCallback(
4156
- (h, j) => {
4175
+ ), j = useDebouncedCallback(
4176
+ (h, y) => {
4157
4177
  c(() => {
4158
- const v = get(i, `colors.${h}`);
4159
- return r ? set(v, 1, j) : set(v, 0, j), {
4178
+ const S = get(i, `colors.${h}`);
4179
+ return r ? set(S, 1, y) : set(S, 0, y), {
4160
4180
  ...i,
4161
4181
  colors: {
4162
4182
  ...i.colors,
4163
- [h]: v
4183
+ [h]: S
4164
4184
  }
4165
4185
  };
4166
4186
  });
4167
4187
  },
4168
4188
  [i],
4169
4189
  200
4170
- ), b = (h) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(h.items).map(([j]) => {
4171
- const v = get(i, `colors.${j}.${r ? 1 : 0}`);
4190
+ ), b = (h) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(h.items).map(([y]) => {
4191
+ const S = get(i, `colors.${y}.${r ? 1 : 0}`);
4172
4192
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4173
4193
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4174
4194
  ColorPickerInput$1,
4175
4195
  {
4176
- value: v,
4177
- onChange: (A) => y(j, A)
4196
+ value: S,
4197
+ onChange: (B) => j(y, B)
4178
4198
  }
4179
4199
  ),
4180
- /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: j.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((A) => A.charAt(0).toUpperCase() + A.slice(1)).join(" ") + (!j.toLowerCase().includes("foreground") && !j.toLowerCase().includes("border") && !j.toLowerCase().includes("input") && !j.toLowerCase().includes("ring") && !j.toLowerCase().includes("background") ? " Background" : "") })
4181
- ] }, j);
4200
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
4201
+ ] }, y);
4182
4202
  }) });
4183
4203
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4184
4204
  l.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 py-2", children: [
@@ -4200,12 +4220,12 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4200
4220
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "w-full text-sm", disabled: n === "", variant: "default", onClick: x, children: p("Apply") }) })
4201
4221
  ] }),
4202
4222
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("space-y-2", o), children: [
4203
- (d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([h, j]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4223
+ (d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([h, y]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4204
4224
  FontSelector$1,
4205
4225
  {
4206
4226
  label: h,
4207
- value: i.fontFamily[h.replace(/font-/g, "")] || j[Object.keys(j)[0]],
4208
- onChange: (v) => f(h, v)
4227
+ value: i.fontFamily[h.replace(/font-/g, "")] || y[Object.keys(y)[0]],
4228
+ onChange: (S) => f(h, S)
4209
4229
  },
4210
4230
  h
4211
4231
  )) }),
@@ -4415,40 +4435,40 @@ function BiExpandVertical(o) {
4415
4435
  const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, dragHandle: n }) => {
4416
4436
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
4417
4437
  let p = null;
4418
- const u = o.children.length > 0, { highlightBlock: x, clearHighlight: f } = useBlockHighlight(), { id: g, data: y, isSelected: b, willReceiveDrop: h, isDragging: j, isEditing: v, handleClick: A } = o, w = (k) => {
4438
+ const u = o.children.length > 0, { highlightBlock: x, clearHighlight: f } = useBlockHighlight(), { id: g, data: j, isSelected: b, willReceiveDrop: h, isDragging: y, isEditing: S, handleClick: B } = o, A = (k) => {
4419
4439
  k.stopPropagation(), !i.includes(g) && o.toggle();
4420
- }, S = (k) => {
4440
+ }, C = (k) => {
4421
4441
  k.isInternal && (p = k.isOpen, k.isOpen && k.close());
4422
- }, B = (k) => {
4442
+ }, v = (k) => {
4423
4443
  k.isInternal && p !== null && (p ? k.open() : k.close(), p = null);
4424
- }, [I, T] = useAtom$1(currentAddSelection), M = () => {
4444
+ }, [_, I] = useAtom$1(currentAddSelection), D = () => {
4425
4445
  var N, $;
4426
- m(), document.getElementById(`tree-node-${(N = o == null ? void 0 : o.parent) == null ? void 0 : N.id}`) && !o.parent.isSelected && T(($ = o == null ? void 0 : o.parent) == null ? void 0 : $.id);
4446
+ m(), document.getElementById(`tree-node-${(N = o == null ? void 0 : o.parent) == null ? void 0 : N.id}`) && !o.parent.isSelected && I(($ = o == null ? void 0 : o.parent) == null ? void 0 : $.id);
4427
4447
  }, m = () => {
4428
- T(null);
4448
+ I(null);
4429
4449
  }, E = (k) => {
4430
- m(), k.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(), A(k);
4450
+ m(), k.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(), B(k);
4431
4451
  };
4432
4452
  useEffect(() => {
4433
4453
  const k = setTimeout(() => {
4434
- h && !o.isOpen && !j && !i.includes(g) && o.toggle();
4454
+ h && !o.isOpen && !y && !i.includes(g) && o.toggle();
4435
4455
  }, 500);
4436
4456
  return () => clearTimeout(k);
4437
- }, [h, o, j]);
4438
- const C = useMemo(() => {
4439
- const k = Object.keys(y), N = [];
4457
+ }, [h, o, y]);
4458
+ const R = useMemo(() => {
4459
+ const k = Object.keys(j), N = [];
4440
4460
  for (let $ = 0; $ < k.length; $++)
4441
4461
  if (k[$].endsWith("_attrs")) {
4442
- const L = y[k[$]], D = Object.keys(L).join("|");
4443
- D.match(/x-data/) && N.push("data"), D.match(/x-on/) && N.push("event"), D.match(/x-show|x-if/) && N.push("show");
4462
+ const L = j[k[$]], P = Object.keys(L).join("|");
4463
+ P.match(/x-data/) && N.push("data"), P.match(/x-on/) && N.push("event"), P.match(/x-show|x-if/) && N.push("show");
4444
4464
  }
4445
4465
  return N;
4446
- }, [y]), R = (k, N) => {
4466
+ }, [j]), w = (k, N) => {
4447
4467
  const $ = d.contentDocument || d.contentWindow.document, L = $.querySelector(`[data-block-id=${k}]`);
4448
4468
  L && L.setAttribute("data-drop", N);
4449
- const D = L.getBoundingClientRect(), P = d.getBoundingClientRect();
4450
- D.top >= P.top && D.left >= P.left && D.bottom <= P.bottom && D.right <= P.right || ($.documentElement.scrollTop = L.offsetTop - P.top);
4451
- }, _ = (k) => {
4469
+ const P = L.getBoundingClientRect(), M = d.getBoundingClientRect();
4470
+ P.top >= M.top && P.left >= M.left && P.bottom <= M.bottom && P.right <= M.right || ($.documentElement.scrollTop = L.offsetTop - M.top);
4471
+ }, T = (k) => {
4452
4472
  m();
4453
4473
  const N = get(o, "parent.id");
4454
4474
  N !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: N, position: k }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK);
@@ -4458,7 +4478,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4458
4478
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4459
4479
  "div",
4460
4480
  {
4461
- onClick: () => _(-1),
4481
+ onClick: () => T(-1),
4462
4482
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4463
4483
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
4464
4484
  /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -4477,23 +4497,23 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4477
4497
  style: r,
4478
4498
  "data-node-id": g,
4479
4499
  ref: i.includes(g) ? null : n,
4480
- onDragStart: () => S(o),
4481
- onDragEnd: () => B(o),
4500
+ onDragStart: () => C(o),
4501
+ onDragEnd: () => v(o),
4482
4502
  onDragOver: (k) => {
4483
- k.preventDefault(), R(g, "yes");
4503
+ k.preventDefault(), w(g, "yes");
4484
4504
  },
4485
4505
  onDragLeave: (k) => {
4486
- k.preventDefault(), R(g, "no");
4506
+ k.preventDefault(), w(g, "no");
4487
4507
  },
4488
4508
  onDrop: (k) => {
4489
- k.preventDefault(), R(g, "no");
4509
+ k.preventDefault(), w(g, "no");
4490
4510
  },
4491
4511
  children: [
4492
4512
  (o == null ? void 0 : o.rowIndex) > 0 && o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4493
4513
  "div",
4494
4514
  {
4495
- onClick: () => _(o.childIndex),
4496
- onMouseEnter: M,
4515
+ onClick: () => T(o.childIndex),
4516
+ onMouseEnter: D,
4497
4517
  onMouseLeave: m,
4498
4518
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
4499
4519
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-5 w-5 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-4 w-4 stroke-[3] text-white" }) })
@@ -4506,9 +4526,9 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4506
4526
  className: cn(
4507
4527
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
4508
4528
  b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
4509
- h && canAcceptChildBlock(y._type, "Icon") ? "bg-green-200" : "",
4510
- (o == null ? void 0 : o.id) === I ? "bg-purple-50" : "",
4511
- j && "opacity-20",
4529
+ h && canAcceptChildBlock(j._type, "Icon") ? "bg-green-200" : "",
4530
+ (o == null ? void 0 : o.id) === _ ? "bg-purple-50" : "",
4531
+ y && "opacity-20",
4512
4532
  i.includes(g) ? "opacity-50" : ""
4513
4533
  ),
4514
4534
  children: [
@@ -4517,7 +4537,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4517
4537
  "div",
4518
4538
  {
4519
4539
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
4520
- children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4540
+ children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4521
4541
  ChevronRight,
4522
4542
  {
4523
4543
  className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
@@ -4526,8 +4546,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4526
4546
  }
4527
4547
  ),
4528
4548
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "leading-1 flex items-center", children: [
4529
- /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: y == null ? void 0 : y._type }),
4530
- v ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4549
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: j == null ? void 0 : j._type }),
4550
+ S ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4531
4551
  "div",
4532
4552
  {
4533
4553
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -4535,10 +4555,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4535
4555
  k.stopPropagation(), o.edit(), o.deselect();
4536
4556
  },
4537
4557
  children: [
4538
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (y == null ? void 0 : y._name) || (y == null ? void 0 : y._type.split("/").pop()) }),
4539
- C.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
4540
- C.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
4541
- C.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
4558
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (j == null ? void 0 : j._name) || (j == null ? void 0 : j._type.split("/").pop()) }),
4559
+ R.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
4560
+ R.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
4561
+ R.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
4542
4562
  ]
4543
4563
  }
4544
4564
  )
@@ -4556,7 +4576,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4556
4576
  ),
4557
4577
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: k.tooltip })
4558
4578
  ] })),
4559
- canAddChildBlock(y == null ? void 0 : y._type) && !i.includes(g) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4579
+ canAddChildBlock(j == null ? void 0 : j._type) && !i.includes(g) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4560
4580
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4561
4581
  TooltipTrigger,
4562
4582
  {
@@ -4926,16 +4946,16 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4926
4946
  }
4927
4947
  }
4928
4948
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
4929
- var p, u, x, f, g, y, b, h;
4949
+ var p, u, x, f, g, j, b, h;
4930
4950
  if (n.type === "comment")
4931
4951
  return [];
4932
4952
  let a = { _id: generateUUID() };
4933
4953
  if (r && (a._parent = r.block._id), n.type === "text")
4934
4954
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
4935
4955
  const l = get(n, "attributes", []), i = l.find(
4936
- (j) => j.key === "data-chai-richtext" || j.key === "chai-richtext"
4956
+ (y) => y.key === "data-chai-richtext" || y.key === "chai-richtext"
4937
4957
  ), c = l.find(
4938
- (j) => j.key === "data-chai-lightbox" || j.key === "chai-lightbox"
4958
+ (y) => y.key === "data-chai-lightbox" || y.key === "chai-lightbox"
4939
4959
  );
4940
4960
  if (a = {
4941
4961
  ...a,
@@ -4943,13 +4963,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4943
4963
  ...getAttrs(n),
4944
4964
  ...getStyles(n)
4945
4965
  }, n.attributes) {
4946
- const j = n.attributes.find((v) => includes(NAME_ATTRIBUTES, v.key));
4947
- j && (a._name = j.value);
4966
+ const y = n.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
4967
+ y && (a._name = y.value);
4948
4968
  }
4949
4969
  if (i)
4950
4970
  return a.content = stringify(n.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];
4951
4971
  if (c) {
4952
- const j = [
4972
+ const y = [
4953
4973
  "data-chai-lightbox",
4954
4974
  "chai-lightbox",
4955
4975
  "data-vbtype",
@@ -4961,25 +4981,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4961
4981
  ];
4962
4982
  a = {
4963
4983
  ...a,
4964
- href: ((p = l.find((v) => v.key === "href")) == null ? void 0 : p.value) || "",
4965
- hrefType: ((u = l.find((v) => v.key === "data-vbtype")) == null ? void 0 : u.value) || "video",
4966
- autoplay: ((x = l.find((v) => v.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
4967
- maxWidth: ((g = (f = l.find((v) => v.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : g.replace("px", "")) || "",
4968
- backdropColor: ((y = l.find((v) => v.key === "data-overlay")) == null ? void 0 : y.value) || "",
4969
- galleryName: ((b = l.find((v) => v.key === "data-gall")) == null ? void 0 : b.value) || ""
4970
- }, forEach(j, (v) => {
4971
- has(a, `styles_attrs.${v}`) && delete a.styles_attrs[v];
4984
+ href: ((p = l.find((S) => S.key === "href")) == null ? void 0 : p.value) || "",
4985
+ hrefType: ((u = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : u.value) || "video",
4986
+ autoplay: ((x = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
4987
+ maxWidth: ((g = (f = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : g.replace("px", "")) || "",
4988
+ backdropColor: ((j = l.find((S) => S.key === "data-overlay")) == null ? void 0 : j.value) || "",
4989
+ galleryName: ((b = l.find((S) => S.key === "data-gall")) == null ? void 0 : b.value) || ""
4990
+ }, forEach(y, (S) => {
4991
+ has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
4972
4992
  });
4973
4993
  }
4974
4994
  if (a._type === "Input") {
4975
- const j = a.inputType || "text";
4976
- j === "checkbox" ? set(a, "_type", "Checkbox") : j === "radio" && set(a, "_type", "Radio");
4995
+ const y = a.inputType || "text";
4996
+ y === "checkbox" ? set(a, "_type", "Checkbox") : y === "radio" && set(a, "_type", "Radio");
4977
4997
  } else if (n.tagName === "video" || n.tagName === "iframe") {
4978
- const j = stringify([n]);
4979
- return hasVideoEmbed(j) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(j)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = j, [a];
4998
+ const y = stringify([n]);
4999
+ return hasVideoEmbed(y) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(y)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = y, [a];
4980
5000
  } else if (n.tagName === "svg") {
4981
- const j = find(n.attributes, { key: "height" }), v = find(n.attributes, { key: "width" }), A = get(j, "value") ? `[${get(j, "value")}px]` : "24px", w = get(v, "value") ? `[${get(v, "value")}px]` : "24px", S = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
4982
- return a.styles = `${STYLES_KEY}, ${cn(`w-${w} h-${A}`, S)}`.trim(), n.attributes = filter(n.attributes, (B) => !includes(["style", "width", "height", "class"], B.key)), a.icon = stringify([n]), [a];
5001
+ const y = find(n.attributes, { key: "height" }), S = find(n.attributes, { key: "width" }), B = get(y, "value") ? `[${get(y, "value")}px]` : "24px", A = get(S, "value") ? `[${get(S, "value")}px]` : "24px", C = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
5002
+ return a.styles = `${STYLES_KEY}, ${cn(`w-${A} h-${B}`, C)}`.trim(), n.attributes = filter(n.attributes, (v) => !includes(["style", "width", "height", "class"], v.key)), a.icon = stringify([n]), [a];
4983
5003
  } else if (n.tagName == "option" && r && ((h = r.block) == null ? void 0 : h._type) === "Select")
4984
5004
  return r.block.options.push({
4985
5005
  label: getTextContent(n.children),
@@ -5165,18 +5185,18 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5165
5185
  collections: r,
5166
5186
  onChange: n
5167
5187
  }) => {
5168
- var M;
5169
- const { t: a } = useTranslation(), l = useBuilderProp("searchCollectionItems", (m, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [f, g] = useState(""), [y, b] = useState([]), [h, j] = useState(-1), v = useRef(null), A = (M = r == null ? void 0 : r.find((m) => m.key === u)) == null ? void 0 : M.name;
5188
+ var D;
5189
+ const { t: a } = useTranslation(), l = useBuilderProp("searchCollectionItems", (m, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [f, g] = useState(""), [j, b] = useState([]), [h, y] = useState(-1), S = useRef(null), B = (D = r == null ? void 0 : r.find((m) => m.key === u)) == null ? void 0 : D.name;
5170
5190
  useEffect(() => {
5171
- if (g(""), b([]), j(-1), p(!1), !o || i || !startsWith(o, "collection:"))
5191
+ if (g(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "collection:"))
5172
5192
  return;
5173
5193
  const m = split(o, ":"), E = get(m, 1, "page") || "page";
5174
5194
  x(E), (async () => {
5175
- const C = await l(E, [get(m, 2, "page")]);
5176
- C && Array.isArray(C) && g(get(C, [0, "name"], ""));
5195
+ const R = await l(E, [get(m, 2, "page")]);
5196
+ R && Array.isArray(R) && g(get(R, [0, "name"], ""));
5177
5197
  })();
5178
5198
  }, [o]);
5179
- const w = useDebouncedCallback(
5199
+ const A = useDebouncedCallback(
5180
5200
  async (m) => {
5181
5201
  if (isEmpty(m))
5182
5202
  b([]);
@@ -5184,41 +5204,41 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5184
5204
  const E = await l(u, m);
5185
5205
  b(E);
5186
5206
  }
5187
- c(!1), j(-1);
5207
+ c(!1), y(-1);
5188
5208
  },
5189
5209
  [u],
5190
5210
  300
5191
- ), S = (m) => {
5211
+ ), C = (m) => {
5192
5212
  const E = ["collection", u, m.id];
5193
- E[1] && (n(E.join(":")), g(m.name), p(!1), b([]), j(-1));
5194
- }, B = (m) => {
5213
+ E[1] && (n(E.join(":")), g(m.name), p(!1), b([]), y(-1));
5214
+ }, v = (m) => {
5195
5215
  switch (m.key) {
5196
5216
  case "ArrowDown":
5197
- m.preventDefault(), j((E) => E < y.length - 1 ? E + 1 : E);
5217
+ m.preventDefault(), y((E) => E < j.length - 1 ? E + 1 : E);
5198
5218
  break;
5199
5219
  case "ArrowUp":
5200
- m.preventDefault(), j((E) => E > 0 ? E - 1 : E);
5220
+ m.preventDefault(), y((E) => E > 0 ? E - 1 : E);
5201
5221
  break;
5202
5222
  case "Enter":
5203
- if (m.preventDefault(), y.length === 0)
5223
+ if (m.preventDefault(), j.length === 0)
5204
5224
  return;
5205
- h >= 0 && S(y[h]);
5225
+ h >= 0 && C(j[h]);
5206
5226
  break;
5207
5227
  case "Escape":
5208
- m.preventDefault(), I();
5228
+ m.preventDefault(), _();
5209
5229
  break;
5210
5230
  }
5211
5231
  };
5212
5232
  useEffect(() => {
5213
- if (h >= 0 && v.current) {
5214
- const m = v.current.children[h];
5233
+ if (h >= 0 && S.current) {
5234
+ const m = S.current.children[h];
5215
5235
  m == null || m.scrollIntoView({ block: "nearest" });
5216
5236
  }
5217
5237
  }, [h]);
5218
- const I = () => {
5219
- g(""), b([]), j(-1), p(!1), n("");
5220
- }, T = (m) => {
5221
- g(m), p(!isEmpty(m)), c(!0), w(m);
5238
+ const _ = () => {
5239
+ g(""), b([]), y(-1), p(!1), n("");
5240
+ }, I = (m) => {
5241
+ g(m), p(!isEmpty(m)), c(!0), A(m);
5222
5242
  };
5223
5243
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5224
5244
  /* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "collection", value: u, onChange: (m) => x(m.target.value), children: map(r, (m) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: m.key, children: m.name }, m.key)) }),
@@ -5228,26 +5248,26 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5228
5248
  {
5229
5249
  type: "text",
5230
5250
  value: f,
5231
- onChange: (m) => T(m.target.value),
5232
- onKeyDown: B,
5233
- placeholder: a(`Search ${A}`),
5251
+ onChange: (m) => I(m.target.value),
5252
+ onKeyDown: v,
5253
+ placeholder: a(`Search ${B}`),
5234
5254
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
5235
5255
  }
5236
5256
  ),
5237
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
5257
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
5238
5258
  ] }),
5239
- (i || !isEmpty(y) || d && isEmpty(y)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
5259
+ (i || !isEmpty(j) || d && isEmpty(j)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
5240
5260
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
5241
5261
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
5242
- ] }) : d && isEmpty(y) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5262
+ ] }) : d && isEmpty(j) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5243
5263
  a("No results found for"),
5244
5264
  ' "',
5245
5265
  f,
5246
5266
  '"'
5247
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: v, children: map(y == null ? void 0 : y.slice(0, 20), (m, E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5267
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: S, children: map(j == null ? void 0 : j.slice(0, 20), (m, E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5248
5268
  "li",
5249
5269
  {
5250
- onClick: () => S(m),
5270
+ onClick: () => C(m),
5251
5271
  className: `cursor-pointer p-2 text-xs ${o != null && o.includes(m.id) ? "bg-blue-200" : E === h ? "bg-gray-100" : "hover:bg-gray-100"}`,
5252
5272
  children: [
5253
5273
  m.name,
@@ -5345,27 +5365,27 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5345
5365
  required: p,
5346
5366
  schema: u
5347
5367
  }) => {
5348
- const { selectedLang: x, fallbackLang: f, languages: g } = useLanguages(), y = isEmpty(g) ? "" : isEmpty(x) ? f : x, b = get(LANGUAGES, y, y), h = useSelectedBlock(), j = useRegisteredChaiBlocks(), v = get(j, [h == null ? void 0 : h._type, "i18nProps"], []) || [], [A, w] = useState(null);
5368
+ const { selectedLang: x, fallbackLang: f, languages: g } = useLanguages(), j = isEmpty(g) ? "" : isEmpty(x) ? f : x, b = get(LANGUAGES, j, j), h = useSelectedBlock(), y = useRegisteredChaiBlocks(), S = get(y, [h == null ? void 0 : h._type, "i18nProps"], []) || [], [B, A] = useState(null);
5349
5369
  if (d)
5350
5370
  return null;
5351
5371
  if (u.type === "boolean")
5352
5372
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r, children: a });
5353
- const B = v == null ? void 0 : v.includes(o.replace("root.", ""));
5373
+ const v = S == null ? void 0 : S.includes(o.replace("root.", ""));
5354
5374
  return u.type === "array" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${r} relative`, children: [
5355
5375
  u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs(
5356
5376
  "label",
5357
5377
  {
5358
5378
  htmlFor: o,
5359
- onClick: () => w(A ? null : o),
5379
+ onClick: () => A(B ? null : o),
5360
5380
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5361
5381
  children: [
5362
- A ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
5382
+ B ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
5363
5383
  /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-3 w-3" }),
5364
5384
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-tight", children: n })
5365
5385
  ]
5366
5386
  }
5367
5387
  ),
5368
- A && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-2", children: [
5388
+ B && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-2", children: [
5369
5389
  c,
5370
5390
  a,
5371
5391
  l,
@@ -5375,7 +5395,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5375
5395
  u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
5376
5396
  n,
5377
5397
  " ",
5378
- B && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5398
+ v && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5379
5399
  " ",
5380
5400
  b
5381
5401
  ] }),
@@ -5503,39 +5523,83 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5503
5523
  return set(n, o, r), n;
5504
5524
  };
5505
5525
  function BlockSettings() {
5506
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), p = ({ formData: y }, b, h) => {
5507
- if (b && (c == null ? void 0 : c._id) === r._id) {
5508
- const j = b.replace("root.", "");
5509
- a([r._id], { [j]: get(y, j) }, h);
5526
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(), f = getRegisteredChaiBlock(x == null ? void 0 : x._type), g = formDataWithSelectedLang(x, o, f), j = ({ formData: v }, _, I) => {
5527
+ if (_ && (c == null ? void 0 : c._id) === r._id) {
5528
+ const D = _.replace("root.", "");
5529
+ a([r._id], { [D]: get(v, D) }, I);
5510
5530
  }
5511
- }, u = useCallback(
5512
- debounce(({ formData: y }, b, h) => {
5513
- p({ formData: y }, b, h), d(y);
5531
+ }, b = useCallback(
5532
+ debounce(({ formData: v }, _, I) => {
5533
+ j({ formData: v }, _, I), d(v);
5514
5534
  }, 1500),
5515
5535
  [r == null ? void 0 : r._id, o]
5516
- ), x = ({ formData: y }, b) => {
5517
- if (b) {
5518
- const h = b.replace("root.", "");
5536
+ ), h = ({ formData: v }, _) => {
5537
+ if (_) {
5538
+ const I = _.replace("root.", "");
5519
5539
  n(
5520
5540
  [r._id],
5521
- convertDotNotationToObject(h, get(y, h.split(".")))
5522
- ), u({ formData: y }, b, { [h]: get(c, h) });
5541
+ convertDotNotationToObject(I, get(v, I.split(".")))
5542
+ ), b({ formData: v }, _, { [I]: get(c, I) });
5543
+ }
5544
+ }, y = ({ formData: v }, _) => {
5545
+ if (_) {
5546
+ const I = _.replace("root.", "");
5547
+ n(
5548
+ [x._id],
5549
+ convertDotNotationToObject(I, get(v, I.split(".")))
5550
+ ), b({ formData: v }, _, { [I]: get(c, I) });
5523
5551
  }
5524
5552
  };
5525
5553
  keys(get(i, "_bindings", {}));
5526
- const { schema: f, uiSchema: g } = useMemo(() => {
5527
- const y = r == null ? void 0 : r._type;
5528
- return y ? getBlockFormSchemas(y) : { schema: {}, uiSchema: {} };
5529
- }, [r]);
5554
+ const { schema: S, uiSchema: B } = useMemo(() => {
5555
+ const v = r == null ? void 0 : r._type;
5556
+ if (v)
5557
+ return getBlockFormSchemas(v);
5558
+ }, [r]), { wrapperSchema: A, wrapperUiSchema: C } = useMemo(() => {
5559
+ if (!x || !(x != null && x._type))
5560
+ return { wrapperSchema: {}, wrapperUiSchema: {} };
5561
+ const v = x == null ? void 0 : x._type, { schema: _ = {}, uiSchema: I = {} } = getBlockFormSchemas(v);
5562
+ return { wrapperSchema: _, wrapperUiSchema: I };
5563
+ }, [x]);
5530
5564
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-hidden px-px", children: [
5531
- isEmpty(f) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
5565
+ !isEmpty(x) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5566
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
5567
+ "div",
5568
+ {
5569
+ onClick: () => u((v) => !v),
5570
+ className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5571
+ children: [
5572
+ p ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
5573
+ startCase(x._type),
5574
+ " settings",
5575
+ " ",
5576
+ x._name && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
5577
+ "(",
5578
+ x._name,
5579
+ ")"
5580
+ ] })
5581
+ ]
5582
+ }
5583
+ ),
5584
+ p && /* @__PURE__ */ jsxRuntimeExports.jsx(
5585
+ JSONForm,
5586
+ {
5587
+ id: x == null ? void 0 : x._id,
5588
+ onChange: y,
5589
+ formData: g,
5590
+ schema: A,
5591
+ uiSchema: C
5592
+ }
5593
+ )
5594
+ ] }),
5595
+ isEmpty(S) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
5532
5596
  JSONForm,
5533
5597
  {
5534
5598
  id: r == null ? void 0 : r._id,
5535
- onChange: x,
5599
+ onChange: h,
5536
5600
  formData: i,
5537
- schema: f,
5538
- uiSchema: g
5601
+ schema: S,
5602
+ uiSchema: B
5539
5603
  }
5540
5604
  ),
5541
5605
  (r == null ? void 0 : r._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null,
@@ -5613,8 +5677,8 @@ const AskAIStyles = ({ blockId: o }) => {
5613
5677
  (g = d.current) == null || g.focus();
5614
5678
  }, []);
5615
5679
  const f = (g) => {
5616
- const { usage: y } = g || {};
5617
- !l && y && x(y), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
5680
+ const { usage: j } = g || {};
5681
+ !l && j && x(j), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
5618
5682
  };
5619
5683
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
5620
5684
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
@@ -5669,37 +5733,37 @@ const AskAIStyles = ({ blockId: o }) => {
5669
5733
  ] });
5670
5734
  };
5671
5735
  function ManualClasses() {
5672
- var I;
5673
- const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), f = (I = first(n)) == null ? void 0 : I.prop, g = reject((get(a, f, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), y = () => {
5674
- const T = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5675
- l(c, T, !0), u("");
5676
- }, [b, h] = useState([]), j = ({ value: T }) => {
5677
- const M = T.trim().toLowerCase(), m = M.match(/.+:/g);
5736
+ var _;
5737
+ const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), f = (_ = first(n)) == null ? void 0 : _.prop, g = reject((get(a, f, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), j = () => {
5738
+ const I = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5739
+ l(c, I, !0), u("");
5740
+ }, [b, h] = useState([]), y = ({ value: I }) => {
5741
+ const D = I.trim().toLowerCase(), m = D.match(/.+:/g);
5678
5742
  let E = [];
5679
5743
  if (m && m.length > 0) {
5680
- const [C] = m, R = M.replace(C, "");
5681
- E = o.search(R).map((k) => ({
5744
+ const [R] = m, w = D.replace(R, "");
5745
+ E = o.search(w).map((k) => ({
5682
5746
  ...k,
5683
- item: { ...k.item, name: C + k.item.name }
5747
+ item: { ...k.item, name: R + k.item.name }
5684
5748
  }));
5685
5749
  } else
5686
- E = o.search(M);
5750
+ E = o.search(D);
5687
5751
  return h(map(E, "item"));
5688
- }, v = () => {
5752
+ }, S = () => {
5689
5753
  h([]);
5690
- }, A = (T) => T.name, w = (T) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: T.name }), S = {
5754
+ }, B = (I) => I.name, A = (I) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: I.name }), C = {
5691
5755
  autoComplete: "off",
5692
5756
  autoCorrect: "off",
5693
5757
  autoCapitalize: "off",
5694
5758
  spellCheck: !1,
5695
5759
  placeholder: r("Enter classes separated by space"),
5696
5760
  value: p,
5697
- onKeyDown: (T) => {
5698
- T.key === "Enter" && p.trim() !== "" && y();
5761
+ onKeyDown: (I) => {
5762
+ I.key === "Enter" && p.trim() !== "" && j();
5699
5763
  },
5700
- onChange: (T, { newValue: M }) => u(M),
5764
+ onChange: (I, { newValue: D }) => u(D),
5701
5765
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5702
- }, B = () => {
5766
+ }, v = () => {
5703
5767
  if (navigator.clipboard === void 0) {
5704
5768
  x({
5705
5769
  title: r("Clipboard not supported"),
@@ -5722,7 +5786,7 @@ function ManualClasses() {
5722
5786
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5723
5787
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: r("Classes") }),
5724
5788
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
5725
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: B, className: "cursor-pointer" }) }),
5789
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: v, className: "cursor-pointer" }) }),
5726
5790
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: r("Copy classes to clipboard") }) })
5727
5791
  ] })
5728
5792
  ] }),
@@ -5739,11 +5803,11 @@ function ManualClasses() {
5739
5803
  Autosuggest,
5740
5804
  {
5741
5805
  suggestions: b,
5742
- onSuggestionsFetchRequested: j,
5743
- onSuggestionsClearRequested: v,
5744
- getSuggestionValue: A,
5745
- renderSuggestion: w,
5746
- inputProps: S,
5806
+ onSuggestionsFetchRequested: y,
5807
+ onSuggestionsClearRequested: S,
5808
+ getSuggestionValue: B,
5809
+ renderSuggestion: A,
5810
+ inputProps: C,
5747
5811
  containerProps: {
5748
5812
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5749
5813
  },
@@ -5759,7 +5823,7 @@ function ManualClasses() {
5759
5823
  {
5760
5824
  variant: "outline",
5761
5825
  className: "h-6 border-border",
5762
- onClick: y,
5826
+ onClick: j,
5763
5827
  disabled: p.trim() === "",
5764
5828
  size: "sm",
5765
5829
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {})
@@ -5767,22 +5831,22 @@ function ManualClasses() {
5767
5831
  )
5768
5832
  ] }),
5769
5833
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: React.Children.toArray(
5770
- g.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5834
+ g.map((I) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5771
5835
  "div",
5772
5836
  {
5773
5837
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
5774
5838
  children: [
5775
- T,
5839
+ I,
5776
5840
  /* @__PURE__ */ jsxRuntimeExports.jsx(
5777
5841
  Cross2Icon,
5778
5842
  {
5779
- onClick: () => i(c, [T]),
5843
+ onClick: () => i(c, [I]),
5780
5844
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5781
5845
  }
5782
5846
  )
5783
5847
  ]
5784
5848
  },
5785
- T
5849
+ I
5786
5850
  ))
5787
5851
  ) })
5788
5852
  ]
@@ -6176,7 +6240,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6176
6240
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""), f = get(u, "2", ""), g = useCallback(
6177
6241
  // eslint-disable-next-line no-shadow
6178
6242
  (h) => {
6179
- ["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((j) => ({ ...j, color: h, shade: j.shade ? j.shade : "500" })));
6243
+ ["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: h, shade: y.shade ? y.shade : "500" })));
6180
6244
  },
6181
6245
  [c, p]
6182
6246
  );
@@ -6185,7 +6249,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6185
6249
  return c([]);
6186
6250
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
6187
6251
  }, [x]);
6188
- const y = useCallback(
6252
+ const j = useCallback(
6189
6253
  // eslint-disable-next-line no-shadow
6190
6254
  (h) => {
6191
6255
  p({ color: x, shade: h });
@@ -6197,8 +6261,8 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6197
6261
  }, [n]);
6198
6262
  const { match: b } = useTailwindClassList();
6199
6263
  return useEffect(() => {
6200
- const j = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6201
- b(o, j) && r(j, o);
6264
+ const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6265
+ b(o, y) && r(y, o);
6202
6266
  }, [b, d, r, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6203
6267
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6204
6268
  DropDown,
@@ -6239,7 +6303,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6239
6303
  ]
6240
6304
  }
6241
6305
  ) }),
6242
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: f, disabled: !x || !l, onChange: y, options: i }) })
6306
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: f, disabled: !x || !l, onChange: j, options: i }) })
6243
6307
  ] });
6244
6308
  }, getUserInputValues = (o, r) => {
6245
6309
  o = o.toLowerCase();
@@ -6434,7 +6498,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6434
6498
  },
6435
6499
  a
6436
6500
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6437
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [f, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [y, b] = useState(!1), [h, j] = useState(""), [v, A] = useState(!1), [w, S] = useState(!1);
6501
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [f, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [j, b] = useState(!1), [h, y] = useState(""), [S, B] = useState(!1), [A, C] = useState(!1);
6438
6502
  useEffect(() => {
6439
6503
  const { value: m, unit: E } = getClassValueAndUnit(i);
6440
6504
  if (E === "") {
@@ -6443,25 +6507,25 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6443
6507
  }
6444
6508
  g(E), l(E === "class" || isEmpty(m) ? "" : m);
6445
6509
  }, [i, p, u]);
6446
- const B = useThrottledCallback((m) => c(m), [c], THROTTLE_TIME), I = useThrottledCallback((m) => c(m, !1), [c], THROTTLE_TIME), T = useCallback(
6510
+ const v = useThrottledCallback((m) => c(m), [c], THROTTLE_TIME), _ = useThrottledCallback((m) => c(m, !1), [c], THROTTLE_TIME), I = useCallback(
6447
6511
  (m = !1) => {
6448
6512
  const E = getUserInputValues(`${a}`, u);
6449
6513
  if (get(E, "error", !1)) {
6450
6514
  b(!0);
6451
6515
  return;
6452
6516
  }
6453
- const C = get(E, "unit") !== "" ? get(E, "unit") : f;
6454
- if (C === "auto" || C === "none") {
6455
- B(`${d}${C}`);
6517
+ const R = get(E, "unit") !== "" ? get(E, "unit") : f;
6518
+ if (R === "auto" || R === "none") {
6519
+ v(`${d}${R}`);
6456
6520
  return;
6457
6521
  }
6458
6522
  if (get(E, "value") === "")
6459
6523
  return;
6460
- const _ = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${C === "-" ? "" : C}]`;
6461
- m ? I(_) : B(_);
6524
+ const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
6525
+ m ? _(T) : v(T);
6462
6526
  },
6463
- [B, I, a, f, d, u]
6464
- ), M = useCallback(
6527
+ [v, _, a, f, d, u]
6528
+ ), D = useCallback(
6465
6529
  (m) => {
6466
6530
  const E = getUserInputValues(`${a}`, u);
6467
6531
  if (get(E, "error", !1)) {
@@ -6469,15 +6533,15 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6469
6533
  return;
6470
6534
  }
6471
6535
  if (m === "auto" || m === "none") {
6472
- B(`${d}${m}`);
6536
+ v(`${d}${m}`);
6473
6537
  return;
6474
6538
  }
6475
6539
  if (get(E, "value") === "")
6476
6540
  return;
6477
- const C = get(E, "unit") !== "" ? get(E, "unit") : m, _ = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${C === "-" ? "" : C}]`;
6478
- B(_);
6541
+ const R = get(E, "unit") !== "" ? get(E, "unit") : m, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
6542
+ v(T);
6479
6543
  },
6480
- [B, a, d, u]
6544
+ [v, a, d, u]
6481
6545
  );
6482
6546
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6483
6547
  /* @__PURE__ */ jsxRuntimeExports.jsx("input", { className: "w-20 rounded py-1", readOnly: !0, value: i }),
@@ -6485,29 +6549,29 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6485
6549
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
6486
6550
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6487
6551
  ] })
6488
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
6552
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
6489
6553
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6490
6554
  ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6491
6555
  "input",
6492
6556
  {
6493
6557
  readOnly: f === "class",
6494
6558
  onKeyPress: (m) => {
6495
- m.key === "Enter" && T();
6559
+ m.key === "Enter" && I();
6496
6560
  },
6497
6561
  onKeyDown: (m) => {
6498
6562
  if (m.keyCode !== 38 && m.keyCode !== 40)
6499
6563
  return;
6500
- m.preventDefault(), S(!0);
6564
+ m.preventDefault(), C(!0);
6501
6565
  const E = parseInt$1(m.target.value);
6502
- let C = isNaN$1(E) ? 0 : E;
6503
- m.keyCode === 38 && (C += 1), m.keyCode === 40 && (C -= 1);
6504
- const R = `${C}`, k = `${R.startsWith("-") ? "-" : ""}${d}[${R.replace("-", "")}${f === "-" ? "" : f}]`;
6505
- I(k);
6566
+ let R = isNaN$1(E) ? 0 : E;
6567
+ m.keyCode === 38 && (R += 1), m.keyCode === 40 && (R -= 1);
6568
+ const w = `${R}`, k = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${f === "-" ? "" : f}]`;
6569
+ _(k);
6506
6570
  },
6507
6571
  onKeyUp: (m) => {
6508
- w && (m.preventDefault(), S(!1));
6572
+ A && (m.preventDefault(), C(!1));
6509
6573
  },
6510
- onBlur: () => T(),
6574
+ onBlur: () => I(),
6511
6575
  onChange: (m) => {
6512
6576
  b(!1), l(m.target.value);
6513
6577
  },
@@ -6515,10 +6579,10 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6515
6579
  var E;
6516
6580
  (E = m == null ? void 0 : m.target) == null || E.select(), n(!1);
6517
6581
  },
6518
- value: v ? h : a,
6582
+ value: S ? h : a,
6519
6583
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6520
6584
  " ",
6521
- y ? "border-red-500 text-red-500" : "border-foreground/20"
6585
+ j ? "border-red-500 text-red-500" : "border-foreground/20"
6522
6586
  )
6523
6587
  }
6524
6588
  ),
@@ -6541,28 +6605,28 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6541
6605
  units: u,
6542
6606
  current: f,
6543
6607
  onSelect: (m) => {
6544
- n(!1), g(m), M(m);
6608
+ n(!1), g(m), D(m);
6545
6609
  }
6546
6610
  }
6547
6611
  ) }) })
6548
6612
  ] })
6549
6613
  ] }),
6550
- ["none", "auto"].indexOf(f) !== -1 || v ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6614
+ ["none", "auto"].indexOf(f) !== -1 || S ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6551
6615
  DragStyleButton,
6552
6616
  {
6553
- onDragStart: () => A(!0),
6617
+ onDragStart: () => B(!0),
6554
6618
  onDragEnd: (m) => {
6555
- if (j(() => ""), A(!1), isEmpty(m))
6619
+ if (y(() => ""), B(!1), isEmpty(m))
6556
6620
  return;
6557
- const E = `${m}`, R = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
6558
- B(R);
6621
+ const E = `${m}`, w = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
6622
+ v(w);
6559
6623
  },
6560
6624
  onDrag: (m) => {
6561
6625
  if (isEmpty(m))
6562
6626
  return;
6563
- j(m);
6564
- const E = `${m}`, R = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
6565
- I(R);
6627
+ y(m);
6628
+ const E = `${m}`, w = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
6629
+ _(w);
6566
6630
  },
6567
6631
  currentValue: a,
6568
6632
  unit: f,
@@ -6659,35 +6723,35 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6659
6723
  "2xl": "1536px"
6660
6724
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6661
6725
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
6662
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), f = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), y = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), h = useMemo(() => get(f, "fullCls", ""), [f]), j = useCallback(
6663
- (I, T = !0) => {
6664
- const M = { dark: p, mq: x, mod: u, cls: I, property: l, fullCls: "" };
6665
- (p || u !== "") && (M.mq = "xs");
6666
- const m = generateFullClsName(M);
6667
- g(b, [m], T);
6726
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), f = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), j = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), h = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
6727
+ (_, I = !0) => {
6728
+ const D = { dark: p, mq: x, mod: u, cls: _, property: l, fullCls: "" };
6729
+ (p || u !== "") && (D.mq = "xs");
6730
+ const m = generateFullClsName(D);
6731
+ g(b, [m], I);
6668
6732
  },
6669
6733
  [b, p, x, u, l, g]
6670
- ), v = useCallback(() => {
6671
- y(b, [h]);
6672
- }, [b, h, y]), A = useMemo(() => canChangeClass(f, x), [f, x]);
6734
+ ), S = useCallback(() => {
6735
+ j(b, [h]);
6736
+ }, [b, h, j]), B = useMemo(() => canChangeClass(f, x), [f, x]);
6673
6737
  useEffect(() => {
6674
- i(A, f);
6675
- }, [A, i, f]);
6676
- const [, , w] = useCanvasWidth(), S = useCallback(
6677
- (I) => {
6678
- w({
6738
+ i(B, f);
6739
+ }, [B, i, f]);
6740
+ const [, , A] = useCanvasWidth(), C = useCallback(
6741
+ (_) => {
6742
+ A({
6679
6743
  xs: 400,
6680
6744
  sm: 640,
6681
6745
  md: 800,
6682
6746
  lg: 1024,
6683
6747
  xl: 1420,
6684
6748
  "2xl": 1920
6685
- }[I]);
6749
+ }[_]);
6686
6750
  },
6687
- [w]
6688
- ), B = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === x;
6689
- return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: A, canReset: f && B, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6690
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${f && !B ? "text-foreground" : ""}`, children: r(a) }) }),
6751
+ [A]
6752
+ ), v = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === x;
6753
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: B, canReset: f && v, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6754
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${f && !v ? "text-foreground" : ""}`, children: r(a) }) }),
6691
6755
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
6692
6756
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
6693
6757
  n === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -6696,17 +6760,17 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6696
6760
  currentClass: get(f, "cls", ""),
6697
6761
  classPrefix: get(CLASS_PREFIXES, l, ""),
6698
6762
  units: c || [],
6699
- onChange: j,
6763
+ onChange: y,
6700
6764
  negative: d,
6701
6765
  cssProperty: l
6702
6766
  }
6703
6767
  ) : null,
6704
- n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: j }),
6705
- n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: j }),
6706
- n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: j }),
6707
- n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: j })
6768
+ n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: y }),
6769
+ n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: y }),
6770
+ n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: y }),
6771
+ n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: y })
6708
6772
  ] }),
6709
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A && f ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
6773
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children: v ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && f ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
6710
6774
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6711
6775
  "button",
6712
6776
  {
@@ -6726,7 +6790,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6726
6790
  "button",
6727
6791
  {
6728
6792
  type: "button",
6729
- onClick: () => S(get(f, "mq")),
6793
+ onClick: () => C(get(f, "mq")),
6730
6794
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6731
6795
  children: [
6732
6796
  "Switch to ",
@@ -6756,18 +6820,18 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6756
6820
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
6757
6821
  o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6758
6822
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6759
- r.map(({ label: g, key: y }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
6823
+ r.map(({ label: g, key: j }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
6760
6824
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
6761
6825
  "button",
6762
6826
  {
6763
6827
  type: "button",
6764
- onClick: () => u(y),
6765
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${y === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6828
+ onClick: () => u(j),
6829
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${j === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6766
6830
  children: [
6767
6831
  React__default.createElement("div", {
6768
- className: f(y) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6832
+ className: f(j) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6769
6833
  }),
6770
- React__default.createElement(get(EDITOR_ICONS, y, BoxIcon), { className: "text-inherit w-3 h-3" })
6834
+ React__default.createElement(get(EDITOR_ICONS, j, BoxIcon), { className: "text-inherit w-3 h-3" })
6771
6835
  ]
6772
6836
  }
6773
6837
  ) }),
@@ -6915,9 +6979,9 @@ function BlockStyling() {
6915
6979
  const x = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6916
6980
  let g = parseFloat(i.dragStartValue);
6917
6981
  g = isNaN(g) ? 0 : g;
6918
- let y = MAPPER[i.dragUnit];
6919
- (startsWith(f, "scale") || f === "opacity") && (y = 10);
6920
- let h = (i.dragStartY - u.pageY) / y + g;
6982
+ let j = MAPPER[i.dragUnit];
6983
+ (startsWith(f, "scale") || f === "opacity") && (j = 10);
6984
+ let h = (i.dragStartY - u.pageY) / j + g;
6921
6985
  x && h < 0 && (h = 0), f === "opacity" && h > 1 && (h = 1), i.onDrag(`${h}`), l(`${h}`);
6922
6986
  },
6923
6987
  [i],
@@ -7006,33 +7070,33 @@ const BlockCard = ({
7006
7070
  parentId: n = void 0,
7007
7071
  position: a = -1
7008
7072
  }) => {
7009
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), f = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, y] = useAtom$1(draggedBlockAtom), b = (v) => {
7010
- const A = has(v, "styles_attrs.data-page-section");
7011
- return v._type === "Box" && A;
7073
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), f = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, j] = useAtom$1(draggedBlockAtom), b = (S) => {
7074
+ const B = has(S, "styles_attrs.data-page-section");
7075
+ return S._type === "Box" && B;
7012
7076
  }, h = useCallback(
7013
- async (v) => {
7014
- if (v.stopPropagation(), has(o, "component")) {
7077
+ async (S) => {
7078
+ if (S.stopPropagation(), has(o, "component")) {
7015
7079
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7016
7080
  return;
7017
7081
  }
7018
7082
  i(!0);
7019
- const A = await c(r, o);
7020
- isEmpty(A) || p(syncBlocksWithDefaults(A), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7083
+ const B = await c(r, o);
7084
+ isEmpty(B) || p(syncBlocksWithDefaults(B), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7021
7085
  },
7022
7086
  [d, p, o, c, r, n, a]
7023
- ), j = async (v) => {
7024
- const A = await c(r, o);
7025
- let w = n;
7026
- if (b(first(A)) && (w = null), !isEmpty(A)) {
7027
- const S = { blocks: A, uiLibrary: !0, parent: w };
7028
- if (v.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7029
- const B = new Image();
7030
- B.src = o.preview, B.onload = () => {
7031
- v.dataTransfer.setDragImage(B, 0, 0);
7087
+ ), y = async (S) => {
7088
+ const B = await c(r, o);
7089
+ let A = n;
7090
+ if (b(first(B)) && (A = null), !isEmpty(B)) {
7091
+ const C = { blocks: B, uiLibrary: !0, parent: A };
7092
+ if (S.dataTransfer.setData("text/plain", JSON.stringify(C)), o.preview) {
7093
+ const v = new Image();
7094
+ v.src = o.preview, v.onload = () => {
7095
+ S.dataTransfer.setDragImage(v, 0, 0);
7032
7096
  };
7033
7097
  } else
7034
- v.dataTransfer.setDragImage(new Image(), 0, 0);
7035
- y(S), setTimeout(() => {
7098
+ S.dataTransfer.setDragImage(new Image(), 0, 0);
7099
+ j(C), setTimeout(() => {
7036
7100
  u([]), x(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7037
7101
  }, 200);
7038
7102
  }
@@ -7044,7 +7108,7 @@ const BlockCard = ({
7044
7108
  onClick: l ? () => {
7045
7109
  } : h,
7046
7110
  draggable: g ? "true" : "false",
7047
- onDragStart: j,
7111
+ onDragStart: y,
7048
7112
  className: clsx(
7049
7113
  "relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
7050
7114
  ),
@@ -7073,9 +7137,9 @@ const BlockCard = ({
7073
7137
  })();
7074
7138
  }, [o, l, i, c, n, a]), { data: l || [], isLoading: i === "loading" };
7075
7139
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7076
- const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [f, g] = useState("Hero"), y = get(x, f, []), b = useRef(null), { t: h } = useTranslation(), j = (w) => {
7140
+ const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((A) => A.category === "custom"), d = l.find((A) => A.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [f, g] = useState("Hero"), j = get(x, f, []), b = useRef(null), { t: h } = useTranslation(), y = (A) => {
7077
7141
  b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
7078
- b.current && g(w);
7142
+ b.current && g(A);
7079
7143
  }, 300);
7080
7144
  };
7081
7145
  if (u)
@@ -7083,7 +7147,7 @@ const BlockCard = ({
7083
7147
  /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
7084
7148
  /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
7085
7149
  ] });
7086
- const v = filter(y, (w, S) => S % 2 === 0), A = filter(y, (w, S) => S % 2 === 1);
7150
+ const S = filter(j, (A, C) => C % 2 === 0), B = filter(j, (A, C) => C % 2 === 1);
7087
7151
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
7088
7152
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7089
7153
  /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
@@ -7091,22 +7155,22 @@ const BlockCard = ({
7091
7155
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
7092
7156
  /* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
7093
7157
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7094
- map(x, (w, S) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
7158
+ map(x, (A, C) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
7095
7159
  "div",
7096
7160
  {
7097
- onMouseEnter: () => j(S),
7161
+ onMouseEnter: () => y(C),
7098
7162
  onMouseLeave: () => clearTimeout(b.current),
7099
- onClick: () => g(S),
7163
+ onClick: () => g(C),
7100
7164
  className: cn(
7101
7165
  "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",
7102
- S === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7166
+ C === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7103
7167
  ),
7104
7168
  children: [
7105
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(h(S.toLowerCase())) }),
7169
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(h(C.toLowerCase())) }),
7106
7170
  /* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7107
7171
  ]
7108
7172
  },
7109
- S
7173
+ C
7110
7174
  ))
7111
7175
  ) })
7112
7176
  ] })
@@ -7119,10 +7183,10 @@ const BlockCard = ({
7119
7183
  children: [
7120
7184
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7121
7185
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7122
- v.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: w, library: d }))
7186
+ S.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
7123
7187
  ) }),
7124
7188
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7125
- A.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: w, library: d }))
7189
+ B.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
7126
7190
  ) })
7127
7191
  ] }),
7128
7192
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
@@ -7638,7 +7702,7 @@ const CoreBlock = ({
7638
7702
  } else
7639
7703
  p(o, n || null, a);
7640
7704
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7641
- }, y = useFeature("dnd"), { t: b } = useTranslation();
7705
+ }, j = useFeature("dnd"), { t: b } = useTranslation();
7642
7706
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
7643
7707
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
7644
7708
  "button",
@@ -7651,7 +7715,7 @@ const CoreBlock = ({
7651
7715
  x([]), f();
7652
7716
  }, 200);
7653
7717
  },
7654
- draggable: y ? "true" : "false",
7718
+ draggable: j ? "true" : "false",
7655
7719
  className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
7656
7720
  children: [
7657
7721
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
@@ -7849,7 +7913,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7849
7913
  var b;
7850
7914
  (b = f.current) == null || b.focus();
7851
7915
  }, []);
7852
- const y = (b) => {
7916
+ const j = (b) => {
7853
7917
  const { usage: h } = b || {};
7854
7918
  !l && h && x(h), g.current = setTimeout(() => x(void 0), 1e4), l || c("");
7855
7919
  };
@@ -7876,7 +7940,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7876
7940
  className: "w-full",
7877
7941
  rows: 3,
7878
7942
  onKeyDown: (b) => {
7879
- b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i, y));
7943
+ b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j));
7880
7944
  }
7881
7945
  }
7882
7946
  ),
@@ -7886,7 +7950,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7886
7950
  {
7887
7951
  disabled: i.trim().length < 5 || a,
7888
7952
  onClick: () => {
7889
- g.current && clearTimeout(g.current), x(void 0), n("content", o, i, y);
7953
+ g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j);
7890
7954
  },
7891
7955
  variant: "default",
7892
7956
  className: "w-fit",
@@ -7919,7 +7983,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7919
7983
  QuickPrompts,
7920
7984
  {
7921
7985
  onClick: (b) => {
7922
- g.current && clearTimeout(g.current), x(void 0), n("content", o, b, y);
7986
+ g.current && clearTimeout(g.current), x(void 0), n("content", o, b, j);
7923
7987
  }
7924
7988
  }
7925
7989
  )
@@ -7933,7 +7997,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7933
7997
  useEffect(() => {
7934
7998
  r && a(r);
7935
7999
  }, [r]);
7936
- const y = async () => {
8000
+ const j = async () => {
7937
8001
  try {
7938
8002
  d(!0), u(null), await i(n), f({
7939
8003
  title: o("Updated AI Context"),
@@ -7967,7 +8031,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7967
8031
  className: "mt-1 w-full",
7968
8032
  rows: 10,
7969
8033
  onKeyDown: (b) => {
7970
- b.key === "Enter" && (b.preventDefault(), y());
8034
+ b.key === "Enter" && (b.preventDefault(), j());
7971
8035
  }
7972
8036
  }
7973
8037
  ),
@@ -7979,7 +8043,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7979
8043
  Button,
7980
8044
  {
7981
8045
  disabled: n.trim().length < 5,
7982
- onClick: () => y(),
8046
+ onClick: () => j(),
7983
8047
  variant: "default",
7984
8048
  className: "w-fit",
7985
8049
  size: "sm",
@@ -8008,7 +8072,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8008
8072
  AlertDialogAction,
8009
8073
  {
8010
8074
  onClick: () => {
8011
- a(""), y();
8075
+ a(""), j();
8012
8076
  },
8013
8077
  children: o("Yes, Delete")
8014
8078
  }
@@ -8029,7 +8093,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8029
8093
  /* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
8030
8094
  ] });
8031
8095
  }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: r = [], onAttributesChange: n }) {
8032
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [f, g] = useState(""), y = useRef(null), b = useRef(null);
8096
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [f, g] = useState(""), j = useRef(null), b = useRef(null);
8033
8097
  useEffect(() => {
8034
8098
  l(r);
8035
8099
  }, [r]);
@@ -8039,32 +8103,32 @@ const AIUserPrompt = ({ blockId: o }) => {
8039
8103
  return;
8040
8104
  }
8041
8105
  if (i) {
8042
- const S = [...a, { key: i, value: d }];
8043
- n(S), l(a), c(""), p(""), g("");
8106
+ const C = [...a, { key: i, value: d }];
8107
+ n(C), l(a), c(""), p(""), g("");
8044
8108
  }
8045
- }, j = (S) => {
8046
- const B = a.filter((I, T) => T !== S);
8047
- n(B), l(B);
8048
- }, v = (S) => {
8049
- x(S), c(a[S].key), p(a[S].value);
8050
- }, A = () => {
8109
+ }, y = (C) => {
8110
+ const v = a.filter((_, I) => I !== C);
8111
+ n(v), l(v);
8112
+ }, S = (C) => {
8113
+ x(C), c(a[C].key), p(a[C].value);
8114
+ }, B = () => {
8051
8115
  if (i.startsWith("@")) {
8052
8116
  g("Attribute keys cannot start with '@'");
8053
8117
  return;
8054
8118
  }
8055
8119
  if (u !== null && i) {
8056
- const S = [...a];
8057
- S[u] = { key: i, value: d }, n(S), l(S), x(null), c(""), p(""), g("");
8120
+ const C = [...a];
8121
+ C[u] = { key: i, value: d }, n(C), l(C), x(null), c(""), p(""), g("");
8058
8122
  }
8059
- }, w = (S) => {
8060
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? A() : h());
8123
+ }, A = (C) => {
8124
+ C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? B() : h());
8061
8125
  };
8062
8126
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
8063
8127
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
8064
8128
  "form",
8065
8129
  {
8066
- onSubmit: (S) => {
8067
- S.preventDefault(), u !== null ? A() : h();
8130
+ onSubmit: (C) => {
8131
+ C.preventDefault(), u !== null ? B() : h();
8068
8132
  },
8069
8133
  className: "space-y-3",
8070
8134
  children: [
@@ -8078,9 +8142,9 @@ const AIUserPrompt = ({ blockId: o }) => {
8078
8142
  autoCorrect: "off",
8079
8143
  spellCheck: "false",
8080
8144
  id: "attrKey",
8081
- ref: y,
8145
+ ref: j,
8082
8146
  value: i,
8083
- onChange: (S) => c(S.target.value),
8147
+ onChange: (C) => c(C.target.value),
8084
8148
  placeholder: "Enter Key",
8085
8149
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
8086
8150
  }
@@ -8098,8 +8162,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8098
8162
  rows: 2,
8099
8163
  ref: b,
8100
8164
  value: d,
8101
- onChange: (S) => p(S.target.value),
8102
- onKeyDown: w,
8165
+ onChange: (C) => p(C.target.value),
8166
+ onKeyDown: A,
8103
8167
  placeholder: "Enter Value",
8104
8168
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
8105
8169
  }
@@ -8111,16 +8175,16 @@ const AIUserPrompt = ({ blockId: o }) => {
8111
8175
  ]
8112
8176
  }
8113
8177
  ),
8114
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((S, B) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8178
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((C, v) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8115
8179
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8116
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
8117
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
8180
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
8181
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: C.value.toString() })
8118
8182
  ] }),
8119
8183
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8120
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(B), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
8121
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => j(B), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
8184
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(v), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
8185
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(v), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
8122
8186
  ] })
8123
- ] }, B)) })
8187
+ ] }, v)) })
8124
8188
  ] });
8125
8189
  }), BlockAttributesEditor = React.memo(() => {
8126
8190
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -8505,10 +8569,10 @@ const RootLayout = () => {
8505
8569
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
8506
8570
  r(1);
8507
8571
  });
8508
- const c = useBuilderProp("sideBarComponents.top", []), d = (y) => {
8509
- y.preventDefault();
8510
- }, p = (y) => {
8511
- r(o === y ? null : y);
8572
+ const c = useBuilderProp("sideBarComponents.top", []), d = (j) => {
8573
+ j.preventDefault();
8574
+ }, p = (j) => {
8575
+ r(o === j ? null : j);
8512
8576
  }, u = useSidebarMenuItems(), { t: x } = useTranslation(), f = [...u, ...c], g = useBuilderProp("htmlDir", "ltr");
8513
8577
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: g, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
8514
8578
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -8520,18 +8584,18 @@ const RootLayout = () => {
8520
8584
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TopBar, {}) }) }),
8521
8585
  /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
8522
8586
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
8523
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: f.map((y, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
8587
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: f.map((j, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
8524
8588
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8525
8589
  Button,
8526
8590
  {
8527
8591
  variant: o === b ? "default" : "ghost",
8528
8592
  className: "mb-2 rounded-lg p-2 transition-colors",
8529
8593
  onClick: () => p(b),
8530
- children: get(y, "icon", null)
8594
+ children: get(j, "icon", null)
8531
8595
  },
8532
8596
  b
8533
8597
  ) }),
8534
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: x(y.label) }) })
8598
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: x(j.label) }) })
8535
8599
  ] }, "button" + b)) }),
8536
8600
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" })
8537
8601
  ] }),
@@ -8734,5 +8798,6 @@ export {
8734
8798
  useUILibraryBlocks,
8735
8799
  useUndoManager,
8736
8800
  useUpdateBlocksProps,
8737
- useUpdateBlocksPropsRealtime
8801
+ useUpdateBlocksPropsRealtime,
8802
+ useWrapperBlock
8738
8803
  };