@1agh/maude 0.51.0 → 0.51.1

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}`:V,L=[],D=new Map;for await(let w of X.prompt(F,J(),q,Q?.(),Y?.(),Z?.
5650
5650
 
5651
5651
  > Maude ${m.app.maudeVersion} · ${m.app.platform} ${m.app.arch} · ${m.app.surface}
5652
5652
  > Local report bundle: \`${p?.dir??".design/_reports/"}\` (attach its files here)`),s=`${uG0}?title=${r}&body=${h}&labels=report`;if(d8())try{await GU(s)}catch{window.open(s,"_blank","noopener")}else window.open(s,"_blank","noopener");_({fallbackDir:p?.dir??null}),Y("done")}catch{P("Saving the local bundle failed too — please file the issue by hand.")}}let g=W.trim().length>0;return z("div",{className:"help-modal-backdrop",onClick:S,"data-testid":"report-bug-dialog",children:A("div",{className:"help-modal rb-modal",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(m)=>m.stopPropagation(),children:[A("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"help-modal-close",onClick:S,"aria-label":"Close",children:"×"})]}),A("div",{className:"help-modal-body rb-body",children:[Q==="describe"&&A(Y0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"rb-desc","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:W,onChange:(m)=>G(m.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."}),A("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"rb-btn",onClick:S,children:"Cancel"}),z("button",{type:"button",className:"rb-btn rb-primary","data-testid":"report-bug-preview",disabled:!g,onClick:()=>Y("preview"),children:"Review & attach"})]})]}),Q==="preview"&&A(Y0,{children:[A("div",{className:"rb-section",children:[A("div",{className:"rb-section-hd",children:[A("span",{children:["Screenshots (",q.length,")"]}),q.length>0&&z("button",{type:"button",className:`rb-link${D?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>w((m)=>!m),children:D?"Done redacting":"Redact…"})]}),q.length===0?A("p",{className:"rb-hint",children:["No screenshot attached. Paste one (⌘V) to add it — up to ",uw,"."]}):A(Y0,{children:[D&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:q.map((m,c)=>z(pG0,{shot:m,redacting:D,onRects:(f)=>K((p)=>p.map((r,h)=>h===c?{...r,rects:f}:r)),onRemove:()=>{URL.revokeObjectURL(m.url),K((f)=>f.filter((p,r)=>r!==c))}},m.url))}),q.length<uw&&z("p",{className:"rb-hint",children:"Paste (⌘V) to attach another screenshot."})]})]}),A("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),A("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),A("span",{children:["Maude ",Z?.app?.maudeVersion??"…"," · ",Z?.app?.platform??"…"," ",Z?.app?.arch??""," · ",d8()?"desktop app":"browser"]})]}),Z?.context?.activeCanvas&&A("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(m)=>L({...F,activeCanvas:m.target.checked})}),A("span",{children:["Active canvas path — ",z("code",{children:Z.context.activeCanvas})]})]}),Z?.context?.projectName&&A("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(m)=>L({...F,projectName:m.target.checked})}),A("span",{children:["Project name — ",z("code",{children:Z.context.projectName})]})]}),Z?.logs?.serverLogTail?A("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(m)=>L({...F,logTail:m.target.checked})}),A("span",{children:["Recent server log (",Z.logs.serverLogTail.split(`
5653
- `).length," lines, paths & secrets scrubbed) —"," ",A("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,d8()&&V.length>0&&A("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(m)=>L({...F,crashLogs:m.target.checked})}),A("span",{children:["Crash logs (",V.length,") — ",z("code",{children:V.map((m)=>m.name).join(", ")})]})]})]}),A("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"rb-btn",onClick:()=>Y("describe"),children:"Back"}),z("button",{type:"button",className:"rb-btn rb-primary","data-testid":"report-bug-send",onClick:b,children:"Send report"})]})]}),Q==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&A(Y0,{children:[R?.issueUrl?A("p",{children:["Thank you — your report is filed as"," ",A("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(d8())GU(R.issueUrl).catch(()=>navigator.clipboard?.writeText(R.issueUrl));else window.open(R.issueUrl,"_blank","noopener")},children:["report #",R.issueNumber]}),". Screenshots and logs stay in a private tracker."]}):A("p",{children:["The bundle is saved locally",R?.fallbackDir?A(Y0,{children:[" ","at ",z("code",{children:R.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:"rb-btn rb-primary",onClick:S,children:"Done"})})]}),Q==="fallback"&&A(Y0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:O}),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."}),A("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"rb-btn",onClick:()=>Y("preview"),children:"Back"}),z("button",{type:"button",className:"rb-btn rb-primary",onClick:y,children:"Save locally & open GitHub"})]})]})]})]})})}var wX=T8(j8(),1);function Tv(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 Iv(X,J){let Q=Tv(X),Y=Tv(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 Cv(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Iv(Q.version,J)))}function Sv(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Iv(Y.version,Q))Q=Y.version}return Q}var lw="mdcc-whatsnew-seen",dw="mdcc-whatsnew-toast-dismissed";function cG0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function iG0(X){try{let J=localStorage.getItem(lw);if(J)return J;localStorage.setItem(lw,X)}catch{}return X}function oG0(){try{return localStorage.getItem(dw)}catch{return null}}function $v(X){let[J,Q]=wX.useState([]),[Y,W]=wX.useState(X),[G,Z]=wX.useState(()=>iG0(X)),[H,q]=wX.useState(()=>oG0()),[K,V]=wX.useState(!1);wX.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then((S)=>S.json()).then((S)=>{if(O)return;if(Q(Array.isArray(S?.entries)?S.entries:[]),typeof S?.version==="string")W(S.version)}).catch(()=>{})};P();let T=()=>P(),I=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",I),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",I)}},[]);let B=Cv(J,G),F=B.length>0&&H!==Y&&!K,L=B[0]??null,D=wX.useCallback(()=>{let O=Sv(J,Y);Z(O),q(Y);try{localStorage.setItem(lw,O),localStorage.setItem(dw,Y)}catch{}},[J,Y]),w=wX.useCallback(()=>{q(Y);try{localStorage.setItem(dw,Y)}catch{}},[Y]),R=wX.useCallback(()=>V(!0),[]),_=wX.useCallback(()=>{V(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:K,openPanel:R,closePanel:_,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:D}}function bv({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return A("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:"×"}),A("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}),A("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 jv({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(wX.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:A("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[A("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)=>A("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[A("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}),cG0(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 S9=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ps="mdcc-usage-tour-seen",cs="mdcc-collab-tour-seen",l8="__system__",Rt="mdcc-theme",is="mdcc-show-hidden",os="mdcc-sections-expanded",ns="maude-cp-mode",rs="mdcc-sidebar-open",as="mdcc-minimap-visible",ss="mdcc-zoomctl-visible",ts="mdcc-annotations-visible";var QV0=30000;function YV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var yP=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],vq={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},es="mdcc-panel-sides",Xt="mdcc-layers-mode";function Jt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return A("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((H)=>z("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(yP.find((q)=>q.id===H)||{}).label||H},H))}),Z]})}var YQ=/\.(tsx|html?)$/i;function PF(X){return X.replace(/^\.[^/]+\//,"").replace(YQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var vP="0.50.0";function Qt(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function WV0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Rt);if(X==="light"||X==="dark")return X}catch{}return"dark"}function NZ(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 CP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function GV0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function TF(X){return X.split("/").pop()}function l9(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(l9._t),l9._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var Yt="maude-browse-hint-seen";function ZV0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(Yt)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let X=document.createElement("div");X.id="st-browse-hint",X.setAttribute("role","status"),X.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;",X.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <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> to select &amp; edit like Figma.</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 J=()=>{try{localStorage.setItem(Yt,"1")}catch{}X.style.opacity="0",setTimeout(()=>X.remove(),200),document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)J()};X.querySelector("button")?.addEventListener("click",J),document.addEventListener("keydown",Q,!0),document.body.appendChild(X),requestAnimationFrame(()=>{X.style.opacity="1"}),setTimeout(J,9000)}function zW(X){return X.replace(YQ,"")}function HV0(X){return X.replace(YQ,"")}function qV0(X){let J=new Map;for(let G of X){if(!YQ.test(G.name))continue;let Z=HV0(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(YQ.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((q,K)=>q.name.localeCompare(K.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 zV0(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 q of Z)H=H[q]=H[q]||{};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 q=0;q<Z.length;q++){let K=Z[q];if(q===Z.length-1)H._files=H._files||[],H._files.push({name:K,path:W});else H[K]=H[K]||{},H=H[K]}}return Y}function kt(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=kt(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 Wt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function KV0(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 Tt(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 RF({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 UV0={"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:A(Y0,{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":A(Y0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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"})]}),"panel-left":A(Y0,{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:A(Y0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:A(Y0,{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:A(Y0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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 VV0({open:X,onClose:J,actions:Q}){let[Y,W]=d.useState(""),[G,Z]=d.useState(0),H=d.useRef(null);d.useEffect(()=>{if(X)W(""),Z(0)},[X]),d.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let q=d.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(d.useEffect(()=>{if(G>=q.length)Z(0)},[q.length,G]),!X)return null;let K=(V)=>{J(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)J()},children:A("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[A("div",{className:"st-pal-search",children:[z(X9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),J();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(q.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),q[G])K(q[G])}}}),z(d6,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:q.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):q.map((V,B)=>{let F=V.group&&(B===0||q[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return A(Y0,{children:[F,A("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>K(V),children:[z("span",{className:"st-pal-icon",children:z(X9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(d6,{children:V.kbd})}):null]})]},V.id)})})]})})}function X9({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:UV0[X]})}function BV0(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 Gt({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 d6({children:X}){return z("span",{className:"kbd",children:X})}function Zt(X,{min:J,max:Q,def:Y}){let W=d.useCallback((q)=>Math.min(Q,Math.max(J,q)),[J,Q]),[G,Z]=d.useState(()=>{try{let q=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(q)?W(q):Y}catch{return Y}});d.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=d.useCallback((q)=>Z((K)=>W(typeof q==="function"?q(K):q)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function Ht({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:q,def:K}=J,V=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":q,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(K),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((L)=>L+F*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((L)=>L-F*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(q)},children:A("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 SP=[{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}],$P={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},FV0={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"]},NV0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],gV=[{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}],LV0="2x",qt=[{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}],DV0="auto",OV0={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 MV0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return OV0[J]||"application/octet-stream"}function wV0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=d.useState(null),[q,K]=d.useState(!1),[V,B]=d.useState(null),[F,L]=d.useState(()=>new Set),[D,w]=d.useState({}),[R,_]=d.useState(W?"artboard":"annotation");d.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((p)=>p.json()).then((p)=>{if(!f)return;let r=p.ok?p.assets:[];H(r),w((h)=>{let s={...h};for(let X0 of r)s[X0.path]=X0.kind;return s})}).catch(()=>f&&H([])),()=>{f=!1}},[]),d.useEffect(()=>{let f=(p)=>{if(p.key==="Escape")p.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(F).some((f)=>(D[f]||"image")!=="image"),P=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";d.useEffect(()=>{if(P&&R==="artboard")_("annotation")},[P,R]);let I=(f)=>{L((p)=>{let r=new Set(p);if(r.has(f))r.delete(f);else r.add(f);return r})},S=async(f)=>{let p=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),r=await p.json().catch(()=>({}));if(p.ok&&r.path)return{ok:!0,path:r.path};return{ok:!1,error:r.error||`upload failed (HTTP ${p.status})`}},C=async(f)=>{if(!f)return;K(!0),B(null);let p=await S(f);if(K(!1),p.ok)J(p.path);else B(p.error)},b=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},y=async(f)=>{if(!f.length)return;K(!0),B(null);let p=await Promise.all(f.map((s)=>S(s).then((X0)=>({...X0,file:s}))));K(!1);let r=p.filter((s)=>s.ok),h=p.length-r.length;if(h>0)B(`${h} of ${p.length} uploads failed`);if(r.length)w((s)=>{let X0={...s};for(let o of r)X0[o.path]=b(o.file.type);return X0}),L((s)=>{let X0=new Set(s);for(let o of r)X0.add(o.path);return X0})},g=async()=>{K(!0),B(null);try{if(Y){let r=(await zf()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:MV0(h.name)}));if(K(!1),r.length)await y(r);return}let f=await o2();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}K(!1)},m=()=>{if(d8()){g();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let p=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(p,300),{once:!0}),f.addEventListener("change",()=>{let r=f.files?Array.from(f.files):[];if(p(),!r.length)return;if(Y)y(r);else C(r[0])}),f.click()},c=(f)=>`/${X}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:A("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[A("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(X9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[A("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:m,disabled:q,children:q?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),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((f)=>{let p=Y&&F.has(f.path);return A("button",{type:"button",className:"st-ap-cell","data-selected":p?"true":void 0,"aria-pressed":Y?p:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?I(f.path):J(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:p?z(X9,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:c(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:c(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&F.size>0&&A("div",{className:"st-dialog-ft st-ap-confirm",children:[A("span",{className:"st-ap-count",children:[F.size," selected"]}),A("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:()=>_("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>_("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),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(F),R),children:"Insert"})]})]})})}function AV0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:Z}){let[H,q]=d.useState(X==="handoff"?"shadcn":"png"),[K,V]=d.useState(J&&$P[J]?J:"artboard"),[B,F]=d.useState(2),[L,D]=d.useState(LV0),[w,R]=d.useState(!0),[_,O]=d.useState(!1),[P,T]=d.useState(!1),[I,S]=d.useState(!1),[C,b]=d.useState(DV0),[y,g]=d.useState(!0),[m,c]=d.useState(!1),[f,p]=d.useState(null),[r,h]=d.useState([]),s=SP.find((i)=>i.id===H)||SP[0],X0=s.handoff?[]:FV0[s.format]||["artboard"];d.useEffect(()=>{if(X0.length&&!X0.includes(K))V(X0[0])},[X0,K]);let o=d.useCallback(()=>{fetch("/_api/export-history").then((i)=>i.json()).then((i)=>h(Array.isArray(i?.history)?i.history.slice(0,6):[])).catch(()=>{})},[]);d.useEffect(()=>{o()},[o]),d.useEffect(()=>{function i(u){if(u.key==="Escape")u.preventDefault(),Z()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Z]);async function U0(){if(s.handoff){let n=`/design:handoff ${Q&&Q!==l8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(n)}catch{}p({ok:!0,msg:`Copied: ${n} — run it in Claude Code.`});return}c(!0),p(null);let i=s.temporal?{scale:B}:{};if(s.format==="png"){let u=gV.find((n)=>n.id===L)||gV[1];if(u.kind==="dpi")i.dpi=u.value;else i.scale=u.value}if(s.format==="mp4"||s.format==="webm")i.audio=y;if(s.format==="pdf"){i.pdfPrint={includeBleed:w,marks:{crop:P,registration:I}};let u=qt.find((n)=>n.id===C)?.value;if(u!==void 0)i.dpi=u}if(W)i.artboardId=W;if(G?.selector)i.selection=G;try{let u=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:K,options:i})});if(!u.ok){p({ok:!1,msg:await u.text()||`Export failed (${u.status})`}),c(!1);return}Z()}catch(u){p({ok:!1,msg:u&&u.message?u.message:String(u)}),c(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)Z()},children:A("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[A("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:Z,children:z(X9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==l8?`Format · ${zW(TF(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:SP.filter((i)=>!i.temporal||Y).map((i)=>A("button",{type:"button",className:"st-fmt"+(i.id===H?" is-on":""),onClick:()=>{q(i.id),p(null)},children:[z(X9,{name:i.icon,size:16}),z("span",{className:"st-fmt-name",children:i.label}),z("span",{className:"st-fmt-sub",children:i.sub})]},i.id))}),!s.handoff&&A("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:K,onChange:(i)=>V(i.target.value),children:X0.map((i)=>z("option",{value:i,children:$P[i]},i))})]}),!s.handoff&&s.format==="png"&&A("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:L,onChange:(i)=>D(i.target.value),children:gV.map((i)=>z("option",{value:i.id,children:i.label},i.id))})]}),!s.handoff&&s.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let i=gV.find((n)=>n.id===L)||gV[1],u=i.kind==="dpi"?i.value/96:i.value;return`${i.label} ≈ ${Math.round(1440*u)}×${Math.round(900*u)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&A("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:B,onChange:(i)=>F(Number(i.target.value)),children:NV0.map((i)=>z("option",{value:i.value,children:i.label},i.value))})]}),!s.handoff&&s.temporal&&A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!s.handoff&&s.format==="pdf"&&A(Y0,{children:[A("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:C,onChange:(i)=>b(i.target.value),children:qt.map((i)=>z("option",{value:i.id,children:i.label},i.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:A("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:w,onChange:(i)=>R(i.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:A("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>O((i)=>!i),"aria-expanded":_,children:[_?"▾":"▸"," Marks"]})}),_&&A("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:P,onChange:(i)=>T(i.target.checked)}),"Crop marks"]}),A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:(i)=>S(i.target.checked)}),"Registration marks"]})]}),A("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.",K==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&z("div",{className:"st-dialog-row",children:A("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:y,onChange:(i)=>g(i.target.checked)}),"Export with audio"]})}),s.handoff&&A("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}),r.length>0&&A("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map((i,u)=>A("div",{className:"st-export-recent-row",children:[A("span",{children:[String(i.format||"").toUpperCase()," ·"," ",$P[i.scope]||i.scope]}),z("span",{className:"st-mono",children:i.filename})]},u))]})]}),A("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:Z,children:"Cancel"}),A("button",{type:"button",className:"btn btn--primary",disabled:m,onClick:U0,children:[z(X9,{name:"download",size:14}),s.handoff?"Copy handoff command":m?"Exporting…":`Export ${s.label}`]})]})]})})}var IF=12,CF=16;function _V0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,q]=d.useState(Q),K=G?G.dropProps(W,!0,()=>q(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},F=G?.draggedPath===W,L=G?.busyPath===W,D=A("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":L||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(F?" is-dragging":"")+(L?" is-busy":""),style:{paddingLeft:IF+J*CF+"px"},onClick:()=>q((w)=>!w),onContextMenu:Z?(w)=>Z.openAt(w,{kind:"dir",dirPath:W}):void 0,...B,...K,children:[z("span",{className:"st-row-glyph",children:z(X9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return A(Y0,{children:[Z?A("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(w)=>Z.openAt(w,{kind:"dir",dirPath:W}),children:z(RF,{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 EV0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,q]=d.useState(Y);return A(Y0,{children:[A("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:IF+Q*CF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>q((K)=>!K),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(X9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),A("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(X9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function fP({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:q,experimentalKind:K,drag:V,menu:B}){let F=X.path===J,L=YQ.test(X.name),D=!L,w=L?zW(X.name):X.name,R=L&&typeof Y==="function"&&Z!=="runtime",_=L&&!H&&Z!=="runtime"&&typeof V<"u",O=_?V.dragProps(X.path,!0):{},P=V?.draggedPath===X.path,T=V?.busyPath===X.path,I=_&&typeof B<"u",S=X.path.split("/").slice(0,-1).join("/"),C=L?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(YQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,b=A("button",{type:"button",role:"treeitem","data-testid":C,"aria-selected":F,"aria-disabled":D?"true":void 0,"aria-busy":T||void 0,tabIndex:F?0:-1,className:"st-row"+(F?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(P?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:IF+G*CF+"px"},title:X.path+(W?` — ${W} open`:D?" (file index only)":""),onClick:()=>{if(!D)Q(X.path)},onContextMenu:I?(y)=>B.openAt(y,{kind:"file",path:X.path,dir:S}):void 0,...O,children:[z("span",{className:"st-row-glyph",children:z(X9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:w}),K==="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"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),W>0&&z("span",{className:"st-row-badge",children:W})]});if(!R&&!I)return b;return A("div",{className:"st-row-wrap",role:"none",children:[b,I&&z("button",{type:"button",className:"st-row-menu-btn"+(R?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${w}…`,"aria-label":`Actions for ${w}`,"aria-haspopup":"menu",onClick:(y)=>B.openAt(y,{kind:"file",path:X.path,dir:S}),children:z(RF,{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})}),R&&z("button",{type:"button",className:"st-row-del",title:`Delete ${w}`,"aria-label":`Delete canvas ${w}`,onClick:(y)=>{y.stopPropagation(),Y(X.path,w)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function PV0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:q,forceOpen:K,dirtyByPath:V,experimentalKind:B,drag:F,menu:L}){let D=V?.get(X.path),w=J.length>0,[R,_]=d.useState(!1),O=K||R,P=X.path===W;if(!(w&&q))return z(fP,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:D,experimentalKind:B,drag:F,menu:L});let I=typeof F<"u",S=I?F.dragProps(X.path,!0):{},C=F?.draggedPath===X.path,b=F?.busyPath===X.path,y=I&&typeof L<"u",g=X.path.split("/").slice(0,-1).join("/"),m=A("button",{type:"button",role:"treeitem","aria-selected":P,"aria-expanded":O,"aria-busy":b||void 0,tabIndex:P?0:-1,className:"st-row st-canvas-row"+(P?" is-sel":"")+(C?" is-dragging":"")+(b?" is-busy":""),style:{paddingLeft:IF+Q*CF+"px"},title:X.path,onClick:(c)=>{if(c.target.closest(".st-canvas-chev")){_((f)=>!f);return}G(X.path)},onContextMenu:y?(c)=>L.openAt(c,{kind:"file",path:X.path,dir:g}):void 0,...S,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(c)=>{c.stopPropagation(),_((f)=>!f)},children:z(X9,{name:"chevron-right",className:"st-chev"+(O?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:zW(X.name)}),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"}),D&&z("span",{className:"st-git-badge","data-kind":D,title:`Unsaved (${D})`,"aria-label":`Unsaved, ${D}`,children:D}),H>0&&z("span",{className:"st-row-badge",children:H})]});return A(Y0,{children:[y?A("div",{className:"st-row-wrap",role:"none",children:[m,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${zW(X.name)}…`,"aria-label":`Actions for ${zW(X.name)}`,"aria-haspopup":"menu",onClick:(c)=>L.openAt(c,{kind:"file",path:X.path,dir:g}),children:z(RF,{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})})]}):m,O&&J.map((c)=>z(fP,{file:c,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},c.path))]})}function It({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:q,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L,dirPath:D="",drag:w,menu:R}){let _=Object.keys(X).filter((C)=>C!=="_files").sort(),O=X._files||[],{canvases:P,orphans:T}=d.useMemo(()=>qV0(O),[O]),I=!!(H&&H.trim()),S=d.useMemo(()=>{if(!q||W!==1)return null;let C=new Map;for(let b of q)C.set(b.folder,b);return C},[q,W]);return A(Y0,{children:[P.map((C)=>{let b=I&&C.sidecars.some((y)=>{let g=H.toLowerCase();return y.name.toLowerCase().includes(g)||y.path.toLowerCase().includes(g)});return z(PV0,{primary:C.primary,sidecars:C.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:Wt(Y[C.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:b,dirtyByPath:F,experimentalKind:L?.[C.primary.path],drag:w,menu:R},C.primary.path)}),Z&&T.map((C)=>z(fP,{file:C.primary,activePath:J,onOpen:Q,openCount:Wt(Y[C.primary.path]),depth:W,kind:G},C.primary.path)),_.map((C)=>{let b=S?.get(C),y=D?`${D}/${C}`:C,g=z(It,{node:X[C],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L,dirPath:y,drag:w,menu:R});if(b&&V)return z(EV0,{name:C,dsName:b.name,depth:W,defaultOpen:!0,active:J===l8&&b.name===K,onOpenSystem:V,children:g},C);return z(_V0,{name:C,depth:W,defaultOpen:!0,dirPath:y,drag:w,menu:R,children:g},C)})]})}var AF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function RV0(X){if(X.kind==="project")return AF.project;if(X.kind==="runtime")return AF.runtime;if(X.label==="Design system")return AF.ds;if(X.label==="UI kit")return AF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function kV0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:q,showHidden:K,sectionsExpanded:V,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:D,refreshing:w,collapsed:R,onCollapse:_,width:O,resizing:P,dirtyByPath:T,project:I,gitBranch:S,remoteSync:C,onGetLatest:b,canvasKinds:y,onMoveCanvas:g,onNewFolder:m,onDeleteFolder:c}){let f=d.useMemo(()=>{if(!Z)return X;return X.map((g0)=>({...g0,tree:kt(g0.tree,Z),filtered:!!Z}))},[X,Z]),p=cC(g),r=dC(),h=d.useMemo(()=>{let g0=[];for(let R8 of X){if(R8.label==="Design system"||R8.kind!=="canvas")continue;let r0=R8.fullPath.replace(/^\.[^/]+\//,"")||R8.fullPath;g0.push({path:R8.fullPath,label:r0});for(let f8 of R8.dirs||[])g0.push({path:f8,label:f8.replace(/^\.[^/]+\//,"")})}return g0},[X]),s=r.state?.extra,X0=s?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>r.showMoveTo()}]:s?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{r.close();let g0=window.prompt("New folder name:");if(g0?.trim())m(s.dirPath,g0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{r.close(),c(s.dirPath,s.dirPath.split("/").pop())}}]:[],o=s?.kind==="file"?h.filter((g0)=>g0.path!==s.dir):[],[U0,i]=d.useState(!1),[u,n]=d.useState("board"),[V0,m0]=d.useState(""),[J8,Q8]=d.useState(""),[t0,F8]=d.useState(!1),Z8=d.useMemo(()=>X.find((g0)=>g0.kind==="canvas"&&g0.label!=="Design system")?.fullPath,[X]),N8=d.useCallback(async()=>{let g0=V0.trim();if(!g0||t0)return;if(F8(!0),Q8(""),u==="folder"){if(!Z8){F8(!1),Q8("no canvas group to create a folder in");return}let r0=await m(Z8,g0);if(F8(!1),r0?.ok)i(!1),m0("");else Q8(r0?.error||"could not create folder");return}let R8=await F(g0);if(F8(!1),R8?.ok)i(!1),m0("");else Q8(R8?.error||"could not create board")},[V0,t0,F,m,u,Z8]),p8=d.useMemo(()=>{let g0=0;for(let R8 of X)for(let r0 of R8.paths||[])if(YQ.test(r0))g0++;return g0},[X]),A8=d.useMemo(()=>{let g0=0;for(let R8 of f)for(let r0 of R8.paths||[])if(YQ.test(r0))g0++;return g0},[f]);return A("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(P?" is-resizing":""),style:R||!O?void 0:{width:O,flexBasis:O},"aria-label":"Files","data-tour":"sidebar",children:[A("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),A("div",{className:"st-sb-hd-actions",children:[z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":U0&&u==="board",onClick:()=>{Q8(""),n("board"),i((g0)=>u==="board"?!g0:!0)},children:z(X9,{name:"plus",size:15})}),Z8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":U0&&u==="folder",onClick:()=>{Q8(""),n("folder"),i((g0)=>u==="folder"?!g0:!0)},children:z(X9,{name:"folder-plus",size:15})}),D&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>D(),children:z(X9,{name:"reload",size:15})}),A("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),A8," / ",p8]}),_&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:_,children:z(X9,{name:"panel-left",size:15})})]})]}),U0?A("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:u==="folder"?"folder name…":"brief board name…",value:V0,maxLength:60,disabled:t0,"aria-label":u==="folder"?"New folder name":"New brief board name",onChange:(g0)=>m0(g0.target.value),onKeyDown:(g0)=>{if(g0.key==="Enter")g0.preventDefault(),N8();else if(g0.key==="Escape")g0.preventDefault(),i(!1),m0(""),Q8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:t0||!V0.trim(),"data-tip":"Create · Enter","aria-label":u==="folder"?"Create folder":"Create brief board",onClick:N8,children:t0?"…":"↵"})]}):null,J8?z("div",{className:"st-newboard-err",role:"alert",children:J8}):null,z("div",{className:"st-search",children:A("div",{className:"st-search-box",children:[z(X9,{name:"search",size:13}),z("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(g0)=>H(g0.target.value),onKeyDown:(g0)=>{if(g0.key==="Escape")if(g0.preventDefault(),Z)H("");else g0.currentTarget.blur()},"aria-label":"Filter files"}),Z?z("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(d6,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:f.map((g0)=>{if(!K&&!Z&&g0.kind==="runtime")return null;let R8=RV0(g0),r0=(g0.paths||[]).filter((Y8)=>YQ.test(Y8)).length,f8=R8.pill||(R8.pillFromDsCount?String(g0.dsFolders?.length||0):null)||(R8.pillFromCount?String(r0||g0.paths?.length||0):null),c8=g0.tree&&Object.keys(g0.tree).length>0,q9=g0.label==="Design system",b0=g0.kind==="project";if(!K&&!Z&&b0&&r0===0)return null;let B0=GV0(g0),K0=V[g0.label],S0=!!Z||(K0===void 0?B0:K0),H0=!q9&&g0.kind==="canvas",L0=H0?p.dropProps(g0.fullPath,!0):{},N0=p.overDir===g0.fullPath;return A("div",{className:"st-tree-section",children:[A("button",{type:"button",className:"st-tree-sec-hd"+(N0?" is-drop-target":""),onClick:()=>B(g0.label,B0),"aria-expanded":S0,"aria-dropeffect":H0?"move":void 0,title:S0?"Collapse section":"Expand section",...L0,children:[z(X9,{name:"chevron-right",className:"st-chev"+(S0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:R8.title}),f8&&z("span",{className:"st-pill",children:f8})]}),S0&&(c8?z(It,{node:g0.tree,activePath:J,onOpen:Y,commentsByFile:q,depth:1,kind:g0.kind,showHidden:K,search:Z,dsFolders:g0.dsFolders,activeDsName:Q,onOpenSystem:q9?W:void 0,onDelete:q9?void 0:L,dirtyByPath:T,canvasKinds:y,dirPath:g0.fullPath,drag:!q9&&g0.kind==="canvas"?p:void 0,menu:!q9&&g0.kind==="canvas"?r:void 0}):z("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},g0.label)})}),z(pC,{state:r.state,onClose:r.close,rootItems:X0,destinations:o,onPickDestination:(g0)=>g(s.path,g0)}),z(Iw,{project:I,liveBranch:S,remoteSync:C,onGetLatest:b}),z(Bw,{}),z(Nw,{})]})}function TV0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:A("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(X9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(X9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(X9,{name:"folder",size:15})})]})})}function IV0({open:X,onClose:J,onStartTour:Q}){if(d.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:A("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[A("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),A("span",{className:"sku",children:["MAUDE-DEV-SRV / v",vP]}),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:"×"})]}),A("div",{className:"help-modal-body",children:[A("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),A("ul",{children:[A("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),A("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),A("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),A("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),A("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),A("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),A("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),A("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),A("details",{children:[z("summary",{children:"Annotation tools"}),A("ul",{children:[A("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),A("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),A("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),A("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),A("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),A("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),A("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),A("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),A("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),A("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),A("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),A("details",{children:[z("summary",{children:"Canvas & panels"}),A("ul",{children:[A("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),A("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),A("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),A("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),A("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),A("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),A("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),A("details",{children:[z("summary",{children:"Slash commands"}),A("ul",{className:"cmds",children:[A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),A("li",{children:[A("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),A("li",{children:[A("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),A("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),A("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),A("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),A("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),A("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),A("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),A("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),A("details",{children:[z("summary",{children:"Opt-out scope"}),A("ul",{children:[A("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),A("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),A("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),A("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),A("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.'})]})]}),A("details",{children:[z("summary",{children:"Auto-critic loop"}),A("ul",{children:[A("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),A("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),A("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),A("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),A("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),A("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."]})]})]}),A("details",{children:[z("summary",{children:"Pin-to-element flow"}),A("ol",{children:[z("li",{children:"Open a canvas"}),A("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),A("li",{children:["Run"," ",A("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),A("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),A("details",{children:[z("summary",{children:"Comments"}),A("ol",{children:[A("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"}),A("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),A("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),A("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var bP=[{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 CV0({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(d6,{children:G},`${G}-${Z}`))},W);return A("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>A(Y0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function SV0({open:X,onClose:J}){if(d.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=bP.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:A("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[A("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),A("span",{className:"so-trigger",children:["press ",z(d6,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:bP.map((Y)=>A("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)=>A("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(CV0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),A("div",{className:"so-overlay-ft",children:[A("span",{children:["close with ",z(d6,{children:"Esc"})]}),A("span",{className:"so-count",children:[Q," bindings · ",bP.length," groups"]})]})]})})}var $V0=["File","Edit","View","Selection","Tools","Help"];function Ct(X){d.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 bV0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Ct(Q),A("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(X9,{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(d6,{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)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(d6,{children:G.shortcut})]},G.label))]})}function lV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Ct(G),A("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):A("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:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(d6,{children:Z.shortcut}):null]},Z.id))]})}function jV0({onAction:X,onClose:J}){return z(lV,{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"},...d8()?[{id:"collab-tour",label:"How sharing works"}]:[],...d8()?[{id:"quick-setup",label:"Quick setup"}]:[],...d8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function yV0({onAction:X,onClose:J}){return z(lV,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]})}function fV0({onAction:X,onClose:J}){return z(lV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{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"}]})}function vV0({onAction:X,onClose:J,hasCanvas:Q}){return z(lV,{label:"File",left:40,onAction:X,onClose:J,items:[{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 xV0({onAction:X,onClose:J,hasCanvas:Q}){return z(lV,{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 hV0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:q,onToggleChanges:K,onOpenSystem:V,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:D,onOpenHelp:w,onOpenShortcuts:R,onReportBug:_,onStartTour:O,onStartCollabTour:P,annotationsVisible:T,onToggleAnnotations:I,minimapVisible:S,onToggleMinimap:C,zoomCtlVisible:b,onToggleZoomCtl:y,presentMode:g,onTogglePresent:m,printGuidesVisible:c,onTogglePrintGuides:f,postToActiveCanvas:p,onOpenWhatsNew:r,onOpenReadiness:h,onOpenQuickSetup:s,onWatchIntro:X0,whatsNewCount:o,exportCenter:U0,artboardCount:i=0,presence:u=null,inspectorOpen:n,inspectorTab:V0,onToggleInspector:m0,autoOpenInspector:J8,onToggleAutoOpenInspector:Q8,onOpenLayers:t0,timelineOpen:F8,onToggleTimeline:Z8,hasComps:N8=!1,assistantOpen:p8,onToggleAssistant:A8,assistantBusy:g0,assistantUnseen:R8,onNewCanvas:r0,onAssembleVideo:f8,onOpenExport:c8,onOpenSettings:q9,onOpenGenerate:b0,onReload:B0,onCloseCanvas:K0,onInsertArtboard:S0}){let H0=X===l8,L0=H0?"SYSTEM":X?"CANVAS":"IDLE",N0=H0?z("b",{children:"design system"}):X?A(Y0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:zW(TF(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),Y8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:q>0?`Changes · ${q} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:n&&V0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:n,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:N8?"video":void 0,checked:F8,disabled:!1},...d8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:p8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:S,disabled:!X||H0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:b,disabled:!X||H0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||H0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:c,disabled:!X||H0}],P8=["file","edit","view","selection","tools","help"];function I8(M0){if(P8.includes(M0))W(Y===M0?null:M0)}return d.useEffect(()=>{if(!Y||!P8.includes(Y))return;let M0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function E0(p0){let e0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!e0.length)return;let w0=e0.indexOf(document.activeElement);if(p0.key==="ArrowDown")p0.preventDefault(),e0[(w0+1)%e0.length].focus();else if(p0.key==="ArrowUp")p0.preventDefault(),e0[(w0-1+e0.length)%e0.length].focus();else if(p0.key==="Home")p0.preventDefault(),e0[0].focus();else if(p0.key==="End")p0.preventDefault(),e0[e0.length-1].focus();else if(p0.key==="ArrowRight"||p0.key==="ArrowLeft"){p0.preventDefault();let o0=p0.key==="ArrowRight"?1:-1,J9=P8.indexOf(Y);W(P8[(J9+o0+P8.length)%P8.length])}else if(p0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",E0),()=>{clearTimeout(M0),window.removeEventListener("keydown",E0)}},[Y,W]),A("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[A("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"})]}),z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:$V0.map((M0)=>{let E0=M0.toLowerCase(),p0=P8.includes(E0),e0=p0||E0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":E0==="help"?"help":void 0,"aria-haspopup":p0?"menu":void 0,"aria-expanded":p0?Y===E0:void 0,onClick:()=>I8(E0),onMouseEnter:()=>{if(Y!==null&&p0)W(E0)},children:M0},E0)})}),Y==="file"&&z(vV0,{hasCanvas:!!X,onAction:(M0)=>{if(M0==="new")r0?.();else if(M0==="assemble")f8?.();else if(M0==="export")c8?.("export");else if(M0==="handoff")c8?.("handoff");else if(M0==="generate")b0?.();else if(M0==="settings")q9?.();else if(M0==="reload")B0?.();else if(M0==="close")K0?.()},onClose:()=>W(null)}),Y==="edit"&&z(xV0,{hasCanvas:!!X&&!H0,onAction:(M0)=>{if(M0==="undo")p({dgn:"undo"});else if(M0==="redo")p({dgn:"redo"});else if(M0==="deselect-all")p({dgn:"selection-clear"});else if(M0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(M0.startsWith("new-artboard:"))S0?.(M0.slice(13))},onClose:()=>W(null)}),Y==="view"&&z(bV0,{panels:Y8,onToggle:(M0)=>{if(M0==="tree")F();else if(M0==="changes")K();else if(M0==="comments")Z();else if(M0==="hidden")D();else if(M0==="annotate")I();else if(M0==="inspector")m0();else if(M0==="autoopen")Q8?.();else if(M0==="timeline")Z8?.();else if(M0==="assistant")A8?.();else if(M0==="layers")t0?.();else if(M0==="minimap")C?.();else if(M0==="zoomctl")y?.();else if(M0==="present")m?.();else if(M0==="print-guides")f?.()},onZoom:(M0)=>p({dgn:"zoom",op:M0}),hasCanvas:!!X&&!H0,onClose:()=>W(null)}),Y==="selection"&&z(yV0,{onAction:(M0)=>{if(M0==="deselect-all")p({dgn:"selection-clear"});else if(M0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&z(fV0,{onAction:(M0)=>p({dgn:"tool-set",tool:M0}),onClose:()=>W(null)}),Y==="help"&&z(jV0,{onAction:(M0)=>{if(M0==="shortcuts")R?.();else if(M0==="help")w?.();else if(M0==="report-bug")_?.();else if(M0==="tour")O?.();else if(M0==="collab-tour")P?.();else if(M0==="quick-setup")s?.();else if(M0==="readiness")h?.();else if(M0==="whatsnew")r?.();else if(M0==="watch-intro")X0?.()},onClose:()=>W(null)}),A("div",{className:"st-mb-right","data-tour":"status",children:[u?z("div",{className:"st-presence",children:u}):null,d8()&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":p8?"true":"false","data-busy":g0?"true":"false","data-unseen":R8?"true":"false","aria-label":`Assistant${g0?" — working":R8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:A8,children:z(X9,{name:"sparkle",size:15})}),U0&&z(Av,{center:U0}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":o>0?"true":"false","aria-label":`What's new${o>0?` — ${o} unseen`:""}`,"data-tip":"What's new",onClick:r,children:z(X9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:L0}),z("span",{className:"st-mb-file",title:X||"",children:N0}),z("span",{className:"st-mb-sep"}),A("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),i," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function gV0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:q,onIframeLoad:K,showQuickSetup:V,onStartQuickSetup:B}){return A("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&A("div",{className:"st-empty",children:[A("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"}),A("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",vP," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),A("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(d6,{children:"⌘"})," and hover to preview an element, click to select it — ",z(d6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",d8()?A(Y0,{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]}),V&&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((F)=>{if(F.path===l8)return z("div",{className:"system-view"+(F.path===J?" active":""),children:z(oV0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return z("iframe",{ref:(L)=>Q(F.path,L),src:fH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>K?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),q&&q===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:A("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 mV0=["color","space","radius","shadow","leading","weight","motion","font","other"],uV0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function lV0(X){return X==="color"}function dV0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return A("section",{className:"sv-section sv-section-tokens",children:[A("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:A("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([...mV0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Y0,{children:W.map((G)=>{let Z=Y[G],H=lV0(G);return A("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[A("h2",{children:["tokens · ",uV0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((q)=>A("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:q.value}}):null,A("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:q.name}),z("span",{className:"sv-tok-value",children:q.value||"—"})]})]},q.name+"|"+q.value))})]},G)})})}function pV0(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 cV0(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 iV0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=cV0(X?.font);return A("section",{className:"sv-section sv-section-type",children:[A("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=pV0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return A("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 oV0({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:q,tokensPath:K,ds:V,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,D=V?.name??B?.[0]?.name??"";return A("div",{className:"sv",children:[A("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),L?A("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>z("option",{value:w.name,children:w.name},w.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(dV0,{tokens:H,tokenGroups:q,tokensPath:K}),z(iV0,{tokenGroups:q}),F?z("div",{className:"sv-empty",children:A("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):A(Y0,{children:[z(zt,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(zt,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function zt({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return A("section",{className:"sv-section",children:[A("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>A("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:fH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),A("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function nV0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:q=0,unpushed:K=0,changesOpen:V=!1,onOpenChanges:B}){let F=X===l8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",D=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",R=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let _=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:_>0?`${_} ↑`:"synced",title:_>0?`${_} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${_} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return A("footer",{className:"st-statusbar",role:"contentinfo",children:[A("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:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&A("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:D,children:L}),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:"×"})]}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),A("span",{className:"val",children:[Y," open"]})]}),B&&A("button",{type:"button",className:"st-sb-slot st-sb-changes"+(V?" is-open":"")+(q>0?" has-changes":K>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":V,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:q>0?`${q} unsaved`:K>0?`${K} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),A("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"})]}),R&&A("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]}),A("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[z(X9,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function rV0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:q,width:K,resizing:V}){let B=Tt(X),F=Object.keys(X||{}).sort(),L=[];for(let D of F){let w=X[D]||[],R=w.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);L.push({file:D,comments:R.map((O)=>({...O,n:_.findIndex((P)=>P.id===O.id)+1}))})}return A("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:K?{width:K,flexBasis:K}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:A("div",{className:"st-cm-filters",role:"tablist",children:[A("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),A("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),A("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:L.length===0?A("div",{className:"st-rp-empty",children:[A("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),A("p",{children:["Open a canvas, hold ",z(d6,{children:"⌘"})," and click an element, then press ",z(d6,{children:"C"})," — or hold ",z(d6,{children:"⌘⇧"})," and click directly."]})]}):L.map((D)=>A(Y0,{children:[A("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:zW(TF(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((w)=>A("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(D.file,w.id),children:[A("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),z("span",{className:"st-comment-time",children:KV0(w.created)})]}),z("div",{className:"st-comment-txt",children:w.text}),A("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),A("span",{className:"st-mini-act",children:[w.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(w.id)},children:z(X9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(w.id)},children:z(X9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),q(w.id)},children:z(X9,{name:"x",size:14})})]})]})]},w.id))]},D.file))})]})}function aV0({update:X,onDismiss:J}){let[Q,Y]=d.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return A("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),A("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Uf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function sV0({status:X}){let[J,Q]=d.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",q=Y==="offline"||Y==="offline-long",K=X.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!q&&!H&&!V&&K===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(q){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;L=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",F=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;L=`diverged:${V.slug}:${V.at}`}else B="warn",F=`${K} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${K}`;if(J===L)return null;return A("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:F}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var tV0=["block","inline-block","flex","inline-flex","grid","inline","none"],Kt=["px","%","fr","em","auto","min-content","max-content"];var eV0=["auto","stretch","flex-start","center","flex-end","baseline"];var Ut=["300","400","500","600","700","800"],Vt=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],Bt=["none","solid","dashed","dotted","double"],Ft=["px","rem","em","%","vw","vh","auto"],Nt=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),jP={"font-size":{node:z(S9,{as:NU,size:12})},"line-height":{node:z(S9,{as:_U,size:12})},"letter-spacing":{node:z(S9,{as:CU,size:12})},gap:{node:z(S9,{as:Bq,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(S9,{as:yU,size:12})},"border-width":{node:z(S9,{as:IU,size:12})}};var Lt=["static","relative","absolute","fixed","sticky"],X10=["normal","italic","oblique"],Dt=["none","uppercase","lowercase","capitalize"];var Ot=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],J10=["fill","contain","cover","none","scale-down"];var Mt=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],wt=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],TJ={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}},xq=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!xq)xq=document.createElement("canvas").getContext("2d");if(!xq)return"";xq.fillStyle="#000000",xq.fillStyle=X;let J=xq.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 KY=(X)=>Math.min(1,Math.max(0,X));function _F(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 mV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function uV({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 hq({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,q=0;if(X<60)[Z,H,q]=[Y,W,0];else if(X<120)[Z,H,q]=[W,Y,0];else if(X<180)[Z,H,q]=[0,Y,W];else if(X<240)[Z,H,q]=[0,W,Y];else if(X<300)[Z,H,q]=[W,0,Y];else[Z,H,q]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(q+G)*255}}function b9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function QQ(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 At(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 St(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function Q10(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],q=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=q&&J[q[1]]?J[q[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 $t(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=d.useState([]);return d.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(q)=>{if(!q.tokensCssRel)return null;try{let K=await fetch(`/${J}/${q.tokensCssRel}`),V=K.ok?await K.text():"";return{name:q.name,...Q10(V)}}catch{return null}})).then((q)=>{if(H)return;let K=q.filter(Boolean);K.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(K)}),()=>{H=!0}},[W,J,Q]),G}function bt({seed:X,label:J,onApply:Q}){let[Y,W]=d.useState(()=>uV(_F(X||"#000000"))),G=d.useRef(Y);G.current=Y;let Z=d.useRef(null),H=d.useRef(null),q=d.useRef(X);d.useEffect(()=>{if(X&&X!==q.current)q.current=X,W(uV(_F(X)))},[X]);let K=mV(hq(Y)),V=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,I=(C)=>{W({h:T,s:KY((C.clientX-P.left)/P.width),v:KY(1-(C.clientY-P.top)/P.height)})};I(O);let S=()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",S),Q(mV(hq(G.current)))};document.addEventListener("pointermove",I),document.addEventListener("pointerup",S)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:I}=G.current,S=(b)=>{W({h:KY((b.clientX-P.left)/P.width)*360,s:T,v:I})};S(O);let C=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),Q(mV(hq(G.current)))};document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)},F=(O)=>{let P={...G.current,...O};W(P),Q(mV(hq(P)))},L=(O)=>{let P=O.shiftKey?0.1:0.02,I={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!I)return;O.preventDefault(),F({s:KY(G.current.s+I[0]),v:KY(G.current.v+I[1])})},D=(O)=>{let P=O.shiftKey?20:2,I={ArrowLeft:-P,ArrowRight:P}[O.key];if(I==null)return;O.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+I))})},w=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(uV(_F(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=hq(Y),_=(O)=>{let P={...R,...O},T=uV({r:KY(P.r/255)*255,g:KY(P.g/255)*255,b:KY(P.b/255)*255});W(T),Q(mV(hq(T)))};return A("div",{className:"st-cp-cpick",children:[A("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:K}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:K,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(uV(_F(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),A("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:V,onKeyDown:L,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:K}})]}),A("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:w,children:z(X9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:K},"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)=>A("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>_({[O]:KY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:q}){let[K,V]=d.useState(!1),[B,F]=d.useState(null),[L,D]=d.useState("custom"),[w,R]=d.useState(""),_=d.useRef(null),O=d.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(X0)=>Q===`var(${X0})`,I=(X0)=>X0.replace(/^--/,"").replace(/-/g," "),S=J||[],C=S.reduce((X0,o)=>X0+(o.names?.length||0),0),b=S.length>1,y=w.trim().toLowerCase(),g=!y?S:S.map((X0)=>({...X0,names:(X0.names||[]).filter((o)=>I(o).toLowerCase().includes(y)||o.toLowerCase().includes(y)||(X0.vals?.[o]||"").toLowerCase().includes(y))})).filter((X0)=>X0.names.length);d.useEffect(()=>{if(!K){R("");return}let X0=()=>{let u=_.current?.getBoundingClientRect();if(!u)return;let n=224,V0=300,m0=Math.min(u.right-n,window.innerWidth-n-8);if(m0<8)m0=8;let Q8=window.innerHeight-u.bottom>V0+8?u.bottom+4:Math.max(8,u.top-V0-4);F({left:m0,top:Q8,width:n,maxHeight:V0})};X0();let o=(u)=>{if(O.current?.contains(u.target)||_.current?.contains(u.target))return;V(!1)},U0=(u)=>{if(u.key==="Escape")V(!1)},i=(u)=>{if(O.current?.contains(u.target))return;X0()};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",X0),document.addEventListener("scroll",i,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",X0),document.removeEventListener("scroll",i,!0)}},[K]),d.useEffect(()=>{if(!K||!B||!O.current)return;let X0=O.current.getBoundingClientRect(),o=B.left-X0.left,U0=B.top-X0.top;if(Math.abs(o)>0.5||Math.abs(U0)>0.5)F((i)=>i?{...i,left:i.left+o,top:i.top+U0}:i)},[K,B]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,c=(X0,o,U0)=>{if(H&&X0&&X0!==H&&U0&&!m.test(U0))Y(U0);else Y(`var(${o})`);V(!1)},f=(X0)=>{let o=(X0||"").trim();if(o)Y(o)},p=A("div",{className:"st-cp-pop-search",children:[z(X9,{name:"search",size:12}),z("input",{value:w,onChange:(X0)=>R(X0.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),r=(X0)=>X0.map((o)=>A("div",{className:"st-cp-pop-group",children:[b?z("div",{className:"st-cp-pop-ds",children:o.ds}):null,z("div",{className:"st-cp-pop-list",children:o.names.map((U0)=>A("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(U0)?" is-on":""}`,onClick:()=>c(o.ds,U0,o.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:o.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:I(U0)}),z("span",{className:"st-cp-pop-val",children:o.vals?.[U0]||""})]},`${o.ds}:${U0}`))})]},o.ds)),h=(X0)=>X0.map((o)=>A("div",{className:"st-cp-pop-group",children:[b?z("div",{className:"st-cp-pop-ds",children:o.ds}):null,z("div",{className:"st-cp-pop-list",children:o.names.map((U0)=>A("button",{type:"button",className:`st-cp-pop-row${T(U0)?" is-on":""}`,onClick:()=>c(o.ds,U0,o.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:I(U0)}),z("span",{className:"st-cp-pop-val",children:o.vals?.[U0]||""})]},`${o.ds}:${U0}`))})]},o.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return A(Y0,{children:[G!==void 0?z("button",{type:"button",ref:_,className:`${q||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!q?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((X0)=>!X0),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:_,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((X0)=>!X0),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),K&&B?Et.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"?A(Y0,{children:[A("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),L==="custom"?z(bt,{seed:Z||kF(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):A(Y0,{children:[p,g.length?r(g):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):A(Y0,{children:[p,g.length?h(g):s]})}),document.body):null]})}function _t({label:X,tracks:J,editable:Q,onChange:Y}){let W=(q,K)=>{let V=J[q];Y(J.map((B,F)=>F===q?AK.has(K)?{value:0,unit:K}:{value:V.value||1,unit:K}:B))},G=(q,K)=>{Y(J.map((V,B)=>B===q?{...V,value:K}:V))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(q)=>Y(J.filter((K,V)=>V!==q));return A("div",{className:"st-cp-gridtracks",children:[A("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?A("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((q,K)=>{let V=AK.has(q.unit);return A("div",{className:"st-cp-gridtrack-row",children:[V?z(n4,{value:q.unit,ariaLabel:`${X} track ${K+1}`,options:Kt.map((B)=>({value:B,label:B})),onChange:(B)=>W(K,B)}):z(sJ,{value:q.value,min:q.unit==="fr"?0.1:0,step:q.unit==="fr"?0.1:1,ariaLabel:`${X} track ${K+1} value`,lead:String(K+1),unitSlot:z(VB,{value:q.unit,units:Kt,ariaLabel:`${X} track ${K+1} unit`,onChange:(B)=>W(K,B)}),onCommit:(B)=>G(K,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${K+1}`,disabled:!Q||J.length<=1,onClick:()=>H(K),children:"×"})]},K)})]})}function Y10({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let q=!!X.id,K=X.computed||{},[V,B]=d.useState({a:{},c:{},t:{}});d.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,F0)=>{let z0={...t||{}};for(let[T0,s0]of Object.entries(F0))if(s0===null)delete z0[T0];else z0[T0]=s0;return z0},L=F(X.authored,V.a),D=F(X.customStyles,V.c),w=F(X.attrs,V.t),R=(t,F0)=>B((z0)=>({...z0,a:{...z0.a,[t]:F0}})),_=(t,F0)=>B((z0)=>({...z0,c:{...z0.c,[t]:F0}})),O=(t,F0)=>B((z0)=>({...z0,t:{...z0.t,[t]:F0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=St(X.file,J),I=$t(J,P,T),S=(t)=>I.map((F0)=>({ds:F0.name,names:F0[t]||[],vals:F0.vals})).filter((F0)=>F0.names.length),[C,b]=d.useState({}),[y,g]=d.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(D).length>0||Object.keys(w).length>0;d.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let c=(L.position||b9(K.position)||"static")!=="static";d.useEffect(()=>{if(c)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,c]);let f=H,[p,r]=d.useState({});async function h(t,F0,z0){b((T0)=>({...T0,[z0]:"saving"}));try{let T0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(F0)}),s0=await T0.json().catch(()=>({}));b((_8)=>({..._8,[z0]:!T0.ok||!s0.ok?`err:${s0&&s0.error||`HTTP ${T0.status}`}`:"saved"}))}catch(T0){b((s0)=>({...s0,[z0]:`err:${T0&&T0.message?T0.message:String(T0)}`}))}}let s=(t,F0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:F0})},X0=(t,F0,z0,T0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:F0,before:z0==null||z0===""?null:z0,after:T0==null||T0===""?null:T0})},o=(t,F0)=>{let z0=(F0||"").trim();if(!q||!z0)return;let T0=L[t]??null;if(z0===(T0??"").trim())return;s(t,z0),R(t,z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:z0},t),X0("css",t,T0,z0)},U0=(t,F0)=>{let z0=(F0||"").trim(),T0=t.trim();if(!q||!T0||!z0)return;let s0=D[T0]??null;s(T0,z0),_(T0,z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:T0,value:z0},T0),X0("css",T0,s0,z0)},i=(t,F0)=>{let z0=(t||"").trim(),T0=(F0||"").trim();if(!q||!z0||!T0)return;let s0=w[z0]??null;O(z0,T0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:z0,value:T0},`@${z0}`),X0("attr",z0,s0,T0)},u=(t)=>{if(!q)return;let F0=L[t]??null;s(t,null),R(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,F0,null)},n=(t)=>{if(!q)return;let F0=D[t]??null;s(t,null),_(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,F0,null)},V0=(t)=>{if(!q)return;let F0=w[t]??null;O(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),X0("attr",t,F0,null)},m0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,F0)=>{if(!q)return;let z0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),T0=uC(t,F0,m0,z0);for(let s0 of T0.reset)if(L[s0])u(s0);for(let[s0,_8]of T0.set)o(s0,_8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",t0=(t)=>{let F0=mC(t,L,K,m0);return A("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(BB,{value:F0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(z0)=>J8(t,z0)})})]},`mode-${t}`)},F8=["flex-start","center","flex-end"],Z8=["flex-start","center","flex-end"],N8=["t","c","b"],p8=["l","c","r"],A8=()=>{let t=!(L["flex-direction"]||b9(K["flex-direction"])||"row").startsWith("column"),F0=Math.max(0,F8.indexOf(L["justify-content"]||b9(K["justify-content"])||"flex-start")),z0=L["align-items"]||b9(K["align-items"])||"stretch",T0=z0==="stretch"?1:Math.max(0,Z8.indexOf(z0)),[s0,_8]=t?[F0,T0]:[T0,F0];return N8[_8]+p8[s0]},g0=(t)=>{let F0=N8.indexOf(t[0]),z0=p8.indexOf(t[1]),T0=!(L["flex-direction"]||b9(K["flex-direction"])||"row").startsWith("column"),[s0,_8]=T0?[z0,F0]:[F0,z0];o("justify-content",F8[s0]),o("align-items",Z8[_8])},R8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let F0=t.key.toLowerCase();if(F0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(F0==="y")t.preventDefault(),G?.("redo")},r0=(t)=>{let F0=L[t];if(!F0)return"inherit";return/var\(\s*--/.test(F0)?"bound":"raw"};if(!q)return A("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),A("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 f8={bound:"token-bound",raw:"raw override",inherit:"inherited"},c8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":f8[t]}),q9=(t,F0)=>{let z0=F0??r0(t),T0=C[t],s0=typeof T0==="string"&&T0.startsWith("err:")?T0.slice(4):"",_8=s0?" is-err":T0==="saved"?" is-saved":T0==="saving"?" is-saving":"",C8=!!L[t],M8=s0?`error: ${s0}`:C8?`${f8[z0]} · double-click to reset`:f8[z0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${z0}${_8}${C8?" is-resettable":""}`,"aria-label":M8,title:M8,tabIndex:C8?0:-1,onDoubleClick:C8?()=>u(t):void 0,onKeyDown:C8?(v8)=>{if(v8.key==="Backspace"||v8.key==="Delete")v8.preventDefault(),u(t)}:void 0})},b0=(t,F0,z0,T0)=>{let s0=z0===void 0&&!L[t],_8=T0??t;return A("div",{className:`st-cp-row${s0?" is-unset":""}`,children:[q9(t,z0),z("label",{className:"st-cp-label",title:_8,children:_8}),z("div",{className:"st-cp-ctl",children:F0})]},t)},B0={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"]},K0=(t)=>{(B0[t]||[]).forEach((F0)=>{if(L[F0])u(F0)})},S0=(t,F0)=>{let z0=(B0[t]||[]).some((T0)=>L[T0]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!y[t],onClick:()=>g((T0)=>({...T0,[t]:!T0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${z0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!z0,onClick:()=>K0(t),children:z(S9,{as:hG,size:12})})]}),z("div",{className:`st-cp-sec-anim${y[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:F0})})]},t)},H0=(t,F0,z0,T0=!0)=>{let s0=`d:${t}`,_8=y[s0]===void 0?T0:y[s0],C8=F0.some((M8)=>L[M8]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":_8,onClick:()=>g((M8)=>({...M8,[s0]:!_8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:_8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${C8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!C8,onClick:()=>F0.forEach((M8)=>{if(L[M8])u(M8)}),children:z(S9,{as:hG,size:12})})]}),z("div",{className:`st-cp-sec-anim${_8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:z0})})]},s0)},L0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!p[t],"aria-label":p[t]?`${t} — fewer options`:`${t} — more options`,title:p[t]?"fewer":"more",onClick:()=>r((F0)=>({...F0,[t]:!F0[t]})),children:p[t]?"▴":"···"}),N0=(t,F0)=>A("select",{className:"st-cp-nsel","aria-label":t,value:F0.includes(L[t])?L[t]:"",onChange:(z0)=>o(t,z0.target.value),children:[z("option",{value:"",disabled:!0,children:b9(K[t])||"—"}),F0.map((z0)=>z("option",{value:z0,children:z0},z0))]}),Y8=(t)=>S(t).flatMap((F0)=>(F0.names||[]).map((z0)=>({name:z0,value:F0.vals?.[z0]||""}))),P8=(t,F0)=>z(yw,{value:L[t]||b9(K[t])||F0[0].value,ariaLabel:t,options:F0,onChange:(z0)=>o(t,z0)}),I8=(t,F0,z0={})=>{let T0=QQ(L[t]??""),s0=Nt.has(t),_8=L[t]??"",C8=typeof _8==="string"&&/var\(\s*--/.test(_8),M8=s0?"":T0.unit&&T0.unit!=="auto"?T0.unit:"px",v8=Number.parseFloat(QQ(b9(K[t])??"").n)||0,K9=T0.n!==""&&T0.n!=null?Number.parseFloat(T0.n)||0:v8,W7=jP[t];return z(FB,{value:C8?_8:K9,tokens:Y8(F0),ariaLabel:t,min:z0.min??0,lead:W7?W7.node??W7.t:void 0,unitSlot:s0?null:z(VB,{units:Ft,value:T0.unit||"px",ariaLabel:`${t} unit`,onChange:(D9)=>o(t,D9==="auto"?"auto":`${T0.n||"0"}${D9}`)}),onChange:(D9)=>o(t,typeof D9==="string"?D9:s0?`${D9}`:`${D9}${M8}`)})},M0=()=>{let t=(s0)=>Number.parseFloat(QQ(L[s0]??L["border-radius"]??b9(K[s0])??b9(K["border-radius"])??"0").n)||0,F0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},z0=(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((C8)=>{if(L[C8])u(C8)}),o("border-radius",`${s0.tl}px`);else o("border-top-left-radius",`${s0.tl}px`),o("border-top-right-radius",`${s0.tr}px`),o("border-bottom-left-radius",`${s0.bl}px`),o("border-bottom-right-radius",`${s0.br}px`)},T0=jP["border-radius"];return z(Uv,{corners:F0,lead:T0?T0.node??T0.t:void 0,onCorners:z0})},E0=()=>A("div",{className:"st-cp-border",children:[E9("border-width",null,{fixedUnit:"px"}),A("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:Bt.includes(L["border-style"])?L["border-style"]:"",onChange:(t)=>o("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),Bt.map((t)=>z("option",{value:t,children:t},t))]}),z(EF,{kind:"color",groups:S("color"),current:L["border-color"],activeDs:T,swatchBg:K["border-color"]||L["border-color"]||"",seedHex:kF(K["border-color"]||L["border-color"])||"#000000",onPick:(t)=>o("border-color",t),label:"border colour"})]}),p0=()=>{let t=L.transform||b9(K.transform)||"",F0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),z0=((F0?Number.parseFloat(F0[1]):0)%360+360)%360,T0=(s0)=>{let _8=(s0%360+360)%360,C8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();o("transform",`${C8?`${C8} `:""}rotate(${_8}deg)`.trim())};return A("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(zv,{value:z0,onChange:T0}),z(sJ,{value:z0,min:0,max:360,ariaLabel:"rotation",lead:z(S9,{as:hG}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:T0})]})},e0=()=>{let t=L.filter||b9(K.filter)||"",F0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),z0=F0?Number.parseFloat(F0[1]):0;return z(sJ,{value:z0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(s0)=>{let _8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();o("filter",s0>0?`${_8?`${_8} `:""}blur(${s0}px)`.trim():_8||"none")}})},w0=()=>{let t=L.opacity,F0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(b9(K.opacity))||1,z0=Math.round((Number.isNaN(F0)?1:F0)*100);return z(s5,{value:z0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(T0)=>s("opacity",String(T0/100)),onCommit:(T0)=>o("opacity",String(T0/100))},`opacity:${t??""}`)},o0=()=>{let t=Number.parseInt(L["font-weight"]||b9(K["font-weight"])||"400",10)>=600,F0=(L["font-style"]||b9(K["font-style"]))==="italic",z0=/underline/.test(L["text-decoration"]||b9(K["text-decoration"])||"");return z(Hv,{value:{b:t,i:F0,u:z0},ariaLabel:"text style",options:[{value:"b",node:z(S9,{as:EU}),label:"Bold"},{value:"i",node:z(S9,{as:TU}),label:"Italic"},{value:"u",node:z(S9,{as:vU}),label:"Underline"}],onToggle:(T0)=>{if(T0==="b")o("font-weight",t?"400":"700");else if(T0==="i")o("font-style",F0?"normal":"italic");else o("text-decoration",z0?"none":"underline")}})},J9=[{value:"row",node:z(S9,{as:g4}),label:"Row"},{value:"column",node:z(S9,{as:m4}),label:"Column"}],i8=[{value:"flex-start",node:z(S9,{as:OU}),label:"Start"},{value:"center",node:z(S9,{as:LU}),label:"Center"},{value:"flex-end",node:z(S9,{as:DU}),label:"End"},{value:"space-between",node:z(S9,{as:Bq}),label:"Space between"}],S6=[{value:"flex-start",node:z(S9,{as:AU}),label:"Start"},{value:"center",node:z(S9,{as:MU}),label:"Center"},{value:"flex-end",node:z(S9,{as:wU}),label:"End"},{value:"stretch",node:z(S9,{as:fU}),label:"Stretch"}],r9=[{value:"left",node:z(S9,{as:aJ}),label:"Left"},{value:"center",node:z(S9,{as:l4}),label:"Center"},{value:"right",node:z(S9,{as:d4}),label:"Right"},{value:"justify",node:z(S9,{as:p4}),label:"Justify"}],n7=[{value:"visible",node:z(S9,{as:xG}),label:"Visible"},{value:"hidden",node:z(S9,{as:$U}),label:"Hidden"},{value:"scroll",node:z(S9,{as:bU}),label:"Scroll"}],$6=(t,F0)=>{let z0=S(F0);return z0.length?z(EF,{kind:"value",groups:z0,current:L[t],activeDs:T,onPick:(T0)=>o(t,T0),label:`${t} design token`}):null},D7=(t)=>{let F0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===F0)F0.select()})},IJ=(t,F0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let z0=t.shiftKey?10:1,T0=t.key==="ArrowUp"?1:-1,s0=(Number.parseFloat(t.currentTarget.value)||0)+T0*z0;return t.currentTarget.value=String(s0),F0(s0),!0},d9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:L[t]??"",placeholder:b9(K[t])||"—",onFocus:D7,onKeyDown:(F0)=>{if(F0.key==="Enter")F0.currentTarget.blur()},onBlur:(F0)=>o(t,F0.currentTarget.value)},`${t}:${L[t]??""}`),E9=(t,F0,z0={})=>{let T0=QQ(L[t]??""),s0=Nt.has(t),_8=s0?"":z0.fixedUnit||(T0.unit&&T0.unit!=="auto"?T0.unit:"px"),C8=jP[t],M8=Number.parseFloat(QQ(b9(K[t])??"").n)||0,v8=T0.n!==""&&T0.n!=null?Number.parseFloat(T0.n)||0:M8;return A(Y0,{children:[z(sJ,{value:v8,min:z0.min??0,step:1,ariaLabel:t,lead:C8?C8.node??C8.t:void 0,onCommit:(K9)=>o(t,s0?`${K9}`:`${K9}${_8}`),unitSlot:s0||z0.fixedUnit?null:z(VB,{units:Ft,value:T0.unit||"px",ariaLabel:`${t} unit`,onChange:(K9)=>o(t,K9==="auto"?"auto":`${T0.n||"0"}${K9}`)})},`${t}:${L[t]??""}`),$6(t,F0)]})},y7=(t)=>{let F0=K[t]||L[t]||"",z0=L[t]??"",T0=typeof z0==="string"&&/var\(\s*--/.test(z0),s0=T0?z0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):z0;return z(hU,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:S("color"),current:L[t],activeDs:T,swatchBg:F0,seedHex:kF(K[t]||L[t])||"#000000",onPick:(_8)=>o(t,_8),label:`${t} colour`}),displayValue:s0,bound:T0,ariaLabel:t,onValue:(_8)=>o(t,_8)})},z9=(t,F0)=>{let z0=null,T0=F0.unitless?"":"px",s0=(M8)=>F0.unitless?`${M8}`:`${M8}${T0}`,_8=(M8,v8,K9)=>{for(let W7 of v8??[t])K9(W7,s0(M8))},C8=jw({getBase:()=>z0?.value??"0",min:F0.min??0,step:1,sides:F0.sides,onInput:(M8,v8)=>{if(z0)z0.value=String(M8);if(v8){let K9=z0?.closest(".st-cp-box");for(let W7 of v8){if(W7===t)continue;let D9=K9?.querySelector(`.st-cp-boxv[aria-label="${W7}"]`);if(D9)D9.value=String(M8)}}_8(M8,v8,s)},onCommit:(M8,v8)=>_8(M8,v8,o)});return{onPointerDown:(M8)=>{z0=M8.currentTarget,C8(M8)}}},w9=(t,F0)=>{let z0=L[t],T0=z0!=null&&z0!==""?QQ(z0).n||z0:QQ(b9(K[t])??"").n||"0",s0=!z0||z0==="0"||z0==="0px"||z0==="auto",_8=t.split("-").pop(),C8=_8==="top"||_8==="bottom"?[`${F0}-top`,`${F0}-bottom`]:[`${F0}-left`,`${F0}-right`],M8=[`${F0}-top`,`${F0}-right`,`${F0}-bottom`,`${F0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${F0[0]}${t.split("-").pop()[0]}${s0?" is-zero":""}`,"aria-label":t,defaultValue:T0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...z9(t,{sides:{pair:C8,all:M8}}),onFocus:D7,onKeyDown:(v8)=>{if(IJ(v8,(K9)=>o(t,`${K9}px`)))return;if(v8.key==="Enter")v8.currentTarget.blur()},onBlur:(v8)=>{let K9=v8.currentTarget.value.trim();if(!K9)return;let W7=/[a-z%]/i.test(K9)?K9:`${K9}px`;o(t,W7)}},`${t}:${z0??""}`)},K7=(t)=>{let F0=L[t],z0=F0!=null&&F0!==""&&F0!=="auto"?QQ(F0).n||F0:QQ(b9(K[t])??"").n||"",T0=!F0||F0==="auto"||F0==="0"||F0==="0px",s0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],_8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${T0?" is-zero":""}`,"aria-label":t,defaultValue:z0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...z9(t,{sides:{pair:s0,all:_8},min:-1/0}),onFocus:D7,onKeyDown:(C8)=>{if(IJ(C8,(M8)=>o(t,`${M8}px`)))return;if(C8.key==="Enter")C8.currentTarget.blur()},onBlur:(C8)=>{let M8=C8.currentTarget.value.trim();if(!M8)return;let v8=/[a-z%]/i.test(M8)?M8:`${M8}px`;o(t,v8)}},`${t}:${F0??""}`)},P7=Object.entries(D),a9=Object.entries(w),p6=()=>{let t=(X.tag||"").toLowerCase(),z0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],T0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:z0,canReplace:T0}},r7=(t)=>A(Y0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),b0("object-fit",N0("object-fit",J10)),b0("object-position",d9("object-position")),b0("aspect-ratio",A("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:wt.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(F0)=>{let z0=F0.target.value;if(o("aspect-ratio",z0),z0&&z0!=="auto"&&L.height)u("height")},children:[z("option",{value:"",disabled:!0,children:b9(K["aspect-ratio"])||"—"}),wt.map((F0)=>z("option",{value:F0,children:F0},F0))]}))]});return A("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:R8,children:[A("div",{className:"st-cp-id",children:[A("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?A("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(yw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(S9,{as:h4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(S9,{as:c4,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?A(Y0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(L.display||b9(K.display)||"").trim();return t==="flex"||t==="inline-flex"?A(Y0,{children:[b0("flex-direction",P8("flex-direction",J9),void 0,"Direction"),b0("align-items",z(qv,{value:A8(),onChange:g0,ariaLabel:"auto-layout alignment"}),r0("align-items"),"Alignment"),b0("gap",I8("gap","space"),void 0,"Gap"),A("div",{className:"st-cp-modes",children:[t0("width"),t0("height")]}),A("div",{className:"st-cp-box","aria-label":"padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[c8(r0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:L0("Auto layout")}),p["Auto layout"]?b0("flex-wrap",z(r4,{checked:/^wrap/.test(L["flex-wrap"]||b9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(z0)=>o("flex-wrap",z0?"wrap":"nowrap")}),r0("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>o("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],A(Y0,{children:[b0("width",E9("width"),void 0,"Width"),b0("height",E9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:L0("Size")}),p.Size?A(Y0,{children:[b0("min-width",E9("min-width"),void 0,"Min width"),b0("max-width",E9("max-width"),void 0,"Max width"),b0("min-height",E9("min-height"),void 0,"Min height"),b0("max-height",E9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],A(Y0,{children:[b0("position",N0("position",Lt),void 0,"Position"),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[c8(r0("top")),"inset"]}),K7("top"),K7("right"),K7("bottom"),K7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||b9(K.position)||"static"})]}),(L.position||b9(K.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:L0("Position")}),p.Position?b0("z-index",E9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],b0("background-color",y7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],b0("border",E0(),r0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],b0("border-radius",M0(),r0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],A(Y0,{children:[b0("box-shadow",$6("box-shadow","shadow")||d9("box-shadow"),void 0,"Shadow"),b0("filter",e0(),r0("filter"),"Blur"),b0("mix-blend-mode",N0("mix-blend-mode",Mt),void 0,"Blend")]})),H0("Opacity",["opacity"],b0("opacity",w0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],A(Y0,{children:[b0("font-family",N0("font-family",Vt),void 0,"Font"),b0("color",y7("color"),void 0,"Color"),b0("font-size",I8("font-size","type"),void 0,"Size"),b0("font-weight",N0("font-weight",Ut),void 0,"Weight"),b0("line-height",E9("line-height","lh"),void 0,"Line height"),b0("text-align",P8("text-align",r9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:L0("Text")}),p.Text?A(Y0,{children:[b0("letter-spacing",E9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),b0("font-style",N0("font-style",X10),void 0,"Style"),b0("text-transform",N0("text-transform",Dt),void 0,"Case"),b0("white-space",N0("white-space",Ot),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],A("div",{className:"st-cp-box","aria-label":"margin",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[c8(r0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:F0}=p6();return t?H0("Media",["object-fit","object-position","aspect-ratio"],r7(F0)):null})()]}):A(Y0,{children:[S0("Layout",(()=>{let t=(L.display||b9(K.display)||"").trim(),F0=t==="flex"||t==="inline-flex",z0=t==="grid"||t==="inline-grid";return A(Y0,{children:[b0("display",N0("display",tV0)),F0?A(Y0,{children:[b0("flex-direction",P8("flex-direction",J9)),b0("flex-wrap",z(r4,{checked:/^wrap/.test(L["flex-wrap"]||b9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(T0)=>o("flex-wrap",T0?"wrap":"nowrap")}),r0("flex-wrap"))]}):null,F0||z0?A(Y0,{children:[b0("align-items",P8("align-items",S6)),b0("justify-content",P8("justify-content",i8)),b0("gap",I8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>o("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(L.display||b9(K.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let z0=L["grid-template-columns"]||"",T0=L["grid-template-rows"]||"",s0=bD(z0),_8=bD(T0),C8=s0.length>0||!z0.trim(),M8=_8.length>0||!T0.trim();return S0("Grid",A(Y0,{children:[C8?z(_t,{label:"Columns",tracks:s0,editable:q,onChange:(v8)=>o("grid-template-columns",jD(v8))}):A("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:z0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),M8?z(_t,{label:"Rows",tracks:_8,editable:q,onChange:(v8)=>o("grid-template-rows",jD(v8))}):A("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:T0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),S0("Position",A(Y0,{children:[b0("position",N0("position",Lt)),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[c8(r0("top")),"inset"]}),K7("top"),K7("right"),K7("bottom"),K7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||b9(K.position)||"static"})]}),(L.position||b9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,b0("z-index",E9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&S0("Grid item",A(Y0,{children:[A("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),b0("grid-column",d9("grid-column")),b0("grid-row",d9("grid-row"))]})),S0("Typography",A(Y0,{children:[b0("font-family",N0("font-family",Vt)),b0("color",y7("color")),b0("font-size",I8("font-size","type")),b0("font-weight",N0("font-weight",Ut)),b0("line-height",E9("line-height","lh")),b0("letter-spacing",E9("letter-spacing",null,{min:-1/0})),b0("text-align",P8("text-align",r9)),b0("font-style",o0(),r0("font-style")),b0("text-transform",N0("text-transform",Dt)),b0("white-space",N0("white-space",Ot))]})),S0("Spacing",z(Y0,{children:A("div",{className:"st-cp-box","aria-label":"margin and padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[c8(r0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin"),A("div",{className:"st-cp-boxpad",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[c8(r0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding"),A("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(L.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(L.height)||X.bounds?.h||0)]})]})]})})),S0("Size",A(Y0,{children:[A("div",{className:"st-cp-modes",children:[t0("width"),t0("height")]}),b0("width",E9("width")),b0("height",E9("height")),b0("min-width",E9("min-width")),b0("max-width",E9("max-width")),b0("min-height",E9("min-height")),b0("max-height",E9("max-height")),b0("overflow",P8("overflow",n7)),Q8?A(Y0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),b0("align-self",N0("align-self",eV0)),b0("flex-grow",E9("flex-grow",null,{unitless:!0})),b0("flex-shrink",E9("flex-shrink",null,{unitless:!0})),b0("flex-basis",E9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:F0}=p6();return t?S0("Media",r7(F0)):null})(),S0("Appearance",A(Y0,{children:[b0("background-color",y7("background-color")),b0("border-radius",M0(),r0("border-radius")),b0("border",E0(),r0("border-width")),b0("box-shadow",$6("box-shadow","shadow")||d9("box-shadow")),b0("filter",e0(),r0("filter")),b0("mix-blend-mode",N0("mix-blend-mode",Mt)),b0("opacity",w0()),b0("rotation",p0(),r0("transform")),b0("transform",d9("transform")),b0("transform-origin",d9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,F0])=>typeof F0==="string"&&F0.startsWith("err:"));return t?A("div",{className:"st-cp-save is-err",role:"status",children:[z(X9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),S0("Advanced",A("div",{className:"st-cp-advbody",children:[P7.length?A(Y0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),P7.map(([t,F0])=>A("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:F0,"aria-label":`${t} value`,onKeyDown:(z0)=>{if(z0.key==="Enter")z0.currentTarget.blur()},onBlur:(z0)=>U0(t,z0.currentTarget.value)},`cs:${t}:${F0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>n(t),children:z(X9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(W10,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),a9.length?A(Y0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),a9.map(([t,F0])=>A("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:F0,"aria-label":`${t} value`,onKeyDown:(z0)=>{if(z0.key==="Enter")z0.currentTarget.blur()},onBlur:(z0)=>i(t,z0.currentTarget.value)},`at:${t}:${F0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>V0(t),children:z(X9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(G10,{commit:i})]}))]}),A("div",{className:"st-cp-legend",children:[A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function W10({commit:X}){let[J,Q]=d.useState(""),[Y,W]=d.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("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 G10({commit:X}){let[J,Q]=d.useState(""),[Y,W]=d.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("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 Z10={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function H10(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===J)return G=q[K],q.splice(K,1),!0;if(q[K].children&&Z(q[K].children))return!0}return!1};if(Z(W),!G)return X;let H=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===Q){if(Y==="inside-start"||Y==="inside-end")if(q[K].children=q[K].children||[],Y==="inside-start")q[K].children.unshift(G);else q[K].children.push(G);else q.splice(Y==="before"?K:K+1,0,G);return!0}if(q[K].children&&H(q[K].children))return!0}return!1};return H(W)?W:X}var q10=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function jt({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:D,onToggleLock:w,onRename:R}){let _=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(_),T=!!X.synthetic,I=!T&&L?L[X.id]:null,S=!T&&!!D?.has(_),[C,b]=d.useState(!1),[y,g]=d.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),c=G?.has(_)?G.get(_):!!X.hidden,f=!!V&&!T&&!S,p=()=>{b(!1);let s=y.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},r=F?.key===_,h=r?{transform:`translate(${F.dx}px, ${F.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 A(Y0,{children:[A("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(c?" is-hidden":"")+(T?" is-group":"")+(I?" is-instance":"")+(S?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":O?!P:void 0,"aria-grabbed":f?r:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":_,onClick:()=>T?O&&Z(_):H(X),onMouseEnter:()=>!T&&q(X),onMouseLeave:()=>q(null),onPointerDown:f?(s)=>B(s,X,_):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)O&&Z(_);else H(X);else if(s.key==="F2"&&R&&!T)s.preventDefault(),g(X.dcElement||X.label||""),b(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(_)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),I?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:I.root?"◆":"◇"}):z(X9,{name:Z10[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:y,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>g(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:p,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")p();else if(s.key==="Escape")b(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!T?(s)=>{s.stopPropagation(),g(X.dcElement||X.label||""),b(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:I?I.component:X.type}),w&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":S?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":S,title:S?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),w(_)},children:z(X9,{name:S?"lock":"unlock",size:12})}):null,K&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":c?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":c,title:c?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),K(X)},children:z(X9,{name:c?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((s,X0)=>z(jt,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:D,onToggleLock:w,onRename:R},`${s.id}:${s.index}`)):null]})}function z10({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(K)=>{let V=Q[K];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return J[K]||V||""},W=(K,V)=>{let B=J[V]||Q[V];if(!B)return null;return A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:K}),A("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(V)})]})]},K)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?QQ(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 A(Y0,{children:[G?A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),A("div",{className:"st-insp-fields",children:[A("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?A("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 yt(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var K10=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],U10=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function V10({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let q=yt(X),K=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=St(X.file,J),B=$t(J,K,V),F=(r)=>B.map((h)=>({ds:h.name,names:h[r]||[],vals:h.vals})).filter((h)=>h.names.length),L=(r)=>F(r).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),D=(r)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(r||"");if(!h)return r||"";for(let s of B){let X0=s.vals?.[h[1]];if(X0)return X0}return""},w=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,_=(r,h)=>{if(!q)return;let s=Number.isFinite(r)&&r>0?Math.round(r):void 0,X0=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&X0==null)return;Q?.(q,s,X0)},O=Object.entries(TJ).find(([,r])=>r.width===w&&r.height===R)?.[0],P=Object.entries(TJ).find(([,r])=>r.width===w)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",I=X.attrs?.["data-dc-bg"]??"",S=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",b=X.attrs?.["data-dc-gap"]??"",y=X.attrs?.["data-dc-kind"]||"digital",g=null;try{g=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let m=(r)=>{if(!q)return;let h=null;if(r==="print"&&!g){let s={paper:"a4"};try{let X0=P3(s);if(X0)h={defaults:s,widthPx:X0.widthPx,heightPx:X0.heightPx}}catch{}}if(G?.(q,r==="digital"?null:r,h),r==="web"&&T)Y?.(q,!1,void 0)},c=(r)=>{if(!q)return;let h={paper:"a4",...g,...r},s;try{s=P3(h)}catch{return}Q?.(q,s.widthPx,s.heightPx),Z?.(q,h)},f=(r)=>{if(!q)return;let h=r&&Number.isFinite(R)?Math.round(R):void 0;Y?.(q,r,h)},p=(r)=>{if(!q)return;W?.(q,r)};return A("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),A("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(sJ,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(r)=>_(r,null)}),z(sJ,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(r)=>{if(T)_(null,r)}})]}),z("div",{style:{padding:"0 12px 8px"},children:y==="print"?A("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(r)=>c({paper:r.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),E3.map((r)=>A("option",{value:r.id,children:[r.label," — ",r.width,"×",r.height,r.unit]},r.id))]}):y==="web"?A("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)_(h.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${TJ[P].label} — ≤ ${TJ[P].width}px`:"Breakpoint…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ≤ ",h.width,"px breakpoint"]},r))]}):A("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)_(h.width,h.height)},children:[z("option",{value:"",disabled:!0,children:O?TJ[O].label:"Preset size…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ",h.width,"×",h.height]},r))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(BB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(r)=>f(r==="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(n4,{value:y,ariaLabel:"artboard kind",options:U10.map(([r,h])=>({value:r,label:h})),onChange:m})}),y!=="print"&&q&&H?z("div",{style:{padding:"0 12px 8px"},children:A("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)H(q,h.width);r.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ",h.width,"px"]},r))]})}):null,y==="print"?A(Y0,{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(BB,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(r)=>c({orientation:r})})}),z("div",{style:{padding:"0 12px 8px"},children:z(sJ,{value:Number.isFinite(g?.bleedMm)?g.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:(r)=>c({bleedMm:r})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),A("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let r=D(I),h=/var\(\s*--/.test(I),s=h?I.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):I;return z(hU,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:I,activeDs:V,swatchBg:r,seedHex:kF(r)||"#000000",onPick:(X0)=>p({background:X0||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(X0)=>p({background:(X0||"").trim()||null})})})(),z(n4,{value:C,ariaLabel:"artboard body layout",options:K10.map(([r,h])=>({value:r,label:h})),onChange:(r)=>p({layout:r||null})}),A("div",{style:{display:"flex",gap:8},children:[z(FB,{value:/^var\(/.test(S)?S:Number.parseFloat(S)||0,tokens:L("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(r)=>p({padding:typeof r==="string"?r:r>0?r:null})}),z(FB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:L("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(r)=>p({gap:typeof r==="string"?r:r>0?r:null})})]})]})]})}var xP=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,B10=new RegExp(xP.source,"gi");function F10(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(B10)||[])],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=xP.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function N10({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:q,onHoverLayer:K,onReorderLayer:V,layersBusyRef:B,cfg:F,onOptimistic:L,onRecordEdit:D,onReplaceMedia:w,onResizeArtboard:R,onSetArtboardHug:_,onSetArtboardStyle:O,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I,onUndoRedo:S,editScope:C,tab:b,onTabChange:y,width:g,resizing:m,photoSel:c,photoRev:f,onPhotoEdit:p,onPhotoRemoveBackground:r,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:X0=!1,hideLayersTab:o=!1,cpMode:U0,onSetCpMode:i}){let[u,n]=d.useState("inspect"),V0=X0?"layers":b??u,m0=(E0)=>{n(E0),y?.(E0)},[J8,Q8]=d.useState(()=>new Set),[t0,F8]=d.useState(()=>new Map);d.useEffect(()=>{let E0=Array.isArray(X)?X[0]:X,p0=E0?.id;if(!p0||!Q?.nodes)return;let e0=E0.index,w0=null,o0=[];if(function J9(i8,S6){for(let r9 of i8||[]){let n7=`${r9.id}:${r9.index}`;if(!r9.synthetic&&r9.id===p0&&(e0==null||r9.index===e0))return w0=n7,o0.push(...S6),!0;if(r9.children&&r9.children.length&&J9(r9.children,[...S6,n7]))return!0}return!1}(Q.nodes,[]),!w0)return;if(o0.length)Q8((J9)=>{let i8=!1,S6=new Set(J9);for(let r9 of o0)if(S6.delete(r9))i8=!0;return i8?S6:J9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${w0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let Z8=(E0)=>{let p0=`${E0.id}:${E0.index}`;return t0.has(p0)?t0.get(p0):!!E0.hidden},[N8,p8]=d.useState(null),[A8,g0]=d.useState(""),R8=(E0,p0)=>{if(!H||!E0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:E0.id,attr:"data-dc-element",value:p0})}).then((e0)=>e0.json().catch(()=>({}))).then((e0)=>{if(!e0.ok)return;D?.({op:"attr",canvas:H,id:E0.id,key:"data-dc-element",before:E0.dcElement??null,after:p0})}).catch(()=>{})},r0=V?(E0,p0,e0)=>{if(B?.current)return;if(E0?.synthetic||p0?.synthetic)return;let w0=e0==="before"?`before ${p0.label}`:e0==="after"?`after ${p0.label}`:`into ${p0.label}`;g0(`Moved ${E0.label} ${w0}`),V(E0.id,p0.id,e0,{idIndex:E0.index,refIndex:p0.index})}:void 0,f8=()=>{let E0=[];return function p0(e0,w0,o0){(e0||[]).forEach((J9,i8)=>{if(E0.push({node:J9,depth:w0,parentNode:o0,siblings:e0,pos:i8}),J9.children&&J9.children.length&&!J8.has(`${J9.id}:${J9.index}`))p0(J9.children,w0+1,J9)})}(Q?.nodes,0,null),E0},c8=(E0)=>{if(E0.key!=="ArrowUp"&&E0.key!=="ArrowDown")return;if(!H0)return;let p0=f8(),e0=p0.findIndex((i8)=>i8.node.id===H0.id&&i8.node.index===H0.index);if(e0<0)return;let w0=E0.key==="ArrowDown"?1:-1,o0=p0[e0];if(!E0.altKey){let i8=p0[e0+w0];if(i8)E0.preventDefault(),q?.(i8.node);return}if(!r0||!Array.isArray(o0.siblings))return;E0.preventDefault();let J9=(i8)=>i8&&i8.children&&i8.children.length&&!J8.has(`${i8.id}:${i8.index}`);if(!E0.shiftKey){if(w0<0&&o0.pos>0)r0(o0.node,o0.siblings[o0.pos-1],"before");else if(w0>0&&o0.pos<o0.siblings.length-1)r0(o0.node,o0.siblings[o0.pos+1],"after");return}if(w0>0){let i8=o0.siblings[o0.pos+1];if(i8)r0(o0.node,i8,J9(i8)?"inside-start":"after");else if(o0.parentNode)r0(o0.node,o0.parentNode,"after")}else{let i8=o0.siblings[o0.pos-1];if(i8)r0(o0.node,i8,J9(i8)?"inside-end":"before");else if(o0.parentNode)r0(o0.node,o0.parentNode,"before")}},q9=d.useRef(null),b0=d.useRef(null),B0=(E0,p0,e0)=>{if(!r0||E0.button!==0||E0.metaKey||E0.ctrlKey||E0.shiftKey||E0.altKey)return;if(B?.current)return;let{clientX:w0,clientY:o0}=E0,J9=new Set([e0]);(function z9(w9){(w9.children||[]).forEach((K7)=>{J9.add(`${K7.id}:${K7.index}`),z9(K7)})})(p0);let i8=14,S6=6,r9=[];(function z9(w9,K7){(w9||[]).forEach((P7)=>{let a9=`${P7.id}:${P7.index}`;if(r9.push({node:P7,key:a9,id:P7.id,depth:K7,tag:P7.tag}),P7.children&&P7.children.length&&!J8.has(a9))z9(P7.children,K7+1)})})(Q?.nodes,0);let n7=new Map(r9.map((z9)=>[z9.key,z9])),$6=!1,D7=(z9)=>{if(!$6){if(Math.hypot(z9.clientX-w0,z9.clientY-o0)<4)return;$6=!0}let w9=z9.clientX-w0,K7=z9.clientY-o0,P7=null,a9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((r7)=>({rect:r7.getBoundingClientRect(),it:n7.get(r7.getAttribute("data-layer-key"))})).filter((r7)=>r7.it&&r7.it.key!==e0);if(a9.length){let r7=a9[0].rect.left,t=a9[0].rect.right,F0=a9.length;for(let D9=0;D9<a9.length;D9++)if(z9.clientY<a9[D9].rect.top+a9[D9].rect.height/2){F0=D9;break}let z0=a9[F0-1]?.it||null,T0=a9[F0]?.it||null,s0=Math.round((z9.clientX-r7-S6)/i8),_8=z0?z0.depth+(q10.has(z0.tag)?0:1):0,C8=T0?T0.depth:0,M8=Math.max(C8,Math.min(s0,_8)),v8=null,K9="before",W7=0;if(!z0){if(T0)v8=T0,K9="before",W7=T0.depth}else if(M8>z0.depth)v8=z0,K9="inside-start",W7=z0.depth+1;else if(M8===z0.depth)v8=z0,K9="after",W7=z0.depth;else{for(let D9=F0-1;D9>=0;D9--)if(a9[D9].it.depth===M8){v8=a9[D9].it;break}if(!v8)v8=z0;K9="after",W7=M8}if(v8&&v8.key!==e0&&!J9.has(v8.key)){let D9=z0?a9[F0-1].rect.bottom:a9[0].rect.top,c6=r7+S6+W7*i8;P7={refId:v8.id,position:K9,node:v8.node,y:D9,left:c6,w:Math.max(24,t-c6)}}}let p6={key:e0,node:p0,dx:w9,dy:K7,target:P7};q9.current=p6,p8(p6)},IJ=()=>{window.removeEventListener("pointermove",D7),window.removeEventListener("pointerup",E9),window.removeEventListener("keydown",y7,!0)},d9=()=>{let z9=(w9)=>{w9.preventDefault(),w9.stopImmediatePropagation(),document.removeEventListener("click",z9,!0)};document.addEventListener("click",z9,!0),setTimeout(()=>document.removeEventListener("click",z9,!0),300)},E9=()=>{IJ();let z9=q9.current;if(q9.current=null,p8(null),$6&&z9?.target)d9(),r0(z9.node,z9.target.node,z9.target.position)},y7=(z9)=>{if(z9.key!=="Escape")return;if(z9.preventDefault(),z9.stopImmediatePropagation(),IJ(),q9.current=null,p8(null),$6)d9()};window.addEventListener("pointermove",D7),window.addEventListener("pointerup",E9),window.addEventListener("keydown",y7,!0)},K0=(E0)=>Q8((p0)=>{let e0=new Set(p0);if(e0.has(E0))e0.delete(E0);else e0.add(E0);return e0}),S0=(E0)=>{let p0=`${E0.id}:${E0.index}`,e0=Z8(E0),w0=!e0;if(F8((o0)=>new Map(o0).set(p0,w0)),L?.({id:E0.id,artboardId:Q?.artboardId??null,index:E0.index,prop:"display",value:w0?"none":null}),!H||!E0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w0?{canvas:H,id:E0.id,property:"display",value:"none"}:{canvas:H,id:E0.id,property:"display",reset:!0})}).catch(()=>{}),D?.({op:"css",canvas:H,id:E0.id,key:"display",before:e0?"none":null,after:w0?"none":null})},H0=Array.isArray(X)?X[0]:X,L0=c?{asset:c.asset,kind:"annotation-image"}:(()=>{let E0=F10(H0);return E0?{asset:E0,kind:"artboard-img"}:null})(),N0=L0?.kind==="annotation-image",Y8=(E0)=>{if(!(E0.metaKey||E0.ctrlKey)||E0.altKey)return;let p0=E0.key.toLowerCase();if(p0==="z")E0.preventDefault(),s?.(E0.shiftKey?"redo":"undo");else if(p0==="y")E0.preventDefault(),s?.("redo")},P8=N0?"photo":V0==="photo"&&!L0?"inspect":V0,I8=(E0,p0,e0)=>A("button",{type:"button",className:"st-rp-tab"+(P8===E0?" is-active":""),onClick:()=>m0(E0),children:[z(X9,{name:e0,size:14}),p0]}),M0=H0?.bounds||null;return A("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[A("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:X0?{display:"none"}:void 0,children:[N0?I8("photo","Photo","image"):A(Y0,{children:[I8("inspect","Inspect","sliders"),!o&&I8("layers","Layers","layers"),I8("css","CSS","code"),L0?I8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:z(X9,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&C?A("div",{className:`st-scope st-scope--${C.scope}`,title:C.scope==="shared"?`Editing this element's style changes ${C.affects} place${C.affects===1?"":"s"}${C.componentName?` (component ${C.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"}),C.scope==="shared"?`Shared${C.componentName?` · ${C.componentName}`:""} · edits ${C.affects} place${C.affects===1?"":"s"}`:"Local · this element only",C.scope==="shared"&&Z?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:P8==="photo"&&L0?z("div",{onKeyDown:Y8,children:z(Bv,{asset:L0.asset,ColorPicker:bt,StIcon:X9,onEdit:(E0)=>p?.(L0.asset,E0),onRemoveBackground:r,onRecordEdit:(E0,p0)=>h?.(L0.asset,E0,p0)},`${L0.asset}:${f??0}`)}):!H0&&!(P8==="layers"&&Q?.nodes?.length)?z("div",{className:"st-rp-empty",children:A("p",{children:["Press ",z(d6,{children:"V"}),", then click an element to select it — or ",z(d6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&P8==="inspect"?A(Y0,{children:[z("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:M0?Math.round(M0.x):"—",readOnly:!0,"aria-label":"x position"})]}),A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:M0?Math.round(M0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:M0?Math.round(M0.w):"—",readOnly:!0,"aria-label":"width"})]}),A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:M0?Math.round(M0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),A("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:H0.tag||"—"})})]}),H0.classes?A("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:H0.classes})})]}):null,z(z10,{el:H0})]}):P8==="layers"?A(Y0,{children:[A("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?A(Y0,{children:[r0?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:b0,onKeyDown:c8,children:Q.nodes.map((E0,p0)=>z(jt,{node:E0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:t0,onToggle:K0,onSelect:(e0)=>{q?.(e0),b0.current?.focus()},onHover:(e0)=>K?.(e0),onToggleVisibility:S0,onReorder:r0,onRowPointerDown:B0,dragState:N8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:R8},`${E0.id}:${E0.index}`))}),N8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:N8.target.left,top:N8.target.y-1,width:N8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:A8})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((E0,p0)=>A("div",{className:"st-layer"+(p0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+p0*12},children:[z(X9,{name:"square",size:13}),E0]},p0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&yt(H0)?z(V10,{el:H0,cfg:F,onResizeArtboard:R,onSetArtboardHug:_,onSetArtboardStyle:O,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I}):z(Y10,{el:H0,cfg:F,onOptimistic:L,onRecordEdit:D,onReplaceMedia:w,onUndoRedo:S,mode:U0,onSetMode:i})})]})}function L10(){let[X,J]=d.useState([]),[Q,Y]=d.useState("Design"),[W,G]=d.useState([]),[Z,H]=d.useState(null),[q,K]=d.useState(null),V=d.useRef(null);d.useEffect(()=>{V.current=q},[q]);let[B,F]=d.useState(null);d.useEffect(()=>{let v=Array.isArray(q)?q.length===1?q[0]:null:q,j=v&&typeof v.id==="string"?v.id:null;if(!j||!Z){F(null);return}let Q0=new AbortController,Z0=new URLSearchParams({canvas:Z,id:j});return fetch(`/_api/edit-scope?${Z0}`,{signal:Q0.signal}).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(W0?.ok)F(W0)}).catch(()=>{}),()=>Q0.abort()},[q,Z]);let L=d.useRef(0),D=d.useRef([]),w=d.useCallback((v)=>{if(!v?.id||!v.file)return;for(let j of D.current)clearTimeout(j);D.current=[50,450,1200,2500,5000].map((j)=>setTimeout(()=>{let Q0=V.current,Z0=Array.isArray(Q0)?Q0[0]:Q0;if(!Z0||Z0.id!==v.id||Z0.file!==v.file)return;let W0=y8.current.get(v.file);if(!W0?.contentWindow)return;try{W0.contentWindow.postMessage({dgn:"select-by-id",id:v.id,artboardId:v.artboardId??null,index:v.index??0},"*")}catch{}},j))},[]),R=d.useRef([]),_=d.useCallback((v,j)=>{if(!v||!j)return;for(let Q0 of R.current)clearTimeout(Q0);R.current=[50,450,1200,2500,5000].map((Q0)=>setTimeout(()=>{let Z0=V.current,W0=Array.isArray(Z0)?Z0[0]:Z0;if(!W0||W0.artboardId!==v||W0.file!==j)return;let f0=y8.current.get(j);if(!f0?.contentWindow)return;try{f0.contentWindow.postMessage({dgn:"select-by-id",artboardId:v},"*")}catch{}},Q0))},[]),O=d.useRef(null),P=d.useRef(null),T=d.useRef(null),I=d.useRef(null),S=d.useRef(!1),C=d.useRef(null),[b,y]=d.useState(null),[g,m]=d.useState(null),c=d.useRef({canvas:null,at:0});d.useEffect(()=>{if(!Z||!b)return;let v=Date.now(),j=c.current;if(j.canvas===Z&&v-j.at<1500)return;c.current={canvas:Z,at:v},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((Q0)=>Q0.json()).then((Q0)=>{if(Q0?.ok&&Q0.map&&typeof Q0.map==="object")m(Q0.map);else m(null)}).catch(()=>m(null))},[Z,b]);let[f,p]=d.useState(!1),[r,h]=d.useState(null),[s,X0]=d.useState(null),[o,U0]=d.useState(null),[i,u]=d.useState(null),[n,V0]=d.useState(!1),[m0,J8]=d.useState(null),[Q8,t0]=d.useState(""),[F8,Z8]=d.useState(null),[N8,p8]=d.useState(null),A8=d.useRef(null),g0=Zt("maude-sb-w",{min:200,max:420,def:252}),R8=Zt("maude-rp-w",{min:260,max:480,def:304}),[r0,f8]=d.useState(null),c8=d.useRef(null);d.useEffect(()=>{if(!r0)return;let v=(Q0)=>{let Z0=c8.current?.getBoundingClientRect();if(!Z0)return;if(r0==="sb")g0.setW(Q0.clientX-Z0.left);else R8.setW(Z0.right-Q0.clientX)},j=()=>f8(null);return window.addEventListener("pointermove",v),window.addEventListener("pointerup",j),()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",j)}},[r0,g0.setW,R8.setW]);let q9=d.useCallback((v)=>{clearTimeout(A8.current),A8.current=setTimeout(()=>{p8((j)=>j===v?null:j)},2500)},[]);d.useEffect(()=>{if(!N8)return;let v=setTimeout(()=>p8(null),15000);return()=>clearTimeout(v)},[N8]);let[b0,B0]=d.useState({designRel:".design"}),K0=d.useCallback(()=>{fetch("/_config").then((v)=>v.json()).then((v)=>{let j=(v.designRoot||".design").replace(/^\/+|\/+$/g,"");B0((Q0)=>({...Q0,designRel:j,tokensCssRel:v.tokensCssRel,designSystems:v.designSystems,canvasOrigin:v.canvasOrigin}))}).catch(()=>{})},[]);d.useEffect(()=>{K0()},[K0]),d.useEffect(()=>{let v=!1;return fetch("/_sync-status").then((j)=>j.json()).then((j)=>{if(v||!j||j.linked===!1)return;X0(j)}).catch(()=>{}),()=>{v=!0}},[]),d.useEffect(()=>{let v=!1;return fetch("/_api/git/status").then((j)=>j.json()).then((j)=>{if(!v&&j)U0(j)}).catch(()=>{}),()=>{v=!0}},[]);let[S0,H0]=d.useState({}),[L0,N0]=d.useState(null),[Y8,P8]=d.useState(!1),[I8,M0]=d.useState("open"),[E0,p0]=d.useState(WV0),[e0,w0]=d.useState(()=>{return CP(ns,"advanced")==="designer"?"designer":"advanced"});d.useEffect(()=>{try{localStorage.setItem(ns,JSON.stringify(e0))}catch{}},[e0]);let[o0,J9]=d.useState(null),[i8,S6]=d.useState(()=>NZ(rs,!0)),[r9,n7]=d.useState(()=>NZ(is,!1)),[$6,D7]=d.useState(()=>CP(os,{})),[IJ,d9]=d.useState(!1),[E9,y7]=d.useState(!1);d.useEffect(()=>{if(!d8())return;let v=Qf(()=>y7(!0));return()=>{v.then((j)=>j()).catch(()=>{})}},[]);let[z9,w9]=d.useState(!1),[K7,P7]=d.useState(!1),[a9,p6]=d.useState(!1),[r7,t]=d.useState(!1),{report:F0}=Mw(d8()),[z0,T0]=d.useState(!1),[s0,_8]=d.useState(!1),[C8,M8]=d.useState(null),[v8,K9]=d.useState(!1),[W7,D9]=d.useState(!1),[c6,WQ]=d.useState(!1),[UY,GQ]=d.useState(!1),[b6,VY]=d.useState(()=>CP(es,vq)),[GX,f7]=d.useState(()=>{try{let v=localStorage.getItem(Xt);if(v==="separate"||v==="in-inspector")return v}catch{}return"separate"}),[CJ,s9]=d.useState(!1),[R7,L5]=d.useState([]),[BY,G7]=d.useState(0),[FY,sX]=d.useState(!1),[k7,gq]=d.useState(!1),[tX,O7]=d.useState(!1),[ZQ,j9]=d.useState(1),[m9,HQ]=d.useState(216),[ZX,LZ]=d.useState(null),[NY,DZ]=d.useState([]),[mq,OZ]=d.useState([]),[qQ,LY]=d.useState(0),j6=d.useMemo(()=>{if(!R7.length)return null;return(R7.find((j)=>j.durationInFrames===qQ)??R7[0]).id},[R7,qQ]),D5=d.useRef(null);d.useEffect(()=>{D5.current=j6},[j6]);let KW=d.useRef(0);d.useEffect(()=>{KW.current=BY},[BY]);let[i6,uq]=d.useState(null),lq=d.useRef(null);d.useEffect(()=>{lq.current=i6},[i6]);let[_X,UW]=d.useState(!1),[dq,O5]=d.useState(!1),[zQ,EX]=d.useState(!1),VW=d.useRef(_X);d.useEffect(()=>{if(VW.current=_X,_X){EX(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let M5=d.useCallback(()=>{if(!VW.current||document.hidden)EX(!0),Qt("Claude finished","Your assistant turn is ready in Maude.")},[]),MZ=d.useRef(0),DY=d.useCallback(()=>{if(!VW.current||document.hidden){EX(!0);let v=Date.now();if(v-MZ.current<QV0)return;MZ.current=v,Qt("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[KQ,w5]=d.useState("inspect"),[SJ,A5]=d.useState(null),_5=d.useRef({undo:[],redo:[]}),[pq,$J]=d.useState(0),[p9,t9]=d.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=d.useRef(p9);d.useEffect(()=>{OY.current=p9;try{localStorage.setItem("maude-auto-open-inspector",p9?"1":"0")}catch{}},[p9]);let eX=d.useRef(!1);d.useEffect(()=>{eX.current=c6||Y8||n||_X},[c6,Y8,n,_X]);let UQ=d.useRef({open:{},side:vq});UQ.current={open:{tree:i8,layers:UY,inspector:c6,comments:Y8,changes:n,assistant:_X},side:b6};let bJ=d.useCallback((v,j)=>{if(v==="tree")S6(j);else if(v==="layers")GQ(j);else if(v==="inspector")WQ(j);else if(v==="comments")P8(j);else if(v==="changes")V0(j);else if(v==="assistant")UW(j)},[]),BW=d.useCallback((v)=>UQ.current.side?.[v]||vq[v],[]),a7=d.useCallback((v)=>{let j=BW(v);bJ(v,!0);for(let Q0 of yP)if(Q0.id!==v&&BW(Q0.id)===j)bJ(Q0.id,!1)},[bJ,BW]),jJ=d.useCallback((v)=>{if(UQ.current.open?.[v])bJ(v,!1);else a7(v)},[a7,bJ]),HX=a7,D6=jJ,PX=d.useCallback((v)=>{if(!OY.current)return;if(!v||!v.id)return;if(eX.current)return;HX("inspector"),w5("css")},[HX]),MY=d.useCallback(()=>s9((v)=>!v),[]),E5=$v(vP),qX=Dv(),[cq,FW]=d.useState(!1),[wZ,AZ]=d.useState(!1);d.useEffect(()=>{if(!d8())return;let v=!0;return Zf().then((j)=>{if(!v)return;if(FW(!!j),!j&&!NZ(cs,!1))AZ(!0)}).catch(()=>{}),()=>{v=!1}},[]);let _Z=d.useCallback(()=>{AZ(!1);try{localStorage.setItem(cs,"1")}catch{}},[]),[NW,EZ]=d.useState(null);d.useEffect(()=>{if(!d8())return;let v;return Kf((j)=>EZ(j&&typeof j==="object"?j:{})).then((j)=>{v=j}).catch(()=>{}),()=>{try{v?.()}catch{}}},[]);let[P5,PZ]=d.useState(null),[LW,iq]=d.useState(()=>!NZ(ps,!1)),yJ=d.useCallback((v)=>{PZ(Array.isArray(v)&&v.length?v:null)},[]),oq={setup:(v)=>{if(!v)return;if((v.canvas||v.requireSelection)&&W.length===0)a7("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(v.inspector||v.tab||v.requireSelection)HX("inspector");if(v.tab)w5(v.tab);if(v.changes)HX("changes")}},DW=d.useCallback(()=>{iq(!1);try{localStorage.setItem(ps,"1")}catch{}},[]),[R5,RZ]=d.useState(()=>NZ(ts,!0)),[kZ,nq]=d.useState(!1),[zX,wY]=d.useState(()=>NZ(as,!1)),[KX,TZ]=d.useState(()=>NZ(ss,!1)),[o6,VQ]=d.useState(!1),[OW,y6]=d.useState(!1),[rq,k5]=d.useState(0),[MW,aq]=d.useState(null),[sq,IZ]=d.useState(!1),fJ=d.useRef(null),T5=d.useRef(null),y8=d.useRef(new Map),K8=d.useCallback((v)=>{let j=Z?y8.current.get(Z):null;if(!j||!j.contentWindow)return;try{j.contentWindow.postMessage(v,"*")}catch{}},[Z]),wW=d.useCallback((v,j)=>K8({dgn:"photo-preview",asset:v,edit:j}),[K8]),tq=d.useCallback((v,j,Q0)=>{_5.current.undo.push({asset:v,before:j,after:Q0}),_5.current.redo.length=0},[]),AW=d.useCallback((v)=>{let j=v?_5.current.redo:_5.current.undo;if(!j.length)return!1;let Q0=j.pop();(v?_5.current.undo:_5.current.redo).push(Q0);let Z0=(v?Q0.after:Q0.before)||{};return wW(Q0.asset,Z0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(Q0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z0)}).catch(()=>{}),$J((W0)=>W0+1),!0},[wW]),eq=d.useCallback(async(v)=>{K8({dgn:"photo-busy",asset:v,busy:!0});try{let j=await fetch(`/${v.replace(/^\/+/,"")}`);if(!j.ok)return null;let Q0=await j.blob(),{removeBackground:Z0}=await Promise.resolve().then(() => (ds(),ls)),W0=await Z0(Q0),f0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":W0.type||"image/png"},body:W0}),l=await f0.json().catch(()=>({}));if(f0.ok&&l.path)return{maskAsset:l.path};return null}catch(j){return console.error("[photo] background removal failed",j),null}finally{K8({dgn:"photo-busy",asset:v,busy:!1})}},[K8]);d.useEffect(()=>{let v=(Z0)=>Array.from(Z0.dataTransfer?.types??[]).includes("Files"),j=(Z0)=>{if(v(Z0))Z0.preventDefault()},Q0=(Z0)=>{if(v(Z0))Z0.preventDefault()};return document.addEventListener("dragover",j),document.addEventListener("drop",Q0),()=>{document.removeEventListener("dragover",j),document.removeEventListener("drop",Q0)}},[]);let BQ=d.useRef({});BQ.current={open:CJ,comps:R7,frame:BY,total:qQ,playing:FY,compId:j6,muted:tX,loop:k7,sequences:NY,post:K8,canvas:Z};let FQ=d.useRef({undo:[],redo:[]}),vJ=d.useCallback((v,j,Q0)=>{if(typeof j!=="number")return;if(FQ.current.undo.push({canvas:v,seq:j,label:Q0}),FQ.current.redo=[],FQ.current.undo.length>50)FQ.current.undo.shift()},[]),xJ=d.useCallback((v)=>{let j=FQ.current,Q0=v==="undo"?j.undo:j.redo,Z0=v==="undo"?j.redo:j.undo,W0=BQ.current.canvas,f0=-1;for(let D0=Q0.length-1;D0>=0;D0--)if(Q0[D0].canvas===W0){f0=D0;break}if(f0<0){l9(v==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let l=Q0[f0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:l.canvas,seq:l.seq,dir:v})}).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{if(Q0.splice(f0,1),D0?.ok)Z0.push(l),l9(`${v==="undo"?"Undid":"Redid"}: ${l.label}`,!0);else l9(`${v==="undo"?"Undo":"Redo"} skipped: ${D0?.error||"failed"}`)}).catch(()=>l9(`${v==="undo"?"Undo":"Redo"} failed: network error`))},[]);d.useEffect(()=>{let v=(j)=>{let Q0=BQ.current;if(!Q0.open||!Q0.comps?.length)return;let Z0=j.target,W0=Z0?.tagName;if(W0==="INPUT"||W0==="TEXTAREA"||W0==="SELECT"||Z0?.isContentEditable)return;let f0=Q0.comps[0]?.fps||30,l=Math.max(1,Q0.total),D0=(v0)=>{let B8=Math.max(0,Math.min(l-1,Math.round(v0)));G7(B8),sX(!1),Q0.post({dgn:"timeline-seek",frame:B8,id:Q0.compId})},k0=()=>{let v0=new Set([0,l-1]);for(let B8 of Q0.sequences||[]){v0.add(B8.from);for(let w8 of B8.keyframes||[])v0.add(w8.from),v0.add(w8.to)}return[...v0].filter((B8)=>B8>=0&&B8<l).sort((B8,w8)=>B8-w8)};if((j.metaKey||j.ctrlKey)&&(j.key==="z"||j.key==="Z")){j.preventDefault(),xJ(j.shiftKey?"redo":"undo");return}if(j.key===" "||j.code==="Space")if(j.preventDefault(),Q0.playing)sX(!1),Q0.post({dgn:"timeline-pause",id:Q0.compId});else sX(!0),Q0.post({dgn:"timeline-mute",muted:Q0.muted,id:Q0.compId}),Q0.post({dgn:"timeline-loop",loop:Q0.loop,id:Q0.compId}),Q0.post({dgn:"timeline-play",id:Q0.compId});else if(j.key==="ArrowRight")j.preventDefault(),D0(Q0.frame+(j.shiftKey?f0:1));else if(j.key==="ArrowLeft")j.preventDefault(),D0(Q0.frame-(j.shiftKey?f0:1));else if(j.key==="Home")j.preventDefault(),D0(0);else if(j.key==="End")j.preventDefault(),D0(l-1);else if(j.key==="."){j.preventDefault();let v0=k0().find((B8)=>B8>Q0.frame);if(v0!=null)D0(v0)}else if(j.key===","){j.preventDefault();let v0=k0().reverse().find((B8)=>B8<Q0.frame);if(v0!=null)D0(v0)}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]),d.useEffect(()=>{L5([]),G7(0),sX(!1);let v=setTimeout(()=>K8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(v)},[Z,K8]);let[s7,AY]=d.useState(""),[CZ,_W]=d.useState([]);d.useEffect(()=>{if(!CJ||R7.length===0||!Z||Z===l8){AY(""),_W([]);return}let v=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((j)=>j.ok?j.json():null).then((j)=>{if(v&&j?.ok&&typeof j.source==="string")AY(j.source)}).catch(()=>{}),()=>{v=!1}},[CJ,R7,Z]),d.useEffect(()=>{if(!CJ||!Z||Z===l8||!s7){_W([]);return}let v=!0,j=i6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${j?`&artboardId=${encodeURIComponent(j)}`:""}`;return fetch(Q0).then((Z0)=>Z0.ok?Z0.json():null).then((Z0)=>{if(!v)return;let W0=Z0?.ok&&Array.isArray(Z0.clips)?Z0.clips.filter((f0)=>f0.kind==="sequence"):[];_W(W0)}).catch(()=>{}),()=>{v=!1}},[CJ,Z,s7,i6]),d.useEffect(()=>{if(!s7){DZ([]),OZ([]),LY(0);return}let v=R7[0]?.durationInFrames||0,j=ZX??q?.artboardId??null,Q0=ef(s7,v,j);uq(Q0.artboardId??j??null);let Z0=Q0.sequences.map((W0,f0)=>{let l=CZ[f0];if(!l)return W0;return{...W0,mediaTag:l.mediaTag??W0.mediaTag,mediaSrc:l.mediaSrc??W0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});DZ(Z0),OZ(Q0.audio||[]),LY(Q0.total)},[s7,CZ,q,R7,ZX]);let I5=d.useCallback(()=>{RZ((v)=>{let j=!v,Q0=Z?y8.current.get(Z):null;if(Q0&&Q0.contentWindow)try{Q0.contentWindow.postMessage({dgn:"view-annotations",visible:j},"*")}catch{}return j})},[Z]),G6=d.useCallback((v)=>{for(let j of y8.current.values())try{j.contentWindow.postMessage({dgn:"view-chrome",...v},"*")}catch{}},[]),_Y=d.useCallback(()=>{wY((v)=>{let j=!v;return G6({minimap:j}),j})},[G6]),EY=d.useCallback(()=>{TZ((v)=>{let j=!v;return G6({zoom:j}),j})},[G6]),EW=d.useCallback(()=>{VQ((v)=>{let j=!v;return G6({present:j}),j})},[G6]),NQ=d.useCallback(()=>{VQ(!1),G6({present:!1})},[G6]),PW=d.useCallback(()=>{if(!Z||Z===l8)return;y6((v)=>{let j=!v;return K8({dgn:"view-chrome",print:j}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:j}}})}).catch(()=>{}),j})},[Z,K8]);d.useEffect(()=>{let v=!1;return fetch("/_api/git-user").then((j)=>j.json()).then((j)=>{if(v)return;let Q0=j&&typeof j.name==="string"?j.name.trim():"";if(Q0)aq(Q0)}).catch(()=>{}),()=>{v=!0}},[]),d.useEffect(()=>{if(!Z||Z===l8){k5(0),y6(!1);return}let v=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((j)=>j.json()).then((j)=>{if(v)return;let Q0=Array.isArray(j?.artboards)?j.artboards.length:0;k5(Q0),y6(j?.overlays?.print===!0),RW(new Set(Array.isArray(j?.locked)?j.locked:[]))}).catch(()=>{if(!v)k5(0),y6(!1),RW(new Set)}),()=>{v=!0}},[Z]),d.useEffect(()=>{if(!Z||Z===l8||!ZX)return;let v=setTimeout(()=>{K8({dgn:"request-layers",artboardId:ZX})},250);return()=>clearTimeout(v)},[Z,ZX,K8]);let[LQ,RW]=d.useState(()=>new Set),kW=d.useCallback((v)=>{if(!Z||Z===l8)return;RW((j)=>{let Q0=new Set(j);if(Q0.has(v))Q0.delete(v);else Q0.add(v);let Z0=[...Q0];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:Z0}})}).catch(()=>{}),K8({dgn:"locked-set",locked:Z0}),Q0})},[Z,K8]);d.useEffect(()=>{if(!Z||Z===l8)return;K8({dgn:"locked-set",locked:[...LQ]})},[LQ,Z,K8]),d.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",E0),localStorage.setItem(Rt,E0)}catch{}for(let v of y8.current.values())try{v.contentWindow.postMessage({dgn:"theme",theme:E0},"*")}catch{}},[E0]),d.useEffect(()=>{try{localStorage.setItem(rs,i8?"1":"0")}catch{}},[i8]),d.useEffect(()=>{try{localStorage.setItem(is,r9?"1":"0")}catch{}},[r9]),d.useEffect(()=>{try{localStorage.setItem(os,JSON.stringify($6))}catch{}},[$6]),d.useEffect(()=>{try{localStorage.setItem(as,zX?"1":"0")}catch{}},[zX]),d.useEffect(()=>{try{localStorage.setItem(ss,KX?"1":"0")}catch{}},[KX]),d.useEffect(()=>{try{localStorage.setItem(ts,R5?"1":"0")}catch{}},[R5]),d.useEffect(()=>{let v=!1;return fetch("/_api/ui-prefs").then((j)=>j.ok?j.json():Promise.reject(Error(`HTTP ${j.status}`))).then((j)=>{if(v||!j||typeof j!=="object")return;if(j.theme==="light"||j.theme==="dark")p0(j.theme);if(typeof j.minimap==="boolean")wY(j.minimap);if(typeof j.zoom==="boolean")TZ(j.zoom);if(typeof j.annotations==="boolean")RZ(j.annotations);if(typeof j.autoOpenInspector==="boolean")t9(j.autoOpenInspector);if(j.panelSides&&typeof j.panelSides==="object")VY({...vq,...j.panelSides});if(j.layersMode==="separate"||j.layersMode==="in-inspector")f7(j.layersMode)}).catch(()=>{}).finally(()=>{if(!v)nq(!0)}),()=>{v=!0}},[]),d.useEffect(()=>{if(!kZ)return;YV0({theme:E0,minimap:zX,zoom:KX,annotations:R5,autoOpenInspector:p9,panelSides:b6,layersMode:GX})},[kZ,E0,zX,KX,R5,p9,b6,GX]),d.useEffect(()=>{try{localStorage.setItem(es,JSON.stringify(b6))}catch{}},[b6]),d.useEffect(()=>{try{localStorage.setItem(Xt,GX)}catch{}},[GX]);let Xz=d.useCallback((v,j)=>{D7((Q0)=>{let Z0=Q0[v],W0=Z0===void 0?j:Z0;return{...Q0,[v]:!W0}})},[]),DQ=d.useCallback(()=>{p0((v)=>v==="dark"?"light":"dark")},[]),$9=d.useCallback(async()=>{try{let j=await(await fetch("/_index-data")).json();Y(j.project||"Design");let Q0=j.groups.map((Z0)=>({...Z0,tree:zV0(Z0.paths,Z0.stripPrefix,Z0.dirs)}));J(Q0),B0((Z0)=>({...Z0,canvasDesignSystems:j.canvasDesignSystems??{},canvasKinds:j.canvasKinds??{}}))}catch(v){console.error("failed to load tree",v)}},[]);d.useEffect(()=>{$9()},[$9]);let G0=d.useCallback(async(v)=>{try{let j=v?`/_system-data?ds=${encodeURIComponent(v)}`:"/_system-data",Q0=await fetch(j);if(!Q0.ok){console.error("failed to load system-data",Q0.status);return}let Z0=await Q0.json();if(!v&&Z0?.defaultDesignSystem&&!Z0.ds){Z8(Z0);let W0=await fetch(`/_system-data?ds=${encodeURIComponent(Z0.defaultDesignSystem)}`);if(W0.ok)Z8(await W0.json());return}Z8(Z0)}catch(j){console.error("failed to load system-data",j)}},[]),SZ=d.useCallback(async()=>{try{let j=await(await fetch("/_comments-all")).json();H0(j||{})}catch(v){console.error("failed to load comments",v)}},[]);d.useEffect(()=>{SZ()},[SZ]),d.useEffect(()=>{function v(){let j=location.protocol==="https:"?"wss:":"ws:",Q0=new WebSocket(j+"//"+location.host+"/_ws");T5.current=Q0,Q0.addEventListener("open",()=>p(!0)),Q0.addEventListener("close",()=>{p(!1),setTimeout(v,1000)}),Q0.addEventListener("error",()=>{}),Q0.addEventListener("message",(Z0)=>{try{let W0=JSON.parse(Z0.data);if(W0.type==="snapshot"&&W0.state)K((f0)=>At(W0.state.selected,f0));else if(W0.type==="selected"){if(Date.now()-L.current<2000)return;let f0=W0.selected,l=Array.isArray(f0)?f0[0]:f0,D0=V.current,k0=Array.isArray(D0)?D0[0]:D0;if(K((v0)=>At(f0,v0)),l?.id&&l.file&&(!k0||k0.id!==l.id||k0.file!==l.file))w(l)}else if(W0.type==="comments"&&typeof W0.file==="string")H0((f0)=>({...f0,[W0.file]:W0.comments||[]}));else if(W0.type==="ai-activity"&&typeof W0.file==="string"){if(IZ(!0),fJ.current)clearTimeout(fJ.current);fJ.current=setTimeout(()=>IZ(!1),8000);for(let f0 of y8.current.values())try{f0.contentWindow.postMessage({dgn:"ai-activity",file:W0.file,entry:W0.entry},"*")}catch{}}else if(W0.type==="export:job"&&W0.payload)qX.upsert(W0.payload);else if(W0.type==="sync:status"&&W0.payload)X0(W0.payload);else if(W0.type==="canvas-list-update"){if($9(),W0.payload?.action==="moved"&&W0.payload.fromRel&&W0.payload.rel){let f0=(b0?.designRel||b0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${f0}/${W0.payload.fromRel}`,D0=`${f0}/${W0.payload.rel}`;G((k0)=>k0.map((v0)=>v0.path===l?{path:D0}:v0)),H((k0)=>k0===l?D0:k0)}}else if(W0.type==="config-updated")K0();else if(W0.type==="acp-focus"){if(d8())HX("assistant")}else if(W0.type==="git-status"&&W0.payload)U0(W0.payload);else if(W0.type==="git-lifecycle"&&W0.payload){h(W0.payload);for(let f0 of y8.current.values())try{f0.contentWindow.postMessage({dgn:"git-lifecycle",payload:W0.payload},"*")}catch{}}}catch{}})}return v(),()=>T5.current&&T5.current.close()},[$9,K0]);function M7(v){let j=T5.current;try{if(j&&j.readyState===1)j.send(JSON.stringify(v))}catch{}}let f6=d.useCallback(async()=>{try{let v=await fetch("/_api/git/status");if(v.ok)U0(await v.json())}catch{}},[]),t7=d.useCallback(async()=>{try{let v=await fetch("/_api/git/status?remote=1");if(!v.ok)return;let j=await v.json();if(j&&j.repo!==!1)u({remoteAhead:!!j.remoteAhead,behind:j.behind||0})}catch{}},[]),A9=d.useCallback(async(v,j)=>{try{let Q0=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j||{})}),Z0=await Q0.json().catch(()=>({}));return{ok:Q0.ok,...Z0}}catch(Q0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),hJ=d.useCallback(async(v,j)=>{let Q0=await A9("/_api/git/commit",{message:v,files:j});if(Q0.ok)await f6();return Q0},[A9,f6]),C5=d.useCallback(async(v)=>{let j=await A9("/_api/git/discard",{files:v});if(j.ok)await f6();return j},[A9,f6]),TW=d.useCallback(async()=>{let v=await A9("/_api/git/push",{});if(v.ok)await f6(),t7();return v},[A9,f6,t7]),PY=d.useCallback(async()=>{let v=await A9("/_api/git/pull",{});if(v.ok)await f6(),t7();if(v.conflict&&Array.isArray(v.files)&&v.files.length)J8({file:v.files[0],conflict:!0});return v},[A9,f6,t7]),IW=d.useCallback(async(v)=>{let j=await A9("/_api/git/resolve",{choice:v});if(j.ok)await f6(),t7();return j},[A9,f6,t7]),S5=d.useCallback(async(v)=>{try{let j="/_api/git/log?limit=40"+(v?`&path=${encodeURIComponent(v)}`:""),Q0=await fetch(j);if(!Q0.ok)return[];return(await Q0.json()).entries||[]}catch{return[]}},[]),CW=d.useMemo(()=>{let v={modified:"M",added:"A",deleted:"D",untracked:"U"},j=new Map;for(let Q0 of o?.files||[])j.set(Q0.path,v[Q0.status]);return j},[o]),RY=o?.files?.length||0;d.useEffect(()=>{if(o?.repo===!1)return;t7();let v=setInterval(t7,n?60000:120000);return()=>clearInterval(v)},[o?.repo,n,t7]);let h0=d.useCallback((v)=>{if(G((j)=>{for(let Q0 of j)if(Q0.path!==v)y8.current.delete(Q0.path);return[{path:v}]}),H(v),N0(null),v!==l8)p8(v)},[]),Z6=d.useCallback((v)=>{let j=typeof v==="string"?v:void 0;if(j)G0(j);else if(!F8)G0();h0(l8)},[F8,G0,h0]);d.useEffect(()=>{M7({type:"tabs",tabs:W.map((v)=>v.path).filter((v)=>v!==l8)})},[W]),d.useEffect(()=>{if(Z&&Z!==l8)M7({type:"active",file:Z});else if(Z===l8)M7({type:"active",file:""});else M7({type:"active",file:""})},[Z]);let OQ=d.useCallback((v)=>{G((j)=>{let Q0=j.findIndex((W0)=>W0.path===v);if(Q0<0)return j;let Z0=j.filter((W0)=>W0.path!==v);if(v===Z)if(Z0.length===0)H(null);else H(Z0[Math.max(0,Q0-1)].path);return Z0}),y8.current.delete(v),p8((j)=>j===v?null:j)},[Z]),x0=d.useCallback(()=>{if(!Z||Z===l8){if(Z===l8)G0();return}let v=y8.current.get(Z);if(v)v.src=v.src},[Z,G0]),$5=d.useCallback(()=>$9(),[$9]),[u0,kY]=d.useState(!1),MQ=d.useRef(!1),wQ=d.useCallback(async()=>{if(MQ.current)return;MQ.current=!0,kY(!0);try{await Promise.all([$9(),new Promise((v)=>setTimeout(v,550))])}finally{MQ.current=!1,kY(!1)}},[$9]);d.useEffect(()=>{let v=null,j=()=>{if(v)clearTimeout(v);v=setTimeout(()=>{v=null,$5()},150)};return window.addEventListener("focus",j),()=>{if(window.removeEventListener("focus",j),v)clearTimeout(v)}},[$5]);let SW=d.useCallback(async(v)=>{try{let j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v,kind:"brief-board"})}),Q0=await j.json().catch(()=>({}));if(!j.ok||!Q0.ok)return{ok:!1,error:Q0.error||`create failed (${j.status})`};return await $9(),h0(Q0.file),{ok:!0,file:Q0.file}}catch(j){return{ok:!1,error:j instanceof Error?j.message:"network error"}}},[$9,h0]),$W=d.useCallback(async()=>{if(!Z||Z===l8)return;try{let v=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),j=v.ok?await v.text():"",Q0=[];if(j){let D0=new DOMParser().parseFromString(j,"image/svg+xml");for(let k0 of D0.querySelectorAll('[data-tool="mediaref"]')){let v0=k0.getAttribute("data-src");if(!v0)continue;Q0.push({src:v0,mediaKind:k0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Q0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let W0=`${zW(TF(Z)).replace(/\.tsx$/i,"")} Video`,f0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W0,kind:"video-comp",clips:Q0})}),l=await f0.json().catch(()=>({}));if(!f0.ok||!l.ok){window.alert(`Assemble failed: ${l.error||`error ${f0.status}`}`);return}await $9(),h0(l.file)}catch(v){window.alert(`Assemble failed: ${v instanceof Error?v.message:"network error"}`)}},[Z,$9,h0]),AQ=d.useCallback(({accept:v,resolveTarget:j})=>{let Q0=Z,Z0=i6||void 0,W0=document.createElement("input");W0.type="file",W0.accept=v,W0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(W0);let f0=()=>{if(W0.isConnected)W0.remove()};window.addEventListener("focus",()=>setTimeout(f0,300),{once:!0}),W0.addEventListener("change",()=>{let l=W0.files?.[0];if(f0(),!l)return;let D0=`/_api/comp-clips?canvas=${encodeURIComponent(Q0)}${Z0?`&artboardId=${encodeURIComponent(Z0)}`:""}`;fetch(D0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let v0=j(k0);if(!v0)return l9("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":l.type||"application/octet-stream"},body:l}).then((B8)=>B8.json().catch(()=>({}))).then((B8)=>{if(!B8?.path)return l9(`Upload failed: ${B8?.error||"unknown error"}`),null;if(v0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,arrayName:v0.arrayRef.arrayName,index:v0.arrayRef.index,field:v0.arrayRef.field,value:B8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,id:v0.cdId,attr:"src",value:B8.path})})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)l9(`Replace refused: ${k0.error||"failed"}`);else if(k0&&k0.ok){if(l9("Media replaced.",!0),k0.seq!=null)vJ(Q0,k0.seq,"replace media")}}).catch(()=>l9("Replace failed: network error"))}),W0.click()},[Z,i6,vJ]),_Q=d.useCallback(async(v,j)=>{if(!window.confirm(`Move “${j}” to trash?
5653
+ `).length," lines, paths & secrets scrubbed) —"," ",A("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,d8()&&V.length>0&&A("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(m)=>L({...F,crashLogs:m.target.checked})}),A("span",{children:["Crash logs (",V.length,") — ",z("code",{children:V.map((m)=>m.name).join(", ")})]})]})]}),A("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."]}),A("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"rb-btn",onClick:()=>Y("describe"),children:"Back"}),z("button",{type:"button",className:"rb-btn rb-primary","data-testid":"report-bug-send",onClick:b,children:"Send report"})]})]}),Q==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&A(Y0,{children:[R?.issueUrl?A("p",{children:["Thank you — your report is filed as"," ",A("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(d8())GU(R.issueUrl).catch(()=>navigator.clipboard?.writeText(R.issueUrl));else window.open(R.issueUrl,"_blank","noopener")},children:["report #",R.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):A("p",{children:["The bundle is saved locally",R?.fallbackDir?A(Y0,{children:[" ","at ",z("code",{children:R.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:"rb-btn rb-primary",onClick:S,children:"Done"})})]}),Q==="fallback"&&A(Y0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:O}),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."}),A("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"rb-btn",onClick:()=>Y("preview"),children:"Back"}),z("button",{type:"button",className:"rb-btn rb-primary",onClick:y,children:"Save locally & open GitHub"})]})]})]})]})})}var wX=T8(j8(),1);function Tv(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 Iv(X,J){let Q=Tv(X),Y=Tv(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 Cv(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Iv(Q.version,J)))}function Sv(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Iv(Y.version,Q))Q=Y.version}return Q}var lw="mdcc-whatsnew-seen",dw="mdcc-whatsnew-toast-dismissed";function cG0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function iG0(X){try{let J=localStorage.getItem(lw);if(J)return J;localStorage.setItem(lw,X)}catch{}return X}function oG0(){try{return localStorage.getItem(dw)}catch{return null}}function $v(X){let[J,Q]=wX.useState([]),[Y,W]=wX.useState(X),[G,Z]=wX.useState(()=>iG0(X)),[H,q]=wX.useState(()=>oG0()),[K,V]=wX.useState(!1);wX.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then((S)=>S.json()).then((S)=>{if(O)return;if(Q(Array.isArray(S?.entries)?S.entries:[]),typeof S?.version==="string")W(S.version)}).catch(()=>{})};P();let T=()=>P(),I=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",I),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",I)}},[]);let B=Cv(J,G),F=B.length>0&&H!==Y&&!K,L=B[0]??null,D=wX.useCallback(()=>{let O=Sv(J,Y);Z(O),q(Y);try{localStorage.setItem(lw,O),localStorage.setItem(dw,Y)}catch{}},[J,Y]),w=wX.useCallback(()=>{q(Y);try{localStorage.setItem(dw,Y)}catch{}},[Y]),R=wX.useCallback(()=>V(!0),[]),_=wX.useCallback(()=>{V(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:K,openPanel:R,closePanel:_,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:D}}function bv({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return A("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:"×"}),A("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}),A("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 jv({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(wX.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:A("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[A("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)=>A("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[A("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}),cG0(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 S9=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ps="mdcc-usage-tour-seen",cs="mdcc-collab-tour-seen",l8="__system__",Rt="mdcc-theme",is="mdcc-show-hidden",os="mdcc-sections-expanded",ns="maude-cp-mode",rs="mdcc-sidebar-open",as="mdcc-minimap-visible",ss="mdcc-zoomctl-visible",ts="mdcc-annotations-visible";var QV0=30000;function YV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var yP=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],vq={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},es="mdcc-panel-sides",Xt="mdcc-layers-mode";function Jt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return A("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((H)=>z("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(yP.find((q)=>q.id===H)||{}).label||H},H))}),Z]})}var YQ=/\.(tsx|html?)$/i;function PF(X){return X.replace(/^\.[^/]+\//,"").replace(YQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var vP="0.51.0";function Qt(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function WV0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Rt);if(X==="light"||X==="dark")return X}catch{}return"dark"}function NZ(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 CP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function GV0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function TF(X){return X.split("/").pop()}function l9(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(l9._t),l9._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var Yt="maude-browse-hint-seen";function ZV0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(Yt)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let X=document.createElement("div");X.id="st-browse-hint",X.setAttribute("role","status"),X.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;",X.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <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> to select &amp; edit like Figma.</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 J=()=>{try{localStorage.setItem(Yt,"1")}catch{}X.style.opacity="0",setTimeout(()=>X.remove(),200),document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)J()};X.querySelector("button")?.addEventListener("click",J),document.addEventListener("keydown",Q,!0),document.body.appendChild(X),requestAnimationFrame(()=>{X.style.opacity="1"}),setTimeout(J,9000)}function zW(X){return X.replace(YQ,"")}function HV0(X){return X.replace(YQ,"")}function qV0(X){let J=new Map;for(let G of X){if(!YQ.test(G.name))continue;let Z=HV0(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(YQ.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((q,K)=>q.name.localeCompare(K.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 zV0(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 q of Z)H=H[q]=H[q]||{};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 q=0;q<Z.length;q++){let K=Z[q];if(q===Z.length-1)H._files=H._files||[],H._files.push({name:K,path:W});else H[K]=H[K]||{},H=H[K]}}return Y}function kt(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=kt(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 Wt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function KV0(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 Tt(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 RF({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 UV0={"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:A(Y0,{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":A(Y0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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"})]}),"panel-left":A(Y0,{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:A(Y0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{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":A(Y0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":A(Y0,{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:A(Y0,{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:A(Y0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:A(Y0,{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:A(Y0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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:A(Y0,{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 VV0({open:X,onClose:J,actions:Q}){let[Y,W]=d.useState(""),[G,Z]=d.useState(0),H=d.useRef(null);d.useEffect(()=>{if(X)W(""),Z(0)},[X]),d.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let q=d.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(d.useEffect(()=>{if(G>=q.length)Z(0)},[q.length,G]),!X)return null;let K=(V)=>{J(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)J()},children:A("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[A("div",{className:"st-pal-search",children:[z(X9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),J();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(q.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),q[G])K(q[G])}}}),z(d6,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:q.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):q.map((V,B)=>{let F=V.group&&(B===0||q[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return A(Y0,{children:[F,A("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>K(V),children:[z("span",{className:"st-pal-icon",children:z(X9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(d6,{children:V.kbd})}):null]})]},V.id)})})]})})}function X9({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:UV0[X]})}function BV0(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 Gt({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 d6({children:X}){return z("span",{className:"kbd",children:X})}function Zt(X,{min:J,max:Q,def:Y}){let W=d.useCallback((q)=>Math.min(Q,Math.max(J,q)),[J,Q]),[G,Z]=d.useState(()=>{try{let q=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(q)?W(q):Y}catch{return Y}});d.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=d.useCallback((q)=>Z((K)=>W(typeof q==="function"?q(K):q)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function Ht({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:q,def:K}=J,V=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":q,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(K),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((L)=>L+F*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((L)=>L-F*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(q)},children:A("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 SP=[{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}],$P={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},FV0={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"]},NV0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],gV=[{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}],LV0="2x",qt=[{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}],DV0="auto",OV0={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 MV0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return OV0[J]||"application/octet-stream"}function wV0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=d.useState(null),[q,K]=d.useState(!1),[V,B]=d.useState(null),[F,L]=d.useState(()=>new Set),[D,w]=d.useState({}),[R,_]=d.useState(W?"artboard":"annotation");d.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((p)=>p.json()).then((p)=>{if(!f)return;let r=p.ok?p.assets:[];H(r),w((h)=>{let s={...h};for(let X0 of r)s[X0.path]=X0.kind;return s})}).catch(()=>f&&H([])),()=>{f=!1}},[]),d.useEffect(()=>{let f=(p)=>{if(p.key==="Escape")p.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(F).some((f)=>(D[f]||"image")!=="image"),P=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";d.useEffect(()=>{if(P&&R==="artboard")_("annotation")},[P,R]);let I=(f)=>{L((p)=>{let r=new Set(p);if(r.has(f))r.delete(f);else r.add(f);return r})},S=async(f)=>{let p=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),r=await p.json().catch(()=>({}));if(p.ok&&r.path)return{ok:!0,path:r.path};return{ok:!1,error:r.error||`upload failed (HTTP ${p.status})`}},C=async(f)=>{if(!f)return;K(!0),B(null);let p=await S(f);if(K(!1),p.ok)J(p.path);else B(p.error)},b=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},y=async(f)=>{if(!f.length)return;K(!0),B(null);let p=await Promise.all(f.map((s)=>S(s).then((X0)=>({...X0,file:s}))));K(!1);let r=p.filter((s)=>s.ok),h=p.length-r.length;if(h>0)B(`${h} of ${p.length} uploads failed`);if(r.length)w((s)=>{let X0={...s};for(let o of r)X0[o.path]=b(o.file.type);return X0}),L((s)=>{let X0=new Set(s);for(let o of r)X0.add(o.path);return X0})},g=async()=>{K(!0),B(null);try{if(Y){let r=(await zf()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:MV0(h.name)}));if(K(!1),r.length)await y(r);return}let f=await o2();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}K(!1)},m=()=>{if(d8()){g();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let p=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(p,300),{once:!0}),f.addEventListener("change",()=>{let r=f.files?Array.from(f.files):[];if(p(),!r.length)return;if(Y)y(r);else C(r[0])}),f.click()},c=(f)=>`/${X}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:A("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[A("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(X9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[A("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:m,disabled:q,children:q?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),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((f)=>{let p=Y&&F.has(f.path);return A("button",{type:"button",className:"st-ap-cell","data-selected":p?"true":void 0,"aria-pressed":Y?p:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?I(f.path):J(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:p?z(X9,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:c(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:c(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&F.size>0&&A("div",{className:"st-dialog-ft st-ap-confirm",children:[A("span",{className:"st-ap-count",children:[F.size," selected"]}),A("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:()=>_("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>_("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),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(F),R),children:"Insert"})]})]})})}function AV0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:Z}){let[H,q]=d.useState(X==="handoff"?"shadcn":"png"),[K,V]=d.useState(J&&$P[J]?J:"artboard"),[B,F]=d.useState(2),[L,D]=d.useState(LV0),[w,R]=d.useState(!0),[_,O]=d.useState(!1),[P,T]=d.useState(!1),[I,S]=d.useState(!1),[C,b]=d.useState(DV0),[y,g]=d.useState(!0),[m,c]=d.useState(!1),[f,p]=d.useState(null),[r,h]=d.useState([]),s=SP.find((i)=>i.id===H)||SP[0],X0=s.handoff?[]:FV0[s.format]||["artboard"];d.useEffect(()=>{if(X0.length&&!X0.includes(K))V(X0[0])},[X0,K]);let o=d.useCallback(()=>{fetch("/_api/export-history").then((i)=>i.json()).then((i)=>h(Array.isArray(i?.history)?i.history.slice(0,6):[])).catch(()=>{})},[]);d.useEffect(()=>{o()},[o]),d.useEffect(()=>{function i(u){if(u.key==="Escape")u.preventDefault(),Z()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Z]);async function U0(){if(s.handoff){let n=`/design:handoff ${Q&&Q!==l8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(n)}catch{}p({ok:!0,msg:`Copied: ${n} — run it in Claude Code.`});return}c(!0),p(null);let i=s.temporal?{scale:B}:{};if(s.format==="png"){let u=gV.find((n)=>n.id===L)||gV[1];if(u.kind==="dpi")i.dpi=u.value;else i.scale=u.value}if(s.format==="mp4"||s.format==="webm")i.audio=y;if(s.format==="pdf"){i.pdfPrint={includeBleed:w,marks:{crop:P,registration:I}};let u=qt.find((n)=>n.id===C)?.value;if(u!==void 0)i.dpi=u}if(W)i.artboardId=W;if(G?.selector)i.selection=G;try{let u=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:K,options:i})});if(!u.ok){p({ok:!1,msg:await u.text()||`Export failed (${u.status})`}),c(!1);return}Z()}catch(u){p({ok:!1,msg:u&&u.message?u.message:String(u)}),c(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)Z()},children:A("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[A("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:Z,children:z(X9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==l8?`Format · ${zW(TF(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:SP.filter((i)=>!i.temporal||Y).map((i)=>A("button",{type:"button",className:"st-fmt"+(i.id===H?" is-on":""),onClick:()=>{q(i.id),p(null)},children:[z(X9,{name:i.icon,size:16}),z("span",{className:"st-fmt-name",children:i.label}),z("span",{className:"st-fmt-sub",children:i.sub})]},i.id))}),!s.handoff&&A("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:K,onChange:(i)=>V(i.target.value),children:X0.map((i)=>z("option",{value:i,children:$P[i]},i))})]}),!s.handoff&&s.format==="png"&&A("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:L,onChange:(i)=>D(i.target.value),children:gV.map((i)=>z("option",{value:i.id,children:i.label},i.id))})]}),!s.handoff&&s.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let i=gV.find((n)=>n.id===L)||gV[1],u=i.kind==="dpi"?i.value/96:i.value;return`${i.label} ≈ ${Math.round(1440*u)}×${Math.round(900*u)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&A("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:B,onChange:(i)=>F(Number(i.target.value)),children:NV0.map((i)=>z("option",{value:i.value,children:i.label},i.value))})]}),!s.handoff&&s.temporal&&A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!s.handoff&&s.format==="pdf"&&A(Y0,{children:[A("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:C,onChange:(i)=>b(i.target.value),children:qt.map((i)=>z("option",{value:i.id,children:i.label},i.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:A("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:w,onChange:(i)=>R(i.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:A("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>O((i)=>!i),"aria-expanded":_,children:[_?"▾":"▸"," Marks"]})}),_&&A("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:P,onChange:(i)=>T(i.target.checked)}),"Crop marks"]}),A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:(i)=>S(i.target.checked)}),"Registration marks"]})]}),A("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.",K==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&z("div",{className:"st-dialog-row",children:A("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:y,onChange:(i)=>g(i.target.checked)}),"Export with audio"]})}),s.handoff&&A("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}),r.length>0&&A("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map((i,u)=>A("div",{className:"st-export-recent-row",children:[A("span",{children:[String(i.format||"").toUpperCase()," ·"," ",$P[i.scope]||i.scope]}),z("span",{className:"st-mono",children:i.filename})]},u))]})]}),A("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:Z,children:"Cancel"}),A("button",{type:"button",className:"btn btn--primary",disabled:m,onClick:U0,children:[z(X9,{name:"download",size:14}),s.handoff?"Copy handoff command":m?"Exporting…":`Export ${s.label}`]})]})]})})}var IF=12,CF=16;function _V0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,q]=d.useState(Q),K=G?G.dropProps(W,!0,()=>q(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},F=G?.draggedPath===W,L=G?.busyPath===W,D=A("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":L||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(F?" is-dragging":"")+(L?" is-busy":""),style:{paddingLeft:IF+J*CF+"px"},onClick:()=>q((w)=>!w),onContextMenu:Z?(w)=>Z.openAt(w,{kind:"dir",dirPath:W}):void 0,...B,...K,children:[z("span",{className:"st-row-glyph",children:z(X9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return A(Y0,{children:[Z?A("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(w)=>Z.openAt(w,{kind:"dir",dirPath:W}),children:z(RF,{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 EV0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,q]=d.useState(Y);return A(Y0,{children:[A("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:IF+Q*CF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>q((K)=>!K),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(X9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),A("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(X9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function fP({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:q,experimentalKind:K,drag:V,menu:B}){let F=X.path===J,L=YQ.test(X.name),D=!L,w=L?zW(X.name):X.name,R=L&&typeof Y==="function"&&Z!=="runtime",_=L&&!H&&Z!=="runtime"&&typeof V<"u",O=_?V.dragProps(X.path,!0):{},P=V?.draggedPath===X.path,T=V?.busyPath===X.path,I=_&&typeof B<"u",S=X.path.split("/").slice(0,-1).join("/"),C=L?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(YQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,b=A("button",{type:"button",role:"treeitem","data-testid":C,"aria-selected":F,"aria-disabled":D?"true":void 0,"aria-busy":T||void 0,tabIndex:F?0:-1,className:"st-row"+(F?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(P?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:IF+G*CF+"px"},title:X.path+(W?` — ${W} open`:D?" (file index only)":""),onClick:()=>{if(!D)Q(X.path)},onContextMenu:I?(y)=>B.openAt(y,{kind:"file",path:X.path,dir:S}):void 0,...O,children:[z("span",{className:"st-row-glyph",children:z(X9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:w}),K==="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"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),W>0&&z("span",{className:"st-row-badge",children:W})]});if(!R&&!I)return b;return A("div",{className:"st-row-wrap",role:"none",children:[b,I&&z("button",{type:"button",className:"st-row-menu-btn"+(R?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${w}…`,"aria-label":`Actions for ${w}`,"aria-haspopup":"menu",onClick:(y)=>B.openAt(y,{kind:"file",path:X.path,dir:S}),children:z(RF,{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})}),R&&z("button",{type:"button",className:"st-row-del",title:`Delete ${w}`,"aria-label":`Delete canvas ${w}`,onClick:(y)=>{y.stopPropagation(),Y(X.path,w)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function PV0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:q,forceOpen:K,dirtyByPath:V,experimentalKind:B,drag:F,menu:L}){let D=V?.get(X.path),w=J.length>0,[R,_]=d.useState(!1),O=K||R,P=X.path===W;if(!(w&&q))return z(fP,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:D,experimentalKind:B,drag:F,menu:L});let I=typeof F<"u",S=I?F.dragProps(X.path,!0):{},C=F?.draggedPath===X.path,b=F?.busyPath===X.path,y=I&&typeof L<"u",g=X.path.split("/").slice(0,-1).join("/"),m=A("button",{type:"button",role:"treeitem","aria-selected":P,"aria-expanded":O,"aria-busy":b||void 0,tabIndex:P?0:-1,className:"st-row st-canvas-row"+(P?" is-sel":"")+(C?" is-dragging":"")+(b?" is-busy":""),style:{paddingLeft:IF+Q*CF+"px"},title:X.path,onClick:(c)=>{if(c.target.closest(".st-canvas-chev")){_((f)=>!f);return}G(X.path)},onContextMenu:y?(c)=>L.openAt(c,{kind:"file",path:X.path,dir:g}):void 0,...S,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(c)=>{c.stopPropagation(),_((f)=>!f)},children:z(X9,{name:"chevron-right",className:"st-chev"+(O?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:zW(X.name)}),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"}),D&&z("span",{className:"st-git-badge","data-kind":D,title:`Unsaved (${D})`,"aria-label":`Unsaved, ${D}`,children:D}),H>0&&z("span",{className:"st-row-badge",children:H})]});return A(Y0,{children:[y?A("div",{className:"st-row-wrap",role:"none",children:[m,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${zW(X.name)}…`,"aria-label":`Actions for ${zW(X.name)}`,"aria-haspopup":"menu",onClick:(c)=>L.openAt(c,{kind:"file",path:X.path,dir:g}),children:z(RF,{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})})]}):m,O&&J.map((c)=>z(fP,{file:c,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},c.path))]})}function It({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:q,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L,dirPath:D="",drag:w,menu:R}){let _=Object.keys(X).filter((C)=>C!=="_files").sort(),O=X._files||[],{canvases:P,orphans:T}=d.useMemo(()=>qV0(O),[O]),I=!!(H&&H.trim()),S=d.useMemo(()=>{if(!q||W!==1)return null;let C=new Map;for(let b of q)C.set(b.folder,b);return C},[q,W]);return A(Y0,{children:[P.map((C)=>{let b=I&&C.sidecars.some((y)=>{let g=H.toLowerCase();return y.name.toLowerCase().includes(g)||y.path.toLowerCase().includes(g)});return z(PV0,{primary:C.primary,sidecars:C.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:Wt(Y[C.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:b,dirtyByPath:F,experimentalKind:L?.[C.primary.path],drag:w,menu:R},C.primary.path)}),Z&&T.map((C)=>z(fP,{file:C.primary,activePath:J,onOpen:Q,openCount:Wt(Y[C.primary.path]),depth:W,kind:G},C.primary.path)),_.map((C)=>{let b=S?.get(C),y=D?`${D}/${C}`:C,g=z(It,{node:X[C],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L,dirPath:y,drag:w,menu:R});if(b&&V)return z(EV0,{name:C,dsName:b.name,depth:W,defaultOpen:!0,active:J===l8&&b.name===K,onOpenSystem:V,children:g},C);return z(_V0,{name:C,depth:W,defaultOpen:!0,dirPath:y,drag:w,menu:R,children:g},C)})]})}var AF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function RV0(X){if(X.kind==="project")return AF.project;if(X.kind==="runtime")return AF.runtime;if(X.label==="Design system")return AF.ds;if(X.label==="UI kit")return AF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function kV0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:q,showHidden:K,sectionsExpanded:V,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:D,refreshing:w,collapsed:R,onCollapse:_,width:O,resizing:P,dirtyByPath:T,project:I,gitBranch:S,remoteSync:C,onGetLatest:b,canvasKinds:y,onMoveCanvas:g,onNewFolder:m,onDeleteFolder:c}){let f=d.useMemo(()=>{if(!Z)return X;return X.map((g0)=>({...g0,tree:kt(g0.tree,Z),filtered:!!Z}))},[X,Z]),p=cC(g),r=dC(),h=d.useMemo(()=>{let g0=[];for(let R8 of X){if(R8.label==="Design system"||R8.kind!=="canvas")continue;let r0=R8.fullPath.replace(/^\.[^/]+\//,"")||R8.fullPath;g0.push({path:R8.fullPath,label:r0});for(let f8 of R8.dirs||[])g0.push({path:f8,label:f8.replace(/^\.[^/]+\//,"")})}return g0},[X]),s=r.state?.extra,X0=s?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>r.showMoveTo()}]:s?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{r.close();let g0=window.prompt("New folder name:");if(g0?.trim())m(s.dirPath,g0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{r.close(),c(s.dirPath,s.dirPath.split("/").pop())}}]:[],o=s?.kind==="file"?h.filter((g0)=>g0.path!==s.dir):[],[U0,i]=d.useState(!1),[u,n]=d.useState("board"),[V0,m0]=d.useState(""),[J8,Q8]=d.useState(""),[t0,F8]=d.useState(!1),Z8=d.useMemo(()=>X.find((g0)=>g0.kind==="canvas"&&g0.label!=="Design system")?.fullPath,[X]),N8=d.useCallback(async()=>{let g0=V0.trim();if(!g0||t0)return;if(F8(!0),Q8(""),u==="folder"){if(!Z8){F8(!1),Q8("no canvas group to create a folder in");return}let r0=await m(Z8,g0);if(F8(!1),r0?.ok)i(!1),m0("");else Q8(r0?.error||"could not create folder");return}let R8=await F(g0);if(F8(!1),R8?.ok)i(!1),m0("");else Q8(R8?.error||"could not create board")},[V0,t0,F,m,u,Z8]),p8=d.useMemo(()=>{let g0=0;for(let R8 of X)for(let r0 of R8.paths||[])if(YQ.test(r0))g0++;return g0},[X]),A8=d.useMemo(()=>{let g0=0;for(let R8 of f)for(let r0 of R8.paths||[])if(YQ.test(r0))g0++;return g0},[f]);return A("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(P?" is-resizing":""),style:R||!O?void 0:{width:O,flexBasis:O},"aria-label":"Files","data-tour":"sidebar",children:[A("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),A("div",{className:"st-sb-hd-actions",children:[z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":U0&&u==="board",onClick:()=>{Q8(""),n("board"),i((g0)=>u==="board"?!g0:!0)},children:z(X9,{name:"plus",size:15})}),Z8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":U0&&u==="folder",onClick:()=>{Q8(""),n("folder"),i((g0)=>u==="folder"?!g0:!0)},children:z(X9,{name:"folder-plus",size:15})}),D&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>D(),children:z(X9,{name:"reload",size:15})}),A("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),A8," / ",p8]}),_&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:_,children:z(X9,{name:"panel-left",size:15})})]})]}),U0?A("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:u==="folder"?"folder name…":"brief board name…",value:V0,maxLength:60,disabled:t0,"aria-label":u==="folder"?"New folder name":"New brief board name",onChange:(g0)=>m0(g0.target.value),onKeyDown:(g0)=>{if(g0.key==="Enter")g0.preventDefault(),N8();else if(g0.key==="Escape")g0.preventDefault(),i(!1),m0(""),Q8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:t0||!V0.trim(),"data-tip":"Create · Enter","aria-label":u==="folder"?"Create folder":"Create brief board",onClick:N8,children:t0?"…":"↵"})]}):null,J8?z("div",{className:"st-newboard-err",role:"alert",children:J8}):null,z("div",{className:"st-search",children:A("div",{className:"st-search-box",children:[z(X9,{name:"search",size:13}),z("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(g0)=>H(g0.target.value),onKeyDown:(g0)=>{if(g0.key==="Escape")if(g0.preventDefault(),Z)H("");else g0.currentTarget.blur()},"aria-label":"Filter files"}),Z?z("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(d6,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:f.map((g0)=>{if(!K&&!Z&&g0.kind==="runtime")return null;let R8=RV0(g0),r0=(g0.paths||[]).filter((Y8)=>YQ.test(Y8)).length,f8=R8.pill||(R8.pillFromDsCount?String(g0.dsFolders?.length||0):null)||(R8.pillFromCount?String(r0||g0.paths?.length||0):null),c8=g0.tree&&Object.keys(g0.tree).length>0,q9=g0.label==="Design system",b0=g0.kind==="project";if(!K&&!Z&&b0&&r0===0)return null;let B0=GV0(g0),K0=V[g0.label],S0=!!Z||(K0===void 0?B0:K0),H0=!q9&&g0.kind==="canvas",L0=H0?p.dropProps(g0.fullPath,!0):{},N0=p.overDir===g0.fullPath;return A("div",{className:"st-tree-section",children:[A("button",{type:"button",className:"st-tree-sec-hd"+(N0?" is-drop-target":""),onClick:()=>B(g0.label,B0),"aria-expanded":S0,"aria-dropeffect":H0?"move":void 0,title:S0?"Collapse section":"Expand section",...L0,children:[z(X9,{name:"chevron-right",className:"st-chev"+(S0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:R8.title}),f8&&z("span",{className:"st-pill",children:f8})]}),S0&&(c8?z(It,{node:g0.tree,activePath:J,onOpen:Y,commentsByFile:q,depth:1,kind:g0.kind,showHidden:K,search:Z,dsFolders:g0.dsFolders,activeDsName:Q,onOpenSystem:q9?W:void 0,onDelete:q9?void 0:L,dirtyByPath:T,canvasKinds:y,dirPath:g0.fullPath,drag:!q9&&g0.kind==="canvas"?p:void 0,menu:!q9&&g0.kind==="canvas"?r:void 0}):z("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},g0.label)})}),z(pC,{state:r.state,onClose:r.close,rootItems:X0,destinations:o,onPickDestination:(g0)=>g(s.path,g0)}),z(Iw,{project:I,liveBranch:S,remoteSync:C,onGetLatest:b}),z(Bw,{}),z(Nw,{})]})}function TV0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:A("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(X9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(X9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(X9,{name:"folder",size:15})})]})})}function IV0({open:X,onClose:J,onStartTour:Q}){if(d.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:A("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[A("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),A("span",{className:"sku",children:["MAUDE-DEV-SRV / v",vP]}),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:"×"})]}),A("div",{className:"help-modal-body",children:[A("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),A("ul",{children:[A("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),A("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),A("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),A("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),A("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),A("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),A("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),A("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),A("details",{children:[z("summary",{children:"Annotation tools"}),A("ul",{children:[A("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),A("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),A("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),A("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),A("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),A("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),A("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),A("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),A("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),A("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),A("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),A("details",{children:[z("summary",{children:"Canvas & panels"}),A("ul",{children:[A("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),A("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),A("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),A("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),A("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),A("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),A("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),A("details",{children:[z("summary",{children:"Slash commands"}),A("ul",{className:"cmds",children:[A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),A("li",{children:[A("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),A("li",{children:[A("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),A("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),A("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),A("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),A("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),A("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),A("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),A("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),A("details",{children:[z("summary",{children:"Opt-out scope"}),A("ul",{children:[A("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),A("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),A("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),A("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),A("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.'})]})]}),A("details",{children:[z("summary",{children:"Auto-critic loop"}),A("ul",{children:[A("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),A("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),A("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),A("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),A("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),A("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."]})]})]}),A("details",{children:[z("summary",{children:"Pin-to-element flow"}),A("ol",{children:[z("li",{children:"Open a canvas"}),A("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),A("li",{children:["Run"," ",A("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),A("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),A("details",{children:[z("summary",{children:"Comments"}),A("ol",{children:[A("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"}),A("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),A("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),A("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var bP=[{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 CV0({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(d6,{children:G},`${G}-${Z}`))},W);return A("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>A(Y0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function SV0({open:X,onClose:J}){if(d.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=bP.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:A("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[A("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),A("span",{className:"so-trigger",children:["press ",z(d6,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:bP.map((Y)=>A("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)=>A("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(CV0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),A("div",{className:"so-overlay-ft",children:[A("span",{children:["close with ",z(d6,{children:"Esc"})]}),A("span",{className:"so-count",children:[Q," bindings · ",bP.length," groups"]})]})]})})}var $V0=["File","Edit","View","Selection","Tools","Help"];function Ct(X){d.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 bV0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Ct(Q),A("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(X9,{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(d6,{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)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(d6,{children:G.shortcut})]},G.label))]})}function lV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Ct(G),A("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):A("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:[A("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(d6,{children:Z.shortcut}):null]},Z.id))]})}function jV0({onAction:X,onClose:J}){return z(lV,{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"},...d8()?[{id:"collab-tour",label:"How sharing works"}]:[],...d8()?[{id:"quick-setup",label:"Quick setup"}]:[],...d8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function yV0({onAction:X,onClose:J}){return z(lV,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]})}function fV0({onAction:X,onClose:J}){return z(lV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{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"}]})}function vV0({onAction:X,onClose:J,hasCanvas:Q}){return z(lV,{label:"File",left:40,onAction:X,onClose:J,items:[{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 xV0({onAction:X,onClose:J,hasCanvas:Q}){return z(lV,{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 hV0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:q,onToggleChanges:K,onOpenSystem:V,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:D,onOpenHelp:w,onOpenShortcuts:R,onReportBug:_,onStartTour:O,onStartCollabTour:P,annotationsVisible:T,onToggleAnnotations:I,minimapVisible:S,onToggleMinimap:C,zoomCtlVisible:b,onToggleZoomCtl:y,presentMode:g,onTogglePresent:m,printGuidesVisible:c,onTogglePrintGuides:f,postToActiveCanvas:p,onOpenWhatsNew:r,onOpenReadiness:h,onOpenQuickSetup:s,onWatchIntro:X0,whatsNewCount:o,exportCenter:U0,artboardCount:i=0,presence:u=null,inspectorOpen:n,inspectorTab:V0,onToggleInspector:m0,autoOpenInspector:J8,onToggleAutoOpenInspector:Q8,onOpenLayers:t0,timelineOpen:F8,onToggleTimeline:Z8,hasComps:N8=!1,assistantOpen:p8,onToggleAssistant:A8,assistantBusy:g0,assistantUnseen:R8,onNewCanvas:r0,onAssembleVideo:f8,onOpenExport:c8,onOpenSettings:q9,onOpenGenerate:b0,onReload:B0,onCloseCanvas:K0,onInsertArtboard:S0}){let H0=X===l8,L0=H0?"SYSTEM":X?"CANVAS":"IDLE",N0=H0?z("b",{children:"design system"}):X?A(Y0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:zW(TF(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),Y8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:q>0?`Changes · ${q} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:n&&V0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:n,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:N8?"video":void 0,checked:F8,disabled:!1},...d8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:p8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:S,disabled:!X||H0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:b,disabled:!X||H0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||H0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:c,disabled:!X||H0}],P8=["file","edit","view","selection","tools","help"];function I8(M0){if(P8.includes(M0))W(Y===M0?null:M0)}return d.useEffect(()=>{if(!Y||!P8.includes(Y))return;let M0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function E0(p0){let e0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!e0.length)return;let w0=e0.indexOf(document.activeElement);if(p0.key==="ArrowDown")p0.preventDefault(),e0[(w0+1)%e0.length].focus();else if(p0.key==="ArrowUp")p0.preventDefault(),e0[(w0-1+e0.length)%e0.length].focus();else if(p0.key==="Home")p0.preventDefault(),e0[0].focus();else if(p0.key==="End")p0.preventDefault(),e0[e0.length-1].focus();else if(p0.key==="ArrowRight"||p0.key==="ArrowLeft"){p0.preventDefault();let o0=p0.key==="ArrowRight"?1:-1,J9=P8.indexOf(Y);W(P8[(J9+o0+P8.length)%P8.length])}else if(p0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",E0),()=>{clearTimeout(M0),window.removeEventListener("keydown",E0)}},[Y,W]),A("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[A("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"})]}),z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:$V0.map((M0)=>{let E0=M0.toLowerCase(),p0=P8.includes(E0),e0=p0||E0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":E0==="help"?"help":void 0,"aria-haspopup":p0?"menu":void 0,"aria-expanded":p0?Y===E0:void 0,onClick:()=>I8(E0),onMouseEnter:()=>{if(Y!==null&&p0)W(E0)},children:M0},E0)})}),Y==="file"&&z(vV0,{hasCanvas:!!X,onAction:(M0)=>{if(M0==="new")r0?.();else if(M0==="assemble")f8?.();else if(M0==="export")c8?.("export");else if(M0==="handoff")c8?.("handoff");else if(M0==="generate")b0?.();else if(M0==="settings")q9?.();else if(M0==="reload")B0?.();else if(M0==="close")K0?.()},onClose:()=>W(null)}),Y==="edit"&&z(xV0,{hasCanvas:!!X&&!H0,onAction:(M0)=>{if(M0==="undo")p({dgn:"undo"});else if(M0==="redo")p({dgn:"redo"});else if(M0==="deselect-all")p({dgn:"selection-clear"});else if(M0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(M0.startsWith("new-artboard:"))S0?.(M0.slice(13))},onClose:()=>W(null)}),Y==="view"&&z(bV0,{panels:Y8,onToggle:(M0)=>{if(M0==="tree")F();else if(M0==="changes")K();else if(M0==="comments")Z();else if(M0==="hidden")D();else if(M0==="annotate")I();else if(M0==="inspector")m0();else if(M0==="autoopen")Q8?.();else if(M0==="timeline")Z8?.();else if(M0==="assistant")A8?.();else if(M0==="layers")t0?.();else if(M0==="minimap")C?.();else if(M0==="zoomctl")y?.();else if(M0==="present")m?.();else if(M0==="print-guides")f?.()},onZoom:(M0)=>p({dgn:"zoom",op:M0}),hasCanvas:!!X&&!H0,onClose:()=>W(null)}),Y==="selection"&&z(yV0,{onAction:(M0)=>{if(M0==="deselect-all")p({dgn:"selection-clear"});else if(M0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&z(fV0,{onAction:(M0)=>p({dgn:"tool-set",tool:M0}),onClose:()=>W(null)}),Y==="help"&&z(jV0,{onAction:(M0)=>{if(M0==="shortcuts")R?.();else if(M0==="help")w?.();else if(M0==="report-bug")_?.();else if(M0==="tour")O?.();else if(M0==="collab-tour")P?.();else if(M0==="quick-setup")s?.();else if(M0==="readiness")h?.();else if(M0==="whatsnew")r?.();else if(M0==="watch-intro")X0?.()},onClose:()=>W(null)}),A("div",{className:"st-mb-right","data-tour":"status",children:[u?z("div",{className:"st-presence",children:u}):null,d8()&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":p8?"true":"false","data-busy":g0?"true":"false","data-unseen":R8?"true":"false","aria-label":`Assistant${g0?" — working":R8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:A8,children:z(X9,{name:"sparkle",size:15})}),U0&&z(Av,{center:U0}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":o>0?"true":"false","aria-label":`What's new${o>0?` — ${o} unseen`:""}`,"data-tip":"What's new",onClick:r,children:z(X9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:L0}),z("span",{className:"st-mb-file",title:X||"",children:N0}),z("span",{className:"st-mb-sep"}),A("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),i," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function gV0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:q,onIframeLoad:K,showQuickSetup:V,onStartQuickSetup:B}){return A("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&A("div",{className:"st-empty",children:[A("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"}),A("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",vP," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),A("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(d6,{children:"⌘"})," and hover to preview an element, click to select it — ",z(d6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",d8()?A(Y0,{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]}),V&&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((F)=>{if(F.path===l8)return z("div",{className:"system-view"+(F.path===J?" active":""),children:z(oV0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return z("iframe",{ref:(L)=>Q(F.path,L),src:fH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>K?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),q&&q===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:A("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 mV0=["color","space","radius","shadow","leading","weight","motion","font","other"],uV0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function lV0(X){return X==="color"}function dV0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return A("section",{className:"sv-section sv-section-tokens",children:[A("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:A("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([...mV0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Y0,{children:W.map((G)=>{let Z=Y[G],H=lV0(G);return A("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[A("h2",{children:["tokens · ",uV0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((q)=>A("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:q.value}}):null,A("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:q.name}),z("span",{className:"sv-tok-value",children:q.value||"—"})]})]},q.name+"|"+q.value))})]},G)})})}function pV0(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 cV0(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 iV0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=cV0(X?.font);return A("section",{className:"sv-section sv-section-type",children:[A("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=pV0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return A("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 oV0({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:q,tokensPath:K,ds:V,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,D=V?.name??B?.[0]?.name??"";return A("div",{className:"sv",children:[A("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),L?A("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>z("option",{value:w.name,children:w.name},w.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(dV0,{tokens:H,tokenGroups:q,tokensPath:K}),z(iV0,{tokenGroups:q}),F?z("div",{className:"sv-empty",children:A("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):A(Y0,{children:[z(zt,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(zt,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function zt({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return A("section",{className:"sv-section",children:[A("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>A("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:fH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),A("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function nV0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:q=0,unpushed:K=0,changesOpen:V=!1,onOpenChanges:B}){let F=X===l8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",D=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",R=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let _=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:_>0?`${_} ↑`:"synced",title:_>0?`${_} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${_} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return A("footer",{className:"st-statusbar",role:"contentinfo",children:[A("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:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&A("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:D,children:L}),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:"×"})]}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),A("span",{className:"val",children:[Y," open"]})]}),B&&A("button",{type:"button",className:"st-sb-slot st-sb-changes"+(V?" is-open":"")+(q>0?" has-changes":K>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":V,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:q>0?`${q} unsaved`:K>0?`${K} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),A("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"})]}),R&&A("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]}),A("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[z(X9,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function rV0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:q,width:K,resizing:V}){let B=Tt(X),F=Object.keys(X||{}).sort(),L=[];for(let D of F){let w=X[D]||[],R=w.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);L.push({file:D,comments:R.map((O)=>({...O,n:_.findIndex((P)=>P.id===O.id)+1}))})}return A("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:K?{width:K,flexBasis:K}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:A("div",{className:"st-cm-filters",role:"tablist",children:[A("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),A("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),A("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:L.length===0?A("div",{className:"st-rp-empty",children:[A("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),A("p",{children:["Open a canvas, hold ",z(d6,{children:"⌘"})," and click an element, then press ",z(d6,{children:"C"})," — or hold ",z(d6,{children:"⌘⇧"})," and click directly."]})]}):L.map((D)=>A(Y0,{children:[A("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:zW(TF(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((w)=>A("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(D.file,w.id),children:[A("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),z("span",{className:"st-comment-time",children:KV0(w.created)})]}),z("div",{className:"st-comment-txt",children:w.text}),A("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),A("span",{className:"st-mini-act",children:[w.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(w.id)},children:z(X9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(w.id)},children:z(X9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),q(w.id)},children:z(X9,{name:"x",size:14})})]})]})]},w.id))]},D.file))})]})}function aV0({update:X,onDismiss:J}){let[Q,Y]=d.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return A("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),A("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Uf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function sV0({status:X}){let[J,Q]=d.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",q=Y==="offline"||Y==="offline-long",K=X.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!q&&!H&&!V&&K===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(q){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;L=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",F=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;L=`diverged:${V.slug}:${V.at}`}else B="warn",F=`${K} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${K}`;if(J===L)return null;return A("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:F}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var tV0=["block","inline-block","flex","inline-flex","grid","inline","none"],Kt=["px","%","fr","em","auto","min-content","max-content"];var eV0=["auto","stretch","flex-start","center","flex-end","baseline"];var Ut=["300","400","500","600","700","800"],Vt=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],Bt=["none","solid","dashed","dotted","double"],Ft=["px","rem","em","%","vw","vh","auto"],Nt=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),jP={"font-size":{node:z(S9,{as:NU,size:12})},"line-height":{node:z(S9,{as:_U,size:12})},"letter-spacing":{node:z(S9,{as:CU,size:12})},gap:{node:z(S9,{as:Bq,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(S9,{as:yU,size:12})},"border-width":{node:z(S9,{as:IU,size:12})}};var Lt=["static","relative","absolute","fixed","sticky"],X10=["normal","italic","oblique"],Dt=["none","uppercase","lowercase","capitalize"];var Ot=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],J10=["fill","contain","cover","none","scale-down"];var Mt=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],wt=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],TJ={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}},xq=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!xq)xq=document.createElement("canvas").getContext("2d");if(!xq)return"";xq.fillStyle="#000000",xq.fillStyle=X;let J=xq.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 KY=(X)=>Math.min(1,Math.max(0,X));function _F(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 mV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function uV({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 hq({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,q=0;if(X<60)[Z,H,q]=[Y,W,0];else if(X<120)[Z,H,q]=[W,Y,0];else if(X<180)[Z,H,q]=[0,Y,W];else if(X<240)[Z,H,q]=[0,W,Y];else if(X<300)[Z,H,q]=[W,0,Y];else[Z,H,q]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(q+G)*255}}function b9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function QQ(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 At(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 St(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function Q10(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],q=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=q&&J[q[1]]?J[q[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 $t(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=d.useState([]);return d.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(q)=>{if(!q.tokensCssRel)return null;try{let K=await fetch(`/${J}/${q.tokensCssRel}`),V=K.ok?await K.text():"";return{name:q.name,...Q10(V)}}catch{return null}})).then((q)=>{if(H)return;let K=q.filter(Boolean);K.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(K)}),()=>{H=!0}},[W,J,Q]),G}function bt({seed:X,label:J,onApply:Q}){let[Y,W]=d.useState(()=>uV(_F(X||"#000000"))),G=d.useRef(Y);G.current=Y;let Z=d.useRef(null),H=d.useRef(null),q=d.useRef(X);d.useEffect(()=>{if(X&&X!==q.current)q.current=X,W(uV(_F(X)))},[X]);let K=mV(hq(Y)),V=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,I=(C)=>{W({h:T,s:KY((C.clientX-P.left)/P.width),v:KY(1-(C.clientY-P.top)/P.height)})};I(O);let S=()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",S),Q(mV(hq(G.current)))};document.addEventListener("pointermove",I),document.addEventListener("pointerup",S)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:I}=G.current,S=(b)=>{W({h:KY((b.clientX-P.left)/P.width)*360,s:T,v:I})};S(O);let C=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),Q(mV(hq(G.current)))};document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)},F=(O)=>{let P={...G.current,...O};W(P),Q(mV(hq(P)))},L=(O)=>{let P=O.shiftKey?0.1:0.02,I={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!I)return;O.preventDefault(),F({s:KY(G.current.s+I[0]),v:KY(G.current.v+I[1])})},D=(O)=>{let P=O.shiftKey?20:2,I={ArrowLeft:-P,ArrowRight:P}[O.key];if(I==null)return;O.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+I))})},w=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(uV(_F(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=hq(Y),_=(O)=>{let P={...R,...O},T=uV({r:KY(P.r/255)*255,g:KY(P.g/255)*255,b:KY(P.b/255)*255});W(T),Q(mV(hq(T)))};return A("div",{className:"st-cp-cpick",children:[A("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:K}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:K,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(uV(_F(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),A("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:V,onKeyDown:L,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:K}})]}),A("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:w,children:z(X9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:K},"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)=>A("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>_({[O]:KY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:q}){let[K,V]=d.useState(!1),[B,F]=d.useState(null),[L,D]=d.useState("custom"),[w,R]=d.useState(""),_=d.useRef(null),O=d.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(X0)=>Q===`var(${X0})`,I=(X0)=>X0.replace(/^--/,"").replace(/-/g," "),S=J||[],C=S.reduce((X0,o)=>X0+(o.names?.length||0),0),b=S.length>1,y=w.trim().toLowerCase(),g=!y?S:S.map((X0)=>({...X0,names:(X0.names||[]).filter((o)=>I(o).toLowerCase().includes(y)||o.toLowerCase().includes(y)||(X0.vals?.[o]||"").toLowerCase().includes(y))})).filter((X0)=>X0.names.length);d.useEffect(()=>{if(!K){R("");return}let X0=()=>{let u=_.current?.getBoundingClientRect();if(!u)return;let n=224,V0=300,m0=Math.min(u.right-n,window.innerWidth-n-8);if(m0<8)m0=8;let Q8=window.innerHeight-u.bottom>V0+8?u.bottom+4:Math.max(8,u.top-V0-4);F({left:m0,top:Q8,width:n,maxHeight:V0})};X0();let o=(u)=>{if(O.current?.contains(u.target)||_.current?.contains(u.target))return;V(!1)},U0=(u)=>{if(u.key==="Escape")V(!1)},i=(u)=>{if(O.current?.contains(u.target))return;X0()};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",X0),document.addEventListener("scroll",i,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",X0),document.removeEventListener("scroll",i,!0)}},[K]),d.useEffect(()=>{if(!K||!B||!O.current)return;let X0=O.current.getBoundingClientRect(),o=B.left-X0.left,U0=B.top-X0.top;if(Math.abs(o)>0.5||Math.abs(U0)>0.5)F((i)=>i?{...i,left:i.left+o,top:i.top+U0}:i)},[K,B]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,c=(X0,o,U0)=>{if(H&&X0&&X0!==H&&U0&&!m.test(U0))Y(U0);else Y(`var(${o})`);V(!1)},f=(X0)=>{let o=(X0||"").trim();if(o)Y(o)},p=A("div",{className:"st-cp-pop-search",children:[z(X9,{name:"search",size:12}),z("input",{value:w,onChange:(X0)=>R(X0.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),r=(X0)=>X0.map((o)=>A("div",{className:"st-cp-pop-group",children:[b?z("div",{className:"st-cp-pop-ds",children:o.ds}):null,z("div",{className:"st-cp-pop-list",children:o.names.map((U0)=>A("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(U0)?" is-on":""}`,onClick:()=>c(o.ds,U0,o.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:o.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:I(U0)}),z("span",{className:"st-cp-pop-val",children:o.vals?.[U0]||""})]},`${o.ds}:${U0}`))})]},o.ds)),h=(X0)=>X0.map((o)=>A("div",{className:"st-cp-pop-group",children:[b?z("div",{className:"st-cp-pop-ds",children:o.ds}):null,z("div",{className:"st-cp-pop-list",children:o.names.map((U0)=>A("button",{type:"button",className:`st-cp-pop-row${T(U0)?" is-on":""}`,onClick:()=>c(o.ds,U0,o.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:I(U0)}),z("span",{className:"st-cp-pop-val",children:o.vals?.[U0]||""})]},`${o.ds}:${U0}`))})]},o.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return A(Y0,{children:[G!==void 0?z("button",{type:"button",ref:_,className:`${q||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!q?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((X0)=>!X0),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:_,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((X0)=>!X0),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),K&&B?Et.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"?A(Y0,{children:[A("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),L==="custom"?z(bt,{seed:Z||kF(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):A(Y0,{children:[p,g.length?r(g):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):A(Y0,{children:[p,g.length?h(g):s]})}),document.body):null]})}function _t({label:X,tracks:J,editable:Q,onChange:Y}){let W=(q,K)=>{let V=J[q];Y(J.map((B,F)=>F===q?AK.has(K)?{value:0,unit:K}:{value:V.value||1,unit:K}:B))},G=(q,K)=>{Y(J.map((V,B)=>B===q?{...V,value:K}:V))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(q)=>Y(J.filter((K,V)=>V!==q));return A("div",{className:"st-cp-gridtracks",children:[A("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?A("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((q,K)=>{let V=AK.has(q.unit);return A("div",{className:"st-cp-gridtrack-row",children:[V?z(n4,{value:q.unit,ariaLabel:`${X} track ${K+1}`,options:Kt.map((B)=>({value:B,label:B})),onChange:(B)=>W(K,B)}):z(sJ,{value:q.value,min:q.unit==="fr"?0.1:0,step:q.unit==="fr"?0.1:1,ariaLabel:`${X} track ${K+1} value`,lead:String(K+1),unitSlot:z(VB,{value:q.unit,units:Kt,ariaLabel:`${X} track ${K+1} unit`,onChange:(B)=>W(K,B)}),onCommit:(B)=>G(K,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${K+1}`,disabled:!Q||J.length<=1,onClick:()=>H(K),children:"×"})]},K)})]})}function Y10({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let q=!!X.id,K=X.computed||{},[V,B]=d.useState({a:{},c:{},t:{}});d.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,F0)=>{let z0={...t||{}};for(let[T0,s0]of Object.entries(F0))if(s0===null)delete z0[T0];else z0[T0]=s0;return z0},L=F(X.authored,V.a),D=F(X.customStyles,V.c),w=F(X.attrs,V.t),R=(t,F0)=>B((z0)=>({...z0,a:{...z0.a,[t]:F0}})),_=(t,F0)=>B((z0)=>({...z0,c:{...z0.c,[t]:F0}})),O=(t,F0)=>B((z0)=>({...z0,t:{...z0.t,[t]:F0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=St(X.file,J),I=$t(J,P,T),S=(t)=>I.map((F0)=>({ds:F0.name,names:F0[t]||[],vals:F0.vals})).filter((F0)=>F0.names.length),[C,b]=d.useState({}),[y,g]=d.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(D).length>0||Object.keys(w).length>0;d.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let c=(L.position||b9(K.position)||"static")!=="static";d.useEffect(()=>{if(c)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,c]);let f=H,[p,r]=d.useState({});async function h(t,F0,z0){b((T0)=>({...T0,[z0]:"saving"}));try{let T0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(F0)}),s0=await T0.json().catch(()=>({}));b((_8)=>({..._8,[z0]:!T0.ok||!s0.ok?`err:${s0&&s0.error||`HTTP ${T0.status}`}`:"saved"}))}catch(T0){b((s0)=>({...s0,[z0]:`err:${T0&&T0.message?T0.message:String(T0)}`}))}}let s=(t,F0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:F0})},X0=(t,F0,z0,T0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:F0,before:z0==null||z0===""?null:z0,after:T0==null||T0===""?null:T0})},o=(t,F0)=>{let z0=(F0||"").trim();if(!q||!z0)return;let T0=L[t]??null;if(z0===(T0??"").trim())return;s(t,z0),R(t,z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:z0},t),X0("css",t,T0,z0)},U0=(t,F0)=>{let z0=(F0||"").trim(),T0=t.trim();if(!q||!T0||!z0)return;let s0=D[T0]??null;s(T0,z0),_(T0,z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:T0,value:z0},T0),X0("css",T0,s0,z0)},i=(t,F0)=>{let z0=(t||"").trim(),T0=(F0||"").trim();if(!q||!z0||!T0)return;let s0=w[z0]??null;O(z0,T0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:z0,value:T0},`@${z0}`),X0("attr",z0,s0,T0)},u=(t)=>{if(!q)return;let F0=L[t]??null;s(t,null),R(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,F0,null)},n=(t)=>{if(!q)return;let F0=D[t]??null;s(t,null),_(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,F0,null)},V0=(t)=>{if(!q)return;let F0=w[t]??null;O(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),X0("attr",t,F0,null)},m0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,F0)=>{if(!q)return;let z0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),T0=uC(t,F0,m0,z0);for(let s0 of T0.reset)if(L[s0])u(s0);for(let[s0,_8]of T0.set)o(s0,_8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",t0=(t)=>{let F0=mC(t,L,K,m0);return A("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(BB,{value:F0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(z0)=>J8(t,z0)})})]},`mode-${t}`)},F8=["flex-start","center","flex-end"],Z8=["flex-start","center","flex-end"],N8=["t","c","b"],p8=["l","c","r"],A8=()=>{let t=!(L["flex-direction"]||b9(K["flex-direction"])||"row").startsWith("column"),F0=Math.max(0,F8.indexOf(L["justify-content"]||b9(K["justify-content"])||"flex-start")),z0=L["align-items"]||b9(K["align-items"])||"stretch",T0=z0==="stretch"?1:Math.max(0,Z8.indexOf(z0)),[s0,_8]=t?[F0,T0]:[T0,F0];return N8[_8]+p8[s0]},g0=(t)=>{let F0=N8.indexOf(t[0]),z0=p8.indexOf(t[1]),T0=!(L["flex-direction"]||b9(K["flex-direction"])||"row").startsWith("column"),[s0,_8]=T0?[z0,F0]:[F0,z0];o("justify-content",F8[s0]),o("align-items",Z8[_8])},R8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let F0=t.key.toLowerCase();if(F0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(F0==="y")t.preventDefault(),G?.("redo")},r0=(t)=>{let F0=L[t];if(!F0)return"inherit";return/var\(\s*--/.test(F0)?"bound":"raw"};if(!q)return A("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),A("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 f8={bound:"token-bound",raw:"raw override",inherit:"inherited"},c8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":f8[t]}),q9=(t,F0)=>{let z0=F0??r0(t),T0=C[t],s0=typeof T0==="string"&&T0.startsWith("err:")?T0.slice(4):"",_8=s0?" is-err":T0==="saved"?" is-saved":T0==="saving"?" is-saving":"",C8=!!L[t],M8=s0?`error: ${s0}`:C8?`${f8[z0]} · double-click to reset`:f8[z0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${z0}${_8}${C8?" is-resettable":""}`,"aria-label":M8,title:M8,tabIndex:C8?0:-1,onDoubleClick:C8?()=>u(t):void 0,onKeyDown:C8?(v8)=>{if(v8.key==="Backspace"||v8.key==="Delete")v8.preventDefault(),u(t)}:void 0})},b0=(t,F0,z0,T0)=>{let s0=z0===void 0&&!L[t],_8=T0??t;return A("div",{className:`st-cp-row${s0?" is-unset":""}`,children:[q9(t,z0),z("label",{className:"st-cp-label",title:_8,children:_8}),z("div",{className:"st-cp-ctl",children:F0})]},t)},B0={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"]},K0=(t)=>{(B0[t]||[]).forEach((F0)=>{if(L[F0])u(F0)})},S0=(t,F0)=>{let z0=(B0[t]||[]).some((T0)=>L[T0]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!y[t],onClick:()=>g((T0)=>({...T0,[t]:!T0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${z0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!z0,onClick:()=>K0(t),children:z(S9,{as:hG,size:12})})]}),z("div",{className:`st-cp-sec-anim${y[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:F0})})]},t)},H0=(t,F0,z0,T0=!0)=>{let s0=`d:${t}`,_8=y[s0]===void 0?T0:y[s0],C8=F0.some((M8)=>L[M8]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":_8,onClick:()=>g((M8)=>({...M8,[s0]:!_8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:_8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${C8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!C8,onClick:()=>F0.forEach((M8)=>{if(L[M8])u(M8)}),children:z(S9,{as:hG,size:12})})]}),z("div",{className:`st-cp-sec-anim${_8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:z0})})]},s0)},L0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!p[t],"aria-label":p[t]?`${t} — fewer options`:`${t} — more options`,title:p[t]?"fewer":"more",onClick:()=>r((F0)=>({...F0,[t]:!F0[t]})),children:p[t]?"▴":"···"}),N0=(t,F0)=>A("select",{className:"st-cp-nsel","aria-label":t,value:F0.includes(L[t])?L[t]:"",onChange:(z0)=>o(t,z0.target.value),children:[z("option",{value:"",disabled:!0,children:b9(K[t])||"—"}),F0.map((z0)=>z("option",{value:z0,children:z0},z0))]}),Y8=(t)=>S(t).flatMap((F0)=>(F0.names||[]).map((z0)=>({name:z0,value:F0.vals?.[z0]||""}))),P8=(t,F0)=>z(yw,{value:L[t]||b9(K[t])||F0[0].value,ariaLabel:t,options:F0,onChange:(z0)=>o(t,z0)}),I8=(t,F0,z0={})=>{let T0=QQ(L[t]??""),s0=Nt.has(t),_8=L[t]??"",C8=typeof _8==="string"&&/var\(\s*--/.test(_8),M8=s0?"":T0.unit&&T0.unit!=="auto"?T0.unit:"px",v8=Number.parseFloat(QQ(b9(K[t])??"").n)||0,K9=T0.n!==""&&T0.n!=null?Number.parseFloat(T0.n)||0:v8,W7=jP[t];return z(FB,{value:C8?_8:K9,tokens:Y8(F0),ariaLabel:t,min:z0.min??0,lead:W7?W7.node??W7.t:void 0,unitSlot:s0?null:z(VB,{units:Ft,value:T0.unit||"px",ariaLabel:`${t} unit`,onChange:(D9)=>o(t,D9==="auto"?"auto":`${T0.n||"0"}${D9}`)}),onChange:(D9)=>o(t,typeof D9==="string"?D9:s0?`${D9}`:`${D9}${M8}`)})},M0=()=>{let t=(s0)=>Number.parseFloat(QQ(L[s0]??L["border-radius"]??b9(K[s0])??b9(K["border-radius"])??"0").n)||0,F0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},z0=(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((C8)=>{if(L[C8])u(C8)}),o("border-radius",`${s0.tl}px`);else o("border-top-left-radius",`${s0.tl}px`),o("border-top-right-radius",`${s0.tr}px`),o("border-bottom-left-radius",`${s0.bl}px`),o("border-bottom-right-radius",`${s0.br}px`)},T0=jP["border-radius"];return z(Uv,{corners:F0,lead:T0?T0.node??T0.t:void 0,onCorners:z0})},E0=()=>A("div",{className:"st-cp-border",children:[E9("border-width",null,{fixedUnit:"px"}),A("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:Bt.includes(L["border-style"])?L["border-style"]:"",onChange:(t)=>o("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),Bt.map((t)=>z("option",{value:t,children:t},t))]}),z(EF,{kind:"color",groups:S("color"),current:L["border-color"],activeDs:T,swatchBg:K["border-color"]||L["border-color"]||"",seedHex:kF(K["border-color"]||L["border-color"])||"#000000",onPick:(t)=>o("border-color",t),label:"border colour"})]}),p0=()=>{let t=L.transform||b9(K.transform)||"",F0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),z0=((F0?Number.parseFloat(F0[1]):0)%360+360)%360,T0=(s0)=>{let _8=(s0%360+360)%360,C8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();o("transform",`${C8?`${C8} `:""}rotate(${_8}deg)`.trim())};return A("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(zv,{value:z0,onChange:T0}),z(sJ,{value:z0,min:0,max:360,ariaLabel:"rotation",lead:z(S9,{as:hG}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:T0})]})},e0=()=>{let t=L.filter||b9(K.filter)||"",F0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),z0=F0?Number.parseFloat(F0[1]):0;return z(sJ,{value:z0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(s0)=>{let _8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();o("filter",s0>0?`${_8?`${_8} `:""}blur(${s0}px)`.trim():_8||"none")}})},w0=()=>{let t=L.opacity,F0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(b9(K.opacity))||1,z0=Math.round((Number.isNaN(F0)?1:F0)*100);return z(s5,{value:z0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(T0)=>s("opacity",String(T0/100)),onCommit:(T0)=>o("opacity",String(T0/100))},`opacity:${t??""}`)},o0=()=>{let t=Number.parseInt(L["font-weight"]||b9(K["font-weight"])||"400",10)>=600,F0=(L["font-style"]||b9(K["font-style"]))==="italic",z0=/underline/.test(L["text-decoration"]||b9(K["text-decoration"])||"");return z(Hv,{value:{b:t,i:F0,u:z0},ariaLabel:"text style",options:[{value:"b",node:z(S9,{as:EU}),label:"Bold"},{value:"i",node:z(S9,{as:TU}),label:"Italic"},{value:"u",node:z(S9,{as:vU}),label:"Underline"}],onToggle:(T0)=>{if(T0==="b")o("font-weight",t?"400":"700");else if(T0==="i")o("font-style",F0?"normal":"italic");else o("text-decoration",z0?"none":"underline")}})},J9=[{value:"row",node:z(S9,{as:g4}),label:"Row"},{value:"column",node:z(S9,{as:m4}),label:"Column"}],i8=[{value:"flex-start",node:z(S9,{as:OU}),label:"Start"},{value:"center",node:z(S9,{as:LU}),label:"Center"},{value:"flex-end",node:z(S9,{as:DU}),label:"End"},{value:"space-between",node:z(S9,{as:Bq}),label:"Space between"}],S6=[{value:"flex-start",node:z(S9,{as:AU}),label:"Start"},{value:"center",node:z(S9,{as:MU}),label:"Center"},{value:"flex-end",node:z(S9,{as:wU}),label:"End"},{value:"stretch",node:z(S9,{as:fU}),label:"Stretch"}],r9=[{value:"left",node:z(S9,{as:aJ}),label:"Left"},{value:"center",node:z(S9,{as:l4}),label:"Center"},{value:"right",node:z(S9,{as:d4}),label:"Right"},{value:"justify",node:z(S9,{as:p4}),label:"Justify"}],n7=[{value:"visible",node:z(S9,{as:xG}),label:"Visible"},{value:"hidden",node:z(S9,{as:$U}),label:"Hidden"},{value:"scroll",node:z(S9,{as:bU}),label:"Scroll"}],$6=(t,F0)=>{let z0=S(F0);return z0.length?z(EF,{kind:"value",groups:z0,current:L[t],activeDs:T,onPick:(T0)=>o(t,T0),label:`${t} design token`}):null},D7=(t)=>{let F0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===F0)F0.select()})},IJ=(t,F0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let z0=t.shiftKey?10:1,T0=t.key==="ArrowUp"?1:-1,s0=(Number.parseFloat(t.currentTarget.value)||0)+T0*z0;return t.currentTarget.value=String(s0),F0(s0),!0},d9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:L[t]??"",placeholder:b9(K[t])||"—",onFocus:D7,onKeyDown:(F0)=>{if(F0.key==="Enter")F0.currentTarget.blur()},onBlur:(F0)=>o(t,F0.currentTarget.value)},`${t}:${L[t]??""}`),E9=(t,F0,z0={})=>{let T0=QQ(L[t]??""),s0=Nt.has(t),_8=s0?"":z0.fixedUnit||(T0.unit&&T0.unit!=="auto"?T0.unit:"px"),C8=jP[t],M8=Number.parseFloat(QQ(b9(K[t])??"").n)||0,v8=T0.n!==""&&T0.n!=null?Number.parseFloat(T0.n)||0:M8;return A(Y0,{children:[z(sJ,{value:v8,min:z0.min??0,step:1,ariaLabel:t,lead:C8?C8.node??C8.t:void 0,onCommit:(K9)=>o(t,s0?`${K9}`:`${K9}${_8}`),unitSlot:s0||z0.fixedUnit?null:z(VB,{units:Ft,value:T0.unit||"px",ariaLabel:`${t} unit`,onChange:(K9)=>o(t,K9==="auto"?"auto":`${T0.n||"0"}${K9}`)})},`${t}:${L[t]??""}`),$6(t,F0)]})},y7=(t)=>{let F0=K[t]||L[t]||"",z0=L[t]??"",T0=typeof z0==="string"&&/var\(\s*--/.test(z0),s0=T0?z0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):z0;return z(hU,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:S("color"),current:L[t],activeDs:T,swatchBg:F0,seedHex:kF(K[t]||L[t])||"#000000",onPick:(_8)=>o(t,_8),label:`${t} colour`}),displayValue:s0,bound:T0,ariaLabel:t,onValue:(_8)=>o(t,_8)})},z9=(t,F0)=>{let z0=null,T0=F0.unitless?"":"px",s0=(M8)=>F0.unitless?`${M8}`:`${M8}${T0}`,_8=(M8,v8,K9)=>{for(let W7 of v8??[t])K9(W7,s0(M8))},C8=jw({getBase:()=>z0?.value??"0",min:F0.min??0,step:1,sides:F0.sides,onInput:(M8,v8)=>{if(z0)z0.value=String(M8);if(v8){let K9=z0?.closest(".st-cp-box");for(let W7 of v8){if(W7===t)continue;let D9=K9?.querySelector(`.st-cp-boxv[aria-label="${W7}"]`);if(D9)D9.value=String(M8)}}_8(M8,v8,s)},onCommit:(M8,v8)=>_8(M8,v8,o)});return{onPointerDown:(M8)=>{z0=M8.currentTarget,C8(M8)}}},w9=(t,F0)=>{let z0=L[t],T0=z0!=null&&z0!==""?QQ(z0).n||z0:QQ(b9(K[t])??"").n||"0",s0=!z0||z0==="0"||z0==="0px"||z0==="auto",_8=t.split("-").pop(),C8=_8==="top"||_8==="bottom"?[`${F0}-top`,`${F0}-bottom`]:[`${F0}-left`,`${F0}-right`],M8=[`${F0}-top`,`${F0}-right`,`${F0}-bottom`,`${F0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${F0[0]}${t.split("-").pop()[0]}${s0?" is-zero":""}`,"aria-label":t,defaultValue:T0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...z9(t,{sides:{pair:C8,all:M8}}),onFocus:D7,onKeyDown:(v8)=>{if(IJ(v8,(K9)=>o(t,`${K9}px`)))return;if(v8.key==="Enter")v8.currentTarget.blur()},onBlur:(v8)=>{let K9=v8.currentTarget.value.trim();if(!K9)return;let W7=/[a-z%]/i.test(K9)?K9:`${K9}px`;o(t,W7)}},`${t}:${z0??""}`)},K7=(t)=>{let F0=L[t],z0=F0!=null&&F0!==""&&F0!=="auto"?QQ(F0).n||F0:QQ(b9(K[t])??"").n||"",T0=!F0||F0==="auto"||F0==="0"||F0==="0px",s0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],_8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${T0?" is-zero":""}`,"aria-label":t,defaultValue:z0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...z9(t,{sides:{pair:s0,all:_8},min:-1/0}),onFocus:D7,onKeyDown:(C8)=>{if(IJ(C8,(M8)=>o(t,`${M8}px`)))return;if(C8.key==="Enter")C8.currentTarget.blur()},onBlur:(C8)=>{let M8=C8.currentTarget.value.trim();if(!M8)return;let v8=/[a-z%]/i.test(M8)?M8:`${M8}px`;o(t,v8)}},`${t}:${F0??""}`)},P7=Object.entries(D),a9=Object.entries(w),p6=()=>{let t=(X.tag||"").toLowerCase(),z0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],T0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:z0,canReplace:T0}},r7=(t)=>A(Y0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),b0("object-fit",N0("object-fit",J10)),b0("object-position",d9("object-position")),b0("aspect-ratio",A("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:wt.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(F0)=>{let z0=F0.target.value;if(o("aspect-ratio",z0),z0&&z0!=="auto"&&L.height)u("height")},children:[z("option",{value:"",disabled:!0,children:b9(K["aspect-ratio"])||"—"}),wt.map((F0)=>z("option",{value:F0,children:F0},F0))]}))]});return A("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:R8,children:[A("div",{className:"st-cp-id",children:[A("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?A("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(yw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(S9,{as:h4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(S9,{as:c4,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?A(Y0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(L.display||b9(K.display)||"").trim();return t==="flex"||t==="inline-flex"?A(Y0,{children:[b0("flex-direction",P8("flex-direction",J9),void 0,"Direction"),b0("align-items",z(qv,{value:A8(),onChange:g0,ariaLabel:"auto-layout alignment"}),r0("align-items"),"Alignment"),b0("gap",I8("gap","space"),void 0,"Gap"),A("div",{className:"st-cp-modes",children:[t0("width"),t0("height")]}),A("div",{className:"st-cp-box","aria-label":"padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[c8(r0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:L0("Auto layout")}),p["Auto layout"]?b0("flex-wrap",z(r4,{checked:/^wrap/.test(L["flex-wrap"]||b9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(z0)=>o("flex-wrap",z0?"wrap":"nowrap")}),r0("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>o("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],A(Y0,{children:[b0("width",E9("width"),void 0,"Width"),b0("height",E9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:L0("Size")}),p.Size?A(Y0,{children:[b0("min-width",E9("min-width"),void 0,"Min width"),b0("max-width",E9("max-width"),void 0,"Max width"),b0("min-height",E9("min-height"),void 0,"Min height"),b0("max-height",E9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],A(Y0,{children:[b0("position",N0("position",Lt),void 0,"Position"),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[c8(r0("top")),"inset"]}),K7("top"),K7("right"),K7("bottom"),K7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||b9(K.position)||"static"})]}),(L.position||b9(K.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:L0("Position")}),p.Position?b0("z-index",E9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],b0("background-color",y7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],b0("border",E0(),r0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],b0("border-radius",M0(),r0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],A(Y0,{children:[b0("box-shadow",$6("box-shadow","shadow")||d9("box-shadow"),void 0,"Shadow"),b0("filter",e0(),r0("filter"),"Blur"),b0("mix-blend-mode",N0("mix-blend-mode",Mt),void 0,"Blend")]})),H0("Opacity",["opacity"],b0("opacity",w0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],A(Y0,{children:[b0("font-family",N0("font-family",Vt),void 0,"Font"),b0("color",y7("color"),void 0,"Color"),b0("font-size",I8("font-size","type"),void 0,"Size"),b0("font-weight",N0("font-weight",Ut),void 0,"Weight"),b0("line-height",E9("line-height","lh"),void 0,"Line height"),b0("text-align",P8("text-align",r9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:L0("Text")}),p.Text?A(Y0,{children:[b0("letter-spacing",E9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),b0("font-style",N0("font-style",X10),void 0,"Style"),b0("text-transform",N0("text-transform",Dt),void 0,"Case"),b0("white-space",N0("white-space",Ot),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],A("div",{className:"st-cp-box","aria-label":"margin",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[c8(r0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:F0}=p6();return t?H0("Media",["object-fit","object-position","aspect-ratio"],r7(F0)):null})()]}):A(Y0,{children:[S0("Layout",(()=>{let t=(L.display||b9(K.display)||"").trim(),F0=t==="flex"||t==="inline-flex",z0=t==="grid"||t==="inline-grid";return A(Y0,{children:[b0("display",N0("display",tV0)),F0?A(Y0,{children:[b0("flex-direction",P8("flex-direction",J9)),b0("flex-wrap",z(r4,{checked:/^wrap/.test(L["flex-wrap"]||b9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(T0)=>o("flex-wrap",T0?"wrap":"nowrap")}),r0("flex-wrap"))]}):null,F0||z0?A(Y0,{children:[b0("align-items",P8("align-items",S6)),b0("justify-content",P8("justify-content",i8)),b0("gap",I8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>o("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(L.display||b9(K.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let z0=L["grid-template-columns"]||"",T0=L["grid-template-rows"]||"",s0=bD(z0),_8=bD(T0),C8=s0.length>0||!z0.trim(),M8=_8.length>0||!T0.trim();return S0("Grid",A(Y0,{children:[C8?z(_t,{label:"Columns",tracks:s0,editable:q,onChange:(v8)=>o("grid-template-columns",jD(v8))}):A("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:z0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),M8?z(_t,{label:"Rows",tracks:_8,editable:q,onChange:(v8)=>o("grid-template-rows",jD(v8))}):A("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:T0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),S0("Position",A(Y0,{children:[b0("position",N0("position",Lt)),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[c8(r0("top")),"inset"]}),K7("top"),K7("right"),K7("bottom"),K7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||b9(K.position)||"static"})]}),(L.position||b9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,b0("z-index",E9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&S0("Grid item",A(Y0,{children:[A("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),b0("grid-column",d9("grid-column")),b0("grid-row",d9("grid-row"))]})),S0("Typography",A(Y0,{children:[b0("font-family",N0("font-family",Vt)),b0("color",y7("color")),b0("font-size",I8("font-size","type")),b0("font-weight",N0("font-weight",Ut)),b0("line-height",E9("line-height","lh")),b0("letter-spacing",E9("letter-spacing",null,{min:-1/0})),b0("text-align",P8("text-align",r9)),b0("font-style",o0(),r0("font-style")),b0("text-transform",N0("text-transform",Dt)),b0("white-space",N0("white-space",Ot))]})),S0("Spacing",z(Y0,{children:A("div",{className:"st-cp-box","aria-label":"margin and padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[c8(r0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin"),A("div",{className:"st-cp-boxpad",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[c8(r0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding"),A("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(L.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(L.height)||X.bounds?.h||0)]})]})]})})),S0("Size",A(Y0,{children:[A("div",{className:"st-cp-modes",children:[t0("width"),t0("height")]}),b0("width",E9("width")),b0("height",E9("height")),b0("min-width",E9("min-width")),b0("max-width",E9("max-width")),b0("min-height",E9("min-height")),b0("max-height",E9("max-height")),b0("overflow",P8("overflow",n7)),Q8?A(Y0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),b0("align-self",N0("align-self",eV0)),b0("flex-grow",E9("flex-grow",null,{unitless:!0})),b0("flex-shrink",E9("flex-shrink",null,{unitless:!0})),b0("flex-basis",E9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:F0}=p6();return t?S0("Media",r7(F0)):null})(),S0("Appearance",A(Y0,{children:[b0("background-color",y7("background-color")),b0("border-radius",M0(),r0("border-radius")),b0("border",E0(),r0("border-width")),b0("box-shadow",$6("box-shadow","shadow")||d9("box-shadow")),b0("filter",e0(),r0("filter")),b0("mix-blend-mode",N0("mix-blend-mode",Mt)),b0("opacity",w0()),b0("rotation",p0(),r0("transform")),b0("transform",d9("transform")),b0("transform-origin",d9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,F0])=>typeof F0==="string"&&F0.startsWith("err:"));return t?A("div",{className:"st-cp-save is-err",role:"status",children:[z(X9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),S0("Advanced",A("div",{className:"st-cp-advbody",children:[P7.length?A(Y0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),P7.map(([t,F0])=>A("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:F0,"aria-label":`${t} value`,onKeyDown:(z0)=>{if(z0.key==="Enter")z0.currentTarget.blur()},onBlur:(z0)=>U0(t,z0.currentTarget.value)},`cs:${t}:${F0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>n(t),children:z(X9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(W10,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),a9.length?A(Y0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),a9.map(([t,F0])=>A("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:F0,"aria-label":`${t} value`,onKeyDown:(z0)=>{if(z0.key==="Enter")z0.currentTarget.blur()},onBlur:(z0)=>i(t,z0.currentTarget.value)},`at:${t}:${F0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>V0(t),children:z(X9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(G10,{commit:i})]}))]}),A("div",{className:"st-cp-legend",children:[A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),A("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function W10({commit:X}){let[J,Q]=d.useState(""),[Y,W]=d.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("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 G10({commit:X}){let[J,Q]=d.useState(""),[Y,W]=d.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("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 Z10={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function H10(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===J)return G=q[K],q.splice(K,1),!0;if(q[K].children&&Z(q[K].children))return!0}return!1};if(Z(W),!G)return X;let H=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===Q){if(Y==="inside-start"||Y==="inside-end")if(q[K].children=q[K].children||[],Y==="inside-start")q[K].children.unshift(G);else q[K].children.push(G);else q.splice(Y==="before"?K:K+1,0,G);return!0}if(q[K].children&&H(q[K].children))return!0}return!1};return H(W)?W:X}var q10=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function jt({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:D,onToggleLock:w,onRename:R}){let _=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(_),T=!!X.synthetic,I=!T&&L?L[X.id]:null,S=!T&&!!D?.has(_),[C,b]=d.useState(!1),[y,g]=d.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),c=G?.has(_)?G.get(_):!!X.hidden,f=!!V&&!T&&!S,p=()=>{b(!1);let s=y.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},r=F?.key===_,h=r?{transform:`translate(${F.dx}px, ${F.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 A(Y0,{children:[A("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(c?" is-hidden":"")+(T?" is-group":"")+(I?" is-instance":"")+(S?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":O?!P:void 0,"aria-grabbed":f?r:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":_,onClick:()=>T?O&&Z(_):H(X),onMouseEnter:()=>!T&&q(X),onMouseLeave:()=>q(null),onPointerDown:f?(s)=>B(s,X,_):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)O&&Z(_);else H(X);else if(s.key==="F2"&&R&&!T)s.preventDefault(),g(X.dcElement||X.label||""),b(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(_)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),I?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:I.root?"◆":"◇"}):z(X9,{name:Z10[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:y,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>g(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:p,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")p();else if(s.key==="Escape")b(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!T?(s)=>{s.stopPropagation(),g(X.dcElement||X.label||""),b(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:I?I.component:X.type}),w&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":S?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":S,title:S?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),w(_)},children:z(X9,{name:S?"lock":"unlock",size:12})}):null,K&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":c?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":c,title:c?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),K(X)},children:z(X9,{name:c?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((s,X0)=>z(jt,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:D,onToggleLock:w,onRename:R},`${s.id}:${s.index}`)):null]})}function z10({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(K)=>{let V=Q[K];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return J[K]||V||""},W=(K,V)=>{let B=J[V]||Q[V];if(!B)return null;return A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:K}),A("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(V)})]})]},K)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?QQ(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 A(Y0,{children:[G?A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),A("div",{className:"st-insp-fields",children:[A("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?A("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 yt(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var K10=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],U10=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function V10({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let q=yt(X),K=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=St(X.file,J),B=$t(J,K,V),F=(r)=>B.map((h)=>({ds:h.name,names:h[r]||[],vals:h.vals})).filter((h)=>h.names.length),L=(r)=>F(r).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),D=(r)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(r||"");if(!h)return r||"";for(let s of B){let X0=s.vals?.[h[1]];if(X0)return X0}return""},w=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,_=(r,h)=>{if(!q)return;let s=Number.isFinite(r)&&r>0?Math.round(r):void 0,X0=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&X0==null)return;Q?.(q,s,X0)},O=Object.entries(TJ).find(([,r])=>r.width===w&&r.height===R)?.[0],P=Object.entries(TJ).find(([,r])=>r.width===w)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",I=X.attrs?.["data-dc-bg"]??"",S=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",b=X.attrs?.["data-dc-gap"]??"",y=X.attrs?.["data-dc-kind"]||"digital",g=null;try{g=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let m=(r)=>{if(!q)return;let h=null;if(r==="print"&&!g){let s={paper:"a4"};try{let X0=P3(s);if(X0)h={defaults:s,widthPx:X0.widthPx,heightPx:X0.heightPx}}catch{}}if(G?.(q,r==="digital"?null:r,h),r==="web"&&T)Y?.(q,!1,void 0)},c=(r)=>{if(!q)return;let h={paper:"a4",...g,...r},s;try{s=P3(h)}catch{return}Q?.(q,s.widthPx,s.heightPx),Z?.(q,h)},f=(r)=>{if(!q)return;let h=r&&Number.isFinite(R)?Math.round(R):void 0;Y?.(q,r,h)},p=(r)=>{if(!q)return;W?.(q,r)};return A("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),A("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(sJ,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(r)=>_(r,null)}),z(sJ,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(r)=>{if(T)_(null,r)}})]}),z("div",{style:{padding:"0 12px 8px"},children:y==="print"?A("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(r)=>c({paper:r.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),E3.map((r)=>A("option",{value:r.id,children:[r.label," — ",r.width,"×",r.height,r.unit]},r.id))]}):y==="web"?A("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)_(h.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${TJ[P].label} — ≤ ${TJ[P].width}px`:"Breakpoint…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ≤ ",h.width,"px breakpoint"]},r))]}):A("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)_(h.width,h.height)},children:[z("option",{value:"",disabled:!0,children:O?TJ[O].label:"Preset size…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ",h.width,"×",h.height]},r))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(BB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(r)=>f(r==="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(n4,{value:y,ariaLabel:"artboard kind",options:U10.map(([r,h])=>({value:r,label:h})),onChange:m})}),y!=="print"&&q&&H?z("div",{style:{padding:"0 12px 8px"},children:A("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(r)=>{let h=TJ[r.currentTarget.value];if(h)H(q,h.width);r.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(TJ).map(([r,h])=>A("option",{value:r,children:[h.label," — ",h.width,"px"]},r))]})}):null,y==="print"?A(Y0,{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(BB,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(r)=>c({orientation:r})})}),z("div",{style:{padding:"0 12px 8px"},children:z(sJ,{value:Number.isFinite(g?.bleedMm)?g.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:(r)=>c({bleedMm:r})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),A("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let r=D(I),h=/var\(\s*--/.test(I),s=h?I.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):I;return z(hU,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:I,activeDs:V,swatchBg:r,seedHex:kF(r)||"#000000",onPick:(X0)=>p({background:X0||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(X0)=>p({background:(X0||"").trim()||null})})})(),z(n4,{value:C,ariaLabel:"artboard body layout",options:K10.map(([r,h])=>({value:r,label:h})),onChange:(r)=>p({layout:r||null})}),A("div",{style:{display:"flex",gap:8},children:[z(FB,{value:/^var\(/.test(S)?S:Number.parseFloat(S)||0,tokens:L("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(r)=>p({padding:typeof r==="string"?r:r>0?r:null})}),z(FB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:L("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(r)=>p({gap:typeof r==="string"?r:r>0?r:null})})]})]})]})}var xP=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,B10=new RegExp(xP.source,"gi");function F10(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(B10)||[])],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=xP.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function N10({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:q,onHoverLayer:K,onReorderLayer:V,layersBusyRef:B,cfg:F,onOptimistic:L,onRecordEdit:D,onReplaceMedia:w,onResizeArtboard:R,onSetArtboardHug:_,onSetArtboardStyle:O,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I,onUndoRedo:S,editScope:C,tab:b,onTabChange:y,width:g,resizing:m,photoSel:c,photoRev:f,onPhotoEdit:p,onPhotoRemoveBackground:r,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:X0=!1,hideLayersTab:o=!1,cpMode:U0,onSetCpMode:i}){let[u,n]=d.useState("inspect"),V0=X0?"layers":b??u,m0=(E0)=>{n(E0),y?.(E0)},[J8,Q8]=d.useState(()=>new Set),[t0,F8]=d.useState(()=>new Map);d.useEffect(()=>{let E0=Array.isArray(X)?X[0]:X,p0=E0?.id;if(!p0||!Q?.nodes)return;let e0=E0.index,w0=null,o0=[];if(function J9(i8,S6){for(let r9 of i8||[]){let n7=`${r9.id}:${r9.index}`;if(!r9.synthetic&&r9.id===p0&&(e0==null||r9.index===e0))return w0=n7,o0.push(...S6),!0;if(r9.children&&r9.children.length&&J9(r9.children,[...S6,n7]))return!0}return!1}(Q.nodes,[]),!w0)return;if(o0.length)Q8((J9)=>{let i8=!1,S6=new Set(J9);for(let r9 of o0)if(S6.delete(r9))i8=!0;return i8?S6:J9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${w0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let Z8=(E0)=>{let p0=`${E0.id}:${E0.index}`;return t0.has(p0)?t0.get(p0):!!E0.hidden},[N8,p8]=d.useState(null),[A8,g0]=d.useState(""),R8=(E0,p0)=>{if(!H||!E0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:E0.id,attr:"data-dc-element",value:p0})}).then((e0)=>e0.json().catch(()=>({}))).then((e0)=>{if(!e0.ok)return;D?.({op:"attr",canvas:H,id:E0.id,key:"data-dc-element",before:E0.dcElement??null,after:p0})}).catch(()=>{})},r0=V?(E0,p0,e0)=>{if(B?.current)return;if(E0?.synthetic||p0?.synthetic)return;let w0=e0==="before"?`before ${p0.label}`:e0==="after"?`after ${p0.label}`:`into ${p0.label}`;g0(`Moved ${E0.label} ${w0}`),V(E0.id,p0.id,e0,{idIndex:E0.index,refIndex:p0.index})}:void 0,f8=()=>{let E0=[];return function p0(e0,w0,o0){(e0||[]).forEach((J9,i8)=>{if(E0.push({node:J9,depth:w0,parentNode:o0,siblings:e0,pos:i8}),J9.children&&J9.children.length&&!J8.has(`${J9.id}:${J9.index}`))p0(J9.children,w0+1,J9)})}(Q?.nodes,0,null),E0},c8=(E0)=>{if(E0.key!=="ArrowUp"&&E0.key!=="ArrowDown")return;if(!H0)return;let p0=f8(),e0=p0.findIndex((i8)=>i8.node.id===H0.id&&i8.node.index===H0.index);if(e0<0)return;let w0=E0.key==="ArrowDown"?1:-1,o0=p0[e0];if(!E0.altKey){let i8=p0[e0+w0];if(i8)E0.preventDefault(),q?.(i8.node);return}if(!r0||!Array.isArray(o0.siblings))return;E0.preventDefault();let J9=(i8)=>i8&&i8.children&&i8.children.length&&!J8.has(`${i8.id}:${i8.index}`);if(!E0.shiftKey){if(w0<0&&o0.pos>0)r0(o0.node,o0.siblings[o0.pos-1],"before");else if(w0>0&&o0.pos<o0.siblings.length-1)r0(o0.node,o0.siblings[o0.pos+1],"after");return}if(w0>0){let i8=o0.siblings[o0.pos+1];if(i8)r0(o0.node,i8,J9(i8)?"inside-start":"after");else if(o0.parentNode)r0(o0.node,o0.parentNode,"after")}else{let i8=o0.siblings[o0.pos-1];if(i8)r0(o0.node,i8,J9(i8)?"inside-end":"before");else if(o0.parentNode)r0(o0.node,o0.parentNode,"before")}},q9=d.useRef(null),b0=d.useRef(null),B0=(E0,p0,e0)=>{if(!r0||E0.button!==0||E0.metaKey||E0.ctrlKey||E0.shiftKey||E0.altKey)return;if(B?.current)return;let{clientX:w0,clientY:o0}=E0,J9=new Set([e0]);(function z9(w9){(w9.children||[]).forEach((K7)=>{J9.add(`${K7.id}:${K7.index}`),z9(K7)})})(p0);let i8=14,S6=6,r9=[];(function z9(w9,K7){(w9||[]).forEach((P7)=>{let a9=`${P7.id}:${P7.index}`;if(r9.push({node:P7,key:a9,id:P7.id,depth:K7,tag:P7.tag}),P7.children&&P7.children.length&&!J8.has(a9))z9(P7.children,K7+1)})})(Q?.nodes,0);let n7=new Map(r9.map((z9)=>[z9.key,z9])),$6=!1,D7=(z9)=>{if(!$6){if(Math.hypot(z9.clientX-w0,z9.clientY-o0)<4)return;$6=!0}let w9=z9.clientX-w0,K7=z9.clientY-o0,P7=null,a9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((r7)=>({rect:r7.getBoundingClientRect(),it:n7.get(r7.getAttribute("data-layer-key"))})).filter((r7)=>r7.it&&r7.it.key!==e0);if(a9.length){let r7=a9[0].rect.left,t=a9[0].rect.right,F0=a9.length;for(let D9=0;D9<a9.length;D9++)if(z9.clientY<a9[D9].rect.top+a9[D9].rect.height/2){F0=D9;break}let z0=a9[F0-1]?.it||null,T0=a9[F0]?.it||null,s0=Math.round((z9.clientX-r7-S6)/i8),_8=z0?z0.depth+(q10.has(z0.tag)?0:1):0,C8=T0?T0.depth:0,M8=Math.max(C8,Math.min(s0,_8)),v8=null,K9="before",W7=0;if(!z0){if(T0)v8=T0,K9="before",W7=T0.depth}else if(M8>z0.depth)v8=z0,K9="inside-start",W7=z0.depth+1;else if(M8===z0.depth)v8=z0,K9="after",W7=z0.depth;else{for(let D9=F0-1;D9>=0;D9--)if(a9[D9].it.depth===M8){v8=a9[D9].it;break}if(!v8)v8=z0;K9="after",W7=M8}if(v8&&v8.key!==e0&&!J9.has(v8.key)){let D9=z0?a9[F0-1].rect.bottom:a9[0].rect.top,c6=r7+S6+W7*i8;P7={refId:v8.id,position:K9,node:v8.node,y:D9,left:c6,w:Math.max(24,t-c6)}}}let p6={key:e0,node:p0,dx:w9,dy:K7,target:P7};q9.current=p6,p8(p6)},IJ=()=>{window.removeEventListener("pointermove",D7),window.removeEventListener("pointerup",E9),window.removeEventListener("keydown",y7,!0)},d9=()=>{let z9=(w9)=>{w9.preventDefault(),w9.stopImmediatePropagation(),document.removeEventListener("click",z9,!0)};document.addEventListener("click",z9,!0),setTimeout(()=>document.removeEventListener("click",z9,!0),300)},E9=()=>{IJ();let z9=q9.current;if(q9.current=null,p8(null),$6&&z9?.target)d9(),r0(z9.node,z9.target.node,z9.target.position)},y7=(z9)=>{if(z9.key!=="Escape")return;if(z9.preventDefault(),z9.stopImmediatePropagation(),IJ(),q9.current=null,p8(null),$6)d9()};window.addEventListener("pointermove",D7),window.addEventListener("pointerup",E9),window.addEventListener("keydown",y7,!0)},K0=(E0)=>Q8((p0)=>{let e0=new Set(p0);if(e0.has(E0))e0.delete(E0);else e0.add(E0);return e0}),S0=(E0)=>{let p0=`${E0.id}:${E0.index}`,e0=Z8(E0),w0=!e0;if(F8((o0)=>new Map(o0).set(p0,w0)),L?.({id:E0.id,artboardId:Q?.artboardId??null,index:E0.index,prop:"display",value:w0?"none":null}),!H||!E0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w0?{canvas:H,id:E0.id,property:"display",value:"none"}:{canvas:H,id:E0.id,property:"display",reset:!0})}).catch(()=>{}),D?.({op:"css",canvas:H,id:E0.id,key:"display",before:e0?"none":null,after:w0?"none":null})},H0=Array.isArray(X)?X[0]:X,L0=c?{asset:c.asset,kind:"annotation-image"}:(()=>{let E0=F10(H0);return E0?{asset:E0,kind:"artboard-img"}:null})(),N0=L0?.kind==="annotation-image",Y8=(E0)=>{if(!(E0.metaKey||E0.ctrlKey)||E0.altKey)return;let p0=E0.key.toLowerCase();if(p0==="z")E0.preventDefault(),s?.(E0.shiftKey?"redo":"undo");else if(p0==="y")E0.preventDefault(),s?.("redo")},P8=N0?"photo":V0==="photo"&&!L0?"inspect":V0,I8=(E0,p0,e0)=>A("button",{type:"button",className:"st-rp-tab"+(P8===E0?" is-active":""),onClick:()=>m0(E0),children:[z(X9,{name:e0,size:14}),p0]}),M0=H0?.bounds||null;return A("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[A("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:X0?{display:"none"}:void 0,children:[N0?I8("photo","Photo","image"):A(Y0,{children:[I8("inspect","Inspect","sliders"),!o&&I8("layers","Layers","layers"),I8("css","CSS","code"),L0?I8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:z(X9,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&C?A("div",{className:`st-scope st-scope--${C.scope}`,title:C.scope==="shared"?`Editing this element's style changes ${C.affects} place${C.affects===1?"":"s"}${C.componentName?` (component ${C.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"}),C.scope==="shared"?`Shared${C.componentName?` · ${C.componentName}`:""} · edits ${C.affects} place${C.affects===1?"":"s"}`:"Local · this element only",C.scope==="shared"&&Z?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:P8==="photo"&&L0?z("div",{onKeyDown:Y8,children:z(Bv,{asset:L0.asset,ColorPicker:bt,StIcon:X9,onEdit:(E0)=>p?.(L0.asset,E0),onRemoveBackground:r,onRecordEdit:(E0,p0)=>h?.(L0.asset,E0,p0)},`${L0.asset}:${f??0}`)}):!H0&&!(P8==="layers"&&Q?.nodes?.length)?z("div",{className:"st-rp-empty",children:A("p",{children:["Press ",z(d6,{children:"V"}),", then click an element to select it — or ",z(d6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&P8==="inspect"?A(Y0,{children:[z("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:M0?Math.round(M0.x):"—",readOnly:!0,"aria-label":"x position"})]}),A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:M0?Math.round(M0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),A("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:M0?Math.round(M0.w):"—",readOnly:!0,"aria-label":"width"})]}),A("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:M0?Math.round(M0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),A("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:H0.tag||"—"})})]}),H0.classes?A("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:H0.classes})})]}):null,z(z10,{el:H0})]}):P8==="layers"?A(Y0,{children:[A("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?A(Y0,{children:[r0?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:b0,onKeyDown:c8,children:Q.nodes.map((E0,p0)=>z(jt,{node:E0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:t0,onToggle:K0,onSelect:(e0)=>{q?.(e0),b0.current?.focus()},onHover:(e0)=>K?.(e0),onToggleVisibility:S0,onReorder:r0,onRowPointerDown:B0,dragState:N8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:R8},`${E0.id}:${E0.index}`))}),N8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:N8.target.left,top:N8.target.y-1,width:N8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:A8})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((E0,p0)=>A("div",{className:"st-layer"+(p0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+p0*12},children:[z(X9,{name:"square",size:13}),E0]},p0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&yt(H0)?z(V10,{el:H0,cfg:F,onResizeArtboard:R,onSetArtboardHug:_,onSetArtboardStyle:O,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I}):z(Y10,{el:H0,cfg:F,onOptimistic:L,onRecordEdit:D,onReplaceMedia:w,onUndoRedo:S,mode:U0,onSetMode:i})})]})}function L10(){let[X,J]=d.useState([]),[Q,Y]=d.useState("Design"),[W,G]=d.useState([]),[Z,H]=d.useState(null),[q,K]=d.useState(null),V=d.useRef(null);d.useEffect(()=>{V.current=q},[q]);let[B,F]=d.useState(null);d.useEffect(()=>{let v=Array.isArray(q)?q.length===1?q[0]:null:q,j=v&&typeof v.id==="string"?v.id:null;if(!j||!Z){F(null);return}let Q0=new AbortController,Z0=new URLSearchParams({canvas:Z,id:j});return fetch(`/_api/edit-scope?${Z0}`,{signal:Q0.signal}).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(W0?.ok)F(W0)}).catch(()=>{}),()=>Q0.abort()},[q,Z]);let L=d.useRef(0),D=d.useRef([]),w=d.useCallback((v)=>{if(!v?.id||!v.file)return;for(let j of D.current)clearTimeout(j);D.current=[50,450,1200,2500,5000].map((j)=>setTimeout(()=>{let Q0=V.current,Z0=Array.isArray(Q0)?Q0[0]:Q0;if(!Z0||Z0.id!==v.id||Z0.file!==v.file)return;let W0=y8.current.get(v.file);if(!W0?.contentWindow)return;try{W0.contentWindow.postMessage({dgn:"select-by-id",id:v.id,artboardId:v.artboardId??null,index:v.index??0},"*")}catch{}},j))},[]),R=d.useRef([]),_=d.useCallback((v,j)=>{if(!v||!j)return;for(let Q0 of R.current)clearTimeout(Q0);R.current=[50,450,1200,2500,5000].map((Q0)=>setTimeout(()=>{let Z0=V.current,W0=Array.isArray(Z0)?Z0[0]:Z0;if(!W0||W0.artboardId!==v||W0.file!==j)return;let f0=y8.current.get(j);if(!f0?.contentWindow)return;try{f0.contentWindow.postMessage({dgn:"select-by-id",artboardId:v},"*")}catch{}},Q0))},[]),O=d.useRef(null),P=d.useRef(null),T=d.useRef(null),I=d.useRef(null),S=d.useRef(!1),C=d.useRef(null),[b,y]=d.useState(null),[g,m]=d.useState(null),c=d.useRef({canvas:null,at:0});d.useEffect(()=>{if(!Z||!b)return;let v=Date.now(),j=c.current;if(j.canvas===Z&&v-j.at<1500)return;c.current={canvas:Z,at:v},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((Q0)=>Q0.json()).then((Q0)=>{if(Q0?.ok&&Q0.map&&typeof Q0.map==="object")m(Q0.map);else m(null)}).catch(()=>m(null))},[Z,b]);let[f,p]=d.useState(!1),[r,h]=d.useState(null),[s,X0]=d.useState(null),[o,U0]=d.useState(null),[i,u]=d.useState(null),[n,V0]=d.useState(!1),[m0,J8]=d.useState(null),[Q8,t0]=d.useState(""),[F8,Z8]=d.useState(null),[N8,p8]=d.useState(null),A8=d.useRef(null),g0=Zt("maude-sb-w",{min:200,max:420,def:252}),R8=Zt("maude-rp-w",{min:260,max:480,def:304}),[r0,f8]=d.useState(null),c8=d.useRef(null);d.useEffect(()=>{if(!r0)return;let v=(Q0)=>{let Z0=c8.current?.getBoundingClientRect();if(!Z0)return;if(r0==="sb")g0.setW(Q0.clientX-Z0.left);else R8.setW(Z0.right-Q0.clientX)},j=()=>f8(null);return window.addEventListener("pointermove",v),window.addEventListener("pointerup",j),()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",j)}},[r0,g0.setW,R8.setW]);let q9=d.useCallback((v)=>{clearTimeout(A8.current),A8.current=setTimeout(()=>{p8((j)=>j===v?null:j)},2500)},[]);d.useEffect(()=>{if(!N8)return;let v=setTimeout(()=>p8(null),15000);return()=>clearTimeout(v)},[N8]);let[b0,B0]=d.useState({designRel:".design"}),K0=d.useCallback(()=>{fetch("/_config").then((v)=>v.json()).then((v)=>{let j=(v.designRoot||".design").replace(/^\/+|\/+$/g,"");B0((Q0)=>({...Q0,designRel:j,tokensCssRel:v.tokensCssRel,designSystems:v.designSystems,canvasOrigin:v.canvasOrigin}))}).catch(()=>{})},[]);d.useEffect(()=>{K0()},[K0]),d.useEffect(()=>{let v=!1;return fetch("/_sync-status").then((j)=>j.json()).then((j)=>{if(v||!j||j.linked===!1)return;X0(j)}).catch(()=>{}),()=>{v=!0}},[]),d.useEffect(()=>{let v=!1;return fetch("/_api/git/status").then((j)=>j.json()).then((j)=>{if(!v&&j)U0(j)}).catch(()=>{}),()=>{v=!0}},[]);let[S0,H0]=d.useState({}),[L0,N0]=d.useState(null),[Y8,P8]=d.useState(!1),[I8,M0]=d.useState("open"),[E0,p0]=d.useState(WV0),[e0,w0]=d.useState(()=>{return CP(ns,"advanced")==="designer"?"designer":"advanced"});d.useEffect(()=>{try{localStorage.setItem(ns,JSON.stringify(e0))}catch{}},[e0]);let[o0,J9]=d.useState(null),[i8,S6]=d.useState(()=>NZ(rs,!0)),[r9,n7]=d.useState(()=>NZ(is,!1)),[$6,D7]=d.useState(()=>CP(os,{})),[IJ,d9]=d.useState(!1),[E9,y7]=d.useState(!1);d.useEffect(()=>{if(!d8())return;let v=Qf(()=>y7(!0));return()=>{v.then((j)=>j()).catch(()=>{})}},[]);let[z9,w9]=d.useState(!1),[K7,P7]=d.useState(!1),[a9,p6]=d.useState(!1),[r7,t]=d.useState(!1),{report:F0}=Mw(d8()),[z0,T0]=d.useState(!1),[s0,_8]=d.useState(!1),[C8,M8]=d.useState(null),[v8,K9]=d.useState(!1),[W7,D9]=d.useState(!1),[c6,WQ]=d.useState(!1),[UY,GQ]=d.useState(!1),[b6,VY]=d.useState(()=>CP(es,vq)),[GX,f7]=d.useState(()=>{try{let v=localStorage.getItem(Xt);if(v==="separate"||v==="in-inspector")return v}catch{}return"separate"}),[CJ,s9]=d.useState(!1),[R7,L5]=d.useState([]),[BY,G7]=d.useState(0),[FY,sX]=d.useState(!1),[k7,gq]=d.useState(!1),[tX,O7]=d.useState(!1),[ZQ,j9]=d.useState(1),[m9,HQ]=d.useState(216),[ZX,LZ]=d.useState(null),[NY,DZ]=d.useState([]),[mq,OZ]=d.useState([]),[qQ,LY]=d.useState(0),j6=d.useMemo(()=>{if(!R7.length)return null;return(R7.find((j)=>j.durationInFrames===qQ)??R7[0]).id},[R7,qQ]),D5=d.useRef(null);d.useEffect(()=>{D5.current=j6},[j6]);let KW=d.useRef(0);d.useEffect(()=>{KW.current=BY},[BY]);let[i6,uq]=d.useState(null),lq=d.useRef(null);d.useEffect(()=>{lq.current=i6},[i6]);let[_X,UW]=d.useState(!1),[dq,O5]=d.useState(!1),[zQ,EX]=d.useState(!1),VW=d.useRef(_X);d.useEffect(()=>{if(VW.current=_X,_X){EX(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let M5=d.useCallback(()=>{if(!VW.current||document.hidden)EX(!0),Qt("Claude finished","Your assistant turn is ready in Maude.")},[]),MZ=d.useRef(0),DY=d.useCallback(()=>{if(!VW.current||document.hidden){EX(!0);let v=Date.now();if(v-MZ.current<QV0)return;MZ.current=v,Qt("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[KQ,w5]=d.useState("inspect"),[SJ,A5]=d.useState(null),_5=d.useRef({undo:[],redo:[]}),[pq,$J]=d.useState(0),[p9,t9]=d.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=d.useRef(p9);d.useEffect(()=>{OY.current=p9;try{localStorage.setItem("maude-auto-open-inspector",p9?"1":"0")}catch{}},[p9]);let eX=d.useRef(!1);d.useEffect(()=>{eX.current=c6||Y8||n||_X},[c6,Y8,n,_X]);let UQ=d.useRef({open:{},side:vq});UQ.current={open:{tree:i8,layers:UY,inspector:c6,comments:Y8,changes:n,assistant:_X},side:b6};let bJ=d.useCallback((v,j)=>{if(v==="tree")S6(j);else if(v==="layers")GQ(j);else if(v==="inspector")WQ(j);else if(v==="comments")P8(j);else if(v==="changes")V0(j);else if(v==="assistant")UW(j)},[]),BW=d.useCallback((v)=>UQ.current.side?.[v]||vq[v],[]),a7=d.useCallback((v)=>{let j=BW(v);bJ(v,!0);for(let Q0 of yP)if(Q0.id!==v&&BW(Q0.id)===j)bJ(Q0.id,!1)},[bJ,BW]),jJ=d.useCallback((v)=>{if(UQ.current.open?.[v])bJ(v,!1);else a7(v)},[a7,bJ]),HX=a7,D6=jJ,PX=d.useCallback((v)=>{if(!OY.current)return;if(!v||!v.id)return;if(eX.current)return;HX("inspector"),w5("css")},[HX]),MY=d.useCallback(()=>s9((v)=>!v),[]),E5=$v(vP),qX=Dv(),[cq,FW]=d.useState(!1),[wZ,AZ]=d.useState(!1);d.useEffect(()=>{if(!d8())return;let v=!0;return Zf().then((j)=>{if(!v)return;if(FW(!!j),!j&&!NZ(cs,!1))AZ(!0)}).catch(()=>{}),()=>{v=!1}},[]);let _Z=d.useCallback(()=>{AZ(!1);try{localStorage.setItem(cs,"1")}catch{}},[]),[NW,EZ]=d.useState(null);d.useEffect(()=>{if(!d8())return;let v;return Kf((j)=>EZ(j&&typeof j==="object"?j:{})).then((j)=>{v=j}).catch(()=>{}),()=>{try{v?.()}catch{}}},[]);let[P5,PZ]=d.useState(null),[LW,iq]=d.useState(()=>!NZ(ps,!1)),yJ=d.useCallback((v)=>{PZ(Array.isArray(v)&&v.length?v:null)},[]),oq={setup:(v)=>{if(!v)return;if((v.canvas||v.requireSelection)&&W.length===0)a7("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(v.inspector||v.tab||v.requireSelection)HX("inspector");if(v.tab)w5(v.tab);if(v.changes)HX("changes")}},DW=d.useCallback(()=>{iq(!1);try{localStorage.setItem(ps,"1")}catch{}},[]),[R5,RZ]=d.useState(()=>NZ(ts,!0)),[kZ,nq]=d.useState(!1),[zX,wY]=d.useState(()=>NZ(as,!1)),[KX,TZ]=d.useState(()=>NZ(ss,!1)),[o6,VQ]=d.useState(!1),[OW,y6]=d.useState(!1),[rq,k5]=d.useState(0),[MW,aq]=d.useState(null),[sq,IZ]=d.useState(!1),fJ=d.useRef(null),T5=d.useRef(null),y8=d.useRef(new Map),K8=d.useCallback((v)=>{let j=Z?y8.current.get(Z):null;if(!j||!j.contentWindow)return;try{j.contentWindow.postMessage(v,"*")}catch{}},[Z]),wW=d.useCallback((v,j)=>K8({dgn:"photo-preview",asset:v,edit:j}),[K8]),tq=d.useCallback((v,j,Q0)=>{_5.current.undo.push({asset:v,before:j,after:Q0}),_5.current.redo.length=0},[]),AW=d.useCallback((v)=>{let j=v?_5.current.redo:_5.current.undo;if(!j.length)return!1;let Q0=j.pop();(v?_5.current.undo:_5.current.redo).push(Q0);let Z0=(v?Q0.after:Q0.before)||{};return wW(Q0.asset,Z0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(Q0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z0)}).catch(()=>{}),$J((W0)=>W0+1),!0},[wW]),eq=d.useCallback(async(v)=>{K8({dgn:"photo-busy",asset:v,busy:!0});try{let j=await fetch(`/${v.replace(/^\/+/,"")}`);if(!j.ok)return null;let Q0=await j.blob(),{removeBackground:Z0}=await Promise.resolve().then(() => (ds(),ls)),W0=await Z0(Q0),f0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":W0.type||"image/png"},body:W0}),l=await f0.json().catch(()=>({}));if(f0.ok&&l.path)return{maskAsset:l.path};return null}catch(j){return console.error("[photo] background removal failed",j),null}finally{K8({dgn:"photo-busy",asset:v,busy:!1})}},[K8]);d.useEffect(()=>{let v=(Z0)=>Array.from(Z0.dataTransfer?.types??[]).includes("Files"),j=(Z0)=>{if(v(Z0))Z0.preventDefault()},Q0=(Z0)=>{if(v(Z0))Z0.preventDefault()};return document.addEventListener("dragover",j),document.addEventListener("drop",Q0),()=>{document.removeEventListener("dragover",j),document.removeEventListener("drop",Q0)}},[]);let BQ=d.useRef({});BQ.current={open:CJ,comps:R7,frame:BY,total:qQ,playing:FY,compId:j6,muted:tX,loop:k7,sequences:NY,post:K8,canvas:Z};let FQ=d.useRef({undo:[],redo:[]}),vJ=d.useCallback((v,j,Q0)=>{if(typeof j!=="number")return;if(FQ.current.undo.push({canvas:v,seq:j,label:Q0}),FQ.current.redo=[],FQ.current.undo.length>50)FQ.current.undo.shift()},[]),xJ=d.useCallback((v)=>{let j=FQ.current,Q0=v==="undo"?j.undo:j.redo,Z0=v==="undo"?j.redo:j.undo,W0=BQ.current.canvas,f0=-1;for(let D0=Q0.length-1;D0>=0;D0--)if(Q0[D0].canvas===W0){f0=D0;break}if(f0<0){l9(v==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let l=Q0[f0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:l.canvas,seq:l.seq,dir:v})}).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{if(Q0.splice(f0,1),D0?.ok)Z0.push(l),l9(`${v==="undo"?"Undid":"Redid"}: ${l.label}`,!0);else l9(`${v==="undo"?"Undo":"Redo"} skipped: ${D0?.error||"failed"}`)}).catch(()=>l9(`${v==="undo"?"Undo":"Redo"} failed: network error`))},[]);d.useEffect(()=>{let v=(j)=>{let Q0=BQ.current;if(!Q0.open||!Q0.comps?.length)return;let Z0=j.target,W0=Z0?.tagName;if(W0==="INPUT"||W0==="TEXTAREA"||W0==="SELECT"||Z0?.isContentEditable)return;let f0=Q0.comps[0]?.fps||30,l=Math.max(1,Q0.total),D0=(v0)=>{let B8=Math.max(0,Math.min(l-1,Math.round(v0)));G7(B8),sX(!1),Q0.post({dgn:"timeline-seek",frame:B8,id:Q0.compId})},k0=()=>{let v0=new Set([0,l-1]);for(let B8 of Q0.sequences||[]){v0.add(B8.from);for(let w8 of B8.keyframes||[])v0.add(w8.from),v0.add(w8.to)}return[...v0].filter((B8)=>B8>=0&&B8<l).sort((B8,w8)=>B8-w8)};if((j.metaKey||j.ctrlKey)&&(j.key==="z"||j.key==="Z")){j.preventDefault(),xJ(j.shiftKey?"redo":"undo");return}if(j.key===" "||j.code==="Space")if(j.preventDefault(),Q0.playing)sX(!1),Q0.post({dgn:"timeline-pause",id:Q0.compId});else sX(!0),Q0.post({dgn:"timeline-mute",muted:Q0.muted,id:Q0.compId}),Q0.post({dgn:"timeline-loop",loop:Q0.loop,id:Q0.compId}),Q0.post({dgn:"timeline-play",id:Q0.compId});else if(j.key==="ArrowRight")j.preventDefault(),D0(Q0.frame+(j.shiftKey?f0:1));else if(j.key==="ArrowLeft")j.preventDefault(),D0(Q0.frame-(j.shiftKey?f0:1));else if(j.key==="Home")j.preventDefault(),D0(0);else if(j.key==="End")j.preventDefault(),D0(l-1);else if(j.key==="."){j.preventDefault();let v0=k0().find((B8)=>B8>Q0.frame);if(v0!=null)D0(v0)}else if(j.key===","){j.preventDefault();let v0=k0().reverse().find((B8)=>B8<Q0.frame);if(v0!=null)D0(v0)}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]),d.useEffect(()=>{L5([]),G7(0),sX(!1);let v=setTimeout(()=>K8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(v)},[Z,K8]);let[s7,AY]=d.useState(""),[CZ,_W]=d.useState([]);d.useEffect(()=>{if(!CJ||R7.length===0||!Z||Z===l8){AY(""),_W([]);return}let v=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((j)=>j.ok?j.json():null).then((j)=>{if(v&&j?.ok&&typeof j.source==="string")AY(j.source)}).catch(()=>{}),()=>{v=!1}},[CJ,R7,Z]),d.useEffect(()=>{if(!CJ||!Z||Z===l8||!s7){_W([]);return}let v=!0,j=i6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${j?`&artboardId=${encodeURIComponent(j)}`:""}`;return fetch(Q0).then((Z0)=>Z0.ok?Z0.json():null).then((Z0)=>{if(!v)return;let W0=Z0?.ok&&Array.isArray(Z0.clips)?Z0.clips.filter((f0)=>f0.kind==="sequence"):[];_W(W0)}).catch(()=>{}),()=>{v=!1}},[CJ,Z,s7,i6]),d.useEffect(()=>{if(!s7){DZ([]),OZ([]),LY(0);return}let v=R7[0]?.durationInFrames||0,j=ZX??q?.artboardId??null,Q0=ef(s7,v,j);uq(Q0.artboardId??j??null);let Z0=Q0.sequences.map((W0,f0)=>{let l=CZ[f0];if(!l)return W0;return{...W0,mediaTag:l.mediaTag??W0.mediaTag,mediaSrc:l.mediaSrc??W0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});DZ(Z0),OZ(Q0.audio||[]),LY(Q0.total)},[s7,CZ,q,R7,ZX]);let I5=d.useCallback(()=>{RZ((v)=>{let j=!v,Q0=Z?y8.current.get(Z):null;if(Q0&&Q0.contentWindow)try{Q0.contentWindow.postMessage({dgn:"view-annotations",visible:j},"*")}catch{}return j})},[Z]),G6=d.useCallback((v)=>{for(let j of y8.current.values())try{j.contentWindow.postMessage({dgn:"view-chrome",...v},"*")}catch{}},[]),_Y=d.useCallback(()=>{wY((v)=>{let j=!v;return G6({minimap:j}),j})},[G6]),EY=d.useCallback(()=>{TZ((v)=>{let j=!v;return G6({zoom:j}),j})},[G6]),EW=d.useCallback(()=>{VQ((v)=>{let j=!v;return G6({present:j}),j})},[G6]),NQ=d.useCallback(()=>{VQ(!1),G6({present:!1})},[G6]),PW=d.useCallback(()=>{if(!Z||Z===l8)return;y6((v)=>{let j=!v;return K8({dgn:"view-chrome",print:j}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:j}}})}).catch(()=>{}),j})},[Z,K8]);d.useEffect(()=>{let v=!1;return fetch("/_api/git-user").then((j)=>j.json()).then((j)=>{if(v)return;let Q0=j&&typeof j.name==="string"?j.name.trim():"";if(Q0)aq(Q0)}).catch(()=>{}),()=>{v=!0}},[]),d.useEffect(()=>{if(!Z||Z===l8){k5(0),y6(!1);return}let v=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((j)=>j.json()).then((j)=>{if(v)return;let Q0=Array.isArray(j?.artboards)?j.artboards.length:0;k5(Q0),y6(j?.overlays?.print===!0),RW(new Set(Array.isArray(j?.locked)?j.locked:[]))}).catch(()=>{if(!v)k5(0),y6(!1),RW(new Set)}),()=>{v=!0}},[Z]),d.useEffect(()=>{if(!Z||Z===l8||!ZX)return;let v=setTimeout(()=>{K8({dgn:"request-layers",artboardId:ZX})},250);return()=>clearTimeout(v)},[Z,ZX,K8]);let[LQ,RW]=d.useState(()=>new Set),kW=d.useCallback((v)=>{if(!Z||Z===l8)return;RW((j)=>{let Q0=new Set(j);if(Q0.has(v))Q0.delete(v);else Q0.add(v);let Z0=[...Q0];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:Z0}})}).catch(()=>{}),K8({dgn:"locked-set",locked:Z0}),Q0})},[Z,K8]);d.useEffect(()=>{if(!Z||Z===l8)return;K8({dgn:"locked-set",locked:[...LQ]})},[LQ,Z,K8]),d.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",E0),localStorage.setItem(Rt,E0)}catch{}for(let v of y8.current.values())try{v.contentWindow.postMessage({dgn:"theme",theme:E0},"*")}catch{}},[E0]),d.useEffect(()=>{try{localStorage.setItem(rs,i8?"1":"0")}catch{}},[i8]),d.useEffect(()=>{try{localStorage.setItem(is,r9?"1":"0")}catch{}},[r9]),d.useEffect(()=>{try{localStorage.setItem(os,JSON.stringify($6))}catch{}},[$6]),d.useEffect(()=>{try{localStorage.setItem(as,zX?"1":"0")}catch{}},[zX]),d.useEffect(()=>{try{localStorage.setItem(ss,KX?"1":"0")}catch{}},[KX]),d.useEffect(()=>{try{localStorage.setItem(ts,R5?"1":"0")}catch{}},[R5]),d.useEffect(()=>{let v=!1;return fetch("/_api/ui-prefs").then((j)=>j.ok?j.json():Promise.reject(Error(`HTTP ${j.status}`))).then((j)=>{if(v||!j||typeof j!=="object")return;if(j.theme==="light"||j.theme==="dark")p0(j.theme);if(typeof j.minimap==="boolean")wY(j.minimap);if(typeof j.zoom==="boolean")TZ(j.zoom);if(typeof j.annotations==="boolean")RZ(j.annotations);if(typeof j.autoOpenInspector==="boolean")t9(j.autoOpenInspector);if(j.panelSides&&typeof j.panelSides==="object")VY({...vq,...j.panelSides});if(j.layersMode==="separate"||j.layersMode==="in-inspector")f7(j.layersMode)}).catch(()=>{}).finally(()=>{if(!v)nq(!0)}),()=>{v=!0}},[]),d.useEffect(()=>{if(!kZ)return;YV0({theme:E0,minimap:zX,zoom:KX,annotations:R5,autoOpenInspector:p9,panelSides:b6,layersMode:GX})},[kZ,E0,zX,KX,R5,p9,b6,GX]),d.useEffect(()=>{try{localStorage.setItem(es,JSON.stringify(b6))}catch{}},[b6]),d.useEffect(()=>{try{localStorage.setItem(Xt,GX)}catch{}},[GX]);let Xz=d.useCallback((v,j)=>{D7((Q0)=>{let Z0=Q0[v],W0=Z0===void 0?j:Z0;return{...Q0,[v]:!W0}})},[]),DQ=d.useCallback(()=>{p0((v)=>v==="dark"?"light":"dark")},[]),$9=d.useCallback(async()=>{try{let j=await(await fetch("/_index-data")).json();Y(j.project||"Design");let Q0=j.groups.map((Z0)=>({...Z0,tree:zV0(Z0.paths,Z0.stripPrefix,Z0.dirs)}));J(Q0),B0((Z0)=>({...Z0,canvasDesignSystems:j.canvasDesignSystems??{},canvasKinds:j.canvasKinds??{}}))}catch(v){console.error("failed to load tree",v)}},[]);d.useEffect(()=>{$9()},[$9]);let G0=d.useCallback(async(v)=>{try{let j=v?`/_system-data?ds=${encodeURIComponent(v)}`:"/_system-data",Q0=await fetch(j);if(!Q0.ok){console.error("failed to load system-data",Q0.status);return}let Z0=await Q0.json();if(!v&&Z0?.defaultDesignSystem&&!Z0.ds){Z8(Z0);let W0=await fetch(`/_system-data?ds=${encodeURIComponent(Z0.defaultDesignSystem)}`);if(W0.ok)Z8(await W0.json());return}Z8(Z0)}catch(j){console.error("failed to load system-data",j)}},[]),SZ=d.useCallback(async()=>{try{let j=await(await fetch("/_comments-all")).json();H0(j||{})}catch(v){console.error("failed to load comments",v)}},[]);d.useEffect(()=>{SZ()},[SZ]),d.useEffect(()=>{function v(){let j=location.protocol==="https:"?"wss:":"ws:",Q0=new WebSocket(j+"//"+location.host+"/_ws");T5.current=Q0,Q0.addEventListener("open",()=>p(!0)),Q0.addEventListener("close",()=>{p(!1),setTimeout(v,1000)}),Q0.addEventListener("error",()=>{}),Q0.addEventListener("message",(Z0)=>{try{let W0=JSON.parse(Z0.data);if(W0.type==="snapshot"&&W0.state)K((f0)=>At(W0.state.selected,f0));else if(W0.type==="selected"){if(Date.now()-L.current<2000)return;let f0=W0.selected,l=Array.isArray(f0)?f0[0]:f0,D0=V.current,k0=Array.isArray(D0)?D0[0]:D0;if(K((v0)=>At(f0,v0)),l?.id&&l.file&&(!k0||k0.id!==l.id||k0.file!==l.file))w(l)}else if(W0.type==="comments"&&typeof W0.file==="string")H0((f0)=>({...f0,[W0.file]:W0.comments||[]}));else if(W0.type==="ai-activity"&&typeof W0.file==="string"){if(IZ(!0),fJ.current)clearTimeout(fJ.current);fJ.current=setTimeout(()=>IZ(!1),8000);for(let f0 of y8.current.values())try{f0.contentWindow.postMessage({dgn:"ai-activity",file:W0.file,entry:W0.entry},"*")}catch{}}else if(W0.type==="export:job"&&W0.payload)qX.upsert(W0.payload);else if(W0.type==="sync:status"&&W0.payload)X0(W0.payload);else if(W0.type==="canvas-list-update"){if($9(),W0.payload?.action==="moved"&&W0.payload.fromRel&&W0.payload.rel){let f0=(b0?.designRel||b0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${f0}/${W0.payload.fromRel}`,D0=`${f0}/${W0.payload.rel}`;G((k0)=>k0.map((v0)=>v0.path===l?{path:D0}:v0)),H((k0)=>k0===l?D0:k0)}}else if(W0.type==="config-updated")K0();else if(W0.type==="acp-focus"){if(d8())HX("assistant")}else if(W0.type==="git-status"&&W0.payload)U0(W0.payload);else if(W0.type==="git-lifecycle"&&W0.payload){h(W0.payload);for(let f0 of y8.current.values())try{f0.contentWindow.postMessage({dgn:"git-lifecycle",payload:W0.payload},"*")}catch{}}}catch{}})}return v(),()=>T5.current&&T5.current.close()},[$9,K0]);function M7(v){let j=T5.current;try{if(j&&j.readyState===1)j.send(JSON.stringify(v))}catch{}}let f6=d.useCallback(async()=>{try{let v=await fetch("/_api/git/status");if(v.ok)U0(await v.json())}catch{}},[]),t7=d.useCallback(async()=>{try{let v=await fetch("/_api/git/status?remote=1");if(!v.ok)return;let j=await v.json();if(j&&j.repo!==!1)u({remoteAhead:!!j.remoteAhead,behind:j.behind||0})}catch{}},[]),A9=d.useCallback(async(v,j)=>{try{let Q0=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j||{})}),Z0=await Q0.json().catch(()=>({}));return{ok:Q0.ok,...Z0}}catch(Q0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),hJ=d.useCallback(async(v,j)=>{let Q0=await A9("/_api/git/commit",{message:v,files:j});if(Q0.ok)await f6();return Q0},[A9,f6]),C5=d.useCallback(async(v)=>{let j=await A9("/_api/git/discard",{files:v});if(j.ok)await f6();return j},[A9,f6]),TW=d.useCallback(async()=>{let v=await A9("/_api/git/push",{});if(v.ok)await f6(),t7();return v},[A9,f6,t7]),PY=d.useCallback(async()=>{let v=await A9("/_api/git/pull",{});if(v.ok)await f6(),t7();if(v.conflict&&Array.isArray(v.files)&&v.files.length)J8({file:v.files[0],conflict:!0});return v},[A9,f6,t7]),IW=d.useCallback(async(v)=>{let j=await A9("/_api/git/resolve",{choice:v});if(j.ok)await f6(),t7();return j},[A9,f6,t7]),S5=d.useCallback(async(v)=>{try{let j="/_api/git/log?limit=40"+(v?`&path=${encodeURIComponent(v)}`:""),Q0=await fetch(j);if(!Q0.ok)return[];return(await Q0.json()).entries||[]}catch{return[]}},[]),CW=d.useMemo(()=>{let v={modified:"M",added:"A",deleted:"D",untracked:"U"},j=new Map;for(let Q0 of o?.files||[])j.set(Q0.path,v[Q0.status]);return j},[o]),RY=o?.files?.length||0;d.useEffect(()=>{if(o?.repo===!1)return;t7();let v=setInterval(t7,n?60000:120000);return()=>clearInterval(v)},[o?.repo,n,t7]);let h0=d.useCallback((v)=>{if(G((j)=>{for(let Q0 of j)if(Q0.path!==v)y8.current.delete(Q0.path);return[{path:v}]}),H(v),N0(null),v!==l8)p8(v)},[]),Z6=d.useCallback((v)=>{let j=typeof v==="string"?v:void 0;if(j)G0(j);else if(!F8)G0();h0(l8)},[F8,G0,h0]);d.useEffect(()=>{M7({type:"tabs",tabs:W.map((v)=>v.path).filter((v)=>v!==l8)})},[W]),d.useEffect(()=>{if(Z&&Z!==l8)M7({type:"active",file:Z});else if(Z===l8)M7({type:"active",file:""});else M7({type:"active",file:""})},[Z]);let OQ=d.useCallback((v)=>{G((j)=>{let Q0=j.findIndex((W0)=>W0.path===v);if(Q0<0)return j;let Z0=j.filter((W0)=>W0.path!==v);if(v===Z)if(Z0.length===0)H(null);else H(Z0[Math.max(0,Q0-1)].path);return Z0}),y8.current.delete(v),p8((j)=>j===v?null:j)},[Z]),x0=d.useCallback(()=>{if(!Z||Z===l8){if(Z===l8)G0();return}let v=y8.current.get(Z);if(v)v.src=v.src},[Z,G0]),$5=d.useCallback(()=>$9(),[$9]),[u0,kY]=d.useState(!1),MQ=d.useRef(!1),wQ=d.useCallback(async()=>{if(MQ.current)return;MQ.current=!0,kY(!0);try{await Promise.all([$9(),new Promise((v)=>setTimeout(v,550))])}finally{MQ.current=!1,kY(!1)}},[$9]);d.useEffect(()=>{let v=null,j=()=>{if(v)clearTimeout(v);v=setTimeout(()=>{v=null,$5()},150)};return window.addEventListener("focus",j),()=>{if(window.removeEventListener("focus",j),v)clearTimeout(v)}},[$5]);let SW=d.useCallback(async(v)=>{try{let j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v,kind:"brief-board"})}),Q0=await j.json().catch(()=>({}));if(!j.ok||!Q0.ok)return{ok:!1,error:Q0.error||`create failed (${j.status})`};return await $9(),h0(Q0.file),{ok:!0,file:Q0.file}}catch(j){return{ok:!1,error:j instanceof Error?j.message:"network error"}}},[$9,h0]),$W=d.useCallback(async()=>{if(!Z||Z===l8)return;try{let v=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),j=v.ok?await v.text():"",Q0=[];if(j){let D0=new DOMParser().parseFromString(j,"image/svg+xml");for(let k0 of D0.querySelectorAll('[data-tool="mediaref"]')){let v0=k0.getAttribute("data-src");if(!v0)continue;Q0.push({src:v0,mediaKind:k0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Q0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let W0=`${zW(TF(Z)).replace(/\.tsx$/i,"")} Video`,f0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W0,kind:"video-comp",clips:Q0})}),l=await f0.json().catch(()=>({}));if(!f0.ok||!l.ok){window.alert(`Assemble failed: ${l.error||`error ${f0.status}`}`);return}await $9(),h0(l.file)}catch(v){window.alert(`Assemble failed: ${v instanceof Error?v.message:"network error"}`)}},[Z,$9,h0]),AQ=d.useCallback(({accept:v,resolveTarget:j})=>{let Q0=Z,Z0=i6||void 0,W0=document.createElement("input");W0.type="file",W0.accept=v,W0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(W0);let f0=()=>{if(W0.isConnected)W0.remove()};window.addEventListener("focus",()=>setTimeout(f0,300),{once:!0}),W0.addEventListener("change",()=>{let l=W0.files?.[0];if(f0(),!l)return;let D0=`/_api/comp-clips?canvas=${encodeURIComponent(Q0)}${Z0?`&artboardId=${encodeURIComponent(Z0)}`:""}`;fetch(D0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let v0=j(k0);if(!v0)return l9("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":l.type||"application/octet-stream"},body:l}).then((B8)=>B8.json().catch(()=>({}))).then((B8)=>{if(!B8?.path)return l9(`Upload failed: ${B8?.error||"unknown error"}`),null;if(v0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,arrayName:v0.arrayRef.arrayName,index:v0.arrayRef.index,field:v0.arrayRef.field,value:B8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,id:v0.cdId,attr:"src",value:B8.path})})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)l9(`Replace refused: ${k0.error||"failed"}`);else if(k0&&k0.ok){if(l9("Media replaced.",!0),k0.seq!=null)vJ(Q0,k0.seq,"replace media")}}).catch(()=>l9("Replace failed: network error"))}),W0.click()},[Z,i6,vJ]),_Q=d.useCallback(async(v,j)=>{if(!window.confirm(`Move “${j}” to trash?
5654
5654
 
5655
5655
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let Z0=await fetch(`/_api/canvas?file=${encodeURIComponent(v)}`,{method:"DELETE"}),W0=await Z0.json().catch(()=>({}));if(!Z0.ok||!W0.ok){window.alert(`Could not delete: ${W0.error||`error ${Z0.status}`}`);return}if(await $9(),Z===v)G([]),H(null)}catch(Z0){window.alert(`Delete failed: ${Z0 instanceof Error?Z0.message:"network error"}`)}},[$9,Z]),bW=d.useCallback(async function v(j,Q0){try{let Z0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j,toDir:Q0})}),W0=await Z0.json().catch(()=>({}));if(!Z0.ok||!W0.ok)return l9(`Could not move: ${W0.error||`error ${Z0.status}`}`),{ok:!1,error:W0.error};let f0=(b0?.designRel||b0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${f0}/${W0.fromRel}`,D0=`${f0}/${W0.toRel}`;await $9(),G((v0)=>v0.map((B8)=>B8.path===l?{path:D0}:B8)),H((v0)=>v0===l?D0:v0);let k0=l.split("/").slice(0,-1).join("/");return l9(`Moved to ${W0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{v(D0,k0)}}),{ok:!0}}catch(Z0){return l9(`Move failed: ${Z0 instanceof Error?Z0.message:"network error"}`),{ok:!1,error:"network error"}}},[$9,b0]),jW=d.useCallback(async(v,j)=>{try{let Q0=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:v,name:j})}),Z0=await Q0.json().catch(()=>({}));if(!Q0.ok||!Z0.ok){let W0=Z0.error||`error ${Q0.status}`;return l9(`Could not create folder: ${W0}`),{ok:!1,error:W0}}return await $9(),{ok:!0,dir:Z0.dir}}catch(Q0){let Z0=Q0 instanceof Error?Q0.message:"network error";return l9(`Create folder failed: ${Z0}`),{ok:!1,error:Z0}}},[$9]),yW=d.useCallback(async(v,j)=>{if(!window.confirm(`Delete folder "${j}"?
5656
5656