@commentkit/comment-kit 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +123 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/node/cli/api.js +61 -15
  5. package/dist/node/cli/credentials.js +8 -0
  6. package/dist/node/cli/doctor.js +152 -25
  7. package/dist/node/cli/init.js +349 -35
  8. package/dist/node/cli/main.js +310 -69
  9. package/dist/node/cli/mcp.js +187 -6
  10. package/dist/node/cli/website.js +140 -0
  11. package/dist/node/shared/dashboard-places.js +33 -0
  12. package/dist/node/types/next.d.ts +4 -4
  13. package/dist/npm/THIRD_PARTY_NOTICES.txt +47 -0
  14. package/dist/npm/chunks/{AgentSend-DxRJIYiz.js → AgentSend-pA7Ufvye.js} +16 -16
  15. package/dist/npm/chunks/Checklist-Cn9skOYK.js +269 -0
  16. package/dist/npm/chunks/Composer-D7H-pzGa.js +734 -0
  17. package/dist/npm/chunks/DatePicker-Nta5a1xD.js +161 -0
  18. package/dist/npm/chunks/{Guest-vvNPz8h-.js → Guest-Bi7hlzhs.js} +63 -59
  19. package/dist/npm/chunks/{MarkupEditor-VCOXh9d2.js → MarkupEditor-WU3USeTk.js} +46 -39
  20. package/dist/npm/chunks/Panel-DhAzbUbC.js +1210 -0
  21. package/dist/npm/chunks/{Settings-BGoZS2iV.js → Settings-BmKqPX40.js} +91 -90
  22. package/dist/npm/chunks/{Shortcuts-B2OMvczr.js → Shortcuts-Bl-c0Sez.js} +25 -23
  23. package/dist/npm/chunks/SignInFirst-CmGvSYkQ.js +35 -0
  24. package/dist/npm/chunks/{StyleEditor-CJ_d8Huf.js → StyleEditor-D6fUnlwq.js} +10 -10
  25. package/dist/npm/chunks/{StylePanel-yQzHHlY7.js → StylePanel-C-Gikxt1.js} +61 -61
  26. package/dist/npm/chunks/TaskFields-CaKi523b.js +617 -0
  27. package/dist/npm/chunks/ThreadCard-d_3pUB5V.js +1142 -0
  28. package/dist/npm/chunks/Viewer-BULQsi9-.js +115 -0
  29. package/dist/npm/chunks/{agent-C1OQzBAm.js → agent-DHdhIJ3s.js} +1 -1
  30. package/dist/npm/chunks/{ar-CAJ3XT8e.js → ar-B5UszrQp.js} +53 -12
  31. package/dist/npm/chunks/card-bits-cV8GdFWX.js +55 -0
  32. package/dist/npm/chunks/{client-kNAo2TTG.js → client-Cv8ddtuM.js} +13 -11
  33. package/dist/npm/chunks/{confetti-CkBdSu19.js → confetti-B9zlyILU.js} +1 -1
  34. package/dist/npm/chunks/{context-B8UAzve0.js → context-CsHnabaA.js} +1 -1
  35. package/dist/npm/chunks/{de-Dl18G48t.js → de-BE0Aaq8u.js} +53 -12
  36. package/dist/npm/chunks/{dialog-GO04oC3D.js → dialog-DvdIkCW0.js} +1 -1
  37. package/dist/npm/chunks/{dpop-U48QIQd7.js → dpop-CwW9ifkq.js} +1 -1
  38. package/dist/npm/chunks/entrance-Bn_5M9uO.js +90 -0
  39. package/dist/npm/chunks/{es-Dxk79lS9.js → es-BQviao4d.js} +53 -12
  40. package/dist/npm/chunks/{extension-E81hWyiT.js → extension-CnQTDC1j.js} +2 -2
  41. package/dist/npm/chunks/{extension-CKFpPWmi.js → extension-DXhz81XD.js} +1 -1
  42. package/dist/npm/chunks/{files-DyD5BZgp.js → files-DLEr_wmh.js} +2 -2
  43. package/dist/npm/chunks/{fr-8BebGKYD.js → fr-C5gu6A06.js} +53 -12
  44. package/dist/npm/chunks/{hi-BIN6Yy_p.js → hi-DXfQ5EvY.js} +53 -12
  45. package/dist/npm/chunks/{i18n-DOBt8e9U.js → i18n-Mgs9VOuk.js} +63 -58
  46. package/dist/npm/chunks/icons-_C6ZWmBY.js +141 -0
  47. package/dist/npm/chunks/{identify-CN-3xzqL.js → identify-BnQGJOa0.js} +4 -4
  48. package/dist/npm/chunks/{it-Cr6EwpPQ.js → it-BPHt13FV.js} +53 -12
  49. package/dist/npm/chunks/{ja-Iy3s5aur.js → ja-BkCqyKR0.js} +52 -11
  50. package/dist/npm/chunks/late-words-D4Oo_yhJ.js +57 -0
  51. package/dist/npm/chunks/{live-CelVeZfP.js → live-DXcxj_Af.js} +28 -22
  52. package/dist/npm/chunks/{nl-B84WHqqe.js → nl-DZxdLLMU.js} +53 -12
  53. package/dist/npm/chunks/{page-key-DepmJzC1.js → page-key-UqAozdZi.js} +1 -1
  54. package/dist/npm/chunks/{pick-yTyqtxN0.js → pick-C20RVUas.js} +1 -1
  55. package/dist/npm/chunks/{pkce-ChKGSW_4.js → pkce-BPvWoBrr.js} +1 -1
  56. package/dist/npm/chunks/{pt-BR-DOkdlfoe.js → pt-BR-lA9mJ05F.js} +53 -12
  57. package/dist/npm/chunks/{report-CrIqQZDI.js → report-BjUgUNnT.js} +1 -1
  58. package/dist/npm/chunks/show-BinoJyED.js +97 -0
  59. package/dist/npm/chunks/signin-C2jjsxz9.js +101 -0
  60. package/dist/npm/chunks/{source-pXVve2Cx.js → source-NuflODx3.js} +1 -1
  61. package/dist/npm/chunks/src-9o2Ocq8d.js +221 -0
  62. package/dist/npm/chunks/start-Cbx6rMrr.js +1904 -0
  63. package/dist/npm/chunks/states-DLMCvwes.js +3 -0
  64. package/dist/npm/chunks/{upload-MgPYqPyE.js → upload-C4NpM-jE.js} +1 -1
  65. package/dist/npm/chunks/uploads-CY4bDbaI.js +1236 -0
  66. package/dist/npm/chunks/{wrap-Bl0gbnFa.js → wrap-D-xTKIzj.js} +20 -20
  67. package/dist/npm/chunks/{zh-CN-Z5fQCb7G.js → zh-CN-yqaDHwBx.js} +53 -12
  68. package/dist/npm/element.js +7 -1
  69. package/dist/npm/headless.js +2 -2
  70. package/dist/npm/index.js +2 -2
  71. package/dist/npm/react.js +1 -1
  72. package/dist/npm/svelte.js +1 -1
  73. package/dist/npm/types/adapters/vue.d.ts +12 -0
  74. package/dist/npm/types/core/auth.d.ts +1 -0
  75. package/dist/npm/types/core/client.d.ts +5 -1
  76. package/dist/npm/types/core/types.d.ts +19 -4
  77. package/dist/npm/vue.js +5 -1
  78. package/package.json +4 -1
  79. package/dist/npm/chunks/Checklist-CnlfeSbc.js +0 -282
  80. package/dist/npm/chunks/Composer-B1bBVszY.js +0 -725
  81. package/dist/npm/chunks/Panel-F37vIL1K.js +0 -1206
  82. package/dist/npm/chunks/TaskFields-fmy6_HtK.js +0 -289
  83. package/dist/npm/chunks/ThreadCard-D51slKST.js +0 -1113
  84. package/dist/npm/chunks/Viewer-BOBadqmC.js +0 -111
  85. package/dist/npm/chunks/card-bits-CAnzrqx3.js +0 -53
  86. package/dist/npm/chunks/late-words-B2bmZceJ.js +0 -12
  87. package/dist/npm/chunks/show-BgVC8gWY.js +0 -97
  88. package/dist/npm/chunks/signin-Dd1rb2BP.js +0 -75
  89. package/dist/npm/chunks/src-BTMy4Gyc.js +0 -208
  90. package/dist/npm/chunks/start-DtVlpt7p.js +0 -1878
  91. package/dist/npm/chunks/states-sfTbjZz8.js +0 -3
  92. package/dist/npm/chunks/uploads-D49mywwz.js +0 -1146
@@ -0,0 +1,97 @@
1
+ import { a as e, i as t, n, o as r, r as i } from "./src-9o2Ocq8d.js";
2
+ import { i as a, l as o, v as s } from "./client-Cv8ddtuM.js";
3
+ import { n as c } from "./page-key-UqAozdZi.js";
4
+ // src/core/show.ts
5
+ var l;
6
+ function u() {
7
+ if (/[?&]ck(_thread)?(=|&|$)/.test(location.search)) return !0;
8
+ try {
9
+ return !!sessionStorage.getItem("commentkit:share");
10
+ } catch {
11
+ return !1;
12
+ }
13
+ }
14
+ o(c);
15
+ var d = (e) => e.disabled_reason === "version_blocked", f = (e) => e.disabled_reason === "not_live", p = (e) => {
16
+ let t = e.state.get().session;
17
+ return !!t && t.role !== "guest";
18
+ };
19
+ async function m(i, a, o, s, m, v, y = () => void 0) {
20
+ let b = (l ?? (l = u())) || o;
21
+ if (d(a)) return y(), null;
22
+ let x = f(a);
23
+ if (x && !i.auth.hasSession() && !e()) return y(), null;
24
+ if (!a.enabled && !b && !x) return null;
25
+ c.ignore(a.pages?.ignored_query_params);
26
+ let S = n(() => import("./start-Cbx6rMrr.js").then((e) => e.t)), C = S.then((e) => e.setLocale(i.options.locale));
27
+ if (S.catch(() => void 0), C.catch(() => void 0), await i.auth.completeRedirect().catch(() => !1), e() && await import("./extension-CnQTDC1j.js").then((e) => e.extensionHandoff(i.auth)).catch(() => !1), v && a.enabled && await import("./identify-BnQGJOa0.js").then((e) => e.identify(i, v, null, !0)).catch(() => !1), await i.loadSession().catch(() => null), i.state.get().session || h(i.options.project), x && !p(i)) return y(), null;
28
+ let w = await S, { installDiagnostics: T, mountWidget: E } = w;
29
+ if (x && Object.assign(w.en, (await import("./late-words-D4Oo_yhJ.js").then((e) => e.n)).LATE), await C, s()) return null;
30
+ let D = T({
31
+ console: a.features.console_capture,
32
+ network: a.features.network_capture,
33
+ endpoint: i.endpoint
34
+ }), O = () => {
35
+ m(), r(!1);
36
+ }, k;
37
+ try {
38
+ k = E(i, () => (g([t() + 1, Date.now()]), O()), O);
39
+ } catch (e) {
40
+ throw D(), e;
41
+ }
42
+ let A = setTimeout(g, 3e4, null), j = _(i, b, m, y), M = i.state.get().config, N = i.state.subscribe((e) => {
43
+ e.config && e.config !== M && c.ignore((M = e.config).pages?.ignored_query_params);
44
+ });
45
+ return i.emit("ready", { session: i.state.get().session }), Object.assign(() => {
46
+ clearTimeout(A), j(), N();
47
+ for (let e of [k, D]) try {
48
+ e();
49
+ } catch (e) {
50
+ console.warn("[CommentKit] hide() failed.", e);
51
+ }
52
+ }, { attach: () => k.attach?.() });
53
+ }
54
+ function h(e) {
55
+ let t = `commentkit:draft:v2:${e}:`;
56
+ try {
57
+ for (let e = localStorage.length - 1; e >= 0; e--) {
58
+ let n = localStorage.key(e);
59
+ n?.startsWith(t) && n.includes("~", t.length) && localStorage.removeItem(n);
60
+ }
61
+ } catch {}
62
+ }
63
+ function g(e) {
64
+ try {
65
+ e ? localStorage.setItem(i, JSON.stringify(e)) : localStorage.removeItem(i);
66
+ } catch {}
67
+ }
68
+ function _(e, t, n, r) {
69
+ let i = Date.now(), a = () => {
70
+ document.visibilityState === "hidden" || Date.now() - i < 15e3 || (i = Date.now(), e.loadConfig().then((i) => {
71
+ d(i) || f(i) && !p(e) ? (n(), r()) : i.enabled || t || f(i) || n();
72
+ }, () => void 0));
73
+ }, o = setInterval(a, 6e4);
74
+ return document.addEventListener("visibilitychange", a), () => {
75
+ clearInterval(o), document.removeEventListener("visibilitychange", a);
76
+ };
77
+ }
78
+ function v(e, t) {
79
+ let n = e.state.get().config;
80
+ if (n && (d(n) || f(n))) return;
81
+ let r = t instanceof s;
82
+ console.warn(r ? `[CommentKit] The widget could not start: ${t.message} (${t.code}). See https://commentkit.dev/docs/errors#${t.code}` : "[CommentKit] The widget could not start; your page is not affected. See https://commentkit.dev/docs/troubleshooting", t), r && e.emit("error", { error: t }), (!r || t.status >= 500) && e.reportCrash(t, "start");
83
+ }
84
+ function y(e, t) {
85
+ import("./report-BjUgUNnT.js").then((n) => n.reportStart(e, t)).catch(() => void 0);
86
+ }
87
+ var b = "See https://commentkit.dev/docs/";
88
+ function x(e, ...t) {
89
+ let [n, r] = t, i = {
90
+ key: `init() needs your publishable project key, which starts with pk_live_ or pk_test_ (${n ? "the one given is not one" : "none was given"}), so the widget stays off. Copy it from the website's Settings → Install in CommentKit and pass it as init({ project: "pk_live_…" }) or data-project="pk_live_…". ${b}quickstart`,
91
+ copy: `CommentKit was added twice: version ${String(n)} is already running on this page, so this copy (${a}) stays off. Add it once, with either the npm package or the script tag, not both. ${b}troubleshooting`,
92
+ project: `init() was called again with another project (${String(n)}) while ${String(r)} is running; the first one stays. Call destroy() on every handle of the first one before starting another project. ${b}troubleshooting`,
93
+ cooling: `The widget is hidden for a few hours on this browser after 3 crashes in a row. Cmd/Ctrl+Shift+K or show() brings it back now. ${b}troubleshooting`
94
+ };
95
+ console.warn(`[CommentKit] ${i[e]}`);
96
+ }
97
+ export { x as explain, v as failed, h as forgetSignedIn, m as mount, y as reportStart };
@@ -0,0 +1,101 @@
1
+ import { b as e } from "./client-Cv8ddtuM.js";
2
+ import { r as t } from "./page-key-UqAozdZi.js";
3
+ import { t as n } from "./pkce-BPvWoBrr.js";
4
+ import { t as r } from "./locale-D8Q4Q2Nt.js";
5
+ // src/core/signin.ts
6
+ function i(e = navigator.userAgent) {
7
+ return /FBAN|FBAV|Instagram|Line\/|WhatsApp|Snapchat|LinkedInApp|Slack|Twitter|MicroMessenger|; wv\)|GSA\//i.test(e);
8
+ }
9
+ var a = "popup=yes,width=460,height=680,left=120,top=80", o = 100, s = 500, c = 6e5, l = (e) => `commentkit:pkce:${e.projectKey}`;
10
+ function u() {
11
+ return (document.querySelector("[data-commentkit-host]")?.shadowRoot?.querySelector(".ck-root"))?.getAttribute("lang") || r();
12
+ }
13
+ var d = null, f = !1, p = !1;
14
+ function m() {
15
+ if (f || window.crossOriginIsolated) return Promise.resolve(!0);
16
+ let e = location.href.split("#")[0];
17
+ return d?.[0] !== e && (d = [e, fetch(e, {
18
+ method: "HEAD",
19
+ credentials: "same-origin",
20
+ cache: "no-store"
21
+ }).then((e) => /^same-origin(;|$)/i.test((e.headers.get("cross-origin-opener-policy") ?? "").replace(/\s/g, ""))).catch(() => !1)]), d[1];
22
+ }
23
+ function h() {
24
+ p || (p = !0, console.warn("[CommentKit] Sign-in cannot use a popup on this page: it is sent with \"Cross-Origin-Opener-Policy: same-origin\", which cuts the sign-in window off from it. Use auth: \"redirect\" (data-auth=\"redirect\"), leave auth unset (\"auto\" signs in on the same tab here), or send \"Cross-Origin-Opener-Policy: same-origin-allow-popups\"."));
25
+ }
26
+ async function g(t, r) {
27
+ let o = e(48), c = e(24), l = r.mode ?? "auto", d = l === "auto" && !i() ? Promise.race([m(), new Promise((e) => setTimeout(e, s, !1))]) : null, p = await n(o), g = l === "redirect" || l === "auto" && (i() || await d), _ = t.signInLink, S = u(), C = v(t, p, c, r.share ?? null, g ? location.href : null, _, S);
28
+ if (g) return t.signInLink = null, y(t, C, o, c);
29
+ let w = window.open(C.toString(), "commentkit-signin", a);
30
+ if (!w) return l === "auto" ? (t.signInLink = null, y(t, v(t, p, c, r.share ?? null, location.href, _, S), o, c)) : "popup_blocked";
31
+ t.signInLink = null;
32
+ let T = await x(t, w, c, r.signal);
33
+ return T === b ? (f = !0, l === "auto" ? y(t, v(t, p, c, r.share ?? null, location.href, _, S), o, c) : (h(), "cancelled")) : T ? await t.exchange(T, o) ? "signed_in" : "failed" : "cancelled";
34
+ }
35
+ async function _(e) {
36
+ let n = new URL(location.href), r = n.searchParams.get("ck_code"), i = n.searchParams.get("ck_state");
37
+ if (!r || !i) return !1;
38
+ history.replaceState(history.state, "", t(location.href, /^ck_(code|state)$/));
39
+ let a = null;
40
+ try {
41
+ a = JSON.parse(sessionStorage.getItem(l(e)) ?? "null"), sessionStorage.removeItem(l(e));
42
+ } catch {
43
+ return !1;
44
+ }
45
+ return !a?.verifier || a.state !== i ? !1 : e.exchange(r, a.verifier);
46
+ }
47
+ function v(e, t, n, r, i, a = null, o = u()) {
48
+ let s = new URL(e.authorize ?? "/widget/connect", e.endpoint), c = a ? new URL("guest", s) : s;
49
+ return c.search = new URLSearchParams({
50
+ key: e.projectKey,
51
+ origin: e.origin,
52
+ code_challenge: t,
53
+ code_challenge_method: "S256",
54
+ state: n,
55
+ locale: o,
56
+ ...r ? { share: r } : {},
57
+ ...i ? { return_to: i } : {}
58
+ }).toString(), a && (c.hash = `signin=${encodeURIComponent(a)}`), c;
59
+ }
60
+ function y(e, t, n, r) {
61
+ try {
62
+ sessionStorage.setItem(l(e), JSON.stringify({
63
+ verifier: n,
64
+ state: r
65
+ }));
66
+ } catch {
67
+ return "failed";
68
+ }
69
+ return location.assign(t.toString()), "redirecting";
70
+ }
71
+ var b = Symbol();
72
+ function x(e, t, n, r) {
73
+ let i = [new URL(e.endpoint).origin, new URL(e.authorize ?? e.endpoint).origin];
74
+ return new Promise((e) => {
75
+ let a = !1, s = Date.now(), l = (t) => {
76
+ a || (a = !0, window.removeEventListener("message", d), r?.removeEventListener("abort", u), clearInterval(m), e(t));
77
+ }, u = () => {
78
+ try {
79
+ t.close();
80
+ } catch {}
81
+ l(null);
82
+ }, d = (e) => {
83
+ if (e.source !== t || !i.includes(e.origin)) return;
84
+ let r = e.data;
85
+ r?.type === "commentkit:auth" && r.state === n && typeof r.code == "string" && l(r.code);
86
+ };
87
+ window.addEventListener("message", d);
88
+ let f = null, p = !1, m = setInterval(() => {
89
+ if (Date.now() - s > c) return l(null);
90
+ if (t.closed && !p) return l(b);
91
+ if (!p) try {
92
+ p = t.location.href !== "about:blank";
93
+ } catch {
94
+ p = !0;
95
+ }
96
+ t.closed && (f ?? (f = Date.now())), f !== null && Date.now() - f > 1e3 && l(null);
97
+ }, o);
98
+ r?.aborted ? u() : r?.addEventListener("abort", u);
99
+ });
100
+ }
101
+ export { v as authorizeUrl, _ as completeRedirect, m as cutOff, g as signIn, u as widgetLocale };
@@ -1,4 +1,4 @@
1
- import { f as e } from "./client-kNAo2TTG.js";
1
+ import { f as e } from "./client-Cv8ddtuM.js";
2
2
  // src/anchor/source.ts
3
3
  var t = /^[A-Za-z_$][\w$.-]*$/, n = /* @__PURE__ */ new Set([
4
4
  "src",
@@ -0,0 +1,221 @@
1
+ import { a as e, d as t, i as n, p as r, s as i, t as a } from "./client-Cv8ddtuM.js";
2
+ // src/activation.ts
3
+ var o = "commentkit:active", s = "data-commentkit-extension";
4
+ function c() {
5
+ return document.documentElement.hasAttribute(s);
6
+ }
7
+ function l() {
8
+ return /^(127\.0\.0\.1|\[::1\])$|(^|\.)localhost$|\.test$/.test(location.hostname);
9
+ }
10
+ function u(e, t = !0) {
11
+ if (!t || l() || c() || /[?&]ck(_thread|_code)?(=|&|$)/.test(location.href)) return !0;
12
+ try {
13
+ let t = `commentkit:v1:${e}`;
14
+ return !!localStorage.getItem(t) || !!sessionStorage.getItem(t) || localStorage.getItem(o) === "1";
15
+ } catch {
16
+ return !1;
17
+ }
18
+ }
19
+ function d(e) {
20
+ try {
21
+ e ? localStorage.setItem(o, "1") : localStorage.removeItem(o);
22
+ } catch {}
23
+ }
24
+ function f(e, t) {
25
+ let n;
26
+ try {
27
+ let r = t ? location.hash : location.href, i = r.replace(RegExp(`([?#&])ck_${e}=([^&#]*)(&?)`), (e, t, r, i) => (n = r, i && t));
28
+ i != r && history.replaceState(history.state, "", location.href.replace(r, () => i));
29
+ } catch {}
30
+ return n;
31
+ }
32
+ function p(e) {
33
+ let t, n = (n) => {
34
+ let r = /^k$/i.test(n.key);
35
+ (n.type == "keydown" ? t = (n.metaKey || n.ctrlKey) && n.shiftKey && r && e() : t && r) && (n.type == "keyup" && (t = 0), n.preventDefault(), n.stopImmediatePropagation());
36
+ }, r = [
37
+ "keydown",
38
+ "keypress",
39
+ "keyup"
40
+ ];
41
+ return r.map((e) => addEventListener(e, n, !0)), () => r.map((e) => removeEventListener(e, n, !0));
42
+ }
43
+ var m = "commentkit:crashes";
44
+ function h() {
45
+ try {
46
+ let [e, t] = JSON.parse(localStorage.getItem(m));
47
+ return Date.now() - t < 216e5 ? e : 0;
48
+ } catch {
49
+ return 0;
50
+ }
51
+ }
52
+ // src/core/retry-import.ts
53
+ function g(e, t = 2) {
54
+ return e().catch((n) => {
55
+ if (!t) throw n;
56
+ return new Promise((e) => setTimeout(e, 1500 / t)).then(() => g(e, t - 1));
57
+ });
58
+ }
59
+ // src/index.ts
60
+ var _ = null, v = null, y = null, b = {}, x = Symbol.for("commentkit.instance");
61
+ function S(e, t, ...n) {
62
+ b[e] || (b[e] = 1, console.warn(`[CommentKit] ${t}`, ...n));
63
+ }
64
+ function C(e, ...t) {
65
+ b[e] || (b[e] = 1, import("./show-BinoJyED.js").then((n) => n.explain(e, ...t)).catch(E));
66
+ }
67
+ function w() {
68
+ let e = (e) => typeof e == "string" && e.trim() ? e.trim().slice(0, 255) : null;
69
+ try {
70
+ let t = typeof __COMMENTKIT_BUILD__ < "u" ? __COMMENTKIT_BUILD__ : globalThis.__COMMENTKIT_BUILD__;
71
+ typeof t == "string" && (t = JSON.parse(t));
72
+ let n = t ?? {};
73
+ return {
74
+ branch: e(n.branch),
75
+ commit: e(n.commit)
76
+ };
77
+ } catch {
78
+ return {
79
+ branch: null,
80
+ commit: null
81
+ };
82
+ }
83
+ }
84
+ function T(e) {
85
+ let t = f("signin"), n = f("code", 1);
86
+ if (typeof window > "u") return M(e);
87
+ try {
88
+ let r = t ?? e?._signin;
89
+ if (r != null && (v = r), y = n ?? e?._finish ?? y, _) return e?.project !== _.project && C("project", e?.project, _.project), _.client.auth.takeSignInLink(v), v = null, k(_);
90
+ let i = A(e);
91
+ return typeof i == "string" ? M(e, i) : (_ = i, k(i));
92
+ } catch (t) {
93
+ return console.warn("[CommentKit] The widget could not start because of an error inside CommentKit; your page is not affected. See https://commentkit.dev/docs/troubleshooting", t), import("./show-BinoJyED.js").then((n) => n.reportStart(e, t)).catch(E), M(e);
94
+ }
95
+ }
96
+ var E = () => void 0, D = (e) => (t) => S(e, `${e}() failed.`, t), O = (e, t) => (...n) => t(...n).then(E, D(e));
97
+ function k(e) {
98
+ e.refs++;
99
+ let t = !0, n = /* @__PURE__ */ new Set();
100
+ return {
101
+ ...e.api,
102
+ client: e.client,
103
+ on: ((r, i) => {
104
+ if (!t) return E;
105
+ let a = e.client.on(r, i);
106
+ return n.add(a), a;
107
+ }),
108
+ destroy() {
109
+ t && (t = !1, n.forEach((e) => e()), --e.refs < 1 && e.destroy());
110
+ },
111
+ _m: e.started
112
+ };
113
+ }
114
+ function A(e) {
115
+ if (!e?.project || !t.test(e.project)) return C("key", !!e?.project), "bad project key";
116
+ let o = document;
117
+ if (o[x]) return C("copy", o[x]), "second copy";
118
+ let s = w(), { _key: l, _signin: f, _finish: m, identity: b, ...S } = e, T = {
119
+ ...S,
120
+ ...r(e.branch || s.branch, e.commit || s.commit)
121
+ }, k = new a(T), A = null, j = null, M = !1, N = !1, P = !!l;
122
+ l && (k.entrance = "key");
123
+ let F = k.auth.takeSignInLink(v) || !!(k.auth.finishLink = y);
124
+ v = y = null;
125
+ let I = 0, L, R = (e) => (e === !0 && (N = !0), N && A?.attach?.(), M || A ? Promise.resolve() : (j ?? (j = (async (e) => {
126
+ let t = () => e !== I, n = g(() => import("./show-BinoJyED.js"));
127
+ n.catch(E);
128
+ try {
129
+ let e = await k.loadConfig();
130
+ if (t()) return;
131
+ A = await (await n).mount(k, e, F, t, z, b, () => L = setTimeout(R, 6e4)), N && A?.attach?.(), A && P && d(!0);
132
+ } catch (e) {
133
+ await n.then((t) => t.failed(k, e), D("show"));
134
+ } finally {
135
+ t() || (j = null);
136
+ }
137
+ })(I)), j)), z = () => {
138
+ clearTimeout(L), I++, N = !1, j = null, A?.(), A = null;
139
+ }, B = T.toggleShortcut === !1 ? E : p(() => {
140
+ try {
141
+ return A ? (k.state.set({ request: {
142
+ kind: "inbox",
143
+ at: Date.now()
144
+ } }), !0) : (P = !0, k.entrance = "key", R(!0), !0);
145
+ } catch (e) {
146
+ D("shortcut")(e);
147
+ }
148
+ });
149
+ c() && import("./extension-CnQTDC1j.js").then((e) => e.extensionHello()).catch(() => void 0);
150
+ let V = F || P || u(T.project, T.hideOnProduction ?? !0) || !!b;
151
+ V && !F && !P && h() >= 3 && (V = !1, C("cooling")), V && !k.auth.hasSession() && k.prefetchSignIn();
152
+ let H = V ? R().then(() => !!A) : Promise.resolve(!1), U = {
153
+ show: () => R(!0),
154
+ hide: z,
155
+ open: O("open", async (e) => {
156
+ k.state.set({ opening: String(e).slice(0, 64) }), await R(!0);
157
+ }),
158
+ comment: O("comment", async (e = !0) => {
159
+ e && (P = !0), await R(e), e && A && d(!0), k.state.set({ request: {
160
+ kind: e ? "comment" : "stop",
161
+ at: Date.now()
162
+ } });
163
+ }),
164
+ signIn: async () => await k.signIn() === "signed_in",
165
+ identify: (e) => import("./identify-BnQGJOa0.js").then((t) => t.identify(k, e, R)).catch(() => !1),
166
+ signOut: O("signOut", () => k.signOut()),
167
+ session: () => i(k.state.get().session)
168
+ };
169
+ Object.defineProperty(o, x, {
170
+ value: n,
171
+ configurable: !0
172
+ });
173
+ let W = {
174
+ project: T.project,
175
+ client: k,
176
+ refs: 0,
177
+ started: H,
178
+ api: U,
179
+ destroy() {
180
+ M = !0, z(), B(), v = k.auth.signInLink, y = k.auth.finishLink, delete o[x], _ === W && (_ = null);
181
+ try {
182
+ k.destroy();
183
+ } catch (e) {
184
+ D("destroy")(e);
185
+ }
186
+ }
187
+ };
188
+ return W;
189
+ }
190
+ var j = () => new Proxy(() => Promise.resolve(), { get: (e, t) => t === "then" ? void 0 : t === Symbol.toPrimitive ? () => "" : j() });
191
+ function M(t, n) {
192
+ let r = async () => void 0, i = async () => !1, a = () => E, o = e(), s = t ?? {}, c = {
193
+ options: s,
194
+ state: {
195
+ get: () => o,
196
+ subscribe: a,
197
+ set: E
198
+ },
199
+ on: a,
200
+ emit: E,
201
+ endpoint: String(s.endpoint ?? "https://commentkit.dev").replace(/\/+$/, "")
202
+ };
203
+ return {
204
+ client: new Proxy(c, { get: (e, t) => t in e ? e[t] : t === "then" ? void 0 : j() }),
205
+ show: r,
206
+ hide: E,
207
+ open: r,
208
+ comment: r,
209
+ signIn: i,
210
+ identify: i,
211
+ signOut: r,
212
+ session: () => null,
213
+ on: a,
214
+ destroy: E,
215
+ ...n ? { _r() {
216
+ let e = n && /* @__PURE__ */ Error(`init() stayed off: ${n}`);
217
+ n = void 0, e && import("./show-BinoJyED.js").then((n) => n.reportStart(t, e)).catch(E);
218
+ } } : {}
219
+ };
220
+ }
221
+ export { c as a, h as i, g as n, d as o, m as r, T as t };