@commentkit/comment-kit 1.0.0 → 1.5.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 (77) hide show
  1. package/CHANGELOG.md +133 -1
  2. package/README.md +12 -5
  3. package/SECURITY.md +3 -1
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +22 -23
  5. package/dist/npm/chunks/AgentSend-DyWxNQ0p.js +64 -0
  6. package/dist/npm/chunks/Checklist-VYkSl6Q9.js +259 -0
  7. package/dist/npm/chunks/Composer-CnsGQirF.js +679 -0
  8. package/dist/npm/chunks/Guest-DkIvY5zt.js +170 -0
  9. package/dist/npm/chunks/MarkupEditor-DxTI9nJH.js +334 -0
  10. package/dist/npm/chunks/Panel-riaMYxt-.js +863 -0
  11. package/dist/npm/chunks/Settings-CB4zxQAL.js +206 -0
  12. package/dist/npm/chunks/{Shortcuts-BSOKdMHt.js → Shortcuts-D1cbajg_.js} +21 -17
  13. package/dist/npm/chunks/StyleEditor-BtTv3I8_.js +44 -0
  14. package/dist/npm/chunks/StylePanel-BI-n5Me1.js +199 -0
  15. package/dist/npm/chunks/TaskFields-HwrD0FrH.js +272 -0
  16. package/dist/npm/chunks/ThreadCard-CjaC8BTa.js +1026 -0
  17. package/dist/npm/chunks/Viewer-BnWshSXb.js +110 -0
  18. package/dist/npm/chunks/agent-Cr6NB6We.js +146 -0
  19. package/dist/npm/chunks/anchor-OCQnjp_6.js +294 -0
  20. package/dist/npm/chunks/{ar-O7EPv0mI.js → ar-BQ9K9Oqf.js} +189 -8
  21. package/dist/npm/chunks/card-bits-CxteYiZ9.js +126 -0
  22. package/dist/npm/chunks/client-CJ1tpI62.js +754 -0
  23. package/dist/npm/chunks/colors-0Ied7PE2.js +101 -0
  24. package/dist/npm/chunks/confetti-DKeKR7-6.js +41 -0
  25. package/dist/npm/chunks/{de-PGyZVNHX.js → de-CcPi8xdC.js} +160 -8
  26. package/dist/npm/chunks/drafts-CpQdHhcK.js +51 -0
  27. package/dist/npm/chunks/{es-Bq1idl8M.js → es-DXgkjDCG.js} +160 -8
  28. package/dist/npm/chunks/extension-BIGfr4Gh.js +50 -0
  29. package/dist/npm/chunks/{extension-B7SelsS0.js → extension-DkDSW4qw.js} +2 -2
  30. package/dist/npm/chunks/{fr-BVB9GGco.js → fr-IjJaUbWh.js} +160 -8
  31. package/dist/npm/chunks/{hi-DyBvrjzQ.js → hi-BhKQK2MU.js} +160 -8
  32. package/dist/npm/chunks/html2canvas-pro.esm-lgs6tb4C.js +8378 -0
  33. package/dist/npm/chunks/i18n-DAJGndZ2.js +904 -0
  34. package/dist/npm/chunks/{it-BlMMMwZh.js → it-DKiSCkiD.js} +160 -8
  35. package/dist/npm/chunks/{ja-lAioBCJv.js → ja-BI1WagDg.js} +160 -8
  36. package/dist/npm/chunks/{live-YFyP1GnP.js → live-B-mo27Qq.js} +1 -1
  37. package/dist/npm/chunks/lock-C82sC17d.js +30 -0
  38. package/dist/npm/chunks/{nl-DR8mLHnn.js → nl-CJw3VUQ5.js} +160 -8
  39. package/dist/npm/chunks/pick-CYPkLLFJ.js +120 -0
  40. package/dist/npm/chunks/{pt-BR-D7j6aDPx.js → pt-BR-CjBolC5g.js} +160 -8
  41. package/dist/npm/chunks/{pusher-BSsQoE1K.js → realtime-D22tI_AS.js} +58 -4
  42. package/dist/npm/chunks/source-CTQmAh0Y.js +146 -0
  43. package/dist/npm/chunks/src-CgBEoWl0.js +150 -0
  44. package/dist/npm/chunks/start-DW9_DKmf.js +1783 -0
  45. package/dist/npm/chunks/upload-BmrpZE5G.js +42 -0
  46. package/dist/npm/chunks/uploads-CipONvCy.js +541 -0
  47. package/dist/npm/chunks/{zh-CN-tzYg9NPH.js → zh-CN-BrZGx2S0.js} +160 -8
  48. package/dist/npm/element.js +4 -5
  49. package/dist/npm/headless.js +3 -3
  50. package/dist/npm/index.js +2 -2
  51. package/dist/npm/react.js +1 -1
  52. package/dist/npm/svelte.js +1 -1
  53. package/dist/npm/types/adapters/vue.d.ts +14 -0
  54. package/dist/npm/types/anchor/index.d.ts +22 -1
  55. package/dist/npm/types/core/api.d.ts +3 -0
  56. package/dist/npm/types/core/auth.d.ts +11 -0
  57. package/dist/npm/types/core/client.d.ts +128 -6
  58. package/dist/npm/types/core/types.d.ts +78 -4
  59. package/dist/npm/types/headless.d.ts +1 -1
  60. package/dist/npm/types/index.d.ts +6 -1
  61. package/dist/npm/vue.js +5 -1
  62. package/package.json +7 -5
  63. package/dist/npm/chunks/Guest-VNoofLxw.js +0 -157
  64. package/dist/npm/chunks/MarkupEditor-DTXrS3DD.js +0 -199
  65. package/dist/npm/chunks/Panel-B88JYH52.js +0 -438
  66. package/dist/npm/chunks/ThreadCard-izybwXIC.js +0 -817
  67. package/dist/npm/chunks/anchor-DT-Ynhh1.js +0 -270
  68. package/dist/npm/chunks/art-DK1JwPIo.js +0 -155
  69. package/dist/npm/chunks/client-Iegfv6ZC.js +0 -620
  70. package/dist/npm/chunks/colors-CX-IPjvb.js +0 -86
  71. package/dist/npm/chunks/extension-DSA8S8Qz.js +0 -26
  72. package/dist/npm/chunks/format-B5tJGtPC.js +0 -524
  73. package/dist/npm/chunks/html2canvas-DfGb8yka.js +0 -4024
  74. package/dist/npm/chunks/mount-Dx_8NhX3.js +0 -1484
  75. package/dist/npm/chunks/privacy-DLhezjyi.js +0 -30
  76. package/dist/npm/chunks/realtime-CBRW9BB3.js +0 -34
  77. package/dist/npm/chunks/src-C1Qp94nr.js +0 -549
@@ -0,0 +1,42 @@
1
+ import { p as e } from "./client-CJ1tpI62.js";
2
+ //#region src/core/upload.ts
3
+ async function t(e, t, a, o, s) {
4
+ let c = await e.request("/uploads", {
5
+ method: "POST",
6
+ idempotent: !0,
7
+ body: {
8
+ name: a,
9
+ mime: t.type || "application/octet-stream",
10
+ bytes: t.size,
11
+ kind: o
12
+ }
13
+ });
14
+ if (s.signal?.aborted) throw r();
15
+ let l = s.onProgress ? await i(c.upload, t, s.onProgress, s.signal) : (await fetch(c.upload.url, {
16
+ method: "PUT",
17
+ headers: c.upload.headers,
18
+ body: t,
19
+ credentials: "omit",
20
+ signal: s.signal
21
+ })).status;
22
+ if (l < 200 || l >= 300) throw n(l);
23
+ return e.request(`/uploads/${encodeURIComponent(c.id)}/complete`, {
24
+ method: "POST",
25
+ idempotent: !0
26
+ }).then((e) => e.data);
27
+ }
28
+ var n = (t) => new e(t, "upload_failed", "The file could not be uploaded. Try again."), r = () => new e(0, "upload_cancelled", "Cancelled");
29
+ function i(e, t, i, a) {
30
+ return new Promise((o, s) => {
31
+ let c = new XMLHttpRequest();
32
+ c.open("PUT", e.url);
33
+ for (let [t, n] of Object.entries(e.headers)) c.setRequestHeader(t, n);
34
+ c.upload.onprogress = (e) => e.lengthComputable && i(e.loaded / e.total);
35
+ let l = () => c.abort(), u = (e, t) => {
36
+ a?.removeEventListener("abort", l), e(t);
37
+ };
38
+ c.onload = () => u(o, c.status), c.onerror = () => u(s, n(0)), c.onabort = () => u(s, r()), a?.addEventListener("abort", l, { once: !0 }), c.send(t);
39
+ });
40
+ }
41
+ //#endregion
42
+ export { t as upload };
@@ -0,0 +1,541 @@
1
+ import { p as e } from "./client-CJ1tpI62.js";
2
+ import { f as t, l as n, m as r, s as i, u as a } from "./i18n-DAJGndZ2.js";
3
+ import { a as o } from "./card-bits-CxteYiZ9.js";
4
+ import { d as s, l as c, n as l } from "./start-DW9_DKmf.js";
5
+ //#region src/ui/editing.ts
6
+ var u = {
7
+ bold: "**",
8
+ italic: "_",
9
+ code: "`",
10
+ strike: "~~"
11
+ };
12
+ function d(e) {
13
+ if (!(e.metaKey || e.ctrlKey) || e.altKey) return null;
14
+ let t = e.key.toLowerCase();
15
+ return e.shiftKey ? t === "x" ? "strike" : null : t === "b" ? "bold" : t === "i" ? "italic" : t === "e" ? "code" : null;
16
+ }
17
+ function f(e, t, n, r) {
18
+ let i = u[r], a = e.slice(0, t), o = e.slice(t, n), s = e.slice(n);
19
+ if (a.endsWith(i) && s.startsWith(i)) return {
20
+ value: a.slice(0, -i.length) + o + s.slice(i.length),
21
+ start: t - i.length,
22
+ end: n - i.length
23
+ };
24
+ if (o.length > 2 * i.length && o.startsWith(i) && o.endsWith(i)) {
25
+ let e = o.slice(i.length, -i.length);
26
+ return {
27
+ value: a + e + s,
28
+ start: t,
29
+ end: t + e.length
30
+ };
31
+ }
32
+ return {
33
+ value: a + i + o + i + s,
34
+ start: t + i.length,
35
+ end: n + i.length
36
+ };
37
+ }
38
+ function p(e) {
39
+ let t = e.replace(/\r\n/g, "\n").split("\n").filter((e) => e.trim());
40
+ return t.length < 2 || e.includes("```") ? !1 : t.filter((e) => /[{};]\s*$|^\s*[<}\])]|=>|^\s*(import|export|const|let|var|function|return|if|for|def|class)\b|^\s{2,}\S|^\t/.test(e)).length / t.length >= .5;
41
+ }
42
+ function m(e) {
43
+ return `\`\`\`\n${e.replace(/\r\n/g, "\n").replace(/\n+$/, "")}\n\`\`\``;
44
+ }
45
+ //#endregion
46
+ //#region src/ui/compose.css?inline
47
+ var h = ".ck-textarea{resize:none;field-sizing:content;border-radius:var(--ck-radius-md);border:1px solid var(--ck-border);background:var(--ck-bg);outline:none;width:100%;min-height:68px;max-height:220px;padding:8px 11px;line-height:1.5;transition:border-color .12s,box-shadow .12s;display:block}.ck-textarea:focus{border-color:var(--ck-accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--ck-accent) 18%, transparent);outline:none}.ck-textarea[aria-invalid=true]{border-color:var(--ck-danger)}.ck-shot{border-radius:var(--ck-radius-md);background:var(--ck-bg-muted);margin-top:10px;position:relative;overflow:hidden}.ck-shot img,.ck-shot canvas{outline:1px solid var(--ck-img-outline);outline-offset:-1px;border-radius:inherit;width:100%;height:auto;display:block}.ck-msg .ck-shot img{object-fit:cover;object-position:top;max-height:150px}.ck-composer .ck-shot{height:140px}.ck-composer .ck-shot img{object-fit:cover;height:100%}.ck-shot-wait{place-items:center;font-size:12px;display:grid}.ck-shot-tools{flex-wrap:wrap;gap:4px;margin-top:8px;display:flex}.ck-composer .ck-shot-tools{margin:0;position:absolute;top:auto;bottom:8px;left:8px;right:8px}.ck-composer .ck-shot-tools .ck-chip{box-shadow:var(--ck-shadow-sm)}.ck-files{flex-wrap:wrap;gap:6px;margin-top:8px;display:flex}.ck-file{background:var(--ck-bg-muted);border-radius:6px;padding:4px 8px;font-size:12px}.ck-suggest{background:var(--ck-bg);max-height:180px;box-shadow:var(--ck-shadow);z-index:3;animation:ck-pop .12s var(--ck-ease);border-radius:12px;padding:4px;position:absolute;bottom:56px;left:14px;right:14px;overflow:auto}.ck-suggest button{border-radius:var(--ck-radius-sm);text-align:start;background:0 0;border:0;align-items:center;gap:8px;width:100%;padding:6px 8px;display:flex}.ck-suggest button[aria-selected=true]{background:var(--ck-bg-hover)}.ck-guest{gap:10px;margin-top:12px;display:grid}.ck-guest-privacy{margin:0;font-size:12px;line-height:1.45}.ck-guest-privacy a{color:inherit;text-underline-offset:2px;text-decoration:underline}.ck-error{color:var(--ck-danger);font-size:12px;font-weight:500}@media (pointer:coarse){.ck-textarea{font-size:16px}}@media (hover:hover){.ck-textarea:hover{border-color:color-mix(in srgb, var(--ck-text-muted) 45%, var(--ck-border))}.ck-suggest button:hover{background:var(--ck-bg-hover)}}.ck-suggest{overscroll-behavior:contain;border:1px solid #0000}.ck-compose{position:relative}.ck-format{gap:2px;margin-top:4px;display:flex}.ck-uploads{flex-wrap:wrap;gap:6px;margin:8px 0 0;padding:0;list-style:none;display:flex}.ck-upload{border-radius:var(--ck-radius-sm);background:var(--ck-bg-muted);max-width:100%;box-shadow:0 0 0 1px var(--ck-hairline);align-items:center;display:flex;position:relative;overflow:hidden}.ck-upload[data-image]{width:56px;height:56px}.ck-upload-thumb{cursor:zoom-in;background:0 0;border:0;width:100%;height:100%;padding:0}.ck-upload-thumb img{object-fit:cover;width:100%;height:100%;display:block}.ck-upload-name{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:200px;color:var(--ck-text);align-items:center;gap:5px;padding:6px 28px 6px 9px;font-size:12.5px;display:inline-flex;overflow:hidden}.ck-upload[data-state=uploading] .ck-upload-thumb img{opacity:.6}.ck-upload-bar{left:6px;right:6px;background:#12131626;border-radius:2px;height:3px;position:absolute;bottom:5px;overflow:hidden}.ck-upload-bar>span{background:var(--ck-accent);height:100%;transition:width .16s linear;display:block}.ck-upload[data-state=failed]{box-shadow:0 0 0 1px color-mix(in srgb, var(--ck-danger) 55%, transparent)}.ck-upload-retry{background:var(--ck-danger);color:#fff;border:0;justify-content:center;align-items:center;gap:3px;height:20px;padding:0;font-size:10.5px;font-weight:700;display:flex;position:absolute;top:auto;bottom:0;left:0;right:0}.ck-upload:not([data-image]) .ck-upload-retry{border-radius:6px;height:auto;margin-inline-end:26px;padding:2px 6px;position:static}.ck-upload-remove{top:3px;color:#fff;background:#12131699;border:0;border-radius:50%;place-items:center;width:18px;height:18px;padding:0;display:grid;position:absolute}.ck-upload-remove:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:3px}.ck-upload-remove:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:3px}.ck-upload-remove:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:3px}.ck-upload-remove:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:3px}.ck-upload:not([data-image]) .ck-upload-remove{color:var(--ck-text-muted);background:0 0;top:50%;translate:0 -50%}@media (pointer:coarse){.ck-upload-remove{top:1px;width:26px;height:26px}.ck-upload-remove:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:1px}.ck-upload-remove:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:1px}.ck-upload-remove:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:1px}.ck-upload-remove:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:1px}}.ck-extra-add{gap:8px;margin-top:6px;display:flex}.ck-draft-list{gap:4px;margin-top:8px;display:grid}.ck-draft-item{align-items:center;gap:8px;font-size:13px;display:flex}.ck-draft-item bdi{overflow-wrap:anywhere;flex:1;min-width:0}.ck-draft-item .ck-ghost,.ck-checklist li .ck-ghost{flex:none;place-items:center;width:24px;height:24px;min-height:0;padding:0;display:grid}.ck-draft-box{width:13px;height:13px;box-shadow:inset 0 0 0 1.5px var(--ck-border);border-radius:3px;flex:none}.ck-pending-pin{z-index:var(--ck-z);pointer-events:none;filter:drop-shadow(0 0 .6px #fff)drop-shadow(0 3px 6px #12131647);width:30px;height:34px;animation:ck-pin-drop .26s var(--ck-ease);transform-origin:49% 97%;position:fixed;transform:translate(-49%,-97%)}.ck-pending-region{z-index:var(--ck-z);pointer-events:none;border-radius:6px;position:fixed}.ck-pending-pin svg{width:100%;height:100%;position:absolute;top:0;bottom:0;left:0;right:0;overflow:visible}.ck-pending-pin path{fill:var(--ck-accent);stroke:#121316;stroke-width:3px;stroke-linejoin:round}.ck-composer{animation:ck-pop .2s var(--ck-ease) 80ms backwards}.ck-style-list .ck-draft-item code,.ck-style-card li code{overflow-wrap:anywhere;flex:1;min-width:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}.ck-style-card{border-radius:var(--ck-radius-sm);background:var(--ck-bg-muted);margin-top:8px;padding:8px 10px}.ck-style-card-head{color:var(--ck-text-muted);justify-content:space-between;align-items:center;gap:8px;font-size:12px;font-weight:600;display:flex}.ck-style-card ul{gap:3px;margin:6px 0 0;padding:0;list-style:none;display:grid}";
48
+ //#endregion
49
+ //#region src/ui/MentionBox.tsx
50
+ l(h);
51
+ var g = /* @__PURE__ */ new WeakMap();
52
+ function _(e) {
53
+ let t = g.get(e);
54
+ return t || g.set(e, t = e.people().catch(() => [])), t;
55
+ }
56
+ var v = [
57
+ {
58
+ mark: "bold",
59
+ icon: "bold",
60
+ label: "formatBold",
61
+ keys: "Meta+B"
62
+ },
63
+ {
64
+ mark: "italic",
65
+ icon: "italic",
66
+ label: "formatItalic",
67
+ keys: "Meta+I"
68
+ },
69
+ {
70
+ mark: "strike",
71
+ icon: "strike",
72
+ label: "formatStrike",
73
+ keys: "Meta+Shift+X"
74
+ },
75
+ {
76
+ mark: "code",
77
+ icon: "code",
78
+ label: "formatCode",
79
+ keys: "Meta+E"
80
+ }
81
+ ];
82
+ function y({ client: e, value: o, onChange: l, onMentions: u, onSubmit: h, placeholder: g, autofocus: y, disabled: x, canMention: S, above: C }) {
83
+ let w = t(null), [T, E] = r([]), [D, O] = r(null), [k, A] = r(0), [j, M] = r(/* @__PURE__ */ new Map()), [N] = r(() => typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches);
84
+ a(() => {
85
+ y && w.current?.focus();
86
+ }, [y]), a(() => {
87
+ S && _(e).then(E);
88
+ }, [e, S]);
89
+ let P = D === null ? [] : T.filter((e) => e.name.toLowerCase().includes(D.toLowerCase())).slice(0, 8), F = (e, t = j) => [...t.entries()].filter(([t]) => e.includes(`@${t}`)).map(([, e]) => e), I = (e) => {
90
+ l(e);
91
+ let t = w.current?.selectionStart ?? e.length, n = e.slice(0, t), r = /(^|\s)@([\p{L}\p{N}._-]{0,30})$/u.exec(n);
92
+ O(S && r ? r[2] ?? "" : null), A(0), u(F(e));
93
+ }, L = (e, t, n = t) => {
94
+ let r = w.current;
95
+ l(e), u(F(e)), requestAnimationFrame(() => {
96
+ r && r.value === e && (r.focus(), r.setSelectionRange(t, n));
97
+ });
98
+ }, R = (e) => {
99
+ let t = w.current;
100
+ if (!t || e.id === null) return;
101
+ let n = t.selectionStart ?? o.length, r = o.slice(0, n).replace(/@[\p{L}\p{N}._-]*$/u, `@${e.name} `), i = r + o.slice(n), a = /^\d+$/.test(e.id) ? new Map(j).set(e.name, Number(e.id)) : j;
102
+ M(a), O(null), l(i), u(F(i, a)), requestAnimationFrame(() => {
103
+ t.value === i && (t.focus(), t.setSelectionRange(r.length, r.length));
104
+ });
105
+ }, z = (e) => {
106
+ let t = w.current;
107
+ if (!t || x) return;
108
+ let n = f(o, t.selectionStart ?? o.length, t.selectionEnd ?? o.length, e);
109
+ L(n.value, n.start, n.end);
110
+ };
111
+ return /* @__PURE__ */ n("div", {
112
+ class: "ck-compose",
113
+ children: [
114
+ C,
115
+ /* @__PURE__ */ n("textarea", {
116
+ ref: w,
117
+ class: "ck-textarea",
118
+ dir: o ? "auto" : void 0,
119
+ value: o,
120
+ placeholder: g,
121
+ disabled: x,
122
+ maxLength: 1e4,
123
+ "aria-label": g,
124
+ "aria-autocomplete": "list",
125
+ "aria-controls": P.length ? "ck-suggest" : void 0,
126
+ "aria-activedescendant": P.length ? `ck-opt-${k}` : void 0,
127
+ "aria-keyshortcuts": N ? void 0 : "Enter",
128
+ onInput: (e) => I(e.target.value),
129
+ onPaste: (e) => {
130
+ let t = e.clipboardData?.getData("text/plain") ?? "";
131
+ if (e.clipboardData?.files.length || !p(t)) return;
132
+ let n = w.current;
133
+ if (!n) return;
134
+ e.preventDefault();
135
+ let r = n.selectionStart ?? o.length, i = n.selectionEnd ?? o.length, a = (r > 0 && o[r - 1] !== "\n" ? "\n" : "") + m(t) + "\n";
136
+ L(o.slice(0, r) + a + o.slice(i), r + a.length);
137
+ },
138
+ onKeyDown: (e) => {
139
+ if ((e.key !== "Escape" || P.length) && e.stopPropagation(), P.length && [
140
+ "ArrowDown",
141
+ "ArrowUp",
142
+ "Enter",
143
+ "Tab",
144
+ "Escape"
145
+ ].includes(e.key)) {
146
+ e.preventDefault(), e.key === "ArrowDown" ? A((e) => (e + 1) % P.length) : e.key === "ArrowUp" ? A((e) => (e - 1 + P.length) % P.length) : e.key === "Escape" ? O(null) : R(P[k]);
147
+ return;
148
+ }
149
+ let t = d(e);
150
+ if (t) return e.preventDefault(), z(t);
151
+ e.key === "Enter" && !e.shiftKey && !e.isComposing && e.keyCode !== 229 && (!N || e.metaKey || e.ctrlKey) && (e.preventDefault(), h());
152
+ }
153
+ }),
154
+ P.length ? /* @__PURE__ */ n("div", {
155
+ class: "ck-suggest",
156
+ id: "ck-suggest",
157
+ role: "listbox",
158
+ "aria-label": i("mentionList"),
159
+ children: P.map((e, t) => /* @__PURE__ */ n("button", {
160
+ type: "button",
161
+ role: "option",
162
+ id: `ck-opt-${t}`,
163
+ "aria-selected": t === k,
164
+ onMouseDown: (t) => {
165
+ t.preventDefault(), R(e);
166
+ },
167
+ children: [/* @__PURE__ */ n(c, { person: e }), /* @__PURE__ */ n("bdi", { children: e.name })]
168
+ }))
169
+ }) : null,
170
+ /* @__PURE__ */ n("div", {
171
+ class: "ck-format",
172
+ role: "toolbar",
173
+ "aria-label": i("formatting"),
174
+ children: v.map((e) => /* @__PURE__ */ n("button", {
175
+ type: "button",
176
+ class: "ck-ghost ck-ghost-sm",
177
+ "aria-label": i(e.label),
178
+ title: `${i(e.label)} (${e.keys.replace("Meta", b() ? "⌘" : "Ctrl").replace(/\+/g, " ")})`,
179
+ "aria-keyshortcuts": e.keys,
180
+ disabled: x,
181
+ onMouseDown: (e) => e.preventDefault(),
182
+ onClick: () => z(e.mark),
183
+ children: /* @__PURE__ */ n(s, {
184
+ name: e.icon,
185
+ size: 14
186
+ })
187
+ }))
188
+ })
189
+ ]
190
+ });
191
+ }
192
+ function b() {
193
+ return typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
194
+ }
195
+ //#endregion
196
+ //#region src/ui/style-edit.ts
197
+ var x = [
198
+ {
199
+ property: "font-size",
200
+ kind: "length"
201
+ },
202
+ {
203
+ property: "font-weight",
204
+ kind: "number"
205
+ },
206
+ {
207
+ property: "line-height",
208
+ kind: "length"
209
+ },
210
+ {
211
+ property: "letter-spacing",
212
+ kind: "length"
213
+ },
214
+ {
215
+ property: "text-align",
216
+ kind: "choice",
217
+ options: [
218
+ "start",
219
+ "left",
220
+ "center",
221
+ "right",
222
+ "end",
223
+ "justify"
224
+ ]
225
+ },
226
+ {
227
+ property: "color",
228
+ kind: "color"
229
+ },
230
+ {
231
+ property: "background-color",
232
+ kind: "color"
233
+ },
234
+ {
235
+ property: "border-color",
236
+ kind: "color"
237
+ },
238
+ {
239
+ property: "border-width",
240
+ kind: "length"
241
+ },
242
+ {
243
+ property: "border-style",
244
+ kind: "choice",
245
+ options: [
246
+ "none",
247
+ "solid",
248
+ "dashed",
249
+ "dotted",
250
+ "double"
251
+ ]
252
+ },
253
+ {
254
+ property: "border-radius",
255
+ kind: "length"
256
+ },
257
+ {
258
+ property: "opacity",
259
+ kind: "number"
260
+ },
261
+ {
262
+ property: "margin",
263
+ kind: "box"
264
+ },
265
+ {
266
+ property: "padding",
267
+ kind: "box"
268
+ },
269
+ {
270
+ property: "width",
271
+ kind: "length"
272
+ },
273
+ {
274
+ property: "height",
275
+ kind: "length"
276
+ },
277
+ {
278
+ property: "gap",
279
+ kind: "length"
280
+ },
281
+ {
282
+ property: "display",
283
+ kind: "choice",
284
+ options: [
285
+ "block",
286
+ "inline",
287
+ "inline-block",
288
+ "flex",
289
+ "inline-flex",
290
+ "grid",
291
+ "none"
292
+ ]
293
+ }
294
+ ], S = new Set(x.map((e) => e.property)), C = /* @__PURE__ */ new Set([
295
+ "rgb",
296
+ "rgba",
297
+ "hsl",
298
+ "hsla",
299
+ "hwb",
300
+ "lab",
301
+ "lch",
302
+ "oklab",
303
+ "oklch",
304
+ "color",
305
+ "color-mix",
306
+ "calc",
307
+ "min",
308
+ "max",
309
+ "clamp",
310
+ "var"
311
+ ]);
312
+ function w(e) {
313
+ if (e.length > 120 || !/^[A-Za-z0-9#.%,()/*+ -]*$/.test(e) || /javascript|expression|import/i.test(e)) return !1;
314
+ let t = [...e.matchAll(/([A-Za-z-]+)\s*\(/g)].map((e) => e[1].toLowerCase()), n = e.split("(").length - 1;
315
+ return t.every((e) => C.has(e)) && n === t.length && n === e.split(")").length - 1;
316
+ }
317
+ function T(e) {
318
+ return typeof e == "string" && S.has(e);
319
+ }
320
+ function E(e) {
321
+ if (!Array.isArray(e)) return [];
322
+ let t = /* @__PURE__ */ new Set(), n = [];
323
+ for (let r of e) {
324
+ if (!r || !T(r.property) || t.has(r.property)) continue;
325
+ let e = typeof r.to == "string" && r.to.trim() ? r.to.trim() : null, i = typeof r.from == "string" && r.from.trim() ? r.from.trim() : null;
326
+ if (!(e !== null && !w(e) || i !== null && !w(i)) && (t.add(r.property), n.push({
327
+ property: r.property,
328
+ from: i,
329
+ to: e
330
+ }), n.length >= 20)) break;
331
+ }
332
+ return n;
333
+ }
334
+ function D(e) {
335
+ let t = getComputedStyle(e), n = {};
336
+ for (let { property: e } of x) {
337
+ let r = O(t, e).trim();
338
+ n[e] = w(r) ? r : "";
339
+ }
340
+ return n;
341
+ }
342
+ function O(e, t) {
343
+ let n = e.getPropertyValue(t);
344
+ if (n || ![
345
+ "margin",
346
+ "padding",
347
+ "border-width",
348
+ "border-color",
349
+ "border-style",
350
+ "border-radius"
351
+ ].includes(t)) return n;
352
+ let r = t === "border-radius" ? [
353
+ "top-left",
354
+ "top-right",
355
+ "bottom-right",
356
+ "bottom-left"
357
+ ].map((t) => e.getPropertyValue(`border-${t}-radius`)) : [
358
+ "top",
359
+ "right",
360
+ "bottom",
361
+ "left"
362
+ ].map((n) => e.getPropertyValue(t.startsWith("border-") ? `border-${n}-${t.slice(7)}` : `${t}-${n}`)), [i, a, o, s] = r;
363
+ return r.some((e) => !e) ? "" : i === a && a === o && o === s ? i : i === o && a === s ? `${i} ${a}` : a === s ? `${i} ${a} ${o}` : r.join(" ");
364
+ }
365
+ function k(e) {
366
+ return `${e.property} ${e.from || i("styleNotSet")} → ${e.to ?? i("styleRemoved")}`;
367
+ }
368
+ var A = class {
369
+ constructor(e) {
370
+ this.element = e, this.saved = /* @__PURE__ */ new Map(), this.hadStyle = e.hasAttribute("style");
371
+ }
372
+ apply(e) {
373
+ let t = new Map(e.filter((e) => T(e.property) && (e.to === null || w(e.to))).map((e) => [e.property, e.to]));
374
+ for (let e of [...this.saved.keys()]) t.has(e) || this.restore(e);
375
+ let n = this.element.style;
376
+ for (let [e, r] of t) this.saved.has(e) || this.saved.set(e, [e, ...M[e] ?? []].map((e) => ({
377
+ name: e,
378
+ value: n.getPropertyValue(e),
379
+ priority: n.getPropertyPriority(e)
380
+ }))), n.setProperty(e, r ?? "unset", "important");
381
+ this.saved.size || this.cleanUp();
382
+ }
383
+ revert() {
384
+ for (let e of [...this.saved.keys()]) this.restore(e);
385
+ this.cleanUp();
386
+ }
387
+ restore(e) {
388
+ let t = this.saved.get(e);
389
+ this.saved.delete(e);
390
+ let n = this.element.style;
391
+ for (let { name: e } of [...t].reverse()) n.removeProperty(e);
392
+ let r = t[0];
393
+ if (r.value) n.setProperty(r.name, r.value, r.priority);
394
+ else for (let { name: e, value: r, priority: i } of t.slice(1)) r && n.setProperty(e, r, i);
395
+ }
396
+ cleanUp() {
397
+ !this.hadStyle && this.element.getAttribute("style") === "" && this.element.removeAttribute("style");
398
+ }
399
+ }, j = (e) => [
400
+ "top",
401
+ "right",
402
+ "bottom",
403
+ "left"
404
+ ].map((t) => e.replace("*", t)), M = {
405
+ margin: j("margin-*"),
406
+ padding: j("padding-*"),
407
+ "border-width": j("border-*-width"),
408
+ "border-color": j("border-*-color"),
409
+ "border-style": j("border-*-style"),
410
+ "border-radius": [
411
+ "top-left",
412
+ "top-right",
413
+ "bottom-right",
414
+ "bottom-left"
415
+ ].map((e) => `border-${e}-radius`),
416
+ gap: ["row-gap", "column-gap"]
417
+ };
418
+ //#endregion
419
+ //#region src/ui/uploads.tsx
420
+ l(h);
421
+ function N(n, i) {
422
+ let [s, c] = r([]), l = t(/* @__PURE__ */ new Map()), u = t(/* @__PURE__ */ new Map()), d = t(/* @__PURE__ */ new Map()), f = t(s);
423
+ f.current = s;
424
+ let p = (e, t) => c((n) => n.map((n) => n.key === e ? {
425
+ ...n,
426
+ ...t
427
+ } : n)), m = (t) => {
428
+ d.current.delete(t.key);
429
+ let r = new AbortController();
430
+ l.current.set(t.key, r), p(t.key, {
431
+ state: "uploading",
432
+ progress: 0
433
+ });
434
+ let i = n.upload(t.file, t.file.name, "file", {
435
+ signal: r.signal,
436
+ onProgress: (e) => p(t.key, { progress: e })
437
+ }).then((e) => {
438
+ d.current.set(t.key, e.id), p(t.key, {
439
+ state: "done",
440
+ progress: 1,
441
+ attachmentId: e.id
442
+ });
443
+ }).catch((n) => {
444
+ n instanceof e && n.code === "upload_cancelled" || (d.current.set(t.key, "failed"), p(t.key, { state: "failed" }));
445
+ }).finally(() => l.current.delete(t.key));
446
+ u.current.set(t.key, i);
447
+ };
448
+ return a(() => () => {
449
+ l.current.forEach((e) => e.abort()), f.current.forEach((e) => e.preview && URL.revokeObjectURL(e.preview));
450
+ }, []), {
451
+ items: s,
452
+ add: (e) => {
453
+ let t = f.current.map((e) => e.file), r = o(t, e, n.state.get().config?.limits.max_upload_bytes ?? 10485760), a = r.files.filter((e) => !t.includes(e)).map((e) => ({
454
+ key: crypto.randomUUID(),
455
+ file: e,
456
+ preview: e.type.startsWith("image/") ? URL.createObjectURL(e) : null,
457
+ progress: 0,
458
+ state: "uploading",
459
+ attachmentId: null
460
+ }));
461
+ c((e) => [...e, ...a]), a.forEach(m), r.problem && i(r.problem);
462
+ },
463
+ remove: (e) => {
464
+ l.current.get(e.key)?.abort(), e.preview && URL.revokeObjectURL(e.preview), c((t) => t.filter((t) => t.key !== e.key));
465
+ },
466
+ retry: m,
467
+ clear: () => {
468
+ d.current.clear(), f.current.forEach((e) => e.preview && URL.revokeObjectURL(e.preview)), c([]);
469
+ },
470
+ ready: async () => {
471
+ let e = f.current.map((e) => e.key);
472
+ await Promise.all(e.map((e) => u.current.get(e)));
473
+ let t = e.map((e) => d.current.get(e));
474
+ return {
475
+ ids: t.filter((e) => !!e && e !== "failed"),
476
+ missing: t.some((e) => e !== void 0 && e === "failed")
477
+ };
478
+ },
479
+ busy: s.some((e) => e.state === "uploading")
480
+ };
481
+ }
482
+ function P({ items: e, onRemove: t, onRetry: r, onOpen: a }) {
483
+ if (!e.length) return null;
484
+ let o = e.filter((e) => e.preview);
485
+ return /* @__PURE__ */ n("ul", {
486
+ class: "ck-uploads",
487
+ "aria-label": i("attachments"),
488
+ children: e.map((e) => /* @__PURE__ */ n("li", {
489
+ class: "ck-upload",
490
+ "data-state": e.state,
491
+ "data-image": e.preview ? "true" : void 0,
492
+ children: [
493
+ e.preview ? /* @__PURE__ */ n("button", {
494
+ class: "ck-upload-thumb",
495
+ "aria-label": i("openImage", { name: e.file.name }),
496
+ onClick: () => a?.(o.indexOf(e)),
497
+ children: /* @__PURE__ */ n("img", {
498
+ src: e.preview,
499
+ alt: ""
500
+ })
501
+ }) : /* @__PURE__ */ n("span", {
502
+ class: "ck-upload-name",
503
+ children: [/* @__PURE__ */ n(s, {
504
+ name: "paperclip",
505
+ size: 13
506
+ }), /* @__PURE__ */ n("bdi", { children: e.file.name })]
507
+ }),
508
+ e.state === "uploading" ? /* @__PURE__ */ n("span", {
509
+ class: "ck-upload-bar",
510
+ role: "progressbar",
511
+ "aria-label": i("uploading", { name: e.file.name }),
512
+ "aria-valuemin": 0,
513
+ "aria-valuemax": 100,
514
+ "aria-valuenow": Math.round(e.progress * 100),
515
+ children: /* @__PURE__ */ n("span", { style: { width: `${Math.round(e.progress * 100)}%` } })
516
+ }) : null,
517
+ e.state === "failed" ? /* @__PURE__ */ n("button", {
518
+ class: "ck-upload-retry",
519
+ "aria-label": i("retryUpload", { name: e.file.name }),
520
+ title: i("uploadFailedShort"),
521
+ onClick: () => r(e),
522
+ children: [/* @__PURE__ */ n(s, {
523
+ name: "alert",
524
+ size: 13
525
+ }), i("retry")]
526
+ }) : null,
527
+ /* @__PURE__ */ n("button", {
528
+ class: "ck-upload-remove",
529
+ "aria-label": i("removeFile", { name: e.file.name }),
530
+ onClick: () => t(e),
531
+ children: /* @__PURE__ */ n(s, {
532
+ name: "close",
533
+ size: 12
534
+ })
535
+ })
536
+ ]
537
+ }))
538
+ });
539
+ }
540
+ //#endregion
541
+ export { E as a, k as c, h as d, A as i, y as l, N as n, D as o, x as r, w as s, P as t, _ as u };