@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,206 @@
1
+ import { a as e } from "./client-CJ1tpI62.js";
2
+ import { f as t, l as n, m as r, n as i, s as a, u as o, v as s } from "./i18n-DAJGndZ2.js";
3
+ import { a as c, b as l, d as u, l as d, n as f } from "./start-DW9_DKmf.js";
4
+ //#endregion
5
+ //#region src/ui/Settings.tsx
6
+ f(".ck-settings{width:min(380px,100vw - 24px)}.ck-settings .ck-card-body{gap:16px;display:grid}.ck-account{border-radius:var(--ck-radius-md);background:var(--ck-bg-muted);align-items:center;gap:12px;padding:12px;display:flex}.ck-account .ck-avatar{width:40px;height:40px;font-size:14px}.ck-account>div{gap:1px;min-width:0;font-size:12.5px;display:grid}.ck-account .ck-muted{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-setting h3{letter-spacing:.02em;text-transform:uppercase;color:var(--ck-text-muted);margin:0 0 8px;font-size:12px;font-weight:650}.ck-setting-hint{margin:6px 0 0;font-size:12px}.ck-segment{background:var(--ck-bg-muted);border-radius:10px;grid-template-columns:repeat(3,1fr);gap:2px;padding:3px;display:grid}.ck-segment button{height:30px;color:var(--ck-text-muted);background:0 0;border:0;border-radius:8px;font-size:13px;font-weight:600;transition:background-color .12s,color .12s,box-shadow .12s}.ck-segment button[aria-checked=true]{background:var(--ck-bg);color:var(--ck-text);box-shadow:var(--ck-shadow-sm)}.ck-setting-links{border-top:1px solid var(--ck-hairline);gap:2px;padding-top:8px;display:grid}.ck-setting-links a,.ck-setting-links button{border-radius:var(--ck-radius-sm);width:100%;color:var(--ck-text);text-align:start;background:0 0;border:0;align-items:center;gap:10px;padding:8px 10px;font-size:13.5px;text-decoration:none;display:flex}.ck-setting-links svg{color:var(--ck-text-muted);flex:none}.ck-setting-links .ck-danger{color:var(--ck-danger)}.ck-setting-links .ck-danger svg{color:currentColor}@media (hover:hover){.ck-setting-links a:hover,.ck-setting-links button:hover{background:var(--ck-bg-hover)}.ck-segment button:hover{color:var(--ck-text)}}@media (pointer:coarse){.ck-segment button{height:40px}.ck-setting-links a,.ck-setting-links button{min-height:44px}}.ck-team{gap:2px;margin:0;padding:0;list-style:none;display:grid}.ck-team li{align-items:center;gap:8px;padding:4px 0;font-size:13px;display:flex}.ck-team-face{display:inline-flex;position:relative}.ck-team-face .ck-avatar{width:24px;height:24px;font-size:10px}.ck-online{background:var(--ck-success);width:8px;height:8px;box-shadow:0 0 0 2px var(--ck-bg);border-radius:50%;position:absolute;bottom:-1px}.ck-online: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-online: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-online:-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-online: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-team-role{margin-inline-start:auto;font-size:12px}.ck-meter{background:var(--ck-bg-muted);height:6px;box-shadow:inset 0 0 0 1px var(--ck-hairline);border-radius:3px;overflow:hidden}.ck-meter>span{background:var(--ck-accent);height:100%;transition:width .3s var(--ck-ease);border-radius:3px;display:block}.ck-meter>span[data-high]{background:var(--ck-warning)}");
7
+ var p = [
8
+ ["auto", "themeSystem"],
9
+ ["light", "themeLight"],
10
+ ["dark", "themeDark"]
11
+ ];
12
+ function m({ client: i, onClose: f, onShortcuts: m, onHide: g, onSignOut: _ }) {
13
+ let v = c(i.state, (e) => e.session), y = c(i.state, (e) => e.theme ?? i.options.theme ?? e.config?.appearance?.theme ?? "auto"), b = t(null), x = c(i.state, (e) => e.team), S = v?.role === "admin" || v?.role === "member", [C, w] = r(null), [T, E] = r(null);
14
+ o(() => {
15
+ S && (i.people().then((e) => w(e.filter((e) => e.role && e.role !== "reviewer")), () => w([])), i.usage().then(E, () => E(null)));
16
+ }, [S]), o(() => {
17
+ let e = b.current?.getRootNode()?.activeElement ?? document.activeElement;
18
+ return b.current?.focus({ preventScroll: !0 }), () => {
19
+ e instanceof HTMLElement && e.isConnected && e.focus({ preventScroll: !0 });
20
+ };
21
+ }, []);
22
+ let D = (t) => {
23
+ e(t), i.state.set({ theme: t });
24
+ }, O = l(v?.dashboard_url), k = C?.find((e) => e.id === v?.person.id)?.role, A = v ? a(`role_${k === "owner" ? "owner" : v.role}`) : "";
25
+ return /* @__PURE__ */ n("div", {
26
+ class: "ck-scrim",
27
+ "data-commentkit-ui": !0,
28
+ onClick: (e) => e.target === e.currentTarget && f(),
29
+ children: /* @__PURE__ */ n("div", {
30
+ class: "ck-card ck-dialog ck-settings",
31
+ role: "dialog",
32
+ "aria-modal": "true",
33
+ "aria-labelledby": "ck-settings-title",
34
+ onKeyDown: (e) => {
35
+ e.stopPropagation(), e.key === "Escape" && f();
36
+ },
37
+ children: [/* @__PURE__ */ n("div", {
38
+ class: "ck-card-head",
39
+ children: [/* @__PURE__ */ n("h2", {
40
+ class: "ck-card-title",
41
+ id: "ck-settings-title",
42
+ children: a("settings")
43
+ }), /* @__PURE__ */ n("button", {
44
+ class: "ck-ghost",
45
+ ref: b,
46
+ "aria-label": a("close"),
47
+ onClick: f,
48
+ children: /* @__PURE__ */ n(u, { name: "close" })
49
+ })]
50
+ }), /* @__PURE__ */ n("div", {
51
+ class: "ck-card-body",
52
+ children: [
53
+ v ? /* @__PURE__ */ n("section", {
54
+ class: "ck-account",
55
+ "aria-label": a("account"),
56
+ children: [/* @__PURE__ */ n(d, { person: v.person }), /* @__PURE__ */ n("div", { children: [
57
+ /* @__PURE__ */ n("bdi", {
58
+ class: "ck-msg-name",
59
+ children: v.person.name
60
+ }),
61
+ v.email ? /* @__PURE__ */ n("div", {
62
+ class: "ck-muted",
63
+ children: /* @__PURE__ */ n("bdi", { children: v.email })
64
+ }) : null,
65
+ /* @__PURE__ */ n("div", {
66
+ class: "ck-muted",
67
+ children: [
68
+ /* @__PURE__ */ n("bdi", { children: v.project.name }),
69
+ " · ",
70
+ A
71
+ ]
72
+ })
73
+ ] })]
74
+ }) : null,
75
+ /* @__PURE__ */ n("section", {
76
+ class: "ck-setting",
77
+ children: [
78
+ /* @__PURE__ */ n("h3", {
79
+ id: "ck-theme-label",
80
+ children: a("appearance")
81
+ }),
82
+ /* @__PURE__ */ n("div", {
83
+ class: "ck-segment",
84
+ role: "radiogroup",
85
+ "aria-labelledby": "ck-theme-label",
86
+ children: p.map(([e, t]) => /* @__PURE__ */ n("button", {
87
+ role: "radio",
88
+ "aria-checked": y === e,
89
+ onClick: () => D(e),
90
+ children: a(t)
91
+ }))
92
+ }),
93
+ /* @__PURE__ */ n("p", {
94
+ class: "ck-muted ck-setting-hint",
95
+ children: a("appearanceHint")
96
+ })
97
+ ]
98
+ }),
99
+ S && C?.length ? /* @__PURE__ */ n("section", {
100
+ class: "ck-setting",
101
+ children: [/* @__PURE__ */ n("h3", { children: a("team") }), /* @__PURE__ */ n("ul", {
102
+ class: "ck-team",
103
+ children: C.map((e) => /* @__PURE__ */ n("li", { children: [
104
+ /* @__PURE__ */ n("span", {
105
+ class: "ck-team-face",
106
+ children: [/* @__PURE__ */ n(d, { person: e }), x.some((t) => t.id === e.id) ? /* @__PURE__ */ n("span", {
107
+ class: "ck-online",
108
+ "aria-label": a("online")
109
+ }) : null]
110
+ }),
111
+ /* @__PURE__ */ n("bdi", { children: e.name }),
112
+ e.id === v?.person.id ? /* @__PURE__ */ n("span", {
113
+ class: "ck-muted",
114
+ children: [
115
+ "(",
116
+ a("you"),
117
+ ")"
118
+ ]
119
+ }) : null,
120
+ /* @__PURE__ */ n("span", {
121
+ class: "ck-muted ck-team-role",
122
+ children: a(`role_${e.role === "owner" ? "owner" : e.role === "admin" ? "admin" : "member"}`)
123
+ })
124
+ ] }))
125
+ })]
126
+ }) : null,
127
+ S && T ? /* @__PURE__ */ n("section", {
128
+ class: "ck-setting",
129
+ children: [/* @__PURE__ */ n("h3", { children: a("storage") }), T.limit_bytes ? /* @__PURE__ */ n(s, { children: [/* @__PURE__ */ n("div", {
130
+ class: "ck-meter",
131
+ role: "meter",
132
+ "aria-valuemin": 0,
133
+ "aria-valuemax": T.limit_bytes,
134
+ "aria-valuenow": T.used_bytes,
135
+ "aria-label": a("storage"),
136
+ children: /* @__PURE__ */ n("span", {
137
+ style: { width: `${Math.min(100, Math.round(T.used_bytes / T.limit_bytes * 100))}%` },
138
+ "data-high": T.used_bytes / T.limit_bytes > .85 || void 0
139
+ })
140
+ }), /* @__PURE__ */ n("p", {
141
+ class: "ck-muted ck-setting-hint",
142
+ children: a("storageUsed", {
143
+ used: h(T.used_bytes),
144
+ limit: h(T.limit_bytes)
145
+ })
146
+ })] }) : /* @__PURE__ */ n("p", {
147
+ class: "ck-muted ck-setting-hint",
148
+ children: a("storageUsedOnly", { used: h(T.used_bytes) })
149
+ })]
150
+ }) : null,
151
+ /* @__PURE__ */ n("nav", {
152
+ class: "ck-setting-links",
153
+ "aria-label": a("settings"),
154
+ children: [
155
+ O ? /* @__PURE__ */ n("a", {
156
+ href: O,
157
+ target: "_blank",
158
+ rel: "noopener noreferrer",
159
+ children: [/* @__PURE__ */ n(u, {
160
+ name: "link",
161
+ size: 15
162
+ }), a("openDashboard")]
163
+ }) : null,
164
+ m ? /* @__PURE__ */ n("button", {
165
+ onClick: () => (f(), m()),
166
+ children: [/* @__PURE__ */ n(u, {
167
+ name: "info",
168
+ size: 15
169
+ }), a("shortcutsTitle")]
170
+ }) : null,
171
+ /* @__PURE__ */ n("button", {
172
+ onClick: g,
173
+ children: [/* @__PURE__ */ n(u, {
174
+ name: "close",
175
+ size: 15
176
+ }), a("hideWidget")]
177
+ }),
178
+ v ? /* @__PURE__ */ n("button", {
179
+ class: "ck-danger",
180
+ onClick: () => (f(), _()),
181
+ children: [/* @__PURE__ */ n(u, {
182
+ name: "user",
183
+ size: 15
184
+ }), a("signOut")]
185
+ }) : null
186
+ ]
187
+ })
188
+ ]
189
+ })]
190
+ })
191
+ });
192
+ }
193
+ function h(e) {
194
+ let [t, n] = e >= 1e9 ? [e / 1e9, "gigabyte"] : e >= 1e6 ? [e / 1e6, "megabyte"] : [e / 1e3, "kilobyte"];
195
+ try {
196
+ return new Intl.NumberFormat(i(), {
197
+ style: "unit",
198
+ unit: n,
199
+ maximumFractionDigits: +(t < 10)
200
+ }).format(t);
201
+ } catch {
202
+ return `${t.toFixed(1)} ${n === "gigabyte" ? "GB" : n === "megabyte" ? "MB" : "KB"}`;
203
+ }
204
+ }
205
+ //#endregion
206
+ export { m as Settings };
@@ -1,18 +1,22 @@
1
- import { o as e } from "./src-C1Qp94nr.js";
2
- import { d as t, f as n, n as r, p as i } from "./format-B5tJGtPC.js";
1
+ import { f as e, l as t, s as n, u as r } from "./i18n-DAJGndZ2.js";
2
+ import { d as i, n as a } from "./start-DW9_DKmf.js";
3
+ //#endregion
3
4
  //#region src/ui/Shortcuts.tsx
4
- var a = [
5
+ a(".ck-keys{gap:10px;margin:0;display:grid}.ck-keys div{grid-template-columns:minmax(96px,auto) 1fr;align-items:baseline;gap:12px;display:grid}.ck-keys dd{color:var(--ck-text-muted);margin:0}");
6
+ var o = [
5
7
  ["C", "shortcutComment"],
6
8
  ["J / K", "shortcutNext"],
7
9
  ["E", "shortcutResolve"],
8
10
  ["Esc", "shortcutClose"],
9
- ["⌘ / Ctrl + Enter", "shortcutSend"],
11
+ ["Enter", "shortcutSend"],
12
+ ["Shift + Enter", "shortcutNewLine"],
13
+ ["⌘ / Ctrl + B · I · E", "shortcutFormat"],
10
14
  ["⌘ / Ctrl + Shift + K", "shortcutToggle"],
11
15
  ["?", "shortcutHelp"]
12
16
  ];
13
- function o({ onClose: o }) {
14
- let s = i(null);
15
- return n(() => {
17
+ function s({ onClose: a }) {
18
+ let s = e(null);
19
+ return r(() => {
16
20
  let e = s.current?.getRootNode()?.activeElement ?? document.activeElement;
17
21
  return s.current?.focus({ preventScroll: !0 }), () => {
18
22
  e instanceof HTMLElement && e.isConnected && e.focus({ preventScroll: !0 });
@@ -20,37 +24,37 @@ function o({ onClose: o }) {
20
24
  }, []), /* @__PURE__ */ t("div", {
21
25
  class: "ck-scrim",
22
26
  "data-commentkit-ui": !0,
23
- onClick: (e) => e.target === e.currentTarget && o(),
27
+ onClick: (e) => e.target === e.currentTarget && a(),
24
28
  children: /* @__PURE__ */ t("div", {
25
29
  class: "ck-card ck-dialog",
26
30
  role: "dialog",
27
31
  "aria-modal": "true",
28
32
  "aria-labelledby": "ck-shortcuts-title",
29
33
  onKeyDown: (e) => {
30
- e.stopPropagation(), e.key === "Escape" || e.key === "?" ? (e.preventDefault(), o()) : e.key === "Tab" && (e.preventDefault(), s.current?.focus());
34
+ e.stopPropagation(), e.key === "Escape" || e.key === "?" ? (e.preventDefault(), a()) : e.key === "Tab" && (e.preventDefault(), s.current?.focus());
31
35
  },
32
36
  children: [/* @__PURE__ */ t("div", {
33
37
  class: "ck-card-head",
34
38
  children: [/* @__PURE__ */ t("h2", {
35
39
  class: "ck-card-title",
36
40
  id: "ck-shortcuts-title",
37
- children: e("shortcutsTitle")
41
+ children: n("shortcutsTitle")
38
42
  }), /* @__PURE__ */ t("button", {
39
43
  class: "ck-ghost",
40
44
  ref: s,
41
- "aria-label": e("close"),
42
- onClick: o,
43
- children: /* @__PURE__ */ t(r, { name: "close" })
45
+ "aria-label": n("close"),
46
+ onClick: a,
47
+ children: /* @__PURE__ */ t(i, { name: "close" })
44
48
  })]
45
49
  }), /* @__PURE__ */ t("dl", {
46
50
  class: "ck-card-body ck-keys",
47
- children: a.map(([n, r]) => /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ t("dt", { children: /* @__PURE__ */ t("kbd", {
51
+ children: o.map(([e, r]) => /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ t("dt", { children: /* @__PURE__ */ t("kbd", {
48
52
  dir: "ltr",
49
- children: n
50
- }) }), /* @__PURE__ */ t("dd", { children: e(r) })] }))
53
+ children: e
54
+ }) }), /* @__PURE__ */ t("dd", { children: n(r) })] }))
51
55
  })]
52
56
  })
53
57
  });
54
58
  }
55
59
  //#endregion
56
- export { o as Shortcuts };
60
+ export { s as Shortcuts };
@@ -0,0 +1,44 @@
1
+ import { d as e, f as t, l as n, m as r, s as i } from "./i18n-DAJGndZ2.js";
2
+ import { a, i as o, o as s } from "./uploads-CipONvCy.js";
3
+ import { StylePanel as c } from "./StylePanel-BI-n5Me1.js";
4
+ //#region src/ui/StyleEditor.tsx
5
+ function l({ client: l, thread: u, element: d, onSaved: f, onClose: p, onError: m }) {
6
+ let [h] = r(() => {
7
+ let e = s(d);
8
+ for (let t of a(u.style_changes)) t.from && (e[t.property] = t.from);
9
+ return e;
10
+ }), [g, _] = r(() => a(u.style_changes)), [v, y] = r(!1), b = t(null);
11
+ e(() => {
12
+ let e = new o(d);
13
+ return b.current = e, () => e.revert();
14
+ }, [d]), e(() => b.current?.apply(g), [g]);
15
+ let x = async () => {
16
+ y(!0);
17
+ try {
18
+ f(await l.updateThread(u.id, { style_changes: a(g) })), p();
19
+ } catch (e) {
20
+ y(!1), m(e);
21
+ }
22
+ };
23
+ return /* @__PURE__ */ n(c, {
24
+ base: h,
25
+ changes: g,
26
+ onChange: _,
27
+ onClose: p,
28
+ actions: /* @__PURE__ */ n("span", {
29
+ class: "ck-style-actions",
30
+ children: [/* @__PURE__ */ n("button", {
31
+ class: "ck-ghost ck-ghost-sm",
32
+ onClick: p,
33
+ children: i("cancel")
34
+ }), /* @__PURE__ */ n("button", {
35
+ class: "ck-btn ck-primary ck-style-done",
36
+ disabled: v,
37
+ onClick: () => void x(),
38
+ children: i("save")
39
+ })]
40
+ })
41
+ });
42
+ }
43
+ //#endregion
44
+ export { l as StyleEditor };
@@ -0,0 +1,199 @@
1
+ import { l as e, m as t, s as n, u as r, v as i } from "./i18n-DAJGndZ2.js";
2
+ import { r as a, s as o } from "./uploads-CipONvCy.js";
3
+ import { n as s } from "./start-DW9_DKmf.js";
4
+ //#endregion
5
+ //#region src/ui/StylePanel.tsx
6
+ s(".ck-style-panel{border-radius:var(--ck-radius-md);background:var(--ck-bg-muted);box-shadow:0 0 0 1px var(--ck-hairline);margin-top:8px;padding:8px 10px 10px}.ck-style-head{justify-content:space-between;align-items:center;gap:8px;font-size:13px;display:flex}.ck-style-done{height:26px;padding:0 10px;font-size:12px}.ck-style-actions{align-items:center;gap:4px;display:flex}.ck-style-hint{margin:4px 0 6px;font-size:12px;line-height:1.4}.ck-style-rows{overscroll-behavior:contain;gap:2px;max-height:236px;margin-inline-start:-4px;margin-inline-end:-4px;padding-inline-start:4px;padding-inline-end:4px;display:grid;overflow:auto}.ck-style-row{border-radius:var(--ck-radius-sm);grid-template-columns:minmax(96px,40%) 1fr;align-items:center;column-gap:8px;min-height:30px;padding:2px 4px;display:grid}.ck-style-row[data-changed]{background:color-mix(in srgb, var(--ck-accent) 10%, transparent)}.ck-style-row .ck-error{grid-column:2}.ck-style-name{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--ck-text-muted);font-size:12px;overflow:hidden}.ck-style-name code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px}.ck-style-row[data-changed] .ck-style-name{color:var(--ck-text)}.ck-style-control{align-items:center;gap:2px;min-width:0;display:flex}.ck-style-control .ck-style-input{flex:1;width:auto;min-width:0;height:26px;padding:0 7px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}.ck-style-control .ck-style-input[aria-invalid=true]{border-color:var(--ck-danger)}.ck-style-control .ck-ghost{flex:none;place-items:center;width:22px;height:22px;min-height:0;padding:0;font-size:14px;line-height:1;display:grid}.ck-style-steps{flex:none;display:flex}.ck-style-swatch{width:18px;height:18px;box-shadow:inset 0 0 0 1px var(--ck-hairline), 0 0 0 1px var(--ck-border);border-radius:50%;flex:none;margin-inline-end:4px}@media (pointer:coarse){.ck-style-control .ck-style-input{height:32px;font-size:16px}.ck-style-control .ck-ghost{width:30px;height:30px}}");
7
+ function c({ base: t, changes: r, onChange: i, onClose: o, actions: s }) {
8
+ let c = (e, n) => {
9
+ let a = r.filter((t) => t.property !== e);
10
+ if (n !== null && n === t[e]) return i(a);
11
+ let o = {
12
+ property: e,
13
+ from: t[e] || null,
14
+ to: n
15
+ }, s = r.findIndex((t) => t.property === e);
16
+ i(s === -1 ? [...r, o] : r.map((e, t) => t === s ? o : e));
17
+ };
18
+ return /* @__PURE__ */ e("div", {
19
+ class: "ck-style-panel",
20
+ role: "group",
21
+ "aria-label": n("adjustStyle"),
22
+ onKeyDown: (e) => {
23
+ e.stopPropagation(), e.key === "Escape" && o();
24
+ },
25
+ children: [
26
+ /* @__PURE__ */ e("div", {
27
+ class: "ck-style-head",
28
+ children: [/* @__PURE__ */ e("strong", { children: n("adjustStyle") }), s ?? /* @__PURE__ */ e("button", {
29
+ class: "ck-btn ck-style-done",
30
+ onClick: o,
31
+ children: n("styleDone")
32
+ })]
33
+ }),
34
+ /* @__PURE__ */ e("p", {
35
+ class: "ck-muted ck-style-hint",
36
+ children: n("adjustStyleHint")
37
+ }),
38
+ /* @__PURE__ */ e("div", {
39
+ class: "ck-style-rows",
40
+ children: a.map(({ property: n, kind: a, options: o }) => {
41
+ let s = r.find((e) => e.property === n);
42
+ return /* @__PURE__ */ e(l, {
43
+ property: n,
44
+ kind: a,
45
+ options: o,
46
+ base: t[n] ?? "",
47
+ value: s ? s.to : t[n] ?? "",
48
+ changed: !!s,
49
+ onSet: (e) => c(n, e),
50
+ onReset: () => i(r.filter((e) => e.property !== n))
51
+ }, n);
52
+ })
53
+ })
54
+ ]
55
+ });
56
+ }
57
+ function l({ property: a, kind: s, options: c, base: l, value: f, changed: p, onSet: m, onReset: h }) {
58
+ let [g, _] = t(f ?? ""), [v, y] = t(!1);
59
+ r(() => {
60
+ _(f ?? ""), y(!1);
61
+ }, [f]);
62
+ let b = `ck-style-${a}`, x = (e) => {
63
+ let t = e.trim();
64
+ _(e);
65
+ let n = t !== "" && o(t);
66
+ y(t !== "" && !n), n && m(t);
67
+ }, S = (e, t = !1) => {
68
+ let n = s === "choice" ? d(c ?? [], f ?? l, e) : u(a, f ?? l, e * (t ? 10 : 1));
69
+ n !== null && m(n);
70
+ };
71
+ return /* @__PURE__ */ e("div", {
72
+ class: "ck-style-row",
73
+ "data-changed": p || void 0,
74
+ children: [
75
+ /* @__PURE__ */ e("label", {
76
+ for: b,
77
+ class: "ck-style-name",
78
+ children: /* @__PURE__ */ e("code", { children: a })
79
+ }),
80
+ /* @__PURE__ */ e("div", {
81
+ class: "ck-style-control",
82
+ children: [
83
+ /* @__PURE__ */ e(i, { children: [
84
+ s === "color" ? /* @__PURE__ */ e("span", {
85
+ class: "ck-style-swatch",
86
+ "aria-hidden": "true",
87
+ style: { backgroundColor: f ?? l ?? "transparent" }
88
+ }) : null,
89
+ /* @__PURE__ */ e("input", {
90
+ id: b,
91
+ class: "ck-input ck-style-input",
92
+ type: "text",
93
+ spellcheck: !1,
94
+ autoComplete: "off",
95
+ maxLength: 120,
96
+ value: g,
97
+ placeholder: f === null ? n("styleRemoved") : "",
98
+ "aria-invalid": v,
99
+ "aria-describedby": v ? `${b}-error` : void 0,
100
+ onInput: (e) => x(e.target.value),
101
+ onKeyDown: (e) => {
102
+ s !== "color" && s !== "box" && (e.key === "ArrowUp" || e.key === "ArrowDown") && (e.preventDefault(), S(e.key === "ArrowUp" ? 1 : -1, e.shiftKey));
103
+ }
104
+ }),
105
+ s === "length" || s === "number" ? /* @__PURE__ */ e("span", {
106
+ class: "ck-style-steps",
107
+ children: [/* @__PURE__ */ e("button", {
108
+ class: "ck-ghost ck-ghost-sm",
109
+ "aria-label": n("styleDecrease", { property: a }),
110
+ onClick: () => S(-1),
111
+ children: "−"
112
+ }), /* @__PURE__ */ e("button", {
113
+ class: "ck-ghost ck-ghost-sm",
114
+ "aria-label": n("styleIncrease", { property: a }),
115
+ onClick: () => S(1),
116
+ children: "+"
117
+ })]
118
+ }) : s === "choice" ? /* @__PURE__ */ e("span", {
119
+ class: "ck-style-steps",
120
+ children: [/* @__PURE__ */ e("button", {
121
+ class: "ck-ghost ck-ghost-sm",
122
+ "aria-label": n("stylePrevious", { property: a }),
123
+ onClick: () => S(-1),
124
+ children: "‹"
125
+ }), /* @__PURE__ */ e("button", {
126
+ class: "ck-ghost ck-ghost-sm",
127
+ "aria-label": n("styleNext", { property: a }),
128
+ onClick: () => S(1),
129
+ children: "›"
130
+ })]
131
+ }) : null
132
+ ] }),
133
+ p ? /* @__PURE__ */ e("button", {
134
+ class: "ck-ghost ck-ghost-sm",
135
+ "aria-label": n("styleReset", { property: a }),
136
+ title: n("styleReset", { property: a }),
137
+ onClick: h,
138
+ children: /* @__PURE__ */ e("svg", {
139
+ width: "13",
140
+ height: "13",
141
+ viewBox: "0 0 24 24",
142
+ fill: "none",
143
+ stroke: "currentColor",
144
+ "stroke-width": "2.2",
145
+ "stroke-linecap": "round",
146
+ "stroke-linejoin": "round",
147
+ "aria-hidden": "true",
148
+ children: /* @__PURE__ */ e("path", { d: "M4 9h11a5 5 0 0 1 0 10H9M8 5L4 9l4 4" })
149
+ })
150
+ }) : null,
151
+ f === null ? null : /* @__PURE__ */ e("button", {
152
+ class: "ck-ghost ck-ghost-sm",
153
+ "aria-label": n("styleRemoveValue", { property: a }),
154
+ title: n("styleRemoveValue", { property: a }),
155
+ onClick: () => m(null),
156
+ children: /* @__PURE__ */ e("svg", {
157
+ width: "12",
158
+ height: "12",
159
+ viewBox: "0 0 24 24",
160
+ fill: "none",
161
+ stroke: "currentColor",
162
+ "stroke-width": "2.2",
163
+ "stroke-linecap": "round",
164
+ "aria-hidden": "true",
165
+ children: /* @__PURE__ */ e("path", { d: "M6 6l12 12M18 6L6 18" })
166
+ })
167
+ })
168
+ ]
169
+ }),
170
+ v ? /* @__PURE__ */ e("span", {
171
+ class: "ck-error",
172
+ id: `${b}-error`,
173
+ role: "alert",
174
+ children: n("styleInvalid")
175
+ }) : null
176
+ ]
177
+ });
178
+ }
179
+ function u(e, t, n) {
180
+ let r = t === "normal" || t === "" ? e === "font-weight" ? "400" : e === "letter-spacing" ? "0px" : null : t === "bold" ? "700" : t, i = r ? /^(-?\d*\.?\d+)([a-z%]*)$/i.exec(r) : null;
181
+ if (!i) return null;
182
+ let [, a, o = ""] = i, s = e === "opacity" ? .05 : e === "font-weight" ? 100 : /^r?em$/i.test(o) || e === "line-height" && o === "" ? .05 : 1, c = Number(a) + n * s;
183
+ return e === "opacity" && (c = Math.min(1, Math.max(0, c))), e === "font-weight" && (c = Math.min(900, Math.max(100, c))), [
184
+ "font-size",
185
+ "border-width",
186
+ "border-radius",
187
+ "width",
188
+ "height",
189
+ "gap",
190
+ "line-height"
191
+ ].includes(e) && (c = Math.max(0, c)), `${Math.round(c * 100) / 100}${o}`;
192
+ }
193
+ function d(e, t, n) {
194
+ if (!e.length) return null;
195
+ let r = e.indexOf(t);
196
+ return r === -1 ? n === 1 ? e[0] : e[e.length - 1] : e[(r + n + e.length) % e.length];
197
+ }
198
+ //#endregion
199
+ export { c as StylePanel };