@commentkit/comment-kit 0.7.5 → 0.7.7
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.
- package/CHANGELOG.md +20 -1
- package/README.md +2 -2
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +3 -3
- package/dist/demo.es.js +2 -2
- package/dist/headless.es.js +2 -2
- package/dist/preact.es.js +2 -2
- package/dist/qwik.qwik.mjs +2 -2
- package/dist/react.es.js +2 -2
- package/dist/shared/{annotation-toolbar-DgqxkHy8.js → annotation-toolbar-zeiCmKIr.js} +110 -109
- package/dist/shared/{attachment-refresh-DRX7dKDI.js → attachment-refresh-DAacLaRu.js} +1 -1
- package/dist/shared/{capture-privacy-DUROnio5.js → capture-privacy-CiOrcAlt.js} +38 -14
- package/dist/shared/{comment-drawing-canvas-hSdcLShI.js → comment-drawing-canvas-Btc12IsS.js} +2 -2
- package/dist/shared/{comment-image-lightbox-4zroOCCG.js → comment-image-lightbox--QpbcAtH.js} +2 -2
- package/dist/shared/{comment-images-content-D4hTya6e.js → comment-images-content-C_r4SHM-.js} +13 -13
- package/dist/shared/{comment-kit-core-D068rcdY.js → comment-kit-core-CmLUFujd.js} +382 -348
- package/dist/shared/{comment-kit-ui-BDzNt0jv.js → comment-kit-ui-BHwYuSIi.js} +5255 -5487
- package/dist/shared/{comment-screenshot-annotator-BGnu_NgP.js → comment-screenshot-annotator-zJZyO-XM.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-BCRmojWB.js → comment-screenshot-overlay-CoKTYB0J.js} +6 -6
- package/dist/shared/{dev-export-panel-CYmUKmIV.js → dev-export-panel-Cnt6oCZU.js} +4 -4
- package/dist/shared/{dev-grab-BYsCpsGI.js → dev-grab-B85jo9AS.js} +3 -3
- package/dist/shared/{element-selector-79Oo5pit.js → element-selector-Cng84xC7.js} +349 -347
- package/dist/shared/input-UPtAj0M6.js +111 -0
- package/dist/shared/{mount-ui-DuHk132g.js → mount-ui-Dz7FB_Ak.js} +4 -4
- package/dist/shared/{pusher-3jyUauYd.js → pusher-CnhQgAvF.js} +1 -1
- package/dist/shared/{realtime-DspH16g5.js → realtime-yGLX4wMK.js} +2 -2
- package/dist/shared/{screenshot-BIuEaRiu.js → screenshot-B5-hwpmt.js} +2 -2
- package/dist/shared/{shadow-root-3-yGIhMs.js → shadow-root-B58ZI2yz.js} +1 -1
- package/dist/shared/{token-session-_Pi4fOEi.js → token-session-D92MYbNu.js} +2 -2
- package/dist/shared/useLabelableId-8n0QmH8N.js +154 -0
- package/dist/shared/{websocket-manager-CvgZSo_L.js → websocket-manager-KhH4hL0Q.js} +2 -2
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +2 -0
- package/dist/types/core/comment-kit-core.d.ts +4 -2
- package/dist/types/core/types.d.ts +12 -5
- package/dist/types/core/write-access.d.ts +2 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as e, c as t, d as n, f as r, l as i, n as a, o, p as s, r as c, s as l, t as u, u as d } from "./validation-3wbbbuX0.js";
|
|
2
2
|
import { t as f } from "./request-activity-DQrAUwfA.js";
|
|
3
3
|
import { n as p, o as m } from "./dom-Bhf4WFtY.js";
|
|
4
|
-
import { n as h, t as g } from "./capture-privacy-
|
|
4
|
+
import { n as h, t as g } from "./capture-privacy-CiOrcAlt.js";
|
|
5
5
|
import { a as _, n as v, r as y, t as ee } from "./text-B4HHZNaa.js";
|
|
6
6
|
var b = "https://api.commentkit.dev/api", te = 3e4, ne = 10485760, re = 10, ie = 1e4, ae = 5e3, oe = 254, se = 6, ce = 4096, le = [
|
|
7
7
|
".png",
|
|
@@ -110,10 +110,10 @@ function _e(e, t) {
|
|
|
110
110
|
}
|
|
111
111
|
var ve = class {
|
|
112
112
|
constructor(e) {
|
|
113
|
-
this.projectId = null, this.channelProjectId = null, this.userEmail = null, this.authToken = null, this.authRevision = 0, this.environment = null, this.onAuthExpired = null, this.baseUrl = me(e.baseUrl), this.apiKey = e.apiKey, this.projectId = e.projectId || null, this.channelProjectId = this.projectId, this.environment = e.environment || null;
|
|
113
|
+
this.projectId = null, this.channelProjectId = null, this.userEmail = null, this.authToken = null, this.authRevision = 0, this.pendingInvite = null, this.inviteRevision = 0, this.environment = null, this.onAuthExpired = null, this.baseUrl = me(e.baseUrl), this.apiKey = e.apiKey, this.projectId = e.projectId || null, this.channelProjectId = this.projectId, this.environment = e.environment || null;
|
|
114
114
|
}
|
|
115
115
|
setProject(e, t = e) {
|
|
116
|
-
this.projectId = String(e).trim(), this.channelProjectId = String(t).trim();
|
|
116
|
+
this.projectId !== String(e).trim() && (this.pendingInvite = null, this.inviteRevision++), this.projectId = String(e).trim(), this.channelProjectId = String(t).trim();
|
|
117
117
|
}
|
|
118
118
|
setUserEmail(e) {
|
|
119
119
|
this.userEmail = e ? C(e) : null;
|
|
@@ -121,7 +121,7 @@ var ve = class {
|
|
|
121
121
|
setAuthToken(e) {
|
|
122
122
|
if (e && (a(e) || e.length > ce)) throw new E("invalid_token", "A valid auth token is required", 400);
|
|
123
123
|
let t = e?.trim() || null;
|
|
124
|
-
this.authToken = t, this.authRevision++;
|
|
124
|
+
this.authToken = t, this.pendingInvite = null, this.inviteRevision++, this.authRevision++;
|
|
125
125
|
}
|
|
126
126
|
setEnvironment(e) {
|
|
127
127
|
this.environment = e;
|
|
@@ -249,7 +249,10 @@ var ve = class {
|
|
|
249
249
|
let t = C(e);
|
|
250
250
|
return this.request("/auth/otp/request", {
|
|
251
251
|
method: "POST",
|
|
252
|
-
body: JSON.stringify({
|
|
252
|
+
body: JSON.stringify({
|
|
253
|
+
email: t,
|
|
254
|
+
...this.pendingInvite?.email === t ? { invitation_challenge: this.pendingInvite.challenge } : {}
|
|
255
|
+
})
|
|
253
256
|
});
|
|
254
257
|
}
|
|
255
258
|
async verifyOtp(e, t) {
|
|
@@ -274,13 +277,18 @@ var ve = class {
|
|
|
274
277
|
}
|
|
275
278
|
async validateInvite(e, t) {
|
|
276
279
|
let n = ge(e), r = C(t);
|
|
277
|
-
|
|
280
|
+
this.pendingInvite = null;
|
|
281
|
+
let i = ++this.inviteRevision, a = await this.request("/auth/validate-invite", {
|
|
278
282
|
method: "POST",
|
|
279
283
|
body: JSON.stringify({
|
|
280
284
|
token: n,
|
|
281
285
|
email: r
|
|
282
286
|
})
|
|
283
287
|
});
|
|
288
|
+
return i === this.inviteRevision && a.success && a.invitationChallenge && (this.pendingInvite = {
|
|
289
|
+
email: r,
|
|
290
|
+
challenge: a.invitationChallenge
|
|
291
|
+
}), a;
|
|
284
292
|
}
|
|
285
293
|
async getComments(e, t = "all", n = 1, r = 50, i, a, o) {
|
|
286
294
|
let s = this.requireProjectId(), c = new URLSearchParams();
|
|
@@ -516,19 +524,19 @@ var E = class extends Error {
|
|
|
516
524
|
isPremiumFeatureError() {
|
|
517
525
|
return this.code === 402;
|
|
518
526
|
}
|
|
519
|
-
},
|
|
520
|
-
function
|
|
521
|
-
return
|
|
527
|
+
}, D = null, xe = 0, Se = 3;
|
|
528
|
+
function Ce() {
|
|
529
|
+
return D || (D = (async () => {
|
|
522
530
|
try {
|
|
523
531
|
let e = await import("element-source");
|
|
524
532
|
return typeof e?.resolveElementInfo == "function" ? e : null;
|
|
525
533
|
} catch {
|
|
526
|
-
return
|
|
534
|
+
return xe += 1, xe < Se && (D = null), null;
|
|
527
535
|
}
|
|
528
|
-
})(),
|
|
536
|
+
})(), D);
|
|
529
537
|
}
|
|
530
|
-
async function
|
|
531
|
-
let t = await
|
|
538
|
+
async function we(e) {
|
|
539
|
+
let t = await Ce();
|
|
532
540
|
if (!t) return null;
|
|
533
541
|
try {
|
|
534
542
|
return await t.resolveElementInfo(e);
|
|
@@ -536,27 +544,27 @@ async function Te(e) {
|
|
|
536
544
|
return null;
|
|
537
545
|
}
|
|
538
546
|
}
|
|
539
|
-
var
|
|
540
|
-
function
|
|
547
|
+
var Te = 200, Ee = 500, De = 500, Oe = 2e3, ke = "application/x-commentkit-agent-context", Ae = "Address the UI feedback in this context.";
|
|
548
|
+
function je(e) {
|
|
541
549
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
542
550
|
}
|
|
543
|
-
function
|
|
544
|
-
return e === void 0 ?
|
|
551
|
+
function Me(e) {
|
|
552
|
+
return e === void 0 ? Te : !Number.isFinite(e) || e <= 0 ? 0 : Math.min(Ee, Math.floor(e));
|
|
545
553
|
}
|
|
546
|
-
function
|
|
554
|
+
function Ne(e) {
|
|
547
555
|
return {
|
|
548
556
|
id: e.id,
|
|
549
557
|
name: e.name,
|
|
550
558
|
email: e.email
|
|
551
559
|
};
|
|
552
560
|
}
|
|
553
|
-
function
|
|
561
|
+
function Pe(e, t) {
|
|
554
562
|
return e.page.path === t.path || e.page.url === t.url;
|
|
555
563
|
}
|
|
556
|
-
function
|
|
557
|
-
return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !
|
|
564
|
+
function Fe(e, t, n, r) {
|
|
565
|
+
return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !Pe(e, t) || r && !r.has(e.id));
|
|
558
566
|
}
|
|
559
|
-
function
|
|
567
|
+
function Ie(e) {
|
|
560
568
|
let t = e.getBoundingClientRect();
|
|
561
569
|
return {
|
|
562
570
|
top: t.top,
|
|
@@ -565,7 +573,7 @@ function Le(e) {
|
|
|
565
573
|
height: t.height
|
|
566
574
|
};
|
|
567
575
|
}
|
|
568
|
-
function
|
|
576
|
+
function Le(e, t, n) {
|
|
569
577
|
let r = n ? p(e.element ?? "", e.xpath) : null, i = {
|
|
570
578
|
...e.element ? { selector: e.element } : {},
|
|
571
579
|
...e.xpath ? { xpath: e.xpath } : {}
|
|
@@ -574,7 +582,7 @@ function Re(e, t, n) {
|
|
|
574
582
|
...i,
|
|
575
583
|
found: !1
|
|
576
584
|
};
|
|
577
|
-
let a = h(r), o = y(a.text,
|
|
585
|
+
let a = h(r), o = y(a.text, De), s = t ? y(a.html, Oe) : "", c = r.getAttribute("class"), l = r.getAttribute("role"), u = r.getAttribute("aria-label");
|
|
578
586
|
return {
|
|
579
587
|
...i,
|
|
580
588
|
found: !0,
|
|
@@ -584,28 +592,28 @@ function Re(e, t, n) {
|
|
|
584
592
|
...l ? { role: l } : {},
|
|
585
593
|
...u ? { ariaLabel: u } : {},
|
|
586
594
|
...o ? { text: o } : {},
|
|
587
|
-
rect:
|
|
595
|
+
rect: Ie(r),
|
|
588
596
|
...s ? { htmlPreview: s } : {}
|
|
589
597
|
};
|
|
590
598
|
}
|
|
591
|
-
function
|
|
599
|
+
function Re(e) {
|
|
592
600
|
return {
|
|
593
601
|
id: e.id,
|
|
594
602
|
content: e.content,
|
|
595
|
-
author:
|
|
603
|
+
author: Ne(e.author),
|
|
596
604
|
createdAt: e.createdAt,
|
|
597
605
|
isEdited: e.isEdited,
|
|
598
606
|
replyTo: e.replyTo,
|
|
599
607
|
mentions: e.mentions,
|
|
600
608
|
reactions: e.reactions,
|
|
601
|
-
attachments: e.attachments?.map(
|
|
609
|
+
attachments: e.attachments?.map(O)
|
|
602
610
|
};
|
|
603
611
|
}
|
|
604
|
-
function
|
|
612
|
+
function ze(e) {
|
|
605
613
|
return e && e.length <= 4096 && !/[?#]/.test(e) && /^https?:\/\//i.test(e) && d(e) ? e : void 0;
|
|
606
614
|
}
|
|
607
|
-
function
|
|
608
|
-
let { id: t, type: n, filename: r, mimeType: i, size: a } = e, o =
|
|
615
|
+
function O(e) {
|
|
616
|
+
let { id: t, type: n, filename: r, mimeType: i, size: a } = e, o = ze(e.url);
|
|
609
617
|
return {
|
|
610
618
|
id: t,
|
|
611
619
|
type: n,
|
|
@@ -615,22 +623,22 @@ function D(e) {
|
|
|
615
623
|
...o ? { url: o } : { inlineContentOmitted: !0 }
|
|
616
624
|
};
|
|
617
625
|
}
|
|
618
|
-
function
|
|
619
|
-
let r = e.attachments.map(
|
|
626
|
+
function Be(e, t, n) {
|
|
627
|
+
let r = e.attachments.map(O), i = r.find((e) => e.type === "screenshot" && e.url)?.url;
|
|
620
628
|
return {
|
|
621
629
|
id: e.id,
|
|
622
630
|
type: e.type,
|
|
623
631
|
status: e.status,
|
|
624
632
|
priority: e.priority,
|
|
625
633
|
content: e.content,
|
|
626
|
-
author:
|
|
634
|
+
author: Ne(e.author),
|
|
627
635
|
createdAt: e.createdAt,
|
|
628
636
|
updatedAt: e.updatedAt,
|
|
629
637
|
environment: e.environment,
|
|
630
638
|
branch: e.branch,
|
|
631
639
|
deviceInfo: e.deviceInfo,
|
|
632
640
|
description: e.description,
|
|
633
|
-
assignees: e.assignees?.map(
|
|
641
|
+
assignees: e.assignees?.map(Ne),
|
|
634
642
|
mentions: e.mentions,
|
|
635
643
|
checklist: e.checklist,
|
|
636
644
|
reactions: e.reactions,
|
|
@@ -646,13 +654,13 @@ function Ve(e, t, n) {
|
|
|
646
654
|
textSelection: e.textSelection,
|
|
647
655
|
drawingData: e.drawingData,
|
|
648
656
|
attachments: r,
|
|
649
|
-
element:
|
|
657
|
+
element: Le(e.position, t.includeHtml === !0, Pe(e, n)),
|
|
650
658
|
...i ? { screenshotUrl: i } : {},
|
|
651
659
|
repliesCount: e.repliesCount ?? e.replies.length,
|
|
652
|
-
replies: e.replies.map(
|
|
660
|
+
replies: e.replies.map(Re)
|
|
653
661
|
};
|
|
654
662
|
}
|
|
655
|
-
function
|
|
663
|
+
function Ve(e) {
|
|
656
664
|
return {
|
|
657
665
|
filePath: e.filePath,
|
|
658
666
|
lineNumber: e.lineNumber,
|
|
@@ -660,16 +668,16 @@ function He(e) {
|
|
|
660
668
|
componentName: e.componentName
|
|
661
669
|
};
|
|
662
670
|
}
|
|
663
|
-
function
|
|
671
|
+
function k(e, t = {}) {
|
|
664
672
|
let n = m(), r = {
|
|
665
673
|
url: n.url,
|
|
666
674
|
path: n.path,
|
|
667
675
|
title: n.title
|
|
668
|
-
}, i = t.commentIds?.length ? new Set(t.commentIds) : null, a =
|
|
676
|
+
}, i = t.commentIds?.length ? new Set(t.commentIds) : null, a = Me(t.maxComments), o = e.comments.filter((e) => Fe(e, r, t, i)), s = o.slice(0, a).map((e) => Be(e, t, r));
|
|
669
677
|
return {
|
|
670
678
|
version: 1,
|
|
671
679
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
672
|
-
instructions: v(t.instructions, 2e3) ||
|
|
680
|
+
instructions: v(t.instructions, 2e3) || Ae,
|
|
673
681
|
page: {
|
|
674
682
|
...r,
|
|
675
683
|
url: _(r.url),
|
|
@@ -694,15 +702,15 @@ function O(e, t = {}) {
|
|
|
694
702
|
sourceResolved: !1
|
|
695
703
|
};
|
|
696
704
|
}
|
|
697
|
-
async function
|
|
705
|
+
async function He(e) {
|
|
698
706
|
let t = !1, n = await Promise.all(e.comments.map(async (e) => {
|
|
699
707
|
if (!e.element.found) return e;
|
|
700
708
|
let n = p(e.element.selector ?? "", e.element.xpath);
|
|
701
709
|
if (!n || g(n)) return e;
|
|
702
|
-
let r = await
|
|
710
|
+
let r = await we(n);
|
|
703
711
|
if (!r || !r.source) return e;
|
|
704
712
|
t = !0;
|
|
705
|
-
let i =
|
|
713
|
+
let i = Ve(r.source), a = r.stack.map(Ve), o = r.componentName ?? void 0;
|
|
706
714
|
return {
|
|
707
715
|
...e,
|
|
708
716
|
element: {
|
|
@@ -719,8 +727,8 @@ async function Ue(e) {
|
|
|
719
727
|
sourceResolved: t
|
|
720
728
|
};
|
|
721
729
|
}
|
|
722
|
-
function
|
|
723
|
-
let t =
|
|
730
|
+
function A(e) {
|
|
731
|
+
let t = Ue(e);
|
|
724
732
|
return [
|
|
725
733
|
"# CommentKit Agent Context",
|
|
726
734
|
"",
|
|
@@ -736,7 +744,7 @@ function k(e) {
|
|
|
736
744
|
"```"
|
|
737
745
|
].join("\n");
|
|
738
746
|
}
|
|
739
|
-
function
|
|
747
|
+
function Ue(e) {
|
|
740
748
|
let t = 2e3, n = (e) => e.length > t ? `${e.slice(0, t)}… [clipped]` : e;
|
|
741
749
|
return {
|
|
742
750
|
version: e.version,
|
|
@@ -785,7 +793,7 @@ function We(e) {
|
|
|
785
793
|
width: e.width,
|
|
786
794
|
height: e.height,
|
|
787
795
|
...e.text ? { text: y(e.text, 200) } : {},
|
|
788
|
-
...e.d ? { bounds:
|
|
796
|
+
...e.d ? { bounds: We(e.d) } : {}
|
|
789
797
|
})),
|
|
790
798
|
...e.drawingData.paths.length > 12 ? { omittedPaths: e.drawingData.paths.length - 12 } : {}
|
|
791
799
|
} } : {},
|
|
@@ -794,7 +802,7 @@ function We(e) {
|
|
|
794
802
|
label: e,
|
|
795
803
|
done: t
|
|
796
804
|
})) } : {},
|
|
797
|
-
...e.attachments?.length ? { attachments: e.attachments.map(
|
|
805
|
+
...e.attachments?.length ? { attachments: e.attachments.map(O) } : {},
|
|
798
806
|
replyCount: e.repliesCount ?? e.replies.length,
|
|
799
807
|
...(e.repliesCount ?? e.replies.length) > Math.min(12, e.replies.length) ? { omittedReplies: (e.repliesCount ?? e.replies.length) - Math.min(12, e.replies.length) } : {},
|
|
800
808
|
replies: e.replies.slice(-12).map((e) => ({
|
|
@@ -806,12 +814,12 @@ function We(e) {
|
|
|
806
814
|
type: e.replyTo.type,
|
|
807
815
|
body: e.replyTo.body
|
|
808
816
|
} } : {},
|
|
809
|
-
...e.attachments?.length ? { attachments: e.attachments.map(
|
|
817
|
+
...e.attachments?.length ? { attachments: e.attachments.map(O) } : {}
|
|
810
818
|
}))
|
|
811
819
|
}))
|
|
812
820
|
};
|
|
813
821
|
}
|
|
814
|
-
function
|
|
822
|
+
function We(e) {
|
|
815
823
|
let t = [...e.matchAll(/[ML]\s*(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/gi)];
|
|
816
824
|
if (!t.length) return null;
|
|
817
825
|
let n = t.map((e) => Number(e[1])), r = t.map((e) => Number(e[2]));
|
|
@@ -822,18 +830,18 @@ function Ge(e) {
|
|
|
822
830
|
height: Math.max(...r) - Math.min(...r)
|
|
823
831
|
};
|
|
824
832
|
}
|
|
825
|
-
function
|
|
833
|
+
function Ge(e) {
|
|
826
834
|
return {
|
|
827
835
|
version: e?.version ?? 1,
|
|
828
836
|
generatedAt: e?.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
829
837
|
commentCount: e?.comments.length ?? 0,
|
|
830
|
-
context: e ?
|
|
838
|
+
context: e ? Ue(e) : null
|
|
831
839
|
};
|
|
832
840
|
}
|
|
833
|
-
function
|
|
841
|
+
function Ke(e, t) {
|
|
834
842
|
if (typeof document > "u" || !document.body || typeof document.execCommand != "function") return !1;
|
|
835
843
|
let n = JSON.stringify(t), r = (t) => {
|
|
836
|
-
t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${
|
|
844
|
+
t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${je(e)}</code></pre>`), t.clipboardData?.setData(ke, n);
|
|
837
845
|
}, i = document.createElement("textarea");
|
|
838
846
|
i.value = e, i.setAttribute("readonly", ""), i.setAttribute("aria-hidden", "true"), i.style.position = "fixed", i.style.left = "-9999px", document.addEventListener("copy", r), document.body.appendChild(i), i.select();
|
|
839
847
|
try {
|
|
@@ -842,10 +850,10 @@ function qe(e, t) {
|
|
|
842
850
|
document.removeEventListener("copy", r), i.remove();
|
|
843
851
|
}
|
|
844
852
|
}
|
|
845
|
-
async function
|
|
853
|
+
async function qe(e, t) {
|
|
846
854
|
if (typeof navigator > "u" || typeof navigator.clipboard?.write != "function" || typeof ClipboardItem > "u") return !1;
|
|
847
855
|
try {
|
|
848
|
-
let n = new Blob([`<meta charset="utf-8"><pre><code>${
|
|
856
|
+
let n = new Blob([`<meta charset="utf-8"><pre><code>${je(e)}</code></pre>`], { type: "text/html" }), r = new Blob([e], { type: "text/plain" }), i = t.type && t.type.startsWith("image/") ? t.type : "image/png";
|
|
849
857
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
850
858
|
"text/plain": r,
|
|
851
859
|
"text/html": n,
|
|
@@ -855,43 +863,45 @@ async function Je(e, t) {
|
|
|
855
863
|
return !1;
|
|
856
864
|
}
|
|
857
865
|
}
|
|
858
|
-
async function
|
|
859
|
-
return t && await
|
|
866
|
+
async function Je(e, t) {
|
|
867
|
+
return t && await qe(e, t) ? !0 : (await Ye(e), !1);
|
|
860
868
|
}
|
|
861
|
-
async function
|
|
862
|
-
if (!
|
|
869
|
+
async function Ye(e, t = null) {
|
|
870
|
+
if (!Ke(e, Ge(t))) {
|
|
863
871
|
if (typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function") await navigator.clipboard.writeText(e);
|
|
864
872
|
else throw Error("Clipboard is unavailable");
|
|
865
873
|
}
|
|
866
874
|
}
|
|
867
|
-
function
|
|
875
|
+
function Xe(e, t, n = null) {
|
|
868
876
|
let r = t.projectContext, i = n ?? (r?.permissions.canWriteComments === !1 ? r.permissions.writeRestriction ?? (r.organization?.plan === "none" ? "plan_required" : "feature_disabled") : null), a = i === "plan_required", o = !i && e.features?.comments !== !1;
|
|
869
877
|
return {
|
|
870
878
|
canWrite: o,
|
|
871
879
|
canManageComments: o && (r?.permissions.canManageComments ?? !1),
|
|
880
|
+
canTriage: o ? r?.permissions.canTriage : !1,
|
|
881
|
+
canComplete: o && r?.permissions.canComplete !== !1,
|
|
872
882
|
planRequired: a,
|
|
873
883
|
message: o ? "" : a ? "This workspace is read-only. An active plan is required to add or change feedback. You can still read and export comments." : "Comment changes are disabled for this project. You can still read and export comments."
|
|
874
884
|
};
|
|
875
885
|
}
|
|
876
|
-
function
|
|
886
|
+
function j() {
|
|
877
887
|
for (let e of document.querySelectorAll("dialog:modal,[aria-modal=true]:is(dialog,[role$=dialog])")) if (e.getClientRects().length && getComputedStyle(e).visibility === "visible") return !0;
|
|
878
888
|
return !1;
|
|
879
889
|
}
|
|
880
|
-
var
|
|
881
|
-
function
|
|
890
|
+
var Ze = 100, Qe = () => {};
|
|
891
|
+
function $e(e) {
|
|
882
892
|
return typeof e == "function";
|
|
883
893
|
}
|
|
884
|
-
var
|
|
894
|
+
var et = class {
|
|
885
895
|
constructor() {
|
|
886
896
|
this.listeners = /* @__PURE__ */ new Map(), this.onceWrappers = /* @__PURE__ */ new Map();
|
|
887
897
|
}
|
|
888
898
|
on(e, t) {
|
|
889
|
-
if (
|
|
899
|
+
if (!$e(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), Qe;
|
|
890
900
|
let n = this.listeners.get(e);
|
|
891
|
-
return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >=
|
|
901
|
+
return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >= Ze && console.warn(`[CommentKit] Max listeners (${Ze}) reached for '${String(e)}' - possible memory leak`), n.add(t), () => this.off(e, t);
|
|
892
902
|
}
|
|
893
903
|
off(e, t) {
|
|
894
|
-
if (
|
|
904
|
+
if (!$e(t)) return;
|
|
895
905
|
let n = this.listeners.get(e);
|
|
896
906
|
if (n) {
|
|
897
907
|
n.delete(t);
|
|
@@ -908,7 +918,7 @@ var tt = class {
|
|
|
908
918
|
}
|
|
909
919
|
}
|
|
910
920
|
once(e, t) {
|
|
911
|
-
if (
|
|
921
|
+
if (!$e(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), Qe;
|
|
912
922
|
let n = (n) => {
|
|
913
923
|
this.off(e, t), t(n);
|
|
914
924
|
}, r = this.onceWrappers.get(e);
|
|
@@ -920,7 +930,7 @@ var tt = class {
|
|
|
920
930
|
listenerCount(e) {
|
|
921
931
|
return this.listeners.get(e)?.size ?? 0;
|
|
922
932
|
}
|
|
923
|
-
},
|
|
933
|
+
}, tt = Symbol(), M = Object.freeze({
|
|
924
934
|
ID: 256,
|
|
925
935
|
CONTENT: 1e4,
|
|
926
936
|
REPLY_CONTENT: 5e3,
|
|
@@ -945,39 +955,39 @@ var tt = class {
|
|
|
945
955
|
REACTION_COUNT: 1e6,
|
|
946
956
|
PENDING_MUTATIONS: 1e3,
|
|
947
957
|
RETRY_DELAY: 3e4
|
|
948
|
-
}),
|
|
949
|
-
function
|
|
958
|
+
}), nt = "commentkit:session:", rt = 4096;
|
|
959
|
+
function it() {
|
|
950
960
|
try {
|
|
951
961
|
return typeof sessionStorage > "u" ? null : sessionStorage;
|
|
952
962
|
} catch {
|
|
953
963
|
return null;
|
|
954
964
|
}
|
|
955
965
|
}
|
|
956
|
-
function
|
|
957
|
-
return `${
|
|
966
|
+
function N(e) {
|
|
967
|
+
return `${nt}${e}`;
|
|
958
968
|
}
|
|
959
|
-
function
|
|
960
|
-
return o(e) && r(e.id,
|
|
969
|
+
function at(e) {
|
|
970
|
+
return o(e) && r(e.id, M.ID) && r(e.name, M.NAME) && typeof e.email == "string" && s(e.email, M.EMAIL);
|
|
961
971
|
}
|
|
962
|
-
function
|
|
963
|
-
return o(e) && r(e.token,
|
|
972
|
+
function ot(e) {
|
|
973
|
+
return o(e) && r(e.token, rt) && typeof e.email == "string" && s(e.email, M.EMAIL) && at(e.user);
|
|
964
974
|
}
|
|
965
|
-
function
|
|
975
|
+
function st(e, t) {
|
|
966
976
|
if (!e) return;
|
|
967
|
-
let n =
|
|
977
|
+
let n = it();
|
|
968
978
|
if (n) try {
|
|
969
|
-
n.setItem(
|
|
979
|
+
n.setItem(N(e), JSON.stringify(t));
|
|
970
980
|
} catch {}
|
|
971
981
|
}
|
|
972
|
-
function
|
|
982
|
+
function ct(e) {
|
|
973
983
|
if (!e) return null;
|
|
974
|
-
let t =
|
|
984
|
+
let t = it();
|
|
975
985
|
if (!t) return null;
|
|
976
986
|
try {
|
|
977
|
-
let n = t.getItem(
|
|
987
|
+
let n = t.getItem(N(e));
|
|
978
988
|
if (!n) return null;
|
|
979
989
|
let r = JSON.parse(n);
|
|
980
|
-
return
|
|
990
|
+
return ot(r) ? {
|
|
981
991
|
token: r.token.trim(),
|
|
982
992
|
email: r.email.trim(),
|
|
983
993
|
user: {
|
|
@@ -986,19 +996,19 @@ function lt(e) {
|
|
|
986
996
|
email: r.user.email.trim(),
|
|
987
997
|
...r.user.avatar ? { avatar: r.user.avatar } : {}
|
|
988
998
|
}
|
|
989
|
-
} : (t.removeItem(
|
|
999
|
+
} : (t.removeItem(N(e)), null);
|
|
990
1000
|
} catch {
|
|
991
1001
|
return null;
|
|
992
1002
|
}
|
|
993
1003
|
}
|
|
994
|
-
function
|
|
1004
|
+
function lt(e) {
|
|
995
1005
|
if (!e) return;
|
|
996
|
-
let t =
|
|
1006
|
+
let t = it();
|
|
997
1007
|
if (t) try {
|
|
998
|
-
t.removeItem(
|
|
1008
|
+
t.removeItem(N(e));
|
|
999
1009
|
} catch {}
|
|
1000
1010
|
}
|
|
1001
|
-
function
|
|
1011
|
+
function ut(e, t) {
|
|
1002
1012
|
for (let n of e.getState().pendingMutations) e.emit("offline:failed", {
|
|
1003
1013
|
id: n.id,
|
|
1004
1014
|
error: {
|
|
@@ -1008,36 +1018,36 @@ function dt(e, t) {
|
|
|
1008
1018
|
}
|
|
1009
1019
|
});
|
|
1010
1020
|
}
|
|
1011
|
-
var
|
|
1012
|
-
function
|
|
1021
|
+
var dt = M.EMAIL, ft = M.NAME, pt = M.ID, mt = 4096, ht = 6;
|
|
1022
|
+
function gt(e) {
|
|
1013
1023
|
if (typeof e != "string") return null;
|
|
1014
1024
|
let t = e.trim();
|
|
1015
|
-
return s(t,
|
|
1025
|
+
return s(t, dt) ? t : null;
|
|
1026
|
+
}
|
|
1027
|
+
function _t(e) {
|
|
1028
|
+
return !a(e) && e.trim().length === ht;
|
|
1016
1029
|
}
|
|
1017
1030
|
function vt(e) {
|
|
1018
|
-
return
|
|
1031
|
+
return o(e) && r(e.id, pt) && r(e.name, ft) && typeof e.email == "string" && gt(e.email) !== null;
|
|
1019
1032
|
}
|
|
1020
1033
|
function yt(e) {
|
|
1021
|
-
return o(e) && r(e.id,
|
|
1022
|
-
}
|
|
1023
|
-
function bt(e) {
|
|
1024
|
-
return o(e) && r(e.id, mt);
|
|
1034
|
+
return o(e) && r(e.id, pt);
|
|
1025
1035
|
}
|
|
1026
|
-
function
|
|
1036
|
+
function P(e, t, n) {
|
|
1027
1037
|
return {
|
|
1028
1038
|
error: e,
|
|
1029
1039
|
message: t,
|
|
1030
1040
|
code: n
|
|
1031
1041
|
};
|
|
1032
1042
|
}
|
|
1033
|
-
async function
|
|
1034
|
-
let r =
|
|
1043
|
+
async function bt(e, t, n = () => !0) {
|
|
1044
|
+
let r = gt(t);
|
|
1035
1045
|
if (!r) e.setState({
|
|
1036
1046
|
isLoading: !1,
|
|
1037
1047
|
otpStep: "idle",
|
|
1038
1048
|
otpEmail: null,
|
|
1039
1049
|
otpMfaChallenge: null
|
|
1040
|
-
}), e.handleError(
|
|
1050
|
+
}), e.handleError(P("invalid_email", "A valid email address is required", 400));
|
|
1041
1051
|
else try {
|
|
1042
1052
|
e.setState({
|
|
1043
1053
|
isLoading: !0,
|
|
@@ -1059,7 +1069,7 @@ async function xt(e, t, n = () => !0) {
|
|
|
1059
1069
|
otpStep: "idle",
|
|
1060
1070
|
otpEmail: null,
|
|
1061
1071
|
otpMfaChallenge: null
|
|
1062
|
-
}), e.handleError(
|
|
1072
|
+
}), e.handleError(P("otp_failed", "Failed to send OTP. Please try again.", 500)));
|
|
1063
1073
|
} catch (t) {
|
|
1064
1074
|
if (!n()) return;
|
|
1065
1075
|
e.setState({
|
|
@@ -1070,14 +1080,14 @@ async function xt(e, t, n = () => !0) {
|
|
|
1070
1080
|
}), e.handleError(t);
|
|
1071
1081
|
}
|
|
1072
1082
|
}
|
|
1073
|
-
async function
|
|
1083
|
+
async function xt(e, t, n) {
|
|
1074
1084
|
let { onAuthenticated: i, onWrongOtp: o, onSuccess: s, isCurrent: c = () => !0 } = typeof n == "function" ? { onAuthenticated: n } : n, { otpEmail: l, otpMfaChallenge: u, otpStep: d } = e.getState();
|
|
1075
1085
|
if (!l) {
|
|
1076
|
-
e.handleError(
|
|
1086
|
+
e.handleError(P("no_email", "No OTP request in progress", 400));
|
|
1077
1087
|
return;
|
|
1078
1088
|
}
|
|
1079
1089
|
let f = d === "mfa";
|
|
1080
|
-
if (!(f ? typeof t == "string" && !a(t) && t.trim().length >= 6 && t.trim().length <= 100 :
|
|
1090
|
+
if (!(f ? typeof t == "string" && !a(t) && t.trim().length >= 6 && t.trim().length <= 100 : _t(t)) || f && !u) e.setState({ isLoading: !1 }), e.handleError(P("invalid_otp", "Invalid or expired OTP code", 401));
|
|
1081
1091
|
else try {
|
|
1082
1092
|
e.setState({
|
|
1083
1093
|
isLoading: !0,
|
|
@@ -1094,8 +1104,8 @@ async function St(e, t, n) {
|
|
|
1094
1104
|
});
|
|
1095
1105
|
return;
|
|
1096
1106
|
}
|
|
1097
|
-
if (n.verified && r(n.token,
|
|
1098
|
-
if (e.apiClient.setAuthToken(n.token), e.apiClient.setUserEmail(n.user.email), e.config.persistence !== "memory" &&
|
|
1107
|
+
if (n.verified && r(n.token, mt) && vt(n.user) && yt(n.project)) {
|
|
1108
|
+
if (e.apiClient.setAuthToken(n.token), e.apiClient.setUserEmail(n.user.email), e.config.persistence !== "memory" && st(e.config.projectId, {
|
|
1099
1109
|
token: n.token,
|
|
1100
1110
|
email: n.user.email,
|
|
1101
1111
|
user: n.user
|
|
@@ -1111,13 +1121,13 @@ async function St(e, t, n) {
|
|
|
1111
1121
|
otpMfaChallenge: null
|
|
1112
1122
|
}), s?.(), e.emit("auth:otp-verified", n.user), !c() || (e.emit("auth:login", n.user), !c())) return;
|
|
1113
1123
|
await i();
|
|
1114
|
-
} else e.setState({ isLoading: !1 }), o?.(), e.handleError(
|
|
1124
|
+
} else e.setState({ isLoading: !1 }), o?.(), e.handleError(P("invalid_otp", "Invalid or expired OTP code", 401));
|
|
1115
1125
|
} catch (t) {
|
|
1116
1126
|
if (!c()) return;
|
|
1117
1127
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
1118
1128
|
}
|
|
1119
1129
|
}
|
|
1120
|
-
function
|
|
1130
|
+
function St(e) {
|
|
1121
1131
|
e.setState({
|
|
1122
1132
|
otpStep: "idle",
|
|
1123
1133
|
otpEmail: null,
|
|
@@ -1126,12 +1136,12 @@ function Ct(e) {
|
|
|
1126
1136
|
isLoading: !1
|
|
1127
1137
|
});
|
|
1128
1138
|
}
|
|
1129
|
-
async function
|
|
1139
|
+
async function Ct(e, t = () => !0) {
|
|
1130
1140
|
let n = e.getState().otpEmail;
|
|
1131
|
-
n && await
|
|
1141
|
+
n && await bt(e, n, t);
|
|
1132
1142
|
}
|
|
1133
|
-
function
|
|
1134
|
-
|
|
1143
|
+
function wt(e, t) {
|
|
1144
|
+
ut(e, "Pending offline changes were discarded on logout"), lt(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), t(), e.setState({
|
|
1135
1145
|
isAuthenticated: !1,
|
|
1136
1146
|
currentUser: null,
|
|
1137
1147
|
comments: [],
|
|
@@ -1160,8 +1170,8 @@ function Tt(e, t) {
|
|
|
1160
1170
|
isLoading: !1
|
|
1161
1171
|
}), e.emit("auth:logout", void 0);
|
|
1162
1172
|
}
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1173
|
+
function Tt(e) {
|
|
1174
|
+
ut(e, "Pending offline changes were discarded because the session expired"), lt(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), e.setState({
|
|
1165
1175
|
isAuthenticated: !1,
|
|
1166
1176
|
currentUser: null,
|
|
1167
1177
|
comments: [],
|
|
@@ -1187,35 +1197,35 @@ function Et(e) {
|
|
|
1187
1197
|
code: 401
|
|
1188
1198
|
});
|
|
1189
1199
|
}
|
|
1190
|
-
function
|
|
1200
|
+
function Et(e) {
|
|
1191
1201
|
e.setState({ isLoginModalVisible: !e.getState().isLoginModalVisible });
|
|
1192
1202
|
}
|
|
1193
|
-
async function
|
|
1203
|
+
async function Dt(e, t, n, r = () => !0) {
|
|
1194
1204
|
let i = e.config.inviteToken;
|
|
1195
1205
|
if (!i) {
|
|
1196
|
-
e.handleError(
|
|
1206
|
+
e.handleError(P("no_invite", "No invite token found", 400));
|
|
1197
1207
|
return;
|
|
1198
1208
|
}
|
|
1199
|
-
let a =
|
|
1200
|
-
if (!a) e.setState({ isLoading: !1 }), e.handleError(
|
|
1209
|
+
let a = gt(t);
|
|
1210
|
+
if (!a) e.setState({ isLoading: !1 }), e.handleError(P("invalid_email", "A valid email address is required", 400));
|
|
1201
1211
|
else try {
|
|
1202
1212
|
e.setState({
|
|
1203
1213
|
isLoading: !0,
|
|
1204
1214
|
error: null
|
|
1205
1215
|
});
|
|
1206
1216
|
let t = await e.apiClient.validateInvite(i, a);
|
|
1207
|
-
if (!r()) return;
|
|
1208
|
-
t.success ? await n(a) : (e.setState({ isLoading: !1 }), e.handleError(
|
|
1217
|
+
if (t.success && t.accessScope !== "project" && e.config.inviteToken === i && (e.config.inviteToken = void 0), !r()) return;
|
|
1218
|
+
t.success ? await n(a) : (e.setState({ isLoading: !1 }), e.handleError(P("invite_invalid", "Invite validation failed", 400)));
|
|
1209
1219
|
} catch (t) {
|
|
1210
1220
|
if (!r()) return;
|
|
1211
1221
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
1212
1222
|
}
|
|
1213
1223
|
}
|
|
1214
|
-
function
|
|
1224
|
+
function F(e) {
|
|
1215
1225
|
return Object.freeze(e);
|
|
1216
1226
|
}
|
|
1217
|
-
var
|
|
1218
|
-
auth:
|
|
1227
|
+
var Ot = Object.freeze({
|
|
1228
|
+
auth: F([
|
|
1219
1229
|
"isAuthenticated",
|
|
1220
1230
|
"currentUser",
|
|
1221
1231
|
"project",
|
|
@@ -1225,7 +1235,7 @@ var kt = Object.freeze({
|
|
|
1225
1235
|
"otpEmail",
|
|
1226
1236
|
"otpMfaChallenge"
|
|
1227
1237
|
]),
|
|
1228
|
-
ui:
|
|
1238
|
+
ui: F([
|
|
1229
1239
|
"isOverlayVisible",
|
|
1230
1240
|
"isSidebarVisible",
|
|
1231
1241
|
"isShortcutsOverlayVisible",
|
|
@@ -1243,7 +1253,7 @@ var kt = Object.freeze({
|
|
|
1243
1253
|
"isLoading",
|
|
1244
1254
|
"error"
|
|
1245
1255
|
]),
|
|
1246
|
-
comments:
|
|
1256
|
+
comments: F([
|
|
1247
1257
|
"comments",
|
|
1248
1258
|
"pagination",
|
|
1249
1259
|
"seenThreadIds",
|
|
@@ -1251,18 +1261,18 @@ var kt = Object.freeze({
|
|
|
1251
1261
|
"commentQuery",
|
|
1252
1262
|
"loadingThreadId"
|
|
1253
1263
|
]),
|
|
1254
|
-
realtime:
|
|
1264
|
+
realtime: F([
|
|
1255
1265
|
"onlineUsers",
|
|
1256
1266
|
"connectionStatus",
|
|
1257
1267
|
"pendingMutations",
|
|
1258
1268
|
"isOnline"
|
|
1259
1269
|
])
|
|
1260
1270
|
});
|
|
1261
|
-
function
|
|
1271
|
+
function kt() {
|
|
1262
1272
|
return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
|
|
1263
1273
|
}
|
|
1264
|
-
var
|
|
1265
|
-
function
|
|
1274
|
+
var At = 2e3;
|
|
1275
|
+
function jt() {
|
|
1266
1276
|
return {
|
|
1267
1277
|
isAuthenticated: !1,
|
|
1268
1278
|
isOverlayVisible: !0,
|
|
@@ -1297,59 +1307,59 @@ function Mt() {
|
|
|
1297
1307
|
otpMfaChallenge: null,
|
|
1298
1308
|
pagination: null,
|
|
1299
1309
|
pendingMutations: [],
|
|
1300
|
-
isOnline:
|
|
1310
|
+
isOnline: kt()
|
|
1301
1311
|
};
|
|
1302
1312
|
}
|
|
1303
|
-
function
|
|
1313
|
+
function I(e) {
|
|
1304
1314
|
let t = e.config.branch ?? e.getState().activeBranch;
|
|
1305
1315
|
if (!(typeof t != "string" || t.length > 255 || a(t))) return t.trim() || void 0;
|
|
1306
1316
|
}
|
|
1307
|
-
var
|
|
1317
|
+
var L = M.ID, Mt = M.CONTENT, Nt = M.REPLY_CONTENT, Pt = M.SELECTOR, Ft = M.TEXT_SELECTION, It = M.DESCRIPTION, Lt = M.ASSIGNEES, Rt = M.CHECKLIST_ITEMS, zt = M.CHECKLIST_LABEL, Bt = M.DRAWING_PATHS, Vt = M.DRAWING_PATH_DATA, Ht = M.DRAWING_TEXT, Ut = M.REACTION_COUNT, Wt = M.EMOJI, Gt = /* @__PURE__ */ new Set([
|
|
1308
1318
|
"pin",
|
|
1309
1319
|
"highlight",
|
|
1310
1320
|
"drawing"
|
|
1311
|
-
]),
|
|
1321
|
+
]), Kt = /* @__PURE__ */ new Set([
|
|
1312
1322
|
"low",
|
|
1313
1323
|
"medium",
|
|
1314
1324
|
"high",
|
|
1315
1325
|
"urgent"
|
|
1316
|
-
]),
|
|
1326
|
+
]), qt = /* @__PURE__ */ new Set([
|
|
1317
1327
|
"open",
|
|
1318
1328
|
"resolved",
|
|
1319
1329
|
"complete"
|
|
1320
|
-
]),
|
|
1330
|
+
]), Jt = /* @__PURE__ */ new Set([
|
|
1321
1331
|
"path",
|
|
1322
1332
|
"line",
|
|
1323
1333
|
"rectangle",
|
|
1324
1334
|
"circle",
|
|
1325
1335
|
"text"
|
|
1326
1336
|
]);
|
|
1327
|
-
function
|
|
1337
|
+
function R(e, t, n) {
|
|
1328
1338
|
e.handleError(new E(t, n, 400));
|
|
1329
1339
|
}
|
|
1330
|
-
function
|
|
1331
|
-
return r(e,
|
|
1340
|
+
function z(e) {
|
|
1341
|
+
return r(e, L);
|
|
1332
1342
|
}
|
|
1333
|
-
function
|
|
1343
|
+
function B(e, t = Mt) {
|
|
1334
1344
|
if (typeof e != "string") return null;
|
|
1335
1345
|
let n = e.trim();
|
|
1336
1346
|
return !n || n.length > t || c(n) ? null : n;
|
|
1337
1347
|
}
|
|
1338
|
-
function
|
|
1348
|
+
function V(e, t) {
|
|
1339
1349
|
if (e === void 0) return;
|
|
1340
1350
|
if (typeof e != "string") return null;
|
|
1341
1351
|
let n = e.trim();
|
|
1342
1352
|
return n.length > t || c(n) ? null : n;
|
|
1343
1353
|
}
|
|
1344
|
-
function
|
|
1354
|
+
function H(e) {
|
|
1345
1355
|
if (e === void 0) return;
|
|
1346
1356
|
if (typeof e != "string") return null;
|
|
1347
1357
|
let t = e.trim();
|
|
1348
|
-
return !t || t.length >
|
|
1358
|
+
return !t || t.length > Pt || c(t) ? null : t;
|
|
1349
1359
|
}
|
|
1350
|
-
function
|
|
1360
|
+
function Yt(t) {
|
|
1351
1361
|
if (!o(t) || !e(t.x) || !e(t.y)) return null;
|
|
1352
|
-
let n =
|
|
1362
|
+
let n = H(t.element), r = H(t.xpath);
|
|
1353
1363
|
return n === null || r === null ? null : {
|
|
1354
1364
|
x: t.x,
|
|
1355
1365
|
y: t.y,
|
|
@@ -1357,10 +1367,10 @@ function Xt(t) {
|
|
|
1357
1367
|
...r === void 0 ? {} : { xpath: r }
|
|
1358
1368
|
};
|
|
1359
1369
|
}
|
|
1360
|
-
function
|
|
1370
|
+
function Xt(e) {
|
|
1361
1371
|
if (!o(e)) return null;
|
|
1362
|
-
let t =
|
|
1363
|
-
return !
|
|
1372
|
+
let t = V(e.avatar, Pt), n = V(e.organizationId, L);
|
|
1373
|
+
return !z(e.id) || typeof e.name != "string" || !e.name.trim() || e.name.length > M.NAME || c(e.name) || typeof e.email != "string" || !e.email.trim() || e.email.length > M.EMAIL || /\s/.test(e.email.trim()) || c(e.email) || t === null || n === null ? null : {
|
|
1364
1374
|
id: e.id.trim(),
|
|
1365
1375
|
name: e.name.trim(),
|
|
1366
1376
|
email: e.email.trim(),
|
|
@@ -1368,25 +1378,25 @@ function Zt(e) {
|
|
|
1368
1378
|
...n === void 0 ? {} : { organizationId: n }
|
|
1369
1379
|
};
|
|
1370
1380
|
}
|
|
1371
|
-
function
|
|
1381
|
+
function Zt(e) {
|
|
1372
1382
|
if (e === void 0) return;
|
|
1373
|
-
if (!Array.isArray(e) || e.length >
|
|
1383
|
+
if (!Array.isArray(e) || e.length > Lt) return null;
|
|
1374
1384
|
let t = [];
|
|
1375
1385
|
for (let n of e) {
|
|
1376
|
-
let e =
|
|
1386
|
+
let e = Xt(n);
|
|
1377
1387
|
if (!e) return null;
|
|
1378
1388
|
t.push(e);
|
|
1379
1389
|
}
|
|
1380
1390
|
return t;
|
|
1381
1391
|
}
|
|
1382
|
-
function
|
|
1392
|
+
function Qt(e) {
|
|
1383
1393
|
if (e === void 0) return;
|
|
1384
|
-
if (!Array.isArray(e) || e.length >
|
|
1394
|
+
if (!Array.isArray(e) || e.length > Rt) return null;
|
|
1385
1395
|
let t = [];
|
|
1386
1396
|
for (let n of e) {
|
|
1387
1397
|
if (!o(n)) return null;
|
|
1388
|
-
let e =
|
|
1389
|
-
if (!
|
|
1398
|
+
let e = B(n.label);
|
|
1399
|
+
if (!z(n.id) || !e || typeof n.done != "boolean" || n.sortOrder !== void 0 && (typeof n.sortOrder != "number" || !Number.isFinite(n.sortOrder)) || e.length > zt) return null;
|
|
1390
1400
|
t.push({
|
|
1391
1401
|
id: n.id.trim(),
|
|
1392
1402
|
label: e,
|
|
@@ -1396,11 +1406,11 @@ function $t(e) {
|
|
|
1396
1406
|
}
|
|
1397
1407
|
return t;
|
|
1398
1408
|
}
|
|
1399
|
-
function
|
|
1409
|
+
function $t(e) {
|
|
1400
1410
|
if (e === void 0) return;
|
|
1401
1411
|
if (!o(e) || typeof e.text != "string") return null;
|
|
1402
|
-
let t = e.text.trim(), n =
|
|
1403
|
-
return !t || t.length >
|
|
1412
|
+
let t = e.text.trim(), n = H(e.element), r = H(e.xpath);
|
|
1413
|
+
return !t || t.length > Ft || c(t) || typeof e.startOffset != "number" || typeof e.endOffset != "number" || !Number.isInteger(e.startOffset) || !Number.isInteger(e.endOffset) || e.startOffset < 0 || e.endOffset < e.startOffset || n === null || r === null || n === void 0 || r === void 0 ? null : {
|
|
1404
1414
|
text: t,
|
|
1405
1415
|
startOffset: e.startOffset,
|
|
1406
1416
|
endOffset: e.endOffset,
|
|
@@ -1408,20 +1418,20 @@ function en(e) {
|
|
|
1408
1418
|
xpath: r
|
|
1409
1419
|
};
|
|
1410
1420
|
}
|
|
1411
|
-
function
|
|
1412
|
-
return typeof e == "string" && e.length > 0 && e.length <=
|
|
1421
|
+
function en(e) {
|
|
1422
|
+
return typeof e == "string" && e.length > 0 && e.length <= M.COLOR && t(e);
|
|
1413
1423
|
}
|
|
1414
|
-
function
|
|
1424
|
+
function U(e) {
|
|
1415
1425
|
return e === void 0 || typeof e == "number" && Number.isFinite(e);
|
|
1416
1426
|
}
|
|
1417
|
-
function
|
|
1427
|
+
function tn(e) {
|
|
1418
1428
|
if (e === void 0) return;
|
|
1419
|
-
if (!o(e) || e.type !== "svg" || !Array.isArray(e.paths) || e.paths.length >
|
|
1429
|
+
if (!o(e) || e.type !== "svg" || !Array.isArray(e.paths) || e.paths.length > Bt || !o(e.viewport) || typeof e.viewport.width != "number" || typeof e.viewport.height != "number" || !Number.isFinite(e.viewport.width) || !Number.isFinite(e.viewport.height) || e.viewport.width <= 0 || e.viewport.height <= 0) return null;
|
|
1420
1430
|
let t = [];
|
|
1421
1431
|
for (let n of e.paths) {
|
|
1422
|
-
if (!o(n) || !
|
|
1423
|
-
let e =
|
|
1424
|
-
if (!
|
|
1432
|
+
if (!o(n) || !Jt.has(String(n.type))) return null;
|
|
1433
|
+
let e = V(n.text, Ht);
|
|
1434
|
+
if (!en(n.stroke) || !en(n.fill) || typeof n.strokeWidth != "number" || !Number.isFinite(n.strokeWidth) || n.strokeWidth < 0 || n.d !== void 0 && (typeof n.d != "string" || n.d.length > Vt || c(n.d)) || !U(n.x) || !U(n.y) || !U(n.width) || !U(n.height) || e === null) return null;
|
|
1425
1435
|
t.push({
|
|
1426
1436
|
type: n.type,
|
|
1427
1437
|
stroke: n.stroke,
|
|
@@ -1444,19 +1454,19 @@ function nn(e) {
|
|
|
1444
1454
|
}
|
|
1445
1455
|
};
|
|
1446
1456
|
}
|
|
1447
|
-
function
|
|
1457
|
+
function nn(e) {
|
|
1448
1458
|
return o(e) && typeof e.browser == "string" && e.browser.length <= 255 && typeof e.os == "string" && e.os.length <= 255 && typeof e.windowSize == "string" && e.windowSize.length <= 64 && typeof e.devicePixelRatio == "number" && e.devicePixelRatio > 0 && e.devicePixelRatio <= 16 && (e.type === "desktop" || e.type === "mobile") && (e.deployment === void 0 || typeof e.deployment == "string" && e.deployment.length <= 255);
|
|
1449
1459
|
}
|
|
1450
|
-
function
|
|
1460
|
+
function rn(e) {
|
|
1451
1461
|
if (e === void 0) return;
|
|
1452
1462
|
if (!o(e)) return null;
|
|
1453
|
-
let t =
|
|
1463
|
+
let t = V(e.description, It), n = Zt(e.assignees), r = Qt(e.checklist);
|
|
1454
1464
|
if (t === null || n === null || r === null) return null;
|
|
1455
|
-
let i = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0, a = Array.isArray(e.attachmentIds) ? e.attachmentIds.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <=
|
|
1465
|
+
let i = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0, a = Array.isArray(e.attachmentIds) ? e.attachmentIds.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= L).slice(0, 20) : void 0;
|
|
1456
1466
|
return {
|
|
1457
|
-
...Array.isArray(e.mentions) ? { mentions: e.mentions.filter((e) => o(e) &&
|
|
1467
|
+
...Array.isArray(e.mentions) ? { mentions: e.mentions.filter((e) => o(e) && z(e.userId) && typeof e.name == "string").slice(0, 100) } : {},
|
|
1458
1468
|
...typeof e.branch == "string" && e.branch.trim() && e.branch.length <= 255 && !c(e.branch) ? { branch: e.branch.trim() } : {},
|
|
1459
|
-
...
|
|
1469
|
+
...nn(e.deviceInfo) ? { deviceInfo: e.deviceInfo } : {},
|
|
1460
1470
|
...t === void 0 ? {} : { description: t },
|
|
1461
1471
|
...n === void 0 ? {} : { assignees: n },
|
|
1462
1472
|
...r === void 0 ? {} : { checklist: r },
|
|
@@ -1464,69 +1474,69 @@ function an(e) {
|
|
|
1464
1474
|
...a && a.length > 0 ? { attachmentIds: a } : {}
|
|
1465
1475
|
};
|
|
1466
1476
|
}
|
|
1467
|
-
function
|
|
1477
|
+
function an(e) {
|
|
1468
1478
|
if (!o(e)) return null;
|
|
1469
1479
|
let t = {};
|
|
1470
1480
|
if ("content" in e) {
|
|
1471
|
-
let n =
|
|
1481
|
+
let n = B(e.content);
|
|
1472
1482
|
if (!n) return null;
|
|
1473
1483
|
t.content = n;
|
|
1474
1484
|
}
|
|
1475
1485
|
if ("status" in e) {
|
|
1476
|
-
if (!
|
|
1486
|
+
if (!qt.has(e.status)) return null;
|
|
1477
1487
|
t.status = e.status;
|
|
1478
1488
|
}
|
|
1479
1489
|
if ("priority" in e) {
|
|
1480
|
-
if (!
|
|
1490
|
+
if (!Kt.has(e.priority)) return null;
|
|
1481
1491
|
t.priority = e.priority;
|
|
1482
1492
|
}
|
|
1483
1493
|
if ("description" in e) {
|
|
1484
|
-
let n =
|
|
1494
|
+
let n = V(e.description, It);
|
|
1485
1495
|
if (n === null) return null;
|
|
1486
1496
|
t.description = n;
|
|
1487
1497
|
}
|
|
1488
|
-
if (Array.isArray(e.mentions) && (t.mentions = e.mentions.filter((e) => o(e) &&
|
|
1489
|
-
let n =
|
|
1498
|
+
if (Array.isArray(e.mentions) && (t.mentions = e.mentions.filter((e) => o(e) && z(e.userId) && typeof e.name == "string").slice(0, 100)), "assignees" in e) {
|
|
1499
|
+
let n = Zt(e.assignees);
|
|
1490
1500
|
if (n === null) return null;
|
|
1491
1501
|
t.assignees = n;
|
|
1492
1502
|
}
|
|
1493
1503
|
if ("checklistPatch" in e) {
|
|
1494
1504
|
let n = e.checklistPatch;
|
|
1495
|
-
if ("checklist" in e || !o(n) || !
|
|
1505
|
+
if ("checklist" in e || !o(n) || !z(n.id) || typeof n.done != "boolean") return null;
|
|
1496
1506
|
t.checklistPatch = {
|
|
1497
1507
|
id: n.id,
|
|
1498
1508
|
done: n.done
|
|
1499
1509
|
};
|
|
1500
1510
|
}
|
|
1501
1511
|
if ("checklist" in e) {
|
|
1502
|
-
let n =
|
|
1512
|
+
let n = Qt(e.checklist);
|
|
1503
1513
|
if (n === null) return null;
|
|
1504
1514
|
t.checklist = n;
|
|
1505
1515
|
}
|
|
1506
1516
|
if ("textSelection" in e) {
|
|
1507
|
-
let n =
|
|
1517
|
+
let n = $t(e.textSelection);
|
|
1508
1518
|
if (n === null) return null;
|
|
1509
1519
|
t.textSelection = n;
|
|
1510
1520
|
}
|
|
1511
1521
|
if ("drawingData" in e) {
|
|
1512
|
-
let n =
|
|
1522
|
+
let n = tn(e.drawingData);
|
|
1513
1523
|
if (n === null) return null;
|
|
1514
1524
|
t.drawingData = n;
|
|
1515
1525
|
}
|
|
1516
1526
|
if ("attachmentIds" in e) {
|
|
1517
1527
|
let n = e.attachmentIds;
|
|
1518
1528
|
if (!Array.isArray(n)) return null;
|
|
1519
|
-
t.attachmentIds = n.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <=
|
|
1529
|
+
t.attachmentIds = n.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= L).slice(0, 20);
|
|
1520
1530
|
}
|
|
1521
1531
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
1522
1532
|
}
|
|
1523
|
-
function
|
|
1533
|
+
function W(e) {
|
|
1524
1534
|
return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
1525
1535
|
}
|
|
1526
|
-
function
|
|
1536
|
+
function G(e, t) {
|
|
1527
1537
|
return e.getState().comments.some((e) => e.id === t);
|
|
1528
1538
|
}
|
|
1529
|
-
function
|
|
1539
|
+
function K(e, t, n) {
|
|
1530
1540
|
if (e.getState().activeBranch && n.branch !== e.getState().activeBranch) {
|
|
1531
1541
|
e.setState({ comments: e.getState().comments.filter((e) => e.id !== t) });
|
|
1532
1542
|
return;
|
|
@@ -1534,7 +1544,7 @@ function G(e, t, n) {
|
|
|
1534
1544
|
let r = e.getState().comments.filter((e) => e.id !== n.id), i = r.some((e) => e.id === t);
|
|
1535
1545
|
e.setState({ comments: i ? r.map((e) => e.id === t ? n : e) : [...r, n] });
|
|
1536
1546
|
}
|
|
1537
|
-
function
|
|
1547
|
+
function on(e, t, n, r) {
|
|
1538
1548
|
e.setState({ comments: e.getState().comments.map((e) => {
|
|
1539
1549
|
if (e.id !== t) return e;
|
|
1540
1550
|
let i = e.replies.filter((e) => e.id !== r.id), a = i.some((e) => e.id === n);
|
|
@@ -1547,7 +1557,7 @@ function sn(e, t, n, r) {
|
|
|
1547
1557
|
};
|
|
1548
1558
|
}) });
|
|
1549
1559
|
}
|
|
1550
|
-
function
|
|
1560
|
+
function q(e, t) {
|
|
1551
1561
|
return !t || t === e.status ? e : {
|
|
1552
1562
|
...e,
|
|
1553
1563
|
status: t,
|
|
@@ -1555,10 +1565,10 @@ function K(e, t) {
|
|
|
1555
1565
|
...t === "complete" ? {} : { resolvedAt: void 0 }
|
|
1556
1566
|
};
|
|
1557
1567
|
}
|
|
1558
|
-
function
|
|
1568
|
+
function sn(e, t, n) {
|
|
1559
1569
|
return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
|
|
1560
1570
|
}
|
|
1561
|
-
async function
|
|
1571
|
+
async function cn(e) {
|
|
1562
1572
|
let t = e.getState().activeBranch, n = e.getState().commentQuery;
|
|
1563
1573
|
e.setState({ isLoading: !0 });
|
|
1564
1574
|
try {
|
|
@@ -1584,7 +1594,7 @@ async function ln(e) {
|
|
|
1584
1594
|
e.setState({ isLoading: !1 });
|
|
1585
1595
|
}
|
|
1586
1596
|
}
|
|
1587
|
-
async function
|
|
1597
|
+
async function ln(e, t) {
|
|
1588
1598
|
let n = e.getState().activeBranch, r = e.getState().pagination, i = e.getState().commentQuery;
|
|
1589
1599
|
if (r && r.hasMore && !t.current) {
|
|
1590
1600
|
t.current = !0;
|
|
@@ -1610,8 +1620,8 @@ async function un(e, t) {
|
|
|
1610
1620
|
}
|
|
1611
1621
|
}
|
|
1612
1622
|
}
|
|
1613
|
-
async function
|
|
1614
|
-
if (
|
|
1623
|
+
async function un(e, t, n) {
|
|
1624
|
+
if (z(t)) {
|
|
1615
1625
|
e.setState({ loadingThreadId: t });
|
|
1616
1626
|
try {
|
|
1617
1627
|
let r = await e.apiClient.getComment(t, {
|
|
@@ -1641,24 +1651,24 @@ async function dn(e, t, n) {
|
|
|
1641
1651
|
}
|
|
1642
1652
|
}
|
|
1643
1653
|
}
|
|
1644
|
-
async function
|
|
1654
|
+
async function dn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
1645
1655
|
let u = e.getState().currentUser;
|
|
1646
1656
|
if (!u) return;
|
|
1647
|
-
let d =
|
|
1648
|
-
if (!
|
|
1649
|
-
|
|
1657
|
+
let d = B(i), f = Yt(a), p = $t(s), h = tn(c), g = rn(l);
|
|
1658
|
+
if (!Gt.has(r) || !d || !f || !Kt.has(o) || p === null || h === null || g === null) {
|
|
1659
|
+
R(e, "invalid_comment", "Comment data is invalid");
|
|
1650
1660
|
return;
|
|
1651
1661
|
}
|
|
1652
1662
|
let _ = `create:${r}:${d.slice(0, 50)}:${f.x}:${f.y}`;
|
|
1653
1663
|
if (n.has(_)) return;
|
|
1654
1664
|
n.add(_);
|
|
1655
1665
|
let v = m(), y = g?.files ?? [], ee = y.map((e, t) => ({
|
|
1656
|
-
id:
|
|
1666
|
+
id: W(`pending-att-${t}`),
|
|
1657
1667
|
type: e.type.startsWith("image/") ? "screenshot" : "file",
|
|
1658
1668
|
url: "",
|
|
1659
1669
|
filename: e.name,
|
|
1660
1670
|
size: e.size
|
|
1661
|
-
})), b =
|
|
1671
|
+
})), b = W("temp"), te = {
|
|
1662
1672
|
id: b,
|
|
1663
1673
|
type: r,
|
|
1664
1674
|
content: d,
|
|
@@ -1694,7 +1704,9 @@ async function fn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1694
1704
|
isHighlightModeActive: !1
|
|
1695
1705
|
});
|
|
1696
1706
|
try {
|
|
1697
|
-
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r, d, f, v, o, p, h, i, b)
|
|
1707
|
+
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r, d, f, v, o, p, h, i, b);
|
|
1708
|
+
if (e.isCurrent?.() === !1) return;
|
|
1709
|
+
let s = a;
|
|
1698
1710
|
if (y.length > 0) try {
|
|
1699
1711
|
let t = (await Promise.all(y.map(async (t) => {
|
|
1700
1712
|
let n = "." + (t.name.split(".").pop()?.toLowerCase() ?? ""), r = t.type.startsWith("image/") && [
|
|
@@ -1723,7 +1735,7 @@ async function fn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1723
1735
|
attachments: a.attachments ?? []
|
|
1724
1736
|
};
|
|
1725
1737
|
}
|
|
1726
|
-
|
|
1738
|
+
K(e, b, s), e.emit("comment:created", s), t.addActivity({
|
|
1727
1739
|
type: "comment_created",
|
|
1728
1740
|
threadId: s.id,
|
|
1729
1741
|
message: "created a new comment"
|
|
@@ -1755,11 +1767,11 @@ async function fn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1755
1767
|
n.delete(_);
|
|
1756
1768
|
}
|
|
1757
1769
|
}
|
|
1758
|
-
async function
|
|
1759
|
-
if (!
|
|
1760
|
-
let i =
|
|
1770
|
+
async function fn(e, t, n, r) {
|
|
1771
|
+
if (!z(n)) return;
|
|
1772
|
+
let i = an(r);
|
|
1761
1773
|
if (i === null) {
|
|
1762
|
-
|
|
1774
|
+
R(e, "invalid_comment_update", "Comment update data is invalid");
|
|
1763
1775
|
return;
|
|
1764
1776
|
}
|
|
1765
1777
|
if (i === void 0) return;
|
|
@@ -1767,7 +1779,7 @@ async function pn(e, t, n, r) {
|
|
|
1767
1779
|
if (!o) return;
|
|
1768
1780
|
let { checklistPatch: s, ...c } = i;
|
|
1769
1781
|
e.setState({ comments: a.map((e) => e.id === n ? {
|
|
1770
|
-
...
|
|
1782
|
+
...q(e, i.status),
|
|
1771
1783
|
...c,
|
|
1772
1784
|
...s ? { checklist: e.checklist?.map((e) => e.id === s.id ? {
|
|
1773
1785
|
...e,
|
|
@@ -1781,8 +1793,8 @@ async function pn(e, t, n, r) {
|
|
|
1781
1793
|
t.shouldQueueMutation(r) && t.queueMutation("updateComment", [n, i]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? o : e) }), e.handleError(r));
|
|
1782
1794
|
}
|
|
1783
1795
|
}
|
|
1784
|
-
async function
|
|
1785
|
-
if (!
|
|
1796
|
+
async function pn(e, t, n) {
|
|
1797
|
+
if (!z(n)) return;
|
|
1786
1798
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1787
1799
|
if (!i) return;
|
|
1788
1800
|
let a = e.getState().selectedComment;
|
|
@@ -1802,19 +1814,19 @@ async function mn(e, t, n) {
|
|
|
1802
1814
|
}
|
|
1803
1815
|
}
|
|
1804
1816
|
}
|
|
1805
|
-
async function
|
|
1817
|
+
async function mn(e, t, n, r, i) {
|
|
1806
1818
|
let a = e.getState().currentUser;
|
|
1807
|
-
if (!a || !
|
|
1808
|
-
let o =
|
|
1819
|
+
if (!a || !z(n) || !G(e, n)) return;
|
|
1820
|
+
let o = B(r, Nt);
|
|
1809
1821
|
if (!o) {
|
|
1810
|
-
|
|
1822
|
+
R(e, "invalid_reply", "Reply content is invalid");
|
|
1811
1823
|
return;
|
|
1812
1824
|
}
|
|
1813
|
-
if (i?.replyTo && (!
|
|
1814
|
-
|
|
1825
|
+
if (i?.replyTo && (!z(i.replyTo.id) || i.replyTo.id.startsWith("temp_") || !["comment", "reply"].includes(i.replyTo.type) || (i.replyTo.type === "comment" ? i.replyTo.id !== n : !sn(e, n, i.replyTo.id)))) {
|
|
1826
|
+
R(e, "invalid_reply", "Reply target must belong to this thread");
|
|
1815
1827
|
return;
|
|
1816
1828
|
}
|
|
1817
|
-
let s = e.getState().comments.find((e) => e.id === n), c = i?.replyTo?.type === "comment" ? s : s?.replies.find((e) => e.id === i?.replyTo?.id), l =
|
|
1829
|
+
let s = e.getState().comments.find((e) => e.id === n), c = i?.replyTo?.type === "comment" ? s : s?.replies.find((e) => e.id === i?.replyTo?.id), l = W("temp_reply"), u = {
|
|
1818
1830
|
...c && i?.replyTo ? { replyTo: {
|
|
1819
1831
|
...i.replyTo,
|
|
1820
1832
|
authorName: c.author.name,
|
|
@@ -1832,7 +1844,7 @@ async function hn(e, t, n, r, i) {
|
|
|
1832
1844
|
replies: [...e.replies, u]
|
|
1833
1845
|
} : e) });
|
|
1834
1846
|
try {
|
|
1835
|
-
|
|
1847
|
+
on(e, n, l, await e.apiClient.addReply(n, o, l, ...i ? [i] : []));
|
|
1836
1848
|
let t = e.getState().comments.find((e) => e.id === n);
|
|
1837
1849
|
t && e.emit("comment:updated", t);
|
|
1838
1850
|
} catch (r) {
|
|
@@ -1847,11 +1859,11 @@ async function hn(e, t, n, r, i) {
|
|
|
1847
1859
|
} : e) }), e.handleError(r));
|
|
1848
1860
|
}
|
|
1849
1861
|
}
|
|
1850
|
-
async function
|
|
1851
|
-
if (!
|
|
1852
|
-
let a =
|
|
1862
|
+
async function hn(e, t, n, r, i) {
|
|
1863
|
+
if (!z(t) || !z(n) || !sn(e, t, n)) return;
|
|
1864
|
+
let a = B(r, Nt);
|
|
1853
1865
|
if (!a) {
|
|
1854
|
-
|
|
1866
|
+
R(e, "invalid_reply", "Reply content is invalid");
|
|
1855
1867
|
return;
|
|
1856
1868
|
}
|
|
1857
1869
|
let o = e.getState().comments, s = o.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
@@ -1878,8 +1890,8 @@ async function gn(e, t, n, r, i) {
|
|
|
1878
1890
|
} : e) }), e.handleError(r);
|
|
1879
1891
|
}
|
|
1880
1892
|
}
|
|
1881
|
-
async function
|
|
1882
|
-
if (!
|
|
1893
|
+
async function gn(e, t, n) {
|
|
1894
|
+
if (!z(t) || !z(n) || !sn(e, t, n)) return;
|
|
1883
1895
|
let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
1884
1896
|
e.setState({ comments: r.map((e) => e.id === t ? {
|
|
1885
1897
|
...e,
|
|
@@ -1898,10 +1910,10 @@ async function _n(e, t, n) {
|
|
|
1898
1910
|
} : e) }), e.handleError(r);
|
|
1899
1911
|
}
|
|
1900
1912
|
}
|
|
1901
|
-
async function
|
|
1902
|
-
if (!
|
|
1913
|
+
async function _n(e, t, n) {
|
|
1914
|
+
if (!z(n) || !G(e, n)) return;
|
|
1903
1915
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1904
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1916
|
+
e.setState({ comments: r.map((e) => e.id === n ? q(e, "resolved") : e) });
|
|
1905
1917
|
try {
|
|
1906
1918
|
let r = await e.apiClient.resolveComment(n);
|
|
1907
1919
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:resolved", r), e.emit("comment:updated", r), t.addActivity({
|
|
@@ -1913,10 +1925,10 @@ async function vn(e, t, n) {
|
|
|
1913
1925
|
t.shouldQueueMutation(r) && t.queueMutation("resolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1914
1926
|
}
|
|
1915
1927
|
}
|
|
1916
|
-
async function
|
|
1917
|
-
if (!
|
|
1928
|
+
async function vn(e, t, n) {
|
|
1929
|
+
if (!z(n) || !G(e, n)) return;
|
|
1918
1930
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1919
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1931
|
+
e.setState({ comments: r.map((e) => e.id === n ? q(e, "open") : e) });
|
|
1920
1932
|
try {
|
|
1921
1933
|
let t = await e.apiClient.unresolveComment(n);
|
|
1922
1934
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
|
|
@@ -1924,10 +1936,10 @@ async function yn(e, t, n) {
|
|
|
1924
1936
|
t.shouldQueueMutation(r) && t.queueMutation("unresolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1925
1937
|
}
|
|
1926
1938
|
}
|
|
1927
|
-
async function
|
|
1928
|
-
if (!
|
|
1939
|
+
async function yn(e, t, n) {
|
|
1940
|
+
if (!z(n) || !G(e, n)) return;
|
|
1929
1941
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1930
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1942
|
+
e.setState({ comments: r.map((e) => e.id === n ? q(e, "complete") : e) });
|
|
1931
1943
|
try {
|
|
1932
1944
|
let r = await e.apiClient.markComplete(n);
|
|
1933
1945
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:completed", r), t.addActivity({
|
|
@@ -1939,15 +1951,15 @@ async function bn(e, t, n) {
|
|
|
1939
1951
|
t.shouldQueueMutation(r) && t.queueMutation("completeComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1940
1952
|
}
|
|
1941
1953
|
}
|
|
1942
|
-
async function
|
|
1943
|
-
if (!
|
|
1954
|
+
async function bn(e, t, n, r, i) {
|
|
1955
|
+
if (!z(n) || typeof r != "string") return;
|
|
1944
1956
|
let a = r.trim();
|
|
1945
|
-
if (!a || a.length >
|
|
1957
|
+
if (!a || a.length > Wt || c(a)) return;
|
|
1946
1958
|
let o = e.getState().comments.find((e) => e.id === n);
|
|
1947
1959
|
if (!o) return;
|
|
1948
1960
|
let s = i ? o.replies.find((e) => e.id === i) : o;
|
|
1949
1961
|
if (!s) return;
|
|
1950
|
-
let l = (s.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <=
|
|
1962
|
+
let l = (s.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <= Wt && !c(e.emoji) && typeof e.count == "number" && Number.isInteger(e.count) && e.count >= 0 && e.count <= Ut), u = l.find((e) => e.emoji === a)?.reacted, d = [...l];
|
|
1951
1963
|
if (u) {
|
|
1952
1964
|
let e = d.findIndex((e) => e.emoji === a), t = d[e];
|
|
1953
1965
|
t.count <= 1 ? d.splice(e, 1) : d[e] = {
|
|
@@ -1959,7 +1971,7 @@ async function xn(e, t, n, r, i) {
|
|
|
1959
1971
|
let e = d.findIndex((e) => e.emoji === a), t = e === -1 ? void 0 : d[e];
|
|
1960
1972
|
t ? d[e] = {
|
|
1961
1973
|
...t,
|
|
1962
|
-
count: Math.min(t.count + 1,
|
|
1974
|
+
count: Math.min(t.count + 1, Ut),
|
|
1963
1975
|
reacted: !0
|
|
1964
1976
|
} : d.push({
|
|
1965
1977
|
emoji: a,
|
|
@@ -2004,14 +2016,14 @@ async function xn(e, t, n, r, i) {
|
|
|
2004
2016
|
} : e) }), e.handleError(r));
|
|
2005
2017
|
}
|
|
2006
2018
|
}
|
|
2007
|
-
async function
|
|
2008
|
-
if (!
|
|
2009
|
-
let a =
|
|
2019
|
+
async function xn(e, t, n, r, i) {
|
|
2020
|
+
if (!z(n) || !G(e, n)) return;
|
|
2021
|
+
let a = Yt({
|
|
2010
2022
|
x: r,
|
|
2011
2023
|
y: i
|
|
2012
2024
|
});
|
|
2013
2025
|
if (!a) {
|
|
2014
|
-
|
|
2026
|
+
R(e, "invalid_position", "Comment position is invalid");
|
|
2015
2027
|
return;
|
|
2016
2028
|
}
|
|
2017
2029
|
let o = e.getState().comments, s = o.find((e) => e.id === n);
|
|
@@ -2032,21 +2044,21 @@ async function Sn(e, t, n, r, i) {
|
|
|
2032
2044
|
} : e) }), e.handleError(r));
|
|
2033
2045
|
}
|
|
2034
2046
|
}
|
|
2035
|
-
function
|
|
2047
|
+
function Sn(e, t) {
|
|
2036
2048
|
e.setState({ selectedComment: t });
|
|
2037
2049
|
}
|
|
2038
|
-
async function
|
|
2050
|
+
async function Cn(e, t, n, r, i) {
|
|
2039
2051
|
let a = e.getState().currentUser;
|
|
2040
2052
|
if (!a) return;
|
|
2041
|
-
let o =
|
|
2053
|
+
let o = B(i), s = $t(r);
|
|
2042
2054
|
if (!o || s == null) {
|
|
2043
|
-
|
|
2055
|
+
R(e, "invalid_highlight", "Highlight data is invalid");
|
|
2044
2056
|
return;
|
|
2045
2057
|
}
|
|
2046
2058
|
let c = `highlight:${s.xpath}:${s.startOffset}:${o.slice(0, 50)}`;
|
|
2047
2059
|
if (n.has(c)) return;
|
|
2048
2060
|
n.add(c);
|
|
2049
|
-
let l = m(), u =
|
|
2061
|
+
let l = m(), u = I(e), d = u ? { branch: u } : void 0, f = W("temp"), p = {
|
|
2050
2062
|
id: f,
|
|
2051
2063
|
type: "highlight",
|
|
2052
2064
|
...u ? { branch: u } : {},
|
|
@@ -2073,7 +2085,7 @@ async function wn(e, t, n, r, i) {
|
|
|
2073
2085
|
e.setState({ comments: [...e.getState().comments, p] });
|
|
2074
2086
|
try {
|
|
2075
2087
|
let t = await e.apiClient.createHighlight(o, s, l, "medium", f, ...d ? [d] : []);
|
|
2076
|
-
|
|
2088
|
+
K(e, f, t), e.emit("comment:created", t);
|
|
2077
2089
|
} catch (n) {
|
|
2078
2090
|
t.shouldQueueMutation(n) && t.queueMutation("createHighlight", [
|
|
2079
2091
|
o,
|
|
@@ -2089,18 +2101,18 @@ async function wn(e, t, n, r, i) {
|
|
|
2089
2101
|
n.delete(c);
|
|
2090
2102
|
}
|
|
2091
2103
|
}
|
|
2092
|
-
async function
|
|
2104
|
+
async function wn(e, t, n, r, i, a) {
|
|
2093
2105
|
let o = e.getState().currentUser;
|
|
2094
2106
|
if (!o) return;
|
|
2095
|
-
let s =
|
|
2107
|
+
let s = B(a), c = Yt(i), l = tn(r);
|
|
2096
2108
|
if (!s || !c || l == null) {
|
|
2097
|
-
|
|
2109
|
+
R(e, "invalid_drawing", "Drawing comment data is invalid");
|
|
2098
2110
|
return;
|
|
2099
2111
|
}
|
|
2100
2112
|
let u = `drawing:${c.x}:${c.y}:${s.slice(0, 50)}`;
|
|
2101
2113
|
if (n.has(u)) return;
|
|
2102
2114
|
n.add(u);
|
|
2103
|
-
let d = m(), f =
|
|
2115
|
+
let d = m(), f = I(e), p = f ? { branch: f } : void 0, h = W("temp"), g = {
|
|
2104
2116
|
id: h,
|
|
2105
2117
|
type: "drawing",
|
|
2106
2118
|
...f ? { branch: f } : {},
|
|
@@ -2124,7 +2136,7 @@ async function Tn(e, t, n, r, i, a) {
|
|
|
2124
2136
|
e.setState({ comments: [...e.getState().comments, g] });
|
|
2125
2137
|
try {
|
|
2126
2138
|
let t = await e.apiClient.createDrawing(s, l, c, d, h, ...p ? [p] : []);
|
|
2127
|
-
|
|
2139
|
+
K(e, h, t), e.emit("comment:created", t);
|
|
2128
2140
|
} catch (n) {
|
|
2129
2141
|
t.shouldQueueMutation(n) && t.queueMutation("createDrawing", [
|
|
2130
2142
|
s,
|
|
@@ -2141,36 +2153,36 @@ async function Tn(e, t, n, r, i, a) {
|
|
|
2141
2153
|
n.delete(u);
|
|
2142
2154
|
}
|
|
2143
2155
|
}
|
|
2144
|
-
var
|
|
2156
|
+
var Tn = {
|
|
2145
2157
|
c: "comment",
|
|
2146
2158
|
e: "select",
|
|
2147
2159
|
d: "draw",
|
|
2148
2160
|
h: "highlight",
|
|
2149
2161
|
s: "screenshot"
|
|
2150
2162
|
};
|
|
2151
|
-
function
|
|
2163
|
+
function En(e) {
|
|
2152
2164
|
return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
|
|
2153
2165
|
}
|
|
2154
|
-
function
|
|
2166
|
+
function J(e) {
|
|
2155
2167
|
return typeof Element < "u" && e instanceof Element;
|
|
2156
2168
|
}
|
|
2157
|
-
function
|
|
2158
|
-
if (!
|
|
2169
|
+
function Dn(e) {
|
|
2170
|
+
if (!J(e)) return !1;
|
|
2159
2171
|
let t = e.tagName.toLowerCase();
|
|
2160
2172
|
return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
|
|
2161
2173
|
}
|
|
2162
|
-
function
|
|
2174
|
+
function On(e) {
|
|
2163
2175
|
let t = e.activeElement;
|
|
2164
2176
|
for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
|
|
2165
2177
|
return t;
|
|
2166
2178
|
}
|
|
2167
|
-
function
|
|
2168
|
-
return
|
|
2179
|
+
function kn(e) {
|
|
2180
|
+
return En(e).some(Dn) ? !0 : typeof document > "u" ? !1 : Dn(On(document));
|
|
2169
2181
|
}
|
|
2170
|
-
function
|
|
2171
|
-
return
|
|
2182
|
+
function An(e) {
|
|
2183
|
+
return En(e).some((e) => J(e) && (e.hasAttribute("data-commentkit") || e.hasAttribute("data-commentkit-ui") || e.hasAttribute("data-commentkit-host")));
|
|
2172
2184
|
}
|
|
2173
|
-
var
|
|
2185
|
+
var jn = [
|
|
2174
2186
|
"popover",
|
|
2175
2187
|
"dialog",
|
|
2176
2188
|
"alert-dialog",
|
|
@@ -2180,23 +2192,23 @@ var Mn = [
|
|
|
2180
2192
|
"select",
|
|
2181
2193
|
"combobox"
|
|
2182
2194
|
].map((e) => `[data-slot="${e}-content"][data-open]`).join(",");
|
|
2183
|
-
function
|
|
2184
|
-
let t =
|
|
2185
|
-
if (
|
|
2195
|
+
function Mn(e) {
|
|
2196
|
+
let t = En(e), n = t.find((e) => J(e) && e.hasAttribute("data-commentkit-host"));
|
|
2197
|
+
if (J(n)) return !!n.shadowRoot?.querySelector(jn);
|
|
2186
2198
|
if (typeof document < "u" && (t[0] === document.body || t[0] === document.documentElement)) {
|
|
2187
2199
|
let e = document.querySelectorAll("[data-commentkit-host]");
|
|
2188
|
-
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(
|
|
2200
|
+
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(jn);
|
|
2189
2201
|
}
|
|
2190
2202
|
return !1;
|
|
2191
2203
|
}
|
|
2192
|
-
function
|
|
2204
|
+
function Nn(e) {
|
|
2193
2205
|
return (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "K" || e.key === "k" || e.code === "KeyK");
|
|
2194
2206
|
}
|
|
2195
|
-
function
|
|
2207
|
+
function Pn(e) {
|
|
2196
2208
|
let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
|
|
2197
|
-
return
|
|
2209
|
+
return Tn[t] ?? Tn[n] ?? null;
|
|
2198
2210
|
}
|
|
2199
|
-
function
|
|
2211
|
+
function Fn(e) {
|
|
2200
2212
|
e.preventDefault(), e.stopPropagation();
|
|
2201
2213
|
}
|
|
2202
2214
|
function In(e, t) {
|
|
@@ -2215,23 +2227,23 @@ function Ln(e, t) {
|
|
|
2215
2227
|
}
|
|
2216
2228
|
function Rn(e, t, n) {
|
|
2217
2229
|
if (e.defaultPrevented || e.repeat || e.isComposing) return;
|
|
2218
|
-
let r =
|
|
2219
|
-
if (
|
|
2230
|
+
let r = kn(e), i = An(e);
|
|
2231
|
+
if (Nn(e)) {
|
|
2220
2232
|
if (r) return;
|
|
2221
|
-
|
|
2233
|
+
Fn(e), Ln(t, n);
|
|
2222
2234
|
} else if (e.key === "Escape") {
|
|
2223
|
-
if (
|
|
2224
|
-
In(t, n) &&
|
|
2235
|
+
if (Mn(e) || r && !i) return;
|
|
2236
|
+
In(t, n) && Fn(e);
|
|
2225
2237
|
} else if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
2226
2238
|
if (e.key === "?") {
|
|
2227
|
-
|
|
2239
|
+
Fn(e), n.toggleShortcutsOverlay();
|
|
2228
2240
|
return;
|
|
2229
2241
|
}
|
|
2230
|
-
let r =
|
|
2231
|
-
r && (
|
|
2242
|
+
let r = Pn(e);
|
|
2243
|
+
r && (Fn(e), n.setTool(t.activeTool === r ? null : r));
|
|
2232
2244
|
}
|
|
2233
2245
|
}
|
|
2234
|
-
var zn =
|
|
2246
|
+
var zn = M.PENDING_MUTATIONS, Bn = M.RETRY_DELAY, Y = M.ID, Vn = M.CONTENT, Hn = M.REPLY_CONTENT, Un = M.SELECTOR, Wn = M.EMOJI, Gn = /* @__PURE__ */ new Set([
|
|
2235
2247
|
"createComment",
|
|
2236
2248
|
"createHighlight",
|
|
2237
2249
|
"createDrawing",
|
|
@@ -2257,7 +2269,7 @@ function Yn(t) {
|
|
|
2257
2269
|
return o(t) && e(t.x) && e(t.y) && n(t.element, Un) && n(t.xpath, Un);
|
|
2258
2270
|
}
|
|
2259
2271
|
function Xn(e) {
|
|
2260
|
-
return typeof e == "string" && e.length <=
|
|
2272
|
+
return typeof e == "string" && e.length <= M.PAGE && !a(e);
|
|
2261
2273
|
}
|
|
2262
2274
|
function Zn(e) {
|
|
2263
2275
|
return e === void 0 || o(e) && Xn(e.url) && Xn(e.path) && Xn(e.title);
|
|
@@ -2459,7 +2471,7 @@ function Sr(e, t, n) {
|
|
|
2459
2471
|
if (t.current || e.getState().pendingMutations.length === 0) return;
|
|
2460
2472
|
let r = e.getState().pendingMutations[0];
|
|
2461
2473
|
if (!r) return;
|
|
2462
|
-
let i = er(r.retries), a = Math.min(Bn,
|
|
2474
|
+
let i = er(r.retries), a = Math.min(Bn, At * 2 ** i);
|
|
2463
2475
|
t.current = setTimeout(() => {
|
|
2464
2476
|
t.current = null, n();
|
|
2465
2477
|
}, a);
|
|
@@ -2491,7 +2503,7 @@ async function Cr(e, t, n, i) {
|
|
|
2491
2503
|
try {
|
|
2492
2504
|
await l(o);
|
|
2493
2505
|
let r = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2494
|
-
e.setState({ pendingMutations: r }), e.emit("offline:completed", { id: o.id }), r.length > 0 ? X(n) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1,
|
|
2506
|
+
e.setState({ pendingMutations: r }), e.emit("offline:completed", { id: o.id }), r.length > 0 ? X(n) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1, cn(e));
|
|
2495
2507
|
} catch (r) {
|
|
2496
2508
|
let i = {
|
|
2497
2509
|
...o,
|
|
@@ -2502,7 +2514,7 @@ async function Cr(e, t, n, i) {
|
|
|
2502
2514
|
e.setState({ pendingMutations: t }), X(n);
|
|
2503
2515
|
} else {
|
|
2504
2516
|
let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2505
|
-
e.setState({ pendingMutations: i }), Z(e, o.id, rr(r)), i.length > 0 ? (t.reconcileAfterDrain = !0, X(n)) : (t.reconcileAfterDrain = !1,
|
|
2517
|
+
e.setState({ pendingMutations: i }), Z(e, o.id, rr(r)), i.length > 0 ? (t.reconcileAfterDrain = !0, X(n)) : (t.reconcileAfterDrain = !1, cn(e));
|
|
2506
2518
|
}
|
|
2507
2519
|
} finally {
|
|
2508
2520
|
t.current = !1;
|
|
@@ -2577,7 +2589,7 @@ function Q(e, t, n, r, i = !1) {
|
|
|
2577
2589
|
reactions: o.reactions
|
|
2578
2590
|
});
|
|
2579
2591
|
}
|
|
2580
|
-
i ?
|
|
2592
|
+
i ? K(e, r, s) : e.setState({ comments: a.comments.map((e) => e.id === r ? s : e) });
|
|
2581
2593
|
}
|
|
2582
2594
|
function Er(e, t, n, r) {
|
|
2583
2595
|
e.setState({ pendingMutations: e.getState().pendingMutations.map((e) => e.type === "reactToComment" && e.args[0] === t && e.args[3] === n ? {
|
|
@@ -2634,7 +2646,7 @@ async function Dr(e, t) {
|
|
|
2634
2646
|
let [n, r, i] = t.args, a = await e.apiClient.addReply(n, r, t.tempId, ...i ? [i] : []);
|
|
2635
2647
|
if (a && t.tempId) {
|
|
2636
2648
|
let r = e.getState().comments.find((e) => e.id === n), i = e.getState().pendingMutations.some((e) => e.type === "reactToComment" && e.ownerId === t.ownerId && e.args[0] === n && e.args[3] === t.tempId), o = r?.replies.find((e) => e.id === t.tempId);
|
|
2637
|
-
|
|
2649
|
+
on(e, n, t.tempId, i && o ? {
|
|
2638
2650
|
...a,
|
|
2639
2651
|
reactions: o.reactions
|
|
2640
2652
|
} : a), Er(e, n, t.tempId, a.id);
|
|
@@ -2657,7 +2669,7 @@ async function Dr(e, t) {
|
|
|
2657
2669
|
}
|
|
2658
2670
|
var $ = null;
|
|
2659
2671
|
async function Or() {
|
|
2660
|
-
return $ || ($ = await import("./realtime-
|
|
2672
|
+
return $ || ($ = await import("./realtime-yGLX4wMK.js"), $);
|
|
2661
2673
|
}
|
|
2662
2674
|
var kr = typeof window < "u", Ar = /* @__PURE__ */ new Set([
|
|
2663
2675
|
"list",
|
|
@@ -2672,7 +2684,7 @@ var kr = typeof window < "u", Ar = /* @__PURE__ */ new Set([
|
|
|
2672
2684
|
"screenshot",
|
|
2673
2685
|
"select",
|
|
2674
2686
|
null
|
|
2675
|
-
]), Mr = 256, Nr = "0.7.
|
|
2687
|
+
]), Mr = 256, Nr = "0.7.7";
|
|
2676
2688
|
function Pr(e) {
|
|
2677
2689
|
let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
|
|
2678
2690
|
return t ? [
|
|
@@ -2695,7 +2707,7 @@ function Ir(e, t) {
|
|
|
2695
2707
|
}
|
|
2696
2708
|
return !1;
|
|
2697
2709
|
}
|
|
2698
|
-
var Lr = class extends
|
|
2710
|
+
var Lr = class extends et {
|
|
2699
2711
|
get isProcessingQueue() {
|
|
2700
2712
|
return this.queueGuard.current;
|
|
2701
2713
|
}
|
|
@@ -2726,7 +2738,7 @@ var Lr = class extends tt {
|
|
|
2726
2738
|
}, this.config.ui = {
|
|
2727
2739
|
...this.config.ui,
|
|
2728
2740
|
loadRemoteFonts: !1
|
|
2729
|
-
}), kr && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = this.localDemo?.client ?? new ve(this.config), this.apiClient.setOnAuthExpired(() => this.handleAuthExpired()), this.state =
|
|
2741
|
+
}), kr && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = this.localDemo?.client ?? new ve(this.config), this.apiClient.setOnAuthExpired(() => this.handleAuthExpired()), this.state = jt(), this.state.activeBranch = typeof e.branch == "string" && e.branch.trim().length <= 255 && !a(e.branch) && e.branch.trim() || null, this.requiresShortcut() && (this.state.isOverlayVisible = !1), this.screenshotProvider = e.screenshotProvider || null, this.ctx = {
|
|
2730
2742
|
getState: () => this.getInternalState(),
|
|
2731
2743
|
setState: (e) => this.setState(e),
|
|
2732
2744
|
apiClient: this.apiClient,
|
|
@@ -2764,7 +2776,7 @@ var Lr = class extends tt {
|
|
|
2764
2776
|
if (!this.localDemo || this.destroyed) return;
|
|
2765
2777
|
let e = this.localDemo.getSession().expired, t = this.getInternalState().activeBranch ?? null;
|
|
2766
2778
|
this.overlayBeforeTool = null, this.setState({
|
|
2767
|
-
...
|
|
2779
|
+
...jt(),
|
|
2768
2780
|
currentUser: e ? null : { ...this.localDemo.user },
|
|
2769
2781
|
isAuthenticated: !e,
|
|
2770
2782
|
isOverlayVisible: !e,
|
|
@@ -2809,7 +2821,7 @@ var Lr = class extends tt {
|
|
|
2809
2821
|
e?.mode === "hold" && e.key && (this.holdActivationHandler = (e) => {
|
|
2810
2822
|
if (this.destroyed || !this.matchesHoldKey(e)) return;
|
|
2811
2823
|
let t = this.getInternalState().activeTool;
|
|
2812
|
-
e.type === "keydown" && !t && !
|
|
2824
|
+
e.type === "keydown" && !t && !j() ? this.setTool("select") : e.type === "keyup" && t === "select" && this.setTool(null);
|
|
2813
2825
|
}, window.addEventListener("keydown", this.holdActivationHandler), window.addEventListener("keyup", this.holdActivationHandler), this.holdBlurHandler = () => {
|
|
2814
2826
|
this.destroyed || this.getInternalState().activeTool === "select" && this.setTool(null);
|
|
2815
2827
|
}, window.addEventListener("blur", this.holdBlurHandler)), this.toggleHandler = () => this.handleToggleRequest(), window.addEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler = () => this.handleDeepLink(), window.addEventListener("hashchange", this.hashChangeHandler), this.handleDeepLink(), !this.localDemo && (this.onlineHandler = () => {
|
|
@@ -2857,7 +2869,7 @@ var Lr = class extends tt {
|
|
|
2857
2869
|
};
|
|
2858
2870
|
}
|
|
2859
2871
|
let n = e.project?.sdkLatestVersion;
|
|
2860
|
-
n && Ir(n, "0.7.
|
|
2872
|
+
n && Ir(n, "0.7.7") && (console.warn(`[CommentKit] You are using v${Nr}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
|
|
2861
2873
|
current: Nr,
|
|
2862
2874
|
latest: n
|
|
2863
2875
|
})), this.setState({
|
|
@@ -2934,7 +2946,7 @@ var Lr = class extends tt {
|
|
|
2934
2946
|
e.activeTool !== void 0 && e.activeTool !== t.activeTool && this.emit("tool:changed", e.activeTool), e.isOverlayVisible !== void 0 && e.isOverlayVisible !== t.isOverlayVisible && this.emit("overlay:toggled", e.isOverlayVisible), e.isSidebarVisible !== void 0 && e.isSidebarVisible !== t.isSidebarVisible && this.emit("sidebar:toggled", e.isSidebarVisible), e.isLoginModalVisible !== void 0 && e.isLoginModalVisible !== t.isLoginModalVisible && this.emit("loginmodal:toggled", e.isLoginModalVisible), e.isShortcutsOverlayVisible !== void 0 && e.isShortcutsOverlayVisible !== t.isShortcutsOverlayVisible && this.emit("shortcuts:toggled", e.isShortcutsOverlayVisible), e.connectionStatus !== void 0 && e.connectionStatus !== t.connectionStatus && this.emit("connection:changed", e.connectionStatus);
|
|
2935
2947
|
let n = Object.keys(e);
|
|
2936
2948
|
for (let [e, t] of this.sliceSubscribers) {
|
|
2937
|
-
let r =
|
|
2949
|
+
let r = Ot[e];
|
|
2938
2950
|
if (n.some((e) => r.includes(e))) for (let n of t) try {
|
|
2939
2951
|
n(this.state);
|
|
2940
2952
|
} catch (t) {
|
|
@@ -2963,7 +2975,7 @@ var Lr = class extends tt {
|
|
|
2963
2975
|
return this.getWriteAccess().canWrite;
|
|
2964
2976
|
}
|
|
2965
2977
|
getWriteAccess() {
|
|
2966
|
-
return
|
|
2978
|
+
return Xe(this.config, this.getInternalState(), this.writeRestriction);
|
|
2967
2979
|
}
|
|
2968
2980
|
requireCommentWrite() {
|
|
2969
2981
|
let e = this.getWriteAccess();
|
|
@@ -2986,10 +2998,12 @@ var Lr = class extends tt {
|
|
|
2986
2998
|
};
|
|
2987
2999
|
}
|
|
2988
3000
|
async validateInvite(e) {
|
|
2989
|
-
if (
|
|
3001
|
+
if (this.destroyed || this.localDemo) return;
|
|
3002
|
+
let t = this.beginAuthRequest();
|
|
3003
|
+
return Dt(this.ctx, e, (e) => bt(this.ctx, e, t), t);
|
|
2990
3004
|
}
|
|
2991
3005
|
onSlice(e, t) {
|
|
2992
|
-
if (!
|
|
3006
|
+
if (!Ot[e] || typeof t != "function" || this.destroyed) return () => {};
|
|
2993
3007
|
let n = this.sliceSubscribers.get(e);
|
|
2994
3008
|
return n || (n = /* @__PURE__ */ new Set(), this.sliceSubscribers.set(e, n)), n.add(t), () => n.delete(t);
|
|
2995
3009
|
}
|
|
@@ -3039,12 +3053,12 @@ var Lr = class extends tt {
|
|
|
3039
3053
|
}), this.emit("error", r);
|
|
3040
3054
|
}
|
|
3041
3055
|
async restorePersistedSession() {
|
|
3042
|
-
this.config.persistence === "memory" &&
|
|
3043
|
-
let e = this.initialAuthToken === void 0 ? this.config.persistence === "memory" ? void 0 :
|
|
3056
|
+
this.config.persistence === "memory" && lt(this.config.projectId);
|
|
3057
|
+
let e = this.initialAuthToken === void 0 ? this.config.persistence === "memory" ? void 0 : ct(this.config.projectId)?.token : this.initialAuthToken;
|
|
3044
3058
|
if (this.initialAuthToken = void 0, e === void 0) return;
|
|
3045
3059
|
let t = () => !this.destroyed && this.authRequestRevision === 0;
|
|
3046
3060
|
try {
|
|
3047
|
-
let { verifyAndRestoreToken: n } = await import("./token-session-
|
|
3061
|
+
let { verifyAndRestoreToken: n } = await import("./token-session-D92MYbNu.js");
|
|
3048
3062
|
await n(this.ctx, e, t, this.config.persistence !== "memory") && await this.afterAuthenticated();
|
|
3049
3063
|
} catch {
|
|
3050
3064
|
t() && this.handleAuthExpired();
|
|
@@ -3064,7 +3078,7 @@ var Lr = class extends tt {
|
|
|
3064
3078
|
return () => !this.destroyed && e === this.authRequestRevision;
|
|
3065
3079
|
}
|
|
3066
3080
|
async login(e) {
|
|
3067
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3081
|
+
if (!(this.destroyed || this.localDemo)) return this.config.inviteToken ? this.validateInvite(e) : bt(this.ctx, e, this.beginAuthRequest());
|
|
3068
3082
|
}
|
|
3069
3083
|
async verifyOtp(e) {
|
|
3070
3084
|
if (this.destroyed || this.localDemo) return;
|
|
@@ -3079,13 +3093,13 @@ var Lr = class extends tt {
|
|
|
3079
3093
|
return;
|
|
3080
3094
|
}
|
|
3081
3095
|
let n = this.getInternalState().currentUser?.id;
|
|
3082
|
-
return
|
|
3096
|
+
return xt(this.ctx, e, {
|
|
3083
3097
|
isCurrent: this.beginAuthRequest(),
|
|
3084
3098
|
onAuthenticated: async () => {
|
|
3085
3099
|
await this.afterAuthenticated(n);
|
|
3086
3100
|
},
|
|
3087
3101
|
onSuccess: () => {
|
|
3088
|
-
this.otpFailedAttempts = 0, this.otpCooldownUntil = 0;
|
|
3102
|
+
this.config.inviteToken = void 0, this.otpFailedAttempts = 0, this.otpCooldownUntil = 0;
|
|
3089
3103
|
},
|
|
3090
3104
|
onWrongOtp: () => {
|
|
3091
3105
|
if (this.otpFailedAttempts += 1, this.otpFailedAttempts >= 3) {
|
|
@@ -3096,24 +3110,26 @@ var Lr = class extends tt {
|
|
|
3096
3110
|
});
|
|
3097
3111
|
}
|
|
3098
3112
|
cancelOtp() {
|
|
3099
|
-
this.destroyed || (this.authRequestRevision++,
|
|
3113
|
+
this.destroyed || (this.authRequestRevision++, St(this.ctx));
|
|
3100
3114
|
}
|
|
3101
3115
|
async resendOtp() {
|
|
3102
|
-
if (
|
|
3116
|
+
if (this.destroyed || this.localDemo) return;
|
|
3117
|
+
let e = this.getInternalState().otpEmail;
|
|
3118
|
+
return this.config.inviteToken && e ? this.validateInvite(e) : Ct(this.ctx, this.beginAuthRequest());
|
|
3103
3119
|
}
|
|
3104
3120
|
logout() {
|
|
3105
3121
|
this.destroyed || (this.authRequestRevision++, this.localDemo ? (this.setTool(null), this.setState({
|
|
3106
3122
|
isOverlayVisible: !1,
|
|
3107
3123
|
isSidebarVisible: !1
|
|
3108
|
-
})) : (this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null,
|
|
3124
|
+
})) : (this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, wt(this.ctx, () => {
|
|
3109
3125
|
this.disconnectRealtime(!0);
|
|
3110
3126
|
})));
|
|
3111
3127
|
}
|
|
3112
3128
|
handleAuthExpired() {
|
|
3113
|
-
this.destroyed || (this.authRequestRevision++, this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, this.disconnectRealtime(!0),
|
|
3129
|
+
this.destroyed || (this.authRequestRevision++, this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, this.disconnectRealtime(!0), Tt(this.ctx));
|
|
3114
3130
|
}
|
|
3115
3131
|
toggleLoginModal() {
|
|
3116
|
-
this.destroyed || this.localDemo || (this.getInternalState().isLoginModalVisible && this.cancelOtp(),
|
|
3132
|
+
this.destroyed || this.localDemo || (this.getInternalState().isLoginModalVisible && this.cancelOtp(), Et(this.ctx));
|
|
3117
3133
|
}
|
|
3118
3134
|
requiresShortcut() {
|
|
3119
3135
|
return this.localDemo ? !0 : this.config.environment !== "development";
|
|
@@ -3204,10 +3220,10 @@ var Lr = class extends tt {
|
|
|
3204
3220
|
};
|
|
3205
3221
|
}
|
|
3206
3222
|
async loadComments() {
|
|
3207
|
-
return
|
|
3223
|
+
return cn(this.commentsRequestContext(++this.commentsFetchRevision));
|
|
3208
3224
|
}
|
|
3209
3225
|
async loadMoreComments() {
|
|
3210
|
-
this.destroyed || await
|
|
3226
|
+
this.destroyed || await ln(this.commentsRequestContext(this.commentsFetchRevision), this.loadMoreGuard);
|
|
3211
3227
|
}
|
|
3212
3228
|
async setCommentQuery(e) {
|
|
3213
3229
|
if (this.destroyed || !this.getInternalState().isAuthenticated || this.localDemo) return;
|
|
@@ -3223,7 +3239,7 @@ var Lr = class extends tt {
|
|
|
3223
3239
|
}
|
|
3224
3240
|
async loadEarlierReplies() {
|
|
3225
3241
|
let e = this.getInternalState(), t = e.comments.find((t) => t.id === e.selectedComment?.id);
|
|
3226
|
-
if (!(this.destroyed || e.loadingThreadId || !t?.repliesPagination?.nextCursor)) return
|
|
3242
|
+
if (!(this.destroyed || e.loadingThreadId || !t?.repliesPagination?.nextCursor)) return un(this.operationContext(), t.id, t.repliesPagination.nextCursor);
|
|
3227
3243
|
}
|
|
3228
3244
|
async reloadComments() {
|
|
3229
3245
|
if (!this.destroyed) return this.loadComments();
|
|
@@ -3327,45 +3343,55 @@ var Lr = class extends tt {
|
|
|
3327
3343
|
});
|
|
3328
3344
|
return;
|
|
3329
3345
|
}
|
|
3330
|
-
let s = o?.[
|
|
3331
|
-
return
|
|
3346
|
+
let s = o?.[tt];
|
|
3347
|
+
return dn(this.operationContext(s), this.operationCallbacks(s), this.activeMutations, e, t, n, r, i, a, {
|
|
3332
3348
|
...o,
|
|
3333
|
-
branch: o?.branch ??
|
|
3349
|
+
branch: o?.branch ?? I(this.ctx)
|
|
3334
3350
|
});
|
|
3335
3351
|
}
|
|
3336
3352
|
async updateComment(e, t) {
|
|
3337
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3353
|
+
if (!this.destroyed && this.requireCommentWrite()) return fn(this.operationContext(), this.operationCallbacks(), e, t);
|
|
3338
3354
|
}
|
|
3339
3355
|
async deleteComment(e) {
|
|
3340
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3356
|
+
if (!this.destroyed && this.requireCommentWrite()) return pn(this.operationContext(), this.operationCallbacks(), e);
|
|
3341
3357
|
}
|
|
3342
3358
|
async addReply(e, t, n) {
|
|
3343
3359
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3344
|
-
let { [
|
|
3345
|
-
return
|
|
3360
|
+
let { [tt]: r, ...i } = n ?? {};
|
|
3361
|
+
return mn(this.operationContext(r), this.operationCallbacks(r), e, t, n ? i : void 0);
|
|
3346
3362
|
}
|
|
3347
3363
|
async updateReply(e, t, n, r) {
|
|
3348
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3364
|
+
if (!this.destroyed && this.requireCommentWrite()) return hn(this.operationContext(), e, t, n, r);
|
|
3349
3365
|
}
|
|
3350
3366
|
async deleteReply(e, t) {
|
|
3351
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3367
|
+
if (!this.destroyed && this.requireCommentWrite()) return gn(this.operationContext(), e, t);
|
|
3368
|
+
}
|
|
3369
|
+
requireThreadStatus(e, t = !1) {
|
|
3370
|
+
let n = this.getInternalState();
|
|
3371
|
+
if (n.projectContext?.permissions?.accessScope !== "project") return !0;
|
|
3372
|
+
let r = n.comments.find((t) => t.id === e)?.author.id === n.currentUser?.id;
|
|
3373
|
+
return !t && r ? !0 : (this.handleError({
|
|
3374
|
+
error: "forbidden",
|
|
3375
|
+
message: t ? "Only workspace members can mark feedback complete." : "You can only resolve or reopen your own feedback.",
|
|
3376
|
+
code: 403
|
|
3377
|
+
}), !1);
|
|
3352
3378
|
}
|
|
3353
3379
|
async resolveComment(e) {
|
|
3354
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3380
|
+
if (!this.destroyed && this.requireCommentWrite() && this.requireThreadStatus(e)) return _n(this.operationContext(), this.operationCallbacks(), e);
|
|
3355
3381
|
}
|
|
3356
3382
|
async unresolveComment(e) {
|
|
3357
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3383
|
+
if (!this.destroyed && this.requireCommentWrite() && this.requireThreadStatus(e)) return vn(this.operationContext(), this.operationCallbacks(), e);
|
|
3358
3384
|
}
|
|
3359
3385
|
selectComment(e) {
|
|
3360
|
-
this.destroyed || (
|
|
3386
|
+
this.destroyed || (Sn(this.operationContext(), e), e?.detailLoaded === !1 && !this.localDemo && un(this.operationContext(), e.id));
|
|
3361
3387
|
}
|
|
3362
3388
|
async completeComment(e) {
|
|
3363
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3389
|
+
if (!this.destroyed && this.requireCommentWrite() && this.requireThreadStatus(e, !0)) return yn(this.operationContext(), this.operationCallbacks(), e);
|
|
3364
3390
|
}
|
|
3365
3391
|
async reactToComment(e, t, n) {
|
|
3366
3392
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3367
3393
|
let r = `${e}:${n ?? "parent"}`, i = this.sessionRevision, a = async () => {
|
|
3368
|
-
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await
|
|
3394
|
+
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await bn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3369
3395
|
}, o = this.reactionRequests.get(r), s = o ? o.then(a, a) : a();
|
|
3370
3396
|
this.reactionRequests.set(r, s);
|
|
3371
3397
|
try {
|
|
@@ -3375,7 +3401,7 @@ var Lr = class extends tt {
|
|
|
3375
3401
|
}
|
|
3376
3402
|
}
|
|
3377
3403
|
async updateCommentPosition(e, t, n) {
|
|
3378
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3404
|
+
if (!this.destroyed && this.requireCommentWrite()) return xn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3379
3405
|
}
|
|
3380
3406
|
hydrateOfflineQueue() {
|
|
3381
3407
|
if (this.config.persistence === "memory") return;
|
|
@@ -3493,10 +3519,10 @@ var Lr = class extends tt {
|
|
|
3493
3519
|
}
|
|
3494
3520
|
}
|
|
3495
3521
|
async createHighlight(e, t) {
|
|
3496
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3522
|
+
if (!this.destroyed && this.requireCommentWrite()) return Cn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t);
|
|
3497
3523
|
}
|
|
3498
3524
|
async createDrawing(e, t, n) {
|
|
3499
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3525
|
+
if (!this.destroyed && this.requireCommentWrite()) return wn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t, n);
|
|
3500
3526
|
}
|
|
3501
3527
|
setActiveDrawing(e) {
|
|
3502
3528
|
this.destroyed || this.setState({ activeDrawing: e });
|
|
@@ -3506,12 +3532,12 @@ var Lr = class extends tt {
|
|
|
3506
3532
|
}
|
|
3507
3533
|
async captureScreenshot(e) {
|
|
3508
3534
|
if (this.destroyed) return null;
|
|
3509
|
-
let { captureScreenshot: t } = await import("./screenshot-
|
|
3535
|
+
let { captureScreenshot: t } = await import("./screenshot-B5-hwpmt.js");
|
|
3510
3536
|
return this.destroyed ? null : t(this.ctx, this.screenshotProvider, e);
|
|
3511
3537
|
}
|
|
3512
3538
|
async uploadScreenshot(e, t, n) {
|
|
3513
3539
|
if (this.destroyed || !this.requireCommentWrite()) return null;
|
|
3514
|
-
let r = this.operationContext(), { uploadScreenshot: i } = await import("./screenshot-
|
|
3540
|
+
let r = this.operationContext(), { uploadScreenshot: i } = await import("./screenshot-B5-hwpmt.js");
|
|
3515
3541
|
return this.destroyed || r.isCurrent?.() === !1 || !this.requireCommentWrite() ? null : i(r, e, t, n);
|
|
3516
3542
|
}
|
|
3517
3543
|
setActiveScreenshot(e) {
|
|
@@ -3519,14 +3545,18 @@ var Lr = class extends tt {
|
|
|
3519
3545
|
}
|
|
3520
3546
|
async uploadFiles(e, t) {
|
|
3521
3547
|
if (this.destroyed || !this.requireCommentWrite()) return [];
|
|
3522
|
-
let n = this.operationContext(), { uploadFiles: r } = await import("./screenshot-
|
|
3548
|
+
let n = this.operationContext(), { uploadFiles: r } = await import("./screenshot-B5-hwpmt.js");
|
|
3523
3549
|
return this.destroyed || n.isCurrent?.() === !1 || !this.requireCommentWrite() ? [] : r(n, e, t);
|
|
3524
3550
|
}
|
|
3551
|
+
requireAgentExport() {
|
|
3552
|
+
if (this.getInternalState().projectContext?.permissions.canExportAgentContext === !1) throw new E("forbidden", "Agent handoff is available to workspace members.", 403);
|
|
3553
|
+
}
|
|
3525
3554
|
getAgentContext(e) {
|
|
3526
|
-
return
|
|
3555
|
+
return this.requireAgentExport(), k(this.getInternalState(), e);
|
|
3527
3556
|
}
|
|
3528
3557
|
async getAgentContextAsync(e) {
|
|
3529
|
-
|
|
3558
|
+
this.requireAgentExport();
|
|
3559
|
+
let t = this.getInternalState(), n = k(t, e);
|
|
3530
3560
|
if (!this.localDemo && t.isAuthenticated) {
|
|
3531
3561
|
let r = new Set(n.comments.map((e) => e.id)), i = t.comments.filter((e) => r.has(e.id) && e.detailLoaded === !1), a = /* @__PURE__ */ new Map(), o = this.sessionRevision;
|
|
3532
3562
|
for (let e = 0; e < i.length; e += 4) {
|
|
@@ -3534,32 +3564,34 @@ var Lr = class extends tt {
|
|
|
3534
3564
|
if (this.destroyed || o !== this.sessionRevision || !this.getInternalState().isAuthenticated) throw new E("unauthorized", "Sign in again to copy feedback.", 401);
|
|
3535
3565
|
for (let e of t) a.set(e.id, e);
|
|
3536
3566
|
}
|
|
3537
|
-
a.size && (n =
|
|
3567
|
+
a.size && (n = k({
|
|
3538
3568
|
...t,
|
|
3539
3569
|
comments: t.comments.map((e) => a.get(e.id) ?? e)
|
|
3540
3570
|
}, e));
|
|
3541
3571
|
}
|
|
3542
|
-
let r = this.localDemo?.getRevision(), i = await
|
|
3543
|
-
return this.localDemo?.checkExpiry(), this.localDemo && r !== this.localDemo.getRevision() ?
|
|
3572
|
+
let r = this.localDemo?.getRevision(), i = await He(n);
|
|
3573
|
+
return this.localDemo?.checkExpiry(), this.localDemo && r !== this.localDemo.getRevision() ? k(this.getInternalState(), e) : i;
|
|
3544
3574
|
}
|
|
3545
3575
|
formatAgentContext(e) {
|
|
3546
|
-
return
|
|
3576
|
+
return A(this.getAgentContext(e));
|
|
3547
3577
|
}
|
|
3548
3578
|
async formatAgentContextAsync(e) {
|
|
3549
|
-
return
|
|
3579
|
+
return A(await this.getAgentContextAsync(e));
|
|
3550
3580
|
}
|
|
3551
3581
|
async copyAgentContext(e) {
|
|
3552
3582
|
if (this.destroyed) return "";
|
|
3553
|
-
let t = await this.getAgentContextAsync(e), n =
|
|
3554
|
-
return await
|
|
3583
|
+
let t = await this.getAgentContextAsync(e), n = A(t);
|
|
3584
|
+
return await Ye(n, t), this.emit("agent:context-copied", {
|
|
3555
3585
|
commentCount: t.comments.length,
|
|
3556
3586
|
sourceResolved: t.sourceResolved
|
|
3557
3587
|
}), n;
|
|
3558
3588
|
}
|
|
3559
3589
|
async grabElement(e, t) {
|
|
3560
3590
|
if (this.destroyed) return null;
|
|
3561
|
-
|
|
3591
|
+
this.requireAgentExport();
|
|
3592
|
+
let { grabElement: n } = await import("./dev-grab-B85jo9AS.js");
|
|
3562
3593
|
if (this.destroyed) return null;
|
|
3594
|
+
this.requireAgentExport();
|
|
3563
3595
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3564
3596
|
return this.destroyed ? null : (r && this.emit("agent:element-grabbed", {
|
|
3565
3597
|
source: r.element.source?.filePath ?? null,
|
|
@@ -3568,8 +3600,10 @@ var Lr = class extends tt {
|
|
|
3568
3600
|
}
|
|
3569
3601
|
async grabElements(e, t) {
|
|
3570
3602
|
if (this.destroyed) return null;
|
|
3571
|
-
|
|
3603
|
+
this.requireAgentExport();
|
|
3604
|
+
let { grabElements: n } = await import("./dev-grab-B85jo9AS.js");
|
|
3572
3605
|
if (this.destroyed) return null;
|
|
3606
|
+
this.requireAgentExport();
|
|
3573
3607
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3574
3608
|
return this.destroyed ? null : (r && this.emit("agent:elements-grabbed", { count: r.results.length }), r);
|
|
3575
3609
|
}
|
|
@@ -3582,10 +3616,10 @@ var Lr = class extends tt {
|
|
|
3582
3616
|
}
|
|
3583
3617
|
}
|
|
3584
3618
|
handleToggleRequest() {
|
|
3585
|
-
this.destroyed ||
|
|
3619
|
+
this.destroyed || j() || Ln(this.getInternalState(), this.kbdCallbacks);
|
|
3586
3620
|
}
|
|
3587
3621
|
handleKeyboardShortcuts(e) {
|
|
3588
|
-
if (!(this.destroyed ||
|
|
3622
|
+
if (!(this.destroyed || j())) {
|
|
3589
3623
|
if (e.key === "Escape") {
|
|
3590
3624
|
if (this.escapeBlockers.size > 0) return;
|
|
3591
3625
|
let t = e.composedPath()[0];
|
|
@@ -3645,4 +3679,4 @@ var Lr = class extends tt {
|
|
|
3645
3679
|
this.destroyed || (this.destroyed = !0, this.initialAuthToken = void 0, kr && (this.keyboardHandler && window.removeEventListener("keydown", this.keyboardHandler, !0), this.holdActivationHandler && (window.removeEventListener("keydown", this.holdActivationHandler), window.removeEventListener("keyup", this.holdActivationHandler)), this.holdBlurHandler && window.removeEventListener("blur", this.holdBlurHandler), this.toggleHandler && window.removeEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler && window.removeEventListener("hashchange", this.hashChangeHandler), this.onlineHandler && window.removeEventListener("online", this.onlineHandler), this.offlineHandler && window.removeEventListener("offline", this.offlineHandler)), this.pendingStateUpdates = null, this.flushScheduled = !1, this.activeMutations.clear(), this.offlinePersistUnsub?.(), this.offlinePersistUnsub = null, this.retryTimer &&= (clearTimeout(this.retryTimer), null), this.bootRetryTimer &&= (clearTimeout(this.bootRetryTimer), null), this.disconnectRealtime(!0), this.localDemo?.destroy(), this.sliceSubscribers.clear(), this.removeAllListeners());
|
|
3646
3680
|
}
|
|
3647
3681
|
};
|
|
3648
|
-
export { ve as _,
|
|
3682
|
+
export { ve as _, vt as a, T as b, tt as c, Xe as d, Je as f, we as g, A as h, yt as i, et as l, k as m, Nr as n, st as o, Ye as p, I as r, M as s, Lr as t, j as u, E as v, be as x, ye as y };
|