@commentkit/comment-kit 1.6.0 → 2.0.1

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 (137) hide show
  1. package/CHANGELOG.md +298 -590
  2. package/README.md +421 -145
  3. package/SECURITY.md +47 -46
  4. package/dist/node/THIRD_PARTY_NOTICES.txt +56 -0
  5. package/dist/node/browser.js +17 -0
  6. package/dist/node/cli/api.js +226 -0
  7. package/dist/node/cli/bin.js +18 -0
  8. package/dist/node/cli/credentials.js +268 -0
  9. package/dist/node/cli/doctor.js +789 -0
  10. package/dist/node/cli/format.js +54 -0
  11. package/dist/node/cli/init.js +686 -0
  12. package/dist/node/cli/main.js +537 -0
  13. package/dist/node/cli/mcp.js +295 -0
  14. package/dist/node/cli/open.js +20 -0
  15. package/dist/node/plugins/astro-B5y1Gtbf.js +31 -0
  16. package/dist/node/plugins/astro.js +26 -0
  17. package/dist/node/plugins/git-BIXLbL3f.js +92 -0
  18. package/dist/node/plugins/jsx-Bg4BdSph.js +7958 -0
  19. package/dist/node/plugins/next.js +48 -0
  20. package/dist/node/plugins/options-THop1K92.js +71 -0
  21. package/dist/node/plugins/transform-CKiAuSbk.js +1155 -0
  22. package/dist/node/plugins/vite-BdAYUW10.js +74 -0
  23. package/dist/node/plugins/vite.js +1 -0
  24. package/dist/node/plugins/webpack-R2U2DLlY.js +35 -0
  25. package/dist/node/plugins/webpack-loader.cjs +21 -0
  26. package/dist/node/plugins/webpack-loader.js +18 -0
  27. package/dist/node/plugins/webpack.js +1 -0
  28. package/dist/node/shared/dashboard-places.js +33 -0
  29. package/dist/node/shared/endpoint.js +26 -0
  30. package/dist/node/shared/format.js +63 -0
  31. package/dist/node/types/astro.d.ts +11 -0
  32. package/dist/node/types/next.d.ts +34 -0
  33. package/dist/node/types/options.d.ts +59 -0
  34. package/dist/node/types/vite.d.ts +11 -0
  35. package/dist/node/types/webpack-loader.d.ts +22 -0
  36. package/dist/node/types/webpack.d.ts +27 -0
  37. package/dist/npm/THIRD_PARTY_NOTICES.txt +6 -6
  38. package/dist/npm/chunks/AgentSend-DOy3jhyF.js +68 -0
  39. package/dist/npm/chunks/Checklist-CW_SwMpS.js +282 -0
  40. package/dist/npm/chunks/Composer-Bveq5QrK.js +727 -0
  41. package/dist/npm/chunks/Guest-7hcN765o.js +270 -0
  42. package/dist/npm/chunks/MarkupEditor-6bJGpWGO.js +345 -0
  43. package/dist/npm/chunks/Panel-ChPUB68C.js +1211 -0
  44. package/dist/npm/chunks/Settings-CB5eEKnf.js +231 -0
  45. package/dist/npm/chunks/Shortcuts-eAyjJ89P.js +62 -0
  46. package/dist/npm/chunks/StyleEditor-CZTdAA5c.js +46 -0
  47. package/dist/npm/chunks/StylePanel-B4pHQUL9.js +199 -0
  48. package/dist/npm/chunks/TaskFields-C8BX0Sgg.js +289 -0
  49. package/dist/npm/chunks/ThreadCard-B1EsX3PR.js +1160 -0
  50. package/dist/npm/chunks/Viewer-DY6zb90M.js +114 -0
  51. package/dist/npm/chunks/{agent-BDMQtOzH.js → agent-MTQHr9ei.js} +9 -9
  52. package/dist/npm/chunks/{anchor-BsradQhn.js → anchor-BsQNVkHj.js} +108 -85
  53. package/dist/npm/chunks/{ar-8tPch6W4.js → ar-L5cQ-NPe.js} +71 -19
  54. package/dist/npm/chunks/card-bits-CTdrkYn8.js +53 -0
  55. package/dist/npm/chunks/{client-EFTWxHbJ.js → client-7eVxvg5j.js} +282 -290
  56. package/dist/npm/chunks/confetti-BIs5s14P.js +49 -0
  57. package/dist/npm/chunks/context-BuMl7A07.js +48 -0
  58. package/dist/npm/chunks/context-Cf6khm7A.js +20 -0
  59. package/dist/npm/chunks/{de-C63897uD.js → de-D0C-v6tP.js} +62 -18
  60. package/dist/npm/chunks/dialog-DvdIkCW0.js +3 -0
  61. package/dist/npm/chunks/dpop-0A76OPa9.js +96 -0
  62. package/dist/npm/chunks/drafts-B0ctr1g9.js +21 -0
  63. package/dist/npm/chunks/{es-CI2bSpvB.js → es-Bw4Dj9tN.js} +62 -18
  64. package/dist/npm/chunks/extension-DFVOvciD.js +62 -0
  65. package/dist/npm/chunks/{extension-BST6LH1q.js → extension-SmoH5AA4.js} +20 -12
  66. package/dist/npm/chunks/files-4lV9YQIX.js +114 -0
  67. package/dist/npm/chunks/{fr-rsVe-Lqk.js → fr-TkuQaIAa.js} +120 -76
  68. package/dist/npm/chunks/{hi-cvwbSaWP.js → hi-DXSH2U8d.js} +63 -19
  69. package/dist/npm/chunks/{i18n-C4v0M-6z.js → i18n-aVSu9TcJ.js} +136 -92
  70. package/dist/npm/chunks/identify-BGYh2dVo.js +106 -0
  71. package/dist/npm/chunks/{it-C8tnV0BF.js → it-CiWA_bch.js} +81 -37
  72. package/dist/npm/chunks/{ja-BWxDfC2f.js → ja-C-QmR3yz.js} +60 -16
  73. package/dist/npm/chunks/late-words-80_VWt8S.js +14 -0
  74. package/dist/npm/chunks/live-BExWHzQ7.js +85 -0
  75. package/dist/npm/chunks/locale-D8Q4Q2Nt.js +26 -0
  76. package/dist/npm/chunks/{nl-DNQ6eCht.js → nl-CEmZRqjX.js} +63 -19
  77. package/dist/npm/chunks/page-key-HSY3Lze5.js +62 -0
  78. package/dist/npm/chunks/{pick-CLyOdjnD.js → pick-B3sR7jtS.js} +45 -44
  79. package/dist/npm/chunks/pkce-CfZhiNBi.js +8 -0
  80. package/dist/npm/chunks/placement-BF_HOUDD.js +74 -0
  81. package/dist/npm/chunks/privacy-BWUGlHw5.js +57 -0
  82. package/dist/npm/chunks/{pt-BR-CkG7vpU2.js → pt-BR-b-a8sxO8.js} +62 -18
  83. package/dist/npm/chunks/{realtime-DIo-Wth4.js → realtime-C79zF50C.js} +14 -12
  84. package/dist/npm/chunks/report-DaVuoRYS.js +44 -0
  85. package/dist/npm/chunks/show-BoN8AC-F.js +97 -0
  86. package/dist/npm/chunks/signin-BOWr_WCo.js +75 -0
  87. package/dist/npm/chunks/{source-CS7C6wJA.js → source-mk3rGBBQ.js} +1 -1
  88. package/dist/npm/chunks/src-C8rZFyL_.js +215 -0
  89. package/dist/npm/chunks/start-CV4j78_q.js +1894 -0
  90. package/dist/npm/chunks/states-b9Bv3Ci7.js +3 -0
  91. package/dist/npm/chunks/upload-B2mkgMeJ.js +42 -0
  92. package/dist/npm/chunks/uploads-8AxyRq7g.js +1147 -0
  93. package/dist/npm/chunks/wrap-DW6EFbVQ.js +69 -0
  94. package/dist/npm/chunks/{zh-CN-BKuZOLBE.js → zh-CN-JTscW8u8.js} +61 -17
  95. package/dist/npm/element.js +58 -21
  96. package/dist/npm/headless.js +7 -3
  97. package/dist/npm/index.js +3 -3
  98. package/dist/npm/react.js +18 -11
  99. package/dist/npm/svelte.js +28 -12
  100. package/dist/npm/types/adapters/react.d.ts +4 -1
  101. package/dist/npm/types/adapters/svelte.d.ts +4 -1
  102. package/dist/npm/types/adapters/vue.d.ts +35 -2
  103. package/dist/npm/types/anchor/index.d.ts +19 -0
  104. package/dist/npm/types/capture/privacy.d.ts +14 -0
  105. package/dist/npm/types/core/api.d.ts +20 -1
  106. package/dist/npm/types/core/auth.d.ts +40 -21
  107. package/dist/npm/types/core/client.d.ts +60 -4
  108. package/dist/npm/types/core/page-key.d.ts +42 -0
  109. package/dist/npm/types/core/types.d.ts +87 -4
  110. package/dist/npm/types/element.d.ts +17 -7
  111. package/dist/npm/types/headless.d.ts +2 -1
  112. package/dist/npm/types/index.d.ts +16 -6
  113. package/dist/npm/vue.js +44 -9
  114. package/package.json +90 -14
  115. package/dist/npm/chunks/AgentSend-2JPDseOo.js +0 -63
  116. package/dist/npm/chunks/Checklist-BpDXQebo.js +0 -257
  117. package/dist/npm/chunks/Composer-CAyj-c8e.js +0 -677
  118. package/dist/npm/chunks/Guest-ZdFmTcXI.js +0 -187
  119. package/dist/npm/chunks/MarkupEditor-BFplZwFy.js +0 -332
  120. package/dist/npm/chunks/Panel-BhZ4XRDR.js +0 -861
  121. package/dist/npm/chunks/Settings-SPG9EHUZ.js +0 -204
  122. package/dist/npm/chunks/Shortcuts-C28HVDw6.js +0 -58
  123. package/dist/npm/chunks/StyleEditor-ByZMtq10.js +0 -43
  124. package/dist/npm/chunks/StylePanel-Iwhce2tE.js +0 -197
  125. package/dist/npm/chunks/TaskFields-BsP_fVJg.js +0 -273
  126. package/dist/npm/chunks/ThreadCard-BzVZdDCb.js +0 -1030
  127. package/dist/npm/chunks/Viewer-CqtGrdD8.js +0 -108
  128. package/dist/npm/chunks/card-bits-Bna-g3Py.js +0 -124
  129. package/dist/npm/chunks/confetti-DTKpwF3O.js +0 -40
  130. package/dist/npm/chunks/drafts-akdBsOd0.js +0 -50
  131. package/dist/npm/chunks/extension-D-V3utTm.js +0 -53
  132. package/dist/npm/chunks/live-BCpJVBeN.js +0 -33
  133. package/dist/npm/chunks/report-BBrT3r89.js +0 -27
  134. package/dist/npm/chunks/src-C4FsVoUp.js +0 -148
  135. package/dist/npm/chunks/start-i9M-r3aH.js +0 -1800
  136. package/dist/npm/chunks/upload-DSv7EyBD.js +0 -41
  137. package/dist/npm/chunks/uploads-I01kdqQF.js +0 -1103
@@ -0,0 +1,270 @@
1
+ import { b as e, o as t, v as n } from "./client-7eVxvg5j.js";
2
+ import { _ as r, c as i, d as a, f as o, m as s, n as c, u as l } from "./i18n-aVSu9TcJ.js";
3
+ import { r as u } from "./card-bits-CTdrkYn8.js";
4
+ import { C as d, f, s as p } from "./start-CV4j78_q.js";
5
+ // src/ui/Guest.tsx
6
+ p(".ck-verify-text{text-wrap:pretty;overflow-wrap:anywhere;margin:0 0 12px;line-height:1.5}.ck-verify .ck-code{height:48px;font-family:var(--ck-mono);font-size:var(--ck-fs-xl);letter-spacing:.32em;text-align:center;font-variant-numeric:tabular-nums;padding-inline-start:calc(12px + .32em);padding-inline-end:12px}.ck-verify .ck-actions .ck-chip{font-variant-numeric:tabular-nums}.ck-verify .ck-chip:disabled{opacity:.5;cursor:default}.ck-verify .ck-note{margin:12px 0 0}@media (hover:hover){.ck-verify .ck-chip:disabled:hover{background:var(--ck-bg);color:var(--ck-text-muted)}}@media (pointer:coarse){.ck-verify .ck-chip{min-height:44px}}");
7
+ async function m(e, r) {
8
+ try {
9
+ let n = await e.api.request("/guest/start", {
10
+ method: "POST",
11
+ anonymous: !0,
12
+ proof: !0,
13
+ body: {
14
+ client_id: e.options.project,
15
+ share: r.share,
16
+ name: r.name.trim(),
17
+ email: r.email.trim(),
18
+ locale: c(),
19
+ page_url: t()
20
+ }
21
+ }), i = Date.parse(n.pending_session.expires_at);
22
+ return e.auth.setPending({
23
+ token: n.access_token,
24
+ email: n.pending_session.email,
25
+ expiresAt: Number.isFinite(i) ? i : Date.now() + n.expires_in * 1e3
26
+ }), "started";
27
+ } catch (e) {
28
+ if (e instanceof n && e.code === "origin_not_allowed") return "popup";
29
+ throw e instanceof n && (e.code === "share_expired" || e.status === 410 || e.errors?.share) ? new n(410, "share_expired", i("shareExpired")) : e;
30
+ }
31
+ }
32
+ function h() {
33
+ let e;
34
+ try {
35
+ e = Intl.DateTimeFormat().resolvedOptions().timeZone;
36
+ } catch {
37
+ e = void 0;
38
+ }
39
+ return {
40
+ ...e && e.length <= 64 ? { timezone: e } : {},
41
+ locale: c()
42
+ };
43
+ }
44
+ function g({ client: t, email: c, onDone: p, onDifferentEmail: m, onClose: g }) {
45
+ let [y, b] = r(""), [x, S] = r(!1), [C, w] = r(null), [T, E] = r(null), D = s(null);
46
+ o(() => D.current?.focus({ preventScroll: !0 }), []);
47
+ let O = s({}), [k, A] = r(_);
48
+ a(() => {
49
+ if (k <= 0) return;
50
+ let e = setTimeout(() => A((e) => e - 1), 1e3);
51
+ return () => clearTimeout(e);
52
+ }, [k]);
53
+ let j = async (r = y) => {
54
+ if (/^\d{6}$/.test(r) && !x) {
55
+ S(!0), w(null);
56
+ try {
57
+ var a;
58
+ let n = {
59
+ code: r,
60
+ ...h()
61
+ }, i = await t.api.request("/guest/verify", {
62
+ method: "POST",
63
+ body: n,
64
+ idempotencyKey: (a = O.current)[r] ?? (a[r] = e(16))
65
+ });
66
+ t.auth.adopt(i), await t.loadSession().catch(() => null), p(i.published_thread_ids ?? []);
67
+ } catch (e) {
68
+ if ((e instanceof n ? e.status : 0) === 422) return b(""), D.current?.focus({ preventScroll: !0 }), w({
69
+ text: i("verifyWrong"),
70
+ tone: "warning"
71
+ });
72
+ let r = v(e);
73
+ r && (t.auth.setPending(null), E(r === "expired" ? "again" : "stop")), w({
74
+ text: r ? i(r === "link" ? "verifyLinkExpired" : r === "removed" ? "verifyRemoved" : "verifyExpired") : f(e),
75
+ tone: "warning"
76
+ });
77
+ } finally {
78
+ S(!1);
79
+ }
80
+ }
81
+ }, M = async () => {
82
+ let r = { "Idempotency-Key": e(16) }, a = () => t.api.request("/guest/resend", {
83
+ method: "POST",
84
+ headers: r
85
+ });
86
+ try {
87
+ await a().catch((e) => {
88
+ if (e instanceof n && e.status === 0) return a();
89
+ throw e;
90
+ }), w({ text: i("verifyResent") }), A(_);
91
+ } catch (e) {
92
+ let t = e instanceof n && e.code === "guest_codes_paused";
93
+ w({
94
+ text: t ? i("guestCodesPaused") : e instanceof n && e.status === 429 ? i("verifyWait") : i("errorGeneric"),
95
+ tone: "warning"
96
+ });
97
+ }
98
+ };
99
+ return /* @__PURE__ */ l("div", {
100
+ class: "ck-card ck-verify",
101
+ style: u({
102
+ x: innerWidth / 2 - 190,
103
+ y: 80
104
+ }),
105
+ role: "region",
106
+ "aria-labelledby": "ck-verify-title",
107
+ "data-commentkit-ui": !0,
108
+ onKeyDown: (e) => e.key === "Escape" && g(!0),
109
+ children: [
110
+ /* @__PURE__ */ l("div", {
111
+ class: "ck-card-head",
112
+ children: [/* @__PURE__ */ l("h2", {
113
+ class: "ck-card-title",
114
+ id: "ck-verify-title",
115
+ children: i("verifyTitle")
116
+ }), /* @__PURE__ */ l("button", {
117
+ class: "ck-ghost",
118
+ "aria-label": i("close"),
119
+ title: i("close"),
120
+ onClick: () => g(),
121
+ children: /* @__PURE__ */ l(d, { name: "close" })
122
+ })]
123
+ }),
124
+ /* @__PURE__ */ l("div", {
125
+ class: "ck-card-body",
126
+ children: [
127
+ /* @__PURE__ */ l("p", {
128
+ class: "ck-verify-text",
129
+ children: i("verifyBody", { email: c })
130
+ }),
131
+ /* @__PURE__ */ l("p", {
132
+ class: "ck-verify-text",
133
+ children: i("verifyLookFor", { website: t.state.get().config?.project?.name ?? "" })
134
+ }),
135
+ /* @__PURE__ */ l("label", {
136
+ class: "ck-field",
137
+ children: [/* @__PURE__ */ l("span", { children: i("verifyCode") }), /* @__PURE__ */ l("input", {
138
+ ref: D,
139
+ class: "ck-input ck-code",
140
+ "aria-invalid": C?.tone === "warning" || void 0,
141
+ "aria-describedby": C ? "ck-verify-note" : void 0,
142
+ inputMode: "numeric",
143
+ autoComplete: "one-time-code",
144
+ pattern: "[0-9]*",
145
+ maxLength: 6,
146
+ value: y,
147
+ onInput: (e) => {
148
+ let t = e.target.value.replace(/\D/g, "").slice(0, 6);
149
+ b(t), C?.tone && w(null), t.length === 6 && t !== y && j(t);
150
+ },
151
+ onKeyDown: (e) => {
152
+ e.stopPropagation(), e.key === "Enter" && j(), e.key === "Escape" && g(!0);
153
+ }
154
+ })]
155
+ }),
156
+ C ? /* @__PURE__ */ l("div", {
157
+ class: "ck-note",
158
+ id: "ck-verify-note",
159
+ role: C.tone ? "alert" : "status",
160
+ "data-tone": C.tone,
161
+ children: C.text
162
+ }) : null,
163
+ T ? null : /* @__PURE__ */ l("div", {
164
+ class: "ck-actions",
165
+ children: [/* @__PURE__ */ l("button", {
166
+ class: "ck-chip",
167
+ "aria-disabled": k > 0 || void 0,
168
+ onClick: () => k > 0 || void M(),
169
+ children: k > 0 ? i("verifyResendIn", { n: k }) : i("verifyResend")
170
+ }), /* @__PURE__ */ l("button", {
171
+ class: "ck-chip",
172
+ onClick: () => {
173
+ t.auth.setPending(null), m();
174
+ },
175
+ children: i("verifyDifferent")
176
+ })]
177
+ })
178
+ ]
179
+ }),
180
+ /* @__PURE__ */ l("div", {
181
+ class: "ck-card-foot",
182
+ children: [/* @__PURE__ */ l("span", { class: "ck-spacer" }), T === "again" ? /* @__PURE__ */ l("button", {
183
+ class: "ck-btn ck-primary",
184
+ onClick: m,
185
+ children: i("writeAgain")
186
+ }) : T === "stop" ? /* @__PURE__ */ l("button", {
187
+ class: "ck-btn",
188
+ onClick: () => g(),
189
+ children: i("close")
190
+ }) : /* @__PURE__ */ l("button", {
191
+ class: "ck-btn ck-primary",
192
+ "aria-disabled": x || y.length !== 6 || void 0,
193
+ "aria-busy": x || void 0,
194
+ onClick: () => void j(),
195
+ children: i(x ? "sending" : "verifyPublish")
196
+ })]
197
+ })
198
+ ]
199
+ });
200
+ }
201
+ var _ = 60;
202
+ function v(e) {
203
+ return e instanceof n ? e.code === "share_expired" || e.status === 410 ? "link" : e.code === "guest_removed" ? "removed" : e.status === 403 ? /\blink\b/i.test(e.message) ? "link" : "removed" : e.status === 409 || e.status === 401 ? "expired" : null : null;
204
+ }
205
+ function y({ client: e, position: t, notify: a, onOpen: o }) {
206
+ let [s, c] = r(e.auth.finishLink), [u, d] = r(!1), [p, m] = r(null);
207
+ if (!s) return null;
208
+ let g = () => {
209
+ e.auth.finishLink = null, c(null);
210
+ }, _ = async () => {
211
+ if (!u) {
212
+ d(!0);
213
+ try {
214
+ let t = await e.api.request("/guest/finish", {
215
+ method: "POST",
216
+ anonymous: !0,
217
+ proof: !0,
218
+ body: {
219
+ client_id: e.options.project,
220
+ link: s,
221
+ ...h()
222
+ }
223
+ });
224
+ g(), e.auth.adopt(t), await e.loadSession().catch(() => null), a({
225
+ text: i("sentGuest"),
226
+ tone: "success"
227
+ }), t.published_thread_ids?.[0] && o(t.published_thread_ids[0]);
228
+ } catch (t) {
229
+ let r = t instanceof n ? t.code : "";
230
+ [
231
+ 402,
232
+ 403,
233
+ 410,
234
+ 422
235
+ ].includes(t instanceof n ? t.status : 0) && (e.auth.finishLink = null), m(r === "finish_link_expired" ? i("finishExpired") : f(t)), d(!1);
236
+ }
237
+ }
238
+ };
239
+ return /* @__PURE__ */ l("div", {
240
+ class: "ck-welcome",
241
+ "data-pos": t,
242
+ role: "region",
243
+ "aria-labelledby": "ck-finish-title",
244
+ "data-commentkit-ui": !0,
245
+ children: [
246
+ /* @__PURE__ */ l("h2", {
247
+ id: "ck-finish-title",
248
+ children: i("finishTitle")
249
+ }),
250
+ /* @__PURE__ */ l("p", {
251
+ role: p ? "alert" : void 0,
252
+ children: p ?? i("finishBody")
253
+ }),
254
+ /* @__PURE__ */ l("div", {
255
+ class: "ck-actions",
256
+ children: p && !e.auth.finishLink ? /* @__PURE__ */ l("button", {
257
+ class: "ck-btn",
258
+ onClick: g,
259
+ children: i("close")
260
+ }) : /* @__PURE__ */ l("button", {
261
+ class: "ck-btn ck-primary",
262
+ "aria-busy": u || void 0,
263
+ onClick: () => void _(),
264
+ children: i(u ? "sending" : "finishSend")
265
+ })
266
+ })
267
+ ]
268
+ });
269
+ }
270
+ export { y as GuestFinish, g as GuestVerify, h as readerSettings, m as startGuest, v as verifyOutcome };
@@ -0,0 +1,345 @@
1
+ import { _ as e, c as t, d as n, f as r, m as i, u as a } from "./i18n-aVSu9TcJ.js";
2
+ import { O as o, m as s, s as c } from "./start-CV4j78_q.js";
3
+ // src/ui/MarkupEditor.tsx
4
+ c(".ck-markup{z-index:calc(var(--ck-z) + 2);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);background:#0a0a0c4d;flex-direction:column;justify-content:center;align-items:center;gap:12px;padding:16px;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.ck-markup canvas{border-radius:var(--ck-radius-md);cursor:crosshair;touch-action:none;background:#fff;max-width:min(100%,1100px);max-height:calc(100dvh - 110px);box-shadow:0 0 0 1px #0000000d,0 20px 50px #00000040}.ck-label-box .ck-input{width:200px;font-weight:600}.ck-markup .ck-markup-tools{background:var(--ck-bg);border-radius:var(--ck-radius-pill);max-width:100%;box-shadow:var(--ck-shadow);border:1px solid #0000;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px;padding:4px;display:flex}.ck-markup .ck-markup-group{align-items:center;gap:4px;padding:0 4px;display:flex}.ck-markup .ck-markup-group+.ck-markup-group{border-inline-start:1px solid var(--ck-hairline);margin-inline-start:4px;padding-inline-start:8px}.ck-markup .ck-tool{border-radius:var(--ck-radius-pill);width:32px;height:32px;color:var(--ck-text-muted);transition:background-color var(--ck-fast), color var(--ck-fast), scale var(--ck-fast) ease-out;background:0 0;border:0;place-items:center;padding:0;display:grid}.ck-markup .ck-tool[aria-pressed=true]{background:var(--ck-accent-soft);color:var(--ck-accent-text)}.ck-markup .ck-tool:active,.ck-markup .ck-icon-btn:active:not([aria-disabled=true]){scale:.96}.ck-markup .ck-dot{width:16px;height:16px;box-shadow:inset 0 0 0 1px var(--ck-hairline);border-radius:50%;display:block}.ck-markup .ck-tool[aria-pressed=true] .ck-dot{box-shadow:0 0 0 2px var(--ck-bg), 0 0 0 4px currentColor}.ck-markup .ck-width{gap:8px;width:152px}.ck-markup .ck-width input{min-width:0;accent-color:var(--ck-accent);cursor:pointer;flex:1}.ck-markup .ck-width span{width:32px;font-size:var(--ck-fs-sm);color:var(--ck-text-muted);font-variant-numeric:tabular-nums;text-align:end;flex:none}.ck-markup .ck-btn-group{display:inline-flex}.ck-markup .ck-icon-btn{border:1px solid var(--ck-control);background:var(--ck-bg);width:32px;height:32px;color:var(--ck-text);transition:background-color var(--ck-fast), scale var(--ck-fast) ease-out;place-items:center;padding:0;display:grid}.ck-markup .ck-icon-btn+.ck-icon-btn{margin-inline-start:-1px}.ck-markup .ck-icon-btn:first-child: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))){border-top-left-radius:var(--ck-radius-sm);border-bottom-left-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:first-child: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))){border-top-left-radius:var(--ck-radius-sm);border-bottom-left-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:first-child:-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)){border-top-right-radius:var(--ck-radius-sm);border-bottom-right-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:first-child: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)){border-top-right-radius:var(--ck-radius-sm);border-bottom-right-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:last-child: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))){border-top-right-radius:var(--ck-radius-sm);border-bottom-right-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:last-child: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))){border-top-right-radius:var(--ck-radius-sm);border-bottom-right-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:last-child:-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)){border-top-left-radius:var(--ck-radius-sm);border-bottom-left-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:last-child: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)){border-top-left-radius:var(--ck-radius-sm);border-bottom-left-radius:var(--ck-radius-sm)}.ck-markup .ck-icon-btn:focus-visible{z-index:1;position:relative}.ck-markup .ck-icon-btn[aria-disabled=true]{opacity:.5;cursor:default}.ck-markup .ck-icon-btn.ck-primary{border-color:var(--ck-accent);background:var(--ck-accent);color:var(--ck-accent-ink);position:relative}.ck-markup .ck-label-box{z-index:1;border-radius:var(--ck-radius-md);background:var(--ck-bg);box-shadow:var(--ck-shadow);border:1px solid #0000;align-items:center;gap:4px;padding:4px;display:flex;position:fixed}.ck-markup .ck-label-box .ck-input{border-radius:var(--ck-radius-sm);height:32px}.ck-markup .ck-label-box .ck-chip{flex:none;height:32px}@media (hover:hover){.ck-markup .ck-icon-btn:hover:not([aria-disabled=true]):not(.ck-primary){background:var(--ck-bg-hover)}.ck-markup .ck-tool:hover{background:var(--ck-bg-hover);color:var(--ck-text)}}@media (forced-colors:active){.ck-markup .ck-tool[aria-pressed=true]{color:highlighttext;background:highlight}}@media (pointer:coarse){.ck-markup .ck-tool,.ck-markup .ck-icon-btn{width:44px;height:44px}}@media (max-width:520px){.ck-markup .ck-markup-tools{border-radius:var(--ck-radius)}}");
5
+ var l = /* @__PURE__ */ new WeakSet(), u = [
6
+ "pen",
7
+ "line",
8
+ "rect",
9
+ "ellipse",
10
+ "arrow",
11
+ "blur",
12
+ "text"
13
+ ], d = [
14
+ "#ef4444",
15
+ "#f97316",
16
+ "#eab308",
17
+ "#22c55e",
18
+ "#3b82f6",
19
+ "#8b5cf6",
20
+ "#ec4899"
21
+ ], f = [
22
+ "color_red",
23
+ "color_orange",
24
+ "color_yellow",
25
+ "color_green",
26
+ "color_blue",
27
+ "color_purple",
28
+ "color_pink"
29
+ ], p = {
30
+ arrow: "M5 19L19 5M10 5h9v9",
31
+ line: "M5 19L19 5",
32
+ rect: "M5 6h14v12H5z",
33
+ ellipse: "M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16z",
34
+ pen: "M4 20l4-1 11-11-3-3L5 16z",
35
+ blur: "M4 4h4v4H4zM10 4h4v4h-4zM16 4h4v4h-4zM4 10h4v4H4zM16 10h4v4h-4zM4 16h4v4H4zM10 16h4v4h-4zM16 16h4v4h-4zM10 10h4v4h-4z",
36
+ text: "M5 6V5h14v1M12 5v14M9 19h6"
37
+ }, m = {
38
+ undo: "M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",
39
+ redo: "M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",
40
+ clear: "M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3",
41
+ cancel: "M6 6l12 12M18 6L6 18",
42
+ save: "M5 12l5 5L20 7"
43
+ };
44
+ function h({ d: e }) {
45
+ return /* @__PURE__ */ a("svg", {
46
+ width: "16",
47
+ height: "16",
48
+ viewBox: "0 0 24 24",
49
+ fill: "none",
50
+ stroke: "currentColor",
51
+ "stroke-width": "2",
52
+ "stroke-linecap": "round",
53
+ "stroke-linejoin": "round",
54
+ "aria-hidden": "true",
55
+ children: /* @__PURE__ */ a("path", { d: e })
56
+ });
57
+ }
58
+ function g({ image: s, onDone: c, onCancel: g }) {
59
+ let b = i(null), [x, S] = e(null), [C, w] = e("pen"), [T, E] = e(d[0]), [D, O] = e(3), [k, A] = e({
60
+ steps: [[]],
61
+ at: 0
62
+ }), j = k.steps[k.at], M = (e) => A((t) => ({
63
+ steps: [...t.steps.slice(0, t.at + 1), e],
64
+ at: t.at + 1
65
+ })), N = () => A((e) => ({
66
+ ...e,
67
+ at: Math.max(0, e.at - 1)
68
+ })), P = () => A((e) => ({
69
+ ...e,
70
+ at: Math.min(e.steps.length - 1, e.at + 1)
71
+ })), F = i(null), [I, L] = e(null), R = i(null), z = i(null);
72
+ r(() => {
73
+ let e = z.current?.getRootNode()?.activeElement ?? document.activeElement;
74
+ return () => {
75
+ e instanceof HTMLElement && e.isConnected && e.focus({ preventScroll: !0 });
76
+ };
77
+ }, []), r(() => (R.current ?? z.current)?.focus({ preventScroll: !0 }), [!!I]);
78
+ let B = () => {
79
+ let e = I?.text.trim().slice(0, 500);
80
+ I && e && M([...j, {
81
+ tool: "text",
82
+ color: T,
83
+ points: [I.x, I.y],
84
+ text: e,
85
+ width: _(b.current, D)
86
+ }]), z.current?.focus({ preventScroll: !0 }), L(null);
87
+ };
88
+ n(() => {
89
+ let e = !0, t = null;
90
+ return createImageBitmap(s).then((n) => e ? S(t = n) : n.close()), () => {
91
+ if (e = !1, t) {
92
+ let e = t;
93
+ S((t) => t === e ? null : t), l.add(e), e.close();
94
+ }
95
+ };
96
+ }, [s]), n(() => V(), [x, j]);
97
+ let V = (e) => {
98
+ let t = b.current;
99
+ if (!t || !x || l.has(x)) return;
100
+ (t.width !== x.width || t.height !== x.height) && (t.width = x.width, t.height = x.height);
101
+ let n = t.getContext("2d");
102
+ n.clearRect(0, 0, t.width, t.height), n.drawImage(x, 0, 0);
103
+ for (let t of e ? [...j, e] : j) y(n, t, x);
104
+ }, H = (e) => {
105
+ let t = b.current, n = t.getBoundingClientRect();
106
+ return [Math.round((e.clientX - n.left) / n.width * t.width), Math.round((e.clientY - n.top) / n.height * t.height)];
107
+ }, U = (e) => {
108
+ let [t, n] = H(e);
109
+ C === "text" ? (e.preventDefault(), B(), L({
110
+ x: t,
111
+ y: n,
112
+ left: Math.min(e.clientX, innerWidth - 240),
113
+ top: Math.max(8, e.clientY - 18),
114
+ text: ""
115
+ })) : (F.current = {
116
+ tool: C,
117
+ color: T,
118
+ points: [
119
+ t,
120
+ n,
121
+ t,
122
+ n
123
+ ],
124
+ width: _(b.current, D)
125
+ }, b.current?.setPointerCapture(e.pointerId));
126
+ }, W = (e) => {
127
+ let t = F.current;
128
+ if (!t?.points) return;
129
+ let [n, r] = H(e);
130
+ t.tool === "pen" ? t.points.length < 4e3 && t.points.push(n, r) : (t.points[2] = n, t.points[3] = r), V(t);
131
+ }, G = () => {
132
+ F.current && M([...j, F.current]), F.current = null;
133
+ }, K = () => {
134
+ let e = I?.text.trim().slice(0, 500), t = I && e ? {
135
+ tool: "text",
136
+ color: T,
137
+ points: [I.x, I.y],
138
+ text: e,
139
+ width: _(b.current, D)
140
+ } : null;
141
+ t && V(t), b.current?.toBlob((e) => e && c(e, t ? [...j, t] : j), "image/webp", .88);
142
+ };
143
+ return /* @__PURE__ */ a("div", {
144
+ class: "ck-markup",
145
+ ref: z,
146
+ tabIndex: -1,
147
+ role: "dialog",
148
+ "aria-modal": "true",
149
+ "aria-label": t("markup"),
150
+ "data-commentkit-ui": !0,
151
+ onKeyDown: (e) => {
152
+ if (e.key === "Tab") {
153
+ let t = [...z.current.querySelectorAll("button, input")], n = t.indexOf(z.current.getRootNode().activeElement);
154
+ e.preventDefault(), t[n < 0 ? e.shiftKey ? t.length - 1 : 0 : (n + (e.shiftKey ? -1 : 1) + t.length) % t.length]?.focus();
155
+ } else {
156
+ if ((e.metaKey || e.ctrlKey) && !I && (e.key.toLowerCase() === "z" || e.key.toLowerCase() === "y")) return e.preventDefault(), e.stopPropagation(), e.key.toLowerCase() === "y" || e.shiftKey ? P() : N();
157
+ e.key === "Escape" && (e.stopPropagation(), I ? (z.current?.focus({ preventScroll: !0 }), L(null)) : g());
158
+ }
159
+ },
160
+ children: [
161
+ /* @__PURE__ */ a("div", {
162
+ class: "ck-markup-tools",
163
+ role: "group",
164
+ "aria-label": t("markup"),
165
+ children: [
166
+ /* @__PURE__ */ a("div", {
167
+ class: "ck-markup-group",
168
+ role: "group",
169
+ "aria-label": t("markupTools"),
170
+ children: u.map((e) => /* @__PURE__ */ a("button", {
171
+ class: "ck-tool",
172
+ "aria-pressed": C === e,
173
+ "aria-label": t(`tool_${e}`),
174
+ title: t(`tool_${e}`),
175
+ onClick: () => w(e),
176
+ children: /* @__PURE__ */ a(h, { d: p[e] })
177
+ }))
178
+ }),
179
+ /* @__PURE__ */ a("div", {
180
+ class: "ck-markup-group",
181
+ role: "group",
182
+ "aria-label": t("markupColors"),
183
+ children: d.map((e, n) => /* @__PURE__ */ a("button", {
184
+ class: "ck-tool",
185
+ "aria-pressed": T === e,
186
+ "aria-label": t(f[n]),
187
+ title: t(f[n]),
188
+ onClick: () => E(e),
189
+ children: /* @__PURE__ */ a("span", {
190
+ class: "ck-dot",
191
+ style: { background: e }
192
+ })
193
+ }))
194
+ }),
195
+ /* @__PURE__ */ a("label", {
196
+ class: "ck-markup-group ck-width",
197
+ children: [/* @__PURE__ */ a("input", {
198
+ type: "range",
199
+ min: 1,
200
+ max: 12,
201
+ step: 1,
202
+ value: D,
203
+ "aria-label": t("markupSize"),
204
+ onInput: (e) => O(Number(e.target.value))
205
+ }), /* @__PURE__ */ a("span", { children: [D, "px"] })]
206
+ }),
207
+ /* @__PURE__ */ a("div", {
208
+ class: "ck-markup-group",
209
+ role: "group",
210
+ "aria-label": t("markupHistory"),
211
+ children: /* @__PURE__ */ a("span", {
212
+ class: "ck-btn-group",
213
+ children: [
214
+ /* @__PURE__ */ a("button", {
215
+ class: "ck-icon-btn",
216
+ "aria-disabled": k.at === 0 || void 0,
217
+ "aria-label": t("undo"),
218
+ title: `${t("undo")} (${v()} Z)`,
219
+ "aria-keyshortcuts": "Meta+Z",
220
+ onClick: N,
221
+ children: /* @__PURE__ */ a(h, { d: m.undo })
222
+ }),
223
+ /* @__PURE__ */ a("button", {
224
+ class: "ck-icon-btn",
225
+ "aria-disabled": k.at === k.steps.length - 1 || void 0,
226
+ "aria-label": t("redo"),
227
+ title: `${t("redo")} (${v()} Shift Z)`,
228
+ "aria-keyshortcuts": "Meta+Shift+Z",
229
+ onClick: P,
230
+ children: /* @__PURE__ */ a(h, { d: m.redo })
231
+ }),
232
+ /* @__PURE__ */ a("button", {
233
+ class: "ck-icon-btn",
234
+ "aria-disabled": !j.length || void 0,
235
+ "aria-label": t("clearAll"),
236
+ title: t("clearAll"),
237
+ onClick: () => j.length && M([]),
238
+ children: /* @__PURE__ */ a(h, { d: m.clear })
239
+ })
240
+ ]
241
+ })
242
+ }),
243
+ /* @__PURE__ */ a("div", {
244
+ class: "ck-markup-group",
245
+ children: /* @__PURE__ */ a("span", {
246
+ class: "ck-btn-group",
247
+ children: [/* @__PURE__ */ a("button", {
248
+ class: "ck-icon-btn",
249
+ "aria-label": t("cancel"),
250
+ title: `${t("cancel")} (Esc)`,
251
+ onClick: g,
252
+ children: /* @__PURE__ */ a(h, { d: m.cancel })
253
+ }), /* @__PURE__ */ a("button", {
254
+ class: "ck-icon-btn ck-primary",
255
+ "aria-disabled": !j.length && !I?.text.trim() || void 0,
256
+ "aria-label": t("markupDone"),
257
+ title: !j.length && !I?.text.trim() ? t("markupEmpty") : t("markupDone"),
258
+ onClick: () => (j.length || I?.text.trim()) && K(),
259
+ children: /* @__PURE__ */ a(h, { d: m.save })
260
+ })]
261
+ })
262
+ })
263
+ ]
264
+ }),
265
+ /* @__PURE__ */ a("canvas", {
266
+ ref: b,
267
+ role: "img",
268
+ "aria-label": t("markup"),
269
+ onPointerDown: U,
270
+ onPointerMove: W,
271
+ onPointerUp: G
272
+ }),
273
+ I ? /* @__PURE__ */ a("div", {
274
+ class: "ck-label-box",
275
+ style: o(I.left, I.top),
276
+ children: [/* @__PURE__ */ a("input", {
277
+ ref: R,
278
+ class: "ck-input",
279
+ maxLength: 500,
280
+ value: I.text,
281
+ placeholder: t("markupTextPrompt"),
282
+ "aria-label": t("markupTextPrompt"),
283
+ style: { color: T },
284
+ onInput: (e) => L({
285
+ ...I,
286
+ text: e.target.value
287
+ }),
288
+ onKeyDown: (e) => {
289
+ e.key === "Enter" && (e.preventDefault(), B());
290
+ }
291
+ }), /* @__PURE__ */ a("button", {
292
+ class: "ck-chip ck-primary",
293
+ onMouseDown: (e) => e.preventDefault(),
294
+ onClick: B,
295
+ children: t("markupTextAdd")
296
+ })]
297
+ }) : null
298
+ ]
299
+ });
300
+ }
301
+ function _(e, t) {
302
+ let n = e?.getBoundingClientRect().width || e?.width || 1;
303
+ return Math.max(1, Math.min(64, Math.round(t * ((e?.width ?? n) / n))));
304
+ }
305
+ var v = () => s() ? "⌘" : "Ctrl";
306
+ function y(e, t, n) {
307
+ let r = t.points ?? [], i = t.width ?? Math.max(3, Math.round(n.width / 300));
308
+ e.save(), e.strokeStyle = e.fillStyle = t.color ?? "#ff3b30", e.lineWidth = i, e.lineCap = e.lineJoin = "round";
309
+ let [a = 0, o = 0, s = 0, c = 0] = r;
310
+ switch (t.tool) {
311
+ case "rect":
312
+ e.strokeRect(Math.min(a, s), Math.min(o, c), Math.abs(s - a), Math.abs(c - o));
313
+ break;
314
+ case "ellipse":
315
+ e.beginPath(), e.ellipse((a + s) / 2, (o + c) / 2, Math.abs(s - a) / 2, Math.abs(c - o) / 2, 0, 0, Math.PI * 2), e.stroke();
316
+ break;
317
+ case "line":
318
+ e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke();
319
+ break;
320
+ case "arrow": {
321
+ let t = Math.atan2(c - o, s - a), n = i * 5;
322
+ e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(s - n * Math.cos(t - .45), c - n * Math.sin(t - .45)), e.lineTo(s - n * Math.cos(t + .45), c - n * Math.sin(t + .45)), e.closePath(), e.fill();
323
+ break;
324
+ }
325
+ case "pen":
326
+ e.beginPath();
327
+ for (let t = 0; t < r.length; t += 2) (t ? e.lineTo : e.moveTo).call(e, r[t], r[t + 1]);
328
+ e.stroke();
329
+ break;
330
+ case "blur": {
331
+ let t = Math.min(a, s), n = Math.min(o, c), r = Math.abs(s - a), i = Math.abs(c - o);
332
+ if (r > 2 && i > 2) {
333
+ let a = Math.max(8, Math.round(Math.min(r, i) / 6)), o = e.getImageData(t, n, r, i);
334
+ for (let s = 0; s < i; s += a) for (let i = 0; i < r; i += a) {
335
+ let c = (s * r + i) * 4;
336
+ e.fillStyle = `rgb(${o.data[c]},${o.data[c + 1]},${o.data[c + 2]})`, e.fillRect(t + i, n + s, a, a);
337
+ }
338
+ }
339
+ break;
340
+ }
341
+ case "text": e.font = `bold ${Math.max(14, i * 6)}px system-ui, sans-serif`, e.lineWidth = i * 1.5, e.strokeStyle = "#ffffff", e.strokeText(t.text ?? "", a, o), e.fillText(t.text ?? "", a, o);
342
+ }
343
+ e.restore();
344
+ }
345
+ export { g as MarkupEditor };