@solibo/solibo-ui 2.3.2 → 2.3.4

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.
Files changed (60) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index15.css +1 -1
  3. package/dist/assets/index2.css +1 -1
  4. package/dist/assets/index23.css +1 -1
  5. package/dist/assets/index26.css +1 -1
  6. package/dist/assets/index27.css +1 -1
  7. package/dist/assets/index29.css +1 -1
  8. package/dist/assets/index41.css +1 -1
  9. package/dist/assets/index43.css +1 -1
  10. package/dist/assets/index49.css +1 -1
  11. package/dist/assets/index52.css +1 -1
  12. package/dist/assets/index53.css +1 -1
  13. package/dist/assets/index55.css +1 -1
  14. package/dist/assets/index59.css +1 -1
  15. package/dist/components/app-link/index.cjs +1 -1
  16. package/dist/components/app-link/index.js +7 -7
  17. package/dist/components/badge/index.cjs +1 -1
  18. package/dist/components/badge/index.js +31 -31
  19. package/dist/components/banner/index.cjs +1 -1
  20. package/dist/components/banner/index.js +9 -9
  21. package/dist/components/branding/index.cjs +13 -2
  22. package/dist/components/branding/index.js +20 -8
  23. package/dist/components/button/index.cjs +1 -1
  24. package/dist/components/button/index.js +26 -26
  25. package/dist/components/dropdown/index.cjs +1 -1
  26. package/dist/components/dropdown/index.js +170 -177
  27. package/dist/components/editor/index.cjs +1 -1
  28. package/dist/components/editor/index.js +169 -169
  29. package/dist/components/form/index.cjs +1 -1
  30. package/dist/components/form/index.js +9 -9
  31. package/dist/components/icon/index.cjs +1 -1
  32. package/dist/components/icon/index.js +22 -22
  33. package/dist/components/input/index.cjs +1 -1
  34. package/dist/components/input/index.js +1 -1
  35. package/dist/components/link/index.cjs +1 -1
  36. package/dist/components/link/index.js +15 -15
  37. package/dist/components/nav/index.cjs +1 -1
  38. package/dist/components/nav/index.js +16 -16
  39. package/dist/components/portal/index.cjs +1 -1
  40. package/dist/components/portal/index.js +22 -21
  41. package/dist/components/search/index.cjs +1 -1
  42. package/dist/components/search/index.js +1 -1
  43. package/dist/components/select/index.cjs +1 -1
  44. package/dist/components/select/index.js +1 -1
  45. package/dist/components/widget/index.cjs +1 -1
  46. package/dist/components/widget/index.js +16 -16
  47. package/dist/index-CFMWBY53.cjs +1 -0
  48. package/dist/index-DBjIWUDE.cjs +1 -0
  49. package/dist/index-DJDY6iu6.js +48 -0
  50. package/dist/index-DO_phxRs.js +92 -0
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.d.ts +5 -3
  53. package/dist/index.js +2 -2
  54. package/dist/tokens.css +55 -55
  55. package/dist/tokens.json +258 -462
  56. package/package.json +1 -1
  57. package/dist/index-CWeknFzO.js +0 -74
  58. package/dist/index-Ct84TXGv.cjs +0 -1
  59. package/dist/index-D3gtJMYv.cjs +0 -1
  60. package/dist/index-DpkXKD1Z.js +0 -87
@@ -1,76 +1,76 @@
1
- import { jsxs as b, Fragment as it, jsx as l } from "react/jsx-runtime";
2
- import k from "classix";
3
- import rt, { Children as lt, isValidElement as F, useRef as _, useId as st, useState as D, useCallback as oe, useEffect as g } from "react";
4
- import { Button as j } from "../button/index.js";
5
- import { FieldError as at } from "../form/index.js";
6
- import { i as ot } from "../../icons-DtAsxlep.js";
7
- import { f as ct, I as dt } from "../../index-DpkXKD1Z.js";
8
- import { Label as ut } from "../label/index.js";
9
- import { List as ft } from "../list/index.js";
10
- import { Loading as Ve } from "../loading/index.js";
11
- import { S as pt, s as mt, r as ce } from "../../index-CWeknFzO.js";
12
- import '../../assets/index41.css';function K(t) {
13
- return typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(K).join(" ") : F(t) ? K(t.props.children) : "";
1
+ import { jsxs as b, Fragment as Ye, jsx as i } from "react/jsx-runtime";
2
+ import C from "classix";
3
+ import Ze, { Children as et, isValidElement as q, useRef as _, useId as tt, useState as D, useCallback as oe, useEffect as j } from "react";
4
+ import { Button as F } from "../button/index.js";
5
+ import { FieldError as nt } from "../form/index.js";
6
+ import { i as rt } from "../../icons-DtAsxlep.js";
7
+ import { f as lt, I as it } from "../../index-DO_phxRs.js";
8
+ import { Label as st } from "../label/index.js";
9
+ import { List as at } from "../list/index.js";
10
+ import { Loading as Ee } from "../loading/index.js";
11
+ import { S as ot, s as ct } from "../../index-DJDY6iu6.js";
12
+ import '../../assets/index41.css';function L(t) {
13
+ return typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(L).join(" ") : q(t) ? L(t.props.children) : "";
14
14
  }
15
- function bt(t) {
16
- return F(t) && t.type === "option";
15
+ function dt(t) {
16
+ return q(t) && t.type === "option";
17
17
  }
18
- function yt(t) {
19
- return F(t) && t.type === "optgroup";
18
+ function ut(t) {
19
+ return q(t) && t.type === "optgroup";
20
20
  }
21
- function _t(t) {
22
- return F(t) && t.type === rt.Fragment;
21
+ function ft(t) {
22
+ return q(t) && t.type === Ze.Fragment;
23
23
  }
24
- function vt(t) {
25
- return F(t) && t.type === pt;
24
+ function pt(t) {
25
+ return q(t) && t.type === ot;
26
26
  }
27
- function de(t, s, r = !1) {
27
+ function ce(t, s, l = !1) {
28
28
  const a = [];
29
- return lt.forEach(t, (n) => {
30
- if (_t(n))
31
- a.push(...de(n.props.children, s, r));
32
- else if (bt(n)) {
33
- const w = K(n.props.children).trim(), W = n.props.value != null ? String(n.props.value) : w;
29
+ return et.forEach(t, (n) => {
30
+ if (ft(n))
31
+ a.push(...ce(n.props.children, s, l));
32
+ else if (dt(n)) {
33
+ const g = L(n.props.children).trim(), z = n.props.value != null ? String(n.props.value) : g;
34
34
  a.push({
35
- disabled: r || !!n.props.disabled,
35
+ disabled: l || !!n.props.disabled,
36
36
  groupLabel: s,
37
37
  hidden: !!n.props.hidden,
38
- isPlaceholder: !!(n.props.hidden && W === ""),
38
+ isPlaceholder: !!(n.props.hidden && z === ""),
39
39
  label: n.props.children,
40
40
  selected: !!n.props.selected,
41
- text: w,
42
- value: W
41
+ text: g,
42
+ value: z
43
43
  });
44
- } else yt(n) && a.push(...de(n.props.children, n.props.label, r || !!n.props.disabled));
44
+ } else ut(n) && a.push(...ce(n.props.children, n.props.label, l || !!n.props.disabled));
45
45
  }), a;
46
46
  }
47
- function ht(t) {
47
+ function mt(t) {
48
48
  const s = t.trim();
49
49
  if (!s) return null;
50
50
  const a = [.../[*?]/.test(s) ? s : `*${s}*`].map((n) => n === "*" ? ".*" : n === "?" ? "." : n.replace(/[|\\{}()[\]^$+.,]/g, "\\$&")).join("");
51
51
  return new RegExp(`^${a}$`, "i");
52
52
  }
53
- function gt(t, s) {
54
- const r = ht(s), a = t.filter((n) => !n.hidden && !n.isPlaceholder);
55
- return r ? a.filter((n) => r.test([n.groupLabel, n.text, n.value].filter(Boolean).join(" "))) : a;
53
+ function bt(t, s) {
54
+ const l = mt(s), a = t.filter((n) => !n.hidden && !n.isPlaceholder);
55
+ return l ? a.filter((n) => l.test([n.groupLabel, n.text, n.value].filter(Boolean).join(" "))) : a;
56
56
  }
57
- function wt(t, s) {
58
- return t.find((r) => r.value === s) ?? t.find((r) => r.isPlaceholder) ?? t[0];
57
+ function ht(t, s) {
58
+ return t.find((l) => l.value === s) ?? t.find((l) => l.isPlaceholder) ?? t[0];
59
59
  }
60
- function qt(t, s, r) {
60
+ function _t(t, s, l) {
61
61
  var a, n;
62
- return s != null ? String(s) : r != null ? String(r) : ((a = t.find((w) => w.selected)) == null ? void 0 : a.value) ?? ((n = t[0]) == null ? void 0 : n.value) ?? "";
62
+ return s != null ? String(s) : l != null ? String(l) : ((a = t.find((g) => g.selected)) == null ? void 0 : a.value) ?? ((n = t[0]) == null ? void 0 : n.value) ?? "";
63
63
  }
64
- function St(t) {
65
- if (vt(t)) {
64
+ function vt(t) {
65
+ if (pt(t)) {
66
66
  const {
67
67
  children: s,
68
- placeholder: r,
68
+ placeholder: l,
69
69
  ...a
70
70
  } = t.props;
71
71
  return {
72
- children: /* @__PURE__ */ b(it, { children: [
73
- r && /* @__PURE__ */ l("option", { hidden: !0, value: "", children: r }),
72
+ children: /* @__PURE__ */ b(Ye, { children: [
73
+ l && /* @__PURE__ */ i("option", { hidden: !0, value: "", children: l }),
74
74
  s
75
75
  ] }),
76
76
  props: a
@@ -81,194 +81,187 @@ function St(t) {
81
81
  props: t.props
82
82
  };
83
83
  }
84
- const It = "_combobox_7iy0q_3", Nt = "_dropdown_7iy0q_21", xt = "_empty_7iy0q_29", Et = "_group_7iy0q_30", Ct = "_placeholder_7iy0q_31", Rt = "_filter_7iy0q_39", Vt = "_native_7iy0q_71", $t = "_option_7iy0q_81", Bt = "_options_7iy0q_107", kt = "_panel_7iy0q_117", Dt = "_selected_7iy0q_142", jt = "_text_7iy0q_146", Ft = "_trigger_7iy0q_154", Wt = "_minimal_7iy0q_199", zt = "_inline_7iy0q_259", Qt = "_field_7iy0q_293", Gt = "_label_7iy0q_297", i = {
85
- combobox: It,
86
- "combobox-input": "_combobox-input_7iy0q_12",
87
- dropdown: Nt,
88
- empty: xt,
89
- group: Et,
90
- placeholder: Ct,
91
- filter: Rt,
92
- "filter-controls": "_filter-controls_7iy0q_46",
93
- "loading-status": "_loading-status_7iy0q_57",
94
- native: Vt,
95
- option: $t,
96
- options: Bt,
97
- panel: kt,
98
- selected: Dt,
99
- text: jt,
100
- trigger: Ft,
101
- minimal: Wt,
102
- inline: zt,
103
- field: Qt,
104
- label: Gt,
105
- "inline-field": "_inline-field_7iy0q_302"
106
- };
107
- function $e(t, s) {
108
- return {
109
- "--icon-svg": ot(t, s)
110
- };
111
- }
112
- const Yt = ({
84
+ const yt = "_combobox_bnh5j_3", jt = "_dropdown_bnh5j_21", gt = "_empty_bnh5j_29", wt = "_group_bnh5j_30", St = "_placeholder_bnh5j_31", Nt = "_filter_bnh5j_39", It = "_native_bnh5j_71", xt = "_option_bnh5j_81", Et = "_options_bnh5j_107", Rt = "_panel_bnh5j_117", $t = "_selected_bnh5j_142", Bt = "_text_bnh5j_146", Vt = "_trigger_bnh5j_154", kt = "_minimal_bnh5j_200", Ct = "_inline_bnh5j_264", Dt = "_field_bnh5j_298", Ft = "_label_bnh5j_302", r = {
85
+ combobox: yt,
86
+ "combobox-input": "_combobox-input_bnh5j_12",
87
+ dropdown: jt,
88
+ empty: gt,
89
+ group: wt,
90
+ placeholder: St,
91
+ filter: Nt,
92
+ "filter-controls": "_filter-controls_bnh5j_46",
93
+ "loading-status": "_loading-status_bnh5j_57",
94
+ native: It,
95
+ option: xt,
96
+ options: Et,
97
+ panel: Rt,
98
+ selected: $t,
99
+ text: Bt,
100
+ trigger: Vt,
101
+ minimal: kt,
102
+ inline: Ct,
103
+ field: Dt,
104
+ label: Ft,
105
+ "inline-field": "_inline-field_bnh5j_307"
106
+ }, Ht = ({
113
107
  children: t,
114
108
  className: s,
115
- combobox: r = !1,
109
+ combobox: l = !1,
116
110
  description: a,
117
111
  errorMessage: n,
118
- invalid: w = !1,
119
- searchable: W,
120
- createOption: q,
121
- emptyLabel: Be = "No matches found",
112
+ invalid: g = !1,
113
+ searchable: z,
114
+ createOption: w,
115
+ emptyLabel: Re = "No matches found",
122
116
  errorLabel: p,
123
- onRetry: ue,
124
- retryLabel: ke = "Retry",
117
+ onRetry: de,
118
+ retryLabel: $e = "Retry",
125
119
  label: v,
126
- filterOptions: De = !0,
127
- hasNextPage: y = !1,
120
+ filterOptions: Be = !0,
121
+ hasNextPage: h = !1,
128
122
  loading: d = !1,
129
- loadingLabel: fe = "Loading",
130
- loadMoreLabel: je = "Load more",
123
+ loadingLabel: ue = "Loading",
124
+ loadMoreLabel: Ve = "Load more",
131
125
  onLoadMore: R,
132
- onOpenChange: z,
133
- onSearchChange: Q,
134
- searchValue: L,
126
+ onOpenChange: Q,
127
+ onSearchChange: W,
128
+ searchValue: M,
135
129
  renderOption: O,
136
130
  searchPlaceholder: T = "Filter",
137
- selectedItems: Fe,
138
- variant: S = "default",
139
- ...pe
131
+ selectedItems: ke,
132
+ variant: $ = "default",
133
+ ...fe
140
134
  }) => {
141
- const H = St(t), {
142
- defaultValue: We,
135
+ const H = vt(t), {
136
+ defaultValue: Ce,
143
137
  onChange: J,
144
138
  value: P,
145
- ...ze
146
- } = H.props, o = mt(ze), {
147
- className: Qe,
148
- ...Ge
149
- } = o, me = _(null), be = _(null), I = st(), U = w && n ? `${I}-error` : void 0, ye = a ? `${I}-description` : void 0, _e = [o["aria-describedby"], ye, U].filter(Boolean).join(" ") || void 0, ve = w ? !0 : o["aria-invalid"], he = _(null), N = _(null), X = _(null), ge = _(null), Y = _(!1), Z = _(!1), ee = _(R), we = !!R, x = de(H.children), V = P != null, te = qt(x, P, We), [ne, ie] = D(() => te), [c, Ae] = D(!1), [Me, qe] = D(!1), [Ke, Le] = D(null), [Oe, Te] = D(""), h = L ?? Oe, re = x.filter((e) => !e.hidden).length, He = Ke ?? (d || !!p || y || re > 8), E = W ?? (He || Me || h.length > 0), $ = oe((e) => {
150
- L === void 0 && Te(e), Q == null || Q(e);
151
- }, [Q, L]), m = oe((e) => {
152
- Y.current === e || e && o.disabled || (Y.current = e, Ae(e), z == null || z(e), e || $(""));
153
- }, [z, o.disabled, $]), G = V ? String(P) : ne, Se = {
154
- default: ce("--colors-semantic-content-secondary"),
155
- white: ce("--color-white", "white")
156
- }, Ie = o.disabled ? ce("--colors-semantic-content-disabled") : S === "minimal" ? Se.white : Se.default, A = wt(x, G), Je = $e("CaretDown", Ie), Pe = $e("MagnifyingGlass", Ie), le = gt(x, De ? h : ""), C = h.trim(), M = !!(r && q && C && q.isValid(C)), Ue = v && S === "inline" ? ct(v) : v, Ne = (e) => e ? (O == null ? void 0 : O({
139
+ ...De
140
+ } = H.props, o = ct(De), {
141
+ className: Fe,
142
+ ...qe
143
+ } = o, pe = _(null), me = _(null), S = tt(), U = g && n ? `${S}-error` : void 0, be = a ? `${S}-description` : void 0, he = [o["aria-describedby"], be, U].filter(Boolean).join(" ") || void 0, _e = g ? !0 : o["aria-invalid"], ve = _(null), N = _(null), X = _(null), ye = _(null), Y = _(!1), Z = _(!1), ee = _(R), je = !!R, I = ce(H.children), B = P != null, te = _t(I, P, Ce), [ne, re] = D(() => te), [c, ze] = D(!1), [Qe, ge] = D(!1), [We, Ae] = D(null), [Ge, Ke] = D(""), y = M ?? Ge, le = I.filter((e) => !e.hidden).length, Le = We ?? (d || !!p || h || le > 8), x = z ?? (Le || Qe || y.length > 0), V = oe((e) => {
144
+ M === void 0 && Ke(e), W == null || W(e);
145
+ }, [W, M]), m = oe((e) => {
146
+ Y.current === e || e && o.disabled || (Y.current = e, ze(e), Q == null || Q(e), e || V(""));
147
+ }, [Q, o.disabled, V]), A = B ? String(P) : ne, G = ht(I, A), Me = {
148
+ "--icon-svg": rt("CaretDown")
149
+ }, ie = bt(I, Be ? y : ""), E = y.trim(), K = !!(l && w && E && w.isValid(E)), Oe = v && $ === "inline" ? lt(v) : v, we = (e) => e ? (O == null ? void 0 : O({
157
150
  groupLabel: e.groupLabel,
158
- isSelected: e.value === G,
151
+ isSelected: e.value === A,
159
152
  label: e.label,
160
153
  text: e.text,
161
154
  value: e.value
162
155
  })) ?? e.label : "Select an option";
163
- g(() => {
164
- c && !h && !d && !p && Le(y || re > 8);
165
- }, [c, h, d, p, y, re]), g(() => {
166
- !V && !x.some((e) => e.value === ne) && ie(te);
167
- }, [te, ne, V, x]), g(() => {
168
- c ? E && qe(!0) : qe(!1);
169
- }, [c, E]), g(() => {
156
+ j(() => {
157
+ c && !y && !d && !p && Ae(h || le > 8);
158
+ }, [c, y, d, p, h, le]), j(() => {
159
+ !B && !I.some((e) => e.value === ne) && re(te);
160
+ }, [te, ne, B, I]), j(() => {
161
+ c ? x && ge(!0) : ge(!1);
162
+ }, [c, x]), j(() => {
170
163
  var e, u, f;
171
- c && (r || E ? (e = N.current) == null || e.focus() : (f = (u = X.current) == null ? void 0 : u.querySelector("button:not(:disabled)")) == null || f.focus());
172
- }, [c, r, E]), g(() => {
164
+ c && (l || x ? (e = N.current) == null || e.focus() : (f = (u = X.current) == null ? void 0 : u.querySelector("button:not(:disabled)")) == null || f.focus());
165
+ }, [c, l, x]), j(() => {
173
166
  if (!c)
174
167
  return;
175
168
  const e = (u) => {
176
169
  var f;
177
- (f = be.current) != null && f.contains(u.target) || m(!1);
170
+ (f = me.current) != null && f.contains(u.target) || m(!1);
178
171
  };
179
172
  return document.addEventListener("mousedown", e), () => {
180
173
  document.removeEventListener("mousedown", e);
181
174
  };
182
- }, [m, c]), g(() => {
175
+ }, [m, c]), j(() => {
183
176
  ee.current = R;
184
- }, [R]), g(() => {
177
+ }, [R]), j(() => {
185
178
  o.disabled && m(!1);
186
179
  }, [m, o.disabled]);
187
180
  const se = oe(() => {
188
- !Y.current || o.disabled || d || p || !y || !ee.current || Z.current || (Z.current = !0, ee.current());
189
- }, [p, y, d, o.disabled]);
190
- g(() => {
191
- if (Z.current = !1, !c || o.disabled || d || p || !y || !we) return;
192
- const e = ge.current, u = X.current;
181
+ !Y.current || o.disabled || d || p || !h || !ee.current || Z.current || (Z.current = !0, ee.current());
182
+ }, [p, h, d, o.disabled]);
183
+ j(() => {
184
+ if (Z.current = !1, !c || o.disabled || d || p || !h || !je) return;
185
+ const e = ye.current, u = X.current;
193
186
  if (!e || !u || typeof IntersectionObserver > "u") return;
194
187
  let f = !0;
195
- const B = new IntersectionObserver((tt) => {
196
- f && tt.some((nt) => nt.isIntersecting) && se();
188
+ const k = new IntersectionObserver((Ue) => {
189
+ f && Ue.some((Xe) => Xe.isIntersecting) && se();
197
190
  }, {
198
191
  root: u
199
192
  });
200
- return B.observe(e), () => {
201
- f = !1, B.disconnect();
193
+ return k.observe(e), () => {
194
+ f = !1, k.disconnect();
202
195
  };
203
- }, [c, d, p, y, we, se, le.length, h, o.disabled]);
204
- const Xe = (e) => {
205
- V || ie(e.target.value), J == null || J(e);
196
+ }, [c, d, p, h, je, se, ie.length, y, o.disabled]);
197
+ const Te = (e) => {
198
+ B || re(e.target.value), J == null || J(e);
206
199
  }, ae = () => {
207
200
  var e;
208
- m(!1), r || (e = me.current) == null || e.focus();
209
- }, xe = () => {
201
+ m(!1), l || (e = pe.current) == null || e.focus();
202
+ }, Se = () => {
210
203
  var e;
211
- $(""), m(!0), (e = N.current) == null || e.focus();
212
- }, Ee = () => {
213
- !q || !M || (q.onCreate(C), xe());
214
- }, Ye = (e) => {
215
- var B;
216
- V || ie(e);
217
- const u = he.current;
204
+ V(""), m(!0), (e = N.current) == null || e.focus();
205
+ }, Ne = () => {
206
+ !w || !K || (w.onCreate(E), Se());
207
+ }, He = (e) => {
208
+ var k;
209
+ B || re(e);
210
+ const u = ve.current;
218
211
  if (!u) {
219
212
  ae();
220
213
  return;
221
214
  }
222
- const f = (B = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")) == null ? void 0 : B.set;
215
+ const f = (k = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")) == null ? void 0 : k.set;
223
216
  f == null || f.call(u, e), u.dispatchEvent(new Event("change", {
224
217
  bubbles: !0
225
- })), r ? xe() : ae();
226
- }, Ze = (e) => {
227
- e.key === "Escape" && ae(), e.key === "Enter" && e.target === N.current && M && (e.preventDefault(), Ee());
228
- }, Ce = /* @__PURE__ */ l("div", { "aria-hidden": !d, "aria-label": fe, className: i["loading-status"], role: "status", children: d && /* @__PURE__ */ l(Ve, { size: "small" }) }), Re = /* @__PURE__ */ b("div", { className: k(i.dropdown, S === "inline" && i.inline, S === "minimal" && i.minimal, s), onKeyDown: Ze, ref: be, ...pe, children: [
229
- /* @__PURE__ */ l("select", { ...Ge, "aria-hidden": "true", className: k(i.native, Qe), onChange: Xe, ref: he, tabIndex: -1, value: G, children: H.children }),
230
- r ? /* @__PURE__ */ b("div", { className: i.combobox, onClick: () => {
218
+ })), l ? Se() : ae();
219
+ }, Je = (e) => {
220
+ e.key === "Escape" && ae(), e.key === "Enter" && e.target === N.current && K && (e.preventDefault(), Ne());
221
+ }, Ie = /* @__PURE__ */ i("div", { "aria-hidden": !d, "aria-label": ue, className: r["loading-status"], role: "status", children: d && /* @__PURE__ */ i(Ee, { size: "small" }) }), xe = /* @__PURE__ */ b("div", { className: C(r.dropdown, $ === "inline" && r.inline, $ === "minimal" && r.minimal, s), onKeyDown: Je, ref: me, ...fe, children: [
222
+ /* @__PURE__ */ i("select", { ...qe, "aria-hidden": "true", className: C(r.native, Fe), onChange: Te, ref: ve, tabIndex: -1, value: A, children: H.children }),
223
+ l ? /* @__PURE__ */ b("div", { className: r.combobox, onClick: () => {
231
224
  var e;
232
225
  return (e = N.current) == null ? void 0 : e.focus();
233
226
  }, children: [
234
- Fe,
235
- /* @__PURE__ */ l("input", { "aria-describedby": _e, "aria-invalid": ve, "aria-autocomplete": "list", "aria-expanded": c, "aria-label": o["aria-label"] ?? v ?? T, className: i["combobox-input"], disabled: o.disabled, onChange: (e) => {
236
- $(e.target.value), m(!0);
237
- }, onClick: () => m(!0), onFocus: () => m(!0), placeholder: T || void 0, ref: N, role: "combobox", type: "text", value: h }),
238
- Ce
239
- ] }) : /* @__PURE__ */ l(j, { "aria-describedby": _e, "aria-invalid": ve, "aria-label": v ? void 0 : o["aria-label"], "aria-expanded": c, "aria-haspopup": "dialog", "aria-labelledby": v ? `${I} ${I}-value` : void 0, className: k(i.trigger, (A == null ? void 0 : A.isPlaceholder) && i.placeholder), "data-open": c ? "true" : void 0, disabled: o.disabled, onClick: () => m(!c), ref: me, style: Je, variant: "simple", children: /* @__PURE__ */ l("span", { className: i.text, id: `${I}-value`, children: Ne(A) }) }),
240
- c && /* @__PURE__ */ b("div", { className: i.panel, children: [
241
- !r && E && /* @__PURE__ */ b("div", { className: i["filter-controls"], children: [
242
- /* @__PURE__ */ l(dt, { "aria-label": "Filter", className: i.filter, icon: "MagnifyingGlass", onChange: (e) => $(e.target.value), placeholder: T, ref: N, style: Pe, type: "search", value: h }),
243
- Ce
227
+ ke,
228
+ /* @__PURE__ */ i("input", { "aria-describedby": he, "aria-invalid": _e, "aria-autocomplete": "list", "aria-expanded": c, "aria-label": o["aria-label"] ?? v ?? T, className: r["combobox-input"], disabled: o.disabled, onChange: (e) => {
229
+ V(e.target.value), m(!0);
230
+ }, onClick: () => m(!0), onFocus: () => m(!0), placeholder: T || void 0, ref: N, role: "combobox", type: "text", value: y }),
231
+ Ie
232
+ ] }) : /* @__PURE__ */ i(F, { "aria-describedby": he, "aria-invalid": _e, "aria-label": v ? void 0 : o["aria-label"], "aria-expanded": c, "aria-haspopup": "dialog", "aria-labelledby": v ? `${S} ${S}-value` : void 0, className: C(r.trigger, (G == null ? void 0 : G.isPlaceholder) && r.placeholder), "data-open": c ? "true" : void 0, disabled: o.disabled, onClick: () => m(!c), ref: pe, style: Me, variant: "simple", children: /* @__PURE__ */ i("span", { className: r.text, id: `${S}-value`, children: we(G) }) }),
233
+ c && /* @__PURE__ */ b("div", { className: r.panel, children: [
234
+ !l && x && /* @__PURE__ */ b("div", { className: r["filter-controls"], children: [
235
+ /* @__PURE__ */ i(it, { "aria-label": "Filter", className: r.filter, icon: "MagnifyingGlass", onChange: (e) => V(e.target.value), placeholder: T, ref: N, type: "search", value: y }),
236
+ Ie
244
237
  ] }),
245
- /* @__PURE__ */ b(ft, { "aria-label": "Dropdown", "aria-busy": d || void 0, className: i.options, ref: X, children: [
246
- le.map((e) => {
247
- const u = e.value === G;
248
- return /* @__PURE__ */ l("li", { "data-component": "dropdown", children: /* @__PURE__ */ b(j, { "aria-label": u ? `${e.text}, selected` : e.text, className: k(i.option, u && i.selected), disabled: e.disabled, onClick: () => Ye(e.value), variant: "tertiary", children: [
249
- /* @__PURE__ */ l("span", { className: i.text, children: Ne(e) }),
250
- e.groupLabel && /* @__PURE__ */ l("small", { className: i.group, children: e.groupLabel })
238
+ /* @__PURE__ */ b(at, { "aria-label": "Dropdown", "aria-busy": d || void 0, className: r.options, ref: X, children: [
239
+ ie.map((e) => {
240
+ const u = e.value === A;
241
+ return /* @__PURE__ */ i("li", { "data-component": "dropdown", children: /* @__PURE__ */ b(F, { "aria-label": u ? `${e.text}, selected` : e.text, className: C(r.option, u && r.selected), disabled: e.disabled, onClick: () => He(e.value), variant: "tertiary", children: [
242
+ /* @__PURE__ */ i("span", { className: r.text, children: we(e) }),
243
+ e.groupLabel && /* @__PURE__ */ i("small", { className: r.group, children: e.groupLabel })
251
244
  ] }) }, `${e.groupLabel ?? "root"}-${e.value}`);
252
245
  }),
253
- M && q && /* @__PURE__ */ l("li", { children: /* @__PURE__ */ l(j, { "aria-label": K(q.render(C)) || C, className: i.option, onClick: Ee, variant: "tertiary", children: /* @__PURE__ */ l("span", { className: i.text, children: q.render(C) }) }) }),
254
- le.length === 0 && !M && !d && !p && !y && /* @__PURE__ */ l("li", { className: i.empty, children: Be }),
255
- p && /* @__PURE__ */ b("li", { className: i.empty, children: [
256
- /* @__PURE__ */ l("span", { role: "alert", children: p }),
257
- ue && /* @__PURE__ */ l(j, { disabled: d, onClick: ue, variant: "tertiary", children: ke })
246
+ K && w && /* @__PURE__ */ i("li", { children: /* @__PURE__ */ i(F, { "aria-label": L(w.render(E)) || E, className: r.option, onClick: Ne, variant: "tertiary", children: /* @__PURE__ */ i("span", { className: r.text, children: w.render(E) }) }) }),
247
+ ie.length === 0 && !K && !d && !p && !h && /* @__PURE__ */ i("li", { className: r.empty, children: Re }),
248
+ p && /* @__PURE__ */ b("li", { className: r.empty, children: [
249
+ /* @__PURE__ */ i("span", { role: "alert", children: p }),
250
+ de && /* @__PURE__ */ i(F, { disabled: d, onClick: de, variant: "tertiary", children: $e })
258
251
  ] }),
259
- d && !r && !E && /* @__PURE__ */ l("li", { "aria-label": fe, className: i.empty, role: "status", children: /* @__PURE__ */ l(Ve, { size: "small" }) }),
260
- y && R && !p && /* @__PURE__ */ l("li", { ref: ge, children: /* @__PURE__ */ l(j, { className: i.option, disabled: d, onClick: se, variant: "tertiary", children: je }) })
252
+ d && !l && !x && /* @__PURE__ */ i("li", { "aria-label": ue, className: r.empty, role: "status", children: /* @__PURE__ */ i(Ee, { size: "small" }) }),
253
+ h && R && !p && /* @__PURE__ */ i("li", { ref: ye, children: /* @__PURE__ */ i(F, { className: r.option, disabled: d, onClick: se, variant: "tertiary", children: Ve }) })
261
254
  ] })
262
255
  ] })
263
- ] }), et = v || a ? /* @__PURE__ */ b("div", { className: k(i.label, S === "inline" && i["inline-field"]), children: [
264
- /* @__PURE__ */ l(ut, { label: Ue, labelId: v ? I : void 0, description: a, descriptionId: ye, inline: S === "inline", required: pe.required }),
265
- Re
266
- ] }) : Re;
267
- return /* @__PURE__ */ b("div", { className: i.field, "data-component": "dropdown", children: [
268
- et,
269
- U && /* @__PURE__ */ l(at, { errorId: U, errorMessage: n })
256
+ ] }), Pe = v || a ? /* @__PURE__ */ b("div", { className: C(r.label, $ === "inline" && r["inline-field"]), children: [
257
+ /* @__PURE__ */ i(st, { label: Oe, labelId: v ? S : void 0, description: a, descriptionId: be, inline: $ === "inline", required: fe.required }),
258
+ xe
259
+ ] }) : xe;
260
+ return /* @__PURE__ */ b("div", { className: r.field, "data-component": "dropdown", children: [
261
+ Pe,
262
+ U && /* @__PURE__ */ i(nt, { errorId: U, errorMessage: n })
270
263
  ] });
271
264
  };
272
265
  export {
273
- Yt as Dropdown
266
+ Ht as Dropdown
274
267
  };
@@ -1 +1 @@
1
- "use strict";require('../../assets/index43.css');var be=Object.defineProperty;var Ie=(l,t,e)=>t in l?be(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var V=(l,t,e)=>Ie(l,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),fe=require("@lexical/html"),P=require("@lexical/link"),O=require("@lexical/list"),De=require("@lexical/react/LexicalAutoFocusPlugin"),Ce=require("@lexical/react/LexicalAutoLinkPlugin"),he=require("@lexical/react/LexicalComposerContext"),ye=require("@lexical/react/LexicalContentEditable"),Le=require("@lexical/react/LexicalErrorBoundary"),ke=require("@lexical/react/LexicalExtensionComposer"),ve=require("@lexical/react/LexicalHistoryPlugin"),we=require("@lexical/react/LexicalLinkPlugin"),Ne=require("@lexical/react/LexicalListPlugin"),Me=require("@lexical/react/LexicalOnChangePlugin"),Ae=require("@lexical/react/LexicalRichTextPlugin"),se=require("classix"),c=require("lexical"),s=require("react"),me=require("sanitize-html"),j=require("../button/index.cjs"),Se=require("../file/index.cjs"),R=require("../icon/index.cjs"),je=require("@lexical/utils"),_e=require("../../index-D3gtJMYv.cjs"),Re=require("../toolbar/index.cjs"),Te="_field_x93yd_3",Ee="_editor_x93yd_8",$e="_submit_x93yd_23",Pe="_resizable_x93yd_68",Oe="_resized_x93yd_72",Be="_invalid_x93yd_98",qe="_error_x93yd_102",Ue="_dragging_x93yd_108",ze="_content_x93yd_112",He="_embedded_x93yd_124",Fe="_files_x93yd_144",We="_placeholder_x93yd_154",Ke="_fill_x93yd_162",Ge="_meta_x93yd_194",Ye="_active_x93yd_203",Xe="_bold_x93yd_272",Ze="_italic_x93yd_276",Ve="_underline_x93yd_280",Je="_link_x93yd_284",Qe="_list_x93yd_290",et="_paragraph_x93yd_291",f={field:Te,editor:Ee,submit:$e,"image-resize-handle":"_image-resize-handle_x93yd_47","with-controls":"_with-controls_x93yd_53",resizable:Pe,resized:Oe,"resize-handle":"_resize-handle_x93yd_76",invalid:Be,error:qe,dragging:Ue,content:ze,embedded:He,"has-files":"_has-files_x93yd_140",files:Fe,placeholder:We,fill:Ke,"fill-editor":"_fill-editor_x93yd_170",meta:Ge,active:Ye,"inline-image":"_inline-image_x93yd_215",bold:Xe,italic:Ze,underline:Ve,link:Je,list:Qe,paragraph:et};function tt({alt:l="",editor:t,height:e,nodeKey:d,soliboDocumentId:p,soliboDocumentSlot:_,src:I,width:o}){const u=s.useRef(null),x=s.useRef(null),[A,L]=s.useState(),C=()=>{const a=t.getRootElement();if(!a)return 1/0;const m=getComputedStyle(a);return Math.max(1,a.clientWidth-(parseFloat(m.paddingLeft)||0)-(parseFloat(m.paddingRight)||0))},v=(a,m=C())=>Math.round(Math.min(m,Math.max(Math.min(32,m),a))),B=a=>{t.update(()=>{const m=c.$getNodeByKey(d);de(m)&&m.setWidth(a)}),L(void 0)};return i.jsxs("span",{className:f["inline-image"],contentEditable:!1,tabIndex:_?0:void 0,onKeyDown:a=>{!_||a.target!==a.currentTarget||!["Backspace","Delete"].includes(a.key)||(a.preventDefault(),a.stopPropagation(),t.update(()=>{const m=c.$getNodeByKey(d);if(!de(m))return;const D=m.getParent();c.$isParagraphNode(D)&&D.getChildrenSize()===1?D.remove():m.remove(),t.dispatchCommand(pe,_)}),t.focus())},"data-component":"editorimage",children:[i.jsx("img",{alt:l,"data-solibo-document-id":p,"data-solibo-document-slot":_,draggable:!1,height:A===void 0?e:void 0,ref:u,src:I,width:A??o,onClick:a=>{var m;a.preventDefault(),_&&((m=a.currentTarget.parentElement)==null||m.focus()),t.dispatchCommand(xe,{key:d,soliboDocumentSlot:_,src:I,width:o})}}),i.jsx("button",{type:"button","aria-label":`Resize image${l?`: ${l}`:""}`,title:"Drag to resize; use arrow keys to adjust width",className:f["image-resize-handle"],tabIndex:0,onClick:a=>{a.preventDefault(),a.stopPropagation()},onKeyDown:a=>{var D;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a.key))return;a.preventDefault(),a.stopPropagation();const m=((D=u.current)==null?void 0:D.getBoundingClientRect().width)??o??32;B(v(m+(["ArrowRight","ArrowUp"].includes(a.key)?10:-10)))},onPointerDown:a=>{a.button!==0||!u.current||(a.preventDefault(),a.stopPropagation(),a.currentTarget.focus({preventScroll:!0}),a.currentTarget.setPointerCapture(a.pointerId),x.current={pointerId:a.pointerId,x:a.clientX,width:u.current.getBoundingClientRect().width,maximum:C()})},onPointerMove:a=>{const m=x.current;!m||m.pointerId!==a.pointerId||L(v(m.width+a.clientX-m.x,m.maximum))},onPointerUp:a=>{const m=x.current;!m||m.pointerId!==a.pointerId||(x.current=null,B(v(m.width+a.clientX-m.x,m.maximum)),a.currentTarget.releasePointerCapture(a.pointerId))},onPointerCancel:()=>{x.current=null,L(void 0)},onLostPointerCapture:()=>{x.current=null,L(void 0)}})]})}const pe=c.createCommand(),xe=c.createCommand();class oe extends c.DecoratorNode{constructor(e,d,p,_,I,o,u){super(I);V(this,"__src");V(this,"__alt");V(this,"__width");V(this,"__height");V(this,"__soliboDocumentId");V(this,"__soliboDocumentSlot");this.__src=e,this.__alt=d,this.__width=p,this.__height=_,this.__soliboDocumentId=o,this.__soliboDocumentSlot=u}static getType(){return"image"}static clone(e){return new oe(e.__src,e.__alt,e.__width,e.__height,e.__key,e.__soliboDocumentId,e.__soliboDocumentSlot)}static importJSON(e){return ue({alt:e.alt,height:e.height,soliboDocumentId:e.soliboDocumentId,soliboDocumentSlot:e.soliboDocumentSlot,src:e.src,width:e.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:e=>({conversion:d=>{if(!(d instanceof HTMLImageElement))return null;const p=d.getAttribute("src")??"";if(!p)return null;const _=d.getAttribute("width"),I=d.getAttribute("height");return{node:ue({alt:d.getAttribute("alt")??"",height:I?Number(I):void 0,soliboDocumentId:d.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:d.getAttribute("data-solibo-document-slot")??void 0,src:p,width:_?Number(_):void 0})}},priority:0})}}exportDOM(){const e=document.createElement("img");return this.__soliboDocumentSlot||e.setAttribute("src",this.__src),this.__soliboDocumentId&&e.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&e.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&e.setAttribute("alt",this.__alt),this.__width&&e.setAttribute("width",String(this.__width)),this.__height&&e.setAttribute("height",String(this.__height)),{element:e}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(e){const d=this.getWritable();return d.__src=e,d}setWidth(e){const d=this.getWritable();return d.__width=e,d.__height=void 0,d}decorate(e){return i.jsx(tt,{alt:this.__alt,editor:e,height:this.__height,nodeKey:this.getKey(),soliboDocumentId:this.__soliboDocumentId,soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})}}function ue({alt:l="",height:t,soliboDocumentId:e,soliboDocumentSlot:d,src:p,width:_}){return c.$applyNodeReplacement(new oe(p,l,_,t,void 0,e,d))}function de(l){return l instanceof oe}const rt=({createImages:l,onRemove:t})=>{const[e]=he.useLexicalComposerContext();return s.useEffect(()=>e.registerCommand(pe,d=>(t(d),!0),c.COMMAND_PRIORITY_HIGH),[e,t]),s.useEffect(()=>e.registerCommand(c.PASTE_COMMAND,d=>{var o;if(!("clipboardData"in d))return!1;const p=d,_=Array.from(((o=p.clipboardData)==null?void 0:o.items)??[]).flatMap(u=>{if(u.kind!=="file"||!u.type.startsWith("image/"))return[];const x=u.getAsFile();return x?[x]:[]});if(_.length===0)return!1;p.preventDefault();const I=l(_);return e.update(()=>{c.$insertNodes(I.map(u=>ue(u)))}),!0},c.COMMAND_PRIORITY_HIGH),[l,e]),null},it=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,nt=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,st=[l=>{const t=it.exec(l);return t!=null&&t.length?{index:t.index,length:t[0].length,text:t[0],url:`mailto:${t[0]}`}:null},l=>{const t=nt.exec(l);return t!=null&&t.length?{index:t.index,length:t[0].length,text:t[0],url:t[0].startsWith("http")?t[0]:`https://${t[0]}`}:null}];function ge(l){try{const t=new URL(l);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ot({editableRef:l}){const t=s.useRef(null),[e,d]=s.useState(0),[p,_]=s.useState(0);s.useEffect(()=>{const o=l.current;if(!o)return;const u=()=>{d(Math.round(o.getBoundingClientRect().height)),_(Math.round(parseFloat(getComputedStyle(o).minHeight)||0))};if(u(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(u);return x.observe(o),()=>x.disconnect()},[l]);const I=o=>{const u=l.current;if(!u)return;const x=parseFloat(getComputedStyle(u).minHeight)||0;u.style.height=`${Math.max(x,o)}px`};return i.jsx("div",{"aria-label":"Resize editor","aria-orientation":"horizontal","aria-valuemin":p,"aria-valuenow":e,"aria-valuetext":`${e} pixels`,className:f["resize-handle"],role:"separator",tabIndex:0,onDoubleClick:()=>{var o;return(o=l.current)==null?void 0:o.style.removeProperty("height")},onKeyDown:o=>{const u=l.current;u&&(o.key==="Home"?(o.preventDefault(),u.style.removeProperty("height")):(o.key==="ArrowUp"||o.key==="ArrowDown")&&(o.preventDefault(),I(u.getBoundingClientRect().height+(o.key==="ArrowUp"?20:-20))))},onPointerDown:o=>{const u=l.current;o.button!==0||!u||(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}),o.currentTarget.setPointerCapture(o.pointerId),t.current={pointerId:o.pointerId,y:o.clientY,height:u.getBoundingClientRect().height})},onPointerMove:o=>{!t.current||t.current.pointerId!==o.pointerId||I(t.current.height+t.current.y-o.clientY)},onPointerUp:o=>{!t.current||t.current.pointerId!==o.pointerId||(t.current=null,o.currentTarget.releasePointerCapture(o.pointerId))},onLostPointerCapture:()=>{t.current=null},onPointerCancel:()=>{t.current=null},"data-component":"editorresizehandle"})}const at=({onFilesSelected:l,onInlineImageRemove:t})=>{const[e]=he.useLexicalComposerContext(),[d,p]=s.useState(!1),[_,I]=s.useState(!1),[o,u]=s.useState(!1),[x,A]=s.useState(!1),[L,C]=s.useState(!1),[v,B]=s.useState(!1),[a,m]=s.useState(""),[D,H]=s.useState(null),[q,F]=s.useState(null),[U,T]=s.useState(""),W=ge(U.trim()),re=s.useRef(null),J=s.useRef(null),ie=s.useRef(null),E=s.useRef(null),K=s.useRef(!1),Q=r=>r.preventDefault(),ee=s.useCallback(r=>{E.current=c.$isRangeSelection(r)?r.clone():null},[]),X=s.useCallback(r=>{e.update(()=>{E.current&&c.$setSelection(E.current),r()}),E.current=null},[e]),ae=r=>{K.current=!0,r.preventDefault()},Z=()=>{if(K.current){K.current=!1;return}k()},w=s.useCallback(()=>{I(!1),m(""),H(null),F(null)},[]),$=s.useCallback(()=>{C(!1),T("")},[]),le=s.useCallback(r=>{I(!0),m((r==null?void 0:r.src)??""),H((r==null?void 0:r.key)??null),F((r==null?void 0:r.soliboDocumentSlot)??null),$(),r!=null&&r.soliboDocumentSlot||setTimeout(()=>{var b;return(b=J.current)==null?void 0:b.focus()},0)},[$]),ce=s.useCallback(r=>{e.getEditorState().read(()=>{ee(c.$getSelection())}),C(!0),T(r),w(),setTimeout(()=>{var b;return(b=ie.current)==null?void 0:b.focus()},0)},[w,e,ee]),N=s.useCallback(()=>{const r=U.trim();ge(r)&&(X(()=>{e.dispatchCommand(P.TOGGLE_LINK_COMMAND,{url:r,target:"_blank"});const b=c.$getSelection();if(!c.$isRangeSelection(b))return;const M=b.getNodes().at(-1)??null,z=(M==null?void 0:M.getParent())??null,y=P.$isLinkNode(M)?M:P.$isLinkNode(z)?z:null;if(y){const n=y.getLastChild();if(c.$isTextNode(n)){const S=n.getTextContent(),ne=S.replace(/\s+$/,"");ne!==S&&n.setTextContent(ne)}const h=y.getNextSibling();if(c.$isTextNode(h)&&/^\s/.test(h.getTextContent())){h.select(1,1);return}const g=c.$createTextNode(" ");y.insertAfter(g),g.selectEnd()}}),$())},[$,e,U,X]),k=s.useCallback(()=>{const r=a.trim();if(!r){w();return}e.update(()=>{if(D){const b=c.$getNodeByKey(D);de(b)&&b.setSrc(r);return}c.$insertNodes([ue({src:r})])}),w()},[w,e,D,a]),G=s.useCallback(()=>{if(!D){w();return}e.update(()=>{const r=c.$getNodeByKey(D);if(de(r)){const b=r.getParent();c.$isParagraphNode(b)&&b.getChildrenSize()===1?b.remove():r.remove(),q&&(t==null||t(q))}}),w()},[w,e,D,q,t]),te=s.useCallback(()=>{X(()=>{e.dispatchCommand(P.TOGGLE_LINK_COMMAND,null)}),$()},[$,e,X]),Y=s.useCallback(()=>{const r=c.$getSelection();if(!c.$isRangeSelection(r)){if(c.$isNodeSelection(r)){const z=r.getNodes(),y=z[0]??null,n=(y==null?void 0:y.getParent())??null;p(z.some(g=>c.$isTextNode(g)&&g.hasFormat("bold"))),u(z.some(g=>c.$isTextNode(g)&&g.hasFormat("italic"))),A(z.some(g=>c.$isTextNode(g)&&g.hasFormat("underline"))),B(O.$isListNode(n)||O.$isListItemNode(n)||O.$isListNode(y)||O.$isListItemNode(y));const h=P.$isLinkNode(y)?y:P.$isLinkNode(n)?n:null;if(h){C(!0),T(h.getURL());return}C(!1),T(""),E.current=null;return}p(!1),u(!1),A(!1),B(!1),C(!1),T(""),E.current=null;return}const[b]=r.getNodes(),M=(b==null?void 0:b.getParent())??null;if(p(r.hasFormat("bold")),u(r.hasFormat("italic")),A(r.hasFormat("underline")),B(O.$isListNode(M)||O.$isListItemNode(M)),P.$isLinkNode(M)){C(!0),T(M.getURL()),ee(r);return}C(!1),T(""),E.current=null},[ee]);return s.useEffect(()=>je.mergeRegister(e.registerUpdateListener(({editorState:r})=>{r.read(()=>{Y()})}),e.registerCommand(xe,r=>(r.soliboDocumentSlot?(w(),$()):le(r),!0),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.SELECTION_CHANGE_COMMAND,()=>(e.getEditorState().read(()=>{Y()}),!1),c.COMMAND_PRIORITY_LOW)),[w,$,e,le,Y]),i.jsxs(Re.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[i.jsx(j.Button,{"aria-label":"Bold","data-active":d,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"bold")},title:"Bold",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextB"})}),i.jsx(j.Button,{"aria-label":"Italic","data-active":o,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"italic")},title:"Italic",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextItalic"})}),i.jsx(j.Button,{"aria-label":"Underline","data-active":x,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"underline")},title:"Underline",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextUnderline"})}),i.jsx(j.Button,{"aria-label":"List","data-active":v,onClick:()=>{v?e.dispatchCommand(O.REMOVE_LIST_COMMAND,void 0):e.dispatchCommand(O.INSERT_UNORDERED_LIST_COMMAND,void 0)},title:"List",variant:"tertiary",children:i.jsx(R.Icon,{name:"ListBullets"})}),i.jsx(j.Button,{"aria-label":"Link","data-active":L,onClick:()=>{L?ce(U):(e.dispatchCommand(P.TOGGLE_LINK_COMMAND,{url:"https://"}),ce("https://"))},title:"Link",variant:"tertiary",children:i.jsx(R.Icon,{name:"Link"})}),l&&i.jsxs(i.Fragment,{children:[i.jsx("input",{hidden:!0,multiple:!0,onChange:r=>{r.target.files&&l(r.target.files),r.target.value=""},ref:re,type:"file"}),i.jsx(j.Button,{"aria-label":"Upload files",onClick:()=>{var r;return(r=re.current)==null?void 0:r.click()},title:"Upload files",variant:"tertiary",children:i.jsx(R.Icon,{name:"Paperclip"})})]}),i.jsxs("div",{className:se(f.meta,L||_?f.active:""),children:[L&&i.jsxs(i.Fragment,{children:[i.jsx(_e.Input,{"aria-invalid":!W,onBlur:()=>N(),onChange:r=>T(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),N())},ref:ie,value:U}),i.jsx(j.Button,{"aria-label":"Apply link",disabled:!W,onClick:()=>{N()},onMouseDown:Q,variant:"tertiary",children:i.jsx(R.Icon,{name:"Check"})}),i.jsx(j.Button,{"aria-label":"Remove link",onClick:()=>te(),onMouseDown:Q,variant:"tertiary",children:i.jsx(R.Icon,{name:"Trash",variant:"danger"})})]}),_&&i.jsxs(i.Fragment,{children:[!q&&i.jsxs(i.Fragment,{children:[i.jsx(_e.Input,{className:se(f.active),onBlur:Z,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),K.current=!0,k())},ref:J,value:a}),i.jsx(j.Button,{"aria-label":"Apply image",onClick:()=>k(),onMouseDown:ae,variant:"tertiary",children:i.jsx(R.Icon,{name:"Check"})})]}),i.jsx(j.Button,{"aria-label":"Remove image",onClick:()=>G(),onMouseDown:ae,variant:"tertiary",children:i.jsx(R.Icon,{name:"Trash",variant:"danger"})})]})]})]})},lt=c.defineExtension({name:"solibo-editor",namespace:"Editor",nodes:[P.AutoLinkNode,P.LinkNode,O.ListNode,O.ListItemNode,oe],onError(l){throw l},theme:{link:f.link,list:{ol:f.list,ul:f.list},paragraph:f.paragraph,text:{bold:f.bold,italic:f.italic,underline:f.underline}}});function ct({autofocus:l,content:t="",sessionKey:e,lastEmittedContentRef:d,imagePreviews:p}){const[_]=he.useLexicalComposerContext(),I=s.useRef(e);return s.useEffect(()=>{const o=I.current!==e;I.current=e,!(!o&&d.current===t)&&(_.update(()=>{const x=new DOMParser().parseFromString(t,"text/html");x.querySelectorAll("img[data-solibo-document-slot]").forEach(C=>{const v=p.get(C.getAttribute("data-solibo-document-slot"));v&&C.setAttribute("src",v)});const A=fe.$generateNodesFromDOM(_,x),L=c.$getRoot();L.clear().select(),c.$insertNodes(A),l||o?L.selectEnd():c.$setSelection(null)},{discrete:!0}),o&&_.dispatchCommand(c.CLEAR_HISTORY_COMMAND,void 0))},[l,t,_,p,d,e]),null}const ut=({autofocus:l=!1,attachmentsEnabled:t=!0,sessionKey:e,autolink:d=!1,content:p,controls:_,disabled:I=!1,errorMessage:o,fill:u=!1,files:x,inline:A=!1,inlineImages:L,invalid:C=!1,isSubmitting:v=!1,maxRows:B=12,minRows:a=1,onChange:m,onFilesChange:D,onInlineImagesChange:H,onSubmit:q,onUpload:F,placeholder:U,required:T=!1,resizable:W=!1,submitLabel:re="Submit",variant:J="default"})=>{const ie=s.useId(),E=s.useRef(void 0),K=s.useRef(!1),Q=s.useRef(null),[ee,X]=s.useState(!1),[ae,Z]=s.useState(!1),[w,$]=s.useState([]),[le,ce]=s.useState([]),N=s.useRef(new Map),k=x??w,G=L??le;s.useEffect(()=>{const n=Q.current;if(!n)return;if(!W||u){n.style.removeProperty("height"),X(!1);return}const h=()=>X(n.style.height!==""),g=new MutationObserver(h);return g.observe(n,{attributes:!0,attributeFilter:["style"]}),h(),()=>g.disconnect()},[u,W]);const te=n=>{x===void 0&&$(n),D==null||D(n)},Y=s.useCallback(n=>{L===void 0&&ce(n),H==null||H(n)},[L,H]),r=s.useCallback(n=>{const h=n.map(g=>{const S=`pasted-${crypto.randomUUID()}`,ne=URL.createObjectURL(g);return N.current.set(S,ne),{image:{alt:g.name,soliboDocumentSlot:S,src:ne},pending:{file:g,slot:S}}});return Y([...G,...h.map(({pending:g})=>g)]),h.map(({image:g})=>g)},[G,Y]),b=s.useCallback(n=>{Y(G.filter(g=>g.slot!==n));const h=N.current.get(n);h&&URL.revokeObjectURL(h),N.current.delete(n)},[G,Y]);s.useEffect(()=>()=>{N.current.forEach(n=>URL.revokeObjectURL(n)),N.current.clear()},[]),s.useEffect(()=>{const n=new Set(G.map(h=>h.slot));N.current.forEach((h,g)=>{n.has(g)||(URL.revokeObjectURL(h),N.current.delete(g))})},[G]);const M=n=>{if(typeof DataTransfer<"u"){const h=new DataTransfer;return n.forEach(g=>h.items.add(g)),h.files}return Object.assign([...n],{item:h=>n[h]??null})},z=async()=>{if(!(I||v||K.current)){K.current=!0;try{t&&k.length>0&&await(F==null?void 0:F(M(k))),await(q==null?void 0:q()),t&&k.length>0&&te([])}catch{return}finally{K.current=!1}}},y=n=>{n.preventDefault(),n.stopPropagation()};return i.jsxs("div",{className:se(f.field,u&&f.fill),"data-max-rows":B,"data-min-rows":a,onDragEnter:n=>{y(n),Z(t&&!!D)},onDragOver:n=>{y(n),Z(t&&!!D)},onDragLeave:n=>{y(n),Z(!1)},onDropCapture:n=>{var g;const h=(g=n.dataTransfer)==null?void 0:g.files;h!=null&&h.length&&(y(n),t&&(D||F)&&te([...k,...Array.from(h)]),Z(!1))},onDrop:n=>{n.preventDefault(),Z(!1)},"data-component":"editor",children:[W==="top"&&!u&&i.jsx(ot,{editableRef:Q}),i.jsx("div",{className:se(f.editor,!!_&&f["with-controls"],J==="embedded"&&f.embedded,u&&f["fill-editor"],W===!0&&!u&&f.resizable,W&&!u&&ee&&f.resized,C&&f.invalid,k.length>0&&f["has-files"]),style:{"--editor-max-height":`calc(${B*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${a*1.25}em + (2 * var(--scale-8)))`},children:i.jsxs(ke.LexicalExtensionComposer,{contentEditable:null,extension:lt,children:[!A&&J!=="embedded"&&i.jsx(at,{onInlineImageRemove:t?b:void 0,onFilesSelected:t&&(F||D)?n=>{te([...k,...Array.from(n)])}:void 0}),i.jsx("div",{className:se(f.content,ae&&f.dragging),children:i.jsx(Ae.RichTextPlugin,{contentEditable:i.jsx(ye.ContentEditable,{ref:Q,"aria-placeholder":U??"",ariaErrorMessage:C&&o?ie:void 0,ariaInvalid:C||void 0,ariaRequired:T||void 0,placeholder:()=>U?i.jsx("div",{className:f.placeholder,children:U}):null}),ErrorBoundary:Le.LexicalErrorBoundary})}),!A&&J!=="embedded"&&(_||q)&&i.jsx("div",{className:f.submit,children:_??i.jsx(j.Button,{"aria-label":re,"data-cy":"toolbar-submit-button",disabled:I,icon:"PaperPlaneTilt",isLoading:v,onClick:()=>void z(),variant:"primary",children:i.jsx("span",{children:re})})}),t&&k.length>0&&i.jsx("div",{"aria-label":"Files to upload",className:f.files,role:"region",children:k.map((n,h)=>i.jsx(Se.File,{deleteAccessibleLabel:`Remove ${n.name} from upload queue`,name:n.name,onDelete:()=>te(k.filter((g,S)=>S!==h))},`${n.name}-${n.size}-${n.lastModified}-${h}`))}),l&&i.jsx(De.AutoFocusPlugin,{}),d&&i.jsx(Ce.AutoLinkPlugin,{matchers:st}),i.jsx(ve.HistoryPlugin,{}),t&&H&&i.jsx(rt,{createImages:r,onRemove:b}),p!==void 0&&i.jsx(ct,{autofocus:l,content:p,sessionKey:e,lastEmittedContentRef:E,imagePreviews:N.current}),i.jsx(we.LinkPlugin,{validateUrl:ge}),i.jsx(Ne.ListPlugin,{}),m&&i.jsx(Me.OnChangePlugin,{ignoreHistoryMergeTagChange:!1,onChange:(n,h)=>{n.read(()=>{const g=fe.$generateHtmlFromNodes(h,null),S=me(g,{allowedAttributes:{...me.defaults.allowedAttributes,img:[...me.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});E.current=S,m(S)})}})]})}),C&&o&&i.jsxs("div",{className:f.error,id:ie,children:[i.jsx(R.Icon,{name:"Warning",gap:"right",size:"small"}),o]})]})};exports.Editor=ut;
1
+ "use strict";require('../../assets/index43.css');var xe=Object.defineProperty;var ve=(l,t,e)=>t in l?xe(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var V=(l,t,e)=>ve(l,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),_e=require("@lexical/html"),P=require("@lexical/link"),O=require("@lexical/list"),Ie=require("@lexical/react/LexicalAutoFocusPlugin"),De=require("@lexical/react/LexicalAutoLinkPlugin"),fe=require("@lexical/react/LexicalComposerContext"),Ce=require("@lexical/react/LexicalContentEditable"),Le=require("@lexical/react/LexicalErrorBoundary"),ke=require("@lexical/react/LexicalExtensionComposer"),we=require("@lexical/react/LexicalHistoryPlugin"),Ne=require("@lexical/react/LexicalLinkPlugin"),Me=require("@lexical/react/LexicalListPlugin"),Ae=require("@lexical/react/LexicalOnChangePlugin"),Se=require("@lexical/react/LexicalRichTextPlugin"),se=require("classix"),c=require("lexical"),s=require("react"),he=require("sanitize-html"),y=require("../button/index.cjs"),je=require("../file/index.cjs"),R=require("../icon/index.cjs"),ye=require("@lexical/utils"),ge=require("../../index-DBjIWUDE.cjs"),Re=require("../toolbar/index.cjs"),Te="_field_1vfh5_3",Ee="_editor_1vfh5_8",$e="_submit_1vfh5_23",Pe="_resizable_1vfh5_68",Oe="_resized_1vfh5_72",Be="_invalid_1vfh5_98",qe="_error_1vfh5_102",Ue="_dragging_1vfh5_108",ze="_content_1vfh5_112",He="_embedded_1vfh5_124",Fe="_files_1vfh5_144",We="_placeholder_1vfh5_154",Ke="_fill_1vfh5_162",Ge="_meta_1vfh5_194",Ye="_active_1vfh5_203",Xe="_bold_1vfh5_272",Ze="_italic_1vfh5_276",Ve="_underline_1vfh5_280",Je="_link_1vfh5_284",Qe="_list_1vfh5_290",et="_paragraph_1vfh5_291",_={field:Te,editor:Ee,submit:$e,"image-resize-handle":"_image-resize-handle_1vfh5_47","with-controls":"_with-controls_1vfh5_53",resizable:Pe,resized:Oe,"resize-handle":"_resize-handle_1vfh5_76",invalid:Be,error:qe,dragging:Ue,content:ze,embedded:He,"has-files":"_has-files_1vfh5_140",files:Fe,placeholder:We,fill:Ke,"fill-editor":"_fill-editor_1vfh5_170",meta:Ge,active:Ye,"inline-image":"_inline-image_1vfh5_215",bold:Xe,italic:Ze,underline:Ve,link:Je,list:Qe,paragraph:et};function tt({alt:l="",editor:t,height:e,nodeKey:d,soliboDocumentId:p,soliboDocumentSlot:g,src:v,width:o}){const u=s.useRef(null),b=s.useRef(null),[S,L]=s.useState(),D=()=>{const a=t.getRootElement();if(!a)return 1/0;const h=getComputedStyle(a);return Math.max(1,a.clientWidth-(parseFloat(h.paddingLeft)||0)-(parseFloat(h.paddingRight)||0))},w=(a,h=D())=>Math.round(Math.min(h,Math.max(Math.min(32,h),a))),B=a=>{t.update(()=>{const h=c.$getNodeByKey(d);de(h)&&h.setWidth(a)}),L(void 0)};return i.jsxs("span",{className:_["inline-image"],contentEditable:!1,tabIndex:g?0:void 0,onKeyDown:a=>{!g||a.target!==a.currentTarget||!["Backspace","Delete"].includes(a.key)||(a.preventDefault(),a.stopPropagation(),t.update(()=>{const h=c.$getNodeByKey(d);if(!de(h))return;const I=h.getParent();c.$isParagraphNode(I)&&I.getChildrenSize()===1?I.remove():h.remove(),t.dispatchCommand(pe,g)}),t.focus())},"data-component":"editorimage",children:[i.jsx("img",{alt:l,"data-solibo-document-id":p,"data-solibo-document-slot":g,draggable:!1,height:S===void 0?e:void 0,ref:u,src:v,width:S??o,onClick:a=>{var h;a.preventDefault(),g&&((h=a.currentTarget.parentElement)==null||h.focus()),t.dispatchCommand(be,{key:d,soliboDocumentSlot:g,src:v,width:o})}}),i.jsx("button",{type:"button","aria-label":`Resize image${l?`: ${l}`:""}`,title:"Drag to resize; use arrow keys to adjust width",className:_["image-resize-handle"],tabIndex:0,onClick:a=>{a.preventDefault(),a.stopPropagation()},onKeyDown:a=>{var I;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a.key))return;a.preventDefault(),a.stopPropagation();const h=((I=u.current)==null?void 0:I.getBoundingClientRect().width)??o??32;B(w(h+(["ArrowRight","ArrowUp"].includes(a.key)?10:-10)))},onPointerDown:a=>{a.button!==0||!u.current||(a.preventDefault(),a.stopPropagation(),a.currentTarget.focus({preventScroll:!0}),a.currentTarget.setPointerCapture(a.pointerId),b.current={pointerId:a.pointerId,x:a.clientX,width:u.current.getBoundingClientRect().width,maximum:D()})},onPointerMove:a=>{const h=b.current;!h||h.pointerId!==a.pointerId||L(w(h.width+a.clientX-h.x,h.maximum))},onPointerUp:a=>{const h=b.current;!h||h.pointerId!==a.pointerId||(b.current=null,B(w(h.width+a.clientX-h.x,h.maximum)),a.currentTarget.releasePointerCapture(a.pointerId))},onPointerCancel:()=>{b.current=null,L(void 0)},onLostPointerCapture:()=>{b.current=null,L(void 0)}})]})}const pe=c.createCommand(),be=c.createCommand();class oe extends c.DecoratorNode{constructor(e,d,p,g,v,o,u){super(v);V(this,"__src");V(this,"__alt");V(this,"__width");V(this,"__height");V(this,"__soliboDocumentId");V(this,"__soliboDocumentSlot");this.__src=e,this.__alt=d,this.__width=p,this.__height=g,this.__soliboDocumentId=o,this.__soliboDocumentSlot=u}static getType(){return"image"}static clone(e){return new oe(e.__src,e.__alt,e.__width,e.__height,e.__key,e.__soliboDocumentId,e.__soliboDocumentSlot)}static importJSON(e){return ue({alt:e.alt,height:e.height,soliboDocumentId:e.soliboDocumentId,soliboDocumentSlot:e.soliboDocumentSlot,src:e.src,width:e.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:e=>({conversion:d=>{if(!(d instanceof HTMLImageElement))return null;const p=d.getAttribute("src")??"";if(!p)return null;const g=d.getAttribute("width"),v=d.getAttribute("height");return{node:ue({alt:d.getAttribute("alt")??"",height:v?Number(v):void 0,soliboDocumentId:d.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:d.getAttribute("data-solibo-document-slot")??void 0,src:p,width:g?Number(g):void 0})}},priority:0})}}exportDOM(){const e=document.createElement("img");return this.__soliboDocumentSlot||e.setAttribute("src",this.__src),this.__soliboDocumentId&&e.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&e.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&e.setAttribute("alt",this.__alt),this.__width&&e.setAttribute("width",String(this.__width)),this.__height&&e.setAttribute("height",String(this.__height)),{element:e}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(e){const d=this.getWritable();return d.__src=e,d}setWidth(e){const d=this.getWritable();return d.__width=e,d.__height=void 0,d}decorate(e){return i.jsx(tt,{alt:this.__alt,editor:e,height:this.__height,nodeKey:this.getKey(),soliboDocumentId:this.__soliboDocumentId,soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})}}function ue({alt:l="",height:t,soliboDocumentId:e,soliboDocumentSlot:d,src:p,width:g}){return c.$applyNodeReplacement(new oe(p,l,g,t,void 0,e,d))}function de(l){return l instanceof oe}const rt=({createImages:l,onRemove:t})=>{const[e]=fe.useLexicalComposerContext();return s.useEffect(()=>e.registerCommand(pe,d=>(t(d),!0),c.COMMAND_PRIORITY_HIGH),[e,t]),s.useEffect(()=>e.registerCommand(c.PASTE_COMMAND,d=>{var o;if(!("clipboardData"in d))return!1;const p=d,g=Array.from(((o=p.clipboardData)==null?void 0:o.items)??[]).flatMap(u=>{if(u.kind!=="file"||!u.type.startsWith("image/"))return[];const b=u.getAsFile();return b?[b]:[]});if(g.length===0)return!1;p.preventDefault();const v=l(g);return e.update(()=>{c.$insertNodes(v.map(u=>ue(u)))}),!0},c.COMMAND_PRIORITY_HIGH),[l,e]),null},it=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,nt=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,st=[l=>{const t=it.exec(l);return t!=null&&t.length?{index:t.index,length:t[0].length,text:t[0],url:`mailto:${t[0]}`}:null},l=>{const t=nt.exec(l);return t!=null&&t.length?{index:t.index,length:t[0].length,text:t[0],url:t[0].startsWith("http")?t[0]:`https://${t[0]}`}:null}];function me(l){try{const t=new URL(l);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ot({editableRef:l}){const t=s.useRef(null),[e,d]=s.useState(0),[p,g]=s.useState(0);s.useEffect(()=>{const o=l.current;if(!o)return;const u=()=>{d(Math.round(o.getBoundingClientRect().height)),g(Math.round(parseFloat(getComputedStyle(o).minHeight)||0))};if(u(),typeof ResizeObserver>"u")return;const b=new ResizeObserver(u);return b.observe(o),()=>b.disconnect()},[l]);const v=o=>{const u=l.current;if(!u)return;const b=parseFloat(getComputedStyle(u).minHeight)||0;u.style.height=`${Math.max(b,o)}px`};return i.jsx("div",{"aria-label":"Resize editor","aria-orientation":"horizontal","aria-valuemin":p,"aria-valuenow":e,"aria-valuetext":`${e} pixels`,className:_["resize-handle"],role:"separator",tabIndex:0,onDoubleClick:()=>{var o;return(o=l.current)==null?void 0:o.style.removeProperty("height")},onKeyDown:o=>{const u=l.current;u&&(o.key==="Home"?(o.preventDefault(),u.style.removeProperty("height")):(o.key==="ArrowUp"||o.key==="ArrowDown")&&(o.preventDefault(),v(u.getBoundingClientRect().height+(o.key==="ArrowUp"?20:-20))))},onPointerDown:o=>{const u=l.current;o.button!==0||!u||(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}),o.currentTarget.setPointerCapture(o.pointerId),t.current={pointerId:o.pointerId,y:o.clientY,height:u.getBoundingClientRect().height})},onPointerMove:o=>{!t.current||t.current.pointerId!==o.pointerId||v(t.current.height+t.current.y-o.clientY)},onPointerUp:o=>{!t.current||t.current.pointerId!==o.pointerId||(t.current=null,o.currentTarget.releasePointerCapture(o.pointerId))},onLostPointerCapture:()=>{t.current=null},onPointerCancel:()=>{t.current=null},"data-component":"editorresizehandle"})}const at=({onFilesSelected:l,onInlineImageRemove:t})=>{const[e]=fe.useLexicalComposerContext(),[d,p]=s.useState(!1),[g,v]=s.useState(!1),[o,u]=s.useState(!1),[b,S]=s.useState(!1),[L,D]=s.useState(!1),[w,B]=s.useState(!1),[a,h]=s.useState(""),[I,H]=s.useState(null),[q,F]=s.useState(null),[U,T]=s.useState(""),W=me(U.trim()),re=s.useRef(null),J=s.useRef(null),ie=s.useRef(null),E=s.useRef(null),K=s.useRef(!1),Q=r=>r.preventDefault(),ee=s.useCallback(r=>{E.current=c.$isRangeSelection(r)?r.clone():null},[]),X=s.useCallback(r=>{e.update(()=>{E.current&&c.$setSelection(E.current),r()}),E.current=null},[e]),ae=r=>{K.current=!0,r.preventDefault()},Z=()=>{if(K.current){K.current=!1;return}k()},N=s.useCallback(()=>{v(!1),h(""),H(null),F(null)},[]),$=s.useCallback(()=>{D(!1),T("")},[]),le=s.useCallback(r=>{v(!0),h((r==null?void 0:r.src)??""),H((r==null?void 0:r.key)??null),F((r==null?void 0:r.soliboDocumentSlot)??null),$(),r!=null&&r.soliboDocumentSlot||setTimeout(()=>{var x;return(x=J.current)==null?void 0:x.focus()},0)},[$]),ce=s.useCallback(r=>{e.getEditorState().read(()=>{ee(c.$getSelection())}),D(!0),T(r),N(),setTimeout(()=>{var x;return(x=ie.current)==null?void 0:x.focus()},0)},[N,e,ee]),M=s.useCallback(()=>{const r=U.trim();me(r)&&(X(()=>{e.dispatchCommand(P.TOGGLE_LINK_COMMAND,{url:r,target:"_blank"});const x=c.$getSelection();if(!c.$isRangeSelection(x))return;const A=x.getNodes().at(-1)??null,z=(A==null?void 0:A.getParent())??null,C=P.$isLinkNode(A)?A:P.$isLinkNode(z)?z:null;if(C){const n=C.getLastChild();if(c.$isTextNode(n)){const j=n.getTextContent(),ne=j.replace(/\s+$/,"");ne!==j&&n.setTextContent(ne)}const f=C.getNextSibling();if(c.$isTextNode(f)&&/^\s/.test(f.getTextContent())){f.select(1,1);return}const m=c.$createTextNode(" ");C.insertAfter(m),m.selectEnd()}}),$())},[$,e,U,X]),k=s.useCallback(()=>{const r=a.trim();if(!r){N();return}e.update(()=>{if(I){const x=c.$getNodeByKey(I);de(x)&&x.setSrc(r);return}c.$insertNodes([ue({src:r})])}),N()},[N,e,I,a]),G=s.useCallback(()=>{if(!I){N();return}e.update(()=>{const r=c.$getNodeByKey(I);if(de(r)){const x=r.getParent();c.$isParagraphNode(x)&&x.getChildrenSize()===1?x.remove():r.remove(),q&&(t==null||t(q))}}),N()},[N,e,I,q,t]),te=s.useCallback(()=>{X(()=>{e.dispatchCommand(P.TOGGLE_LINK_COMMAND,null)}),$()},[$,e,X]),Y=s.useCallback(()=>{const r=c.$getSelection();if(!c.$isRangeSelection(r)){if(c.$isNodeSelection(r)){const z=r.getNodes(),C=z[0]??null,n=(C==null?void 0:C.getParent())??null;p(z.some(m=>c.$isTextNode(m)&&m.hasFormat("bold"))),u(z.some(m=>c.$isTextNode(m)&&m.hasFormat("italic"))),S(z.some(m=>c.$isTextNode(m)&&m.hasFormat("underline"))),B(O.$isListNode(n)||O.$isListItemNode(n)||O.$isListNode(C)||O.$isListItemNode(C));const f=P.$isLinkNode(C)?C:P.$isLinkNode(n)?n:null;if(f){D(!0),T(f.getURL());return}D(!1),T(""),E.current=null;return}p(!1),u(!1),S(!1),B(!1),D(!1),T(""),E.current=null;return}const[x]=r.getNodes(),A=(x==null?void 0:x.getParent())??null;if(p(r.hasFormat("bold")),u(r.hasFormat("italic")),S(r.hasFormat("underline")),B(O.$isListNode(A)||O.$isListItemNode(A)),P.$isLinkNode(A)){D(!0),T(A.getURL()),ee(r);return}D(!1),T(""),E.current=null},[ee]);return s.useEffect(()=>ye.mergeRegister(e.registerUpdateListener(({editorState:r})=>{r.read(()=>{Y()})}),e.registerCommand(be,r=>(r.soliboDocumentSlot?(N(),$()):le(r),!0),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.SELECTION_CHANGE_COMMAND,()=>(e.getEditorState().read(()=>{Y()}),!1),c.COMMAND_PRIORITY_LOW)),[N,$,e,le,Y]),i.jsxs(Re.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[i.jsx(y.Button,{"aria-label":"Bold","data-active":d,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"bold")},title:"Bold",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextB"})}),i.jsx(y.Button,{"aria-label":"Italic","data-active":o,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"italic")},title:"Italic",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextItalic"})}),i.jsx(y.Button,{"aria-label":"Underline","data-active":b,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"underline")},title:"Underline",variant:"tertiary",children:i.jsx(R.Icon,{name:"TextUnderline"})}),i.jsx(y.Button,{"aria-label":"List","data-active":w,onClick:()=>{w?e.dispatchCommand(O.REMOVE_LIST_COMMAND,void 0):e.dispatchCommand(O.INSERT_UNORDERED_LIST_COMMAND,void 0)},title:"List",variant:"tertiary",children:i.jsx(R.Icon,{name:"ListBullets"})}),i.jsx(y.Button,{"aria-label":"Link","data-active":L,onClick:()=>{L?ce(U):(e.dispatchCommand(P.TOGGLE_LINK_COMMAND,{url:"https://"}),ce("https://"))},title:"Link",variant:"tertiary",children:i.jsx(R.Icon,{name:"Link"})}),l&&i.jsxs(i.Fragment,{children:[i.jsx("input",{hidden:!0,multiple:!0,onChange:r=>{r.target.files&&l(r.target.files),r.target.value=""},ref:re,type:"file"}),i.jsx(y.Button,{"aria-label":"Upload files",onClick:()=>{var r;return(r=re.current)==null?void 0:r.click()},title:"Upload files",variant:"tertiary",children:i.jsx(R.Icon,{name:"Paperclip"})})]}),i.jsxs("div",{className:se(_.meta,L||g?_.active:""),children:[L&&i.jsxs(i.Fragment,{children:[i.jsx(ge.Input,{"aria-invalid":!W,onBlur:()=>M(),onChange:r=>T(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),M())},ref:ie,value:U}),i.jsx(y.Button,{"aria-label":"Apply link",disabled:!W,onClick:()=>{M()},onMouseDown:Q,variant:"tertiary",children:i.jsx(R.Icon,{name:"Check"})}),i.jsx(y.Button,{"aria-label":"Remove link",onClick:()=>te(),onMouseDown:Q,variant:"tertiary",children:i.jsx(R.Icon,{name:"Trash",variant:"danger"})})]}),g&&i.jsxs(i.Fragment,{children:[!q&&i.jsxs(i.Fragment,{children:[i.jsx(ge.Input,{className:se(_.active),onBlur:Z,onChange:r=>h(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),K.current=!0,k())},ref:J,value:a}),i.jsx(y.Button,{"aria-label":"Apply image",onClick:()=>k(),onMouseDown:ae,variant:"tertiary",children:i.jsx(R.Icon,{name:"Check"})})]}),i.jsx(y.Button,{"aria-label":"Remove image",onClick:()=>G(),onMouseDown:ae,variant:"tertiary",children:i.jsx(R.Icon,{name:"Trash",variant:"danger"})})]})]})]})},lt=c.defineExtension({name:"solibo-editor",namespace:"Editor",nodes:[P.AutoLinkNode,P.LinkNode,O.ListNode,O.ListItemNode,oe],onError(l){throw l},theme:{link:_.link,list:{ol:_.list,ul:_.list},paragraph:_.paragraph,text:{bold:_.bold,italic:_.italic,underline:_.underline}}});function ct({autofocus:l,content:t="",sessionKey:e,lastEmittedContentRef:d,imagePreviews:p}){const[g]=fe.useLexicalComposerContext(),v=s.useRef(e);return s.useEffect(()=>{const o=v.current!==e;v.current=e,!(!o&&d.current===t)&&(g.update(()=>{const b=new DOMParser().parseFromString(t,"text/html");b.querySelectorAll("img[data-solibo-document-slot]").forEach(D=>{const w=p.get(D.getAttribute("data-solibo-document-slot"));w&&D.setAttribute("src",w)});const S=_e.$generateNodesFromDOM(g,b),L=c.$getRoot();L.clear().select(),c.$insertNodes(S),l||o?L.selectEnd():c.$setSelection(null)},{discrete:!0}),o&&g.dispatchCommand(c.CLEAR_HISTORY_COMMAND,void 0))},[l,t,g,p,d,e]),null}const ut=({autofocus:l=!1,attachmentsEnabled:t=!0,sessionKey:e,autolink:d=!1,content:p,controls:g,disabled:v=!1,errorMessage:o,fill:u=!1,files:b,inline:S=!1,inlineImages:L,invalid:D=!1,isSubmitting:w=!1,maxRows:B=12,minRows:a=1,onChange:h,onFilesChange:I,onInlineImagesChange:H,onSubmit:q,onUpload:F,placeholder:U,required:T=!1,resizable:W=!1,submitLabel:re="Submit",variant:J="default"})=>{const ie=s.useId(),E=s.useRef(void 0),K=s.useRef(!1),Q=s.useRef(null),[ee,X]=s.useState(!1),[ae,Z]=s.useState(!1),[N,$]=s.useState([]),[le,ce]=s.useState([]),M=s.useRef(new Map),k=b??N,G=L??le;s.useEffect(()=>{const n=Q.current;if(!n)return;if(!W||u){n.style.removeProperty("height"),X(!1);return}const f=()=>X(n.style.height!==""),m=new MutationObserver(f);return m.observe(n,{attributes:!0,attributeFilter:["style"]}),f(),()=>m.disconnect()},[u,W]);const te=n=>{b===void 0&&$(n),I==null||I(n)},Y=s.useCallback(n=>{L===void 0&&ce(n),H==null||H(n)},[L,H]),r=s.useCallback(n=>{const f=n.map(m=>{const j=`pasted-${crypto.randomUUID()}`,ne=URL.createObjectURL(m);return M.current.set(j,ne),{image:{alt:m.name,soliboDocumentSlot:j,src:ne},pending:{file:m,slot:j}}});return Y([...G,...f.map(({pending:m})=>m)]),f.map(({image:m})=>m)},[G,Y]),x=s.useCallback(n=>{Y(G.filter(m=>m.slot!==n));const f=M.current.get(n);f&&URL.revokeObjectURL(f),M.current.delete(n)},[G,Y]);s.useEffect(()=>()=>{M.current.forEach(n=>URL.revokeObjectURL(n)),M.current.clear()},[]),s.useEffect(()=>{const n=new Set(G.map(f=>f.slot));M.current.forEach((f,m)=>{n.has(m)||(URL.revokeObjectURL(f),M.current.delete(m))})},[G]);const A=n=>{if(typeof DataTransfer<"u"){const f=new DataTransfer;return n.forEach(m=>f.items.add(m)),f.files}return Object.assign([...n],{item:f=>n[f]??null})},z=async()=>{if(!(v||w||K.current)){K.current=!0;try{t&&k.length>0&&await(F==null?void 0:F(A(k))),await(q==null?void 0:q()),t&&k.length>0&&te([])}catch{return}finally{K.current=!1}}},C=n=>{n.preventDefault(),n.stopPropagation()};return i.jsxs("div",{className:se(_.field,u&&_.fill),"data-max-rows":B,"data-min-rows":a,onDragEnter:n=>{C(n),Z(t&&!!I)},onDragOver:n=>{C(n),Z(t&&!!I)},onDragLeave:n=>{C(n),Z(!1)},onDropCapture:n=>{var m;const f=(m=n.dataTransfer)==null?void 0:m.files;f!=null&&f.length&&(C(n),t&&(I||F)&&te([...k,...Array.from(f)]),Z(!1))},onDrop:n=>{n.preventDefault(),Z(!1)},"data-component":"editor",children:[W==="top"&&!u&&i.jsx(ot,{editableRef:Q}),i.jsx("div",{className:se(_.editor,!!g&&_["with-controls"],J==="embedded"&&_.embedded,u&&_["fill-editor"],W===!0&&!u&&_.resizable,W&&!u&&ee&&_.resized,D&&_.invalid,k.length>0&&_["has-files"]),style:{"--editor-max-height":`calc(${B*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${a*1.25}em + (2 * var(--scale-8)))`},children:i.jsxs(ke.LexicalExtensionComposer,{contentEditable:null,extension:lt,children:[!S&&J!=="embedded"&&i.jsx(at,{onInlineImageRemove:t?x:void 0,onFilesSelected:t&&(F||I)?n=>{te([...k,...Array.from(n)])}:void 0}),i.jsx("div",{className:se(_.content,ae&&_.dragging),children:i.jsx(Se.RichTextPlugin,{contentEditable:i.jsx(Ce.ContentEditable,{ref:Q,"aria-placeholder":U??"",ariaErrorMessage:D&&o?ie:void 0,ariaInvalid:D||void 0,ariaRequired:T||void 0,placeholder:()=>U?i.jsx("div",{className:_.placeholder,children:U}):null}),ErrorBoundary:Le.LexicalErrorBoundary})}),!S&&J!=="embedded"&&(g||q)&&i.jsx("div",{className:_.submit,children:g??i.jsx(y.Button,{"aria-label":re,"data-cy":"toolbar-submit-button",disabled:v,icon:"PaperPlaneTilt",isLoading:w,onClick:()=>void z(),variant:"primary",children:i.jsx("span",{children:re})})}),t&&k.length>0&&i.jsx("div",{"aria-label":"Files to upload",className:_.files,role:"region",children:k.map((n,f)=>i.jsx(je.File,{deleteAccessibleLabel:`Remove ${n.name} from upload queue`,name:n.name,onDelete:()=>te(k.filter((m,j)=>j!==f))},`${n.name}-${n.size}-${n.lastModified}-${f}`))}),l&&i.jsx(Ie.AutoFocusPlugin,{}),d&&i.jsx(De.AutoLinkPlugin,{matchers:st}),i.jsx(we.HistoryPlugin,{}),t&&H&&i.jsx(rt,{createImages:r,onRemove:x}),p!==void 0&&i.jsx(ct,{autofocus:l,content:p,sessionKey:e,lastEmittedContentRef:E,imagePreviews:M.current}),i.jsx(Ne.LinkPlugin,{validateUrl:me}),i.jsx(Me.ListPlugin,{}),h&&i.jsx(Ae.OnChangePlugin,{ignoreHistoryMergeTagChange:!1,onChange:(n,f)=>{n.read(()=>{const m=_e.$generateHtmlFromNodes(f,null),j=he(m,{allowedAttributes:{...he.defaults.allowedAttributes,img:[...he.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});E.current=j,h(j)})}})]})}),D&&o&&i.jsxs("div",{className:_.error,id:ie,children:[i.jsx(R.Icon,{name:"Warning",gap:"right",size:"small"}),o]})]})};exports.Editor=ut;