cosmic-ai-input 1.0.13 → 1.0.15

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/index.es.js CHANGED
@@ -1,38 +1,38 @@
1
- // Generated at: 2026-03-10T07:58:48.343Z
2
- import { jsx as u, jsxs as Y } from "react/jsx-runtime";
3
- import { forwardRef as j, useState as L, useRef as F, useEffect as M, useCallback as Pe, useImperativeHandle as lt } from "react";
4
- import Se from "classnames";
5
- import { createPortal as ot } from "react-dom";
1
+ // Generated at: 2026-04-03T02:03:21.169Z
2
+ import { jsx as u, jsxs as te } from "react/jsx-runtime";
3
+ import { forwardRef as j, useState as L, useRef as O, useEffect as M, useCallback as Pe, useImperativeHandle as ot } from "react";
4
+ import De from "classnames";
5
+ import { createPortal as st } from "react-dom";
6
6
  var h = /* @__PURE__ */ ((r) => (r.INPUT = "input", r.SELECT = "select", r.MULTIPLE_SELECT = "multiple-select", r.DATE_PICKER = "date-picker", r.LABEL = "label", r))(h || {});
7
7
  const $e = j(
8
8
  ({ value: r, position: s, id: o, onChange: f }, k) => {
9
- const [w, g] = L(!0), $ = F(null), D = F(null);
9
+ const [C, E] = L(!0), $ = O(null), N = O(null);
10
10
  M(() => {
11
11
  typeof k == "function" ? k($.current) : k && (k.current = $.current);
12
12
  }, [k]);
13
13
  const T = (p) => {
14
- const y = p.target.value;
15
- f == null || f(y, h.DATE_PICKER);
14
+ const g = p.target.value;
15
+ f == null || f(g, h.DATE_PICKER);
16
16
  };
17
17
  M(() => {
18
- if (D.current)
18
+ if (N.current)
19
19
  try {
20
20
  setTimeout(() => {
21
- N();
21
+ S();
22
22
  }, 100);
23
23
  } catch {
24
24
  }
25
25
  }, []);
26
- const N = () => {
27
- if (D.current)
26
+ const S = () => {
27
+ if (N.current)
28
28
  try {
29
- D.current.showPicker();
29
+ N.current.showPicker();
30
30
  } catch {
31
31
  }
32
32
  }, A = (p) => {
33
33
  p.stopPropagation();
34
34
  };
35
- return w ? /* @__PURE__ */ u(
35
+ return C ? /* @__PURE__ */ u(
36
36
  "div",
37
37
  {
38
38
  ref: $,
@@ -46,7 +46,7 @@ const $e = j(
46
46
  children: /* @__PURE__ */ u(
47
47
  "input",
48
48
  {
49
- ref: D,
49
+ ref: N,
50
50
  type: "date",
51
51
  value: r || "",
52
52
  onChange: T,
@@ -58,11 +58,11 @@ const $e = j(
58
58
  }
59
59
  );
60
60
  $e.displayName = "DatePicker";
61
- function fe(r) {
61
+ function he(r) {
62
62
  const s = r.textContent || "", o = r.nextSibling;
63
63
  s.length ? (o == null || o.setAttribute("style", "display: none"), r.style.padding = "2px 4px", r.style.borderTopLeftRadius = "2px", r.style.borderBottomLeftRadius = "2px", r.style.borderTopRightRadius = "2px", r.style.borderBottomRightRadius = "2px") : (o == null || o.setAttribute("style", "display: inline"), r.style.padding = "2px 0 2px 4px", r.style.borderTopLeftRadius = "2px", r.style.borderBottomLeftRadius = "2px", r.style.borderTopRightRadius = "0", r.style.borderBottomRightRadius = "0");
64
64
  }
65
- function V(r) {
65
+ function q(r) {
66
66
  if (r && r.getAttribute("data-set-type") === "input") {
67
67
  const s = r.children[0];
68
68
  s.setAttribute("contenteditable", "true"), requestAnimationFrame(() => {
@@ -70,7 +70,7 @@ function V(r) {
70
70
  });
71
71
  }
72
72
  }
73
- function Ne(r) {
73
+ function Se(r) {
74
74
  r && r.getAttribute("data-set-type") === "input" && r.children[0].setAttribute("contenteditable", "false");
75
75
  }
76
76
  function _(r) {
@@ -82,16 +82,16 @@ const Be = j(({
82
82
  position: o,
83
83
  id: f,
84
84
  height: k = 37,
85
- onChange: w
86
- }, g) => {
87
- const [$, D] = L(s || ""), T = F(null);
85
+ onChange: C
86
+ }, E) => {
87
+ const [$, N] = L(s || ""), T = O(null);
88
88
  M(() => {
89
- typeof g == "function" ? g(T.current) : g && (g.current = T.current);
90
- }, [g]);
91
- const N = (p) => {
92
- const y = $.split(",").filter((E) => E) || [];
89
+ typeof E == "function" ? E(T.current) : E && (E.current = T.current);
90
+ }, [E]);
91
+ const S = (p) => {
92
+ const g = $.split(",").filter((y) => y) || [];
93
93
  let b = "";
94
- y.includes(p) ? b = y.filter((E) => E !== p).join(",") : y.length ? b = `${y.join(",")},${p}` : b = p, D(b), w == null || w(b, h.MULTIPLE_SELECT);
94
+ g.includes(p) ? b = g.filter((y) => y !== p).join(",") : g.length ? b = `${g.join(",")},${p}` : b = p, N(b), C == null || C(b, h.MULTIPLE_SELECT);
95
95
  }, A = $.split(",") || [];
96
96
  return /* @__PURE__ */ u(
97
97
  "div",
@@ -106,14 +106,14 @@ const Be = j(({
106
106
  zIndex: 5e3,
107
107
  maxHeight: `${k}px`
108
108
  },
109
- children: r.map((p, y) => /* @__PURE__ */ u(
109
+ children: r.map((p, g) => /* @__PURE__ */ u(
110
110
  "div",
111
111
  {
112
112
  className: `selectOption ${A.includes(p) ? "selected" : ""}`,
113
- onClick: () => N(p),
113
+ onClick: () => S(p),
114
114
  children: p
115
115
  },
116
- y
116
+ g
117
117
  ))
118
118
  }
119
119
  );
@@ -125,14 +125,14 @@ const Me = j(({
125
125
  position: o,
126
126
  id: f,
127
127
  height: k = 120,
128
- onChange: w
129
- }, g) => {
130
- const [$, D] = L(s || ""), T = F(null);
128
+ onChange: C
129
+ }, E) => {
130
+ const [$, N] = L(s || ""), T = O(null);
131
131
  M(() => {
132
- typeof g == "function" ? g(T.current) : g && (g.current = T.current);
133
- }, [g]);
134
- const N = (A) => {
135
- D(A), w == null || w(A, h.SELECT);
132
+ typeof E == "function" ? E(T.current) : E && (E.current = T.current);
133
+ }, [E]);
134
+ const S = (A) => {
135
+ N(A), C == null || C(A, h.SELECT);
136
136
  };
137
137
  return /* @__PURE__ */ u(
138
138
  "div",
@@ -151,7 +151,7 @@ const Me = j(({
151
151
  "div",
152
152
  {
153
153
  className: `selectOption ${$ === A ? "selected" : ""}`,
154
- onClick: () => N(A),
154
+ onClick: () => S(A),
155
155
  children: A
156
156
  },
157
157
  p
@@ -160,23 +160,23 @@ const Me = j(({
160
160
  );
161
161
  });
162
162
  Me.displayName = "Select";
163
- function De(r) {
163
+ function Ne(r) {
164
164
  const s = r instanceof Element ? r : document.getElementById(r);
165
165
  return s && s.children[0].textContent || "";
166
166
  }
167
- function st(r, s) {
167
+ function ct(r, s) {
168
168
  const o = r instanceof Element ? r : document.getElementById(r);
169
169
  o && (o.children[0].textContent = s);
170
170
  }
171
- function ee(r) {
171
+ function ne(r) {
172
172
  const s = document.createRange(), o = window.getSelection();
173
173
  o && (!r || !(r instanceof Node) || (s.selectNodeContents(r), s.collapse(!0), o.removeAllRanges(), o.addRange(s)));
174
174
  }
175
- function q(r) {
175
+ function v(r) {
176
176
  const s = document.createRange(), o = window.getSelection();
177
177
  o && (!r || !(r instanceof Node) || (s.selectNodeContents(r), s.collapse(!1), o.removeAllRanges(), o.addRange(s)));
178
178
  }
179
- function pe(r) {
179
+ function ge(r) {
180
180
  const s = window.getSelection();
181
181
  if (!s || s.rangeCount === 0)
182
182
  return 0;
@@ -185,37 +185,37 @@ function pe(r) {
185
185
  const o = s.getRangeAt(0), f = o.cloneRange();
186
186
  return f.selectNodeContents(r), f.setEnd(o.startContainer, o.startOffset), f.toString().length;
187
187
  }
188
- function ct() {
188
+ function at() {
189
189
  const r = window.getSelection();
190
190
  if (!r || r.rangeCount === 0)
191
191
  return null;
192
192
  const o = r.getRangeAt(0).startContainer;
193
193
  return o.nodeType === Node.TEXT_NODE ? o.parentElement : o.nodeType === Node.ELEMENT_NODE ? o : null;
194
194
  }
195
- function at() {
195
+ function dt() {
196
196
  const r = window.getSelection();
197
197
  return !r || r.rangeCount === 0 ? null : r.getRangeAt(0).getBoundingClientRect();
198
198
  }
199
- function dt() {
199
+ function ut() {
200
200
  return new Promise((r) => {
201
201
  requestAnimationFrame(() => {
202
- r(at());
202
+ r(dt());
203
203
  });
204
204
  });
205
205
  }
206
- function ut() {
206
+ function ft() {
207
207
  const r = window.getSelection();
208
208
  if (!r || r.rangeCount === 0) return null;
209
209
  const s = r.getRangeAt(0), o = s.startContainer, f = s.startOffset;
210
210
  return o.nodeType === Node.TEXT_NODE ? f > 0 ? o : o.previousSibling : o.nodeType === Node.ELEMENT_NODE ? f > 0 ? o.childNodes[f - 1] : o.previousSibling : null;
211
211
  }
212
- function ft() {
212
+ function pt() {
213
213
  const r = window.getSelection();
214
214
  if (!r || r.rangeCount === 0) return null;
215
215
  const s = r.getRangeAt(0), o = s.startContainer, f = s.startOffset;
216
216
  return o.nodeType === Node.TEXT_NODE ? f < o.length ? o : o.nextSibling : o.nodeType === Node.ELEMENT_NODE ? f < o.childNodes.length ? o.childNodes[f] : o.nextSibling : null;
217
217
  }
218
- function pt(r) {
218
+ function ht(r) {
219
219
  return r && !r.getAttribute("data-set-type");
220
220
  }
221
221
  function ke() {
@@ -227,28 +227,28 @@ const He = j(({
227
227
  position: o,
228
228
  id: f,
229
229
  height: k = 120,
230
- onChange: w
231
- }, g) => {
232
- const [$, D] = L(s || ""), [T, N] = L(0), A = F(null), p = F(T), y = Pe((b) => {
233
- D(b), w == null || w(b, h.LABEL);
234
- }, [w]);
230
+ onChange: C
231
+ }, E) => {
232
+ const [$, N] = L(s || ""), [T, S] = L(0), A = O(null), p = O(T), g = Pe((b) => {
233
+ N(b), C == null || C(b, h.LABEL);
234
+ }, [C]);
235
235
  return M(() => {
236
- typeof g == "function" ? g(A.current) : g && (g.current = A.current);
237
- }, [g]), M(() => {
236
+ typeof E == "function" ? E(A.current) : E && (E.current = A.current);
237
+ }, [E]), M(() => {
238
238
  p.current = T;
239
239
  }, [T]), M(() => {
240
- N(0);
240
+ S(0);
241
241
  }, [r]), M(() => {
242
- const b = (E) => {
243
- r.length !== 0 && (E.key === "ArrowDown" ? (E.preventDefault(), N((x) => x < r.length - 1 ? x + 1 : x)) : E.key === "ArrowUp" ? (E.preventDefault(), N((x) => x > 0 ? x - 1 : x)) : E.key === "Enter" && (E.preventDefault(), setTimeout(() => {
244
- const x = p.current;
245
- x >= 0 && r[x] && y(r[x]);
242
+ const b = (y) => {
243
+ r.length !== 0 && (y.key === "ArrowDown" ? (y.preventDefault(), S((m) => m < r.length - 1 ? m + 1 : m)) : y.key === "ArrowUp" ? (y.preventDefault(), S((m) => m > 0 ? m - 1 : m)) : y.key === "Enter" && (y.preventDefault(), setTimeout(() => {
244
+ const m = p.current;
245
+ m >= 0 && r[m] && g(r[m]);
246
246
  }, 0)));
247
247
  };
248
248
  return document.addEventListener("keydown", b), () => {
249
249
  document.removeEventListener("keydown", b);
250
250
  };
251
- }, [r, y]), /* @__PURE__ */ u(
251
+ }, [r, g]), /* @__PURE__ */ u(
252
252
  "div",
253
253
  {
254
254
  ref: A,
@@ -261,56 +261,56 @@ const He = j(({
261
261
  zIndex: 5e3,
262
262
  maxHeight: `${k}px`
263
263
  },
264
- children: r.length > 0 && r.map((b, E) => /* @__PURE__ */ u(
264
+ children: r.length > 0 && r.map((b, y) => /* @__PURE__ */ u(
265
265
  "div",
266
266
  {
267
- className: `selectOption ${$ === b ? "selected" : ""} ${T === E ? "highlighted" : ""}`,
268
- onClick: () => y(b),
269
- onMouseEnter: () => N(E),
267
+ className: `selectOption ${$ === b ? "selected" : ""} ${T === y ? "highlighted" : ""}`,
268
+ onClick: () => g(b),
269
+ onMouseEnter: () => S(y),
270
270
  children: b
271
271
  },
272
- E
272
+ y
273
273
  ))
274
274
  }
275
275
  );
276
276
  });
277
277
  He.displayName = "Mention";
278
- const ht = j((r, s) => {
278
+ const gt = j((r, s) => {
279
279
  const {
280
280
  value: o = "",
281
281
  varList: f,
282
282
  placeholder: k = "",
283
- maxLength: w,
284
- defaultRows: g = 3,
283
+ maxLength: C,
284
+ defaultRows: E = 3,
285
285
  disabled: $ = !1,
286
- defaultFocus: D = !1,
286
+ defaultFocus: N = !1,
287
287
  textIndex: T = 0,
288
- mentions: N = [],
288
+ mentions: S = [],
289
289
  onFocus: A,
290
290
  onBlur: p,
291
- onChange: y,
291
+ onChange: g,
292
292
  onClick: b,
293
- onSend: E,
294
- onKeyDown: x,
293
+ onSend: y,
294
+ onKeyDown: m,
295
295
  onKeyUp: K,
296
- onMaxLengthExceeded: te
297
- } = r, [gt, Et] = L(o || ""), [ne, ie] = L(""), [yt, he] = L(""), [U, O] = L(!1), [X, W] = L({ top: 0, left: 0 }), [re, le] = L([]), [G, ge] = L(""), [C, oe] = L(null), [se, J] = L(120), [Ee, ye] = L(D), be = 240, Ce = 240, we = 240, Ae = 276, m = F(null), R = F(null), B = F(null), ce = F(!1), v = () => {
298
- var i, e;
299
- let n = ((e = (i = m.current) == null ? void 0 : i.innerText) == null ? void 0 : e.replace(/\u200B/g, "")) || "";
300
- return n === `
301
- ` && (n = ""), n;
302
- }, xe = () => {
296
+ onMaxLengthExceeded: ie
297
+ } = r, [Et, yt] = L(o || ""), [re, X] = L(""), [bt, le] = L(""), [U, F] = L(!1), [G, W] = L({ top: 0, left: 0 }), [oe, se] = L([]), [J, Ee] = L(""), [w, ce] = L(null), [ae, Q] = L(120), [ye, be] = L(N), we = 240, Ce = 240, Ae = 240, me = 276, x = O(null), R = O(null), B = O(null), Z = O(!1), V = () => {
298
+ var i, t;
299
+ let e = ((t = (i = x.current) == null ? void 0 : i.innerText) == null ? void 0 : t.replace(/\u200B/g, "")) || "";
300
+ return e === `
301
+ ` && (e = ""), e;
302
+ }, de = () => {
303
303
  var i;
304
- let n = ((i = m.current) == null ? void 0 : i.innerHTML) || "";
305
- return n === "<br>" && (n = ""), n;
306
- }, Fe = (n) => {
304
+ let e = ((i = x.current) == null ? void 0 : i.innerHTML) || "";
305
+ return e === "<br>" && (e = ""), e;
306
+ }, Oe = (e) => {
307
307
  const i = [];
308
- let e = 0;
308
+ let t = 0;
309
309
  const l = /\[([^\]]+)\]/g;
310
310
  let c;
311
311
  const a = ke();
312
312
  let d = 0;
313
- if (n === "" || !n || n === `
313
+ if (e === "" || !e || e === `
314
314
  `)
315
315
  return [
316
316
  {
@@ -319,429 +319,445 @@ const ht = j((r, s) => {
319
319
  id: `text-${d++}-${a}`
320
320
  }
321
321
  ];
322
- const P = new Set((f || []).map((S) => S.name));
323
- for (; (c = l.exec(n)) !== null; ) {
324
- if (c.index > e) {
325
- const H = n.substring(e, c.index).split(`
322
+ const P = new Set((f || []).map((D) => D.name));
323
+ for (; (c = l.exec(e)) !== null; ) {
324
+ if (c.index > t) {
325
+ const H = e.substring(t, c.index).split(`
326
326
  `);
327
- H.forEach((I, rt) => {
328
- I && i.push({
327
+ H.forEach((ee, lt) => {
328
+ ee && i.push({
329
329
  type: "text",
330
- content: I,
330
+ content: ee,
331
331
  id: `text-${d++}-${a}`
332
- }), rt < H.length - 1 && i.push({
332
+ }), lt < H.length - 1 && i.push({
333
333
  type: "newline",
334
334
  id: `newline-${d++}-${a}`
335
335
  });
336
336
  });
337
337
  }
338
- const S = c[1];
339
- if (P.has(S)) {
340
- const t = f.find((H) => H.name === S);
341
- (t == null ? void 0 : t.type) === "input" ? i.push({
338
+ const D = c[1];
339
+ if (P.has(D)) {
340
+ const n = f.find((H) => H.name === D);
341
+ (n == null ? void 0 : n.type) === "input" ? i.push({
342
342
  type: "input",
343
- name: t == null ? void 0 : t.name,
344
- content: (t == null ? void 0 : t.content) || "",
345
- placeholder: (t == null ? void 0 : t.placeholder) || S,
343
+ name: n == null ? void 0 : n.name,
344
+ content: (n == null ? void 0 : n.content) || "",
345
+ placeholder: (n == null ? void 0 : n.placeholder) || D,
346
346
  id: `input-${d++}-${a}`
347
- }) : (t == null ? void 0 : t.type) === "label" ? i.push({
347
+ }) : (n == null ? void 0 : n.type) === "label" ? i.push({
348
348
  type: "label",
349
- name: t == null ? void 0 : t.name,
350
- content: (t == null ? void 0 : t.content) || "",
349
+ name: n == null ? void 0 : n.name,
350
+ content: (n == null ? void 0 : n.content) || "",
351
351
  id: `label-${d++}-${a}`
352
- }) : (t == null ? void 0 : t.type) === "select" ? i.push({
352
+ }) : (n == null ? void 0 : n.type) === "select" ? i.push({
353
353
  type: "select",
354
- name: t == null ? void 0 : t.name,
355
- content: (t == null ? void 0 : t.content) || "",
356
- placeholder: (t == null ? void 0 : t.placeholder) || S,
357
- options: (t == null ? void 0 : t.options) || [],
354
+ name: n == null ? void 0 : n.name,
355
+ content: (n == null ? void 0 : n.content) || "",
356
+ placeholder: (n == null ? void 0 : n.placeholder) || D,
357
+ options: (n == null ? void 0 : n.options) || [],
358
358
  id: `select-${d++}-${a}`
359
- }) : (t == null ? void 0 : t.type) === "multiple-select" ? i.push({
359
+ }) : (n == null ? void 0 : n.type) === "multiple-select" ? i.push({
360
360
  type: "multiple-select",
361
- name: t == null ? void 0 : t.name,
362
- content: (t == null ? void 0 : t.content) || "",
363
- placeholder: (t == null ? void 0 : t.placeholder) || S,
364
- options: (t == null ? void 0 : t.options) || [],
361
+ name: n == null ? void 0 : n.name,
362
+ content: (n == null ? void 0 : n.content) || "",
363
+ placeholder: (n == null ? void 0 : n.placeholder) || D,
364
+ options: (n == null ? void 0 : n.options) || [],
365
365
  id: `multiple-select-${d++}-${a}`
366
- }) : (t == null ? void 0 : t.type) === "date-picker" && i.push({
366
+ }) : (n == null ? void 0 : n.type) === "date-picker" && i.push({
367
367
  type: "date-picker",
368
- name: t == null ? void 0 : t.name,
369
- content: (t == null ? void 0 : t.content) || "",
370
- placeholder: (t == null ? void 0 : t.placeholder) || S,
368
+ name: n == null ? void 0 : n.name,
369
+ content: (n == null ? void 0 : n.content) || "",
370
+ placeholder: (n == null ? void 0 : n.placeholder) || D,
371
371
  id: `date-picker-${d++}-${a}`
372
372
  });
373
373
  } else
374
374
  i.push({
375
375
  type: "text",
376
- content: `[${S}]`,
376
+ content: `[${D}]`,
377
377
  id: `text-${d++}-${a}`
378
378
  });
379
- e = l.lastIndex;
379
+ t = l.lastIndex;
380
380
  }
381
- if (e < n.length) {
382
- const t = n.substring(e).split(`
381
+ if (t < e.length) {
382
+ const n = e.substring(t).split(`
383
383
  `);
384
- t.forEach((H, I) => {
384
+ n.forEach((H, ee) => {
385
385
  H && i.push({
386
386
  type: "text",
387
387
  content: H,
388
388
  id: `text-${d++}`
389
- }), I < t.length - 1 && i.push({
389
+ }), ee < n.length - 1 && i.push({
390
390
  type: "newline",
391
391
  id: `newline-${d++}`
392
392
  });
393
393
  });
394
394
  }
395
395
  return i;
396
- }, ae = () => {
397
- var n;
398
- (n = m.current) == null || n.setAttribute("contenteditable", "true"), R.current && (_(R.current) && R.current.children[0].setAttribute(
396
+ }, ue = () => {
397
+ var e;
398
+ (e = x.current) == null || e.setAttribute("contenteditable", "true"), R.current && (_(R.current) && R.current.children[0].setAttribute(
399
399
  "contenteditable",
400
400
  "false"
401
- ), R.current = null), q(m.current);
402
- }, Oe = (n) => {
403
- b == null || b(n);
404
- }, Ve = (n) => {
405
- ae();
406
- }, z = (n) => {
407
- ie(v()), he(xe()), y == null || y(v()), et(n);
408
- }, qe = (n) => {
401
+ ), R.current = null), v(x.current);
402
+ }, Fe = (e) => {
403
+ b == null || b(e);
404
+ }, Ve = (e) => {
405
+ ue();
406
+ }, z = (e) => {
407
+ Z.current || (X(V()), le(de()), g == null || g(V()), tt(e));
408
+ }, qe = (e) => {
409
409
  var i;
410
- if (!ce.current && n.code === "Enter" && !n.shiftKey) {
411
- n.preventDefault();
412
- const e = v();
413
- if (e.length === 0 || (i = m.current) != null && i.innerHTML.match(
410
+ if (!Z.current && e.code === "Enter" && !e.shiftKey) {
411
+ e.preventDefault();
412
+ const t = V();
413
+ if (t.length === 0 || (i = x.current) != null && i.innerHTML.match(
414
414
  /^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/
415
415
  ))
416
416
  return;
417
- w ? e.length <= w ? E == null || E(e) : te == null || te(e, w) : E == null || E(e);
417
+ C ? t.length <= C ? y == null || y(t) : ie == null || ie(t, C) : y == null || y(t);
418
418
  }
419
- }, _e = (n) => {
420
- var e;
421
- if (U && (C == null ? void 0 : C.type) === h.LABEL && (n.code === "ArrowUp" || n.code === "ArrowDown" || n.code === "Enter")) {
422
- n.preventDefault();
419
+ }, ve = (e) => {
420
+ var t;
421
+ if (U && (w == null ? void 0 : w.type) === h.LABEL && (e.code === "ArrowUp" || e.code === "ArrowDown" || e.code === "Enter")) {
422
+ e.preventDefault();
423
423
  return;
424
424
  }
425
- O(!1), x == null || x(n);
426
- const i = ct();
427
- if (i && pt(i)) {
428
- if (n.code === "ArrowLeft") {
429
- const l = i == null ? void 0 : i.previousElementSibling, c = pe(i);
430
- l && c === 0 && _(l) && l.children[0] && (R.current = l, V(l), requestAnimationFrame(() => {
431
- q(l.children[0]);
425
+ F(!1), m == null || m(e);
426
+ const i = at();
427
+ if (i && ht(i)) {
428
+ if (e.code === "ArrowLeft") {
429
+ const l = i == null ? void 0 : i.previousElementSibling, c = ge(i);
430
+ l && c === 0 && _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
431
+ v(l.children[0]);
432
432
  }));
433
433
  }
434
- if (n.code === "ArrowRight") {
435
- const l = i == null ? void 0 : i.nextElementSibling, c = pe(i);
436
- l && c === ((e = i.textContent) == null ? void 0 : e.length) && _(l) && l.children[0] && (R.current = l, V(l), requestAnimationFrame(() => {
437
- ee(l.children[0]);
434
+ if (e.code === "ArrowRight") {
435
+ const l = i == null ? void 0 : i.nextElementSibling, c = ge(i);
436
+ l && c === ((t = i.textContent) == null ? void 0 : t.length) && _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
437
+ ne(l.children[0]);
438
438
  }));
439
439
  }
440
- n.code === "Backspace" && (i.innerHTML === "​" && n.preventDefault(), i.innerHTML === "<br>" && (n.preventDefault(), i.innerHTML = "​"));
440
+ e.code === "Backspace" && (i.innerHTML === "​" && e.preventDefault(), i.innerHTML === "<br>" && (e.preventDefault(), i.innerHTML = "​"));
441
+ }
442
+ if (e.code === "Backspace" && e.target) {
443
+ const l = e.target;
444
+ if (l.childElementCount === 1 && l.children[0].tagName === "SPAN") {
445
+ const c = l.children[0];
446
+ l.childNodes.length === 1 && (c.innerHTML === "​" && e.preventDefault(), c.innerHTML === "<br>" && (e.preventDefault(), c.innerHTML = "​"));
447
+ }
441
448
  }
442
449
  if (i && i.getAttribute("data-set-type") === "container") {
443
- if (n.code === "ArrowLeft") {
444
- const l = ut();
445
- _(l) && l.children[0] && (R.current = l, V(l), requestAnimationFrame(() => {
446
- q(l.children[0]);
450
+ if (e.code === "ArrowLeft") {
451
+ const l = ft();
452
+ _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
453
+ v(l.children[0]);
447
454
  }));
448
455
  }
449
- if (n.code === "ArrowRight") {
450
- const l = ft();
451
- _(l) && l.children[0] && (R.current = l, V(l), requestAnimationFrame(() => {
452
- ee(l.children[0]);
456
+ if (e.code === "ArrowRight") {
457
+ const l = pt();
458
+ _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
459
+ ne(l.children[0]);
453
460
  }));
454
461
  }
455
462
  }
456
- qe(n);
457
- }, Ke = (n) => {
458
- if (U && (C == null ? void 0 : C.type) === h.LABEL && (n.code === "ArrowUp" || n.code === "ArrowDown" || n.code === "Enter")) {
459
- n.preventDefault();
463
+ qe(e);
464
+ }, _e = (e) => {
465
+ if (U && (w == null ? void 0 : w.type) === h.LABEL && (e.code === "ArrowUp" || e.code === "ArrowDown" || e.code === "Enter")) {
466
+ e.preventDefault();
460
467
  return;
461
468
  }
462
- K == null || K(n);
463
- }, ve = (n) => {
464
- n.preventDefault();
465
- const e = window.getSelection().toString();
466
- if (!e) return;
467
- const l = e, c = e;
468
- n.clipboardData.setData("text/plain", l), n.clipboardData.setData("text/html", c);
469
- }, Ue = (n) => {
470
- A == null || A(n);
471
- }, We = () => {
472
- ce.current = !0;
469
+ K == null || K(e);
470
+ }, Ke = (e) => {
471
+ const t = e.clipboardData.items;
472
+ for (let l = 0; l < t.length; l++)
473
+ if (t[l].type.indexOf("image") !== -1) {
474
+ e.preventDefault();
475
+ return;
476
+ }
477
+ }, Ue = (e) => {
478
+ e.preventDefault();
479
+ const t = window.getSelection().toString();
480
+ if (!t) return;
481
+ const l = t.replace(/\u200B/g, "") || "", c = t.replace(/\u200B/g, "") || "";
482
+ e.clipboardData.setData("text/plain", l), e.clipboardData.setData("text/html", c);
483
+ }, We = (e) => {
484
+ A == null || A(e);
473
485
  }, ze = () => {
474
- ce.current = !1;
475
- }, je = (n, i) => {
486
+ Z.current = !0;
487
+ }, je = () => {
488
+ setTimeout(() => {
489
+ Z.current = !1, X(V()), le(de()), g == null || g(V());
490
+ }, 0);
491
+ }, Xe = (e, i) => {
476
492
  i.stopPropagation();
477
- }, Xe = (n, i) => {
493
+ }, Ge = (e, i) => {
478
494
  var l;
479
- i.stopPropagation(), R.current && Ne(R.current), (l = m.current) == null || l.setAttribute("contenteditable", "false");
480
- const e = document.getElementById(n.id);
481
- R.current = e, requestAnimationFrame(() => {
482
- V(e);
495
+ i.stopPropagation(), R.current && Se(R.current), (l = x.current) == null || l.setAttribute("contenteditable", "false");
496
+ const t = document.getElementById(e.id);
497
+ R.current = t, requestAnimationFrame(() => {
498
+ q(t);
483
499
  });
484
- }, Ge = (n, i) => {
485
- var c, a, d, P, S;
486
- x == null || x(i), i.stopPropagation();
487
- const e = i.target, l = pe(e);
500
+ }, Je = (e, i) => {
501
+ var c, a, d, P, D;
502
+ m == null || m(i), i.stopPropagation();
503
+ const t = i.target, l = ge(t);
488
504
  if (i.code === "Backspace" && l === 0) {
489
- const t = (c = e.parentElement) == null ? void 0 : c.previousElementSibling;
490
- t && (_(t) && t.children[0] && ((a = t.children[0].textContent) != null && a.length) ? (R.current = t, V(t), q(t.children[0]), requestAnimationFrame(() => {
491
- fe(t.children[0]);
492
- })) : (ae(), q(t)));
505
+ const n = (c = t.parentElement) == null ? void 0 : c.previousElementSibling;
506
+ n && (_(n) && n.children[0] && ((a = n.children[0].textContent) != null && a.length) ? (R.current = n, q(n), v(n.children[0]), requestAnimationFrame(() => {
507
+ he(n.children[0]);
508
+ })) : (ue(), v(n)));
493
509
  }
494
- if (i.code === "ArrowRight" && l === ((d = e.textContent) == null ? void 0 : d.length)) {
495
- const t = (P = e.parentElement) == null ? void 0 : P.nextElementSibling;
496
- t && (_(t) && t.children[0] && ((S = t.children[0].textContent) != null && S.length) ? (R.current = t, V(t), ee(t.children[0]), requestAnimationFrame(() => {
497
- fe(t.children[0]);
498
- })) : (ae(), ee(t)));
510
+ if (i.code === "ArrowRight" && l === ((d = t.textContent) == null ? void 0 : d.length)) {
511
+ const n = (P = t.parentElement) == null ? void 0 : P.nextElementSibling;
512
+ n && (_(n) && n.children[0] && ((D = n.children[0].textContent) != null && D.length) ? (R.current = n, q(n), ne(n.children[0]), requestAnimationFrame(() => {
513
+ he(n.children[0]);
514
+ })) : (ue(), ne(n)));
499
515
  }
500
516
  i.code === "Enter" && i.shiftKey && i.preventDefault();
501
- }, Je = (n, i) => {
517
+ }, Qe = (e, i) => {
502
518
  K == null || K(i);
503
- const e = i.target;
504
- fe(e);
505
- }, Qe = (n, i) => {
519
+ const t = i.target;
520
+ he(t);
521
+ }, Ze = (e, i) => {
506
522
  var l;
507
- i.stopPropagation(), R.current && Ne(R.current), (l = m.current) == null || l.setAttribute("contenteditable", "false");
508
- const e = document.getElementById(n.id);
509
- R.current = e, requestAnimationFrame(() => {
510
- V(e);
523
+ i.stopPropagation(), R.current && Se(R.current), (l = x.current) == null || l.setAttribute("contenteditable", "false");
524
+ const t = document.getElementById(e.id);
525
+ R.current = t, requestAnimationFrame(() => {
526
+ q(t);
511
527
  });
512
- }, Ze = (n, i) => {
513
- ie(v()), he(xe()), y == null || y(v());
514
- }, Ie = (n, i) => {
528
+ }, Ie = (e, i) => {
529
+ X(V()), le(de()), g == null || g(V());
530
+ }, Ye = (e, i) => {
515
531
  };
516
532
  M(() => {
517
533
  if (!U) return;
518
- const n = (l) => {
519
- B.current && !B.current.contains(l.target) && O(!1);
534
+ const e = (l) => {
535
+ B.current && !B.current.contains(l.target) && F(!1);
520
536
  }, i = (l) => {
521
- B.current && !B.current.contains(l.target) && O(!1);
522
- }, e = () => {
523
- O(!1);
537
+ B.current && !B.current.contains(l.target) && F(!1);
538
+ }, t = () => {
539
+ F(!1);
524
540
  };
525
- return document.addEventListener("mousedown", n), document.addEventListener("scroll", i, !0), window.addEventListener("resize", e), () => {
526
- document.removeEventListener("mousedown", n), document.removeEventListener("scroll", i, !0), window.removeEventListener("resize", e);
541
+ return document.addEventListener("mousedown", e), document.addEventListener("scroll", i, !0), window.addEventListener("resize", t), () => {
542
+ document.removeEventListener("mousedown", e), document.removeEventListener("scroll", i, !0), window.removeEventListener("resize", t);
527
543
  };
528
544
  }, [U]);
529
- const Q = (n, i) => {
530
- if (C && i !== h.LABEL && st(C.id, n), i === h.SELECT && (O(!1), z({})), i === h.LABEL && (ue(), O(!1), requestAnimationFrame(() => {
531
- const e = window.getSelection();
532
- e && Z.current && (e.removeAllRanges(), e.addRange(Z.current), setTimeout(() => {
545
+ const I = (e, i) => {
546
+ if (w && i !== h.LABEL && ct(w.id, e), i === h.SELECT && (F(!1), z({})), i === h.LABEL && (pe(), F(!1), requestAnimationFrame(() => {
547
+ const t = window.getSelection();
548
+ t && Y.current && (t.removeAllRanges(), t.addRange(Y.current), setTimeout(() => {
533
549
  var d;
534
550
  const l = document.createElement("span");
535
- l.contentEditable = "false", l.setAttribute("data-set-type", "label"), l.id = C.id;
551
+ l.contentEditable = "false", l.setAttribute("data-set-type", "label"), l.id = w.id;
536
552
  const c = document.createElement("span");
537
- c.contentEditable = "false", c.textContent = n, l.appendChild(c);
538
- const a = (d = m.current) == null ? void 0 : d.children;
553
+ c.contentEditable = "false", c.textContent = e, l.appendChild(c);
554
+ const a = (d = x.current) == null ? void 0 : d.children;
539
555
  if ((a == null ? void 0 : a.length) === 1 && a[0].tagName === "SPAN" && a[0].innerHTML === "​[")
540
- m.current.innerHTML = "", m.current.appendChild(l), setTimeout(() => {
541
- z({}), ue();
556
+ x.current.innerHTML = "", x.current.appendChild(l), setTimeout(() => {
557
+ z({}), pe();
542
558
  }, 0);
543
559
  else {
544
560
  document.execCommand("delete", !1, void 0);
545
- const P = Z.current;
546
- P.insertNode(l), P.setStartAfter(l), P.setEndAfter(l), e.removeAllRanges(), e.addRange(P), setTimeout(() => {
561
+ const P = Y.current;
562
+ P.insertNode(l), P.setStartAfter(l), P.setEndAfter(l), t.removeAllRanges(), t.addRange(P), setTimeout(() => {
547
563
  z({});
548
564
  }, 0);
549
565
  }
550
566
  }, 0));
551
567
  })), i === h.MULTIPLE_SELECT || i === h.DATE_PICKER) {
552
- const e = document.getElementById(
553
- C.id
568
+ const t = document.getElementById(
569
+ w.id
554
570
  );
555
- e && e.children[0] && e.children[1] && (n.length > 0 ? (e.children[0].setAttribute("style", "display: inline"), e.children[0].setAttribute("contenteditable", "false"), e.children[1].setAttribute("style", "display: none"), e.children[1].setAttribute("contenteditable", "true")) : (e.children[0].setAttribute("style", "display: none"), e.children[0].setAttribute("contenteditable", "true"), e.children[1].setAttribute("style", "display: inline"), e.children[1].setAttribute("contenteditable", "true"))), z({});
571
+ t && t.children[0] && t.children[1] && (e.length > 0 ? (t.children[0].setAttribute("style", "display: inline"), t.children[0].setAttribute("contenteditable", "false"), t.children[1].setAttribute("style", "display: none"), t.children[1].setAttribute("contenteditable", "true")) : (t.children[0].setAttribute("style", "display: none"), t.children[0].setAttribute("contenteditable", "true"), t.children[1].setAttribute("style", "display: inline"), t.children[1].setAttribute("contenteditable", "true"))), z({});
556
572
  }
557
- }, Z = F(null), Ye = (N == null ? void 0 : N.map((n) => n.prefix)) || [], et = (n) => {
558
- const i = n == null ? void 0 : n.nativeEvent, e = i == null ? void 0 : i.data;
559
- Ye.includes(e) && dt().then((l) => {
573
+ }, Y = O(null), et = (S == null ? void 0 : S.map((e) => e.prefix)) || [], tt = (e) => {
574
+ const i = e == null ? void 0 : e.nativeEvent, t = i == null ? void 0 : i.data;
575
+ et.includes(t) && ut().then((l) => {
560
576
  var a;
561
577
  const c = window.getSelection();
562
- c && c.rangeCount > 0 && (Z.current = c.getRangeAt(0)), tt({
563
- options: ((a = N.find((d) => d.prefix === e)) == null ? void 0 : a.options) || [],
578
+ c && c.rangeCount > 0 && (Y.current = c.getRangeAt(0)), nt({
579
+ options: ((a = S.find((d) => d.prefix === t)) == null ? void 0 : a.options) || [],
564
580
  value: "",
565
581
  type: h.LABEL,
566
582
  id: "label-" + ke()
567
583
  }, l);
568
584
  });
569
- }, tt = (n, i) => {
570
- le(n.options), W({ top: -999999, left: -999999999 }), oe(n), J(Ce), O(!0), requestAnimationFrame(() => {
585
+ }, nt = (e, i) => {
586
+ se(e.options), W({ top: -999999, left: -999999999 }), ce(e), Q(Ce), F(!0), requestAnimationFrame(() => {
571
587
  if (B.current) {
572
- const e = B.current.getBoundingClientRect();
588
+ const t = B.current.getBoundingClientRect();
573
589
  let l = i.left, c = i.top + i.height;
574
- window.innerWidth - i.right < be && i.width < e.width && (l = i.right - e.width), i.top < e.height && (c = i.top + i.height), W({ top: c, left: l }), J(e.height);
590
+ window.innerWidth - i.right < we && i.width < t.width && (l = i.right - t.width), i.top < t.height && (c = i.top + i.height), W({ top: c, left: l }), Q(t.height);
575
591
  }
576
592
  });
577
- }, me = (n, i) => {
593
+ }, xe = (e, i) => {
578
594
  const l = i.target.getBoundingClientRect();
579
- le(n.options), ge(n.value || De(n.id)), W({ top: -999999, left: -999999999 }), oe(n), J(Ce), O(!0), requestAnimationFrame(() => {
595
+ se(e.options), Ee(e.value || Ne(e.id)), W({ top: -999999, left: -999999999 }), ce(e), Q(Ce), F(!0), requestAnimationFrame(() => {
580
596
  if (B.current) {
581
597
  const c = B.current.getBoundingClientRect();
582
598
  let a = l.left, d = l.top + l.height;
583
- window.innerWidth - l.right < be && l.width < c.width && (a = l.right - c.width), l.top < c.height && (d = l.top + l.height), W({ top: d, left: a }), J(c.height);
599
+ window.innerWidth - l.right < we && l.width < c.width && (a = l.right - c.width), l.top < c.height && (d = l.top + l.height), W({ top: d, left: a }), Q(c.height);
584
600
  }
585
601
  });
586
- }, nt = (n, i) => {
602
+ }, it = (e, i) => {
587
603
  const l = i.target.getBoundingClientRect();
588
- let c = l.left, a = l.top - Ae;
589
- window.innerWidth - l.right < we && (c = c - we + l.width), l.top < Ae && (a = l.top + l.height), le(n.options), ge(n.value || De(n.id)), W({ top: a, left: c }), oe(n), O(!0);
590
- }, [it, Le] = L([]), [de, Te] = L(!0), Re = Pe(() => {
604
+ let c = l.left, a = l.top - me;
605
+ window.innerWidth - l.right < Ae && (c = c - Ae + l.width), l.top < me && (a = l.top + l.height), se(e.options), Ee(e.value || Ne(e.id)), W({ top: a, left: c }), ce(e), F(!0);
606
+ }, [rt, Le] = L([]), [fe, Te] = L(!0), Re = Pe(() => {
591
607
  Te(!1);
592
- const n = Fe(o), i = [];
593
- return n.forEach((e) => {
594
- var l, c, a, d, P, S;
595
- if (e.type === "text")
608
+ const e = Oe(o), i = [];
609
+ return e.forEach((t) => {
610
+ var l, c, a, d, P, D;
611
+ if (t.type === "text")
596
612
  i.push(
597
- /* @__PURE__ */ u("span", { onKeyDown: (t) => Ie(), children: e.content }, e.id)
613
+ /* @__PURE__ */ u("span", { onKeyDown: (n) => Ye(), children: t.content }, t.id)
598
614
  );
599
- else if (e.type === "newline")
600
- i.push(/* @__PURE__ */ u("br", {}, e.id));
601
- else if (e.type === "label")
615
+ else if (t.type === "newline")
616
+ i.push(/* @__PURE__ */ u("br", {}, t.id));
617
+ else if (t.type === "label")
602
618
  i.push(
603
619
  /* @__PURE__ */ u(
604
620
  "span",
605
621
  {
606
- id: e.id,
622
+ id: t.id,
607
623
  "data-set-type": "label",
608
624
  contentEditable: !1,
609
625
  children: /* @__PURE__ */ u(
610
626
  "span",
611
627
  {
612
628
  contentEditable: !1,
613
- children: e.name
629
+ children: t.name
614
630
  }
615
631
  )
616
632
  },
617
- e.id
633
+ t.id
618
634
  )
619
635
  );
620
- else if (e.type === "input")
636
+ else if (t.type === "input")
621
637
  i.push(
622
- /* @__PURE__ */ Y(
638
+ /* @__PURE__ */ te(
623
639
  "span",
624
640
  {
625
- id: e.id,
641
+ id: t.id,
626
642
  "data-set-type": "input",
627
643
  contentEditable: !1,
628
644
  suppressContentEditableWarning: !0,
629
- onInput: (t) => Ze(),
630
- onClick: (t) => je(e, t),
631
- onMouseDown: (t) => Xe(e, t),
632
- "data-cosmic-ai-input-placeholder": e.placeholder,
645
+ onInput: (n) => Ie(),
646
+ onClick: (n) => Xe(t, n),
647
+ onMouseDown: (n) => Ge(t, n),
648
+ "data-cosmic-ai-input-placeholder": t.placeholder,
633
649
  children: [
634
650
  /* @__PURE__ */ u(
635
651
  "span",
636
652
  {
637
653
  className: "cosmic-ai-input-inputContent",
638
654
  style: {
639
- padding: (l = e.content) != null && l.length ? "2px 4px" : "2px 0 2px 4px"
655
+ padding: (l = t.content) != null && l.length ? "2px 4px" : "2px 0 2px 4px"
640
656
  },
641
657
  contentEditable: !1,
642
- onKeyDown: (t) => Ge(e, t),
643
- onKeyUp: (t) => Je(e, t),
644
- children: e.content
658
+ onKeyDown: (n) => Je(t, n),
659
+ onKeyUp: (n) => Qe(t, n),
660
+ children: t.content
645
661
  }
646
662
  ),
647
663
  /* @__PURE__ */ u(
648
664
  "span",
649
665
  {
650
666
  contentEditable: !1,
651
- style: { display: (c = e.content) != null && c.length ? "none" : "inline" },
667
+ style: { display: (c = t.content) != null && c.length ? "none" : "inline" },
652
668
  className: "cosmic-ai-input-placeholder",
653
- onMouseDown: (t) => Qe(e, t),
654
- children: e.placeholder
669
+ onMouseDown: (n) => Ze(t, n),
670
+ children: t.placeholder
655
671
  }
656
672
  )
657
673
  ]
658
674
  },
659
- e.id
675
+ t.id
660
676
  )
661
677
  );
662
- else if (e.type === h.SELECT) {
663
- const t = e.content || ((a = e.options) == null ? void 0 : a[0]) || e.placeholder;
678
+ else if (t.type === h.SELECT) {
679
+ const n = t.content || ((a = t.options) == null ? void 0 : a[0]) || t.placeholder;
664
680
  i.push(
665
681
  /* @__PURE__ */ u(
666
682
  "span",
667
683
  {
668
- id: e.id,
684
+ id: t.id,
669
685
  "data-set-type": "select",
670
686
  contentEditable: !1,
671
687
  suppressContentEditableWarning: !0,
672
- onClick: (H) => me(e, H),
673
- "data-cosmic-ai-input-placeholder": e.placeholder,
674
- children: /* @__PURE__ */ u("span", { contentEditable: !1, children: t })
688
+ onClick: (H) => xe(t, H),
689
+ "data-cosmic-ai-input-placeholder": t.placeholder,
690
+ children: /* @__PURE__ */ u("span", { contentEditable: !1, children: n })
675
691
  },
676
- e.id
692
+ t.id
677
693
  )
678
694
  );
679
- } else if (e.type === h.MULTIPLE_SELECT) {
680
- const t = e.content || ((d = e.options) == null ? void 0 : d[0]);
695
+ } else if (t.type === h.MULTIPLE_SELECT) {
696
+ const n = t.content || ((d = t.options) == null ? void 0 : d[0]);
681
697
  i.push(
682
- /* @__PURE__ */ Y(
698
+ /* @__PURE__ */ te(
683
699
  "span",
684
700
  {
685
- id: e.id,
701
+ id: t.id,
686
702
  "data-set-type": "multiple-select",
687
703
  contentEditable: !1,
688
704
  suppressContentEditableWarning: !0,
689
- onClick: (H) => me(e, H),
690
- "data-cosmic-ai-input-placeholder": e.placeholder,
705
+ onClick: (H) => xe(t, H),
706
+ "data-cosmic-ai-input-placeholder": t.placeholder,
691
707
  children: [
692
708
  /* @__PURE__ */ u(
693
709
  "span",
694
710
  {
695
- style: { display: t != null && t.length ? "inline" : "none" },
711
+ style: { display: n != null && n.length ? "inline" : "none" },
696
712
  contentEditable: !1,
697
- children: t
713
+ children: n
698
714
  }
699
715
  ),
700
716
  /* @__PURE__ */ u(
701
717
  "span",
702
718
  {
703
- style: { display: t != null && t.length ? "none" : "inline" },
719
+ style: { display: n != null && n.length ? "none" : "inline" },
704
720
  className: "cosmic-ai-input-selectPlaceholder",
705
721
  contentEditable: !1,
706
- children: e.placeholder
722
+ children: t.placeholder
707
723
  }
708
724
  )
709
725
  ]
710
726
  },
711
- e.id
727
+ t.id
712
728
  )
713
729
  );
714
- } else e.type === h.DATE_PICKER && i.push(
715
- /* @__PURE__ */ Y(
730
+ } else t.type === h.DATE_PICKER && i.push(
731
+ /* @__PURE__ */ te(
716
732
  "span",
717
733
  {
718
- id: e.id,
734
+ id: t.id,
719
735
  "data-set-type": "date-picker",
720
736
  contentEditable: !1,
721
737
  suppressContentEditableWarning: !0,
722
- onClick: (t) => nt(e, t),
723
- "data-cosmic-ai-input-placeholder": e.placeholder,
738
+ onClick: (n) => it(t, n),
739
+ "data-cosmic-ai-input-placeholder": t.placeholder,
724
740
  children: [
725
741
  /* @__PURE__ */ u(
726
742
  "span",
727
743
  {
728
- style: { display: (P = e.content) != null && P.length ? "inline" : "none" },
744
+ style: { display: (P = t.content) != null && P.length ? "inline" : "none" },
729
745
  contentEditable: !1,
730
- children: e.content
746
+ children: t.content
731
747
  }
732
748
  ),
733
749
  /* @__PURE__ */ u(
734
750
  "span",
735
751
  {
736
- style: { display: (S = e.content) != null && S.length ? "none" : "inline" },
752
+ style: { display: (D = t.content) != null && D.length ? "none" : "inline" },
737
753
  className: "cosmic-ai-input-datePickerPlaceholder",
738
754
  contentEditable: !1,
739
- children: e.placeholder
755
+ children: t.placeholder
740
756
  }
741
757
  )
742
758
  ]
743
759
  },
744
- e.id
760
+ t.id
745
761
  )
746
762
  );
747
763
  }), setTimeout(() => {
@@ -749,102 +765,103 @@ const ht = j((r, s) => {
749
765
  }, 0), i;
750
766
  }, [o]);
751
767
  M(() => {
752
- de && setTimeout(() => {
753
- q(m.current);
768
+ fe && setTimeout(() => {
769
+ v(x.current);
754
770
  }, 0);
755
- }, [de]), M(() => {
756
- o !== ne ? (Le(Re()), ie(o), ye(!0)) : (o === "" || !o) && Le(Re());
757
- }, [o, ne]), M(() => {
758
- if (!D && !Ee) return;
759
- const n = new MutationObserver(() => {
760
- m.current && document.contains(m.current) && (requestAnimationFrame(() => {
761
- q(m.current), ye(!1);
762
- }), n.disconnect());
771
+ }, [fe]), M(() => {
772
+ o !== re ? (Le(Re()), X(o), be(!0)) : (o === "" || !o) && Le(Re());
773
+ }, [o, re]), M(() => {
774
+ if (!N && !ye) return;
775
+ const e = new MutationObserver(() => {
776
+ x.current && document.contains(x.current) && (requestAnimationFrame(() => {
777
+ v(x.current), be(!1);
778
+ }), e.disconnect());
763
779
  });
764
- return m.current && n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
765
- }, [D, Ee]);
766
- const ue = () => {
767
- m.current && requestAnimationFrame(() => {
768
- q(m.current);
780
+ return x.current && e.observe(document.body, { childList: !0, subtree: !0 }), () => e.disconnect();
781
+ }, [N, ye]);
782
+ const pe = () => {
783
+ x.current && requestAnimationFrame(() => {
784
+ v(x.current);
769
785
  });
770
786
  };
771
- return lt(s, () => ({
772
- getCurrentValue: v,
773
- focus: ue
787
+ return ot(s, () => ({
788
+ getCurrentValue: V,
789
+ focus: pe
774
790
  })), // 最外层的防止renderContainer为false的时候样式坍塌
775
- /* @__PURE__ */ Y("div", { className: Se(`cosmic-ai-input-rows${g}`), style: { textIndent: T + "px" }, children: [
776
- de && /* @__PURE__ */ u(
791
+ /* @__PURE__ */ te("div", { className: De(`cosmic-ai-input-rows${E}`), style: { textIndent: T + "px" }, children: [
792
+ fe && /* @__PURE__ */ u(
777
793
  "div",
778
794
  {
779
795
  "data-set-type": "container",
780
796
  "data-cosmic-ai-input-placeholder": k,
781
- className: Se(
797
+ className: De(
782
798
  "cosmic-ai-input",
783
- `cosmic-ai-input-rows${g}`,
799
+ `cosmic-ai-input-rows${E}`,
784
800
  { "is-disabled": $ },
785
- { "is-empty": ne.length === 0 }
801
+ { "is-empty": re.length === 0 }
786
802
  ),
787
- ref: m,
803
+ ref: x,
788
804
  contentEditable: !0,
789
805
  suppressContentEditableWarning: !0,
790
- onClick: (n) => Oe(n),
791
- onFocus: (n) => {
792
- Ue(n);
806
+ onClick: (e) => Fe(e),
807
+ onFocus: (e) => {
808
+ We(e);
793
809
  },
794
- onBlur: (n) => {
795
- p == null || p(n);
810
+ onBlur: (e) => {
811
+ p == null || p(e);
796
812
  },
797
- onMouseDown: (n) => Ve(),
798
- onKeyDown: (n) => _e(n),
799
- onKeyUp: (n) => Ke(n),
800
- onInput: (n) => z(n),
801
- onCopy: (n) => ve(n),
802
- onCompositionStart: We,
803
- onCompositionEnd: ze,
804
- children: it
813
+ onMouseDown: (e) => Ve(),
814
+ onKeyDown: (e) => ve(e),
815
+ onKeyUp: (e) => _e(e),
816
+ onInput: (e) => z(e),
817
+ onCopy: (e) => Ue(e),
818
+ onPaste: (e) => Ke(e),
819
+ onCompositionStart: ze,
820
+ onCompositionEnd: je,
821
+ children: rt
805
822
  }
806
823
  ),
807
- U && ot(
808
- (C == null ? void 0 : C.type) === h.MULTIPLE_SELECT ? /* @__PURE__ */ u(
824
+ U && st(
825
+ (w == null ? void 0 : w.type) === h.MULTIPLE_SELECT ? /* @__PURE__ */ u(
809
826
  Be,
810
827
  {
811
828
  ref: B,
812
- options: re,
813
- value: G,
814
- position: X,
815
- height: se,
816
- onChange: Q
829
+ options: oe,
830
+ value: J,
831
+ position: G,
832
+ height: ae,
833
+ onChange: I
817
834
  },
818
835
  h.MULTIPLE_SELECT
819
- ) : (C == null ? void 0 : C.type) === h.DATE_PICKER ? /* @__PURE__ */ u(
836
+ ) : (w == null ? void 0 : w.type) === h.DATE_PICKER ? /* @__PURE__ */ u(
820
837
  $e,
821
838
  {
822
839
  ref: B,
823
- value: G,
824
- position: X,
825
- onChange: Q
840
+ value: J,
841
+ position: G,
842
+ onChange: I
826
843
  },
827
844
  h.DATE_PICKER
828
- ) : (C == null ? void 0 : C.type) === h.LABEL ? /* @__PURE__ */ u(
845
+ ) : (w == null ? void 0 : w.type) === h.LABEL ? /* @__PURE__ */ u(
829
846
  He,
830
847
  {
831
848
  ref: B,
832
- options: re,
833
- value: G,
834
- position: X,
835
- height: se,
836
- onChange: Q
849
+ options: oe,
850
+ value: J,
851
+ position: G,
852
+ height: ae,
853
+ onChange: I
837
854
  },
838
855
  h.LABEL
839
856
  ) : /* @__PURE__ */ u(
840
857
  Me,
841
858
  {
842
859
  ref: B,
843
- options: re,
844
- value: G,
845
- position: X,
846
- height: se,
847
- onChange: Q
860
+ options: oe,
861
+ value: J,
862
+ position: G,
863
+ height: ae,
864
+ onChange: I
848
865
  },
849
866
  h.SELECT
850
867
  ),
@@ -852,7 +869,7 @@ const ht = j((r, s) => {
852
869
  )
853
870
  ] });
854
871
  });
855
- ht.displayName = "AiInput";
872
+ gt.displayName = "AiInput";
856
873
  export {
857
- ht as default
874
+ gt as default
858
875
  };