@uiwwsw/virtual-keyboard 2.0.1 → 2.1.0

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.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsxs as Y, jsx as L, Fragment as Pe } from "react/jsx-runtime";
3
- import { useContext as tt, createContext as nt, forwardRef as rt, useId as qe, useRef as T, useState as $, useMemo as Fe, useCallback as E, useEffect as K, useImperativeHandle as ot, useLayoutEffect as at, createElement as ct } from "react";
4
- import { convertQwertyToHangul as Ye, assemble as it, removeLastCharacter as lt } from "es-hangul";
5
- import { createPortal as Ie } from "react-dom";
6
- class ut {
2
+ import { jsxs as q, jsx as T, Fragment as Me } from "react/jsx-runtime";
3
+ import { useContext as Oe, createContext as et, forwardRef as tt, useId as $e, useRef as I, useState as P, useMemo as He, useCallback as S, useEffect as z, useImperativeHandle as nt, useLayoutEffect as rt, createElement as at } from "react";
4
+ import { convertQwertyToHangul as Ue, assemble as ot, removeLastCharacter as it } from "es-hangul";
5
+ import { createPortal as Te } from "react-dom";
6
+ class ct {
7
7
  past = [];
8
8
  future = [];
9
9
  record(n, r) {
@@ -21,9 +21,9 @@ class ut {
21
21
  this.past = [], this.future = [];
22
22
  }
23
23
  }
24
- const Ze = nt(null);
25
- function _e() {
26
- const e = tt(Ze);
24
+ const We = et(null);
25
+ function Ze() {
26
+ const e = Oe(We);
27
27
  if (!e)
28
28
  throw new Error(
29
29
  "VirtualInput must be used within a <VirtualInputProvider>."
@@ -33,14 +33,14 @@ function _e() {
33
33
  function we(e) {
34
34
  return /^[\u1100-\u11FF\u3130-\u318F\uAC00-\uD7AF]$/.test(e);
35
35
  }
36
- function st(e, n) {
36
+ function lt(e, n) {
37
37
  if (e.key === "HangulMode") return { handled: !0, toggleHangulMode: !0 };
38
38
  if (e.ctrlKey || e.metaKey || e.altKey || [...e.key].length !== 1 || /[\r\n\t]/.test(e.key))
39
39
  return { handled: !1 };
40
- const r = n && /^[A-Za-z]$/.test(e.key) ? Ye(e.key) : e.key;
40
+ const r = n && /^[A-Za-z]$/.test(e.key) ? Ue(e.key) : e.key;
41
41
  return { handled: !0, text: r, composing: we(r) };
42
42
  }
43
- const ee = [
43
+ const re = [
44
44
  [
45
45
  {
46
46
  label: "q",
@@ -211,7 +211,7 @@ const ee = [
211
211
  width: 1.25
212
212
  }
213
213
  ]
214
- ], dt = [
214
+ ], ut = [
215
215
  [
216
216
  {
217
217
  label: "1",
@@ -280,7 +280,7 @@ const ee = [
280
280
  type: "action"
281
281
  }
282
282
  ]
283
- ], ft = [
283
+ ], st = [
284
284
  [
285
285
  {
286
286
  label: "1",
@@ -363,7 +363,7 @@ const ee = [
363
363
  }
364
364
  ]
365
365
  ];
366
- function ge(e) {
366
+ function me(e) {
367
367
  switch (e) {
368
368
  case "hangul":
369
369
  return !0;
@@ -376,34 +376,34 @@ function ge(e) {
376
376
  return null;
377
377
  }
378
378
  }
379
- const he = () => !0, pt = {
379
+ const ge = () => !0, dt = {
380
380
  text: {
381
381
  mode: "text",
382
- layout: ee,
383
- filterKey: he,
382
+ layout: re,
383
+ filterKey: ge,
384
384
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
385
385
  },
386
386
  number: {
387
387
  mode: "number",
388
- layout: dt,
388
+ layout: ut,
389
389
  filterKey: (e) => /^[0-9.]+$/.test(e),
390
390
  sanitizeValue: (e) => e.replace(/[^0-9.]/g, "")
391
391
  },
392
392
  tel: {
393
393
  mode: "tel",
394
- layout: ft,
394
+ layout: st,
395
395
  filterKey: (e) => /^[0-9*#+]+$/.test(e),
396
396
  sanitizeValue: (e) => e.replace(/[^0-9*#+]/g, "")
397
397
  },
398
398
  hangul: {
399
399
  mode: "hangul",
400
- layout: ee,
401
- filterKey: he,
400
+ layout: re,
401
+ filterKey: ge,
402
402
  sanitizeValue: (e) => e.replace(/[A-Za-z]/g, "")
403
403
  },
404
404
  alpha: {
405
405
  mode: "alpha",
406
- layout: ee,
406
+ layout: re,
407
407
  filterKey: (e) => /^[A-Za-z]+$/.test(e),
408
408
  sanitizeValue: (e) => e.replace(/[^A-Za-z]/g, "")
409
409
  },
@@ -411,64 +411,56 @@ const he = () => !0, pt = {
411
411
  mode: "alphanumeric",
412
412
  layout: [
413
413
  Array.from("1234567890", (e) => ({ value: e })),
414
- ...ee
414
+ ...re
415
415
  ],
416
416
  filterKey: (e) => /^[A-Za-z0-9]+$/.test(e),
417
417
  sanitizeValue: (e) => e.replace(/[^A-Za-z0-9]/g, "")
418
418
  },
419
419
  custom: {
420
420
  mode: "custom",
421
- layout: ee,
422
- filterKey: he,
421
+ layout: re,
422
+ filterKey: ge,
423
423
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
424
424
  }
425
425
  };
426
- function Le(e) {
427
- const n = e?.mode ?? "text", r = pt[n];
426
+ function Se(e) {
427
+ const n = e?.mode ?? "text", r = dt[n];
428
428
  return {
429
429
  mode: n,
430
- layout: e?.layout ?? r.layout ?? ee,
431
- filterKey: e?.filterKey ?? r.filterKey ?? he,
430
+ layout: e?.layout ?? r.layout ?? re,
431
+ filterKey: e?.filterKey ?? r.filterKey ?? ge,
432
432
  sanitizeValue: e?.sanitizeValue ?? r.sanitizeValue ?? ((a) => a)
433
433
  };
434
434
  }
435
- const ht = new Intl.Segmenter(void 0, { granularity: "grapheme" }), gt = new Intl.Segmenter(void 0, { granularity: "word" });
436
- function mt(e, n) {
437
- const r = Math.max(0, Math.min(n, e.length - 1));
438
- for (const a of gt.segment(e))
439
- if (r < a.index + a.segment.length)
440
- return [a.index, a.index + a.segment.length];
441
- return [0, 0];
442
- }
443
- const me = (e) => Array.from(ht.segment(e));
444
- function oe(e, n) {
435
+ const ft = new Intl.Segmenter(void 0, { granularity: "grapheme" }), Ve = (e) => Array.from(ft.segment(e));
436
+ function Z(e, n) {
445
437
  return [
446
- ...me(e).map((a) => a.index),
438
+ ...Ve(e).map((a) => a.index),
447
439
  e.length
448
440
  ].filter((a) => a <= Math.max(0, n)).at(-1) ?? 0;
449
441
  }
450
- function Ce(e, n, r) {
442
+ function Le(e, n, r) {
451
443
  const a = [
452
- ...me(e).map((i) => i.index),
444
+ ...Ve(e).map((i) => i.index),
453
445
  e.length
454
446
  ];
455
447
  return r < 0 ? a.filter((i) => i < n).at(-1) ?? 0 : a.find((i) => i > n) ?? e.length;
456
448
  }
457
- const te = ({ anchor: e, caret: n }) => [Math.min(e, n), Math.max(e, n)];
458
- function wt(e, n, r = !1, a) {
459
- const [i, s] = te(e);
460
- let m = e.value.slice(0, i), v = n;
461
- i === s && e.composing && r && we(m.at(-1) ?? "") && (v = it([m.at(-1), n]), m = m.slice(0, -1));
462
- const d = m + v + e.value.slice(s);
463
- if (a !== void 0 && d.length > a) return e;
464
- const k = m.length + v.length;
465
- return { value: d, caret: k, anchor: k, composing: r };
449
+ const ae = ({ anchor: e, caret: n }) => [Math.min(e, n), Math.max(e, n)];
450
+ function qe(e, n, r = !1, a) {
451
+ const [i, s] = ae(e);
452
+ let f = e.value.slice(0, i), v = n;
453
+ i === s && e.composing && r && we(f.at(-1) ?? "") && (v = ot([f.at(-1), n]), f = f.slice(0, -1));
454
+ const c = f + v + e.value.slice(s);
455
+ if (a !== void 0 && c.length > a) return e;
456
+ const m = f.length + v.length;
457
+ return { value: c, caret: m, anchor: m, composing: r };
466
458
  }
467
- function ke(e, n) {
468
- let [r, a] = te(e);
459
+ function ve(e, n) {
460
+ let [r, a] = ae(e);
469
461
  if (r === a) {
470
462
  if (n < 0 && e.composing && we(e.value[r - 1] ?? "")) {
471
- const i = e.value.slice(0, r - 1) + lt(e.value[r - 1]);
463
+ const i = e.value.slice(0, r - 1) + it(e.value[r - 1]);
472
464
  return {
473
465
  value: i + e.value.slice(a),
474
466
  anchor: i.length,
@@ -476,7 +468,7 @@ function ke(e, n) {
476
468
  composing: !0
477
469
  };
478
470
  }
479
- n < 0 ? r = Ce(e.value, r, -1) : a = Ce(e.value, a, 1);
471
+ n < 0 ? r = Le(e.value, r, -1) : a = Le(e.value, a, 1);
480
472
  }
481
473
  return {
482
474
  value: e.value.slice(0, r) + e.value.slice(a),
@@ -485,8 +477,8 @@ function ke(e, n) {
485
477
  composing: !1
486
478
  };
487
479
  }
488
- function je(e, n, r = !1) {
489
- const [a, i] = te(e), s = n === "home" ? 0 : n === "end" ? e.value.length : !r && a !== i ? n < 0 ? a : i : Ce(e.value, e.caret, n);
480
+ function Fe(e, n, r = !1) {
481
+ const [a, i] = ae(e), s = n === "home" ? 0 : n === "end" ? e.value.length : !r && a !== i ? n < 0 ? a : i : Le(e.value, e.caret, n);
490
482
  return {
491
483
  ...e,
492
484
  caret: s,
@@ -494,279 +486,271 @@ function je(e, n, r = !1) {
494
486
  composing: !1
495
487
  };
496
488
  }
497
- function Ae(e) {
498
- const n = e.ownerDocument.getSelection();
499
- if (!n?.anchorNode || !n.focusNode || !e.contains(n.anchorNode) || !e.contains(n.focusNode))
500
- return null;
501
- const r = (i, s) => s >= 0 && s <= (i.nodeType === Node.TEXT_NODE ? i.textContent?.length ?? 0 : i.childNodes.length);
502
- if (!r(n.anchorNode, n.anchorOffset) || !r(n.focusNode, n.focusOffset))
503
- return null;
504
- const a = (i, s) => {
505
- const m = e.ownerDocument.createRange();
506
- return m.selectNodeContents(e), m.setEnd(i, s), m.toString().length;
507
- };
489
+ function pt(e, n, r, a, i, s) {
490
+ if (n === e.value) return e;
491
+ let f = 0;
492
+ for (; f < e.value.length && f < n.length && e.value[f] === n[f]; )
493
+ f++;
494
+ f = Math.min(
495
+ Z(e.value, f),
496
+ Z(n, f)
497
+ );
498
+ let v = e.value.length, c = n.length;
499
+ for (; v > f && c > f && e.value[v - 1] === n[c - 1]; )
500
+ v--, c--;
501
+ for (; Z(e.value, v) !== v || Z(n, c) !== c; )
502
+ v < e.value.length && v++, c < n.length && c++;
503
+ const m = n.slice(f, c), p = a(m).replace(/[\r\n\t]+/g, " ");
504
+ if (m && (!p || !i(p))) return e;
505
+ const l = { ...e, anchor: f, caret: v, composing: !1 }, u = m ? qe(l, p, !1, s) : ve(l, -1);
506
+ if (u === l) return e;
507
+ const V = (w) => Z(
508
+ u.value,
509
+ w <= f ? w : w >= c ? w + p.length - m.length : f + a(m.slice(0, w - f)).replace(/[\r\n\t]+/g, " ").length
510
+ );
508
511
  return {
509
- anchor: a(n.anchorNode, n.anchorOffset),
510
- caret: a(n.focusNode, n.focusOffset)
512
+ ...u,
513
+ anchor: V(r.backward ? r.end : r.start),
514
+ caret: V(r.backward ? r.start : r.end)
511
515
  };
512
516
  }
513
- function vt(e, n, r) {
514
- const a = e.ownerDocument.getSelection();
515
- if (!a) return;
516
- const i = Ae(e);
517
- if (i?.anchor === n && i.caret === r) return;
518
- const s = (p) => {
519
- const l = e.ownerDocument.createTreeWalker(
520
- e,
521
- NodeFilter.SHOW_TEXT
522
- );
523
- let u = l.nextNode(), P = p;
524
- for (; u; ) {
525
- const w = u.textContent?.length ?? 0;
526
- if (P <= w) return [u, P];
527
- P -= w, u = l.nextNode();
528
- }
529
- return [e, e.childNodes.length];
530
- }, [m, v] = s(n), [d, k] = s(r);
531
- a.setBaseAndExtent(m, v, d, k);
532
- }
533
- const Xe = typeof window > "u" ? K : at, Dt = rt(
517
+ const ht = typeof window > "u" ? z : rt, Mt = tt(
534
518
  function({
535
519
  value: n,
536
520
  defaultValue: r = "",
537
521
  placeholder: a,
538
522
  onChange: i,
539
523
  onValueChange: s,
540
- onClipboardError: m,
524
+ onClipboardError: f,
541
525
  mode: v = "text",
542
- layout: d,
543
- filterKey: k,
526
+ layout: c,
527
+ filterKey: m,
544
528
  sanitizeValue: p,
545
529
  disabled: l = !1,
546
530
  readOnly: u = !1,
547
- maxLength: P,
531
+ maxLength: V,
548
532
  ...w
549
- }, _) {
550
- const B = qe(), {
551
- focusId: ae,
552
- onFocus: Z,
533
+ }, Q) {
534
+ const H = $e(), {
535
+ focusId: le,
536
+ onFocus: te,
553
537
  onBlur: F,
554
- defaultLayout: O,
538
+ defaultLayout: oe,
555
539
  inputRef: X,
556
- hangulMode: ce,
557
- theme: ie,
558
- toggleKorean: h,
559
- setEditingStatus: b
560
- } = _e(), g = T(null), A = T(null), I = T(null), U = T(!1), [C, J] = $(() => ({
540
+ hangulMode: J,
541
+ theme: ue,
542
+ toggleKorean: g,
543
+ setEditingStatus: L
544
+ } = Ze(), y = I(null), A = I(null), x = I(!1), B = I(!1), R = I(null), [Y, N] = P(null), [b, O] = P(!1), [U, de] = P(() => ({
561
545
  value: n ?? r,
562
546
  caret: (n ?? r).length,
563
547
  anchor: (n ?? r).length,
564
548
  composing: !1
565
- })), M = n ?? C.value, c = T(C), W = T(0), ne = T(new ut()), G = T(!1), V = ae === B, Q = T(V);
566
- Q.current = V;
567
- const le = n !== void 0 && n !== C.value;
568
- le && ne.current.clear(), c.current = {
569
- ...C,
570
- value: M,
571
- caret: oe(M, C.caret),
572
- anchor: oe(M, C.anchor),
573
- composing: le ? !1 : C.composing
549
+ })), W = n ?? U.value, d = I(U), ne = I(0), ie = I(new ct()), G = I(!1), h = le === H, k = I(h);
550
+ k.current = h;
551
+ const $ = n !== void 0 && n !== U.value;
552
+ $ && ie.current.clear(), d.current = {
553
+ ...U,
554
+ value: W,
555
+ caret: Z(W, U.caret),
556
+ anchor: Z(W, U.anchor),
557
+ composing: $ ? !1 : U.composing
574
558
  };
575
- const j = Fe(
576
- () => Le({
559
+ const j = He(
560
+ () => Se({
577
561
  mode: v,
578
- layout: d ?? (v === "text" || v === "custom" ? O : void 0),
579
- filterKey: k,
562
+ layout: c ?? (v === "text" || v === "custom" ? oe : void 0),
563
+ filterKey: m,
580
564
  sanitizeValue: p
581
565
  }),
582
- [v, d, O, k, p]
583
- ), [y, D] = $(""), q = T(
584
- void 0
585
- ), R = T(null), z = E(() => {
586
- clearTimeout(q.current), R.current = null;
587
- }, []);
588
- K(() => {
589
- (l || u) && z();
590
- }, [l, u, z]), K(() => {
591
- const t = (o) => {
592
- R.current && R.current.id !== o.pointerId && z();
593
- };
594
- return window.addEventListener("blur", z), window.addEventListener("scroll", z, !0), window.addEventListener("pointerdown", t, !0), document.addEventListener("visibilitychange", z), () => {
595
- z(), window.removeEventListener("blur", z), window.removeEventListener("scroll", z, !0), window.removeEventListener("pointerdown", t, !0), document.removeEventListener("visibilitychange", z);
596
- };
597
- }, [z]);
598
- const S = E(
599
- (t, o = !0, f = !1) => {
600
- const x = c.current.value;
601
- if (o && ne.current.record(c.current, t), U.current = !f, c.current = t, W.current++, D(""), J(t), t.value !== x) {
566
+ [v, c, oe, m, p]
567
+ ), [ye, fe] = P(""), E = S(
568
+ (t, o = !0, C = !1) => {
569
+ const K = d.current.value;
570
+ if (o && ie.current.record(d.current, t), x.current = !C, d.current = t, ne.current++, fe(""), de(t), t.value !== K) {
602
571
  s?.(t.value);
603
- const N = { value: t.value };
572
+ const M = { value: t.value };
604
573
  i?.({
605
- target: N,
606
- currentTarget: N
574
+ target: M,
575
+ currentTarget: M
607
576
  });
608
577
  }
609
578
  },
610
579
  [i, s]
611
- ), H = E(() => {
580
+ ), D = S(() => {
612
581
  const t = A.current;
613
- if (!t || l || U.current || t.textContent !== c.current.value)
582
+ if (!t || l || x.current || t.value !== d.current.value || B.current)
614
583
  return null;
615
- const o = Ae(t);
616
- if (!o) return null;
617
- const f = oe(c.current.value, o.anchor), x = oe(c.current.value, o.caret);
618
- return (f !== c.current.anchor || x !== c.current.caret || f !== o.anchor || x !== o.caret) && S(
619
- { ...c.current, anchor: f, caret: x, composing: !1 },
584
+ const o = t.selectionStart ?? 0, C = t.selectionEnd ?? o, K = t.selectionDirection === "backward" ? { anchor: C, caret: o } : { anchor: o, caret: C }, M = Z(d.current.value, K.anchor), _ = Z(d.current.value, K.caret);
585
+ return (M !== d.current.anchor || _ !== d.current.caret || M !== K.anchor || _ !== K.caret) && E(
586
+ { ...d.current, anchor: M, caret: _, composing: !1 },
620
587
  !1,
621
- f === o.anchor && x === o.caret
622
- ), { anchor: f, caret: x };
623
- }, [l, S]);
624
- K(() => {
588
+ M === K.anchor && _ === K.caret
589
+ ), { anchor: M, caret: _ };
590
+ }, [l, E]);
591
+ z(() => {
625
592
  const t = () => {
626
- const o = H();
627
- o && o.anchor !== o.caret && (clearTimeout(q.current), R.current && (R.current.held = !0), !u && g.current && !Q.current && (g.current.focus({ preventScroll: !0 }), Z(B, g.current, j)));
593
+ document.activeElement === A.current && D();
594
+ }, o = A.current;
595
+ return document.addEventListener("selectionchange", t), o?.addEventListener("select", t), () => {
596
+ document.removeEventListener("selectionchange", t), o?.removeEventListener("select", t);
628
597
  };
629
- return document.addEventListener("selectionchange", t), () => document.removeEventListener("selectionchange", t);
630
- }, [H, u, Z, B, j]), Xe(() => {
631
- (V || document.activeElement === g.current) && !l && A.current && (U.current || le) && vt(
632
- A.current,
633
- c.current.anchor,
634
- c.current.caret
635
- ), U.current = !1;
636
- }), K(() => {
637
- if (!V) return;
638
- const [t, o] = te(c.current);
639
- b({
640
- selectionLength: me(M.slice(t, o)).length,
641
- hasValue: !!M,
642
- message: y
598
+ }, [D]), ht(() => {
599
+ if (R.current && R.current.value !== W && (B.current = !1, R.current = null, N(null)), !l && A.current && !B.current && (x.current || $)) {
600
+ const { anchor: t, caret: o } = d.current, C = Math.min(t, o), K = Math.max(t, o), M = t > o ? "backward" : "forward";
601
+ (A.current.selectionStart !== C || A.current.selectionEnd !== K || C !== K && A.current.selectionDirection !== M) && A.current.setSelectionRange(C, K, M);
602
+ }
603
+ x.current = !1;
604
+ }), z(() => {
605
+ if (!h) return;
606
+ const [t, o] = ae(d.current);
607
+ L({
608
+ selectionLength: Ve(W.slice(t, o)).length,
609
+ hasValue: !!W,
610
+ message: ye
643
611
  });
644
612
  }, [
645
- M,
646
- C.anchor,
647
- C.caret,
648
- y,
649
- V,
650
- b
613
+ W,
614
+ U.anchor,
615
+ U.caret,
616
+ ye,
617
+ h,
618
+ L
651
619
  ]);
652
- const re = E(
620
+ const ce = S(
653
621
  (t, o = !1) => {
654
622
  if (l || u) return;
655
- H();
656
- const f = j.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
657
- f && S(wt(c.current, f, o, P));
623
+ D();
624
+ const C = j.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
625
+ C && E(qe(d.current, C, o, V));
658
626
  },
659
- [l, u, j, P, S, H]
660
- ), ve = E(() => {
661
- !l && !u && S(ne.current.undo(c.current), !1);
662
- }, [l, u, S]), ye = E(() => {
663
- !l && !u && S(ne.current.redo(c.current), !1);
664
- }, [l, u, S]), De = E(
665
- () => S({
666
- ...c.current,
667
- caret: c.current.value.length,
627
+ [l, u, j, V, E, D]
628
+ ), be = S(() => {
629
+ !l && !u && E(ie.current.undo(d.current), !1);
630
+ }, [l, u, E]), xe = S(() => {
631
+ !l && !u && E(ie.current.redo(d.current), !1);
632
+ }, [l, u, E]), Ke = S(
633
+ () => E({
634
+ ...d.current,
635
+ caret: d.current.value.length,
668
636
  anchor: 0,
669
637
  composing: !1
670
638
  }),
671
- [S]
672
- ), Ke = E(
639
+ [E]
640
+ ), Ie = S(
673
641
  (t, o = !1) => {
674
- H(), S(je(c.current, t === "left" ? -1 : 1, o));
642
+ D(), E(Fe(d.current, t === "left" ? -1 : 1, o));
675
643
  },
676
- [S, H]
677
- ), Ge = (t) => {
678
- if (w.onKeyDown?.(t), t.defaultPrevented || l) return;
679
- H();
644
+ [E, D]
645
+ ), Ye = (t) => {
646
+ if (w.onKeyDown?.(t), t.defaultPrevented || l || B.current || t.nativeEvent.isComposing || t.keyCode === 229)
647
+ return;
648
+ D();
680
649
  const o = t.key;
681
650
  if (o === "Escape") {
682
- t.preventDefault(), S({ ...c.current, composing: !1 }), F(!0), g.current?.blur();
651
+ t.preventDefault(), E({ ...d.current, composing: !1 }), F(!0), A.current?.blur();
683
652
  return;
684
653
  }
685
654
  if (o === "HangulMode") {
686
- t.preventDefault(), S({ ...c.current, composing: !1 }), h();
655
+ t.preventDefault(), E({ ...d.current, composing: !1 }), g();
687
656
  return;
688
657
  }
689
- const f = t.ctrlKey || t.metaKey;
690
- if (f && ["z", "y"].includes(o.toLowerCase())) {
691
- t.preventDefault(), o.toLowerCase() === "y" || t.shiftKey ? ye() : ve();
658
+ const C = t.ctrlKey || t.metaKey;
659
+ if (C && ["z", "y"].includes(o.toLowerCase())) {
660
+ t.preventDefault(), o.toLowerCase() === "y" || t.shiftKey ? xe() : be();
692
661
  return;
693
662
  }
694
- if (f && o.toLowerCase() === "a") {
695
- t.preventDefault(), S({
696
- ...c.current,
697
- caret: c.current.value.length,
663
+ if (C && o.toLowerCase() === "a") {
664
+ t.preventDefault(), E({
665
+ ...d.current,
666
+ caret: d.current.value.length,
698
667
  anchor: 0,
699
668
  composing: !1
700
669
  });
701
670
  return;
702
671
  }
703
- const x = o === "Home" || o === "ArrowUp" || f && o === "ArrowLeft" ? "home" : o === "End" || o === "ArrowDown" || f && o === "ArrowRight" ? "end" : o === "ArrowLeft" ? -1 : o === "ArrowRight" ? 1 : null;
704
- if (x !== null) {
705
- t.preventDefault(), S(je(c.current, x, t.shiftKey));
672
+ const K = o === "Home" || o === "ArrowUp" || C && o === "ArrowLeft" ? "home" : o === "End" || o === "ArrowDown" || C && o === "ArrowRight" ? "end" : o === "ArrowLeft" ? -1 : o === "ArrowRight" ? 1 : null;
673
+ if (K !== null) {
674
+ t.preventDefault(), E(Fe(d.current, K, t.shiftKey));
706
675
  return;
707
676
  }
708
677
  if (o === "Tab" || o === "Enter") {
709
- S({ ...c.current, composing: !1 });
678
+ o === "Enter" && t.preventDefault(), E({ ...d.current, composing: !1 });
710
679
  return;
711
680
  }
712
681
  if (u) return;
713
682
  if (o === "Backspace" || o === "Delete") {
714
- t.preventDefault(), S(ke(c.current, o === "Backspace" ? -1 : 1));
683
+ t.preventDefault(), E(ve(d.current, o === "Backspace" ? -1 : 1));
715
684
  return;
716
685
  }
717
- const N = st(
686
+ const M = lt(
718
687
  t,
719
- ge(j.mode) ?? ce
688
+ me(j.mode) ?? J
720
689
  );
721
- N.handled && N.text && (t.preventDefault(), j.filterKey(N.text) && re(N.text, N.composing));
722
- }, de = E(
690
+ M.handled && M.text && (t.preventDefault(), j.filterKey(M.text) && ce(M.text, M.composing));
691
+ }, pe = S(
723
692
  (t) => {
724
693
  const o = t instanceof Error ? t : new Error(String(t));
725
- G.current && (D(
726
- "클립보드에 접근할 수 없습니다. 선택한 글자를 길게 눌러 기본 복사 메뉴를 사용해 주세요."
727
- ), m?.(o));
694
+ G.current && (fe(
695
+ "클립보드에 접근할 수 없습니다. 입력란을 길게 눌러 기본 편집 메뉴를 사용해 주세요."
696
+ ), f?.(o));
728
697
  },
729
- [m]
730
- ), fe = E(async () => {
731
- H();
732
- const [t, o] = te(c.current);
698
+ [f]
699
+ ), he = S(async () => {
700
+ D();
701
+ const [t, o] = ae(d.current);
733
702
  if (t === o) return;
734
- const f = c.current.value.slice(t, o);
703
+ const C = d.current.value, K = d.current.value.slice(t, o);
735
704
  try {
736
705
  if (!navigator.clipboard?.writeText)
737
706
  throw new Error("Clipboard API unavailable");
738
- await navigator.clipboard.writeText(f);
739
- } catch (x) {
740
- if (!A.current || document.getSelection()?.toString() !== f || !document.execCommand?.("copy"))
741
- throw x;
707
+ await navigator.clipboard.writeText(K);
708
+ } catch (M) {
709
+ D();
710
+ const _ = A.current, [Ge, Qe] = ae(d.current);
711
+ if (!_ || !G.current || d.current.value !== C || Ge !== t || Qe !== o)
712
+ throw M;
713
+ let ee = document.activeElement;
714
+ const Re = ee?.hasAttribute(
715
+ "data-virtual-keypad"
716
+ );
717
+ if (ee !== _ && !Re) throw M;
718
+ for (; ee?.shadowRoot?.activeElement; )
719
+ ee = ee.shadowRoot.activeElement;
720
+ _.focus({ preventScroll: !0 });
721
+ try {
722
+ if (!document.execCommand?.("copy")) throw M;
723
+ } finally {
724
+ ee instanceof HTMLElement && ee !== _ && Re && ee.focus({ preventScroll: !0 });
725
+ }
742
726
  }
743
- G.current && D("복사했어요");
744
- }, [H]), Ve = E(async () => {
727
+ G.current && fe("복사했어요");
728
+ }, [D]), Pe = S(async () => {
745
729
  if (l || u) return;
746
- H();
747
- const t = c.current, o = W.current;
748
- t.anchor !== t.caret && (await fe(), G.current && Q.current && W.current === o && c.current.value === t.value && S(ke(t, -1)));
749
- }, [l, u, fe, S, H]), ze = E(async () => {
730
+ D();
731
+ const t = d.current, o = ne.current;
732
+ t.anchor !== t.caret && (await he(), G.current && k.current && ne.current === o && d.current.value === t.value && E(ve(t, -1)));
733
+ }, [l, u, he, E, D]), De = S(async () => {
750
734
  if (l || u) return;
751
- H();
752
- const t = W.current, o = c.current.value, f = await navigator.clipboard.readText();
753
- G.current && Q.current && W.current === t && c.current.value === o && re(f);
754
- }, [l, u, re, H]), ue = Fe(
735
+ D();
736
+ const t = ne.current, o = d.current.value, C = await navigator.clipboard.readText();
737
+ G.current && k.current && ne.current === t && d.current.value === o && ce(C);
738
+ }, [l, u, ce, D]), se = He(
755
739
  () => ({
756
740
  focus: (t) => {
757
- l || g.current?.focus(t);
741
+ l || A.current?.focus(t);
758
742
  },
759
743
  blur: () => {
760
- g.current?.blur(), Q.current && F(!0);
744
+ A.current?.blur(), k.current && F(!0);
761
745
  },
762
- getValue: () => c.current.value,
763
- setSelectionRange: (t, o) => S({
764
- ...c.current,
765
- anchor: oe(c.current.value, t),
766
- caret: oe(c.current.value, o),
746
+ getValue: () => d.current.value,
747
+ setSelectionRange: (t, o) => E({
748
+ ...d.current,
749
+ anchor: Z(d.current.value, t),
750
+ caret: Z(d.current.value, o),
767
751
  composing: !1
768
752
  }),
769
- handleKeyDown: (t) => g.current?.dispatchEvent(
753
+ handleKeyDown: (t) => A.current?.dispatchEvent(
770
754
  new KeyboardEvent("keydown", {
771
755
  key: t.key,
772
756
  shiftKey: t.shiftKey,
@@ -779,153 +763,90 @@ const Xe = typeof window > "u" ? K : at, Dt = rt(
779
763
  })
780
764
  ),
781
765
  insertText: (t, o) => {
782
- j.filterKey(t) && re(t, o);
766
+ j.filterKey(t) && ce(t, o);
783
767
  },
784
- scrollIntoView: () => g.current?.scrollIntoView({ block: "nearest", inline: "nearest" }),
785
- moveCaret: Ke,
786
- undo: ve,
787
- redo: ye,
788
- selectAll: De,
789
- copySelection: () => fe().catch(de),
790
- pasteClipboard: () => ze().catch(de),
791
- cutSelection: () => Ve().catch(de)
768
+ scrollIntoView: () => y.current?.scrollIntoView({ block: "nearest", inline: "nearest" }),
769
+ moveCaret: Ie,
770
+ undo: be,
771
+ redo: xe,
772
+ selectAll: Ke,
773
+ copySelection: () => he().catch(pe),
774
+ pasteClipboard: () => De().catch(pe),
775
+ cutSelection: () => Pe().catch(pe)
792
776
  }),
793
777
  [
794
778
  j,
795
- re,
796
- Ke,
797
- fe,
798
- ze,
799
- Ve,
800
- de,
801
- ve,
802
- ye,
779
+ ce,
780
+ Ie,
781
+ he,
803
782
  De,
783
+ Pe,
784
+ pe,
785
+ be,
786
+ xe,
787
+ Ke,
804
788
  l,
805
789
  F,
806
- S
790
+ E
807
791
  ]
808
792
  );
809
- ot(_, () => ue, [ue]), K(() => {
810
- V || J(
793
+ nt(Q, () => se, [se]), z(() => {
794
+ h || de(
811
795
  (t) => t.composing ? { ...t, composing: !1 } : t
812
796
  );
813
- }, [V]), K(() => {
814
- if (!(!V || l || u))
815
- return X.current = ue, () => {
816
- X.current === ue && (X.current = null);
797
+ }, [h]), z(() => {
798
+ if (!(!h || l || u))
799
+ return X.current = se, () => {
800
+ X.current === se && (X.current = null);
817
801
  };
818
- }, [V, l, u, ue, X]), K(() => {
819
- V && g.current && (l || u ? F(!0) : Z(B, g.current, j));
820
- }, [V, l, u, B, j, Z, F]), K(() => (G.current = !0, () => {
821
- G.current = !1, clearTimeout(q.current), Q.current && F(!0);
822
- }), [F]), Xe(() => {
823
- if (!g.current || !A.current || !I.current)
824
- return;
825
- const t = () => {
826
- const f = g.current, x = A.current, N = f.getBoundingClientRect(), $e = x.querySelector(
827
- `[data-char-index="${c.current.caret}"]`
828
- ), pe = ($e ?? x).getBoundingClientRect(), se = $e || !c.current.value ? pe.left : pe.right;
829
- Object.assign(I.current.style, {
830
- left: `${se - N.left + f.scrollLeft - f.clientLeft}px`,
831
- top: `${pe.top - N.top + f.scrollTop - f.clientTop}px`,
832
- height: `${pe.height}px`
833
- }), !(!V || c.current.anchor !== c.current.caret) && (se > N.right - 12 ? f.scrollLeft += se - N.right + 12 : se < N.left + 12 && (f.scrollLeft -= N.left + 12 - se));
834
- };
835
- t();
836
- const o = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
837
- return o?.observe(g.current), () => o?.disconnect();
838
- }, [M, C.caret, C.anchor, V]);
839
- const Ne = (t, o) => {
840
- if (o ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || o && u) return;
841
- const f = document.getSelection();
842
- if (f && !f.isCollapsed && A.current && !Ae(A.current))
843
- return;
844
- H();
845
- const [x, N] = te(c.current);
846
- x !== N && (t.preventDefault(), t.clipboardData.setData(
802
+ }, [h, l, u, se, X]), z(() => {
803
+ h && y.current && (l || u ? F(!0) : te(H, y.current, j));
804
+ }, [h, l, u, H, j, te, F]), z(() => (G.current = !0, () => {
805
+ G.current = !1, k.current && F(!0);
806
+ }), [F]);
807
+ const ze = (t, o) => {
808
+ if (o ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || o && u || t.target !== A.current) return;
809
+ D();
810
+ const [C, K] = ae(d.current);
811
+ C !== K && (t.preventDefault(), t.clipboardData.setData(
847
812
  "text/plain",
848
- c.current.value.slice(x, N)
849
- ), o ? S(ke(c.current, -1)) : D("복사했어요"));
850
- }, be = (t, o = !0) => {
851
- for (const f of g.current?.querySelectorAll(
852
- "[data-char-index]"
853
- ) ?? []) {
854
- const x = f.getBoundingClientRect();
855
- if (t < x.left + x.width * (o ? 0.5 : 1))
856
- return Number(f.dataset.charIndex);
857
- }
858
- return c.current.value.length;
859
- }, xe = () => {
860
- g.current?.focus({ preventScroll: !0 }), !u && g.current && Z(B, g.current, j);
813
+ d.current.value.slice(C, K)
814
+ ), o ? E(ve(d.current, -1)) : fe("복사했어요"));
861
815
  }, Be = (t) => {
862
- const [o, f] = mt(
863
- c.current.value,
864
- be(t, !1)
865
- );
866
- xe(), S({ ...c.current, anchor: o, caret: f, composing: !1 });
867
- }, Qe = (t) => {
868
- if (w.onPointerDown?.(t), t.defaultPrevented || l || t.button !== 0) return;
869
- const o = t.pointerType === "mouse";
870
- if (R.current || t.isPrimary === !1) {
871
- z();
872
- return;
873
- }
874
- const f = be(t.clientX), x = t.shiftKey ? c.current.anchor : f;
875
- R.current = {
876
- id: t.pointerId,
877
- x: t.clientX,
878
- y: t.clientY,
879
- anchor: x,
880
- mouse: o,
881
- held: !1
882
- }, clearTimeout(q.current), o ? xe() : q.current = setTimeout(() => {
883
- R.current && (R.current.held = !0, Be(R.current.x));
884
- }, 550);
885
- }, [Re, He] = te(c.current), Oe = me(M), et = /* @__PURE__ */ L(
886
- "span",
887
- {
888
- ref: I,
889
- "aria-hidden": "true",
890
- className: "vk-caret",
891
- style: {
892
- display: V && !u && !l && Re === He ? "block" : "none",
893
- width: 0,
894
- height: "1.1em",
895
- position: "absolute",
896
- pointerEvents: "none",
897
- userSelect: "none"
816
+ if (l || u) return;
817
+ const o = pt(
818
+ d.current,
819
+ t.value,
820
+ {
821
+ start: t.selectionStart ?? t.value.length,
822
+ end: t.selectionEnd ?? t.value.length,
823
+ backward: t.selectionDirection === "backward"
898
824
  },
899
- children: V && !u && !l && Re === He && /* @__PURE__ */ L(
900
- "span",
901
- {
902
- style: {
903
- position: "absolute",
904
- height: "100%",
905
- borderLeft: "2px solid currentColor"
906
- }
907
- }
825
+ j.sanitizeValue,
826
+ j.filterKey,
827
+ V
828
+ );
829
+ t.value = o.value, E({ ...o });
830
+ }, _e = Object.fromEntries(
831
+ Object.entries(w).filter(([t]) => t.startsWith("aria-"))
832
+ ), Je = Object.fromEntries(
833
+ Object.entries(w).filter(
834
+ ([t]) => !t.startsWith("aria-") && !["id", "tabIndex", "role", "contentEditable", "children"].includes(
835
+ t
908
836
  )
909
- }
837
+ )
910
838
  );
911
- return /* @__PURE__ */ Y(
839
+ return /* @__PURE__ */ q(
912
840
  "div",
913
841
  {
914
- ...w,
915
- ref: g,
916
- id: w.id ?? B,
917
- role: "textbox",
918
- tabIndex: l ? -1 : w.tabIndex ?? 0,
919
- "aria-disabled": l || void 0,
920
- "aria-readonly": u || void 0,
921
- "aria-multiline": "false",
922
- "aria-placeholder": a,
842
+ ...Je,
843
+ ref: y,
923
844
  "data-virtual-input": "true",
924
- "data-focused": V || void 0,
925
- "data-value": M,
845
+ "data-focused": h || void 0,
926
846
  style: {
927
- display: "block",
928
847
  position: "relative",
848
+ display: "flex",
849
+ alignItems: "center",
929
850
  boxSizing: "border-box",
930
851
  minHeight: "2.75em",
931
852
  padding: "0.65em 0.8em",
@@ -933,86 +854,89 @@ const Xe = typeof window > "u" ? K : at, Dt = rt(
933
854
  borderRadius: 8,
934
855
  font: "inherit",
935
856
  width: "100%",
936
- whiteSpace: "pre",
937
- overflowX: "auto",
938
- scrollbarWidth: "none",
939
857
  cursor: l ? "not-allowed" : "text",
940
- userSelect: l ? "none" : "text",
941
- WebkitUserSelect: l ? "none" : "text",
942
- WebkitTouchCallout: "default",
943
- touchAction: "manipulation",
944
858
  opacity: l ? 0.5 : 1,
945
- outlineOffset: 3,
859
+ colorScheme: ue,
860
+ outline: b ? "2px solid currentColor" : void 0,
861
+ outlineOffset: 2,
946
862
  ...w.style
947
863
  },
948
864
  onFocus: (t) => {
949
- w.onFocus?.(t), !t.defaultPrevented && !l && !u && Z(B, t.currentTarget, j);
865
+ O(!0), w.onFocus?.(t), !t.defaultPrevented && !l && !u && te(H, t.currentTarget, j);
950
866
  },
951
867
  onBlur: (t) => {
952
- w.onBlur?.(t), z(), t.defaultPrevented || F(t);
868
+ O(!1), w.onBlur?.(t), t.defaultPrevented || F(t);
953
869
  },
954
- onKeyDown: Ge,
955
- onCopy: (t) => Ne(t, !1),
956
- onCut: (t) => Ne(t, !0),
870
+ onKeyDown: Ye,
871
+ onCopy: (t) => ze(t, !1),
872
+ onCut: (t) => ze(t, !0),
957
873
  onPaste: (t) => {
958
- w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), re(t.clipboardData.getData("text/plain")));
959
- },
960
- onPointerDown: Qe,
961
- onDoubleClick: (t) => {
962
- w.onDoubleClick?.(t), !(t.defaultPrevented || l || t.button !== 0) && (t.preventDefault(), Be(t.clientX));
963
- },
964
- onPointerMove: (t) => {
965
- if (w.onPointerMove?.(t), t.defaultPrevented) {
966
- z();
967
- return;
968
- }
969
- !R.current || R.current.id !== t.pointerId || Math.hypot(
970
- t.clientX - R.current.x,
971
- t.clientY - R.current.y
972
- ) > 8 && (clearTimeout(q.current), R.current.mouse || z());
973
- },
974
- onPointerUp: (t) => {
975
- w.onPointerUp?.(t);
976
- const o = R.current;
977
- if (!t.defaultPrevented && o?.id === t.pointerId && !o.held && Math.hypot(t.clientX - o.x, t.clientY - o.y) <= 8) {
978
- const f = H();
979
- if (!f || !o.mouse && f.anchor === f.caret) {
980
- const x = be(t.clientX);
981
- xe(), S({
982
- ...c.current,
983
- caret: x,
984
- anchor: t.shiftKey ? o.anchor : x,
985
- composing: !1
986
- });
987
- }
988
- }
989
- z();
990
- },
991
- onPointerCancel: (t) => {
992
- w.onPointerCancel?.(t), z();
993
- },
994
- onLostPointerCapture: (t) => {
995
- w.onLostPointerCapture?.(t), R.current?.id === t.pointerId && z();
996
- },
997
- onContextMenu: (t) => {
998
- w.onContextMenu?.(t), t.defaultPrevented || H();
874
+ w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), ce(t.clipboardData.getData("text/plain")));
999
875
  },
1000
876
  children: [
1001
- /* @__PURE__ */ L("span", { ref: A, "data-input-text": "true", children: Oe.map(({ segment: t, index: o }) => /* @__PURE__ */ L("span", { "data-char-index": o, children: t }, o)) }),
1002
- et,
1003
- !M && /* @__PURE__ */ L(
1004
- "span",
877
+ /* @__PURE__ */ T(
878
+ "input",
1005
879
  {
1006
- "aria-hidden": "true",
880
+ ..._e,
881
+ ref: A,
882
+ id: w.id ?? H,
883
+ type: "text",
884
+ role: "textbox",
885
+ inputMode: "none",
886
+ autoComplete: "off",
887
+ autoCorrect: "off",
888
+ autoCapitalize: "off",
889
+ spellCheck: w.spellCheck ?? !1,
890
+ tabIndex: l ? -1 : w.tabIndex ?? 0,
891
+ disabled: l,
892
+ readOnly: u,
893
+ "aria-disabled": l || void 0,
894
+ "aria-readonly": u || void 0,
895
+ "data-virtual-input": "true",
896
+ "data-focused": h || void 0,
897
+ "data-value": W,
898
+ placeholder: a,
899
+ value: Y ?? W,
1007
900
  style: {
1008
- color: ie === "dark" ? "#a6b7a9" : "#58665d",
1009
- userSelect: "none",
1010
- WebkitUserSelect: "none"
901
+ position: "absolute",
902
+ inset: 0,
903
+ boxSizing: "border-box",
904
+ display: "block",
905
+ width: "100%",
906
+ height: "100%",
907
+ minWidth: 0,
908
+ minHeight: "1.5em",
909
+ margin: 0,
910
+ padding: "inherit",
911
+ border: 0,
912
+ borderRadius: "inherit",
913
+ outline: "none",
914
+ background: "transparent",
915
+ color: "inherit",
916
+ caretColor: "currentColor",
917
+ font: "inherit",
918
+ lineHeight: "inherit",
919
+ letterSpacing: "inherit",
920
+ textAlign: "inherit",
921
+ appearance: "none",
922
+ WebkitAppearance: "none",
923
+ userSelect: "text",
924
+ WebkitUserSelect: "text",
925
+ touchAction: "manipulation"
1011
926
  },
1012
- children: a || " "
927
+ onChange: (t) => {
928
+ B.current ? N(t.currentTarget.value) : Be(t.currentTarget);
929
+ },
930
+ onSelect: D,
931
+ onCompositionStart: () => {
932
+ D(), R.current = d.current, B.current = !0, N(A.current?.value ?? d.current.value);
933
+ },
934
+ onCompositionEnd: (t) => {
935
+ B.current = !1, N(null), R.current?.value === d.current.value ? Be(t.currentTarget) : (t.currentTarget.value = d.current.value, E({ ...d.current })), R.current = null;
936
+ }
1013
937
  }
1014
938
  ),
1015
- /* @__PURE__ */ L(
939
+ /* @__PURE__ */ T(
1016
940
  "span",
1017
941
  {
1018
942
  role: "status",
@@ -1022,18 +946,16 @@ const Xe = typeof window > "u" ? K : at, Dt = rt(
1022
946
  height: 1,
1023
947
  overflow: "hidden",
1024
948
  clipPath: "inset(50%)",
1025
- whiteSpace: "nowrap",
1026
- userSelect: "none",
1027
- WebkitUserSelect: "none"
949
+ whiteSpace: "nowrap"
1028
950
  },
1029
- children: y
951
+ children: ye
1030
952
  }
1031
953
  )
1032
954
  ]
1033
955
  }
1034
956
  );
1035
957
  }
1036
- ), yt = [
958
+ ), gt = [
1037
959
  [
1038
960
  {
1039
961
  value: "1"
@@ -1150,55 +1072,55 @@ const Xe = typeof window > "u" ? K : at, Dt = rt(
1150
1072
  }
1151
1073
  ]
1152
1074
  ];
1153
- function bt({
1075
+ function vt({
1154
1076
  tagName: e,
1155
1077
  css: n,
1156
1078
  children: r,
1157
1079
  hostRef: a,
1158
1080
  ...i
1159
1081
  }) {
1160
- const [s, m] = $(null), v = E(
1161
- (d) => {
1162
- a && (a.current = d), d && m(d.shadowRoot ?? d.attachShadow({ mode: "open" }));
1082
+ const [s, f] = P(null), v = S(
1083
+ (c) => {
1084
+ a && (a.current = c), c && f(c.shadowRoot ?? c.attachShadow({ mode: "open" }));
1163
1085
  },
1164
1086
  [a]
1165
1087
  );
1166
- return ct(
1088
+ return at(
1167
1089
  e,
1168
1090
  { ...i, ref: v },
1169
- s && Ie(
1170
- /* @__PURE__ */ Y(Pe, { children: [
1171
- n && /* @__PURE__ */ L("style", { children: n }),
1091
+ s && Te(
1092
+ /* @__PURE__ */ q(Me, { children: [
1093
+ n && /* @__PURE__ */ T("style", { children: n }),
1172
1094
  r
1173
1095
  ] }),
1174
1096
  s
1175
1097
  )
1176
1098
  );
1177
1099
  }
1178
- function Ue(e, n, r) {
1100
+ function je(e, n, r) {
1179
1101
  if (e.type === "action") return e.value === `
1180
1102
  ` ? "Enter" : e.value;
1181
1103
  if (!/^[a-zA-Z]$/.test(e.value)) return e.value;
1182
1104
  const a = r ? e.value.toUpperCase() : e.value;
1183
- return n ? Ye(a) : a;
1105
+ return n ? Ue(a) : a;
1184
1106
  }
1185
- function Me(e, { disabled: n = !1, repeat: r = !1 } = {}) {
1186
- const a = T(e);
1107
+ function Ae(e, { disabled: n = !1, repeat: r = !1 } = {}) {
1108
+ const a = I(e);
1187
1109
  a.current = e;
1188
- const i = T(void 0), s = T(null), [m, v] = $(!1), d = E(() => {
1110
+ const i = I(void 0), s = I(null), [f, v] = P(!1), c = S(() => {
1189
1111
  clearTimeout(i.current), s.current = null, v(!1);
1190
1112
  }, []);
1191
- K(() => (window.addEventListener("blur", d), document.addEventListener("visibilitychange", d), () => {
1192
- d(), window.removeEventListener("blur", d), document.removeEventListener("visibilitychange", d);
1193
- }), [d]), K(() => {
1194
- n && d();
1195
- }, [n, d]);
1196
- const k = (p) => {
1113
+ z(() => (window.addEventListener("blur", c), document.addEventListener("visibilitychange", c), () => {
1114
+ c(), window.removeEventListener("blur", c), document.removeEventListener("visibilitychange", c);
1115
+ }), [c]), z(() => {
1116
+ n && c();
1117
+ }, [n, c]);
1118
+ const m = (p) => {
1197
1119
  const l = s.current?.bounds;
1198
1120
  return !!l && p.clientX >= l.left && p.clientX <= l.right && p.clientY >= l.top && p.clientY <= l.bottom;
1199
1121
  };
1200
1122
  return {
1201
- "data-pressed": m || void 0,
1123
+ "data-pressed": f || void 0,
1202
1124
  onPointerDown: (p) => {
1203
1125
  if (!(n || p.button !== 0 || s.current)) {
1204
1126
  p.preventDefault(), s.current = {
@@ -1219,28 +1141,28 @@ function Me(e, { disabled: n = !1, repeat: r = !1 } = {}) {
1219
1141
  }
1220
1142
  },
1221
1143
  onPointerMove: (p) => {
1222
- s.current?.id === p.pointerId && !k(p) && d();
1144
+ s.current?.id === p.pointerId && !m(p) && c();
1223
1145
  },
1224
1146
  onPointerUp: (p) => {
1225
1147
  if (s.current?.id !== p.pointerId) return;
1226
- const l = !n && k(p) && !s.current.repeated;
1227
- d(), l && a.current();
1148
+ const l = !n && m(p) && !s.current.repeated;
1149
+ c(), l && a.current();
1228
1150
  },
1229
1151
  onPointerCancel: (p) => {
1230
- s.current?.id === p.pointerId && d();
1152
+ s.current?.id === p.pointerId && c();
1231
1153
  },
1232
1154
  onLostPointerCapture: (p) => {
1233
- s.current?.id === p.pointerId && d();
1155
+ s.current?.id === p.pointerId && c();
1234
1156
  },
1235
1157
  onPointerLeave: (p) => {
1236
- s.current?.id === p.pointerId && !k(p) && d();
1158
+ s.current?.id === p.pointerId && !m(p) && c();
1237
1159
  },
1238
1160
  onClick: (p) => {
1239
1161
  !n && p.detail === 0 && !s.current && a.current();
1240
1162
  }
1241
1163
  };
1242
1164
  }
1243
- const Te = {
1165
+ const Ce = {
1244
1166
  Shift: "Shift",
1245
1167
  HangulMode: "한영 전환",
1246
1168
  Backspace: "지우기",
@@ -1259,7 +1181,7 @@ const Te = {
1259
1181
  Redo: "다시 실행",
1260
1182
  SelectAll: "전체 선택"
1261
1183
  };
1262
- function We({
1184
+ function Ne({
1263
1185
  cell: e,
1264
1186
  label: n,
1265
1187
  value: r,
@@ -1267,22 +1189,22 @@ function We({
1267
1189
  disabled: i,
1268
1190
  dispatch: s
1269
1191
  }) {
1270
- const m = Me(s, {
1192
+ const f = Ae(s, {
1271
1193
  disabled: i,
1272
1194
  repeat: ["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(r)
1273
- }), v = e.type === "action" && r === "HangulMode", d = e.type === "action" && (r === "Backspace" && (!e.label || e.label === "⌫") || r === "Delete" && (!e.label || e.label === "⌦"));
1274
- return /* @__PURE__ */ L(
1195
+ }), v = e.type === "action" && r === "HangulMode", c = e.type === "action" && (r === "Backspace" && (!e.label || e.label === "⌫") || r === "Delete" && (!e.label || e.label === "⌦"));
1196
+ return /* @__PURE__ */ T(
1275
1197
  "button",
1276
1198
  {
1277
1199
  type: "button",
1278
1200
  disabled: i,
1279
- "aria-label": Te[r] ?? n,
1201
+ "aria-label": Ce[r] ?? n,
1280
1202
  "aria-pressed": a,
1281
1203
  className: v ? "key action language" : e.type === "action" ? "key action" : "key",
1282
1204
  title: v ? i ? `${a ? "한국어" : "영어"} 전용` : `${a ? "영어" : "한국어"}로 전환` : void 0,
1283
1205
  style: { flex: e.width && e.width > 0 ? e.width : 1 },
1284
- ...m,
1285
- children: d ? /* @__PURE__ */ Y(
1206
+ ...f,
1207
+ children: c ? /* @__PURE__ */ q(
1286
1208
  "svg",
1287
1209
  {
1288
1210
  "data-key-icon": r === "Backspace" ? "backspace" : "delete",
@@ -1298,12 +1220,12 @@ function We({
1298
1220
  focusable: "false",
1299
1221
  style: r === "Delete" ? { transform: "scaleX(-1)" } : void 0,
1300
1222
  children: [
1301
- /* @__PURE__ */ L("path", { d: "M9 5H20a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 20 19H9l-7-7 7-7Z" }),
1302
- /* @__PURE__ */ L("path", { d: "m12 9 6 6m0-6-6 6" })
1223
+ /* @__PURE__ */ T("path", { d: "M9 5H20a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 20 19H9l-7-7 7-7Z" }),
1224
+ /* @__PURE__ */ T("path", { d: "m12 9 6 6m0-6-6 6" })
1303
1225
  ]
1304
1226
  }
1305
- ) : v && !e.label ? /* @__PURE__ */ Y("span", { className: "language-label", "aria-hidden": "true", children: [
1306
- /* @__PURE__ */ Y(
1227
+ ) : v && !e.label ? /* @__PURE__ */ q("span", { className: "language-label", "aria-hidden": "true", children: [
1228
+ /* @__PURE__ */ q(
1307
1229
  "svg",
1308
1230
  {
1309
1231
  width: "19",
@@ -1316,73 +1238,73 @@ function We({
1316
1238
  strokeLinejoin: "round",
1317
1239
  focusable: "false",
1318
1240
  children: [
1319
- /* @__PURE__ */ L("circle", { cx: "12", cy: "12", r: "9" }),
1320
- /* @__PURE__ */ L("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1321
- /* @__PURE__ */ L("path", { d: "M3 12h18" })
1241
+ /* @__PURE__ */ T("circle", { cx: "12", cy: "12", r: "9" }),
1242
+ /* @__PURE__ */ T("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1243
+ /* @__PURE__ */ T("path", { d: "M3 12h18" })
1322
1244
  ]
1323
1245
  }
1324
1246
  ),
1325
- /* @__PURE__ */ L("span", { children: a ? "한" : "EN" })
1247
+ /* @__PURE__ */ T("span", { children: a ? "한" : "EN" })
1326
1248
  ] }) : n
1327
1249
  }
1328
1250
  );
1329
1251
  }
1330
- function xt({
1252
+ function mt({
1331
1253
  layout: e,
1332
1254
  viewport: n,
1333
1255
  onHeightChange: r
1334
1256
  }) {
1335
- const a = _e(), {
1257
+ const a = Ze(), {
1336
1258
  inputRef: i,
1337
1259
  hangulMode: s,
1338
- shift: m,
1260
+ shift: f,
1339
1261
  shiftLocked: v,
1340
- theme: d,
1341
- selectionMode: k,
1262
+ theme: c,
1263
+ selectionMode: m,
1342
1264
  selectionAdjusting: p,
1343
1265
  activeInputPolicy: l,
1344
1266
  editingStatus: u,
1345
- onBlur: P
1346
- } = a, w = T(null), [_, B] = $(!1), ae = Me(() => B((h) => !h)), Z = Me(() => P(!0)), F = ["text", "hangul", "custom"].includes(
1267
+ onBlur: V
1268
+ } = a, w = I(null), [Q, H] = P(!1), le = Ae(() => H((g) => !g)), te = Ae(() => V(!0)), F = ["text", "hangul", "custom"].includes(
1347
1269
  l.mode
1348
- ), O = _ && F && !k ? yt : e;
1349
- K(() => {
1270
+ ), oe = Q && F && !m ? gt : e;
1271
+ z(() => {
1350
1272
  if (!w.current) return;
1351
- const h = () => {
1352
- const g = w.current?.getBoundingClientRect().height ?? 0;
1353
- r(g);
1273
+ const g = () => {
1274
+ const y = w.current?.getBoundingClientRect().height ?? 0;
1275
+ r(y);
1354
1276
  };
1355
- h();
1356
- const b = new ResizeObserver(h);
1357
- return b.observe(w.current), () => b.disconnect();
1358
- }, [r]), K(() => {
1359
- let h = null;
1360
- const b = /* @__PURE__ */ new Set(), g = (c) => c.composedPath().some(
1361
- (W) => W === w.current || W instanceof Element && W.hasAttribute("data-virtual-input")
1362
- ), A = (c) => {
1363
- b.add(c.pointerId), h = b.size !== 1 || c.button !== 0 || g(c) ? null : { x: c.clientX, y: c.clientY, id: c.pointerId };
1364
- }, I = (c) => {
1365
- h && h.id === c.pointerId && Math.hypot(c.clientX - h.x, c.clientY - h.y) < 10 && !g(c) && P(!0), h = null, b.delete(c.pointerId);
1366
- }, U = (c) => {
1367
- h?.id === c.pointerId && Math.hypot(c.clientX - h.x, c.clientY - h.y) >= 10 && (h = null);
1368
- }, C = () => {
1369
- h = null;
1370
- }, J = (c) => {
1371
- C(), b.delete(c.pointerId);
1372
- }, M = () => {
1373
- C(), b.clear();
1277
+ g();
1278
+ const L = new ResizeObserver(g);
1279
+ return L.observe(w.current), () => L.disconnect();
1280
+ }, [r]), z(() => {
1281
+ let g = null;
1282
+ const L = /* @__PURE__ */ new Set(), y = (b) => b.composedPath().some(
1283
+ (O) => O === w.current || O instanceof Element && O.hasAttribute("data-virtual-input")
1284
+ ), A = (b) => {
1285
+ L.add(b.pointerId), g = L.size !== 1 || b.button !== 0 || y(b) ? null : { x: b.clientX, y: b.clientY, id: b.pointerId };
1286
+ }, x = (b) => {
1287
+ g && g.id === b.pointerId && Math.hypot(b.clientX - g.x, b.clientY - g.y) < 10 && !y(b) && V(!0), g = null, L.delete(b.pointerId);
1288
+ }, B = (b) => {
1289
+ g?.id === b.pointerId && Math.hypot(b.clientX - g.x, b.clientY - g.y) >= 10 && (g = null);
1290
+ }, R = () => {
1291
+ g = null;
1292
+ }, Y = (b) => {
1293
+ R(), L.delete(b.pointerId);
1294
+ }, N = () => {
1295
+ R(), L.clear();
1374
1296
  };
1375
- return window.addEventListener("pointerdown", A, !0), window.addEventListener("pointermove", U, !0), window.addEventListener("pointerup", I, !0), window.addEventListener("pointercancel", J, !0), window.addEventListener("scroll", C, !0), window.addEventListener("blur", M), document.addEventListener("visibilitychange", M), () => {
1376
- window.removeEventListener("pointerdown", A, !0), window.removeEventListener("pointermove", U, !0), window.removeEventListener("pointerup", I, !0), window.removeEventListener("pointercancel", J, !0), window.removeEventListener("scroll", C, !0), window.removeEventListener("blur", M), document.removeEventListener("visibilitychange", M);
1297
+ return window.addEventListener("pointerdown", A, !0), window.addEventListener("pointermove", B, !0), window.addEventListener("pointerup", x, !0), window.addEventListener("pointercancel", Y, !0), window.addEventListener("scroll", R, !0), window.addEventListener("blur", N), document.addEventListener("visibilitychange", N), () => {
1298
+ window.removeEventListener("pointerdown", A, !0), window.removeEventListener("pointermove", B, !0), window.removeEventListener("pointerup", x, !0), window.removeEventListener("pointercancel", Y, !0), window.removeEventListener("scroll", R, !0), window.removeEventListener("blur", N), document.removeEventListener("visibilitychange", N);
1377
1299
  };
1378
- }, [P]);
1379
- const X = (h) => {
1380
- const b = Ue(h, s, m);
1381
- if (h.type !== "action") {
1382
- i.current?.insertText(b, we(b)), a.consumeShift();
1300
+ }, [V]);
1301
+ const X = (g) => {
1302
+ const L = je(g, s, f);
1303
+ if (g.type !== "action") {
1304
+ i.current?.insertText(L, we(L)), a.consumeShift();
1383
1305
  return;
1384
1306
  }
1385
- switch (b) {
1307
+ switch (L) {
1386
1308
  case "Undo":
1387
1309
  i.current?.undo();
1388
1310
  break;
@@ -1397,11 +1319,11 @@ function xt({
1397
1319
  break;
1398
1320
  case "HangulMode":
1399
1321
  i.current?.handleKeyDown(
1400
- new KeyboardEvent("keydown", { key: b })
1322
+ new KeyboardEvent("keydown", { key: L })
1401
1323
  );
1402
1324
  break;
1403
1325
  case "EnterSelectionMode":
1404
- B(!1), a.enterSelectionMode();
1326
+ H(!1), a.enterSelectionMode();
1405
1327
  break;
1406
1328
  case "ExitSelectionMode":
1407
1329
  a.exitSelectionMode();
@@ -1425,11 +1347,11 @@ function xt({
1425
1347
  i.current?.moveCaret("right", p);
1426
1348
  break;
1427
1349
  default:
1428
- b === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1429
- new KeyboardEvent("keydown", { key: b })
1350
+ L === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1351
+ new KeyboardEvent("keydown", { key: L })
1430
1352
  );
1431
1353
  }
1432
- }, ce = ge(l.mode) !== null, ie = {
1354
+ }, J = me(l.mode) !== null, ue = {
1433
1355
  position: "fixed",
1434
1356
  zIndex: 9999,
1435
1357
  boxSizing: "border-box",
@@ -1440,33 +1362,33 @@ function xt({
1440
1362
  ...n.height ? { top: n.offsetTop + n.height } : { bottom: 0 },
1441
1363
  maxHeight: n.height ? n.height * 0.65 : "65dvh",
1442
1364
  overflowY: "auto",
1443
- colorScheme: d,
1444
- background: d === "dark" ? "#18201f" : "#e9eeeb",
1445
- color: d === "dark" ? "#eef4ef" : "#203b31",
1446
- border: "1px solid " + (d === "dark" ? "#35413c" : "#c8d3cb"),
1365
+ colorScheme: c,
1366
+ background: c === "dark" ? "#18201f" : "#e9eeeb",
1367
+ color: c === "dark" ? "#eef4ef" : "#203b31",
1368
+ border: "1px solid " + (c === "dark" ? "#35413c" : "#c8d3cb"),
1447
1369
  borderRadius: "20px 20px 0 0",
1448
1370
  boxShadow: "0 -8px 48px #10251a20",
1449
1371
  touchAction: "manipulation",
1450
1372
  userSelect: "none",
1451
1373
  WebkitUserSelect: "none"
1452
1374
  };
1453
- return Ie(
1454
- /* @__PURE__ */ L(
1455
- bt,
1375
+ return Te(
1376
+ /* @__PURE__ */ T(
1377
+ vt,
1456
1378
  {
1457
1379
  tagName: "virtual-keypad",
1458
1380
  hostRef: w,
1459
1381
  "data-virtual-keypad": "true",
1460
- style: ie,
1461
- onPointerDown: (h) => {
1462
- h.button === 0 && h.preventDefault();
1382
+ style: ue,
1383
+ onPointerDown: (g) => {
1384
+ g.button === 0 && g.preventDefault();
1463
1385
  },
1464
- onMouseDown: (h) => {
1465
- h.button === 0 && h.preventDefault();
1386
+ onMouseDown: (g) => {
1387
+ g.button === 0 && g.preventDefault();
1466
1388
  },
1467
1389
  onBlur: a.onBlur,
1468
- onKeyDown: (h) => {
1469
- h.key === "Escape" && (h.preventDefault(), P(!0));
1390
+ onKeyDown: (g) => {
1391
+ g.key === "Escape" && (g.preventDefault(), V(!0));
1470
1392
  },
1471
1393
  css: `
1472
1394
  * {
@@ -1514,9 +1436,9 @@ function xt({
1514
1436
  min-height: 44px;
1515
1437
  border: 0;
1516
1438
  border-radius: 8px;
1517
- background: ${d === "dark" ? "#303c37" : "#fff"};
1439
+ background: ${c === "dark" ? "#303c37" : "#fff"};
1518
1440
  color: inherit;
1519
- box-shadow: 0 2px 0 ${d === "dark" ? "#0d1611" : "#bdc9c1"};
1441
+ box-shadow: 0 2px 0 ${c === "dark" ? "#0d1611" : "#bdc9c1"};
1520
1442
  font: inherit;
1521
1443
  padding: 8px 0;
1522
1444
  touch-action: none;
@@ -1524,7 +1446,7 @@ function xt({
1524
1446
  user-select: none;
1525
1447
  }
1526
1448
  .action {
1527
- background: ${d === "dark" ? "#414e46" : "#d7e1db"};
1449
+ background: ${c === "dark" ? "#414e46" : "#d7e1db"};
1528
1450
  font-size: 14px;
1529
1451
  }
1530
1452
  .selection-count {
@@ -1596,10 +1518,10 @@ function xt({
1596
1518
  }
1597
1519
  }
1598
1520
  `,
1599
- children: /* @__PURE__ */ Y("section", { className: "keyboard", role: "group", "aria-label": "가상 키보드", children: [
1600
- /* @__PURE__ */ Y("div", { className: "toolbar", children: [
1601
- u.selectionLength > 0 && !k ? /* @__PURE__ */ Y(Pe, { children: [
1602
- /* @__PURE__ */ L(
1521
+ children: /* @__PURE__ */ q("section", { className: "keyboard", role: "group", "aria-label": "가상 키보드", children: [
1522
+ /* @__PURE__ */ q("div", { className: "toolbar", children: [
1523
+ u.selectionLength > 0 && !m ? /* @__PURE__ */ q(Me, { children: [
1524
+ /* @__PURE__ */ T(
1603
1525
  "span",
1604
1526
  {
1605
1527
  className: "selection-count",
@@ -1607,91 +1529,91 @@ function xt({
1607
1529
  children: u.message === "복사했어요" ? "복사했어요" : `${u.selectionLength}자 선택`
1608
1530
  }
1609
1531
  ),
1610
- /* @__PURE__ */ L(
1532
+ /* @__PURE__ */ T(
1611
1533
  "div",
1612
1534
  {
1613
1535
  className: "selection-actions",
1614
1536
  role: "group",
1615
1537
  "aria-label": "선택한 텍스트 편집",
1616
- children: ["Copy", "Cut", "SelectAll"].map((h) => /* @__PURE__ */ L(
1617
- We,
1538
+ children: ["Copy", "Cut", "SelectAll"].map((g) => /* @__PURE__ */ T(
1539
+ Ne,
1618
1540
  {
1619
- cell: { value: h, type: "action" },
1620
- value: h,
1621
- label: Te[h],
1622
- dispatch: () => X({ value: h, type: "action" })
1541
+ cell: { value: g, type: "action" },
1542
+ value: g,
1543
+ label: Ce[g],
1544
+ dispatch: () => X({ value: g, type: "action" })
1623
1545
  },
1624
- h
1546
+ g
1625
1547
  ))
1626
1548
  }
1627
1549
  )
1628
- ] }) : /* @__PURE__ */ Y("span", { children: [
1629
- k ? u.message === "복사했어요" ? "복사했어요" : "텍스트 편집" : _ && F ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : s ? "한국어 · 두벌식" : "English",
1550
+ ] }) : /* @__PURE__ */ q("span", { children: [
1551
+ m ? u.message === "복사했어요" ? "복사했어요" : "텍스트 편집" : Q && F ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : s ? "한국어 · 두벌식" : "English",
1630
1552
  v ? " · Shift 고정" : ""
1631
1553
  ] }),
1632
- F && !k && !u.selectionLength && /* @__PURE__ */ L(
1554
+ F && !m && !u.selectionLength && /* @__PURE__ */ T(
1633
1555
  "button",
1634
1556
  {
1635
1557
  type: "button",
1636
1558
  className: "close",
1637
1559
  "aria-label": "숫자·기호 전환",
1638
- "aria-pressed": _,
1639
- ...ae,
1640
- children: _ ? "가 / ABC" : "123 / #+="
1560
+ "aria-pressed": Q,
1561
+ ...le,
1562
+ children: Q ? "가 / ABC" : "123 / #+="
1641
1563
  }
1642
1564
  ),
1643
- /* @__PURE__ */ L(
1565
+ /* @__PURE__ */ T(
1644
1566
  "button",
1645
1567
  {
1646
1568
  type: "button",
1647
1569
  className: "close",
1648
- ...Z,
1570
+ ...te,
1649
1571
  "aria-label": "키보드 닫기",
1650
1572
  children: "닫기 ↓"
1651
1573
  }
1652
1574
  )
1653
1575
  ] }),
1654
- u.message && u.message !== "복사했어요" && /* @__PURE__ */ L("p", { className: "feedback", children: u.message }),
1655
- O.map((h, b) => /* @__PURE__ */ L("div", { className: "row", children: h.map((g, A) => {
1656
- const I = Ue(g, s, m), U = g.type === "action" ? g.label ?? Te[I] ?? I : /^[A-Za-z]$/.test(g.value) ? I : g.label ?? I, C = g.value === "Shift" ? m : g.value === "HangulMode" ? s : g.value === "ToggleSelectionAdjust" ? p : void 0;
1657
- return /* @__PURE__ */ L(
1658
- We,
1576
+ u.message && u.message !== "복사했어요" && /* @__PURE__ */ T("p", { className: "feedback", children: u.message }),
1577
+ oe.map((g, L) => /* @__PURE__ */ T("div", { className: "row", children: g.map((y, A) => {
1578
+ const x = je(y, s, f), B = y.type === "action" ? y.label ?? Ce[x] ?? x : /^[A-Za-z]$/.test(y.value) ? x : y.label ?? x, R = y.value === "Shift" ? f : y.value === "HangulMode" ? s : y.value === "ToggleSelectionAdjust" ? p : void 0;
1579
+ return /* @__PURE__ */ T(
1580
+ Ne,
1659
1581
  {
1660
- cell: g,
1661
- label: U,
1662
- value: I,
1663
- active: C,
1664
- disabled: g.value === "HangulMode" && ce || ["Copy", "Cut"].includes(I) && !u.selectionLength || I === "SelectAll" && !u.hasValue || (g.type !== "action" || I === " ") && !l.filterKey(I),
1665
- dispatch: () => X(g)
1582
+ cell: y,
1583
+ label: B,
1584
+ value: x,
1585
+ active: R,
1586
+ disabled: y.value === "HangulMode" && J || ["Copy", "Cut"].includes(x) && !u.selectionLength || x === "SelectAll" && !u.hasValue || (y.type !== "action" || x === " ") && !l.filterKey(x),
1587
+ dispatch: () => X(y)
1666
1588
  },
1667
- `${b}-${A}-${g.value}`
1589
+ `${L}-${A}-${y.value}`
1668
1590
  );
1669
- }) }, b))
1591
+ }) }, L))
1670
1592
  ] })
1671
1593
  }
1672
1594
  ),
1673
1595
  document.body
1674
1596
  );
1675
1597
  }
1676
- const Se = "virtual-keyboard:storage";
1677
- function kt(e, n) {
1678
- const r = T(n), [a, i] = $(n), s = T(a), m = E(
1598
+ const ke = "virtual-keyboard:storage";
1599
+ function wt(e, n) {
1600
+ const r = I(n), [a, i] = P(n), s = I(a), f = S(
1679
1601
  () => r.current instanceof Function ? r.current() : r.current,
1680
1602
  []
1681
1603
  );
1682
- K(() => {
1683
- const d = (u) => {
1604
+ z(() => {
1605
+ const c = (u) => {
1684
1606
  try {
1685
- const P = u === null ? m() : JSON.parse(u);
1686
- return typeof P == typeof m() ? P : m();
1607
+ const V = u === null ? f() : JSON.parse(u);
1608
+ return typeof V == typeof f() ? V : f();
1687
1609
  } catch {
1688
- return m();
1610
+ return f();
1689
1611
  }
1690
- }, k = (u) => {
1691
- s.current = d(u), i(s.current);
1612
+ }, m = (u) => {
1613
+ s.current = c(u), i(s.current);
1692
1614
  };
1693
1615
  try {
1694
- k(window.localStorage.getItem(e));
1616
+ m(window.localStorage.getItem(e));
1695
1617
  } catch {
1696
1618
  }
1697
1619
  const p = (u) => {
@@ -1701,19 +1623,19 @@ function kt(e, n) {
1701
1623
  } catch {
1702
1624
  return;
1703
1625
  }
1704
- (u.key === e || u.key === null) && k(u.newValue);
1626
+ (u.key === e || u.key === null) && m(u.newValue);
1705
1627
  }, l = (u) => {
1706
- const P = u.detail;
1707
- P.key === e && k(P.raw);
1628
+ const V = u.detail;
1629
+ V.key === e && m(V.raw);
1708
1630
  };
1709
- return window.addEventListener("storage", p), window.addEventListener(Se, l), () => {
1710
- window.removeEventListener("storage", p), window.removeEventListener(Se, l);
1631
+ return window.addEventListener("storage", p), window.addEventListener(ke, l), () => {
1632
+ window.removeEventListener("storage", p), window.removeEventListener(ke, l);
1711
1633
  };
1712
- }, [e, m]);
1713
- const v = E(
1714
- (d) => {
1715
- s.current = d instanceof Function ? d(s.current) : d, i(s.current), window.dispatchEvent(
1716
- new CustomEvent(Se, {
1634
+ }, [e, f]);
1635
+ const v = S(
1636
+ (c) => {
1637
+ s.current = c instanceof Function ? c(s.current) : c, i(s.current), window.dispatchEvent(
1638
+ new CustomEvent(ke, {
1717
1639
  detail: { key: e, raw: JSON.stringify(s.current) }
1718
1640
  })
1719
1641
  );
@@ -1726,7 +1648,7 @@ function kt(e, n) {
1726
1648
  );
1727
1649
  return [a, v];
1728
1650
  }
1729
- const St = [
1651
+ const yt = [
1730
1652
  [
1731
1653
  {
1732
1654
  label: "전체 선택",
@@ -1806,7 +1728,7 @@ const St = [
1806
1728
  type: "action"
1807
1729
  }
1808
1730
  ]
1809
- ], Et = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1731
+ ], bt = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1810
1732
  width: window.visualViewport.width,
1811
1733
  height: window.visualViewport.height,
1812
1734
  scale: window.visualViewport.scale,
@@ -1818,21 +1740,21 @@ const St = [
1818
1740
  scale: 1,
1819
1741
  offsetLeft: 0,
1820
1742
  offsetTop: 0
1821
- }, Lt = (e, n) => e.width === n.width && e.height === n.height && e.scale === n.scale && e.offsetLeft === n.offsetLeft && e.offsetTop === n.offsetTop, Ct = () => {
1822
- const [e, n] = $(() => ({
1743
+ }, xt = (e, n) => e.width === n.width && e.height === n.height && e.scale === n.scale && e.offsetLeft === n.offsetLeft && e.offsetTop === n.offsetTop, kt = () => {
1744
+ const [e, n] = P(() => ({
1823
1745
  width: 0,
1824
1746
  height: 0,
1825
1747
  scale: 1,
1826
1748
  offsetLeft: 0,
1827
1749
  offsetTop: 0
1828
1750
  }));
1829
- return K(() => {
1751
+ return z(() => {
1830
1752
  if (typeof window > "u") return;
1831
1753
  let r = null;
1832
1754
  const a = () => {
1833
- const s = Et();
1755
+ const s = bt();
1834
1756
  n(
1835
- (m) => Lt(m, s) ? m : s
1757
+ (f) => xt(f, s) ? f : s
1836
1758
  );
1837
1759
  };
1838
1760
  a();
@@ -1848,9 +1770,9 @@ const St = [
1848
1770
  };
1849
1771
  }, []), e;
1850
1772
  };
1851
- function At() {
1852
- const [e, n] = $("light");
1853
- return K(() => {
1773
+ function Et() {
1774
+ const [e, n] = P("light");
1775
+ return z(() => {
1854
1776
  if (typeof window > "u" || !window.matchMedia) return;
1855
1777
  const r = window.matchMedia("(prefers-color-scheme: dark)");
1856
1778
  n(r.matches ? "dark" : "light");
@@ -1860,149 +1782,154 @@ function At() {
1860
1782
  return r.addEventListener("change", a), () => r.removeEventListener("change", a);
1861
1783
  }, []), e;
1862
1784
  }
1863
- function Je(e) {
1785
+ function Xe(e) {
1864
1786
  return e !== void 0 ? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1865
1787
  e
1866
- ) : typeof navigator > "u" ? !1 : Je(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1788
+ ) : typeof navigator > "u" ? !1 : Xe(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1867
1789
  }
1868
1790
  const Ee = "virtual-keyboard:focus-change";
1869
- function Kt({
1791
+ function Tt({
1870
1792
  children: e,
1871
- layout: n = ee,
1793
+ layout: n = re,
1872
1794
  defaultHangulMode: r = !0,
1873
1795
  theme: a,
1874
1796
  keyboardVisibility: i = "auto"
1875
1797
  }) {
1876
- const s = qe(), m = T(null), v = T(null), d = T(
1798
+ const s = $e(), f = I(null), v = I(null), c = I(
1877
1799
  void 0
1878
- ), [k, p] = $(), [l, u] = $(0), [P, w] = $(!1), [_, B] = $(!1), [ae, Z] = $({
1800
+ ), [m, p] = P(), [l, u] = P(0), [V, w] = P(!1), [Q, H] = P(!1), [le, te] = P({
1879
1801
  selectionLength: 0,
1880
1802
  hasValue: !1,
1881
1803
  message: ""
1882
- }), [F, O] = kt(
1804
+ }), F = S((h) => {
1805
+ te(
1806
+ (k) => k.selectionLength === h.selectionLength && k.hasValue === h.hasValue && k.message === h.message ? k : h
1807
+ );
1808
+ }, []), [oe, X] = wt(
1883
1809
  "virtual-keyboard-hangul-mode",
1884
1810
  r
1885
- ), [X, ce] = $(
1886
- () => Le({ layout: n })
1887
- ), [ie, h] = $(!1), [b, g] = $(0), A = Ct(), I = At(), U = ge(X.mode) ?? F, C = !!k && (i === "always" || i === "auto" && ie), J = T(C);
1888
- J.current = C, K(() => {
1889
- const y = () => h(Je());
1890
- y();
1891
- const D = window.matchMedia?.("(pointer: coarse)");
1892
- return D?.addEventListener("change", y), () => D?.removeEventListener("change", y);
1811
+ ), [J, ue] = P(
1812
+ () => Se({ layout: n })
1813
+ ), [g, L] = P(!1), [y, A] = P(0), x = kt(), B = Et(), R = me(J.mode) ?? oe, Y = !!m && (i === "always" || i === "auto" && g), N = I(Y);
1814
+ N.current = Y, z(() => {
1815
+ const h = () => L(Xe());
1816
+ h();
1817
+ const k = window.matchMedia?.("(pointer: coarse)");
1818
+ return k?.addEventListener("change", h), () => k?.removeEventListener("change", h);
1893
1819
  }, []);
1894
- const M = E(() => {
1895
- clearTimeout(d.current), v.current = null, m.current = null, p(void 0), u(0), w(!1), B(!1);
1820
+ const b = S(() => {
1821
+ clearTimeout(c.current), v.current = null, f.current = null, p(void 0), u(0), w(!1), H(!1);
1896
1822
  }, []);
1897
- K(() => {
1898
- const y = (D) => {
1899
- D.detail !== s && M();
1823
+ z(() => {
1824
+ const h = (k) => {
1825
+ k.detail !== s && b();
1900
1826
  };
1901
- return window.addEventListener(Ee, y), () => {
1902
- window.removeEventListener(Ee, y), clearTimeout(d.current);
1827
+ return window.addEventListener(Ee, h), () => {
1828
+ window.removeEventListener(Ee, h), clearTimeout(c.current);
1903
1829
  };
1904
- }, [s, M]);
1905
- const c = E(
1906
- (y, D, q) => {
1907
- clearTimeout(d.current), v.current !== D && (u(0), w(!1), B(!1)), v.current = D, ce(Le(q)), p(y), window.dispatchEvent(
1830
+ }, [s, b]);
1831
+ const O = S(
1832
+ (h, k, $) => {
1833
+ clearTimeout(c.current), v.current !== k && (u(0), w(!1), H(!1)), v.current = k, ue(Se($)), p(h), window.dispatchEvent(
1908
1834
  new CustomEvent(Ee, { detail: s })
1909
1835
  );
1910
1836
  },
1911
1837
  [s]
1912
- ), W = E(
1913
- (y) => {
1914
- if (y === !0) {
1915
- M();
1838
+ ), U = S(
1839
+ (h) => {
1840
+ if (h === !0) {
1841
+ const $ = document.activeElement, j = $ instanceof HTMLElement && v.current?.contains($);
1842
+ b(), j && $.blur();
1916
1843
  return;
1917
1844
  }
1918
- const D = typeof y == "object" ? y.relatedTarget : null;
1919
- D?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !D && J.current || (clearTimeout(d.current), d.current = setTimeout(M, 0));
1845
+ const k = typeof h == "object" ? h.relatedTarget : null;
1846
+ k?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !k && N.current || (clearTimeout(c.current), c.current = setTimeout(b, 0));
1920
1847
  },
1921
- [M]
1848
+ [b]
1922
1849
  );
1923
- K(() => {
1924
- if (!C || !b || A.scale !== 1) return;
1925
- const y = requestAnimationFrame(() => {
1926
- const D = v.current?.getBoundingClientRect();
1927
- if (!D) return;
1928
- const q = A.offsetTop + A.height - b - 16;
1929
- D.bottom > q && window.scrollBy({ top: D.bottom - q, behavior: "instant" });
1850
+ z(() => {
1851
+ if (!Y || !y || x.scale !== 1) return;
1852
+ const h = requestAnimationFrame(() => {
1853
+ const k = v.current?.getBoundingClientRect();
1854
+ if (!k) return;
1855
+ const $ = x.offsetTop + x.height - y - 16;
1856
+ k.bottom > $ && window.scrollBy({ top: k.bottom - $, behavior: "instant" });
1930
1857
  });
1931
- return () => cancelAnimationFrame(y);
1858
+ return () => cancelAnimationFrame(h);
1932
1859
  }, [
1933
- k,
1934
- C,
1935
- b,
1936
- A.height,
1937
- A.offsetTop,
1938
- A.scale
1860
+ m,
1861
+ Y,
1862
+ y,
1863
+ x.height,
1864
+ x.offsetTop,
1865
+ x.scale
1939
1866
  ]);
1940
- const ne = E(() => {
1941
- ge(X.mode) === null && O((y) => !y);
1942
- }, [X.mode, O]), G = E(
1943
- () => u((y) => (y + 1) % 3),
1867
+ const de = S(() => {
1868
+ me(J.mode) === null && X((h) => !h);
1869
+ }, [J.mode, X]), W = S(
1870
+ () => u((h) => (h + 1) % 3),
1944
1871
  []
1945
- ), V = E(
1946
- () => u((y) => y === 1 ? 0 : y),
1872
+ ), d = S(
1873
+ () => u((h) => h === 1 ? 0 : h),
1947
1874
  []
1948
- ), Q = E(() => {
1949
- w(!0), B(!1);
1950
- }, []), le = E(() => {
1951
- w(!1), B(!1);
1952
- }, []), j = E(
1953
- () => B((y) => !y),
1875
+ ), ne = S(() => {
1876
+ w(!0), H(!1);
1877
+ }, []), ie = S(() => {
1878
+ w(!1), H(!1);
1879
+ }, []), G = S(
1880
+ () => H((h) => !h),
1954
1881
  []
1955
1882
  );
1956
- return /* @__PURE__ */ Y(
1957
- Ze.Provider,
1883
+ return /* @__PURE__ */ q(
1884
+ We.Provider,
1958
1885
  {
1959
1886
  value: {
1960
- inputRef: m,
1961
- focusId: k,
1962
- onFocus: c,
1963
- onBlur: W,
1887
+ inputRef: f,
1888
+ focusId: m,
1889
+ onFocus: O,
1890
+ onBlur: U,
1964
1891
  defaultLayout: n,
1965
- hangulMode: U,
1892
+ hangulMode: R,
1966
1893
  shift: l > 0,
1967
1894
  shiftLocked: l === 2,
1968
- theme: a ?? I,
1969
- toggleKorean: ne,
1970
- toggleShift: G,
1971
- consumeShift: V,
1972
- selectionMode: P,
1973
- selectionAdjusting: _,
1974
- enterSelectionMode: Q,
1975
- exitSelectionMode: le,
1976
- toggleSelectionAdjust: j,
1977
- activeInputPolicy: X,
1978
- editingStatus: ae,
1979
- setEditingStatus: Z
1895
+ theme: a ?? B,
1896
+ toggleKorean: de,
1897
+ toggleShift: W,
1898
+ consumeShift: d,
1899
+ selectionMode: V,
1900
+ selectionAdjusting: Q,
1901
+ enterSelectionMode: ne,
1902
+ exitSelectionMode: ie,
1903
+ toggleSelectionAdjust: G,
1904
+ activeInputPolicy: J,
1905
+ editingStatus: le,
1906
+ setEditingStatus: F
1980
1907
  },
1981
1908
  children: [
1982
1909
  e,
1983
- C && /* @__PURE__ */ Y(Pe, { children: [
1984
- Ie(
1985
- /* @__PURE__ */ L(
1910
+ Y && /* @__PURE__ */ q(Me, { children: [
1911
+ Te(
1912
+ /* @__PURE__ */ T(
1986
1913
  "div",
1987
1914
  {
1988
1915
  "aria-hidden": "true",
1989
1916
  style: {
1990
- height: b,
1917
+ height: y,
1991
1918
  pointerEvents: "none",
1992
- background: (a ?? I) === "dark" ? "#121c17" : "#f7f8f4"
1919
+ background: (a ?? B) === "dark" ? "#121c17" : "#f7f8f4"
1993
1920
  }
1994
1921
  }
1995
1922
  ),
1996
1923
  document.body
1997
1924
  ),
1998
- /* @__PURE__ */ L(
1999
- xt,
1925
+ /* @__PURE__ */ T(
1926
+ mt,
2000
1927
  {
2001
- layout: P ? St : X.layout,
2002
- viewport: A,
2003
- onHeightChange: g
1928
+ layout: V ? yt : J.layout,
1929
+ viewport: x,
1930
+ onHeightChange: A
2004
1931
  },
2005
- k
1932
+ m
2006
1933
  )
2007
1934
  ] })
2008
1935
  ]
@@ -2010,6 +1937,6 @@ function Kt({
2010
1937
  );
2011
1938
  }
2012
1939
  export {
2013
- Dt as VirtualInput,
2014
- Kt as VirtualInputProvider
1940
+ Mt as VirtualInput,
1941
+ Tt as VirtualInputProvider
2015
1942
  };