@1agh/maude 0.52.0 → 0.52.2

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 @@ ${F.block}`:B,D=[],M=new Map;for await(let A of X.prompt(L,J(),z,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: \`${d?.dir??".design/_reports/"}\` (attach its files here)`),a=`${vZ0}?title=${l}&body=${h}&labels=report`;if(l8())try{await L1(a)}catch{window.open(a,"_blank","noopener")}else window.open(a,"_blank","noopener");P({fallbackDir:d?.dir??null}),Y("done")}catch{R("Saving the local bundle failed too — please file the issue by hand.")}}let g=W.trim().length>0;return K("div",{className:"st-scrim",onClick:b,"data-testid":"report-bug-dialog",children:_("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(m)=>m.stopPropagation(),children:[_("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),K("button",{type:"button",className:"st-iconbtn",onClick:b,"aria-label":"Close",children:"×"})]}),_("div",{className:"st-dialog-bd rb-body",children:[Q==="describe"&&_(Y0,{children:[K("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),K("textarea",{id:"rb-desc",className:"textarea","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…"}),K("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),_("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:b,children:"Cancel"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!g,onClick:()=>Y("preview"),children:"Review & attach"})]})]}),Q==="preview"&&_(Y0,{children:[_("div",{className:"rb-section",children:[_("div",{className:"rb-section-hd",children:[_("span",{children:["Screenshots (",z.length,")"]}),z.length>0&&K("button",{type:"button",className:`rb-link${M?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>A((m)=>!m),children:M?"Done redacting":"Redact…"})]}),z.length===0?_("p",{className:"rb-hint",children:["No screenshot attached. Paste one (⌘V) to add it — up to ",V_,"."]}):_(Y0,{children:[M&&K("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),K("div",{className:"rb-shots",children:z.map((m,p)=>K(gZ0,{shot:m,redacting:M,onRects:(f)=>U((d)=>d.map((l,h)=>h===p?{...l,rects:f}:l)),onRemove:()=>{URL.revokeObjectURL(m.url),U((f)=>f.filter((d,l)=>l!==p))}},m.url))}),z.length<V_&&K("p",{className:"rb-hint",children:"Paste (⌘V) to attach another screenshot."})]})]}),_("div",{className:"rb-section",children:[K("div",{className:"rb-section-hd",children:K("span",{children:"Included with the report"})}),_("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:!0,disabled:!0}),_("span",{children:["Maude ",Z?.app?.maudeVersion??"…"," · ",Z?.app?.platform??"…"," ",Z?.app?.arch??""," · ",l8()?"desktop app":"browser"]})]}),Z?.context?.activeCanvas&&_("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:L.activeCanvas,onChange:(m)=>D({...L,activeCanvas:m.target.checked})}),_("span",{children:["Active canvas path — ",K("code",{children:Z.context.activeCanvas})]})]}),Z?.context?.projectName&&_("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:L.projectName,onChange:(m)=>D({...L,projectName:m.target.checked})}),_("span",{children:["Project name — ",K("code",{children:Z.context.projectName})]})]}),Z?.logs?.serverLogTail?_("label",{className:"rb-check",children:[K("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:L.logTail,onChange:(m)=>D({...L,logTail:m.target.checked})}),_("span",{children:["Recent server log (",Z.logs.serverLogTail.split(`
5653
- `).length," lines, paths & secrets scrubbed) —"," ",_("details",{className:"rb-details",children:[K("summary",{children:"view"}),K("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,l8()&&B.length>0&&_("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:L.crashLogs,onChange:(m)=>D({...L,crashLogs:m.target.checked})}),_("span",{children:["Crash logs (",B.length,") — ",K("code",{children:B.map((m)=>m.name).join(", ")})]})]})]}),_("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",K("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),_("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("describe"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:y,children:"Send report"})]})]}),Q==="sending"&&K("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&_(Y0,{children:[I?.issueUrl?_("p",{children:["Thank you — your report is filed as"," ",_("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(l8())L1(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):_("p",{children:["The bundle is saved locally",I?.fallbackDir?_(Y0,{children:[" ","at ",K("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),K("footer",{className:"rb-actions",children:K("button",{type:"button",className:"st-btn rb-primary",onClick:b,children:"Done"})})]}),Q==="fallback"&&_(Y0,{children:[K("p",{className:"rb-error","data-testid":"report-bug-error",children:w}),K("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."}),_("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("preview"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary",onClick:v,children:"Save locally & open GitHub"})]})]})]})]})})}var xX=P8(S8(),1);function Vx(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 qx(X,J){let Q=Vx(X),Y=Vx(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 Bx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||qx(Q.version,J)))}function Nx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&qx(Y.version,Q))Q=Y.version}return Q}var q_="mdcc-whatsnew-seen",B_="mdcc-whatsnew-toast-dismissed";function mZ0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function uZ0(X){try{let J=localStorage.getItem(q_);if(J)return J;localStorage.setItem(q_,X)}catch{}return X}function lZ0(){try{return localStorage.getItem(B_)}catch{return null}}function Fx(X){let[J,Q]=xX.useState([]),[Y,W]=xX.useState(X),[G,Z]=xX.useState(()=>uZ0(X)),[H,z]=xX.useState(()=>lZ0()),[U,B]=xX.useState(!1);xX.useEffect(()=>{let w=!1,R=()=>{fetch("/_api/whats-new").then((b)=>b.json()).then((b)=>{if(w)return;if(Q(Array.isArray(b?.entries)?b.entries:[]),typeof b?.version==="string")W(b.version)}).catch(()=>{})};R();let T=()=>R(),C=()=>{if(document.visibilityState==="visible")R()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",C),()=>{w=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",C)}},[]);let F=Bx(J,G),L=F.length>0&&H!==Y&&!U,D=F[0]??null,M=xX.useCallback(()=>{let w=Nx(J,Y);Z(w),z(Y);try{localStorage.setItem(q_,w),localStorage.setItem(B_,Y)}catch{}},[J,Y]),A=xX.useCallback(()=>{z(Y);try{localStorage.setItem(B_,Y)}catch{}},[Y]),I=xX.useCallback(()=>B(!0),[]),P=xX.useCallback(()=>{B(!1),M()},[M]);return{entries:J,unseen:F,feedVersion:Y,panelOpen:U,openPanel:I,closePanel:P,showToast:L,toastEntry:D,dismissToast:A,markAllSeen:M}}function Lx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),_("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Dx({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(xX.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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:_("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[_("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>_("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[_("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),mZ0(G.learnMore)&&K("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&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var h9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Tt="mdcc-usage-tour-seen",Ct="mdcc-collab-tour-seen",T8="__system__",Ke="mdcc-theme",$t="mdcc-show-hidden",St="mdcc-sections-expanded",bt="maude-cp-mode",jt="mdcc-sidebar-open",yt="mdcc-minimap-visible",ft="mdcc-zoomctl-visible",vt="mdcc-annotations-visible";var sV0=30000;function tV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var WR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],tz={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},xt="mdcc-panel-sides",ht="mdcc-layers-mode";function gt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return _("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(WR.find((z)=>z.id===H)||{}).label||H},H))}),Z]})}var AQ=/\.(tsx|html?)$/i;function mN(X){return X.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var ZR="0.51.1";function mt(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function eV0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Ke);if(X==="light"||X==="dark")return X}catch{}return"dark"}function RZ(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 eP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function Xq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function dN(X){return X.split("/").pop()}function A8(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(A8._t),A8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var ut="maude-browse-hint-seen";function Jq0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(ut)==="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(ut,"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 BW(X){return X.replace(AQ,"")}function Qq0(X){return X.replace(AQ,"")}function Yq0(X){let J=new Map;for(let G of X){if(!AQ.test(G.name))continue;let Z=Qq0(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(AQ.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((z,U)=>z.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function Wq0(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 z of Z)H=H[z]=H[z]||{};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 z=0;z<Z.length;z++){let U=Z[z];if(z===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function Ue(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=Ue(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 lt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Gq0(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 Ve(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 uN({d:X,size:J=14,color:Q}){return K("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:K("path",{d:X})})}var Zq0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:_(Y0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":_(Y0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),K("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:_(Y0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:_(Y0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:_(Y0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:_(Y0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:_(Y0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("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:_(Y0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:_(Y0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:_(Y0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:_(Y0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:_(Y0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:_(Y0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:_(Y0,{children:[K("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"}),K("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:_(Y0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:_(Y0,{children:[K("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"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:_(Y0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":_(Y0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":_(Y0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("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":_(Y0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":_(Y0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("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":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":_(Y0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":_(Y0,{children:[K("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"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:_(Y0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:_(Y0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:_(Y0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:_(Y0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:_(Y0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:_(Y0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:_(Y0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:_(Y0,{children:[K("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"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function Hq0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let z=u.useMemo(()=>{let B=Y.trim().toLowerCase();if(!B)return Q;return Q.filter((F)=>F.label.toLowerCase().includes(B)||F.group&&F.group.toLowerCase().includes(B))},[Y,Q]);if(u.useEffect(()=>{if(G>=z.length)Z(0)},[z.length,G]),!X)return null;let U=(B)=>{J(),B.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(B)=>{if(B.target===B.currentTarget)J()},children:_("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[_("div",{className:"st-pal-search",children:[K(W9,{name:"search",size:18}),K("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(B)=>W(B.target.value),onKeyDown:(B)=>{if(B.key==="Escape")B.preventDefault(),J();else if(B.key==="ArrowDown")B.preventDefault(),Z((F)=>Math.min(z.length-1,F+1));else if(B.key==="ArrowUp")B.preventDefault(),Z((F)=>Math.max(0,F-1));else if(B.key==="Enter"){if(B.preventDefault(),z[G])U(z[G])}}}),K(JX,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):z.map((B,F)=>{let L=B.group&&(F===0||z[F-1].group!==B.group)?K("div",{className:"st-pal-group",children:B.group},"g-"+B.group):null;return _(Y0,{children:[L,_("button",{type:"button",className:"st-pal-item"+(F===G?" is-active":""),onMouseEnter:()=>Z(F),onClick:()=>U(B),children:[K("span",{className:"st-pal-icon",children:K(W9,{name:B.icon,size:15})}),K("span",{className:"st-pal-label",children:B.label}),B.kbd?K("span",{className:"st-pal-kbd",children:K(JX,{children:B.kbd})}):null]})]},B.id)})})]})})}function W9({name:X,size:J=16,className:Q}){return K("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:Zq0[X]})}function zq0(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 dt({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function JX({children:X}){return K("span",{className:"kbd",children:X})}function pt(X,{min:J,max:Q,def:Y}){let W=u.useCallback((z)=>Math.min(Q,Math.max(J,z)),[J,Q]),[G,Z]=u.useState(()=>{try{let z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(z)?W(z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((z)=>Z((U)=>W(typeof z==="function"?z(U):z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ct({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:z,def:U}=J,B=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(F)=>{let L=F.shiftKey?24:8;if(F.key==="ArrowRight")F.preventDefault(),Z((D)=>D+L*B);else if(F.key==="ArrowLeft")F.preventDefault(),Z((D)=>D-L*B);else if(F.key==="Home")F.preventDefault(),Z(H);else if(F.key==="End")F.preventDefault(),Z(z)},children:_("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var XR=[{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}],JR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},Kq0={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"]},Uq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Jq=[{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}],Vq0="2x",it=[{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}],qq0="auto",Bq0={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 Nq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return Bq0[J]||"application/octet-stream"}function Fq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[z,U]=u.useState(!1),[B,F]=u.useState(null),[L,D]=u.useState(()=>new Set),[M,A]=u.useState({}),[I,P]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((d)=>d.json()).then((d)=>{if(!f)return;let l=d.ok?d.assets:[];H(l),A((h)=>{let a={...h};for(let s of l)a[s.path]=s.kind;return a})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(d)=>{if(d.key==="Escape")d.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let w=Array.from(L).some((f)=>(M[f]||"image")!=="image"),R=!W||w,T=!W?"No artboard on this canvas":w?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(R&&I==="artboard")P("annotation")},[R,I]);let C=(f)=>{D((d)=>{let l=new Set(d);if(l.has(f))l.delete(f);else l.add(f);return l})},b=async(f)=>{let d=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),l=await d.json().catch(()=>({}));if(d.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${d.status})`}},$=async(f)=>{if(!f)return;U(!0),F(null);let d=await b(f);if(U(!1),d.ok)J(d.path);else F(d.error)},y=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},v=async(f)=>{if(!f.length)return;U(!0),F(null);let d=await Promise.all(f.map((a)=>b(a).then((s)=>({...s,file:a}))));U(!1);let l=d.filter((a)=>a.ok),h=d.length-l.length;if(h>0)F(`${h} of ${d.length} uploads failed`);if(l.length)A((a)=>{let s={...a};for(let c of l)s[c.path]=y(c.file.type);return s}),D((a)=>{let s=new Set(a);for(let c of l)s.add(c.path);return s})},g=async()=>{U(!0),F(null);try{if(Y){let l=(await yf()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:Nq0(h.name)}));if(U(!1),l.length)await v(l);return}let f=await O1();if(f?.bytes){await $(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){F(f?.message||"open failed")}U(!1)},m=()=>{if(l8()){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 d=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(d,300),{once:!0}),f.addEventListener("change",()=>{let l=f.files?Array.from(f.files):[];if(d(),!l.length)return;if(Y)v(l);else $(l[0])}),f.click()},p=(f)=>`/${X}/${f}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:_("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[_("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(W9,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[_("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:m,disabled:z,children:z?"Uploading…":"Upload…"}),B&&K("span",{className:"st-ap-err",children:B})]}),K("div",{className:"st-ap-grid",children:Z==null?K("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let d=Y&&L.has(f.path);return _("button",{type:"button",className:"st-ap-cell","data-selected":d?"true":void 0,"aria-pressed":Y?d:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?C(f.path):J(f.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:d?K(W9,{name:"check",size:12}):null}),f.kind==="video"?K("video",{className:"st-ap-thumb",src:p(f.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:p(f.path),alt:f.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&L.size>0&&_("div",{className:"st-dialog-ft st-ap-confirm",children:[_("span",{className:"st-ap-count",children:[L.size," selected"]}),_("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="artboard",disabled:R,onClick:()=>P("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="annotation",onClick:()=>P("annotation"),children:"Add as annotation"})]}),R&&K("span",{className:"st-ap-dest-note",children:T}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(L),I),children:"Insert"})]})]})})}function Lq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[z,U]=u.useState(X==="handoff"?"shadcn":"png"),[B,F]=u.useState(J&&JR[J]?J:"artboard"),[L,D]=u.useState(2),[M,A]=u.useState(Vq0),[I,P]=u.useState(!0),[w,R]=u.useState(!1),[T,C]=u.useState(!1),[b,$]=u.useState(!1),[y,v]=u.useState(qq0),[g,m]=u.useState(!0),[p,f]=u.useState(!1),[d,l]=u.useState(null),[h,a]=u.useState([]),s=XR.find((w0)=>w0.id===z)||XR[0],c=s.handoff?[]:Kq0[s.format]||["artboard"],z0=900,e=3600,n=W[0]||null,o=n?.durationInFrames||0,V0=n?.fps||30,f0=s.temporal&&o>900,G8=s.temporal&&o>3600;u.useEffect(()=>{if(c.length&&!c.includes(B))F(c[0])},[c,B]);let X8=u.useCallback(()=>{fetch("/_api/export-history").then((w0)=>w0.json()).then((w0)=>a(Array.isArray(w0?.history)?w0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{X8()},[X8]),u.useEffect(()=>{function w0(d0){if(d0.key==="Escape")d0.preventDefault(),H()}return window.addEventListener("keydown",w0),()=>window.removeEventListener("keydown",w0)},[H]);async function a0(){if(s.handoff){let Y8=`/design:handoff ${Q&&Q!==T8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(Y8)}catch{}l({ok:!0,msg:`Copied: ${Y8} — run it in Claude Code.`});return}f(!0),l(null);let w0=s.temporal?{scale:L}:{};if(s.format==="png"){let d0=Jq.find((Y8)=>Y8.id===M)||Jq[1];if(d0.kind==="dpi")w0.dpi=d0.value;else w0.scale=d0.value}if(s.format==="mp4"||s.format==="webm")w0.audio=g;if(G8)w0.maxFrames=o;if(s.format==="pdf"){w0.pdfPrint={includeBleed:I,marks:{crop:T,registration:b}};let d0=it.find((Y8)=>Y8.id===y)?.value;if(d0!==void 0)w0.dpi=d0}if(G)w0.artboardId=G;if(Z?.selector)w0.selection=Z;try{let d0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:B,options:w0})});if(!d0.ok){l({ok:!1,msg:await d0.text()||`Export failed (${d0.status})`}),f(!1);return}H()}catch(d0){l({ok:!1,msg:d0&&d0.message?d0.message:String(d0)}),f(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(w0)=>{if(w0.target===w0.currentTarget)H()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[_("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:H,children:K(W9,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==T8?`Format · ${BW(dN(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:XR.filter((w0)=>!w0.temporal||Y).map((w0)=>_("button",{type:"button",className:"st-fmt"+(w0.id===z?" is-on":""),onClick:()=>{U(w0.id),l(null)},children:[K(W9,{name:w0.icon,size:16}),K("span",{className:"st-fmt-name",children:w0.label}),K("span",{className:"st-fmt-sub",children:w0.sub})]},w0.id))}),!s.handoff&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:B,onChange:(w0)=>F(w0.target.value),children:c.map((w0)=>K("option",{value:w0,children:JR[w0]},w0))})]}),!s.handoff&&s.format==="png"&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),K("select",{id:"st-export-size",className:"st-select",value:M,onChange:(w0)=>A(w0.target.value),children:Jq.map((w0)=>K("option",{value:w0.id,children:w0.label},w0.id))})]}),!s.handoff&&s.format==="png"&&K("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let w0=Jq.find((Y8)=>Y8.id===M)||Jq[1],d0=w0.kind==="dpi"?w0.value/96:w0.value;return`${w0.label} ≈ ${Math.round(1440*d0)}×${Math.round(900*d0)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),K("select",{id:"st-export-temporal-size",className:"st-select",value:L,onChange:(w0)=>D(Number(w0.target.value)),children:Uq0.map((w0)=>K("option",{value:w0.value,children:w0.label},w0.value))})]}),!s.handoff&&s.temporal&&_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[L,"× the artboard's native resolution (e.g. 960×540 → ",960*L,"×",540*L,")."]}),f0&&_("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",o," frames (≈",Math.round(o/V0),"s).",G8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!s.handoff&&s.format==="pdf"&&_(Y0,{children:[_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),K("select",{id:"st-export-pdf-dpi",className:"st-select",value:y,onChange:(w0)=>v(w0.target.value),children:it.map((w0)=>K("option",{value:w0.id,children:w0.label},w0.id))})]}),K("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)."}),K("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(w0)=>P(w0.target.checked)}),"Include bleed"]})}),K("div",{className:"st-dialog-row",children:_("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>R((w0)=>!w0),"aria-expanded":w,children:[w?"▾":"▸"," Marks"]})}),w&&_("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:T,onChange:(w0)=>C(w0.target.checked)}),"Crop marks"]}),_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:b,onChange:(w0)=>$(w0.target.checked)}),"Registration marks"]})]}),_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",K("code",{children:'kind="print"'}),") artboards only.",B==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&K("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:g,onChange:(w0)=>m(w0.target.checked)}),"Export with audio"]})}),s.handoff&&_("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("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."]}),d&&K("div",{className:"callout "+(d.ok?"callout--success":"callout--error"),style:{fontSize:12},children:d.msg}),h.length>0&&_("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),h.map((w0,d0)=>_("div",{className:"st-export-recent-row",children:[_("span",{children:[String(w0.format||"").toUpperCase()," ·"," ",JR[w0.scope]||w0.scope]}),K("span",{className:"st-mono",children:w0.filename})]},d0))]})]}),_("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),_("button",{type:"button",className:"btn btn--primary",disabled:p,onClick:a0,children:[K(W9,{name:"download",size:14}),s.handoff?"Copy handoff command":p?"Exporting…":`Export ${s.label}`]})]})]})})}var pN=12,cN=16;function Dq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,z]=u.useState(Q),U=G?G.dropProps(W,!0,()=>z(!0)):{},B=G?.overDir===W,F=G?G.dragProps(W,!0):{},L=G?.draggedPath===W,D=G?.busyPath===W,M=_("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${mN(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":D||void 0,tabIndex:-1,className:"st-row"+(B?" is-drop-target":"")+(L?" is-dragging":"")+(D?" is-busy":""),style:{paddingLeft:pN+J*cN+"px"},onClick:()=>z((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...F,...U,children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]});return _(Y0,{children:[Z?_("div",{className:"st-row-wrap",role:"none",children:[M,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${mN(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:K(uN,{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,H&&Y]})}function Oq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,z]=u.useState(Y);return _(Y0,{children:[_("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:pN+Q*cN+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>z((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(W9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),_("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function GR({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:z,experimentalKind:U,drag:B,menu:F}){let L=X.path===J,D=AQ.test(X.name),M=!D,A=D?BW(X.name):X.name,I=D&&typeof Y==="function"&&Z!=="runtime",P=D&&!H&&Z!=="runtime"&&typeof B<"u",w=P?B.dragProps(X.path,!0):{},R=B?.draggedPath===X.path,T=B?.busyPath===X.path,C=P&&typeof F<"u",b=X.path.split("/").slice(0,-1).join("/"),$=D?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,y=_("button",{type:"button",role:"treeitem","data-testid":$,"aria-selected":L,"aria-disabled":M?"true":void 0,"aria-busy":T||void 0,tabIndex:L?0:-1,className:"st-row"+(L?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(R?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:pN+G*cN+"px"},title:X.path+(W?` — ${W} open`:M?" (file index only)":""),onClick:()=>{if(!M)Q(X.path)},onContextMenu:C?(v)=>F.openAt(v,{kind:"file",path:X.path,dir:b}):void 0,...w,children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"file",size:13})}),K("span",{className:"st-row-name",children:A}),U==="reconstructed-experimental"&&K("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"}),z&&K("span",{className:"st-git-badge","data-kind":z,title:`Unsaved (${z})`,"aria-label":`Unsaved, ${z}`,children:z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!I&&!C)return y;return _("div",{className:"st-row-wrap",role:"none",children:[y,C&&K("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${mN(X.path)}`,title:`Move ${A}…`,"aria-label":`Actions for ${A}`,"aria-haspopup":"menu",onClick:(v)=>F.openAt(v,{kind:"file",path:X.path,dir:b}),children:K(uN,{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})}),I&&K("button",{type:"button",className:"st-row-del",title:`Delete ${A}`,"aria-label":`Delete canvas ${A}`,onClick:(v)=>{v.stopPropagation(),Y(X.path,A)},children:K(uN,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function Mq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:z,forceOpen:U,dirtyByPath:B,experimentalKind:F,drag:L,menu:D}){let M=B?.get(X.path),A=J.length>0,[I,P]=u.useState(!1),w=U||I,R=X.path===W;if(!(A&&z))return K(GR,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:M,experimentalKind:F,drag:L,menu:D});let C=typeof L<"u",b=C?L.dragProps(X.path,!0):{},$=L?.draggedPath===X.path,y=L?.busyPath===X.path,v=C&&typeof D<"u",g=X.path.split("/").slice(0,-1).join("/"),m=_("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":w,"aria-busy":y||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+($?" is-dragging":"")+(y?" is-busy":""),style:{paddingLeft:pN+Q*cN+"px"},title:X.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){P((f)=>!f);return}G(X.path)},onContextMenu:v?(p)=>D.openAt(p,{kind:"file",path:X.path,dir:g}):void 0,...b,children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),P((f)=>!f)},children:K(W9,{name:"chevron-right",className:"st-chev"+(w?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:BW(X.name)}),F==="reconstructed-experimental"&&K("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"}),M&&K("span",{className:"st-git-badge","data-kind":M,title:`Unsaved (${M})`,"aria-label":`Unsaved, ${M}`,children:M}),H>0&&K("span",{className:"st-row-badge",children:H})]});return _(Y0,{children:[v?_("div",{className:"st-row-wrap",role:"none",children:[m,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${mN(X.path)}`,title:`Move ${BW(X.name)}…`,"aria-label":`Actions for ${BW(X.name)}`,"aria-haspopup":"menu",onClick:(p)=>D.openAt(p,{kind:"file",path:X.path,dir:g}),children:K(uN,{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,w&&J.map((p)=>K(GR,{file:p,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function qe({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:z,activeDsName:U,onOpenSystem:B,onDelete:F,dirtyByPath:L,canvasKinds:D,dirPath:M="",drag:A,menu:I}){let P=Object.keys(X).filter(($)=>$!=="_files").sort(),w=X._files||[],{canvases:R,orphans:T}=u.useMemo(()=>Yq0(w),[w]),C=!!(H&&H.trim()),b=u.useMemo(()=>{if(!z||W!==1)return null;let $=new Map;for(let y of z)$.set(y.folder,y);return $},[z,W]);return _(Y0,{children:[R.map(($)=>{let y=C&&$.sidecars.some((v)=>{let g=H.toLowerCase();return v.name.toLowerCase().includes(g)||v.path.toLowerCase().includes(g)});return K(Mq0,{primary:$.primary,sidecars:$.sidecars,activePath:J,onOpen:Q,onDelete:F,openCount:lt(Y[$.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:y,dirtyByPath:L,experimentalKind:D?.[$.primary.path],drag:A,menu:I},$.primary.path)}),Z&&T.map(($)=>K(GR,{file:$.primary,activePath:J,onOpen:Q,openCount:lt(Y[$.primary.path]),depth:W,kind:G},$.primary.path)),P.map(($)=>{let y=b?.get($),v=M?`${M}/${$}`:$,g=K(qe,{node:X[$],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:U,onOpenSystem:B,onDelete:F,dirtyByPath:L,canvasKinds:D,dirPath:v,drag:A,menu:I});if(y&&B)return K(Oq0,{name:$,dsName:y.name,depth:W,defaultOpen:!0,active:J===T8&&y.name===U,onOpenSystem:B,children:g},$);return K(Dq0,{name:$,depth:W,defaultOpen:!0,dirPath:v,drag:A,menu:I,children:g},$)})]})}var xN={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function wq0(X){if(X.kind==="project")return xN.project;if(X.kind==="runtime")return xN.runtime;if(X.label==="Design system")return xN.ds;if(X.label==="UI kit")return xN.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function _q0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:z,showHidden:U,sectionsExpanded:B,onToggleSection:F,onNewBoard:L,onDeleteBoard:D,onRefresh:M,refreshing:A,collapsed:I,onCollapse:P,width:w,resizing:R,dirtyByPath:T,project:C,gitBranch:b,remoteSync:$,onGetLatest:y,canvasKinds:v,onMoveCanvas:g,onNewFolder:m,onDeleteFolder:p}){let f=u.useMemo(()=>{if(!Z)return X;return X.map((b0)=>({...b0,tree:Ue(b0.tree,Z),filtered:!!Z}))},[X,Z]),d=L$(g),l=N$(),h=u.useMemo(()=>{let b0=[];for(let Z8 of X){if(Z8.label==="Design system"||Z8.kind!=="canvas")continue;let p0=Z8.fullPath.replace(/^\.[^/]+\//,"")||Z8.fullPath;b0.push({path:Z8.fullPath,label:p0});for(let C8 of Z8.dirs||[])b0.push({path:C8,label:C8.replace(/^\.[^/]+\//,"")})}return b0},[X]),a=l.state?.extra,s=a?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>l.showMoveTo()}]:a?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{l.close();let b0=window.prompt("New folder name:");if(b0?.trim())m(a.dirPath,b0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{l.close(),p(a.dirPath,a.dirPath.split("/").pop())}}]:[],c=a?.kind==="file"?h.filter((b0)=>b0.path!==a.dir):[],[z0,e]=u.useState(!1),[n,o]=u.useState("board"),[V0,f0]=u.useState(""),[G8,X8]=u.useState(""),[a0,w0]=u.useState(!1),d0=u.useMemo(()=>X.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[X]),Y8=u.useCallback(async()=>{let b0=V0.trim();if(!b0||a0)return;if(w0(!0),X8(""),n==="folder"){if(!d0){w0(!1),X8("no canvas group to create a folder in");return}let p0=await m(d0,b0);if(w0(!1),p0?.ok)e(!1),f0("");else X8(p0?.error||"could not create folder");return}let Z8=await L(b0);if(w0(!1),Z8?.ok)e(!1),f0("");else X8(Z8?.error||"could not create board")},[V0,a0,L,m,n,d0]),k8=u.useMemo(()=>{let b0=0;for(let Z8 of X)for(let p0 of Z8.paths||[])if(AQ.test(p0))b0++;return b0},[X]),e0=u.useMemo(()=>{let b0=0;for(let Z8 of f)for(let p0 of Z8.paths||[])if(AQ.test(p0))b0++;return b0},[f]);return _("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(R?" is-resizing":""),style:I||!w?void 0:{width:w,flexBasis:w},"aria-label":"Files","data-tour":"sidebar",children:[_("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),_("div",{className:"st-sb-hd-actions",children:[K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":z0&&n==="board",onClick:()=>{X8(""),o("board"),e((b0)=>n==="board"?!b0:!0)},children:K(W9,{name:"plus",size:15})}),d0&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":z0&&n==="folder",onClick:()=>{X8(""),o("folder"),e((b0)=>n==="folder"?!b0:!0)},children:K(W9,{name:"folder-plus",size:15})}),M&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(A?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":A||void 0,disabled:A,onClick:()=>M(),children:K(W9,{name:"reload",size:15})}),_("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),e0," / ",k8]}),P&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:P,children:K(W9,{name:"panel-left",size:15})})]})]}),z0?_("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:n==="folder"?"folder name…":"brief board name…",value:V0,maxLength:60,disabled:a0,"aria-label":n==="folder"?"New folder name":"New brief board name",onChange:(b0)=>f0(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),Y8();else if(b0.key==="Escape")b0.preventDefault(),e(!1),f0(""),X8("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:a0||!V0.trim(),"data-tip":"Create · Enter","aria-label":n==="folder"?"Create folder":"Create brief board",onClick:Y8,children:a0?"…":"↵"})]}):null,G8?K("div",{className:"st-newboard-err",role:"alert",children:G8}):null,K("div",{className:"st-search",children:_("div",{className:"st-search-box",children:[K(W9,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(b0)=>H(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),Z)H("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),Z?K("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(JX,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:f.map((b0)=>{if(!U&&!Z&&b0.kind==="runtime")return null;let Z8=wq0(b0),p0=(b0.paths||[]).filter((z8)=>AQ.test(z8)).length,C8=Z8.pill||(Z8.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(Z8.pillFromCount?String(p0||b0.paths?.length||0):null),Q9=b0.tree&&Object.keys(b0.tree).length>0,Z9=b0.label==="Design system",T0=b0.kind==="project";if(!U&&!Z&&T0&&p0===0)return null;let H9=Xq0(b0),$0=B[b0.label],J8=!!Z||($0===void 0?H9:$0),Z0=!Z9&&b0.kind==="canvas",I0=Z0?d.dropProps(b0.fullPath,!0):{},F0=d.overDir===b0.fullPath;return _("div",{className:"st-tree-section",children:[_("button",{type:"button",className:"st-tree-sec-hd"+(F0?" is-drop-target":""),onClick:()=>F(b0.label,H9),"aria-expanded":J8,"aria-dropeffect":Z0?"move":void 0,title:J8?"Collapse section":"Expand section",...I0,children:[K(W9,{name:"chevron-right",className:"st-chev"+(J8?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:Z8.title}),C8&&K("span",{className:"st-pill",children:C8})]}),J8&&(Q9?K(qe,{node:b0.tree,activePath:J,onOpen:Y,commentsByFile:z,depth:1,kind:b0.kind,showHidden:U,search:Z,dsFolders:b0.dsFolders,activeDsName:Q,onOpenSystem:Z9?W:void 0,onDelete:Z9?void 0:D,dirtyByPath:T,canvasKinds:v,dirPath:b0.fullPath,drag:!Z9&&b0.kind==="canvas"?d:void 0,menu:!Z9&&b0.kind==="canvas"?l:void 0}):K("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},b0.label)})}),K(F$,{state:l.state,onClose:l.close,rootItems:s,destinations:c,onPickDestination:(b0)=>g(a.path,b0)}),K(Q_,{project:C,liveBranch:b,remoteSync:$,onGetLatest:y}),K(Cw,{}),K(Sw,{})]})}function Aq0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:_("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(W9,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(W9,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(W9,{name:"folder",size:15})})]})})}function Eq0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[_("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),_("span",{className:"sku",children:["MAUDE-DEV-SRV / v",ZR]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),_("div",{className:"help-modal-body",children:[_("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),_("ul",{children:[_("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),_("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),_("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),_("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),_("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),_("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),_("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),_("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),_("details",{children:[K("summary",{children:"Annotation tools"}),_("ul",{children:[_("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),_("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),_("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),_("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),_("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),_("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),_("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),_("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),_("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),_("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),_("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),_("details",{children:[K("summary",{children:"Canvas & panels"}),_("ul",{children:[_("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),_("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),_("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),_("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),_("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),_("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),_("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),_("details",{children:[K("summary",{children:"Slash commands"}),_("ul",{className:"cmds",children:[_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),_("li",{children:[_("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),_("li",{children:[_("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),_("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),_("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),_("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),_("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),_("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),_("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),_("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),_("details",{children:[K("summary",{children:"Opt-out scope"}),_("ul",{children:[_("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),_("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),_("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),_("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),_("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),_("details",{children:[K("summary",{children:"Auto-critic loop"}),_("ul",{children:[_("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),_("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),_("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),_("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),_("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),_("li",{children:["When ",K("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."]})]})]}),_("details",{children:[K("summary",{children:"Pin-to-element flow"}),_("ol",{children:[K("li",{children:"Open a canvas"}),_("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),_("li",{children:["Run"," ",_("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),_("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),_("details",{children:[K("summary",{children:"Comments"}),_("ol",{children:[_("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),_("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),_("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),_("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var QR=[{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 Pq0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>K(JX,{children:G},`${G}-${Z}`))},W);return _("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>_(Y0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function Rq0({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=QR.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[_("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),_("span",{className:"so-trigger",children:["press ",K(JX,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:QR.map((Y)=>_("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>_("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(Pq0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),_("div",{className:"so-overlay-ft",children:[_("span",{children:["close with ",K(JX,{children:"Esc"})]}),_("span",{className:"so-count",children:[Q," bindings · ",QR.length," groups"]})]})]})})}var Iq0=["File","Edit","View","Selection","Tools","Help"];function Be(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function kq0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Be(Q),_("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>_("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:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(W9,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(JX,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("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)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(JX,{children:G.shortcut})]},G.label))]})}function Wq({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Be(G),_("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?K("div",{className:"st-dd-sep"},"s"+H):_("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:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:Z.label})]}),Z.shortcut?K(JX,{children:Z.shortcut}):null]},Z.id))]})}function Tq0({onAction:X,onClose:J}){return K(Wq,{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"},...l8()?[{id:"collab-tour",label:"How sharing works"}]:[],...l8()?[{id:"quick-setup",label:"Quick setup"}]:[],...l8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function Cq0({onAction:X,onClose:J}){return K(Wq,{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 $q0({onAction:X,onClose:J}){return K(Wq,{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 Sq0({onAction:X,onClose:J,hasCanvas:Q}){return K(Wq,{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 bq0({onAction:X,onClose:J,hasCanvas:Q}){return K(Wq,{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 jq0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:z,onToggleChanges:U,onOpenSystem:B,sidebarOpen:F,onToggleSidebar:L,showHidden:D,onToggleShowHidden:M,onOpenHelp:A,onOpenShortcuts:I,onReportBug:P,onStartTour:w,onStartCollabTour:R,annotationsVisible:T,onToggleAnnotations:C,minimapVisible:b,onToggleMinimap:$,zoomCtlVisible:y,onToggleZoomCtl:v,presentMode:g,onTogglePresent:m,printGuidesVisible:p,onTogglePrintGuides:f,postToActiveCanvas:d,onOpenWhatsNew:l,onOpenReadiness:h,onOpenQuickSetup:a,onWatchIntro:s,whatsNewCount:c,exportCenter:z0,artboardCount:e=0,presence:n=null,inspectorOpen:o,inspectorTab:V0,onToggleInspector:f0,autoOpenInspector:G8,onToggleAutoOpenInspector:X8,onOpenLayers:a0,timelineOpen:w0,onToggleTimeline:d0,hasComps:Y8=!1,assistantOpen:k8,onToggleAssistant:e0,assistantBusy:b0,assistantUnseen:Z8,onNewCanvas:p0,onAssembleVideo:C8,onOpenExport:Q9,onOpenSettings:Z9,onOpenGenerate:T0,onReload:H9,onCloseCanvas:$0,onInsertArtboard:J8}){let Z0=X===T8,I0=Z0?"SYSTEM":X?"CANVAS":"IDLE",F0=Z0?K("b",{children:"design system"}):X?_(Y0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:BW(dN(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),z8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:F,disabled:!1},{id:"changes",label:z>0?`Changes · ${z} 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:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:o&&V0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:o,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!G8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:Y8?"video":void 0,checked:w0,disabled:!1},...l8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:k8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:b,disabled:!X||Z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:y,disabled:!X||Z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||Z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!X||Z0}],I8=["file","edit","view","selection","tools","help"];function W8(j0){if(I8.includes(j0))W(Y===j0?null:j0)}return u.useEffect(()=>{if(!Y||!I8.includes(Y))return;let j0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function N0(c0){let s0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!s0.length)return;let M0=s0.indexOf(document.activeElement);if(c0.key==="ArrowDown")c0.preventDefault(),s0[(M0+1)%s0.length].focus();else if(c0.key==="ArrowUp")c0.preventDefault(),s0[(M0-1+s0.length)%s0.length].focus();else if(c0.key==="Home")c0.preventDefault(),s0[0].focus();else if(c0.key==="End")c0.preventDefault(),s0[s0.length-1].focus();else if(c0.key==="ArrowRight"||c0.key==="ArrowLeft"){c0.preventDefault();let n0=c0.key==="ArrowRight"?1:-1,D8=I8.indexOf(Y);W(I8[(D8+n0+I8.length)%I8.length])}else if(c0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",N0),()=>{clearTimeout(j0),window.removeEventListener("keydown",N0)}},[Y,W]),_("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[_("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:Iq0.map((j0)=>{let N0=j0.toLowerCase(),c0=I8.includes(N0),s0=c0||N0==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":N0==="help"?"help":void 0,"aria-haspopup":c0?"menu":void 0,"aria-expanded":c0?Y===N0:void 0,onClick:()=>W8(N0),onMouseEnter:()=>{if(Y!==null&&c0)W(N0)},children:j0},N0)})}),Y==="file"&&K(Sq0,{hasCanvas:!!X,onAction:(j0)=>{if(j0==="new")p0?.();else if(j0==="assemble")C8?.();else if(j0==="export")Q9?.("export");else if(j0==="handoff")Q9?.("handoff");else if(j0==="generate")T0?.();else if(j0==="settings")Z9?.();else if(j0==="reload")H9?.();else if(j0==="close")$0?.()},onClose:()=>W(null)}),Y==="edit"&&K(bq0,{hasCanvas:!!X&&!Z0,onAction:(j0)=>{if(j0==="undo")d({dgn:"undo"});else if(j0==="redo")d({dgn:"redo"});else if(j0==="deselect-all")d({dgn:"selection-clear"});else if(j0==="select-all-annotations")d({dgn:"annotation-select-all"});else if(j0.startsWith("new-artboard:"))J8?.(j0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(kq0,{panels:z8,onToggle:(j0)=>{if(j0==="tree")L();else if(j0==="changes")U();else if(j0==="comments")Z();else if(j0==="hidden")M();else if(j0==="annotate")C();else if(j0==="inspector")f0();else if(j0==="autoopen")X8?.();else if(j0==="timeline")d0?.();else if(j0==="assistant")e0?.();else if(j0==="layers")a0?.();else if(j0==="minimap")$?.();else if(j0==="zoomctl")v?.();else if(j0==="present")m?.();else if(j0==="print-guides")f?.()},onZoom:(j0)=>d({dgn:"zoom",op:j0}),hasCanvas:!!X&&!Z0,onClose:()=>W(null)}),Y==="selection"&&K(Cq0,{onAction:(j0)=>{if(j0==="deselect-all")d({dgn:"selection-clear"});else if(j0==="select-all-annotations")d({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K($q0,{onAction:(j0)=>d({dgn:"tool-set",tool:j0}),onClose:()=>W(null)}),Y==="help"&&K(Tq0,{onAction:(j0)=>{if(j0==="shortcuts")I?.();else if(j0==="help")A?.();else if(j0==="report-bug")P?.();else if(j0==="tour")w?.();else if(j0==="collab-tour")R?.();else if(j0==="quick-setup")a?.();else if(j0==="readiness")h?.();else if(j0==="whatsnew")l?.();else if(j0==="watch-intro")s?.()},onClose:()=>W(null)}),_("div",{className:"st-mb-right","data-tour":"status",children:[n?K("div",{className:"st-presence",children:n}):null,l8()&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":k8?"true":"false","data-busy":b0?"true":"false","data-unseen":Z8?"true":"false","aria-label":`Assistant${b0?" — working":Z8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:e0,children:K(W9,{name:"sparkle",size:15})}),z0&&K(Gx,{center:z0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":c>0?"true":"false","aria-label":`What's new${c>0?` — ${c} unseen`:""}`,"data-tip":"What's new",onClick:l,children:K(W9,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:I0}),K("span",{className:"st-mb-file",title:X||"",children:F0}),K("span",{className:"st-mb-sep"}),_("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function yq0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:z,onIframeLoad:U,showQuickSetup:B,onStartQuickSetup:F}){return _("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&_("div",{className:"st-empty",children:[_("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),_("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",ZR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),_("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(JX,{children:"⌘"})," and hover to preview an element, click to select it — ",K(JX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",l8()?_(Y0,{children:[K("br",{}),K("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]}),B&&K("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:F,children:"Start quick setup"})]}),X.map((L)=>{if(L.path===T8)return K("div",{className:"system-view"+(L.path===J?" active":""),children:K(lq0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},L.path);return K("iframe",{ref:(D)=>Q(L.path,D),src:aH(L.path,H),className:L.path===J?"active":"","data-path":L.path,"data-testid":L.path===J?"canvas-frame":void 0,onLoad:()=>U?.(L.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},L.path)}),z&&z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:_("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var fq0=["color","space","radius","shadow","leading","weight","motion","font","other"],vq0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function xq0(X){return X==="color"}function hq0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return _("section",{className:"sv-section sv-section-tokens",children:[_("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:_("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...fq0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(Y0,{children:W.map((G)=>{let Z=Y[G],H=xq0(G);return _("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[_("h2",{children:["tokens · ",vq0[G]||G,K("span",{className:"sv-h-num",children:Z.length})]}),K("div",{className:"sv-tokens-ladder",children:Z.map((z)=>_("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:z.value}}):null,_("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:z.name}),K("span",{className:"sv-tok-value",children:z.value||"—"})]})]},z.name+"|"+z.value))})]},G)})})}function gq0(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 mq0(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 uq0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=mq0(X?.font);return _("section",{className:"sv-section sv-section-type",children:[_("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=gq0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return _("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function lq0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:z,tokensPath:U,ds:B,availableDesignSystems:F}=X,L=(!W||!W.length)&&(!G||!G.length),D=Array.isArray(F)&&F.length>1,M=B?.name??F?.[0]?.name??"";return _("div",{className:"sv",children:[_("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),D?_("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:F.map((A)=>K("option",{value:A.name,children:A.name},A.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:Z})})]}),B?.description?K("p",{className:"sv-ds-description",children:B.description}):null,K(hq0,{tokens:H,tokenGroups:z,tokensPath:U}),K(uq0,{tokenGroups:z}),L?K("div",{className:"sv-empty",children:_("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:Z}),"."]})}):_(Y0,{children:[K(ot,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(ot,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function ot({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return _("section",{className:"sv-section",children:[_("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>_("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:aH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),_("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function dq0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:z=0,unpushed:U=0,changesOpen:B=!1,onOpenChanges:F}){let L=X===T8,D=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",A=W==="dark"?"light":"dark",I=(()=>{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 P=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:P>0?`${P} ↑`:"synced",title:P>0?`${P} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${P} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return _("footer",{className:"st-statusbar",role:"contentinfo",children:[_("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:L?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!L&&_("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:M,children:D}),K("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:"×"})]}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),_("span",{className:"val",children:[Y," open"]})]}),F&&_("button",{type:"button",className:"st-sb-slot st-sb-changes"+(B?" is-open":"")+(z>0?" has-changes":U>0?" has-unpushed":""),onClick:F,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":B,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:z>0?`${z} unsaved`:U>0?`${U} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),I&&_("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(I.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:I.title,children:I.label})]}),_("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${A} theme`,"data-tip-pos":"top","aria-label":`Switch to ${A} theme`,children:[K(W9,{name:W==="dark"?"sun":"moon",size:13}),A]})]})}function pq0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:z,width:U,resizing:B}){let F=Ve(X),L=Object.keys(X||{}).sort(),D=[];for(let M of L){let A=X[M]||[],I=A.filter((w)=>{if(J==="open")return w.status!=="resolved";if(J==="resolved")return w.status==="resolved";return!0});if(I.length===0)continue;let P=A.filter((w)=>w.selector);D.push({file:M,comments:I.map((w)=>({...w,n:P.findIndex((R)=>R.id===w.id)+1}))})}return _("aside",{className:"st-rpanel"+(B?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:_("div",{className:"st-cm-filters",role:"tablist",children:[_("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",F.all]}),_("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",F.open]}),_("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",F.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:D.length===0?_("div",{className:"st-rp-empty",children:[_("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),_("p",{children:["Open a canvas, hold ",K(JX,{children:"⌘"})," and click an element, then press ",K(JX,{children:"C"})," — or hold ",K(JX,{children:"⌘⇧"})," and click directly."]})]}):D.map((M)=>_(Y0,{children:[_("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[K("span",{children:BW(dN(M.file))}),K("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>_("div",{className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[_("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),K("span",{className:"st-comment-time",children:Gq0(A.created)})]}),K("div",{className:"st-comment-txt",children:A.text}),_("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),_("span",{className:"st-mini-act",children:[A.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(I)=>{I.stopPropagation(),H(A.id)},children:K(W9,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(I)=>{I.stopPropagation(),Z(A.id)},children:K(W9,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(I)=>{I.stopPropagation(),z(A.id)},children:K(W9,{name:"x",size:14})})]})]})]},A.id))]},M.file))})]})}function cq0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return _("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),_("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),vf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function iq0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",z=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,B=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!z&&!H&&!B&&U===0)return null;let F,L,D;if(H)F="success",L="Synced with hub",D=`${Y}:flash`;else if(z){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")F="error",L=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else F="warn",L=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;D=`${Y}:offline`}else if(B){if(B.snapshotFailed)F="error",L=`Diverged on ${B.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else F="warn",L=`Diverged on ${B.slug}: kept the ${B.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${B.slug}`;D=`diverged:${B.slug}:${B.at}`}else F="warn",L=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,D=`rejected:${U}`;if(J===D)return null;return _("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${F}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:L}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(D),children:"×"})]})}var oq0=["block","inline-block","flex","inline-flex","grid","inline","none"],nt=["px","%","fr","em","auto","min-content","max-content"];var nq0=["auto","stretch","flex-start","center","flex-end","baseline"];var rt=["300","400","500","600","700","800"],at=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],st=["none","solid","dashed","dotted","double"],tt=["px","rem","em","%","vw","vh","auto"],et=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),YR={"font-size":{node:K(h9,{as:I1,size:12})},"line-height":{node:K(h9,{as:j1,size:12})},"letter-spacing":{node:K(h9,{as:l1,size:12})},gap:{node:K(h9,{as:kz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(h9,{as:o1,size:12})},"border-width":{node:K(h9,{as:u1,size:12})}};var Xe=["static","relative","absolute","fixed","sticky"],rq0=["normal","italic","oblique"],Je=["none","uppercase","lowercase","capitalize"];var Qe=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],aq0=["fill","contain","cover","none","scale-down"];var Ye=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],We=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],W5={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}},ez=null;function lN(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!ez)ez=document.createElement("canvas").getContext("2d");if(!ez)return"";ez.fillStyle="#000000",ez.fillStyle=X;let J=ez.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 AY=(X)=>Math.min(1,Math.max(0,X));function hN(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 Qq({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Yq({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 XK({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,z=0;if(X<60)[Z,H,z]=[Y,W,0];else if(X<120)[Z,H,z]=[W,Y,0];else if(X<180)[Z,H,z]=[0,Y,W];else if(X<240)[Z,H,z]=[0,W,Y];else if(X<300)[Z,H,z]=[W,0,Y];else[Z,H,z]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(z+G)*255}}function l9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function _Q(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 Ge(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 Ne(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function sq0(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],z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=z&&J[z[1]]?J[z[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 Fe(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(z)=>{if(!z.tokensCssRel)return null;try{let U=await fetch(`/${J}/${z.tokensCssRel}`),B=U.ok?await U.text():"";return{name:z.name,...sq0(B)}}catch{return null}})).then((z)=>{if(H)return;let U=z.filter(Boolean);U.sort((B,F)=>B.name===Q?-1:F.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function Le({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>Yq(hN(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),z=u.useRef(X);u.useEffect(()=>{if(X&&X!==z.current)z.current=X,W(Yq(hN(X)))},[X]);let U=Qq(XK(Y)),B=(w)=>{w.preventDefault();let R=Z.current?.getBoundingClientRect();if(!R)return;let T=G.current.h,C=($)=>{W({h:T,s:AY(($.clientX-R.left)/R.width),v:AY(1-($.clientY-R.top)/R.height)})};C(w);let b=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",b),Q(Qq(XK(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",b)},F=(w)=>{w.preventDefault();let R=H.current?.getBoundingClientRect();if(!R)return;let{s:T,v:C}=G.current,b=(y)=>{W({h:AY((y.clientX-R.left)/R.width)*360,s:T,v:C})};b(w);let $=()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",$),Q(Qq(XK(G.current)))};document.addEventListener("pointermove",b),document.addEventListener("pointerup",$)},L=(w)=>{let R={...G.current,...w};W(R),Q(Qq(XK(R)))},D=(w)=>{let R=w.shiftKey?0.1:0.02,C={ArrowLeft:[-R,0],ArrowRight:[R,0],ArrowUp:[0,R],ArrowDown:[0,-R]}[w.key];if(!C)return;w.preventDefault(),L({s:AY(G.current.s+C[0]),v:AY(G.current.v+C[1])})},M=(w)=>{let R=w.shiftKey?20:2,C={ArrowLeft:-R,ArrowRight:R}[w.key];if(C==null)return;w.preventDefault(),L({h:Math.min(360,Math.max(0,G.current.h+C))})},A=async()=>{try{let w=window.EyeDropper;if(!w)return;let R=await new w().open();if(R?.sRGBHex)W(Yq(hN(R.sRGBHex))),Q(R.sRGBHex)}catch{}},I=XK(Y),P=(w)=>{let R={...I,...w},T=Yq({r:AY(R.r/255)*255,g:AY(R.g/255)*255,b:AY(R.b/255)*255});W(T),Q(Qq(XK(T)))};return _("div",{className:"st-cp-cpick",children:[_("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(w)=>{let R=w.target.value;if(/^#?[0-9a-f]{6}$/i.test(R))W(Yq(hN(R)))},onKeyDown:(w)=>{if(w.key==="Enter")Q(w.currentTarget.value)},onBlur:(w)=>Q(w.currentTarget.value),onFocus:(w)=>w.currentTarget.select()})]}),_("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:B,onKeyDown:D,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),_("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:K(W9,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:F,onKeyDown:M,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((w)=>_("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":w.toUpperCase(),value:Math.round(I[w]),onChange:(R)=>P({[w]:AY((Number.parseFloat(R.target.value)||0)/255)*255}),onFocus:(R)=>R.currentTarget.select()}),K("span",{children:w.toUpperCase()})]},w))})]})}function gN({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:z}){let[U,B]=u.useState(!1),[F,L]=u.useState(null),[D,M]=u.useState("custom"),[A,I]=u.useState(""),P=u.useRef(null),w=u.useRef(null),R=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(s)=>Q===`var(${s})`,C=(s)=>s.replace(/^--/,"").replace(/-/g," "),b=J||[],$=b.reduce((s,c)=>s+(c.names?.length||0),0),y=b.length>1,v=A.trim().toLowerCase(),g=!v?b:b.map((s)=>({...s,names:(s.names||[]).filter((c)=>C(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(s.vals?.[c]||"").toLowerCase().includes(v))})).filter((s)=>s.names.length);u.useEffect(()=>{if(!U){I("");return}let s=()=>{let n=P.current?.getBoundingClientRect();if(!n)return;let o=224,V0=300,f0=Math.min(n.right-o,window.innerWidth-o-8);if(f0<8)f0=8;let X8=window.innerHeight-n.bottom>V0+8?n.bottom+4:Math.max(8,n.top-V0-4);L({left:f0,top:X8,width:o,maxHeight:V0})};s();let c=(n)=>{if(w.current?.contains(n.target)||P.current?.contains(n.target))return;B(!1)},z0=(n)=>{if(n.key==="Escape")B(!1)},e=(n)=>{if(w.current?.contains(n.target))return;s()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",z0),window.addEventListener("resize",s),document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",z0),window.removeEventListener("resize",s),document.removeEventListener("scroll",e,!0)}},[U]),u.useEffect(()=>{if(!U||!F||!w.current)return;let s=w.current.getBoundingClientRect(),c=F.left-s.left,z0=F.top-s.top;if(Math.abs(c)>0.5||Math.abs(z0)>0.5)L((e)=>e?{...e,left:e.left+c,top:e.top+z0}:e)},[U,F]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,p=(s,c,z0)=>{if(H&&s&&s!==H&&z0&&!m.test(z0))Y(z0);else Y(`var(${c})`);B(!1)},f=(s)=>{let c=(s||"").trim();if(c)Y(c)},d=_("div",{className:"st-cp-pop-search",children:[K(W9,{name:"search",size:12}),K("input",{value:A,onChange:(s)=>I(s.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(s)=>s.map((c)=>_("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:c.ds}):null,K("div",{className:"st-cp-pop-list",children:c.names.map((z0)=>_("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(z0)?" is-on":""}`,onClick:()=>p(c.ds,z0,c.vals?.[z0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[z0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:C(z0)}),K("span",{className:"st-cp-pop-val",children:c.vals?.[z0]||""})]},`${c.ds}:${z0}`))})]},c.ds)),h=(s)=>s.map((c)=>_("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:c.ds}):null,K("div",{className:"st-cp-pop-list",children:c.names.map((z0)=>_("button",{type:"button",className:`st-cp-pop-row${T(z0)?" is-on":""}`,onClick:()=>p(c.ds,z0,c.vals?.[z0]),children:[K("span",{className:"st-cp-pop-name",children:C(z0)}),K("span",{className:"st-cp-pop-val",children:c.vals?.[z0]||""})]},`${c.ds}:${z0}`))})]},c.ds)),a=K("div",{className:"st-cp-pop-empty",children:"No match"});return _(Y0,{children:[G!==void 0?K("button",{type:"button",ref:P,className:`${z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${R&&!z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>B((s)=>!s),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:P,className:`st-cp-tokbtn${R?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>B((s)=>!s),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&F?He.createPortal(K("div",{ref:w,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:F.left,top:F.top,width:F.width,maxHeight:F.maxHeight},children:X==="color"?_(Y0,{children:[_("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":D==="custom",className:`st-cp-poptab${D==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":D==="vars",className:`st-cp-poptab${D==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),D==="custom"?K(Le,{seed:Z||lN(Q)||"#000000",onApply:f}):!$?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):_(Y0,{children:[d,g.length?l(g):a]})]}):!$?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):_(Y0,{children:[d,g.length?h(g):a]})}),document.body):null]})}function Ze({label:X,tracks:J,editable:Q,onChange:Y}){let W=(z,U)=>{let B=J[z];Y(J.map((F,L)=>L===z?bU.has(U)?{value:0,unit:U}:{value:B.value||1,unit:U}:F))},G=(z,U)=>{Y(J.map((B,F)=>F===z?{...B,value:U}:B))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(z)=>Y(J.filter((U,B)=>B!==z));return _("div",{className:"st-cp-gridtracks",children:[_("div",{className:"st-cp-gridtracks-hd",children:[K("span",{className:"st-cp-gridtracks-label",children:X}),K("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?_("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((z,U)=>{let B=bU.has(z.unit);return _("div",{className:"st-cp-gridtrack-row",children:[B?K(s4,{value:z.unit,ariaLabel:`${X} track ${U+1}`,options:nt.map((F)=>({value:F,label:F})),onChange:(F)=>W(U,F)}):K(h6,{value:z.value,min:z.unit==="fr"?0.1:0,step:z.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:K(wB,{value:z.unit,units:nt,ariaLabel:`${X} track ${U+1} unit`,onChange:(F)=>W(U,F)}),onCommit:(F)=>G(U,F)}),K("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function tq0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let z=!!X.id,U=X.computed||{},[B,F]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{F({a:{},c:{},t:{}})},[X.id]);let L=(t,q0)=>{let G0={...t||{}};for(let[E0,u0]of Object.entries(q0))if(u0===null)delete G0[E0];else G0[E0]=u0;return G0},D=L(X.authored,B.a),M=L(X.customStyles,B.c),A=L(X.attrs,B.t),I=(t,q0)=>F((G0)=>({...G0,a:{...G0.a,[t]:q0}})),P=(t,q0)=>F((G0)=>({...G0,c:{...G0.c,[t]:q0}})),w=(t,q0)=>F((G0)=>({...G0,t:{...G0.t,[t]:q0}})),R=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Ne(X.file,J),C=Fe(J,R,T),b=(t)=>C.map((q0)=>({ds:q0.name,names:q0[t]||[],vals:q0.vals})).filter((q0)=>q0.names.length),[$,y]=u.useState({}),[v,g]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let p=(D.position||l9(U.position)||"static")!=="static";u.useEffect(()=>{if(p)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,p]);let f=H,[d,l]=u.useState({});async function h(t,q0,G0){y((E0)=>({...E0,[G0]:"saving"}));try{let E0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(q0)}),u0=await E0.json().catch(()=>({}));y((O8)=>({...O8,[G0]:!E0.ok||!u0.ok?`err:${u0&&u0.error||`HTTP ${E0.status}`}`:"saved"}))}catch(E0){y((u0)=>({...u0,[G0]:`err:${E0&&E0.message?E0.message:String(E0)}`}))}}let a=(t,q0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:q0})},s=(t,q0,G0,E0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:q0,before:G0==null||G0===""?null:G0,after:E0==null||E0===""?null:E0})},c=(t,q0)=>{let G0=(q0||"").trim();if(!z||!G0)return;let E0=D[t]??null;if(G0===(E0??"").trim())return;a(t,G0),I(t,G0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:G0},t),s("css",t,E0,G0)},z0=(t,q0)=>{let G0=(q0||"").trim(),E0=t.trim();if(!z||!E0||!G0)return;let u0=M[E0]??null;a(E0,G0),P(E0,G0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:E0,value:G0},E0),s("css",E0,u0,G0)},e=(t,q0)=>{let G0=(t||"").trim(),E0=(q0||"").trim();if(!z||!G0||!E0)return;let u0=A[G0]??null;w(G0,E0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:G0,value:E0},`@${G0}`),s("attr",G0,u0,E0)},n=(t)=>{if(!z)return;let q0=D[t]??null;a(t,null),I(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),s("css",t,q0,null)},o=(t)=>{if(!z)return;let q0=M[t]??null;a(t,null),P(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),s("css",t,q0,null)},V0=(t)=>{if(!z)return;let q0=A[t]??null;w(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),s("attr",t,q0,null)},f0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},G8=(t,q0)=>{if(!z)return;let G0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),E0=q$(t,q0,f0,G0);for(let u0 of E0.reset)if(D[u0])n(u0);for(let[u0,O8]of E0.set)c(u0,O8)},X8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",a0=(t)=>{let q0=V$(t,D,U,f0);return _("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:K(_B,{value:q0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(G0)=>G8(t,G0)})})]},`mode-${t}`)},w0=["flex-start","center","flex-end"],d0=["flex-start","center","flex-end"],Y8=["t","c","b"],k8=["l","c","r"],e0=()=>{let t=!(D["flex-direction"]||l9(U["flex-direction"])||"row").startsWith("column"),q0=Math.max(0,w0.indexOf(D["justify-content"]||l9(U["justify-content"])||"flex-start")),G0=D["align-items"]||l9(U["align-items"])||"stretch",E0=G0==="stretch"?1:Math.max(0,d0.indexOf(G0)),[u0,O8]=t?[q0,E0]:[E0,q0];return Y8[O8]+k8[u0]},b0=(t)=>{let q0=Y8.indexOf(t[0]),G0=k8.indexOf(t[1]),E0=!(D["flex-direction"]||l9(U["flex-direction"])||"row").startsWith("column"),[u0,O8]=E0?[G0,q0]:[q0,G0];c("justify-content",w0[u0]),c("align-items",d0[O8])},Z8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let q0=t.key.toLowerCase();if(q0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(q0==="y")t.preventDefault(),G?.("redo")},p0=(t)=>{let q0=D[t];if(!q0)return"inherit";return/var\(\s*--/.test(q0)?"bound":"raw"};if(!z)return _("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),_("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let C8={bound:"token-bound",raw:"raw override",inherit:"inherited"},Q9=(t)=>K("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":C8[t]}),Z9=(t,q0)=>{let G0=q0??p0(t),E0=$[t],u0=typeof E0==="string"&&E0.startsWith("err:")?E0.slice(4):"",O8=u0?" is-err":E0==="saved"?" is-saved":E0==="saving"?" is-saving":"",M8=!!D[t],w8=u0?`error: ${u0}`:M8?`${C8[G0]} · double-click to reset`:C8[G0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${G0}${O8}${M8?" is-resettable":""}`,"aria-label":w8,title:w8,tabIndex:M8?0:-1,onDoubleClick:M8?()=>n(t):void 0,onKeyDown:M8?($8)=>{if($8.key==="Backspace"||$8.key==="Delete")$8.preventDefault(),n(t)}:void 0})},T0=(t,q0,G0,E0)=>{let u0=G0===void 0&&!D[t],O8=E0??t;return _("div",{className:`st-cp-row${u0?" is-unset":""}`,children:[Z9(t,G0),K("label",{className:"st-cp-label",title:O8,children:O8}),K("div",{className:"st-cp-ctl",children:q0})]},t)},H9={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"]},$0=(t)=>{(H9[t]||[]).forEach((q0)=>{if(D[q0])n(q0)})},J8=(t,q0)=>{let G0=(H9[t]||[]).some((E0)=>D[E0]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[t],onClick:()=>g((E0)=>({...E0,[t]:!E0[t]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:v[t]?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${G0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!G0,onClick:()=>$0(t),children:K(h9,{as:iG,size:12})})]}),K("div",{className:`st-cp-sec-anim${v[t]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:q0})})]},t)},Z0=(t,q0,G0,E0=!0)=>{let u0=`d:${t}`,O8=v[u0]===void 0?E0:v[u0],M8=q0.some((w8)=>D[w8]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":O8,onClick:()=>g((w8)=>({...w8,[u0]:!O8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:O8?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${M8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!M8,onClick:()=>q0.forEach((w8)=>{if(D[w8])n(w8)}),children:K(h9,{as:iG,size:12})})]}),K("div",{className:`st-cp-sec-anim${O8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:G0})})]},u0)},I0=(t)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!d[t],"aria-label":d[t]?`${t} — fewer options`:`${t} — more options`,title:d[t]?"fewer":"more",onClick:()=>l((q0)=>({...q0,[t]:!q0[t]})),children:d[t]?"▴":"···"}),F0=(t,q0)=>_("select",{className:"st-cp-nsel","aria-label":t,value:q0.includes(D[t])?D[t]:"",onChange:(G0)=>c(t,G0.target.value),children:[K("option",{value:"",disabled:!0,children:l9(U[t])||"—"}),q0.map((G0)=>K("option",{value:G0,children:G0},G0))]}),z8=(t)=>b(t).flatMap((q0)=>(q0.names||[]).map((G0)=>({name:G0,value:q0.vals?.[G0]||""}))),I8=(t,q0)=>K(mw,{value:D[t]||l9(U[t])||q0[0].value,ariaLabel:t,options:q0,onChange:(G0)=>c(t,G0)}),W8=(t,q0,G0={})=>{let E0=_Q(D[t]??""),u0=et.has(t),O8=D[t]??"",M8=typeof O8==="string"&&/var\(\s*--/.test(O8),w8=u0?"":E0.unit&&E0.unit!=="auto"?E0.unit:"px",$8=Number.parseFloat(_Q(l9(U[t])??"").n)||0,n8=E0.n!==""&&E0.n!=null?Number.parseFloat(E0.n)||0:$8,$9=YR[t];return K(AB,{value:M8?O8:n8,tokens:z8(q0),ariaLabel:t,min:G0.min??0,lead:$9?$9.node??$9.t:void 0,unitSlot:u0?null:K(wB,{units:tt,value:E0.unit||"px",ariaLabel:`${t} unit`,onChange:(q9)=>c(t,q9==="auto"?"auto":`${E0.n||"0"}${q9}`)}),onChange:(q9)=>c(t,typeof q9==="string"?q9:u0?`${q9}`:`${q9}${w8}`)})},j0=()=>{let t=(u0)=>Number.parseFloat(_Q(D[u0]??D["border-radius"]??l9(U[u0])??l9(U["border-radius"])??"0").n)||0,q0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},G0=(u0)=>{if(u0.tl===u0.tr&&u0.tr===u0.bl&&u0.bl===u0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((M8)=>{if(D[M8])n(M8)}),c("border-radius",`${u0.tl}px`);else c("border-top-left-radius",`${u0.tl}px`),c("border-top-right-radius",`${u0.tr}px`),c("border-bottom-left-radius",`${u0.bl}px`),c("border-bottom-right-radius",`${u0.br}px`)},E0=YR["border-radius"];return K($v,{corners:q0,lead:E0?E0.node??E0.t:void 0,onCorners:G0})},N0=()=>_("div",{className:"st-cp-border",children:[V9("border-width",null,{fixedUnit:"px"}),_("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:st.includes(D["border-style"])?D["border-style"]:"",onChange:(t)=>c("border-style",t.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),st.map((t)=>K("option",{value:t,children:t},t))]}),K(gN,{kind:"color",groups:b("color"),current:D["border-color"],activeDs:T,swatchBg:U["border-color"]||D["border-color"]||"",seedHex:lN(U["border-color"]||D["border-color"])||"#000000",onPick:(t)=>c("border-color",t),label:"border colour"})]}),c0=()=>{let t=D.transform||l9(U.transform)||"",q0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),G0=((q0?Number.parseFloat(q0[1]):0)%360+360)%360,E0=(u0)=>{let O8=(u0%360+360)%360,M8=(D.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${M8?`${M8} `:""}rotate(${O8}deg)`.trim())};return _("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(Tv,{value:G0,onChange:E0}),K(h6,{value:G0,min:0,max:360,ariaLabel:"rotation",lead:K(h9,{as:iG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:E0})]})},s0=()=>{let t=D.filter||l9(U.filter)||"",q0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),G0=q0?Number.parseFloat(q0[1]):0;return K(h6,{value:G0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(u0)=>{let O8=(D.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",u0>0?`${O8?`${O8} `:""}blur(${u0}px)`.trim():O8||"none")}})},M0=()=>{let t=D.opacity,q0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(l9(U.opacity))||1,G0=Math.round((Number.isNaN(q0)?1:q0)*100);return K(qJ,{value:G0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(E0)=>a("opacity",String(E0/100)),onCommit:(E0)=>c("opacity",String(E0/100))},`opacity:${t??""}`)},n0=()=>{let t=Number.parseInt(D["font-weight"]||l9(U["font-weight"])||"400",10)>=600,q0=(D["font-style"]||l9(U["font-style"]))==="italic",G0=/underline/.test(D["text-decoration"]||l9(U["text-decoration"])||"");return K(Iv,{value:{b:t,i:q0,u:G0},ariaLabel:"text style",options:[{value:"b",node:K(h9,{as:y1}),label:"Bold"},{value:"i",node:K(h9,{as:g1}),label:"Italic"},{value:"u",node:K(h9,{as:a1}),label:"Underline"}],onToggle:(E0)=>{if(E0==="b")c("font-weight",t?"400":"700");else if(E0==="i")c("font-style",q0?"normal":"italic");else c("text-decoration",G0?"none":"underline")}})},D8=[{value:"row",node:K(h9,{as:u4}),label:"Row"},{value:"column",node:K(h9,{as:l4}),label:"Column"}],x8=[{value:"flex-start",node:K(h9,{as:C1}),label:"Start"},{value:"center",node:K(h9,{as:k1}),label:"Center"},{value:"flex-end",node:K(h9,{as:T1}),label:"End"},{value:"space-between",node:K(h9,{as:kz}),label:"Space between"}],I9=[{value:"flex-start",node:K(h9,{as:b1}),label:"Start"},{value:"center",node:K(h9,{as:$1}),label:"Center"},{value:"flex-end",node:K(h9,{as:S1}),label:"End"},{value:"stretch",node:K(h9,{as:n1}),label:"Stretch"}],d9=[{value:"left",node:K(h9,{as:A5}),label:"Left"},{value:"center",node:K(h9,{as:c4}),label:"Center"},{value:"right",node:K(h9,{as:i4}),label:"Right"},{value:"justify",node:K(h9,{as:o4}),label:"Justify"}],U9=[{value:"visible",node:K(h9,{as:cG}),label:"Visible"},{value:"hidden",node:K(h9,{as:oG}),label:"Hidden"},{value:"scroll",node:K(h9,{as:c1}),label:"Scroll"}],l7=(t,q0)=>{let G0=b(q0);return G0.length?K(gN,{kind:"value",groups:G0,current:D[t],activeDs:T,onPick:(E0)=>c(t,E0),label:`${t} design token`}):null},q7=(t)=>{let q0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===q0)q0.select()})},wX=(t,q0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let G0=t.shiftKey?10:1,E0=t.key==="ArrowUp"?1:-1,u0=(Number.parseFloat(t.currentTarget.value)||0)+E0*G0;return t.currentTarget.value=String(u0),q0(u0),!0},p9=(t)=>K("input",{className:"st-cp-fin","aria-label":t,defaultValue:D[t]??"",placeholder:l9(U[t])||"—",onFocus:q7,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>c(t,q0.currentTarget.value)},`${t}:${D[t]??""}`),V9=(t,q0,G0={})=>{let E0=_Q(D[t]??""),u0=et.has(t),O8=u0?"":G0.fixedUnit||(E0.unit&&E0.unit!=="auto"?E0.unit:"px"),M8=YR[t],w8=Number.parseFloat(_Q(l9(U[t])??"").n)||0,$8=E0.n!==""&&E0.n!=null?Number.parseFloat(E0.n)||0:w8;return _(Y0,{children:[K(h6,{value:$8,min:G0.min??0,step:1,ariaLabel:t,lead:M8?M8.node??M8.t:void 0,onCommit:(n8)=>c(t,u0?`${n8}`:`${n8}${O8}`),unitSlot:u0||G0.fixedUnit?null:K(wB,{units:tt,value:E0.unit||"px",ariaLabel:`${t} unit`,onChange:(n8)=>c(t,n8==="auto"?"auto":`${E0.n||"0"}${n8}`)})},`${t}:${D[t]??""}`),l7(t,q0)]})},c9=(t)=>{let q0=U[t]||D[t]||"",G0=D[t]??"",E0=typeof G0==="string"&&/var\(\s*--/.test(G0),u0=E0?G0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):G0;return K(t1,{swatch:K(gN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:b("color"),current:D[t],activeDs:T,swatchBg:q0,seedHex:lN(U[t]||D[t])||"#000000",onPick:(O8)=>c(t,O8),label:`${t} colour`}),displayValue:u0,bound:E0,ariaLabel:t,onValue:(O8)=>c(t,O8)})},X9=(t,q0)=>{let G0=null,E0=q0.unitless?"":"px",u0=(w8)=>q0.unitless?`${w8}`:`${w8}${E0}`,O8=(w8,$8,n8)=>{for(let $9 of $8??[t])n8($9,u0(w8))},M8=gw({getBase:()=>G0?.value??"0",min:q0.min??0,step:1,sides:q0.sides,onInput:(w8,$8)=>{if(G0)G0.value=String(w8);if($8){let n8=G0?.closest(".st-cp-box");for(let $9 of $8){if($9===t)continue;let q9=n8?.querySelector(`.st-cp-boxv[aria-label="${$9}"]`);if(q9)q9.value=String(w8)}}O8(w8,$8,a)},onCommit:(w8,$8)=>O8(w8,$8,c)});return{onPointerDown:(w8)=>{G0=w8.currentTarget,M8(w8)}}},G9=(t,q0)=>{let G0=D[t],E0=G0!=null&&G0!==""?_Q(G0).n||G0:_Q(l9(U[t])??"").n||"0",u0=!G0||G0==="0"||G0==="0px"||G0==="auto",O8=t.split("-").pop(),M8=O8==="top"||O8==="bottom"?[`${q0}-top`,`${q0}-bottom`]:[`${q0}-left`,`${q0}-right`],w8=[`${q0}-top`,`${q0}-right`,`${q0}-bottom`,`${q0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${q0[0]}${t.split("-").pop()[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:E0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...X9(t,{sides:{pair:M8,all:w8}}),onFocus:q7,onKeyDown:($8)=>{if(wX($8,(n8)=>c(t,`${n8}px`)))return;if($8.key==="Enter")$8.currentTarget.blur()},onBlur:($8)=>{let n8=$8.currentTarget.value.trim();if(!n8)return;let $9=/[a-z%]/i.test(n8)?n8:`${n8}px`;c(t,$9)}},`${t}:${G0??""}`)},J7=(t)=>{let q0=D[t],G0=q0!=null&&q0!==""&&q0!=="auto"?_Q(q0).n||q0:_Q(l9(U[t])??"").n||"",E0=!q0||q0==="auto"||q0==="0"||q0==="0px",u0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],O8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${E0?" is-zero":""}`,"aria-label":t,defaultValue:G0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...X9(t,{sides:{pair:u0,all:O8},min:-1/0}),onFocus:q7,onKeyDown:(M8)=>{if(wX(M8,(w8)=>c(t,`${w8}px`)))return;if(M8.key==="Enter")M8.currentTarget.blur()},onBlur:(M8)=>{let w8=M8.currentTarget.value.trim();if(!w8)return;let $8=/[a-z%]/i.test(w8)?w8:`${w8}px`;c(t,$8)}},`${t}:${q0??""}`)},g9=Object.entries(M),i9=Object.entries(A),W7=()=>{let t=(X.tag||"").toLowerCase(),G0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!D["object-fit"]||!!D["object-position"]||!!D["aspect-ratio"],E0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:G0,canReplace:E0}},O7=(t)=>_(Y0,{children:[t&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),T0("object-fit",F0("object-fit",aq0)),T0("object-position",p9("object-position")),T0("aspect-ratio",_("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:We.includes(D["aspect-ratio"])?D["aspect-ratio"]:"",onChange:(q0)=>{let G0=q0.target.value;if(c("aspect-ratio",G0),G0&&G0!=="auto"&&D.height)n("height")},children:[K("option",{value:"",disabled:!0,children:l9(U["aspect-ratio"])||"—"}),We.map((q0)=>K("option",{value:q0,children:q0},q0))]}))]});return _("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Z8,children:[_("div",{className:"st-cp-id",children:[_("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?_("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(mw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(h9,{as:m4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(h9,{as:n4,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?_(Y0,{children:[Z0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(D.display||l9(U.display)||"").trim();return t==="flex"||t==="inline-flex"?_(Y0,{children:[T0("flex-direction",I8("flex-direction",D8),void 0,"Direction"),T0("align-items",K(kv,{value:e0(),onChange:b0,ariaLabel:"auto-layout alignment"}),p0("align-items"),"Alignment"),T0("gap",W8("gap","space"),void 0,"Gap"),_("div",{className:"st-cp-modes",children:[a0("width"),a0("height")]}),_("div",{className:"st-cp-box","aria-label":"padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[Q9(p0("padding-top")),"padding"]}),G9("padding-top","padding"),G9("padding-right","padding"),G9("padding-bottom","padding"),G9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:I0("Auto layout")}),d["Auto layout"]?T0("flex-wrap",K(FQ,{checked:/^wrap/.test(D["flex-wrap"]||l9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(G0)=>c("flex-wrap",G0?"wrap":"nowrap")}),p0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),Z0("Size",["width","height","min-width","max-width","min-height","max-height"],_(Y0,{children:[T0("width",V9("width"),void 0,"Width"),T0("height",V9("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:I0("Size")}),d.Size?_(Y0,{children:[T0("min-width",V9("min-width"),void 0,"Min width"),T0("max-width",V9("max-width"),void 0,"Max width"),T0("min-height",V9("min-height"),void 0,"Min height"),T0("max-height",V9("max-height"),void 0,"Max height")]}):null]})),Z0("Position",["position","top","right","bottom","left","z-index"],_(Y0,{children:[T0("position",F0("position",Xe),void 0,"Position"),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[Q9(p0("top")),"inset"]}),J7("top"),J7("right"),J7("bottom"),J7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:D.position||l9(U.position)||"static"})]}),(D.position||l9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:I0("Position")}),d.Position?T0("z-index",V9("z-index"),void 0,"Layer order"):null]}),!1),Z0("Fill",["background-color"],T0("background-color",c9("background-color"),void 0,"Fill")),Z0("Stroke",["border-width","border-style","border-color"],T0("border",N0(),p0("border-width"),"Stroke")),Z0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],T0("border-radius",j0(),p0("border-radius"),"Corner radius")),Z0("Effects",["box-shadow","filter","mix-blend-mode"],_(Y0,{children:[T0("box-shadow",l7("box-shadow","shadow")||p9("box-shadow"),void 0,"Shadow"),T0("filter",s0(),p0("filter"),"Blur"),T0("mix-blend-mode",F0("mix-blend-mode",Ye),void 0,"Blend")]})),Z0("Opacity",["opacity"],T0("opacity",M0(),void 0,"Opacity")),Z0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],_(Y0,{children:[T0("font-family",F0("font-family",at),void 0,"Font"),T0("color",c9("color"),void 0,"Color"),T0("font-size",W8("font-size","type"),void 0,"Size"),T0("font-weight",F0("font-weight",rt),void 0,"Weight"),T0("line-height",V9("line-height","lh"),void 0,"Line height"),T0("text-align",I8("text-align",d9),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:I0("Text")}),d.Text?_(Y0,{children:[T0("letter-spacing",V9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),T0("font-style",F0("font-style",rq0),void 0,"Style"),T0("text-transform",F0("text-transform",Je),void 0,"Case"),T0("white-space",F0("white-space",Qe),void 0,"Whitespace")]}):null]})),Z0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],_("div",{className:"st-cp-box","aria-label":"margin",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[Q9(p0("margin-top")),"margin"]}),G9("margin-top","margin"),G9("margin-right","margin"),G9("margin-bottom","margin"),G9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:q0}=W7();return t?Z0("Media",["object-fit","object-position","aspect-ratio"],O7(q0)):null})()]}):_(Y0,{children:[J8("Layout",(()=>{let t=(D.display||l9(U.display)||"").trim(),q0=t==="flex"||t==="inline-flex",G0=t==="grid"||t==="inline-grid";return _(Y0,{children:[T0("display",F0("display",oq0)),q0?_(Y0,{children:[T0("flex-direction",I8("flex-direction",D8)),T0("flex-wrap",K(FQ,{checked:/^wrap/.test(D["flex-wrap"]||l9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>c("flex-wrap",E0?"wrap":"nowrap")}),p0("flex-wrap"))]}):null,q0||G0?_(Y0,{children:[T0("align-items",I8("align-items",I9)),T0("justify-content",I8("justify-content",x8)),T0("gap",W8("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(D.display||l9(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let G0=D["grid-template-columns"]||"",E0=D["grid-template-rows"]||"",u0=nD(G0),O8=nD(E0),M8=u0.length>0||!G0.trim(),w8=O8.length>0||!E0.trim();return J8("Grid",_(Y0,{children:[M8?K(Ze,{label:"Columns",tracks:u0,editable:z,onChange:($8)=>c("grid-template-columns",rD($8))}):_("div",{className:"st-cp-note",children:["Columns use ",K("code",{children:G0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),w8?K(Ze,{label:"Rows",tracks:O8,editable:z,onChange:($8)=>c("grid-template-rows",rD($8))}):_("div",{className:"st-cp-note",children:["Rows use ",K("code",{children:E0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),J8("Position",_(Y0,{children:[T0("position",F0("position",Xe)),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[Q9(p0("top")),"inset"]}),J7("top"),J7("right"),J7("bottom"),J7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:D.position||l9(U.position)||"static"})]}),(D.position||l9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,T0("z-index",V9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&J8("Grid item",_(Y0,{children:[_("div",{className:"st-cp-note",children:["Manual cell placement — ",K("code",{children:"start / end"})," or ",K("code",{children:"start / span N"}),"."]}),T0("grid-column",p9("grid-column")),T0("grid-row",p9("grid-row"))]})),J8("Typography",_(Y0,{children:[T0("font-family",F0("font-family",at)),T0("color",c9("color")),T0("font-size",W8("font-size","type")),T0("font-weight",F0("font-weight",rt)),T0("line-height",V9("line-height","lh")),T0("letter-spacing",V9("letter-spacing",null,{min:-1/0})),T0("text-align",I8("text-align",d9)),T0("font-style",n0(),p0("font-style")),T0("text-transform",F0("text-transform",Je)),T0("white-space",F0("white-space",Qe))]})),J8("Spacing",K(Y0,{children:_("div",{className:"st-cp-box","aria-label":"margin and padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[Q9(p0("margin-top")),"margin"]}),G9("margin-top","margin"),G9("margin-right","margin"),G9("margin-bottom","margin"),G9("margin-left","margin"),_("div",{className:"st-cp-boxpad",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[Q9(p0("padding-top")),"padding"]}),G9("padding-top","padding"),G9("padding-right","padding"),G9("padding-bottom","padding"),G9("padding-left","padding"),_("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(D.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(D.height)||X.bounds?.h||0)]})]})]})})),J8("Size",_(Y0,{children:[_("div",{className:"st-cp-modes",children:[a0("width"),a0("height")]}),T0("width",V9("width")),T0("height",V9("height")),T0("min-width",V9("min-width")),T0("max-width",V9("max-width")),T0("min-height",V9("min-height")),T0("max-height",V9("max-height")),T0("overflow",I8("overflow",U9)),X8?_(Y0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),T0("align-self",F0("align-self",nq0)),T0("flex-grow",V9("flex-grow",null,{unitless:!0})),T0("flex-shrink",V9("flex-shrink",null,{unitless:!0})),T0("flex-basis",V9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:q0}=W7();return t?J8("Media",O7(q0)):null})(),J8("Appearance",_(Y0,{children:[T0("background-color",c9("background-color")),T0("border-radius",j0(),p0("border-radius")),T0("border",N0(),p0("border-width")),T0("box-shadow",l7("box-shadow","shadow")||p9("box-shadow")),T0("filter",s0(),p0("filter")),T0("mix-blend-mode",F0("mix-blend-mode",Ye)),T0("opacity",M0()),T0("rotation",c0(),p0("transform")),T0("transform",p9("transform")),T0("transform-origin",p9("transform-origin"))]})),(()=>{let t=Object.entries($).find(([,q0])=>typeof q0==="string"&&q0.startsWith("err:"));return t?_("div",{className:"st-cp-save is-err",role:"status",children:[K(W9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),J8("Advanced",_("div",{className:"st-cp-advbody",children:[g9.length?_(Y0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),g9.map(([t,q0])=>_("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(G0)=>{if(G0.key==="Enter")G0.currentTarget.blur()},onBlur:(G0)=>z0(t,G0.currentTarget.value)},`cs:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>o(t),children:K(W9,{name:"x",size:11})})]},`cs:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(eq0,{commit:z0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),i9.length?_(Y0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),i9.map(([t,q0])=>_("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(G0)=>{if(G0.key==="Enter")G0.currentTarget.blur()},onBlur:(G0)=>e(t,G0.currentTarget.value)},`at:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>V0(t),children:K(W9,{name:"x",size:11})})]},`at:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(X30,{commit:e})]}))]}),_("div",{className:"st-cp-legend",children:[_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function eq0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 X30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 J30={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function Q30(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===J)return G=z[U],z.splice(U,1),!0;if(z[U].children&&Z(z[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(z[U].children=z[U].children||[],Y==="inside-start")z[U].children.unshift(G);else z[U].children.push(G);else z.splice(Y==="before"?U:U+1,0,G);return!0}if(z[U].children&&H(z[U].children))return!0}return!1};return H(W)?W:X}var Y30=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function De({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:B,onRowPointerDown:F,dragState:L,componentMap:D,lockedKeys:M,onToggleLock:A,onRename:I}){let P=`${X.id}:${X.index}`,w=X.children&&X.children.length>0,R=W.has(P),T=!!X.synthetic,C=!T&&D?D[X.id]:null,b=!T&&!!M?.has(P),[$,y]=u.useState(!1),[v,g]=u.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),p=G?.has(P)?G.get(P):!!X.hidden,f=!!B&&!T&&!b,d=()=>{y(!1);let a=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!a||a===(X.dcElement??""))return;I?.(X,a)},l=L?.key===P,h=l?{transform:`translate(${L.dx}px, ${L.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 _(Y0,{children:[_("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(p?" is-hidden":"")+(T?" is-group":"")+(C?" is-instance":"")+(b?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":w?!R:void 0,"aria-grabbed":f?l:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${I?" · F2 to rename":""}`,"data-layer-key":P,onClick:()=>T?w&&Z(P):H(X),onMouseEnter:()=>!T&&z(X),onMouseLeave:()=>z(null),onPointerDown:f?(a)=>F(a,X,P):void 0,onKeyDown:(a)=>{if(a.key==="Enter"||a.key===" ")if(a.preventDefault(),T)w&&Z(P);else H(X);else if(a.key==="F2"&&I&&!T)a.preventDefault(),g(X.dcElement||X.label||""),y(!0)},children:[w?K("button",{type:"button",className:"st-layer-caret","aria-label":R?"Expand":"Collapse",onClick:(a)=>{a.stopPropagation(),Z(P)},children:R?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),C?K("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:C.root?"◆":"◇"}):K(W9,{name:J30[X.type]||"box",size:12,className:"st-layer-ticon"}),$?K("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(a)=>a.target.select(),onChange:(a)=>g(a.target.value),onClick:(a)=>a.stopPropagation(),onPointerDown:(a)=>a.stopPropagation(),onBlur:d,onKeyDown:(a)=>{if(a.stopPropagation(),a.key==="Enter")d();else if(a.key==="Escape")y(!1)}}):K("span",{className:"st-layer-label",onDoubleClick:I&&!T?(a)=>{a.stopPropagation(),g(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),K("span",{className:"st-layer-type",children:C?C.component:X.type}),A&&!T?K("button",{type:"button",className:"st-layer-lock","aria-label":b?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":b,title:b?"Unlock":"Lock",onClick:(a)=>{a.stopPropagation(),A(P)},children:K(W9,{name:b?"lock":"unlock",size:12})}):null,U&&!T?K("button",{type:"button",className:"st-layer-eye","aria-label":p?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":p,title:p?"Show":"Hide",onClick:(a)=>{a.stopPropagation(),U(X)},children:K(W9,{name:p?"eye-off":"eye",size:13})}):null]}),w&&!R?X.children.map((a,s)=>K(De,{node:a,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:B,onRowPointerDown:F,dragState:L,componentMap:D,lockedKeys:M,onToggleLock:A,onRename:I},`${a.id}:${a.index}`)):null]})}function W30({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let B=Q[U];if(B&&/var\(\s*--/.test(B))return B.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||B||""},W=(U,B)=>{let F=J[B]||Q[B];if(!F)return null;return _("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:U}),_("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:F},"aria-hidden":"true"}),K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(B)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?_Q(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 _(Y0,{children:[G?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Oe(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var G30=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],Z30=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function H30({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let z=Oe(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),B=Ne(X.file,J),F=Fe(J,U,B),L=(l)=>F.map((h)=>({ds:h.name,names:h[l]||[],vals:h.vals})).filter((h)=>h.names.length),D=(l)=>L(l).flatMap((h)=>(h.names||[]).map((a)=>({name:a,value:h.vals?.[a]||""}))),M=(l)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(l||"");if(!h)return l||"";for(let a of F){let s=a.vals?.[h[1]];if(s)return s}return""},A=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,I=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,P=(l,h)=>{if(!z)return;let a=Number.isFinite(l)&&l>0?Math.round(l):void 0,s=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(a==null&&s==null)return;Q?.(z,a,s)},w=Object.entries(W5).find(([,l])=>l.width===A&&l.height===I)?.[0],R=Object.entries(W5).find(([,l])=>l.width===A)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",C=X.attrs?.["data-dc-bg"]??"",b=X.attrs?.["data-dc-padding"]??"",$=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=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=(l)=>{if(!z)return;let h=null;if(l==="print"&&!g){let a={paper:"a4"};try{let s=g3(a);if(s)h={defaults:a,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(z,l==="digital"?null:l,h),l==="web"&&T)Y?.(z,!1,void 0)},p=(l)=>{if(!z)return;let h={paper:"a4",...g,...l},a;try{a=g3(h)}catch{return}Q?.(z,a.widthPx,a.heightPx),Z?.(z,h)},f=(l)=>{if(!z)return;let h=l&&Number.isFinite(I)?Math.round(I):void 0;Y?.(z,l,h)},d=(l)=>{if(!z)return;W?.(z,l)};return _("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),_("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[K(h6,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(l)=>P(l,null)}),K(h6,{value:I??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(l)=>{if(T)P(null,l)}})]}),K("div",{style:{padding:"0 12px 8px"},children:v==="print"?_("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(l)=>p({paper:l.currentTarget.value}),children:[K("option",{value:"",disabled:!0,children:"Paper size…"}),h3.map((l)=>_("option",{value:l.id,children:[l.label," — ",l.width,"×",l.height,l.unit]},l.id))]}):v==="web"?_("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:R??"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)P(h.width,null)},children:[K("option",{value:"",disabled:!0,children:R?`${W5[R].label} — ≤ ${W5[R].width}px`:"Breakpoint…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ≤ ",h.width,"px breakpoint"]},l))]}):_("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:w??"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)P(h.width,h.height)},children:[K("option",{value:"",disabled:!0,children:w?W5[w].label:"Preset size…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ",h.width,"×",h.height]},l))]})}),K("div",{style:{padding:"0 12px 8px"},children:K(_B,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(l)=>f(l==="fixed")})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Kind"})}),K("div",{style:{padding:"0 12px 8px"},children:K(s4,{value:v,ariaLabel:"artboard kind",options:Z30.map(([l,h])=>({value:l,label:h})),onChange:m})}),v!=="print"&&z&&H?K("div",{style:{padding:"0 12px 8px"},children:_("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)H(z,h.width);l.currentTarget.value=""},children:[K("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ",h.width,"px"]},l))]})}):null,v==="print"?_(Y0,{children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Print"})}),K("div",{style:{padding:"0 12px 8px"},children:K(_B,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(l)=>p({orientation:l})})}),K("div",{style:{padding:"0 12px 8px"},children:K(h6,{value:Number.isFinite(g?.bleedMm)?g.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(l)=>p({bleedMm:l})})})]}):null,K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),_("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let l=M(C),h=/var\(\s*--/.test(C),a=h?C.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):C;return K(t1,{swatch:K(gN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:L("color"),current:C,activeDs:B,swatchBg:l,seedHex:lN(l)||"#000000",onPick:(s)=>d({background:s||null}),label:"artboard background colour"}),displayValue:a,bound:h,ariaLabel:"artboard background",onValue:(s)=>d({background:(s||"").trim()||null})})})(),K(s4,{value:$,ariaLabel:"artboard body layout",options:G30.map(([l,h])=>({value:l,label:h})),onChange:(l)=>d({layout:l||null})}),_("div",{style:{display:"flex",gap:8},children:[K(AB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:D("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(l)=>d({padding:typeof l==="string"?l:l>0?l:null})}),K(AB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:D("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(l)=>d({gap:typeof l==="string"?l:l>0?l:null})})]})]})]})}var HR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,z30=new RegExp(HR.source,"gi");function K30(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(z30)||[])],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=HR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function U30({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:z,onHoverLayer:U,onReorderLayer:B,layersBusyRef:F,cfg:L,onOptimistic:D,onRecordEdit:M,onReplaceMedia:A,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C,onUndoRedo:b,editScope:$,tab:y,onTabChange:v,width:g,resizing:m,photoSel:p,photoRev:f,onPhotoEdit:d,onPhotoRemoveBackground:l,onPhotoRecordEdit:h,onPhotoUndoRedo:a,layersOnly:s=!1,hideLayersTab:c=!1,cpMode:z0,onSetCpMode:e}){let[n,o]=u.useState("inspect"),V0=s?"layers":y??n,f0=(N0)=>{o(N0),v?.(N0)},[G8,X8]=u.useState(()=>new Set),[a0,w0]=u.useState(()=>new Map);u.useEffect(()=>{let N0=Array.isArray(X)?X[0]:X,c0=N0?.id;if(!c0||!Q?.nodes)return;let s0=N0.index,M0=null,n0=[];if(function D8(x8,I9){for(let d9 of x8||[]){let U9=`${d9.id}:${d9.index}`;if(!d9.synthetic&&d9.id===c0&&(s0==null||d9.index===s0))return M0=U9,n0.push(...I9),!0;if(d9.children&&d9.children.length&&D8(d9.children,[...I9,U9]))return!0}return!1}(Q.nodes,[]),!M0)return;if(n0.length)X8((D8)=>{let x8=!1,I9=new Set(D8);for(let d9 of n0)if(I9.delete(d9))x8=!0;return x8?I9:D8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${M0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let d0=(N0)=>{let c0=`${N0.id}:${N0.index}`;return a0.has(c0)?a0.get(c0):!!N0.hidden},[Y8,k8]=u.useState(null),[e0,b0]=u.useState(""),Z8=(N0,c0)=>{if(!H||!N0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:N0.id,attr:"data-dc-element",value:c0})}).then((s0)=>s0.json().catch(()=>({}))).then((s0)=>{if(!s0.ok)return;M?.({op:"attr",canvas:H,id:N0.id,key:"data-dc-element",before:N0.dcElement??null,after:c0})}).catch(()=>{})},p0=B?(N0,c0,s0)=>{if(F?.current)return;if(N0?.synthetic||c0?.synthetic)return;let M0=s0==="before"?`before ${c0.label}`:s0==="after"?`after ${c0.label}`:`into ${c0.label}`;b0(`Moved ${N0.label} ${M0}`),B(N0.id,c0.id,s0,{idIndex:N0.index,refIndex:c0.index})}:void 0,C8=()=>{let N0=[];return function c0(s0,M0,n0){(s0||[]).forEach((D8,x8)=>{if(N0.push({node:D8,depth:M0,parentNode:n0,siblings:s0,pos:x8}),D8.children&&D8.children.length&&!G8.has(`${D8.id}:${D8.index}`))c0(D8.children,M0+1,D8)})}(Q?.nodes,0,null),N0},Q9=(N0)=>{if(N0.key!=="ArrowUp"&&N0.key!=="ArrowDown")return;if(!Z0)return;let c0=C8(),s0=c0.findIndex((x8)=>x8.node.id===Z0.id&&x8.node.index===Z0.index);if(s0<0)return;let M0=N0.key==="ArrowDown"?1:-1,n0=c0[s0];if(!N0.altKey){let x8=c0[s0+M0];if(x8)N0.preventDefault(),z?.(x8.node);return}if(!p0||!Array.isArray(n0.siblings))return;N0.preventDefault();let D8=(x8)=>x8&&x8.children&&x8.children.length&&!G8.has(`${x8.id}:${x8.index}`);if(!N0.shiftKey){if(M0<0&&n0.pos>0)p0(n0.node,n0.siblings[n0.pos-1],"before");else if(M0>0&&n0.pos<n0.siblings.length-1)p0(n0.node,n0.siblings[n0.pos+1],"after");return}if(M0>0){let x8=n0.siblings[n0.pos+1];if(x8)p0(n0.node,x8,D8(x8)?"inside-start":"after");else if(n0.parentNode)p0(n0.node,n0.parentNode,"after")}else{let x8=n0.siblings[n0.pos-1];if(x8)p0(n0.node,x8,D8(x8)?"inside-end":"before");else if(n0.parentNode)p0(n0.node,n0.parentNode,"before")}},Z9=u.useRef(null),T0=u.useRef(null),H9=(N0,c0,s0)=>{if(!p0||N0.button!==0||N0.metaKey||N0.ctrlKey||N0.shiftKey||N0.altKey)return;if(F?.current)return;let{clientX:M0,clientY:n0}=N0,D8=new Set([s0]);(function X9(G9){(G9.children||[]).forEach((J7)=>{D8.add(`${J7.id}:${J7.index}`),X9(J7)})})(c0);let x8=14,I9=6,d9=[];(function X9(G9,J7){(G9||[]).forEach((g9)=>{let i9=`${g9.id}:${g9.index}`;if(d9.push({node:g9,key:i9,id:g9.id,depth:J7,tag:g9.tag}),g9.children&&g9.children.length&&!G8.has(i9))X9(g9.children,J7+1)})})(Q?.nodes,0);let U9=new Map(d9.map((X9)=>[X9.key,X9])),l7=!1,q7=(X9)=>{if(!l7){if(Math.hypot(X9.clientX-M0,X9.clientY-n0)<4)return;l7=!0}let G9=X9.clientX-M0,J7=X9.clientY-n0,g9=null,i9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((O7)=>({rect:O7.getBoundingClientRect(),it:U9.get(O7.getAttribute("data-layer-key"))})).filter((O7)=>O7.it&&O7.it.key!==s0);if(i9.length){let O7=i9[0].rect.left,t=i9[0].rect.right,q0=i9.length;for(let q9=0;q9<i9.length;q9++)if(X9.clientY<i9[q9].rect.top+i9[q9].rect.height/2){q0=q9;break}let G0=i9[q0-1]?.it||null,E0=i9[q0]?.it||null,u0=Math.round((X9.clientX-O7-I9)/x8),O8=G0?G0.depth+(Y30.has(G0.tag)?0:1):0,M8=E0?E0.depth:0,w8=Math.max(M8,Math.min(u0,O8)),$8=null,n8="before",$9=0;if(!G0){if(E0)$8=E0,n8="before",$9=E0.depth}else if(w8>G0.depth)$8=G0,n8="inside-start",$9=G0.depth+1;else if(w8===G0.depth)$8=G0,n8="after",$9=G0.depth;else{for(let q9=q0-1;q9>=0;q9--)if(i9[q9].it.depth===w8){$8=i9[q9].it;break}if(!$8)$8=G0;n8="after",$9=w8}if($8&&$8.key!==s0&&!D8.has($8.key)){let q9=G0?i9[q0-1].rect.bottom:i9[0].rect.top,k6=O7+I9+$9*x8;g9={refId:$8.id,position:n8,node:$8.node,y:q9,left:k6,w:Math.max(24,t-k6)}}}let W7={key:s0,node:c0,dx:G9,dy:J7,target:g9};Z9.current=W7,k8(W7)},wX=()=>{window.removeEventListener("pointermove",q7),window.removeEventListener("pointerup",V9),window.removeEventListener("keydown",c9,!0)},p9=()=>{let X9=(G9)=>{G9.preventDefault(),G9.stopImmediatePropagation(),document.removeEventListener("click",X9,!0)};document.addEventListener("click",X9,!0),setTimeout(()=>document.removeEventListener("click",X9,!0),300)},V9=()=>{wX();let X9=Z9.current;if(Z9.current=null,k8(null),l7&&X9?.target)p9(),p0(X9.node,X9.target.node,X9.target.position)},c9=(X9)=>{if(X9.key!=="Escape")return;if(X9.preventDefault(),X9.stopImmediatePropagation(),wX(),Z9.current=null,k8(null),l7)p9()};window.addEventListener("pointermove",q7),window.addEventListener("pointerup",V9),window.addEventListener("keydown",c9,!0)},$0=(N0)=>X8((c0)=>{let s0=new Set(c0);if(s0.has(N0))s0.delete(N0);else s0.add(N0);return s0}),J8=(N0)=>{let c0=`${N0.id}:${N0.index}`,s0=d0(N0),M0=!s0;if(w0((n0)=>new Map(n0).set(c0,M0)),D?.({id:N0.id,artboardId:Q?.artboardId??null,index:N0.index,prop:"display",value:M0?"none":null}),!H||!N0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0?{canvas:H,id:N0.id,property:"display",value:"none"}:{canvas:H,id:N0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:N0.id,key:"display",before:s0?"none":null,after:M0?"none":null})},Z0=Array.isArray(X)?X[0]:X,I0=p?{asset:p.asset,kind:"annotation-image"}:(()=>{let N0=K30(Z0);return N0?{asset:N0,kind:"artboard-img"}:null})(),F0=I0?.kind==="annotation-image",z8=(N0)=>{if(!(N0.metaKey||N0.ctrlKey)||N0.altKey)return;let c0=N0.key.toLowerCase();if(c0==="z")N0.preventDefault(),a?.(N0.shiftKey?"redo":"undo");else if(c0==="y")N0.preventDefault(),a?.("redo")},I8=F0?"photo":V0==="photo"&&!I0?"inspect":V0,W8=(N0,c0,s0)=>_("button",{type:"button",className:"st-rp-tab"+(I8===N0?" is-active":""),onClick:()=>f0(N0),children:[K(W9,{name:s0,size:14}),c0]}),j0=Z0?.bounds||null;return _("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[_("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[F0?W8("photo","Photo","image"):_(Y0,{children:[W8("inspect","Inspect","sliders"),!c&&W8("layers","Layers","layers"),W8("css","CSS","code"),I0?W8("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(W9,{name:"x",size:14})})]}),Z0?.id&&!(Array.isArray(X)&&X.length>1)&&$?_("div",{className:`st-scope st-scope--${$.scope}`,title:$.scope==="shared"?`Editing this element's style changes ${$.affects} place${$.affects===1?"":"s"}${$.componentName?` (component ${$.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),$.scope==="shared"?`Shared${$.componentName?` · ${$.componentName}`:""} · edits ${$.affects} place${$.affects===1?"":"s"}`:"Local · this element only",$.scope==="shared"&&Z?K("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(Z0.id,Z0.index),children:"Detach"}):null]}):null,K("div",{className:"st-rp-body",children:I8==="photo"&&I0?K("div",{onKeyDown:z8,children:K(sv,{asset:I0.asset,ColorPicker:Le,StIcon:W9,onEdit:(N0)=>d?.(I0.asset,N0),onRemoveBackground:l,onRecordEdit:(N0,c0)=>h?.(I0.asset,N0,c0)},`${I0.asset}:${f??0}`)}):!Z0&&!(I8==="layers"&&Q?.nodes?.length)?K("div",{className:"st-rp-empty",children:_("p",{children:["Press ",K(JX,{children:"V"}),", then click an element to select it — or ",K(JX,{children:"⌘"}),"-click straight from Browse."]})}):Z0&&I8==="inspect"?_(Y0,{children:[K("div",{className:"st-rp-hd",children:Z0.selector||Z0.tag||"element"}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:j0?Math.round(j0.x):"—",readOnly:!0,"aria-label":"x position"})]}),_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:j0?Math.round(j0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:j0?Math.round(j0.w):"—",readOnly:!0,"aria-label":"width"})]}),_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:j0?Math.round(j0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z0.tag||"—"})})]}),Z0.classes?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z0.classes})})]}):null,K(W30,{el:Z0})]}):I8==="layers"?_(Y0,{children:[_("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?_(Y0,{children:[p0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:T0,onKeyDown:Q9,children:Q.nodes.map((N0,c0)=>K(De,{node:N0,depth:0,selectedId:Z0?.id,selectedIndex:Z0?.index,collapsed:G8,hiddenOverride:a0,onToggle:$0,onSelect:(s0)=>{z?.(s0),T0.current?.focus()},onHover:(s0)=>U?.(s0),onToggleVisibility:J8,onReorder:p0,onRowPointerDown:H9,dragState:Y8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:Z8},`${N0.id}:${N0.index}`))}),Y8?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:Y8.target.left,top:Y8.target.y-1,width:Y8.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:e0})]}):Z0&&Array.isArray(Z0.dom_path)&&Z0.dom_path.length?Z0.dom_path.map((N0,c0)=>_("div",{className:"st-layer"+(c0===Z0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+c0*12},children:[K(W9,{name:"square",size:13}),N0]},c0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z0.id&&Oe(Z0)?K(H30,{el:Z0,cfg:L,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C}):K(tq0,{el:Z0,cfg:L,onOptimistic:D,onRecordEdit:M,onReplaceMedia:A,onUndoRedo:b,mode:z0,onSetMode:e})})]})}function V30(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[z,U]=u.useState(null),B=u.useRef(null);u.useEffect(()=>{B.current=z},[z]);let[F,L]=u.useState(null);u.useEffect(()=>{let q=Array.isArray(z)?z.length===1?z[0]:null:z,N=q&&typeof q.id==="string"?q.id:null;if(!N||!Z){L(null);return}let O=new AbortController,E=new URLSearchParams({canvas:Z,id:N});return fetch(`/_api/edit-scope?${E}`,{signal:O.signal}).then((k)=>k.ok?k.json():null).then((k)=>{if(k?.ok)L(k)}).catch(()=>{}),()=>O.abort()},[z,Z]);let D=u.useRef(0),M=u.useRef([]),A=u.useCallback((q)=>{if(!q?.id||!q.file)return;for(let N of M.current)clearTimeout(N);M.current=[50,450,1200,2500,5000].map((N)=>setTimeout(()=>{let O=B.current,E=Array.isArray(O)?O[0]:O;if(!E||E.id!==q.id||E.file!==q.file)return;let k=v8.current.get(q.file);if(!k?.contentWindow)return;try{k.contentWindow.postMessage({dgn:"select-by-id",id:q.id,artboardId:q.artboardId??null,index:q.index??0},"*")}catch{}},N))},[]),I=u.useRef([]),P=u.useCallback((q,N)=>{if(!q||!N)return;for(let O of I.current)clearTimeout(O);I.current=[50,450,1200,2500,5000].map((O)=>setTimeout(()=>{let E=B.current,k=Array.isArray(E)?E[0]:E;if(!k||k.artboardId!==q||k.file!==N)return;let j=v8.current.get(N);if(!j?.contentWindow)return;try{j.contentWindow.postMessage({dgn:"select-by-id",artboardId:q},"*")}catch{}},O))},[]),w=u.useRef(null),R=u.useRef(null),T=u.useRef(null),C=u.useRef(null),b=u.useRef(!1),$=u.useRef(null),[y,v]=u.useState(null),[g,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!y)return;let q=Date.now(),N=p.current;if(N.canvas===Z&&q-N.at<1500)return;p.current={canvas:Z,at:q},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((O)=>O.json()).then((O)=>{if(O?.ok&&O.map&&typeof O.map==="object")m(O.map);else m(null)}).catch(()=>m(null))},[Z,y]);let[f,d]=u.useState(!1),[l,h]=u.useState(null),[a,s]=u.useState(null),[c,z0]=u.useState(null),[e,n]=u.useState(null),[o,V0]=u.useState(!1),[f0,G8]=u.useState(null),[X8,a0]=u.useState(""),[w0,d0]=u.useState(null),[Y8,k8]=u.useState(null),e0=u.useRef(null),b0=pt("maude-sb-w",{min:200,max:420,def:252}),Z8=pt("maude-rp-w",{min:260,max:480,def:304}),[p0,C8]=u.useState(null),Q9=u.useRef(null);u.useEffect(()=>{if(!p0)return;let q=(O)=>{let E=Q9.current?.getBoundingClientRect();if(!E)return;if(p0==="sb")b0.setW(O.clientX-E.left);else Z8.setW(E.right-O.clientX)},N=()=>C8(null);return window.addEventListener("pointermove",q),window.addEventListener("pointerup",N),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",N)}},[p0,b0.setW,Z8.setW]);let Z9=u.useCallback((q)=>{clearTimeout(e0.current),e0.current=setTimeout(()=>{k8((N)=>N===q?null:N)},2500)},[]);u.useEffect(()=>{if(!Y8)return;let q=setTimeout(()=>k8(null),15000);return()=>clearTimeout(q)},[Y8]);let[T0,H9]=u.useState({designRel:".design"}),$0=u.useCallback(()=>{fetch("/_config").then((q)=>q.json()).then((q)=>{let N=(q.designRoot||".design").replace(/^\/+|\/+$/g,"");H9((O)=>({...O,designRel:N,tokensCssRel:q.tokensCssRel,designSystems:q.designSystems,canvasOrigin:q.canvasOrigin}))}).catch(()=>{})},[]);u.useEffect(()=>{$0()},[$0]),u.useEffect(()=>{let q=!1;return fetch("/_sync-status").then((N)=>N.json()).then((N)=>{if(q||!N||N.linked===!1)return;s(N)}).catch(()=>{}),()=>{q=!0}},[]),u.useEffect(()=>{let q=!1;return fetch("/_api/git/status").then((N)=>N.json()).then((N)=>{if(!q&&N)z0(N)}).catch(()=>{}),()=>{q=!0}},[]);let[J8,Z0]=u.useState({}),[I0,F0]=u.useState(null),[z8,I8]=u.useState(!1),[W8,j0]=u.useState("open"),[N0,c0]=u.useState(eV0),[s0,M0]=u.useState(()=>{return eP(bt,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(bt,JSON.stringify(s0))}catch{}},[s0]);let[n0,D8]=u.useState(null),[x8,I9]=u.useState(()=>RZ(jt,!0)),[d9,U9]=u.useState(()=>RZ($t,!1)),[l7,q7]=u.useState(()=>eP(St,{})),[wX,p9]=u.useState(!1),[V9,c9]=u.useState(!1);u.useEffect(()=>{if(!l8())return;let q=kf(()=>c9(!0));return()=>{q.then((N)=>N()).catch(()=>{})}},[]);let[X9,G9]=u.useState(!1),[J7,g9]=u.useState(!1),[i9,W7]=u.useState(!1),[O7,t]=u.useState(!1),{report:q0}=fw(l8()),[G0,E0]=u.useState(!1),[u0,O8]=u.useState(!1),[M8,w8]=u.useState(null),[$8,n8]=u.useState(!1),[$9,q9]=u.useState(!1),[k6,u5]=u.useState(!1),[l5,_J]=u.useState(!1),[r8,d5]=u.useState(()=>eP(xt,tz)),[d6,$7]=u.useState(()=>{try{let q=localStorage.getItem(ht);if(q==="separate"||q==="in-inspector")return q}catch{}return"separate"}),[gX,m9]=u.useState(!1),[o9,mX]=u.useState([]),[QX,n9]=u.useState(0),[G5,_X]=u.useState(!1),[u9,uX]=u.useState(!1),[T6,B7]=u.useState(!1),[YX,S9]=u.useState(1),[r9,Z5]=u.useState(216),[d7,H5]=u.useState(null),[p6,z5]=u.useState([]),[NW,EY]=u.useState([]),[PY,i]=u.useState([]),[Q0,K0]=u.useState(0),L0=u.useMemo(()=>{if(!o9.length)return null;return(o9.find((N)=>N.durationInFrames===Q0)??o9[0]).id},[o9,Q0]),B0=u.useRef(null);u.useEffect(()=>{B0.current=L0},[L0]);let l0=u.useRef(0);u.useEffect(()=>{l0.current=QX},[QX]);let[v0,c8]=u.useState(null),g8=u.useRef(null);u.useEffect(()=>{g8.current=v0},[v0]);let[lX,WX]=u.useState(null),[S7,dX]=u.useState(0),W6=u.useCallback((q,N)=>{if(/concurrent edit|changed since it was read/i.test(N||""))A8("Timeline changed — reloaded, try again."),dX((O)=>O+1);else A8(`${q}: ${N||"failed"}`)},[]),[N6,EQ]=u.useState(!1),[PQ,AJ]=u.useState(!1),[pX,F6]=u.useState(!1),AX=u.useRef(N6);u.useEffect(()=>{if(AX.current=N6,N6){F6(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[N6]);let E8=u.useCallback(()=>{if(!AX.current||document.hidden)F6(!0),mt("Claude finished","Your assistant turn is ready in Maude.")},[]),p7=u.useRef(0),H7=u.useCallback(()=>{if(!AX.current||document.hidden){F6(!0);let q=Date.now();if(q-p7.current<sV0)return;p7.current=q,mt("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[G7,k9]=u.useState("inspect"),[FW,EX]=u.useState(null),EJ=u.useRef({undo:[],redo:[]}),[LW,JK]=u.useState(0),[c6,DW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),RY=u.useRef(c6);u.useEffect(()=>{RY.current=c6;try{localStorage.setItem("maude-auto-open-inspector",c6?"1":"0")}catch{}},[c6]);let IZ=u.useRef(!1);u.useEffect(()=>{IZ.current=k6||z8||o||N6},[k6,z8,o,N6]);let cX=u.useRef({open:{},side:tz});cX.current={open:{tree:x8,layers:l5,inspector:k6,comments:z8,changes:o,assistant:N6},side:r8};let RQ=u.useCallback((q,N)=>{if(q==="tree")I9(N);else if(q==="layers")_J(N);else if(q==="inspector")u5(N);else if(q==="comments")I8(N);else if(q==="changes")V0(N);else if(q==="assistant")EQ(N)},[]),OW=u.useCallback((q)=>cX.current.side?.[q]||tz[q],[]),f7=u.useCallback((q)=>{let N=OW(q);RQ(q,!0);for(let O of WR)if(O.id!==q&&OW(O.id)===N)RQ(O.id,!1)},[RQ,OW]),K5=u.useCallback((q)=>{if(cX.current.open?.[q])RQ(q,!1);else f7(q)},[f7,RQ]),PX=f7,C6=K5,MW=u.useCallback((q)=>{if(!RY.current)return;if(!q||!q.id)return;if(IZ.current)return;PX("inspector"),k9("css")},[PX]),IY=u.useCallback(()=>m9((q)=>!q),[]),PJ=Fx(ZR),kY=Jx(),[QK,YK]=u.useState(!1),[kZ,TZ]=u.useState(!1);u.useEffect(()=>{if(!l8())return;let q=!0;return Sf().then((N)=>{if(!q)return;if(YK(!!N),!N&&!RZ(Ct,!1))TZ(!0)}).catch(()=>{}),()=>{q=!1}},[]);let CZ=u.useCallback(()=>{TZ(!1);try{localStorage.setItem(Ct,"1")}catch{}},[]),[WK,$Z]=u.useState(null);u.useEffect(()=>{if(!l8())return;let q;return ff((N)=>$Z(N&&typeof N==="object"?N:{})).then((N)=>{q=N}).catch(()=>{}),()=>{try{q?.()}catch{}}},[]);let[p5,SZ]=u.useState(null),[wW,GK]=u.useState(()=>!RZ(Tt,!1)),iX=u.useCallback((q)=>{SZ(Array.isArray(q)&&q.length?q:null)},[]),_W={setup:(q)=>{if(!q)return;if((q.canvas||q.requireSelection)&&W.length===0)f7("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(q.inspector||q.tab||q.requireSelection)PX("inspector");if(q.tab)k9(q.tab);if(q.changes)PX("changes")}},IQ=u.useCallback(()=>{GK(!1);try{localStorage.setItem(Tt,"1")}catch{}},[]),[c5,bZ]=u.useState(()=>RZ(vt,!0)),[TY,AW]=u.useState(!1),[c7,jZ]=u.useState(()=>RZ(yt,!1)),[RX,yZ]=u.useState(()=>RZ(ft,!1)),[GX,EW]=u.useState(!1),[ZK,RJ]=u.useState(!1),[PW,CY]=u.useState(0),[RW,HK]=u.useState(null),[zK,fZ]=u.useState(!1),IW=u.useRef(null),$Y=u.useRef(null),v8=u.useRef(new Map),q8=u.useCallback((q)=>{let N=Z?v8.current.get(Z):null;if(!N||!N.contentWindow)return;try{N.contentWindow.postMessage(q,"*")}catch{}},[Z]),oX=u.useCallback((q,N)=>q8({dgn:"photo-preview",asset:q,edit:N}),[q8]),ZX=u.useCallback((q,N,O)=>{EJ.current.undo.push({asset:q,before:N,after:O}),EJ.current.redo.length=0},[]),kQ=u.useCallback((q)=>{let N=q?EJ.current.redo:EJ.current.undo;if(!N.length)return!1;let O=N.pop();(q?EJ.current.undo:EJ.current.redo).push(O);let E=(q?O.after:O.before)||{};return oX(O.asset,E),fetch(`/_api/photo-edit?asset=${encodeURIComponent(O.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)}).catch(()=>{}),JK((k)=>k+1),!0},[oX]),KK=u.useCallback(async(q)=>{q8({dgn:"photo-busy",asset:q,busy:!0});try{let N=await fetch(`/${q.replace(/^\/+/,"")}`);if(!N.ok)return null;let O=await N.blob(),{removeBackground:E}=await Promise.resolve().then(() => (kt(),It)),k=await E(O),j=await fetch("/_api/asset",{method:"POST",headers:{"content-type":k.type||"image/png"},body:k}),S=await j.json().catch(()=>({}));if(j.ok&&S.path)return{maskAsset:S.path};return null}catch(N){return console.error("[photo] background removal failed",N),null}finally{q8({dgn:"photo-busy",asset:q,busy:!1})}},[q8]);u.useEffect(()=>{let q=(E)=>Array.from(E.dataTransfer?.types??[]).includes("Files"),N=(E)=>{if(q(E))E.preventDefault()},O=(E)=>{if(q(E))E.preventDefault()};return document.addEventListener("dragover",N),document.addEventListener("drop",O),()=>{document.removeEventListener("dragover",N),document.removeEventListener("drop",O)}},[]);let G6=u.useRef({});G6.current={open:gX,comps:o9,frame:QX,total:Q0,playing:G5,compId:L0,muted:T6,loop:u9,sequences:p6,post:q8,canvas:Z};let nX=u.useRef({undo:[],redo:[]}),E7=u.useCallback((q,N,O)=>{if(typeof N!=="number")return;if(nX.current.undo.push({canvas:q,seq:N,label:O}),nX.current.redo=[],nX.current.undo.length>50)nX.current.undo.shift()},[]),kW=u.useCallback((q)=>{let N=nX.current,O=q==="undo"?N.undo:N.redo,E=q==="undo"?N.redo:N.undo,k=G6.current.canvas,j=-1;for(let x=O.length-1;x>=0;x--)if(O[x].canvas===k){j=x;break}if(j<0){A8(q==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let S=O[j];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S.canvas,seq:S.seq,dir:q})}).then((x)=>x.json().catch(()=>({}))).then((x)=>{if(O.splice(j,1),x?.ok)E.push(S),A8(`${q==="undo"?"Undid":"Redid"}: ${S.label}`,!0);else A8(`${q==="undo"?"Undo":"Redo"} skipped: ${x?.error||"failed"}`)}).catch(()=>A8(`${q==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=u.useCallback((q,N)=>{let O=q?.ok&&Array.isArray(q.clips)?q.clips.filter((E)=>E.kind==="sequence"):[];if(N==null)return null;if(typeof N==="object")return(N.stableId?O.find((E)=>E.stableId===N.stableId):null)||(Number.isInteger(N.index)?O[N.index]:null)||null;if(typeof N==="string")return O.find((E)=>E.stableId===N)||null;return O[N]||null},[]),SY=u.useCallback((q)=>{let N=G6.current.canvas;if(!N||N===T8)return;let O=g8.current||void 0,E=`/_api/comp-clips?canvas=${encodeURIComponent(N)}${O?`&artboardId=${encodeURIComponent(O)}`:""}`;fetch(E).then((k)=>k.json().catch(()=>({}))).then((k)=>{let j=Z6(k,q);if(!j?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:N,artboardId:O,stableId:j.stableId,contentHash:j.contentHash})})}).then((k)=>k?k.json():null).then((k)=>{if(k&&!k.ok)console.warn("[remove-clip]",k.error||"failed"),W6("Remove refused",k.error);else if(k?.ok){if(A8("Clip removed.",!0),k.seq!=null)E7(N,k.seq,"remove clip");WX(null)}}).catch(()=>A8("Remove failed: network error"))},[Z6,E7]),i5=u.useCallback((q,N,O)=>{let E=G6.current.canvas;if(!E||E===T8)return;let k=g8.current||void 0,j=`/_api/comp-clips?canvas=${encodeURIComponent(E)}${k?`&artboardId=${encodeURIComponent(k)}`:""}`;fetch(j).then((S)=>S.json().catch(()=>({}))).then((S)=>{let x=S?.ok&&Array.isArray(S.clips)?S.clips:[],r=q?.transition?x.find((X0)=>X0.kind==="transition"&&X0.stableId===q.stableId)||null:Z6(S,q);if(!r?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:E,artboardId:k,stableId:r.stableId,contentHash:r.contentHash,verb:N,...O})})}).then((S)=>S?S.json():null).then((S)=>{if(S&&!S.ok)console.warn("[clip-edit]",N,S.error||"failed"),W6(`${N} refused`,S.error);else if(S?.ok){let x={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(A8(`Applied: ${x[N]||N}.`,!0),S.seq!=null)E7(E,S.seq,x[N]||N)}}).catch(()=>A8(`${N} failed: network error`))},[Z6,E7,W6]),[o5,bY]=u.useState(null),n5=u.useCallback((q,N="")=>new Promise((O)=>{bY({title:q,value:N,resolve:O})}),[]),U5=u.useCallback((q)=>{bY((N)=>{return N?.resolve?.(q),null})},[]),vZ=u.useCallback((q,N)=>{let O=G6.current.canvas;if(!O||O===T8||!N||!String(N).trim())return;C0({type:"comments-add",payload:{file:O,text:String(N).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:q}}),A8("Comment added.",!0)},[]);G6.current.selected=lX,G6.current.setSelected=WX,G6.current.removeClip=SY,G6.current.clipVerb=i5,G6.current.addComment=vZ,G6.current.askText=n5,u.useEffect(()=>{let q=(N)=>{let O=G6.current;if(!O.open||!O.comps?.length)return;let E=N.target,k=E?.tagName;if(k==="INPUT"&&E?.type!=="range")return;if(k==="TEXTAREA"||k==="SELECT"||E?.isContentEditable)return;let j=O.comps[0]?.fps||30,S=Math.max(1,O.total),x=(X0)=>{let H0=Math.max(0,Math.min(S-1,Math.round(X0)));n9(H0),_X(!1),O.post({dgn:"timeline-seek",frame:H0,id:O.compId})},r=()=>{let X0=new Set([0,S-1]);for(let H0 of O.sequences||[]){X0.add(H0.from);for(let U0 of H0.keyframes||[])X0.add(U0.from),X0.add(U0.to)}return[...X0].filter((H0)=>H0>=0&&H0<S).sort((H0,U0)=>H0-U0)};if((N.metaKey||N.ctrlKey)&&(N.key==="z"||N.key==="Z")){N.preventDefault(),kW(N.shiftKey?"redo":"undo");return}if(N.key==="Escape"){if(O.selected!=null)N.preventDefault(),O.setSelected?.(null);return}if((N.key==="Delete"||N.key==="Backspace")&&O.selected!=null){N.preventDefault(),O.removeClip?.({stableId:O.selected});return}if((N.metaKey||N.ctrlKey)&&(N.key==="b"||N.key==="B")){N.preventDefault();let X0=O.selected!=null?{stableId:O.selected}:null;if(!X0){let H0=O.sequences||[],U0=H0.find((o0)=>o0.series&&O.frame>=o0.from&&O.frame<o0.from+o0.duration)||H0.find((o0)=>O.frame>=o0.from&&O.frame<o0.from+o0.duration);if(U0?.stableId)X0={stableId:U0.stableId}}if(X0)O.clipVerb?.(X0,"split",{atFrame:O.frame});else A8("Nothing under the playhead to split.");return}if(N.key===" "||N.code==="Space")if(N.preventDefault(),O.playing)_X(!1),O.post({dgn:"timeline-pause",id:O.compId});else _X(!0),O.post({dgn:"timeline-mute",muted:O.muted,id:O.compId}),O.post({dgn:"timeline-loop",loop:O.loop,id:O.compId}),O.post({dgn:"timeline-play",id:O.compId});else if(N.key==="ArrowRight")N.preventDefault(),x(O.frame+(N.shiftKey?j:1));else if(N.key==="ArrowLeft")N.preventDefault(),x(O.frame-(N.shiftKey?j:1));else if(N.key==="Home")N.preventDefault(),x(0);else if(N.key==="End")N.preventDefault(),x(S-1);else if(N.key==="."){N.preventDefault();let X0=r().find((H0)=>H0>O.frame);if(X0!=null)x(X0)}else if(N.key===","){N.preventDefault();let X0=r().reverse().find((H0)=>H0<O.frame);if(X0!=null)x(X0)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),u.useEffect(()=>{mX([]),n9(0),_X(!1),WX(null),c8(null);let q=setTimeout(()=>q8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(q)},[Z,q8]);let[V5,IJ]=u.useState(""),[W0,TW]=u.useState([]),[CW,jY]=u.useState([]);u.useEffect(()=>{if(!gX||o9.length===0||!Z||Z===T8){IJ(""),TW([]);return}let q=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((N)=>N.ok?N.json():null).then((N)=>{if(q&&N?.ok&&typeof N.source==="string")IJ(N.source)}).catch(()=>{}),()=>{q=!1}},[gX,o9,Z,S7]),u.useEffect(()=>{if(!gX||!Z||Z===T8||!V5){TW([]),jY([]);return}let q=!0,N=v0||void 0,O=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${N?`&artboardId=${encodeURIComponent(N)}`:""}`;return fetch(O).then((E)=>E.ok?E.json():null).then((E)=>{if(!q)return;let k=E?.ok&&Array.isArray(E.clips)?E.clips:[];TW(k.filter((j)=>j.kind==="sequence")),jY(k.filter((j)=>j.kind==="transition"))}).catch(()=>{}),()=>{q=!1}},[gX,Z,V5,v0,S7]),u.useEffect(()=>{if(!V5){z5([]),EY([]),i([]),K0(0);return}let q=o9[0]?.durationInFrames||0,N=d7??z?.artboardId??null,O=ov(V5,q,N);c8(O.artboardId??N??null);let E=O.sequences.map((k,j)=>{let S=W0[j];if(!S)return k;return{...k,stableId:S.stableId,contentHash:S.contentHash,mediaProps:S.mediaProps??null,placeholder:S.placeholder??null,mediaTag:S.mediaTag??k.mediaTag,mediaSrc:S.mediaSrc??k.mediaSrc,replaceable:!!(S.mediaCdId||S.mediaArrayRef),layers:Array.isArray(S.layers)?S.layers:[],hidden:!!S.hidden}});z5(E),EY(O.audio||[]),i(O.transitions||[]),K0(O.total)},[V5,W0,z,o9,d7]);let kJ=u.useCallback(()=>{bZ((q)=>{let N=!q,O=Z?v8.current.get(Z):null;if(O&&O.contentWindow)try{O.contentWindow.postMessage({dgn:"view-annotations",visible:N},"*")}catch{}return N})},[Z]),T9=u.useCallback((q)=>{for(let N of v8.current.values())try{N.contentWindow.postMessage({dgn:"view-chrome",...q},"*")}catch{}},[]),TJ=u.useCallback(()=>{jZ((q)=>{let N=!q;return T9({minimap:N}),N})},[T9]),r5=u.useCallback(()=>{yZ((q)=>{let N=!q;return T9({zoom:N}),N})},[T9]),$W=u.useCallback(()=>{EW((q)=>{let N=!q;return T9({present:N}),N})},[T9]),TQ=u.useCallback(()=>{EW(!1),T9({present:!1})},[T9]),SW=u.useCallback(()=>{if(!Z||Z===T8)return;RJ((q)=>{let N=!q;return q8({dgn:"view-chrome",print:N}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:N}}})}).catch(()=>{}),N})},[Z,q8]);u.useEffect(()=>{let q=!1;return fetch("/_api/git-user").then((N)=>N.json()).then((N)=>{if(q)return;let O=N&&typeof N.name==="string"?N.name.trim():"";if(O)HK(O)}).catch(()=>{}),()=>{q=!0}},[]),u.useEffect(()=>{if(!Z||Z===T8){CY(0),RJ(!1);return}let q=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((N)=>N.json()).then((N)=>{if(q)return;let O=Array.isArray(N?.artboards)?N.artboards.length:0;CY(O),RJ(N?.overlays?.print===!0),CQ(new Set(Array.isArray(N?.locked)?N.locked:[]))}).catch(()=>{if(!q)CY(0),RJ(!1),CQ(new Set)}),()=>{q=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===T8||!d7)return;let q=setTimeout(()=>{q8({dgn:"request-layers",artboardId:d7})},250);return()=>clearTimeout(q)},[Z,d7,q8]);let[q5,CQ]=u.useState(()=>new Set),bW=u.useCallback((q)=>{if(!Z||Z===T8)return;CQ((N)=>{let O=new Set(N);if(O.has(q))O.delete(q);else O.add(q);let E=[...O];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:E}})}).catch(()=>{}),q8({dgn:"locked-set",locked:E}),O})},[Z,q8]);u.useEffect(()=>{if(!Z||Z===T8)return;q8({dgn:"locked-set",locked:[...q5]})},[q5,Z,q8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",N0),localStorage.setItem(Ke,N0)}catch{}for(let q of v8.current.values())try{q.contentWindow.postMessage({dgn:"theme",theme:N0},"*")}catch{}},[N0]),u.useEffect(()=>{try{localStorage.setItem(jt,x8?"1":"0")}catch{}},[x8]),u.useEffect(()=>{try{localStorage.setItem($t,d9?"1":"0")}catch{}},[d9]),u.useEffect(()=>{try{localStorage.setItem(St,JSON.stringify(l7))}catch{}},[l7]),u.useEffect(()=>{try{localStorage.setItem(yt,c7?"1":"0")}catch{}},[c7]),u.useEffect(()=>{try{localStorage.setItem(ft,RX?"1":"0")}catch{}},[RX]),u.useEffect(()=>{try{localStorage.setItem(vt,c5?"1":"0")}catch{}},[c5]),u.useEffect(()=>{let q=!1;return fetch("/_api/ui-prefs").then((N)=>N.ok?N.json():Promise.reject(Error(`HTTP ${N.status}`))).then((N)=>{if(q||!N||typeof N!=="object")return;if(N.theme==="light"||N.theme==="dark")c0(N.theme);if(typeof N.minimap==="boolean")jZ(N.minimap);if(typeof N.zoom==="boolean")yZ(N.zoom);if(typeof N.annotations==="boolean")bZ(N.annotations);if(typeof N.autoOpenInspector==="boolean")DW(N.autoOpenInspector);if(N.panelSides&&typeof N.panelSides==="object")d5({...tz,...N.panelSides});if(N.layersMode==="separate"||N.layersMode==="in-inspector")$7(N.layersMode)}).catch(()=>{}).finally(()=>{if(!q)AW(!0)}),()=>{q=!0}},[]),u.useEffect(()=>{if(!TY)return;tV0({theme:N0,minimap:c7,zoom:RX,annotations:c5,autoOpenInspector:c6,panelSides:r8,layersMode:d6})},[TY,N0,c7,RX,c5,c6,r8,d6]),u.useEffect(()=>{try{localStorage.setItem(xt,JSON.stringify(r8))}catch{}},[r8]),u.useEffect(()=>{try{localStorage.setItem(ht,d6)}catch{}},[d6]);let g0=u.useCallback((q,N)=>{q7((O)=>{let E=O[q],k=E===void 0?N:E;return{...O,[q]:!k}})},[]),HX=u.useCallback(()=>{c0((q)=>q==="dark"?"light":"dark")},[]),a9=u.useCallback(async()=>{try{let N=await(await fetch("/_index-data")).json();Y(N.project||"Design");let O=N.groups.map((E)=>({...E,tree:Wq0(E.paths,E.stripPrefix,E.dirs)}));J(O),H9((E)=>({...E,canvasDesignSystems:N.canvasDesignSystems??{},canvasKinds:N.canvasKinds??{}}))}catch(q){console.error("failed to load tree",q)}},[]);u.useEffect(()=>{a9()},[a9]);let y0=u.useCallback(async(q)=>{try{let N=q?`/_system-data?ds=${encodeURIComponent(q)}`:"/_system-data",O=await fetch(N);if(!O.ok){console.error("failed to load system-data",O.status);return}let E=await O.json();if(!q&&E?.defaultDesignSystem&&!E.ds){d0(E);let k=await fetch(`/_system-data?ds=${encodeURIComponent(E.defaultDesignSystem)}`);if(k.ok)d0(await k.json());return}d0(E)}catch(N){console.error("failed to load system-data",N)}},[]),a5=u.useCallback(async()=>{try{let N=await(await fetch("/_comments-all")).json();Z0(N||{})}catch(q){console.error("failed to load comments",q)}},[]);u.useEffect(()=>{a5()},[a5]),u.useEffect(()=>{function q(){let N=location.protocol==="https:"?"wss:":"ws:",O=new WebSocket(N+"//"+location.host+"/_ws");$Y.current=O,O.addEventListener("open",()=>d(!0)),O.addEventListener("close",()=>{d(!1),setTimeout(q,1000)}),O.addEventListener("error",()=>{}),O.addEventListener("message",(E)=>{try{let k=JSON.parse(E.data);if(k.type==="snapshot"&&k.state)U((j)=>Ge(k.state.selected,j));else if(k.type==="selected"){if(Date.now()-D.current<2000)return;let j=k.selected,S=Array.isArray(j)?j[0]:j,x=B.current,r=Array.isArray(x)?x[0]:x;if(U((X0)=>Ge(j,X0)),S?.id&&S.file&&(!r||r.id!==S.id||r.file!==S.file))A(S)}else if(k.type==="comments"&&typeof k.file==="string")Z0((j)=>({...j,[k.file]:k.comments||[]}));else if(k.type==="ai-activity"&&typeof k.file==="string"){if(fZ(!0),IW.current)clearTimeout(IW.current);IW.current=setTimeout(()=>fZ(!1),8000);for(let j of v8.current.values())try{j.contentWindow.postMessage({dgn:"ai-activity",file:k.file,entry:k.entry},"*")}catch{}}else if(k.type==="export:job"&&k.payload)kY.upsert(k.payload);else if(k.type==="sync:status"&&k.payload)s(k.payload);else if(k.type==="canvas-list-update"){if(a9(),k.payload?.action==="moved"&&k.payload.fromRel&&k.payload.rel){let j=(T0?.designRel||T0?.designRoot||".design").replace(/^\/+|\/+$/g,""),S=`${j}/${k.payload.fromRel}`,x=`${j}/${k.payload.rel}`;G((r)=>r.map((X0)=>X0.path===S?{path:x}:X0)),H((r)=>r===S?x:r)}}else if(k.type==="config-updated")$0();else if(k.type==="acp-focus"){if(l8())PX("assistant")}else if(k.type==="git-status"&&k.payload)z0(k.payload);else if(k.type==="git-lifecycle"&&k.payload){h(k.payload);for(let j of v8.current.values())try{j.contentWindow.postMessage({dgn:"git-lifecycle",payload:k.payload},"*")}catch{}}}catch{}})}return q(),()=>$Y.current&&$Y.current.close()},[a9,$0]);function C0(q){let N=$Y.current;try{if(N&&N.readyState===1)N.send(JSON.stringify(q))}catch{}}let i6=u.useCallback(async()=>{try{let q=await fetch("/_api/git/status");if(q.ok)z0(await q.json())}catch{}},[]),zX=u.useCallback(async()=>{try{let q=await fetch("/_api/git/status?remote=1");if(!q.ok)return;let N=await q.json();if(N&&N.repo!==!1)n({remoteAhead:!!N.remoteAhead,behind:N.behind||0})}catch{}},[]),o6=u.useCallback(async(q,N)=>{try{let O=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N||{})}),E=await O.json().catch(()=>({}));return{ok:O.ok,...E}}catch(O){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jW=u.useCallback(async(q,N)=>{let O=await o6("/_api/git/commit",{message:q,files:N});if(O.ok)await i6();return O},[o6,i6]),yY=u.useCallback(async(q)=>{let N=await o6("/_api/git/discard",{files:q});if(N.ok)await i6();return N},[o6,i6]),yW=u.useCallback(async()=>{let q=await o6("/_api/git/push",{});if(q.ok)await i6(),zX();return q},[o6,i6,zX]),s5=u.useCallback(async()=>{let q=await o6("/_api/git/pull",{});if(q.ok)await i6(),zX();if(q.conflict&&Array.isArray(q.files)&&q.files.length)G8({file:q.files[0],conflict:!0});return q},[o6,i6,zX]),fW=u.useCallback(async(q)=>{let N=await o6("/_api/git/resolve",{choice:q});if(N.ok)await i6(),zX();return N},[o6,i6,zX]),fY=u.useCallback(async(q)=>{try{let N="/_api/git/log?limit=40"+(q?`&path=${encodeURIComponent(q)}`:""),O=await fetch(N);if(!O.ok)return[];return(await O.json()).entries||[]}catch{return[]}},[]),vW=u.useMemo(()=>{let q={modified:"M",added:"A",deleted:"D",untracked:"U"},N=new Map;for(let O of c?.files||[])N.set(O.path,q[O.status]);return N},[c]),vY=c?.files?.length||0;u.useEffect(()=>{if(c?.repo===!1)return;zX();let q=setInterval(zX,o?60000:120000);return()=>clearInterval(q)},[c?.repo,o,zX]);let L6=u.useCallback((q)=>{if(G((N)=>{for(let O of N)if(O.path!==q)v8.current.delete(O.path);return[{path:q}]}),H(q),F0(null),q!==T8)k8(q)},[]),CJ=u.useCallback((q)=>{let N=typeof q==="string"?q:void 0;if(N)y0(N);else if(!w0)y0();L6(T8)},[w0,y0,L6]);u.useEffect(()=>{C0({type:"tabs",tabs:W.map((q)=>q.path).filter((q)=>q!==T8)})},[W]),u.useEffect(()=>{if(Z&&Z!==T8)C0({type:"active",file:Z});else if(Z===T8)C0({type:"active",file:""});else C0({type:"active",file:""})},[Z]);let $Q=u.useCallback((q)=>{G((N)=>{let O=N.findIndex((k)=>k.path===q);if(O<0)return N;let E=N.filter((k)=>k.path!==q);if(q===Z)if(E.length===0)H(null);else H(E[Math.max(0,O-1)].path);return E}),v8.current.delete(q),k8((N)=>N===q?null:N)},[Z]),rX=u.useCallback(()=>{if(!Z||Z===T8){if(Z===T8)y0();return}let q=v8.current.get(Z);if(q)q.src=q.src},[Z,y0]),xY=u.useCallback(()=>a9(),[a9]),[xW,hY]=u.useState(!1),SQ=u.useRef(!1),bQ=u.useCallback(async()=>{if(SQ.current)return;SQ.current=!0,hY(!0);try{await Promise.all([a9(),new Promise((q)=>setTimeout(q,550))])}finally{SQ.current=!1,hY(!1)}},[a9]);u.useEffect(()=>{let q=null,N=()=>{if(q)clearTimeout(q);q=setTimeout(()=>{q=null,xY()},150)};return window.addEventListener("focus",N),()=>{if(window.removeEventListener("focus",N),q)clearTimeout(q)}},[xY]);let hW=u.useCallback(async(q)=>{try{let N=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q,kind:"brief-board"})}),O=await N.json().catch(()=>({}));if(!N.ok||!O.ok)return{ok:!1,error:O.error||`create failed (${N.status})`};return await a9(),L6(O.file),{ok:!0,file:O.file}}catch(N){return{ok:!1,error:N instanceof Error?N.message:"network error"}}},[a9,L6]),gY=u.useCallback(async()=>{let q=await n5("New video name");if(!q)return;let O=(await n5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),E=O?Number(O[1]):1920,k=O?Number(O[2]):1080,j=Math.max(1,Math.min(60,Number(await n5("Frames per second","30"))||30));try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q,kind:"video-comp",clips:[],fps:j,width:E,height:k})}),x=await S.json().catch(()=>({}));if(!S.ok||!x.ok){A8(`New video failed: ${x.error||`error ${S.status}`}`);return}await a9(),L6(x.file),m9(!0),A8("New video created — drop clips on the timeline to start the cut.",!0)}catch(S){A8(`New video failed: ${S instanceof Error?S.message:"network error"}`)}},[a9,L6,n5]),gW=u.useCallback(async()=>{if(!Z||Z===T8)return;try{let q=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),N=q.ok?await q.text():"",O=[];if(N){let x=new DOMParser().parseFromString(N,"image/svg+xml");for(let r of x.querySelectorAll('[data-tool="mediaref"]')){let X0=r.getAttribute("data-src");if(!X0)continue;O.push({src:X0,mediaKind:r.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(O.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let k=`${BW(dN(Z)).replace(/\.tsx$/i,"")} Video`,j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:k,kind:"video-comp",clips:O})}),S=await j.json().catch(()=>({}));if(!j.ok||!S.ok){window.alert(`Assemble failed: ${S.error||`error ${j.status}`}`);return}await a9(),L6(S.file)}catch(q){window.alert(`Assemble failed: ${q instanceof Error?q.message:"network error"}`)}},[Z,a9,L6]),jQ=u.useCallback(({accept:q,resolveTarget:N})=>{let O=Z,E=v0||void 0,k=document.createElement("input");k.type="file",k.accept=q,k.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(k);let j=()=>{if(k.isConnected)k.remove()};window.addEventListener("focus",()=>setTimeout(j,300),{once:!0}),k.addEventListener("change",()=>{let S=k.files?.[0];if(j(),!S)return;let x=`/_api/comp-clips?canvas=${encodeURIComponent(O)}${E?`&artboardId=${encodeURIComponent(E)}`:""}`;fetch(x).then((r)=>r.json().catch(()=>({}))).then((r)=>{let X0=N(r);if(!X0)return A8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":S.type||"application/octet-stream"},body:S}).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{if(!H0?.path)return A8(`Upload failed: ${H0?.error||"unknown error"}`),null;if(X0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:O,arrayName:X0.arrayRef.arrayName,index:X0.arrayRef.index,field:X0.arrayRef.field,value:H0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:O,id:X0.cdId,attr:"src",value:H0.path})})})}).then((r)=>r?r.json():null).then((r)=>{if(r&&!r.ok)A8(`Replace refused: ${r.error||"failed"}`);else if(r&&r.ok){if(A8("Media replaced.",!0),r.seq!=null)E7(O,r.seq,"replace media")}}).catch(()=>A8("Replace failed: network error"))}),k.click()},[Z,v0,E7]),mW=u.useCallback(async(q,N)=>{if(!window.confirm(`Move “${N}” to trash?
5653
+ `).length," lines, paths & secrets scrubbed) —"," ",_("details",{className:"rb-details",children:[K("summary",{children:"view"}),K("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,l8()&&B.length>0&&_("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:L.crashLogs,onChange:(m)=>D({...L,crashLogs:m.target.checked})}),_("span",{children:["Crash logs (",B.length,") — ",K("code",{children:B.map((m)=>m.name).join(", ")})]})]})]}),_("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",K("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),_("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("describe"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:y,children:"Send report"})]})]}),Q==="sending"&&K("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&_(Y0,{children:[I?.issueUrl?_("p",{children:["Thank you — your report is filed as"," ",_("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(l8())L1(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):_("p",{children:["The bundle is saved locally",I?.fallbackDir?_(Y0,{children:[" ","at ",K("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),K("footer",{className:"rb-actions",children:K("button",{type:"button",className:"st-btn rb-primary",onClick:b,children:"Done"})})]}),Q==="fallback"&&_(Y0,{children:[K("p",{className:"rb-error","data-testid":"report-bug-error",children:w}),K("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."}),_("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("preview"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary",onClick:v,children:"Save locally & open GitHub"})]})]})]})]})})}var xX=P8(S8(),1);function Vx(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 qx(X,J){let Q=Vx(X),Y=Vx(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 Bx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||qx(Q.version,J)))}function Nx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&qx(Y.version,Q))Q=Y.version}return Q}var q_="mdcc-whatsnew-seen",B_="mdcc-whatsnew-toast-dismissed";function mZ0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function uZ0(X){try{let J=localStorage.getItem(q_);if(J)return J;localStorage.setItem(q_,X)}catch{}return X}function lZ0(){try{return localStorage.getItem(B_)}catch{return null}}function Fx(X){let[J,Q]=xX.useState([]),[Y,W]=xX.useState(X),[G,Z]=xX.useState(()=>uZ0(X)),[H,z]=xX.useState(()=>lZ0()),[U,B]=xX.useState(!1);xX.useEffect(()=>{let w=!1,R=()=>{fetch("/_api/whats-new").then((b)=>b.json()).then((b)=>{if(w)return;if(Q(Array.isArray(b?.entries)?b.entries:[]),typeof b?.version==="string")W(b.version)}).catch(()=>{})};R();let T=()=>R(),C=()=>{if(document.visibilityState==="visible")R()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",C),()=>{w=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",C)}},[]);let F=Bx(J,G),L=F.length>0&&H!==Y&&!U,D=F[0]??null,M=xX.useCallback(()=>{let w=Nx(J,Y);Z(w),z(Y);try{localStorage.setItem(q_,w),localStorage.setItem(B_,Y)}catch{}},[J,Y]),A=xX.useCallback(()=>{z(Y);try{localStorage.setItem(B_,Y)}catch{}},[Y]),I=xX.useCallback(()=>B(!0),[]),P=xX.useCallback(()=>{B(!1),M()},[M]);return{entries:J,unseen:F,feedVersion:Y,panelOpen:U,openPanel:I,closePanel:P,showToast:L,toastEntry:D,dismissToast:A,markAllSeen:M}}function Lx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),_("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Dx({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(xX.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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:_("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[_("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>_("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[_("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),mZ0(G.learnMore)&&K("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&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var h9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Tt="mdcc-usage-tour-seen",Ct="mdcc-collab-tour-seen",T8="__system__",Ke="mdcc-theme",$t="mdcc-show-hidden",St="mdcc-sections-expanded",bt="maude-cp-mode",jt="mdcc-sidebar-open",yt="mdcc-minimap-visible",ft="mdcc-zoomctl-visible",vt="mdcc-annotations-visible";var sV0=30000;function tV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var WR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],tz={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},xt="mdcc-panel-sides",ht="mdcc-layers-mode";function gt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return _("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(WR.find((z)=>z.id===H)||{}).label||H},H))}),Z]})}var AQ=/\.(tsx|html?)$/i;function mN(X){return X.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var ZR="0.52.2";function mt(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function eV0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Ke);if(X==="light"||X==="dark")return X}catch{}return"dark"}function RZ(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 eP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function Xq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function dN(X){return X.split("/").pop()}function A8(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(A8._t),A8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var ut="maude-browse-hint-seen";function Jq0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(ut)==="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(ut,"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 BW(X){return X.replace(AQ,"")}function Qq0(X){return X.replace(AQ,"")}function Yq0(X){let J=new Map;for(let G of X){if(!AQ.test(G.name))continue;let Z=Qq0(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(AQ.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((z,U)=>z.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function Wq0(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 z of Z)H=H[z]=H[z]||{};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 z=0;z<Z.length;z++){let U=Z[z];if(z===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function Ue(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=Ue(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 lt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Gq0(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 Ve(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 uN({d:X,size:J=14,color:Q}){return K("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:K("path",{d:X})})}var Zq0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:_(Y0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":_(Y0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),K("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:_(Y0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:_(Y0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:_(Y0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:_(Y0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:_(Y0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("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:_(Y0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:_(Y0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:_(Y0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:_(Y0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:_(Y0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:_(Y0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:_(Y0,{children:[K("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"}),K("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:_(Y0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:_(Y0,{children:[K("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"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:_(Y0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":_(Y0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":_(Y0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("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":_(Y0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":_(Y0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("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":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":_(Y0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":_(Y0,{children:[K("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"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:_(Y0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:_(Y0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:_(Y0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:_(Y0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:_(Y0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:_(Y0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:_(Y0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:_(Y0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:_(Y0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:_(Y0,{children:[K("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"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function Hq0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let z=u.useMemo(()=>{let B=Y.trim().toLowerCase();if(!B)return Q;return Q.filter((F)=>F.label.toLowerCase().includes(B)||F.group&&F.group.toLowerCase().includes(B))},[Y,Q]);if(u.useEffect(()=>{if(G>=z.length)Z(0)},[z.length,G]),!X)return null;let U=(B)=>{J(),B.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(B)=>{if(B.target===B.currentTarget)J()},children:_("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[_("div",{className:"st-pal-search",children:[K(W9,{name:"search",size:18}),K("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(B)=>W(B.target.value),onKeyDown:(B)=>{if(B.key==="Escape")B.preventDefault(),J();else if(B.key==="ArrowDown")B.preventDefault(),Z((F)=>Math.min(z.length-1,F+1));else if(B.key==="ArrowUp")B.preventDefault(),Z((F)=>Math.max(0,F-1));else if(B.key==="Enter"){if(B.preventDefault(),z[G])U(z[G])}}}),K(JX,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):z.map((B,F)=>{let L=B.group&&(F===0||z[F-1].group!==B.group)?K("div",{className:"st-pal-group",children:B.group},"g-"+B.group):null;return _(Y0,{children:[L,_("button",{type:"button",className:"st-pal-item"+(F===G?" is-active":""),onMouseEnter:()=>Z(F),onClick:()=>U(B),children:[K("span",{className:"st-pal-icon",children:K(W9,{name:B.icon,size:15})}),K("span",{className:"st-pal-label",children:B.label}),B.kbd?K("span",{className:"st-pal-kbd",children:K(JX,{children:B.kbd})}):null]})]},B.id)})})]})})}function W9({name:X,size:J=16,className:Q}){return K("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:Zq0[X]})}function zq0(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 dt({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function JX({children:X}){return K("span",{className:"kbd",children:X})}function pt(X,{min:J,max:Q,def:Y}){let W=u.useCallback((z)=>Math.min(Q,Math.max(J,z)),[J,Q]),[G,Z]=u.useState(()=>{try{let z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(z)?W(z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((z)=>Z((U)=>W(typeof z==="function"?z(U):z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ct({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:z,def:U}=J,B=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(F)=>{let L=F.shiftKey?24:8;if(F.key==="ArrowRight")F.preventDefault(),Z((D)=>D+L*B);else if(F.key==="ArrowLeft")F.preventDefault(),Z((D)=>D-L*B);else if(F.key==="Home")F.preventDefault(),Z(H);else if(F.key==="End")F.preventDefault(),Z(z)},children:_("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var XR=[{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}],JR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},Kq0={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"]},Uq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Jq=[{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}],Vq0="2x",it=[{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}],qq0="auto",Bq0={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 Nq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return Bq0[J]||"application/octet-stream"}function Fq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[z,U]=u.useState(!1),[B,F]=u.useState(null),[L,D]=u.useState(()=>new Set),[M,A]=u.useState({}),[I,P]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((d)=>d.json()).then((d)=>{if(!f)return;let l=d.ok?d.assets:[];H(l),A((h)=>{let a={...h};for(let s of l)a[s.path]=s.kind;return a})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(d)=>{if(d.key==="Escape")d.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let w=Array.from(L).some((f)=>(M[f]||"image")!=="image"),R=!W||w,T=!W?"No artboard on this canvas":w?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(R&&I==="artboard")P("annotation")},[R,I]);let C=(f)=>{D((d)=>{let l=new Set(d);if(l.has(f))l.delete(f);else l.add(f);return l})},b=async(f)=>{let d=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),l=await d.json().catch(()=>({}));if(d.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${d.status})`}},$=async(f)=>{if(!f)return;U(!0),F(null);let d=await b(f);if(U(!1),d.ok)J(d.path);else F(d.error)},y=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},v=async(f)=>{if(!f.length)return;U(!0),F(null);let d=await Promise.all(f.map((a)=>b(a).then((s)=>({...s,file:a}))));U(!1);let l=d.filter((a)=>a.ok),h=d.length-l.length;if(h>0)F(`${h} of ${d.length} uploads failed`);if(l.length)A((a)=>{let s={...a};for(let c of l)s[c.path]=y(c.file.type);return s}),D((a)=>{let s=new Set(a);for(let c of l)s.add(c.path);return s})},g=async()=>{U(!0),F(null);try{if(Y){let l=(await yf()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:Nq0(h.name)}));if(U(!1),l.length)await v(l);return}let f=await O1();if(f?.bytes){await $(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){F(f?.message||"open failed")}U(!1)},m=()=>{if(l8()){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 d=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(d,300),{once:!0}),f.addEventListener("change",()=>{let l=f.files?Array.from(f.files):[];if(d(),!l.length)return;if(Y)v(l);else $(l[0])}),f.click()},p=(f)=>`/${X}/${f}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:_("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[_("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(W9,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[_("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:m,disabled:z,children:z?"Uploading…":"Upload…"}),B&&K("span",{className:"st-ap-err",children:B})]}),K("div",{className:"st-ap-grid",children:Z==null?K("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let d=Y&&L.has(f.path);return _("button",{type:"button",className:"st-ap-cell","data-selected":d?"true":void 0,"aria-pressed":Y?d:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?C(f.path):J(f.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:d?K(W9,{name:"check",size:12}):null}),f.kind==="video"?K("video",{className:"st-ap-thumb",src:p(f.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:p(f.path),alt:f.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&L.size>0&&_("div",{className:"st-dialog-ft st-ap-confirm",children:[_("span",{className:"st-ap-count",children:[L.size," selected"]}),_("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="artboard",disabled:R,onClick:()=>P("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="annotation",onClick:()=>P("annotation"),children:"Add as annotation"})]}),R&&K("span",{className:"st-ap-dest-note",children:T}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(L),I),children:"Insert"})]})]})})}function Lq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[z,U]=u.useState(X==="handoff"?"shadcn":"png"),[B,F]=u.useState(J&&JR[J]?J:"artboard"),[L,D]=u.useState(2),[M,A]=u.useState(Vq0),[I,P]=u.useState(!0),[w,R]=u.useState(!1),[T,C]=u.useState(!1),[b,$]=u.useState(!1),[y,v]=u.useState(qq0),[g,m]=u.useState(!0),[p,f]=u.useState(!1),[d,l]=u.useState(null),[h,a]=u.useState([]),s=XR.find((w0)=>w0.id===z)||XR[0],c=s.handoff?[]:Kq0[s.format]||["artboard"],z0=900,e=3600,n=W[0]||null,o=n?.durationInFrames||0,V0=n?.fps||30,f0=s.temporal&&o>900,G8=s.temporal&&o>3600;u.useEffect(()=>{if(c.length&&!c.includes(B))F(c[0])},[c,B]);let X8=u.useCallback(()=>{fetch("/_api/export-history").then((w0)=>w0.json()).then((w0)=>a(Array.isArray(w0?.history)?w0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{X8()},[X8]),u.useEffect(()=>{function w0(d0){if(d0.key==="Escape")d0.preventDefault(),H()}return window.addEventListener("keydown",w0),()=>window.removeEventListener("keydown",w0)},[H]);async function a0(){if(s.handoff){let Y8=`/design:handoff ${Q&&Q!==T8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(Y8)}catch{}l({ok:!0,msg:`Copied: ${Y8} — run it in Claude Code.`});return}f(!0),l(null);let w0=s.temporal?{scale:L}:{};if(s.format==="png"){let d0=Jq.find((Y8)=>Y8.id===M)||Jq[1];if(d0.kind==="dpi")w0.dpi=d0.value;else w0.scale=d0.value}if(s.format==="mp4"||s.format==="webm")w0.audio=g;if(G8)w0.maxFrames=o;if(s.format==="pdf"){w0.pdfPrint={includeBleed:I,marks:{crop:T,registration:b}};let d0=it.find((Y8)=>Y8.id===y)?.value;if(d0!==void 0)w0.dpi=d0}if(G)w0.artboardId=G;if(Z?.selector)w0.selection=Z;try{let d0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:B,options:w0})});if(!d0.ok){l({ok:!1,msg:await d0.text()||`Export failed (${d0.status})`}),f(!1);return}H()}catch(d0){l({ok:!1,msg:d0&&d0.message?d0.message:String(d0)}),f(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(w0)=>{if(w0.target===w0.currentTarget)H()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[_("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:H,children:K(W9,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==T8?`Format · ${BW(dN(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:XR.filter((w0)=>!w0.temporal||Y).map((w0)=>_("button",{type:"button",className:"st-fmt"+(w0.id===z?" is-on":""),onClick:()=>{U(w0.id),l(null)},children:[K(W9,{name:w0.icon,size:16}),K("span",{className:"st-fmt-name",children:w0.label}),K("span",{className:"st-fmt-sub",children:w0.sub})]},w0.id))}),!s.handoff&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:B,onChange:(w0)=>F(w0.target.value),children:c.map((w0)=>K("option",{value:w0,children:JR[w0]},w0))})]}),!s.handoff&&s.format==="png"&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),K("select",{id:"st-export-size",className:"st-select",value:M,onChange:(w0)=>A(w0.target.value),children:Jq.map((w0)=>K("option",{value:w0.id,children:w0.label},w0.id))})]}),!s.handoff&&s.format==="png"&&K("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let w0=Jq.find((Y8)=>Y8.id===M)||Jq[1],d0=w0.kind==="dpi"?w0.value/96:w0.value;return`${w0.label} ≈ ${Math.round(1440*d0)}×${Math.round(900*d0)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),K("select",{id:"st-export-temporal-size",className:"st-select",value:L,onChange:(w0)=>D(Number(w0.target.value)),children:Uq0.map((w0)=>K("option",{value:w0.value,children:w0.label},w0.value))})]}),!s.handoff&&s.temporal&&_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[L,"× the artboard's native resolution (e.g. 960×540 → ",960*L,"×",540*L,")."]}),f0&&_("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",o," frames (≈",Math.round(o/V0),"s).",G8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!s.handoff&&s.format==="pdf"&&_(Y0,{children:[_("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),K("select",{id:"st-export-pdf-dpi",className:"st-select",value:y,onChange:(w0)=>v(w0.target.value),children:it.map((w0)=>K("option",{value:w0.id,children:w0.label},w0.id))})]}),K("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)."}),K("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(w0)=>P(w0.target.checked)}),"Include bleed"]})}),K("div",{className:"st-dialog-row",children:_("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>R((w0)=>!w0),"aria-expanded":w,children:[w?"▾":"▸"," Marks"]})}),w&&_("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:T,onChange:(w0)=>C(w0.target.checked)}),"Crop marks"]}),_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:b,onChange:(w0)=>$(w0.target.checked)}),"Registration marks"]})]}),_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",K("code",{children:'kind="print"'}),") artboards only.",B==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&K("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:g,onChange:(w0)=>m(w0.target.checked)}),"Export with audio"]})}),s.handoff&&_("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("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."]}),d&&K("div",{className:"callout "+(d.ok?"callout--success":"callout--error"),style:{fontSize:12},children:d.msg}),h.length>0&&_("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),h.map((w0,d0)=>_("div",{className:"st-export-recent-row",children:[_("span",{children:[String(w0.format||"").toUpperCase()," ·"," ",JR[w0.scope]||w0.scope]}),K("span",{className:"st-mono",children:w0.filename})]},d0))]})]}),_("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),_("button",{type:"button",className:"btn btn--primary",disabled:p,onClick:a0,children:[K(W9,{name:"download",size:14}),s.handoff?"Copy handoff command":p?"Exporting…":`Export ${s.label}`]})]})]})})}var pN=12,cN=16;function Dq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,z]=u.useState(Q),U=G?G.dropProps(W,!0,()=>z(!0)):{},B=G?.overDir===W,F=G?G.dragProps(W,!0):{},L=G?.draggedPath===W,D=G?.busyPath===W,M=_("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${mN(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":D||void 0,tabIndex:-1,className:"st-row"+(B?" is-drop-target":"")+(L?" is-dragging":"")+(D?" is-busy":""),style:{paddingLeft:pN+J*cN+"px"},onClick:()=>z((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...F,...U,children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]});return _(Y0,{children:[Z?_("div",{className:"st-row-wrap",role:"none",children:[M,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${mN(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:K(uN,{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,H&&Y]})}function Oq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,z]=u.useState(Y);return _(Y0,{children:[_("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:pN+Q*cN+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>z((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(W9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),_("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function GR({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:z,experimentalKind:U,drag:B,menu:F}){let L=X.path===J,D=AQ.test(X.name),M=!D,A=D?BW(X.name):X.name,I=D&&typeof Y==="function"&&Z!=="runtime",P=D&&!H&&Z!=="runtime"&&typeof B<"u",w=P?B.dragProps(X.path,!0):{},R=B?.draggedPath===X.path,T=B?.busyPath===X.path,C=P&&typeof F<"u",b=X.path.split("/").slice(0,-1).join("/"),$=D?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,y=_("button",{type:"button",role:"treeitem","data-testid":$,"aria-selected":L,"aria-disabled":M?"true":void 0,"aria-busy":T||void 0,tabIndex:L?0:-1,className:"st-row"+(L?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(R?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:pN+G*cN+"px"},title:X.path+(W?` — ${W} open`:M?" (file index only)":""),onClick:()=>{if(!M)Q(X.path)},onContextMenu:C?(v)=>F.openAt(v,{kind:"file",path:X.path,dir:b}):void 0,...w,children:[K("span",{className:"st-row-glyph",children:K(W9,{name:"file",size:13})}),K("span",{className:"st-row-name",children:A}),U==="reconstructed-experimental"&&K("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"}),z&&K("span",{className:"st-git-badge","data-kind":z,title:`Unsaved (${z})`,"aria-label":`Unsaved, ${z}`,children:z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!I&&!C)return y;return _("div",{className:"st-row-wrap",role:"none",children:[y,C&&K("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${mN(X.path)}`,title:`Move ${A}…`,"aria-label":`Actions for ${A}`,"aria-haspopup":"menu",onClick:(v)=>F.openAt(v,{kind:"file",path:X.path,dir:b}),children:K(uN,{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})}),I&&K("button",{type:"button",className:"st-row-del",title:`Delete ${A}`,"aria-label":`Delete canvas ${A}`,onClick:(v)=>{v.stopPropagation(),Y(X.path,A)},children:K(uN,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function Mq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:z,forceOpen:U,dirtyByPath:B,experimentalKind:F,drag:L,menu:D}){let M=B?.get(X.path),A=J.length>0,[I,P]=u.useState(!1),w=U||I,R=X.path===W;if(!(A&&z))return K(GR,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:M,experimentalKind:F,drag:L,menu:D});let C=typeof L<"u",b=C?L.dragProps(X.path,!0):{},$=L?.draggedPath===X.path,y=L?.busyPath===X.path,v=C&&typeof D<"u",g=X.path.split("/").slice(0,-1).join("/"),m=_("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":w,"aria-busy":y||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+($?" is-dragging":"")+(y?" is-busy":""),style:{paddingLeft:pN+Q*cN+"px"},title:X.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){P((f)=>!f);return}G(X.path)},onContextMenu:v?(p)=>D.openAt(p,{kind:"file",path:X.path,dir:g}):void 0,...b,children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),P((f)=>!f)},children:K(W9,{name:"chevron-right",className:"st-chev"+(w?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:BW(X.name)}),F==="reconstructed-experimental"&&K("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"}),M&&K("span",{className:"st-git-badge","data-kind":M,title:`Unsaved (${M})`,"aria-label":`Unsaved, ${M}`,children:M}),H>0&&K("span",{className:"st-row-badge",children:H})]});return _(Y0,{children:[v?_("div",{className:"st-row-wrap",role:"none",children:[m,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${mN(X.path)}`,title:`Move ${BW(X.name)}…`,"aria-label":`Actions for ${BW(X.name)}`,"aria-haspopup":"menu",onClick:(p)=>D.openAt(p,{kind:"file",path:X.path,dir:g}),children:K(uN,{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,w&&J.map((p)=>K(GR,{file:p,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function qe({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:z,activeDsName:U,onOpenSystem:B,onDelete:F,dirtyByPath:L,canvasKinds:D,dirPath:M="",drag:A,menu:I}){let P=Object.keys(X).filter(($)=>$!=="_files").sort(),w=X._files||[],{canvases:R,orphans:T}=u.useMemo(()=>Yq0(w),[w]),C=!!(H&&H.trim()),b=u.useMemo(()=>{if(!z||W!==1)return null;let $=new Map;for(let y of z)$.set(y.folder,y);return $},[z,W]);return _(Y0,{children:[R.map(($)=>{let y=C&&$.sidecars.some((v)=>{let g=H.toLowerCase();return v.name.toLowerCase().includes(g)||v.path.toLowerCase().includes(g)});return K(Mq0,{primary:$.primary,sidecars:$.sidecars,activePath:J,onOpen:Q,onDelete:F,openCount:lt(Y[$.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:y,dirtyByPath:L,experimentalKind:D?.[$.primary.path],drag:A,menu:I},$.primary.path)}),Z&&T.map(($)=>K(GR,{file:$.primary,activePath:J,onOpen:Q,openCount:lt(Y[$.primary.path]),depth:W,kind:G},$.primary.path)),P.map(($)=>{let y=b?.get($),v=M?`${M}/${$}`:$,g=K(qe,{node:X[$],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:U,onOpenSystem:B,onDelete:F,dirtyByPath:L,canvasKinds:D,dirPath:v,drag:A,menu:I});if(y&&B)return K(Oq0,{name:$,dsName:y.name,depth:W,defaultOpen:!0,active:J===T8&&y.name===U,onOpenSystem:B,children:g},$);return K(Dq0,{name:$,depth:W,defaultOpen:!0,dirPath:v,drag:A,menu:I,children:g},$)})]})}var xN={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function wq0(X){if(X.kind==="project")return xN.project;if(X.kind==="runtime")return xN.runtime;if(X.label==="Design system")return xN.ds;if(X.label==="UI kit")return xN.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function _q0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:z,showHidden:U,sectionsExpanded:B,onToggleSection:F,onNewBoard:L,onDeleteBoard:D,onRefresh:M,refreshing:A,collapsed:I,onCollapse:P,width:w,resizing:R,dirtyByPath:T,project:C,gitBranch:b,remoteSync:$,onGetLatest:y,canvasKinds:v,onMoveCanvas:g,onNewFolder:m,onDeleteFolder:p}){let f=u.useMemo(()=>{if(!Z)return X;return X.map((b0)=>({...b0,tree:Ue(b0.tree,Z),filtered:!!Z}))},[X,Z]),d=L$(g),l=N$(),h=u.useMemo(()=>{let b0=[];for(let Z8 of X){if(Z8.label==="Design system"||Z8.kind!=="canvas")continue;let p0=Z8.fullPath.replace(/^\.[^/]+\//,"")||Z8.fullPath;b0.push({path:Z8.fullPath,label:p0});for(let C8 of Z8.dirs||[])b0.push({path:C8,label:C8.replace(/^\.[^/]+\//,"")})}return b0},[X]),a=l.state?.extra,s=a?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>l.showMoveTo()}]:a?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{l.close();let b0=window.prompt("New folder name:");if(b0?.trim())m(a.dirPath,b0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{l.close(),p(a.dirPath,a.dirPath.split("/").pop())}}]:[],c=a?.kind==="file"?h.filter((b0)=>b0.path!==a.dir):[],[z0,e]=u.useState(!1),[n,o]=u.useState("board"),[V0,f0]=u.useState(""),[G8,X8]=u.useState(""),[a0,w0]=u.useState(!1),d0=u.useMemo(()=>X.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[X]),Y8=u.useCallback(async()=>{let b0=V0.trim();if(!b0||a0)return;if(w0(!0),X8(""),n==="folder"){if(!d0){w0(!1),X8("no canvas group to create a folder in");return}let p0=await m(d0,b0);if(w0(!1),p0?.ok)e(!1),f0("");else X8(p0?.error||"could not create folder");return}let Z8=await L(b0);if(w0(!1),Z8?.ok)e(!1),f0("");else X8(Z8?.error||"could not create board")},[V0,a0,L,m,n,d0]),k8=u.useMemo(()=>{let b0=0;for(let Z8 of X)for(let p0 of Z8.paths||[])if(AQ.test(p0))b0++;return b0},[X]),e0=u.useMemo(()=>{let b0=0;for(let Z8 of f)for(let p0 of Z8.paths||[])if(AQ.test(p0))b0++;return b0},[f]);return _("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(R?" is-resizing":""),style:I||!w?void 0:{width:w,flexBasis:w},"aria-label":"Files","data-tour":"sidebar",children:[_("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),_("div",{className:"st-sb-hd-actions",children:[K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":z0&&n==="board",onClick:()=>{X8(""),o("board"),e((b0)=>n==="board"?!b0:!0)},children:K(W9,{name:"plus",size:15})}),d0&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":z0&&n==="folder",onClick:()=>{X8(""),o("folder"),e((b0)=>n==="folder"?!b0:!0)},children:K(W9,{name:"folder-plus",size:15})}),M&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(A?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":A||void 0,disabled:A,onClick:()=>M(),children:K(W9,{name:"reload",size:15})}),_("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),e0," / ",k8]}),P&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:P,children:K(W9,{name:"panel-left",size:15})})]})]}),z0?_("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:n==="folder"?"folder name…":"brief board name…",value:V0,maxLength:60,disabled:a0,"aria-label":n==="folder"?"New folder name":"New brief board name",onChange:(b0)=>f0(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),Y8();else if(b0.key==="Escape")b0.preventDefault(),e(!1),f0(""),X8("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:a0||!V0.trim(),"data-tip":"Create · Enter","aria-label":n==="folder"?"Create folder":"Create brief board",onClick:Y8,children:a0?"…":"↵"})]}):null,G8?K("div",{className:"st-newboard-err",role:"alert",children:G8}):null,K("div",{className:"st-search",children:_("div",{className:"st-search-box",children:[K(W9,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(b0)=>H(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),Z)H("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),Z?K("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(JX,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:f.map((b0)=>{if(!U&&!Z&&b0.kind==="runtime")return null;let Z8=wq0(b0),p0=(b0.paths||[]).filter((z8)=>AQ.test(z8)).length,C8=Z8.pill||(Z8.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(Z8.pillFromCount?String(p0||b0.paths?.length||0):null),Q9=b0.tree&&Object.keys(b0.tree).length>0,Z9=b0.label==="Design system",T0=b0.kind==="project";if(!U&&!Z&&T0&&p0===0)return null;let H9=Xq0(b0),$0=B[b0.label],J8=!!Z||($0===void 0?H9:$0),Z0=!Z9&&b0.kind==="canvas",I0=Z0?d.dropProps(b0.fullPath,!0):{},F0=d.overDir===b0.fullPath;return _("div",{className:"st-tree-section",children:[_("button",{type:"button",className:"st-tree-sec-hd"+(F0?" is-drop-target":""),onClick:()=>F(b0.label,H9),"aria-expanded":J8,"aria-dropeffect":Z0?"move":void 0,title:J8?"Collapse section":"Expand section",...I0,children:[K(W9,{name:"chevron-right",className:"st-chev"+(J8?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:Z8.title}),C8&&K("span",{className:"st-pill",children:C8})]}),J8&&(Q9?K(qe,{node:b0.tree,activePath:J,onOpen:Y,commentsByFile:z,depth:1,kind:b0.kind,showHidden:U,search:Z,dsFolders:b0.dsFolders,activeDsName:Q,onOpenSystem:Z9?W:void 0,onDelete:Z9?void 0:D,dirtyByPath:T,canvasKinds:v,dirPath:b0.fullPath,drag:!Z9&&b0.kind==="canvas"?d:void 0,menu:!Z9&&b0.kind==="canvas"?l:void 0}):K("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},b0.label)})}),K(F$,{state:l.state,onClose:l.close,rootItems:s,destinations:c,onPickDestination:(b0)=>g(a.path,b0)}),K(Q_,{project:C,liveBranch:b,remoteSync:$,onGetLatest:y}),K(Cw,{}),K(Sw,{})]})}function Aq0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:_("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(W9,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(W9,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(W9,{name:"folder",size:15})})]})})}function Eq0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[_("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),_("span",{className:"sku",children:["MAUDE-DEV-SRV / v",ZR]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),_("div",{className:"help-modal-body",children:[_("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),_("ul",{children:[_("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),_("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),_("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),_("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),_("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),_("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),_("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),_("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),_("details",{children:[K("summary",{children:"Annotation tools"}),_("ul",{children:[_("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),_("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),_("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),_("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),_("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),_("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),_("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),_("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),_("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),_("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),_("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),_("details",{children:[K("summary",{children:"Canvas & panels"}),_("ul",{children:[_("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),_("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),_("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),_("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),_("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),_("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),_("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),_("details",{children:[K("summary",{children:"Slash commands"}),_("ul",{className:"cmds",children:[_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),_("li",{children:[_("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),_("li",{children:[_("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),_("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),_("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),_("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),_("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),_("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),_("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),_("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),_("details",{children:[K("summary",{children:"Opt-out scope"}),_("ul",{children:[_("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),_("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),_("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),_("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),_("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),_("details",{children:[K("summary",{children:"Auto-critic loop"}),_("ul",{children:[_("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),_("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),_("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),_("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),_("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),_("li",{children:["When ",K("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."]})]})]}),_("details",{children:[K("summary",{children:"Pin-to-element flow"}),_("ol",{children:[K("li",{children:"Open a canvas"}),_("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),_("li",{children:["Run"," ",_("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),_("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),_("details",{children:[K("summary",{children:"Comments"}),_("ol",{children:[_("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),_("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),_("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),_("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var QR=[{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 Pq0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>K(JX,{children:G},`${G}-${Z}`))},W);return _("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>_(Y0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function Rq0({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=QR.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[_("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),_("span",{className:"so-trigger",children:["press ",K(JX,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:QR.map((Y)=>_("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>_("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(Pq0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),_("div",{className:"so-overlay-ft",children:[_("span",{children:["close with ",K(JX,{children:"Esc"})]}),_("span",{className:"so-count",children:[Q," bindings · ",QR.length," groups"]})]})]})})}var Iq0=["File","Edit","View","Selection","Tools","Help"];function Be(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function kq0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Be(Q),_("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>_("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:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(W9,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(JX,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("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)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(JX,{children:G.shortcut})]},G.label))]})}function Wq({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Be(G),_("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?K("div",{className:"st-dd-sep"},"s"+H):_("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:[_("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:Z.label})]}),Z.shortcut?K(JX,{children:Z.shortcut}):null]},Z.id))]})}function Tq0({onAction:X,onClose:J}){return K(Wq,{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"},...l8()?[{id:"collab-tour",label:"How sharing works"}]:[],...l8()?[{id:"quick-setup",label:"Quick setup"}]:[],...l8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function Cq0({onAction:X,onClose:J}){return K(Wq,{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 $q0({onAction:X,onClose:J}){return K(Wq,{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 Sq0({onAction:X,onClose:J,hasCanvas:Q}){return K(Wq,{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 bq0({onAction:X,onClose:J,hasCanvas:Q}){return K(Wq,{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 jq0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:z,onToggleChanges:U,onOpenSystem:B,sidebarOpen:F,onToggleSidebar:L,showHidden:D,onToggleShowHidden:M,onOpenHelp:A,onOpenShortcuts:I,onReportBug:P,onStartTour:w,onStartCollabTour:R,annotationsVisible:T,onToggleAnnotations:C,minimapVisible:b,onToggleMinimap:$,zoomCtlVisible:y,onToggleZoomCtl:v,presentMode:g,onTogglePresent:m,printGuidesVisible:p,onTogglePrintGuides:f,postToActiveCanvas:d,onOpenWhatsNew:l,onOpenReadiness:h,onOpenQuickSetup:a,onWatchIntro:s,whatsNewCount:c,exportCenter:z0,artboardCount:e=0,presence:n=null,inspectorOpen:o,inspectorTab:V0,onToggleInspector:f0,autoOpenInspector:G8,onToggleAutoOpenInspector:X8,onOpenLayers:a0,timelineOpen:w0,onToggleTimeline:d0,hasComps:Y8=!1,assistantOpen:k8,onToggleAssistant:e0,assistantBusy:b0,assistantUnseen:Z8,onNewCanvas:p0,onAssembleVideo:C8,onOpenExport:Q9,onOpenSettings:Z9,onOpenGenerate:T0,onReload:H9,onCloseCanvas:$0,onInsertArtboard:J8}){let Z0=X===T8,I0=Z0?"SYSTEM":X?"CANVAS":"IDLE",F0=Z0?K("b",{children:"design system"}):X?_(Y0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:BW(dN(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),z8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:F,disabled:!1},{id:"changes",label:z>0?`Changes · ${z} 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:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:o&&V0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:o,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!G8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:Y8?"video":void 0,checked:w0,disabled:!1},...l8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:k8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:b,disabled:!X||Z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:y,disabled:!X||Z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||Z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!X||Z0}],I8=["file","edit","view","selection","tools","help"];function W8(j0){if(I8.includes(j0))W(Y===j0?null:j0)}return u.useEffect(()=>{if(!Y||!I8.includes(Y))return;let j0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function N0(c0){let s0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!s0.length)return;let M0=s0.indexOf(document.activeElement);if(c0.key==="ArrowDown")c0.preventDefault(),s0[(M0+1)%s0.length].focus();else if(c0.key==="ArrowUp")c0.preventDefault(),s0[(M0-1+s0.length)%s0.length].focus();else if(c0.key==="Home")c0.preventDefault(),s0[0].focus();else if(c0.key==="End")c0.preventDefault(),s0[s0.length-1].focus();else if(c0.key==="ArrowRight"||c0.key==="ArrowLeft"){c0.preventDefault();let n0=c0.key==="ArrowRight"?1:-1,D8=I8.indexOf(Y);W(I8[(D8+n0+I8.length)%I8.length])}else if(c0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",N0),()=>{clearTimeout(j0),window.removeEventListener("keydown",N0)}},[Y,W]),_("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[_("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:Iq0.map((j0)=>{let N0=j0.toLowerCase(),c0=I8.includes(N0),s0=c0||N0==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":N0==="help"?"help":void 0,"aria-haspopup":c0?"menu":void 0,"aria-expanded":c0?Y===N0:void 0,onClick:()=>W8(N0),onMouseEnter:()=>{if(Y!==null&&c0)W(N0)},children:j0},N0)})}),Y==="file"&&K(Sq0,{hasCanvas:!!X,onAction:(j0)=>{if(j0==="new")p0?.();else if(j0==="assemble")C8?.();else if(j0==="export")Q9?.("export");else if(j0==="handoff")Q9?.("handoff");else if(j0==="generate")T0?.();else if(j0==="settings")Z9?.();else if(j0==="reload")H9?.();else if(j0==="close")$0?.()},onClose:()=>W(null)}),Y==="edit"&&K(bq0,{hasCanvas:!!X&&!Z0,onAction:(j0)=>{if(j0==="undo")d({dgn:"undo"});else if(j0==="redo")d({dgn:"redo"});else if(j0==="deselect-all")d({dgn:"selection-clear"});else if(j0==="select-all-annotations")d({dgn:"annotation-select-all"});else if(j0.startsWith("new-artboard:"))J8?.(j0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(kq0,{panels:z8,onToggle:(j0)=>{if(j0==="tree")L();else if(j0==="changes")U();else if(j0==="comments")Z();else if(j0==="hidden")M();else if(j0==="annotate")C();else if(j0==="inspector")f0();else if(j0==="autoopen")X8?.();else if(j0==="timeline")d0?.();else if(j0==="assistant")e0?.();else if(j0==="layers")a0?.();else if(j0==="minimap")$?.();else if(j0==="zoomctl")v?.();else if(j0==="present")m?.();else if(j0==="print-guides")f?.()},onZoom:(j0)=>d({dgn:"zoom",op:j0}),hasCanvas:!!X&&!Z0,onClose:()=>W(null)}),Y==="selection"&&K(Cq0,{onAction:(j0)=>{if(j0==="deselect-all")d({dgn:"selection-clear"});else if(j0==="select-all-annotations")d({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K($q0,{onAction:(j0)=>d({dgn:"tool-set",tool:j0}),onClose:()=>W(null)}),Y==="help"&&K(Tq0,{onAction:(j0)=>{if(j0==="shortcuts")I?.();else if(j0==="help")A?.();else if(j0==="report-bug")P?.();else if(j0==="tour")w?.();else if(j0==="collab-tour")R?.();else if(j0==="quick-setup")a?.();else if(j0==="readiness")h?.();else if(j0==="whatsnew")l?.();else if(j0==="watch-intro")s?.()},onClose:()=>W(null)}),_("div",{className:"st-mb-right","data-tour":"status",children:[n?K("div",{className:"st-presence",children:n}):null,l8()&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":k8?"true":"false","data-busy":b0?"true":"false","data-unseen":Z8?"true":"false","aria-label":`Assistant${b0?" — working":Z8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:e0,children:K(W9,{name:"sparkle",size:15})}),z0&&K(Gx,{center:z0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":c>0?"true":"false","aria-label":`What's new${c>0?` — ${c} unseen`:""}`,"data-tip":"What's new",onClick:l,children:K(W9,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:I0}),K("span",{className:"st-mb-file",title:X||"",children:F0}),K("span",{className:"st-mb-sep"}),_("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function yq0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:z,onIframeLoad:U,showQuickSetup:B,onStartQuickSetup:F}){return _("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&_("div",{className:"st-empty",children:[_("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),_("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",ZR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),_("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(JX,{children:"⌘"})," and hover to preview an element, click to select it — ",K(JX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",l8()?_(Y0,{children:[K("br",{}),K("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]}),B&&K("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:F,children:"Start quick setup"})]}),X.map((L)=>{if(L.path===T8)return K("div",{className:"system-view"+(L.path===J?" active":""),children:K(lq0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},L.path);return K("iframe",{ref:(D)=>Q(L.path,D),src:aH(L.path,H),className:L.path===J?"active":"","data-path":L.path,"data-testid":L.path===J?"canvas-frame":void 0,onLoad:()=>U?.(L.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},L.path)}),z&&z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:_("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var fq0=["color","space","radius","shadow","leading","weight","motion","font","other"],vq0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function xq0(X){return X==="color"}function hq0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return _("section",{className:"sv-section sv-section-tokens",children:[_("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:_("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...fq0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(Y0,{children:W.map((G)=>{let Z=Y[G],H=xq0(G);return _("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[_("h2",{children:["tokens · ",vq0[G]||G,K("span",{className:"sv-h-num",children:Z.length})]}),K("div",{className:"sv-tokens-ladder",children:Z.map((z)=>_("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:z.value}}):null,_("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:z.name}),K("span",{className:"sv-tok-value",children:z.value||"—"})]})]},z.name+"|"+z.value))})]},G)})})}function gq0(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 mq0(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 uq0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=mq0(X?.font);return _("section",{className:"sv-section sv-section-type",children:[_("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=gq0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return _("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function lq0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:z,tokensPath:U,ds:B,availableDesignSystems:F}=X,L=(!W||!W.length)&&(!G||!G.length),D=Array.isArray(F)&&F.length>1,M=B?.name??F?.[0]?.name??"";return _("div",{className:"sv",children:[_("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),D?_("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:F.map((A)=>K("option",{value:A.name,children:A.name},A.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:Z})})]}),B?.description?K("p",{className:"sv-ds-description",children:B.description}):null,K(hq0,{tokens:H,tokenGroups:z,tokensPath:U}),K(uq0,{tokenGroups:z}),L?K("div",{className:"sv-empty",children:_("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:Z}),"."]})}):_(Y0,{children:[K(ot,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(ot,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function ot({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return _("section",{className:"sv-section",children:[_("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>_("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:aH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),_("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function dq0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:z=0,unpushed:U=0,changesOpen:B=!1,onOpenChanges:F}){let L=X===T8,D=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",A=W==="dark"?"light":"dark",I=(()=>{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 P=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:P>0?`${P} ↑`:"synced",title:P>0?`${P} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${P} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return _("footer",{className:"st-statusbar",role:"contentinfo",children:[_("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:L?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!L&&_("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:M,children:D}),K("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:"×"})]}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),_("span",{className:"val",children:[Y," open"]})]}),F&&_("button",{type:"button",className:"st-sb-slot st-sb-changes"+(B?" is-open":"")+(z>0?" has-changes":U>0?" has-unpushed":""),onClick:F,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":B,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:z>0?`${z} unsaved`:U>0?`${U} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),I&&_("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(I.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:I.title,children:I.label})]}),_("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${A} theme`,"data-tip-pos":"top","aria-label":`Switch to ${A} theme`,children:[K(W9,{name:W==="dark"?"sun":"moon",size:13}),A]})]})}function pq0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:z,width:U,resizing:B}){let F=Ve(X),L=Object.keys(X||{}).sort(),D=[];for(let M of L){let A=X[M]||[],I=A.filter((w)=>{if(J==="open")return w.status!=="resolved";if(J==="resolved")return w.status==="resolved";return!0});if(I.length===0)continue;let P=A.filter((w)=>w.selector);D.push({file:M,comments:I.map((w)=>({...w,n:P.findIndex((R)=>R.id===w.id)+1}))})}return _("aside",{className:"st-rpanel"+(B?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:_("div",{className:"st-cm-filters",role:"tablist",children:[_("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",F.all]}),_("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",F.open]}),_("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",F.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:D.length===0?_("div",{className:"st-rp-empty",children:[_("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),_("p",{children:["Open a canvas, hold ",K(JX,{children:"⌘"})," and click an element, then press ",K(JX,{children:"C"})," — or hold ",K(JX,{children:"⌘⇧"})," and click directly."]})]}):D.map((M)=>_(Y0,{children:[_("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[K("span",{children:BW(dN(M.file))}),K("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>_("div",{className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[_("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),K("span",{className:"st-comment-time",children:Gq0(A.created)})]}),K("div",{className:"st-comment-txt",children:A.text}),_("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),_("span",{className:"st-mini-act",children:[A.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(I)=>{I.stopPropagation(),H(A.id)},children:K(W9,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(I)=>{I.stopPropagation(),Z(A.id)},children:K(W9,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(I)=>{I.stopPropagation(),z(A.id)},children:K(W9,{name:"x",size:14})})]})]})]},A.id))]},M.file))})]})}function cq0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return _("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),_("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),vf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function iq0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",z=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,B=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!z&&!H&&!B&&U===0)return null;let F,L,D;if(H)F="success",L="Synced with hub",D=`${Y}:flash`;else if(z){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")F="error",L=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else F="warn",L=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;D=`${Y}:offline`}else if(B){if(B.snapshotFailed)F="error",L=`Diverged on ${B.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else F="warn",L=`Diverged on ${B.slug}: kept the ${B.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${B.slug}`;D=`diverged:${B.slug}:${B.at}`}else F="warn",L=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,D=`rejected:${U}`;if(J===D)return null;return _("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${F}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:L}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(D),children:"×"})]})}var oq0=["block","inline-block","flex","inline-flex","grid","inline","none"],nt=["px","%","fr","em","auto","min-content","max-content"];var nq0=["auto","stretch","flex-start","center","flex-end","baseline"];var rt=["300","400","500","600","700","800"],at=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],st=["none","solid","dashed","dotted","double"],tt=["px","rem","em","%","vw","vh","auto"],et=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),YR={"font-size":{node:K(h9,{as:I1,size:12})},"line-height":{node:K(h9,{as:j1,size:12})},"letter-spacing":{node:K(h9,{as:l1,size:12})},gap:{node:K(h9,{as:kz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(h9,{as:o1,size:12})},"border-width":{node:K(h9,{as:u1,size:12})}};var Xe=["static","relative","absolute","fixed","sticky"],rq0=["normal","italic","oblique"],Je=["none","uppercase","lowercase","capitalize"];var Qe=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],aq0=["fill","contain","cover","none","scale-down"];var Ye=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],We=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],W5={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}},ez=null;function lN(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!ez)ez=document.createElement("canvas").getContext("2d");if(!ez)return"";ez.fillStyle="#000000",ez.fillStyle=X;let J=ez.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 AY=(X)=>Math.min(1,Math.max(0,X));function hN(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 Qq({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Yq({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 XK({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,z=0;if(X<60)[Z,H,z]=[Y,W,0];else if(X<120)[Z,H,z]=[W,Y,0];else if(X<180)[Z,H,z]=[0,Y,W];else if(X<240)[Z,H,z]=[0,W,Y];else if(X<300)[Z,H,z]=[W,0,Y];else[Z,H,z]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(z+G)*255}}function l9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function _Q(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 Ge(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 Ne(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function sq0(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],z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=z&&J[z[1]]?J[z[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 Fe(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(z)=>{if(!z.tokensCssRel)return null;try{let U=await fetch(`/${J}/${z.tokensCssRel}`),B=U.ok?await U.text():"";return{name:z.name,...sq0(B)}}catch{return null}})).then((z)=>{if(H)return;let U=z.filter(Boolean);U.sort((B,F)=>B.name===Q?-1:F.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function Le({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>Yq(hN(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),z=u.useRef(X);u.useEffect(()=>{if(X&&X!==z.current)z.current=X,W(Yq(hN(X)))},[X]);let U=Qq(XK(Y)),B=(w)=>{w.preventDefault();let R=Z.current?.getBoundingClientRect();if(!R)return;let T=G.current.h,C=($)=>{W({h:T,s:AY(($.clientX-R.left)/R.width),v:AY(1-($.clientY-R.top)/R.height)})};C(w);let b=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",b),Q(Qq(XK(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",b)},F=(w)=>{w.preventDefault();let R=H.current?.getBoundingClientRect();if(!R)return;let{s:T,v:C}=G.current,b=(y)=>{W({h:AY((y.clientX-R.left)/R.width)*360,s:T,v:C})};b(w);let $=()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",$),Q(Qq(XK(G.current)))};document.addEventListener("pointermove",b),document.addEventListener("pointerup",$)},L=(w)=>{let R={...G.current,...w};W(R),Q(Qq(XK(R)))},D=(w)=>{let R=w.shiftKey?0.1:0.02,C={ArrowLeft:[-R,0],ArrowRight:[R,0],ArrowUp:[0,R],ArrowDown:[0,-R]}[w.key];if(!C)return;w.preventDefault(),L({s:AY(G.current.s+C[0]),v:AY(G.current.v+C[1])})},M=(w)=>{let R=w.shiftKey?20:2,C={ArrowLeft:-R,ArrowRight:R}[w.key];if(C==null)return;w.preventDefault(),L({h:Math.min(360,Math.max(0,G.current.h+C))})},A=async()=>{try{let w=window.EyeDropper;if(!w)return;let R=await new w().open();if(R?.sRGBHex)W(Yq(hN(R.sRGBHex))),Q(R.sRGBHex)}catch{}},I=XK(Y),P=(w)=>{let R={...I,...w},T=Yq({r:AY(R.r/255)*255,g:AY(R.g/255)*255,b:AY(R.b/255)*255});W(T),Q(Qq(XK(T)))};return _("div",{className:"st-cp-cpick",children:[_("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(w)=>{let R=w.target.value;if(/^#?[0-9a-f]{6}$/i.test(R))W(Yq(hN(R)))},onKeyDown:(w)=>{if(w.key==="Enter")Q(w.currentTarget.value)},onBlur:(w)=>Q(w.currentTarget.value),onFocus:(w)=>w.currentTarget.select()})]}),_("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:B,onKeyDown:D,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),_("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:K(W9,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:F,onKeyDown:M,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((w)=>_("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":w.toUpperCase(),value:Math.round(I[w]),onChange:(R)=>P({[w]:AY((Number.parseFloat(R.target.value)||0)/255)*255}),onFocus:(R)=>R.currentTarget.select()}),K("span",{children:w.toUpperCase()})]},w))})]})}function gN({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:z}){let[U,B]=u.useState(!1),[F,L]=u.useState(null),[D,M]=u.useState("custom"),[A,I]=u.useState(""),P=u.useRef(null),w=u.useRef(null),R=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(s)=>Q===`var(${s})`,C=(s)=>s.replace(/^--/,"").replace(/-/g," "),b=J||[],$=b.reduce((s,c)=>s+(c.names?.length||0),0),y=b.length>1,v=A.trim().toLowerCase(),g=!v?b:b.map((s)=>({...s,names:(s.names||[]).filter((c)=>C(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(s.vals?.[c]||"").toLowerCase().includes(v))})).filter((s)=>s.names.length);u.useEffect(()=>{if(!U){I("");return}let s=()=>{let n=P.current?.getBoundingClientRect();if(!n)return;let o=224,V0=300,f0=Math.min(n.right-o,window.innerWidth-o-8);if(f0<8)f0=8;let X8=window.innerHeight-n.bottom>V0+8?n.bottom+4:Math.max(8,n.top-V0-4);L({left:f0,top:X8,width:o,maxHeight:V0})};s();let c=(n)=>{if(w.current?.contains(n.target)||P.current?.contains(n.target))return;B(!1)},z0=(n)=>{if(n.key==="Escape")B(!1)},e=(n)=>{if(w.current?.contains(n.target))return;s()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",z0),window.addEventListener("resize",s),document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",z0),window.removeEventListener("resize",s),document.removeEventListener("scroll",e,!0)}},[U]),u.useEffect(()=>{if(!U||!F||!w.current)return;let s=w.current.getBoundingClientRect(),c=F.left-s.left,z0=F.top-s.top;if(Math.abs(c)>0.5||Math.abs(z0)>0.5)L((e)=>e?{...e,left:e.left+c,top:e.top+z0}:e)},[U,F]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,p=(s,c,z0)=>{if(H&&s&&s!==H&&z0&&!m.test(z0))Y(z0);else Y(`var(${c})`);B(!1)},f=(s)=>{let c=(s||"").trim();if(c)Y(c)},d=_("div",{className:"st-cp-pop-search",children:[K(W9,{name:"search",size:12}),K("input",{value:A,onChange:(s)=>I(s.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(s)=>s.map((c)=>_("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:c.ds}):null,K("div",{className:"st-cp-pop-list",children:c.names.map((z0)=>_("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(z0)?" is-on":""}`,onClick:()=>p(c.ds,z0,c.vals?.[z0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[z0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:C(z0)}),K("span",{className:"st-cp-pop-val",children:c.vals?.[z0]||""})]},`${c.ds}:${z0}`))})]},c.ds)),h=(s)=>s.map((c)=>_("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:c.ds}):null,K("div",{className:"st-cp-pop-list",children:c.names.map((z0)=>_("button",{type:"button",className:`st-cp-pop-row${T(z0)?" is-on":""}`,onClick:()=>p(c.ds,z0,c.vals?.[z0]),children:[K("span",{className:"st-cp-pop-name",children:C(z0)}),K("span",{className:"st-cp-pop-val",children:c.vals?.[z0]||""})]},`${c.ds}:${z0}`))})]},c.ds)),a=K("div",{className:"st-cp-pop-empty",children:"No match"});return _(Y0,{children:[G!==void 0?K("button",{type:"button",ref:P,className:`${z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${R&&!z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>B((s)=>!s),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:P,className:`st-cp-tokbtn${R?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>B((s)=>!s),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&F?He.createPortal(K("div",{ref:w,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:F.left,top:F.top,width:F.width,maxHeight:F.maxHeight},children:X==="color"?_(Y0,{children:[_("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":D==="custom",className:`st-cp-poptab${D==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":D==="vars",className:`st-cp-poptab${D==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),D==="custom"?K(Le,{seed:Z||lN(Q)||"#000000",onApply:f}):!$?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):_(Y0,{children:[d,g.length?l(g):a]})]}):!$?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):_(Y0,{children:[d,g.length?h(g):a]})}),document.body):null]})}function Ze({label:X,tracks:J,editable:Q,onChange:Y}){let W=(z,U)=>{let B=J[z];Y(J.map((F,L)=>L===z?bU.has(U)?{value:0,unit:U}:{value:B.value||1,unit:U}:F))},G=(z,U)=>{Y(J.map((B,F)=>F===z?{...B,value:U}:B))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(z)=>Y(J.filter((U,B)=>B!==z));return _("div",{className:"st-cp-gridtracks",children:[_("div",{className:"st-cp-gridtracks-hd",children:[K("span",{className:"st-cp-gridtracks-label",children:X}),K("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?_("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((z,U)=>{let B=bU.has(z.unit);return _("div",{className:"st-cp-gridtrack-row",children:[B?K(s4,{value:z.unit,ariaLabel:`${X} track ${U+1}`,options:nt.map((F)=>({value:F,label:F})),onChange:(F)=>W(U,F)}):K(h6,{value:z.value,min:z.unit==="fr"?0.1:0,step:z.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:K(wB,{value:z.unit,units:nt,ariaLabel:`${X} track ${U+1} unit`,onChange:(F)=>W(U,F)}),onCommit:(F)=>G(U,F)}),K("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function tq0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let z=!!X.id,U=X.computed||{},[B,F]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{F({a:{},c:{},t:{}})},[X.id]);let L=(t,q0)=>{let G0={...t||{}};for(let[E0,u0]of Object.entries(q0))if(u0===null)delete G0[E0];else G0[E0]=u0;return G0},D=L(X.authored,B.a),M=L(X.customStyles,B.c),A=L(X.attrs,B.t),I=(t,q0)=>F((G0)=>({...G0,a:{...G0.a,[t]:q0}})),P=(t,q0)=>F((G0)=>({...G0,c:{...G0.c,[t]:q0}})),w=(t,q0)=>F((G0)=>({...G0,t:{...G0.t,[t]:q0}})),R=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Ne(X.file,J),C=Fe(J,R,T),b=(t)=>C.map((q0)=>({ds:q0.name,names:q0[t]||[],vals:q0.vals})).filter((q0)=>q0.names.length),[$,y]=u.useState({}),[v,g]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let p=(D.position||l9(U.position)||"static")!=="static";u.useEffect(()=>{if(p)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,p]);let f=H,[d,l]=u.useState({});async function h(t,q0,G0){y((E0)=>({...E0,[G0]:"saving"}));try{let E0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(q0)}),u0=await E0.json().catch(()=>({}));y((O8)=>({...O8,[G0]:!E0.ok||!u0.ok?`err:${u0&&u0.error||`HTTP ${E0.status}`}`:"saved"}))}catch(E0){y((u0)=>({...u0,[G0]:`err:${E0&&E0.message?E0.message:String(E0)}`}))}}let a=(t,q0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:q0})},s=(t,q0,G0,E0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:q0,before:G0==null||G0===""?null:G0,after:E0==null||E0===""?null:E0})},c=(t,q0)=>{let G0=(q0||"").trim();if(!z||!G0)return;let E0=D[t]??null;if(G0===(E0??"").trim())return;a(t,G0),I(t,G0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:G0},t),s("css",t,E0,G0)},z0=(t,q0)=>{let G0=(q0||"").trim(),E0=t.trim();if(!z||!E0||!G0)return;let u0=M[E0]??null;a(E0,G0),P(E0,G0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:E0,value:G0},E0),s("css",E0,u0,G0)},e=(t,q0)=>{let G0=(t||"").trim(),E0=(q0||"").trim();if(!z||!G0||!E0)return;let u0=A[G0]??null;w(G0,E0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:G0,value:E0},`@${G0}`),s("attr",G0,u0,E0)},n=(t)=>{if(!z)return;let q0=D[t]??null;a(t,null),I(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),s("css",t,q0,null)},o=(t)=>{if(!z)return;let q0=M[t]??null;a(t,null),P(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),s("css",t,q0,null)},V0=(t)=>{if(!z)return;let q0=A[t]??null;w(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),s("attr",t,q0,null)},f0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},G8=(t,q0)=>{if(!z)return;let G0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),E0=q$(t,q0,f0,G0);for(let u0 of E0.reset)if(D[u0])n(u0);for(let[u0,O8]of E0.set)c(u0,O8)},X8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",a0=(t)=>{let q0=V$(t,D,U,f0);return _("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:K(_B,{value:q0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(G0)=>G8(t,G0)})})]},`mode-${t}`)},w0=["flex-start","center","flex-end"],d0=["flex-start","center","flex-end"],Y8=["t","c","b"],k8=["l","c","r"],e0=()=>{let t=!(D["flex-direction"]||l9(U["flex-direction"])||"row").startsWith("column"),q0=Math.max(0,w0.indexOf(D["justify-content"]||l9(U["justify-content"])||"flex-start")),G0=D["align-items"]||l9(U["align-items"])||"stretch",E0=G0==="stretch"?1:Math.max(0,d0.indexOf(G0)),[u0,O8]=t?[q0,E0]:[E0,q0];return Y8[O8]+k8[u0]},b0=(t)=>{let q0=Y8.indexOf(t[0]),G0=k8.indexOf(t[1]),E0=!(D["flex-direction"]||l9(U["flex-direction"])||"row").startsWith("column"),[u0,O8]=E0?[G0,q0]:[q0,G0];c("justify-content",w0[u0]),c("align-items",d0[O8])},Z8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let q0=t.key.toLowerCase();if(q0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(q0==="y")t.preventDefault(),G?.("redo")},p0=(t)=>{let q0=D[t];if(!q0)return"inherit";return/var\(\s*--/.test(q0)?"bound":"raw"};if(!z)return _("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),_("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let C8={bound:"token-bound",raw:"raw override",inherit:"inherited"},Q9=(t)=>K("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":C8[t]}),Z9=(t,q0)=>{let G0=q0??p0(t),E0=$[t],u0=typeof E0==="string"&&E0.startsWith("err:")?E0.slice(4):"",O8=u0?" is-err":E0==="saved"?" is-saved":E0==="saving"?" is-saving":"",M8=!!D[t],w8=u0?`error: ${u0}`:M8?`${C8[G0]} · double-click to reset`:C8[G0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${G0}${O8}${M8?" is-resettable":""}`,"aria-label":w8,title:w8,tabIndex:M8?0:-1,onDoubleClick:M8?()=>n(t):void 0,onKeyDown:M8?($8)=>{if($8.key==="Backspace"||$8.key==="Delete")$8.preventDefault(),n(t)}:void 0})},T0=(t,q0,G0,E0)=>{let u0=G0===void 0&&!D[t],O8=E0??t;return _("div",{className:`st-cp-row${u0?" is-unset":""}`,children:[Z9(t,G0),K("label",{className:"st-cp-label",title:O8,children:O8}),K("div",{className:"st-cp-ctl",children:q0})]},t)},H9={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"]},$0=(t)=>{(H9[t]||[]).forEach((q0)=>{if(D[q0])n(q0)})},J8=(t,q0)=>{let G0=(H9[t]||[]).some((E0)=>D[E0]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[t],onClick:()=>g((E0)=>({...E0,[t]:!E0[t]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:v[t]?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${G0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!G0,onClick:()=>$0(t),children:K(h9,{as:iG,size:12})})]}),K("div",{className:`st-cp-sec-anim${v[t]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:q0})})]},t)},Z0=(t,q0,G0,E0=!0)=>{let u0=`d:${t}`,O8=v[u0]===void 0?E0:v[u0],M8=q0.some((w8)=>D[w8]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":O8,onClick:()=>g((w8)=>({...w8,[u0]:!O8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:O8?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${M8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!M8,onClick:()=>q0.forEach((w8)=>{if(D[w8])n(w8)}),children:K(h9,{as:iG,size:12})})]}),K("div",{className:`st-cp-sec-anim${O8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:G0})})]},u0)},I0=(t)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!d[t],"aria-label":d[t]?`${t} — fewer options`:`${t} — more options`,title:d[t]?"fewer":"more",onClick:()=>l((q0)=>({...q0,[t]:!q0[t]})),children:d[t]?"▴":"···"}),F0=(t,q0)=>_("select",{className:"st-cp-nsel","aria-label":t,value:q0.includes(D[t])?D[t]:"",onChange:(G0)=>c(t,G0.target.value),children:[K("option",{value:"",disabled:!0,children:l9(U[t])||"—"}),q0.map((G0)=>K("option",{value:G0,children:G0},G0))]}),z8=(t)=>b(t).flatMap((q0)=>(q0.names||[]).map((G0)=>({name:G0,value:q0.vals?.[G0]||""}))),I8=(t,q0)=>K(mw,{value:D[t]||l9(U[t])||q0[0].value,ariaLabel:t,options:q0,onChange:(G0)=>c(t,G0)}),W8=(t,q0,G0={})=>{let E0=_Q(D[t]??""),u0=et.has(t),O8=D[t]??"",M8=typeof O8==="string"&&/var\(\s*--/.test(O8),w8=u0?"":E0.unit&&E0.unit!=="auto"?E0.unit:"px",$8=Number.parseFloat(_Q(l9(U[t])??"").n)||0,n8=E0.n!==""&&E0.n!=null?Number.parseFloat(E0.n)||0:$8,$9=YR[t];return K(AB,{value:M8?O8:n8,tokens:z8(q0),ariaLabel:t,min:G0.min??0,lead:$9?$9.node??$9.t:void 0,unitSlot:u0?null:K(wB,{units:tt,value:E0.unit||"px",ariaLabel:`${t} unit`,onChange:(q9)=>c(t,q9==="auto"?"auto":`${E0.n||"0"}${q9}`)}),onChange:(q9)=>c(t,typeof q9==="string"?q9:u0?`${q9}`:`${q9}${w8}`)})},j0=()=>{let t=(u0)=>Number.parseFloat(_Q(D[u0]??D["border-radius"]??l9(U[u0])??l9(U["border-radius"])??"0").n)||0,q0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},G0=(u0)=>{if(u0.tl===u0.tr&&u0.tr===u0.bl&&u0.bl===u0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((M8)=>{if(D[M8])n(M8)}),c("border-radius",`${u0.tl}px`);else c("border-top-left-radius",`${u0.tl}px`),c("border-top-right-radius",`${u0.tr}px`),c("border-bottom-left-radius",`${u0.bl}px`),c("border-bottom-right-radius",`${u0.br}px`)},E0=YR["border-radius"];return K($v,{corners:q0,lead:E0?E0.node??E0.t:void 0,onCorners:G0})},N0=()=>_("div",{className:"st-cp-border",children:[V9("border-width",null,{fixedUnit:"px"}),_("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:st.includes(D["border-style"])?D["border-style"]:"",onChange:(t)=>c("border-style",t.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),st.map((t)=>K("option",{value:t,children:t},t))]}),K(gN,{kind:"color",groups:b("color"),current:D["border-color"],activeDs:T,swatchBg:U["border-color"]||D["border-color"]||"",seedHex:lN(U["border-color"]||D["border-color"])||"#000000",onPick:(t)=>c("border-color",t),label:"border colour"})]}),c0=()=>{let t=D.transform||l9(U.transform)||"",q0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),G0=((q0?Number.parseFloat(q0[1]):0)%360+360)%360,E0=(u0)=>{let O8=(u0%360+360)%360,M8=(D.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${M8?`${M8} `:""}rotate(${O8}deg)`.trim())};return _("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(Tv,{value:G0,onChange:E0}),K(h6,{value:G0,min:0,max:360,ariaLabel:"rotation",lead:K(h9,{as:iG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:E0})]})},s0=()=>{let t=D.filter||l9(U.filter)||"",q0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),G0=q0?Number.parseFloat(q0[1]):0;return K(h6,{value:G0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(u0)=>{let O8=(D.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",u0>0?`${O8?`${O8} `:""}blur(${u0}px)`.trim():O8||"none")}})},M0=()=>{let t=D.opacity,q0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(l9(U.opacity))||1,G0=Math.round((Number.isNaN(q0)?1:q0)*100);return K(qJ,{value:G0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(E0)=>a("opacity",String(E0/100)),onCommit:(E0)=>c("opacity",String(E0/100))},`opacity:${t??""}`)},n0=()=>{let t=Number.parseInt(D["font-weight"]||l9(U["font-weight"])||"400",10)>=600,q0=(D["font-style"]||l9(U["font-style"]))==="italic",G0=/underline/.test(D["text-decoration"]||l9(U["text-decoration"])||"");return K(Iv,{value:{b:t,i:q0,u:G0},ariaLabel:"text style",options:[{value:"b",node:K(h9,{as:y1}),label:"Bold"},{value:"i",node:K(h9,{as:g1}),label:"Italic"},{value:"u",node:K(h9,{as:a1}),label:"Underline"}],onToggle:(E0)=>{if(E0==="b")c("font-weight",t?"400":"700");else if(E0==="i")c("font-style",q0?"normal":"italic");else c("text-decoration",G0?"none":"underline")}})},D8=[{value:"row",node:K(h9,{as:u4}),label:"Row"},{value:"column",node:K(h9,{as:l4}),label:"Column"}],x8=[{value:"flex-start",node:K(h9,{as:C1}),label:"Start"},{value:"center",node:K(h9,{as:k1}),label:"Center"},{value:"flex-end",node:K(h9,{as:T1}),label:"End"},{value:"space-between",node:K(h9,{as:kz}),label:"Space between"}],I9=[{value:"flex-start",node:K(h9,{as:b1}),label:"Start"},{value:"center",node:K(h9,{as:$1}),label:"Center"},{value:"flex-end",node:K(h9,{as:S1}),label:"End"},{value:"stretch",node:K(h9,{as:n1}),label:"Stretch"}],d9=[{value:"left",node:K(h9,{as:A5}),label:"Left"},{value:"center",node:K(h9,{as:c4}),label:"Center"},{value:"right",node:K(h9,{as:i4}),label:"Right"},{value:"justify",node:K(h9,{as:o4}),label:"Justify"}],U9=[{value:"visible",node:K(h9,{as:cG}),label:"Visible"},{value:"hidden",node:K(h9,{as:oG}),label:"Hidden"},{value:"scroll",node:K(h9,{as:c1}),label:"Scroll"}],l7=(t,q0)=>{let G0=b(q0);return G0.length?K(gN,{kind:"value",groups:G0,current:D[t],activeDs:T,onPick:(E0)=>c(t,E0),label:`${t} design token`}):null},q7=(t)=>{let q0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===q0)q0.select()})},wX=(t,q0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let G0=t.shiftKey?10:1,E0=t.key==="ArrowUp"?1:-1,u0=(Number.parseFloat(t.currentTarget.value)||0)+E0*G0;return t.currentTarget.value=String(u0),q0(u0),!0},p9=(t)=>K("input",{className:"st-cp-fin","aria-label":t,defaultValue:D[t]??"",placeholder:l9(U[t])||"—",onFocus:q7,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>c(t,q0.currentTarget.value)},`${t}:${D[t]??""}`),V9=(t,q0,G0={})=>{let E0=_Q(D[t]??""),u0=et.has(t),O8=u0?"":G0.fixedUnit||(E0.unit&&E0.unit!=="auto"?E0.unit:"px"),M8=YR[t],w8=Number.parseFloat(_Q(l9(U[t])??"").n)||0,$8=E0.n!==""&&E0.n!=null?Number.parseFloat(E0.n)||0:w8;return _(Y0,{children:[K(h6,{value:$8,min:G0.min??0,step:1,ariaLabel:t,lead:M8?M8.node??M8.t:void 0,onCommit:(n8)=>c(t,u0?`${n8}`:`${n8}${O8}`),unitSlot:u0||G0.fixedUnit?null:K(wB,{units:tt,value:E0.unit||"px",ariaLabel:`${t} unit`,onChange:(n8)=>c(t,n8==="auto"?"auto":`${E0.n||"0"}${n8}`)})},`${t}:${D[t]??""}`),l7(t,q0)]})},c9=(t)=>{let q0=U[t]||D[t]||"",G0=D[t]??"",E0=typeof G0==="string"&&/var\(\s*--/.test(G0),u0=E0?G0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):G0;return K(t1,{swatch:K(gN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:b("color"),current:D[t],activeDs:T,swatchBg:q0,seedHex:lN(U[t]||D[t])||"#000000",onPick:(O8)=>c(t,O8),label:`${t} colour`}),displayValue:u0,bound:E0,ariaLabel:t,onValue:(O8)=>c(t,O8)})},X9=(t,q0)=>{let G0=null,E0=q0.unitless?"":"px",u0=(w8)=>q0.unitless?`${w8}`:`${w8}${E0}`,O8=(w8,$8,n8)=>{for(let $9 of $8??[t])n8($9,u0(w8))},M8=gw({getBase:()=>G0?.value??"0",min:q0.min??0,step:1,sides:q0.sides,onInput:(w8,$8)=>{if(G0)G0.value=String(w8);if($8){let n8=G0?.closest(".st-cp-box");for(let $9 of $8){if($9===t)continue;let q9=n8?.querySelector(`.st-cp-boxv[aria-label="${$9}"]`);if(q9)q9.value=String(w8)}}O8(w8,$8,a)},onCommit:(w8,$8)=>O8(w8,$8,c)});return{onPointerDown:(w8)=>{G0=w8.currentTarget,M8(w8)}}},G9=(t,q0)=>{let G0=D[t],E0=G0!=null&&G0!==""?_Q(G0).n||G0:_Q(l9(U[t])??"").n||"0",u0=!G0||G0==="0"||G0==="0px"||G0==="auto",O8=t.split("-").pop(),M8=O8==="top"||O8==="bottom"?[`${q0}-top`,`${q0}-bottom`]:[`${q0}-left`,`${q0}-right`],w8=[`${q0}-top`,`${q0}-right`,`${q0}-bottom`,`${q0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${q0[0]}${t.split("-").pop()[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:E0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...X9(t,{sides:{pair:M8,all:w8}}),onFocus:q7,onKeyDown:($8)=>{if(wX($8,(n8)=>c(t,`${n8}px`)))return;if($8.key==="Enter")$8.currentTarget.blur()},onBlur:($8)=>{let n8=$8.currentTarget.value.trim();if(!n8)return;let $9=/[a-z%]/i.test(n8)?n8:`${n8}px`;c(t,$9)}},`${t}:${G0??""}`)},J7=(t)=>{let q0=D[t],G0=q0!=null&&q0!==""&&q0!=="auto"?_Q(q0).n||q0:_Q(l9(U[t])??"").n||"",E0=!q0||q0==="auto"||q0==="0"||q0==="0px",u0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],O8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${E0?" is-zero":""}`,"aria-label":t,defaultValue:G0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...X9(t,{sides:{pair:u0,all:O8},min:-1/0}),onFocus:q7,onKeyDown:(M8)=>{if(wX(M8,(w8)=>c(t,`${w8}px`)))return;if(M8.key==="Enter")M8.currentTarget.blur()},onBlur:(M8)=>{let w8=M8.currentTarget.value.trim();if(!w8)return;let $8=/[a-z%]/i.test(w8)?w8:`${w8}px`;c(t,$8)}},`${t}:${q0??""}`)},g9=Object.entries(M),i9=Object.entries(A),W7=()=>{let t=(X.tag||"").toLowerCase(),G0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!D["object-fit"]||!!D["object-position"]||!!D["aspect-ratio"],E0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:G0,canReplace:E0}},O7=(t)=>_(Y0,{children:[t&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),T0("object-fit",F0("object-fit",aq0)),T0("object-position",p9("object-position")),T0("aspect-ratio",_("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:We.includes(D["aspect-ratio"])?D["aspect-ratio"]:"",onChange:(q0)=>{let G0=q0.target.value;if(c("aspect-ratio",G0),G0&&G0!=="auto"&&D.height)n("height")},children:[K("option",{value:"",disabled:!0,children:l9(U["aspect-ratio"])||"—"}),We.map((q0)=>K("option",{value:q0,children:q0},q0))]}))]});return _("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Z8,children:[_("div",{className:"st-cp-id",children:[_("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?_("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(mw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(h9,{as:m4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(h9,{as:n4,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?_(Y0,{children:[Z0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(D.display||l9(U.display)||"").trim();return t==="flex"||t==="inline-flex"?_(Y0,{children:[T0("flex-direction",I8("flex-direction",D8),void 0,"Direction"),T0("align-items",K(kv,{value:e0(),onChange:b0,ariaLabel:"auto-layout alignment"}),p0("align-items"),"Alignment"),T0("gap",W8("gap","space"),void 0,"Gap"),_("div",{className:"st-cp-modes",children:[a0("width"),a0("height")]}),_("div",{className:"st-cp-box","aria-label":"padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[Q9(p0("padding-top")),"padding"]}),G9("padding-top","padding"),G9("padding-right","padding"),G9("padding-bottom","padding"),G9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:I0("Auto layout")}),d["Auto layout"]?T0("flex-wrap",K(FQ,{checked:/^wrap/.test(D["flex-wrap"]||l9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(G0)=>c("flex-wrap",G0?"wrap":"nowrap")}),p0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),Z0("Size",["width","height","min-width","max-width","min-height","max-height"],_(Y0,{children:[T0("width",V9("width"),void 0,"Width"),T0("height",V9("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:I0("Size")}),d.Size?_(Y0,{children:[T0("min-width",V9("min-width"),void 0,"Min width"),T0("max-width",V9("max-width"),void 0,"Max width"),T0("min-height",V9("min-height"),void 0,"Min height"),T0("max-height",V9("max-height"),void 0,"Max height")]}):null]})),Z0("Position",["position","top","right","bottom","left","z-index"],_(Y0,{children:[T0("position",F0("position",Xe),void 0,"Position"),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[Q9(p0("top")),"inset"]}),J7("top"),J7("right"),J7("bottom"),J7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:D.position||l9(U.position)||"static"})]}),(D.position||l9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:I0("Position")}),d.Position?T0("z-index",V9("z-index"),void 0,"Layer order"):null]}),!1),Z0("Fill",["background-color"],T0("background-color",c9("background-color"),void 0,"Fill")),Z0("Stroke",["border-width","border-style","border-color"],T0("border",N0(),p0("border-width"),"Stroke")),Z0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],T0("border-radius",j0(),p0("border-radius"),"Corner radius")),Z0("Effects",["box-shadow","filter","mix-blend-mode"],_(Y0,{children:[T0("box-shadow",l7("box-shadow","shadow")||p9("box-shadow"),void 0,"Shadow"),T0("filter",s0(),p0("filter"),"Blur"),T0("mix-blend-mode",F0("mix-blend-mode",Ye),void 0,"Blend")]})),Z0("Opacity",["opacity"],T0("opacity",M0(),void 0,"Opacity")),Z0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],_(Y0,{children:[T0("font-family",F0("font-family",at),void 0,"Font"),T0("color",c9("color"),void 0,"Color"),T0("font-size",W8("font-size","type"),void 0,"Size"),T0("font-weight",F0("font-weight",rt),void 0,"Weight"),T0("line-height",V9("line-height","lh"),void 0,"Line height"),T0("text-align",I8("text-align",d9),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:I0("Text")}),d.Text?_(Y0,{children:[T0("letter-spacing",V9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),T0("font-style",F0("font-style",rq0),void 0,"Style"),T0("text-transform",F0("text-transform",Je),void 0,"Case"),T0("white-space",F0("white-space",Qe),void 0,"Whitespace")]}):null]})),Z0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],_("div",{className:"st-cp-box","aria-label":"margin",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[Q9(p0("margin-top")),"margin"]}),G9("margin-top","margin"),G9("margin-right","margin"),G9("margin-bottom","margin"),G9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:q0}=W7();return t?Z0("Media",["object-fit","object-position","aspect-ratio"],O7(q0)):null})()]}):_(Y0,{children:[J8("Layout",(()=>{let t=(D.display||l9(U.display)||"").trim(),q0=t==="flex"||t==="inline-flex",G0=t==="grid"||t==="inline-grid";return _(Y0,{children:[T0("display",F0("display",oq0)),q0?_(Y0,{children:[T0("flex-direction",I8("flex-direction",D8)),T0("flex-wrap",K(FQ,{checked:/^wrap/.test(D["flex-wrap"]||l9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>c("flex-wrap",E0?"wrap":"nowrap")}),p0("flex-wrap"))]}):null,q0||G0?_(Y0,{children:[T0("align-items",I8("align-items",I9)),T0("justify-content",I8("justify-content",x8)),T0("gap",W8("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(D.display||l9(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let G0=D["grid-template-columns"]||"",E0=D["grid-template-rows"]||"",u0=nD(G0),O8=nD(E0),M8=u0.length>0||!G0.trim(),w8=O8.length>0||!E0.trim();return J8("Grid",_(Y0,{children:[M8?K(Ze,{label:"Columns",tracks:u0,editable:z,onChange:($8)=>c("grid-template-columns",rD($8))}):_("div",{className:"st-cp-note",children:["Columns use ",K("code",{children:G0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),w8?K(Ze,{label:"Rows",tracks:O8,editable:z,onChange:($8)=>c("grid-template-rows",rD($8))}):_("div",{className:"st-cp-note",children:["Rows use ",K("code",{children:E0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),J8("Position",_(Y0,{children:[T0("position",F0("position",Xe)),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[Q9(p0("top")),"inset"]}),J7("top"),J7("right"),J7("bottom"),J7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:D.position||l9(U.position)||"static"})]}),(D.position||l9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,T0("z-index",V9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&J8("Grid item",_(Y0,{children:[_("div",{className:"st-cp-note",children:["Manual cell placement — ",K("code",{children:"start / end"})," or ",K("code",{children:"start / span N"}),"."]}),T0("grid-column",p9("grid-column")),T0("grid-row",p9("grid-row"))]})),J8("Typography",_(Y0,{children:[T0("font-family",F0("font-family",at)),T0("color",c9("color")),T0("font-size",W8("font-size","type")),T0("font-weight",F0("font-weight",rt)),T0("line-height",V9("line-height","lh")),T0("letter-spacing",V9("letter-spacing",null,{min:-1/0})),T0("text-align",I8("text-align",d9)),T0("font-style",n0(),p0("font-style")),T0("text-transform",F0("text-transform",Je)),T0("white-space",F0("white-space",Qe))]})),J8("Spacing",K(Y0,{children:_("div",{className:"st-cp-box","aria-label":"margin and padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[Q9(p0("margin-top")),"margin"]}),G9("margin-top","margin"),G9("margin-right","margin"),G9("margin-bottom","margin"),G9("margin-left","margin"),_("div",{className:"st-cp-boxpad",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[Q9(p0("padding-top")),"padding"]}),G9("padding-top","padding"),G9("padding-right","padding"),G9("padding-bottom","padding"),G9("padding-left","padding"),_("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(D.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(D.height)||X.bounds?.h||0)]})]})]})})),J8("Size",_(Y0,{children:[_("div",{className:"st-cp-modes",children:[a0("width"),a0("height")]}),T0("width",V9("width")),T0("height",V9("height")),T0("min-width",V9("min-width")),T0("max-width",V9("max-width")),T0("min-height",V9("min-height")),T0("max-height",V9("max-height")),T0("overflow",I8("overflow",U9)),X8?_(Y0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),T0("align-self",F0("align-self",nq0)),T0("flex-grow",V9("flex-grow",null,{unitless:!0})),T0("flex-shrink",V9("flex-shrink",null,{unitless:!0})),T0("flex-basis",V9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:q0}=W7();return t?J8("Media",O7(q0)):null})(),J8("Appearance",_(Y0,{children:[T0("background-color",c9("background-color")),T0("border-radius",j0(),p0("border-radius")),T0("border",N0(),p0("border-width")),T0("box-shadow",l7("box-shadow","shadow")||p9("box-shadow")),T0("filter",s0(),p0("filter")),T0("mix-blend-mode",F0("mix-blend-mode",Ye)),T0("opacity",M0()),T0("rotation",c0(),p0("transform")),T0("transform",p9("transform")),T0("transform-origin",p9("transform-origin"))]})),(()=>{let t=Object.entries($).find(([,q0])=>typeof q0==="string"&&q0.startsWith("err:"));return t?_("div",{className:"st-cp-save is-err",role:"status",children:[K(W9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),J8("Advanced",_("div",{className:"st-cp-advbody",children:[g9.length?_(Y0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),g9.map(([t,q0])=>_("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(G0)=>{if(G0.key==="Enter")G0.currentTarget.blur()},onBlur:(G0)=>z0(t,G0.currentTarget.value)},`cs:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>o(t),children:K(W9,{name:"x",size:11})})]},`cs:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(eq0,{commit:z0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),i9.length?_(Y0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),i9.map(([t,q0])=>_("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(G0)=>{if(G0.key==="Enter")G0.currentTarget.blur()},onBlur:(G0)=>e(t,G0.currentTarget.value)},`at:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>V0(t),children:K(W9,{name:"x",size:11})})]},`at:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(X30,{commit:e})]}))]}),_("div",{className:"st-cp-legend",children:[_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),_("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function eq0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 X30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 J30={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function Q30(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===J)return G=z[U],z.splice(U,1),!0;if(z[U].children&&Z(z[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(z[U].children=z[U].children||[],Y==="inside-start")z[U].children.unshift(G);else z[U].children.push(G);else z.splice(Y==="before"?U:U+1,0,G);return!0}if(z[U].children&&H(z[U].children))return!0}return!1};return H(W)?W:X}var Y30=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function De({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:B,onRowPointerDown:F,dragState:L,componentMap:D,lockedKeys:M,onToggleLock:A,onRename:I}){let P=`${X.id}:${X.index}`,w=X.children&&X.children.length>0,R=W.has(P),T=!!X.synthetic,C=!T&&D?D[X.id]:null,b=!T&&!!M?.has(P),[$,y]=u.useState(!1),[v,g]=u.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),p=G?.has(P)?G.get(P):!!X.hidden,f=!!B&&!T&&!b,d=()=>{y(!1);let a=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!a||a===(X.dcElement??""))return;I?.(X,a)},l=L?.key===P,h=l?{transform:`translate(${L.dx}px, ${L.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 _(Y0,{children:[_("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(p?" is-hidden":"")+(T?" is-group":"")+(C?" is-instance":"")+(b?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":w?!R:void 0,"aria-grabbed":f?l:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${I?" · F2 to rename":""}`,"data-layer-key":P,onClick:()=>T?w&&Z(P):H(X),onMouseEnter:()=>!T&&z(X),onMouseLeave:()=>z(null),onPointerDown:f?(a)=>F(a,X,P):void 0,onKeyDown:(a)=>{if(a.key==="Enter"||a.key===" ")if(a.preventDefault(),T)w&&Z(P);else H(X);else if(a.key==="F2"&&I&&!T)a.preventDefault(),g(X.dcElement||X.label||""),y(!0)},children:[w?K("button",{type:"button",className:"st-layer-caret","aria-label":R?"Expand":"Collapse",onClick:(a)=>{a.stopPropagation(),Z(P)},children:R?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),C?K("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:C.root?"◆":"◇"}):K(W9,{name:J30[X.type]||"box",size:12,className:"st-layer-ticon"}),$?K("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(a)=>a.target.select(),onChange:(a)=>g(a.target.value),onClick:(a)=>a.stopPropagation(),onPointerDown:(a)=>a.stopPropagation(),onBlur:d,onKeyDown:(a)=>{if(a.stopPropagation(),a.key==="Enter")d();else if(a.key==="Escape")y(!1)}}):K("span",{className:"st-layer-label",onDoubleClick:I&&!T?(a)=>{a.stopPropagation(),g(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),K("span",{className:"st-layer-type",children:C?C.component:X.type}),A&&!T?K("button",{type:"button",className:"st-layer-lock","aria-label":b?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":b,title:b?"Unlock":"Lock",onClick:(a)=>{a.stopPropagation(),A(P)},children:K(W9,{name:b?"lock":"unlock",size:12})}):null,U&&!T?K("button",{type:"button",className:"st-layer-eye","aria-label":p?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":p,title:p?"Show":"Hide",onClick:(a)=>{a.stopPropagation(),U(X)},children:K(W9,{name:p?"eye-off":"eye",size:13})}):null]}),w&&!R?X.children.map((a,s)=>K(De,{node:a,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:B,onRowPointerDown:F,dragState:L,componentMap:D,lockedKeys:M,onToggleLock:A,onRename:I},`${a.id}:${a.index}`)):null]})}function W30({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let B=Q[U];if(B&&/var\(\s*--/.test(B))return B.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||B||""},W=(U,B)=>{let F=J[B]||Q[B];if(!F)return null;return _("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:U}),_("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:F},"aria-hidden":"true"}),K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(B)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?_Q(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 _(Y0,{children:[G?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Oe(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var G30=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],Z30=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function H30({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let z=Oe(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),B=Ne(X.file,J),F=Fe(J,U,B),L=(l)=>F.map((h)=>({ds:h.name,names:h[l]||[],vals:h.vals})).filter((h)=>h.names.length),D=(l)=>L(l).flatMap((h)=>(h.names||[]).map((a)=>({name:a,value:h.vals?.[a]||""}))),M=(l)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(l||"");if(!h)return l||"";for(let a of F){let s=a.vals?.[h[1]];if(s)return s}return""},A=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,I=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,P=(l,h)=>{if(!z)return;let a=Number.isFinite(l)&&l>0?Math.round(l):void 0,s=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(a==null&&s==null)return;Q?.(z,a,s)},w=Object.entries(W5).find(([,l])=>l.width===A&&l.height===I)?.[0],R=Object.entries(W5).find(([,l])=>l.width===A)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",C=X.attrs?.["data-dc-bg"]??"",b=X.attrs?.["data-dc-padding"]??"",$=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=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=(l)=>{if(!z)return;let h=null;if(l==="print"&&!g){let a={paper:"a4"};try{let s=g3(a);if(s)h={defaults:a,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(z,l==="digital"?null:l,h),l==="web"&&T)Y?.(z,!1,void 0)},p=(l)=>{if(!z)return;let h={paper:"a4",...g,...l},a;try{a=g3(h)}catch{return}Q?.(z,a.widthPx,a.heightPx),Z?.(z,h)},f=(l)=>{if(!z)return;let h=l&&Number.isFinite(I)?Math.round(I):void 0;Y?.(z,l,h)},d=(l)=>{if(!z)return;W?.(z,l)};return _("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),_("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[K(h6,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(l)=>P(l,null)}),K(h6,{value:I??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(l)=>{if(T)P(null,l)}})]}),K("div",{style:{padding:"0 12px 8px"},children:v==="print"?_("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(l)=>p({paper:l.currentTarget.value}),children:[K("option",{value:"",disabled:!0,children:"Paper size…"}),h3.map((l)=>_("option",{value:l.id,children:[l.label," — ",l.width,"×",l.height,l.unit]},l.id))]}):v==="web"?_("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:R??"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)P(h.width,null)},children:[K("option",{value:"",disabled:!0,children:R?`${W5[R].label} — ≤ ${W5[R].width}px`:"Breakpoint…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ≤ ",h.width,"px breakpoint"]},l))]}):_("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:w??"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)P(h.width,h.height)},children:[K("option",{value:"",disabled:!0,children:w?W5[w].label:"Preset size…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ",h.width,"×",h.height]},l))]})}),K("div",{style:{padding:"0 12px 8px"},children:K(_B,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(l)=>f(l==="fixed")})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Kind"})}),K("div",{style:{padding:"0 12px 8px"},children:K(s4,{value:v,ariaLabel:"artboard kind",options:Z30.map(([l,h])=>({value:l,label:h})),onChange:m})}),v!=="print"&&z&&H?K("div",{style:{padding:"0 12px 8px"},children:_("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(l)=>{let h=W5[l.currentTarget.value];if(h)H(z,h.width);l.currentTarget.value=""},children:[K("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(W5).map(([l,h])=>_("option",{value:l,children:[h.label," — ",h.width,"px"]},l))]})}):null,v==="print"?_(Y0,{children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Print"})}),K("div",{style:{padding:"0 12px 8px"},children:K(_B,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(l)=>p({orientation:l})})}),K("div",{style:{padding:"0 12px 8px"},children:K(h6,{value:Number.isFinite(g?.bleedMm)?g.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(l)=>p({bleedMm:l})})})]}):null,K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),_("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let l=M(C),h=/var\(\s*--/.test(C),a=h?C.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):C;return K(t1,{swatch:K(gN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:L("color"),current:C,activeDs:B,swatchBg:l,seedHex:lN(l)||"#000000",onPick:(s)=>d({background:s||null}),label:"artboard background colour"}),displayValue:a,bound:h,ariaLabel:"artboard background",onValue:(s)=>d({background:(s||"").trim()||null})})})(),K(s4,{value:$,ariaLabel:"artboard body layout",options:G30.map(([l,h])=>({value:l,label:h})),onChange:(l)=>d({layout:l||null})}),_("div",{style:{display:"flex",gap:8},children:[K(AB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:D("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(l)=>d({padding:typeof l==="string"?l:l>0?l:null})}),K(AB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:D("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(l)=>d({gap:typeof l==="string"?l:l>0?l:null})})]})]})]})}var HR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,z30=new RegExp(HR.source,"gi");function K30(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(z30)||[])],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=HR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function U30({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:z,onHoverLayer:U,onReorderLayer:B,layersBusyRef:F,cfg:L,onOptimistic:D,onRecordEdit:M,onReplaceMedia:A,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C,onUndoRedo:b,editScope:$,tab:y,onTabChange:v,width:g,resizing:m,photoSel:p,photoRev:f,onPhotoEdit:d,onPhotoRemoveBackground:l,onPhotoRecordEdit:h,onPhotoUndoRedo:a,layersOnly:s=!1,hideLayersTab:c=!1,cpMode:z0,onSetCpMode:e}){let[n,o]=u.useState("inspect"),V0=s?"layers":y??n,f0=(N0)=>{o(N0),v?.(N0)},[G8,X8]=u.useState(()=>new Set),[a0,w0]=u.useState(()=>new Map);u.useEffect(()=>{let N0=Array.isArray(X)?X[0]:X,c0=N0?.id;if(!c0||!Q?.nodes)return;let s0=N0.index,M0=null,n0=[];if(function D8(x8,I9){for(let d9 of x8||[]){let U9=`${d9.id}:${d9.index}`;if(!d9.synthetic&&d9.id===c0&&(s0==null||d9.index===s0))return M0=U9,n0.push(...I9),!0;if(d9.children&&d9.children.length&&D8(d9.children,[...I9,U9]))return!0}return!1}(Q.nodes,[]),!M0)return;if(n0.length)X8((D8)=>{let x8=!1,I9=new Set(D8);for(let d9 of n0)if(I9.delete(d9))x8=!0;return x8?I9:D8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${M0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let d0=(N0)=>{let c0=`${N0.id}:${N0.index}`;return a0.has(c0)?a0.get(c0):!!N0.hidden},[Y8,k8]=u.useState(null),[e0,b0]=u.useState(""),Z8=(N0,c0)=>{if(!H||!N0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:N0.id,attr:"data-dc-element",value:c0})}).then((s0)=>s0.json().catch(()=>({}))).then((s0)=>{if(!s0.ok)return;M?.({op:"attr",canvas:H,id:N0.id,key:"data-dc-element",before:N0.dcElement??null,after:c0})}).catch(()=>{})},p0=B?(N0,c0,s0)=>{if(F?.current)return;if(N0?.synthetic||c0?.synthetic)return;let M0=s0==="before"?`before ${c0.label}`:s0==="after"?`after ${c0.label}`:`into ${c0.label}`;b0(`Moved ${N0.label} ${M0}`),B(N0.id,c0.id,s0,{idIndex:N0.index,refIndex:c0.index})}:void 0,C8=()=>{let N0=[];return function c0(s0,M0,n0){(s0||[]).forEach((D8,x8)=>{if(N0.push({node:D8,depth:M0,parentNode:n0,siblings:s0,pos:x8}),D8.children&&D8.children.length&&!G8.has(`${D8.id}:${D8.index}`))c0(D8.children,M0+1,D8)})}(Q?.nodes,0,null),N0},Q9=(N0)=>{if(N0.key!=="ArrowUp"&&N0.key!=="ArrowDown")return;if(!Z0)return;let c0=C8(),s0=c0.findIndex((x8)=>x8.node.id===Z0.id&&x8.node.index===Z0.index);if(s0<0)return;let M0=N0.key==="ArrowDown"?1:-1,n0=c0[s0];if(!N0.altKey){let x8=c0[s0+M0];if(x8)N0.preventDefault(),z?.(x8.node);return}if(!p0||!Array.isArray(n0.siblings))return;N0.preventDefault();let D8=(x8)=>x8&&x8.children&&x8.children.length&&!G8.has(`${x8.id}:${x8.index}`);if(!N0.shiftKey){if(M0<0&&n0.pos>0)p0(n0.node,n0.siblings[n0.pos-1],"before");else if(M0>0&&n0.pos<n0.siblings.length-1)p0(n0.node,n0.siblings[n0.pos+1],"after");return}if(M0>0){let x8=n0.siblings[n0.pos+1];if(x8)p0(n0.node,x8,D8(x8)?"inside-start":"after");else if(n0.parentNode)p0(n0.node,n0.parentNode,"after")}else{let x8=n0.siblings[n0.pos-1];if(x8)p0(n0.node,x8,D8(x8)?"inside-end":"before");else if(n0.parentNode)p0(n0.node,n0.parentNode,"before")}},Z9=u.useRef(null),T0=u.useRef(null),H9=(N0,c0,s0)=>{if(!p0||N0.button!==0||N0.metaKey||N0.ctrlKey||N0.shiftKey||N0.altKey)return;if(F?.current)return;let{clientX:M0,clientY:n0}=N0,D8=new Set([s0]);(function X9(G9){(G9.children||[]).forEach((J7)=>{D8.add(`${J7.id}:${J7.index}`),X9(J7)})})(c0);let x8=14,I9=6,d9=[];(function X9(G9,J7){(G9||[]).forEach((g9)=>{let i9=`${g9.id}:${g9.index}`;if(d9.push({node:g9,key:i9,id:g9.id,depth:J7,tag:g9.tag}),g9.children&&g9.children.length&&!G8.has(i9))X9(g9.children,J7+1)})})(Q?.nodes,0);let U9=new Map(d9.map((X9)=>[X9.key,X9])),l7=!1,q7=(X9)=>{if(!l7){if(Math.hypot(X9.clientX-M0,X9.clientY-n0)<4)return;l7=!0}let G9=X9.clientX-M0,J7=X9.clientY-n0,g9=null,i9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((O7)=>({rect:O7.getBoundingClientRect(),it:U9.get(O7.getAttribute("data-layer-key"))})).filter((O7)=>O7.it&&O7.it.key!==s0);if(i9.length){let O7=i9[0].rect.left,t=i9[0].rect.right,q0=i9.length;for(let q9=0;q9<i9.length;q9++)if(X9.clientY<i9[q9].rect.top+i9[q9].rect.height/2){q0=q9;break}let G0=i9[q0-1]?.it||null,E0=i9[q0]?.it||null,u0=Math.round((X9.clientX-O7-I9)/x8),O8=G0?G0.depth+(Y30.has(G0.tag)?0:1):0,M8=E0?E0.depth:0,w8=Math.max(M8,Math.min(u0,O8)),$8=null,n8="before",$9=0;if(!G0){if(E0)$8=E0,n8="before",$9=E0.depth}else if(w8>G0.depth)$8=G0,n8="inside-start",$9=G0.depth+1;else if(w8===G0.depth)$8=G0,n8="after",$9=G0.depth;else{for(let q9=q0-1;q9>=0;q9--)if(i9[q9].it.depth===w8){$8=i9[q9].it;break}if(!$8)$8=G0;n8="after",$9=w8}if($8&&$8.key!==s0&&!D8.has($8.key)){let q9=G0?i9[q0-1].rect.bottom:i9[0].rect.top,k6=O7+I9+$9*x8;g9={refId:$8.id,position:n8,node:$8.node,y:q9,left:k6,w:Math.max(24,t-k6)}}}let W7={key:s0,node:c0,dx:G9,dy:J7,target:g9};Z9.current=W7,k8(W7)},wX=()=>{window.removeEventListener("pointermove",q7),window.removeEventListener("pointerup",V9),window.removeEventListener("keydown",c9,!0)},p9=()=>{let X9=(G9)=>{G9.preventDefault(),G9.stopImmediatePropagation(),document.removeEventListener("click",X9,!0)};document.addEventListener("click",X9,!0),setTimeout(()=>document.removeEventListener("click",X9,!0),300)},V9=()=>{wX();let X9=Z9.current;if(Z9.current=null,k8(null),l7&&X9?.target)p9(),p0(X9.node,X9.target.node,X9.target.position)},c9=(X9)=>{if(X9.key!=="Escape")return;if(X9.preventDefault(),X9.stopImmediatePropagation(),wX(),Z9.current=null,k8(null),l7)p9()};window.addEventListener("pointermove",q7),window.addEventListener("pointerup",V9),window.addEventListener("keydown",c9,!0)},$0=(N0)=>X8((c0)=>{let s0=new Set(c0);if(s0.has(N0))s0.delete(N0);else s0.add(N0);return s0}),J8=(N0)=>{let c0=`${N0.id}:${N0.index}`,s0=d0(N0),M0=!s0;if(w0((n0)=>new Map(n0).set(c0,M0)),D?.({id:N0.id,artboardId:Q?.artboardId??null,index:N0.index,prop:"display",value:M0?"none":null}),!H||!N0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0?{canvas:H,id:N0.id,property:"display",value:"none"}:{canvas:H,id:N0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:N0.id,key:"display",before:s0?"none":null,after:M0?"none":null})},Z0=Array.isArray(X)?X[0]:X,I0=p?{asset:p.asset,kind:"annotation-image"}:(()=>{let N0=K30(Z0);return N0?{asset:N0,kind:"artboard-img"}:null})(),F0=I0?.kind==="annotation-image",z8=(N0)=>{if(!(N0.metaKey||N0.ctrlKey)||N0.altKey)return;let c0=N0.key.toLowerCase();if(c0==="z")N0.preventDefault(),a?.(N0.shiftKey?"redo":"undo");else if(c0==="y")N0.preventDefault(),a?.("redo")},I8=F0?"photo":V0==="photo"&&!I0?"inspect":V0,W8=(N0,c0,s0)=>_("button",{type:"button",className:"st-rp-tab"+(I8===N0?" is-active":""),onClick:()=>f0(N0),children:[K(W9,{name:s0,size:14}),c0]}),j0=Z0?.bounds||null;return _("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[_("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[F0?W8("photo","Photo","image"):_(Y0,{children:[W8("inspect","Inspect","sliders"),!c&&W8("layers","Layers","layers"),W8("css","CSS","code"),I0?W8("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(W9,{name:"x",size:14})})]}),Z0?.id&&!(Array.isArray(X)&&X.length>1)&&$?_("div",{className:`st-scope st-scope--${$.scope}`,title:$.scope==="shared"?`Editing this element's style changes ${$.affects} place${$.affects===1?"":"s"}${$.componentName?` (component ${$.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),$.scope==="shared"?`Shared${$.componentName?` · ${$.componentName}`:""} · edits ${$.affects} place${$.affects===1?"":"s"}`:"Local · this element only",$.scope==="shared"&&Z?K("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(Z0.id,Z0.index),children:"Detach"}):null]}):null,K("div",{className:"st-rp-body",children:I8==="photo"&&I0?K("div",{onKeyDown:z8,children:K(sv,{asset:I0.asset,ColorPicker:Le,StIcon:W9,onEdit:(N0)=>d?.(I0.asset,N0),onRemoveBackground:l,onRecordEdit:(N0,c0)=>h?.(I0.asset,N0,c0)},`${I0.asset}:${f??0}`)}):!Z0&&!(I8==="layers"&&Q?.nodes?.length)?K("div",{className:"st-rp-empty",children:_("p",{children:["Press ",K(JX,{children:"V"}),", then click an element to select it — or ",K(JX,{children:"⌘"}),"-click straight from Browse."]})}):Z0&&I8==="inspect"?_(Y0,{children:[K("div",{className:"st-rp-hd",children:Z0.selector||Z0.tag||"element"}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:j0?Math.round(j0.x):"—",readOnly:!0,"aria-label":"x position"})]}),_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:j0?Math.round(j0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:j0?Math.round(j0.w):"—",readOnly:!0,"aria-label":"width"})]}),_("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:j0?Math.round(j0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z0.tag||"—"})})]}),Z0.classes?_("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z0.classes})})]}):null,K(W30,{el:Z0})]}):I8==="layers"?_(Y0,{children:[_("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?_(Y0,{children:[p0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:T0,onKeyDown:Q9,children:Q.nodes.map((N0,c0)=>K(De,{node:N0,depth:0,selectedId:Z0?.id,selectedIndex:Z0?.index,collapsed:G8,hiddenOverride:a0,onToggle:$0,onSelect:(s0)=>{z?.(s0),T0.current?.focus()},onHover:(s0)=>U?.(s0),onToggleVisibility:J8,onReorder:p0,onRowPointerDown:H9,dragState:Y8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:Z8},`${N0.id}:${N0.index}`))}),Y8?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:Y8.target.left,top:Y8.target.y-1,width:Y8.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:e0})]}):Z0&&Array.isArray(Z0.dom_path)&&Z0.dom_path.length?Z0.dom_path.map((N0,c0)=>_("div",{className:"st-layer"+(c0===Z0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+c0*12},children:[K(W9,{name:"square",size:13}),N0]},c0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z0.id&&Oe(Z0)?K(H30,{el:Z0,cfg:L,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C}):K(tq0,{el:Z0,cfg:L,onOptimistic:D,onRecordEdit:M,onReplaceMedia:A,onUndoRedo:b,mode:z0,onSetMode:e})})]})}function V30(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[z,U]=u.useState(null),B=u.useRef(null);u.useEffect(()=>{B.current=z},[z]);let[F,L]=u.useState(null);u.useEffect(()=>{let q=Array.isArray(z)?z.length===1?z[0]:null:z,N=q&&typeof q.id==="string"?q.id:null;if(!N||!Z){L(null);return}let O=new AbortController,E=new URLSearchParams({canvas:Z,id:N});return fetch(`/_api/edit-scope?${E}`,{signal:O.signal}).then((k)=>k.ok?k.json():null).then((k)=>{if(k?.ok)L(k)}).catch(()=>{}),()=>O.abort()},[z,Z]);let D=u.useRef(0),M=u.useRef([]),A=u.useCallback((q)=>{if(!q?.id||!q.file)return;for(let N of M.current)clearTimeout(N);M.current=[50,450,1200,2500,5000].map((N)=>setTimeout(()=>{let O=B.current,E=Array.isArray(O)?O[0]:O;if(!E||E.id!==q.id||E.file!==q.file)return;let k=v8.current.get(q.file);if(!k?.contentWindow)return;try{k.contentWindow.postMessage({dgn:"select-by-id",id:q.id,artboardId:q.artboardId??null,index:q.index??0},"*")}catch{}},N))},[]),I=u.useRef([]),P=u.useCallback((q,N)=>{if(!q||!N)return;for(let O of I.current)clearTimeout(O);I.current=[50,450,1200,2500,5000].map((O)=>setTimeout(()=>{let E=B.current,k=Array.isArray(E)?E[0]:E;if(!k||k.artboardId!==q||k.file!==N)return;let j=v8.current.get(N);if(!j?.contentWindow)return;try{j.contentWindow.postMessage({dgn:"select-by-id",artboardId:q},"*")}catch{}},O))},[]),w=u.useRef(null),R=u.useRef(null),T=u.useRef(null),C=u.useRef(null),b=u.useRef(!1),$=u.useRef(null),[y,v]=u.useState(null),[g,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!y)return;let q=Date.now(),N=p.current;if(N.canvas===Z&&q-N.at<1500)return;p.current={canvas:Z,at:q},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((O)=>O.json()).then((O)=>{if(O?.ok&&O.map&&typeof O.map==="object")m(O.map);else m(null)}).catch(()=>m(null))},[Z,y]);let[f,d]=u.useState(!1),[l,h]=u.useState(null),[a,s]=u.useState(null),[c,z0]=u.useState(null),[e,n]=u.useState(null),[o,V0]=u.useState(!1),[f0,G8]=u.useState(null),[X8,a0]=u.useState(""),[w0,d0]=u.useState(null),[Y8,k8]=u.useState(null),e0=u.useRef(null),b0=pt("maude-sb-w",{min:200,max:420,def:252}),Z8=pt("maude-rp-w",{min:260,max:480,def:304}),[p0,C8]=u.useState(null),Q9=u.useRef(null);u.useEffect(()=>{if(!p0)return;let q=(O)=>{let E=Q9.current?.getBoundingClientRect();if(!E)return;if(p0==="sb")b0.setW(O.clientX-E.left);else Z8.setW(E.right-O.clientX)},N=()=>C8(null);return window.addEventListener("pointermove",q),window.addEventListener("pointerup",N),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",N)}},[p0,b0.setW,Z8.setW]);let Z9=u.useCallback((q)=>{clearTimeout(e0.current),e0.current=setTimeout(()=>{k8((N)=>N===q?null:N)},2500)},[]);u.useEffect(()=>{if(!Y8)return;let q=setTimeout(()=>k8(null),15000);return()=>clearTimeout(q)},[Y8]);let[T0,H9]=u.useState({designRel:".design"}),$0=u.useCallback(()=>{fetch("/_config").then((q)=>q.json()).then((q)=>{let N=(q.designRoot||".design").replace(/^\/+|\/+$/g,"");H9((O)=>({...O,designRel:N,tokensCssRel:q.tokensCssRel,designSystems:q.designSystems,canvasOrigin:q.canvasOrigin}))}).catch(()=>{})},[]);u.useEffect(()=>{$0()},[$0]),u.useEffect(()=>{let q=!1;return fetch("/_sync-status").then((N)=>N.json()).then((N)=>{if(q||!N||N.linked===!1)return;s(N)}).catch(()=>{}),()=>{q=!0}},[]),u.useEffect(()=>{let q=!1;return fetch("/_api/git/status").then((N)=>N.json()).then((N)=>{if(!q&&N)z0(N)}).catch(()=>{}),()=>{q=!0}},[]);let[J8,Z0]=u.useState({}),[I0,F0]=u.useState(null),[z8,I8]=u.useState(!1),[W8,j0]=u.useState("open"),[N0,c0]=u.useState(eV0),[s0,M0]=u.useState(()=>{return eP(bt,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(bt,JSON.stringify(s0))}catch{}},[s0]);let[n0,D8]=u.useState(null),[x8,I9]=u.useState(()=>RZ(jt,!0)),[d9,U9]=u.useState(()=>RZ($t,!1)),[l7,q7]=u.useState(()=>eP(St,{})),[wX,p9]=u.useState(!1),[V9,c9]=u.useState(!1);u.useEffect(()=>{if(!l8())return;let q=kf(()=>c9(!0));return()=>{q.then((N)=>N()).catch(()=>{})}},[]);let[X9,G9]=u.useState(!1),[J7,g9]=u.useState(!1),[i9,W7]=u.useState(!1),[O7,t]=u.useState(!1),{report:q0}=fw(l8()),[G0,E0]=u.useState(!1),[u0,O8]=u.useState(!1),[M8,w8]=u.useState(null),[$8,n8]=u.useState(!1),[$9,q9]=u.useState(!1),[k6,u5]=u.useState(!1),[l5,_J]=u.useState(!1),[r8,d5]=u.useState(()=>eP(xt,tz)),[d6,$7]=u.useState(()=>{try{let q=localStorage.getItem(ht);if(q==="separate"||q==="in-inspector")return q}catch{}return"separate"}),[gX,m9]=u.useState(!1),[o9,mX]=u.useState([]),[QX,n9]=u.useState(0),[G5,_X]=u.useState(!1),[u9,uX]=u.useState(!1),[T6,B7]=u.useState(!1),[YX,S9]=u.useState(1),[r9,Z5]=u.useState(216),[d7,H5]=u.useState(null),[p6,z5]=u.useState([]),[NW,EY]=u.useState([]),[PY,i]=u.useState([]),[Q0,K0]=u.useState(0),L0=u.useMemo(()=>{if(!o9.length)return null;return(o9.find((N)=>N.durationInFrames===Q0)??o9[0]).id},[o9,Q0]),B0=u.useRef(null);u.useEffect(()=>{B0.current=L0},[L0]);let l0=u.useRef(0);u.useEffect(()=>{l0.current=QX},[QX]);let[v0,c8]=u.useState(null),g8=u.useRef(null);u.useEffect(()=>{g8.current=v0},[v0]);let[lX,WX]=u.useState(null),[S7,dX]=u.useState(0),W6=u.useCallback((q,N)=>{if(/concurrent edit|changed since it was read/i.test(N||""))A8("Timeline changed — reloaded, try again."),dX((O)=>O+1);else A8(`${q}: ${N||"failed"}`)},[]),[N6,EQ]=u.useState(!1),[PQ,AJ]=u.useState(!1),[pX,F6]=u.useState(!1),AX=u.useRef(N6);u.useEffect(()=>{if(AX.current=N6,N6){F6(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[N6]);let E8=u.useCallback(()=>{if(!AX.current||document.hidden)F6(!0),mt("Claude finished","Your assistant turn is ready in Maude.")},[]),p7=u.useRef(0),H7=u.useCallback(()=>{if(!AX.current||document.hidden){F6(!0);let q=Date.now();if(q-p7.current<sV0)return;p7.current=q,mt("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[G7,k9]=u.useState("inspect"),[FW,EX]=u.useState(null),EJ=u.useRef({undo:[],redo:[]}),[LW,JK]=u.useState(0),[c6,DW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),RY=u.useRef(c6);u.useEffect(()=>{RY.current=c6;try{localStorage.setItem("maude-auto-open-inspector",c6?"1":"0")}catch{}},[c6]);let IZ=u.useRef(!1);u.useEffect(()=>{IZ.current=k6||z8||o||N6},[k6,z8,o,N6]);let cX=u.useRef({open:{},side:tz});cX.current={open:{tree:x8,layers:l5,inspector:k6,comments:z8,changes:o,assistant:N6},side:r8};let RQ=u.useCallback((q,N)=>{if(q==="tree")I9(N);else if(q==="layers")_J(N);else if(q==="inspector")u5(N);else if(q==="comments")I8(N);else if(q==="changes")V0(N);else if(q==="assistant")EQ(N)},[]),OW=u.useCallback((q)=>cX.current.side?.[q]||tz[q],[]),f7=u.useCallback((q)=>{let N=OW(q);RQ(q,!0);for(let O of WR)if(O.id!==q&&OW(O.id)===N)RQ(O.id,!1)},[RQ,OW]),K5=u.useCallback((q)=>{if(cX.current.open?.[q])RQ(q,!1);else f7(q)},[f7,RQ]),PX=f7,C6=K5,MW=u.useCallback((q)=>{if(!RY.current)return;if(!q||!q.id)return;if(IZ.current)return;PX("inspector"),k9("css")},[PX]),IY=u.useCallback(()=>m9((q)=>!q),[]),PJ=Fx(ZR),kY=Jx(),[QK,YK]=u.useState(!1),[kZ,TZ]=u.useState(!1);u.useEffect(()=>{if(!l8())return;let q=!0;return Sf().then((N)=>{if(!q)return;if(YK(!!N),!N&&!RZ(Ct,!1))TZ(!0)}).catch(()=>{}),()=>{q=!1}},[]);let CZ=u.useCallback(()=>{TZ(!1);try{localStorage.setItem(Ct,"1")}catch{}},[]),[WK,$Z]=u.useState(null);u.useEffect(()=>{if(!l8())return;let q;return ff((N)=>$Z(N&&typeof N==="object"?N:{})).then((N)=>{q=N}).catch(()=>{}),()=>{try{q?.()}catch{}}},[]);let[p5,SZ]=u.useState(null),[wW,GK]=u.useState(()=>!RZ(Tt,!1)),iX=u.useCallback((q)=>{SZ(Array.isArray(q)&&q.length?q:null)},[]),_W={setup:(q)=>{if(!q)return;if((q.canvas||q.requireSelection)&&W.length===0)f7("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(q.inspector||q.tab||q.requireSelection)PX("inspector");if(q.tab)k9(q.tab);if(q.changes)PX("changes")}},IQ=u.useCallback(()=>{GK(!1);try{localStorage.setItem(Tt,"1")}catch{}},[]),[c5,bZ]=u.useState(()=>RZ(vt,!0)),[TY,AW]=u.useState(!1),[c7,jZ]=u.useState(()=>RZ(yt,!1)),[RX,yZ]=u.useState(()=>RZ(ft,!1)),[GX,EW]=u.useState(!1),[ZK,RJ]=u.useState(!1),[PW,CY]=u.useState(0),[RW,HK]=u.useState(null),[zK,fZ]=u.useState(!1),IW=u.useRef(null),$Y=u.useRef(null),v8=u.useRef(new Map),q8=u.useCallback((q)=>{let N=Z?v8.current.get(Z):null;if(!N||!N.contentWindow)return;try{N.contentWindow.postMessage(q,"*")}catch{}},[Z]),oX=u.useCallback((q,N)=>q8({dgn:"photo-preview",asset:q,edit:N}),[q8]),ZX=u.useCallback((q,N,O)=>{EJ.current.undo.push({asset:q,before:N,after:O}),EJ.current.redo.length=0},[]),kQ=u.useCallback((q)=>{let N=q?EJ.current.redo:EJ.current.undo;if(!N.length)return!1;let O=N.pop();(q?EJ.current.undo:EJ.current.redo).push(O);let E=(q?O.after:O.before)||{};return oX(O.asset,E),fetch(`/_api/photo-edit?asset=${encodeURIComponent(O.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)}).catch(()=>{}),JK((k)=>k+1),!0},[oX]),KK=u.useCallback(async(q)=>{q8({dgn:"photo-busy",asset:q,busy:!0});try{let N=await fetch(`/${q.replace(/^\/+/,"")}`);if(!N.ok)return null;let O=await N.blob(),{removeBackground:E}=await Promise.resolve().then(() => (kt(),It)),k=await E(O),j=await fetch("/_api/asset",{method:"POST",headers:{"content-type":k.type||"image/png"},body:k}),S=await j.json().catch(()=>({}));if(j.ok&&S.path)return{maskAsset:S.path};return null}catch(N){return console.error("[photo] background removal failed",N),null}finally{q8({dgn:"photo-busy",asset:q,busy:!1})}},[q8]);u.useEffect(()=>{let q=(E)=>Array.from(E.dataTransfer?.types??[]).includes("Files"),N=(E)=>{if(q(E))E.preventDefault()},O=(E)=>{if(q(E))E.preventDefault()};return document.addEventListener("dragover",N),document.addEventListener("drop",O),()=>{document.removeEventListener("dragover",N),document.removeEventListener("drop",O)}},[]);let G6=u.useRef({});G6.current={open:gX,comps:o9,frame:QX,total:Q0,playing:G5,compId:L0,muted:T6,loop:u9,sequences:p6,post:q8,canvas:Z};let nX=u.useRef({undo:[],redo:[]}),E7=u.useCallback((q,N,O)=>{if(typeof N!=="number")return;if(nX.current.undo.push({canvas:q,seq:N,label:O}),nX.current.redo=[],nX.current.undo.length>50)nX.current.undo.shift()},[]),kW=u.useCallback((q)=>{let N=nX.current,O=q==="undo"?N.undo:N.redo,E=q==="undo"?N.redo:N.undo,k=G6.current.canvas,j=-1;for(let x=O.length-1;x>=0;x--)if(O[x].canvas===k){j=x;break}if(j<0){A8(q==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let S=O[j];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S.canvas,seq:S.seq,dir:q})}).then((x)=>x.json().catch(()=>({}))).then((x)=>{if(O.splice(j,1),x?.ok)E.push(S),A8(`${q==="undo"?"Undid":"Redid"}: ${S.label}`,!0);else A8(`${q==="undo"?"Undo":"Redo"} skipped: ${x?.error||"failed"}`)}).catch(()=>A8(`${q==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=u.useCallback((q,N)=>{let O=q?.ok&&Array.isArray(q.clips)?q.clips.filter((E)=>E.kind==="sequence"):[];if(N==null)return null;if(typeof N==="object")return(N.stableId?O.find((E)=>E.stableId===N.stableId):null)||(Number.isInteger(N.index)?O[N.index]:null)||null;if(typeof N==="string")return O.find((E)=>E.stableId===N)||null;return O[N]||null},[]),SY=u.useCallback((q)=>{let N=G6.current.canvas;if(!N||N===T8)return;let O=g8.current||void 0,E=`/_api/comp-clips?canvas=${encodeURIComponent(N)}${O?`&artboardId=${encodeURIComponent(O)}`:""}`;fetch(E).then((k)=>k.json().catch(()=>({}))).then((k)=>{let j=Z6(k,q);if(!j?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:N,artboardId:O,stableId:j.stableId,contentHash:j.contentHash})})}).then((k)=>k?k.json():null).then((k)=>{if(k&&!k.ok)console.warn("[remove-clip]",k.error||"failed"),W6("Remove refused",k.error);else if(k?.ok){if(A8("Clip removed.",!0),k.seq!=null)E7(N,k.seq,"remove clip");WX(null)}}).catch(()=>A8("Remove failed: network error"))},[Z6,E7]),i5=u.useCallback((q,N,O)=>{let E=G6.current.canvas;if(!E||E===T8)return;let k=g8.current||void 0,j=`/_api/comp-clips?canvas=${encodeURIComponent(E)}${k?`&artboardId=${encodeURIComponent(k)}`:""}`;fetch(j).then((S)=>S.json().catch(()=>({}))).then((S)=>{let x=S?.ok&&Array.isArray(S.clips)?S.clips:[],r=q?.transition?x.find((X0)=>X0.kind==="transition"&&X0.stableId===q.stableId)||null:Z6(S,q);if(!r?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:E,artboardId:k,stableId:r.stableId,contentHash:r.contentHash,verb:N,...O})})}).then((S)=>S?S.json():null).then((S)=>{if(S&&!S.ok)console.warn("[clip-edit]",N,S.error||"failed"),W6(`${N} refused`,S.error);else if(S?.ok){let x={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(A8(`Applied: ${x[N]||N}.`,!0),S.seq!=null)E7(E,S.seq,x[N]||N)}}).catch(()=>A8(`${N} failed: network error`))},[Z6,E7,W6]),[o5,bY]=u.useState(null),n5=u.useCallback((q,N="")=>new Promise((O)=>{bY({title:q,value:N,resolve:O})}),[]),U5=u.useCallback((q)=>{bY((N)=>{return N?.resolve?.(q),null})},[]),vZ=u.useCallback((q,N)=>{let O=G6.current.canvas;if(!O||O===T8||!N||!String(N).trim())return;C0({type:"comments-add",payload:{file:O,text:String(N).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:q}}),A8("Comment added.",!0)},[]);G6.current.selected=lX,G6.current.setSelected=WX,G6.current.removeClip=SY,G6.current.clipVerb=i5,G6.current.addComment=vZ,G6.current.askText=n5,u.useEffect(()=>{let q=(N)=>{let O=G6.current;if(!O.open||!O.comps?.length)return;let E=N.target,k=E?.tagName;if(k==="INPUT"&&E?.type!=="range")return;if(k==="TEXTAREA"||k==="SELECT"||E?.isContentEditable)return;let j=O.comps[0]?.fps||30,S=Math.max(1,O.total),x=(X0)=>{let H0=Math.max(0,Math.min(S-1,Math.round(X0)));n9(H0),_X(!1),O.post({dgn:"timeline-seek",frame:H0,id:O.compId})},r=()=>{let X0=new Set([0,S-1]);for(let H0 of O.sequences||[]){X0.add(H0.from);for(let U0 of H0.keyframes||[])X0.add(U0.from),X0.add(U0.to)}return[...X0].filter((H0)=>H0>=0&&H0<S).sort((H0,U0)=>H0-U0)};if((N.metaKey||N.ctrlKey)&&(N.key==="z"||N.key==="Z")){N.preventDefault(),kW(N.shiftKey?"redo":"undo");return}if(N.key==="Escape"){if(O.selected!=null)N.preventDefault(),O.setSelected?.(null);return}if((N.key==="Delete"||N.key==="Backspace")&&O.selected!=null){N.preventDefault(),O.removeClip?.({stableId:O.selected});return}if((N.metaKey||N.ctrlKey)&&(N.key==="b"||N.key==="B")){N.preventDefault();let X0=O.selected!=null?{stableId:O.selected}:null;if(!X0){let H0=O.sequences||[],U0=H0.find((o0)=>o0.series&&O.frame>=o0.from&&O.frame<o0.from+o0.duration)||H0.find((o0)=>O.frame>=o0.from&&O.frame<o0.from+o0.duration);if(U0?.stableId)X0={stableId:U0.stableId}}if(X0)O.clipVerb?.(X0,"split",{atFrame:O.frame});else A8("Nothing under the playhead to split.");return}if(N.key===" "||N.code==="Space")if(N.preventDefault(),O.playing)_X(!1),O.post({dgn:"timeline-pause",id:O.compId});else _X(!0),O.post({dgn:"timeline-mute",muted:O.muted,id:O.compId}),O.post({dgn:"timeline-loop",loop:O.loop,id:O.compId}),O.post({dgn:"timeline-play",id:O.compId});else if(N.key==="ArrowRight")N.preventDefault(),x(O.frame+(N.shiftKey?j:1));else if(N.key==="ArrowLeft")N.preventDefault(),x(O.frame-(N.shiftKey?j:1));else if(N.key==="Home")N.preventDefault(),x(0);else if(N.key==="End")N.preventDefault(),x(S-1);else if(N.key==="."){N.preventDefault();let X0=r().find((H0)=>H0>O.frame);if(X0!=null)x(X0)}else if(N.key===","){N.preventDefault();let X0=r().reverse().find((H0)=>H0<O.frame);if(X0!=null)x(X0)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),u.useEffect(()=>{mX([]),n9(0),_X(!1),WX(null),c8(null);let q=setTimeout(()=>q8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(q)},[Z,q8]);let[V5,IJ]=u.useState(""),[W0,TW]=u.useState([]),[CW,jY]=u.useState([]);u.useEffect(()=>{if(!gX||o9.length===0||!Z||Z===T8){IJ(""),TW([]);return}let q=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((N)=>N.ok?N.json():null).then((N)=>{if(q&&N?.ok&&typeof N.source==="string")IJ(N.source)}).catch(()=>{}),()=>{q=!1}},[gX,o9,Z,S7]),u.useEffect(()=>{if(!gX||!Z||Z===T8||!V5){TW([]),jY([]);return}let q=!0,N=v0||void 0,O=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${N?`&artboardId=${encodeURIComponent(N)}`:""}`;return fetch(O).then((E)=>E.ok?E.json():null).then((E)=>{if(!q)return;let k=E?.ok&&Array.isArray(E.clips)?E.clips:[];TW(k.filter((j)=>j.kind==="sequence")),jY(k.filter((j)=>j.kind==="transition"))}).catch(()=>{}),()=>{q=!1}},[gX,Z,V5,v0,S7]),u.useEffect(()=>{if(!V5){z5([]),EY([]),i([]),K0(0);return}let q=o9[0]?.durationInFrames||0,N=d7??z?.artboardId??null,O=ov(V5,q,N);c8(O.artboardId??N??null);let E=O.sequences.map((k,j)=>{let S=W0[j];if(!S)return k;return{...k,stableId:S.stableId,contentHash:S.contentHash,mediaProps:S.mediaProps??null,placeholder:S.placeholder??null,mediaTag:S.mediaTag??k.mediaTag,mediaSrc:S.mediaSrc??k.mediaSrc,replaceable:!!(S.mediaCdId||S.mediaArrayRef),layers:Array.isArray(S.layers)?S.layers:[],hidden:!!S.hidden}});z5(E),EY(O.audio||[]),i(O.transitions||[]),K0(O.total)},[V5,W0,z,o9,d7]);let kJ=u.useCallback(()=>{bZ((q)=>{let N=!q,O=Z?v8.current.get(Z):null;if(O&&O.contentWindow)try{O.contentWindow.postMessage({dgn:"view-annotations",visible:N},"*")}catch{}return N})},[Z]),T9=u.useCallback((q)=>{for(let N of v8.current.values())try{N.contentWindow.postMessage({dgn:"view-chrome",...q},"*")}catch{}},[]),TJ=u.useCallback(()=>{jZ((q)=>{let N=!q;return T9({minimap:N}),N})},[T9]),r5=u.useCallback(()=>{yZ((q)=>{let N=!q;return T9({zoom:N}),N})},[T9]),$W=u.useCallback(()=>{EW((q)=>{let N=!q;return T9({present:N}),N})},[T9]),TQ=u.useCallback(()=>{EW(!1),T9({present:!1})},[T9]),SW=u.useCallback(()=>{if(!Z||Z===T8)return;RJ((q)=>{let N=!q;return q8({dgn:"view-chrome",print:N}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:N}}})}).catch(()=>{}),N})},[Z,q8]);u.useEffect(()=>{let q=!1;return fetch("/_api/git-user").then((N)=>N.json()).then((N)=>{if(q)return;let O=N&&typeof N.name==="string"?N.name.trim():"";if(O)HK(O)}).catch(()=>{}),()=>{q=!0}},[]),u.useEffect(()=>{if(!Z||Z===T8){CY(0),RJ(!1);return}let q=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((N)=>N.json()).then((N)=>{if(q)return;let O=Array.isArray(N?.artboards)?N.artboards.length:0;CY(O),RJ(N?.overlays?.print===!0),CQ(new Set(Array.isArray(N?.locked)?N.locked:[]))}).catch(()=>{if(!q)CY(0),RJ(!1),CQ(new Set)}),()=>{q=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===T8||!d7)return;let q=setTimeout(()=>{q8({dgn:"request-layers",artboardId:d7})},250);return()=>clearTimeout(q)},[Z,d7,q8]);let[q5,CQ]=u.useState(()=>new Set),bW=u.useCallback((q)=>{if(!Z||Z===T8)return;CQ((N)=>{let O=new Set(N);if(O.has(q))O.delete(q);else O.add(q);let E=[...O];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:E}})}).catch(()=>{}),q8({dgn:"locked-set",locked:E}),O})},[Z,q8]);u.useEffect(()=>{if(!Z||Z===T8)return;q8({dgn:"locked-set",locked:[...q5]})},[q5,Z,q8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",N0),localStorage.setItem(Ke,N0)}catch{}for(let q of v8.current.values())try{q.contentWindow.postMessage({dgn:"theme",theme:N0},"*")}catch{}},[N0]),u.useEffect(()=>{try{localStorage.setItem(jt,x8?"1":"0")}catch{}},[x8]),u.useEffect(()=>{try{localStorage.setItem($t,d9?"1":"0")}catch{}},[d9]),u.useEffect(()=>{try{localStorage.setItem(St,JSON.stringify(l7))}catch{}},[l7]),u.useEffect(()=>{try{localStorage.setItem(yt,c7?"1":"0")}catch{}},[c7]),u.useEffect(()=>{try{localStorage.setItem(ft,RX?"1":"0")}catch{}},[RX]),u.useEffect(()=>{try{localStorage.setItem(vt,c5?"1":"0")}catch{}},[c5]),u.useEffect(()=>{let q=!1;return fetch("/_api/ui-prefs").then((N)=>N.ok?N.json():Promise.reject(Error(`HTTP ${N.status}`))).then((N)=>{if(q||!N||typeof N!=="object")return;if(N.theme==="light"||N.theme==="dark")c0(N.theme);if(typeof N.minimap==="boolean")jZ(N.minimap);if(typeof N.zoom==="boolean")yZ(N.zoom);if(typeof N.annotations==="boolean")bZ(N.annotations);if(typeof N.autoOpenInspector==="boolean")DW(N.autoOpenInspector);if(N.panelSides&&typeof N.panelSides==="object")d5({...tz,...N.panelSides});if(N.layersMode==="separate"||N.layersMode==="in-inspector")$7(N.layersMode)}).catch(()=>{}).finally(()=>{if(!q)AW(!0)}),()=>{q=!0}},[]),u.useEffect(()=>{if(!TY)return;tV0({theme:N0,minimap:c7,zoom:RX,annotations:c5,autoOpenInspector:c6,panelSides:r8,layersMode:d6})},[TY,N0,c7,RX,c5,c6,r8,d6]),u.useEffect(()=>{try{localStorage.setItem(xt,JSON.stringify(r8))}catch{}},[r8]),u.useEffect(()=>{try{localStorage.setItem(ht,d6)}catch{}},[d6]);let g0=u.useCallback((q,N)=>{q7((O)=>{let E=O[q],k=E===void 0?N:E;return{...O,[q]:!k}})},[]),HX=u.useCallback(()=>{c0((q)=>q==="dark"?"light":"dark")},[]),a9=u.useCallback(async()=>{try{let N=await(await fetch("/_index-data")).json();Y(N.project||"Design");let O=N.groups.map((E)=>({...E,tree:Wq0(E.paths,E.stripPrefix,E.dirs)}));J(O),H9((E)=>({...E,canvasDesignSystems:N.canvasDesignSystems??{},canvasKinds:N.canvasKinds??{}}))}catch(q){console.error("failed to load tree",q)}},[]);u.useEffect(()=>{a9()},[a9]);let y0=u.useCallback(async(q)=>{try{let N=q?`/_system-data?ds=${encodeURIComponent(q)}`:"/_system-data",O=await fetch(N);if(!O.ok){console.error("failed to load system-data",O.status);return}let E=await O.json();if(!q&&E?.defaultDesignSystem&&!E.ds){d0(E);let k=await fetch(`/_system-data?ds=${encodeURIComponent(E.defaultDesignSystem)}`);if(k.ok)d0(await k.json());return}d0(E)}catch(N){console.error("failed to load system-data",N)}},[]),a5=u.useCallback(async()=>{try{let N=await(await fetch("/_comments-all")).json();Z0(N||{})}catch(q){console.error("failed to load comments",q)}},[]);u.useEffect(()=>{a5()},[a5]),u.useEffect(()=>{function q(){let N=location.protocol==="https:"?"wss:":"ws:",O=new WebSocket(N+"//"+location.host+"/_ws");$Y.current=O,O.addEventListener("open",()=>d(!0)),O.addEventListener("close",()=>{d(!1),setTimeout(q,1000)}),O.addEventListener("error",()=>{}),O.addEventListener("message",(E)=>{try{let k=JSON.parse(E.data);if(k.type==="snapshot"&&k.state)U((j)=>Ge(k.state.selected,j));else if(k.type==="selected"){if(Date.now()-D.current<2000)return;let j=k.selected,S=Array.isArray(j)?j[0]:j,x=B.current,r=Array.isArray(x)?x[0]:x;if(U((X0)=>Ge(j,X0)),S?.id&&S.file&&(!r||r.id!==S.id||r.file!==S.file))A(S)}else if(k.type==="comments"&&typeof k.file==="string")Z0((j)=>({...j,[k.file]:k.comments||[]}));else if(k.type==="ai-activity"&&typeof k.file==="string"){if(fZ(!0),IW.current)clearTimeout(IW.current);IW.current=setTimeout(()=>fZ(!1),8000);for(let j of v8.current.values())try{j.contentWindow.postMessage({dgn:"ai-activity",file:k.file,entry:k.entry},"*")}catch{}}else if(k.type==="export:job"&&k.payload)kY.upsert(k.payload);else if(k.type==="sync:status"&&k.payload)s(k.payload);else if(k.type==="canvas-list-update"){if(a9(),k.payload?.action==="moved"&&k.payload.fromRel&&k.payload.rel){let j=(T0?.designRel||T0?.designRoot||".design").replace(/^\/+|\/+$/g,""),S=`${j}/${k.payload.fromRel}`,x=`${j}/${k.payload.rel}`;G((r)=>r.map((X0)=>X0.path===S?{path:x}:X0)),H((r)=>r===S?x:r)}}else if(k.type==="config-updated")$0();else if(k.type==="acp-focus"){if(l8())PX("assistant")}else if(k.type==="git-status"&&k.payload)z0(k.payload);else if(k.type==="git-lifecycle"&&k.payload){h(k.payload);for(let j of v8.current.values())try{j.contentWindow.postMessage({dgn:"git-lifecycle",payload:k.payload},"*")}catch{}}}catch{}})}return q(),()=>$Y.current&&$Y.current.close()},[a9,$0]);function C0(q){let N=$Y.current;try{if(N&&N.readyState===1)N.send(JSON.stringify(q))}catch{}}let i6=u.useCallback(async()=>{try{let q=await fetch("/_api/git/status");if(q.ok)z0(await q.json())}catch{}},[]),zX=u.useCallback(async()=>{try{let q=await fetch("/_api/git/status?remote=1");if(!q.ok)return;let N=await q.json();if(N&&N.repo!==!1)n({remoteAhead:!!N.remoteAhead,behind:N.behind||0})}catch{}},[]),o6=u.useCallback(async(q,N)=>{try{let O=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N||{})}),E=await O.json().catch(()=>({}));return{ok:O.ok,...E}}catch(O){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jW=u.useCallback(async(q,N)=>{let O=await o6("/_api/git/commit",{message:q,files:N});if(O.ok)await i6();return O},[o6,i6]),yY=u.useCallback(async(q)=>{let N=await o6("/_api/git/discard",{files:q});if(N.ok)await i6();return N},[o6,i6]),yW=u.useCallback(async()=>{let q=await o6("/_api/git/push",{});if(q.ok)await i6(),zX();return q},[o6,i6,zX]),s5=u.useCallback(async()=>{let q=await o6("/_api/git/pull",{});if(q.ok)await i6(),zX();if(q.conflict&&Array.isArray(q.files)&&q.files.length)G8({file:q.files[0],conflict:!0});return q},[o6,i6,zX]),fW=u.useCallback(async(q)=>{let N=await o6("/_api/git/resolve",{choice:q});if(N.ok)await i6(),zX();return N},[o6,i6,zX]),fY=u.useCallback(async(q)=>{try{let N="/_api/git/log?limit=40"+(q?`&path=${encodeURIComponent(q)}`:""),O=await fetch(N);if(!O.ok)return[];return(await O.json()).entries||[]}catch{return[]}},[]),vW=u.useMemo(()=>{let q={modified:"M",added:"A",deleted:"D",untracked:"U"},N=new Map;for(let O of c?.files||[])N.set(O.path,q[O.status]);return N},[c]),vY=c?.files?.length||0;u.useEffect(()=>{if(c?.repo===!1)return;zX();let q=setInterval(zX,o?60000:120000);return()=>clearInterval(q)},[c?.repo,o,zX]);let L6=u.useCallback((q)=>{if(G((N)=>{for(let O of N)if(O.path!==q)v8.current.delete(O.path);return[{path:q}]}),H(q),F0(null),q!==T8)k8(q)},[]),CJ=u.useCallback((q)=>{let N=typeof q==="string"?q:void 0;if(N)y0(N);else if(!w0)y0();L6(T8)},[w0,y0,L6]);u.useEffect(()=>{C0({type:"tabs",tabs:W.map((q)=>q.path).filter((q)=>q!==T8)})},[W]),u.useEffect(()=>{if(Z&&Z!==T8)C0({type:"active",file:Z});else if(Z===T8)C0({type:"active",file:""});else C0({type:"active",file:""})},[Z]);let $Q=u.useCallback((q)=>{G((N)=>{let O=N.findIndex((k)=>k.path===q);if(O<0)return N;let E=N.filter((k)=>k.path!==q);if(q===Z)if(E.length===0)H(null);else H(E[Math.max(0,O-1)].path);return E}),v8.current.delete(q),k8((N)=>N===q?null:N)},[Z]),rX=u.useCallback(()=>{if(!Z||Z===T8){if(Z===T8)y0();return}let q=v8.current.get(Z);if(q)q.src=q.src},[Z,y0]),xY=u.useCallback(()=>a9(),[a9]),[xW,hY]=u.useState(!1),SQ=u.useRef(!1),bQ=u.useCallback(async()=>{if(SQ.current)return;SQ.current=!0,hY(!0);try{await Promise.all([a9(),new Promise((q)=>setTimeout(q,550))])}finally{SQ.current=!1,hY(!1)}},[a9]);u.useEffect(()=>{let q=null,N=()=>{if(q)clearTimeout(q);q=setTimeout(()=>{q=null,xY()},150)};return window.addEventListener("focus",N),()=>{if(window.removeEventListener("focus",N),q)clearTimeout(q)}},[xY]);let hW=u.useCallback(async(q)=>{try{let N=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q,kind:"brief-board"})}),O=await N.json().catch(()=>({}));if(!N.ok||!O.ok)return{ok:!1,error:O.error||`create failed (${N.status})`};return await a9(),L6(O.file),{ok:!0,file:O.file}}catch(N){return{ok:!1,error:N instanceof Error?N.message:"network error"}}},[a9,L6]),gY=u.useCallback(async()=>{let q=await n5("New video name");if(!q)return;let O=(await n5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),E=O?Number(O[1]):1920,k=O?Number(O[2]):1080,j=Math.max(1,Math.min(60,Number(await n5("Frames per second","30"))||30));try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q,kind:"video-comp",clips:[],fps:j,width:E,height:k})}),x=await S.json().catch(()=>({}));if(!S.ok||!x.ok){A8(`New video failed: ${x.error||`error ${S.status}`}`);return}await a9(),L6(x.file),m9(!0),A8("New video created — drop clips on the timeline to start the cut.",!0)}catch(S){A8(`New video failed: ${S instanceof Error?S.message:"network error"}`)}},[a9,L6,n5]),gW=u.useCallback(async()=>{if(!Z||Z===T8)return;try{let q=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),N=q.ok?await q.text():"",O=[];if(N){let x=new DOMParser().parseFromString(N,"image/svg+xml");for(let r of x.querySelectorAll('[data-tool="mediaref"]')){let X0=r.getAttribute("data-src");if(!X0)continue;O.push({src:X0,mediaKind:r.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(O.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let k=`${BW(dN(Z)).replace(/\.tsx$/i,"")} Video`,j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:k,kind:"video-comp",clips:O})}),S=await j.json().catch(()=>({}));if(!j.ok||!S.ok){window.alert(`Assemble failed: ${S.error||`error ${j.status}`}`);return}await a9(),L6(S.file)}catch(q){window.alert(`Assemble failed: ${q instanceof Error?q.message:"network error"}`)}},[Z,a9,L6]),jQ=u.useCallback(({accept:q,resolveTarget:N})=>{let O=Z,E=v0||void 0,k=document.createElement("input");k.type="file",k.accept=q,k.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(k);let j=()=>{if(k.isConnected)k.remove()};window.addEventListener("focus",()=>setTimeout(j,300),{once:!0}),k.addEventListener("change",()=>{let S=k.files?.[0];if(j(),!S)return;let x=`/_api/comp-clips?canvas=${encodeURIComponent(O)}${E?`&artboardId=${encodeURIComponent(E)}`:""}`;fetch(x).then((r)=>r.json().catch(()=>({}))).then((r)=>{let X0=N(r);if(!X0)return A8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":S.type||"application/octet-stream"},body:S}).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{if(!H0?.path)return A8(`Upload failed: ${H0?.error||"unknown error"}`),null;if(X0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:O,arrayName:X0.arrayRef.arrayName,index:X0.arrayRef.index,field:X0.arrayRef.field,value:H0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:O,id:X0.cdId,attr:"src",value:H0.path})})})}).then((r)=>r?r.json():null).then((r)=>{if(r&&!r.ok)A8(`Replace refused: ${r.error||"failed"}`);else if(r&&r.ok){if(A8("Media replaced.",!0),r.seq!=null)E7(O,r.seq,"replace media")}}).catch(()=>A8("Replace failed: network error"))}),k.click()},[Z,v0,E7]),mW=u.useCallback(async(q,N)=>{if(!window.confirm(`Move “${N}” to trash?
5654
5654
 
5655
5655
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let E=await fetch(`/_api/canvas?file=${encodeURIComponent(q)}`,{method:"DELETE"}),k=await E.json().catch(()=>({}));if(!E.ok||!k.ok){window.alert(`Could not delete: ${k.error||`error ${E.status}`}`);return}if(await a9(),Z===q)G([]),H(null)}catch(E){window.alert(`Delete failed: ${E instanceof Error?E.message:"network error"}`)}},[a9,Z]),uW=u.useCallback(async function q(N,O){try{let E=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:N,toDir:O})}),k=await E.json().catch(()=>({}));if(!E.ok||!k.ok)return A8(`Could not move: ${k.error||`error ${E.status}`}`),{ok:!1,error:k.error};let j=(T0?.designRel||T0?.designRoot||".design").replace(/^\/+|\/+$/g,""),S=`${j}/${k.fromRel}`,x=`${j}/${k.toRel}`;await a9(),G((X0)=>X0.map((H0)=>H0.path===S?{path:x}:H0)),H((X0)=>X0===S?x:X0);let r=S.split("/").slice(0,-1).join("/");return A8(`Moved to ${k.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{q(x,r)}}),{ok:!0}}catch(E){return A8(`Move failed: ${E instanceof Error?E.message:"network error"}`),{ok:!1,error:"network error"}}},[a9,T0]),lW=u.useCallback(async(q,N)=>{try{let O=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:q,name:N})}),E=await O.json().catch(()=>({}));if(!O.ok||!E.ok){let k=E.error||`error ${O.status}`;return A8(`Could not create folder: ${k}`),{ok:!1,error:k}}return await a9(),{ok:!0,dir:E.dir}}catch(O){let E=O instanceof Error?O.message:"network error";return A8(`Create folder failed: ${E}`),{ok:!1,error:E}}},[a9]),dW=u.useCallback(async(q,N)=>{if(!window.confirm(`Delete folder "${N}"?
5656
5656