@1agh/maude 1.0.5 → 1.0.6
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.
|
@@ -5650,7 +5650,7 @@ ${B.block}`:q,F=[],D=new Map;for await(let _ of X.prompt(N,J(),K,Q?.(),Y?.(),Z?.
|
|
|
5650
5650
|
|
|
5651
5651
|
> Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
|
|
5652
5652
|
> Local report bundle: \`${s?.dir??".design/_reports/"}\` (attach its files here)`),X0=`${bz0}?title=${c}&body=${Z0}&labels=report`;if(W9())try{await cU(X0)}catch{window.open(X0,"_blank","noopener")}else window.open(X0,"_blank","noopener");I({fallbackDir:s?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let m=G.trim().length>0;return z("div",{className:"st-scrim",onClick:x,"data-testid":"report-bug-dialog",children:M("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[M("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:x,"aria-label":"Close",children:"×"})]}),M("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&M(G0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(p)=>Z(p.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:x,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!m,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&M(G0,{children:[M("div",{className:"rb-section",children:[M("div",{className:"rb-section-hd",children:[M("span",{children:["Screenshots (",U.length,")"]}),M("span",{className:"rb-hd-actions",children:[U.length<Qw&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:v,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>O((p)=>!p),children:w?"Done redacting":"Redact…"})]})]}),M("p",{className:"rb-hint",children:["Maude captures its own window and the active artboard for you. The window shot is a fresh render, so anything mid-flight — an open menu, a stuck spinner — won't be in it: grab that yourself (",yz0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),_&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!_?M("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",Qw,"."]}):M(G0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((p,f)=>z(vz0,{shot:p,redacting:w,onRects:(n)=>q((s)=>s.map((c,Z0)=>Z0===f?{...c,rects:n}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),q((n)=>n.filter((s,c)=>c!==f))}},p.url))})]})]}),M("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),M("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",W9()?"desktop app":"browser"]})]}),Q&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>D({...F,activeCanvas:p.target.checked})}),M("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>D({...F,projectName:p.target.checked})}),M("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?M("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>D({...F,logTail:p.target.checked})}),M("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
|
|
5653
|
-
`).length," lines, paths & secrets scrubbed) —"," ",M("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),M("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),M("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&M(G0,{children:[P?.issueUrl?M("p",{children:["Thank you — your report is filed as"," ",M("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())cU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):M("p",{children:["The bundle is saved locally",P?.fallbackDir?M(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Done"})})]}),Y==="fallback"&&M(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Save locally & open GitHub"})]})]})]})]})})}var WJ=v8(i8(),1);function Ex(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function Px(X,J){let Q=Ex(X),Y=Ex(J);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function Rx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Px(Q.version,J)))}function Tx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Px(Y.version,Q))Q=Y.version}return Q}var Yw="mdcc-whatsnew-seen",Ww="mdcc-whatsnew-toast-dismissed";function hz0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function xz0(X){try{let J=localStorage.getItem(Yw);if(J)return J;localStorage.setItem(Yw,X)}catch{}return X}function gz0(){try{return localStorage.getItem(Ww)}catch{return null}}function Ix(X){let[J,Q]=WJ.useState([]),[Y,W]=WJ.useState(X),[G,Z]=WJ.useState(()=>xz0(X)),[H,K]=WJ.useState(()=>gz0()),[U,q]=WJ.useState(!1);WJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=Rx(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=WJ.useCallback(()=>{let O=Tx(J,Y);Z(O),K(Y);try{localStorage.setItem(Yw,O),localStorage.setItem(Ww,Y)}catch{}},[J,Y]),_=WJ.useCallback(()=>{K(Y);try{localStorage.setItem(Ww,Y)}catch{}},[Y]),R=WJ.useCallback(()=>q(!0),[]),w=WJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function kx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return M("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),M("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),M("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Cx({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(WJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:M("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>M("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[M("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),hz0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var W7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),me="mdcc-usage-tour-seen",ue="mdcc-collab-tour-seen",n8="__system__",_00="mdcc-theme",pe="mdcc-show-hidden",le="mdcc-sections-expanded",de="maude-cp-mode",ce="mdcc-sidebar-open",ie="mdcc-minimap-visible",oe="mdcc-zoomctl-visible",ne="mdcc-annotations-visible";var nq0=30000;function rq0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var rR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],RK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},re="mdcc-panel-sides",ae="mdcc-layers-mode";function se({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return M("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(rR.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,aq0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function aR(X){for(let[J,Q]of aq0)if(J.test(X))return Q;return null}function _F(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var sR="1.0.5";function te(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){$7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function sq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(_00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function aZ(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function dR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function tq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function kK(X){return X.split("/").pop()}function m8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(m8._t),m8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var ee="maude-mode-hint-seen";function eq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(ee)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select & inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(ee,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function X20(X){return X.replace(GQ,"")}function J20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=X20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function Q20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function A00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=A00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function MF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Y20(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(X).toLocaleDateString()}function w00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function AF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var W20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:M(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":M(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:M(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:M(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:M(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:M(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:M(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:M(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:M(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:M(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:M(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:M(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:M(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:M(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:M(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:M(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:M(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:M(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":M(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":M(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":M(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":M(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":M(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":M(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:M(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:M(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:M(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:M(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:M(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:M(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:M(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:M(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function G20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:M("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[M("div",{className:"st-pal-search",children:[z(w9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return M(G0,{children:[N,M("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(w9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function w9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:W20[X]})}function Z20(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function X00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function J00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function Q00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:M("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var cR=[{id:"png",label:"PNG",sub:"raster · 2×",icon:"image",format:"png",options:{scale:2}},{id:"pdf",label:"PDF",sub:"vector · print",icon:"file",format:"pdf"},{id:"svg",label:"SVG",sub:"per artboard",icon:"vector",format:"svg"},{id:"html",label:"HTML",sub:"self-contained",icon:"code",format:"html"},{id:"pptx",label:"PPTX",sub:"slides",icon:"presentation",format:"pptx"},{id:"mp4",label:"MP4",sub:"video · H.264",icon:"presentation",format:"mp4",temporal:!0},{id:"gif",label:"GIF",sub:"animated",icon:"image",format:"gif",temporal:!0},{id:"canva",label:"Canva",sub:"handoff bundle",icon:"external",format:"canva"},{id:"zip",label:"ZIP",sub:"project bundle",icon:"archive",format:"zip"},{id:"shadcn",label:"AI handoff",sub:"production drop",icon:"sparkle",handoff:!0}],iR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},H20={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},z20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],S3=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],K20="2x",Y00=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],U20="auto",V20={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",m4v:"video/mp4",ogg:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",oga:"audio/ogg",opus:"audio/opus"};function q20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return V20[J]||"application/octet-stream"}function B20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let h=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!h)return;let p=m.ok?m.assets:[];H(p),_((f)=>{let n={...f};for(let s of p)n[s.path]=s.kind;return n})}).catch(()=>h&&H([])),()=>{h=!1}},[]),u.useEffect(()=>{let h=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[Q]);let O=Array.from(N).some((h)=>(D[h]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(h)=>{F((m)=>{let p=new Set(m);if(p.has(h))p.delete(h);else p.add(h);return p})},$=async(h)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":h.type||"application/octet-stream"},body:h}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(h)=>{if(!h)return;U(!0),B(null);let m=await $(h);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(h)=>{if(typeof h==="string"&&h.startsWith("video/"))return"video";if(typeof h==="string"&&h.startsWith("audio/"))return"audio";return"image"},v=async(h)=>{if(!h.length)return;U(!0),B(null);let m=await Promise.all(h.map((n)=>$(n).then((s)=>({...s,file:n}))));U(!1);let p=m.filter((n)=>n.ok),f=m.length-p.length;if(f>0)B(`${f} of ${m.length} uploads failed`);if(p.length)_((n)=>{let s={...n};for(let c of p)s[c.path]=y(c.file.type);return s}),F((n)=>{let s=new Set(n);for(let c of p)s.add(c.path);return s})},x=async()=>{U(!0),B(null);try{if(Y){let p=(await fv()||[]).map((f)=>new File([new Uint8Array(f.bytes)],f.name,{type:q20(f.name)}));if(U(!1),p.length)await v(p);return}let h=await NZ();if(h?.bytes){await C(new Blob([new Uint8Array(h.bytes)]));return}}catch(h){B(h?.message||"open failed")}U(!1)},d=()=>{if(W9()){x();return}let h=document.createElement("input");if(h.type="file",h.accept="image/*,video/*",Y)h.multiple=!0;h.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(h);let m=()=>{if(h.isConnected)h.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),h.addEventListener("change",()=>{let p=h.files?Array.from(h.files):[];if(m(),!p.length)return;if(Y)v(p);else C(p[0])}),h.click()},o=(h)=>`/${X}/${h}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)Q()},children:M("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[M("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(w9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[M("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((h)=>{let m=Y&&N.has(h.path);return M("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${h.name} · ${Math.max(1,Math.round(h.size/1024))} KB`,onClick:()=>Y?k(h.path):J(h.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(w9,{name:"check",size:12}):null}),h.kind==="video"?z("video",{className:"st-ap-thumb",src:o(h.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(h.path),alt:h.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:h.name})]},h.path)})})]}),Y&&N.size>0&&M("div",{className:"st-dialog-ft st-ap-confirm",children:[M("span",{className:"st-ap-count",children:[N.size," selected"]}),M("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function N20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onClose:K}){let U=u.useCallback((O0)=>H==="none"&&!O0.handoff&&O0.format!=="zip"||H!=="local"&&O0.format==="canva",[H]),[q,B]=u.useState(X==="handoff"?"shadcn":H==="none"?"zip":"png"),[N,F]=u.useState(J&&iR[J]?J:"artboard"),[D,_]=u.useState(2),[R,w]=u.useState(K20),[O,P]=u.useState(!0),[I,k]=u.useState(!1),[$,C]=u.useState(!1),[y,v]=u.useState(!1),[x,d]=u.useState(U20),[o,h]=u.useState(!0),[m,p]=u.useState(!1),[f,n]=u.useState(null),[s,c]=u.useState([]),Z0=cR.find((O0)=>O0.id===q)||cR[0],X0=Z0.handoff?[]:H20[Z0.format]||["artboard"],H0=900,t=3600,N0=XK(W,SA(W,{artboardId:G})),U0=N0?.durationInFrames||0,l0=N0?.fps||30,J8=Z0.temporal&&U0>900,o0=Z0.temporal&&U0>3600;u.useEffect(()=>{if(X0.length&&!X0.includes(N))F(X0[0])},[X0,N]);let L8=u.useCallback(()=>{fetch("/_api/export-history").then((O0)=>O0.json()).then((O0)=>c(Array.isArray(O0?.history)?O0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{L8()},[L8]),u.useEffect(()=>{function O0(Z8){if(Z8.key==="Escape")Z8.preventDefault(),K()}return window.addEventListener("keydown",O0),()=>window.removeEventListener("keydown",O0)},[K]);async function w0(){if(Z0.handoff){let H8=`/design:handoff ${Q&&Q!==n8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(H8)}catch{}n({ok:!0,msg:`Copied: ${H8} — run it in Claude Code.`});return}if(U(Z0)){n({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}p(!0),n(null);let O0=Z0.temporal?{scale:D}:{};if(Z0.format==="png"){let Z8=S3.find((H8)=>H8.id===R)||S3[1];if(Z8.kind==="dpi")O0.dpi=Z8.value;else O0.scale=Z8.value}if(Z0.format==="mp4"||Z0.format==="webm")O0.audio=o;if(o0)O0.maxFrames=U0;if(Z0.format==="pdf"){O0.pdfPrint={includeBleed:O,marks:{crop:$,registration:y}};let Z8=Y00.find((H8)=>H8.id===x)?.value;if(Z8!==void 0)O0.dpi=Z8}if(G)O0.artboardId=G;if(Z?.selector)O0.selection=Z;try{let Z8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:Z0.format,scope:N,options:O0})});if(!Z8.ok){n({ok:!1,msg:await Z8.text()||`Export failed (${Z8.status})`}),p(!1);return}K()}catch(Z8){n({ok:!1,msg:Z8&&Z8.message?Z8.message:String(Z8)}),p(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(O0)=>{if(O0.target===O0.currentTarget)K()},children:M("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[M("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:K,children:z(w9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==n8?`Format · ${pW(kK(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:cR.filter((O0)=>!O0.temporal||Y).map((O0)=>M("button",{type:"button",className:"st-fmt"+(O0.id===q?" is-on":""),disabled:U(O0),title:U(O0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{B(O0.id),n(null)},children:[z(w9,{name:O0.icon,size:16}),z("span",{className:"st-fmt-name",children:O0.label}),z("span",{className:"st-fmt-sub",children:O0.sub})]},O0.id))}),H==="none"&&M("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["Rendered exports (PNG, PDF, video…) need the render service, which this workspace doesn't have configured. ZIP and AI handoff still work here — for everything else use the desktop app, or ask your admin to add the",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!Z0.handoff&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:N,onChange:(O0)=>F(O0.target.value),children:X0.map((O0)=>z("option",{value:O0,children:iR[O0]},O0))})]}),!Z0.handoff&&Z0.format==="png"&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:R,onChange:(O0)=>w(O0.target.value),children:S3.map((O0)=>z("option",{value:O0.id,children:O0.label},O0.id))})]}),!Z0.handoff&&Z0.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let O0=S3.find((H8)=>H8.id===R)||S3[1],Z8=O0.kind==="dpi"?O0.value/96:O0.value;return`${O0.label} ≈ ${Math.round(1440*Z8)}×${Math.round(900*Z8)} for a 1440×900 artboard.`})()}),!Z0.handoff&&Z0.temporal&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:D,onChange:(O0)=>_(Number(O0.target.value)),children:z20.map((O0)=>z("option",{value:O0.value,children:O0.label},O0.value))})]}),!Z0.handoff&&Z0.temporal&&M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[D,"× the artboard's native resolution (e.g. 960×540 → ",960*D,"×",540*D,")."]}),J8&&M("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",U0," frames (≈",Math.round(U0/l0),"s).",o0?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!Z0.handoff&&Z0.format==="pdf"&&M(G0,{children:[M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:x,onChange:(O0)=>d(O0.target.value),children:Y00.map((O0)=>z("option",{value:O0.id,children:O0.label},O0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:M("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:O,onChange:(O0)=>P(O0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:M("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>k((O0)=>!O0),"aria-expanded":I,children:[I?"▾":"▸"," Marks"]})}),I&&M("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:$,onChange:(O0)=>C(O0.target.checked)}),"Crop marks"]}),M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:y,onChange:(O0)=>v(O0.target.checked)}),"Registration marks"]})]}),M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",N==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!Z0.handoff&&(Z0.format==="mp4"||Z0.format==="webm")&&z("div",{className:"st-dialog-row",children:M("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:o,onChange:(O0)=>h(O0.target.checked)}),"Export with audio"]})}),Z0.handoff&&M("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),f&&z("div",{className:"callout "+(f.ok?"callout--success":"callout--error"),style:{fontSize:12},children:f.msg}),s.length>0&&M("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((O0,Z8)=>M("div",{className:"st-export-recent-row",children:[M("span",{children:[String(O0.format||"").toUpperCase()," ·"," ",iR[O0.scope]||O0.scope]}),z("span",{className:"st-mono",children:O0.filename})]},Z8))]})]}),M("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:K,children:"Cancel"}),M("button",{type:"button",className:"btn btn--primary",disabled:m,onClick:w0,children:[z(w9,{name:"download",size:14}),Z0.handoff?"Copy handoff command":m?"Exporting…":`Export ${Z0.label}`]})]})]})})}var PF=12,RF=16;function F20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=M("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${_F(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:PF+J*RF+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return M(G0,{children:[Z?M("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_F(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):D,H&&Y]})}function L20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return M(G0,{children:[M("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:PF+Q*RF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(w9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),M("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function wF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?aR(X.name):null,w=!_&&!R,O=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",v=X.path.split("/").slice(0,-1).join("/"),x=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=M("button",{type:"button",role:"treeitem","data-testid":x,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:PF+H*RF+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return M("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${_F(X.path)}`,title:`Move ${O}…`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(o)=>{o.stopPropagation(),G(X.path,O)},children:z(AF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function D20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[O,P]=u.useState(!1),I=B||O,k=X.path===W;if(!(w&&q))return z(wF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},v=D?.draggedPath===X.path,x=D?.busyPath===X.path,d=C&&typeof _<"u",o=X.path.split("/").slice(0,-1).join("/"),h=M("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":x||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(v?" is-dragging":"")+(x?" is-busy":""),style:{paddingLeft:PF+Q*RF+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(w9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return M(G0,{children:[d?M("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_F(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,I&&J.map((m)=>z(wF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function E00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:O}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>J20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],o=[];for(let h of $){let m=aR(h.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:o).push(h)}return{mediaOrphans:d,metaOrphans:o}},[$]),v=!!(U&&U.trim()),x=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let o of q)d.set(o.folder,o);return d},[q,Z]);return M(G0,{children:[k.map((d)=>{let o=v&&d.sidecars.some((h)=>{let m=U.toLowerCase();return h.name.toLowerCase().includes(m)||h.path.toLowerCase().includes(m)});return z(D20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:MF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:o,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(wF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:MF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(wF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:MF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let o=x?.get(d),h=R?`${R}/${d}`:d,m=z(E00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:h,drag:w,menu:O});if(o&&N)return z(L20,{name:d,dsName:o.name,depth:Z,defaultOpen:!0,active:J===n8&&o.name===B,onOpenSystem:N,children:m},d);return z(F20,{name:d,depth:Z,defaultOpen:!0,dirPath:h,drag:w,menu:O,children:m},d)})]})}var LF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function M20(X){if(X.kind==="project")return LF.project;if(X.kind==="runtime")return LF.runtime;if(X.label==="Design system")return LF.ds;if(X.label==="UI kit")return LF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function O20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:O,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:v,gitBranch:x,remoteSync:d,onGetLatest:o,canvasKinds:h,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:f,syncStatus:n,onLinkedHub:s,savingIsManaged:c=!1}){let Z0=u.useMemo(()=>{if(!q)return Q;return Q.map((c0)=>({...c0,tree:A00(c0.tree,q),filtered:!!q}))},[Q,q]),X0=BS(m),H0=VS(),t=u.useMemo(()=>{let c0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;c0.push({path:j0.fullPath,label:I0});for(let P8 of j0.dirs||[])c0.push({path:P8,label:P8.replace(/^\.[^/]+\//,"")})}return c0},[Q]),N0=H0.state?.extra,U0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>H0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{H0.close();let c0=window.prompt("New folder name:");if(c0?.trim())p(N0.dirPath,c0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{H0.close(),f(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],l0=N0?.kind==="file"?t.filter((c0)=>c0.path!==N0.dir):[],[J8,o0]=u.useState(!1),[L8,w0]=u.useState("board"),[O0,Z8]=u.useState(""),[H8,r8]=u.useState(""),[A8,K8]=u.useState(!1),T8=u.useMemo(()=>Q.find((c0)=>c0.kind==="canvas"&&c0.label!=="Design system")?.fullPath,[Q]),s8=u.useCallback(async()=>{let c0=O0.trim();if(!c0||A8)return;if(K8(!0),r8(""),L8==="folder"){if(!T8){K8(!1),r8("no canvas group to create a folder in");return}let I0=await p(T8,c0);if(K8(!1),I0?.ok)o0(!1),Z8("");else r8(I0?.error||"could not create folder");return}let j0=await R(c0);if(K8(!1),j0?.ok)o0(!1),Z8("");else r8(j0?.error||"could not create board")},[O0,A8,R,p,L8,T8]),E9=u.useMemo(()=>{let c0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))c0++;return c0},[Q]),u0=u.useMemo(()=>{let c0=0;for(let j0 of Z0)for(let I0 of j0.paths||[])if(GQ.test(I0))c0++;return c0},[Z0]);return M("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[M("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),M("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":J8&&L8==="board",onClick:()=>{r8(""),w0("board"),o0((c0)=>L8==="board"?!c0:!0)},children:z(w9,{name:"plus",size:15})}),!X&&T8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":J8&&L8==="folder",onClick:()=>{r8(""),w0("folder"),o0((c0)=>L8==="folder"?!c0:!0)},children:z(w9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>O(),children:z(w9,{name:"reload",size:15})}),M("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),u0," / ",E9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(w9,{name:"panel-left",size:15})})]})]}),J8?M("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:L8==="folder"?"folder name…":"brief board name…",value:O0,maxLength:60,disabled:A8,"aria-label":L8==="folder"?"New folder name":"New brief board name",onChange:(c0)=>Z8(c0.target.value),onKeyDown:(c0)=>{if(c0.key==="Enter")c0.preventDefault(),s8();else if(c0.key==="Escape")c0.preventDefault(),o0(!1),Z8(""),r8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A8||!O0.trim(),"data-tip":"Create · Enter","aria-label":L8==="folder"?"Create folder":"Create brief board",onClick:s8,children:A8?"…":"↵"})]}):null,H8?z("div",{className:"st-newboard-err",role:"alert",children:H8}):null,z("div",{className:"st-search",children:M("div",{className:"st-search-box",children:[z(w9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(c0)=>B(c0.target.value),onKeyDown:(c0)=>{if(c0.key==="Escape")if(c0.preventDefault(),q)B("");else c0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:Z0.map((c0)=>{if(!F&&!q&&c0.kind==="runtime")return null;let j0=M20(c0),I0=(c0.paths||[]).filter((d0)=>GQ.test(d0)).length,P8=j0.pill||(j0.pillFromDsCount?String(c0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||c0.paths?.length||0):null),W8=c0.tree&&Object.keys(c0.tree).length>0,K0=c0.label==="Design system",v0=c0.kind==="project";if(!F&&!q&&v0&&I0===0)return null;let B8=tq0(c0),c8=D[c0.label],I8=!!q||(c8===void 0?B8:c8),V8=!K0&&c0.kind==="canvas"&&!X,E0=V8?X0.dropProps(c0.fullPath,!0):{},F0=X0.overDir===c0.fullPath;return M("div",{className:"st-tree-section",children:[M("button",{type:"button",className:"st-tree-sec-hd"+(F0?" is-drop-target":""),onClick:()=>_(c0.label,B8),"aria-expanded":I8,"aria-dropeffect":V8?"move":void 0,title:I8?"Collapse section":"Expand section",...E0,children:[z(w9,{name:"chevron-right",className:"st-chev"+(I8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),P8&&z("span",{className:"st-pill",children:P8})]}),I8&&(W8?z(E00,{node:c0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:c0.kind,showHidden:F,search:q,dsFolders:c0.dsFolders,activeDsName:G,onOpenSystem:K0?K:void 0,onDelete:K0||X?void 0:w,dirtyByPath:y,canvasKinds:h,dirPath:c0.fullPath,drag:!K0&&c0.kind==="canvas"&&!X?X0:void 0,menu:!K0&&c0.kind==="canvas"&&!X?H0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},c0.label)})}),z(qS,{state:H0.state,onClose:H0.close,rootItems:U0,destinations:l0,onPickDestination:(c0)=>m(N0.path,c0)}),!c&&z(oA,{project:v,liveBranch:x,remoteSync:d,onGetLatest:o}),J===null?z(DA,{syncStatus:n,onLinkedHub:s}):null,z(OA,{})]})}function _20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:M("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(w9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(w9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(w9,{name:"folder",size:15})})]})})}function A20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),M("span",{className:"sku",children:["MAUDE-DEV-SRV / v",sR]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),M("div",{className:"help-modal-body",children:[M("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),M("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),M("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),M("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),M("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),M("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),M("details",{children:[z("summary",{children:"Annotation tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),M("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),M("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),M("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),M("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),M("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),M("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),M("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),M("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),M("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),M("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),M("details",{children:[z("summary",{children:"Canvas & panels"}),M("ul",{children:[M("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),M("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),M("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),M("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),M("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),M("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),M("details",{children:[z("summary",{children:"Slash commands"}),M("ul",{className:"cmds",children:[M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),M("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),M("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),M("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),M("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),M("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),M("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),M("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),M("details",{children:[z("summary",{children:"Opt-out scope"}),M("ul",{children:[M("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),M("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),M("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),M("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),M("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),M("details",{children:[z("summary",{children:"Auto-critic loop"}),M("ul",{children:[M("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),M("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),M("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),M("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),M("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),M("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),M("details",{children:[z("summary",{children:"Pin-to-element flow"}),M("ol",{children:[z("li",{children:"Open a canvas"}),M("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),M("li",{children:["Run"," ",M("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),M("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),M("details",{children:[z("summary",{children:"Comments"}),M("ol",{children:[M("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),M("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),M("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var oR=[{id:"canvas",label:"Canvas",items:[{label:"Command palette",kbd:"⌘ K"},{label:"New brief board",kbd:"N"},{label:"Export…",kbd:"⇧ ⌘ E"},{label:"Handoff to production",kbd:"⇧ ⌘ H"},{label:"Reload canvas",kbd:"⌘ R"},{label:"Search files",kbd:"/",alt:"⌘ F"}]},{id:"tools",label:"Tools · canvas focus",items:[{label:"Move · Hand · Comment",kbd:"V",alt:"H / C"},{label:"Pen · Highlighter · Eraser",kbd:"B",alt:"I / E"},{label:"Shape · Arrow",kbd:"R",alt:"A"},{label:"Sticky · Text · Section",kbd:"N",alt:"T / ⇧S"},{label:"Undo / redo",kbd:"⌘ Z",alt:"⇧ ⌘ Z"}]},{id:"selection",label:"Selection & zoom",items:[{label:"Select element",kbd:"⌘ click"},{label:"Add to selection",kbd:"⌘ ⇧ click"},{label:"Preview deepest",kbd:"⌘ hover"},{label:"Deselect · close menu",kbd:"Esc"},{label:"Zoom in / out",kbd:"⌘ +",alt:"⌘ −"},{label:"Fit · actual size",kbd:"⌘ 0",alt:"⌘ 1"}]},{id:"view",label:"View",items:[{label:"Project tree",kbd:"T"},{label:"Design system view",kbd:"S"},{label:"Inspector",kbd:"⌘ ⇧ I"},{label:"Comments sidebar",kbd:"⌘ ⇧ M"},{label:"Annotations",kbd:"⇧ P"},{label:"Hidden files",kbd:"H"},{label:"This cheat sheet · help",kbd:"?",alt:"F1"}]}];function w20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return M("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>M(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function E20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=oR.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[M("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),M("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:oR.map((Y)=>M("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>M("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(w20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),M("div",{className:"so-overlay-ft",children:[M("span",{children:["close with ",z(wX,{children:"Esc"})]}),M("span",{className:"so-count",children:[Q," bindings · ",oR.length," groups"]})]})]})})}var P20=["File","Edit","View","Selection","Tools","Help"];function P00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function R20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return P00(Q),M("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(w9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function CK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return P00(G),M("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function T20({onAction:X,onClose:J}){return z(CK,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function I20({onAction:X,onClose:J,readOnly:Q=!1}){return z(CK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function k20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(CK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function C20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(CK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function $20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(CK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(CK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function S20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:O,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:v,onToggleZoomCtl:x,presentMode:d,onTogglePresent:o,printGuidesVisible:h,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:f,onOpenReadiness:n,onOpenQuickSetup:s,onWatchIntro:c,whatsNewCount:Z0,exportCenter:X0,artboardCount:H0=0,presence:t=null,inspectorOpen:N0,inspectorTab:U0,onToggleInspector:l0,autoOpenInspector:J8,onToggleAutoOpenInspector:o0,onOpenLayers:L8,timelineOpen:w0,onToggleTimeline:O0,hasComps:Z8=!1,assistantOpen:H8,onToggleAssistant:r8,assistantBusy:A8,assistantUnseen:K8,onNewCanvas:T8,onAssembleVideo:s8,onOpenExport:E9,onOpenSettings:u0,onOpenGenerate:c0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:P8,readOnly:W8=!1}){let K0=X===n8,v0=K0?"SYSTEM":X?"CANVAS":"IDLE",B8=K0?z("b",{children:"design system"}):X?M(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(kK(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),c8=new Set(Q?["autoopen"]:["assistant","autoopen"]),I8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&U0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:Z8?"video":void 0,checked:w0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:H8,disabled:!1}]:Q?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||K0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:v,disabled:!X||K0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||K0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:h,disabled:!X||K0}].filter((F0)=>!W8||!c8.has(F0.id)),V8=["file","edit","view","selection","tools","help"];function E0(F0){if(V8.includes(F0))G(W===F0?null:F0)}return u.useEffect(()=>{if(!W||!V8.includes(W))return;let F0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(U8){let N8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N8.length)return;let o8=N8.indexOf(document.activeElement);if(U8.key==="ArrowDown")U8.preventDefault(),N8[(o8+1)%N8.length].focus();else if(U8.key==="ArrowUp")U8.preventDefault(),N8[(o8-1+N8.length)%N8.length].focus();else if(U8.key==="Home")U8.preventDefault(),N8[0].focus();else if(U8.key==="End")U8.preventDefault(),N8[N8.length-1].focus();else if(U8.key==="ArrowRight"||U8.key==="ArrowLeft"){U8.preventDefault();let O8=U8.key==="ArrowRight"?1:-1,N9=V8.indexOf(W);G(V8[(N9+O8+V8.length)%V8.length])}else if(U8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(F0),window.removeEventListener("keydown",d0)}},[W,G]),M("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[M("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?M("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:P20.map((F0)=>{let d0=F0.toLowerCase(),U8=V8.includes(d0),N8=U8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":U8?"menu":void 0,"aria-expanded":U8?W===d0:void 0,onClick:()=>E0(d0),onMouseEnter:()=>{if(W!==null&&U8)G(d0)},children:F0},d0)})}),W==="file"&&z(C20,{readOnly:W8,hasCanvas:!!X,onAction:(F0)=>{if(F0==="new")T8?.();else if(F0==="assemble")s8?.();else if(F0==="export")E9?.("export");else if(F0==="handoff")E9?.("handoff");else if(F0==="generate")c0?.();else if(F0==="settings")u0?.();else if(F0==="reload")j0?.();else if(F0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z($20,{readOnly:W8,hasCanvas:!!X&&!K0,onAction:(F0)=>{if(F0==="undo")p({dgn:"undo"});else if(F0==="redo")p({dgn:"redo"});else if(F0==="deselect-all")p({dgn:"selection-clear"});else if(F0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(F0.startsWith("new-artboard:"))P8?.(F0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(R20,{panels:I8,onToggle:(F0)=>{if(F0==="tree")F();else if(F0==="changes")q();else if(F0==="comments")H();else if(F0==="hidden")_();else if(F0==="annotate")$();else if(F0==="inspector")l0();else if(F0==="autoopen")o0?.();else if(F0==="timeline")O0?.();else if(F0==="assistant")r8?.();else if(F0==="layers")L8?.();else if(F0==="minimap")y?.();else if(F0==="zoomctl")x?.();else if(F0==="present")o?.();else if(F0==="print-guides")m?.()},onZoom:(F0)=>p({dgn:"zoom",op:F0}),hasCanvas:!!X&&!K0,onClose:()=>G(null)}),W==="selection"&&z(I20,{readOnly:W8,onAction:(F0)=>{if(F0==="deselect-all")p({dgn:"selection-clear"});else if(F0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(k20,{readOnly:W8,onAction:(F0)=>p({dgn:"tool-set",tool:F0}),onClose:()=>G(null)}),W==="help"&&z(T20,{onAction:(F0)=>{if(F0==="shortcuts")w?.();else if(F0==="help")R?.();else if(F0==="report-bug")O?.();else if(F0==="tour")P?.();else if(F0==="collab-tour")I?.();else if(F0==="quick-setup")s?.();else if(F0==="readiness")n?.();else if(F0==="whatsnew")f?.();else if(F0==="watch-intro")c?.()},onClose:()=>G(null)}),M("div",{className:"st-mb-right","data-tour":"status",children:[t?z("div",{className:"st-presence",children:t}):null,W8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?M("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!W8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":H8?"true":"false","data-busy":A8?"true":"false","data-unseen":K8?"true":"false","aria-label":`Assistant${A8?" — working":K8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:r8,children:z(w9,{name:"sparkle",size:15})}),X0&&z(Lx,{center:X0}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:O,children:z(w9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":Z0>0?"true":"false","aria-label":`What's new${Z0>0?` — ${Z0} unseen`:""}`,"data-tip":"What's new",onClick:f,children:z(w9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:v0}),z("span",{className:"st-mb-file",title:X||"",children:B8}),z("span",{className:"st-mb-sep"}),M("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),H0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function b20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),M("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${oB(kK(N))}`,tabIndex:0,children:z(Ih,{path:N,kind:aR(kK(N))})}),X.length===0&&!N&&M("div",{className:"st-empty",children:[M("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),M("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",sR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),M("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?M(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===n8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(m20,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:wz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:M("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var y20=["color","space","radius","shadow","leading","weight","motion","font","other"],j20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function f20(X){return X==="color"}function v20({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return M("section",{className:"sv-section sv-section-tokens",children:[M("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:M("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...y20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=f20(G);return M("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[M("h2",{children:["tokens · ",j20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>M("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,M("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function h20(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function x20(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function g20({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=x20(X?.font);return M("section",{className:"sv-section sv-section-type",children:[M("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=h20(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return M("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function m20({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return M("div",{className:"sv",children:[M("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?M("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(v20,{tokens:H,tokenGroups:K,tokensPath:U}),z(g20,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:M("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):M(G0,{children:[z(W00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(W00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function W00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return M("section",{className:"sv-section",children:[M("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>M("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:wz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),M("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function u20({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===n8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Az(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&M(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return M("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[M("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&M("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),M("span",{className:"val",children:[Y," open"]})]}),_&&M("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:M("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),M("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(w9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function p20({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=w00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((O)=>O.selector);F.push({file:D,comments:R.map((O)=>({...O,n:w.findIndex((P)=>P.id===O.id)+1}))})}return M("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:M("div",{className:"st-cm-filters",role:"tablist",children:[M("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),M("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),M("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?M("div",{className:"st-rp-empty",children:[M("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),M("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>M(G0,{children:[M("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(kK(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>M("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[M("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:Y20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),M("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?M("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(w9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(w9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(w9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var l20={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function d20({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=l20[J];if(!Z)return null;return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function c20({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),M("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),hv().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function i20({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return M("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var o20=["block","inline-block","flex","inline-flex","grid","inline","none"],G00=["px","%","fr","em","auto","min-content","max-content"];var n20=["auto","stretch","flex-start","center","flex-end","baseline"];var Z00=["300","400","500","600","700","800"],H00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],z00=["none","solid","dashed","dotted","double"],K00=["px","rem","em","%","vw","vh","auto"],U00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),nR={"font-size":{node:z(W7,{as:JV,size:12})},"line-height":{node:z(W7,{as:zV,size:12})},"letter-spacing":{node:z(W7,{as:DV,size:12})},gap:{node:z(W7,{as:tz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(W7,{as:wV,size:12})},"border-width":{node:z(W7,{as:LV,size:12})}};var V00=["static","relative","absolute","fixed","sticky"],r20=["normal","italic","oblique"],q00=["none","uppercase","lowercase","capitalize"];var B00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],a20=["fill","contain","cover","none","scale-down"];var N00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],M5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},TK=null;function EF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!TK)TK=document.createElement("canvas").getContext("2d");if(!TK)return"";TK.fillStyle="#000000",TK.fillStyle=X;let J=TK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var r4=(X)=>Math.min(1,Math.max(0,X));function DF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function b3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function y3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function IK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function H7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function mQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function L00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function R00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function s20(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function T00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...s20(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function I00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>y3(DF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(y3(DF(X)))},[X]);let U=b3(IK(Y)),q=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:r4((C.clientX-P.left)/P.width),v:r4(1-(C.clientY-P.top)/P.height)})};k(O);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(b3(IK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:r4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(b3(IK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let P={...G.current,...O};W(P),Q(b3(IK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!k)return;O.preventDefault(),N({s:r4(G.current.s+k[0]),v:r4(G.current.v+k[1])})},D=(O)=>{let P=O.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[O.key];if(k==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(y3(DF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=IK(Y),w=(O)=>{let P={...R,...O},I=y3({r:r4(P.r/255)*255,g:r4(P.g/255)*255,b:r4(P.b/255)*255});W(I),Q(b3(IK(I)))};return M("div",{className:"st-cp-cpick",children:[M("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(y3(DF(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),M("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),M("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(w9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>M("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>w({[O]:r4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function OF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(s)=>Q===`var(${s})`,k=(s)=>s.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((s,c)=>s+(c.names?.length||0),0),y=$.length>1,v=_.trim().toLowerCase(),x=!v?$:$.map((s)=>({...s,names:(s.names||[]).filter((c)=>k(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(s.vals?.[c]||"").toLowerCase().includes(v))})).filter((s)=>s.names.length);u.useEffect(()=>{if(!U){R("");return}let s=()=>{let H0=w.current?.getBoundingClientRect();if(!H0)return;let t=224,N0=300,U0=Math.min(H0.right-t,window.innerWidth-t-8);if(U0<8)U0=8;let J8=window.innerHeight-H0.bottom>N0+8?H0.bottom+4:Math.max(8,H0.top-N0-4);N({left:U0,top:J8,width:t,maxHeight:N0})};s();let c=(H0)=>{if(O.current?.contains(H0.target)||w.current?.contains(H0.target))return;q(!1)},Z0=(H0)=>{if(H0.key==="Escape")q(!1)},X0=(H0)=>{if(O.current?.contains(H0.target))return;s()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",Z0),window.addEventListener("resize",s),document.addEventListener("scroll",X0,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",Z0),window.removeEventListener("resize",s),document.removeEventListener("scroll",X0,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let s=O.current.getBoundingClientRect(),c=B.left-s.left,Z0=B.top-s.top;if(Math.abs(c)>0.5||Math.abs(Z0)>0.5)N((X0)=>X0?{...X0,left:X0.left+c,top:X0.top+Z0}:X0)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(s,c,Z0)=>{if(H&&s&&s!==H&&Z0&&!d.test(Z0))Y(Z0);else Y(`var(${c})`);q(!1)},h=(s)=>{let c=(s||"").trim();if(c)Y(c)},m=M("div",{className:"st-cp-pop-search",children:[z(w9,{name:"search",size:12}),z("input",{value:_,onChange:(s)=>R(s.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(s)=>s.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((Z0)=>M("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(Z0)?" is-on":""}`,onClick:()=>o(c.ds,Z0,c.vals?.[Z0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[Z0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(Z0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[Z0]||""})]},`${c.ds}:${Z0}`))})]},c.ds)),f=(s)=>s.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((Z0)=>M("button",{type:"button",className:`st-cp-pop-row${I(Z0)?" is-on":""}`,onClick:()=>o(c.ds,Z0,c.vals?.[Z0]),children:[z("span",{className:"st-cp-pop-name",children:k(Z0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[Z0]||""})]},`${c.ds}:${Z0}`))})]},c.ds)),n=z("div",{className:"st-cp-pop-empty",children:"No match"});return M(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((s)=>!s),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((s)=>!s),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?M00.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?M(G0,{children:[M("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(I00,{seed:Z||EF(Q)||"#000000",onApply:h}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):M(G0,{children:[m,x.length?p(x):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):M(G0,{children:[m,x.length?f(x):n]})}),document.body):null]})}function D00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?WU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return M("div",{className:"st-cp-gridtracks",children:[M("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?M("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=WU.has(K.unit);return M("div",{className:"st-cp-gridtrack-row",children:[q?z(TW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:G00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(tB,{value:K.unit,units:G00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function t20({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(e,A0)=>{let B0={...e||{}};for(let[S0,s0]of Object.entries(A0))if(s0===null)delete B0[S0];else B0[S0]=s0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(e,A0)=>B((B0)=>({...B0,a:{...B0.a,[e]:A0}})),w=(e,A0)=>B((B0)=>({...B0,c:{...B0.c,[e]:A0}})),O=(e,A0)=>B((B0)=>({...B0,t:{...B0.t,[e]:A0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=R00(X.file,J),k=T00(J,P,I),$=(e)=>k.map((A0)=>({ds:A0.name,names:A0[e]||[],vals:A0.vals})).filter((A0)=>A0.names.length),[C,y]=u.useState({}),[v,x]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)x((e)=>e.Advanced?e:{...e,Advanced:!0})},[X.id,d]);let o=(F.position||H7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)x((e)=>e["d:Position"]?e:{...e,"d:Position":!0})},[X.id,o]);let h=H,[m,p]=u.useState({});async function f(e,A0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0)}),s0=await S0.json().catch(()=>({}));y((y8)=>({...y8,[B0]:!S0.ok||!s0.ok?`err:${s0&&s0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((s0)=>({...s0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let n=(e,A0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:e,value:A0})},s=(e,A0,B0,S0)=>{Y?.({op:e,canvas:X.file,id:X.id,key:A0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(e,A0)=>{let B0=(A0||"").trim();if(!K||!B0)return;let S0=F[e]??null;if(B0===(S0??"").trim())return;n(e,B0),R(e,B0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,value:B0},e),s("css",e,S0,B0)},Z0=(e,A0)=>{let B0=(A0||"").trim(),S0=e.trim();if(!K||!S0||!B0)return;let s0=D[S0]??null;n(S0,B0),w(S0,B0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),s("css",S0,s0,B0)},X0=(e,A0)=>{let B0=(e||"").trim(),S0=(A0||"").trim();if(!K||!B0||!S0)return;let s0=_[B0]??null;O(B0,S0),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),s("attr",B0,s0,S0)},H0=(e)=>{if(!K)return;let A0=F[e]??null;n(e,null),R(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),s("css",e,A0,null)},t=(e)=>{if(!K)return;let A0=D[e]??null;n(e,null),w(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),s("css",e,A0,null)},N0=(e)=>{if(!K)return;let A0=_[e]??null;O(e,null),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:e,reset:!0},`@${e}`),s("attr",e,A0,null)},U0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},l0=(e,A0)=>{if(!K)return;let B0=Math.round((e==="width"?X.bounds?.w:X.bounds?.h)||0),S0=zS(e,A0,U0,B0);for(let s0 of S0.reset)if(F[s0])H0(s0);for(let[s0,y8]of S0.set)c(s0,y8)},J8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(e)=>{let A0=HS(e,F,U,U0);return M("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:e==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${e} sizing mode`,children:z(eB,{value:A0,ariaLabel:`${e} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>l0(e,B0)})})]},`mode-${e}`)},L8=["flex-start","center","flex-end"],w0=["flex-start","center","flex-end"],O0=["t","c","b"],Z8=["l","c","r"],H8=()=>{let e=!(F["flex-direction"]||H7(U["flex-direction"])||"row").startsWith("column"),A0=Math.max(0,L8.indexOf(F["justify-content"]||H7(U["justify-content"])||"flex-start")),B0=F["align-items"]||H7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,w0.indexOf(B0)),[s0,y8]=e?[A0,S0]:[S0,A0];return O0[y8]+Z8[s0]},r8=(e)=>{let A0=O0.indexOf(e[0]),B0=Z8.indexOf(e[1]),S0=!(F["flex-direction"]||H7(U["flex-direction"])||"row").startsWith("column"),[s0,y8]=S0?[B0,A0]:[A0,B0];c("justify-content",L8[s0]),c("align-items",w0[y8])},A8=(e)=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let A0=e.key.toLowerCase();if(A0==="z")e.preventDefault(),G?.(e.shiftKey?"redo":"undo");else if(A0==="y")e.preventDefault(),G?.("redo")},K8=(e)=>{let A0=F[e];if(!A0)return"inherit";return/var\(\s*--/.test(A0)?"bound":"raw"};if(!K)return M("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),M("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let T8={bound:"token-bound",raw:"raw override",inherit:"inherited"},s8=(e)=>z("span",{className:`st-cp-prov st-cp-prov--${e}`,role:"img","aria-label":T8[e]}),E9=(e,A0)=>{let B0=A0??K8(e),S0=C[e],s0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",y8=s0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",x8=!!F[e],t8=s0?`error: ${s0}`:x8?`${T8[B0]} · double-click to reset`:T8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${y8}${x8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:x8?0:-1,onDoubleClick:x8?()=>H0(e):void 0,onKeyDown:x8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),H0(e)}:void 0})},u0=(e,A0,B0,S0)=>{let s0=B0===void 0&&!F[e],y8=S0??e;return M("div",{className:`st-cp-row${s0?" is-unset":""}`,children:[E9(e,B0),z("label",{className:"st-cp-label",title:y8,children:y8}),z("div",{className:"st-cp-ctl",children:A0})]},e)},c0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},j0=(e)=>{(c0[e]||[]).forEach((A0)=>{if(F[A0])H0(A0)})},I0=(e,A0)=>{let B0=(c0[e]||[]).some((S0)=>F[S0]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[e],onClick:()=>x((S0)=>({...S0,[e]:!S0[e]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:v[e]?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${e} section to original`,title:`reset ${e}`,disabled:!B0,onClick:()=>j0(e),children:z(W7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${v[e]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:A0})})]},e)},P8=(e,A0,B0,S0=!0)=>{let s0=`d:${e}`,y8=v[s0]===void 0?S0:v[s0],x8=A0.some((t8)=>F[t8]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":y8,onClick:()=>x((t8)=>({...t8,[s0]:!y8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y8?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${x8?"":" is-quiet"}`,"aria-label":`reset ${e} to original`,title:`reset ${e}`,disabled:!x8,onClick:()=>A0.forEach((t8)=>{if(F[t8])H0(t8)}),children:z(W7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${y8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},s0)},W8=(e)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[e],"aria-label":m[e]?`${e} — fewer options`:`${e} — more options`,title:m[e]?"fewer":"more",onClick:()=>p((A0)=>({...A0,[e]:!A0[e]})),children:m[e]?"▴":"···"}),K0=(e,A0)=>M("select",{className:"st-cp-nsel","aria-label":e,value:A0.includes(F[e])?F[e]:"",onChange:(B0)=>c(e,B0.target.value),children:[z("option",{value:"",disabled:!0,children:H7(U[e])||"—"}),A0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),v0=(e)=>$(e).flatMap((A0)=>(A0.names||[]).map((B0)=>({name:B0,value:A0.vals?.[B0]||""}))),B8=(e,A0)=>z(CA,{value:F[e]||H7(U[e])||A0[0].value,ariaLabel:e,options:A0,onChange:(B0)=>c(e,B0)}),c8=(e,A0,B0={})=>{let S0=mQ(F[e]??""),s0=U00.has(e),y8=F[e]??"",x8=typeof y8==="string"&&/var\(\s*--/.test(y8),t8=s0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(mQ(H7(U[e])??"").n)||0,A9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=nR[e];return z(XN,{value:x8?y8:A9,tokens:v0(A0),ariaLabel:e,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:s0?null:z(tB,{units:K00,value:S0.unit||"px",ariaLabel:`${e} unit`,onChange:(x9)=>c(e,x9==="auto"?"auto":`${S0.n||"0"}${x9}`)}),onChange:(x9)=>c(e,typeof x9==="string"?x9:s0?`${x9}`:`${x9}${t8}`)})},I8=()=>{let e=(s0)=>Number.parseFloat(mQ(F[s0]??F["border-radius"]??H7(U[s0])??H7(U["border-radius"])??"0").n)||0,A0={tl:e("border-top-left-radius"),tr:e("border-top-right-radius"),bl:e("border-bottom-left-radius"),br:e("border-bottom-right-radius")},B0=(s0)=>{if(s0.tl===s0.tr&&s0.tr===s0.bl&&s0.bl===s0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((x8)=>{if(F[x8])H0(x8)}),c("border-radius",`${s0.tl}px`);else c("border-top-left-radius",`${s0.tl}px`),c("border-top-right-radius",`${s0.tr}px`),c("border-bottom-left-radius",`${s0.bl}px`),c("border-bottom-right-radius",`${s0.br}px`)},S0=nR["border-radius"];return z(hh,{corners:A0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},V8=()=>M("div",{className:"st-cp-border",children:[S9("border-width",null,{fixedUnit:"px"}),M("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:z00.includes(F["border-style"])?F["border-style"]:"",onChange:(e)=>c("border-style",e.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),z00.map((e)=>z("option",{value:e,children:e},e))]}),z(OF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:EF(U["border-color"]||F["border-color"])||"#000000",onPick:(e)=>c("border-color",e),label:"border colour"})]}),E0=()=>{let e=F.transform||H7(U.transform)||"",A0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(e),B0=((A0?Number.parseFloat(A0[1]):0)%360+360)%360,S0=(s0)=>{let y8=(s0%360+360)%360,x8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${x8?`${x8} `:""}rotate(${y8}deg)`.trim())};return M("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(fh,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(W7,{as:MZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},F0=()=>{let e=F.filter||H7(U.filter)||"",A0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(e),B0=A0?Number.parseFloat(A0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(s0)=>{let y8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",s0>0?`${y8?`${y8} `:""}blur(${s0}px)`.trim():y8||"none")}})},d0=()=>{let e=F.opacity,A0=e!=null&&e!==""?Number.parseFloat(e):Number.parseFloat(H7(U.opacity))||1,B0=Math.round((Number.isNaN(A0)?1:A0)*100);return z(RJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>n("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${e??""}`)},U8=()=>{let e=Number.parseInt(F["font-weight"]||H7(U["font-weight"])||"400",10)>=600,A0=(F["font-style"]||H7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||H7(U["text-decoration"])||"");return z(yh,{value:{b:e,i:A0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(W7,{as:KV}),label:"Bold"},{value:"i",node:z(W7,{as:NV}),label:"Italic"},{value:"u",node:z(W7,{as:RV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",e?"400":"700");else if(S0==="i")c("font-style",A0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},N8=[{value:"row",node:z(W7,{as:LW}),label:"Row"},{value:"column",node:z(W7,{as:DW}),label:"Column"}],o8=[{value:"flex-start",node:z(W7,{as:WV}),label:"Start"},{value:"center",node:z(W7,{as:QV}),label:"Center"},{value:"flex-end",node:z(W7,{as:YV}),label:"End"},{value:"space-between",node:z(W7,{as:tz}),label:"Space between"}],O8=[{value:"flex-start",node:z(W7,{as:HV}),label:"Start"},{value:"center",node:z(W7,{as:GV}),label:"Center"},{value:"flex-end",node:z(W7,{as:ZV}),label:"End"},{value:"stretch",node:z(W7,{as:EV}),label:"Stretch"}],N9=[{value:"left",node:z(W7,{as:m5}),label:"Left"},{value:"center",node:z(W7,{as:_W}),label:"Center"},{value:"right",node:z(W7,{as:AW}),label:"Right"},{value:"justify",node:z(W7,{as:wW}),label:"Justify"}],Y9=[{value:"visible",node:z(W7,{as:DZ}),label:"Visible"},{value:"hidden",node:z(W7,{as:OZ}),label:"Hidden"},{value:"scroll",node:z(W7,{as:_V}),label:"Scroll"}],t7=(e,A0)=>{let B0=$(A0);return B0.length?z(OF,{kind:"value",groups:B0,current:F[e],activeDs:I,onPick:(S0)=>c(e,S0),label:`${e} design token`}):null},P0=(e)=>{let A0=e.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===A0)A0.select()})},h8=(e,A0)=>{if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return!1;e.preventDefault();let B0=e.shiftKey?10:1,S0=e.key==="ArrowUp"?1:-1,s0=(Number.parseFloat(e.currentTarget.value)||0)+S0*B0;return e.currentTarget.value=String(s0),A0(s0),!0},F9=(e)=>z("input",{className:"st-cp-fin","aria-label":e,defaultValue:F[e]??"",placeholder:H7(U[e])||"—",onFocus:P0,onKeyDown:(A0)=>{if(A0.key==="Enter")A0.currentTarget.blur()},onBlur:(A0)=>c(e,A0.currentTarget.value)},`${e}:${F[e]??""}`),S9=(e,A0,B0={})=>{let S0=mQ(F[e]??""),s0=U00.has(e),y8=s0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),x8=nR[e],t8=Number.parseFloat(mQ(H7(U[e])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return M(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:e,lead:x8?x8.node??x8.t:void 0,onCommit:(A9)=>c(e,s0?`${A9}`:`${A9}${y8}`),unitSlot:s0||B0.fixedUnit?null:z(tB,{units:K00,value:S0.unit||"px",ariaLabel:`${e} unit`,onChange:(A9)=>c(e,A9==="auto"?"auto":`${S0.n||"0"}${A9}`)})},`${e}:${F[e]??""}`),t7(e,A0)]})},g7=(e)=>{let A0=U[e]||F[e]||"",B0=F[e]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),s0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z(IV,{swatch:z(OF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[e],activeDs:I,swatchBg:A0,seedHex:EF(U[e]||F[e])||"#000000",onPick:(y8)=>c(e,y8),label:`${e} colour`}),displayValue:s0,bound:S0,ariaLabel:e,onValue:(y8)=>c(e,y8)})},d6=(e,A0)=>{let B0=null,S0=A0.unitless?"":"px",s0=(t8)=>A0.unitless?`${t8}`:`${t8}${S0}`,y8=(t8,G9,A9)=>{for(let F7 of G9??[e])A9(F7,s0(t8))},x8=kA({getBase:()=>B0?.value??"0",min:A0.min??0,step:1,sides:A0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let A9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===e)continue;let x9=A9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(x9)x9.value=String(t8)}}y8(t8,G9,n)},onCommit:(t8,G9)=>y8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,x8(t8)}}},u8=(e,A0)=>{let B0=F[e],S0=B0!=null&&B0!==""?mQ(B0).n||B0:mQ(H7(U[e])??"").n||"0",s0=!B0||B0==="0"||B0==="0px"||B0==="auto",y8=e.split("-").pop(),x8=y8==="top"||y8==="bottom"?[`${A0}-top`,`${A0}-bottom`]:[`${A0}-left`,`${A0}-right`],t8=[`${A0}-top`,`${A0}-right`,`${A0}-bottom`,`${A0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${A0[0]}${e.split("-").pop()[0]}${s0?" is-zero":""}`,"aria-label":e,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...d6(e,{sides:{pair:x8,all:t8}}),onFocus:P0,onKeyDown:(G9)=>{if(h8(G9,(A9)=>c(e,`${A9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let A9=G9.currentTarget.value.trim();if(!A9)return;let F7=/[a-z%]/i.test(A9)?A9:`${A9}px`;c(e,F7)}},`${e}:${B0??""}`)},z7=(e)=>{let A0=F[e],B0=A0!=null&&A0!==""&&A0!=="auto"?mQ(A0).n||A0:mQ(H7(U[e])??"").n||"",S0=!A0||A0==="auto"||A0==="0"||A0==="0px",s0=e==="top"||e==="bottom"?["top","bottom"]:["left","right"],y8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${e[0]}${S0?" is-zero":""}`,"aria-label":e,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...d6(e,{sides:{pair:s0,all:y8},min:-1/0}),onFocus:P0,onKeyDown:(x8)=>{if(h8(x8,(t8)=>c(e,`${t8}px`)))return;if(x8.key==="Enter")x8.currentTarget.blur()},onBlur:(x8)=>{let t8=x8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(e,G9)}},`${e}:${A0??""}`)},K7=Object.entries(D),E7=Object.entries(_),R9=()=>{let e=(X.tag||"").toLowerCase(),B0=e==="img"||e==="video"||e==="picture"||e==="svg"||e==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(e==="img"||e==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(e)=>M(G0,{children:[e&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),u0("object-fit",K0("object-fit",a20)),u0("object-position",F9("object-position")),u0("aspect-ratio",M("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:F00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(A0)=>{let B0=A0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)H0("height")},children:[z("option",{value:"",disabled:!0,children:H7(U["aspect-ratio"])||"—"}),F00.map((A0)=>z("option",{value:A0,children:A0},A0))]}))]});return M("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:A8,children:[M("div",{className:"st-cp-id",children:[M("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?M("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(CA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(W7,{as:FW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(W7,{as:EW,size:12}),label:"Designer — Figma vocabulary"}],onChange:h})})]}),Z==="designer"?M(G0,{children:[P8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let e=(F.display||H7(U.display)||"").trim();return e==="flex"||e==="inline-flex"?M(G0,{children:[u0("flex-direction",B8("flex-direction",N8),void 0,"Direction"),u0("align-items",z(jh,{value:H8(),onChange:r8,ariaLabel:"auto-layout alignment"}),K8("align-items"),"Alignment"),u0("gap",c8("gap","space"),void 0,"Gap"),M("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),M("div",{className:"st-cp-box","aria-label":"padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[s8(K8("padding-top")),"padding"]}),u8("padding-top","padding"),u8("padding-right","padding"),u8("padding-bottom","padding"),u8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:W8("Auto layout")}),m["Auto layout"]?u0("flex-wrap",z(jQ,{checked:/^wrap/.test(F["flex-wrap"]||H7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),K8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),P8("Size",["width","height","min-width","max-width","min-height","max-height"],M(G0,{children:[u0("width",S9("width"),void 0,"Width"),u0("height",S9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:W8("Size")}),m.Size?M(G0,{children:[u0("min-width",S9("min-width"),void 0,"Min width"),u0("max-width",S9("max-width"),void 0,"Max width"),u0("min-height",S9("min-height"),void 0,"Min height"),u0("max-height",S9("max-height"),void 0,"Max height")]}):null]})),P8("Position",["position","top","right","bottom","left","z-index"],M(G0,{children:[u0("position",K0("position",V00),void 0,"Position"),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[s8(K8("top")),"inset"]}),z7("top"),z7("right"),z7("bottom"),z7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||H7(U.position)||"static"})]}),(F.position||H7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:W8("Position")}),m.Position?u0("z-index",S9("z-index"),void 0,"Layer order"):null]}),!1),P8("Fill",["background-color"],u0("background-color",g7("background-color"),void 0,"Fill")),P8("Stroke",["border-width","border-style","border-color"],u0("border",V8(),K8("border-width"),"Stroke")),P8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],u0("border-radius",I8(),K8("border-radius"),"Corner radius")),P8("Effects",["box-shadow","filter","mix-blend-mode"],M(G0,{children:[u0("box-shadow",t7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),u0("filter",F0(),K8("filter"),"Blur"),u0("mix-blend-mode",K0("mix-blend-mode",N00),void 0,"Blend")]})),P8("Opacity",["opacity"],u0("opacity",d0(),void 0,"Opacity")),P8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],M(G0,{children:[u0("font-family",K0("font-family",H00),void 0,"Font"),u0("color",g7("color"),void 0,"Color"),u0("font-size",c8("font-size","type"),void 0,"Size"),u0("font-weight",K0("font-weight",Z00),void 0,"Weight"),u0("line-height",S9("line-height","lh"),void 0,"Line height"),u0("text-align",B8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:W8("Text")}),m.Text?M(G0,{children:[u0("letter-spacing",S9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),u0("font-style",K0("font-style",r20),void 0,"Style"),u0("text-transform",K0("text-transform",q00),void 0,"Case"),u0("white-space",K0("white-space",B00),void 0,"Whitespace")]}):null]})),P8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],M("div",{className:"st-cp-box","aria-label":"margin",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[s8(K8("margin-top")),"margin"]}),u8("margin-top","margin"),u8("margin-right","margin"),u8("margin-bottom","margin"),u8("margin-left","margin")]})),(()=>{let{showMedia:e,canReplace:A0}=R9();return e?P8("Media",["object-fit","object-position","aspect-ratio"],S6(A0)):null})()]}):M(G0,{children:[I0("Layout",(()=>{let e=(F.display||H7(U.display)||"").trim(),A0=e==="flex"||e==="inline-flex",B0=e==="grid"||e==="inline-grid";return M(G0,{children:[u0("display",K0("display",o20)),A0?M(G0,{children:[u0("flex-direction",B8("flex-direction",N8)),u0("flex-wrap",z(jQ,{checked:/^wrap/.test(F["flex-wrap"]||H7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),K8("flex-wrap"))]}):null,A0||B0?M(G0,{children:[u0("align-items",B8("align-items",O8)),u0("justify-content",B8("justify-content",o8)),u0("gap",c8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let e=(F.display||H7(U.display)||"").trim();if(!(e==="grid"||e==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",s0=kM(B0),y8=kM(S0),x8=s0.length>0||!B0.trim(),t8=y8.length>0||!S0.trim();return I0("Grid",M(G0,{children:[x8?z(D00,{label:"Columns",tracks:s0,editable:K,onChange:(G9)=>c("grid-template-columns",CM(G9))}):M("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(D00,{label:"Rows",tracks:y8,editable:K,onChange:(G9)=>c("grid-template-rows",CM(G9))}):M("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",M(G0,{children:[u0("position",K0("position",V00)),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[s8(K8("top")),"inset"]}),z7("top"),z7("right"),z7("bottom"),z7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||H7(U.position)||"static"})]}),(F.position||H7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,u0("z-index",S9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",M(G0,{children:[M("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),u0("grid-column",F9("grid-column")),u0("grid-row",F9("grid-row"))]})),I0("Typography",M(G0,{children:[u0("font-family",K0("font-family",H00)),u0("color",g7("color")),u0("font-size",c8("font-size","type")),u0("font-weight",K0("font-weight",Z00)),u0("line-height",S9("line-height","lh")),u0("letter-spacing",S9("letter-spacing",null,{min:-1/0})),u0("text-align",B8("text-align",N9)),u0("font-style",U8(),K8("font-style")),u0("text-transform",K0("text-transform",q00)),u0("white-space",K0("white-space",B00))]})),I0("Spacing",z(G0,{children:M("div",{className:"st-cp-box","aria-label":"margin and padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[s8(K8("margin-top")),"margin"]}),u8("margin-top","margin"),u8("margin-right","margin"),u8("margin-bottom","margin"),u8("margin-left","margin"),M("div",{className:"st-cp-boxpad",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[s8(K8("padding-top")),"padding"]}),u8("padding-top","padding"),u8("padding-right","padding"),u8("padding-bottom","padding"),u8("padding-left","padding"),M("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",M(G0,{children:[M("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),u0("width",S9("width")),u0("height",S9("height")),u0("min-width",S9("min-width")),u0("max-width",S9("max-width")),u0("min-height",S9("min-height")),u0("max-height",S9("max-height")),u0("overflow",B8("overflow",Y9)),J8?M(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),u0("align-self",K0("align-self",n20)),u0("flex-grow",S9("flex-grow",null,{unitless:!0})),u0("flex-shrink",S9("flex-shrink",null,{unitless:!0})),u0("flex-basis",S9("flex-basis"))]}):null]})),(()=>{let{showMedia:e,canReplace:A0}=R9();return e?I0("Media",S6(A0)):null})(),I0("Appearance",M(G0,{children:[u0("background-color",g7("background-color")),u0("border-radius",I8(),K8("border-radius")),u0("border",V8(),K8("border-width")),u0("box-shadow",t7("box-shadow","shadow")||F9("box-shadow")),u0("filter",F0(),K8("filter")),u0("mix-blend-mode",K0("mix-blend-mode",N00)),u0("opacity",d0()),u0("rotation",E0(),K8("transform")),u0("transform",F9("transform")),u0("transform-origin",F9("transform-origin"))]})),(()=>{let e=Object.entries(C).find(([,A0])=>typeof A0==="string"&&A0.startsWith("err:"));return e?M("div",{className:"st-cp-save is-err",role:"status",children:[z(w9,{name:"x",size:12}),e[0],": ",e[1].slice(4)]}):null})(),I0("Advanced",M("div",{className:"st-cp-advbody",children:[K7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),K7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`custom property ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>Z0(e,B0.currentTarget.value)},`cs:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>t(e),children:z(w9,{name:"x",size:11})})]},`cs:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(e20,{commit:Z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),E7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),E7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`attribute ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>X0(e,B0.currentTarget.value)},`at:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>N0(e),children:z(w9,{name:"x",size:11})})]},`at:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(XB0,{commit:X0})]}))]}),M("div",{className:"st-cp-legend",children:[M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function e20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function XB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var JB0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function QB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var YB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function k00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[v,x]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),o=G?.has(w)?G.get(w):!!X.hidden,h=!!q&&!I&&!$,m=()=>{y(!1);let n=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(X.dcElement??""))return;R?.(X,n)},p=N?.key===w,f=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return M(G0,{children:[M("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(o?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...f},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":O?!P:void 0,"aria-grabbed":h?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?O&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:h?(n)=>B(n,X,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),I)O&&Z(w);else H(X);else if(n.key==="F2"&&R&&!I)n.preventDefault(),x(X.dcElement||X.label||""),y(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(w9,{name:JB0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>x(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:m,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")m();else if(n.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(n)=>{n.stopPropagation(),x(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),_(w)},children:z(w9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(X)},children:z(w9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((n,s)=>z(k00,{node:n,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${n.id}:${n.index}`)):null]})}function WB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),M("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?mQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return M(G0,{children:[G?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function C00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var GB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],ZB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function HB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=C00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=R00(X.file,J),B=T00(J,U,q),N=(f)=>B.map((n)=>({ds:n.name,names:n[f]||[],vals:n.vals})).filter((n)=>n.names.length),F=(f)=>N(f).flatMap((n)=>(n.names||[]).map((s)=>({name:s,value:n.vals?.[s]||""}))),D=(f)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f||"");if(!n)return f||"";for(let s of B){let c=s.vals?.[n[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(f,n)=>{if(!K)return;let s=Number.isFinite(f)&&f>0?Math.round(f):void 0,c=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(s==null&&c==null)return;Q?.(K,s,c)},O=Object.entries(M5).find(([,f])=>f.width===_&&f.height===R)?.[0],P=Object.entries(M5).find(([,f])=>f.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",x=null;try{x=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(f)=>{if(!K)return;let n=null;if(f==="print"&&!x){let s={paper:"a4"};try{let c=N2(s);if(c)n={defaults:s,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,f==="digital"?null:f,n),f==="web"&&I)Y?.(K,!1,void 0)},o=(f)=>{if(!K)return;let n={paper:"a4",...x,...f},s;try{s=N2(n)}catch{return}Q?.(K,s.widthPx,s.heightPx),Z?.(K,n)},h=(f,n)=>{if(!K)return;let s=Number.isFinite(n)?n:R,c=f&&Number.isFinite(s)?Math.round(s):void 0;Y?.(K,f,c)},m=(f)=>{let n=WS(I,f);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")h(!0,n.height)},p=(f)=>{if(!K)return;W?.(K,f)};return M("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),M("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(f)=>w(f,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:v==="print"?M("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:x?.paper??"",onChange:(f)=>o({paper:f.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),B2.map((f)=>M("option",{value:f.id,children:[f.label," — ",f.width,"×",f.height,f.unit]},f.id))]}):v==="web"?M("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${M5[P].label} — ≤ ${M5[P].width}px`:"Breakpoint…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ≤ ",n.width,"px breakpoint"]},f))]}):M("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?M5[O].label:"Preset size…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ",n.width,"×",n.height]},f))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(eB,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(f)=>h(f==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(TW,{value:v,ariaLabel:"artboard kind",options:ZB0.map(([f,n])=>({value:f,label:n})),onChange:d})}),v!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:M("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)H(K,n.width);f.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ",n.width,"px"]},f))]})}):null,v==="print"?M(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(eB,{value:x?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(f)=>o({orientation:f})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(x?.bleedMm)?x.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(f)=>o({bleedMm:f})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),M("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let f=D(k),n=/var\(\s*--/.test(k),s=n?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z(IV,{swatch:z(OF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:f,seedHex:EF(f)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:s,bound:n,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(TW,{value:C,ariaLabel:"artboard body layout",options:GB0.map(([f,n])=>({value:f,label:n})),onChange:(f)=>p({layout:f||null})}),M("div",{style:{display:"flex",gap:8},children:[z(XN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(f)=>p({padding:typeof f==="string"?f:f>0?f:null})}),z(XN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(f)=>p({gap:typeof f==="string"?f:f>0?f:null})})]})]})]})}var tR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,zB0=new RegExp(tR.source,"gi");function KB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(zB0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=tR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function UB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:v,onTabChange:x,width:d,resizing:o,photoSel:h,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:f,onPhotoRecordEdit:n,onPhotoUndoRedo:s,layersOnly:c=!1,hideLayersTab:Z0=!1,cpMode:X0,onSetCpMode:H0}){let[t,N0]=u.useState("inspect"),U0=c?"layers":v??t,l0=(E0)=>{N0(E0),x?.(E0)},[J8,o0]=u.useState(()=>new Set),[L8,w0]=u.useState(()=>new Map);u.useEffect(()=>{let E0=Array.isArray(J)?J[0]:J,F0=E0?.id;if(!F0||!Y?.nodes)return;let d0=E0.index,U8=null,N8=[];if(function o8(O8,N9){for(let Y9 of O8||[]){let t7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===F0&&(d0==null||Y9.index===d0))return U8=t7,N8.push(...N9),!0;if(Y9.children&&Y9.children.length&&o8(Y9.children,[...N9,t7]))return!0}return!1}(Y.nodes,[]),!U8)return;if(N8.length)o0((o8)=>{let O8=!1,N9=new Set(o8);for(let Y9 of N8)if(N9.delete(Y9))O8=!0;return O8?N9:o8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${U8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let O0=(E0)=>{let F0=`${E0.id}:${E0.index}`;return L8.has(F0)?L8.get(F0):!!E0.hidden},[Z8,H8]=u.useState(null),[r8,A8]=u.useState(""),K8=(E0,F0)=>{if(!K||!E0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:E0.id,attr:"data-dc-element",value:F0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:E0.id,key:"data-dc-element",before:E0.dcElement??null,after:F0})}).catch(()=>{})},T8=B?(E0,F0,d0)=>{if(N?.current)return;if(E0?.synthetic||F0?.synthetic)return;let U8=d0==="before"?`before ${F0.label}`:d0==="after"?`after ${F0.label}`:`into ${F0.label}`;A8(`Moved ${E0.label} ${U8}`),B(E0.id,F0.id,d0,{idIndex:E0.index,refIndex:F0.index})}:void 0,s8=()=>{let E0=[];return function F0(d0,U8,N8){(d0||[]).forEach((o8,O8)=>{if(E0.push({node:o8,depth:U8,parentNode:N8,siblings:d0,pos:O8}),o8.children&&o8.children.length&&!J8.has(`${o8.id}:${o8.index}`))F0(o8.children,U8+1,o8)})}(Y?.nodes,0,null),E0},E9=(E0)=>{if(E0.key!=="ArrowUp"&&E0.key!=="ArrowDown")return;if(!W8)return;let F0=s8(),d0=F0.findIndex((O8)=>O8.node.id===W8.id&&O8.node.index===W8.index);if(d0<0)return;let U8=E0.key==="ArrowDown"?1:-1,N8=F0[d0];if(!E0.altKey){let O8=F0[d0+U8];if(O8)E0.preventDefault(),U?.(O8.node);return}if(!T8||!Array.isArray(N8.siblings))return;E0.preventDefault();let o8=(O8)=>O8&&O8.children&&O8.children.length&&!J8.has(`${O8.id}:${O8.index}`);if(!E0.shiftKey){if(U8<0&&N8.pos>0)T8(N8.node,N8.siblings[N8.pos-1],"before");else if(U8>0&&N8.pos<N8.siblings.length-1)T8(N8.node,N8.siblings[N8.pos+1],"after");return}if(U8>0){let O8=N8.siblings[N8.pos+1];if(O8)T8(N8.node,O8,o8(O8)?"inside-start":"after");else if(N8.parentNode)T8(N8.node,N8.parentNode,"after")}else{let O8=N8.siblings[N8.pos-1];if(O8)T8(N8.node,O8,o8(O8)?"inside-end":"before");else if(N8.parentNode)T8(N8.node,N8.parentNode,"before")}},u0=u.useRef(null),c0=u.useRef(null),j0=(E0,F0,d0)=>{if(!T8||E0.button!==0||E0.metaKey||E0.ctrlKey||E0.shiftKey||E0.altKey)return;if(N?.current)return;let{clientX:U8,clientY:N8}=E0,o8=new Set([d0]);(function u8(z7){(z7.children||[]).forEach((K7)=>{o8.add(`${K7.id}:${K7.index}`),u8(K7)})})(F0);let O8=14,N9=6,Y9=[];(function u8(z7,K7){(z7||[]).forEach((E7)=>{let R9=`${E7.id}:${E7.index}`;if(Y9.push({node:E7,key:R9,id:E7.id,depth:K7,tag:E7.tag}),E7.children&&E7.children.length&&!J8.has(R9))u8(E7.children,K7+1)})})(Y?.nodes,0);let t7=new Map(Y9.map((u8)=>[u8.key,u8])),P0=!1,h8=(u8)=>{if(!P0){if(Math.hypot(u8.clientX-U8,u8.clientY-N8)<4)return;P0=!0}let z7=u8.clientX-U8,K7=u8.clientY-N8,E7=null,R9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((e)=>({rect:e.getBoundingClientRect(),it:t7.get(e.getAttribute("data-layer-key"))})).filter((e)=>e.it&&e.it.key!==d0);if(R9.length){let e=R9[0].rect.left,A0=R9[0].rect.right,B0=R9.length;for(let L7=0;L7<R9.length;L7++)if(u8.clientY<R9[L7].rect.top+R9[L7].rect.height/2){B0=L7;break}let S0=R9[B0-1]?.it||null,s0=R9[B0]?.it||null,y8=Math.round((u8.clientX-e-N9)/O8),x8=S0?S0.depth+(YB0.has(S0.tag)?0:1):0,t8=s0?s0.depth:0,G9=Math.max(t8,Math.min(y8,x8)),A9=null,F7="before",x9=0;if(!S0){if(s0)A9=s0,F7="before",x9=s0.depth}else if(G9>S0.depth)A9=S0,F7="inside-start",x9=S0.depth+1;else if(G9===S0.depth)A9=S0,F7="after",x9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(R9[L7].it.depth===G9){A9=R9[L7].it;break}if(!A9)A9=S0;F7="after",x9=G9}if(A9&&A9.key!==d0&&!o8.has(A9.key)){let L7=S0?R9[B0-1].rect.bottom:R9[0].rect.top,mX=e+N9+x9*O8;E7={refId:A9.id,position:F7,node:A9.node,y:L7,left:mX,w:Math.max(24,A0-mX)}}}let S6={key:d0,node:F0,dx:z7,dy:K7,target:E7};u0.current=S6,H8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",g7),window.removeEventListener("keydown",d6,!0)},S9=()=>{let u8=(z7)=>{z7.preventDefault(),z7.stopImmediatePropagation(),document.removeEventListener("click",u8,!0)};document.addEventListener("click",u8,!0),setTimeout(()=>document.removeEventListener("click",u8,!0),300)},g7=()=>{F9();let u8=u0.current;if(u0.current=null,H8(null),P0&&u8?.target)S9(),T8(u8.node,u8.target.node,u8.target.position)},d6=(u8)=>{if(u8.key!=="Escape")return;if(u8.preventDefault(),u8.stopImmediatePropagation(),F9(),u0.current=null,H8(null),P0)S9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",g7),window.addEventListener("keydown",d6,!0)},I0=(E0)=>o0((F0)=>{let d0=new Set(F0);if(d0.has(E0))d0.delete(E0);else d0.add(E0);return d0}),P8=(E0)=>{let F0=`${E0.id}:${E0.index}`,d0=O0(E0),U8=!d0;if(w0((N8)=>new Map(N8).set(F0,U8)),D?.({id:E0.id,artboardId:Y?.artboardId??null,index:E0.index,prop:"display",value:U8?"none":null}),!K||!E0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(U8?{canvas:K,id:E0.id,property:"display",value:"none"}:{canvas:K,id:E0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:E0.id,key:"display",before:d0?"none":null,after:U8?"none":null})},W8=Array.isArray(J)?J[0]:J,K0=h?{asset:h.asset,kind:"annotation-image"}:(()=>{let E0=KB0(W8);return E0?{asset:E0,kind:"artboard-img"}:null})(),v0=K0?.kind==="annotation-image",B8=(E0)=>{if(!(E0.metaKey||E0.ctrlKey)||E0.altKey)return;let F0=E0.key.toLowerCase();if(F0==="z")E0.preventDefault(),s?.(E0.shiftKey?"redo":"undo");else if(F0==="y")E0.preventDefault(),s?.("redo")},c8=v0?"photo":U0==="photo"&&!K0?"inspect":U0,I8=(E0,F0,d0)=>M("button",{type:"button",className:"st-rp-tab"+(c8===E0?" is-active":""),onClick:()=>l0(E0),children:[z(w9,{name:d0,size:14}),F0]}),V8=W8?.bounds||null;return M("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[M("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[v0?I8("photo","Photo","image"):M(G0,{children:[I8("inspect","Inspect","sliders"),!Z0&&I8("layers","Layers","layers"),I8("css","CSS","code"),K0?I8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(w9,{name:"x",size:14})})]}),W8?.id&&!(Array.isArray(J)&&J.length>1)&&y?M("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(W8.id,W8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:c8==="photo"&&K0?z("div",{onKeyDown:B8,children:z(Hx,{asset:K0.asset,ColorPicker:I00,StIcon:w9,onEdit:(E0)=>p?.(K0.asset,E0),onRemoveBackground:f,onRecordEdit:(E0,F0)=>n?.(K0.asset,E0,F0)},`${K0.asset}:${m??0}`)}):!W8&&!(c8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:M("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):W8&&c8==="inspect"?M(G0,{children:[z("div",{className:"st-rp-hd",children:W8.selector||W8.tag||"element"}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:V8?Math.round(V8.x):"—",readOnly:!0,"aria-label":"x position"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:V8?Math.round(V8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:V8?Math.round(V8.w):"—",readOnly:!0,"aria-label":"width"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:V8?Math.round(V8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:W8.tag||"—"})})]}),W8.classes?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:W8.classes})})]}):null,z(WB0,{el:W8})]}):c8==="layers"?M(G0,{children:[M("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?M(G0,{children:[T8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:c0,onKeyDown:E9,children:Y.nodes.map((E0,F0)=>z(k00,{node:E0,depth:0,selectedId:W8?.id,selectedIndex:W8?.index,collapsed:J8,hiddenOverride:L8,onToggle:I0,onSelect:(d0)=>{U?.(d0),c0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:P8,onReorder:T8,onRowPointerDown:j0,dragState:Z8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:K8},`${E0.id}:${E0.index}`))}),Z8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:Z8.target.left,top:Z8.target.y-1,width:Z8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:r8})]}):W8&&Array.isArray(W8.dom_path)&&W8.dom_path.length?W8.dom_path.map((E0,F0)=>M("div",{className:"st-layer"+(F0===W8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+F0*12},children:[z(w9,{name:"square",size:13}),E0]},F0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!W8.id&&C00(W8)?z(HB0,{el:W8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(t20,{el:W8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:X0,onSetMode:H0})})]})}function VB0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let a=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:a.signal}).then((D0)=>D0.ok?D0.json():null).then((D0)=>{if(D0?.ok)_(D0)}).catch(()=>{}),()=>a.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),O=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let a=F.current,W0=Array.isArray(a)?a[0]:a;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let D0=p8.current.get(j.file);if(!D0?.contentWindow)return;try{D0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let a of P.current)clearTimeout(a);P.current=[50,450,1200,2500,5000].map((a)=>setTimeout(()=>{let W0=F.current,D0=Array.isArray(W0)?W0[0]:W0;if(!D0||D0.artboardId!==j||D0.file!==b)return;let q0=p8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},a))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),v=u.useRef(!1),x=u.useRef(null),[d,o]=u.useState(null),[h,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((a)=>a.json()).then((a)=>{if(a?.ok&&a.map&&typeof a.map==="object")m(a.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[f,n]=u.useState(!1),[s,c]=u.useState(null),[Z0,X0]=u.useState(null),[H0,t]=u.useState(null),[N0,U0]=u.useState(null),[l0,J8]=u.useState(null),[o0,L8]=u.useState(!1),[w0,O0]=u.useState(!1),[Z8,H8]=u.useState(null),[r8,A8]=u.useState(""),[K8,T8]=u.useState(null),[s8,E9]=u.useState(null),u0=u.useRef(null),c0=J00("maude-sb-w",{min:200,max:420,def:252}),j0=J00("maude-rp-w",{min:260,max:480,def:304}),[I0,P8]=u.useState(null),W8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(a)=>{let W0=W8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")c0.setW(a.clientX-W0.left);else j0.setW(W0.right-a.clientX)},b=()=>P8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,c0.setW,j0.setW]);let K0=u.useCallback((j)=>{clearTimeout(u0.current),u0.current=setTimeout(()=>{E9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!s8)return;let j=setTimeout(()=>E9(null),15000);return()=>clearTimeout(j)},[s8]);let[v0,B8]=u.useState({designRel:".design",cloud:void 0}),c8=!!v0.cloud,I8=!v0.cloud&&!!H0?.credentialed,V8=c8||I8,E0=V8?0:N0?.files?.length||0,F0=u.useRef(V8);F0.current=V8;let d0=!!v0.readOnly,U8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");B8((a)=>({...a,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{U8()},[U8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(V8){U0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)U0(b)}).catch(()=>{}),()=>{j=!0}},[V8]);let[N8,o8]=u.useState({}),[O8,N9]=u.useState(null),[Y9,t7]=u.useState(!1),[P0,h8]=u.useState("open"),[F9,S9]=u.useState(sq0),[g7,d6]=u.useState(()=>{return dR(de,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(de,JSON.stringify(g7))}catch{}},[g7]);let[u8,z7]=u.useState(null),[K7,E7]=u.useState(()=>aZ(ce,!0)),[R9,S6]=u.useState(()=>aZ(pe,!1)),[e,A0]=u.useState(()=>dR(le,{})),[B0,S0]=u.useState(!1),[s0,y8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=kv(()=>y8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[x8,t8]=u.useState(!1),[G9,A9]=u.useState(!1),[F7,x9]=u.useState(!1),[L7,mX]=u.useState(!1),[uQ,pQ]=u.useState(!1),{report:ZQ}=PA(W9()),[HQ,I9]=u.useState(!1),[e7,lQ]=u.useState(!1),[D7,w6]=u.useState(null),[EX,O5]=u.useState(!1),[S7,KX]=u.useState(!1),[PX,b7]=u.useState(!1),[a4,Z6]=u.useState(!1),[k9,RX]=u.useState(()=>dR(re,RK)),[T9,p9]=u.useState(()=>{try{let j=localStorage.getItem(ae);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[c6,zQ]=u.useState(!1),[X6,jJ]=u.useState([]),[ZJ,TX]=u.useState(0),[_5,uX]=u.useState(!1),[A5,s4]=u.useState(!1),[i,Q0]=u.useState(!1),[L0,f0]=u.useState(1),[T0,G8]=u.useState(216),[Q8,V9]=u.useState(null),[a8,i6]=u.useState([]),[pX,b6]=u.useState([]),[w5,dQ]=u.useState([]),[E5,t4]=u.useState(0),P5=u.useRef(0);u.useEffect(()=>{P5.current=ZJ},[ZJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let y7=u.useMemo(()=>SA(X6,{artboardId:[o9,Q8],total:E5}),[X6,o9,Q8,E5]),w8=u.useRef(null);u.useEffect(()=>{w8.current=y7},[y7]);let b9=u.useMemo(()=>XK(X6,y7)?.fps||30,[X6,y7]),[y9,lX]=u.useState(null),[VX,lW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))m8("Timeline changed — reloaded, try again."),lW((a)=>a+1);else m8(`${j}: ${b||"failed"}`)},[]),[HJ,R5]=u.useState(!1),[$K,e4]=u.useState(!1),[SK,zJ]=u.useState(!1),dW=u.useRef(HJ);u.useEffect(()=>{if(dW.current=HJ,HJ){zJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[HJ]);let sZ=u.useCallback(()=>{if(!dW.current||document.hidden)zJ(!0),te("Claude finished","Your assistant turn is ready in Maude.")},[]),vJ=u.useRef(0),XY=u.useCallback(()=>{if(!dW.current||document.hidden){zJ(!0);let j=Date.now();if(j-vJ.current<nq0)return;vJ.current=j,te("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[T5,KQ]=u.useState("inspect"),[bK,JY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[yK,jK]=u.useState(0),[xJ,cW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),tZ=u.useRef(xJ);u.useEffect(()=>{tZ.current=xJ;try{localStorage.setItem("maude-auto-open-inspector",xJ?"1":"0")}catch{}},[xJ]);let eZ=u.useRef(!1);u.useEffect(()=>{eZ.current=PX||Y9||o0||w0||HJ},[PX,Y9,o0,w0,HJ]);let iW=u.useRef({open:{},side:RK});iW.current={open:{tree:K7,layers:a4,inspector:PX,comments:Y9,changes:o0,sync:w0,assistant:HJ},side:k9};let cQ=u.useCallback((j,b)=>{if(j==="tree")E7(b);else if(j==="layers")Z6(b);else if(j==="inspector")b7(b);else if(j==="comments")t7(b);else if(j==="changes")L8(b);else if(j==="sync")O0(b);else if(j==="assistant")R5(b)},[]),oW=u.useCallback((j)=>iW.current.side?.[j]||RK[j],[]),IX=u.useCallback((j)=>{let b=oW(j);cQ(j,!0);for(let a of rR)if(a.id!==j&&oW(a.id)===b)cQ(a.id,!1)},[cQ,oW]),I5=u.useCallback((j)=>{if(iW.current.open?.[j])cQ(j,!1);else IX(j)},[IX,cQ]),gJ=IX,H6=I5,iQ=u.useCallback((j)=>{if(!tZ.current)return;if(d0)return;if(!j||!j.id)return;if(eZ.current)return;gJ("inspector"),KQ("css")},[gJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=Ix(sR),QY=Vx({enabled:v0.cloud===null||v0.exportLane==="remote"}),[YY,nW]=u.useState(!1),[dX,XH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return bv().then((b)=>{if(!j)return;if(nW(!!b),!b&&!aZ(ue,!1))XH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let WY=u.useCallback(()=>{XH(!1);try{localStorage.setItem(ue,"1")}catch{}},[]),[fK,JH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return vv((b)=>JH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,QH]=u.useState(null),[k5,rW]=u.useState(()=>!aZ(me,!1)),C5=u.useCallback((j)=>{QH(Array.isArray(j)&&j.length?j:null)},[]),vK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)gJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)gJ("changes")}},aW=u.useCallback(()=>{rW(!1);try{localStorage.setItem(me,"1")}catch{}},[]),[BQ,YH]=u.useState(()=>aZ(ne,!0)),[WH,hK]=u.useState(!1),[mJ,GH]=u.useState(()=>aZ(ie,!1)),[j6,qX]=u.useState(()=>aZ(oe,!1)),[o6,sW]=u.useState(!1),[xK,uJ]=u.useState(!1),[oQ,NQ]=u.useState(0),[nQ,tW]=u.useState(null),[eW,GY]=u.useState(!1),rQ=u.useRef(null),ZY=u.useRef(null),p8=u.useRef(new Map),$8=u.useCallback((j)=>{let b=Z?p8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),aQ=u.useCallback((j,b)=>$8({dgn:"photo-preview",asset:j,edit:b}),[$8]),$5=u.useCallback((j,b,a)=>{hJ.current.undo.push({asset:j,before:b,after:a}),hJ.current.redo.length=0},[]),z0=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let a=b.pop();(j?hJ.current.undo:hJ.current.redo).push(a);let W0=(j?a.after:a.before)||{};return aQ(a.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(a.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),jK((D0)=>D0+1),!0},[aQ]),gK=u.useCallback(async(j)=>{$8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let a=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (ge(),xe)),D0=await W0(a),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":D0.type||"image/png"},body:D0}),$0=await q0.json().catch(()=>({}));if(q0.ok&&$0.path)return{maskAsset:$0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{$8({dgn:"photo-busy",asset:j,busy:!1})}},[$8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},a=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",a),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",a)}},[]);let J6=u.useRef({});J6.current={open:c6,comps:X6,frame:ZJ,total:E5,playing:_5,compId:y7,muted:i,loop:A5,sequences:a8,post:$8,canvas:Z};let S5=u.useRef({undo:[],redo:[]}),P7=u.useCallback((j,b,a)=>{if(typeof b!=="number")return;if(S5.current.undo.push({canvas:j,seq:b,label:a}),S5.current.redo=[],S5.current.undo.length>50)S5.current.undo.shift()},[]),m7=u.useCallback((j)=>{let b=S5.current,a=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,D0=J6.current.canvas,q0=-1;for(let l=a.length-1;l>=0;l--)if(a[l].canvas===D0){q0=l;break}if(q0<0){m8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let $0=a[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:$0.canvas,seq:$0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(a.splice(q0,1),l?.ok)W0.push($0),m8(`${j==="undo"?"Undid":"Redid"}: ${$0.label}`,!0);else m8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>m8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),u7=u.useCallback((j,b)=>{let a=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?a.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?a[b.index]:null)||null;if(typeof b==="string")return a.find((W0)=>W0.stableId===b)||null;return a[b]||null},[]),FQ=u.useCallback((j)=>{let b=J6.current.canvas;if(!b||b===n8)return;let a=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${a?`&artboardId=${encodeURIComponent(a)}`:""}`;fetch(W0).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let q0=u7(D0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:a,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)console.warn("[remove-clip]",D0.error||"failed"),y6("Remove refused",D0.error);else if(D0?.ok){if(m8("Clip removed.",!0),D0.seq!=null)P7(b,D0.seq,"remove clip");lX(null)}}).catch(()=>m8("Remove failed: network error"))},[u7,P7]),LQ=u.useCallback((j,b,a)=>{let W0=J6.current.canvas;if(!W0||W0===n8)return;let D0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${D0?`&artboardId=${encodeURIComponent(D0)}`:""}`;fetch(q0).then(($0)=>$0.json().catch(()=>({}))).then(($0)=>{let l=$0?.ok&&Array.isArray($0.clips)?$0.clips:[],_0=j?.transition?l.find((M0)=>M0.kind==="transition"&&M0.stableId===j.stableId)||null:u7($0,j);if(!_0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:D0,stableId:_0.stableId,contentHash:_0.contentHash,verb:b,...a})})}).then(($0)=>$0?$0.json():null).then(($0)=>{if($0&&!$0.ok)console.warn("[clip-edit]",b,$0.error||"failed"),y6(`${b} refused`,$0.error);else if($0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(m8(`Applied: ${l[b]||b}.`,!0),$0.seq!=null)P7(W0,$0.seq,l[b]||b)}}).catch(()=>m8(`${b} failed: network error`))},[u7,P7,y6]),[DQ,HY]=u.useState(null),cX=u.useCallback((j,b="")=>new Promise((a)=>{HY({title:j,value:b,resolve:a})}),[]),b5=u.useCallback((j)=>{HY((b)=>{return b?.resolve?.(j),null})},[]),zY=u.useCallback((j,b)=>{let a=J6.current.canvas;if(!a||a===n8||!b||!String(b).trim())return;R7({type:"comments-add",payload:{file:a,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),m8("Comment added.",!0)},[]);J6.current.selected=y9,J6.current.setSelected=lX,J6.current.removeClip=FQ,J6.current.clipVerb=LQ,J6.current.addComment=zY,J6.current.askText=cX,u.useEffect(()=>{let j=(b)=>{let a=J6.current;if(!a.open||!a.comps?.length)return;let W0=b.target,D0=W0?.tagName;if(D0==="INPUT"&&W0?.type!=="range")return;if(D0==="TEXTAREA"||D0==="SELECT"||W0?.isContentEditable)return;let q0=XK(a.comps,a.compId)?.fps||30,$0=Math.max(1,a.total),l=(M0)=>{let i0=Math.max(0,Math.min($0-1,Math.round(M0)));TX(i0),uX(!1),a.post({dgn:"timeline-seek",frame:i0,id:a.compId})},_0=()=>{let M0=new Set([0,$0-1]);for(let i0 of a.sequences||[]){M0.add(i0.from);for(let _8 of i0.keyframes||[])M0.add(_8.from),M0.add(_8.to)}return[...M0].filter((i0)=>i0>=0&&i0<$0).sort((i0,_8)=>i0-_8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),m7(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(a.selected!=null)b.preventDefault(),a.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&a.selected!=null){b.preventDefault(),a.removeClip?.({stableId:a.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let M0=a.selected!=null?{stableId:a.selected}:null;if(!M0){let i0=a.sequences||[],_8=i0.find((D8)=>D8.series&&a.frame>=D8.from&&a.frame<D8.from+D8.duration)||i0.find((D8)=>a.frame>=D8.from&&a.frame<D8.from+D8.duration);if(_8?.stableId)M0={stableId:_8.stableId}}if(M0)a.clipVerb?.(M0,"split",{atFrame:a.frame});else m8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),a.playing)uX(!1),a.post({dgn:"timeline-pause",id:a.compId});else uX(!0),a.post({dgn:"timeline-mute",muted:a.muted,id:a.compId}),a.post({dgn:"timeline-loop",loop:a.loop,id:a.compId}),a.post({dgn:"timeline-play",id:a.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(a.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(a.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l($0-1);else if(b.key==="."){b.preventDefault();let M0=_0().find((i0)=>i0>a.frame);if(M0!=null)l(M0)}else if(b.key===","){b.preventDefault();let M0=_0().reverse().find((i0)=>i0<a.frame);if(M0!=null)l(M0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{jJ([]),TX(0),uX(!1),lX(null),UX(null);let j=setTimeout(()=>$8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,$8]);let[r0,iX]=u.useState(""),[KY,n0]=u.useState([]),[sQ,a0]=u.useState([]);u.useEffect(()=>{if(!c6||X6.length===0||!Z||Z===n8){iX(""),n0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")iX(b.source)}).catch(()=>{}),()=>{j=!1}},[c6,X6,Z,VX]),u.useEffect(()=>{if(!c6||!Z||Z===n8||!r0){n0([]),a0([]);return}let j=!0,b=o9||void 0,a=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(a).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let D0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];n0(D0.filter((q0)=>q0.kind==="sequence")),a0(D0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[c6,Z,r0,o9,VX]),u.useEffect(()=>{if(!r0){i6([]),b6([]),dQ([]),t4(0);return}let j=Q8??B?.artboardId??null,a=(j&&X6.find((q0)=>q0.artboardId===j||q0.id===j)||X6[0])?.durationInFrames||0,W0=Jx(r0,a,j);UX(W0.artboardId??j??null);let D0=W0.sequences.map((q0,$0)=>{let l=KY[$0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});i6(D0),b6(W0.audio||[]),dQ(W0.transitions||[]),t4(W0.total)},[r0,KY,B,X6,Q8]);let UY=u.useCallback(()=>{YH((j)=>{let b=!j,a=Z?p8.current.get(Z):null;if(a&&a.contentWindow)try{a.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of p8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{GH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),XG=u.useCallback(()=>{sW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{sW(!1),BX({present:!1})},[BX]),eQ=u.useCallback(()=>{if(!Z||Z===n8)return;uJ((j)=>{let b=!j;return $8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,$8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let a=b&&typeof b.name==="string"?b.name.trim():"";if(a)tW(a)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===n8){NQ(0),uJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let a=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(a),uJ(b?.overlays?.print===!0),J4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),uJ(!1),J4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===n8||!Q8)return;let j=setTimeout(()=>{$8({dgn:"request-layers",artboardId:Q8})},250);return()=>clearTimeout(j)},[Z,Q8,$8]);let[X4,J4]=u.useState(()=>new Set),JG=u.useCallback((j)=>{if(!Z||Z===n8)return;J4((b)=>{let a=new Set(b);if(a.has(j))a.delete(j);else a.add(j);let W0=[...a];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),$8({dgn:"locked-set",locked:W0}),a})},[Z,$8]);u.useEffect(()=>{if(!Z||Z===n8)return;$8({dgn:"locked-set",locked:[...X4]})},[X4,Z,$8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(_00,F9)}catch{}for(let j of p8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(ce,K7?"1":"0")}catch{}},[K7]),u.useEffect(()=>{try{localStorage.setItem(pe,R9?"1":"0")}catch{}},[R9]),u.useEffect(()=>{try{localStorage.setItem(le,JSON.stringify(e))}catch{}},[e]),u.useEffect(()=>{try{localStorage.setItem(ie,mJ?"1":"0")}catch{}},[mJ]),u.useEffect(()=>{try{localStorage.setItem(oe,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(ne,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")S9(b.theme);if(typeof b.minimap==="boolean")GH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")YH(b.annotations);if(typeof b.autoOpenInspector==="boolean")cW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...RK,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")p9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)hK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!WH)return;rq0({theme:F9,minimap:mJ,zoom:j6,annotations:BQ,autoOpenInspector:xJ,panelSides:k9,layersMode:T9})},[WH,F9,mJ,j6,BQ,xJ,k9,T9]),u.useEffect(()=>{try{localStorage.setItem(re,JSON.stringify(k9))}catch{}},[k9]),u.useEffect(()=>{try{localStorage.setItem(ae,T9)}catch{}},[T9]);let QG=u.useCallback((j,b)=>{A0((a)=>{let W0=a[j],D0=W0===void 0?b:W0;return{...a,[j]:!D0}})},[]),Q4=u.useCallback(()=>{S9((j)=>j==="dark"?"light":"dark")},[]),G7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let a=b.groups.map((W0)=>({...W0,tree:Q20(W0.paths,W0.stripPrefix,W0.dirs)}));J(a),B8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{G7()},[G7]);let pJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",a=await fetch(b);if(!a.ok){console.error("failed to load system-data",a.status);return}let W0=await a.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){T8(W0);let D0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(D0.ok)T8(await D0.json());return}T8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();o8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let a=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(a+"//"+location.host+"/_ws");ZY.current=W0,W0.addEventListener("open",()=>{n(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{n(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(D0)=>{try{let q0=JSON.parse(D0.data);if(q0.type==="snapshot"&&q0.state)N(($0)=>L00(q0.state.selected,$0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let $0=q0.selected,l=Array.isArray($0)?$0[0]:$0,_0=F.current,M0=Array.isArray(_0)?_0[0]:_0;if(N((i0)=>L00($0,i0)),l?.id&&l.file&&(!M0||M0.id!==l.id||M0.file!==l.file))O(l)}else if(q0.type==="comments"&&typeof q0.file==="string")o8(($0)=>({...$0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(GY(!0),rQ.current)clearTimeout(rQ.current);rQ.current=setTimeout(()=>GY(!1),8000);for(let $0 of p8.current.values())try{$0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)QY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)X0(q0.payload);else if(q0.type==="canvas-list-update"){if(G7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let $0=(v0?.designRel||v0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${$0}/${q0.payload.fromRel}`,_0=`${$0}/${q0.payload.rel}`;G((M0)=>M0.map((i0)=>i0.path===l?{path:_0}:i0)),H((M0)=>M0===l?_0:M0)}}else if(q0.type==="config-updated")U8();else if(q0.type==="acp-focus"){if(W9())gJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!F0.current)U0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let $0 of p8.current.values())try{$0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),ZY.current)ZY.current.close()}},[G7,U8]);function R7(j){let b=ZY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(F0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)U0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(F0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)J8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let a=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await a.json().catch(()=>({}));return{ok:a.ok,...W0}}catch(a){return{ok:!1,error:"Network error — is the project still open?"}}},[]),YG=u.useCallback(async(j,b)=>{let a=await FX("/_api/git/commit",{message:j,files:b});if(a.ok)await NX();return a},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),WG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)H8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),GG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),a=await fetch(b);if(!a.ok)return[];return(await a.json()).entries||[]}catch{return[]}},[]),[ZG,HG]=u.useState(null),zG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),a=await fetch(b);if(!a.ok)return null;let W0=await a.json();if(!W0?.ok)return null;return HG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),KG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(V8)return b;for(let a of N0?.files||[])b.set(a.path,j[a.status]);return b},[N0,V8]);u.useEffect(()=>{if(V8){J8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[V8,N0?.repo,o0,kX]);let z6=u.useCallback((j)=>{if(G((b)=>{for(let a of b)if(a.path!==j)p8.current.delete(a.path);return[{path:j}]}),H(j),N9(null),U(null),j!==n8)E9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!v0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let a of b.paths||[]){if(!GQ.test(a))continue;if(/(^|\/)system\//.test(a))continue;j=a;break}if(j)break}if(!j)return;DY.current=!0,z6(j)},[v0.cloud,X,W.length,z6]);let lJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)pJ(b);else if(!K8)pJ();z6(n8)},[K8,pJ,z6]);u.useEffect(()=>{R7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==n8)})},[W]),u.useEffect(()=>{if(Z&&Z!==n8)R7({type:"active",file:Z});else if(Z===n8)R7({type:"active",file:""});else R7({type:"active",file:""})},[Z]);let Y4=u.useCallback((j)=>{G((b)=>{let a=b.findIndex((D0)=>D0.path===j);if(a<0)return b;let W0=b.filter((D0)=>D0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,a-1)].path);return W0}),p8.current.delete(j),E9((b)=>b===j?null:b)},[Z]),KJ=u.useCallback(()=>{if(!Z||Z===n8){if(Z===n8)pJ();return}let j=p8.current.get(Z);if(j)j.src=j.src},[Z,pJ]),MY=u.useCallback(()=>G7(),[G7]),[UG,OY]=u.useState(!1),W4=u.useRef(!1),G4=u.useCallback(async()=>{if(W4.current)return;W4.current=!0,OY(!0);try{await Promise.all([G7(),new Promise((j)=>setTimeout(j,550))])}finally{W4.current=!1,OY(!1)}},[G7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,MY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[MY]);let VG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),a=await b.json().catch(()=>({}));if(!b.ok||!a.ok)return{ok:!1,error:a.error||`create failed (${b.status})`};return await G7(),z6(a.file),{ok:!0,file:a.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[G7,z6]),_Y=u.useCallback(async()=>{let j=await cX("New video name");if(!j)return;let a=(await cX("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=a?Number(a[1]):1920,D0=a?Number(a[2]):1080,q0=Math.max(1,Math.min(60,Number(await cX("Frames per second","30"))||30));try{let $0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:D0})}),l=await $0.json().catch(()=>({}));if(!$0.ok||!l.ok){m8(`New video failed: ${l.error||`error ${$0.status}`}`);return}await G7(),z6(l.file),zQ(!0),m8("New video created — drop clips on the timeline to start the cut.",!0)}catch($0){m8(`New video failed: ${$0 instanceof Error?$0.message:"network error"}`)}},[G7,z6,cX]),qG=u.useCallback(async()=>{if(!Z||Z===n8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",a=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let _0 of l.querySelectorAll('[data-tool="mediaref"]')){let M0=_0.getAttribute("data-src");if(!M0)continue;a.push({src:M0,mediaKind:_0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(a.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let D0=`${pW(kK(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D0,kind:"video-comp",clips:a})}),$0=await q0.json().catch(()=>({}));if(!q0.ok||!$0.ok){window.alert(`Assemble failed: ${$0.error||`error ${q0.status}`}`);return}await G7(),z6($0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,G7,z6]),Z4=u.useCallback(({accept:j,resolveTarget:b})=>{let a=Z,W0=o9||void 0,D0=document.createElement("input");D0.type="file",D0.accept=j,D0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(D0);let q0=()=>{if(D0.isConnected)D0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),D0.addEventListener("change",()=>{let $0=D0.files?.[0];if(q0(),!$0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(a)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let M0=b(_0);if(!M0)return m8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":$0.type||"application/octet-stream"},body:$0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return m8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(M0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:a,arrayName:M0.arrayRef.arrayName,index:M0.arrayRef.index,field:M0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:a,id:M0.cdId,attr:"src",value:i0.path})})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)m8(`Replace refused: ${_0.error||"failed"}`);else if(_0&&_0.ok){if(m8("Media replaced.",!0),_0.seq!=null)P7(a,_0.seq,"replace media")}}).catch(()=>m8("Replace failed: network error"))}),D0.click()},[Z,o9,P7]),BG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5653
|
+
`).length," lines, paths & secrets scrubbed) —"," ",M("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),M("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),M("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&M(G0,{children:[P?.issueUrl?M("p",{children:["Thank you — your report is filed as"," ",M("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())cU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):M("p",{children:["The bundle is saved locally",P?.fallbackDir?M(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Done"})})]}),Y==="fallback"&&M(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Save locally & open GitHub"})]})]})]})]})})}var WJ=v8(i8(),1);function Ex(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function Px(X,J){let Q=Ex(X),Y=Ex(J);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function Rx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Px(Q.version,J)))}function Tx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Px(Y.version,Q))Q=Y.version}return Q}var Yw="mdcc-whatsnew-seen",Ww="mdcc-whatsnew-toast-dismissed";function hz0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function xz0(X){try{let J=localStorage.getItem(Yw);if(J)return J;localStorage.setItem(Yw,X)}catch{}return X}function gz0(){try{return localStorage.getItem(Ww)}catch{return null}}function Ix(X){let[J,Q]=WJ.useState([]),[Y,W]=WJ.useState(X),[G,Z]=WJ.useState(()=>xz0(X)),[H,K]=WJ.useState(()=>gz0()),[U,q]=WJ.useState(!1);WJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=Rx(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=WJ.useCallback(()=>{let O=Tx(J,Y);Z(O),K(Y);try{localStorage.setItem(Yw,O),localStorage.setItem(Ww,Y)}catch{}},[J,Y]),_=WJ.useCallback(()=>{K(Y);try{localStorage.setItem(Ww,Y)}catch{}},[Y]),R=WJ.useCallback(()=>q(!0),[]),w=WJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function kx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return M("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),M("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),M("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Cx({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(WJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:M("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>M("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[M("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),hz0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var W7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),me="mdcc-usage-tour-seen",ue="mdcc-collab-tour-seen",n8="__system__",_00="mdcc-theme",pe="mdcc-show-hidden",le="mdcc-sections-expanded",de="maude-cp-mode",ce="mdcc-sidebar-open",ie="mdcc-minimap-visible",oe="mdcc-zoomctl-visible",ne="mdcc-annotations-visible";var nq0=30000;function rq0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var rR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],RK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},re="mdcc-panel-sides",ae="mdcc-layers-mode";function se({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return M("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(rR.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,aq0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function aR(X){for(let[J,Q]of aq0)if(J.test(X))return Q;return null}function _F(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var sR="1.0.6";function te(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){$7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function sq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(_00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function aZ(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function dR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function tq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function kK(X){return X.split("/").pop()}function m8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(m8._t),m8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var ee="maude-mode-hint-seen";function eq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(ee)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select & inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(ee,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function X20(X){return X.replace(GQ,"")}function J20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=X20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function Q20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function A00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=A00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function MF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Y20(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(X).toLocaleDateString()}function w00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function AF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var W20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:M(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":M(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:M(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:M(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:M(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:M(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:M(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:M(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:M(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:M(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:M(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:M(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:M(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:M(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:M(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:M(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:M(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:M(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":M(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":M(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":M(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":M(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":M(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":M(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:M(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:M(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:M(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:M(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:M(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:M(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:M(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:M(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:M(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function G20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:M("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[M("div",{className:"st-pal-search",children:[z(w9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return M(G0,{children:[N,M("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(w9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function w9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:W20[X]})}function Z20(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function X00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function J00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function Q00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:M("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var cR=[{id:"png",label:"PNG",sub:"raster · 2×",icon:"image",format:"png",options:{scale:2}},{id:"pdf",label:"PDF",sub:"vector · print",icon:"file",format:"pdf"},{id:"svg",label:"SVG",sub:"per artboard",icon:"vector",format:"svg"},{id:"html",label:"HTML",sub:"self-contained",icon:"code",format:"html"},{id:"pptx",label:"PPTX",sub:"slides",icon:"presentation",format:"pptx"},{id:"mp4",label:"MP4",sub:"video · H.264",icon:"presentation",format:"mp4",temporal:!0},{id:"gif",label:"GIF",sub:"animated",icon:"image",format:"gif",temporal:!0},{id:"canva",label:"Canva",sub:"handoff bundle",icon:"external",format:"canva"},{id:"zip",label:"ZIP",sub:"project bundle",icon:"archive",format:"zip"},{id:"shadcn",label:"AI handoff",sub:"production drop",icon:"sparkle",handoff:!0}],iR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},H20={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},z20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],S3=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],K20="2x",Y00=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],U20="auto",V20={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",m4v:"video/mp4",ogg:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",oga:"audio/ogg",opus:"audio/opus"};function q20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return V20[J]||"application/octet-stream"}function B20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let h=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!h)return;let p=m.ok?m.assets:[];H(p),_((f)=>{let n={...f};for(let s of p)n[s.path]=s.kind;return n})}).catch(()=>h&&H([])),()=>{h=!1}},[]),u.useEffect(()=>{let h=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[Q]);let O=Array.from(N).some((h)=>(D[h]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(h)=>{F((m)=>{let p=new Set(m);if(p.has(h))p.delete(h);else p.add(h);return p})},$=async(h)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":h.type||"application/octet-stream"},body:h}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(h)=>{if(!h)return;U(!0),B(null);let m=await $(h);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(h)=>{if(typeof h==="string"&&h.startsWith("video/"))return"video";if(typeof h==="string"&&h.startsWith("audio/"))return"audio";return"image"},v=async(h)=>{if(!h.length)return;U(!0),B(null);let m=await Promise.all(h.map((n)=>$(n).then((s)=>({...s,file:n}))));U(!1);let p=m.filter((n)=>n.ok),f=m.length-p.length;if(f>0)B(`${f} of ${m.length} uploads failed`);if(p.length)_((n)=>{let s={...n};for(let c of p)s[c.path]=y(c.file.type);return s}),F((n)=>{let s=new Set(n);for(let c of p)s.add(c.path);return s})},x=async()=>{U(!0),B(null);try{if(Y){let p=(await fv()||[]).map((f)=>new File([new Uint8Array(f.bytes)],f.name,{type:q20(f.name)}));if(U(!1),p.length)await v(p);return}let h=await NZ();if(h?.bytes){await C(new Blob([new Uint8Array(h.bytes)]));return}}catch(h){B(h?.message||"open failed")}U(!1)},d=()=>{if(W9()){x();return}let h=document.createElement("input");if(h.type="file",h.accept="image/*,video/*",Y)h.multiple=!0;h.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(h);let m=()=>{if(h.isConnected)h.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),h.addEventListener("change",()=>{let p=h.files?Array.from(h.files):[];if(m(),!p.length)return;if(Y)v(p);else C(p[0])}),h.click()},o=(h)=>`/${X}/${h}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)Q()},children:M("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[M("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(w9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[M("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((h)=>{let m=Y&&N.has(h.path);return M("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${h.name} · ${Math.max(1,Math.round(h.size/1024))} KB`,onClick:()=>Y?k(h.path):J(h.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(w9,{name:"check",size:12}):null}),h.kind==="video"?z("video",{className:"st-ap-thumb",src:o(h.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(h.path),alt:h.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:h.name})]},h.path)})})]}),Y&&N.size>0&&M("div",{className:"st-dialog-ft st-ap-confirm",children:[M("span",{className:"st-ap-count",children:[N.size," selected"]}),M("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function N20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onClose:K}){let U=u.useCallback((O0)=>H==="none"&&!O0.handoff&&O0.format!=="zip"||H!=="local"&&O0.format==="canva",[H]),[q,B]=u.useState(X==="handoff"?"shadcn":H==="none"?"zip":"png"),[N,F]=u.useState(J&&iR[J]?J:"artboard"),[D,_]=u.useState(2),[R,w]=u.useState(K20),[O,P]=u.useState(!0),[I,k]=u.useState(!1),[$,C]=u.useState(!1),[y,v]=u.useState(!1),[x,d]=u.useState(U20),[o,h]=u.useState(!0),[m,p]=u.useState(!1),[f,n]=u.useState(null),[s,c]=u.useState([]),Z0=cR.find((O0)=>O0.id===q)||cR[0],X0=Z0.handoff?[]:H20[Z0.format]||["artboard"],H0=900,t=3600,N0=XK(W,SA(W,{artboardId:G})),U0=N0?.durationInFrames||0,l0=N0?.fps||30,J8=Z0.temporal&&U0>900,o0=Z0.temporal&&U0>3600;u.useEffect(()=>{if(X0.length&&!X0.includes(N))F(X0[0])},[X0,N]);let L8=u.useCallback(()=>{fetch("/_api/export-history").then((O0)=>O0.json()).then((O0)=>c(Array.isArray(O0?.history)?O0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{L8()},[L8]),u.useEffect(()=>{function O0(Z8){if(Z8.key==="Escape")Z8.preventDefault(),K()}return window.addEventListener("keydown",O0),()=>window.removeEventListener("keydown",O0)},[K]);async function w0(){if(Z0.handoff){let H8=`/design:handoff ${Q&&Q!==n8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(H8)}catch{}n({ok:!0,msg:`Copied: ${H8} — run it in Claude Code.`});return}if(U(Z0)){n({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}p(!0),n(null);let O0=Z0.temporal?{scale:D}:{};if(Z0.format==="png"){let Z8=S3.find((H8)=>H8.id===R)||S3[1];if(Z8.kind==="dpi")O0.dpi=Z8.value;else O0.scale=Z8.value}if(Z0.format==="mp4"||Z0.format==="webm")O0.audio=o;if(o0)O0.maxFrames=U0;if(Z0.format==="pdf"){O0.pdfPrint={includeBleed:O,marks:{crop:$,registration:y}};let Z8=Y00.find((H8)=>H8.id===x)?.value;if(Z8!==void 0)O0.dpi=Z8}if(G)O0.artboardId=G;if(Z?.selector)O0.selection=Z;try{let Z8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:Z0.format,scope:N,options:O0})});if(!Z8.ok){n({ok:!1,msg:await Z8.text()||`Export failed (${Z8.status})`}),p(!1);return}K()}catch(Z8){n({ok:!1,msg:Z8&&Z8.message?Z8.message:String(Z8)}),p(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(O0)=>{if(O0.target===O0.currentTarget)K()},children:M("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[M("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:K,children:z(w9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==n8?`Format · ${pW(kK(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:cR.filter((O0)=>!O0.temporal||Y).map((O0)=>M("button",{type:"button",className:"st-fmt"+(O0.id===q?" is-on":""),disabled:U(O0),title:U(O0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{B(O0.id),n(null)},children:[z(w9,{name:O0.icon,size:16}),z("span",{className:"st-fmt-name",children:O0.label}),z("span",{className:"st-fmt-sub",children:O0.sub})]},O0.id))}),H==="none"&&M("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["Rendered exports (PNG, PDF, video…) need the render service, which this workspace doesn't have configured. ZIP and AI handoff still work here — for everything else use the desktop app, or ask your admin to add the",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!Z0.handoff&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:N,onChange:(O0)=>F(O0.target.value),children:X0.map((O0)=>z("option",{value:O0,children:iR[O0]},O0))})]}),!Z0.handoff&&Z0.format==="png"&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:R,onChange:(O0)=>w(O0.target.value),children:S3.map((O0)=>z("option",{value:O0.id,children:O0.label},O0.id))})]}),!Z0.handoff&&Z0.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let O0=S3.find((H8)=>H8.id===R)||S3[1],Z8=O0.kind==="dpi"?O0.value/96:O0.value;return`${O0.label} ≈ ${Math.round(1440*Z8)}×${Math.round(900*Z8)} for a 1440×900 artboard.`})()}),!Z0.handoff&&Z0.temporal&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:D,onChange:(O0)=>_(Number(O0.target.value)),children:z20.map((O0)=>z("option",{value:O0.value,children:O0.label},O0.value))})]}),!Z0.handoff&&Z0.temporal&&M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[D,"× the artboard's native resolution (e.g. 960×540 → ",960*D,"×",540*D,")."]}),J8&&M("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",U0," frames (≈",Math.round(U0/l0),"s).",o0?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!Z0.handoff&&Z0.format==="pdf"&&M(G0,{children:[M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:x,onChange:(O0)=>d(O0.target.value),children:Y00.map((O0)=>z("option",{value:O0.id,children:O0.label},O0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:M("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:O,onChange:(O0)=>P(O0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:M("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>k((O0)=>!O0),"aria-expanded":I,children:[I?"▾":"▸"," Marks"]})}),I&&M("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:$,onChange:(O0)=>C(O0.target.checked)}),"Crop marks"]}),M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:y,onChange:(O0)=>v(O0.target.checked)}),"Registration marks"]})]}),M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",N==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!Z0.handoff&&(Z0.format==="mp4"||Z0.format==="webm")&&z("div",{className:"st-dialog-row",children:M("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:o,onChange:(O0)=>h(O0.target.checked)}),"Export with audio"]})}),Z0.handoff&&M("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),f&&z("div",{className:"callout "+(f.ok?"callout--success":"callout--error"),style:{fontSize:12},children:f.msg}),s.length>0&&M("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((O0,Z8)=>M("div",{className:"st-export-recent-row",children:[M("span",{children:[String(O0.format||"").toUpperCase()," ·"," ",iR[O0.scope]||O0.scope]}),z("span",{className:"st-mono",children:O0.filename})]},Z8))]})]}),M("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:K,children:"Cancel"}),M("button",{type:"button",className:"btn btn--primary",disabled:m,onClick:w0,children:[z(w9,{name:"download",size:14}),Z0.handoff?"Copy handoff command":m?"Exporting…":`Export ${Z0.label}`]})]})]})})}var PF=12,RF=16;function F20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=M("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${_F(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:PF+J*RF+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return M(G0,{children:[Z?M("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_F(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):D,H&&Y]})}function L20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return M(G0,{children:[M("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:PF+Q*RF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(w9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),M("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function wF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?aR(X.name):null,w=!_&&!R,O=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",v=X.path.split("/").slice(0,-1).join("/"),x=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=M("button",{type:"button",role:"treeitem","data-testid":x,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:PF+H*RF+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(w9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return M("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${_F(X.path)}`,title:`Move ${O}…`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(o)=>{o.stopPropagation(),G(X.path,O)},children:z(AF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function D20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[O,P]=u.useState(!1),I=B||O,k=X.path===W;if(!(w&&q))return z(wF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},v=D?.draggedPath===X.path,x=D?.busyPath===X.path,d=C&&typeof _<"u",o=X.path.split("/").slice(0,-1).join("/"),h=M("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":x||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(v?" is-dragging":"")+(x?" is-busy":""),style:{paddingLeft:PF+Q*RF+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(w9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return M(G0,{children:[d?M("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_F(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}),children:z(AF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,I&&J.map((m)=>z(wF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function E00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:O}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>J20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],o=[];for(let h of $){let m=aR(h.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:o).push(h)}return{mediaOrphans:d,metaOrphans:o}},[$]),v=!!(U&&U.trim()),x=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let o of q)d.set(o.folder,o);return d},[q,Z]);return M(G0,{children:[k.map((d)=>{let o=v&&d.sidecars.some((h)=>{let m=U.toLowerCase();return h.name.toLowerCase().includes(m)||h.path.toLowerCase().includes(m)});return z(D20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:MF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:o,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(wF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:MF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(wF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:MF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let o=x?.get(d),h=R?`${R}/${d}`:d,m=z(E00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:h,drag:w,menu:O});if(o&&N)return z(L20,{name:d,dsName:o.name,depth:Z,defaultOpen:!0,active:J===n8&&o.name===B,onOpenSystem:N,children:m},d);return z(F20,{name:d,depth:Z,defaultOpen:!0,dirPath:h,drag:w,menu:O,children:m},d)})]})}var LF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function M20(X){if(X.kind==="project")return LF.project;if(X.kind==="runtime")return LF.runtime;if(X.label==="Design system")return LF.ds;if(X.label==="UI kit")return LF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function O20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:O,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:v,gitBranch:x,remoteSync:d,onGetLatest:o,canvasKinds:h,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:f,syncStatus:n,onLinkedHub:s,savingIsManaged:c=!1}){let Z0=u.useMemo(()=>{if(!q)return Q;return Q.map((c0)=>({...c0,tree:A00(c0.tree,q),filtered:!!q}))},[Q,q]),X0=BS(m),H0=VS(),t=u.useMemo(()=>{let c0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;c0.push({path:j0.fullPath,label:I0});for(let P8 of j0.dirs||[])c0.push({path:P8,label:P8.replace(/^\.[^/]+\//,"")})}return c0},[Q]),N0=H0.state?.extra,U0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>H0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{H0.close();let c0=window.prompt("New folder name:");if(c0?.trim())p(N0.dirPath,c0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{H0.close(),f(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],l0=N0?.kind==="file"?t.filter((c0)=>c0.path!==N0.dir):[],[J8,o0]=u.useState(!1),[L8,w0]=u.useState("board"),[O0,Z8]=u.useState(""),[H8,r8]=u.useState(""),[A8,K8]=u.useState(!1),T8=u.useMemo(()=>Q.find((c0)=>c0.kind==="canvas"&&c0.label!=="Design system")?.fullPath,[Q]),s8=u.useCallback(async()=>{let c0=O0.trim();if(!c0||A8)return;if(K8(!0),r8(""),L8==="folder"){if(!T8){K8(!1),r8("no canvas group to create a folder in");return}let I0=await p(T8,c0);if(K8(!1),I0?.ok)o0(!1),Z8("");else r8(I0?.error||"could not create folder");return}let j0=await R(c0);if(K8(!1),j0?.ok)o0(!1),Z8("");else r8(j0?.error||"could not create board")},[O0,A8,R,p,L8,T8]),E9=u.useMemo(()=>{let c0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))c0++;return c0},[Q]),u0=u.useMemo(()=>{let c0=0;for(let j0 of Z0)for(let I0 of j0.paths||[])if(GQ.test(I0))c0++;return c0},[Z0]);return M("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[M("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),M("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":J8&&L8==="board",onClick:()=>{r8(""),w0("board"),o0((c0)=>L8==="board"?!c0:!0)},children:z(w9,{name:"plus",size:15})}),!X&&T8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":J8&&L8==="folder",onClick:()=>{r8(""),w0("folder"),o0((c0)=>L8==="folder"?!c0:!0)},children:z(w9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>O(),children:z(w9,{name:"reload",size:15})}),M("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),u0," / ",E9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(w9,{name:"panel-left",size:15})})]})]}),J8?M("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:L8==="folder"?"folder name…":"brief board name…",value:O0,maxLength:60,disabled:A8,"aria-label":L8==="folder"?"New folder name":"New brief board name",onChange:(c0)=>Z8(c0.target.value),onKeyDown:(c0)=>{if(c0.key==="Enter")c0.preventDefault(),s8();else if(c0.key==="Escape")c0.preventDefault(),o0(!1),Z8(""),r8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A8||!O0.trim(),"data-tip":"Create · Enter","aria-label":L8==="folder"?"Create folder":"Create brief board",onClick:s8,children:A8?"…":"↵"})]}):null,H8?z("div",{className:"st-newboard-err",role:"alert",children:H8}):null,z("div",{className:"st-search",children:M("div",{className:"st-search-box",children:[z(w9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(c0)=>B(c0.target.value),onKeyDown:(c0)=>{if(c0.key==="Escape")if(c0.preventDefault(),q)B("");else c0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:Z0.map((c0)=>{if(!F&&!q&&c0.kind==="runtime")return null;let j0=M20(c0),I0=(c0.paths||[]).filter((d0)=>GQ.test(d0)).length,P8=j0.pill||(j0.pillFromDsCount?String(c0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||c0.paths?.length||0):null),W8=c0.tree&&Object.keys(c0.tree).length>0,K0=c0.label==="Design system",v0=c0.kind==="project";if(!F&&!q&&v0&&I0===0)return null;let B8=tq0(c0),c8=D[c0.label],I8=!!q||(c8===void 0?B8:c8),V8=!K0&&c0.kind==="canvas"&&!X,E0=V8?X0.dropProps(c0.fullPath,!0):{},F0=X0.overDir===c0.fullPath;return M("div",{className:"st-tree-section",children:[M("button",{type:"button",className:"st-tree-sec-hd"+(F0?" is-drop-target":""),onClick:()=>_(c0.label,B8),"aria-expanded":I8,"aria-dropeffect":V8?"move":void 0,title:I8?"Collapse section":"Expand section",...E0,children:[z(w9,{name:"chevron-right",className:"st-chev"+(I8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),P8&&z("span",{className:"st-pill",children:P8})]}),I8&&(W8?z(E00,{node:c0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:c0.kind,showHidden:F,search:q,dsFolders:c0.dsFolders,activeDsName:G,onOpenSystem:K0?K:void 0,onDelete:K0||X?void 0:w,dirtyByPath:y,canvasKinds:h,dirPath:c0.fullPath,drag:!K0&&c0.kind==="canvas"&&!X?X0:void 0,menu:!K0&&c0.kind==="canvas"&&!X?H0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},c0.label)})}),z(qS,{state:H0.state,onClose:H0.close,rootItems:U0,destinations:l0,onPickDestination:(c0)=>m(N0.path,c0)}),!c&&z(oA,{project:v,liveBranch:x,remoteSync:d,onGetLatest:o}),J===null?z(DA,{syncStatus:n,onLinkedHub:s}):null,z(OA,{})]})}function _20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:M("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(w9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(w9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(w9,{name:"folder",size:15})})]})})}function A20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),M("span",{className:"sku",children:["MAUDE-DEV-SRV / v",sR]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),M("div",{className:"help-modal-body",children:[M("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),M("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),M("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),M("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),M("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),M("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),M("details",{children:[z("summary",{children:"Annotation tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),M("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),M("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),M("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),M("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),M("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),M("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),M("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),M("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),M("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),M("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),M("details",{children:[z("summary",{children:"Canvas & panels"}),M("ul",{children:[M("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),M("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),M("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),M("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),M("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),M("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),M("details",{children:[z("summary",{children:"Slash commands"}),M("ul",{className:"cmds",children:[M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),M("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),M("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),M("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),M("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),M("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),M("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),M("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),M("details",{children:[z("summary",{children:"Opt-out scope"}),M("ul",{children:[M("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),M("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),M("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),M("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),M("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),M("details",{children:[z("summary",{children:"Auto-critic loop"}),M("ul",{children:[M("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),M("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),M("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),M("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),M("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),M("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),M("details",{children:[z("summary",{children:"Pin-to-element flow"}),M("ol",{children:[z("li",{children:"Open a canvas"}),M("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),M("li",{children:["Run"," ",M("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),M("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),M("details",{children:[z("summary",{children:"Comments"}),M("ol",{children:[M("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),M("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),M("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var oR=[{id:"canvas",label:"Canvas",items:[{label:"Command palette",kbd:"⌘ K"},{label:"New brief board",kbd:"N"},{label:"Export…",kbd:"⇧ ⌘ E"},{label:"Handoff to production",kbd:"⇧ ⌘ H"},{label:"Reload canvas",kbd:"⌘ R"},{label:"Search files",kbd:"/",alt:"⌘ F"}]},{id:"tools",label:"Tools · canvas focus",items:[{label:"Move · Hand · Comment",kbd:"V",alt:"H / C"},{label:"Pen · Highlighter · Eraser",kbd:"B",alt:"I / E"},{label:"Shape · Arrow",kbd:"R",alt:"A"},{label:"Sticky · Text · Section",kbd:"N",alt:"T / ⇧S"},{label:"Undo / redo",kbd:"⌘ Z",alt:"⇧ ⌘ Z"}]},{id:"selection",label:"Selection & zoom",items:[{label:"Select element",kbd:"⌘ click"},{label:"Add to selection",kbd:"⌘ ⇧ click"},{label:"Preview deepest",kbd:"⌘ hover"},{label:"Deselect · close menu",kbd:"Esc"},{label:"Zoom in / out",kbd:"⌘ +",alt:"⌘ −"},{label:"Fit · actual size",kbd:"⌘ 0",alt:"⌘ 1"}]},{id:"view",label:"View",items:[{label:"Project tree",kbd:"T"},{label:"Design system view",kbd:"S"},{label:"Inspector",kbd:"⌘ ⇧ I"},{label:"Comments sidebar",kbd:"⌘ ⇧ M"},{label:"Annotations",kbd:"⇧ P"},{label:"Hidden files",kbd:"H"},{label:"This cheat sheet · help",kbd:"?",alt:"F1"}]}];function w20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return M("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>M(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function E20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=oR.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[M("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),M("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:oR.map((Y)=>M("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>M("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(w20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),M("div",{className:"so-overlay-ft",children:[M("span",{children:["close with ",z(wX,{children:"Esc"})]}),M("span",{className:"so-count",children:[Q," bindings · ",oR.length," groups"]})]})]})})}var P20=["File","Edit","View","Selection","Tools","Help"];function P00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function R20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return P00(Q),M("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(w9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function CK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return P00(G),M("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function T20({onAction:X,onClose:J}){return z(CK,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function I20({onAction:X,onClose:J,readOnly:Q=!1}){return z(CK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function k20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(CK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function C20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(CK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function $20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(CK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(CK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function S20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:O,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:v,onToggleZoomCtl:x,presentMode:d,onTogglePresent:o,printGuidesVisible:h,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:f,onOpenReadiness:n,onOpenQuickSetup:s,onWatchIntro:c,whatsNewCount:Z0,exportCenter:X0,artboardCount:H0=0,presence:t=null,inspectorOpen:N0,inspectorTab:U0,onToggleInspector:l0,autoOpenInspector:J8,onToggleAutoOpenInspector:o0,onOpenLayers:L8,timelineOpen:w0,onToggleTimeline:O0,hasComps:Z8=!1,assistantOpen:H8,onToggleAssistant:r8,assistantBusy:A8,assistantUnseen:K8,onNewCanvas:T8,onAssembleVideo:s8,onOpenExport:E9,onOpenSettings:u0,onOpenGenerate:c0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:P8,readOnly:W8=!1}){let K0=X===n8,v0=K0?"SYSTEM":X?"CANVAS":"IDLE",B8=K0?z("b",{children:"design system"}):X?M(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(kK(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),c8=new Set(Q?["autoopen"]:["assistant","autoopen"]),I8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&U0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:Z8?"video":void 0,checked:w0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:H8,disabled:!1}]:Q?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||K0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:v,disabled:!X||K0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||K0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:h,disabled:!X||K0}].filter((F0)=>!W8||!c8.has(F0.id)),V8=["file","edit","view","selection","tools","help"];function E0(F0){if(V8.includes(F0))G(W===F0?null:F0)}return u.useEffect(()=>{if(!W||!V8.includes(W))return;let F0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(U8){let N8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N8.length)return;let o8=N8.indexOf(document.activeElement);if(U8.key==="ArrowDown")U8.preventDefault(),N8[(o8+1)%N8.length].focus();else if(U8.key==="ArrowUp")U8.preventDefault(),N8[(o8-1+N8.length)%N8.length].focus();else if(U8.key==="Home")U8.preventDefault(),N8[0].focus();else if(U8.key==="End")U8.preventDefault(),N8[N8.length-1].focus();else if(U8.key==="ArrowRight"||U8.key==="ArrowLeft"){U8.preventDefault();let O8=U8.key==="ArrowRight"?1:-1,N9=V8.indexOf(W);G(V8[(N9+O8+V8.length)%V8.length])}else if(U8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(F0),window.removeEventListener("keydown",d0)}},[W,G]),M("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[M("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?M("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:P20.map((F0)=>{let d0=F0.toLowerCase(),U8=V8.includes(d0),N8=U8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":U8?"menu":void 0,"aria-expanded":U8?W===d0:void 0,onClick:()=>E0(d0),onMouseEnter:()=>{if(W!==null&&U8)G(d0)},children:F0},d0)})}),W==="file"&&z(C20,{readOnly:W8,hasCanvas:!!X,onAction:(F0)=>{if(F0==="new")T8?.();else if(F0==="assemble")s8?.();else if(F0==="export")E9?.("export");else if(F0==="handoff")E9?.("handoff");else if(F0==="generate")c0?.();else if(F0==="settings")u0?.();else if(F0==="reload")j0?.();else if(F0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z($20,{readOnly:W8,hasCanvas:!!X&&!K0,onAction:(F0)=>{if(F0==="undo")p({dgn:"undo"});else if(F0==="redo")p({dgn:"redo"});else if(F0==="deselect-all")p({dgn:"selection-clear"});else if(F0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(F0.startsWith("new-artboard:"))P8?.(F0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(R20,{panels:I8,onToggle:(F0)=>{if(F0==="tree")F();else if(F0==="changes")q();else if(F0==="comments")H();else if(F0==="hidden")_();else if(F0==="annotate")$();else if(F0==="inspector")l0();else if(F0==="autoopen")o0?.();else if(F0==="timeline")O0?.();else if(F0==="assistant")r8?.();else if(F0==="layers")L8?.();else if(F0==="minimap")y?.();else if(F0==="zoomctl")x?.();else if(F0==="present")o?.();else if(F0==="print-guides")m?.()},onZoom:(F0)=>p({dgn:"zoom",op:F0}),hasCanvas:!!X&&!K0,onClose:()=>G(null)}),W==="selection"&&z(I20,{readOnly:W8,onAction:(F0)=>{if(F0==="deselect-all")p({dgn:"selection-clear"});else if(F0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(k20,{readOnly:W8,onAction:(F0)=>p({dgn:"tool-set",tool:F0}),onClose:()=>G(null)}),W==="help"&&z(T20,{onAction:(F0)=>{if(F0==="shortcuts")w?.();else if(F0==="help")R?.();else if(F0==="report-bug")O?.();else if(F0==="tour")P?.();else if(F0==="collab-tour")I?.();else if(F0==="quick-setup")s?.();else if(F0==="readiness")n?.();else if(F0==="whatsnew")f?.();else if(F0==="watch-intro")c?.()},onClose:()=>G(null)}),M("div",{className:"st-mb-right","data-tour":"status",children:[t?z("div",{className:"st-presence",children:t}):null,W8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?M("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!W8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":H8?"true":"false","data-busy":A8?"true":"false","data-unseen":K8?"true":"false","aria-label":`Assistant${A8?" — working":K8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:r8,children:z(w9,{name:"sparkle",size:15})}),X0&&z(Lx,{center:X0}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:O,children:z(w9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":Z0>0?"true":"false","aria-label":`What's new${Z0>0?` — ${Z0} unseen`:""}`,"data-tip":"What's new",onClick:f,children:z(w9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:v0}),z("span",{className:"st-mb-file",title:X||"",children:B8}),z("span",{className:"st-mb-sep"}),M("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),H0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function b20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),M("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${oB(kK(N))}`,tabIndex:0,children:z(Ih,{path:N,kind:aR(kK(N))})}),X.length===0&&!N&&M("div",{className:"st-empty",children:[M("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),M("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",sR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),M("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?M(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===n8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(m20,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:wz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:M("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var y20=["color","space","radius","shadow","leading","weight","motion","font","other"],j20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function f20(X){return X==="color"}function v20({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return M("section",{className:"sv-section sv-section-tokens",children:[M("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:M("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...y20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=f20(G);return M("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[M("h2",{children:["tokens · ",j20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>M("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,M("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function h20(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function x20(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function g20({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=x20(X?.font);return M("section",{className:"sv-section sv-section-type",children:[M("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=h20(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return M("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function m20({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return M("div",{className:"sv",children:[M("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?M("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(v20,{tokens:H,tokenGroups:K,tokensPath:U}),z(g20,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:M("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):M(G0,{children:[z(W00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(W00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function W00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return M("section",{className:"sv-section",children:[M("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>M("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:wz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),M("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function u20({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===n8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Az(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&M(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return M("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[M("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&M("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),M("span",{className:"val",children:[Y," open"]})]}),_&&M("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:M("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),M("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(w9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function p20({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=w00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((O)=>O.selector);F.push({file:D,comments:R.map((O)=>({...O,n:w.findIndex((P)=>P.id===O.id)+1}))})}return M("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:M("div",{className:"st-cm-filters",role:"tablist",children:[M("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),M("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),M("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?M("div",{className:"st-rp-empty",children:[M("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),M("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>M(G0,{children:[M("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(kK(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>M("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[M("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:Y20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),M("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?M("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(w9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(w9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(w9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var l20={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function d20({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=l20[J];if(!Z)return null;return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function c20({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),M("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),hv().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function i20({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return M("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var o20=["block","inline-block","flex","inline-flex","grid","inline","none"],G00=["px","%","fr","em","auto","min-content","max-content"];var n20=["auto","stretch","flex-start","center","flex-end","baseline"];var Z00=["300","400","500","600","700","800"],H00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],z00=["none","solid","dashed","dotted","double"],K00=["px","rem","em","%","vw","vh","auto"],U00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),nR={"font-size":{node:z(W7,{as:JV,size:12})},"line-height":{node:z(W7,{as:zV,size:12})},"letter-spacing":{node:z(W7,{as:DV,size:12})},gap:{node:z(W7,{as:tz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(W7,{as:wV,size:12})},"border-width":{node:z(W7,{as:LV,size:12})}};var V00=["static","relative","absolute","fixed","sticky"],r20=["normal","italic","oblique"],q00=["none","uppercase","lowercase","capitalize"];var B00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],a20=["fill","contain","cover","none","scale-down"];var N00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],M5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},TK=null;function EF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!TK)TK=document.createElement("canvas").getContext("2d");if(!TK)return"";TK.fillStyle="#000000",TK.fillStyle=X;let J=TK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var r4=(X)=>Math.min(1,Math.max(0,X));function DF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function b3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function y3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function IK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function H7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function mQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function L00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function R00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function s20(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function T00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...s20(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function I00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>y3(DF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(y3(DF(X)))},[X]);let U=b3(IK(Y)),q=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:r4((C.clientX-P.left)/P.width),v:r4(1-(C.clientY-P.top)/P.height)})};k(O);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(b3(IK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:r4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(b3(IK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let P={...G.current,...O};W(P),Q(b3(IK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!k)return;O.preventDefault(),N({s:r4(G.current.s+k[0]),v:r4(G.current.v+k[1])})},D=(O)=>{let P=O.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[O.key];if(k==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(y3(DF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=IK(Y),w=(O)=>{let P={...R,...O},I=y3({r:r4(P.r/255)*255,g:r4(P.g/255)*255,b:r4(P.b/255)*255});W(I),Q(b3(IK(I)))};return M("div",{className:"st-cp-cpick",children:[M("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(y3(DF(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),M("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),M("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(w9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>M("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>w({[O]:r4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function OF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(s)=>Q===`var(${s})`,k=(s)=>s.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((s,c)=>s+(c.names?.length||0),0),y=$.length>1,v=_.trim().toLowerCase(),x=!v?$:$.map((s)=>({...s,names:(s.names||[]).filter((c)=>k(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(s.vals?.[c]||"").toLowerCase().includes(v))})).filter((s)=>s.names.length);u.useEffect(()=>{if(!U){R("");return}let s=()=>{let H0=w.current?.getBoundingClientRect();if(!H0)return;let t=224,N0=300,U0=Math.min(H0.right-t,window.innerWidth-t-8);if(U0<8)U0=8;let J8=window.innerHeight-H0.bottom>N0+8?H0.bottom+4:Math.max(8,H0.top-N0-4);N({left:U0,top:J8,width:t,maxHeight:N0})};s();let c=(H0)=>{if(O.current?.contains(H0.target)||w.current?.contains(H0.target))return;q(!1)},Z0=(H0)=>{if(H0.key==="Escape")q(!1)},X0=(H0)=>{if(O.current?.contains(H0.target))return;s()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",Z0),window.addEventListener("resize",s),document.addEventListener("scroll",X0,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",Z0),window.removeEventListener("resize",s),document.removeEventListener("scroll",X0,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let s=O.current.getBoundingClientRect(),c=B.left-s.left,Z0=B.top-s.top;if(Math.abs(c)>0.5||Math.abs(Z0)>0.5)N((X0)=>X0?{...X0,left:X0.left+c,top:X0.top+Z0}:X0)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(s,c,Z0)=>{if(H&&s&&s!==H&&Z0&&!d.test(Z0))Y(Z0);else Y(`var(${c})`);q(!1)},h=(s)=>{let c=(s||"").trim();if(c)Y(c)},m=M("div",{className:"st-cp-pop-search",children:[z(w9,{name:"search",size:12}),z("input",{value:_,onChange:(s)=>R(s.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(s)=>s.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((Z0)=>M("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(Z0)?" is-on":""}`,onClick:()=>o(c.ds,Z0,c.vals?.[Z0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[Z0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(Z0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[Z0]||""})]},`${c.ds}:${Z0}`))})]},c.ds)),f=(s)=>s.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((Z0)=>M("button",{type:"button",className:`st-cp-pop-row${I(Z0)?" is-on":""}`,onClick:()=>o(c.ds,Z0,c.vals?.[Z0]),children:[z("span",{className:"st-cp-pop-name",children:k(Z0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[Z0]||""})]},`${c.ds}:${Z0}`))})]},c.ds)),n=z("div",{className:"st-cp-pop-empty",children:"No match"});return M(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((s)=>!s),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((s)=>!s),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?M00.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?M(G0,{children:[M("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(I00,{seed:Z||EF(Q)||"#000000",onApply:h}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):M(G0,{children:[m,x.length?p(x):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):M(G0,{children:[m,x.length?f(x):n]})}),document.body):null]})}function D00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?WU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return M("div",{className:"st-cp-gridtracks",children:[M("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?M("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=WU.has(K.unit);return M("div",{className:"st-cp-gridtrack-row",children:[q?z(TW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:G00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(tB,{value:K.unit,units:G00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function t20({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(e,A0)=>{let B0={...e||{}};for(let[S0,s0]of Object.entries(A0))if(s0===null)delete B0[S0];else B0[S0]=s0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(e,A0)=>B((B0)=>({...B0,a:{...B0.a,[e]:A0}})),w=(e,A0)=>B((B0)=>({...B0,c:{...B0.c,[e]:A0}})),O=(e,A0)=>B((B0)=>({...B0,t:{...B0.t,[e]:A0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=R00(X.file,J),k=T00(J,P,I),$=(e)=>k.map((A0)=>({ds:A0.name,names:A0[e]||[],vals:A0.vals})).filter((A0)=>A0.names.length),[C,y]=u.useState({}),[v,x]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)x((e)=>e.Advanced?e:{...e,Advanced:!0})},[X.id,d]);let o=(F.position||H7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)x((e)=>e["d:Position"]?e:{...e,"d:Position":!0})},[X.id,o]);let h=H,[m,p]=u.useState({});async function f(e,A0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0)}),s0=await S0.json().catch(()=>({}));y((y8)=>({...y8,[B0]:!S0.ok||!s0.ok?`err:${s0&&s0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((s0)=>({...s0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let n=(e,A0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:e,value:A0})},s=(e,A0,B0,S0)=>{Y?.({op:e,canvas:X.file,id:X.id,key:A0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(e,A0)=>{let B0=(A0||"").trim();if(!K||!B0)return;let S0=F[e]??null;if(B0===(S0??"").trim())return;n(e,B0),R(e,B0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,value:B0},e),s("css",e,S0,B0)},Z0=(e,A0)=>{let B0=(A0||"").trim(),S0=e.trim();if(!K||!S0||!B0)return;let s0=D[S0]??null;n(S0,B0),w(S0,B0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),s("css",S0,s0,B0)},X0=(e,A0)=>{let B0=(e||"").trim(),S0=(A0||"").trim();if(!K||!B0||!S0)return;let s0=_[B0]??null;O(B0,S0),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),s("attr",B0,s0,S0)},H0=(e)=>{if(!K)return;let A0=F[e]??null;n(e,null),R(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),s("css",e,A0,null)},t=(e)=>{if(!K)return;let A0=D[e]??null;n(e,null),w(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),s("css",e,A0,null)},N0=(e)=>{if(!K)return;let A0=_[e]??null;O(e,null),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:e,reset:!0},`@${e}`),s("attr",e,A0,null)},U0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},l0=(e,A0)=>{if(!K)return;let B0=Math.round((e==="width"?X.bounds?.w:X.bounds?.h)||0),S0=zS(e,A0,U0,B0);for(let s0 of S0.reset)if(F[s0])H0(s0);for(let[s0,y8]of S0.set)c(s0,y8)},J8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(e)=>{let A0=HS(e,F,U,U0);return M("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:e==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${e} sizing mode`,children:z(eB,{value:A0,ariaLabel:`${e} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>l0(e,B0)})})]},`mode-${e}`)},L8=["flex-start","center","flex-end"],w0=["flex-start","center","flex-end"],O0=["t","c","b"],Z8=["l","c","r"],H8=()=>{let e=!(F["flex-direction"]||H7(U["flex-direction"])||"row").startsWith("column"),A0=Math.max(0,L8.indexOf(F["justify-content"]||H7(U["justify-content"])||"flex-start")),B0=F["align-items"]||H7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,w0.indexOf(B0)),[s0,y8]=e?[A0,S0]:[S0,A0];return O0[y8]+Z8[s0]},r8=(e)=>{let A0=O0.indexOf(e[0]),B0=Z8.indexOf(e[1]),S0=!(F["flex-direction"]||H7(U["flex-direction"])||"row").startsWith("column"),[s0,y8]=S0?[B0,A0]:[A0,B0];c("justify-content",L8[s0]),c("align-items",w0[y8])},A8=(e)=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let A0=e.key.toLowerCase();if(A0==="z")e.preventDefault(),G?.(e.shiftKey?"redo":"undo");else if(A0==="y")e.preventDefault(),G?.("redo")},K8=(e)=>{let A0=F[e];if(!A0)return"inherit";return/var\(\s*--/.test(A0)?"bound":"raw"};if(!K)return M("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),M("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let T8={bound:"token-bound",raw:"raw override",inherit:"inherited"},s8=(e)=>z("span",{className:`st-cp-prov st-cp-prov--${e}`,role:"img","aria-label":T8[e]}),E9=(e,A0)=>{let B0=A0??K8(e),S0=C[e],s0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",y8=s0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",x8=!!F[e],t8=s0?`error: ${s0}`:x8?`${T8[B0]} · double-click to reset`:T8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${y8}${x8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:x8?0:-1,onDoubleClick:x8?()=>H0(e):void 0,onKeyDown:x8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),H0(e)}:void 0})},u0=(e,A0,B0,S0)=>{let s0=B0===void 0&&!F[e],y8=S0??e;return M("div",{className:`st-cp-row${s0?" is-unset":""}`,children:[E9(e,B0),z("label",{className:"st-cp-label",title:y8,children:y8}),z("div",{className:"st-cp-ctl",children:A0})]},e)},c0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},j0=(e)=>{(c0[e]||[]).forEach((A0)=>{if(F[A0])H0(A0)})},I0=(e,A0)=>{let B0=(c0[e]||[]).some((S0)=>F[S0]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[e],onClick:()=>x((S0)=>({...S0,[e]:!S0[e]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:v[e]?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${e} section to original`,title:`reset ${e}`,disabled:!B0,onClick:()=>j0(e),children:z(W7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${v[e]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:A0})})]},e)},P8=(e,A0,B0,S0=!0)=>{let s0=`d:${e}`,y8=v[s0]===void 0?S0:v[s0],x8=A0.some((t8)=>F[t8]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":y8,onClick:()=>x((t8)=>({...t8,[s0]:!y8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y8?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${x8?"":" is-quiet"}`,"aria-label":`reset ${e} to original`,title:`reset ${e}`,disabled:!x8,onClick:()=>A0.forEach((t8)=>{if(F[t8])H0(t8)}),children:z(W7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${y8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},s0)},W8=(e)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[e],"aria-label":m[e]?`${e} — fewer options`:`${e} — more options`,title:m[e]?"fewer":"more",onClick:()=>p((A0)=>({...A0,[e]:!A0[e]})),children:m[e]?"▴":"···"}),K0=(e,A0)=>M("select",{className:"st-cp-nsel","aria-label":e,value:A0.includes(F[e])?F[e]:"",onChange:(B0)=>c(e,B0.target.value),children:[z("option",{value:"",disabled:!0,children:H7(U[e])||"—"}),A0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),v0=(e)=>$(e).flatMap((A0)=>(A0.names||[]).map((B0)=>({name:B0,value:A0.vals?.[B0]||""}))),B8=(e,A0)=>z(CA,{value:F[e]||H7(U[e])||A0[0].value,ariaLabel:e,options:A0,onChange:(B0)=>c(e,B0)}),c8=(e,A0,B0={})=>{let S0=mQ(F[e]??""),s0=U00.has(e),y8=F[e]??"",x8=typeof y8==="string"&&/var\(\s*--/.test(y8),t8=s0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(mQ(H7(U[e])??"").n)||0,A9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=nR[e];return z(XN,{value:x8?y8:A9,tokens:v0(A0),ariaLabel:e,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:s0?null:z(tB,{units:K00,value:S0.unit||"px",ariaLabel:`${e} unit`,onChange:(x9)=>c(e,x9==="auto"?"auto":`${S0.n||"0"}${x9}`)}),onChange:(x9)=>c(e,typeof x9==="string"?x9:s0?`${x9}`:`${x9}${t8}`)})},I8=()=>{let e=(s0)=>Number.parseFloat(mQ(F[s0]??F["border-radius"]??H7(U[s0])??H7(U["border-radius"])??"0").n)||0,A0={tl:e("border-top-left-radius"),tr:e("border-top-right-radius"),bl:e("border-bottom-left-radius"),br:e("border-bottom-right-radius")},B0=(s0)=>{if(s0.tl===s0.tr&&s0.tr===s0.bl&&s0.bl===s0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((x8)=>{if(F[x8])H0(x8)}),c("border-radius",`${s0.tl}px`);else c("border-top-left-radius",`${s0.tl}px`),c("border-top-right-radius",`${s0.tr}px`),c("border-bottom-left-radius",`${s0.bl}px`),c("border-bottom-right-radius",`${s0.br}px`)},S0=nR["border-radius"];return z(hh,{corners:A0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},V8=()=>M("div",{className:"st-cp-border",children:[S9("border-width",null,{fixedUnit:"px"}),M("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:z00.includes(F["border-style"])?F["border-style"]:"",onChange:(e)=>c("border-style",e.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),z00.map((e)=>z("option",{value:e,children:e},e))]}),z(OF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:EF(U["border-color"]||F["border-color"])||"#000000",onPick:(e)=>c("border-color",e),label:"border colour"})]}),E0=()=>{let e=F.transform||H7(U.transform)||"",A0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(e),B0=((A0?Number.parseFloat(A0[1]):0)%360+360)%360,S0=(s0)=>{let y8=(s0%360+360)%360,x8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${x8?`${x8} `:""}rotate(${y8}deg)`.trim())};return M("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(fh,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(W7,{as:MZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},F0=()=>{let e=F.filter||H7(U.filter)||"",A0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(e),B0=A0?Number.parseFloat(A0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(s0)=>{let y8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",s0>0?`${y8?`${y8} `:""}blur(${s0}px)`.trim():y8||"none")}})},d0=()=>{let e=F.opacity,A0=e!=null&&e!==""?Number.parseFloat(e):Number.parseFloat(H7(U.opacity))||1,B0=Math.round((Number.isNaN(A0)?1:A0)*100);return z(RJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>n("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${e??""}`)},U8=()=>{let e=Number.parseInt(F["font-weight"]||H7(U["font-weight"])||"400",10)>=600,A0=(F["font-style"]||H7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||H7(U["text-decoration"])||"");return z(yh,{value:{b:e,i:A0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(W7,{as:KV}),label:"Bold"},{value:"i",node:z(W7,{as:NV}),label:"Italic"},{value:"u",node:z(W7,{as:RV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",e?"400":"700");else if(S0==="i")c("font-style",A0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},N8=[{value:"row",node:z(W7,{as:LW}),label:"Row"},{value:"column",node:z(W7,{as:DW}),label:"Column"}],o8=[{value:"flex-start",node:z(W7,{as:WV}),label:"Start"},{value:"center",node:z(W7,{as:QV}),label:"Center"},{value:"flex-end",node:z(W7,{as:YV}),label:"End"},{value:"space-between",node:z(W7,{as:tz}),label:"Space between"}],O8=[{value:"flex-start",node:z(W7,{as:HV}),label:"Start"},{value:"center",node:z(W7,{as:GV}),label:"Center"},{value:"flex-end",node:z(W7,{as:ZV}),label:"End"},{value:"stretch",node:z(W7,{as:EV}),label:"Stretch"}],N9=[{value:"left",node:z(W7,{as:m5}),label:"Left"},{value:"center",node:z(W7,{as:_W}),label:"Center"},{value:"right",node:z(W7,{as:AW}),label:"Right"},{value:"justify",node:z(W7,{as:wW}),label:"Justify"}],Y9=[{value:"visible",node:z(W7,{as:DZ}),label:"Visible"},{value:"hidden",node:z(W7,{as:OZ}),label:"Hidden"},{value:"scroll",node:z(W7,{as:_V}),label:"Scroll"}],t7=(e,A0)=>{let B0=$(A0);return B0.length?z(OF,{kind:"value",groups:B0,current:F[e],activeDs:I,onPick:(S0)=>c(e,S0),label:`${e} design token`}):null},P0=(e)=>{let A0=e.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===A0)A0.select()})},h8=(e,A0)=>{if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return!1;e.preventDefault();let B0=e.shiftKey?10:1,S0=e.key==="ArrowUp"?1:-1,s0=(Number.parseFloat(e.currentTarget.value)||0)+S0*B0;return e.currentTarget.value=String(s0),A0(s0),!0},F9=(e)=>z("input",{className:"st-cp-fin","aria-label":e,defaultValue:F[e]??"",placeholder:H7(U[e])||"—",onFocus:P0,onKeyDown:(A0)=>{if(A0.key==="Enter")A0.currentTarget.blur()},onBlur:(A0)=>c(e,A0.currentTarget.value)},`${e}:${F[e]??""}`),S9=(e,A0,B0={})=>{let S0=mQ(F[e]??""),s0=U00.has(e),y8=s0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),x8=nR[e],t8=Number.parseFloat(mQ(H7(U[e])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return M(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:e,lead:x8?x8.node??x8.t:void 0,onCommit:(A9)=>c(e,s0?`${A9}`:`${A9}${y8}`),unitSlot:s0||B0.fixedUnit?null:z(tB,{units:K00,value:S0.unit||"px",ariaLabel:`${e} unit`,onChange:(A9)=>c(e,A9==="auto"?"auto":`${S0.n||"0"}${A9}`)})},`${e}:${F[e]??""}`),t7(e,A0)]})},g7=(e)=>{let A0=U[e]||F[e]||"",B0=F[e]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),s0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z(IV,{swatch:z(OF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[e],activeDs:I,swatchBg:A0,seedHex:EF(U[e]||F[e])||"#000000",onPick:(y8)=>c(e,y8),label:`${e} colour`}),displayValue:s0,bound:S0,ariaLabel:e,onValue:(y8)=>c(e,y8)})},d6=(e,A0)=>{let B0=null,S0=A0.unitless?"":"px",s0=(t8)=>A0.unitless?`${t8}`:`${t8}${S0}`,y8=(t8,G9,A9)=>{for(let F7 of G9??[e])A9(F7,s0(t8))},x8=kA({getBase:()=>B0?.value??"0",min:A0.min??0,step:1,sides:A0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let A9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===e)continue;let x9=A9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(x9)x9.value=String(t8)}}y8(t8,G9,n)},onCommit:(t8,G9)=>y8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,x8(t8)}}},u8=(e,A0)=>{let B0=F[e],S0=B0!=null&&B0!==""?mQ(B0).n||B0:mQ(H7(U[e])??"").n||"0",s0=!B0||B0==="0"||B0==="0px"||B0==="auto",y8=e.split("-").pop(),x8=y8==="top"||y8==="bottom"?[`${A0}-top`,`${A0}-bottom`]:[`${A0}-left`,`${A0}-right`],t8=[`${A0}-top`,`${A0}-right`,`${A0}-bottom`,`${A0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${A0[0]}${e.split("-").pop()[0]}${s0?" is-zero":""}`,"aria-label":e,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...d6(e,{sides:{pair:x8,all:t8}}),onFocus:P0,onKeyDown:(G9)=>{if(h8(G9,(A9)=>c(e,`${A9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let A9=G9.currentTarget.value.trim();if(!A9)return;let F7=/[a-z%]/i.test(A9)?A9:`${A9}px`;c(e,F7)}},`${e}:${B0??""}`)},z7=(e)=>{let A0=F[e],B0=A0!=null&&A0!==""&&A0!=="auto"?mQ(A0).n||A0:mQ(H7(U[e])??"").n||"",S0=!A0||A0==="auto"||A0==="0"||A0==="0px",s0=e==="top"||e==="bottom"?["top","bottom"]:["left","right"],y8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${e[0]}${S0?" is-zero":""}`,"aria-label":e,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...d6(e,{sides:{pair:s0,all:y8},min:-1/0}),onFocus:P0,onKeyDown:(x8)=>{if(h8(x8,(t8)=>c(e,`${t8}px`)))return;if(x8.key==="Enter")x8.currentTarget.blur()},onBlur:(x8)=>{let t8=x8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(e,G9)}},`${e}:${A0??""}`)},K7=Object.entries(D),E7=Object.entries(_),R9=()=>{let e=(X.tag||"").toLowerCase(),B0=e==="img"||e==="video"||e==="picture"||e==="svg"||e==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(e==="img"||e==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(e)=>M(G0,{children:[e&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),u0("object-fit",K0("object-fit",a20)),u0("object-position",F9("object-position")),u0("aspect-ratio",M("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:F00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(A0)=>{let B0=A0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)H0("height")},children:[z("option",{value:"",disabled:!0,children:H7(U["aspect-ratio"])||"—"}),F00.map((A0)=>z("option",{value:A0,children:A0},A0))]}))]});return M("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:A8,children:[M("div",{className:"st-cp-id",children:[M("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?M("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(CA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(W7,{as:FW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(W7,{as:EW,size:12}),label:"Designer — Figma vocabulary"}],onChange:h})})]}),Z==="designer"?M(G0,{children:[P8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let e=(F.display||H7(U.display)||"").trim();return e==="flex"||e==="inline-flex"?M(G0,{children:[u0("flex-direction",B8("flex-direction",N8),void 0,"Direction"),u0("align-items",z(jh,{value:H8(),onChange:r8,ariaLabel:"auto-layout alignment"}),K8("align-items"),"Alignment"),u0("gap",c8("gap","space"),void 0,"Gap"),M("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),M("div",{className:"st-cp-box","aria-label":"padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[s8(K8("padding-top")),"padding"]}),u8("padding-top","padding"),u8("padding-right","padding"),u8("padding-bottom","padding"),u8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:W8("Auto layout")}),m["Auto layout"]?u0("flex-wrap",z(jQ,{checked:/^wrap/.test(F["flex-wrap"]||H7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),K8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),P8("Size",["width","height","min-width","max-width","min-height","max-height"],M(G0,{children:[u0("width",S9("width"),void 0,"Width"),u0("height",S9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:W8("Size")}),m.Size?M(G0,{children:[u0("min-width",S9("min-width"),void 0,"Min width"),u0("max-width",S9("max-width"),void 0,"Max width"),u0("min-height",S9("min-height"),void 0,"Min height"),u0("max-height",S9("max-height"),void 0,"Max height")]}):null]})),P8("Position",["position","top","right","bottom","left","z-index"],M(G0,{children:[u0("position",K0("position",V00),void 0,"Position"),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[s8(K8("top")),"inset"]}),z7("top"),z7("right"),z7("bottom"),z7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||H7(U.position)||"static"})]}),(F.position||H7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:W8("Position")}),m.Position?u0("z-index",S9("z-index"),void 0,"Layer order"):null]}),!1),P8("Fill",["background-color"],u0("background-color",g7("background-color"),void 0,"Fill")),P8("Stroke",["border-width","border-style","border-color"],u0("border",V8(),K8("border-width"),"Stroke")),P8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],u0("border-radius",I8(),K8("border-radius"),"Corner radius")),P8("Effects",["box-shadow","filter","mix-blend-mode"],M(G0,{children:[u0("box-shadow",t7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),u0("filter",F0(),K8("filter"),"Blur"),u0("mix-blend-mode",K0("mix-blend-mode",N00),void 0,"Blend")]})),P8("Opacity",["opacity"],u0("opacity",d0(),void 0,"Opacity")),P8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],M(G0,{children:[u0("font-family",K0("font-family",H00),void 0,"Font"),u0("color",g7("color"),void 0,"Color"),u0("font-size",c8("font-size","type"),void 0,"Size"),u0("font-weight",K0("font-weight",Z00),void 0,"Weight"),u0("line-height",S9("line-height","lh"),void 0,"Line height"),u0("text-align",B8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:W8("Text")}),m.Text?M(G0,{children:[u0("letter-spacing",S9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),u0("font-style",K0("font-style",r20),void 0,"Style"),u0("text-transform",K0("text-transform",q00),void 0,"Case"),u0("white-space",K0("white-space",B00),void 0,"Whitespace")]}):null]})),P8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],M("div",{className:"st-cp-box","aria-label":"margin",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[s8(K8("margin-top")),"margin"]}),u8("margin-top","margin"),u8("margin-right","margin"),u8("margin-bottom","margin"),u8("margin-left","margin")]})),(()=>{let{showMedia:e,canReplace:A0}=R9();return e?P8("Media",["object-fit","object-position","aspect-ratio"],S6(A0)):null})()]}):M(G0,{children:[I0("Layout",(()=>{let e=(F.display||H7(U.display)||"").trim(),A0=e==="flex"||e==="inline-flex",B0=e==="grid"||e==="inline-grid";return M(G0,{children:[u0("display",K0("display",o20)),A0?M(G0,{children:[u0("flex-direction",B8("flex-direction",N8)),u0("flex-wrap",z(jQ,{checked:/^wrap/.test(F["flex-wrap"]||H7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),K8("flex-wrap"))]}):null,A0||B0?M(G0,{children:[u0("align-items",B8("align-items",O8)),u0("justify-content",B8("justify-content",o8)),u0("gap",c8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let e=(F.display||H7(U.display)||"").trim();if(!(e==="grid"||e==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",s0=kM(B0),y8=kM(S0),x8=s0.length>0||!B0.trim(),t8=y8.length>0||!S0.trim();return I0("Grid",M(G0,{children:[x8?z(D00,{label:"Columns",tracks:s0,editable:K,onChange:(G9)=>c("grid-template-columns",CM(G9))}):M("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(D00,{label:"Rows",tracks:y8,editable:K,onChange:(G9)=>c("grid-template-rows",CM(G9))}):M("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",M(G0,{children:[u0("position",K0("position",V00)),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[s8(K8("top")),"inset"]}),z7("top"),z7("right"),z7("bottom"),z7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||H7(U.position)||"static"})]}),(F.position||H7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,u0("z-index",S9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",M(G0,{children:[M("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),u0("grid-column",F9("grid-column")),u0("grid-row",F9("grid-row"))]})),I0("Typography",M(G0,{children:[u0("font-family",K0("font-family",H00)),u0("color",g7("color")),u0("font-size",c8("font-size","type")),u0("font-weight",K0("font-weight",Z00)),u0("line-height",S9("line-height","lh")),u0("letter-spacing",S9("letter-spacing",null,{min:-1/0})),u0("text-align",B8("text-align",N9)),u0("font-style",U8(),K8("font-style")),u0("text-transform",K0("text-transform",q00)),u0("white-space",K0("white-space",B00))]})),I0("Spacing",z(G0,{children:M("div",{className:"st-cp-box","aria-label":"margin and padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[s8(K8("margin-top")),"margin"]}),u8("margin-top","margin"),u8("margin-right","margin"),u8("margin-bottom","margin"),u8("margin-left","margin"),M("div",{className:"st-cp-boxpad",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[s8(K8("padding-top")),"padding"]}),u8("padding-top","padding"),u8("padding-right","padding"),u8("padding-bottom","padding"),u8("padding-left","padding"),M("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",M(G0,{children:[M("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),u0("width",S9("width")),u0("height",S9("height")),u0("min-width",S9("min-width")),u0("max-width",S9("max-width")),u0("min-height",S9("min-height")),u0("max-height",S9("max-height")),u0("overflow",B8("overflow",Y9)),J8?M(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),u0("align-self",K0("align-self",n20)),u0("flex-grow",S9("flex-grow",null,{unitless:!0})),u0("flex-shrink",S9("flex-shrink",null,{unitless:!0})),u0("flex-basis",S9("flex-basis"))]}):null]})),(()=>{let{showMedia:e,canReplace:A0}=R9();return e?I0("Media",S6(A0)):null})(),I0("Appearance",M(G0,{children:[u0("background-color",g7("background-color")),u0("border-radius",I8(),K8("border-radius")),u0("border",V8(),K8("border-width")),u0("box-shadow",t7("box-shadow","shadow")||F9("box-shadow")),u0("filter",F0(),K8("filter")),u0("mix-blend-mode",K0("mix-blend-mode",N00)),u0("opacity",d0()),u0("rotation",E0(),K8("transform")),u0("transform",F9("transform")),u0("transform-origin",F9("transform-origin"))]})),(()=>{let e=Object.entries(C).find(([,A0])=>typeof A0==="string"&&A0.startsWith("err:"));return e?M("div",{className:"st-cp-save is-err",role:"status",children:[z(w9,{name:"x",size:12}),e[0],": ",e[1].slice(4)]}):null})(),I0("Advanced",M("div",{className:"st-cp-advbody",children:[K7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),K7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`custom property ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>Z0(e,B0.currentTarget.value)},`cs:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>t(e),children:z(w9,{name:"x",size:11})})]},`cs:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(e20,{commit:Z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),E7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),E7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`attribute ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>X0(e,B0.currentTarget.value)},`at:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>N0(e),children:z(w9,{name:"x",size:11})})]},`at:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(XB0,{commit:X0})]}))]}),M("div",{className:"st-cp-legend",children:[M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function e20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function XB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var JB0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function QB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var YB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function k00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[v,x]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),o=G?.has(w)?G.get(w):!!X.hidden,h=!!q&&!I&&!$,m=()=>{y(!1);let n=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(X.dcElement??""))return;R?.(X,n)},p=N?.key===w,f=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return M(G0,{children:[M("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(o?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...f},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":O?!P:void 0,"aria-grabbed":h?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?O&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:h?(n)=>B(n,X,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),I)O&&Z(w);else H(X);else if(n.key==="F2"&&R&&!I)n.preventDefault(),x(X.dcElement||X.label||""),y(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(w9,{name:JB0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>x(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:m,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")m();else if(n.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(n)=>{n.stopPropagation(),x(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),_(w)},children:z(w9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(X)},children:z(w9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((n,s)=>z(k00,{node:n,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${n.id}:${n.index}`)):null]})}function WB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),M("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?mQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return M(G0,{children:[G?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function C00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var GB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],ZB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function HB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=C00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=R00(X.file,J),B=T00(J,U,q),N=(f)=>B.map((n)=>({ds:n.name,names:n[f]||[],vals:n.vals})).filter((n)=>n.names.length),F=(f)=>N(f).flatMap((n)=>(n.names||[]).map((s)=>({name:s,value:n.vals?.[s]||""}))),D=(f)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f||"");if(!n)return f||"";for(let s of B){let c=s.vals?.[n[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(f,n)=>{if(!K)return;let s=Number.isFinite(f)&&f>0?Math.round(f):void 0,c=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(s==null&&c==null)return;Q?.(K,s,c)},O=Object.entries(M5).find(([,f])=>f.width===_&&f.height===R)?.[0],P=Object.entries(M5).find(([,f])=>f.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",x=null;try{x=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(f)=>{if(!K)return;let n=null;if(f==="print"&&!x){let s={paper:"a4"};try{let c=N2(s);if(c)n={defaults:s,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,f==="digital"?null:f,n),f==="web"&&I)Y?.(K,!1,void 0)},o=(f)=>{if(!K)return;let n={paper:"a4",...x,...f},s;try{s=N2(n)}catch{return}Q?.(K,s.widthPx,s.heightPx),Z?.(K,n)},h=(f,n)=>{if(!K)return;let s=Number.isFinite(n)?n:R,c=f&&Number.isFinite(s)?Math.round(s):void 0;Y?.(K,f,c)},m=(f)=>{let n=WS(I,f);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")h(!0,n.height)},p=(f)=>{if(!K)return;W?.(K,f)};return M("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),M("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(f)=>w(f,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:v==="print"?M("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:x?.paper??"",onChange:(f)=>o({paper:f.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),B2.map((f)=>M("option",{value:f.id,children:[f.label," — ",f.width,"×",f.height,f.unit]},f.id))]}):v==="web"?M("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${M5[P].label} — ≤ ${M5[P].width}px`:"Breakpoint…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ≤ ",n.width,"px breakpoint"]},f))]}):M("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?M5[O].label:"Preset size…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ",n.width,"×",n.height]},f))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(eB,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(f)=>h(f==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(TW,{value:v,ariaLabel:"artboard kind",options:ZB0.map(([f,n])=>({value:f,label:n})),onChange:d})}),v!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:M("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(f)=>{let n=M5[f.currentTarget.value];if(n)H(K,n.width);f.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(M5).map(([f,n])=>M("option",{value:f,children:[n.label," — ",n.width,"px"]},f))]})}):null,v==="print"?M(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(eB,{value:x?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(f)=>o({orientation:f})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(x?.bleedMm)?x.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(f)=>o({bleedMm:f})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),M("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let f=D(k),n=/var\(\s*--/.test(k),s=n?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z(IV,{swatch:z(OF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:f,seedHex:EF(f)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:s,bound:n,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(TW,{value:C,ariaLabel:"artboard body layout",options:GB0.map(([f,n])=>({value:f,label:n})),onChange:(f)=>p({layout:f||null})}),M("div",{style:{display:"flex",gap:8},children:[z(XN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(f)=>p({padding:typeof f==="string"?f:f>0?f:null})}),z(XN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(f)=>p({gap:typeof f==="string"?f:f>0?f:null})})]})]})]})}var tR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,zB0=new RegExp(tR.source,"gi");function KB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(zB0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=tR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function UB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:v,onTabChange:x,width:d,resizing:o,photoSel:h,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:f,onPhotoRecordEdit:n,onPhotoUndoRedo:s,layersOnly:c=!1,hideLayersTab:Z0=!1,cpMode:X0,onSetCpMode:H0}){let[t,N0]=u.useState("inspect"),U0=c?"layers":v??t,l0=(E0)=>{N0(E0),x?.(E0)},[J8,o0]=u.useState(()=>new Set),[L8,w0]=u.useState(()=>new Map);u.useEffect(()=>{let E0=Array.isArray(J)?J[0]:J,F0=E0?.id;if(!F0||!Y?.nodes)return;let d0=E0.index,U8=null,N8=[];if(function o8(O8,N9){for(let Y9 of O8||[]){let t7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===F0&&(d0==null||Y9.index===d0))return U8=t7,N8.push(...N9),!0;if(Y9.children&&Y9.children.length&&o8(Y9.children,[...N9,t7]))return!0}return!1}(Y.nodes,[]),!U8)return;if(N8.length)o0((o8)=>{let O8=!1,N9=new Set(o8);for(let Y9 of N8)if(N9.delete(Y9))O8=!0;return O8?N9:o8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${U8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let O0=(E0)=>{let F0=`${E0.id}:${E0.index}`;return L8.has(F0)?L8.get(F0):!!E0.hidden},[Z8,H8]=u.useState(null),[r8,A8]=u.useState(""),K8=(E0,F0)=>{if(!K||!E0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:E0.id,attr:"data-dc-element",value:F0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:E0.id,key:"data-dc-element",before:E0.dcElement??null,after:F0})}).catch(()=>{})},T8=B?(E0,F0,d0)=>{if(N?.current)return;if(E0?.synthetic||F0?.synthetic)return;let U8=d0==="before"?`before ${F0.label}`:d0==="after"?`after ${F0.label}`:`into ${F0.label}`;A8(`Moved ${E0.label} ${U8}`),B(E0.id,F0.id,d0,{idIndex:E0.index,refIndex:F0.index})}:void 0,s8=()=>{let E0=[];return function F0(d0,U8,N8){(d0||[]).forEach((o8,O8)=>{if(E0.push({node:o8,depth:U8,parentNode:N8,siblings:d0,pos:O8}),o8.children&&o8.children.length&&!J8.has(`${o8.id}:${o8.index}`))F0(o8.children,U8+1,o8)})}(Y?.nodes,0,null),E0},E9=(E0)=>{if(E0.key!=="ArrowUp"&&E0.key!=="ArrowDown")return;if(!W8)return;let F0=s8(),d0=F0.findIndex((O8)=>O8.node.id===W8.id&&O8.node.index===W8.index);if(d0<0)return;let U8=E0.key==="ArrowDown"?1:-1,N8=F0[d0];if(!E0.altKey){let O8=F0[d0+U8];if(O8)E0.preventDefault(),U?.(O8.node);return}if(!T8||!Array.isArray(N8.siblings))return;E0.preventDefault();let o8=(O8)=>O8&&O8.children&&O8.children.length&&!J8.has(`${O8.id}:${O8.index}`);if(!E0.shiftKey){if(U8<0&&N8.pos>0)T8(N8.node,N8.siblings[N8.pos-1],"before");else if(U8>0&&N8.pos<N8.siblings.length-1)T8(N8.node,N8.siblings[N8.pos+1],"after");return}if(U8>0){let O8=N8.siblings[N8.pos+1];if(O8)T8(N8.node,O8,o8(O8)?"inside-start":"after");else if(N8.parentNode)T8(N8.node,N8.parentNode,"after")}else{let O8=N8.siblings[N8.pos-1];if(O8)T8(N8.node,O8,o8(O8)?"inside-end":"before");else if(N8.parentNode)T8(N8.node,N8.parentNode,"before")}},u0=u.useRef(null),c0=u.useRef(null),j0=(E0,F0,d0)=>{if(!T8||E0.button!==0||E0.metaKey||E0.ctrlKey||E0.shiftKey||E0.altKey)return;if(N?.current)return;let{clientX:U8,clientY:N8}=E0,o8=new Set([d0]);(function u8(z7){(z7.children||[]).forEach((K7)=>{o8.add(`${K7.id}:${K7.index}`),u8(K7)})})(F0);let O8=14,N9=6,Y9=[];(function u8(z7,K7){(z7||[]).forEach((E7)=>{let R9=`${E7.id}:${E7.index}`;if(Y9.push({node:E7,key:R9,id:E7.id,depth:K7,tag:E7.tag}),E7.children&&E7.children.length&&!J8.has(R9))u8(E7.children,K7+1)})})(Y?.nodes,0);let t7=new Map(Y9.map((u8)=>[u8.key,u8])),P0=!1,h8=(u8)=>{if(!P0){if(Math.hypot(u8.clientX-U8,u8.clientY-N8)<4)return;P0=!0}let z7=u8.clientX-U8,K7=u8.clientY-N8,E7=null,R9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((e)=>({rect:e.getBoundingClientRect(),it:t7.get(e.getAttribute("data-layer-key"))})).filter((e)=>e.it&&e.it.key!==d0);if(R9.length){let e=R9[0].rect.left,A0=R9[0].rect.right,B0=R9.length;for(let L7=0;L7<R9.length;L7++)if(u8.clientY<R9[L7].rect.top+R9[L7].rect.height/2){B0=L7;break}let S0=R9[B0-1]?.it||null,s0=R9[B0]?.it||null,y8=Math.round((u8.clientX-e-N9)/O8),x8=S0?S0.depth+(YB0.has(S0.tag)?0:1):0,t8=s0?s0.depth:0,G9=Math.max(t8,Math.min(y8,x8)),A9=null,F7="before",x9=0;if(!S0){if(s0)A9=s0,F7="before",x9=s0.depth}else if(G9>S0.depth)A9=S0,F7="inside-start",x9=S0.depth+1;else if(G9===S0.depth)A9=S0,F7="after",x9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(R9[L7].it.depth===G9){A9=R9[L7].it;break}if(!A9)A9=S0;F7="after",x9=G9}if(A9&&A9.key!==d0&&!o8.has(A9.key)){let L7=S0?R9[B0-1].rect.bottom:R9[0].rect.top,mX=e+N9+x9*O8;E7={refId:A9.id,position:F7,node:A9.node,y:L7,left:mX,w:Math.max(24,A0-mX)}}}let S6={key:d0,node:F0,dx:z7,dy:K7,target:E7};u0.current=S6,H8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",g7),window.removeEventListener("keydown",d6,!0)},S9=()=>{let u8=(z7)=>{z7.preventDefault(),z7.stopImmediatePropagation(),document.removeEventListener("click",u8,!0)};document.addEventListener("click",u8,!0),setTimeout(()=>document.removeEventListener("click",u8,!0),300)},g7=()=>{F9();let u8=u0.current;if(u0.current=null,H8(null),P0&&u8?.target)S9(),T8(u8.node,u8.target.node,u8.target.position)},d6=(u8)=>{if(u8.key!=="Escape")return;if(u8.preventDefault(),u8.stopImmediatePropagation(),F9(),u0.current=null,H8(null),P0)S9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",g7),window.addEventListener("keydown",d6,!0)},I0=(E0)=>o0((F0)=>{let d0=new Set(F0);if(d0.has(E0))d0.delete(E0);else d0.add(E0);return d0}),P8=(E0)=>{let F0=`${E0.id}:${E0.index}`,d0=O0(E0),U8=!d0;if(w0((N8)=>new Map(N8).set(F0,U8)),D?.({id:E0.id,artboardId:Y?.artboardId??null,index:E0.index,prop:"display",value:U8?"none":null}),!K||!E0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(U8?{canvas:K,id:E0.id,property:"display",value:"none"}:{canvas:K,id:E0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:E0.id,key:"display",before:d0?"none":null,after:U8?"none":null})},W8=Array.isArray(J)?J[0]:J,K0=h?{asset:h.asset,kind:"annotation-image"}:(()=>{let E0=KB0(W8);return E0?{asset:E0,kind:"artboard-img"}:null})(),v0=K0?.kind==="annotation-image",B8=(E0)=>{if(!(E0.metaKey||E0.ctrlKey)||E0.altKey)return;let F0=E0.key.toLowerCase();if(F0==="z")E0.preventDefault(),s?.(E0.shiftKey?"redo":"undo");else if(F0==="y")E0.preventDefault(),s?.("redo")},c8=v0?"photo":U0==="photo"&&!K0?"inspect":U0,I8=(E0,F0,d0)=>M("button",{type:"button",className:"st-rp-tab"+(c8===E0?" is-active":""),onClick:()=>l0(E0),children:[z(w9,{name:d0,size:14}),F0]}),V8=W8?.bounds||null;return M("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[M("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[v0?I8("photo","Photo","image"):M(G0,{children:[I8("inspect","Inspect","sliders"),!Z0&&I8("layers","Layers","layers"),I8("css","CSS","code"),K0?I8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(w9,{name:"x",size:14})})]}),W8?.id&&!(Array.isArray(J)&&J.length>1)&&y?M("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(W8.id,W8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:c8==="photo"&&K0?z("div",{onKeyDown:B8,children:z(Hx,{asset:K0.asset,ColorPicker:I00,StIcon:w9,onEdit:(E0)=>p?.(K0.asset,E0),onRemoveBackground:f,onRecordEdit:(E0,F0)=>n?.(K0.asset,E0,F0)},`${K0.asset}:${m??0}`)}):!W8&&!(c8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:M("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):W8&&c8==="inspect"?M(G0,{children:[z("div",{className:"st-rp-hd",children:W8.selector||W8.tag||"element"}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:V8?Math.round(V8.x):"—",readOnly:!0,"aria-label":"x position"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:V8?Math.round(V8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:V8?Math.round(V8.w):"—",readOnly:!0,"aria-label":"width"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:V8?Math.round(V8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:W8.tag||"—"})})]}),W8.classes?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:W8.classes})})]}):null,z(WB0,{el:W8})]}):c8==="layers"?M(G0,{children:[M("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?M(G0,{children:[T8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:c0,onKeyDown:E9,children:Y.nodes.map((E0,F0)=>z(k00,{node:E0,depth:0,selectedId:W8?.id,selectedIndex:W8?.index,collapsed:J8,hiddenOverride:L8,onToggle:I0,onSelect:(d0)=>{U?.(d0),c0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:P8,onReorder:T8,onRowPointerDown:j0,dragState:Z8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:K8},`${E0.id}:${E0.index}`))}),Z8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:Z8.target.left,top:Z8.target.y-1,width:Z8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:r8})]}):W8&&Array.isArray(W8.dom_path)&&W8.dom_path.length?W8.dom_path.map((E0,F0)=>M("div",{className:"st-layer"+(F0===W8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+F0*12},children:[z(w9,{name:"square",size:13}),E0]},F0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!W8.id&&C00(W8)?z(HB0,{el:W8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(t20,{el:W8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:X0,onSetMode:H0})})]})}function VB0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let a=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:a.signal}).then((D0)=>D0.ok?D0.json():null).then((D0)=>{if(D0?.ok)_(D0)}).catch(()=>{}),()=>a.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),O=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let a=F.current,W0=Array.isArray(a)?a[0]:a;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let D0=p8.current.get(j.file);if(!D0?.contentWindow)return;try{D0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let a of P.current)clearTimeout(a);P.current=[50,450,1200,2500,5000].map((a)=>setTimeout(()=>{let W0=F.current,D0=Array.isArray(W0)?W0[0]:W0;if(!D0||D0.artboardId!==j||D0.file!==b)return;let q0=p8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},a))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),v=u.useRef(!1),x=u.useRef(null),[d,o]=u.useState(null),[h,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((a)=>a.json()).then((a)=>{if(a?.ok&&a.map&&typeof a.map==="object")m(a.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[f,n]=u.useState(!1),[s,c]=u.useState(null),[Z0,X0]=u.useState(null),[H0,t]=u.useState(null),[N0,U0]=u.useState(null),[l0,J8]=u.useState(null),[o0,L8]=u.useState(!1),[w0,O0]=u.useState(!1),[Z8,H8]=u.useState(null),[r8,A8]=u.useState(""),[K8,T8]=u.useState(null),[s8,E9]=u.useState(null),u0=u.useRef(null),c0=J00("maude-sb-w",{min:200,max:420,def:252}),j0=J00("maude-rp-w",{min:260,max:480,def:304}),[I0,P8]=u.useState(null),W8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(a)=>{let W0=W8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")c0.setW(a.clientX-W0.left);else j0.setW(W0.right-a.clientX)},b=()=>P8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,c0.setW,j0.setW]);let K0=u.useCallback((j)=>{clearTimeout(u0.current),u0.current=setTimeout(()=>{E9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!s8)return;let j=setTimeout(()=>E9(null),15000);return()=>clearTimeout(j)},[s8]);let[v0,B8]=u.useState({designRel:".design",cloud:void 0}),c8=!!v0.cloud,I8=!v0.cloud&&!!H0?.credentialed,V8=c8||I8,E0=V8?0:N0?.files?.length||0,F0=u.useRef(V8);F0.current=V8;let d0=!!v0.readOnly,U8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");B8((a)=>({...a,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{U8()},[U8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(V8){U0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)U0(b)}).catch(()=>{}),()=>{j=!0}},[V8]);let[N8,o8]=u.useState({}),[O8,N9]=u.useState(null),[Y9,t7]=u.useState(!1),[P0,h8]=u.useState("open"),[F9,S9]=u.useState(sq0),[g7,d6]=u.useState(()=>{return dR(de,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(de,JSON.stringify(g7))}catch{}},[g7]);let[u8,z7]=u.useState(null),[K7,E7]=u.useState(()=>aZ(ce,!0)),[R9,S6]=u.useState(()=>aZ(pe,!1)),[e,A0]=u.useState(()=>dR(le,{})),[B0,S0]=u.useState(!1),[s0,y8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=kv(()=>y8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[x8,t8]=u.useState(!1),[G9,A9]=u.useState(!1),[F7,x9]=u.useState(!1),[L7,mX]=u.useState(!1),[uQ,pQ]=u.useState(!1),{report:ZQ}=PA(W9()),[HQ,I9]=u.useState(!1),[e7,lQ]=u.useState(!1),[D7,w6]=u.useState(null),[EX,O5]=u.useState(!1),[S7,KX]=u.useState(!1),[PX,b7]=u.useState(!1),[a4,Z6]=u.useState(!1),[k9,RX]=u.useState(()=>dR(re,RK)),[T9,p9]=u.useState(()=>{try{let j=localStorage.getItem(ae);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[c6,zQ]=u.useState(!1),[X6,jJ]=u.useState([]),[ZJ,TX]=u.useState(0),[_5,uX]=u.useState(!1),[A5,s4]=u.useState(!1),[i,Q0]=u.useState(!1),[L0,f0]=u.useState(1),[T0,G8]=u.useState(216),[Q8,V9]=u.useState(null),[a8,i6]=u.useState([]),[pX,b6]=u.useState([]),[w5,dQ]=u.useState([]),[E5,t4]=u.useState(0),P5=u.useRef(0);u.useEffect(()=>{P5.current=ZJ},[ZJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let y7=u.useMemo(()=>SA(X6,{artboardId:[o9,Q8],total:E5}),[X6,o9,Q8,E5]),w8=u.useRef(null);u.useEffect(()=>{w8.current=y7},[y7]);let b9=u.useMemo(()=>XK(X6,y7)?.fps||30,[X6,y7]),[y9,lX]=u.useState(null),[VX,lW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))m8("Timeline changed — reloaded, try again."),lW((a)=>a+1);else m8(`${j}: ${b||"failed"}`)},[]),[HJ,R5]=u.useState(!1),[$K,e4]=u.useState(!1),[SK,zJ]=u.useState(!1),dW=u.useRef(HJ);u.useEffect(()=>{if(dW.current=HJ,HJ){zJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[HJ]);let sZ=u.useCallback(()=>{if(!dW.current||document.hidden)zJ(!0),te("Claude finished","Your assistant turn is ready in Maude.")},[]),vJ=u.useRef(0),XY=u.useCallback(()=>{if(!dW.current||document.hidden){zJ(!0);let j=Date.now();if(j-vJ.current<nq0)return;vJ.current=j,te("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[T5,KQ]=u.useState("inspect"),[bK,JY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[yK,jK]=u.useState(0),[xJ,cW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),tZ=u.useRef(xJ);u.useEffect(()=>{tZ.current=xJ;try{localStorage.setItem("maude-auto-open-inspector",xJ?"1":"0")}catch{}},[xJ]);let eZ=u.useRef(!1);u.useEffect(()=>{eZ.current=PX||Y9||o0||w0||HJ},[PX,Y9,o0,w0,HJ]);let iW=u.useRef({open:{},side:RK});iW.current={open:{tree:K7,layers:a4,inspector:PX,comments:Y9,changes:o0,sync:w0,assistant:HJ},side:k9};let cQ=u.useCallback((j,b)=>{if(j==="tree")E7(b);else if(j==="layers")Z6(b);else if(j==="inspector")b7(b);else if(j==="comments")t7(b);else if(j==="changes")L8(b);else if(j==="sync")O0(b);else if(j==="assistant")R5(b)},[]),oW=u.useCallback((j)=>iW.current.side?.[j]||RK[j],[]),IX=u.useCallback((j)=>{let b=oW(j);cQ(j,!0);for(let a of rR)if(a.id!==j&&oW(a.id)===b)cQ(a.id,!1)},[cQ,oW]),I5=u.useCallback((j)=>{if(iW.current.open?.[j])cQ(j,!1);else IX(j)},[IX,cQ]),gJ=IX,H6=I5,iQ=u.useCallback((j)=>{if(!tZ.current)return;if(d0)return;if(!j||!j.id)return;if(eZ.current)return;gJ("inspector"),KQ("css")},[gJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=Ix(sR),QY=Vx({enabled:v0.cloud===null||v0.exportLane==="remote"}),[YY,nW]=u.useState(!1),[dX,XH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return bv().then((b)=>{if(!j)return;if(nW(!!b),!b&&!aZ(ue,!1))XH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let WY=u.useCallback(()=>{XH(!1);try{localStorage.setItem(ue,"1")}catch{}},[]),[fK,JH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return vv((b)=>JH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,QH]=u.useState(null),[k5,rW]=u.useState(()=>!aZ(me,!1)),C5=u.useCallback((j)=>{QH(Array.isArray(j)&&j.length?j:null)},[]),vK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)gJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)gJ("changes")}},aW=u.useCallback(()=>{rW(!1);try{localStorage.setItem(me,"1")}catch{}},[]),[BQ,YH]=u.useState(()=>aZ(ne,!0)),[WH,hK]=u.useState(!1),[mJ,GH]=u.useState(()=>aZ(ie,!1)),[j6,qX]=u.useState(()=>aZ(oe,!1)),[o6,sW]=u.useState(!1),[xK,uJ]=u.useState(!1),[oQ,NQ]=u.useState(0),[nQ,tW]=u.useState(null),[eW,GY]=u.useState(!1),rQ=u.useRef(null),ZY=u.useRef(null),p8=u.useRef(new Map),$8=u.useCallback((j)=>{let b=Z?p8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),aQ=u.useCallback((j,b)=>$8({dgn:"photo-preview",asset:j,edit:b}),[$8]),$5=u.useCallback((j,b,a)=>{hJ.current.undo.push({asset:j,before:b,after:a}),hJ.current.redo.length=0},[]),z0=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let a=b.pop();(j?hJ.current.undo:hJ.current.redo).push(a);let W0=(j?a.after:a.before)||{};return aQ(a.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(a.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),jK((D0)=>D0+1),!0},[aQ]),gK=u.useCallback(async(j)=>{$8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let a=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (ge(),xe)),D0=await W0(a),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":D0.type||"image/png"},body:D0}),$0=await q0.json().catch(()=>({}));if(q0.ok&&$0.path)return{maskAsset:$0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{$8({dgn:"photo-busy",asset:j,busy:!1})}},[$8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},a=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",a),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",a)}},[]);let J6=u.useRef({});J6.current={open:c6,comps:X6,frame:ZJ,total:E5,playing:_5,compId:y7,muted:i,loop:A5,sequences:a8,post:$8,canvas:Z};let S5=u.useRef({undo:[],redo:[]}),P7=u.useCallback((j,b,a)=>{if(typeof b!=="number")return;if(S5.current.undo.push({canvas:j,seq:b,label:a}),S5.current.redo=[],S5.current.undo.length>50)S5.current.undo.shift()},[]),m7=u.useCallback((j)=>{let b=S5.current,a=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,D0=J6.current.canvas,q0=-1;for(let l=a.length-1;l>=0;l--)if(a[l].canvas===D0){q0=l;break}if(q0<0){m8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let $0=a[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:$0.canvas,seq:$0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(a.splice(q0,1),l?.ok)W0.push($0),m8(`${j==="undo"?"Undid":"Redid"}: ${$0.label}`,!0);else m8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>m8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),u7=u.useCallback((j,b)=>{let a=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?a.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?a[b.index]:null)||null;if(typeof b==="string")return a.find((W0)=>W0.stableId===b)||null;return a[b]||null},[]),FQ=u.useCallback((j)=>{let b=J6.current.canvas;if(!b||b===n8)return;let a=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${a?`&artboardId=${encodeURIComponent(a)}`:""}`;fetch(W0).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let q0=u7(D0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:a,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)console.warn("[remove-clip]",D0.error||"failed"),y6("Remove refused",D0.error);else if(D0?.ok){if(m8("Clip removed.",!0),D0.seq!=null)P7(b,D0.seq,"remove clip");lX(null)}}).catch(()=>m8("Remove failed: network error"))},[u7,P7]),LQ=u.useCallback((j,b,a)=>{let W0=J6.current.canvas;if(!W0||W0===n8)return;let D0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${D0?`&artboardId=${encodeURIComponent(D0)}`:""}`;fetch(q0).then(($0)=>$0.json().catch(()=>({}))).then(($0)=>{let l=$0?.ok&&Array.isArray($0.clips)?$0.clips:[],_0=j?.transition?l.find((M0)=>M0.kind==="transition"&&M0.stableId===j.stableId)||null:u7($0,j);if(!_0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:D0,stableId:_0.stableId,contentHash:_0.contentHash,verb:b,...a})})}).then(($0)=>$0?$0.json():null).then(($0)=>{if($0&&!$0.ok)console.warn("[clip-edit]",b,$0.error||"failed"),y6(`${b} refused`,$0.error);else if($0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(m8(`Applied: ${l[b]||b}.`,!0),$0.seq!=null)P7(W0,$0.seq,l[b]||b)}}).catch(()=>m8(`${b} failed: network error`))},[u7,P7,y6]),[DQ,HY]=u.useState(null),cX=u.useCallback((j,b="")=>new Promise((a)=>{HY({title:j,value:b,resolve:a})}),[]),b5=u.useCallback((j)=>{HY((b)=>{return b?.resolve?.(j),null})},[]),zY=u.useCallback((j,b)=>{let a=J6.current.canvas;if(!a||a===n8||!b||!String(b).trim())return;R7({type:"comments-add",payload:{file:a,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),m8("Comment added.",!0)},[]);J6.current.selected=y9,J6.current.setSelected=lX,J6.current.removeClip=FQ,J6.current.clipVerb=LQ,J6.current.addComment=zY,J6.current.askText=cX,u.useEffect(()=>{let j=(b)=>{let a=J6.current;if(!a.open||!a.comps?.length)return;let W0=b.target,D0=W0?.tagName;if(D0==="INPUT"&&W0?.type!=="range")return;if(D0==="TEXTAREA"||D0==="SELECT"||W0?.isContentEditable)return;let q0=XK(a.comps,a.compId)?.fps||30,$0=Math.max(1,a.total),l=(M0)=>{let i0=Math.max(0,Math.min($0-1,Math.round(M0)));TX(i0),uX(!1),a.post({dgn:"timeline-seek",frame:i0,id:a.compId})},_0=()=>{let M0=new Set([0,$0-1]);for(let i0 of a.sequences||[]){M0.add(i0.from);for(let _8 of i0.keyframes||[])M0.add(_8.from),M0.add(_8.to)}return[...M0].filter((i0)=>i0>=0&&i0<$0).sort((i0,_8)=>i0-_8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),m7(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(a.selected!=null)b.preventDefault(),a.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&a.selected!=null){b.preventDefault(),a.removeClip?.({stableId:a.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let M0=a.selected!=null?{stableId:a.selected}:null;if(!M0){let i0=a.sequences||[],_8=i0.find((D8)=>D8.series&&a.frame>=D8.from&&a.frame<D8.from+D8.duration)||i0.find((D8)=>a.frame>=D8.from&&a.frame<D8.from+D8.duration);if(_8?.stableId)M0={stableId:_8.stableId}}if(M0)a.clipVerb?.(M0,"split",{atFrame:a.frame});else m8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),a.playing)uX(!1),a.post({dgn:"timeline-pause",id:a.compId});else uX(!0),a.post({dgn:"timeline-mute",muted:a.muted,id:a.compId}),a.post({dgn:"timeline-loop",loop:a.loop,id:a.compId}),a.post({dgn:"timeline-play",id:a.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(a.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(a.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l($0-1);else if(b.key==="."){b.preventDefault();let M0=_0().find((i0)=>i0>a.frame);if(M0!=null)l(M0)}else if(b.key===","){b.preventDefault();let M0=_0().reverse().find((i0)=>i0<a.frame);if(M0!=null)l(M0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{jJ([]),TX(0),uX(!1),lX(null),UX(null);let j=setTimeout(()=>$8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,$8]);let[r0,iX]=u.useState(""),[KY,n0]=u.useState([]),[sQ,a0]=u.useState([]);u.useEffect(()=>{if(!c6||X6.length===0||!Z||Z===n8){iX(""),n0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")iX(b.source)}).catch(()=>{}),()=>{j=!1}},[c6,X6,Z,VX]),u.useEffect(()=>{if(!c6||!Z||Z===n8||!r0){n0([]),a0([]);return}let j=!0,b=o9||void 0,a=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(a).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let D0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];n0(D0.filter((q0)=>q0.kind==="sequence")),a0(D0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[c6,Z,r0,o9,VX]),u.useEffect(()=>{if(!r0){i6([]),b6([]),dQ([]),t4(0);return}let j=Q8??B?.artboardId??null,a=(j&&X6.find((q0)=>q0.artboardId===j||q0.id===j)||X6[0])?.durationInFrames||0,W0=Jx(r0,a,j);UX(W0.artboardId??j??null);let D0=W0.sequences.map((q0,$0)=>{let l=KY[$0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});i6(D0),b6(W0.audio||[]),dQ(W0.transitions||[]),t4(W0.total)},[r0,KY,B,X6,Q8]);let UY=u.useCallback(()=>{YH((j)=>{let b=!j,a=Z?p8.current.get(Z):null;if(a&&a.contentWindow)try{a.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of p8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{GH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),XG=u.useCallback(()=>{sW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{sW(!1),BX({present:!1})},[BX]),eQ=u.useCallback(()=>{if(!Z||Z===n8)return;uJ((j)=>{let b=!j;return $8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,$8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let a=b&&typeof b.name==="string"?b.name.trim():"";if(a)tW(a)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===n8){NQ(0),uJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let a=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(a),uJ(b?.overlays?.print===!0),J4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),uJ(!1),J4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===n8||!Q8)return;let j=setTimeout(()=>{$8({dgn:"request-layers",artboardId:Q8})},250);return()=>clearTimeout(j)},[Z,Q8,$8]);let[X4,J4]=u.useState(()=>new Set),JG=u.useCallback((j)=>{if(!Z||Z===n8)return;J4((b)=>{let a=new Set(b);if(a.has(j))a.delete(j);else a.add(j);let W0=[...a];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),$8({dgn:"locked-set",locked:W0}),a})},[Z,$8]);u.useEffect(()=>{if(!Z||Z===n8)return;$8({dgn:"locked-set",locked:[...X4]})},[X4,Z,$8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(_00,F9)}catch{}for(let j of p8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(ce,K7?"1":"0")}catch{}},[K7]),u.useEffect(()=>{try{localStorage.setItem(pe,R9?"1":"0")}catch{}},[R9]),u.useEffect(()=>{try{localStorage.setItem(le,JSON.stringify(e))}catch{}},[e]),u.useEffect(()=>{try{localStorage.setItem(ie,mJ?"1":"0")}catch{}},[mJ]),u.useEffect(()=>{try{localStorage.setItem(oe,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(ne,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")S9(b.theme);if(typeof b.minimap==="boolean")GH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")YH(b.annotations);if(typeof b.autoOpenInspector==="boolean")cW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...RK,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")p9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)hK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!WH)return;rq0({theme:F9,minimap:mJ,zoom:j6,annotations:BQ,autoOpenInspector:xJ,panelSides:k9,layersMode:T9})},[WH,F9,mJ,j6,BQ,xJ,k9,T9]),u.useEffect(()=>{try{localStorage.setItem(re,JSON.stringify(k9))}catch{}},[k9]),u.useEffect(()=>{try{localStorage.setItem(ae,T9)}catch{}},[T9]);let QG=u.useCallback((j,b)=>{A0((a)=>{let W0=a[j],D0=W0===void 0?b:W0;return{...a,[j]:!D0}})},[]),Q4=u.useCallback(()=>{S9((j)=>j==="dark"?"light":"dark")},[]),G7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let a=b.groups.map((W0)=>({...W0,tree:Q20(W0.paths,W0.stripPrefix,W0.dirs)}));J(a),B8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{G7()},[G7]);let pJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",a=await fetch(b);if(!a.ok){console.error("failed to load system-data",a.status);return}let W0=await a.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){T8(W0);let D0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(D0.ok)T8(await D0.json());return}T8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();o8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let a=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(a+"//"+location.host+"/_ws");ZY.current=W0,W0.addEventListener("open",()=>{n(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{n(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(D0)=>{try{let q0=JSON.parse(D0.data);if(q0.type==="snapshot"&&q0.state)N(($0)=>L00(q0.state.selected,$0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let $0=q0.selected,l=Array.isArray($0)?$0[0]:$0,_0=F.current,M0=Array.isArray(_0)?_0[0]:_0;if(N((i0)=>L00($0,i0)),l?.id&&l.file&&(!M0||M0.id!==l.id||M0.file!==l.file))O(l)}else if(q0.type==="comments"&&typeof q0.file==="string")o8(($0)=>({...$0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(GY(!0),rQ.current)clearTimeout(rQ.current);rQ.current=setTimeout(()=>GY(!1),8000);for(let $0 of p8.current.values())try{$0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)QY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)X0(q0.payload);else if(q0.type==="canvas-list-update"){if(G7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let $0=(v0?.designRel||v0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${$0}/${q0.payload.fromRel}`,_0=`${$0}/${q0.payload.rel}`;G((M0)=>M0.map((i0)=>i0.path===l?{path:_0}:i0)),H((M0)=>M0===l?_0:M0)}}else if(q0.type==="config-updated")U8();else if(q0.type==="acp-focus"){if(W9())gJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!F0.current)U0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let $0 of p8.current.values())try{$0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),ZY.current)ZY.current.close()}},[G7,U8]);function R7(j){let b=ZY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(F0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)U0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(F0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)J8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let a=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await a.json().catch(()=>({}));return{ok:a.ok,...W0}}catch(a){return{ok:!1,error:"Network error — is the project still open?"}}},[]),YG=u.useCallback(async(j,b)=>{let a=await FX("/_api/git/commit",{message:j,files:b});if(a.ok)await NX();return a},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),WG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)H8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),GG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),a=await fetch(b);if(!a.ok)return[];return(await a.json()).entries||[]}catch{return[]}},[]),[ZG,HG]=u.useState(null),zG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),a=await fetch(b);if(!a.ok)return null;let W0=await a.json();if(!W0?.ok)return null;return HG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),KG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(V8)return b;for(let a of N0?.files||[])b.set(a.path,j[a.status]);return b},[N0,V8]);u.useEffect(()=>{if(V8){J8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[V8,N0?.repo,o0,kX]);let z6=u.useCallback((j)=>{if(G((b)=>{for(let a of b)if(a.path!==j)p8.current.delete(a.path);return[{path:j}]}),H(j),N9(null),U(null),j!==n8)E9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!v0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let a of b.paths||[]){if(!GQ.test(a))continue;if(/(^|\/)system\//.test(a))continue;j=a;break}if(j)break}if(!j)return;DY.current=!0,z6(j)},[v0.cloud,X,W.length,z6]);let lJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)pJ(b);else if(!K8)pJ();z6(n8)},[K8,pJ,z6]);u.useEffect(()=>{R7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==n8)})},[W]),u.useEffect(()=>{if(Z&&Z!==n8)R7({type:"active",file:Z});else if(Z===n8)R7({type:"active",file:""});else R7({type:"active",file:""})},[Z]);let Y4=u.useCallback((j)=>{G((b)=>{let a=b.findIndex((D0)=>D0.path===j);if(a<0)return b;let W0=b.filter((D0)=>D0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,a-1)].path);return W0}),p8.current.delete(j),E9((b)=>b===j?null:b)},[Z]),KJ=u.useCallback(()=>{if(!Z||Z===n8){if(Z===n8)pJ();return}let j=p8.current.get(Z);if(j)j.src=j.src},[Z,pJ]),MY=u.useCallback(()=>G7(),[G7]),[UG,OY]=u.useState(!1),W4=u.useRef(!1),G4=u.useCallback(async()=>{if(W4.current)return;W4.current=!0,OY(!0);try{await Promise.all([G7(),new Promise((j)=>setTimeout(j,550))])}finally{W4.current=!1,OY(!1)}},[G7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,MY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[MY]);let VG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),a=await b.json().catch(()=>({}));if(!b.ok||!a.ok)return{ok:!1,error:a.error||`create failed (${b.status})`};return await G7(),z6(a.file),{ok:!0,file:a.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[G7,z6]),_Y=u.useCallback(async()=>{let j=await cX("New video name");if(!j)return;let a=(await cX("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=a?Number(a[1]):1920,D0=a?Number(a[2]):1080,q0=Math.max(1,Math.min(60,Number(await cX("Frames per second","30"))||30));try{let $0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:D0})}),l=await $0.json().catch(()=>({}));if(!$0.ok||!l.ok){m8(`New video failed: ${l.error||`error ${$0.status}`}`);return}await G7(),z6(l.file),zQ(!0),m8("New video created — drop clips on the timeline to start the cut.",!0)}catch($0){m8(`New video failed: ${$0 instanceof Error?$0.message:"network error"}`)}},[G7,z6,cX]),qG=u.useCallback(async()=>{if(!Z||Z===n8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",a=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let _0 of l.querySelectorAll('[data-tool="mediaref"]')){let M0=_0.getAttribute("data-src");if(!M0)continue;a.push({src:M0,mediaKind:_0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(a.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let D0=`${pW(kK(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D0,kind:"video-comp",clips:a})}),$0=await q0.json().catch(()=>({}));if(!q0.ok||!$0.ok){window.alert(`Assemble failed: ${$0.error||`error ${q0.status}`}`);return}await G7(),z6($0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,G7,z6]),Z4=u.useCallback(({accept:j,resolveTarget:b})=>{let a=Z,W0=o9||void 0,D0=document.createElement("input");D0.type="file",D0.accept=j,D0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(D0);let q0=()=>{if(D0.isConnected)D0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),D0.addEventListener("change",()=>{let $0=D0.files?.[0];if(q0(),!$0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(a)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let M0=b(_0);if(!M0)return m8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":$0.type||"application/octet-stream"},body:$0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return m8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(M0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:a,arrayName:M0.arrayRef.arrayName,index:M0.arrayRef.index,field:M0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:a,id:M0.cdId,attr:"src",value:i0.path})})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)m8(`Replace refused: ${_0.error||"failed"}`);else if(_0&&_0.ok){if(m8("Media replaced.",!0),_0.seq!=null)P7(a,_0.seq,"replace media")}}).catch(()=>m8("Replace failed: network error"))}),D0.click()},[Z,o9,P7]),BG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5654
5654
|
|
|
5655
5655
|
Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let W0=await fetch(`/_api/canvas?file=${encodeURIComponent(j)}`,{method:"DELETE"}),D0=await W0.json().catch(()=>({}));if(!W0.ok||!D0.ok){window.alert(`Could not delete: ${D0.error||`error ${W0.status}`}`);return}if(await G7(),Z===j)G([]),H(null)}catch(W0){window.alert(`Delete failed: ${W0 instanceof Error?W0.message:"network error"}`)}},[G7,Z]),NG=u.useCallback(async function j(b,a){try{let W0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:a})}),D0=await W0.json().catch(()=>({}));if(!W0.ok||!D0.ok)return m8(`Could not move: ${D0.error||`error ${W0.status}`}`),{ok:!1,error:D0.error};let q0=(v0?.designRel||v0?.designRoot||".design").replace(/^\/+|\/+$/g,""),$0=`${q0}/${D0.fromRel}`,l=`${q0}/${D0.toRel}`;await G7(),G((M0)=>M0.map((i0)=>i0.path===$0?{path:l}:i0)),H((M0)=>M0===$0?l:M0);let _0=$0.split("/").slice(0,-1).join("/");return m8(`Moved to ${D0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{j(l,_0)}}),{ok:!0}}catch(W0){return m8(`Move failed: ${W0 instanceof Error?W0.message:"network error"}`),{ok:!1,error:"network error"}}},[G7,v0]),FG=u.useCallback(async(j,b)=>{try{let a=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:j,name:b})}),W0=await a.json().catch(()=>({}));if(!a.ok||!W0.ok){let D0=W0.error||`error ${a.status}`;return m8(`Could not create folder: ${D0}`),{ok:!1,error:D0}}return await G7(),{ok:!0,dir:W0.dir}}catch(a){let W0=a instanceof Error?a.message:"network error";return m8(`Create folder failed: ${W0}`),{ok:!1,error:W0}}},[G7]),LG=u.useCallback(async(j,b)=>{if(!window.confirm(`Delete folder "${b}"?
|
|
5656
5656
|
|