use-chisel 0.1.8 → 0.1.9
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/README.md +3 -2
- package/dist/hosted-entry.js +4 -133
- package/dist/index.js +5 -168
- package/dist/review-content-entry.js +2 -2
- package/dist/review-entry.js +3 -3
- package/dist/workspace-entry.js +7 -346
- package/package.json +4 -4
- package/dist/persistence.d.ts +0 -30
- package/dist/review/media-lightbox.d.ts +0 -8
- package/dist/theme.d.ts +0 -1
- package/dist/workspace/area.d.ts +0 -10
- package/dist/workspace/color-picker.d.ts +0 -6
- package/dist/workspace/color.d.ts +0 -9
- package/dist/workspace/comment-drag-handle.d.ts +0 -3
- package/dist/workspace/composer-position.d.ts +0 -13
- package/dist/workspace/confirmation.d.ts +0 -11
- package/dist/workspace/hover-dismiss.d.ts +0 -4
- package/dist/workspace/mode-shortcuts.d.ts +0 -1
- package/dist/workspace/page-control.d.ts +0 -7
- package/dist/workspace/preview-navigation.d.ts +0 -4
- package/dist/workspace/thread-morph.d.ts +0 -1
package/README.md
CHANGED
|
@@ -121,5 +121,6 @@ dictation, and explicit submit in the same form. Custom rich text can be passed
|
|
|
121
121
|
optional mutation `body`, with validated upload IDs in `attachmentTokens`. Adapters
|
|
122
122
|
must validate both before storing them and bind uploads to the authenticated user
|
|
123
123
|
and site. Keep the editor and attachment draft when `onSubmit` or `onReply` returns
|
|
124
|
-
`false`; release it only after a successful save.
|
|
125
|
-
|
|
124
|
+
`false`; release it only after a successful save. The shared rich-text review UI
|
|
125
|
+
uses Slate. Supabase stays in the hosted service or the host's adapter; client
|
|
126
|
+
projects do not need its SDK. Icons are bundled at build time.
|
package/dist/hosted-entry.js
CHANGED
|
@@ -1,134 +1,5 @@
|
|
|
1
|
-
"use client";import{
|
|
2
|
-
.chisel-review .comment-thread[data-native-ui=true]{padding:0;gap:0;border:0;border-radius:
|
|
3
|
-
|
|
4
|
-
.chisel-review .comment-thread[data-native-ui=true] form{width:100%}
|
|
5
|
-
.chisel-review-thread-content{width:100%;min-width:0}
|
|
6
|
-
.chisel-review-message{display:flex;gap:12px;padding:16px}
|
|
7
|
-
.chisel-review-message-content{min-width:0;flex:1}
|
|
8
|
-
.chisel-review-avatar{width:32px;height:32px;flex-shrink:0}
|
|
9
|
-
.chisel-review-avatar img,.chisel-review .feedback-reply-avatar img{width:100%;height:100%;object-fit:cover;border-radius:inherit}
|
|
10
|
-
.chisel-review-byline{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline;line-height:1.5}
|
|
11
|
-
.chisel-review-byline strong{font-weight:500}
|
|
12
|
-
.chisel-review-byline time{color:var(--chisel-ui-secondary);font-size:12px;font-variant-numeric:tabular-nums}
|
|
13
|
-
.chisel-rich-body{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;color:var(--chisel-ui-text)}
|
|
14
|
-
.chisel-rich-body p,.chisel-rich-editor p{margin:0;min-height:1.5em}
|
|
15
|
-
.chisel-rich-body a,.chisel-rich-editor a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:2px}
|
|
16
|
-
.chisel-rich-body code,.chisel-rich-editor code{font:0.9em ui-monospace,monospace;background:var(--chisel-ui-inset);padding:1px 3px;border-radius:4px}
|
|
17
|
-
.chisel-review .chisel-expand-thread{margin:0 16px 12px 60px;min-height:40px;padding:0;background:transparent;color:var(--chisel-ui-accent-text)}
|
|
18
|
-
.chisel-review-reply{display:flex;align-items:flex-start;gap:12px;padding:16px;border-top:1px solid var(--chisel-ui-border)}
|
|
19
|
-
.chisel-rich-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow-y:auto;padding:8px;font-size:14px;line-height:1.5;outline:none;overflow-wrap:anywhere}
|
|
20
|
-
.chisel-review-reply .chisel-rich-editor{padding:12px 14px;min-height:44px}
|
|
21
|
-
.chisel-review .comment-box-native{border:0;border-radius:var(--chisel-ui-radius);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font:inherit}
|
|
22
|
-
.chisel-review .comment-box-native>form{display:flex;flex-direction:column;min-height:0;height:100%;flex:1}
|
|
23
|
-
.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
|
|
24
|
-
.chisel-review .comment-box-native .comment-box-symbol{margin-top:0;background:transparent;border-radius:8px}
|
|
25
|
-
.chisel-review .comment-box-native .comment-box-footer{background:var(--chisel-ui-surface);border-top:1px solid var(--chisel-ui-border)}
|
|
26
|
-
.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent;font:inherit}
|
|
27
|
-
.chisel-review .comment-box-native .comment-box-submit{border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
|
|
28
|
-
.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-inset)}
|
|
29
|
-
.chisel-review .comment-box-native .comment-box-properties{background:var(--chisel-ui-surface)}
|
|
30
|
-
.chisel-review .feedback-comment{border-radius:var(--chisel-ui-radius)}
|
|
31
|
-
.chisel-review .comment-thread[data-expanded=false] .chisel-rich-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.5em;overflow:hidden}
|
|
32
|
-
.chisel-review [data-slate-placeholder]{color:var(--chisel-ui-secondary);opacity:1!important}
|
|
33
|
-
.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;border:1px solid var(--chisel-ui-border);border-radius:16px;background:var(--chisel-ui-raised)}
|
|
34
|
-
.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:50%;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
|
|
35
|
-
.chisel-review .feedback-reply-avatar{width:32px;height:32px;margin-top:8px}
|
|
36
|
-
.chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
|
|
37
|
-
.chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;font-size:12px;color:var(--chisel-ui-secondary)}
|
|
38
|
-
.chisel-review-reply .chisel-attachment-controls{padding-right:48px}
|
|
39
|
-
.chisel-formatting-tools button{display:grid;place-items:center;width:40px;height:40px;flex-shrink:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary);transition:background 150ms,scale 150ms}
|
|
40
|
-
.chisel-formatting-tools button:hover{background:var(--chisel-ui-hover)}
|
|
41
|
-
.chisel-formatting-tools button[aria-pressed=true]{color:var(--chisel-ui-accent-text);background:var(--chisel-ui-accent-surface)}
|
|
42
|
-
.chisel-formatting-tools{display:flex;gap:0;flex-wrap:wrap;padding:0 4px}
|
|
43
|
-
.chisel-formatting-tools button:active{scale:0.96}
|
|
44
|
-
.chisel-link-dialog{display:flex;flex-wrap:wrap;gap:6px;padding:8px;border-top:1px solid var(--chisel-ui-border);background:var(--chisel-ui-surface)}
|
|
45
|
-
.chisel-link-dialog label{flex:1;min-width:120px;font-size:12px;color:var(--chisel-ui-secondary)}
|
|
46
|
-
.chisel-link-dialog input{display:block;width:100%;height:40px;background:var(--chisel-ui-inset);border:1px solid var(--chisel-ui-border);border-radius:6px;color:var(--chisel-ui-text);padding:6px}
|
|
47
|
-
.chisel-link-dialog button{align-self:flex-end;min-height:40px;min-width:40px;padding:6px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
|
|
48
|
-
.chisel-link-dialog [role=alert]{width:100%;color:var(--chisel-ui-danger);font-size:12px}
|
|
49
|
-
.chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
|
|
50
|
-
.chisel-attachment-previews{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
|
|
51
|
-
.chisel-attachment-preview{position:relative;min-width:0;overflow:hidden;border:1px solid var(--chisel-ui-border);border-radius:8px;background:var(--chisel-ui-surface)}
|
|
52
|
-
.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{display:block;width:100%;height:100px;object-fit:contain;background:var(--chisel-ui-inset);outline:1px solid #0000001a;outline-offset:-1px}
|
|
53
|
-
.chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
|
|
54
|
-
.chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
|
|
55
|
-
.chisel-attachment-preview>.chisel-attachment-retry{right:40px;border-radius:0 0 0 8px}
|
|
56
|
-
.chisel-attachment-preview>.chisel-attachment-load{position:static;width:100%;height:auto;min-height:100px;padding:8px}
|
|
57
|
-
.comment-thread .feedback-thread-header{position:sticky;top:0;z-index:1;background:var(--chisel-ui-surface)}
|
|
58
|
-
.chisel-review .comment-thread[data-native-ui=true][data-expanded=false]{border-radius:16px 16px 16px 0}
|
|
59
|
-
@media(prefers-color-scheme:dark){.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{outline-color:#ffffff1a}}
|
|
60
|
-
@media(prefers-reduced-motion:reduce){.chisel-formatting-tools button{transition:none}}
|
|
61
|
-
`;var X=`/* Shared presentation for the owned review UI. */
|
|
62
|
-
.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native{border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:var(--chisel-ui-popover-shadow)}
|
|
63
|
-
.feedback-shell.chisel-review .comment-thread[data-expanded=false]{border-radius:16px 16px 16px 0}
|
|
64
|
-
.chisel-review-thread-content,.review-thread,.review-comment-content{width:100%;min-width:0}
|
|
65
|
-
.review-comment,.feedback-shell.chisel-review .chisel-review-message{display:flex;align-items:flex-start;gap:12px;padding:12px 20px}
|
|
66
|
-
.review-comment-content,.chisel-review-message-content{flex:1;min-width:0}
|
|
67
|
-
.review-comment-avatar{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:50%;overflow:hidden;background:var(--chisel-ui-avatar);color:var(--chisel-ui-avatar-text);font-size:12px}
|
|
68
|
-
.review-comment-avatar img{width:100%;height:100%;object-fit:cover}
|
|
69
|
-
.review-comment-header,.chisel-review-byline{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;line-height:20px;margin-bottom:4px}
|
|
70
|
-
.review-comment-author{font-size:13px;font-weight:500;overflow-wrap:anywhere}
|
|
71
|
-
.review-comment-time{font-size:12px;color:var(--chisel-ui-muted);font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
72
|
-
.review-comment-header{position:relative;padding-right:32px}
|
|
73
|
-
.review-comment-edit{position:absolute;right:-8px;top:-10px;display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-muted);opacity:0;transition:opacity 120ms,background 120ms}
|
|
74
|
-
.review-comment:hover .review-comment-edit,.review-comment:focus-within .review-comment-edit,.review-comment-edit:focus-visible{opacity:1}
|
|
75
|
-
.review-comment-edit:hover{background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
|
|
76
|
-
@media(hover:none){.review-comment-edit{opacity:1}}
|
|
77
|
-
.review-inline-edit{border:1px solid var(--chisel-ui-border);border-radius:10px;padding:8px}
|
|
78
|
-
.review-inline-edit-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:8px}
|
|
79
|
-
.review-inline-edit-actions button{min-height:32px;padding:0 10px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
|
|
80
|
-
.review-comment-body,.chisel-rich-body{font-size:14px;line-height:21px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
81
|
-
.review-comment-body p{margin:0;min-height:21px}.review-comment-body p+p{margin-top:8px}
|
|
82
|
-
.review-comment-body a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:3px}
|
|
83
|
-
.review-comment-body code{font:12px/1.5 ui-monospace,SFMono-Regular,monospace;background:var(--chisel-ui-inset);border-radius:4px;padding:2px 4px}
|
|
84
|
-
.review-composer{margin:0}
|
|
85
|
-
.feedback-shell.chisel-review .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;border:0;padding:20px}
|
|
86
|
-
.feedback-shell.chisel-review .chisel-review-reply[hidden]{display:none}
|
|
87
|
-
.feedback-shell.chisel-review .feedback-reply-avatar{width:28px;height:28px;margin-top:8px}
|
|
88
|
-
.feedback-shell.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;min-height:48px;border:0;border-radius:12px;background:var(--chisel-ui-raised)}
|
|
89
|
-
.review-composer-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow:auto;padding:10px 12px;font-size:14px;line-height:21px;overflow-wrap:anywhere;outline:none}
|
|
90
|
-
.review-composer-editor p{margin:0}
|
|
91
|
-
.review-composer-editor>p,.chisel-rich-editor>p{position:relative}
|
|
92
|
-
.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:56px}
|
|
93
|
-
.feedback-shell.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
|
|
94
|
-
.chisel-reply-submit:disabled{opacity:.35}
|
|
95
|
-
.feedback-shell.chisel-review .comment-box-native>form{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}
|
|
96
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
|
|
97
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-footer{border:0;background:var(--chisel-ui-surface)}
|
|
98
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-raised)}
|
|
99
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent}
|
|
100
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-cancel:hover{background:var(--chisel-ui-hover)}
|
|
101
|
-
.feedback-shell.chisel-review .comment-box-native .comment-box-submit{border-radius:8px}
|
|
102
|
-
.chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
|
|
103
|
-
.chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;color:var(--chisel-ui-secondary);font-size:12px;line-height:18px}
|
|
104
|
-
.chisel-review-reply .chisel-attachment-controls{padding-right:48px}
|
|
105
|
-
.chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
|
|
106
|
-
.chisel-attachment-previews,.review-attachments{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
|
|
107
|
-
.review-attachments{padding:12px 0 0;max-height:none}
|
|
108
|
-
.feedback-shell.chisel-review .chisel-attachment-preview,.review-attachment{position:relative;min-width:0;margin:0;overflow:hidden;border:0;border-radius:8px;background:var(--chisel-ui-raised)}
|
|
109
|
-
.chisel-attachment-preview>img,.chisel-attachment-preview>video,.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain;background:var(--chisel-ui-inset)}
|
|
110
|
-
.review-attachment figcaption{padding:8px;font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
|
111
|
-
.review-attachment-placeholder{min-height:100px;display:grid;place-items:center;padding:12px;color:var(--chisel-ui-secondary);font-size:12px}
|
|
112
|
-
.chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
|
|
113
|
-
.review-retry-upload{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text);font:inherit}
|
|
114
|
-
.review-retry-upload:hover{background:var(--chisel-ui-hover)}
|
|
115
|
-
.chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
|
|
116
|
-
.feedback-shell.chisel-review .chisel-expand-thread{display:inline-flex;align-items:center;margin:0 20px 8px 60px;min-height:40px;padding:0;border:0;background:transparent;color:var(--chisel-ui-secondary);font-size:13px}
|
|
117
|
-
.chisel-review [data-slate-placeholder]{opacity:1!important;color:var(--chisel-ui-secondary)}
|
|
118
|
-
@media(pointer:coarse){.feedback-shell.chisel-review .chisel-reply-submit{width:44px;height:44px}.chisel-review-reply .chisel-attachment-controls{padding-right:52px}.feedback-shell.chisel-review .chisel-reply-field{min-height:52px}.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:60px}}
|
|
119
|
-
@media(forced-colors:active){.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native,.feedback-shell.chisel-review .chisel-reply-field{border:1px solid CanvasText;box-shadow:none}.review-comment-avatar{border:1px solid CanvasText}}
|
|
120
|
-
.review-media-thumbnail{position:relative;display:block;width:100%;padding:0;border:0;background:var(--chisel-ui-inset);cursor:pointer}
|
|
121
|
-
.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain}
|
|
122
|
-
.review-media-play{position:absolute;inset:50% auto auto 50%;display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#0009;color:white;transform:translate(-50%,-50%)}
|
|
123
|
-
.review-media-lightbox{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:24px;border:0;background:transparent;color:var(--chisel-ui-text)}
|
|
124
|
-
.review-media-lightbox::backdrop{background:#000b}
|
|
125
|
-
.review-media-lightbox-content{display:flex;flex-direction:column;width:min(100%,1000px);max-height:100%;margin:auto;border-radius:12px;overflow:hidden;background:var(--chisel-ui-surface);box-shadow:0 16px 48px #0006}
|
|
126
|
-
.review-media-lightbox-content header{display:flex;align-items:center;gap:12px;min-height:56px;padding:8px 12px 8px 16px}
|
|
127
|
-
.review-media-lightbox-content header span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
128
|
-
.review-media-lightbox-content header a{color:var(--chisel-ui-text);font-size:13px}
|
|
129
|
-
.review-media-lightbox-content header button{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text)}
|
|
130
|
-
.review-media-lightbox-content header button:hover{background:var(--chisel-ui-hover)}
|
|
131
|
-
.review-media-lightbox-content>img,.review-media-lightbox-content>video{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;object-fit:contain;background:#000}
|
|
132
|
-
`;var b="https://chisel-review.vercel.app";function H(p){return Array.isArray(p)?p.filter(o=>o&&typeof o.id=="string"&&typeof o.name=="string"&&typeof o.path=="string").map(o=>({id:o.id,name:o.name.slice(0,100),path:o.path.slice(0,2048),image:typeof o.image=="string"&&/^https?:\/\//.test(o.image)?o.image:null})):[]}function Pe({projectId:p}){let o=`chisel:session:${p}`,c=w(""),[m,N]=h(null),[q,y]=h(!0),[B,I]=h(""),[Q,k]=h(!1),[M,S]=h([]),[Y,G]=h([]),[K,L]=h("connecting"),C=w("/"),T=w(!1),[Z,ee]=h(0),j=w(new Set),u=x(()=>{for(let e of j.current)e()},[]),E=w(null);E.current=m;let P=w(null),z=w(""),d=x(async(e,i,t,r,a=!1)=>{let n=await fetch(`${b}/chisel/api/hosted/${e}`,{method:i,headers:{Authorization:`Bearer ${c.current}`,...t?{"Content-Type":"application/json","X-Chisel-Protocol":"2"}:{}},...t?{body:JSON.stringify(t)}:{},signal:r,keepalive:a}),v=await n.json();if(!n.ok)throw n.status===401&&E.current&&k(!0),Object.assign(new Error(v.error||"Chisel is unavailable. Please try again."),{status:n.status});if(v.siteId&&v.siteId!==p)throw new Error("This session belongs to another project.");return v},[p]),l=x((e,i)=>d(e==="GET"?`comments?path=${encodeURIComponent(C.current)}`:"comments",e,i),[d]),ie=U(()=>{let e=0;return{async list(){let i=++e;try{let t=await l("GET");return i===e&&(S(t.comments),T.current||G(H(t.participants))),t.comments}catch(t){throw t}},async mutate(i){++e;let t=(await l("POST",i)).comment;return++e,S(r=>r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[...r,t]),window.setTimeout(u,0),t},async delete(i){++e,await l("POST",{type:"delete",id:i}),++e,S(t=>t.filter(r=>r.id!==i)),window.setTimeout(u,0)},subscribe(i){return j.current.add(i),()=>{j.current.delete(i)}}}},[l,u]),te=x(async(e,i)=>{await l("POST",{type:"read",id:e,activity:i})},[l]),re=x((e,i)=>{S(t=>t.map(r=>r.id===e?{...r,readActivity:Math.max(r.readActivity??0,i)}:r))},[]),{flush:D,markDisplayed:ae}=ge(te,re);O(()=>{if(!m)return;let e=!0,i,t,r=new AbortController,a=()=>{document.visibilityState==="visible"&&(clearTimeout(t),t=setTimeout(()=>{u(),D()},40))};async function n(){try{let R=await fetch(`${b}/chisel/api/hosted/events?path=${encodeURIComponent(C.current)}`,{headers:{Authorization:`Bearer ${c.current}`},signal:r.signal});if(R.status===401&&k(!0),!R.ok||!R.body)throw new Error("Live updates unavailable");let se=R.body.getReader(),ce=new TextDecoder,f="";for(;e;){let{value:le,done:de}=await se.read();if(de)break;f+=ce.decode(le,{stream:!0});let $;for(;($=f.indexOf(`
|
|
1
|
+
"use client";import{useCallback as w,useEffect as U,useMemo as j,useRef as x,useState as h}from"react";import{ChiselWorkspace as he,ChiselWorkspaceStyles as H}from"use-chisel/workspace";import{ReviewComposer as pe,ReviewThread as me,useReviewAttachments as ue,useReadQueue as ve}from"use-chisel/review";var X=`.chisel-review{font-family:var(--chisel-ui-font);-webkit-font-smoothing:antialiased}.chisel-review .comment-thread[data-native-ui=true]{padding:0;gap:0;border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font-size:14px}.chisel-review .comment-thread[data-native-ui=true] .feedback-preview{margin:4px 12px 0;border-radius:8px}.chisel-review .comment-thread[data-native-ui=true] form{width:100%}.chisel-review-thread-content{width:100%;min-width:0}.chisel-review-message{display:flex;gap:12px;padding:16px}.chisel-review-message-content{min-width:0;flex:1}.chisel-review-avatar{width:32px;height:32px;flex-shrink:0}.chisel-review-avatar img,.chisel-review .feedback-reply-avatar img{width:100%;height:100%;object-fit:cover;border-radius:inherit}.chisel-review-byline{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline;line-height:1.5}.chisel-review-byline strong{font-weight:500}.chisel-review-byline time{color:var(--chisel-ui-secondary);font-size:12px;font-variant-numeric:tabular-nums}.chisel-rich-body{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;color:var(--chisel-ui-text)}.chisel-rich-body p,.chisel-rich-editor p{margin:0;min-height:1.5em}.chisel-rich-body a,.chisel-rich-editor a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:2px}.chisel-rich-body code,.chisel-rich-editor code{font:.9em ui-monospace,monospace;background:var(--chisel-ui-inset);padding:1px 3px;border-radius:4px}.chisel-review .chisel-expand-thread{margin:0 16px 12px 60px;min-height:40px;padding:0;background:transparent;color:var(--chisel-ui-accent-text)}.chisel-review-reply{display:flex;align-items:flex-start;gap:12px;padding:16px;border-top:1px solid var(--chisel-ui-border)}.chisel-rich-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow-y:auto;padding:8px;font-size:14px;line-height:1.5;outline:none;overflow-wrap:anywhere}.chisel-review-reply .chisel-rich-editor{padding:12px 14px;min-height:44px}.chisel-review .comment-box-native{border:0;border-radius:var(--chisel-ui-radius);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font:inherit}.chisel-review .comment-box-native>form{display:flex;flex-direction:column;min-height:0;height:100%;flex:1}.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}.chisel-review .comment-box-native .comment-box-symbol{margin-top:0;background:transparent;border-radius:8px}.chisel-review .comment-box-native .comment-box-footer{background:var(--chisel-ui-surface);border-top:1px solid var(--chisel-ui-border)}.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent;font:inherit}.chisel-review .comment-box-native .comment-box-submit{border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-inset)}.chisel-review .comment-box-native .comment-box-properties{background:var(--chisel-ui-surface)}.chisel-review .feedback-comment{border-radius:var(--chisel-ui-radius)}.chisel-review .comment-thread[data-expanded=false] .chisel-rich-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.5em;overflow:hidden}.chisel-review [data-slate-placeholder]{color:var(--chisel-ui-secondary);opacity:1!important}.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;border:1px solid var(--chisel-ui-border);border-radius:16px;background:var(--chisel-ui-raised)}.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:50%;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}.chisel-review .feedback-reply-avatar{width:32px;height:32px;margin-top:8px}.chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}.chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;font-size:12px;color:var(--chisel-ui-secondary)}.chisel-review-reply .chisel-attachment-controls{padding-right:48px}.chisel-formatting-tools button{display:grid;place-items:center;width:40px;height:40px;flex-shrink:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary);transition:background .15s,scale .15s}.chisel-formatting-tools button:hover{background:var(--chisel-ui-hover)}.chisel-formatting-tools button[aria-pressed=true]{color:var(--chisel-ui-accent-text);background:var(--chisel-ui-accent-surface)}.chisel-formatting-tools{display:flex;gap:0;flex-wrap:wrap;padding:0 4px}.chisel-formatting-tools button:active{scale:.96}.chisel-link-dialog{display:flex;flex-wrap:wrap;gap:6px;padding:8px;border-top:1px solid var(--chisel-ui-border);background:var(--chisel-ui-surface)}.chisel-link-dialog label{flex:1;min-width:120px;font-size:12px;color:var(--chisel-ui-secondary)}.chisel-link-dialog input{display:block;width:100%;height:40px;background:var(--chisel-ui-inset);border:1px solid var(--chisel-ui-border);border-radius:6px;color:var(--chisel-ui-text);padding:6px}.chisel-link-dialog button{align-self:flex-end;min-height:40px;min-width:40px;padding:6px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}.chisel-link-dialog [role=alert]{width:100%;color:var(--chisel-ui-danger);font-size:12px}.chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}.chisel-attachment-previews{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}.chisel-attachment-preview{position:relative;min-width:0;overflow:hidden;border:1px solid var(--chisel-ui-border);border-radius:8px;background:var(--chisel-ui-surface)}.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{display:block;width:100%;height:100px;object-fit:contain;background:var(--chisel-ui-inset);outline:1px solid #0000001a;outline-offset:-1px}.chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}.chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}.chisel-attachment-preview>.chisel-attachment-retry{right:40px;border-radius:0 0 0 8px}.chisel-attachment-preview>.chisel-attachment-load{position:static;width:100%;height:auto;min-height:100px;padding:8px}.comment-thread .feedback-thread-header{position:sticky;top:0;z-index:1;background:var(--chisel-ui-surface)}.chisel-review .comment-thread[data-native-ui=true][data-expanded=false]{border-radius:16px 16px 16px 0}@media(prefers-color-scheme:dark){.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{outline-color:#ffffff1a}}@media(prefers-reduced-motion:reduce){.chisel-formatting-tools button{transition:none}}
|
|
2
|
+
`;var F=`.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native{border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:var(--chisel-ui-popover-shadow)}.feedback-shell.chisel-review .comment-thread[data-expanded=false]{border-radius:16px 16px 16px 0}.chisel-review-thread-content,.review-thread,.review-comment-content{width:100%;min-width:0}.review-comment,.feedback-shell.chisel-review .chisel-review-message{display:flex;align-items:flex-start;gap:12px;padding:12px 20px}.review-comment-content,.chisel-review-message-content{flex:1;min-width:0}.review-comment-avatar{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:50%;overflow:hidden;background:var(--chisel-ui-avatar);color:var(--chisel-ui-avatar-text);font-size:12px}.review-comment-avatar img{width:100%;height:100%;object-fit:cover}.review-comment-header,.chisel-review-byline{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;line-height:20px;margin-bottom:4px}.review-comment-author{font-size:13px;font-weight:500;overflow-wrap:anywhere}.review-comment-time{font-size:12px;color:var(--chisel-ui-muted);font-variant-numeric:tabular-nums;white-space:nowrap}.review-comment-header{position:relative;padding-right:32px}.review-comment-edit{position:absolute;right:-8px;top:-10px;display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-muted);opacity:0;transition:opacity .12s,background .12s}.review-comment:hover .review-comment-edit,.review-comment:focus-within .review-comment-edit,.review-comment-edit:focus-visible{opacity:1}.review-comment-edit:hover{background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}@media(hover:none){.review-comment-edit{opacity:1}}.review-inline-edit{border:1px solid var(--chisel-ui-border);border-radius:10px;padding:8px}.review-inline-edit-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:8px}.review-inline-edit-actions button{min-height:32px;padding:0 10px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}.review-comment-body,.chisel-rich-body{font-size:14px;line-height:21px;white-space:pre-wrap;overflow-wrap:anywhere}.review-comment-body p{margin:0;min-height:21px}.review-comment-body p+p{margin-top:8px}.review-comment-body a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:3px}.review-comment-body code{font:12px/1.5 ui-monospace,SFMono-Regular,monospace;background:var(--chisel-ui-inset);border-radius:4px;padding:2px 4px}.review-composer{margin:0}.feedback-shell.chisel-review .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;border:0;padding:20px}.feedback-shell.chisel-review .chisel-review-reply[hidden]{display:none}.feedback-shell.chisel-review .feedback-reply-avatar{width:28px;height:28px;margin-top:8px}.feedback-shell.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;min-height:48px;border:0;border-radius:12px;background:var(--chisel-ui-raised)}.review-composer-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow:auto;padding:10px 12px;font-size:14px;line-height:21px;overflow-wrap:anywhere;outline:none}.review-composer-editor p{margin:0}.review-composer-editor>p,.chisel-rich-editor>p{position:relative}.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:56px}.feedback-shell.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}.chisel-reply-submit:disabled{opacity:.35}.feedback-shell.chisel-review .comment-box-native>form{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.feedback-shell.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}.feedback-shell.chisel-review .comment-box-native .comment-box-footer{border:0;background:var(--chisel-ui-surface)}.feedback-shell.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-raised)}.feedback-shell.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent}.feedback-shell.chisel-review .comment-box-native .comment-box-cancel:hover{background:var(--chisel-ui-hover)}.feedback-shell.chisel-review .comment-box-native .comment-box-submit{border-radius:8px}.chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}.chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;color:var(--chisel-ui-secondary);font-size:12px;line-height:18px}.chisel-review-reply .chisel-attachment-controls{padding-right:48px}.chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}.chisel-attachment-previews,.review-attachments{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}.review-attachments{padding:12px 0 0;max-height:none}.feedback-shell.chisel-review .chisel-attachment-preview,.review-attachment{position:relative;min-width:0;margin:0;overflow:hidden;border:0;border-radius:8px;background:var(--chisel-ui-raised)}.chisel-attachment-preview>img,.chisel-attachment-preview>video,.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain;background:var(--chisel-ui-inset)}.review-attachment figcaption{padding:8px;font-size:12px;line-height:18px;overflow-wrap:anywhere}.review-attachment-placeholder{min-height:100px;display:grid;place-items:center;padding:12px;color:var(--chisel-ui-secondary);font-size:12px}.chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}.review-retry-upload{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text);font:inherit}.review-retry-upload:hover{background:var(--chisel-ui-hover)}.chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}.feedback-shell.chisel-review .chisel-expand-thread{display:inline-flex;align-items:center;margin:0 20px 8px 60px;min-height:40px;padding:0;border:0;background:transparent;color:var(--chisel-ui-secondary);font-size:13px}.chisel-review [data-slate-placeholder]{opacity:1!important;color:var(--chisel-ui-secondary)}@media(pointer:coarse){.feedback-shell.chisel-review .chisel-reply-submit{width:44px;height:44px}.chisel-review-reply .chisel-attachment-controls{padding-right:52px}.feedback-shell.chisel-review .chisel-reply-field{min-height:52px}.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:60px}}@media(forced-colors:active){.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native,.feedback-shell.chisel-review .chisel-reply-field{border:1px solid CanvasText;box-shadow:none}.review-comment-avatar{border:1px solid CanvasText}}.review-media-thumbnail{position:relative;display:block;width:100%;padding:0;border:0;background:var(--chisel-ui-inset);cursor:pointer}.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain}.review-media-play{position:absolute;inset:50% auto auto 50%;display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#0009;color:#fff;transform:translate(-50%,-50%)}.review-media-lightbox{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:24px;border:0;background:transparent;color:var(--chisel-ui-text)}.review-media-lightbox::backdrop{background:#000b}.review-media-lightbox-content{display:flex;flex-direction:column;width:min(100%,1000px);max-height:100%;margin:auto;border-radius:12px;overflow:hidden;background:var(--chisel-ui-surface);box-shadow:0 16px 48px #0006}.review-media-lightbox-content header{display:flex;align-items:center;gap:12px;min-height:56px;padding:8px 12px 8px 16px}.review-media-lightbox-content header span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.review-media-lightbox-content header a{color:var(--chisel-ui-text);font-size:13px}.review-media-lightbox-content header button{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text)}.review-media-lightbox-content header button:hover{background:var(--chisel-ui-hover)}.review-media-lightbox-content>img,.review-media-lightbox-content>video{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;object-fit:contain;background:#000}
|
|
3
|
+
`;import{Fragment as we,jsx as s,jsxs as b}from"react/jsx-runtime";var g="https://chisel-review.vercel.app";function q(p){return Array.isArray(p)?p.filter(n=>n&&typeof n.id=="string"&&typeof n.name=="string"&&typeof n.path=="string").map(n=>({id:n.id,name:n.name.slice(0,100),path:n.path.slice(0,2048),image:typeof n.image=="string"&&/^https?:\/\//.test(n.image)?n.image:null})):[]}function Ce({projectId:p}){let n=`chisel:session:${p}`,c=x(""),[m,M]=h(null),[Q,y]=h(!0),[W,I]=h(""),[Y,k]=h(!1),[N,S]=h([]),[K,G]=h([]),[Z,L]=h("connecting"),C=x("/"),T=x(!1),[_,ee]=h(0),O=x(new Set),u=w(()=>{for(let e of O.current)e()},[]),E=x(null);E.current=m;let P=x(null),R=x(""),d=w(async(e,i,t,r,a=!1)=>{let o=await fetch(`${g}/chisel/api/hosted/${e}`,{method:i,headers:{Authorization:`Bearer ${c.current}`,...t?{"Content-Type":"application/json","X-Chisel-Protocol":"2"}:{}},...t?{body:JSON.stringify(t)}:{},signal:r,keepalive:a}),v=await o.json();if(!o.ok)throw o.status===401&&E.current&&k(!0),Object.assign(new Error(v.error||"Chisel is unavailable. Please try again."),{status:o.status});if(v.siteId&&v.siteId!==p)throw new Error("This session belongs to another project.");return v},[p]),l=w((e,i)=>d(e==="GET"?`comments?path=${encodeURIComponent(C.current)}`:"comments",e,i),[d]),ie=j(()=>{let e=0;return{async list(){let i=++e,t=await l("GET");return i===e&&(S(t.comments),T.current||G(q(t.participants))),t.comments},async mutate(i){++e;let t=(await l("POST",i)).comment;return++e,S(r=>r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[...r,t]),window.setTimeout(u,0),t},async delete(i){++e,await l("POST",{type:"delete",id:i}),++e,S(t=>t.filter(r=>r.id!==i)),window.setTimeout(u,0)},subscribe(i){return O.current.add(i),()=>{O.current.delete(i)}}}},[l,u]),te=w(async(e,i)=>{await l("POST",{type:"read",id:e,activity:i})},[l]),re=w((e,i)=>{S(t=>t.map(r=>r.id===e?{...r,readActivity:Math.max(r.readActivity??0,i)}:r))},[]),{flush:B,markDisplayed:ae}=ve(te,re);U(()=>{if(!m)return;let e=!0,i,t,r=new AbortController,a=()=>{document.visibilityState==="visible"&&(clearTimeout(t),t=setTimeout(()=>{u(),B()},40))};async function o(){try{let z=await fetch(`${g}/chisel/api/hosted/events?path=${encodeURIComponent(C.current)}`,{headers:{Authorization:`Bearer ${c.current}`},signal:r.signal});if(z.status===401&&k(!0),!z.ok||!z.body)throw new Error("Live updates unavailable");let se=z.body.getReader(),ce=new TextDecoder,f="";for(;e;){let{value:le,done:de}=await se.read();if(de)break;f+=ce.decode(le,{stream:!0});let $;for(;($=f.indexOf(`
|
|
133
4
|
|
|
134
|
-
`))>=0;){let A=f.slice(0,$);if(f=f.slice($+2),A==="data: ready")L("connected"),a();else if(A==="data: change")a();else if(A.startsWith("data: presence:"))try{T.current=!0,G(
|
|
5
|
+
`))>=0;){let A=f.slice(0,$);if(f=f.slice($+2),A==="data: ready")L("connected"),a();else if(A==="data: change")a();else if(A.startsWith("data: presence:"))try{T.current=!0,G(q(JSON.parse(A.slice(15))))}catch{}}}}catch{}e&&(T.current=!1,L("reconnecting"),i=setTimeout(()=>{o()},2e3))}L("connecting"),o();let v=window.setInterval(a,1e4);return window.addEventListener("focus",a),window.addEventListener("online",a),document.addEventListener("visibilitychange",a),()=>{e=!1,T.current=!1,r.abort(),clearTimeout(i),clearTimeout(t),window.clearInterval(v),window.removeEventListener("focus",a),window.removeEventListener("online",a),document.removeEventListener("visibilitychange",a)}},[m,_,u,B]);let ne=w(e=>{C.current!==e&&(C.current=e,ee(i=>i+1),u())},[u]),D=j(()=>({async userId(){return E.current?.user.id??""},async discard(e){await d("attachments","POST",{action:"cancel",id:e.id},void 0,!0)},async send(e,i,t){let r=async()=>{let o=await d("attachments","POST",{action:"confirm",id:e.id});if(o.attachment?.id!==e.id||o.attachment.token!==e.id)throw new Error("The upload confirmation was incomplete. Please retry.");return e.id};if(i){if(!t())return"";try{return await r()}catch(o){if(![404,503].includes(o.status??0))throw o}}let a=await d("attachments","POST",{action:"prepare",id:e.id,name:e.name,mimeType:e.mimeType,size:e.size});if(a.attachment?.id===e.id&&a.attachment.token===e.id)return e.id;if(typeof a.url!="string"||typeof a.key!="string")throw new Error("The upload could not be started. Please retry.");if(!t())return"";if(!e.stored){let o=new FormData;o.append("cacheControl","3600"),o.append("",e.file);try{(await fetch(a.url,{method:"PUT",headers:{apikey:a.key,"x-upsert":"false"},body:o})).ok&&(e.stored=!0)}catch{}}return t()?r():""}}),[d]),J=j(()=>function(i=!1,t=0){return ue(i,t,D)},[D]),oe=w(async(e,i)=>{let t=await d(`attachments?id=${encodeURIComponent(e)}`,"GET",void 0,i);if(typeof t.url!="string")throw new Error("Attachment unavailable");return t.url},[d]);U(()=>{if(c.current=sessionStorage.getItem(n)||"",!c.current){y(!1);return}let e=!0;return l("GET").then(i=>{e&&M(i)}).catch(()=>{e&&(c.current="",sessionStorage.removeItem(n))}).finally(()=>{e&&y(!1)}),()=>{e=!1}},[n,l]),U(()=>{let e=i=>{i.origin!==g||i.source!==P.current||i.data?.type!=="chisel:session"||i.data.state!==R.current||!/^[0-9a-f]{64}$/.test(i.data.token)||(c.current=i.data.token,sessionStorage.setItem(n,c.current),R.current="",P.current=null,E.current||y(!0),I(""),l("GET").then(t=>{M(t),k(!1);let r=new URL(window.location.href);r.searchParams.delete("invite"),window.history.replaceState(window.history.state,"",r)}).catch(t=>{c.current="",sessionStorage.removeItem(n),I(t instanceof Error?t.message:"Could not connect to Chisel.")}).finally(()=>y(!1)))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n,l]);function V(){let e=crypto.getRandomValues(new Uint8Array(32));R.current=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");let i=new URL("/chisel/connect",g);i.searchParams.set("site",p),i.searchParams.set("origin",window.location.origin),i.searchParams.set("state",R.current);let t=new URLSearchParams(window.location.search).get("invite");t&&i.searchParams.set("invite",t),P.current=window.open(i.toString(),"chisel-sign-in","popup,width=520,height=700"),P.current||I("Allow pop-ups for this site, then try again.")}return Q?b("main",{className:"chisel-sign-in",children:[s(H,{}),s("section",{children:s("p",{children:"Connecting to Chisel\u2026"})})]}):m?b(we,{children:[b("style",{children:[X,F]}),s(he,{user:m.user,commentStore:ie,canManageComments:m.role==="owner",commentUI:{className:"chisel-review",renderComposer:e=>{let i=N.find(t=>t.id===e.commentId);return s(pe,{...e,defaultBody:i?.body,existingAttachments:i?.attachments,useAttachments:J})},renderThread:e=>s(me,{...e,onRead:ae,useAttachments:J,loadMedia:oe},e.comment.id)},collaboration:{status:Z,participants:K,setPage:ne,markRead(){},unreadThreadIds:N.filter(e=>e.readActivity!==null&&e.readActivity<e.activity).map(e=>e.id)},getReviewLink:m.role==="owner"?async(e=!1)=>{let i=await fetch(`${g}/chisel/api/hosted/invite`,{method:"POST",headers:{Authorization:`Bearer ${c.current}`,"Content-Type":"application/json","X-Chisel-Protocol":"2"},body:JSON.stringify({rotate:e})}),t=await i.json();if(i.status===401&&k(!0),!i.ok||typeof t.invite!="string")throw new Error(t.error||"Could not create a review link.");let r=new URL("/chisel",window.location.origin);return r.searchParams.set("mode","comment"),r.searchParams.set("invite",t.invite),r.toString()}:void 0,validateSession:async()=>!!c.current,signOut:async()=>{let e=await fetch(`${g}/chisel/api/hosted/logout`,{method:"DELETE",headers:{Authorization:`Bearer ${c.current}`,"X-Chisel-Protocol":"2"}});if(!e.ok&&e.status!==401)throw new Error("Sign out failed.");c.current="",sessionStorage.removeItem(n)}}),Y&&b("div",{role:"alert",style:{position:"fixed",bottom:16,right:16,zIndex:999999,background:"white",color:"black",padding:12,borderRadius:8,boxShadow:"0 2px 12px #0003"},children:["Your Chisel session expired. ",s("button",{type:"button",onClick:V,children:"Sign in again"})]})]}):b("main",{className:"chisel-sign-in",children:[s(H,{}),b("section",{children:[s("strong",{className:"chisel-sign-in-brand",children:"chisel"}),s("h1",{children:"Sign in to review"}),s("p",{children:"Connect this website to your Chisel account."}),s("button",{onClick:V,children:"Continue with Chisel"}),W&&s("p",{role:"alert",children:W})]})]})}export{Ce as HostedChisel};
|