use-chisel 0.1.9 → 0.1.10
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 +73 -0
- package/dist/hosted-entry.js +4 -4
- package/dist/index.js +1 -1
- package/dist/review/snapshot-upload.d.ts +2 -0
- package/dist/review-content-entry.d.ts +1 -0
- package/dist/review-content-entry.js +9 -3
- package/dist/review-entry.d.ts +1 -0
- package/dist/review-entry.js +4 -3
- package/dist/workspace/breakpoints.d.ts +3 -0
- package/dist/workspace/comment-box.d.ts +4 -1
- package/dist/workspace/comments.d.ts +22 -0
- package/dist/workspace/project-controls.d.ts +20 -0
- package/dist/workspace/review-links.d.ts +4 -0
- package/dist/workspace/workspace.d.ts +9 -1
- package/dist/workspace-entry.d.ts +2 -1
- package/dist/workspace-entry.js +19 -9
- package/package.json +5 -4
- package/src/review/workspace-design.css +11 -3
package/README.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# use-chisel
|
|
2
2
|
|
|
3
|
+
Hosted website reviews and visual editing for Next.js.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install use-chisel
|
|
9
|
+
npx chisel
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Sign in with Google, connect the project, restart its development server, and
|
|
13
|
+
open `/chisel`. Chisel stores shared feedback in its hosted service; client
|
|
14
|
+
projects do not configure a database.
|
|
15
|
+
|
|
16
|
+
Before inviting clients, deploy the site with `CHISEL_ENABLED=1`, open its public
|
|
17
|
+
HTTPS `/chisel` page, then use **Share review link**. Chisel remembers the deployed
|
|
18
|
+
URL for sharing from local development. Localhost links cannot be shared with clients.
|
|
19
|
+
Return to your projects from the account menu or the hosted `/chisel/projects` page.
|
|
20
|
+
|
|
21
|
+
## Review workflow
|
|
22
|
+
|
|
23
|
+
- Copy a thread link to reopen its page, breakpoint, and exact captured width,
|
|
24
|
+
including after sign-in. Links require existing review access.
|
|
25
|
+
- The thread header's status pill shows **Open**, **Ready**, or **Resolved**.
|
|
26
|
+
Owners choose Ready for review; the comment author confirms by selecting
|
|
27
|
+
Resolved, or selects Open if more work is needed. Changes appear immediately
|
|
28
|
+
while saving; failed saves restore the previous status.
|
|
29
|
+
- Open and unread counts appear on the breakpoint controls and page picker.
|
|
30
|
+
- Comment and reply text, rich formatting, and inline edit drafts recover locally
|
|
31
|
+
after refresh. Drafts expire after seven days and are isolated by project/user.
|
|
32
|
+
Uploaded files must be reattached after refresh.
|
|
33
|
+
- A screenshot and viewport context are captured when composing a new comment.
|
|
34
|
+
Its image uploads after the comment posts. Failed captures do not block feedback;
|
|
35
|
+
failed uploads offer retry. Password/payment-code fields and elements marked
|
|
36
|
+
`data-chisel-private` are excluded. Cross-origin media or browser restrictions
|
|
37
|
+
can prevent a complete capture; a screenshot is a reference, not a browser recording.
|
|
38
|
+
- Owners can copy selected feedback for Codex, including context, replies, proposed
|
|
39
|
+
changes, and private attachment links. Media links expire; thread links remain.
|
|
40
|
+
|
|
3
41
|
## Combined Workspace
|
|
4
42
|
|
|
5
43
|
`use-chisel/workspace` exports `ChiselWorkspace`, `ChiselPreview`,
|
|
@@ -12,6 +50,18 @@ with Google.
|
|
|
12
50
|
|
|
13
51
|
Edit, Comment, and View share one toolbar. Threads expand from element pins;
|
|
14
52
|
history appears in the sidebar.
|
|
53
|
+
The mode toolbar sits at bottom left; the breakpoint switcher sits at bottom
|
|
54
|
+
right. **D**, **T**, and **M** select exact iframe widths of 1440px, 768px, and
|
|
55
|
+
390px. Drag either preview edge to resize, use arrow keys on the edge, or type a
|
|
56
|
+
pixel width and press Enter, up to the space available beside the sidebar.
|
|
57
|
+
Typed widths also apply when leaving the field; Escape cancels the edit.
|
|
58
|
+
Wider previews scroll horizontally rather than shrinking the selected width.
|
|
59
|
+
Comments cascade to narrower previews: Desktop feedback appears on all three
|
|
60
|
+
breakpoints, Tablet feedback on Tablet and Mobile, and Mobile feedback only on
|
|
61
|
+
Mobile. Mobile is below 768px, Tablet is 768–1023px, and Desktop starts at 1024px;
|
|
62
|
+
comments without a `breakpoint` belong to Desktop. Opening inherited feedback
|
|
63
|
+
keeps the current preview width. Custom stores
|
|
64
|
+
should persist the optional `WorkspaceComment.breakpoint` field on creation.
|
|
15
65
|
Use **E** for Edit, **C** for Comment, and **V** for View. **Shift+C** toggles
|
|
16
66
|
all comment pins, threads, and the comments sidebar. Shortcuts are ignored
|
|
17
67
|
while typing in form fields or editable content. Comments are browser-local by
|
|
@@ -53,6 +103,11 @@ hosted service; project credentials and Supabase service keys are not required
|
|
|
53
103
|
in the client project. The hosted workspace supports rich text, attachments,
|
|
54
104
|
replies, resolution, review links, reviewer presence, and unread indicators.
|
|
55
105
|
|
|
106
|
+
Review sign-in is remembered across tabs and browser restarts on the same
|
|
107
|
+
website. Sessions expire after 30 days of inactivity and renew during use.
|
|
108
|
+
Temporary connection failures keep the saved sign-in; signing out clears it
|
|
109
|
+
across tabs. Project access and website origin are still checked on every request.
|
|
110
|
+
|
|
56
111
|
The generated route defaults off in production. To use it on a deployed review
|
|
57
112
|
site, set `CHISEL_ENABLED=1` for that deployment and redeploy. Hosted connections
|
|
58
113
|
require HTTPS, except on localhost. Automatic setup currently requires an App
|
|
@@ -124,3 +179,21 @@ and site. Keep the editor and attachment draft when `onSubmit` or `onReply` retu
|
|
|
124
179
|
`false`; release it only after a successful save. The shared rich-text review UI
|
|
125
180
|
uses Slate. Supabase stays in the hosted service or the host's adapter; client
|
|
126
181
|
projects do not need its SDK. Icons are bundled at build time.
|
|
182
|
+
|
|
183
|
+
### Custom host adapters
|
|
184
|
+
|
|
185
|
+
Optional workspace props keep custom hosts on the same review workflow:
|
|
186
|
+
`projectId` isolates local drafts; `manageReview(action, payload)` loads project
|
|
187
|
+
settings and handles `settings`, `remove_reviewer`, `start_round`, and `approve`;
|
|
188
|
+
`accountURL` links to the host's project directory. The exported `ManageReview`
|
|
189
|
+
and `ReviewProject` types describe this contract.
|
|
190
|
+
|
|
191
|
+
`saveSnapshot(commentId, file)` uploads the captured PNG after the comment saves.
|
|
192
|
+
The shared `uploadSnapshot` helper reuses the attachment transport and preserves
|
|
193
|
+
upload IDs on retry. Bind the upload through the `snapshot` mutation, checking
|
|
194
|
+
membership, author permissions, file ownership/type, and one snapshot per thread.
|
|
195
|
+
`getAttachmentURL(id)` supplies private media links for the Codex export.
|
|
196
|
+
Stores should persist `context`, `status`, status author/time, and review-round IDs.
|
|
197
|
+
The `status` mutation supports `open`, `ready`, and `resolved`; keep `resolved`
|
|
198
|
+
consistent for older clients. `commentURL`, `feedbackMarkdown`, and
|
|
199
|
+
`publicReviewURL` are exported from `use-chisel/review-content` for custom hosts.
|
package/dist/hosted-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
2
|
-
`;var
|
|
3
|
-
`;import{Fragment as
|
|
1
|
+
"use client";import{useCallback as u,useEffect as F,useMemo as H,useRef as g,useState as v}from"react";import{ChiselWorkspace as ye,ChiselWorkspaceStyles as J}from"use-chisel/workspace";import{ReviewComposer as ke,ReviewThread as Se,useReviewAttachments as Te,useReadQueue as Ce,uploadSnapshot as Ee}from"use-chisel/review";import{publicReviewURL as Re}from"use-chisel/review-content";var ee=`.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 ie=`.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-capture-context{margin:4px 12px 8px;font-size:12px;line-height:18px;color:var(--chisel-ui-muted);overflow-wrap:anywhere}.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:40px;padding:0 10px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text)}.review-inline-edit-actions button:last-child{background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}.review-inline-edit-actions button:not(:last-child):hover{background:var(--chisel-ui-hover)}.review-inline-edit-actions button:disabled{opacity:.45}@media(pointer:coarse){.review-inline-edit-actions button{min-height:44px}}.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-controls .review-retry-upload[aria-label]{min-width:40px;justify-content:center}.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[open]{display:flex;align-items:center;justify-content:center}.review-media-lightbox::backdrop{background:#000b}.review-media-lightbox-content{display:flex;flex-direction:column;width:fit-content;min-width:min(320px,100%);max-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{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:40px;min-height:40px;padding:0;border-radius:8px;color:var(--chisel-ui-text);font-size:13px}.review-media-lightbox-content header a:hover{background:var(--chisel-ui-hover)}.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 Le,jsx as d,jsxs as b}from"react/jsx-runtime";var x="https://chisel-review.vercel.app";function re(l,n){try{localStorage.setItem(l,n),sessionStorage.removeItem(l);return}catch{}try{sessionStorage.setItem(l,n)}catch{}}function X(l){try{localStorage.removeItem(l)}catch{}try{sessionStorage.removeItem(l)}catch{}}function Pe(l){let n="";try{n=localStorage.getItem(l)||""}catch{}if(!/^[0-9a-f]{64}$/.test(n))try{n=sessionStorage.getItem(l)||""}catch{}return/^[0-9a-f]{64}$/.test(n)?(re(l,n),n):""}function te(l){return Array.isArray(l)?l.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 Me({projectId:l}){let n=`chisel:session:${l}`,o=g(""),Y=g(n),[ne,O]=v(0),[m,j]=v(null),[ae,q]=v(!0),[P,k]=v(""),[oe,y]=v(!1),[K,S]=v([]),[se,N]=v([]),[ce,M]=v("connecting"),L=g("/"),z=g(!1),[le,de]=v(0),W=g(new Set),f=u(()=>{for(let e of W.current)e()},[]),T=g(null);T.current=m;let A=g(null),I=g(""),p=u(async(e,i,t,a,r=!1)=>{let c=o.current,h=await fetch(`${x}/chisel/api/hosted/${e}`,{method:i,headers:{Authorization:`Bearer ${c}`,...t?{"Content-Type":"application/json","X-Chisel-Protocol":"2"}:{}},...t?{body:JSON.stringify(t)}:{},signal:a,keepalive:r}),s=await h.json().catch(()=>null);if(c!==o.current)throw new Error("Your Chisel account changed. Please retry.");if(!h.ok)throw h.status===401&&c===o.current&&T.current&&y(!0),Object.assign(new Error(s?.error||"Chisel is unavailable. Please try again."),{status:h.status});if(!s||typeof s!="object")throw new Error("Chisel is unavailable. Please try again.");if(s.siteId&&s.siteId!==l)throw new Error("This session belongs to another project.");return s},[l]),w=u((e,i)=>p(e==="GET"?`comments?path=${encodeURIComponent(L.current)}`:"comments",e,i),[p]),B=H(()=>{let e=0;return{async list(){let i=++e,t=await w("GET");return i===e&&(S(t.comments),z.current||N(te(t.participants))),t.comments},async mutate(i){++e;let t=(await w("POST",i)).comment;return++e,S(a=>a.some(r=>r.id===t.id)?a.map(r=>r.id===t.id?t:r):[...a,t]),window.setTimeout(f,0),t},async delete(i){++e,await w("POST",{type:"delete",id:i}),++e,S(t=>t.filter(a=>a.id!==i)),window.setTimeout(f,0)},subscribe(i){return W.current.add(i),()=>{W.current.delete(i)}}}},[w,f]),he=u(async(e,i)=>{await w("POST",{type:"read",id:e,activity:i})},[w]),pe=u((e,i)=>{S(t=>t.map(a=>a.id===e?{...a,readActivity:Math.max(a.readActivity??0,i)}:a))},[]),{flush:Q,markDisplayed:ue}=Ce(he,pe);F(()=>{if(!m)return;let e=!0,i,t,a=new AbortController,r=()=>{document.visibilityState==="visible"&&(clearTimeout(t),t=setTimeout(()=>{f(),Q()},40))};async function c(){let s=!1;try{let C=o.current,$=await fetch(`${x}/chisel/api/hosted/events?path=${encodeURIComponent(L.current)}`,{headers:{Authorization:`Bearer ${C}`},signal:a.signal});if(e&&$.status===401&&C===o.current&&y(!0),!$.ok||!$.body)throw new Error("Live updates unavailable");let ge=$.body.getReader(),xe=new TextDecoder,E="";for(;e;){let{value:be,done:fe}=await ge.read();if(fe)break;E+=xe.decode(be,{stream:!0});let D;for(;(D=E.indexOf(`
|
|
4
4
|
|
|
5
|
-
`))>=0;){let
|
|
5
|
+
`))>=0;){let R=E.slice(0,D);if(E=E.slice(D+2),R==="data: ready")M("connected"),r();else if(R==="data: renew")s=!0;else if(R==="data: change")r();else if(R.startsWith("data: presence:"))try{z.current=!0,N(te(JSON.parse(R.slice(15))))}catch{}}}}catch{}e&&(z.current=!1,s||M("reconnecting"),i=setTimeout(()=>{c()},s?0:2e3))}M(s=>s==="connected"?s:"connecting"),c();let h=window.setInterval(r,1e4);return window.addEventListener("focus",r),window.addEventListener("online",r),document.addEventListener("visibilitychange",r),()=>{e=!1,z.current=!1,a.abort(),clearTimeout(i),clearTimeout(t),window.clearInterval(h),window.removeEventListener("focus",r),window.removeEventListener("online",r),document.removeEventListener("visibilitychange",r)}},[m,le,f,Q]);let me=u(e=>{L.current!==e&&(L.current=e,de(i=>i+1),f())},[f]),U=H(()=>({async userId(){return T.current?.user.id??""},async discard(e){await p("attachments","POST",{action:"cancel",id:e.id},void 0,!0)},async send(e,i,t){let a=async()=>{let c=await p("attachments","POST",{action:"confirm",id:e.id});if(c.attachment?.id!==e.id||c.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 a()}catch(c){if(![404,503].includes(c.status??0))throw c}}let r=await p("attachments","POST",{action:"prepare",id:e.id,name:e.name,mimeType:e.mimeType,size:e.size});if(r.attachment?.id===e.id&&r.attachment.token===e.id)return e.id;if(typeof r.url!="string"||typeof r.key!="string")throw new Error("The upload could not be started. Please retry.");if(!t())return"";if(!e.stored){let c=new FormData;c.append("cacheControl","3600"),c.append("",e.file);try{(await fetch(r.url,{method:"PUT",headers:{apikey:r.key,"x-upsert":"false"},body:c})).ok&&(e.stored=!0)}catch{}}return t()?a():""}}),[p]),Z=H(()=>function(i=!1,t=0){return Te(i,t,U)},[U]),V=u(async(e,i)=>{let t=await p(`attachments?id=${encodeURIComponent(e)}`,"GET",void 0,i);if(typeof t.url!="string")throw new Error("Attachment unavailable");return t.url},[p]),G=u((e,i)=>p("project",e==="get"?"GET":"POST",e==="get"?void 0:{...i,action:e}),[p]),ve=u((e,i)=>Ee(i,U,t=>B.mutate({type:"snapshot",id:e,attachmentTokens:[t]})),[U,B]),we=u(e=>V(e,new AbortController().signal),[V]);F(()=>{Y.current!==n&&(o.current="",Y.current=n,j(null)),o.current=o.current||Pe(n);let e=!0,i=!1,t;q(!!o.current&&!T.current);async function a(){if(i||!o.current)return;clearTimeout(t),i=!0;let h=o.current;try{let s=await w("GET");if(!s.user?.id||s.siteId!==l||!["owner","reviewer"].includes(s.role))throw new Error("Could not verify your Chisel session. Please retry.");if(!e||h!==o.current)return;j(s),y(!1),k("");let C=new URL(window.location.href);C.searchParams.delete("invite"),window.history.replaceState(window.history.state,"",C)}catch(s){if(!e||h!==o.current)return;s.status===401?(o.current="",X(n),y(!!T.current)):t=setTimeout(()=>{document.visibilityState==="visible"&&a()},5e3),k(s instanceof Error?s.message:"Could not connect to Chisel.")}finally{i=!1,e&&q(!1)}}let r=()=>{document.visibilityState==="visible"&&a()},c=h=>{if(!(h.key!==n&&h.key!==null)){try{if(h.storageArea!==localStorage)return}catch{return}o.current=h.newValue&&/^[0-9a-f]{64}$/.test(h.newValue)?h.newValue:"",o.current||X(n),j(null),S([]),N([]),y(!1),k(""),O(s=>s+1)}};return o.current&&a(),window.addEventListener("online",r),window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),window.addEventListener("storage",c),()=>{e=!1,clearTimeout(t),window.removeEventListener("online",r),window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("storage",c)}},[n,l,w,ne]),F(()=>{let e=i=>{i.origin!==x||i.source!==A.current||i.data?.type!=="chisel:session"||i.data.state!==I.current||!/^[0-9a-f]{64}$/.test(i.data.token)||(o.current=i.data.token,re(n,o.current),I.current="",A.current=null,k(""),O(t=>t+1))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]);function _(){let e=crypto.getRandomValues(new Uint8Array(32));I.current=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");let i=new URL("/chisel/connect",x);i.searchParams.set("site",l),i.searchParams.set("origin",window.location.origin),i.searchParams.set("state",I.current);let t=new URLSearchParams(window.location.search).get("invite");t&&i.searchParams.set("invite",t),A.current=window.open(i.toString(),"chisel-sign-in","popup,width=520,height=700"),A.current||k("Allow pop-ups for this site, then try again.")}return ae?b("main",{className:"chisel-sign-in",children:[d(J,{}),d("section",{children:d("p",{children:"Connecting to Chisel\u2026"})})]}):!m&&o.current?b("main",{className:"chisel-sign-in",children:[d(J,{}),b("section",{children:[d("strong",{className:"chisel-sign-in-brand",children:"chisel"}),d("h1",{children:"Reconnecting to Chisel"}),d("p",{children:"Your sign-in is saved. Check your connection and try again."}),d("button",{onClick:()=>O(e=>e+1),children:"Retry connection"}),P&&d("p",{role:"alert",children:P})]})]}):m?b(Le,{children:[b("style",{children:[ee,ie]}),d(ye,{user:m.user,commentStore:B,canManageComments:m.role==="owner",projectId:l,manageReview:G,saveSnapshot:ve,getAttachmentURL:we,accountURL:`${x}/chisel/projects`,agentURL:`${x}/chisel/mcp`,commentUI:{className:"chisel-review",renderComposer:e=>{let i=K.find(t=>t.id===e.commentId);return d(ke,{...e,defaultBody:i?.body,existingAttachments:i?.attachments,useAttachments:Z})},renderThread:e=>d(Se,{...e,onRead:ue,useAttachments:Z,loadMedia:V},e.comment.id)},collaboration:{status:ce,participants:se,setPage:me,markRead(){},unreadThreadIds:K.filter(e=>e.readActivity!==null&&e.readActivity<e.activity).map(e=>e.id)},getReviewLink:m.role==="owner"?async(e=!1)=>{let i=await G("get"),t=i.reviewURL??Re(window.location.origin);if(!t)throw new Error("Open the deployed website\u2019s HTTPS /chisel page to copy a review link. Localhost links cannot be shared with clients.");i.reviewURL||await G("settings",{reviewURL:t});let a=await fetch(`${x}/chisel/api/hosted/invite`,{method:"POST",headers:{Authorization:`Bearer ${o.current}`,"Content-Type":"application/json","X-Chisel-Protocol":"2"},body:JSON.stringify({rotate:e})}),r=await a.json();if(a.status===401&&y(!0),!a.ok||typeof r.invite!="string")throw new Error(r.error||"Could not create a review link.");let c=new URL(t);return c.searchParams.set("mode","comment"),c.searchParams.set("invite",r.invite),c.toString()}:void 0,validateSession:async()=>!!o.current,signOut:async()=>{let e=await fetch(`${x}/chisel/api/hosted/logout`,{method:"DELETE",headers:{Authorization:`Bearer ${o.current}`,"X-Chisel-Protocol":"2"}});if(!e.ok&&e.status!==401)throw new Error("Sign out failed.");o.current="",X(n)}},m.user.id),oe&&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. ",d("button",{type:"button",onClick:_,children:"Sign in again"})]})]}):b("main",{className:"chisel-sign-in",children:[d(J,{}),b("section",{children:[d("strong",{className:"chisel-sign-in-brand",children:"chisel"}),d("h1",{children:"Sign in to review"}),d("p",{children:"Connect this website to your Chisel account."}),d("button",{onClick:_,children:"Continue with Chisel"}),P&&d("p",{role:"alert",children:P})]})]})}export{Me as HostedChisel};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import*as p from"react";import{forwardRef as vt,createElement as Mt}from"react";var Fa=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Ba(e,a,t=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:Fa(e),size:24,node:a,...t.length>0?{aliases:t}:{}}}var Da=e=>{let a="",t=!1;for(let o of e){if(o==="-"||o==="_"||o<=" "){t=a.length>0;continue}a.length===0?a+=o.toLowerCase():a+=t?o.toUpperCase():o,t=!1}return a};var Ta=e=>{let a=Da(e);return a.charAt(0).toUpperCase()+a.slice(1)};import{forwardRef as Pt,createElement as Ua}from"react";var Ge=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var Le={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function na(e){return e!=null}function qa(e,a={}){let t=a.attributeNames??{},o=B=>t[B]??B,r=e.size??e.width??Le.width,n=e.size??e.height??Le.height,i=e.aliases?.filter(B=>typeof B=="string"&&B.trim()!=="").map(B=>`lucide-${B}`)??[],c=[...e.name?[`lucide-${e.name}`]:[],...i],f=a.className?.split(" ").filter(Boolean)??[],I=a.includeDefaultClasses===!1?Ge(...f):Ge("lucide",...c,...f),S=a.absoluteStrokeWidth?Number(a.strokeWidth??Le["stroke-width"])*Number(e.size??e.width??Le.width)/Number(a.size??a.width??Le.width):a.strokeWidth??Le["stroke-width"];return["svg",{...Object.entries(Le).reduce((B,[A,b])=>(B[o(A)]=b,B),{}),..."color"in a&&a.color&&{[o("stroke")]:a.color},..."size"in a&&na(a.size)&&{[o("width")]:a.size,[o("height")]:a.size},..."width"in a&&na(a.width)&&{[o("width")]:a.width},..."height"in a&&na(a.height)&&{[o("height")]:a.height},[o("stroke-width")]:S,...I&&{[o("class")]:I},[o("viewBox")]:`0 0 ${r} ${n}`,...a.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(B=>{let[A,b,P]=B,T=a.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...b}:b;return P?[A,T,P]:[A,T]})]}function Ha(e,a={}){return qa(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Oa=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};import{createContext as bt,useContext as kt,useMemo as Xo,createElement as Ko}from"react";var yt=bt({});var Ea=()=>kt(yt);var Na=Pt(({color:e,size:a,width:t,height:o,strokeWidth:r,absoluteStrokeWidth:n,nonScalingStroke:i,className:c="",children:f,iconNode:I=[],icon:S={node:I,aliases:[],size:24},...v},B)=>{let{size:A=24,strokeWidth:b=2,absoluteStrokeWidth:P=!1,nonScalingStroke:T=!1,color:q="currentColor",className:E=""}=Ea()??{},ae=!!f||Oa(v),[M,H,R=[]]=Ha(S,{color:e??q,width:t??a??A,height:o??a??A,strokeWidth:r??b,absoluteStrokeWidth:n??P,nonScalingStroke:i??T,className:Ge(E,c),hasA11yProp:ae,attributes:v});return Ua(M,{ref:B,...H},[...R.map(([W,G])=>Ua(W,G)),...Array.isArray(f)?f:[f]])});function Pe(e,a=[],t=[]){let o=typeof e=="string"?Ba(e,a,t):e,r=vt(({className:n,...i},c)=>Mt(Na,{ref:c,icon:o,className:n,...i}));return o.name&&(r.displayName=Ta(o.name)),r}var At={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]},ve=Pe(At);var Rt={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]},Ve=Pe(Rt);var Ft={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]},ze=Pe(Ft);var Ga=`:is(.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box) :focus{outline:none}.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:light;--chisel-ui-panel-shadow:0 4px 20px rgba(0,0,0,.08);--chisel-ui-canvas:#f7f7f7;--chisel-ui-surface:#ffffff;--chisel-ui-raised:#f5f5f5;--chisel-ui-inset:#eeeeee;--chisel-ui-hover:#f0f0f0;--chisel-ui-selected:#eaeaea;--chisel-ui-border:#e2e2e2;--chisel-ui-border-strong:#c4c4c4;--chisel-ui-text:#242424;--chisel-ui-secondary:#626262;--chisel-ui-muted:#686868;--chisel-ui-focus:#2468d3;--chisel-ui-accent-text:#2468d3;--chisel-ui-accent-surface:#edf4ff;--chisel-ui-action:#242424;--chisel-ui-action-text:#ffffff;--chisel-ui-danger:#b33737;--chisel-ui-avatar:#ededed;--chisel-ui-avatar-text:#565656;--chisel-ui-scrollbar:#c2c2c2;--chisel-ui-checker-light:#e5e5e5;--chisel-ui-checker-dark:#c7c7c7}@media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:dark;--chisel-ui-panel-shadow:0 4px 20px #0003;--chisel-ui-canvas:#171717;--chisel-ui-surface:#222222;--chisel-ui-raised:#2a2a2a;--chisel-ui-inset:#191919;--chisel-ui-hover:#303030;--chisel-ui-selected:#383838;--chisel-ui-border:#3c3c3c;--chisel-ui-border-strong:#555555;--chisel-ui-text:#ededed;--chisel-ui-secondary:#b7b7b7;--chisel-ui-muted:#a5a5a5;--chisel-ui-focus:#8bb9ff;--chisel-ui-accent-text:#8bb9ff;--chisel-ui-accent-surface:#253447;--chisel-ui-action:#ededed;--chisel-ui-action-text:#111111;--chisel-ui-danger:#ffa5a5;--chisel-ui-avatar:#383838;--chisel-ui-avatar-text:#cccccc;--chisel-ui-scrollbar:#50504d;--chisel-ui-checker-light:#555555;--chisel-ui-checker-dark:#333333}}.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--chisel-ui-space:4px;--chisel-ui-control:40px;--chisel-ui-radius:8px;--chisel-ui-text-size:13px;--chisel-ui-small:12px;--chisel-ui-motion:.12s cubic-bezier(.2,0,0,1);--chisel-ui-popover-shadow:0 2px 6px #0000000f,0 12px 36px #0000001f}@media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-popover-shadow:0 0 0 1px #ffffff0d,0 4px 12px #0003,0 16px 40px #0004}}
|
|
1
|
+
"use client";import*as p from"react";import{forwardRef as vt,createElement as Mt}from"react";var Fa=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Ba(e,a,t=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:Fa(e),size:24,node:a,...t.length>0?{aliases:t}:{}}}var Da=e=>{let a="",t=!1;for(let o of e){if(o==="-"||o==="_"||o<=" "){t=a.length>0;continue}a.length===0?a+=o.toLowerCase():a+=t?o.toUpperCase():o,t=!1}return a};var Ta=e=>{let a=Da(e);return a.charAt(0).toUpperCase()+a.slice(1)};import{forwardRef as Pt,createElement as Ua}from"react";var Ge=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var Le={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function na(e){return e!=null}function qa(e,a={}){let t=a.attributeNames??{},o=B=>t[B]??B,r=e.size??e.width??Le.width,n=e.size??e.height??Le.height,i=e.aliases?.filter(B=>typeof B=="string"&&B.trim()!=="").map(B=>`lucide-${B}`)??[],c=[...e.name?[`lucide-${e.name}`]:[],...i],f=a.className?.split(" ").filter(Boolean)??[],I=a.includeDefaultClasses===!1?Ge(...f):Ge("lucide",...c,...f),S=a.absoluteStrokeWidth?Number(a.strokeWidth??Le["stroke-width"])*Number(e.size??e.width??Le.width)/Number(a.size??a.width??Le.width):a.strokeWidth??Le["stroke-width"];return["svg",{...Object.entries(Le).reduce((B,[A,b])=>(B[o(A)]=b,B),{}),..."color"in a&&a.color&&{[o("stroke")]:a.color},..."size"in a&&na(a.size)&&{[o("width")]:a.size,[o("height")]:a.size},..."width"in a&&na(a.width)&&{[o("width")]:a.width},..."height"in a&&na(a.height)&&{[o("height")]:a.height},[o("stroke-width")]:S,...I&&{[o("class")]:I},[o("viewBox")]:`0 0 ${r} ${n}`,...a.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(B=>{let[A,b,P]=B,T=a.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...b}:b;return P?[A,T,P]:[A,T]})]}function Ha(e,a={}){return qa(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Oa=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};import{createContext as bt,useContext as kt,useMemo as Xo,createElement as Ko}from"react";var yt=bt({});var Ea=()=>kt(yt);var Na=Pt(({color:e,size:a,width:t,height:o,strokeWidth:r,absoluteStrokeWidth:n,nonScalingStroke:i,className:c="",children:f,iconNode:I=[],icon:S={node:I,aliases:[],size:24},...v},B)=>{let{size:A=24,strokeWidth:b=2,absoluteStrokeWidth:P=!1,nonScalingStroke:T=!1,color:q="currentColor",className:E=""}=Ea()??{},ae=!!f||Oa(v),[M,H,R=[]]=Ha(S,{color:e??q,width:t??a??A,height:o??a??A,strokeWidth:r??b,absoluteStrokeWidth:n??P,nonScalingStroke:i??T,className:Ge(E,c),hasA11yProp:ae,attributes:v});return Ua(M,{ref:B,...H},[...R.map(([W,G])=>Ua(W,G)),...Array.isArray(f)?f:[f]])});function Pe(e,a=[],t=[]){let o=typeof e=="string"?Ba(e,a,t):e,r=vt(({className:n,...i},c)=>Mt(Na,{ref:c,icon:o,className:n,...i}));return o.name&&(r.displayName=Ta(o.name)),r}var At={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]},ve=Pe(At);var Rt={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]},Ve=Pe(Rt);var Ft={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]},ze=Pe(Ft);var Ga=`:is(.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box,.chisel-project-directory) :focus{outline:none}.chisel-project-directory,.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:light;--chisel-ui-panel-shadow:0 4px 20px rgba(0,0,0,.08);--chisel-ui-canvas:#f7f7f7;--chisel-ui-surface:#ffffff;--chisel-ui-raised:#f5f5f5;--chisel-ui-inset:#eeeeee;--chisel-ui-hover:#f0f0f0;--chisel-ui-selected:#eaeaea;--chisel-ui-border:#e2e2e2;--chisel-ui-border-strong:#c4c4c4;--chisel-ui-text:#242424;--chisel-ui-secondary:#626262;--chisel-ui-muted:#686868;--chisel-ui-focus:#2468d3;--chisel-ui-accent-text:#2468d3;--chisel-ui-accent-surface:#edf4ff;--chisel-ui-action:#242424;--chisel-ui-action-text:#ffffff;--chisel-ui-danger:#b33737;--chisel-ui-avatar:#ededed;--chisel-ui-avatar-text:#565656;--chisel-ui-scrollbar:#c2c2c2;--chisel-ui-checker-light:#e5e5e5;--chisel-ui-checker-dark:#c7c7c7}@media(prefers-color-scheme:dark){.chisel-project-directory,.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:dark;--chisel-ui-panel-shadow:0 4px 20px #0003;--chisel-ui-canvas:#171717;--chisel-ui-surface:#222222;--chisel-ui-raised:#2a2a2a;--chisel-ui-inset:#191919;--chisel-ui-hover:#303030;--chisel-ui-selected:#383838;--chisel-ui-border:#3c3c3c;--chisel-ui-border-strong:#555555;--chisel-ui-text:#ededed;--chisel-ui-secondary:#b7b7b7;--chisel-ui-muted:#a5a5a5;--chisel-ui-focus:#8bb9ff;--chisel-ui-accent-text:#8bb9ff;--chisel-ui-accent-surface:#253447;--chisel-ui-action:#ededed;--chisel-ui-action-text:#111111;--chisel-ui-danger:#ffa5a5;--chisel-ui-avatar:#383838;--chisel-ui-avatar-text:#cccccc;--chisel-ui-scrollbar:#50504d;--chisel-ui-checker-light:#555555;--chisel-ui-checker-dark:#333333}}.chisel-project-directory,.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--chisel-ui-space:4px;--chisel-ui-control:40px;--chisel-ui-radius:8px;--chisel-ui-text-size:13px;--chisel-ui-small:12px;--chisel-ui-motion:.12s cubic-bezier(.2,0,0,1);--chisel-ui-popover-shadow:0 2px 6px #0000000f,0 12px 36px #0000001f}@media(prefers-color-scheme:dark){.chisel-project-directory,.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-popover-shadow:0 0 0 1px #ffffff0d,0 4px 12px #0003,0 16px 40px #0004}}
|
|
2
2
|
`;function ca(e,a){return{schemaVersion:1,activeVersionId:e.some(o=>o.id===a)?a:e[0]?.id??a,versions:e}}function Va(e){if(e===null)return{migrated:!1};let a;try{a=JSON.parse(e)}catch{return{migrated:!1,warning:"Saved edits could not be read. Edits will be kept for this session."}}if(Array.isArray(a)){let t=a.filter(za);return a.length>0&&t.length===0?{migrated:!1,warning:"Saved edits are malformed. Edits will be kept for this session."}:{envelope:ca(t,t[0]?.id??"version-1"),migrated:t.length===a.length,warning:t.length<a.length?"Some malformed saved versions were skipped. Recovered edits will be kept for this session until you make a change.":void 0}}return Bt(a)?{envelope:a,migrated:!1}:{migrated:!1,warning:"Saved edits use an unsupported or malformed format. Edits will be kept for this session."}}function Bt(e){return!Me(e)||e.schemaVersion!==1||typeof e.activeVersionId!="string"||!Array.isArray(e.versions)||!e.versions.every(za)?!1:e.versions.length===0||e.versions.some(a=>a.id===e.activeVersionId)}function za(e){return!Me(e)||typeof e.id!="string"||typeof e.name!="string"||!Me(e.elements)?!1:Object.values(e.elements).every(Dt)}function Dt(e){return!(!Me(e)||typeof e.selector!="string"||!Me(e.styles)||e.sourceHint!==void 0&&typeof e.sourceHint!="string"||e.text!==void 0&&typeof e.text!="string"||!Object.values(e.styles).every(a=>typeof a=="string")||e.asset!==void 0&&!Tt(e.asset))}function Tt(e){return Me(e)&&typeof e.fileName=="string"&&typeof e.mimeType=="string"&&typeof e.size=="number"&&Number.isFinite(e.size)&&e.size>=0}function Me(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}import{Fragment as Xe,jsx as u,jsxs as w}from"react/jsx-runtime";var qt=["px","rem","em"],Ht=[{label:"Inter",value:'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},{label:"System",value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:'Georgia, "Times New Roman", serif'},{label:"Mono",value:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"}],Ot=["Hex","RGB","RGBA","HSL"],Et=["Solid","Gradient","Image"],Ut=[{label:"Font Size",property:"fontSize",cssProperty:"font-size",min:8,max:96,step:1,unit:"px"},{label:"Line",property:"lineHeight",cssProperty:"line-height",min:8,max:120,step:1,unit:"px"},{label:"Tracking",property:"letterSpacing",cssProperty:"letter-spacing",min:-2,max:12,step:.25,unit:"px"},{label:"Padding X",property:"paddingInline",cssProperty:"padding-inline",min:0,max:120,step:1,unit:"px"},{label:"Padding Y",property:"paddingBlock",cssProperty:"padding-block",min:0,max:120,step:1,unit:"px"},{label:"Margin X",property:"marginInline",cssProperty:"margin-inline",min:-80,max:160,step:1,unit:"px"},{label:"Margin Y",property:"marginBlock",cssProperty:"margin-block",min:-80,max:160,step:1,unit:"px"},{label:"Radius",property:"borderRadius",cssProperty:"border-radius",min:0,max:80,step:1,unit:"px"},{label:"Opacity",property:"opacity",cssProperty:"opacity",min:0,max:1,step:.01,unit:""},{label:"Width",property:"width",cssProperty:"width",min:0,max:1200,step:1,unit:"px"},{label:"Height",property:"height",cssProperty:"height",min:0,max:1200,step:1,unit:"px"}],Sa=["color","backgroundColor","backgroundImage","backgroundPosition","backgroundSize","fontFamily","fontSize","lineHeight","letterSpacing","paddingInline","paddingBlock","marginInline","marginBlock","borderRadius","opacity","width","height"],Nt=new Set(["area","audio","base","br","button","canvas","col","embed","hr","iframe","img","input","link","meta","object","param","picture","portal","select","source","textarea","track","video","wbr"]),La="chisel:locationchange",ea=0,la,Ke=!1,Wa=0,xa=new Map,We=new WeakMap;function Cr({id:e,as:a,children:t,...o}){return u(a??"span",{"data-chisel-id":e,...o,children:t})}function Sr({enabled:e=process.env.NODE_ENV!=="production",position:a="right",projectName:t="Next.js app",embedded:o=!1}){let[r,n]=p.useState(null),[i,c]=p.useState(null),[f,I]=p.useState(null),[S,v]=p.useState([]),[B,A]=p.useState(null),[b,P]=p.useState([]),[T,q]=p.useState(!1),[E,ae]=p.useState(""),[M,H]=p.useState(()=>[pa(1)]),[R,W]=p.useState("version-1"),[G,K]=p.useState(!1),[te,U]=p.useState(""),[fe,oe]=p.useState(""),[re,le]=p.useState(!1),[$,ee]=p.useState([]),[m,g]=p.useState(0),[Z,j]=p.useState(""),se=p.useRef(new WeakMap),O=p.useRef(new Map),N=p.useRef(new Map),xe=p.useRef(""),V=p.useRef(null),ne=p.useRef(null),X=p.useRef([]),Je=p.useRef(null),Qe=p.useRef([]),me=p.useRef(null),ge=p.useRef(null),ye=p.useRef(null),He=p.useRef(!1),Ie=p.useRef(null),s=p.useRef(null),L=p.useRef(null),k=p.useRef(!0),D=r?new URLSearchParams(r.search).has("editor"):!1,Q=e&&process.env.NEXT_PUBLIC_CHISEL_ENABLED!=="0"&&(o||D),ya=r?rt(r.pathname,r.search):"";if(p.useEffect(()=>()=>ha(N.current),[]),p.useEffect(()=>{let l=()=>n(Kt());return l(),$t(l)},[]),p.useEffect(()=>{if(Q){He.current=!0;return}if(!He.current||(He.current=!1,o))return;let l=M.find(d=>d.id===R)??M[0];l&&Za(l,O.current,N.current),ha(N.current),V.current=null,ne.current=null,X.current=[],c(null),I(null),v([]),A(null),P([]),q(!1)},[R,Q,o,M]),p.useEffect(()=>{if(!Q||!o)return;let l=()=>{let d=document.documentElement?.dataset.chiselSelection,x=d?document.querySelector(d):null;x instanceof HTMLElement&&!Re(x)&&Ye([x])};return window.addEventListener("chisel:select",l),()=>window.removeEventListener("chisel:select",l)},[Q,o]),p.useEffect(()=>{if(!Q){Ke=!1;return}let l=()=>{Ie.current===null&&(Ie.current=window.requestAnimationFrame(()=>{Ie.current=null;let x=V.current,h=X.current;A(C=>x?ie(x.getBoundingClientRect()):C),P(h.map(C=>ie(C.getBoundingClientRect())))}))},d=x=>{let h=x.target;h instanceof HTMLElement&&Re(h)||x.key==="Escape"&&(ne.current=null,X.current=[],I(null),v([]),P([]))};return document.addEventListener("keydown",d),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{Ie.current!==null&&window.cancelAnimationFrame(Ie.current),s.current!==null&&window.cancelAnimationFrame(s.current),document.removeEventListener("keydown",d),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[Q]),p.useEffect(()=>{ne.current=f},[f]),p.useEffect(()=>{X.current=S},[S]),p.useEffect(()=>{if(!S.length)return;let l=null,d=()=>{l===null&&(l=window.requestAnimationFrame(()=>{l=null,P(S.map(h=>ie(h.getBoundingClientRect())))}))};if(typeof ResizeObserver>"u"){let h=window.setInterval(d,750);return()=>{l!==null&&window.cancelAnimationFrame(l),window.clearInterval(h)}}let x=new ResizeObserver(d);for(let h of S)x.observe(h);return()=>{l!==null&&window.cancelAnimationFrame(l),x.disconnect()}},[f,S]),p.useEffect(()=>{if(!Q)return;let l=jt(ya);xe.current=l,oe(""),V.current=null,ne.current=null,X.current=[],c(null),I(null),v([]),A(null),P([]);let d=M.find(_=>_.id===R)??M[0];d&&Za(d,O.current,N.current),O.current.clear(),ha(N.current);let x=Jt(r?.pathname??window.location.pathname,r?.search??window.location.search),h=Qt(l,x);k.current=!h.warning,U(h.warning??"");let C=h.envelope?.versions.length?h.envelope.versions:[pa(1)],y=h.envelope?.activeVersionId??C[0].id;H(C),W(y),oe(l);let F=C.find(_=>_.id===y)??C[0],z=window.setTimeout(()=>aa(F,C,O.current,N.current),0);if(h.migrated&&h.envelope){let _=$a(l,C,y);_&&U(_)}return Ke=!1,()=>window.clearTimeout(z)},[ya,Q]),p.useEffect(()=>{if(!Q||!k.current||!xe.current||fe!==xe.current)return;let l=$a(xe.current,M,R);l&&U(l)},[R,Q,fe,M]),p.useEffect(()=>{if(!Q||typeof MutationObserver>"u"||!document.body)return;let l=null,d=()=>{l=null;let h=M.find(y=>y.id===R)??M[0];h&&aa(h,M,O.current,N.current,!1),V.current&&!V.current.isConnected&&(V.current=null,c(null),A(null));let C=X.current.filter(y=>y.isConnected);if(C.length!==X.current.length){let y=C[C.length-1]??null;X.current=C,ne.current=y,v(C),I(y),P(C.map(F=>ie(F.getBoundingClientRect())))}},x=new MutationObserver(h=>{if(Ke)return;let C=h.some(F=>{let z=F.target instanceof HTMLElement?F.target:F.target.parentElement;return z&&We.has(z)?!1:z&&!Re(z)?!0:Array.from(F.addedNodes).some(_=>{let Ra=_ instanceof HTMLElement?_:_.parentElement;return!!(Ra&&!Re(Ra))})}),y=h.some(F=>Array.from(F.removedNodes).some(z=>z instanceof HTMLElement&&((V.current?z===V.current||z.contains(V.current):!1)||X.current.some(_=>z===_||z.contains(_)))));!C&&!y||l===null&&(l=window.requestAnimationFrame(d))});return x.observe(document.body,{attributes:!0,attributeFilter:["style"],characterData:!0,childList:!0,subtree:!0}),()=>{x.disconnect(),l!==null&&window.cancelAnimationFrame(l)}},[R,Q,M]),p.useEffect(()=>{if(!re)return;let l=h=>{let C=Y(h,0,Math.max(0,$.length-1)),y=$[C];g(C),y&&(V.current=y,c(y),A(ie(y.getBoundingClientRect())),j(_a(y)))},d=()=>{Ye(Qe.current.filter(h=>h.isConnected)),le(!1),window.requestAnimationFrame(()=>Je.current?.focus())},x=h=>{let C=$[m],y=m;if(h.key==="ArrowDown")y=m+1;else if(h.key==="ArrowUp")y=m-1;else if(h.key==="Home")y=0;else if(h.key==="End")y=$.length-1;else if(h.key==="ArrowRight"&&C){let F=$.find(z=>z.parentElement===C);F&&(y=$.indexOf(F))}else if(h.key==="ArrowLeft"&&C){let F=C.parentElement;for(;F&&!$.includes(F);)F=F.parentElement;F&&(y=$.indexOf(F))}else if(h.key==="Enter"&&C){Ye(h.shiftKey?Ja(X.current,C):[C]),h.shiftKey||le(!1),h.preventDefault();return}else if(h.key==="Escape"){d(),h.preventDefault();return}else return;l(y),h.preventDefault()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[re,$,m]),p.useEffect(()=>{E&&(me.current?.focus(),me.current?.select())},[E]),p.useEffect(()=>{if(!G)return;let l=h=>{K(!1),h&&window.requestAnimationFrame(()=>ye.current?.focus())},d=h=>{h.target instanceof Node&&ge.current?.contains(h.target)||l(!0)},x=h=>{h.key==="Escape"&&(l(!0),h.preventDefault())};return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",x)}},[G]),!Q)return null;let he=S.length,Oe=f?se.current.get(f):void 0,fa=!!(he<=1&&f&&Ya(f)),Ee=f?De(f):void 0,Pa=f?$e(f):"",ue=M.find(l=>l.id===R)??M[0]??pa(1),_e=he>1?S.flatMap(l=>ao(ue.elements[de(l)])):f&&Oe?eo(f,Oe):[],Ce=f?getComputedStyle(f):null,Ue=l=>he>1&&new Set(S.map(d=>getComputedStyle(d)[l])).size>1,Ne=()=>S.length?S:f?[f]:[];function Ye(l){for(let x of l)Wt(x,se.current);let d=l[l.length-1]??null;if(X.current=l,ne.current=d,v(l),I(d),P(l.map(x=>ie(x.getBoundingClientRect()))),o&&d){let x=d.getBoundingClientRect();window.dispatchEvent(new CustomEvent("chisel:selection",{detail:{selector:$e(d),tag:d.tagName.toLowerCase(),x:x.left+x.width/2+window.scrollX,y:x.top+x.height/2+window.scrollY,offsetX:.5,offsetY:.5}}))}}let Se=()=>{P(S.map(l=>ie(l.getBoundingClientRect())))},va=(l,d)=>{let x=document.elementsFromPoint(l,d).find(h=>h instanceof HTMLElement&&!Re(h));return x instanceof HTMLElement?lo(x):null},nt=l=>{L.current={x:l.clientX,y:l.clientY},s.current===null&&(s.current=window.requestAnimationFrame(()=>{s.current=null;let d=L.current;if(!d)return;let x=va(d.x,d.y);if(!x){V.current=null,c(null),A(null);return}x!==V.current&&(V.current=x,c(x),A(ie(x.getBoundingClientRect())))}))},ct=l=>{l.preventDefault(),l.stopPropagation();let d=va(l.clientX,l.clientY);d&&(le(!1),Ye(l.shiftKey?Ja(X.current,d):[d]))},pt=()=>{let l=so();Qe.current=X.current,ee(l),g(0),le(!0);let d=l[0];d?(V.current=d,c(d),A(ie(d.getBoundingClientRect())),j(_a(d))):j("No visible elements available")},mt=()=>{let l={id:`version-${Date.now()}`,name:`Version ${M.length+1}`,elements:Xt(ue.elements)};ia(d=>[...d,l]),W(l.id),K(!1);for(let[d,x]of Object.entries(ue.elements)){if(!x.asset)continue;let h=N.current.get(ke(ue.id,d));h&&N.current.set(ke(l.id,d),h)}aa(l,[...M,l],O.current,N.current),Se()},ht=l=>{W(l.id),K(!1),aa(l,M,O.current,N.current),Se(),window.requestAnimationFrame(()=>ye.current?.focus())},Lt=(l,d)=>{let x=l.unit==="px"?`${d}px`:String(d);Ma(l,x)},Ma=(l,d)=>{let x=Ne();if(x.length){for(let h of x)be(h,de(h),O.current),ce(h),h.style[l.property]=d,we(h,{styles:{[l.property]:d}});Se()}},Aa=(l,d,x)=>{let h=Ne();if(h.length){for(let C of h){let y=de(C);if(be(C,de(C),O.current),ce(C),l==="backgroundColor"&&ho(d)){if(C.style.backgroundImage=d,d.startsWith("url(")){let F=Ia(d),z=ke(R,y);x&&F?_t(N.current,z,F):ma(N.current,z),C.style.backgroundPosition="center",C.style.backgroundSize="cover",we(C,{styles:{backgroundImage:x?"":d,backgroundPosition:"center",backgroundSize:"cover"},asset:x??null})}else we(C,{styles:{backgroundImage:d},asset:null});continue}if(C.style[l]=d,l==="backgroundColor"){ma(N.current,ke(R,y)),C.style.backgroundImage="",C.style.backgroundPosition="",C.style.backgroundSize="",we(C,{styles:{backgroundColor:d,backgroundImage:"",backgroundPosition:"",backgroundSize:""},asset:null});continue}we(C,{styles:{[l]:d}})}Se()}},xt=l=>{let d=Ne();if(d.length){for(let x of d)be(x,de(x),O.current),ce(x),x.style.fontFamily=l,we(x,{styles:{fontFamily:l}});Se()}},gt=l=>{let d=Ne();if(d.length)for(let x of d)be(x,de(x),O.current),ce(x),x.style.fontFamily=l},It=l=>{!f||!fa||(be(f,de(f),O.current),ce(f),f.textContent=l,we(f,{text:l}),Se())},Ct=()=>{let l=Ne();if(l.length){for(let d of l){let x=se.current.get(d),h=de(d),C=O.current.get(h),y=ue.elements[h];if(y){ce(d);for(let F of Object.keys(y.styles))d.style[F]=C?.styles[F]??"";typeof y.text=="string"&&Ya(d)&&(d.textContent=C?.text??x?.text??""),St(d),y.asset&&ma(N.current,ke(R,h))}}Se()}};function we(l,d){let x=de(l);be(l,x,O.current),ia(h=>h.map(C=>{if(C.id!==R)return C;let y=C.elements[x];return{...C,elements:{...C.elements,[x]:{selector:$e(l),sourceHint:De(l),text:d.text??y?.text,asset:d.asset===null?void 0:d.asset??y?.asset,styles:{...y?.styles??{},...d.styles??{}}}}}}))}function St(l){let d=de(l),x=M.some(h=>h.id!==R&&!!h.elements[d]);ia(h=>h.map(C=>{if(C.id!==R)return C;let{[d]:y,...F}=C.elements;return{...C,elements:F}})),x||O.current.delete(d)}function ia(l){k.current=!0,H(l)}let wt=async()=>{let l=f?ie(f.getBoundingClientRect()):void 0,d=Object.keys(ue.elements).length?oo({projectName:t,version:ue,baselines:O.current}):f&&Oe&&l?to({projectName:t,element:f,snapshot:Oe,rect:l,selector:Pa,sourceHint:Ee,changes:_e}):void 0;if(d)try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(d),ae(""),q(!0),window.setTimeout(()=>q(!1),1600)}catch{q(!1),ae(d)}};return w("div",{"data-chisel-root":"true",className:"chisel-root",children:[u(zt,{}),u("div",{className:"chisel-visually-hidden","aria-live":"polite",children:Z}),u("div",{className:"chisel-inspection-layer","aria-hidden":"true",onPointerMove:nt,onPointerLeave:()=>{L.current=null,s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,V.current=null,c(null),A(null)},onClick:ct}),B&&i&&!S.includes(i)?u(Xa,{rect:B,tone:"hover"}):null,b.map((l,d)=>u(Xa,{rect:l,tone:"selected"},`${l.left}-${l.top}-${d}`)),u("aside",{className:`chisel-panel chisel-panel-${a}`,"aria-label":"Chisel editor",children:u("div",{className:"chisel-panel-wrapper",children:u("div",{className:"chisel-panel-inner",children:w("div",{className:"chisel-folder chisel-folder-root",children:[u("header",{className:"chisel-folder-header chisel-panel-header",children:w("div",{className:"chisel-panel-toolbar",children:[u("button",{className:"chisel-toolbar-add",type:"button","aria-label":"Add version",onClick:mt,children:u(Ve,{size:16,strokeWidth:1.75,"aria-hidden":"true"})}),w("div",{className:"chisel-preset-manager",ref:ge,children:[w("button",{className:"chisel-preset-trigger",type:"button","aria-expanded":G,"aria-haspopup":"listbox",ref:ye,onClick:()=>K(l=>{let d=!l;return d&&window.requestAnimationFrame(()=>ge.current?.querySelector('[role="option"][aria-selected="true"]')?.focus()),d}),children:[u("span",{className:"chisel-preset-trigger-label",children:ue.name}),u(ve,{className:"chisel-chevron",size:16,strokeWidth:1.75,"aria-hidden":"true"})]}),G?u("div",{className:"chisel-preset-dropdown",role:"listbox","aria-label":"Page versions",onKeyDown:ba,children:u("div",{className:"chisel-preset-list",children:M.map(l=>w("button",{className:"chisel-preset-item",type:"button",role:"option","aria-selected":l.id===ue.id,"data-active":l.id===ue.id,onClick:()=>ht(l),children:[u("span",{className:"chisel-preset-name",children:l.name}),u("span",{className:"chisel-preset-count",children:Object.keys(l.elements).length})]},l.id))})}):null]}),u("button",{className:"chisel-toolbar-add",type:"button",onClick:()=>{ne.current=null,X.current=[],I(null),v([]),P([])},"aria-label":"Clear selection",children:u(ze,{size:16,strokeWidth:1.75,"aria-hidden":"true"})})]})}),te?u("div",{className:"chisel-note-row chisel-warning",role:"alert",children:te}):null,f&&Oe?w("div",{className:"chisel-content",children:[w("div",{className:"chisel-text-control chisel-context-row",children:[u("span",{className:"chisel-text-label",children:he>1?"Selection":"Element"}),u("code",{className:"chisel-text-code",children:he>1?`${he} elements`:f.tagName.toLowerCase()})]}),he===1?w(Xe,{children:[w("div",{className:"chisel-text-control chisel-context-row chisel-selector-row",children:[u("span",{className:"chisel-text-label",children:"Selector"}),u("code",{className:"chisel-selector",children:Pa})]}),w("div",{className:Ee?"chisel-text-control chisel-context-row":"chisel-text-control chisel-context-row chisel-warning-row",children:[u("span",{className:"chisel-text-label",children:"Source"}),u("span",{className:Ee?"chisel-text-value":"chisel-warning",children:Ee?`Source hint: ${Ee}`:"Low-confidence source mapping"})]})]}):null,w("div",{className:"chisel-folder",children:[u("div",{className:"chisel-folder-header",children:u("div",{className:"chisel-folder-header-top",children:u("div",{className:"chisel-folder-title-row",children:u("span",{className:"chisel-folder-title",children:"Content"})})})}),u("div",{className:"chisel-folder-content",children:w("div",{className:"chisel-folder-inner",children:[w("label",{className:"chisel-text-control chisel-textarea-control",children:[u("span",{className:"chisel-text-label",children:"Text"}),u("textarea",{className:"chisel-text-input",value:f.textContent??"",onChange:l=>It(l.target.value),disabled:!fa,rows:3})]}),fa?null:u("div",{className:"chisel-note-row",children:he>1?"Text editing is enabled for one element at a time.":"Text editing is enabled for simple text elements."})]})})]}),w("div",{className:"chisel-folder",children:[u("div",{className:"chisel-folder-header",children:u("div",{className:"chisel-folder-header-top",children:u("div",{className:"chisel-folder-title-row",children:u("span",{className:"chisel-folder-title",children:"Color"})})})}),u("div",{className:"chisel-folder-content",children:w("div",{className:"chisel-folder-inner",children:[u(Ka,{label:"Text",value:f.style.color||Be(Ce?.color??"#000000"),onChange:l=>Aa("color",l),mixed:Ue("color")}),u(Ka,{label:"Fill",value:f.style.backgroundImage||(Ce?.backgroundImage&&Ce.backgroundImage!=="none"?Ce.backgroundImage:f.style.backgroundColor||Be(Ce?.backgroundColor??"#ffffff")),onChange:(l,d)=>Aa("backgroundColor",l,d),supportsBackgroundImages:!0,unavailableAsset:ue.elements[de(f)]?.asset,mixed:Ue("backgroundColor")||Ue("backgroundImage")})]})})]}),w("div",{className:"chisel-folder",children:[u("div",{className:"chisel-folder-header",children:u("div",{className:"chisel-folder-header-top",children:u("div",{className:"chisel-folder-title-row",children:u("span",{className:"chisel-folder-title",children:"Style"})})})}),u("div",{className:"chisel-folder-content",children:w("div",{className:"chisel-folder-inner",children:[u(Gt,{value:Ce?.fontFamily??"",onChange:xt,onPreview:gt,mixed:Ue("fontFamily")}),Ut.map(l=>u(Vt,{control:l,computedStyle:Ce,element:f,mixed:Ue(l.property),onSlide:d=>Lt(l,d),onValueChange:d=>Ma(l,d)},l.cssProperty))]})})]}),w("div",{className:"chisel-folder",children:[u("div",{className:"chisel-folder-header",children:w("div",{className:"chisel-folder-header-top",children:[u("div",{className:"chisel-folder-title-row",children:u("span",{className:"chisel-folder-title",children:"Changes"})}),u("span",{className:"chisel-folder-count",children:_e.length})]})}),u("div",{className:"chisel-folder-content",children:u("div",{className:"chisel-folder-inner",children:_e.length?_e.map((l,d)=>w("div",{className:"chisel-text-control",children:[u("span",{className:"chisel-text-label",children:l.property}),u("strong",{className:"chisel-text-value",children:String(l.after)})]},`${l.property}-${d}`)):u("div",{className:"chisel-note-row",children:"No preview changes yet."})})})]}),w("div",{className:"chisel-actions",children:[u("button",{className:"chisel-button",type:"button",onClick:Ct,children:"Reset"}),u("button",{className:"chisel-button chisel-button-primary",type:"button",onClick:wt,children:T?"Copied":"Copy agent prompt"})]}),T?u("div",{className:"chisel-note-row",role:"status",children:"Prompt copied"}):null,E?w("div",{className:"chisel-note-row",role:"alert",children:["Press Cmd+C/Ctrl+C",u("textarea",{ref:me,readOnly:!0,value:E,"aria-label":"Agent prompt copy fallback"})]}):null]}):w("div",{className:"chisel-empty",children:[u("div",{className:"chisel-note-row",children:"Select any visible element to edit its text and style preview."}),u("button",{className:"chisel-button",type:"button",ref:Je,onClick:pt,"aria-pressed":re,children:"Pick element"})]})]})})})})]})}function Xa({rect:e,tone:a}){return u("div",{className:`chisel-box chisel-box-${a}`,style:{transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:e.width,height:e.height}})}function Gt({value:e,onChange:a,onPreview:t,mixed:o=!1}){let[r,n]=p.useState(!1),i=p.useRef(null),c=p.useRef(null),f=p.useRef(e),I=p.useMemo(()=>io(e),[e]),S=no(e,I),v=o?"Mixed":S?.label??Ze(e)??"Font";p.useEffect(()=>{r||(f.current=e)},[r,e]),p.useEffect(()=>{if(!r)return;let b=T=>{let q=T.target;q instanceof Node&&i.current?.contains(q)||(t(f.current),n(!1),window.requestAnimationFrame(()=>c.current?.focus()))},P=T=>{T.key==="Escape"&&(t(f.current),n(!1),window.requestAnimationFrame(()=>c.current?.focus()))};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",P)}},[r,t]);let B=()=>{if(r){t(f.current),n(!1);return}f.current=e,n(!0),window.requestAnimationFrame(()=>i.current?.querySelector('[role="option"][aria-selected="true"]')?.focus())},A=b=>{f.current=b.value,a(b.value),n(!1),window.requestAnimationFrame(()=>c.current?.focus())};return w("div",{className:"chisel-font-control",ref:i,children:[u("span",{className:"chisel-font-label",children:"Font"}),w("div",{className:"chisel-font-picker",children:[w("button",{className:"chisel-font-trigger",ref:c,type:"button","aria-expanded":r,"aria-haspopup":"listbox",onClick:B,children:[u("span",{className:"chisel-font-trigger-label",children:v}),u(ve,{className:"chisel-chevron",size:16,strokeWidth:1.75,"aria-hidden":"true"})]}),r?u("div",{className:"chisel-preset-dropdown chisel-font-dropdown",role:"listbox","aria-label":"Font family",onKeyDown:ba,children:u("div",{className:"chisel-preset-list chisel-font-list",children:I.map(b=>u("button",{className:"chisel-preset-item chisel-font-item","data-active":ua(e,b.value),"aria-selected":ua(e,b.value),onClick:()=>A(b),onFocus:()=>t(b.value),onPointerEnter:()=>t(b.value),role:"option",style:{fontFamily:b.value},type:"button",children:u("span",{className:"chisel-preset-name",children:b.label})},b.value))})}):null]})]})}function Ka({label:e,value:a,onChange:t,supportsBackgroundImages:o=!1,unavailableAsset:r,mixed:n=!1}){let i=tt(a),c=Ia(a),f=o&&i?"Gradient":o&&(c!==void 0||r)?"Image":"Solid",I=i?.start??(c!==void 0?"#FFFFFF":at(a)),[S,v]=p.useState(f),[B,A]=p.useState(()=>Ae(I)),[b,P]=p.useState(I),[T,q]=p.useState(i?.start??I),[E,ae]=p.useState(i?.end??"#FFFFFF"),[M,H]=p.useState("start"),[R,W]=p.useState(c??""),[G,K]=p.useState(""),[te,U]=p.useState(!1),[fe,oe]=p.useState(!1),re=p.useRef(null),le=p.useRef(null),$=S==="Gradient"?M==="start"?T:E:b,ee=Be($).toUpperCase(),m=mo($),g=p.useMemo(()=>uo(ka(ee)),[ee]),Z=n?"Mixed":S==="Gradient"?"Gradient":S==="Image"?"Image":b;p.useEffect(()=>{let s=tt(a),L=Ia(a);if(o&&s){let D=M==="end"?s.end:s.start;v("Gradient"),q(s.start),ae(s.end),P(D),A(Ae(D)),U(!1);return}if(o&&L!==void 0){v("Image"),W(L),P("#FFFFFF"),U(!1);return}if(o&&r){v("Image"),W(""),K(""),U(!1);return}let k=at(a);v("Solid"),P(D=>D&&Be(D)===Be(k)?D:k),A(Ae(k)),U(!1)},[M,o,r,a]),p.useEffect(()=>{if(!fe)return;let s=k=>{let D=k.target;D instanceof Node&&re.current?.contains(D)||(oe(!1),window.requestAnimationFrame(()=>le.current?.focus()))},L=k=>{k.key==="Escape"&&(oe(!1),window.requestAnimationFrame(()=>le.current?.focus()),k.preventDefault())};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",L)}},[fe]);let j=s=>{let L=et(s);if(!L){U(s.trim().length>0);return}let k=Te(L)??L;if(A(Ae(k)),P(k),U(!1),S==="Gradient"){ge(M,k);return}t(k)},se=(s,L=m,k=B)=>{let D=po(s,L,k);if(P(D),U(!1),S==="Gradient"){ge(M,D);return}t(D)},O=(s,L)=>{let k=Y((s.clientX-L.left)/L.width*100,0,100),D=Y((1-(s.clientY-L.top)/L.height)*100,0,100);se(ta(g.h,k,D))},N=(s,L)=>{let k=Y((s.clientX-L.left)/L.width*360,0,360);se(ta(k,g.s,g.v))},xe=(s,L)=>{let k=Y((s.clientX-L.left)/L.width,0,1);se(ee,k)},V=s=>{if(!ra(s.key))return;let L=s.shiftKey?10:1,k=Y(g.s+(s.key==="ArrowRight"?L:s.key==="ArrowLeft"?-L:0),0,100),D=Y(g.v+(s.key==="ArrowUp"?L:s.key==="ArrowDown"?-L:0),0,100);se(ta(g.h,k,D)),s.preventDefault()},ne=s=>{if(!ra(s.key))return;let L=s.shiftKey?10:1,k=Y(g.h+(Ca(s.key)?L:-L),0,360);se(ta(k,g.s,g.v)),s.preventDefault()},X=s=>{if(!ra(s.key))return;let L=s.shiftKey?.1:.01;se(ee,Y(m+(Ca(s.key)?L:-L),0,1)),s.preventDefault()},Je=s=>{A(s),se(ee,m,s)},Qe=s=>{if(!(s!=="Solid"&&!o)){if(v(s),s==="Solid"&&t(b),s==="Gradient"){let L=T||b;q(L),H("start"),P(L),t(oa(L,E))}s==="Image"&&R.trim()&&t(Fe(R))}},me=s=>{let L=s==="start"?T:E;H(s),P(L),A(Ae(L)),U(!1)},ge=(s,L)=>{let k=s==="start"?L:T,D=s==="end"?L:E;q(k),ae(D),t(oa(k,D))},ye=(s,L)=>{let k=et(L);if(s==="start"?q(L):ae(L),H(s),P(L),!k){U(L.trim().length>0);return}let D=Te(k)??k;A(Ae(D)),P(D),U(!1),ge(s,D)},He=s=>{W(s),K(""),t(s.trim()?Fe(s):"")},Ie=s=>{let L=s.currentTarget.files?.[0];if(!L)return;let k=URL.createObjectURL(L);K(L.name),W(k),t(Fe(k),{fileName:L.name,mimeType:L.type,size:L.size})};return w("div",{className:"chisel-color-control","data-picker-open":fe,ref:re,children:[u("span",{className:"chisel-color-label",children:e}),w("span",{className:"chisel-color-inputs",children:[u("button",{className:"chisel-color-swatch",ref:le,"aria-expanded":fe,"aria-label":`${e} color picker`,onClick:()=>oe(s=>!s),style:{background:S==="Gradient"?oa(T,E):S==="Image"&&R?Fe(R):b},type:"button"}),u("input",{className:"chisel-color-value-input","aria-label":`${e} color value`,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off","data-invalid":te,readOnly:S!=="Solid",spellCheck:!1,style:{width:`${Math.max(7.5,Math.min(Z.length+.5,18))}ch`},value:Z,onBlur:()=>{S==="Solid"&&j(b)},onChange:s=>{if(S!=="Solid")return;let L=s.target.value;P(L),j(L)},onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),j(b),s.currentTarget.blur()),s.key==="Escape"&&(s.preventDefault(),P(I),U(!1),oe(!1),s.currentTarget.blur())}})]}),fe?w("div",{className:"chisel-color-popover",role:"dialog","aria-label":`${e} custom color picker`,children:[w("div",{className:"chisel-color-tabs",children:[Et.map(s=>u("button",{className:"chisel-color-tab","data-active":S===s,"aria-disabled":s!=="Solid"&&!o,onClick:()=>Qe(s),type:"button",children:s},s)),u("button",{className:"chisel-color-close","aria-label":"Close color picker",onClick:()=>oe(!1),type:"button",children:"\xD7"})]}),S!=="Image"?w(Xe,{children:[S==="Gradient"?w(Xe,{children:[u("div",{className:"chisel-color-gradient-preview",style:{backgroundImage:oa(T,E)}}),w("div",{className:"chisel-color-stop-buttons",role:"group","aria-label":`${e} gradient endpoints`,children:[w("button",{className:"chisel-color-stop-button","data-active":M==="start","aria-label":`${e} gradient From`,onClick:()=>me("start"),type:"button",children:[u("span",{className:"chisel-color-stop-swatch",style:{background:T}}),u("span",{children:"From"})]}),w("button",{className:"chisel-color-stop-button","data-active":M==="end","aria-label":`${e} gradient To`,onClick:()=>me("end"),type:"button",children:[u("span",{className:"chisel-color-stop-swatch",style:{background:E}}),u("span",{children:"To"})]})]})]}):null,u("div",{className:"chisel-color-field",role:"slider",tabIndex:0,"aria-label":`${e} saturation and brightness`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":g.s,"aria-valuetext":`Saturation ${g.s}%, brightness ${g.v}%`,onKeyDown:V,onPointerDown:s=>{let L=s.currentTarget.getBoundingClientRect();O(s,L),s.currentTarget.setPointerCapture(s.pointerId)},onPointerMove:s=>{s.buttons&1&&O(s,s.currentTarget.getBoundingClientRect())},style:{backgroundColor:`hsl(${g.h} 100% 50%)`},children:u("span",{className:"chisel-color-field-cursor",style:{left:`clamp(10px, ${g.s}%, calc(100% - 10px))`,top:`clamp(10px, ${100-g.v}%, calc(100% - 10px))`,backgroundColor:ee}})}),u("div",{className:"chisel-color-hue",role:"slider",tabIndex:0,"aria-label":`${e} hue`,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":g.h,onKeyDown:ne,onPointerDown:s=>{let L=s.currentTarget.getBoundingClientRect();N(s,L),s.currentTarget.setPointerCapture(s.pointerId)},onPointerMove:s=>{s.buttons&1&&N(s,s.currentTarget.getBoundingClientRect())},children:u("span",{className:"chisel-color-hue-cursor",style:{left:`clamp(8px, ${g.h/360*100}%, calc(100% - 8px))`}})}),w("div",{className:"chisel-color-alpha",role:"slider",tabIndex:0,"aria-label":`${e} alpha`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(m*100),"aria-valuetext":`${Math.round(m*100)}%`,onKeyDown:X,onPointerDown:s=>{let L=s.currentTarget.getBoundingClientRect();xe(s,L),s.currentTarget.setPointerCapture(s.pointerId)},onPointerMove:s=>{s.buttons&1&&xe(s,s.currentTarget.getBoundingClientRect())},style:{"--chisel-alpha-color":ee},children:[u("span",{className:"chisel-color-alpha-fill",style:{width:`${m*100}%`}}),u("span",{className:"chisel-color-alpha-cursor",style:{left:`clamp(12px, ${m*100}%, calc(100% - 12px))`,backgroundColor:ft(ee,m)}})]}),w("div",{className:"chisel-color-format-row",children:[u("select",{className:"chisel-color-format-select","aria-label":`${e} color format`,value:B,onChange:s=>Je(s.target.value),children:Ot.map(s=>u("option",{value:s,children:s},s))}),u("input",{className:"chisel-color-format-input","aria-label":`${e} formatted color value`,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off","data-invalid":te,spellCheck:!1,value:b,onBlur:()=>j(b),onChange:s=>{let L=s.target.value;P(L),j(L)}})]})]}):null,S==="Gradient"?w(Xe,{children:[w("label",{className:"chisel-color-extra-row",children:[u("span",{children:"From"}),u("input",{"aria-label":`${e} gradient From value`,value:T,onFocus:()=>me("start"),onChange:s=>ye("start",s.target.value)})]}),w("label",{className:"chisel-color-extra-row",children:[u("span",{children:"To"}),u("input",{"aria-label":`${e} gradient To value`,value:E,onFocus:()=>me("end"),onChange:s=>ye("end",s.target.value)})]})]}):null,S==="Image"?w(Xe,{children:[w("label",{className:"chisel-color-extra-row",children:[u("span",{children:"URL"}),u("input",{"aria-label":`${e} image URL`,value:R,onChange:s=>He(s.target.value),placeholder:"https://..."})]}),w("label",{className:"chisel-color-upload-row",children:[u("span",{children:"Upload"}),u("span",{className:"chisel-color-upload-name",children:G||"Choose image"}),u("input",{"aria-label":`${e} image upload`,accept:"image/*",type:"file",onChange:Ie})]}),r&&!R.startsWith("blob:")?w("div",{className:"chisel-note-row",role:"status",children:["Re-select this asset: ",r.fileName]}):null]}):null]}):null]})}function Vt({control:e,computedStyle:a,element:t,onSlide:o,onValueChange:r,mixed:n=!1}){let c=(a??getComputedStyle(t))[e.property],f=parseFloat(c),I=e.property==="width"?t.getBoundingClientRect().width:e.property==="height"?t.getBoundingClientRect().height:e.min,S=Number.isFinite(f)?f:I,v=Y(S,e.min,e.max),B=vo(v,e.min,e.max),A=t.style[e.property],b=n?"Mixed":A||`${pe(S)}${e.unit}`,P=yo(b,e),[T,q]=p.useState(b),[E,ae]=p.useState(!1),[M,H]=p.useState(!1),[R,W]=p.useState(!1),G=p.useRef(null),K=p.useRef(null),te=p.useRef(!1),U=p.useMemo(()=>xo(e),[e]),fe={left:`max(5px, ${B}% - 9px)`,"--chisel-handle-opacity":B<18?"0.18":"1","--chisel-handle-scale":B<18?"0.25":"1"};p.useEffect(()=>{E||(q(b),H(!1))},[b,E]),p.useEffect(()=>{if(!R)return;let m=()=>{W(!1),window.requestAnimationFrame(()=>G.current?.focus())},g=j=>{j.target instanceof Node&&G.current?.parentElement?.contains(j.target)||m()},Z=j=>{j.key==="Escape"&&(m(),j.preventDefault())};return document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",Z),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",Z)}},[R]);let oe=(m=T)=>{let g=da(m,e,t,P);if(!g){H(!0);return}q(g),H(!1),r(g)},re=()=>{G.current?.focus(),G.current?.select()},le=(m,g)=>{let Z=Mo(m,g,e);q(`${pe(Z)}${e.unit}`),H(!1),o(Z)},$=()=>{U.length<=1||(W(!0),window.requestAnimationFrame(()=>G.current?.parentElement?.querySelector('[role="option"][aria-selected="true"]')?.focus()))},ee=m=>{let g=go(T,m,e,t,P);if(!g){H(!0);return}q(g),H(!1),r(g),W(!1),G.current?.focus()};return w("div",{className:"chisel-slider","data-units-open":R,onDoubleClick:m=>{m.preventDefault(),m.stopPropagation(),$()},onClick:()=>{if(te.current){te.current=!1;return}window.setTimeout(re,0)},onMouseUp:()=>{te.current||window.setTimeout(re,0)},onPointerCancel:m=>{K.current?.pointerId===m.pointerId&&(K.current=null)},onPointerDown:m=>{m.preventDefault(),K.current={pointerId:m.pointerId,startX:m.clientX,rect:m.currentTarget.getBoundingClientRect(),dragging:!1},m.currentTarget.setPointerCapture(m.pointerId),window.setTimeout(re,0)},onPointerMove:m=>{let g=K.current;!g||g.pointerId!==m.pointerId||!g.dragging&&Math.abs(m.clientX-g.startX)<4||(g.dragging=!0,G.current?.blur(),m.preventDefault(),le(m.clientX,g.rect))},onPointerUp:m=>{let g=K.current;!g||g.pointerId!==m.pointerId||(g.dragging&&(te.current=!0,window.setTimeout(()=>{te.current=!1},250),le(m.clientX,g.rect)),g.dragging||window.setTimeout(re,0),K.current=null)},children:[u("span",{className:"chisel-slider-label",children:e.label}),u("span",{className:"chisel-slider-hashmarks","aria-hidden":"true",children:Array.from({length:9},(m,g)=>u("span",{className:"chisel-slider-hashmark",style:{left:`${(g+1)*10}%`}},g))}),u("span",{className:"chisel-slider-fill",style:{width:`${B}%`}}),u("span",{className:"chisel-slider-handle",style:fe}),u("input",{type:"range",tabIndex:-1,"aria-hidden":"true",min:e.min,max:e.max,step:e.step,value:v,onChange:m=>o(Number(m.target.value))}),u("input",{ref:G,className:"chisel-slider-value-input","aria-label":`${e.label} value`,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off","data-invalid":M,spellCheck:!1,value:T,onBlur:m=>{oe(),ae(!1),m.relatedTarget instanceof HTMLElement&&m.currentTarget.parentElement?.contains(m.relatedTarget)||W(!1)},onChange:m=>{let g=m.target.value;q(g);let Z=da(g,e,t,P);if(!Z){H(g.trim().length>0);return}H(!1),r(Z),Z!==g&&Lo(g)&&q(Z)},onFocus:m=>{ae(!0),m.currentTarget.select()},onMouseDown:m=>{window.setTimeout(()=>{m.currentTarget.focus(),m.currentTarget.select()},0)},onMouseUp:m=>{window.setTimeout(()=>{m.currentTarget.focus(),m.currentTarget.select()},0)},onDoubleClick:m=>{m.preventDefault(),m.stopPropagation(),$()},onKeyDown:m=>{if(m.key==="Enter"&&(m.preventDefault(),oe(),m.currentTarget.blur()),ra(m.key)){let g=Po(T,e,t,P,m.shiftKey?10:1,Ca(m.key));if(!g)return;m.preventDefault(),q(g),H(!1),r(g)}m.key==="Escape"&&(m.preventDefault(),q(b),H(!1),W(!1),m.currentTarget.blur())}}),R?u("div",{className:"chisel-unit-menu",role:"listbox","aria-label":`${e.label} units`,onKeyDown:ba,children:U.map(m=>u("button",{className:"chisel-unit-option","data-active":m===P,"aria-selected":m===P,onClick:g=>{g.preventDefault(),ee(m)},onPointerDown:g=>{g.preventDefault(),g.stopPropagation()},role:"option",type:"button",children:m||"unitless"},m||"unitless"))}):null]})}function zt(){return u("style",{children:""+Ga+`.chisel-root,.chisel-root *{box-sizing:border-box}.chisel-root :where(button,input,textarea,select){margin:0;font:inherit;color:inherit;text-transform:none}.chisel-root button{appearance:none;min-width:var(--chisel-ui-control);min-height:var(--chisel-ui-control)}.chisel-root{--chisel-surface: rgba(0, 0, 0, .04);--chisel-surface-hover: rgba(0, 0, 0, .08);--chisel-surface-active: rgba(0, 0, 0, .1);--chisel-surface-subtle: rgba(0, 0, 0, .06);--chisel-text-root: #000;--chisel-text-section: rgba(0, 0, 0, .65);--chisel-text-label: rgba(0, 0, 0, .6);--chisel-text-focus: #000;--chisel-text-primary: rgba(0, 0, 0, .9);--chisel-text-secondary: rgba(0, 0, 0, .55);--chisel-text-tertiary: rgba(0, 0, 0, .55);--chisel-border: rgba(0, 0, 0, .1);--chisel-border-hover: rgba(0, 0, 0, .15);--chisel-glass-bg: rgba(250, 250, 250, .88);--chisel-radius: 8px;--chisel-row-height: 40px;--chisel-shadow: 0 4px 20px rgba(0, 0, 0, .08);--chisel-motion: .15s cubic-bezier(.2, .8, .2, 1);position:fixed;inset:0;height:100dvh;z-index:2147483647;pointer-events:none;font-family:var(--chisel-ui-font);color:var(--chisel-text-primary);letter-spacing:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.chisel-root{color-scheme:light;--chisel-warning-color: #805b12;--chisel-danger-color: #8a1f1f}@media(prefers-color-scheme:dark){.chisel-root{color-scheme:dark;--chisel-warning-color: #e2c78c;--chisel-danger-color: #ffa5a5;--chisel-surface: #303030;--chisel-surface-hover: #393939;--chisel-surface-active: #41413e;--chisel-surface-subtle: #383838;--chisel-text-root: #e8e8e5;--chisel-text-section: #b4b4ae;--chisel-text-label: #b4b4ae;--chisel-text-focus: #efeee9;--chisel-text-primary: #e8e8e5;--chisel-text-secondary: #b4b4ae;--chisel-text-tertiary: #9b9b93;--chisel-border: #41413e;--chisel-border-hover: #62625b;--chisel-glass-bg: #262626;--chisel-shadow: 0 4px 20px #0003}}.chisel-root{--chisel-surface:var(--chisel-ui-raised);--chisel-surface-hover:var(--chisel-ui-hover);--chisel-surface-active:var(--chisel-ui-selected);--chisel-surface-subtle:var(--chisel-ui-border);--chisel-text-root:var(--chisel-ui-text);--chisel-text-section:var(--chisel-ui-secondary);--chisel-text-label:var(--chisel-ui-secondary);--chisel-text-focus:var(--chisel-ui-text);--chisel-text-primary:var(--chisel-ui-text);--chisel-text-secondary:var(--chisel-ui-secondary);--chisel-text-tertiary:var(--chisel-ui-muted);--chisel-border:var(--chisel-ui-border);--chisel-border-hover:var(--chisel-ui-border-strong);--chisel-glass-bg:var(--chisel-ui-surface);--chisel-radius:var(--chisel-ui-radius);--chisel-row-height:var(--chisel-ui-control);--chisel-shadow:var(--chisel-ui-panel-shadow);--chisel-motion:var(--chisel-ui-motion)}.chisel-inspection-layer{position:fixed;inset:0;pointer-events:auto;touch-action:pan-y pinch-zoom}.chisel-visually-hidden{position:fixed;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.chisel-box{position:fixed;left:0;top:0;border-radius:0;pointer-events:none;transition:none}.chisel-box-hover{border:1px solid var(--chisel-ui-focus);background:color-mix(in srgb,var(--chisel-ui-focus) 8%,transparent)}.chisel-box-selected{border:2px solid var(--chisel-ui-focus);box-shadow:0 0 0 1px #ffffffeb,0 0 0 4px color-mix(in srgb,var(--chisel-ui-focus) 18%,transparent)}.chisel-panel{position:fixed;top:max(16px,env(safe-area-inset-top));max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));width:280px;pointer-events:auto;overflow:visible}.chisel-panel-right{right:16px}.chisel-panel-left{left:16px}.chisel-panel-wrapper{display:inline-flex;flex-direction:column;width:100%}.chisel-panel-inner{width:280px;max-height:calc(100vh - 32px);overflow-y:auto;padding:12px 16px 0;border:0;border-radius:16px;background:var(--chisel-glass-bg);box-shadow:var(--chisel-ui-popover-shadow);transform:translateZ(0);-ms-overflow-style:none;scrollbar-width:none}.chisel-panel-inner::-webkit-scrollbar{display:none}.chisel-folder{border:0;margin-bottom:16px;padding-bottom:0}.chisel-folder-root{border-bottom:none;margin-bottom:0;padding-bottom:0}.chisel-panel-header{border:0;margin-bottom:16px;padding-bottom:0}.chisel-folder-header{user-select:none}.chisel-folder-header-top{display:flex;align-items:center;justify-content:space-between;height:var(--chisel-row-height);padding:0}.chisel-folder-title-row{display:flex;align-items:center;gap:6px;min-width:0;flex:1;overflow:hidden;white-space:nowrap}.chisel-folder-title{color:var(--chisel-text-section);font-size:13px;font-weight:600;letter-spacing:-.01em;transform:translateY(-.5px)}.chisel-folder-title-root{color:var(--chisel-text-root);font-size:15px;font-weight:600;transform:translateZ(0)}.chisel-folder-count{color:var(--chisel-text-tertiary);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:12px;font-weight:500}.chisel-folder-content{position:relative}.chisel-folder-inner,.chisel-content,.chisel-empty{display:flex;flex-direction:column;gap:6px;padding-bottom:10px}.chisel-folder:not(.chisel-folder-root){border:0;margin-top:16px;margin-bottom:0;padding-bottom:0}.chisel-folder:not(.chisel-folder-root)+.chisel-folder:not(.chisel-folder-root){margin-top:16px}.chisel-panel-toolbar{display:flex;align-items:center;gap:6px;height:var(--chisel-row-height);min-width:0;margin-bottom:6px;overflow:visible}.chisel-toolbar-add{width:var(--chisel-row-height);height:var(--chisel-row-height);flex-shrink:0;display:flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--chisel-radius);background:var(--chisel-surface);color:var(--chisel-text-label);font:inherit;font-size:16px;font-weight:500;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}.chisel-toolbar-add:hover,.chisel-preset-trigger:hover,.chisel-button:hover{background:var(--chisel-surface-hover);color:var(--chisel-text-primary)}.chisel-toolbar-add:active,.chisel-preset-trigger:active,.chisel-button:active{transform:scale(.96)}.chisel-preset-manager{position:relative;flex:1;min-width:0}.chisel-preset-trigger{width:100%;min-width:0;height:var(--chisel-row-height);display:flex;align-items:center;justify-content:space-between;padding:0 12px;border:none;border-radius:var(--chisel-radius);background:var(--chisel-surface);color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion);overflow:hidden}.chisel-preset-trigger[aria-expanded=true]{background:var(--chisel-surface-active)}.chisel-preset-trigger-label,.chisel-font-trigger-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chisel-chevron{width:16px;height:16px;flex-shrink:0;margin-left:8px;opacity:.72;transition:transform var(--chisel-motion),opacity var(--chisel-motion)}.chisel-preset-trigger[aria-expanded=true] .chisel-chevron,.chisel-font-trigger[aria-expanded=true] .chisel-chevron{opacity:1;transform:rotate(180deg)}.chisel-preset-dropdown{position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:2147483647;padding:4px;border:0;border-radius:12px;background:var(--chisel-glass-bg);box-shadow:0 4px 16px #00000014;animation:chisel-pop-in var(--chisel-motion);transform-origin:top center}.chisel-preset-list{display:flex;flex-direction:column;gap:2px}.chisel-preset-item{width:100%;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border:none;border-radius:8px;background:transparent;color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}.chisel-preset-item:hover{background:var(--chisel-surface-hover)}.chisel-preset-item[data-active=true]{background:var(--chisel-surface-active);color:var(--chisel-text-primary)}.chisel-preset-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chisel-preset-count{color:var(--chisel-text-tertiary);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:11px}.chisel-text-control,.chisel-color-control,.chisel-font-control{min-height:var(--chisel-row-height);display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 12px;border-radius:var(--chisel-radius);background:var(--chisel-surface)}.chisel-text-label,.chisel-color-label,.chisel-font-label,.chisel-slider-label{color:var(--chisel-text-label);flex-shrink:0;font-size:13px;font-weight:500;line-height:17px;transform:translateY(-.5px)}.chisel-text-code,.chisel-text-value,.chisel-selector,.chisel-warning,.chisel-color-value-input,.chisel-slider-value-input{min-width:0;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--chisel-text-label);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:13px;font-weight:500;text-align:right}.chisel-context-row{background:transparent;padding-inline:0}.chisel-selector-row{min-height:var(--chisel-row-height)}.chisel-selector{max-width:168px;line-height:1.25}.chisel-warning{color:var(--chisel-warning-color);font-family:inherit}.chisel-textarea-control{height:auto;align-items:flex-start;padding-top:10px;padding-bottom:10px}.chisel-text-input{min-width:0;width:100%;flex:1;resize:vertical;border:none;outline:none;background:transparent;color:var(--chisel-text-label);text-align:right;font:inherit;font-size:13px;font-weight:500;line-height:1.35}.chisel-text-input::selection,.chisel-color-value-input::selection,.chisel-slider-value-input::selection{background:color-mix(in srgb,var(--chisel-ui-focus) 22%,transparent);color:var(--chisel-text-focus)}.chisel-text-input:disabled{color:var(--chisel-text-tertiary);cursor:not-allowed}.chisel-note-row{min-height:var(--chisel-row-height);display:flex;align-items:center;padding:8px 0;border-radius:var(--chisel-radius);background:transparent;color:var(--chisel-text-tertiary);font-size:12px;font-weight:400;line-height:1.5}.chisel-toolbar-add,.chisel-actions .chisel-button{background:transparent}.chisel-actions .chisel-button-primary{background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}.chisel-actions .chisel-button-primary:hover{background:var(--chisel-ui-action);opacity:.9}.chisel-button:disabled{color:var(--chisel-text-tertiary);cursor:not-allowed;transform:none}.chisel-font-control{position:relative;overflow:visible;cursor:default}.chisel-font-picker{min-width:0;flex:0 1 150px}.chisel-font-trigger{width:100%;min-width:0;height:28px;display:flex;align-items:center;justify-content:flex-end;padding:0;border:none;border-radius:0;background:transparent;color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:color var(--chisel-motion)}.chisel-font-trigger:hover,.chisel-font-trigger[aria-expanded=true]{color:var(--chisel-text-primary)}.chisel-font-dropdown{left:0;right:0;width:100%;max-height:262px;overflow:hidden}.chisel-font-list{max-height:252px;overflow-y:auto;padding-right:1px;-ms-overflow-style:none;scrollbar-width:none}.chisel-font-list::-webkit-scrollbar{display:none}.chisel-font-item{justify-content:flex-start;text-align:left;font-size:14px}.chisel-color-control{position:relative;overflow:visible;flex-wrap:wrap}.chisel-color-control[data-picker-open=true]{z-index:25;padding-bottom:0}.chisel-color-inputs{display:inline-flex;align-items:center;gap:10px;min-width:0;flex:0 0 auto;justify-content:flex-end}.chisel-root .chisel-color-swatch{position:relative;width:24px;height:24px;min-width:24px;min-height:24px;flex-shrink:0;padding:0;border:0;border-radius:4.5px;box-shadow:inset 0 0 0 1px var(--chisel-border);cursor:pointer;transition:transform var(--chisel-motion),box-shadow var(--chisel-motion)}.chisel-color-swatch:after{content:"";position:absolute;inset:-8px;border-radius:inherit}@media(pointer:coarse){.chisel-color-swatch:after{inset:-10px}}.chisel-color-control:hover .chisel-color-swatch{box-shadow:0 0 0 2px var(--chisel-surface-hover)}.chisel-color-swatch:active{transform:scale(.96)}.chisel-color-value-input{width:7.5ch;max-width:150px;padding:0;border:0;outline:none;background:transparent;font-variant-numeric:tabular-nums;text-align:right}.chisel-color-value-input[data-invalid=true]{color:var(--chisel-danger-color)}.chisel-color-popover{flex:0 0 calc(100% + 24px);width:calc(100% + 24px);display:flex;flex-direction:column;gap:8px;margin:4px -12px 0;padding:8px 12px 0;border-top:1px solid var(--chisel-surface-subtle);animation:chisel-pop-in var(--chisel-motion)}.chisel-color-tabs{min-height:40px;height:32px;display:flex;align-items:flex-start;gap:14px;border-bottom:1px solid var(--chisel-surface-subtle)}.chisel-color-tab,.chisel-color-close,.chisel-color-saved-row button{border:none;background:transparent;color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:600;cursor:pointer}.chisel-color-tab{height:32px;padding:0;border-bottom:2px solid transparent}.chisel-color-tab[data-active=true]{color:var(--chisel-text-primary);border-bottom-color:var(--chisel-text-primary)}.chisel-color-tab[aria-disabled=true]{color:var(--chisel-text-tertiary);cursor:default}.chisel-color-close{margin-left:auto;font-size:18px;line-height:1;color:var(--chisel-text-tertiary)}.chisel-color-close:hover,.chisel-color-saved-row button:hover{color:var(--chisel-text-primary)}.chisel-color-field{position:relative;height:132px;overflow:hidden;border-radius:9px;cursor:crosshair;touch-action:none;background-image:linear-gradient(90deg,#fff,#fff0),linear-gradient(0deg,#000,#0000)}.chisel-color-field-cursor{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:999px;box-shadow:0 0 0 1px #00000059;transform:translate(-50%,-50%);pointer-events:none}.chisel-color-hue{position:relative;height:12px;border-radius:999px;background:linear-gradient(90deg,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer;touch-action:none}.chisel-color-hue-cursor{position:absolute;top:50%;width:8px;height:16px;border:2px solid #fff;border-radius:999px;box-shadow:0 0 0 1px #00000047;transform:translate(-50%,-50%);pointer-events:none}.chisel-color-alpha{position:relative;height:12px;overflow:visible;border-radius:999px;background-color:#fff;background-image:linear-gradient(45deg,rgba(0,0,0,.12) 25%,transparent 25%),linear-gradient(-45deg,rgba(0,0,0,.12) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.12) 75%),linear-gradient(-45deg,transparent 75%,rgba(0,0,0,.12) 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0;cursor:pointer;touch-action:none}.chisel-color-alpha:after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg,transparent,var(--chisel-alpha-color));pointer-events:none}.chisel-color-alpha-fill{position:absolute;inset:0 auto 0 0;border-radius:inherit;background:color-mix(in srgb,var(--chisel-alpha-color),transparent 18%);pointer-events:none}.chisel-color-alpha-cursor{position:absolute;top:50%;z-index:2;width:16px;height:16px;border:2px solid #fff;border-radius:999px;box-shadow:0 0 0 1px #00000038;transform:translate(-50%,-50%);pointer-events:none}.chisel-color-gradient-preview{height:28px;border:1px solid var(--chisel-border);border-radius:var(--chisel-radius);box-shadow:inset 0 0 0 1px #ffffff47}.chisel-color-stop-buttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.chisel-color-stop-button{min-width:0;height:32px;display:flex;align-items:center;justify-content:center;gap:7px;padding:0 9px;border:none;border-radius:var(--chisel-radius);background:var(--chisel-surface);color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:600;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}.chisel-color-stop-button:hover{background:var(--chisel-surface-hover);color:var(--chisel-text-primary)}.chisel-color-stop-button[data-active=true]{background:var(--chisel-surface-active);color:var(--chisel-text-primary)}.chisel-color-stop-swatch{width:10.5px;height:10.5px;flex-shrink:0;overflow:hidden;border:1px solid var(--chisel-border-hover);border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff47}.chisel-color-format-row{display:grid;grid-template-columns:76px minmax(0,1fr);gap:6px}.chisel-color-format-select,.chisel-color-format-input{height:40px;min-width:0;border:none;border-radius:var(--chisel-radius);outline:none;background:var(--chisel-surface);color:var(--chisel-text-label);font:inherit;font-size:13px;font-weight:500}.chisel-color-format-select{padding:0 8px;cursor:pointer}.chisel-color-format-input{padding:0 9px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}.chisel-color-format-input[data-invalid=true]{color:var(--chisel-danger-color)}.chisel-color-extra-row,.chisel-color-upload-row{position:relative;min-height:32px;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 9px;border-radius:var(--chisel-radius);background:var(--chisel-surface);color:var(--chisel-text-label);font-size:13px;font-weight:500}.chisel-color-extra-row span,.chisel-color-upload-row span:first-child{flex-shrink:0}.chisel-color-extra-row input{min-width:0;flex:1;border:none;outline:none;background:transparent;color:var(--chisel-text-label);font:inherit;text-align:right}.chisel-color-upload-row{cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}.chisel-color-upload-row:hover{background:var(--chisel-surface-hover);color:var(--chisel-text-primary)}.chisel-color-upload-row input{position:absolute;inset:0;opacity:0;cursor:pointer}.chisel-color-upload-name{min-width:0;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap;color:var(--chisel-text-tertiary)}.chisel-slider{position:relative;height:var(--chisel-row-height);display:block;overflow:hidden;border-radius:var(--chisel-radius);background:var(--chisel-surface);cursor:pointer;user-select:none;touch-action:none}.chisel-slider[data-units-open=true]{z-index:20;overflow:visible}.chisel-slider input[type=range]{position:absolute;inset:0;z-index:3;width:100%;height:100%;opacity:0;pointer-events:none;cursor:pointer}.chisel-slider-label{position:absolute;top:50%;left:10px;pointer-events:none;transform:translateY(calc(-50% - .5px));z-index:2}.chisel-slider-value-input{position:absolute;inset:0;z-index:4;width:100%;max-width:none;height:100%;padding:0 10px 0 92px;border:1px solid transparent;border-radius:var(--chisel-radius);outline:none;background:transparent;font-variant-numeric:tabular-nums;cursor:pointer}.chisel-root .chisel-slider-value-input:focus{cursor:text}.chisel-slider-value-input[data-invalid=true]{border-color:#aa303061;background:#aa303014;color:var(--chisel-danger-color)}.chisel-slider-hashmarks{position:absolute;inset:0;pointer-events:none}.chisel-slider-hashmark{position:absolute;top:50%;width:1px;height:8px;border-radius:999px;background:transparent;transform:translate(-50%,-50%);transition:background .2s}.chisel-slider:hover .chisel-slider-hashmark{background:var(--chisel-surface-hover)}.chisel-slider-fill{position:absolute;top:0;bottom:0;left:0;background:var(--chisel-surface-active);pointer-events:none;transition:background .15s}.chisel-slider-handle{position:absolute;top:50%;z-index:2;width:3px;height:20px;border-radius:999px;background:var(--chisel-text-primary);pointer-events:none;opacity:0;transform:translateY(-50%) scaleX(var(--chisel-handle-scale, 1));transition:opacity .15s,transform .15s}.chisel-slider:hover .chisel-slider-handle{opacity:var(--chisel-handle-opacity, 1)}.chisel-unit-menu{position:absolute;top:calc(100% + 4px);right:6px;z-index:30;display:grid;grid-template-columns:repeat(4,minmax(40px,1fr));gap:2px;width:186px;padding:4px;border:1px solid var(--chisel-border);border-radius:10px;background:var(--chisel-glass-bg);box-shadow:0 6px 18px #0000001a;animation:chisel-pop-in var(--chisel-motion);cursor:default}.chisel-unit-option{min-width:0;height:26px;border:none;border-radius:7px;background:transparent;color:var(--chisel-text-label);font:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:11px;font-weight:600;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}.chisel-unit-option:hover{background:var(--chisel-surface-hover);color:var(--chisel-text-primary)}.chisel-unit-option[data-active=true]{background:var(--chisel-surface-active);color:var(--chisel-text-primary)}.chisel-actions{display:flex;flex-direction:column;gap:6px;padding-bottom:10px}.chisel-button{width:100%;min-height:var(--chisel-row-height);border:none;border-radius:var(--chisel-radius);background:var(--chisel-surface);color:var(--chisel-text-secondary);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:background var(--chisel-motion),color var(--chisel-motion),transform var(--chisel-motion)}@keyframes chisel-pop-in{0%{opacity:0;transform:translateY(-3px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.chisel-root,.chisel-root *{animation-duration:.01ms!important;transition-duration:.01ms!important}}@media(max-width:760px){.chisel-root{--chisel-row-height: 44px}.chisel-panel{top:auto;left:max(10px,env(safe-area-inset-left));right:max(10px,env(safe-area-inset-right));bottom:max(10px,env(safe-area-inset-bottom));width:auto;max-height:58dvh;touch-action:pan-y}.chisel-panel-inner{width:100%;max-height:58dvh}.chisel-color-tab,.chisel-color-close,.chisel-color-stop-button,.chisel-color-format-select,.chisel-color-format-input,.chisel-color-extra-row,.chisel-color-upload-row,.chisel-unit-option{min-width:44px;min-height:44px}.chisel-color-tabs{min-height:40px;height:44px}.chisel-color-hue,.chisel-color-alpha{height:44px}.chisel-unit-menu{grid-template-columns:repeat(4,minmax(44px,1fr));width:206px}}@media(forced-colors:active){.chisel-panel-inner,.chisel-preset-dropdown,.chisel-color-popover{forced-color-adjust:auto;border:1px solid CanvasText;background:Canvas}.chisel-box{border-color:Highlight}}
|
|
3
3
|
`})}function Wt(e,a){if(a.has(e))return;let t=getComputedStyle(e),o={};for(let r of Sa)o[r]=t[r];a.set(e,{text:e.textContent??"",styles:o})}function pa(e){return{id:`version-${e}`,name:`Version ${e}`,elements:{}}}function Xt(e){return Object.fromEntries(Object.entries(e).map(([a,t])=>[a,{...t,styles:{...t.styles}}]))}function Kt(){return{pathname:window.location.pathname,search:window.location.search}}function $t(e){Zt(),ea+=1;let a=()=>{ot(),e()};return window.addEventListener(La,a),window.addEventListener("popstate",a),()=>{window.removeEventListener(La,a),window.removeEventListener("popstate",a),ea-=1,ea<=0&&(ea=0,la?.(),la=void 0)}}function Zt(){if(la)return;let e=window.history.pushState,a=window.history.replaceState,t=()=>{ot(),window.setTimeout(()=>window.dispatchEvent(new Event(La)),0)},o=function(...i){let c=e.apply(this,i);return t(),c},r=function(...i){let c=a.apply(this,i);return t(),c};window.history.pushState=o,window.history.replaceState=r,la=()=>{window.history.pushState===o&&(window.history.pushState=e),window.history.replaceState===r&&(window.history.replaceState=a)}}function ot(){let e=++Wa;Ke=!0,window.setTimeout(()=>{Wa===e&&(Ke=!1)},0)}function jt(e=rt(window.location.pathname,window.location.search)){return`vse:versions:${e}`}function Jt(e,a){return`vse:versions:${e}${a}`}function rt(e,a){let t=new URLSearchParams(a);t.delete("editor");let o=Array.from(t.entries()).sort(([n,i],[c,f])=>n===c?i.localeCompare(f):n.localeCompare(c)),r=new URLSearchParams(o).toString();return r?`${e}?${r}`:e}function Qt(e,a=e){try{let t=window.localStorage.getItem(e),o=t??(a===e?null:window.localStorage.getItem(a)),r=Va(o);return r.envelope&&xa.set(e,r.envelope),t===null&&o!==null?{...r,migrated:!r.warning}:r}catch{return{envelope:xa.get(e),migrated:!1,warning:"Browser storage is unavailable. Edits will be kept for this session."}}}function $a(e,a,t){let o=ca(a,t);xa.set(e,o);try{window.localStorage.setItem(e,JSON.stringify(o));return}catch{return"Browser storage is unavailable or full. Edits will be kept for this session."}}function de(e){return De(e)??$e(e)}function be(e,a,t){let o=t.get(a);if(o?.element===e||o?.element.isConnected)return;let r={};for(let n of Sa)r[n]=e.style[n]??"";t.set(a,{element:e,selector:$e(e),sourceHint:De(e),text:e.textContent??"",styles:r})}function ce(e){let a=(We.get(e)??0)+1;We.set(e,a),window.setTimeout(()=>{We.get(e)===a&&We.delete(e)},0)}function aa(e,a,t,o,r=!0){if(r)for(let[n,i]of t){let c=i.element.isConnected?i.element:null;if(!c)continue;let f=a.map(S=>S.elements[n]).filter(Boolean);if(!f.length)continue;ce(c),f.some(S=>typeof S.text=="string")&&c.textContent!==i.text&&(c.textContent=i.text);let I=new Set(f.flatMap(S=>Object.keys(S.styles)));f.some(S=>S.asset)&&I.add("backgroundImage");for(let S of I){let v=i.styles[S]??"";c.style[S]!==v&&(c.style[S]=v)}}for(let[n,i]of Object.entries(e.elements)){let c=lt(i);if(c){be(c,n,t),ce(c),typeof i.text=="string"&&c.textContent!==i.text&&(c.textContent=i.text);for(let[f,I]of Object.entries(i.styles))c.style[f]!==I&&(c.style[f]=I);if(i.asset){let f=o.get(ke(e.id,n)),I=f?Fe(f):"";c.style.backgroundImage!==I&&(c.style.backgroundImage=I)}}}}function _t(e,a,t){let o=e.get(a);e.set(a,t),o&&o!==t&&!Array.from(e.values()).includes(o)&&URL.revokeObjectURL(o)}function ma(e,a){let t=e.get(a);e.delete(a),t&&!Array.from(e.values()).includes(t)&&URL.revokeObjectURL(t)}function ha(e){for(let a of new Set(e.values()))URL.revokeObjectURL(a);e.clear()}function ke(e,a){return`${e}:${a}`}function Za(e,a,t){for(let[o,r]of Object.entries(e.elements)){let n=a.get(o);if(!n)continue;let i=n.element.isConnected?n.element:null;if(i){ce(i),typeof r.text=="string"&&i.textContent===r.text&&(i.textContent=n.text);for(let[c,f]of Object.entries(r.styles)){if(c==="backgroundImage"&&r.asset)continue;let I=n.styles[c]??"";Yt(c,i.style[c],f)&&(i.style[c]=I)}if(r.asset){let c=t.get(ke(e.id,o));c&&i.style.backgroundImage===Fe(c)&&(i.style.backgroundImage=n.styles.backgroundImage??"")}}}}function Yt(e,a,t){if(a===t)return!0;let o=document.createElement("div").style;return o[e]=t,o[e]===a}function lt(e){let a=e.sourceHint?wa(e.sourceHint):void 0;return ja(a)??ja(e.selector)}function ja(e){if(e)try{let a=document.querySelector(e);return a instanceof HTMLElement?a:void 0}catch{return}}function Ja(e,a){return e.includes(a)?e.filter(t=>t!==a):[...e,a]}function eo(e,a){let t=getComputedStyle(e),o=[],r=e.textContent??"";r!==a.text&&o.push({property:"textContent",before:a.text,after:r});for(let n of Sa){let i=a.styles[n],f=(e.style[n]??"")||t[n];sa(i)!==sa(f)&&o.push({property:n,before:i,after:f})}return o}function ao(e){if(!e)return[];let a=[];e.text!==void 0&&a.push({property:"textContent",before:null,after:e.text});for(let[t,o]of Object.entries(e.styles))a.push({property:t,before:null,after:o??""});return e.asset&&a.push({property:"localAsset",before:null,after:e.asset.fileName}),a}function to({projectName:e,element:a,snapshot:t,rect:o,selector:r,sourceHint:n,changes:i}){let c={route:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},element:{tagName:a.tagName.toLowerCase(),selector:r,ancestry:ut(a),boundingRect:o,textBefore:t.text,textAfter:a.textContent??"",sourceHint:n},changes:i},f=!n&&!r.includes("[data-chisel-id")&&!r.includes("#");return[`You are editing ${e}. Update the source files for this Next.js app to match the visual edit intent below.`,"","Do not ship a broad global CSS override. Find the component, JSX, CSS module, Tailwind classes, or style object that owns the selected element and make the smallest source-level change.",f?"Selector confidence is low. Use the route, visible text, DOM ancestry, and nearby structure to find the matching source component before editing.":"A source hint is available. Prefer it when locating the component.","","Edit intent:","```json",JSON.stringify(c,null,2),"```","","Acceptance criteria:","- The selected element visually matches the requested text/style changes on the same route.","- Existing responsive behavior is preserved.","- No editor-only attributes or temporary inline preview styles are added unless they already belong to the app source."].join(`
|
|
4
4
|
`)}function oo({projectName:e,version:a,baselines:t}){let o=Object.entries(a.elements).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>{let i=t.get(r),c=lt(n);return{selector:n.selector,sourceHint:n.sourceHint,tagName:c?.tagName.toLowerCase(),ancestry:c?ut(c):void 0,textBefore:i?.text,textAfter:n.text,asset:n.asset,styleChanges:Object.fromEntries(Object.entries(n.styles).map(([f,I])=>[f,{before:i?.styles[f]??null,after:I}]))}});return[`You are editing ${e}. Update the source files for this Next.js app to match all page-level visual edit intents below.`,"","Do not ship broad global CSS overrides. Find the owning components, JSX, CSS modules, Tailwind classes, or style objects and make the smallest source-level changes.","","Edit intent:","```json",JSON.stringify({route:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},elements:o},null,2),"```","","Acceptance criteria:","- All changed elements visually match the requested page edits on the same route.","- Existing responsive behavior is preserved.","- No editor-only attributes or temporary inline preview styles are added unless they already belong to the app source."].join(`
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
function
|
|
2
|
-
`).map(
|
|
3
|
-
`)}function
|
|
1
|
+
function h(n){return{version:1,content:n.split(`
|
|
2
|
+
`).map(t=>({type:"paragraph",children:[{text:t}]}))}}function m(n){return n.content.map(t=>t.children.map(e=>"type"in e?e.text||e.url:e.text).join("")).join(`
|
|
3
|
+
`)}function u(n){let t=n.content.slice();for(;t.length;){let e=t[t.length-1],o=e.children.slice();for(;o.length;){let r=o[o.length-1],a="type"in r?r.text||r.url:r.text,i=a.trimEnd();if(i)return o[o.length-1]=i===a?r:{...r,text:i},t[t.length-1]={...e,children:o},{...n,content:t};o.pop()}t.pop()}return h("")}var x=5242880,y=20971520,s=["image/jpeg","image/png","image/gif","image/webp","image/avif","image/bmp"],p=["video/mp4","video/webm","video/quicktime"],b=[...s,...p].join(",");function f(n){let t=s.includes(n.type);return!t&&!p.includes(n.type)?"Choose a JPG, PNG, GIF, WebP, AVIF, BMP, MP4, WebM, or MOV file.":!Number.isSafeInteger(n.size)||n.size<=0?"This file is empty or invalid.":n.size>(t?5242880:20971520)?`${t?"Images must be 5 MB":"Videos must be 20 MB"} or smaller.`:null}function d(n){try{let t=new URL(n),e=/^\d+(?:\.\d+){3}$/.test(t.hostname)&&/^(0\.|10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(t.hostname);if(t.protocol!=="https:"||t.username||t.password||!t.hostname.includes(".")||e||/\.(localhost|local|internal)$/.test(t.hostname)||t.hostname.includes(":"))return null;let o=t.pathname.replace(/\/+$/,"");return t.pathname=o.endsWith("/chisel")?o:`${o}/chisel`,t.search="",t.hash="",t.toString()}catch{return null}}function c(n,t){let e=new URL(n);e.search="",e.hash="",e.searchParams.set("mode","comment"),e.searchParams.set("path",t.path),e.searchParams.set("thread",t.id),e.searchParams.set("breakpoint",t.breakpoint??"desktop");let o=t.context?.width??{desktop:1440,tablet:768,mobile:390}[t.breakpoint??"desktop"];return e.searchParams.set("width",String(o)),e.toString()}function l(n,t){return["# Website feedback for Codex","Apply the requested changes in the source code. Preserve unrelated behavior. Verify each affected page and viewport.",...n.map((e,o)=>[`## ${o+1}. ${e.path} \xB7 ${e.breakpoint??"desktop"}`,`Thread: ${c(t,e)}`,`Status: ${e.status??(e.resolved?"resolved":"open")}`,e.context?`Viewport: ${e.context.width} \xD7 ${e.context.height}px
|
|
4
|
+
Captured: ${e.context.capturedAt}${e.context.deployment?`
|
|
5
|
+
Deployment: ${e.context.deployment}`:""}`:"",e.selector?`Element: ${e.selector}`:"Page/area comment",e.area?`Area: ${JSON.stringify(e.area)}`:"",`${e.author}: ${e.text}`,...(e.replies??[]).map(r=>typeof r=="string"?r:`${r.author}: ${r.text}`),...(e.attachments??[]).map(r=>r.previewUrl?`![${r.name.replace(/[\[\]]/g,"")}](${r.previewUrl})`:`Attachment: ${r.name} (open the thread to view)`),...(e.changes??[]).map(r=>`${r.property}: ${JSON.stringify(r.before)} \u2192 ${JSON.stringify(r.after)}`)].filter(Boolean).join(`
|
|
6
|
+
|
|
7
|
+
`))].join(`
|
|
8
|
+
|
|
9
|
+
`)}export{m as bodyText,h as commentBody,c as commentURL,l as feedbackMarkdown,x as imageLimit,s as imageTypes,b as mediaAccept,f as mediaFileError,d as publicReviewURL,u as trimCommentBody,y as videoLimit,p as videoTypes};
|
package/dist/review-entry.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { useReadQueue } from "./review/read-queue";
|
|
|
6
6
|
export type { ReviewComment, ReviewReply, ReviewAttachment } from "./review/types";
|
|
7
7
|
export { useReviewAttachments } from "./review/attachments";
|
|
8
8
|
export type { Upload, AttachmentTransport } from "./review/attachments";
|
|
9
|
+
export { uploadSnapshot } from "./review/snapshot-upload";
|