efficient-easel 0.100.0 → 0.101.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.
Files changed (53) hide show
  1. package/dist/chrome/index.js +24 -16
  2. package/dist/{chunk-QKVR3K73.js → chunk-2FZJWH24.js} +1 -1
  3. package/dist/chunk-546BBOPE.js +1 -0
  4. package/dist/{chunk-LGKQXSKO.js → chunk-EOJNJCMJ.js} +8 -8
  5. package/dist/{chunk-A5UK76FC.js → chunk-EWVJSRRY.js} +6 -6
  6. package/dist/chunk-FPOKPNO4.js +1 -0
  7. package/dist/chunk-H24N5TMZ.js +11 -0
  8. package/dist/chunk-IG3U5NWJ.js +1 -0
  9. package/dist/chunk-KTVH2ZRL.js +15 -0
  10. package/dist/{chunk-6EIVTKZZ.js → chunk-L5KW4HG5.js} +21 -20
  11. package/dist/{chunk-TRVZ7C23.js → chunk-QTLAVDJE.js} +1 -1
  12. package/dist/chunk-UH7IGZKF.js +1 -0
  13. package/dist/{chunk-V7GIIXFB.js → chunk-ZFDCDJNZ.js} +1 -1
  14. package/dist/{chunk-DICUMYMG.js → chunk-ZNS7727Y.js} +1 -1
  15. package/dist/copy/copy.css +83 -29
  16. package/dist/copy/index.d.ts +41 -7
  17. package/dist/copy/index.js +32 -31
  18. package/dist/drag/index.js +4 -4
  19. package/dist/fields/fields.css +185 -30
  20. package/dist/fields/index.d.ts +165 -20
  21. package/dist/fields/index.js +22 -37
  22. package/dist/gold/index.js +1 -1
  23. package/dist/icons/index.d.ts +4 -1
  24. package/dist/icons/index.js +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/markup/index.d.ts +18 -1
  27. package/dist/markup/index.js +1 -1
  28. package/dist/menu/index.js +1 -15
  29. package/dist/node-ops/index.js +1 -1
  30. package/dist/panel/index.d.ts +49 -38
  31. package/dist/panel/index.js +18 -18
  32. package/dist/panel/panel.css +99 -81
  33. package/dist/pick/index.d.ts +40 -2
  34. package/dist/pick/index.js +1 -1
  35. package/dist/pick/pick.css +183 -10
  36. package/dist/rail/index.js +1 -1
  37. package/dist/strings/catalogue.d.ts +3 -3
  38. package/dist/strings/catalogue.js +1 -1
  39. package/dist/strings/index.d.ts +3 -3
  40. package/dist/strings/index.js +1 -1
  41. package/dist/style-clipboard/index.js +1 -1
  42. package/dist/text-styles/index.js +13 -13
  43. package/dist/tree/index.js +1 -1
  44. package/dist/{words-CJjUKcV5.d.ts → words-BGrHZAJJ.d.ts} +13 -4
  45. package/dist/{words-CzoyDNHm.d.ts → words-D8kf071T.d.ts} +40 -2
  46. package/dist/{words-DBq7vfHy.d.ts → words-XH0TvZPg.d.ts} +8 -5
  47. package/package.json +1 -1
  48. package/dist/chunk-AZT7V4UM.js +0 -10
  49. package/dist/chunk-HDVD27VB.js +0 -1
  50. package/dist/chunk-JQM3V7XQ.js +0 -1
  51. package/dist/chunk-LA54QLP5.js +0 -1
  52. package/dist/chunk-MH5GUZFQ.js +0 -9
  53. package/dist/chunk-SAJUCHOX.js +0 -1
@@ -448,14 +448,61 @@
448
448
  with its label to the right). The switch is the panel's own (`.es-switch`). */
449
449
  .es-copy-marks {
450
450
  display: flex;
451
+ flex-wrap: wrap;
451
452
  align-items: center;
452
- gap: var(--es-space-8, 8px);
453
- margin-top: var(--es-copy-gap);
453
+ gap: var(--es-space-4, 4px) var(--es-space-8, 8px);
454
+ margin-top: var(--es-space-12, 12px);
454
455
  }
455
456
 
457
+ /* Words never break inside: in a narrow box (a 220px panel) Clear style
458
+ moves to a line of its own, still at the right end. */
456
459
  .es-copy-marks-label {
457
460
  font-size: 13px;
461
+ white-space: nowrap;
462
+ color: var(--es-text-secondary, #374151);
463
+ }
464
+
465
+ /*
466
+ * CLEAR STYLE (owner ruling 2026-10-07, mockup
467
+ * https://claude.ai/artifact/GiyeV3xazepzArKGVkFM8T): a quiet text button at
468
+ * the right end of the line under the box — beside Show marks, or alone under
469
+ * a one-line box (GG, 2026-10-07) — with the clear-marks glyph. Grey and
470
+ * not pressable until words are selected in the box.
471
+ */
472
+ .es-copy-clear {
473
+ margin-left: auto;
474
+ display: inline-flex;
475
+ align-items: center;
476
+ gap: var(--es-space-4, 4px);
477
+ padding: var(--es-space-4, 4px) var(--es-space-8, 8px);
478
+ border: 0;
479
+ border-radius: 6px;
480
+ background: transparent;
481
+ font: inherit;
482
+ font-size: 13px;
483
+ white-space: nowrap;
458
484
  color: var(--es-text-secondary, #374151);
485
+ cursor: pointer;
486
+ }
487
+
488
+ .es-copy-clear svg {
489
+ flex: none;
490
+ width: 16px;
491
+ height: 16px;
492
+ }
493
+
494
+ .es-copy-clear:hover:not(:disabled) {
495
+ background: var(--es-hover, #f3f4f6);
496
+ }
497
+
498
+ .es-copy-clear:focus-visible {
499
+ outline: none;
500
+ box-shadow: var(--es-copy-focus-ring);
501
+ }
502
+
503
+ .es-copy-clear:disabled {
504
+ color: var(--es-disabled, #9ca3af);
505
+ cursor: default;
459
506
  }
460
507
 
461
508
  /* — the final toolbar (E5b, design final 2026-10-06) — */
@@ -475,6 +522,8 @@
475
522
  * the two windows, which sit beside the toolbar, read it too.
476
523
  */
477
524
  --es-tb-size: min(var(--es-copy-mark-size), calc(100cqw / 9));
525
+ /* The gaps across row 1, for the windows' points (below). */
526
+ --es-tb-steps: 8;
478
527
  position: relative;
479
528
  margin-bottom: var(--es-copy-gap);
480
529
  }
@@ -491,6 +540,17 @@
491
540
  justify-content: space-between;
492
541
  }
493
542
 
543
+ /* Row 1 with no host control in its 9th cell (owner ruling 2026-10-07):
544
+ eight buttons spread over the same width, not eight and a hole. The
545
+ wrapper carries it too, so the windows' points follow the buttons. */
546
+ .es-tb-row.is-eight {
547
+ grid-template-columns: repeat(8, var(--es-tb-size));
548
+ }
549
+
550
+ .es-tb-wrap.is-eight {
551
+ --es-tb-steps: 7;
552
+ }
553
+
494
554
  /* The alignment and case groups are radiogroups for a screen reader and
495
555
  nothing for the grid: their buttons are cells of the row. */
496
556
  .es-tb-group {
@@ -566,10 +626,14 @@
566
626
  }
567
627
 
568
628
  /*
569
- * THE TWO WINDOWS (colour, link) drop from their button, under the first row
570
- * and over the second, pushing nothing down — as drawn. They sit over the box
571
- * itself, so the panel's scrolling edge is not near them. DatePicker's
572
- * popover: 288px, 12px corners, a 12px inset, react-os-shell's shadow.
629
+ * THE TWO WINDOWS (colour, link) float, pushing nothing down. They open just
630
+ * BELOW the words they act on, left-aligned to them, or ABOVE them with no
631
+ * room below (Lewis 2026-10-07: under the toolbar, the window covered the
632
+ * words being coloured). `CopyBox` measures that and writes `top`, `left`,
633
+ * `--es-pop-point` and `data-side` on the window (./place). The `top` here is
634
+ * only the unmeasured fallback: under the first row, as first drawn.
635
+ * DatePicker's popover: 288px, 12px corners, a 12px inset, react-os-shell's
636
+ * shadow; never wider than the box.
573
637
  */
574
638
  .es-copy-pop {
575
639
  position: absolute;
@@ -590,7 +654,8 @@
590
654
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
591
655
  }
592
656
 
593
- /* The point, aimed at its button: column k of 9 across the row (100cqw). */
657
+ /* The point, aimed at its button: column k of row 1 across the box (100cqw),
658
+ whose cells are `--es-tb-steps` + 1 (nine, or eight with no host control). */
594
659
  .es-copy-pop::before {
595
660
  content: '';
596
661
  position: absolute;
@@ -603,12 +668,20 @@
603
668
  transform: rotate(45deg);
604
669
  }
605
670
 
671
+ /* Aimed at the words (measured), or — unmeasured — at its button, as above. */
606
672
  .es-copy-colors::before {
607
- left: calc(4 * (100cqw - var(--es-tb-size)) / 8 + var(--es-tb-size) / 2 - 6px);
673
+ left: var(--es-pop-point, calc(4 * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
608
674
  }
609
675
 
610
676
  .es-copy-link.es-copy-pop::before {
611
- left: calc(5 * (100cqw - var(--es-tb-size)) / 8 + var(--es-tb-size) / 2 - 6px);
677
+ left: var(--es-pop-point, calc(5 * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
678
+ }
679
+
680
+ /* Opened above the words: the point is on the bottom edge, aimed down. */
681
+ .es-copy-pop[data-side='above']::before {
682
+ top: auto;
683
+ bottom: -6px;
684
+ transform: rotate(225deg);
612
685
  }
613
686
 
614
687
  .es-copy-pop-label,
@@ -618,26 +691,7 @@
618
691
  color: var(--es-text-secondary, #4b5563);
619
692
  }
620
693
 
621
- .es-copy-swatches {
622
- display: flex;
623
- flex-wrap: wrap;
624
- /* One group of colours: the scale's step for things that are one thing. */
625
- gap: var(--es-space-4, 4px);
626
- }
627
-
628
- .es-copy-swatch {
629
- width: 22px;
630
- height: 22px;
631
- padding: 0;
632
- border: 0;
633
- border-radius: 6px;
634
- box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
635
- cursor: pointer;
636
- }
637
-
638
- .es-copy-swatch[aria-pressed='true'] {
639
- box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 2px #fff, 0 0 0 4px var(--es-accent, #2563eb);
640
- }
694
+ /* The theme colours are pick's ONE theme row (`.es-pick-theme`, pick.css). */
641
695
 
642
696
  /* Any color (E1 widened 2026-10-06) is pick's own ColourWindow (pick.css):
643
697
  inside this window it is not a second box — no border, no inset. */
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { MarkStyle, MarkupTool, WrapResult, InlineRule, MarkedLine } from '../markup/index.js';
4
- import { C as CopyWords, a as CopyAlign } from '../words-DBq7vfHy.js';
5
- export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-DBq7vfHy.js';
4
+ import { C as CopyWords, a as CopyAlign } from '../words-XH0TvZPg.js';
5
+ export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-XH0TvZPg.js';
6
6
 
7
7
  type CellWords = NonNullable<CopyWords['cells']>;
8
8
  interface CopyCell {
@@ -83,7 +83,9 @@ interface TextToolbarProps {
83
83
  onToggle: () => void;
84
84
  };
85
85
  linkOpen: boolean;
86
- onUndo: () => void;
86
+ /** The host's own control for row 1's 9th cell. Left out: row 1 is eight
87
+ * buttons, spread over the row. */
88
+ last?: ReactNode;
87
89
  alignment?: {
88
90
  value: CopyAlign | '';
89
91
  allow: readonly CopyAlign[];
@@ -103,7 +105,7 @@ interface TextToolbarProps {
103
105
  disabled?: boolean;
104
106
  ariaLabel?: string;
105
107
  }
106
- declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, onUndo, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element;
108
+ declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, last, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element;
107
109
 
108
110
  /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
109
111
  * shortcut. Meta is what the tooltips promise (⌘); Ctrl works too. */
@@ -261,6 +263,27 @@ interface CopyBoxFooter {
261
263
  /** Put a literal string where the caret is, replacing any selection. */
262
264
  insert: (text: string) => void;
263
265
  }
266
+ /**
267
+ * What a host needs to draw its OWN control in row 1's 9th cell of the final
268
+ * toolbar ({@link CopyBoxProps.lastTool}) — the campaign designer's Insert
269
+ * (merge tags), owner ruling 2026-10-07. The website editor passes nothing.
270
+ *
271
+ * `className` makes it a cell that looks like its neighbours; `keepCaret` on
272
+ * its mousedown keeps the caret and the selection in the box; `insert` writes
273
+ * at the caret, as {@link CopyBoxFooter.insert} does.
274
+ */
275
+ interface CopyBoxLastTool {
276
+ className: string;
277
+ /** The box is read-only. */
278
+ disabled: boolean;
279
+ /** Words are selected (not just a caret). */
280
+ selected: boolean;
281
+ keepCaret: (e: {
282
+ preventDefault(): void;
283
+ }) => void;
284
+ /** Put a literal string where the caret is, replacing any selection. */
285
+ insert: (text: string) => void;
286
+ }
264
287
  /**
265
288
  * The alignment strip, when the host has an alignment to offer.
266
289
  *
@@ -370,7 +393,8 @@ interface CopyBoxProps {
370
393
  /**
371
394
  * Which toolbar (E5b). `'final'` — the default — is the design made final
372
395
  * on 2026-10-06: two rows on one 9-column grid, B · I · U · S · Color ·
373
- * Link · Superscript · Subscript · Undo over Left · Center · Right · Justify
396
+ * Link · Superscript · Subscript · the host's {@link lastTool} (Undo until
397
+ * 2026-10-07) over Left · Center · Right · Justify
374
398
  * · Bulleted · Numbered · Aa · AA · aa, with the number {@link cells}
375
399
  * between it and the box. `'classic'` is the bar before it (`MarkBar` and
376
400
  * the alignment strip), for a host not moved over yet.
@@ -397,13 +421,20 @@ interface CopyBoxProps {
397
421
  onChange: (next: CopyCase | '') => void;
398
422
  disabled?: boolean;
399
423
  };
424
+ /**
425
+ * Row 1's 9th cell of the final toolbar, drawn by the host (owner ruling
426
+ * 2026-10-07: Undo left that cell). Return one control; it is placed in the
427
+ * cell as given. Left out, row 1 is eight buttons spread over the row. See
428
+ * {@link CopyBoxLastTool}.
429
+ */
430
+ lastTool?: (slot: CopyBoxLastTool) => ReactNode;
400
431
  /** A handle on the textarea, for a host that needs one — and the SAME object
401
432
  * the control uses, so there is never a second ref to reconcile. A plain prop
402
433
  * rather than `ref`, for the reason `GoldLayer.layerRef` gives. */
403
434
  inputRef?: TextAreaHandle;
404
435
  }
405
436
 
406
- declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, actions, align, glyphs, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, toolbar, colors, cells, letterCase, }: CopyBoxProps): react.JSX.Element;
437
+ declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, actions, align, glyphs, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, toolbar, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
407
438
 
408
439
  /** The clipboard type a copy from this box carries, so a paste back in keeps
409
440
  * every mark (the HTML filter keeps only bold, italic and links). */
@@ -419,6 +450,9 @@ interface RichHandle {
419
450
  * commit or more late — the same wait as `useCaretEdit`). */
420
451
  setSource(start: number, end: number, text: string): void;
421
452
  focus(): void;
453
+ /** The drawn words between two saved offsets, as a DOM range — what the
454
+ * colour and link windows open under. Null before the box is drawn. */
455
+ rangeOf(start: number, end: number): Range | null;
422
456
  }
423
457
  interface RichBoxProps {
424
458
  value: string;
@@ -596,4 +630,4 @@ interface CaretEdit {
596
630
  */
597
631
  declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
598
632
 
599
- export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxProps, type CopyCase, type CopyCell, type CopyCellPreset, CopyCells, type CopyThemeColor, CopyWords, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInsert, type RichLayout, type RichLine, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, TextToolbar, type TextToolbarProps, type ToolbarMark, ariaShortcut, createHistory, editVisible, insertSelection, markSelection, markupOfRange, newLine, pasteToMarkup, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
633
+ export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxLastTool, type CopyBoxProps, type CopyCase, type CopyCell, type CopyCellPreset, CopyCells, type CopyThemeColor, CopyWords, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInsert, type RichLayout, type RichLine, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, TextToolbar, type TextToolbarProps, type ToolbarMark, ariaShortcut, createHistory, editVisible, insertSelection, markSelection, markupOfRange, newLine, pasteToMarkup, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
@@ -1,31 +1,32 @@
1
- import{ColourWindow as e}from"../chunk-AZT7V4UM.js";import{DEFAULT_COPY_WORDS as t}from"../chunk-JQM3V7XQ.js";import{DEFAULT_PICK_WORDS as n}from"../chunk-ZAOM6PFH.js";import{FieldNumber as l}from"../chunk-A5UK76FC.js";import{SettingsSegmented as r,SettingsSwitch as a}from"../chunk-P6O363EE.js";import"../chunk-LA54QLP5.js";import{GoldTextInput as o}from"../chunk-QKVR3K73.js";import{RETIRED_MARKS as s,applyMark as i,STANDARD_MARKUP as c,writeMarkedLines as u,sameMarks as d,markedLines as h,spanFor as p,markupTools as m,marksIn as f,findLink as b,markedAt as g,listIn as y,colorIn as v,isSafeLinkHref as k,toggleMark as x,colorOver as w,setList as C,unlinkAt as D,removeLink as N,linkOver as S,writeLink as E}from"../chunk-HDVD27VB.js";import{useWords as M}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{AlignJustifyIcon as L,AlignRightIcon as T,AlignCenterIcon as j,AlignLeftIcon as K,ParagraphSpacingIcon as P,LetterSpacingIcon as O,TextLinesIcon as B,TextSizeIcon as F,CaseNormalIcon as $,CaseUpperIcon as A,CaseLowerIcon as H,TextColorIcon as R,UndoIcon as U,ListIcon as W,NumberedListIcon as z,BoldIcon as I,ItalicIcon as V,UnderlineIcon as Z,StrikeIcon as q,LinkIcon as Q,SuperscriptIcon as X,SubscriptIcon as Y,ClearMarksIcon as G,QuietIcon as J,EmphasisIcon as _}from"../chunk-6EIVTKZZ.js";import{useRef as ee,useState as te,useLayoutEffect as ne,useEffect as le,useId as re}from"react";import{jsx as ae,jsxs as oe,Fragment as se}from"react/jsx-runtime";var ie=["left","center","right","justify"],ce=t.align,ue={left:/* @__PURE__ */ae(K,{}),center:/* @__PURE__ */ae(j,{}),right:/* @__PURE__ */ae(T,{}),justify:/* @__PURE__ */ae(L,{})},de={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function he(e,t=ce){return ie.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:ue[e],title:t[e]}))}var pe=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function me(e){if(e.every(e=>e.label===ce[e.id]))return e.length>3?de.four:de.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(pe.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function fe(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function be(e,t,n,l=i){const{start:r,end:a}=fe(e,n);return l(e,r,a,t)}function ge(e,t,n){const{start:l,end:r}=fe(e,n),a=l+t.length;return{text:e.slice(0,l)+t+e.slice(r),selectionStart:a,selectionEnd:a}}var ye=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),ve=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function ke(e,t){const n=t.rules??c,l=e.html&&""!==e.html.trim()?function(e,t,n){const l=t.createElement("template");l.innerHTML=e;const r=[[]],a=()=>r[r.length-1],o=()=>{const e=a();for(;e.length>0&&" "===e[e.length-1].ch;)e.pop();e.length>0&&r.push([])},s=(e,t,n,l)=>{if(3===e.nodeType){for(const o of e.textContent??""){const e=/\s/.test(o)?" ":o,s=a();" "===e&&(0===s.length&&r.length>1||" "===s[s.length-1]?.ch)||s.push({ch:e,bold:t,italic:n,href:l})}return}if(1!==e.nodeType&&11!==e.nodeType)return;const i=e,c=1===e.nodeType?i.localName:"";if(ye.has(c))return;if("br"===c)return void r.push([]);let u=t,d=n,h=l;if("b"!==c&&"strong"!==c||(u=!0),"i"!==c&&"em"!==c||(d=!0),"a"===c){const e=(i.getAttribute("href")??"").trim();h=k(e)?e:null}const p=1===e.nodeType?i.style:null;if(p){const e=p.fontWeight;"bold"===e||"bolder"===e||Number(e)>=600?u=!0:("normal"===e||"lighter"===e||""!==e&&Number(e)<600)&&(u=!1),"italic"===p.fontStyle||"oblique"===p.fontStyle?d=!0:"normal"===p.fontStyle&&(d=!1)}const m=ve.has(c);m&&o();for(const t of[...e.childNodes])s(t,u,d,h);m&&o()};s(l.content,!1,!1,null);for(;r.length>1&&0===r[r.length-1].length;)r.pop();return r.map(e=>function(e,t){const n=t=>e.map((n,l)=>n[t]&&(" "!==n.ch||Boolean(e[l-1]?.[t])&&Boolean(e[l+1]?.[t]))),l=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const r of l){const l=xe(e,r.bold?n("bold"):null,r.italic?n("italic"):null,r.links),a=u([l]).text;if(d([l],h(a,t)))return a}return e.map(e=>e.ch).join("")}(e,n))}(e.html,t.doc,n):(e.text??"").replace(/\r\n?/g,"\n").split("\n");return t.multiline?l.join("\n"):1===l.length?l[0]:l.map(e=>e.trim()).filter(e=>""!==e).join(" ")}function xe(e,t,n,l){let r=0,a=null,o=null,s=null;return{bullet:!1,chars:e.map((e,i)=>{const c=l?e.href:null;return a=null===c?null:a&&a.href===c?a:p(++r,"link",c),o=t?.[i]?o??p(++r,"bold"):null,s=n?.[i]?s??p(++r,"italic"):null,{ch:e.ch,at:-1,marks:[a,o,s].filter(e=>null!==e)}})}}var we=/^([0-9]{1,3})\. $/;function Ce(e,t){const n=e.split("\n"),l=h(e,t);let r=0,a=0;const o=l.map((e,t)=>{const l=!e.bullet&&null==e.number&&"- "===n[t],o=null!=e.number||e.bullet?null:we.exec(n[t]),s=e.bullet||l,i=o?o[1]:e.number??null,c=l||o?[]:e.chars,u=c.map(e=>e.ch).join(""),d=null!=i?i.length+2:s?2:0,h={bullet:s,number:i,chars:c,start:r,src:r+d,vis:a,text:u};return r+=n[t].length+1,a+=u.length+1,h});return{lines:o,text:o.map(e=>e.text).join("\n")}}function De(e,t){const{lines:n}=e;for(let e=0;e<n.length;e+=1){const l=n[e];if(t<=l.vis+l.text.length||e===n.length-1)return[l,Math.max(0,Math.min(t-l.vis,l.text.length)),e]}return[n[0],0,0]}function Ne(e,t){const[n,l]=De(e,t);if(0===l)return n.src;let r=0;for(const e of n.chars){if(l<=r+e.ch.length)return e.at+(l-r);r+=e.ch.length}return n.src}function Se(e,t){const[n,l]=De(e,t);let r=0;for(const e of n.chars){if(l===r)return e.at;r+=e.ch.length}return Ne(e,t)}function Ee(e,t){const{lines:n}=e;let l=n[0];for(const e of n)t>=e.start&&(l=e);let r=0;for(const e of l.chars){if(!(t>=e.at+e.ch.length)){t>e.at&&(r+=t-e.at);break}r+=e.ch.length}return l.vis+r}function Me(e,t,n){return[Ee(e,t),Ee(e,n)]}function Le(e,t,n){return t===n?[Ne(e,t),Ne(e,t)]:[Se(e,t),Ne(e,n)]}function Te(e,t){let n=0;for(let l=0;l<e.chars.length;l+=1){if(n>=t)return l;n+=e.chars[l].ch.length}return e.chars.length}function je(e,t,n,l,r){const a=Ce(e,t),[o,s,i]=De(a,Math.min(n,l)),[c,m,f]=De(a,Math.max(n,l)),b=Te(o,s),g=Te(c,m),y=o.chars.slice(0,b),v=c.chars.slice(g),k=n!==l&&o.chars[b]&&(i!==f||b<g)?o.chars[b].marks:function(e,t){const n=e.chars[t-1],l=e.chars[t],r=(e,t)=>{const n=e.findIndex(e=>"link"===e.kind);return-1===n||t?e:e.slice(0,n)};if(n){const e=n.marks.find(e=>"link"===e.kind),t=Boolean(e&&l?.marks.some(t=>t.id===e.id));return r(n.marks,t)}return l?r(l.marks,!1):[]}(o,b);let x=(w=a.lines,Math.max(0,...w.flatMap(e=>e.chars.flatMap(e=>e.marks.map(e=>e.id))))+1);var w;const C=e=>{let n;if(void 0!==r.markup){const e=x;n=h(r.markup,t).map(t=>({bullet:t.bullet,number:t.number??null,chars:t.chars.map(t=>({...t,at:-1,marks:t.marks.map(t=>({...t,id:t.id+e}))}))}))}else{let t=o.number??null;n=(r.text??"").split("\n").map((n,l)=>(l>0&&null!=t&&(t=function(e){return String(Number(e)+1).padStart(e.length,"0")}(t)),{bullet:o.bullet,number:t,chars:[...n].map(t=>({ch:t,at:-1,marks:e??[]}))}))}const l=n.map(e=>e.chars.map(e=>e.ch).join("")).join("\n"),s={bullet:o.bullet,number:o.number??null,chars:[...y,...n[0].chars]},c=n.slice(1);if(c.length>0){const e=c[c.length-1];c[c.length-1]={...e,chars:[...e.chars,...v]}}else s.chars.push(...v);return{lines:[...a.lines.slice(0,i).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n})),s,...c,...a.lines.slice(f+1).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n}))],shown:l}},D=void 0!==r.markup?[null]:[(e=>{let t=e.filter(e=>!r.drop?.some(t=>e.kind===t||"highlight"===t&&"accent"===e.kind));for(const e of r.add??[]){if(t.some(t=>t.kind===e))continue;const n=p(x++,e);n&&(t=[...t,n])}if(void 0!==r.color){t=t.filter(e=>"color"!==e.kind);const e=null===r.color?null:p(x++,"color",r.color);e&&(t=[...t,e])}return t})(k),k,[]];let N="",S="";for(const e of D){const n=C(e),l=u(n.lines).text;if(N=l,S=n.shown,d(n.lines,Ce(l,t).lines))break}return{text:N,caret:Math.min(n,l)+S.length}}function Ke(e,t,n,l){const r=Ce(e,t),[a,,o]=De(r,n);return n!==l||!a.bullet&&null==a.number||""!==a.text?je(e,t,n,l,{text:"\n"}):Pe(e,t,o,!1,n)}function Pe(e,t,n,l,r){const a=Ce(e,t).lines.map(({bullet:e,number:t,chars:r},a)=>a===n?{bullet:l,number:null,chars:r}:{bullet:e,number:t,chars:r});return{text:u(a).text,caret:r}}function Oe(e,t,n,l){const r=Ce(e,t),[a,o,s]=De(r,Math.min(n,l)),[i,c,d]=De(r,Math.max(n,l)),h=r.lines.slice(s,d+1).map(({bullet:e,number:t,chars:n},l)=>{const r=0===l?Te(a,o):0,u=l===d-s?Te(i,c):n.length;return{bullet:e,number:t,chars:n.slice(r,u)}});return u(h).text}var Be="application/x-efficient-markup";function Fe(e,t,n,l){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",l&&(t.dataset.color=l,t.title=l.startsWith("#")?l.toUpperCase():l,t.style.color=l.startsWith("#")?l:`var(--es-color-${l}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function $e(e,t,n,l){const r=e.layout.lines;if(n===t)return l>=e.lines.length?e.layout.text.length:r[l].vis;const a=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===a)return 0;const o=t.ownerDocument.createRange();o.setStart(e.lines[a],0);try{o.setEnd(n,l)}catch{return r[a].vis}return r[a].vis+Math.min(o.toString().length,r[a].text.length)}function Ae(e,t){const n=e.layout.lines;let l=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){l=e;break}let r=Math.max(0,t-n[l].vis);const a=e.lines[l].ownerDocument.createTreeWalker(e.lines[l],4);let o=a.nextNode(),s=null;for(;o;){if(r<=o.data.length)return[o,r];r-=o.data.length,s=o,o=a.nextNode()}return s?[s,s.data.length]:[e.lines[l],0]}function He(e,t,n){if(n<0){const n=e.charCodeAt(t-1);return t-(n>=56320&&n<=57343&&t>=2?2:1)}const l=e.charCodeAt(t);return t+(l>=55296&&l<=56319?2:1)}function Re({value:e,rules:t,multiline:n,readOnly:l=!1,placeholder:r,ariaLabel:a,handle:o,onEdit:s,onSelect:i,onHistory:c,onFormat:u,pending:d,onCommit:h,onCancel:p}){const m=ee(null),f=ee(null),b=ee(null),g=ee(null),y=ee(null),v=ee(e),[k,x]=te(0),w=ee({value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u});w.current={value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u};const C=()=>{const e=m.current,t=f.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const l=$e(t,e,n.anchorNode,n.anchorOffset),r=n.focusNode&&e.contains(n.focusNode)?$e(t,e,n.focusNode,n.focusOffset):l;return l<=r?[l,r]:[r,l]},D=(e,t)=>{const n=m.current,l=f.current;if(!n||!l)return;const[r,a]=Ae(l,e),[o,s]=Ae(l,t);n.ownerDocument.getSelection()?.setBaseAndExtent(r,a,o,s)};o.current={getSource(){const e=C(),t=f.current;if(!e||!t)return null;const[n,l]=Le(t.layout,e[0],e[1]);return{start:n,end:l}},setSource(e,t,n){g.current={text:n,src:[e,t]},x(e=>e+1)},focus(){m.current?.focus()}},ne(()=>{const n=m.current;if(!n||y.current)return;const l=g.current?null:C();f.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const l=t.lines.map(t=>{const l=n.createElement("div");l.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(l.dataset.number=t.number);const r=[],a=()=>r.length?r[r.length-1].el:l;let o=null;for(const e of t.chars){let t=0;for(;t<r.length&&t<e.marks.length&&r[t].id===e.marks[t].id;)t+=1;(r.length>t||e.marks.length>t)&&(o=null),r.length=t;for(let l=t;l<e.marks.length;l+=1){const t=Fe(n,e.marks[l].kind,e.marks[l].href,e.marks[l].color);a().appendChild(t),r.push({id:e.marks[l].id,el:t})}o||(o=n.createTextNode(""),a().appendChild(o)),o.data+=e.ch}return 0===t.chars.length&&l.appendChild(n.createElement("br")),e.appendChild(l),l});return{layout:t,lines:l}}(n,Ce(e,t)),b.current=e;const r=g.current;if(!r||r.text!==e)return void(l&&n.ownerDocument.activeElement===n&&D(l[0],Math.min(l[1],f.current.layout.text.length)));g.current=null;const a=f.current.layout,[o,s]=r.vis??Me(a,r.src[0],r.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),D(o,s)},[e,t,k]);const N=(e,t,n)=>{const l=f.current,[r,a]=Le(l.layout,t[0],t[1]);g.current={text:e.text,vis:[e.caret,e.caret]},e.text!==w.current.value?w.current.onEdit(e.text,{start:r,end:a},n):x(e=>e+1)};le(()=>{const e=m.current;if(!e)return;const t=t=>{const{value:n,rules:l,multiline:r,readOnly:a,pending:o}=w.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),a)return;const s=f.current,i=C();if(!s||!i)return;let[c,u]=i;const d="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0;d&&!d.collapsed&&t.inputType.startsWith("delete")&&(c=$e(s,e,d.startContainer,d.startOffset),u=$e(s,e,d.endContainer,d.endOffset));const h=s.layout.text,p=t.inputType;if("historyUndo"!==p&&"historyRedo"!==p)if("formatBold"!==p&&"formatItalic"!==p&&"formatStrikeThrough"!==p)if("insertParagraph"!==p&&"insertLineBreak"!==p){if(p.startsWith("insert")){let a=t.data??t.dataTransfer?.getData("text/plain")??"";if("insertFromDrop"===p||"insertFromPaste"===p){const o=ke({html:t.dataTransfer?.getData("text/html"),text:a},{doc:e.ownerDocument,multiline:r,rules:l});return void N(je(n,l,c,u,{markup:o}),[c,u],"edit")}return r||(a=a.replace(/\s*\r?\n\s*/g," ")),void N(je(n,l,c,u,{text:a,add:o?.add,drop:o?.drop,color:o?.color}),[c,u],"type")}if(p.startsWith("delete")){if(c===u){const e=p.includes("Backward"),t=s.layout.lines.findIndex(e=>c>=e.vis&&c<=e.vis+e.text.length),r=s.layout.lines[t];if(e&&r&&c===r.vis&&(r.bullet||null!=r.number))return void N(Pe(n,l,t,!1,c),[c,u],"edit");if(e?0===c:c===h.length)return;e?c=He(h,c,-1):u=He(h,u,1)}N(je(n,l,c,u,{text:""}),[c,u],"type")}}else r&&N(Ke(n,l,c,u),[c,u],"edit");else w.current.onFormat("formatBold"===p?"bold":"formatItalic"===p?"italic":"strike");else w.current.onHistory("historyUndo"===p?"undo":"redo")},n=()=>{y.current||x(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),le(()=>{const e=m.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=o.current?.getSource();e&&i(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const S=(n,r=!1)=>{const a=C();if(!a||a[0]===a[1])return;n.preventDefault();const o=f.current;n.clipboardData.setData("text/plain",o.layout.text.slice(a[0],a[1])),n.clipboardData.setData(Be,Oe(e,t,a[0],a[1])),r&&!l&&N(je(e,t,a[0],a[1],{text:""}),a,"edit")};/* @__PURE__ */
2
- return oe("div",{className:"es-rich-wrap",children:[r&&""===e?/* @__PURE__ */ae("div",{className:"es-rich-placeholder","aria-hidden":"true",children:r}):null,
3
- /* @__PURE__ */ae("div",{ref:m,className:`es-rich${n?" is-multiline":" is-single"}${l?" is-off":""}`,contentEditable:!l,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":n,"aria-label":a,"aria-readonly":l||void 0,"aria-placeholder":r,tabIndex:l?-1:0,spellCheck:!0,onFocus:()=>{v.current=e},onBlur:()=>{e!==v.current&&h?.(e),v.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),p?.(v.current),void(v.current=e);"Enter"!==t.key||n||(t.preventDefault(),e!==v.current&&h?.(e),v.current=e)},onCompositionStart:()=>{const e=C()??[0,0];y.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=y.current;if(y.current=null,!t)return;const{value:n,rules:l,pending:r}=w.current;e.data?N(je(n,l,t.from,t.to,{text:e.data,add:r?.add,drop:r?.drop,color:r?.color}),[t.from,t.to],"type"):x(e=>e+1)},onCopy:e=>S(e),onCut:e=>S(e,!0),onPaste:r=>{if(r.preventDefault(),l)return;const a=C();if(!a)return;const o=r.clipboardData.getData(Be),s=o?n?o:o.replace(/\s*\r?\n\s*/g," "):ke({html:r.clipboardData.getData("text/html"),text:r.clipboardData.getData("text/plain")},{doc:r.currentTarget.ownerDocument,multiline:n,rules:t});N(je(e,t,a[0],a[1],{markup:s}),a,"edit")}})]})}var Ue=1e3;function We(e=200){let t=[],n=[],l=null,r=0;return{record(a,o,s){const i="type"===o&&"type"===l&&s-r<1e3;l=o,r=s,n=[],i||(t.push(a),t.length>e&&t.shift())},undo(e){const r=t.pop();return r?(n.push(e),l=null,r):null},redo(e){const r=n.pop();return r?(t.push(e),l=null,r):null},reset(){t=[],n=[],l=null}}}var ze={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ae(F,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ae(B,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ae(O,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ae(P,{}),unit:"px",step:1,shiftStep:10,min:0}};function Ie(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Ve({cells:e,words:n,readOnly:r=!1}){const a=n??t.cells;/* @__PURE__ */
4
- return ae("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?a[e.nameKey]:e.key),o=e.unit??"",s=e.step??1;/* @__PURE__ */
5
- return ae(l,{value:Ie(e.value,t),styleValue:Ie(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:o||void 0,steppers:!0,readOnly:r,ariaLabel:n,title:a.tip({name:n,step:s,unit:o})},e.key)})})}var Ze=e=>e.preventDefault();function qe({colors:t,current:l,words:r,onPick:a}){const o=null===l?null:l.startsWith("#")?l.toLowerCase():t.find(e=>e.name===l)?.value.toLowerCase()??null;/* @__PURE__ */
6
- return oe("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":r.title,onMouseDown:e=>{e.target instanceof HTMLInputElement||e.preventDefault()},children:[
7
- /* @__PURE__ */ae("span",{className:"es-copy-pop-label",children:r.theme}),
8
- /* @__PURE__ */ae("div",{className:"es-copy-swatches",children:t.map(e=>/* @__PURE__ */ae("button",{type:"button",className:"es-copy-swatch","data-color":e.name,"aria-label":e.label,title:`${e.label} · ${e.value.toUpperCase()}`,"aria-pressed":l===e.name,style:{background:e.value},onMouseDown:Ze,onClick:()=>a(e.name)},e.name))}),
9
- /* @__PURE__ */ae("span",{className:"es-copy-pop-label",children:r.any}),
10
- /* @__PURE__ */ae(e,{value:o??"",onChange:e=>{e!==l&&a(e)},label:r.title,swatch:!0,dragWrites:"end",words:{...n.colour,dialog:()=>r.any,square:r.square,hue:r.hue,hex:()=>r.hex}}),
11
- /* @__PURE__ */ae("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-danger",onMouseDown:Ze,onClick:()=>a(null),children:r.remove})})]})}function Qe({href:e,editing:n,onApply:l,onRemove:r,onClose:a,floating:o=!1}){const s=M("copy",t).link,i=re(),[c,u]=te(e),[d,h]=te(!1),p=ee(null);le(()=>{p.current?.focus(),p.current?.select()},[]);const m=()=>{const e=c.trim();k(e)?l(e):h(!0)};/* @__PURE__ */
12
- return oe("div",{role:"dialog","aria-label":s.title,className:"es-copy-link"+(o?" es-copy-pop":""),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),m()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},children:[
13
- /* @__PURE__ */ae("label",{htmlFor:i,className:"es-copy-link-label",children:s.label}),
14
- /* @__PURE__ */ae("input",{ref:p,id:i,type:"text",className:"es-copy-link-input",value:c,placeholder:s.placeholder,spellCheck:!1,autoComplete:"off","aria-invalid":d||void 0,"aria-describedby":d?`${i}-why`:void 0,onChange:e=>{u(e.target.value),h(!1)}}),d?/* @__PURE__ */ae("p",{id:`${i}-why`,role:"alert",className:"es-copy-link-why",children:s.refused}):null,
15
- /* @__PURE__ */oe("div",{className:"es-copy-link-actions",children:[n?/* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-danger",onClick:r,children:s.remove}):null,
16
- /* @__PURE__ */oe("span",{className:"es-copy-link-end",children:[
17
- /* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn",onClick:a,children:s.cancel??t.link.cancel}),
18
- /* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-primary",onClick:m,disabled:""===c.trim(),children:s.apply})]})]})]})}var Xe=e=>e.preventDefault();function Ye(){/* @__PURE__ */
19
- return ae("span",{className:"es-tb-cell is-empty","aria-hidden":"true"})}function Ge({words:e,align:t,alignmentLabel:n,offered:l,pressed:r,onMark:a,color:o,linkOpen:s,onUndo:i,alignment:c,list:u,letterCase:d,disabled:h=!1,ariaLabel:p="Formatting"}){const m=(e,t,n,o)=>l.has(e)?/* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn"+(r[e]||"link"===e&&s?" is-on":""),"aria-label":t,title:t,"aria-pressed":"link"===e?void 0:Boolean(r[e]),"aria-haspopup":"link"===e?"dialog":void 0,"aria-expanded":"link"===e?s:void 0,"aria-keyshortcuts":o,disabled:h,onMouseDown:Xe,onClick:()=>a(e),children:n},e):/* @__PURE__ */ae(Ye,{},e),f=[["left",/* @__PURE__ */ae(K,{},"l")],["center",/* @__PURE__ */ae(j,{},"c")],["right",/* @__PURE__ */ae(T,{},"r")],["justify",/* @__PURE__ */ae(L,{},"j")]],b=[["none",e.caseNone,/* @__PURE__ */ae($,{},"n")],["upper",e.caseUpper,/* @__PURE__ */ae(A,{},"u")],["lower",e.caseLower,/* @__PURE__ */ae(H,{},"w")]];/* @__PURE__ */
20
- return oe("div",{className:"es-tb",role:"toolbar","aria-label":p,children:[
21
- /* @__PURE__ */oe("div",{className:"es-tb-row",children:[m("bold",e.bold,/* @__PURE__ */ae(I,{}),"Meta+B"),m("italic",e.italic,/* @__PURE__ */ae(V,{}),"Meta+I"),m("underline",e.underline,/* @__PURE__ */ae(Z,{}),"Meta+U"),m("strike",e.strike,/* @__PURE__ */ae(q,{})),o?/* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn es-tb-color"+(o.open?" is-on":""),"aria-label":e.color,title:e.color,"aria-haspopup":"dialog","aria-expanded":o.open,disabled:h,style:o.run?{"--es-tb-run":o.run}:void 0,onMouseDown:Xe,onClick:o.onToggle,children:/* @__PURE__ */ae(R,{})}):/* @__PURE__ */ae(Ye,{}),m("link",e.link,/* @__PURE__ */ae(Q,{}),"Meta+K"),m("sup",e.sup,/* @__PURE__ */ae(X,{})),m("sub",e.sub,/* @__PURE__ */ae(Y,{})),
22
- /* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn","aria-label":e.undo,title:e.undoTitle,"aria-keyshortcuts":"Meta+Z",disabled:h,onMouseDown:Xe,onClick:i,children:/* @__PURE__ */ae(U,{})})]}),
23
- /* @__PURE__ */oe("div",{className:"es-tb-row",children:[
24
- /* @__PURE__ */ae("div",{className:"es-tb-group",role:"radiogroup","aria-label":n,children:f.map(([e,n])=>c&&c.allow.includes(e)?/* @__PURE__ */ae("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(c.value===e?" is-on":""),"aria-checked":c.value===e,"aria-label":t[e],title:t[e],disabled:h||c.disabled,onMouseDown:Xe,onClick:()=>c.onChange(e),children:n},e):/* @__PURE__ */ae(Ye,{},e))}),u&&l.has("bullet")?/* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn"+("bullet"===u.pressed?" is-on":""),"aria-label":e.bullet,title:e.bullet,"aria-pressed":"bullet"===u.pressed,disabled:h,onMouseDown:Xe,onClick:()=>u.onList("bullet"),children:/* @__PURE__ */ae(W,{})}):/* @__PURE__ */ae(Ye,{}),u&&l.has("number")?/* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn"+("number"===u.pressed?" is-on":""),"aria-label":e.number,title:e.number,"aria-pressed":"number"===u.pressed,disabled:h,onMouseDown:Xe,onClick:()=>u.onList("number"),children:/* @__PURE__ */ae(z,{})}):/* @__PURE__ */ae(Ye,{}),
25
- /* @__PURE__ */ae("div",{className:"es-tb-group",role:"radiogroup","aria-label":e.letterCase,children:b.map(([e,t,n])=>d?/* @__PURE__ */ae("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(d.value===e?" is-on":""),"aria-checked":d.value===e,"aria-label":t,title:t,disabled:h||d.disabled,onMouseDown:Xe,onClick:()=>d.onChange(d.value===e?"":e),children:n},e):/* @__PURE__ */ae(Ye,{},e))})]})]})}var Je=/* @__PURE__ */new Set([...s,"clear"]),_e={bold:/* @__PURE__ */ae(I,{size:16}),italic:/* @__PURE__ */ae(V,{size:16}),strike:/* @__PURE__ */ae(q,{size:16}),highlight:/* @__PURE__ */ae(_,{size:16}),quiet:/* @__PURE__ */ae(J,{size:16}),link:/* @__PURE__ */ae(Q,{size:16}),clear:/* @__PURE__ */ae(G,{size:16})};function et(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var tt={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function nt({tools:e,onApply:n,disabled:l=!1,actions:r,align:a,glyphs:o,ariaLabel:s,pressed:i,open:c=null}){const u=M("copy",t),d=("string"==typeof e[0]?m(e).map(e=>({...e,...u.marks[e.style]})):e).filter(e=>!Je.has(e.style));return 0!==d.length||r||a?/* @__PURE__ */oe("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=o?.[e.style]??_e[e.style],r=c===e.style||Boolean(i?.[e.style]);/* @__PURE__ */
26
- return ae("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:l,title:e.title,"aria-label":e.name??e.title,"aria-keyshortcuts":et(e.shortcut),"aria-pressed":i||c?r:void 0,"aria-haspopup":"link"===e.style&&i?"dialog":void 0,"aria-expanded":"link"===e.style&&i?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":tt[e.style]?` ${tt[e.style]}`:""}${r?" is-active":""}`,children:t??e.label},e.style)}),r?/* @__PURE__ */oe(se,{children:[
27
- /* @__PURE__ */ae("span",{className:"es-copy-bar-split","aria-hidden":"true"}),r]}):null,a?/* @__PURE__ */ae("span",{className:"es-copy-bar-end",children:a}):null]}):null}function lt({target:e,onChange:t}){const n=ee(null);return ne(()=>{const t=n.current,l=e.current;t&&l&&l.value===t.text&&(n.current=null,l.focus(),l.setSelectionRange(t.start,t.end))}),l=>{const r=l(e.current);t(r.text),n.current={start:r.selectionStart,end:r.selectionEnd,text:r.text}}}function rt({value:e,onChange:n,onCommit:l,onCancel:s,multiline:u=!1,placeholder:d,ariaLabel:h,className:k,readOnly:L=!1,rules:T,tools:j=[],writeMark:K,actions:P,align:O,glyphs:B,barLabel:F,renderFooter:$,inputRef:A,barShows:H="always",richText:R=!0,defaultShowMarks:U=!1,toolbar:W="final",colors:z,cells:I,letterCase:V}){const Z="final"===W,q=M("copy",t),Q=ee(null),X=A??Q,[Y,G]=te(!1),[J,_]=te(null),se=ee(We()).current,ie=ee(null);le(()=>{const t=ie.current;t&&e===t.to?ie.current=null:t&&e===t.from||(ie.current=null,se.reset())},[e,se]);const ce=t=>{ie.current={from:ie.current?.from??e,to:t},n(t)},ue=t=>({text:e,start:t?.selectionStart??J?.start??e.length,end:t?.selectionEnd??J?.end??e.length}),[de,pe]=te(U),fe=R&&!(u&&de),ye=ee(null),ve=re(),[xe,we]=te(null),[Ce,De]=te(!1),Ne=()=>{if(!fe)return X.current;const e=ye.current?.getSource()??J;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Se=lt({target:X,onChange:ce}),Ee=e=>(_({start:e.selectionStart,end:e.selectionEnd}),e),Me=(t,n)=>{if(!fe)return void Se(e=>(n&&se.record(ue(e),"edit",Date.now()),Ee(t(e))));const l=Ne(),r=Ee(t(l));n&&se.record(ue(l),"edit",Date.now()),we(null),r.text!==e&&ce(r.text),ye.current?.setSource(r.selectionStart,r.selectionEnd,r.text)},Le=e=>Me(e,!0),Te=e=>Me(t=>{const n=ue(t),l=se[e](n);return l?{text:l.text,selectionStart:l.start,selectionEnd:l.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),je=ee(null);ne(()=>{const t=je.current;t&&(je.current=null,fe?ye.current?.setSource(t.start,t.end,e):(X.current?.focus(),X.current?.setSelectionRange(t.start,t.end),_(t)))},[fe]);const[Ke,Pe]=te(null),Oe=T??c,Be=("string"==typeof j[0]?m(j):j).filter(e=>!Je.has(e.style)),Fe=Z?("string"==typeof j[0]?j:j.map(e=>e.style)).filter(e=>!Je.has(e)):Be.map(e=>e.style),$e={};if(J&&(fe||Z)){const t=f(e,J.start,J.end,Oe);for(const e of Fe){const n=t.has(e)||"highlight"===e&&t.has("accent");$e[e]=!!xe?.add.includes(e)||!xe?.drop.includes(e)&&n}Z&&($e.link=t.has("link"))}else if(J)for(const t of Fe)$e[t]="link"===t?null!==b(e,J.start,J.end):g(e,J.start,J.end,t);const Ae=()=>{const t=Ne(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},He={sup:"sub",sub:"sup"},Ue=t=>{if(Z&&"link"!==t&&p(0,t)){const{start:n,end:l}=Ae(),r=He[t];if(n===l){if(!fe)return void Le(n=>be(e,t,n,(e,t,n,l)=>i(e,t,n,l,Oe,q.placeholders)));const a=f(e,n,l,Oe),o=xe&&xe.at===n?xe:null,s=a.has(t),c=!!o?.add.includes(t)||!o?.drop.includes(t)&&s;let u=(o?.add??[]).filter(e=>e!==t),d=(o?.drop??[]).filter(e=>e!==t);return c&&s?d.push(t):c||s||u.push(t),!c&&r&&(u=u.filter(e=>e!==r),a.has(r)&&(d=[...d.filter(e=>e!==r),r])),void we(u.length||d.length||void 0!==o?.color?{add:u,drop:d,color:o?.color,at:n}:null)}return void Le(()=>{let a=e,o=n,s=l;if(r&&!f(a,o,s,Oe).has(t)&&f(a,o,s,Oe).has(r)){const e=x(a,o,s,r,Oe);({text:a,selectionStart:o,selectionEnd:s}=e)}return x(a,o,s,t,Oe)})}if("clear"===t)return void Le(n=>be(e,t,n,(e,t,n)=>i(e,t,n,"clear",Oe)));if("link"!==t&&fe&&p(0,t)){const n=Ne(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;if(l===r){const n=f(e,l,r,Oe),a=n.has(t)||"highlight"===t&&n.has("accent"),o=xe&&xe.at===l?xe:null,s=!!o?.add.includes(t)||!o?.drop.includes(t)&&a,i=(o?.add??[]).filter(e=>e!==t),c=(o?.drop??[]).filter(e=>e!==t);return s&&a?c.push(t):s||a||i.push(t),void we(i.length||c.length?{add:i,drop:c,at:l}:null)}return void Le(n=>x(e,n?.selectionStart??l,n?.selectionEnd??r,t,Oe))}if("link"!==t){const n=K??((e,t,n,l)=>i(e,t,n,l,c,q.placeholders));return void Le(l=>be(e,t,l,n))}const n=Ne(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;De(!1),Pe({start:l,end:r,link:b(e,l,r)})},ze=J?y(e,J.start,J.end,Oe):null,Ie=J?xe&&void 0!==xe.color&&xe.at===J.start?xe.color:v(e,J.start,J.end,Oe):null,Ze=Ie?Ie.startsWith("#")?Ie:z?.find(e=>e.name===Ie)?.value:void 0,Xe=()=>{Pe(null),fe?ye.current?.focus():X.current?.focus()},Ye=t=>Ke&&/* @__PURE__ */ae(Qe,{floating:t,href:Ke.link?.href??"",editing:null!==Ke.link,onApply:t=>{const n=Ke;Pe(null),Le(()=>fe?S(e,n.start,n.end,t,Oe):E(e,n.start,n.end,t))},onRemove:()=>{const t=Ke.link,n=Ke;Pe(null),t&&Le(()=>fe?D(e,n.start,n.end,Oe):N(e,t))},onClose:Xe}),_e=O?he(O.allow,q.align):[],et="always"===H||Y||null!==Ke||Ce;/* @__PURE__ */
28
- return oe("div",{className:"es-copy"+(k?` ${k}`:""),onFocus:()=>G(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||G(!1)},onKeyDownCapture:e=>{Ce&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),De(!1))},onKeyDown:e=>{const t=e.target===X.current||Boolean(e.target.closest?.(".es-rich"));if(L||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),l="KeyZ"===e.code||"z"===n,r=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(l||r)return e.preventDefault(),e.stopPropagation(),void Te(r||e.shiftKey?"redo":"undo");const a=`${e.shiftKey?"shift+":""}${n}`;if(Z){const t={b:"bold",i:"italic",u:"underline",k:"link"}[a];if(!t||!Fe.includes(t))return;return e.preventDefault(),e.stopPropagation(),void Ue(t)}const o=Be.find(e=>e.shortcut===a);o&&(e.preventDefault(),e.stopPropagation(),Ue(o.style))},onPaste:t=>{const n=X.current;if(L||!n||t.target!==n)return;t.preventDefault();const l=ke({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:u,rules:Oe});Le(t=>ge(e,l,t))},style:z&&z.length>0?Object.fromEntries(z.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=X.current;t&&t.ownerDocument.activeElement===t&&_({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[et&&Z?/* @__PURE__ */oe("div",{className:"es-tb-wrap",children:[
29
- /* @__PURE__ */ae(Ge,{words:q.toolbar??t.toolbar,align:q.align,alignmentLabel:q.alignment,ariaLabel:F??q.formatting,offered:new Set(Fe),pressed:$e,onMark:e=>Ue(e),color:z&&z.length>0?{run:Ze,open:Ce,onToggle:()=>{Pe(null),De(e=>!e)}}:void 0,linkOpen:null!==Ke,onUndo:()=>Te("undo"),alignment:O?{value:O.value,allow:O.allow,onChange:O.onChange,disabled:O.disabled}:void 0,list:{pressed:ze,onList:t=>{const{start:n,end:l}=Ae(),r=y(e,n,l,Oe);Le(()=>C(e,n,l,r===t?null:t,Oe))}},letterCase:V,disabled:L}),Ce&&z&&z.length>0?/* @__PURE__ */ae(qe,{colors:z,current:Ie,words:q.colors??t.colors,onPick:t=>{const{start:n,end:l}=Ae();if(n!==l)Le(()=>w(e,n,l,t,Oe));else{if(!fe)return;we({add:xe?.add??[],drop:xe?.drop??[],color:t,at:n})}}}):null,Ke?Ye(!0):null]}):null,Z&&I&&I.length>0?/* @__PURE__ */ae(Ve,{cells:I,words:q.cells??t.cells,readOnly:L}):null,et&&!Z?/* @__PURE__ */ae(nt,{tools:j,disabled:L,actions:P,glyphs:B,ariaLabel:F,pressed:$e,open:Ke?"link":null,onApply:Ue,align:O?/* @__PURE__ */ae(r,{options:_e,value:O.value,onChange:O.onChange,ariaLabel:q.alignment,disabled:L||O.disabled,fit:me(_e)}):null}):null,fe?/* @__PURE__ */ae(Re,{value:e,rules:Oe,multiline:u,readOnly:L,placeholder:d,ariaLabel:h,handle:ye,pending:xe??void 0,onEdit:(t,n,l)=>{se.record({text:e,start:n.start,end:n.end},l,Date.now()),we(null),ce(t)},onSelect:e=>{_(t=>t&&t.start===e.start&&t.end===e.end?t:e),!xe||e.start===xe.at&&e.end===xe.at||we(null)},onHistory:Te,onFormat:e=>{Fe.includes(e)&&Ue(e)},onCommit:l,onCancel:s}):/* @__PURE__ */ae(o,{value:e,onInput:e=>{se.record(ue(null),"type",Date.now()),ce(e)},onCommit:l,onCancel:s,multiline:u,placeholder:d,ariaLabel:h,rules:T,disabled:L,inputRef:X,className:"es-copy-box"}),Ke&&!Z?Ye(!1):null,$?$({focused:Y,insert:t=>Le(n=>ge(e,t,n))}):null,R&&u?/* @__PURE__ */oe("div",{className:"es-copy-marks",children:[
30
- /* @__PURE__ */ae(a,{checked:de,onChange:()=>{const e=Ne();je.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:J,we(null),pe(e=>!e)},ariaLabelledBy:ve,disabled:L}),
31
- /* @__PURE__ */ae("span",{id:ve,className:"es-copy-marks-label",children:q.showMarks??"Show marks"})]}):null]})}export{ie as COPY_ALIGNS,de as COPY_ALIGN_FIT,ue as COPY_ALIGN_GLYPHS,ce as COPY_ALIGN_LABELS,ze as COPY_CELLS,qe as ColorWindow,rt as CopyBox,Ve as CopyCells,Be as MARKUP_CLIPBOARD_TYPE,nt as MarkBar,Re as RichBox,Ue as TYPING_BURST_MS,Ge as TextToolbar,et as ariaShortcut,he as copyAlignOptions,We as createHistory,je as editVisible,ge as insertSelection,be as markSelection,Oe as markupOfRange,Ke as newLine,ke as pasteToMarkup,Ce as richLayout,Le as selectionToSource,Me as selectionToVisible,Pe as setBullet,Ne as toSource,Se as toSourceStart,Ee as toVisible,lt as useCaretEdit};
1
+ import{ColourWindow as e}from"../chunk-H24N5TMZ.js";import{DEFAULT_COPY_WORDS as t}from"../chunk-UH7IGZKF.js";import{DEFAULT_PICK_WORDS as n}from"../chunk-ZAOM6PFH.js";import{FieldNumber as l}from"../chunk-EWVJSRRY.js";import{SettingsSegmented as r,SettingsSwitch as o}from"../chunk-P6O363EE.js";import"../chunk-FPOKPNO4.js";import{GoldTextInput as a}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as s,applyMark as i,STANDARD_MARKUP as c,writeMarkedLines as u,sameMarks as d,markedLines as h,spanFor as p,markupTools as f,marksIn as m,findLink as b,markedAt as g,listIn as y,colorIn as v,clearStyle as k,isSafeLinkHref as x,toggleMark as w,colorOver as C,setList as E,unlinkAt as S,removeLink as D,linkOver as N,writeLink as M}from"../chunk-546BBOPE.js";import{useWords as L}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{AlignJustifyIcon as T,AlignRightIcon as j,AlignCenterIcon as B,AlignLeftIcon as O,ParagraphSpacingIcon as R,LetterSpacingIcon as P,TextLinesIcon as K,TextSizeIcon as F,CaseNormalIcon as H,CaseUpperIcon as W,CaseLowerIcon as $,TextColorIcon as z,ListIcon as I,NumberedListIcon as A,ClearMarksIcon as q,BoldIcon as U,ItalicIcon as V,UnderlineIcon as Z,StrikeIcon as Y,LinkIcon as G,SuperscriptIcon as J,SubscriptIcon as X,QuietIcon as Q,EmphasisIcon as _}from"../chunk-L5KW4HG5.js";import{useRef as ee,useState as te,useLayoutEffect as ne,useEffect as le,useId as re}from"react";import{jsx as oe,jsxs as ae,Fragment as se}from"react/jsx-runtime";var ie=["left","center","right","justify"],ce=t.align,ue={left:/* @__PURE__ */oe(O,{}),center:/* @__PURE__ */oe(B,{}),right:/* @__PURE__ */oe(j,{}),justify:/* @__PURE__ */oe(T,{})},de={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function he(e,t=ce){return ie.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:ue[e],title:t[e]}))}var pe=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function fe(e){if(e.every(e=>e.label===ce[e.id]))return e.length>3?de.four:de.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(pe.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function me(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function be(e,t,n,l=i){const{start:r,end:o}=me(e,n);return l(e,r,o,t)}function ge(e,t,n){const{start:l,end:r}=me(e,n),o=l+t.length;return{text:e.slice(0,l)+t+e.slice(r),selectionStart:o,selectionEnd:o}}var ye=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),ve=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function ke(e,t){const n=t.rules??c,l=e.html&&""!==e.html.trim()?function(e,t,n){const l=t.createElement("template");l.innerHTML=e;const r=[[]],o=()=>r[r.length-1],a=()=>{const e=o();for(;e.length>0&&" "===e[e.length-1].ch;)e.pop();e.length>0&&r.push([])},s=(e,t,n,l)=>{if(3===e.nodeType){for(const a of e.textContent??""){const e=/\s/.test(a)?" ":a,s=o();" "===e&&(0===s.length&&r.length>1||" "===s[s.length-1]?.ch)||s.push({ch:e,bold:t,italic:n,href:l})}return}if(1!==e.nodeType&&11!==e.nodeType)return;const i=e,c=1===e.nodeType?i.localName:"";if(ye.has(c))return;if("br"===c)return void r.push([]);let u=t,d=n,h=l;if("b"!==c&&"strong"!==c||(u=!0),"i"!==c&&"em"!==c||(d=!0),"a"===c){const e=(i.getAttribute("href")??"").trim();h=x(e)?e:null}const p=1===e.nodeType?i.style:null;if(p){const e=p.fontWeight;"bold"===e||"bolder"===e||Number(e)>=600?u=!0:("normal"===e||"lighter"===e||""!==e&&Number(e)<600)&&(u=!1),"italic"===p.fontStyle||"oblique"===p.fontStyle?d=!0:"normal"===p.fontStyle&&(d=!1)}const f=ve.has(c);f&&a();for(const t of[...e.childNodes])s(t,u,d,h);f&&a()};s(l.content,!1,!1,null);for(;r.length>1&&0===r[r.length-1].length;)r.pop();return r.map(e=>function(e,t){const n=t=>e.map((n,l)=>n[t]&&(" "!==n.ch||Boolean(e[l-1]?.[t])&&Boolean(e[l+1]?.[t]))),l=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const r of l){const l=xe(e,r.bold?n("bold"):null,r.italic?n("italic"):null,r.links),o=u([l]).text;if(d([l],h(o,t)))return o}return e.map(e=>e.ch).join("")}(e,n))}(e.html,t.doc,n):(e.text??"").replace(/\r\n?/g,"\n").split("\n");return t.multiline?l.join("\n"):1===l.length?l[0]:l.map(e=>e.trim()).filter(e=>""!==e).join(" ")}function xe(e,t,n,l){let r=0,o=null,a=null,s=null;return{bullet:!1,chars:e.map((e,i)=>{const c=l?e.href:null;return o=null===c?null:o&&o.href===c?o:p(++r,"link",c),a=t?.[i]?a??p(++r,"bold"):null,s=n?.[i]?s??p(++r,"italic"):null,{ch:e.ch,at:-1,marks:[o,a,s].filter(e=>null!==e)}})}}var we=/^([0-9]{1,3})\. $/;function Ce(e,t){const n=e.split("\n"),l=h(e,t);let r=0,o=0;const a=l.map((e,t)=>{const l=!e.bullet&&null==e.number&&"- "===n[t],a=null!=e.number||e.bullet?null:we.exec(n[t]),s=e.bullet||l,i=a?a[1]:e.number??null,c=l||a?[]:e.chars,u=c.map(e=>e.ch).join(""),d=null!=i?i.length+2:s?2:0,h={bullet:s,number:i,chars:c,start:r,src:r+d,vis:o,text:u};return r+=n[t].length+1,o+=u.length+1,h});return{lines:a,text:a.map(e=>e.text).join("\n")}}function Ee(e,t){const{lines:n}=e;for(let e=0;e<n.length;e+=1){const l=n[e];if(t<=l.vis+l.text.length||e===n.length-1)return[l,Math.max(0,Math.min(t-l.vis,l.text.length)),e]}return[n[0],0,0]}function Se(e,t){const[n,l]=Ee(e,t);if(0===l)return n.src;let r=0;for(const e of n.chars){if(l<=r+e.ch.length)return e.at+(l-r);r+=e.ch.length}return n.src}function De(e,t){const[n,l]=Ee(e,t);let r=0;for(const e of n.chars){if(l===r)return e.at;r+=e.ch.length}return Se(e,t)}function Ne(e,t){const{lines:n}=e;let l=n[0];for(const e of n)t>=e.start&&(l=e);let r=0;for(const e of l.chars){if(!(t>=e.at+e.ch.length)){t>e.at&&(r+=t-e.at);break}r+=e.ch.length}return l.vis+r}function Me(e,t,n){return[Ne(e,t),Ne(e,n)]}function Le(e,t,n){return t===n?[Se(e,t),Se(e,t)]:[De(e,t),Se(e,n)]}function Te(e,t){let n=0;for(let l=0;l<e.chars.length;l+=1){if(n>=t)return l;n+=e.chars[l].ch.length}return e.chars.length}function je(e,t,n,l,r){const o=Ce(e,t),[a,s,i]=Ee(o,Math.min(n,l)),[c,f,m]=Ee(o,Math.max(n,l)),b=Te(a,s),g=Te(c,f),y=a.chars.slice(0,b),v=c.chars.slice(g),k=n!==l&&a.chars[b]&&(i!==m||b<g)?a.chars[b].marks:function(e,t){const n=e.chars[t-1],l=e.chars[t],r=(e,t)=>{const n=e.findIndex(e=>"link"===e.kind);return-1===n||t?e:e.slice(0,n)};if(n){const e=n.marks.find(e=>"link"===e.kind),t=Boolean(e&&l?.marks.some(t=>t.id===e.id));return r(n.marks,t)}return l?r(l.marks,!1):[]}(a,b);let x=(w=o.lines,Math.max(0,...w.flatMap(e=>e.chars.flatMap(e=>e.marks.map(e=>e.id))))+1);var w;const C=e=>{let n;if(void 0!==r.markup){const e=x;n=h(r.markup,t).map(t=>({bullet:t.bullet,number:t.number??null,chars:t.chars.map(t=>({...t,at:-1,marks:t.marks.map(t=>({...t,id:t.id+e}))}))}))}else{let t=a.number??null;n=(r.text??"").split("\n").map((n,l)=>(l>0&&null!=t&&(t=function(e){return String(Number(e)+1).padStart(e.length,"0")}(t)),{bullet:a.bullet,number:t,chars:[...n].map(t=>({ch:t,at:-1,marks:e??[]}))}))}const l=n.map(e=>e.chars.map(e=>e.ch).join("")).join("\n"),s={bullet:a.bullet,number:a.number??null,chars:[...y,...n[0].chars]},c=n.slice(1);if(c.length>0){const e=c[c.length-1];c[c.length-1]={...e,chars:[...e.chars,...v]}}else s.chars.push(...v);return{lines:[...o.lines.slice(0,i).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n})),s,...c,...o.lines.slice(m+1).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n}))],shown:l}},E=void 0!==r.markup?[null]:[(e=>{let t=e.filter(e=>!r.drop?.some(t=>e.kind===t||"highlight"===t&&"accent"===e.kind));for(const e of r.add??[]){if(t.some(t=>t.kind===e))continue;const n=p(x++,e);n&&(t=[...t,n])}if(void 0!==r.color){t=t.filter(e=>"color"!==e.kind);const e=null===r.color?null:p(x++,"color",r.color);e&&(t=[...t,e])}return t})(k),k,[]];let S="",D="";for(const e of E){const n=C(e),l=u(n.lines).text;if(S=l,D=n.shown,d(n.lines,Ce(l,t).lines))break}return{text:S,caret:Math.min(n,l)+D.length}}function Be(e,t,n,l){const r=Ce(e,t),[o,,a]=Ee(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?je(e,t,n,l,{text:"\n"}):Oe(e,t,a,!1,n)}function Oe(e,t,n,l,r){const o=Ce(e,t).lines.map(({bullet:e,number:t,chars:r},o)=>o===n?{bullet:l,number:null,chars:r}:{bullet:e,number:t,chars:r});return{text:u(o).text,caret:r}}function Re(e,t,n,l){const r=Ce(e,t),[o,a,s]=Ee(r,Math.min(n,l)),[i,c,d]=Ee(r,Math.max(n,l)),h=r.lines.slice(s,d+1).map(({bullet:e,number:t,chars:n},l)=>{const r=0===l?Te(o,a):0,u=l===d-s?Te(i,c):n.length;return{bullet:e,number:t,chars:n.slice(r,u)}});return u(h).text}var Pe="application/x-efficient-markup";function Ke(e,t,n,l){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",l&&(t.dataset.color=l,t.title=l.startsWith("#")?l.toUpperCase():l,t.style.color=l.startsWith("#")?l:`var(--es-color-${l}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Fe(e,t,n,l){const r=e.layout.lines;if(n===t)return l>=e.lines.length?e.layout.text.length:r[l].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,l)}catch{return r[o].vis}return r[o].vis+Math.min(a.toString().length,r[o].text.length)}function He(e,t){const n=e.layout.lines;let l=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){l=e;break}let r=Math.max(0,t-n[l].vis);const o=e.lines[l].ownerDocument.createTreeWalker(e.lines[l],4);let a=o.nextNode(),s=null;for(;a;){if(r<=a.data.length)return[a,r];r-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[l],0]}function We(e,t,n){if(n<0){const n=e.charCodeAt(t-1);return t-(n>=56320&&n<=57343&&t>=2?2:1)}const l=e.charCodeAt(t);return t+(l>=55296&&l<=56319?2:1)}function $e({value:e,rules:t,multiline:n,readOnly:l=!1,placeholder:r,ariaLabel:o,handle:a,onEdit:s,onSelect:i,onHistory:c,onFormat:u,pending:d,onCommit:h,onCancel:p}){const f=ee(null),m=ee(null),b=ee(null),g=ee(null),y=ee(null),v=ee(e),[k,x]=te(0),w=ee({value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u});w.current={value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u};const C=()=>{const e=f.current,t=m.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const l=Fe(t,e,n.anchorNode,n.anchorOffset),r=n.focusNode&&e.contains(n.focusNode)?Fe(t,e,n.focusNode,n.focusOffset):l;return l<=r?[l,r]:[r,l]},E=(e,t)=>{const n=f.current,l=m.current;if(!n||!l)return;const[r,o]=He(l,e),[a,s]=He(l,t);n.ownerDocument.getSelection()?.setBaseAndExtent(r,o,a,s)};a.current={getSource(){const e=C(),t=m.current;if(!e||!t)return null;const[n,l]=Le(t.layout,e[0],e[1]);return{start:n,end:l}},setSource(e,t,n){g.current={text:n,src:[e,t]},x(e=>e+1)},focus(){f.current?.focus()},rangeOf(e,t){const n=f.current,l=m.current;if(!n||!l)return null;const[r,o]=Me(l.layout,e,t),[a,s]=He(l,r),[i,c]=He(l,o),u=n.ownerDocument.createRange();return u.setStart(a,s),u.setEnd(i,c),u}},ne(()=>{const n=f.current;if(!n||y.current)return;const l=g.current?null:C();m.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const l=t.lines.map(t=>{const l=n.createElement("div");l.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(l.dataset.number=t.number);const r=[],o=()=>r.length?r[r.length-1].el:l;let a=null;for(const e of t.chars){let t=0;for(;t<r.length&&t<e.marks.length&&r[t].id===e.marks[t].id;)t+=1;(r.length>t||e.marks.length>t)&&(a=null),r.length=t;for(let l=t;l<e.marks.length;l+=1){const t=Ke(n,e.marks[l].kind,e.marks[l].href,e.marks[l].color);o().appendChild(t),r.push({id:e.marks[l].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&l.appendChild(n.createElement("br")),e.appendChild(l),l});return{layout:t,lines:l}}(n,Ce(e,t)),b.current=e;const r=g.current;if(!r||r.text!==e)return void(l&&n.ownerDocument.activeElement===n&&E(l[0],Math.min(l[1],m.current.layout.text.length)));g.current=null;const o=m.current.layout,[a,s]=r.vis??Me(o,r.src[0],r.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),E(a,s)},[e,t,k]);const S=(e,t,n)=>{const l=m.current,[r,o]=Le(l.layout,t[0],t[1]);g.current={text:e.text,vis:[e.caret,e.caret]},e.text!==w.current.value?w.current.onEdit(e.text,{start:r,end:o},n):x(e=>e+1)};le(()=>{const e=f.current;if(!e)return;const t=t=>{const{value:n,rules:l,multiline:r,readOnly:o,pending:a}=w.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=m.current,i=C();if(!s||!i)return;let[c,u]=i;const d="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0;d&&!d.collapsed&&t.inputType.startsWith("delete")&&(c=Fe(s,e,d.startContainer,d.startOffset),u=Fe(s,e,d.endContainer,d.endOffset));const h=s.layout.text,p=t.inputType;if("historyUndo"!==p&&"historyRedo"!==p)if("formatBold"!==p&&"formatItalic"!==p&&"formatStrikeThrough"!==p)if("insertParagraph"!==p&&"insertLineBreak"!==p){if(p.startsWith("insert")){let o=t.data??t.dataTransfer?.getData("text/plain")??"";if("insertFromDrop"===p||"insertFromPaste"===p){const a=ke({html:t.dataTransfer?.getData("text/html"),text:o},{doc:e.ownerDocument,multiline:r,rules:l});return void S(je(n,l,c,u,{markup:a}),[c,u],"edit")}return r||(o=o.replace(/\s*\r?\n\s*/g," ")),void S(je(n,l,c,u,{text:o,add:a?.add,drop:a?.drop,color:a?.color}),[c,u],"type")}if(p.startsWith("delete")){if(c===u){const e=p.includes("Backward"),t=s.layout.lines.findIndex(e=>c>=e.vis&&c<=e.vis+e.text.length),r=s.layout.lines[t];if(e&&r&&c===r.vis&&(r.bullet||null!=r.number))return void S(Oe(n,l,t,!1,c),[c,u],"edit");if(e?0===c:c===h.length)return;e?c=We(h,c,-1):u=We(h,u,1)}S(je(n,l,c,u,{text:""}),[c,u],"type")}}else r&&S(Be(n,l,c,u),[c,u],"edit");else w.current.onFormat("formatBold"===p?"bold":"formatItalic"===p?"italic":"strike");else w.current.onHistory("historyUndo"===p?"undo":"redo")},n=()=>{y.current||x(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),le(()=>{const e=f.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=a.current?.getSource();e&&i(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const D=(n,r=!1)=>{const o=C();if(!o||o[0]===o[1])return;n.preventDefault();const a=m.current;n.clipboardData.setData("text/plain",a.layout.text.slice(o[0],o[1])),n.clipboardData.setData(Pe,Re(e,t,o[0],o[1])),r&&!l&&S(je(e,t,o[0],o[1],{text:""}),o,"edit")};/* @__PURE__ */
2
+ return ae("div",{className:"es-rich-wrap",children:[r&&""===e?/* @__PURE__ */oe("div",{className:"es-rich-placeholder","aria-hidden":"true",children:r}):null,
3
+ /* @__PURE__ */oe("div",{ref:f,className:`es-rich${n?" is-multiline":" is-single"}${l?" is-off":""}`,contentEditable:!l,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":n,"aria-label":o,"aria-readonly":l||void 0,"aria-placeholder":r,tabIndex:l?-1:0,spellCheck:!0,onFocus:()=>{v.current=e},onBlur:()=>{e!==v.current&&h?.(e),v.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),p?.(v.current),void(v.current=e);"Enter"!==t.key||n||(t.preventDefault(),e!==v.current&&h?.(e),v.current=e)},onCompositionStart:()=>{const e=C()??[0,0];y.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=y.current;if(y.current=null,!t)return;const{value:n,rules:l,pending:r}=w.current;e.data?S(je(n,l,t.from,t.to,{text:e.data,add:r?.add,drop:r?.drop,color:r?.color}),[t.from,t.to],"type"):x(e=>e+1)},onCopy:e=>D(e),onCut:e=>D(e,!0),onPaste:r=>{if(r.preventDefault(),l)return;const o=C();if(!o)return;const a=r.clipboardData.getData(Pe),s=a?n?a:a.replace(/\s*\r?\n\s*/g," "):ke({html:r.clipboardData.getData("text/html"),text:r.clipboardData.getData("text/plain")},{doc:r.currentTarget.ownerDocument,multiline:n,rules:t});S(je(e,t,o[0],o[1],{markup:s}),o,"edit")}})]})}var ze=1e3;function Ie(e=200){let t=[],n=[],l=null,r=0;return{record(o,a,s){const i="type"===a&&"type"===l&&s-r<1e3;l=a,r=s,n=[],i||(t.push(o),t.length>e&&t.shift())},undo(e){const r=t.pop();return r?(n.push(e),l=null,r):null},redo(e){const r=n.pop();return r?(t.push(e),l=null,r):null},reset(){t=[],n=[],l=null}}}var Ae={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */oe(F,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */oe(K,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */oe(P,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */oe(R,{}),unit:"px",step:1,shiftStep:10,min:0}};function qe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Ue({cells:e,words:n,readOnly:r=!1}){const o=n??t.cells;/* @__PURE__ */
4
+ return oe("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?o[e.nameKey]:e.key),a=e.unit??"",s=e.step??1;/* @__PURE__ */
5
+ return oe(l,{value:qe(e.value,t),styleValue:qe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:!0,readOnly:r,ariaLabel:n,title:o.tip({name:n,step:s,unit:a})},e.key)})})}var Ve=e=>e.preventDefault();function Ze({colors:t,current:l,words:r,onPick:o}){const a=null===l?null:l.startsWith("#")?l.toLowerCase():t.find(e=>e.name===l)?.value.toLowerCase()??null;/* @__PURE__ */
6
+ return ae("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":r.title,onMouseDown:e=>{e.target instanceof HTMLInputElement||e.preventDefault()},children:[
7
+ /* @__PURE__ */oe("span",{className:"es-copy-pop-label",children:r.theme}),
8
+ /* @__PURE__ */oe("div",{className:"es-pick-theme",role:"group","aria-label":r.theme,children:t.map(e=>/* @__PURE__ */oe("button",{type:"button",className:"es-pick-theme-swatch","data-color":e.name,"aria-label":e.label,title:`${e.label} · ${e.value.toUpperCase()}`,"aria-pressed":l===e.name,style:{background:e.value},onMouseDown:Ve,onClick:()=>o(e.name)},e.name))}),
9
+ /* @__PURE__ */oe("span",{className:"es-copy-pop-label",children:r.any}),
10
+ /* @__PURE__ */oe(e,{value:a??"",onChange:e=>{e!==l&&o(e)},label:r.title,swatch:!0,dragWrites:"end",words:{...n.colour,dialog:()=>r.any,square:r.square,hue:r.hue,hex:()=>r.hex}}),
11
+ /* @__PURE__ */oe("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-danger",onMouseDown:Ve,onClick:()=>o(null),children:r.remove})})]})}function Ye({href:e,editing:n,onApply:l,onRemove:r,onClose:o,floating:a=!1}){const s=L("copy",t).link,i=re(),[c,u]=te(e),[d,h]=te(!1),p=ee(null);le(()=>{p.current?.focus(),p.current?.select()},[]);const f=()=>{const e=c.trim();x(e)?l(e):h(!0)};/* @__PURE__ */
12
+ return ae("div",{role:"dialog","aria-label":s.title,className:"es-copy-link"+(a?" es-copy-pop":""),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),f()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o())},children:[
13
+ /* @__PURE__ */oe("label",{htmlFor:i,className:"es-copy-link-label",children:s.label}),
14
+ /* @__PURE__ */oe("input",{ref:p,id:i,type:"text",className:"es-copy-link-input",value:c,placeholder:s.placeholder,spellCheck:!1,autoComplete:"off","aria-invalid":d||void 0,"aria-describedby":d?`${i}-why`:void 0,onChange:e=>{u(e.target.value),h(!1)}}),d?/* @__PURE__ */oe("p",{id:`${i}-why`,role:"alert",className:"es-copy-link-why",children:s.refused}):null,
15
+ /* @__PURE__ */ae("div",{className:"es-copy-link-actions",children:[n?/* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-danger",onClick:r,children:s.remove}):null,
16
+ /* @__PURE__ */ae("span",{className:"es-copy-link-end",children:[
17
+ /* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn",onClick:o,children:s.cancel??t.link.cancel}),
18
+ /* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-primary",onClick:f,disabled:""===c.trim(),children:s.apply})]})]})]})}var Ge=e=>e.preventDefault();function Je(){/* @__PURE__ */
19
+ return oe("span",{className:"es-tb-cell is-empty","aria-hidden":"true"})}function Xe({words:e,align:t,alignmentLabel:n,offered:l,pressed:r,onMark:o,color:a,linkOpen:s,last:i,alignment:c,list:u,letterCase:d,disabled:h=!1,ariaLabel:p="Formatting"}){const f=(e,t,n,a)=>l.has(e)?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+(r[e]||"link"===e&&s?" is-on":""),"aria-label":t,title:t,"aria-pressed":"link"===e?void 0:Boolean(r[e]),"aria-haspopup":"link"===e?"dialog":void 0,"aria-expanded":"link"===e?s:void 0,"aria-keyshortcuts":a,disabled:h,onMouseDown:Ge,onClick:()=>o(e),children:n},e):/* @__PURE__ */oe(Je,{},e),m=[["left",/* @__PURE__ */oe(O,{},"l")],["center",/* @__PURE__ */oe(B,{},"c")],["right",/* @__PURE__ */oe(j,{},"r")],["justify",/* @__PURE__ */oe(T,{},"j")]],b=[["none",e.caseNone,/* @__PURE__ */oe(H,{},"n")],["upper",e.caseUpper,/* @__PURE__ */oe(W,{},"u")],["lower",e.caseLower,/* @__PURE__ */oe($,{},"w")]];/* @__PURE__ */
20
+ return ae("div",{className:"es-tb",role:"toolbar","aria-label":p,children:[
21
+ /* @__PURE__ */ae("div",{className:"es-tb-row"+(void 0===i?" is-eight":""),children:[f("bold",e.bold,/* @__PURE__ */oe(U,{}),"Meta+B"),f("italic",e.italic,/* @__PURE__ */oe(V,{}),"Meta+I"),f("underline",e.underline,/* @__PURE__ */oe(Z,{}),"Meta+U"),f("strike",e.strike,/* @__PURE__ */oe(Y,{})),a?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn es-tb-color"+(a.open?" is-on":""),"aria-label":e.color,title:e.color,"aria-haspopup":"dialog","aria-expanded":a.open,disabled:h,style:a.run?{"--es-tb-run":a.run}:void 0,onMouseDown:Ge,onClick:a.onToggle,children:/* @__PURE__ */oe(z,{})}):/* @__PURE__ */oe(Je,{}),f("link",e.link,/* @__PURE__ */oe(G,{}),"Meta+K"),f("sup",e.sup,/* @__PURE__ */oe(J,{})),f("sub",e.sub,/* @__PURE__ */oe(X,{})),void 0!==i?i??/* @__PURE__ */oe(Je,{}):null]}),
22
+ /* @__PURE__ */ae("div",{className:"es-tb-row",children:[
23
+ /* @__PURE__ */oe("div",{className:"es-tb-group",role:"radiogroup","aria-label":n,children:m.map(([e,n])=>c&&c.allow.includes(e)?/* @__PURE__ */oe("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(c.value===e?" is-on":""),"aria-checked":c.value===e,"aria-label":t[e],title:t[e],disabled:h||c.disabled,onMouseDown:Ge,onClick:()=>c.onChange(e),children:n},e):/* @__PURE__ */oe(Je,{},e))}),u&&l.has("bullet")?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+("bullet"===u.pressed?" is-on":""),"aria-label":e.bullet,title:e.bullet,"aria-pressed":"bullet"===u.pressed,disabled:h,onMouseDown:Ge,onClick:()=>u.onList("bullet"),children:/* @__PURE__ */oe(I,{})}):/* @__PURE__ */oe(Je,{}),u&&l.has("number")?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+("number"===u.pressed?" is-on":""),"aria-label":e.number,title:e.number,"aria-pressed":"number"===u.pressed,disabled:h,onMouseDown:Ge,onClick:()=>u.onList("number"),children:/* @__PURE__ */oe(A,{})}):/* @__PURE__ */oe(Je,{}),
24
+ /* @__PURE__ */oe("div",{className:"es-tb-group",role:"radiogroup","aria-label":e.letterCase,children:b.map(([e,t,n])=>d?/* @__PURE__ */oe("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(d.value===e?" is-on":""),"aria-checked":d.value===e,"aria-label":t,title:t,disabled:h||d.disabled,onMouseDown:Ge,onClick:()=>d.onChange(d.value===e?"":e),children:n},e):/* @__PURE__ */oe(Je,{},e))})]})]})}var Qe=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var _e=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function et(e){const t=e.ownerDocument,n=t.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=t.defaultView?.getComputedStyle.bind(t.defaultView);for(let o=e.parentElement;o&&o!==n&&o!==t.body;o=o.parentElement){const e=r?.(o);if(!e||"visible"===e.overflowX&&"visible"===e.overflowY)continue;const t=o.getBoundingClientRect();if(0===t.width&&0===t.height)continue;const n=t.left+o.clientLeft,a=t.top+o.clientTop;l.left=Math.max(l.left,n),l.top=Math.max(l.top,a),l.right=Math.min(l.right,n+(o.clientWidth||t.width)),l.bottom=Math.min(l.bottom,a+(o.clientHeight||t.height))}return l}function tt(e){const t=e.offsetParent??e.parentElement;if(!t)return{left:0,top:0};const n=t.getBoundingClientRect();return{left:n.left+t.clientLeft-t.scrollLeft,top:n.top+t.clientTop-t.scrollTop}}var nt=/* @__PURE__ */new Set([...s,"clear"]),lt={bold:/* @__PURE__ */oe(U,{size:16}),italic:/* @__PURE__ */oe(V,{size:16}),strike:/* @__PURE__ */oe(Y,{size:16}),highlight:/* @__PURE__ */oe(_,{size:16}),quiet:/* @__PURE__ */oe(Q,{size:16}),link:/* @__PURE__ */oe(G,{size:16}),clear:/* @__PURE__ */oe(q,{size:16})};function rt(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var ot={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function at({tools:e,onApply:n,disabled:l=!1,actions:r,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=L("copy",t),d=("string"==typeof e[0]?f(e).map(e=>({...e,...u.marks[e.style]})):e).filter(e=>!nt.has(e.style));return 0!==d.length||r||o?/* @__PURE__ */ae("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??lt[e.style],r=c===e.style||Boolean(i?.[e.style]);/* @__PURE__ */
25
+ return oe("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:l,title:e.title,"aria-label":e.name??e.title,"aria-keyshortcuts":rt(e.shortcut),"aria-pressed":i||c?r:void 0,"aria-haspopup":"link"===e.style&&i?"dialog":void 0,"aria-expanded":"link"===e.style&&i?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":ot[e.style]?` ${ot[e.style]}`:""}${r?" is-active":""}`,children:t??e.label},e.style)}),r?/* @__PURE__ */ae(se,{children:[
26
+ /* @__PURE__ */oe("span",{className:"es-copy-bar-split","aria-hidden":"true"}),r]}):null,o?/* @__PURE__ */oe("span",{className:"es-copy-bar-end",children:o}):null]}):null}function st({target:e,onChange:t}){const n=ee(null);return ne(()=>{const t=n.current,l=e.current;t&&l&&l.value===t.text&&(n.current=null,l.focus(),l.setSelectionRange(t.start,t.end))}),l=>{const r=l(e.current);t(r.text),n.current={start:r.selectionStart,end:r.selectionEnd,text:r.text}}}function it({value:e,onChange:n,onCommit:l,onCancel:s,multiline:u=!1,placeholder:d,ariaLabel:h,className:x,readOnly:T=!1,rules:j,tools:B=[],writeMark:O,actions:R,align:P,glyphs:K,barLabel:F,renderFooter:H,inputRef:W,barShows:$="always",richText:z=!0,defaultShowMarks:I=!1,toolbar:A="final",colors:U,cells:V,letterCase:Z,lastTool:Y}){const G="final"===A,J=L("copy",t),X=ee(null),Q=W??X,[_,ie]=te(!1),[ce,ue]=te(null),de=ee(Ie()).current,pe=ee(null);le(()=>{const t=pe.current;t&&e===t.to?pe.current=null:t&&e===t.from||(pe.current=null,de.reset())},[e,de]);const me=t=>{pe.current={from:pe.current?.from??e,to:t},n(t)},ye=t=>({text:e,start:t?.selectionStart??ce?.start??e.length,end:t?.selectionEnd??ce?.end??e.length}),[ve,xe]=te(I),we=z&&!(u&&ve),Ce=ee(null),Ee=re(),[Se,De]=te(null),[Ne,Me]=te(!1),Le=()=>{if(!we)return Q.current;const e=Ce.current?.getSource()??ce;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Te=st({target:Q,onChange:me}),je=e=>(ue({start:e.selectionStart,end:e.selectionEnd}),e),Be=(t,n)=>{if(!we)return void Te(e=>(n&&de.record(ye(e),"edit",Date.now()),je(t(e))));const l=Le(),r=je(t(l));n&&de.record(ye(l),"edit",Date.now()),De(null),r.text!==e&&me(r.text),Ce.current?.setSource(r.selectionStart,r.selectionEnd,r.text)},Oe=e=>Be(e,!0),Re=e=>Be(t=>{const n=ye(t),l=de[e](n);return l?{text:l.text,selectionStart:l.start,selectionEnd:l.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Pe=ee(null);ne(()=>{const t=Pe.current;t&&(Pe.current=null,we?Ce.current?.setSource(t.start,t.end,e):(Q.current?.focus(),Q.current?.setSelectionRange(t.start,t.end),ue(t)))},[we]);const[Ke,Fe]=te(null),He=j??c,We=("string"==typeof B[0]?f(B):B).filter(e=>!nt.has(e.style)),ze=G?("string"==typeof B[0]?B:B.map(e=>e.style)).filter(e=>!nt.has(e)):We.map(e=>e.style),Ae={};if(ce&&(we||G)){const t=m(e,ce.start,ce.end,He);for(const e of ze){const n=t.has(e)||"highlight"===e&&t.has("accent");Ae[e]=!!Se?.add.includes(e)||!Se?.drop.includes(e)&&n}G&&(Ae.link=t.has("link"))}else if(ce)for(const t of ze)Ae[t]="link"===t?null!==b(e,ce.start,ce.end):g(e,ce.start,ce.end,t);const qe=()=>{const t=Le(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},Ve={sup:"sub",sub:"sup"},Ge=t=>{if(G&&"link"!==t&&p(0,t)){const{start:n,end:l}=qe(),r=Ve[t];if(n===l){if(!we)return void Oe(n=>be(e,t,n,(e,t,n,l)=>i(e,t,n,l,He,J.placeholders)));const o=m(e,n,l,He),a=Se&&Se.at===n?Se:null,s=o.has(t),c=!!a?.add.includes(t)||!a?.drop.includes(t)&&s;let u=(a?.add??[]).filter(e=>e!==t),d=(a?.drop??[]).filter(e=>e!==t);return c&&s?d.push(t):c||s||u.push(t),!c&&r&&(u=u.filter(e=>e!==r),o.has(r)&&(d=[...d.filter(e=>e!==r),r])),void De(u.length||d.length||void 0!==a?.color?{add:u,drop:d,color:a?.color,at:n}:null)}return void Oe(()=>{let o=e,a=n,s=l;if(r&&!m(o,a,s,He).has(t)&&m(o,a,s,He).has(r)){const e=w(o,a,s,r,He);({text:o,selectionStart:a,selectionEnd:s}=e)}return w(o,a,s,t,He)})}if("clear"===t)return void Oe(n=>be(e,t,n,(e,t,n)=>i(e,t,n,"clear",He)));if("link"!==t&&we&&p(0,t)){const n=Le(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;if(l===r){const n=m(e,l,r,He),o=n.has(t)||"highlight"===t&&n.has("accent"),a=Se&&Se.at===l?Se:null,s=!!a?.add.includes(t)||!a?.drop.includes(t)&&o,i=(a?.add??[]).filter(e=>e!==t),c=(a?.drop??[]).filter(e=>e!==t);return s&&o?c.push(t):s||o||i.push(t),void De(i.length||c.length?{add:i,drop:c,at:l}:null)}return void Oe(n=>w(e,n?.selectionStart??l,n?.selectionEnd??r,t,He))}if("link"!==t){const n=O??((e,t,n,l)=>i(e,t,n,l,c,J.placeholders));return void Oe(l=>be(e,t,l,n))}const n=Le(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;Me(!1),Fe({start:l,end:r,link:b(e,l,r)})},Je=Boolean(ce&&ce.start!==ce.end),lt=ce?y(e,ce.start,ce.end,He):null,rt=ce?Se&&void 0!==Se.color&&Se.at===ce.start?Se.color:v(e,ce.start,ce.end,He):null,ot=rt?rt.startsWith("#")?rt:U?.find(e=>e.name===rt)?.value:void 0,it=t=>{we?t?Ce.current?.setSource(t.start,t.end,e):Ce.current?.focus():(Q.current?.focus(),t&&Q.current?.setSelectionRange(t.start,t.end))},ct=()=>{const e=Ke;Fe(null),it(e?{start:e.start,end:e.end}:ce)},ut=()=>{const e=dt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Me(!1),t&&it(ce)},dt=ee(null),ht=Ne||null!==Ke;le(()=>{const e=dt.current;if(!ht||!e)return;const t=e.ownerDocument,n=()=>{Me(!1),Fe(null)},l=t=>{e.contains(t.target)||n()};let r;const o=l=>{const o=l.relatedTarget;o?e.contains(o)||n():(clearTimeout(r),r=setTimeout(()=>{const l=t.activeElement;t.hasFocus()&&l&&l!==t.body&&!e.contains(l)&&n()},0))};return t.addEventListener("pointerdown",l,!0),e.addEventListener("focusout",o),()=>{clearTimeout(r),t.removeEventListener("pointerdown",l,!0),e.removeEventListener("focusout",o)}},[ht]);const pt=Ke??(Ne?ce??{start:e.length,end:e.length}:null),ft=ee(()=>{});ft.current=()=>{const e=dt.current,t=e?.querySelector(".es-tb-wrap > .es-copy-pop");if(!e||!t||!pt)return;const n=we?null:e.querySelector(".es-gold-layer"),l=we?Ce.current?.rangeOf(pt.start,pt.end)??null:n?function(e,t,n){const l=e.ownerDocument,r=l.createTreeWalker(e,4),o=e=>{let t=e,n=null;for(let e=r.nextNode();e;e=r.nextNode()){if(t<=e.data.length)return[e,t];t-=e.data.length,n=e}return n?[n,n.data.length]:null},a=o(t);r.currentNode=e;const s=o(n);if(!a||!s)return null;const i=l.createRange();return i.setStart(a[0],a[1]),i.setEnd(s[0],s[1]),i}(n,pt.start,pt.end):null,r=l?.endContainer,o=r?1===r.nodeType?r:r.parentElement:null,a=l?function(e,t){const n=("function"==typeof e.getClientRects?[...e.getClientRects()]:[]).filter(e=>e.height>0);if(n.length>0){const t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():n[0];return t.height>0?_e(t):_e(n[0])}if(!t)return null;const l=t.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}(l,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=function({anchor:e,size:t,within:n,clip:l,parent:r,gap:o=8}){const a=Math.max(n.left,l.left),s=Math.min(n.right,l.right)-t.width,i=Qe(e.left,a,s),c=l.bottom-(e.bottom+o),u=e.top-o-l.top,d=t.height>c&&(t.height<=u||u>c),h=d?e.top-o-t.height:e.bottom+o,p=e.left+Math.min((e.right-e.left)/2,10),f=Qe(p-5-i,10,t.width-10-10);return{top:h-r.top,left:i-r.left,above:d,point:f}}({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:et(e),parent:tt(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},ne(()=>{const e=dt.current;if(!ht||!e)return;const t=()=>ft.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const l=e.querySelector(".es-tb-wrap > .es-copy-pop"),r=n?.ResizeObserver,o=r&&l?new r(t):null;return o&&l&&o.observe(l),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ht,Ne,Ke,pt?.start,pt?.end,we]);const mt=t=>Ke&&/* @__PURE__ */oe(Ye,{floating:t,href:Ke.link?.href??"",editing:null!==Ke.link,onApply:t=>{const n=Ke;Fe(null),Oe(()=>we?N(e,n.start,n.end,t,He):M(e,n.start,n.end,t))},onRemove:()=>{const t=Ke.link,n=Ke;Fe(null),t&&Oe(()=>we?S(e,n.start,n.end,He):D(e,t))},onClose:ct}),bt=P?he(P.allow,J.align):[],gt="always"===$||_||null!==Ke||Ne;/* @__PURE__ */
27
+ return ae("div",{ref:dt,className:"es-copy"+(x?` ${x}`:""),onFocus:()=>ie(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ie(!1)},onKeyDownCapture:e=>{Ne&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),ut())},onKeyDown:e=>{const t=e.target===Q.current||Boolean(e.target.closest?.(".es-rich"));if(T||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),l="KeyZ"===e.code||"z"===n,r=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(l||r)return e.preventDefault(),e.stopPropagation(),void Re(r||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(G){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!ze.includes(t))return;return e.preventDefault(),e.stopPropagation(),void Ge(t)}const a=We.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),Ge(a.style))},onPaste:t=>{const n=Q.current;if(T||!n||t.target!==n)return;t.preventDefault();const l=ke({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:u,rules:He});Oe(t=>ge(e,l,t))},style:U&&U.length>0?Object.fromEntries(U.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=Q.current;t&&t.ownerDocument.activeElement===t&&ue({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[gt&&G?/* @__PURE__ */ae("div",{className:"es-tb-wrap"+(Y?"":" is-eight"),children:[
28
+ /* @__PURE__ */oe(Xe,{words:J.toolbar??t.toolbar,align:J.align,alignmentLabel:J.alignment,ariaLabel:F??J.formatting,offered:new Set(ze),pressed:Ae,onMark:e=>Ge(e),color:U&&U.length>0?{run:ot,open:Ne,onToggle:()=>{Fe(null),Ne?ut():Me(!0)}}:void 0,linkOpen:null!==Ke,last:Y?Y({className:"es-tb-cell es-tb-btn",disabled:T,selected:Je,keepCaret:e=>e.preventDefault(),insert:t=>Oe(n=>ge(e,t,n))}):void 0,alignment:P?{value:P.value,allow:P.allow,onChange:P.onChange,disabled:P.disabled}:void 0,list:{pressed:lt,onList:t=>{const{start:n,end:l}=qe(),r=y(e,n,l,He);Oe(()=>E(e,n,l,r===t?null:t,He))}},letterCase:Z,disabled:T}),Ne&&U&&U.length>0?/* @__PURE__ */oe(Ze,{colors:U,current:rt,words:J.colors??t.colors,onPick:t=>{const{start:n,end:l}=qe();if(n!==l)Oe(()=>C(e,n,l,t,He));else{if(!we)return;De({add:Se?.add??[],drop:Se?.drop??[],color:t,at:n})}}}):null,Ke?mt(!0):null]}):null,G&&V&&V.length>0?/* @__PURE__ */oe(Ue,{cells:V,words:J.cells??t.cells,readOnly:T}):null,gt&&!G?/* @__PURE__ */oe(at,{tools:B,disabled:T,actions:R,glyphs:K,ariaLabel:F,pressed:Ae,open:Ke?"link":null,onApply:Ge,align:P?/* @__PURE__ */oe(r,{options:bt,value:P.value,onChange:P.onChange,ariaLabel:J.alignment,disabled:T||P.disabled,fit:fe(bt)}):null}):null,we?/* @__PURE__ */oe($e,{value:e,rules:He,multiline:u,readOnly:T,placeholder:d,ariaLabel:h,handle:Ce,pending:Se??void 0,onEdit:(t,n,l)=>{de.record({text:e,start:n.start,end:n.end},l,Date.now()),De(null),me(t)},onSelect:e=>{ue(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Se||e.start===Se.at&&e.end===Se.at||De(null)},onHistory:Re,onFormat:e=>{ze.includes(e)&&Ge(e)},onCommit:l,onCancel:s}):/* @__PURE__ */oe(a,{value:e,onInput:e=>{de.record(ye(null),"type",Date.now()),me(e)},onCommit:l,onCancel:s,multiline:u,placeholder:d,ariaLabel:h,rules:j,disabled:T,inputRef:Q,className:"es-copy-box"}),Ke&&!G?mt(!1):null,H?H({focused:_,insert:t=>Oe(n=>ge(e,t,n))}):null,z&&u||G&&gt?
29
+ /* @__PURE__ */ae("div",{className:"es-copy-marks",children:[z&&u?/* @__PURE__ */ae(se,{children:[
30
+ /* @__PURE__ */oe(o,{checked:ve,onChange:()=>{const e=Le();Pe.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ce,De(null),xe(e=>!e)},ariaLabelledBy:Ee,disabled:T}),
31
+ /* @__PURE__ */oe("span",{id:Ee,className:"es-copy-marks-label",children:J.showMarks??"Show marks"})]}):null,G&&gt?/* @__PURE__ */ae("button",{type:"button",className:"es-copy-clear",disabled:T||!Je,title:Je?void 0:J.clearStyleEmpty??"Select words first",onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:t,end:n}=qe();if(t===n)return;const l=k(e,t,n,He);l.text!==e&&Oe(()=>l)},children:[
32
+ /* @__PURE__ */oe(q,{size:16}),J.clearStyle??"Clear style"]}):null]}):null]})}export{ie as COPY_ALIGNS,de as COPY_ALIGN_FIT,ue as COPY_ALIGN_GLYPHS,ce as COPY_ALIGN_LABELS,Ae as COPY_CELLS,Ze as ColorWindow,it as CopyBox,Ue as CopyCells,Pe as MARKUP_CLIPBOARD_TYPE,at as MarkBar,$e as RichBox,ze as TYPING_BURST_MS,Xe as TextToolbar,rt as ariaShortcut,he as copyAlignOptions,Ie as createHistory,je as editVisible,ge as insertSelection,be as markSelection,Re as markupOfRange,Be as newLine,ke as pasteToMarkup,Ce as richLayout,Le as selectionToSource,Me as selectionToVisible,Oe as setBullet,Se as toSource,De as toSourceStart,Ne as toVisible,st as useCaretEdit};