@1agh/maude 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5650,7 +5650,7 @@ ${B.block}`:q,F=[],D=new Map;for await(let _ of X.prompt(N,J(),K,Q?.(),Y?.(),Z?.
5650
5650
 
5651
5651
  > Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
5652
5652
  > Local report bundle: \`${a?.dir??".design/_reports/"}\` (attach its files here)`),o=`${tz0}?title=${c}&body=${U0}&labels=report`;if(W9())try{await nU(o)}catch{window.open(o,"_blank","noopener")}else window.open(o,"_blank","noopener");I({fallbackDir:a?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let m=G.trim().length>0;return z("div",{className:"st-scrim",onClick:h,"data-testid":"report-bug-dialog",children:O("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:h,"aria-label":"Close",children:"×"})]}),O("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&O(G0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(p)=>Z(p.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:h,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!m,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&O(G0,{children:[O("div",{className:"rb-section",children:[O("div",{className:"rb-section-hd",children:[O("span",{children:["Screenshots (",U.length,")"]}),O("span",{className:"rb-hd-actions",children:[U.length<Bw&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:f,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>M((p)=>!p),children:w?"Done redacting":"Redact…"})]})]}),O("p",{className:"rb-hint",children:["Maude captures its own window and the active artboard for you. The window shot is a fresh render, so anything mid-flight — an open menu, a stuck spinner — won't be in it: grab that yourself (",ez0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),_&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!_?O("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",Bw,"."]}):O(G0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((p,v)=>z(QK0,{shot:p,redacting:w,onRects:(r)=>q((a)=>a.map((c,U0)=>U0===v?{...c,rects:r}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),q((r)=>r.filter((a,c)=>c!==v))}},p.url))})]})]}),O("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),O("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",W9()?"desktop app":"browser"]})]}),Q&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>D({...F,activeCanvas:p.target.checked})}),O("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>D({...F,projectName:p.target.checked})}),O("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?O("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>D({...F,logTail:p.target.checked})}),O("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
5653
- `).length," lines, paths & secrets scrubbed) —"," ",O("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),O("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),O("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:n,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&O(G0,{children:[P?.issueUrl?O("p",{children:["Thank you — your report is filed as"," ",O("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())nU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):O("p",{children:["The bundle is saved locally",P?.fallbackDir?O(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Done"})})]}),Y==="fallback"&&O(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var GJ=x8(r8(),1);function fh(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 xh(X,J){let Q=fh(X),Y=fh(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 hh(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||xh(Q.version,J)))}function gh(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&xh(Y.version,Q))Q=Y.version}return Q}var Nw="mdcc-whatsnew-seen",Fw="mdcc-whatsnew-toast-dismissed";function YK0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function WK0(X){try{let J=localStorage.getItem(Nw);if(J)return J;localStorage.setItem(Nw,X)}catch{}return X}function GK0(){try{return localStorage.getItem(Fw)}catch{return null}}function mh(X){let[J,Q]=GJ.useState([]),[Y,W]=GJ.useState(X),[G,Z]=GJ.useState(()=>WK0(X)),[H,K]=GJ.useState(()=>GK0()),[U,q]=GJ.useState(!1);GJ.useEffect(()=>{let M=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(M)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{M=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=hh(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=GJ.useCallback(()=>{let M=gh(J,Y);Z(M),K(Y);try{localStorage.setItem(Nw,M),localStorage.setItem(Fw,Y)}catch{}},[J,Y]),_=GJ.useCallback(()=>{K(Y);try{localStorage.setItem(Fw,Y)}catch{}},[Y]),R=GJ.useCallback(()=>q(!0),[]),w=GJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function uh({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return O("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),O("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),O("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function lh({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(GJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:O("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>O("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[O("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),YK0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ee="mdcc-usage-tour-seen",X00="mdcc-collab-tour-seen",c8="__system__",j00="mdcc-theme",J00="mdcc-show-hidden",Q00="mdcc-sections-expanded",Y00="maude-cp-mode",W00="mdcc-sidebar-open",G00="mdcc-minimap-visible",Z00="mdcc-zoomctl-visible",H00="mdcc-annotations-visible";var N20=30000;function F20(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],$K={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},z00="mdcc-panel-sides",K00="mdcc-layers-mode";function U00({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return O("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(GT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,L20=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function ZT(X){for(let[J,Q]of L20)if(J.test(X))return Q;return null}function PF(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HT="1.0.8";function V00(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){y7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function D20(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(j00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function XH(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 JT(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function O20(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function JH(X){return X.split("/").pop()}function l8(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(l8._t),l8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var q00="maude-mode-hint-seen";function M20(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(q00)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select &amp; inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(q00,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function _20(X){return X.replace(GQ,"")}function A20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=_20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function w20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function v00(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=v00(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 wF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function E20(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 f00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function RF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var P20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":O(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:O(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:O(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:O(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:O(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:O(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:O(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:O(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:O(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:O(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:O(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":O(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":O(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":O(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":O(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":O(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":O(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:O(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:O(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:O(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:O(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:O(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:O(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:O(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function R20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:O("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[O("div",{className:"st-pal-search",children:[z(E9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return O(G0,{children:[N,O("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(E9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function E9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:P20[X]})}function T20(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 B00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function N00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function F00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:O("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var QT=[{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}],L00={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},I20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],j3=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],k20="2x",D00=[{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}],C20="auto",$20={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 S20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return $20[J]||"application/octet-stream"}function b20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((v)=>{let r={...v};for(let a of p)r[a.path]=a.kind;return r})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let M=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||M,I=!W?"No artboard on this canvas":M?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((r)=>$(r).then((a)=>({...a,file:r}))));U(!1);let p=m.filter((r)=>r.ok),v=m.length-p.length;if(v>0)B(`${v} of ${m.length} uploads failed`);if(p.length)_((r)=>{let a={...r};for(let c of p)a[c.path]=y(c.file.type);return a}),F((r)=>{let a=new Set(r);for(let c of p)a.add(c.path);return a})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await nf()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:S20(v.name)}));if(U(!1),p.length)await f(p);return}let x=await OZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(W9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)f(p);else C(p[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:O("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[O("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let m=Y&&N.has(x.path);return O("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(E9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&O("div",{className:"st-dialog-ft st-ap-confirm",children:[O("span",{className:"st-ap-count",children:[N.size," selected"]}),O("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function TF(X,J){let Q=URL.createObjectURL(J),Y=document.createElement("a");Y.href=Q,Y.download=X||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function y20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let q=u.useCallback((P0)=>H==="none"&&!P0.handoff&&P0.format!=="zip"&&!wS.has(P0.format)||H!=="local"&&P0.format==="canva",[H]),[B,N]=u.useState(X==="handoff"?"shadcn":"png"),[F,D]=u.useState(()=>J&&FS("png",J)?J:yO("png")),[_,R]=u.useState(2),[w,M]=u.useState(k20),[P,I]=u.useState(!0),[k,$]=u.useState(!1),[C,y]=u.useState(!1),[f,h]=u.useState(!1),[d,n]=u.useState(C20),[x,m]=u.useState(!0),[p,v]=u.useState(!1),[r,a]=u.useState(null),[c,U0]=u.useState([]),o=QT.find((P0)=>P0.id===B)||QT[0],Z0=o.handoff?[]:jO(o.format),e=900,N0=3600,K0=GK(W,lA(W,{artboardId:G})),u0=K0?.durationInFrames||0,Q8=K0?.fps||30,o0=o.temporal&&u0>900,_8=o.temporal&&u0>3600;u.useEffect(()=>{if(Z0.length&&!Z0.includes(F))D(yO(o.format))},[Z0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let A0=u.useCallback(()=>{fetch("/_api/export-history").then((P0)=>P0.json()).then((P0)=>U0(Array.isArray(P0?.history)?P0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{A0()},[A0]),u.useEffect(()=>{function P0(K8){if(K8.key==="Escape")K8.preventDefault(),U()}return window.addEventListener("keydown",P0),()=>window.removeEventListener("keydown",P0)},[U]);async function r0(){if(o.handoff){let D8=`/design:handoff ${Q&&Q!==c8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(D8)}catch{}a({ok:!0,msg:`Copied: ${D8} — run it in Claude Code.`});return}if(q(o)){a({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}v(!0),a(null);let P0=o.temporal?{scale:_}:{};if(o.format==="png"){let F8=j3.find((D8)=>D8.id===w)||j3[1];if(F8.kind==="dpi")P0.dpi=F8.value;else P0.scale=F8.value}if(o.format==="mp4"||o.format==="webm")P0.audio=x;if(_8)P0.maxFrames=u0;if(o.format==="pdf"){P0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let F8=D00.find((D8)=>D8.id===d)?.value;if(F8!==void 0)P0.dpi=F8}if(G)P0.artboardId=G;if(Z?.selector)P0.selection=Z;if(Q&&Q!==c8)P0.canvasFile=Q;if(zU.has(o.format)&&O2({exportLane:H,format:o.format,scope:F,artboardId:P0.artboardId})&&typeof K==="function")try{let F8=mO(P0);a({ok:!0,msg:"Capturing…"});let D8=await K({format:o.format,artboardIds:[P0.artboardId],scale:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`})}),W8=await gO(D8,o.format);for(let A8 of W8)TF(A8.name,A8.blob);for(let A8 of W8)await uO({format:o.format,scope:F,filename:A8.name});v(!1),a({ok:!0,msg:`Saved ${W8.map((A8)=>A8.name).join(", ")} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Capture failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(O2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{a({ok:!0,msg:"Capturing artboards…"});let F8=Q&&Q!==c8?JH(Q).replace(/\.[^.]+$/,""):"export",{filename:D8,blob:W8}=await hO({capture:K,name:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`}),onAssemble:()=>a({ok:!0,msg:"Assembling deck…"})});TF(D8,W8),await uO({format:o.format,scope:F,filename:D8}),v(!1),a({ok:!0,msg:`Saved ${D8} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Deck export failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(H==="none"&&zU.has(o.format)){a({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),v(!1);return}try{let F8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:P0})});if(!F8.ok){a({ok:!1,msg:await F8.text()||`Export failed (${F8.status})`}),v(!1);return}U()}catch(F8){a({ok:!1,msg:F8&&F8.message?F8.message:String(F8)}),v(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(P0)=>{if(P0.target===P0.currentTarget)U()},children:O("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==c8?`Format · ${pW(JH(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:QT.filter((P0)=>!P0.temporal||Y).map((P0)=>O("button",{type:"button","data-testid":`export-format-${P0.id}`,className:"st-fmt"+(P0.id===B?" is-on":""),disabled:q(P0),title:q(P0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(P0.id),a(null)},children:[z(E9,{name:P0.icon,size:16}),z("span",{className:"st-fmt-name",children:P0.label}),z("span",{className:"st-fmt-sub",children:P0.sub})]},P0.id))}),H==="none"&&O("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(P0)=>D(P0.target.value),children:Z0.map((P0)=>z("option",{value:P0,children:L00[P0]},P0))})]}),!o.handoff&&o.format==="png"&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(P0)=>M(P0.target.value),children:j3.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let P0=j3.find((F8)=>F8.id===w)||j3[1],K8=P0.kind==="dpi"?P0.value/96:P0.value;return`${P0.label} ≈ ${Math.round(1440*K8)}×${Math.round(900*K8)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:_,onChange:(P0)=>R(Number(P0.target.value)),children:I20.map((P0)=>z("option",{value:P0.value,children:P0.label},P0.value))})]}),!o.handoff&&o.temporal&&O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[_,"× the artboard's native resolution (e.g. 960×540 → ",960*_,"×",540*_,")."]}),o0&&O("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",u0," frames (≈",Math.round(u0/Q8),"s).",_8?` 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."]}),!o.handoff&&o.format==="pdf"&&O(G0,{children:[O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(P0)=>n(P0.target.value),children:D00.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:P,onChange:(P0)=>I(P0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:O("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((P0)=>!P0),"aria-expanded":k,children:[k?"▾":"▸"," Marks"]})}),k&&O("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(P0)=>y(P0.target.checked)}),"Crop marks"]}),O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(P0)=>h(P0.target.checked)}),"Registration marks"]})]}),O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:x,onChange:(P0)=>m(P0.target.checked)}),"Export with audio"]})}),o.handoff&&O("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),r&&z("div",{className:"callout "+(r.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":r.ok?"1":"0",children:r.msg}),c.length>0&&O("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),c.map((P0,K8)=>O("div",{className:"st-export-recent-row",children:[O("span",{children:[String(P0.format||"").toUpperCase()," ·"," ",L00[P0.scope]||P0.scope]}),z("span",{className:"st-mono",children:P0.filename})]},K8))]})]}),O("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:p,onClick:r0,children:[z(E9,{name:"download",size:14}),o.handoff?"Copy handoff command":p?"Exporting…":`Export ${o.label}`]})]})]})})}var CF=12,$F=16;function j20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=O("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:CF+J*$F+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return O(G0,{children:[Z?O("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):D,H&&Y]})}function v20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return O(G0,{children:[O("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:CF+Q*$F+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),O("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function IF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?ZT(X.name):null,w=!_&&!R,M=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",f=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=O("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:CF+H*$F+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:M}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return O("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${M}…`,"aria-label":`Actions for ${M}`,"aria-haspopup":"menu",onClick:(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${M}`,"aria-label":`Delete canvas ${M}`,onClick:(n)=>{n.stopPropagation(),G(X.path,M)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function f20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[M,P]=u.useState(!1),I=B||M,k=X.path===W;if(!(w&&q))return z(IF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},f=D?.draggedPath===X.path,h=D?.busyPath===X.path,d=C&&typeof _<"u",n=X.path.split("/").slice(0,-1).join("/"),x=O("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(f?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:CF+Q*$F+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(E9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return O(G0,{children:[d?O("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):x,I&&J.map((m)=>z(IF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function x00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:M}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>A20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],n=[];for(let x of $){let m=ZT(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:n).push(x)}return{mediaOrphans:d,metaOrphans:n}},[$]),f=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let n of q)d.set(n.folder,n);return d},[q,Z]);return O(G0,{children:[k.map((d)=>{let n=f&&d.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(f20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:wF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:n,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:M},d.primary.path)}),C.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let n=h?.get(d),x=R?`${R}/${d}`:d,m=z(x00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:M});if(n&&N)return z(v20,{name:d,dsName:n.name,depth:Z,defaultOpen:!0,active:J===c8&&n.name===B,onOpenSystem:N,children:m},d);return z(j20,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:M,children:m},d)})]})}var _F={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function x20(X){if(X.kind==="project")return _F.project;if(X.kind==="runtime")return _F.runtime;if(X.label==="Design system")return _F.ds;if(X.label==="UI kit")return _F.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function h20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:M,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:f,gitBranch:h,remoteSync:d,onGetLatest:n,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:v,syncStatus:r,onLinkedHub:a,savingIsManaged:c=!1}){let U0=u.useMemo(()=>{if(!q)return Q;return Q.map((i0)=>({...i0,tree:v00(i0.tree,q),filtered:!!q}))},[Q,q]),o=TS(m),Z0=PS(),e=u.useMemo(()=>{let i0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;i0.push({path:j0.fullPath,label:I0});for(let T8 of j0.dirs||[])i0.push({path:T8,label:T8.replace(/^\.[^/]+\//,"")})}return i0},[Q]),N0=Z0.state?.extra,K0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>Z0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{Z0.close();let i0=window.prompt("New folder name:");if(i0?.trim())p(N0.dirPath,i0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{Z0.close(),v(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],u0=N0?.kind==="file"?e.filter((i0)=>i0.path!==N0.dir):[],[Q8,o0]=u.useState(!1),[_8,A0]=u.useState("board"),[r0,P0]=u.useState(""),[K8,F8]=u.useState(""),[D8,W8]=u.useState(!1),A8=u.useMemo(()=>Q.find((i0)=>i0.kind==="canvas"&&i0.label!=="Design system")?.fullPath,[Q]),i8=u.useCallback(async()=>{let i0=r0.trim();if(!i0||D8)return;if(W8(!0),F8(""),_8==="folder"){if(!A8){W8(!1),F8("no canvas group to create a folder in");return}let I0=await p(A8,i0);if(W8(!1),I0?.ok)o0(!1),P0("");else F8(I0?.error||"could not create folder");return}let j0=await R(i0);if(W8(!1),j0?.ok)o0(!1),P0("");else F8(j0?.error||"could not create board")},[r0,D8,R,p,_8,A8]),P9=u.useMemo(()=>{let i0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[Q]),l0=u.useMemo(()=>{let i0=0;for(let j0 of U0)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[U0]);return O("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[O("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),O("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":Q8&&_8==="board",onClick:()=>{F8(""),A0("board"),o0((i0)=>_8==="board"?!i0:!0)},children:z(E9,{name:"plus",size:15})}),!X&&A8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":Q8&&_8==="folder",onClick:()=>{F8(""),A0("folder"),o0((i0)=>_8==="folder"?!i0:!0)},children:z(E9,{name:"folder-plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>M(),children:z(E9,{name:"reload",size:15})}),O("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),l0," / ",P9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(E9,{name:"panel-left",size:15})})]})]}),Q8?O("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:_8==="folder"?"folder name…":"brief board name…",value:r0,maxLength:60,disabled:D8,"aria-label":_8==="folder"?"New folder name":"New brief board name",onChange:(i0)=>P0(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Enter")i0.preventDefault(),i8();else if(i0.key==="Escape")i0.preventDefault(),o0(!1),P0(""),F8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:D8||!r0.trim(),"data-tip":"Create · Enter","aria-label":_8==="folder"?"Create folder":"Create brief board",onClick:i8,children:D8?"…":"↵"})]}):null,K8?z("div",{className:"st-newboard-err",role:"alert",children:K8}):null,z("div",{className:"st-search",children:O("div",{className:"st-search-box",children:[z(E9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(i0)=>B(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Escape")if(i0.preventDefault(),q)B("");else i0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:U0.map((i0)=>{if(!F&&!q&&i0.kind==="runtime")return null;let j0=x20(i0),I0=(i0.paths||[]).filter((d0)=>GQ.test(d0)).length,T8=j0.pill||(j0.pillFromDsCount?String(i0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||i0.paths?.length||0):null),Z8=i0.tree&&Object.keys(i0.tree).length>0,z0=i0.label==="Design system",f0=i0.kind==="project";if(!F&&!q&&f0&&I0===0)return null;let L8=O20(i0),n8=D[i0.label],k8=!!q||(n8===void 0?L8:n8),q8=!z0&&i0.kind==="canvas"&&!X,w0=q8?o.dropProps(i0.fullPath,!0):{},L0=o.overDir===i0.fullPath;return O("div",{className:"st-tree-section",children:[O("button",{type:"button",className:"st-tree-sec-hd"+(L0?" is-drop-target":""),onClick:()=>_(i0.label,L8),"aria-expanded":k8,"aria-dropeffect":q8?"move":void 0,title:k8?"Collapse section":"Expand section",...w0,children:[z(E9,{name:"chevron-right",className:"st-chev"+(k8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),T8&&z("span",{className:"st-pill",children:T8})]}),k8&&(Z8?z(x00,{node:i0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:i0.kind,showHidden:F,search:q,dsFolders:i0.dsFolders,activeDsName:G,onOpenSystem:z0?K:void 0,onDelete:z0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:i0.fullPath,drag:!z0&&i0.kind==="canvas"&&!X?o:void 0,menu:!z0&&i0.kind==="canvas"&&!X?Z0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},i0.label)})}),z(RS,{state:Z0.state,onClose:Z0.close,rootItems:K0,destinations:u0,onPickDestination:(i0)=>m(N0.path,i0)}),!c&&z(Ww,{project:f,liveBranch:h,remoteSync:d,onGetLatest:n}),J===null?z(kA,{syncStatus:r,onLinkedHub:a}):null,z($A,{})]})}function g20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:O("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(E9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(E9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(E9,{name:"folder",size:15})})]})})}function m20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),O("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HT]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[O("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),O("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),O("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),O("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),O("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),O("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),O("details",{children:[z("summary",{children:"Annotation tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),O("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),O("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),O("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),O("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),O("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),O("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),O("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),O("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),O("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),O("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),O("details",{children:[z("summary",{children:"Canvas & panels"}),O("ul",{children:[O("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),O("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),O("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),O("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),O("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),O("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),O("details",{children:[z("summary",{children:"Slash commands"}),O("ul",{className:"cmds",children:[O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),O("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),O("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),O("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),O("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),O("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),O("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),O("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),O("details",{children:[z("summary",{children:"Opt-out scope"}),O("ul",{children:[O("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),O("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),O("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),O("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),O("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),O("details",{children:[z("summary",{children:"Auto-critic loop"}),O("ul",{children:[O("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),O("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),O("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),O("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),O("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),O("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),O("details",{children:[z("summary",{children:"Pin-to-element flow"}),O("ol",{children:[z("li",{children:"Open a canvas"}),O("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),O("li",{children:["Run"," ",O("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),O("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),O("details",{children:[z("summary",{children:"Comments"}),O("ol",{children:[O("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),O("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),O("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var YT=[{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 u20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return O("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>O(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function l20({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=YT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[O("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),O("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:YT.map((Y)=>O("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>O("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(u20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),O("div",{className:"so-overlay-ft",children:[O("span",{children:["close with ",z(wX,{children:"Esc"})]}),O("span",{className:"so-count",children:[Q," bindings · ",YT.length," groups"]})]})]})})}var p20=["File","Edit","View","Selection","Tools","Help"];function h00(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 d20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return h00(Q),O("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(E9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function yK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return h00(G),O("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):O("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:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function c20({onAction:X,onClose:J}){return z(yK,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function i20({onAction:X,onClose:J,readOnly:Q=!1}){return z(yK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function o20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(yK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function n20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(yK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function r20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(yK,{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 a20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:M,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:f,onToggleZoomCtl:h,presentMode:d,onTogglePresent:n,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:v,onOpenReadiness:r,onOpenQuickSetup:a,onWatchIntro:c,whatsNewCount:U0,exportCenter:o,artboardCount:Z0=0,presence:e=null,inspectorOpen:N0,inspectorTab:K0,onToggleInspector:u0,autoOpenInspector:Q8,onToggleAutoOpenInspector:o0,onOpenLayers:_8,timelineOpen:A0,onToggleTimeline:r0,hasComps:P0=!1,assistantOpen:K8,onToggleAssistant:F8,assistantBusy:D8,assistantUnseen:W8,onNewCanvas:A8,onAssembleVideo:i8,onOpenExport:P9,onOpenSettings:l0,onOpenGenerate:i0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:T8,readOnly:Z8=!1}){let z0=X===c8,f0=z0?"SYSTEM":X?"CANVAS":"IDLE",L8=z0?z("b",{children:"design system"}):X?O(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(JH(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n8=new Set(Q?["autoopen"]:["assistant","autoopen"]),k8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&K0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Q8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:P0?"video":void 0,checked:A0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:K8,disabled:!1}]:Q?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:f,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||z0}].filter((L0)=>!Z8||!n8.has(L0.id)),q8=["file","edit","view","selection","tools","help"];function w0(L0){if(q8.includes(L0))G(W===L0?null:L0)}return u.useEffect(()=>{if(!W||!q8.includes(W))return;let L0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(V8){let O8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!O8.length)return;let a8=O8.indexOf(document.activeElement);if(V8.key==="ArrowDown")V8.preventDefault(),O8[(a8+1)%O8.length].focus();else if(V8.key==="ArrowUp")V8.preventDefault(),O8[(a8-1+O8.length)%O8.length].focus();else if(V8.key==="Home")V8.preventDefault(),O8[0].focus();else if(V8.key==="End")V8.preventDefault(),O8[O8.length-1].focus();else if(V8.key==="ArrowRight"||V8.key==="ArrowLeft"){V8.preventDefault();let E8=V8.key==="ArrowRight"?1:-1,N9=q8.indexOf(W);G(q8[(N9+E8+q8.length)%q8.length])}else if(V8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(L0),window.removeEventListener("keydown",d0)}},[W,G]),O("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[O("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?O("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:p20.map((L0)=>{let d0=L0.toLowerCase(),V8=q8.includes(d0),O8=V8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":V8?"menu":void 0,"aria-expanded":V8?W===d0:void 0,onClick:()=>w0(d0),onMouseEnter:()=>{if(W!==null&&V8)G(d0)},children:L0},d0)})}),W==="file"&&z(n20,{readOnly:Z8,hasCanvas:!!X,onAction:(L0)=>{if(L0==="new")A8?.();else if(L0==="assemble")i8?.();else if(L0==="export")P9?.("export");else if(L0==="handoff")P9?.("handoff");else if(L0==="generate")i0?.();else if(L0==="settings")l0?.();else if(L0==="reload")j0?.();else if(L0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z(r20,{readOnly:Z8,hasCanvas:!!X&&!z0,onAction:(L0)=>{if(L0==="undo")p({dgn:"undo"});else if(L0==="redo")p({dgn:"redo"});else if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(L0.startsWith("new-artboard:"))T8?.(L0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(d20,{panels:k8,onToggle:(L0)=>{if(L0==="tree")F();else if(L0==="changes")q();else if(L0==="comments")H();else if(L0==="hidden")_();else if(L0==="annotate")$();else if(L0==="inspector")u0();else if(L0==="autoopen")o0?.();else if(L0==="timeline")r0?.();else if(L0==="assistant")F8?.();else if(L0==="layers")_8?.();else if(L0==="minimap")y?.();else if(L0==="zoomctl")h?.();else if(L0==="present")n?.();else if(L0==="print-guides")m?.()},onZoom:(L0)=>p({dgn:"zoom",op:L0}),hasCanvas:!!X&&!z0,onClose:()=>G(null)}),W==="selection"&&z(i20,{readOnly:Z8,onAction:(L0)=>{if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(o20,{readOnly:Z8,onAction:(L0)=>p({dgn:"tool-set",tool:L0}),onClose:()=>G(null)}),W==="help"&&z(c20,{onAction:(L0)=>{if(L0==="shortcuts")w?.();else if(L0==="help")R?.();else if(L0==="report-bug")M?.();else if(L0==="tour")P?.();else if(L0==="collab-tour")I?.();else if(L0==="quick-setup")a?.();else if(L0==="readiness")r?.();else if(L0==="whatsnew")v?.();else if(L0==="watch-intro")c?.()},onClose:()=>G(null)}),O("div",{className:"st-mb-right","data-tour":"status",children:[e?z("div",{className:"st-presence",children:e}):null,Z8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?O("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!Z8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":K8?"true":"false","data-busy":D8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${D8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:F8,children:z(E9,{name:"sparkle",size:15})}),o&&z(Ch,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:M,children:z(E9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:v,children:z(E9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:f0}),z("span",{className:"st-mb-file",title:X||"",children:L8}),z("span",{className:"st-mb-sep"}),O("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),Z0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function s20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),O("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${sB(JH(N))}`,tabIndex:0,children:z(mx,{path:N,kind:ZT(JH(N))})}),X.length===0&&!N&&O("div",{className:"st-empty",children:[O("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),O("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),O("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?O(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===c8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(GB0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Iz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:O("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var t20=["color","space","radius","shadow","leading","weight","motion","font","other"],e20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function XB0(X){return X==="color"}function JB0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return O("section",{className:"sv-section sv-section-tokens",children:[O("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:O("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...t20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=XB0(G);return O("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[O("h2",{children:["tokens · ",e20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>O("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,O("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function QB0(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 YB0(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 WB0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=YB0(X?.font);return O("section",{className:"sv-section sv-section-type",children:[O("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=QB0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return O("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function GB0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return O("div",{className:"sv",children:[O("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?O("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(JB0,{tokens:H,tokenGroups:K,tokensPath:U}),z(WB0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:O("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):O(G0,{children:[z(O00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(O00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function O00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return O("section",{className:"sv-section",children:[O("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>O("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Iz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),O("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function ZB0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===c8,M=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Tz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&O(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return O("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[O("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&O("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:M}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),O("span",{className:"val",children:[Y," open"]})]}),_&&O("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:O("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),O("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(E9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function HB0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=f00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((M)=>{if(J==="open")return M.status!=="resolved";if(J==="resolved")return M.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((M)=>M.selector);F.push({file:D,comments:R.map((M)=>({...M,n:w.findIndex((P)=>P.id===M.id)+1}))})}return O("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:O("div",{className:"st-cm-filters",role:"tablist",children:[O("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),O("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),O("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?O("div",{className:"st-rp-empty",children:[O("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),O("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>O(G0,{children:[O("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(JH(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>O("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[O("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:E20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),O("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?O("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(E9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(E9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(E9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var zB0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function KB0({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=zB0[J];if(!Z)return null;return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function UB0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),O("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),af().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function VB0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return O("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var qB0=["block","inline-block","flex","inline-flex","grid","inline","none"],M00=["px","%","fr","em","auto","min-content","max-content"];var BB0=["auto","stretch","flex-start","center","flex-end","baseline"];var _00=["300","400","500","600","700","800"],A00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],w00=["none","solid","dashed","dotted","double"],E00=["px","rem","em","%","vw","vh","auto"],P00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WT={"font-size":{node:z(Y7,{as:WV,size:12})},"line-height":{node:z(Y7,{as:VV,size:12})},"letter-spacing":{node:z(Y7,{as:_V,size:12})},gap:{node:z(Y7,{as:YK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:RV,size:12})},"border-width":{node:z(Y7,{as:MV,size:12})}};var R00=["static","relative","absolute","fixed","sticky"],NB0=["normal","italic","oblique"],T00=["none","uppercase","lowercase","capitalize"];var I00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],FB0=["fill","contain","cover","none","scale-down"];var k00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],C00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],_5={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}},SK=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!SK)SK=document.createElement("canvas").getContext("2d");if(!SK)return"";SK.fillStyle="#000000",SK.fillStyle=X;let J=SK.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 n4=(X)=>Math.min(1,Math.max(0,X));function AF(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 v3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function f3({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 bK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function gQ(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 $00(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 g00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function LB0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function m00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...LB0(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function u00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>f3(AF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(f3(AF(X)))},[X]);let U=v3(bK(Y)),q=(M)=>{M.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:n4((C.clientX-P.left)/P.width),v:n4(1-(C.clientY-P.top)/P.height)})};k(M);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(v3(bK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(M)=>{M.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:n4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(M);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(v3(bK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(M)=>{let P={...G.current,...M};W(P),Q(v3(bK(P)))},F=(M)=>{let P=M.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[M.key];if(!k)return;M.preventDefault(),N({s:n4(G.current.s+k[0]),v:n4(G.current.v+k[1])})},D=(M)=>{let P=M.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[M.key];if(k==null)return;M.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let M=window.EyeDropper;if(!M)return;let P=await new M().open();if(P?.sRGBHex)W(f3(AF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=bK(Y),w=(M)=>{let P={...R,...M},I=f3({r:n4(P.r/255)*255,g:n4(P.g/255)*255,b:n4(P.b/255)*255});W(I),Q(v3(bK(I)))};return O("div",{className:"st-cp-cpick",children:[O("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(M)=>{let P=M.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(f3(AF(P)))},onKeyDown:(M)=>{if(M.key==="Enter")Q(M.currentTarget.value)},onBlur:(M)=>Q(M.currentTarget.value),onFocus:(M)=>M.currentTarget.select()})]}),O("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),O("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(E9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((M)=>O("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":M.toUpperCase(),value:Math.round(R[M]),onChange:(P)=>w({[M]:n4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:M.toUpperCase()})]},M))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),M=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(a)=>Q===`var(${a})`,k=(a)=>a.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((a,c)=>a+(c.names?.length||0),0),y=$.length>1,f=_.trim().toLowerCase(),h=!f?$:$.map((a)=>({...a,names:(a.names||[]).filter((c)=>k(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(a.vals?.[c]||"").toLowerCase().includes(f))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){R("");return}let a=()=>{let Z0=w.current?.getBoundingClientRect();if(!Z0)return;let e=224,N0=300,K0=Math.min(Z0.right-e,window.innerWidth-e-8);if(K0<8)K0=8;let Q8=window.innerHeight-Z0.bottom>N0+8?Z0.bottom+4:Math.max(8,Z0.top-N0-4);N({left:K0,top:Q8,width:e,maxHeight:N0})};a();let c=(Z0)=>{if(M.current?.contains(Z0.target)||w.current?.contains(Z0.target))return;q(!1)},U0=(Z0)=>{if(Z0.key==="Escape")q(!1)},o=(Z0)=>{if(M.current?.contains(Z0.target))return;a()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",a),document.removeEventListener("scroll",o,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!M.current)return;let a=M.current.getBoundingClientRect(),c=B.left-a.left,U0=B.top-a.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((o)=>o?{...o,left:o.left+c,top:o.top+U0}:o)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(a,c,U0)=>{if(H&&a&&a!==H&&U0&&!d.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(a)=>{let c=(a||"").trim();if(c)Y(c)},m=O("div",{className:"st-cp-pop-search",children:[z(E9,{name:"search",size:12}),z("input",{value:_,onChange:(a)=>R(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),v=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return O(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?b00.createPortal(z("div",{ref:M,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?O(G0,{children:[O("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(u00,{seed:Z||kF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):O(G0,{children:[m,h.length?p(h):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):O(G0,{children:[m,h.length?v(h):r]})}),document.body):null]})}function S00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?ZU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return O("div",{className:"st-cp-gridtracks",children:[O("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?O("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=ZU.has(K.unit);return O("div",{className:"st-cp-gridtrack-row",children:[q?z(IW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:M00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(QN,{value:K.unit,units:M00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function DB0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(X0,_0)=>{let B0={...X0||{}};for(let[S0,t0]of Object.entries(_0))if(t0===null)delete B0[S0];else B0[S0]=t0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(X0,_0)=>B((B0)=>({...B0,a:{...B0.a,[X0]:_0}})),w=(X0,_0)=>B((B0)=>({...B0,c:{...B0.c,[X0]:_0}})),M=(X0,_0)=>B((B0)=>({...B0,t:{...B0.t,[X0]:_0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=g00(X.file,J),k=m00(J,P,I),$=(X0)=>k.map((_0)=>({ds:_0.name,names:_0[X0]||[],vals:_0.vals})).filter((_0)=>_0.names.length),[C,y]=u.useState({}),[f,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)h((X0)=>X0.Advanced?X0:{...X0,Advanced:!0})},[X.id,d]);let n=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(n)h((X0)=>X0["d:Position"]?X0:{...X0,"d:Position":!0})},[X.id,n]);let x=H,[m,p]=u.useState({});async function v(X0,_0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(X0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0)}),t0=await S0.json().catch(()=>({}));y((j8)=>({...j8,[B0]:!S0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((t0)=>({...t0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let r=(X0,_0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:X0,value:_0})},a=(X0,_0,B0,S0)=>{Y?.({op:X0,canvas:X.file,id:X.id,key:_0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(X0,_0)=>{let B0=(_0||"").trim();if(!K||!B0)return;let S0=F[X0]??null;if(B0===(S0??"").trim())return;r(X0,B0),R(X0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,value:B0},X0),a("css",X0,S0,B0)},U0=(X0,_0)=>{let B0=(_0||"").trim(),S0=X0.trim();if(!K||!S0||!B0)return;let t0=D[S0]??null;r(S0,B0),w(S0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),a("css",S0,t0,B0)},o=(X0,_0)=>{let B0=(X0||"").trim(),S0=(_0||"").trim();if(!K||!B0||!S0)return;let t0=_[B0]??null;M(B0,S0),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),a("attr",B0,t0,S0)},Z0=(X0)=>{if(!K)return;let _0=F[X0]??null;r(X0,null),R(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},e=(X0)=>{if(!K)return;let _0=D[X0]??null;r(X0,null),w(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},N0=(X0)=>{if(!K)return;let _0=_[X0]??null;M(X0,null),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:X0,reset:!0},`@${X0}`),a("attr",X0,_0,null)},K0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},u0=(X0,_0)=>{if(!K)return;let B0=Math.round((X0==="width"?X.bounds?.w:X.bounds?.h)||0),S0=_S(X0,_0,K0,B0);for(let t0 of S0.reset)if(F[t0])Z0(t0);for(let[t0,j8]of S0.set)c(t0,j8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(X0)=>{let _0=MS(X0,F,U,K0);return O("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:X0==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${X0} sizing mode`,children:z(YN,{value:_0,ariaLabel:`${X0} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>u0(X0,B0)})})]},`mode-${X0}`)},_8=["flex-start","center","flex-end"],A0=["flex-start","center","flex-end"],r0=["t","c","b"],P0=["l","c","r"],K8=()=>{let X0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),_0=Math.max(0,_8.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),B0=F["align-items"]||Z7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,A0.indexOf(B0)),[t0,j8]=X0?[_0,S0]:[S0,_0];return r0[j8]+P0[t0]},F8=(X0)=>{let _0=r0.indexOf(X0[0]),B0=P0.indexOf(X0[1]),S0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[t0,j8]=S0?[B0,_0]:[_0,B0];c("justify-content",_8[t0]),c("align-items",A0[j8])},D8=(X0)=>{if(!(X0.metaKey||X0.ctrlKey)||X0.altKey)return;let _0=X0.key.toLowerCase();if(_0==="z")X0.preventDefault(),G?.(X0.shiftKey?"redo":"undo");else if(_0==="y")X0.preventDefault(),G?.("redo")},W8=(X0)=>{let _0=F[X0];if(!_0)return"inherit";return/var\(\s*--/.test(_0)?"bound":"raw"};if(!K)return O("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),O("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(X0)=>z("span",{className:`st-cp-prov st-cp-prov--${X0}`,role:"img","aria-label":A8[X0]}),P9=(X0,_0)=>{let B0=_0??W8(X0),S0=C[X0],t0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",j8=t0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",g8=!!F[X0],t8=t0?`error: ${t0}`:g8?`${A8[B0]} · double-click to reset`:A8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${j8}${g8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:g8?0:-1,onDoubleClick:g8?()=>Z0(X0):void 0,onKeyDown:g8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),Z0(X0)}:void 0})},l0=(X0,_0,B0,S0)=>{let t0=B0===void 0&&!F[X0],j8=S0??X0;return O("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[P9(X0,B0),z("label",{className:"st-cp-label",title:j8,children:j8}),z("div",{className:"st-cp-ctl",children:_0})]},X0)},i0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},j0=(X0)=>{(i0[X0]||[]).forEach((_0)=>{if(F[_0])Z0(_0)})},I0=(X0,_0)=>{let B0=(i0[X0]||[]).some((S0)=>F[S0]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[X0],onClick:()=>h((S0)=>({...S0,[X0]:!S0[X0]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[X0]?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${X0} section to original`,title:`reset ${X0}`,disabled:!B0,onClick:()=>j0(X0),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[X0]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},X0)},T8=(X0,_0,B0,S0=!0)=>{let t0=`d:${X0}`,j8=f[t0]===void 0?S0:f[t0],g8=_0.some((t8)=>F[t8]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":j8,onClick:()=>h((t8)=>({...t8,[t0]:!j8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:j8?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${g8?"":" is-quiet"}`,"aria-label":`reset ${X0} to original`,title:`reset ${X0}`,disabled:!g8,onClick:()=>_0.forEach((t8)=>{if(F[t8])Z0(t8)}),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${j8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t0)},Z8=(X0)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[X0],"aria-label":m[X0]?`${X0} — fewer options`:`${X0} — more options`,title:m[X0]?"fewer":"more",onClick:()=>p((_0)=>({..._0,[X0]:!_0[X0]})),children:m[X0]?"▴":"···"}),z0=(X0,_0)=>O("select",{className:"st-cp-nsel","aria-label":X0,value:_0.includes(F[X0])?F[X0]:"",onChange:(B0)=>c(X0,B0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[X0])||"—"}),_0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),f0=(X0)=>$(X0).flatMap((_0)=>(_0.names||[]).map((B0)=>({name:B0,value:_0.vals?.[B0]||""}))),L8=(X0,_0)=>z(mA,{value:F[X0]||Z7(U[X0])||_0[0].value,ariaLabel:X0,options:_0,onChange:(B0)=>c(X0,B0)}),n8=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=F[X0]??"",g8=typeof j8==="string"&&/var\(\s*--/.test(j8),t8=t0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,w9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=WT[X0];return z(WN,{value:g8?j8:w9,tokens:f0(_0),ariaLabel:X0,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:t0?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(g9)=>c(X0,g9==="auto"?"auto":`${S0.n||"0"}${g9}`)}),onChange:(g9)=>c(X0,typeof g9==="string"?g9:t0?`${g9}`:`${g9}${t8}`)})},k8=()=>{let X0=(t0)=>Number.parseFloat(gQ(F[t0]??F["border-radius"]??Z7(U[t0])??Z7(U["border-radius"])??"0").n)||0,_0={tl:X0("border-top-left-radius"),tr:X0("border-top-right-radius"),bl:X0("border-bottom-left-radius"),br:X0("border-bottom-right-radius")},B0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((g8)=>{if(F[g8])Z0(g8)}),c("border-radius",`${t0.tl}px`);else c("border-top-left-radius",`${t0.tl}px`),c("border-top-right-radius",`${t0.tr}px`),c("border-bottom-left-radius",`${t0.bl}px`),c("border-bottom-right-radius",`${t0.br}px`)},S0=WT["border-radius"];return z(ax,{corners:_0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},q8=()=>O("div",{className:"st-cp-border",children:[b9("border-width",null,{fixedUnit:"px"}),O("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:w00.includes(F["border-style"])?F["border-style"]:"",onChange:(X0)=>c("border-style",X0.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),w00.map((X0)=>z("option",{value:X0,children:X0},X0))]}),z(EF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:kF(U["border-color"]||F["border-color"])||"#000000",onPick:(X0)=>c("border-color",X0),label:"border colour"})]}),w0=()=>{let X0=F.transform||Z7(U.transform)||"",_0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(X0),B0=((_0?Number.parseFloat(_0[1]):0)%360+360)%360,S0=(t0)=>{let j8=(t0%360+360)%360,g8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${g8?`${g8} `:""}rotate(${j8}deg)`.trim())};return O("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(nx,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:wZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},L0=()=>{let X0=F.filter||Z7(U.filter)||"",_0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(X0),B0=_0?Number.parseFloat(_0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let j8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",t0>0?`${j8?`${j8} `:""}blur(${t0}px)`.trim():j8||"none")}})},d0=()=>{let X0=F.opacity,_0=X0!=null&&X0!==""?Number.parseFloat(X0):Number.parseFloat(Z7(U.opacity))||1,B0=Math.round((Number.isNaN(_0)?1:_0)*100);return z(TJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>r("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${X0??""}`)},V8=()=>{let X0=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,_0=(F["font-style"]||Z7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(ix,{value:{b:X0,i:_0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:qV}),label:"Bold"},{value:"i",node:z(Y7,{as:DV}),label:"Italic"},{value:"u",node:z(Y7,{as:kV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",X0?"400":"700");else if(S0==="i")c("font-style",_0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},O8=[{value:"row",node:z(Y7,{as:DW}),label:"Row"},{value:"column",node:z(Y7,{as:OW}),label:"Column"}],a8=[{value:"flex-start",node:z(Y7,{as:HV}),label:"Start"},{value:"center",node:z(Y7,{as:GV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:ZV}),label:"End"},{value:"space-between",node:z(Y7,{as:YK}),label:"Space between"}],E8=[{value:"flex-start",node:z(Y7,{as:UV}),label:"Start"},{value:"center",node:z(Y7,{as:zV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:KV}),label:"End"},{value:"stretch",node:z(Y7,{as:TV}),label:"Stretch"}],N9=[{value:"left",node:z(Y7,{as:m5}),label:"Left"},{value:"center",node:z(Y7,{as:AW}),label:"Center"},{value:"right",node:z(Y7,{as:wW}),label:"Right"},{value:"justify",node:z(Y7,{as:EW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:AZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:EZ}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:EV}),label:"Scroll"}],e7=(X0,_0)=>{let B0=$(_0);return B0.length?z(EF,{kind:"value",groups:B0,current:F[X0],activeDs:I,onPick:(S0)=>c(X0,S0),label:`${X0} design token`}):null},E0=(X0)=>{let _0=X0.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===_0)_0.select()})},h8=(X0,_0)=>{if(X0.key!=="ArrowUp"&&X0.key!=="ArrowDown")return!1;X0.preventDefault();let B0=X0.shiftKey?10:1,S0=X0.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(X0.currentTarget.value)||0)+S0*B0;return X0.currentTarget.value=String(t0),_0(t0),!0},F9=(X0)=>z("input",{className:"st-cp-fin","aria-label":X0,defaultValue:F[X0]??"",placeholder:Z7(U[X0])||"—",onFocus:E0,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>c(X0,_0.currentTarget.value)},`${X0}:${F[X0]??""}`),b9=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=t0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),g8=WT[X0],t8=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return O(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:X0,lead:g8?g8.node??g8.t:void 0,onCommit:(w9)=>c(X0,t0?`${w9}`:`${w9}${j8}`),unitSlot:t0||B0.fixedUnit?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(w9)=>c(X0,w9==="auto"?"auto":`${S0.n||"0"}${w9}`)})},`${X0}:${F[X0]??""}`),e7(X0,_0)]})},l7=(X0)=>{let _0=U[X0]||F[X0]||"",B0=F[X0]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),t0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[X0],activeDs:I,swatchBg:_0,seedHex:kF(U[X0]||F[X0])||"#000000",onPick:(j8)=>c(X0,j8),label:`${X0} colour`}),displayValue:t0,bound:S0,ariaLabel:X0,onValue:(j8)=>c(X0,j8)})},c6=(X0,_0)=>{let B0=null,S0=_0.unitless?"":"px",t0=(t8)=>_0.unitless?`${t8}`:`${t8}${S0}`,j8=(t8,G9,w9)=>{for(let F7 of G9??[X0])w9(F7,t0(t8))},g8=gA({getBase:()=>B0?.value??"0",min:_0.min??0,step:1,sides:_0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let w9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===X0)continue;let g9=w9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(g9)g9.value=String(t8)}}j8(t8,G9,r)},onCommit:(t8,G9)=>j8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,g8(t8)}}},p8=(X0,_0)=>{let B0=F[X0],S0=B0!=null&&B0!==""?gQ(B0).n||B0:gQ(Z7(U[X0])??"").n||"0",t0=!B0||B0==="0"||B0==="0px"||B0==="auto",j8=X0.split("-").pop(),g8=j8==="top"||j8==="bottom"?[`${_0}-top`,`${_0}-bottom`]:[`${_0}-left`,`${_0}-right`],t8=[`${_0}-top`,`${_0}-right`,`${_0}-bottom`,`${_0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${_0[0]}${X0.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":X0,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...c6(X0,{sides:{pair:g8,all:t8}}),onFocus:E0,onKeyDown:(G9)=>{if(h8(G9,(w9)=>c(X0,`${w9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let w9=G9.currentTarget.value.trim();if(!w9)return;let F7=/[a-z%]/i.test(w9)?w9:`${w9}px`;c(X0,F7)}},`${X0}:${B0??""}`)},H7=(X0)=>{let _0=F[X0],B0=_0!=null&&_0!==""&&_0!=="auto"?gQ(_0).n||_0:gQ(Z7(U[X0])??"").n||"",S0=!_0||_0==="auto"||_0==="0"||_0==="0px",t0=X0==="top"||X0==="bottom"?["top","bottom"]:["left","right"],j8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${X0[0]}${S0?" is-zero":""}`,"aria-label":X0,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...c6(X0,{sides:{pair:t0,all:j8},min:-1/0}),onFocus:E0,onKeyDown:(g8)=>{if(h8(g8,(t8)=>c(X0,`${t8}px`)))return;if(g8.key==="Enter")g8.currentTarget.blur()},onBlur:(g8)=>{let t8=g8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(X0,G9)}},`${X0}:${_0??""}`)},z7=Object.entries(D),P7=Object.entries(_),T9=()=>{let X0=(X.tag||"").toLowerCase(),B0=X0==="img"||X0==="video"||X0==="picture"||X0==="svg"||X0==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(X0==="img"||X0==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(X0)=>O(G0,{children:[X0&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),l0("object-fit",z0("object-fit",FB0)),l0("object-position",F9("object-position")),l0("aspect-ratio",O("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:C00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(_0)=>{let B0=_0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)Z0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),C00.map((_0)=>z("option",{value:_0,children:_0},_0))]}))]});return O("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:D8,children:[O("div",{className:"st-cp-id",children:[O("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?O("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(mA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:LW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:PW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?O(G0,{children:[T8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let X0=(F.display||Z7(U.display)||"").trim();return X0==="flex"||X0==="inline-flex"?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8),void 0,"Direction"),l0("align-items",z(ox,{value:K8(),onChange:F8,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),l0("gap",n8("gap","space"),void 0,"Gap"),O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),O("div",{className:"st-cp-box","aria-label":"padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Z8("Auto layout")}),m["Auto layout"]?l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),T8("Size",["width","height","min-width","max-width","min-height","max-height"],O(G0,{children:[l0("width",b9("width"),void 0,"Width"),l0("height",b9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Z8("Size")}),m.Size?O(G0,{children:[l0("min-width",b9("min-width"),void 0,"Min width"),l0("max-width",b9("max-width"),void 0,"Max width"),l0("min-height",b9("min-height"),void 0,"Min height"),l0("max-height",b9("max-height"),void 0,"Max height")]}):null]})),T8("Position",["position","top","right","bottom","left","z-index"],O(G0,{children:[l0("position",z0("position",R00),void 0,"Position"),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Z8("Position")}),m.Position?l0("z-index",b9("z-index"),void 0,"Layer order"):null]}),!1),T8("Fill",["background-color"],l0("background-color",l7("background-color"),void 0,"Fill")),T8("Stroke",["border-width","border-style","border-color"],l0("border",q8(),W8("border-width"),"Stroke")),T8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],l0("border-radius",k8(),W8("border-radius"),"Corner radius")),T8("Effects",["box-shadow","filter","mix-blend-mode"],O(G0,{children:[l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),l0("filter",L0(),W8("filter"),"Blur"),l0("mix-blend-mode",z0("mix-blend-mode",k00),void 0,"Blend")]})),T8("Opacity",["opacity"],l0("opacity",d0(),void 0,"Opacity")),T8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],O(G0,{children:[l0("font-family",z0("font-family",A00),void 0,"Font"),l0("color",l7("color"),void 0,"Color"),l0("font-size",n8("font-size","type"),void 0,"Size"),l0("font-weight",z0("font-weight",_00),void 0,"Weight"),l0("line-height",b9("line-height","lh"),void 0,"Line height"),l0("text-align",L8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Z8("Text")}),m.Text?O(G0,{children:[l0("letter-spacing",b9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),l0("font-style",z0("font-style",NB0),void 0,"Style"),l0("text-transform",z0("text-transform",T00),void 0,"Case"),l0("white-space",z0("white-space",I00),void 0,"Whitespace")]}):null]})),T8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],O("div",{className:"st-cp-box","aria-label":"margin",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin")]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?T8("Media",["object-fit","object-position","aspect-ratio"],S6(_0)):null})()]}):O(G0,{children:[I0("Layout",(()=>{let X0=(F.display||Z7(U.display)||"").trim(),_0=X0==="flex"||X0==="inline-flex",B0=X0==="grid"||X0==="inline-grid";return O(G0,{children:[l0("display",z0("display",qB0)),_0?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8)),l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,_0||B0?O(G0,{children:[l0("align-items",L8("align-items",E8)),l0("justify-content",L8("justify-content",a8)),l0("gap",n8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let X0=(F.display||Z7(U.display)||"").trim();if(!(X0==="grid"||X0==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",t0=vO(B0),j8=vO(S0),g8=t0.length>0||!B0.trim(),t8=j8.length>0||!S0.trim();return I0("Grid",O(G0,{children:[g8?z(S00,{label:"Columns",tracks:t0,editable:K,onChange:(G9)=>c("grid-template-columns",fO(G9))}):O("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(S00,{label:"Rows",tracks:j8,editable:K,onChange:(G9)=>c("grid-template-rows",fO(G9))}):O("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",O(G0,{children:[l0("position",z0("position",R00)),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l0("z-index",b9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",O(G0,{children:[O("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),l0("grid-column",F9("grid-column")),l0("grid-row",F9("grid-row"))]})),I0("Typography",O(G0,{children:[l0("font-family",z0("font-family",A00)),l0("color",l7("color")),l0("font-size",n8("font-size","type")),l0("font-weight",z0("font-weight",_00)),l0("line-height",b9("line-height","lh")),l0("letter-spacing",b9("letter-spacing",null,{min:-1/0})),l0("text-align",L8("text-align",N9)),l0("font-style",V8(),W8("font-style")),l0("text-transform",z0("text-transform",T00)),l0("white-space",z0("white-space",I00))]})),I0("Spacing",z(G0,{children:O("div",{className:"st-cp-box","aria-label":"margin and padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin"),O("div",{className:"st-cp-boxpad",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding"),O("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",O(G0,{children:[O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),l0("width",b9("width")),l0("height",b9("height")),l0("min-width",b9("min-width")),l0("max-width",b9("max-width")),l0("min-height",b9("min-height")),l0("max-height",b9("max-height")),l0("overflow",L8("overflow",Y9)),Q8?O(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),l0("align-self",z0("align-self",BB0)),l0("flex-grow",b9("flex-grow",null,{unitless:!0})),l0("flex-shrink",b9("flex-shrink",null,{unitless:!0})),l0("flex-basis",b9("flex-basis"))]}):null]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?I0("Media",S6(_0)):null})(),I0("Appearance",O(G0,{children:[l0("background-color",l7("background-color")),l0("border-radius",k8(),W8("border-radius")),l0("border",q8(),W8("border-width")),l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow")),l0("filter",L0(),W8("filter")),l0("mix-blend-mode",z0("mix-blend-mode",k00)),l0("opacity",d0()),l0("rotation",w0(),W8("transform")),l0("transform",F9("transform")),l0("transform-origin",F9("transform-origin"))]})),(()=>{let X0=Object.entries(C).find(([,_0])=>typeof _0==="string"&&_0.startsWith("err:"));return X0?O("div",{className:"st-cp-save is-err",role:"status",children:[z(E9,{name:"x",size:12}),X0[0],": ",X0[1].slice(4)]}):null})(),I0("Advanced",O("div",{className:"st-cp-advbody",children:[z7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),z7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`custom property ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>U0(X0,B0.currentTarget.value)},`cs:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>e(X0),children:z(E9,{name:"x",size:11})})]},`cs:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(OB0,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`attribute ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>o(X0,B0.currentTarget.value)},`at:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>N0(X0),children:z(E9,{name:"x",size:11})})]},`at:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(MB0,{commit:o})]}))]}),O("div",{className:"st-cp-legend",children:[O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function OB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function MB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var _B0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function AB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var wB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function l00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,M=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[f,h]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(X.dcElement??""))return;R?.(X,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return O(G0,{children:[O("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(n?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...v},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":M?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?M&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(r)=>B(r,X,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),I)M&&Z(w);else H(X);else if(r.key==="F2"&&R&&!I)r.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[M?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(E9,{name:_B0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>h(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:m,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")m();else if(r.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(r)=>{r.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),_(w)},children:z(E9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(X)},children:z(E9,{name:n?"eye-off":"eye",size:13})}):null]}),M&&!P?X.children.map((r,a)=>z(l00,{node:r,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${r.id}:${r.index}`)):null]})}function EB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),O("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?gQ(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 O(G0,{children:[G?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function p00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var PB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],RB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function TB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=p00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=g00(X.file,J),B=m00(J,U,q),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((a)=>({name:a,value:r.vals?.[a]||""}))),D=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let a of B){let c=a.vals?.[r[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(v,r)=>{if(!K)return;let a=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(a==null&&c==null)return;Q?.(K,a,c)},M=Object.entries(_5).find(([,v])=>v.width===_&&v.height===R)?.[0],P=Object.entries(_5).find(([,v])=>v.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!h){let a={paper:"a4"};try{let c=D2(a);if(c)r={defaults:a,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&I)Y?.(K,!1,void 0)},n=(v)=>{if(!K)return;let r={paper:"a4",...h,...v},a;try{a=D2(r)}catch{return}Q?.(K,a.widthPx,a.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let a=Number.isFinite(r)?r:R,c=v&&Number.isFinite(a)?Math.round(a):void 0;Y?.(K,v,c)},m=(v)=>{let r=LS(I,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return O("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),O("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?O("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(v)=>n({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),L2.map((v)=>O("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?O("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${_5[P].label} — ≤ ${_5[P].width}px`:"Breakpoint…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):O("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:M??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:M?_5[M].label:"Preset size…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(IW,{value:f,ariaLabel:"artboard kind",options:RB0.map(([v,r])=>({value:v,label:r})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:O("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,f==="print"?O(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>n({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(h?.bleedMm)?h.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>n({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),O("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=D(k),r=/var\(\s*--/.test(k),a=r?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:v,seedHex:kF(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:a,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(IW,{value:C,ariaLabel:"artboard body layout",options:PB0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),O("div",{style:{display:"flex",gap:8},children:[z(WN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(WN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var zT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,IB0=new RegExp(zT.source,"gi");function kB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(IB0)||[])],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=zT.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function CB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:f,onTabChange:h,width:d,resizing:n,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:a,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:o,onSetCpMode:Z0}){let[e,N0]=u.useState("inspect"),K0=c?"layers":f??e,u0=(w0)=>{N0(w0),h?.(w0)},[Q8,o0]=u.useState(()=>new Set),[_8,A0]=u.useState(()=>new Map);u.useEffect(()=>{let w0=Array.isArray(J)?J[0]:J,L0=w0?.id;if(!L0||!Y?.nodes)return;let d0=w0.index,V8=null,O8=[];if(function a8(E8,N9){for(let Y9 of E8||[]){let e7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===L0&&(d0==null||Y9.index===d0))return V8=e7,O8.push(...N9),!0;if(Y9.children&&Y9.children.length&&a8(Y9.children,[...N9,e7]))return!0}return!1}(Y.nodes,[]),!V8)return;if(O8.length)o0((a8)=>{let E8=!1,N9=new Set(a8);for(let Y9 of O8)if(N9.delete(Y9))E8=!0;return E8?N9:a8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${V8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let r0=(w0)=>{let L0=`${w0.id}:${w0.index}`;return _8.has(L0)?_8.get(L0):!!w0.hidden},[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),W8=(w0,L0)=>{if(!K||!w0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:w0.id,attr:"data-dc-element",value:L0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:w0.id,key:"data-dc-element",before:w0.dcElement??null,after:L0})}).catch(()=>{})},A8=B?(w0,L0,d0)=>{if(N?.current)return;if(w0?.synthetic||L0?.synthetic)return;let V8=d0==="before"?`before ${L0.label}`:d0==="after"?`after ${L0.label}`:`into ${L0.label}`;D8(`Moved ${w0.label} ${V8}`),B(w0.id,L0.id,d0,{idIndex:w0.index,refIndex:L0.index})}:void 0,i8=()=>{let w0=[];return function L0(d0,V8,O8){(d0||[]).forEach((a8,E8)=>{if(w0.push({node:a8,depth:V8,parentNode:O8,siblings:d0,pos:E8}),a8.children&&a8.children.length&&!Q8.has(`${a8.id}:${a8.index}`))L0(a8.children,V8+1,a8)})}(Y?.nodes,0,null),w0},P9=(w0)=>{if(w0.key!=="ArrowUp"&&w0.key!=="ArrowDown")return;if(!Z8)return;let L0=i8(),d0=L0.findIndex((E8)=>E8.node.id===Z8.id&&E8.node.index===Z8.index);if(d0<0)return;let V8=w0.key==="ArrowDown"?1:-1,O8=L0[d0];if(!w0.altKey){let E8=L0[d0+V8];if(E8)w0.preventDefault(),U?.(E8.node);return}if(!A8||!Array.isArray(O8.siblings))return;w0.preventDefault();let a8=(E8)=>E8&&E8.children&&E8.children.length&&!Q8.has(`${E8.id}:${E8.index}`);if(!w0.shiftKey){if(V8<0&&O8.pos>0)A8(O8.node,O8.siblings[O8.pos-1],"before");else if(V8>0&&O8.pos<O8.siblings.length-1)A8(O8.node,O8.siblings[O8.pos+1],"after");return}if(V8>0){let E8=O8.siblings[O8.pos+1];if(E8)A8(O8.node,E8,a8(E8)?"inside-start":"after");else if(O8.parentNode)A8(O8.node,O8.parentNode,"after")}else{let E8=O8.siblings[O8.pos-1];if(E8)A8(O8.node,E8,a8(E8)?"inside-end":"before");else if(O8.parentNode)A8(O8.node,O8.parentNode,"before")}},l0=u.useRef(null),i0=u.useRef(null),j0=(w0,L0,d0)=>{if(!A8||w0.button!==0||w0.metaKey||w0.ctrlKey||w0.shiftKey||w0.altKey)return;if(N?.current)return;let{clientX:V8,clientY:O8}=w0,a8=new Set([d0]);(function p8(H7){(H7.children||[]).forEach((z7)=>{a8.add(`${z7.id}:${z7.index}`),p8(z7)})})(L0);let E8=14,N9=6,Y9=[];(function p8(H7,z7){(H7||[]).forEach((P7)=>{let T9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:T9,id:P7.id,depth:z7,tag:P7.tag}),P7.children&&P7.children.length&&!Q8.has(T9))p8(P7.children,z7+1)})})(Y?.nodes,0);let e7=new Map(Y9.map((p8)=>[p8.key,p8])),E0=!1,h8=(p8)=>{if(!E0){if(Math.hypot(p8.clientX-V8,p8.clientY-O8)<4)return;E0=!0}let H7=p8.clientX-V8,z7=p8.clientY-O8,P7=null,T9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((X0)=>({rect:X0.getBoundingClientRect(),it:e7.get(X0.getAttribute("data-layer-key"))})).filter((X0)=>X0.it&&X0.it.key!==d0);if(T9.length){let X0=T9[0].rect.left,_0=T9[0].rect.right,B0=T9.length;for(let L7=0;L7<T9.length;L7++)if(p8.clientY<T9[L7].rect.top+T9[L7].rect.height/2){B0=L7;break}let S0=T9[B0-1]?.it||null,t0=T9[B0]?.it||null,j8=Math.round((p8.clientX-X0-N9)/E8),g8=S0?S0.depth+(wB0.has(S0.tag)?0:1):0,t8=t0?t0.depth:0,G9=Math.max(t8,Math.min(j8,g8)),w9=null,F7="before",g9=0;if(!S0){if(t0)w9=t0,F7="before",g9=t0.depth}else if(G9>S0.depth)w9=S0,F7="inside-start",g9=S0.depth+1;else if(G9===S0.depth)w9=S0,F7="after",g9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(T9[L7].it.depth===G9){w9=T9[L7].it;break}if(!w9)w9=S0;F7="after",g9=G9}if(w9&&w9.key!==d0&&!a8.has(w9.key)){let L7=S0?T9[B0-1].rect.bottom:T9[0].rect.top,mX=X0+N9+g9*E8;P7={refId:w9.id,position:F7,node:w9.node,y:L7,left:mX,w:Math.max(24,_0-mX)}}}let S6={key:d0,node:L0,dx:H7,dy:z7,target:P7};l0.current=S6,K8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",l7),window.removeEventListener("keydown",c6,!0)},b9=()=>{let p8=(H7)=>{H7.preventDefault(),H7.stopImmediatePropagation(),document.removeEventListener("click",p8,!0)};document.addEventListener("click",p8,!0),setTimeout(()=>document.removeEventListener("click",p8,!0),300)},l7=()=>{F9();let p8=l0.current;if(l0.current=null,K8(null),E0&&p8?.target)b9(),A8(p8.node,p8.target.node,p8.target.position)},c6=(p8)=>{if(p8.key!=="Escape")return;if(p8.preventDefault(),p8.stopImmediatePropagation(),F9(),l0.current=null,K8(null),E0)b9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",l7),window.addEventListener("keydown",c6,!0)},I0=(w0)=>o0((L0)=>{let d0=new Set(L0);if(d0.has(w0))d0.delete(w0);else d0.add(w0);return d0}),T8=(w0)=>{let L0=`${w0.id}:${w0.index}`,d0=r0(w0),V8=!d0;if(A0((O8)=>new Map(O8).set(L0,V8)),D?.({id:w0.id,artboardId:Y?.artboardId??null,index:w0.index,prop:"display",value:V8?"none":null}),!K||!w0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V8?{canvas:K,id:w0.id,property:"display",value:"none"}:{canvas:K,id:w0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:w0.id,key:"display",before:d0?"none":null,after:V8?"none":null})},Z8=Array.isArray(J)?J[0]:J,z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let w0=kB0(Z8);return w0?{asset:w0,kind:"artboard-img"}:null})(),f0=z0?.kind==="annotation-image",L8=(w0)=>{if(!(w0.metaKey||w0.ctrlKey)||w0.altKey)return;let L0=w0.key.toLowerCase();if(L0==="z")w0.preventDefault(),a?.(w0.shiftKey?"redo":"undo");else if(L0==="y")w0.preventDefault(),a?.("redo")},n8=f0?"photo":K0==="photo"&&!z0?"inspect":K0,k8=(w0,L0,d0)=>O("button",{type:"button",className:"st-rp-tab"+(n8===w0?" is-active":""),onClick:()=>u0(w0),children:[z(E9,{name:d0,size:14}),L0]}),q8=Z8?.bounds||null;return O("aside",{className:"st-rpanel"+(n?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[O("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[f0?k8("photo","Photo","image"):O(G0,{children:[k8("inspect","Inspect","sliders"),!U0&&k8("layers","Layers","layers"),k8("css","CSS","code"),z0?k8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(E9,{name:"x",size:14})})]}),Z8?.id&&!(Array.isArray(J)&&J.length>1)&&y?O("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(Z8.id,Z8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:n8==="photo"&&z0?z("div",{onKeyDown:L8,children:z(_h,{asset:z0.asset,ColorPicker:u00,StIcon:E9,onEdit:(w0)=>p?.(z0.asset,w0),onRemoveBackground:v,onRecordEdit:(w0,L0)=>r?.(z0.asset,w0,L0)},`${z0.asset}:${m??0}`)}):!Z8&&!(n8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:O("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):Z8&&n8==="inspect"?O(G0,{children:[z("div",{className:"st-rp-hd",children:Z8.selector||Z8.tag||"element"}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z8.tag||"—"})})]}),Z8.classes?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z8.classes})})]}):null,z(EB0,{el:Z8})]}):n8==="layers"?O(G0,{children:[O("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?O(G0,{children:[A8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:i0,onKeyDown:P9,children:Y.nodes.map((w0,L0)=>z(l00,{node:w0,depth:0,selectedId:Z8?.id,selectedIndex:Z8?.index,collapsed:Q8,hiddenOverride:_8,onToggle:I0,onSelect:(d0)=>{U?.(d0),i0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:T8,onReorder:A8,onRowPointerDown:j0,dragState:P0,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${w0.id}:${w0.index}`))}),P0?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:P0.target.left,top:P0.target.y-1,width:P0.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:F8})]}):Z8&&Array.isArray(Z8.dom_path)&&Z8.dom_path.length?Z8.dom_path.map((w0,L0)=>O("div",{className:"st-layer"+(L0===Z8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+L0*12},children:[z(E9,{name:"square",size:13}),w0]},L0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z8.id&&p00(Z8)?z(TB0,{el:Z8,cfg:F,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(DB0,{el:Z8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:o,onSetMode:Z0})})]})}function $B0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),M=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let q0=m8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),f=u.useRef(!1),h=u.useRef(null),[d,n]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[v,r]=u.useState(!1),[a,c]=u.useState(null),[U0,o]=u.useState(null),[Z0,e]=u.useState(null),[N0,K0]=u.useState(null),[u0,Q8]=u.useState(null),[o0,_8]=u.useState(!1),[A0,r0]=u.useState(!1),[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),[W8,A8]=u.useState(null),[i8,P9]=u.useState(null),l0=u.useRef(null),i0=N00("maude-sb-w",{min:200,max:420,def:252}),j0=N00("maude-rp-w",{min:260,max:480,def:304}),[I0,T8]=u.useState(null),Z8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(t)=>{let W0=Z8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")i0.setW(t.clientX-W0.left);else j0.setW(W0.right-t.clientX)},b=()=>T8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,i0.setW,j0.setW]);let z0=u.useCallback((j)=>{clearTimeout(l0.current),l0.current=setTimeout(()=>{P9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>P9(null),15000);return()=>clearTimeout(j)},[i8]);let[f0,L8]=u.useState({designRel:".design",cloud:void 0}),n8=!!f0.cloud,k8=!f0.cloud&&!!Z0?.credentialed,q8=n8||k8,w0=q8?0:N0?.files?.length||0,L0=u.useRef(q8);L0.current=q8;let d0=!!f0.readOnly,V8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");L8((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{V8()},[V8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;o(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(q8){K0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)K0(b)}).catch(()=>{}),()=>{j=!0}},[q8]);let[O8,a8]=u.useState({}),[E8,N9]=u.useState(null),[Y9,e7]=u.useState(!1),[E0,h8]=u.useState("open"),[F9,b9]=u.useState(D20),[l7,c6]=u.useState(()=>{return JT(Y00,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Y00,JSON.stringify(l7))}catch{}},[l7]);let[p8,H7]=u.useState(null),[z7,P7]=u.useState(()=>XH(W00,!0)),[T9,S6]=u.useState(()=>XH(J00,!1)),[X0,_0]=u.useState(()=>JT(Q00,{})),[B0,S0]=u.useState(!1),[t0,j8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=mf(()=>j8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[g8,t8]=u.useState(!1),[G9,w9]=u.useState(!1),[F7,g9]=u.useState(!1),[L7,mX]=u.useState(!1),[mQ,uQ]=u.useState(!1),{report:ZQ}=vA(W9()),[HQ,k9]=u.useState(!1),[X6,lQ]=u.useState(!1),[D7,A6]=u.useState(null),[EX,A5]=u.useState(!1),[j7,KX]=u.useState(!1),[PX,v7]=u.useState(!1),[r4,H6]=u.useState(!1),[C9,RX]=u.useState(()=>JT(z00,$K)),[I9,l9]=u.useState(()=>{try{let j=localStorage.getItem(K00);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[i6,zQ]=u.useState(!1),[J6,vJ]=u.useState([]),[HJ,TX]=u.useState(0),[w5,uX]=u.useState(!1),[E5,a4]=u.useState(!1),[i,Q0]=u.useState(!1),[D0,v0]=u.useState(1),[T0,H8]=u.useState(216),[Y8,V9]=u.useState(null),[s8,o6]=u.useState([]),[lX,b6]=u.useState([]),[P5,pQ]=u.useState([]),[R5,s4]=u.useState(0),T5=u.useRef(0);u.useEffect(()=>{T5.current=HJ},[HJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let f7=u.useMemo(()=>lA(J6,{artboardId:[o9,Y8],total:R5}),[J6,o9,Y8,R5]),P8=u.useRef(null);u.useEffect(()=>{P8.current=f7},[f7]);let y9=u.useMemo(()=>GK(J6,f7)?.fps||30,[J6,f7]),[j9,pX]=u.useState(null),[VX,dW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))l8("Timeline changed — reloaded, try again."),dW((t)=>t+1);else l8(`${j}: ${b||"failed"}`)},[]),[zJ,I5]=u.useState(!1),[jK,t4]=u.useState(!1),[vK,KJ]=u.useState(!1),cW=u.useRef(zJ);u.useEffect(()=>{if(cW.current=zJ,zJ){KJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[zJ]);let QH=u.useCallback(()=>{if(!cW.current||document.hidden)KJ(!0),V00("Claude finished","Your assistant turn is ready in Maude.")},[]),xJ=u.useRef(0),e4=u.useCallback(()=>{if(!cW.current||document.hidden){KJ(!0);let j=Date.now();if(j-xJ.current<N20)return;xJ.current=j,V00("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[k5,KQ]=u.useState("inspect"),[fK,XY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[xK,hK]=u.useState(0),[gJ,iW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),YH=u.useRef(gJ);u.useEffect(()=>{YH.current=gJ;try{localStorage.setItem("maude-auto-open-inspector",gJ?"1":"0")}catch{}},[gJ]);let WH=u.useRef(!1);u.useEffect(()=>{WH.current=PX||Y9||o0||A0||zJ},[PX,Y9,o0,A0,zJ]);let oW=u.useRef({open:{},side:$K});oW.current={open:{tree:z7,layers:r4,inspector:PX,comments:Y9,changes:o0,sync:A0,assistant:zJ},side:C9};let dQ=u.useCallback((j,b)=>{if(j==="tree")P7(b);else if(j==="layers")H6(b);else if(j==="inspector")v7(b);else if(j==="comments")e7(b);else if(j==="changes")_8(b);else if(j==="sync")r0(b);else if(j==="assistant")I5(b)},[]),nW=u.useCallback((j)=>oW.current.side?.[j]||$K[j],[]),IX=u.useCallback((j)=>{let b=nW(j);dQ(j,!0);for(let t of GT)if(t.id!==j&&nW(t.id)===b)dQ(t.id,!1)},[dQ,nW]),C5=u.useCallback((j)=>{if(oW.current.open?.[j])dQ(j,!1);else IX(j)},[IX,dQ]),mJ=IX,z6=C5,cQ=u.useCallback((j)=>{if(!YH.current)return;if(d0)return;if(!j||!j.id)return;if(WH.current)return;mJ("inspector"),KQ("css")},[mJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=mh(HT),JY=Ph({enabled:f0.cloud===null||f0.exportLane==="remote"}),[QY,rW]=u.useState(!1),[dX,GH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return df().then((b)=>{if(!j)return;if(rW(!!b),!b&&!XH(X00,!1))GH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let YY=u.useCallback(()=>{GH(!1);try{localStorage.setItem(X00,"1")}catch{}},[]),[gK,ZH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return rf((b)=>ZH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,HH]=u.useState(null),[$5,aW]=u.useState(()=>!XH(ee,!1)),S5=u.useCallback((j)=>{HH(Array.isArray(j)&&j.length?j:null)},[]),mK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)mJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)mJ("changes")}},sW=u.useCallback(()=>{aW(!1);try{localStorage.setItem(ee,"1")}catch{}},[]),[BQ,zH]=u.useState(()=>XH(H00,!0)),[KH,uK]=u.useState(!1),[uJ,UH]=u.useState(()=>XH(G00,!1)),[j6,qX]=u.useState(()=>XH(Z00,!1)),[n6,tW]=u.useState(!1),[lK,lJ]=u.useState(!1),[iQ,NQ]=u.useState(0),[oQ,eW]=u.useState(null),[XG,WY]=u.useState(!1),nQ=u.useRef(null),GY=u.useRef(null),m8=u.useRef(new Map),S8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),ZY=u.useRef(0),cX=u.useCallback(({format:j,artboardIds:b=null,scale:t=1,onProgress:W0,timeoutMs:F0=120000})=>new Promise((q0,k0)=>{let l=Z?m8.current.get(Z):null;if(!l||!l.contentWindow){k0(Error("no active canvas to capture"));return}let M0=l.contentWindow;ZY.current+=1;let O0=`cap-${Date.now().toString(36)}-${ZY.current}`,c0=!1,z8=(M9,k7)=>{if(c0)return;c0=!0,window.removeEventListener("message",B8),clearTimeout(Q6),M9(k7)},B8=(M9)=>{if(M9.source!==M0)return;let k7=M9.data;if(!k7||k7.id!==O0)return;if(k7.dgn==="export-capture-progress")W0?.(k7.current,k7.total);else if(k7.dgn==="export-capture-done")z8(q0,Array.isArray(k7.items)?k7.items:[]);else if(k7.dgn==="export-capture-error")z8(k0,Error(k7.message||"capture failed"))},Q6=setTimeout(()=>z8(k0,Error("capture timed out — the canvas did not answer")),F0);window.addEventListener("message",B8);try{M0.postMessage({dgn:"export-capture",id:O0,format:j,artboardIds:b,scale:t},"*")}catch(M9){z8(k0,M9)}}),[Z]),H0=u.useCallback((j,b)=>S8({dgn:"photo-preview",asset:j,edit:b}),[S8]),pK=u.useCallback((j,b,t)=>{hJ.current.undo.push({asset:j,before:b,after:t}),hJ.current.redo.length=0},[]),rQ=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let t=b.pop();(j?hJ.current.undo:hJ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return H0(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),hK((F0)=>F0+1),!0},[H0]),JG=u.useCallback(async(j)=>{S8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (te(),se)),F0=await W0(t),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await q0.json().catch(()=>({}));if(q0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{S8({dgn:"photo-busy",asset:j,busy:!1})}},[S8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let R7=u.useRef({});R7.current={open:i6,comps:J6,frame:HJ,total:R5,playing:w5,compId:f7,muted:i,loop:E5,sequences:s8,post:S8,canvas:Z};let O7=u.useRef({undo:[],redo:[]}),T7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(O7.current.undo.push({canvas:j,seq:b,label:t}),O7.current.redo=[],O7.current.undo.length>50)O7.current.undo.shift()},[]),aQ=u.useCallback((j)=>{let b=O7.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=R7.current.canvas,q0=-1;for(let l=t.length-1;l>=0;l--)if(t[l].canvas===F0){q0=l;break}if(q0<0){l8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(t.splice(q0,1),l?.ok)W0.push(k0),l8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else l8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>l8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),w6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),HY=u.useCallback((j)=>{let b=R7.current.canvas;if(!b||b===c8)return;let t=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let q0=w6(F0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),y6("Remove refused",F0.error);else if(F0?.ok){if(l8("Clip removed.",!0),F0.seq!=null)T7(b,F0.seq,"remove clip");pX(null)}}).catch(()=>l8("Remove failed: network error"))},[w6,T7]),FQ=u.useCallback((j,b,t)=>{let W0=R7.current.canvas;if(!W0||W0===c8)return;let F0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(q0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let l=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],M0=j?.transition?l.find((O0)=>O0.kind==="transition"&&O0.stableId===j.stableId)||null:w6(k0,j);if(!M0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:M0.stableId,contentHash:M0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),y6(`${b} refused`,k0.error);else if(k0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(l8(`Applied: ${l[b]||b}.`,!0),k0.seq!=null)T7(W0,k0.seq,l[b]||b)}}).catch(()=>l8(`${b} failed: network error`))},[w6,T7,y6]),[pJ,zY]=u.useState(null),dJ=u.useCallback((j,b="")=>new Promise((t)=>{zY({title:j,value:b,resolve:t})}),[]),a0=u.useCallback((j)=>{zY((b)=>{return b?.resolve?.(j),null})},[]),iX=u.useCallback((j,b)=>{let t=R7.current.canvas;if(!t||t===c8||!b||!String(b).trim())return;I7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),l8("Comment added.",!0)},[]);R7.current.selected=j9,R7.current.setSelected=pX,R7.current.removeClip=HY,R7.current.clipVerb=FQ,R7.current.addComment=iX,R7.current.askText=dJ,u.useEffect(()=>{let j=(b)=>{let t=R7.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let q0=GK(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),l=(O0)=>{let c0=Math.max(0,Math.min(k0-1,Math.round(O0)));TX(c0),uX(!1),t.post({dgn:"timeline-seek",frame:c0,id:t.compId})},M0=()=>{let O0=new Set([0,k0-1]);for(let c0 of t.sequences||[]){O0.add(c0.from);for(let z8 of c0.keyframes||[])O0.add(z8.from),O0.add(z8.to)}return[...O0].filter((c0)=>c0>=0&&c0<k0).sort((c0,z8)=>c0-z8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),aQ(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let O0=t.selected!=null?{stableId:t.selected}:null;if(!O0){let c0=t.sequences||[],z8=c0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||c0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(z8?.stableId)O0={stableId:z8.stableId}}if(O0)t.clipVerb?.(O0,"split",{atFrame:t.frame});else l8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(t.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(t.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l(k0-1);else if(b.key==="."){b.preventDefault();let O0=M0().find((c0)=>c0>t.frame);if(O0!=null)l(O0)}else if(b.key===","){b.preventDefault();let O0=M0().reverse().find((c0)=>c0<t.frame);if(O0!=null)l(O0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{vJ([]),TX(0),uX(!1),pX(null),UX(null);let j=setTimeout(()=>S8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,S8]);let[b5,n0]=u.useState(""),[LQ,s0]=u.useState([]),[QG,KY]=u.useState([]);u.useEffect(()=>{if(!i6||J6.length===0||!Z||Z===c8){n0(""),s0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")n0(b.source)}).catch(()=>{}),()=>{j=!1}},[i6,J6,Z,VX]),u.useEffect(()=>{if(!i6||!Z||Z===c8||!b5){s0([]),KY([]);return}let j=!0,b=o9||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];s0(F0.filter((q0)=>q0.kind==="sequence")),KY(F0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[i6,Z,b5,o9,VX]),u.useEffect(()=>{if(!b5){o6([]),b6([]),pQ([]),s4(0);return}let j=Y8??B?.artboardId??null,t=(j&&J6.find((q0)=>q0.artboardId===j||q0.id===j)||J6[0])?.durationInFrames||0,W0=Nh(b5,t,j);UX(W0.artboardId??j??null);let F0=W0.sequences.map((q0,k0)=>{let l=LQ[k0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});o6(F0),b6(W0.audio||[]),pQ(W0.transitions||[]),s4(W0.total)},[b5,LQ,B,J6,Y8]);let UY=u.useCallback(()=>{zH((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{UH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),sQ=u.useCallback(()=>{tW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{tW(!1),BX({present:!1})},[BX]),YG=u.useCallback(()=>{if(!Z||Z===c8)return;lJ((j)=>{let b=!j;return S8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,S8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)eW(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===c8){NQ(0),lJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(t),lJ(b?.overlays?.print===!0),X4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),lJ(!1),X4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===c8||!Y8)return;let j=setTimeout(()=>{S8({dgn:"request-layers",artboardId:Y8})},250);return()=>clearTimeout(j)},[Z,Y8,S8]);let[eQ,X4]=u.useState(()=>new Set),WG=u.useCallback((j)=>{if(!Z||Z===c8)return;X4((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),S8({dgn:"locked-set",locked:W0}),t})},[Z,S8]);u.useEffect(()=>{if(!Z||Z===c8)return;S8({dgn:"locked-set",locked:[...eQ]})},[eQ,Z,S8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(j00,F9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(W00,z7?"1":"0")}catch{}},[z7]),u.useEffect(()=>{try{localStorage.setItem(J00,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(Q00,JSON.stringify(X0))}catch{}},[X0]),u.useEffect(()=>{try{localStorage.setItem(G00,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(Z00,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(H00,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")b9(b.theme);if(typeof b.minimap==="boolean")UH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")zH(b.annotations);if(typeof b.autoOpenInspector==="boolean")iW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...$K,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")l9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)uK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!KH)return;F20({theme:F9,minimap:uJ,zoom:j6,annotations:BQ,autoOpenInspector:gJ,panelSides:C9,layersMode:I9})},[KH,F9,uJ,j6,BQ,gJ,C9,I9]),u.useEffect(()=>{try{localStorage.setItem(z00,JSON.stringify(C9))}catch{}},[C9]),u.useEffect(()=>{try{localStorage.setItem(K00,I9)}catch{}},[I9]);let GG=u.useCallback((j,b)=>{_0((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),J4=u.useCallback(()=>{b9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:w20(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),L8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let cJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){A8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)A8(await F0.json());return}A8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();a8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");GY.current=W0,W0.addEventListener("open",()=>{r(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{r(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let q0=JSON.parse(F0.data);if(q0.type==="snapshot"&&q0.state)N((k0)=>$00(q0.state.selected,k0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=q0.selected,l=Array.isArray(k0)?k0[0]:k0,M0=F.current,O0=Array.isArray(M0)?M0[0]:M0;if(N((c0)=>$00(k0,c0)),l?.id&&l.file&&(!O0||O0.id!==l.id||O0.file!==l.file))M(l)}else if(q0.type==="comments"&&typeof q0.file==="string")a8((k0)=>({...k0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(WY(!0),nQ.current)clearTimeout(nQ.current);nQ.current=setTimeout(()=>WY(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)JY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)o(q0.payload);else if(q0.type==="canvas-list-update"){if(W7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let k0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${k0}/${q0.payload.fromRel}`,M0=`${k0}/${q0.payload.rel}`;G((O0)=>O0.map((c0)=>c0.path===l?{path:M0}:c0)),H((O0)=>O0===l?M0:O0)}}else if(q0.type==="config-updated")V8();else if(q0.type==="acp-focus"){if(W9())mJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!L0.current)K0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),GY.current)GY.current.close()}},[W7,V8]);function I7(j){let b=GY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)K0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)Q8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),ZG=u.useCallback(async(j,b)=>{let t=await FX("/_api/git/commit",{message:j,files:b});if(t.ok)await NX();return t},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),HG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)K8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),zG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),[KG,UG]=u.useState(null),VG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return null;let W0=await t.json();if(!W0?.ok)return null;return UG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),qG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(q8)return b;for(let t of N0?.files||[])b.set(t.path,j[t.status]);return b},[N0,q8]);u.useEffect(()=>{if(q8){Q8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[q8,N0?.repo,o0,kX]);let K6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),N9(null),U(null),j!==c8)P9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!f0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!GQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;DY.current=!0,K6(j)},[f0.cloud,X,W.length,K6]);let iJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)cJ(b);else if(!W8)cJ();K6(c8)},[W8,cJ,K6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==c8)})},[W]),u.useEffect(()=>{if(Z&&Z!==c8)I7({type:"active",file:Z});else if(Z===c8)I7({type:"active",file:""});else I7({type:"active",file:""})},[Z]);let Q4=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),P9((b)=>b===j?null:b)},[Z]),UJ=u.useCallback(()=>{if(!Z||Z===c8){if(Z===c8)cJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,cJ]),OY=u.useCallback(()=>W7(),[W7]),[BG,MY]=u.useState(!1),Y4=u.useRef(!1),W4=u.useCallback(async()=>{if(Y4.current)return;Y4.current=!0,MY(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{Y4.current=!1,MY(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,OY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[OY]);let NG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),K6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,K6]),_Y=u.useCallback(async()=>{let j=await dJ("New video name");if(!j)return;let t=(await dJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,q0=Math.max(1,Math.min(60,Number(await dJ("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:F0})}),l=await k0.json().catch(()=>({}));if(!k0.ok||!l.ok){l8(`New video failed: ${l.error||`error ${k0.status}`}`);return}await W7(),K6(l.file),zQ(!0),l8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){l8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,K6,dJ]),FG=u.useCallback(async()=>{if(!Z||Z===c8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let M0 of l.querySelectorAll('[data-tool="mediaref"]')){let O0=M0.getAttribute("data-src");if(!O0)continue;t.push({src:O0,mediaKind:M0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${pW(JH(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await q0.json().catch(()=>({}));if(!q0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${q0.status}`}`);return}await W7(),K6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,K6]),G4=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=o9||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let q0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(q0(),!k0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{let O0=b(M0);if(!O0)return l8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return l8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:O0.cdId,attr:"src",value:c0.path})})})}).then((M0)=>M0?M0.json():null).then((M0)=>{if(M0&&!M0.ok)l8(`Replace refused: ${M0.error||"failed"}`);else if(M0&&M0.ok){if(l8("Media replaced.",!0),M0.seq!=null)T7(t,M0.seq,"replace media")}}).catch(()=>l8("Replace failed: network error"))}),F0.click()},[Z,o9,T7]),LG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
5653
+ `).length," lines, paths & secrets scrubbed) —"," ",O("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),O("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),O("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:n,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&O(G0,{children:[P?.issueUrl?O("p",{children:["Thank you — your report is filed as"," ",O("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())nU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):O("p",{children:["The bundle is saved locally",P?.fallbackDir?O(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Done"})})]}),Y==="fallback"&&O(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var GJ=x8(r8(),1);function fh(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 xh(X,J){let Q=fh(X),Y=fh(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 hh(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||xh(Q.version,J)))}function gh(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&xh(Y.version,Q))Q=Y.version}return Q}var Nw="mdcc-whatsnew-seen",Fw="mdcc-whatsnew-toast-dismissed";function YK0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function WK0(X){try{let J=localStorage.getItem(Nw);if(J)return J;localStorage.setItem(Nw,X)}catch{}return X}function GK0(){try{return localStorage.getItem(Fw)}catch{return null}}function mh(X){let[J,Q]=GJ.useState([]),[Y,W]=GJ.useState(X),[G,Z]=GJ.useState(()=>WK0(X)),[H,K]=GJ.useState(()=>GK0()),[U,q]=GJ.useState(!1);GJ.useEffect(()=>{let M=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(M)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{M=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=hh(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=GJ.useCallback(()=>{let M=gh(J,Y);Z(M),K(Y);try{localStorage.setItem(Nw,M),localStorage.setItem(Fw,Y)}catch{}},[J,Y]),_=GJ.useCallback(()=>{K(Y);try{localStorage.setItem(Fw,Y)}catch{}},[Y]),R=GJ.useCallback(()=>q(!0),[]),w=GJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function uh({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return O("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),O("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),O("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function lh({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(GJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:O("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>O("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[O("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),YK0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ee="mdcc-usage-tour-seen",X00="mdcc-collab-tour-seen",c8="__system__",j00="mdcc-theme",J00="mdcc-show-hidden",Q00="mdcc-sections-expanded",Y00="maude-cp-mode",W00="mdcc-sidebar-open",G00="mdcc-minimap-visible",Z00="mdcc-zoomctl-visible",H00="mdcc-annotations-visible";var N20=30000;function F20(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],$K={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},z00="mdcc-panel-sides",K00="mdcc-layers-mode";function U00({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return O("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(GT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,L20=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function ZT(X){for(let[J,Q]of L20)if(J.test(X))return Q;return null}function PF(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HT="1.0.9";function V00(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){y7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function D20(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(j00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function XH(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 JT(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function O20(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function JH(X){return X.split("/").pop()}function l8(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(l8._t),l8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var q00="maude-mode-hint-seen";function M20(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(q00)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select &amp; inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(q00,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function _20(X){return X.replace(GQ,"")}function A20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=_20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function w20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function v00(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=v00(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 wF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function E20(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 f00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function RF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var P20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":O(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:O(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:O(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:O(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:O(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:O(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:O(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:O(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:O(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:O(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:O(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":O(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":O(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":O(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":O(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":O(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":O(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:O(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:O(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:O(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:O(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:O(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:O(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:O(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function R20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:O("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[O("div",{className:"st-pal-search",children:[z(E9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return O(G0,{children:[N,O("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(E9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function E9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:P20[X]})}function T20(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 B00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function N00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function F00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:O("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var QT=[{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}],L00={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},I20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],j3=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],k20="2x",D00=[{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}],C20="auto",$20={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 S20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return $20[J]||"application/octet-stream"}function b20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((v)=>{let r={...v};for(let a of p)r[a.path]=a.kind;return r})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let M=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||M,I=!W?"No artboard on this canvas":M?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((r)=>$(r).then((a)=>({...a,file:r}))));U(!1);let p=m.filter((r)=>r.ok),v=m.length-p.length;if(v>0)B(`${v} of ${m.length} uploads failed`);if(p.length)_((r)=>{let a={...r};for(let c of p)a[c.path]=y(c.file.type);return a}),F((r)=>{let a=new Set(r);for(let c of p)a.add(c.path);return a})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await nf()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:S20(v.name)}));if(U(!1),p.length)await f(p);return}let x=await OZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(W9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)f(p);else C(p[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:O("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[O("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let m=Y&&N.has(x.path);return O("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(E9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&O("div",{className:"st-dialog-ft st-ap-confirm",children:[O("span",{className:"st-ap-count",children:[N.size," selected"]}),O("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function TF(X,J){let Q=URL.createObjectURL(J),Y=document.createElement("a");Y.href=Q,Y.download=X||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function y20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let q=u.useCallback((P0)=>H==="none"&&!P0.handoff&&P0.format!=="zip"&&!wS.has(P0.format)||H!=="local"&&P0.format==="canva",[H]),[B,N]=u.useState(X==="handoff"?"shadcn":"png"),[F,D]=u.useState(()=>J&&FS("png",J)?J:yO("png")),[_,R]=u.useState(2),[w,M]=u.useState(k20),[P,I]=u.useState(!0),[k,$]=u.useState(!1),[C,y]=u.useState(!1),[f,h]=u.useState(!1),[d,n]=u.useState(C20),[x,m]=u.useState(!0),[p,v]=u.useState(!1),[r,a]=u.useState(null),[c,U0]=u.useState([]),o=QT.find((P0)=>P0.id===B)||QT[0],Z0=o.handoff?[]:jO(o.format),e=900,N0=3600,K0=GK(W,lA(W,{artboardId:G})),u0=K0?.durationInFrames||0,Q8=K0?.fps||30,o0=o.temporal&&u0>900,_8=o.temporal&&u0>3600;u.useEffect(()=>{if(Z0.length&&!Z0.includes(F))D(yO(o.format))},[Z0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let A0=u.useCallback(()=>{fetch("/_api/export-history").then((P0)=>P0.json()).then((P0)=>U0(Array.isArray(P0?.history)?P0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{A0()},[A0]),u.useEffect(()=>{function P0(K8){if(K8.key==="Escape")K8.preventDefault(),U()}return window.addEventListener("keydown",P0),()=>window.removeEventListener("keydown",P0)},[U]);async function r0(){if(o.handoff){let D8=`/design:handoff ${Q&&Q!==c8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(D8)}catch{}a({ok:!0,msg:`Copied: ${D8} — run it in Claude Code.`});return}if(q(o)){a({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}v(!0),a(null);let P0=o.temporal?{scale:_}:{};if(o.format==="png"){let F8=j3.find((D8)=>D8.id===w)||j3[1];if(F8.kind==="dpi")P0.dpi=F8.value;else P0.scale=F8.value}if(o.format==="mp4"||o.format==="webm")P0.audio=x;if(_8)P0.maxFrames=u0;if(o.format==="pdf"){P0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let F8=D00.find((D8)=>D8.id===d)?.value;if(F8!==void 0)P0.dpi=F8}if(G)P0.artboardId=G;if(Z?.selector)P0.selection=Z;if(Q&&Q!==c8)P0.canvasFile=Q;if(zU.has(o.format)&&O2({exportLane:H,format:o.format,scope:F,artboardId:P0.artboardId})&&typeof K==="function")try{let F8=mO(P0);a({ok:!0,msg:"Capturing…"});let D8=await K({format:o.format,artboardIds:[P0.artboardId],scale:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`})}),W8=await gO(D8,o.format);for(let A8 of W8)TF(A8.name,A8.blob);for(let A8 of W8)await uO({format:o.format,scope:F,filename:A8.name});v(!1),a({ok:!0,msg:`Saved ${W8.map((A8)=>A8.name).join(", ")} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Capture failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(O2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{a({ok:!0,msg:"Capturing artboards…"});let F8=Q&&Q!==c8?JH(Q).replace(/\.[^.]+$/,""):"export",{filename:D8,blob:W8}=await hO({capture:K,name:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`}),onAssemble:()=>a({ok:!0,msg:"Assembling deck…"})});TF(D8,W8),await uO({format:o.format,scope:F,filename:D8}),v(!1),a({ok:!0,msg:`Saved ${D8} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Deck export failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(H==="none"&&zU.has(o.format)){a({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),v(!1);return}try{let F8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:P0})});if(!F8.ok){a({ok:!1,msg:await F8.text()||`Export failed (${F8.status})`}),v(!1);return}U()}catch(F8){a({ok:!1,msg:F8&&F8.message?F8.message:String(F8)}),v(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(P0)=>{if(P0.target===P0.currentTarget)U()},children:O("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==c8?`Format · ${pW(JH(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:QT.filter((P0)=>!P0.temporal||Y).map((P0)=>O("button",{type:"button","data-testid":`export-format-${P0.id}`,className:"st-fmt"+(P0.id===B?" is-on":""),disabled:q(P0),title:q(P0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(P0.id),a(null)},children:[z(E9,{name:P0.icon,size:16}),z("span",{className:"st-fmt-name",children:P0.label}),z("span",{className:"st-fmt-sub",children:P0.sub})]},P0.id))}),H==="none"&&O("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(P0)=>D(P0.target.value),children:Z0.map((P0)=>z("option",{value:P0,children:L00[P0]},P0))})]}),!o.handoff&&o.format==="png"&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(P0)=>M(P0.target.value),children:j3.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let P0=j3.find((F8)=>F8.id===w)||j3[1],K8=P0.kind==="dpi"?P0.value/96:P0.value;return`${P0.label} ≈ ${Math.round(1440*K8)}×${Math.round(900*K8)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:_,onChange:(P0)=>R(Number(P0.target.value)),children:I20.map((P0)=>z("option",{value:P0.value,children:P0.label},P0.value))})]}),!o.handoff&&o.temporal&&O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[_,"× the artboard's native resolution (e.g. 960×540 → ",960*_,"×",540*_,")."]}),o0&&O("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",u0," frames (≈",Math.round(u0/Q8),"s).",_8?` 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."]}),!o.handoff&&o.format==="pdf"&&O(G0,{children:[O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(P0)=>n(P0.target.value),children:D00.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:P,onChange:(P0)=>I(P0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:O("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((P0)=>!P0),"aria-expanded":k,children:[k?"▾":"▸"," Marks"]})}),k&&O("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(P0)=>y(P0.target.checked)}),"Crop marks"]}),O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(P0)=>h(P0.target.checked)}),"Registration marks"]})]}),O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:x,onChange:(P0)=>m(P0.target.checked)}),"Export with audio"]})}),o.handoff&&O("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),r&&z("div",{className:"callout "+(r.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":r.ok?"1":"0",children:r.msg}),c.length>0&&O("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),c.map((P0,K8)=>O("div",{className:"st-export-recent-row",children:[O("span",{children:[String(P0.format||"").toUpperCase()," ·"," ",L00[P0.scope]||P0.scope]}),z("span",{className:"st-mono",children:P0.filename})]},K8))]})]}),O("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:p,onClick:r0,children:[z(E9,{name:"download",size:14}),o.handoff?"Copy handoff command":p?"Exporting…":`Export ${o.label}`]})]})]})})}var CF=12,$F=16;function j20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=O("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:CF+J*$F+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return O(G0,{children:[Z?O("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):D,H&&Y]})}function v20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return O(G0,{children:[O("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:CF+Q*$F+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),O("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function IF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?ZT(X.name):null,w=!_&&!R,M=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",f=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=O("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:CF+H*$F+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:M}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return O("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${M}…`,"aria-label":`Actions for ${M}`,"aria-haspopup":"menu",onClick:(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${M}`,"aria-label":`Delete canvas ${M}`,onClick:(n)=>{n.stopPropagation(),G(X.path,M)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function f20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[M,P]=u.useState(!1),I=B||M,k=X.path===W;if(!(w&&q))return z(IF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},f=D?.draggedPath===X.path,h=D?.busyPath===X.path,d=C&&typeof _<"u",n=X.path.split("/").slice(0,-1).join("/"),x=O("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(f?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:CF+Q*$F+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(E9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return O(G0,{children:[d?O("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):x,I&&J.map((m)=>z(IF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function x00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:M}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>A20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],n=[];for(let x of $){let m=ZT(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:n).push(x)}return{mediaOrphans:d,metaOrphans:n}},[$]),f=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let n of q)d.set(n.folder,n);return d},[q,Z]);return O(G0,{children:[k.map((d)=>{let n=f&&d.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(f20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:wF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:n,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:M},d.primary.path)}),C.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let n=h?.get(d),x=R?`${R}/${d}`:d,m=z(x00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:M});if(n&&N)return z(v20,{name:d,dsName:n.name,depth:Z,defaultOpen:!0,active:J===c8&&n.name===B,onOpenSystem:N,children:m},d);return z(j20,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:M,children:m},d)})]})}var _F={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function x20(X){if(X.kind==="project")return _F.project;if(X.kind==="runtime")return _F.runtime;if(X.label==="Design system")return _F.ds;if(X.label==="UI kit")return _F.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function h20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:M,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:f,gitBranch:h,remoteSync:d,onGetLatest:n,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:v,syncStatus:r,onLinkedHub:a,savingIsManaged:c=!1}){let U0=u.useMemo(()=>{if(!q)return Q;return Q.map((i0)=>({...i0,tree:v00(i0.tree,q),filtered:!!q}))},[Q,q]),o=TS(m),Z0=PS(),e=u.useMemo(()=>{let i0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;i0.push({path:j0.fullPath,label:I0});for(let T8 of j0.dirs||[])i0.push({path:T8,label:T8.replace(/^\.[^/]+\//,"")})}return i0},[Q]),N0=Z0.state?.extra,K0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>Z0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{Z0.close();let i0=window.prompt("New folder name:");if(i0?.trim())p(N0.dirPath,i0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{Z0.close(),v(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],u0=N0?.kind==="file"?e.filter((i0)=>i0.path!==N0.dir):[],[Q8,o0]=u.useState(!1),[_8,A0]=u.useState("board"),[r0,P0]=u.useState(""),[K8,F8]=u.useState(""),[D8,W8]=u.useState(!1),A8=u.useMemo(()=>Q.find((i0)=>i0.kind==="canvas"&&i0.label!=="Design system")?.fullPath,[Q]),i8=u.useCallback(async()=>{let i0=r0.trim();if(!i0||D8)return;if(W8(!0),F8(""),_8==="folder"){if(!A8){W8(!1),F8("no canvas group to create a folder in");return}let I0=await p(A8,i0);if(W8(!1),I0?.ok)o0(!1),P0("");else F8(I0?.error||"could not create folder");return}let j0=await R(i0);if(W8(!1),j0?.ok)o0(!1),P0("");else F8(j0?.error||"could not create board")},[r0,D8,R,p,_8,A8]),P9=u.useMemo(()=>{let i0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[Q]),l0=u.useMemo(()=>{let i0=0;for(let j0 of U0)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[U0]);return O("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[O("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),O("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":Q8&&_8==="board",onClick:()=>{F8(""),A0("board"),o0((i0)=>_8==="board"?!i0:!0)},children:z(E9,{name:"plus",size:15})}),!X&&A8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":Q8&&_8==="folder",onClick:()=>{F8(""),A0("folder"),o0((i0)=>_8==="folder"?!i0:!0)},children:z(E9,{name:"folder-plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>M(),children:z(E9,{name:"reload",size:15})}),O("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),l0," / ",P9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(E9,{name:"panel-left",size:15})})]})]}),Q8?O("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:_8==="folder"?"folder name…":"brief board name…",value:r0,maxLength:60,disabled:D8,"aria-label":_8==="folder"?"New folder name":"New brief board name",onChange:(i0)=>P0(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Enter")i0.preventDefault(),i8();else if(i0.key==="Escape")i0.preventDefault(),o0(!1),P0(""),F8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:D8||!r0.trim(),"data-tip":"Create · Enter","aria-label":_8==="folder"?"Create folder":"Create brief board",onClick:i8,children:D8?"…":"↵"})]}):null,K8?z("div",{className:"st-newboard-err",role:"alert",children:K8}):null,z("div",{className:"st-search",children:O("div",{className:"st-search-box",children:[z(E9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(i0)=>B(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Escape")if(i0.preventDefault(),q)B("");else i0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:U0.map((i0)=>{if(!F&&!q&&i0.kind==="runtime")return null;let j0=x20(i0),I0=(i0.paths||[]).filter((d0)=>GQ.test(d0)).length,T8=j0.pill||(j0.pillFromDsCount?String(i0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||i0.paths?.length||0):null),Z8=i0.tree&&Object.keys(i0.tree).length>0,z0=i0.label==="Design system",f0=i0.kind==="project";if(!F&&!q&&f0&&I0===0)return null;let L8=O20(i0),n8=D[i0.label],k8=!!q||(n8===void 0?L8:n8),q8=!z0&&i0.kind==="canvas"&&!X,w0=q8?o.dropProps(i0.fullPath,!0):{},L0=o.overDir===i0.fullPath;return O("div",{className:"st-tree-section",children:[O("button",{type:"button",className:"st-tree-sec-hd"+(L0?" is-drop-target":""),onClick:()=>_(i0.label,L8),"aria-expanded":k8,"aria-dropeffect":q8?"move":void 0,title:k8?"Collapse section":"Expand section",...w0,children:[z(E9,{name:"chevron-right",className:"st-chev"+(k8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),T8&&z("span",{className:"st-pill",children:T8})]}),k8&&(Z8?z(x00,{node:i0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:i0.kind,showHidden:F,search:q,dsFolders:i0.dsFolders,activeDsName:G,onOpenSystem:z0?K:void 0,onDelete:z0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:i0.fullPath,drag:!z0&&i0.kind==="canvas"&&!X?o:void 0,menu:!z0&&i0.kind==="canvas"&&!X?Z0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},i0.label)})}),z(RS,{state:Z0.state,onClose:Z0.close,rootItems:K0,destinations:u0,onPickDestination:(i0)=>m(N0.path,i0)}),!c&&z(Ww,{project:f,liveBranch:h,remoteSync:d,onGetLatest:n}),J===null?z(kA,{syncStatus:r,onLinkedHub:a}):null,z($A,{})]})}function g20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:O("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(E9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(E9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(E9,{name:"folder",size:15})})]})})}function m20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),O("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HT]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[O("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),O("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),O("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),O("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),O("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),O("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),O("details",{children:[z("summary",{children:"Annotation tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),O("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),O("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),O("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),O("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),O("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),O("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),O("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),O("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),O("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),O("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),O("details",{children:[z("summary",{children:"Canvas & panels"}),O("ul",{children:[O("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),O("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),O("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),O("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),O("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),O("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),O("details",{children:[z("summary",{children:"Slash commands"}),O("ul",{className:"cmds",children:[O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),O("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),O("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),O("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),O("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),O("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),O("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),O("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),O("details",{children:[z("summary",{children:"Opt-out scope"}),O("ul",{children:[O("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),O("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),O("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),O("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),O("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),O("details",{children:[z("summary",{children:"Auto-critic loop"}),O("ul",{children:[O("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),O("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),O("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),O("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),O("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),O("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),O("details",{children:[z("summary",{children:"Pin-to-element flow"}),O("ol",{children:[z("li",{children:"Open a canvas"}),O("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),O("li",{children:["Run"," ",O("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),O("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),O("details",{children:[z("summary",{children:"Comments"}),O("ol",{children:[O("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),O("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),O("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var YT=[{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 u20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return O("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>O(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function l20({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=YT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[O("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),O("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:YT.map((Y)=>O("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>O("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(u20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),O("div",{className:"so-overlay-ft",children:[O("span",{children:["close with ",z(wX,{children:"Esc"})]}),O("span",{className:"so-count",children:[Q," bindings · ",YT.length," groups"]})]})]})})}var p20=["File","Edit","View","Selection","Tools","Help"];function h00(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 d20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return h00(Q),O("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(E9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function yK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return h00(G),O("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):O("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:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function c20({onAction:X,onClose:J}){return z(yK,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function i20({onAction:X,onClose:J,readOnly:Q=!1}){return z(yK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function o20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(yK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function n20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(yK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function r20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(yK,{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 a20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:M,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:f,onToggleZoomCtl:h,presentMode:d,onTogglePresent:n,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:v,onOpenReadiness:r,onOpenQuickSetup:a,onWatchIntro:c,whatsNewCount:U0,exportCenter:o,artboardCount:Z0=0,presence:e=null,inspectorOpen:N0,inspectorTab:K0,onToggleInspector:u0,autoOpenInspector:Q8,onToggleAutoOpenInspector:o0,onOpenLayers:_8,timelineOpen:A0,onToggleTimeline:r0,hasComps:P0=!1,assistantOpen:K8,onToggleAssistant:F8,assistantBusy:D8,assistantUnseen:W8,onNewCanvas:A8,onAssembleVideo:i8,onOpenExport:P9,onOpenSettings:l0,onOpenGenerate:i0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:T8,readOnly:Z8=!1}){let z0=X===c8,f0=z0?"SYSTEM":X?"CANVAS":"IDLE",L8=z0?z("b",{children:"design system"}):X?O(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(JH(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n8=new Set(Q?["autoopen"]:["assistant","autoopen"]),k8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&K0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Q8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:P0?"video":void 0,checked:A0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:K8,disabled:!1}]:Q?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:f,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||z0}].filter((L0)=>!Z8||!n8.has(L0.id)),q8=["file","edit","view","selection","tools","help"];function w0(L0){if(q8.includes(L0))G(W===L0?null:L0)}return u.useEffect(()=>{if(!W||!q8.includes(W))return;let L0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(V8){let O8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!O8.length)return;let a8=O8.indexOf(document.activeElement);if(V8.key==="ArrowDown")V8.preventDefault(),O8[(a8+1)%O8.length].focus();else if(V8.key==="ArrowUp")V8.preventDefault(),O8[(a8-1+O8.length)%O8.length].focus();else if(V8.key==="Home")V8.preventDefault(),O8[0].focus();else if(V8.key==="End")V8.preventDefault(),O8[O8.length-1].focus();else if(V8.key==="ArrowRight"||V8.key==="ArrowLeft"){V8.preventDefault();let E8=V8.key==="ArrowRight"?1:-1,N9=q8.indexOf(W);G(q8[(N9+E8+q8.length)%q8.length])}else if(V8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(L0),window.removeEventListener("keydown",d0)}},[W,G]),O("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[O("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?O("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:p20.map((L0)=>{let d0=L0.toLowerCase(),V8=q8.includes(d0),O8=V8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":V8?"menu":void 0,"aria-expanded":V8?W===d0:void 0,onClick:()=>w0(d0),onMouseEnter:()=>{if(W!==null&&V8)G(d0)},children:L0},d0)})}),W==="file"&&z(n20,{readOnly:Z8,hasCanvas:!!X,onAction:(L0)=>{if(L0==="new")A8?.();else if(L0==="assemble")i8?.();else if(L0==="export")P9?.("export");else if(L0==="handoff")P9?.("handoff");else if(L0==="generate")i0?.();else if(L0==="settings")l0?.();else if(L0==="reload")j0?.();else if(L0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z(r20,{readOnly:Z8,hasCanvas:!!X&&!z0,onAction:(L0)=>{if(L0==="undo")p({dgn:"undo"});else if(L0==="redo")p({dgn:"redo"});else if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(L0.startsWith("new-artboard:"))T8?.(L0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(d20,{panels:k8,onToggle:(L0)=>{if(L0==="tree")F();else if(L0==="changes")q();else if(L0==="comments")H();else if(L0==="hidden")_();else if(L0==="annotate")$();else if(L0==="inspector")u0();else if(L0==="autoopen")o0?.();else if(L0==="timeline")r0?.();else if(L0==="assistant")F8?.();else if(L0==="layers")_8?.();else if(L0==="minimap")y?.();else if(L0==="zoomctl")h?.();else if(L0==="present")n?.();else if(L0==="print-guides")m?.()},onZoom:(L0)=>p({dgn:"zoom",op:L0}),hasCanvas:!!X&&!z0,onClose:()=>G(null)}),W==="selection"&&z(i20,{readOnly:Z8,onAction:(L0)=>{if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(o20,{readOnly:Z8,onAction:(L0)=>p({dgn:"tool-set",tool:L0}),onClose:()=>G(null)}),W==="help"&&z(c20,{onAction:(L0)=>{if(L0==="shortcuts")w?.();else if(L0==="help")R?.();else if(L0==="report-bug")M?.();else if(L0==="tour")P?.();else if(L0==="collab-tour")I?.();else if(L0==="quick-setup")a?.();else if(L0==="readiness")r?.();else if(L0==="whatsnew")v?.();else if(L0==="watch-intro")c?.()},onClose:()=>G(null)}),O("div",{className:"st-mb-right","data-tour":"status",children:[e?z("div",{className:"st-presence",children:e}):null,Z8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?O("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!Z8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":K8?"true":"false","data-busy":D8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${D8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:F8,children:z(E9,{name:"sparkle",size:15})}),o&&z(Ch,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:M,children:z(E9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:v,children:z(E9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:f0}),z("span",{className:"st-mb-file",title:X||"",children:L8}),z("span",{className:"st-mb-sep"}),O("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),Z0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function s20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),O("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${sB(JH(N))}`,tabIndex:0,children:z(mx,{path:N,kind:ZT(JH(N))})}),X.length===0&&!N&&O("div",{className:"st-empty",children:[O("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),O("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),O("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?O(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===c8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(GB0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Iz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:O("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var t20=["color","space","radius","shadow","leading","weight","motion","font","other"],e20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function XB0(X){return X==="color"}function JB0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return O("section",{className:"sv-section sv-section-tokens",children:[O("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:O("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...t20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=XB0(G);return O("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[O("h2",{children:["tokens · ",e20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>O("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,O("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function QB0(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 YB0(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 WB0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=YB0(X?.font);return O("section",{className:"sv-section sv-section-type",children:[O("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=QB0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return O("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function GB0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return O("div",{className:"sv",children:[O("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?O("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(JB0,{tokens:H,tokenGroups:K,tokensPath:U}),z(WB0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:O("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):O(G0,{children:[z(O00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(O00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function O00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return O("section",{className:"sv-section",children:[O("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>O("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Iz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),O("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function ZB0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===c8,M=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Tz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&O(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return O("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[O("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&O("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:M}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),O("span",{className:"val",children:[Y," open"]})]}),_&&O("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:O("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),O("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(E9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function HB0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=f00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((M)=>{if(J==="open")return M.status!=="resolved";if(J==="resolved")return M.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((M)=>M.selector);F.push({file:D,comments:R.map((M)=>({...M,n:w.findIndex((P)=>P.id===M.id)+1}))})}return O("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:O("div",{className:"st-cm-filters",role:"tablist",children:[O("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),O("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),O("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?O("div",{className:"st-rp-empty",children:[O("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),O("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>O(G0,{children:[O("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(JH(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>O("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[O("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:E20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),O("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?O("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(E9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(E9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(E9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var zB0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function KB0({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=zB0[J];if(!Z)return null;return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function UB0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),O("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),af().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function VB0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return O("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var qB0=["block","inline-block","flex","inline-flex","grid","inline","none"],M00=["px","%","fr","em","auto","min-content","max-content"];var BB0=["auto","stretch","flex-start","center","flex-end","baseline"];var _00=["300","400","500","600","700","800"],A00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],w00=["none","solid","dashed","dotted","double"],E00=["px","rem","em","%","vw","vh","auto"],P00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WT={"font-size":{node:z(Y7,{as:WV,size:12})},"line-height":{node:z(Y7,{as:VV,size:12})},"letter-spacing":{node:z(Y7,{as:_V,size:12})},gap:{node:z(Y7,{as:YK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:RV,size:12})},"border-width":{node:z(Y7,{as:MV,size:12})}};var R00=["static","relative","absolute","fixed","sticky"],NB0=["normal","italic","oblique"],T00=["none","uppercase","lowercase","capitalize"];var I00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],FB0=["fill","contain","cover","none","scale-down"];var k00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],C00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],_5={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}},SK=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!SK)SK=document.createElement("canvas").getContext("2d");if(!SK)return"";SK.fillStyle="#000000",SK.fillStyle=X;let J=SK.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 n4=(X)=>Math.min(1,Math.max(0,X));function AF(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 v3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function f3({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 bK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function gQ(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 $00(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 g00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function LB0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function m00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...LB0(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function u00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>f3(AF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(f3(AF(X)))},[X]);let U=v3(bK(Y)),q=(M)=>{M.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:n4((C.clientX-P.left)/P.width),v:n4(1-(C.clientY-P.top)/P.height)})};k(M);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(v3(bK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(M)=>{M.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:n4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(M);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(v3(bK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(M)=>{let P={...G.current,...M};W(P),Q(v3(bK(P)))},F=(M)=>{let P=M.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[M.key];if(!k)return;M.preventDefault(),N({s:n4(G.current.s+k[0]),v:n4(G.current.v+k[1])})},D=(M)=>{let P=M.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[M.key];if(k==null)return;M.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let M=window.EyeDropper;if(!M)return;let P=await new M().open();if(P?.sRGBHex)W(f3(AF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=bK(Y),w=(M)=>{let P={...R,...M},I=f3({r:n4(P.r/255)*255,g:n4(P.g/255)*255,b:n4(P.b/255)*255});W(I),Q(v3(bK(I)))};return O("div",{className:"st-cp-cpick",children:[O("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(M)=>{let P=M.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(f3(AF(P)))},onKeyDown:(M)=>{if(M.key==="Enter")Q(M.currentTarget.value)},onBlur:(M)=>Q(M.currentTarget.value),onFocus:(M)=>M.currentTarget.select()})]}),O("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),O("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(E9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((M)=>O("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":M.toUpperCase(),value:Math.round(R[M]),onChange:(P)=>w({[M]:n4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:M.toUpperCase()})]},M))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),M=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(a)=>Q===`var(${a})`,k=(a)=>a.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((a,c)=>a+(c.names?.length||0),0),y=$.length>1,f=_.trim().toLowerCase(),h=!f?$:$.map((a)=>({...a,names:(a.names||[]).filter((c)=>k(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(a.vals?.[c]||"").toLowerCase().includes(f))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){R("");return}let a=()=>{let Z0=w.current?.getBoundingClientRect();if(!Z0)return;let e=224,N0=300,K0=Math.min(Z0.right-e,window.innerWidth-e-8);if(K0<8)K0=8;let Q8=window.innerHeight-Z0.bottom>N0+8?Z0.bottom+4:Math.max(8,Z0.top-N0-4);N({left:K0,top:Q8,width:e,maxHeight:N0})};a();let c=(Z0)=>{if(M.current?.contains(Z0.target)||w.current?.contains(Z0.target))return;q(!1)},U0=(Z0)=>{if(Z0.key==="Escape")q(!1)},o=(Z0)=>{if(M.current?.contains(Z0.target))return;a()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",a),document.removeEventListener("scroll",o,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!M.current)return;let a=M.current.getBoundingClientRect(),c=B.left-a.left,U0=B.top-a.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((o)=>o?{...o,left:o.left+c,top:o.top+U0}:o)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(a,c,U0)=>{if(H&&a&&a!==H&&U0&&!d.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(a)=>{let c=(a||"").trim();if(c)Y(c)},m=O("div",{className:"st-cp-pop-search",children:[z(E9,{name:"search",size:12}),z("input",{value:_,onChange:(a)=>R(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),v=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return O(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?b00.createPortal(z("div",{ref:M,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?O(G0,{children:[O("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(u00,{seed:Z||kF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):O(G0,{children:[m,h.length?p(h):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):O(G0,{children:[m,h.length?v(h):r]})}),document.body):null]})}function S00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?ZU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return O("div",{className:"st-cp-gridtracks",children:[O("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?O("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=ZU.has(K.unit);return O("div",{className:"st-cp-gridtrack-row",children:[q?z(IW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:M00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(QN,{value:K.unit,units:M00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function DB0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(X0,_0)=>{let B0={...X0||{}};for(let[S0,t0]of Object.entries(_0))if(t0===null)delete B0[S0];else B0[S0]=t0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(X0,_0)=>B((B0)=>({...B0,a:{...B0.a,[X0]:_0}})),w=(X0,_0)=>B((B0)=>({...B0,c:{...B0.c,[X0]:_0}})),M=(X0,_0)=>B((B0)=>({...B0,t:{...B0.t,[X0]:_0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=g00(X.file,J),k=m00(J,P,I),$=(X0)=>k.map((_0)=>({ds:_0.name,names:_0[X0]||[],vals:_0.vals})).filter((_0)=>_0.names.length),[C,y]=u.useState({}),[f,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)h((X0)=>X0.Advanced?X0:{...X0,Advanced:!0})},[X.id,d]);let n=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(n)h((X0)=>X0["d:Position"]?X0:{...X0,"d:Position":!0})},[X.id,n]);let x=H,[m,p]=u.useState({});async function v(X0,_0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(X0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0)}),t0=await S0.json().catch(()=>({}));y((j8)=>({...j8,[B0]:!S0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((t0)=>({...t0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let r=(X0,_0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:X0,value:_0})},a=(X0,_0,B0,S0)=>{Y?.({op:X0,canvas:X.file,id:X.id,key:_0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(X0,_0)=>{let B0=(_0||"").trim();if(!K||!B0)return;let S0=F[X0]??null;if(B0===(S0??"").trim())return;r(X0,B0),R(X0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,value:B0},X0),a("css",X0,S0,B0)},U0=(X0,_0)=>{let B0=(_0||"").trim(),S0=X0.trim();if(!K||!S0||!B0)return;let t0=D[S0]??null;r(S0,B0),w(S0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),a("css",S0,t0,B0)},o=(X0,_0)=>{let B0=(X0||"").trim(),S0=(_0||"").trim();if(!K||!B0||!S0)return;let t0=_[B0]??null;M(B0,S0),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),a("attr",B0,t0,S0)},Z0=(X0)=>{if(!K)return;let _0=F[X0]??null;r(X0,null),R(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},e=(X0)=>{if(!K)return;let _0=D[X0]??null;r(X0,null),w(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},N0=(X0)=>{if(!K)return;let _0=_[X0]??null;M(X0,null),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:X0,reset:!0},`@${X0}`),a("attr",X0,_0,null)},K0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},u0=(X0,_0)=>{if(!K)return;let B0=Math.round((X0==="width"?X.bounds?.w:X.bounds?.h)||0),S0=_S(X0,_0,K0,B0);for(let t0 of S0.reset)if(F[t0])Z0(t0);for(let[t0,j8]of S0.set)c(t0,j8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(X0)=>{let _0=MS(X0,F,U,K0);return O("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:X0==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${X0} sizing mode`,children:z(YN,{value:_0,ariaLabel:`${X0} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>u0(X0,B0)})})]},`mode-${X0}`)},_8=["flex-start","center","flex-end"],A0=["flex-start","center","flex-end"],r0=["t","c","b"],P0=["l","c","r"],K8=()=>{let X0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),_0=Math.max(0,_8.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),B0=F["align-items"]||Z7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,A0.indexOf(B0)),[t0,j8]=X0?[_0,S0]:[S0,_0];return r0[j8]+P0[t0]},F8=(X0)=>{let _0=r0.indexOf(X0[0]),B0=P0.indexOf(X0[1]),S0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[t0,j8]=S0?[B0,_0]:[_0,B0];c("justify-content",_8[t0]),c("align-items",A0[j8])},D8=(X0)=>{if(!(X0.metaKey||X0.ctrlKey)||X0.altKey)return;let _0=X0.key.toLowerCase();if(_0==="z")X0.preventDefault(),G?.(X0.shiftKey?"redo":"undo");else if(_0==="y")X0.preventDefault(),G?.("redo")},W8=(X0)=>{let _0=F[X0];if(!_0)return"inherit";return/var\(\s*--/.test(_0)?"bound":"raw"};if(!K)return O("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),O("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(X0)=>z("span",{className:`st-cp-prov st-cp-prov--${X0}`,role:"img","aria-label":A8[X0]}),P9=(X0,_0)=>{let B0=_0??W8(X0),S0=C[X0],t0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",j8=t0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",g8=!!F[X0],t8=t0?`error: ${t0}`:g8?`${A8[B0]} · double-click to reset`:A8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${j8}${g8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:g8?0:-1,onDoubleClick:g8?()=>Z0(X0):void 0,onKeyDown:g8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),Z0(X0)}:void 0})},l0=(X0,_0,B0,S0)=>{let t0=B0===void 0&&!F[X0],j8=S0??X0;return O("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[P9(X0,B0),z("label",{className:"st-cp-label",title:j8,children:j8}),z("div",{className:"st-cp-ctl",children:_0})]},X0)},i0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},j0=(X0)=>{(i0[X0]||[]).forEach((_0)=>{if(F[_0])Z0(_0)})},I0=(X0,_0)=>{let B0=(i0[X0]||[]).some((S0)=>F[S0]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[X0],onClick:()=>h((S0)=>({...S0,[X0]:!S0[X0]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[X0]?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${X0} section to original`,title:`reset ${X0}`,disabled:!B0,onClick:()=>j0(X0),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[X0]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},X0)},T8=(X0,_0,B0,S0=!0)=>{let t0=`d:${X0}`,j8=f[t0]===void 0?S0:f[t0],g8=_0.some((t8)=>F[t8]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":j8,onClick:()=>h((t8)=>({...t8,[t0]:!j8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:j8?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${g8?"":" is-quiet"}`,"aria-label":`reset ${X0} to original`,title:`reset ${X0}`,disabled:!g8,onClick:()=>_0.forEach((t8)=>{if(F[t8])Z0(t8)}),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${j8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t0)},Z8=(X0)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[X0],"aria-label":m[X0]?`${X0} — fewer options`:`${X0} — more options`,title:m[X0]?"fewer":"more",onClick:()=>p((_0)=>({..._0,[X0]:!_0[X0]})),children:m[X0]?"▴":"···"}),z0=(X0,_0)=>O("select",{className:"st-cp-nsel","aria-label":X0,value:_0.includes(F[X0])?F[X0]:"",onChange:(B0)=>c(X0,B0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[X0])||"—"}),_0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),f0=(X0)=>$(X0).flatMap((_0)=>(_0.names||[]).map((B0)=>({name:B0,value:_0.vals?.[B0]||""}))),L8=(X0,_0)=>z(mA,{value:F[X0]||Z7(U[X0])||_0[0].value,ariaLabel:X0,options:_0,onChange:(B0)=>c(X0,B0)}),n8=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=F[X0]??"",g8=typeof j8==="string"&&/var\(\s*--/.test(j8),t8=t0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,w9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=WT[X0];return z(WN,{value:g8?j8:w9,tokens:f0(_0),ariaLabel:X0,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:t0?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(g9)=>c(X0,g9==="auto"?"auto":`${S0.n||"0"}${g9}`)}),onChange:(g9)=>c(X0,typeof g9==="string"?g9:t0?`${g9}`:`${g9}${t8}`)})},k8=()=>{let X0=(t0)=>Number.parseFloat(gQ(F[t0]??F["border-radius"]??Z7(U[t0])??Z7(U["border-radius"])??"0").n)||0,_0={tl:X0("border-top-left-radius"),tr:X0("border-top-right-radius"),bl:X0("border-bottom-left-radius"),br:X0("border-bottom-right-radius")},B0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((g8)=>{if(F[g8])Z0(g8)}),c("border-radius",`${t0.tl}px`);else c("border-top-left-radius",`${t0.tl}px`),c("border-top-right-radius",`${t0.tr}px`),c("border-bottom-left-radius",`${t0.bl}px`),c("border-bottom-right-radius",`${t0.br}px`)},S0=WT["border-radius"];return z(ax,{corners:_0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},q8=()=>O("div",{className:"st-cp-border",children:[b9("border-width",null,{fixedUnit:"px"}),O("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:w00.includes(F["border-style"])?F["border-style"]:"",onChange:(X0)=>c("border-style",X0.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),w00.map((X0)=>z("option",{value:X0,children:X0},X0))]}),z(EF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:kF(U["border-color"]||F["border-color"])||"#000000",onPick:(X0)=>c("border-color",X0),label:"border colour"})]}),w0=()=>{let X0=F.transform||Z7(U.transform)||"",_0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(X0),B0=((_0?Number.parseFloat(_0[1]):0)%360+360)%360,S0=(t0)=>{let j8=(t0%360+360)%360,g8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${g8?`${g8} `:""}rotate(${j8}deg)`.trim())};return O("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(nx,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:wZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},L0=()=>{let X0=F.filter||Z7(U.filter)||"",_0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(X0),B0=_0?Number.parseFloat(_0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let j8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",t0>0?`${j8?`${j8} `:""}blur(${t0}px)`.trim():j8||"none")}})},d0=()=>{let X0=F.opacity,_0=X0!=null&&X0!==""?Number.parseFloat(X0):Number.parseFloat(Z7(U.opacity))||1,B0=Math.round((Number.isNaN(_0)?1:_0)*100);return z(TJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>r("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${X0??""}`)},V8=()=>{let X0=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,_0=(F["font-style"]||Z7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(ix,{value:{b:X0,i:_0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:qV}),label:"Bold"},{value:"i",node:z(Y7,{as:DV}),label:"Italic"},{value:"u",node:z(Y7,{as:kV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",X0?"400":"700");else if(S0==="i")c("font-style",_0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},O8=[{value:"row",node:z(Y7,{as:DW}),label:"Row"},{value:"column",node:z(Y7,{as:OW}),label:"Column"}],a8=[{value:"flex-start",node:z(Y7,{as:HV}),label:"Start"},{value:"center",node:z(Y7,{as:GV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:ZV}),label:"End"},{value:"space-between",node:z(Y7,{as:YK}),label:"Space between"}],E8=[{value:"flex-start",node:z(Y7,{as:UV}),label:"Start"},{value:"center",node:z(Y7,{as:zV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:KV}),label:"End"},{value:"stretch",node:z(Y7,{as:TV}),label:"Stretch"}],N9=[{value:"left",node:z(Y7,{as:m5}),label:"Left"},{value:"center",node:z(Y7,{as:AW}),label:"Center"},{value:"right",node:z(Y7,{as:wW}),label:"Right"},{value:"justify",node:z(Y7,{as:EW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:AZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:EZ}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:EV}),label:"Scroll"}],e7=(X0,_0)=>{let B0=$(_0);return B0.length?z(EF,{kind:"value",groups:B0,current:F[X0],activeDs:I,onPick:(S0)=>c(X0,S0),label:`${X0} design token`}):null},E0=(X0)=>{let _0=X0.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===_0)_0.select()})},h8=(X0,_0)=>{if(X0.key!=="ArrowUp"&&X0.key!=="ArrowDown")return!1;X0.preventDefault();let B0=X0.shiftKey?10:1,S0=X0.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(X0.currentTarget.value)||0)+S0*B0;return X0.currentTarget.value=String(t0),_0(t0),!0},F9=(X0)=>z("input",{className:"st-cp-fin","aria-label":X0,defaultValue:F[X0]??"",placeholder:Z7(U[X0])||"—",onFocus:E0,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>c(X0,_0.currentTarget.value)},`${X0}:${F[X0]??""}`),b9=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=t0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),g8=WT[X0],t8=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return O(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:X0,lead:g8?g8.node??g8.t:void 0,onCommit:(w9)=>c(X0,t0?`${w9}`:`${w9}${j8}`),unitSlot:t0||B0.fixedUnit?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(w9)=>c(X0,w9==="auto"?"auto":`${S0.n||"0"}${w9}`)})},`${X0}:${F[X0]??""}`),e7(X0,_0)]})},l7=(X0)=>{let _0=U[X0]||F[X0]||"",B0=F[X0]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),t0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[X0],activeDs:I,swatchBg:_0,seedHex:kF(U[X0]||F[X0])||"#000000",onPick:(j8)=>c(X0,j8),label:`${X0} colour`}),displayValue:t0,bound:S0,ariaLabel:X0,onValue:(j8)=>c(X0,j8)})},c6=(X0,_0)=>{let B0=null,S0=_0.unitless?"":"px",t0=(t8)=>_0.unitless?`${t8}`:`${t8}${S0}`,j8=(t8,G9,w9)=>{for(let F7 of G9??[X0])w9(F7,t0(t8))},g8=gA({getBase:()=>B0?.value??"0",min:_0.min??0,step:1,sides:_0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let w9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===X0)continue;let g9=w9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(g9)g9.value=String(t8)}}j8(t8,G9,r)},onCommit:(t8,G9)=>j8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,g8(t8)}}},p8=(X0,_0)=>{let B0=F[X0],S0=B0!=null&&B0!==""?gQ(B0).n||B0:gQ(Z7(U[X0])??"").n||"0",t0=!B0||B0==="0"||B0==="0px"||B0==="auto",j8=X0.split("-").pop(),g8=j8==="top"||j8==="bottom"?[`${_0}-top`,`${_0}-bottom`]:[`${_0}-left`,`${_0}-right`],t8=[`${_0}-top`,`${_0}-right`,`${_0}-bottom`,`${_0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${_0[0]}${X0.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":X0,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...c6(X0,{sides:{pair:g8,all:t8}}),onFocus:E0,onKeyDown:(G9)=>{if(h8(G9,(w9)=>c(X0,`${w9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let w9=G9.currentTarget.value.trim();if(!w9)return;let F7=/[a-z%]/i.test(w9)?w9:`${w9}px`;c(X0,F7)}},`${X0}:${B0??""}`)},H7=(X0)=>{let _0=F[X0],B0=_0!=null&&_0!==""&&_0!=="auto"?gQ(_0).n||_0:gQ(Z7(U[X0])??"").n||"",S0=!_0||_0==="auto"||_0==="0"||_0==="0px",t0=X0==="top"||X0==="bottom"?["top","bottom"]:["left","right"],j8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${X0[0]}${S0?" is-zero":""}`,"aria-label":X0,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...c6(X0,{sides:{pair:t0,all:j8},min:-1/0}),onFocus:E0,onKeyDown:(g8)=>{if(h8(g8,(t8)=>c(X0,`${t8}px`)))return;if(g8.key==="Enter")g8.currentTarget.blur()},onBlur:(g8)=>{let t8=g8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(X0,G9)}},`${X0}:${_0??""}`)},z7=Object.entries(D),P7=Object.entries(_),T9=()=>{let X0=(X.tag||"").toLowerCase(),B0=X0==="img"||X0==="video"||X0==="picture"||X0==="svg"||X0==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(X0==="img"||X0==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(X0)=>O(G0,{children:[X0&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),l0("object-fit",z0("object-fit",FB0)),l0("object-position",F9("object-position")),l0("aspect-ratio",O("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:C00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(_0)=>{let B0=_0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)Z0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),C00.map((_0)=>z("option",{value:_0,children:_0},_0))]}))]});return O("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:D8,children:[O("div",{className:"st-cp-id",children:[O("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?O("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(mA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:LW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:PW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?O(G0,{children:[T8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let X0=(F.display||Z7(U.display)||"").trim();return X0==="flex"||X0==="inline-flex"?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8),void 0,"Direction"),l0("align-items",z(ox,{value:K8(),onChange:F8,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),l0("gap",n8("gap","space"),void 0,"Gap"),O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),O("div",{className:"st-cp-box","aria-label":"padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Z8("Auto layout")}),m["Auto layout"]?l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),T8("Size",["width","height","min-width","max-width","min-height","max-height"],O(G0,{children:[l0("width",b9("width"),void 0,"Width"),l0("height",b9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Z8("Size")}),m.Size?O(G0,{children:[l0("min-width",b9("min-width"),void 0,"Min width"),l0("max-width",b9("max-width"),void 0,"Max width"),l0("min-height",b9("min-height"),void 0,"Min height"),l0("max-height",b9("max-height"),void 0,"Max height")]}):null]})),T8("Position",["position","top","right","bottom","left","z-index"],O(G0,{children:[l0("position",z0("position",R00),void 0,"Position"),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Z8("Position")}),m.Position?l0("z-index",b9("z-index"),void 0,"Layer order"):null]}),!1),T8("Fill",["background-color"],l0("background-color",l7("background-color"),void 0,"Fill")),T8("Stroke",["border-width","border-style","border-color"],l0("border",q8(),W8("border-width"),"Stroke")),T8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],l0("border-radius",k8(),W8("border-radius"),"Corner radius")),T8("Effects",["box-shadow","filter","mix-blend-mode"],O(G0,{children:[l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),l0("filter",L0(),W8("filter"),"Blur"),l0("mix-blend-mode",z0("mix-blend-mode",k00),void 0,"Blend")]})),T8("Opacity",["opacity"],l0("opacity",d0(),void 0,"Opacity")),T8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],O(G0,{children:[l0("font-family",z0("font-family",A00),void 0,"Font"),l0("color",l7("color"),void 0,"Color"),l0("font-size",n8("font-size","type"),void 0,"Size"),l0("font-weight",z0("font-weight",_00),void 0,"Weight"),l0("line-height",b9("line-height","lh"),void 0,"Line height"),l0("text-align",L8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Z8("Text")}),m.Text?O(G0,{children:[l0("letter-spacing",b9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),l0("font-style",z0("font-style",NB0),void 0,"Style"),l0("text-transform",z0("text-transform",T00),void 0,"Case"),l0("white-space",z0("white-space",I00),void 0,"Whitespace")]}):null]})),T8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],O("div",{className:"st-cp-box","aria-label":"margin",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin")]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?T8("Media",["object-fit","object-position","aspect-ratio"],S6(_0)):null})()]}):O(G0,{children:[I0("Layout",(()=>{let X0=(F.display||Z7(U.display)||"").trim(),_0=X0==="flex"||X0==="inline-flex",B0=X0==="grid"||X0==="inline-grid";return O(G0,{children:[l0("display",z0("display",qB0)),_0?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8)),l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,_0||B0?O(G0,{children:[l0("align-items",L8("align-items",E8)),l0("justify-content",L8("justify-content",a8)),l0("gap",n8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let X0=(F.display||Z7(U.display)||"").trim();if(!(X0==="grid"||X0==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",t0=vO(B0),j8=vO(S0),g8=t0.length>0||!B0.trim(),t8=j8.length>0||!S0.trim();return I0("Grid",O(G0,{children:[g8?z(S00,{label:"Columns",tracks:t0,editable:K,onChange:(G9)=>c("grid-template-columns",fO(G9))}):O("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(S00,{label:"Rows",tracks:j8,editable:K,onChange:(G9)=>c("grid-template-rows",fO(G9))}):O("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",O(G0,{children:[l0("position",z0("position",R00)),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l0("z-index",b9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",O(G0,{children:[O("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),l0("grid-column",F9("grid-column")),l0("grid-row",F9("grid-row"))]})),I0("Typography",O(G0,{children:[l0("font-family",z0("font-family",A00)),l0("color",l7("color")),l0("font-size",n8("font-size","type")),l0("font-weight",z0("font-weight",_00)),l0("line-height",b9("line-height","lh")),l0("letter-spacing",b9("letter-spacing",null,{min:-1/0})),l0("text-align",L8("text-align",N9)),l0("font-style",V8(),W8("font-style")),l0("text-transform",z0("text-transform",T00)),l0("white-space",z0("white-space",I00))]})),I0("Spacing",z(G0,{children:O("div",{className:"st-cp-box","aria-label":"margin and padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin"),O("div",{className:"st-cp-boxpad",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding"),O("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",O(G0,{children:[O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),l0("width",b9("width")),l0("height",b9("height")),l0("min-width",b9("min-width")),l0("max-width",b9("max-width")),l0("min-height",b9("min-height")),l0("max-height",b9("max-height")),l0("overflow",L8("overflow",Y9)),Q8?O(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),l0("align-self",z0("align-self",BB0)),l0("flex-grow",b9("flex-grow",null,{unitless:!0})),l0("flex-shrink",b9("flex-shrink",null,{unitless:!0})),l0("flex-basis",b9("flex-basis"))]}):null]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?I0("Media",S6(_0)):null})(),I0("Appearance",O(G0,{children:[l0("background-color",l7("background-color")),l0("border-radius",k8(),W8("border-radius")),l0("border",q8(),W8("border-width")),l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow")),l0("filter",L0(),W8("filter")),l0("mix-blend-mode",z0("mix-blend-mode",k00)),l0("opacity",d0()),l0("rotation",w0(),W8("transform")),l0("transform",F9("transform")),l0("transform-origin",F9("transform-origin"))]})),(()=>{let X0=Object.entries(C).find(([,_0])=>typeof _0==="string"&&_0.startsWith("err:"));return X0?O("div",{className:"st-cp-save is-err",role:"status",children:[z(E9,{name:"x",size:12}),X0[0],": ",X0[1].slice(4)]}):null})(),I0("Advanced",O("div",{className:"st-cp-advbody",children:[z7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),z7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`custom property ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>U0(X0,B0.currentTarget.value)},`cs:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>e(X0),children:z(E9,{name:"x",size:11})})]},`cs:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(OB0,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`attribute ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>o(X0,B0.currentTarget.value)},`at:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>N0(X0),children:z(E9,{name:"x",size:11})})]},`at:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(MB0,{commit:o})]}))]}),O("div",{className:"st-cp-legend",children:[O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function OB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function MB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var _B0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function AB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var wB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function l00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,M=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[f,h]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(X.dcElement??""))return;R?.(X,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return O(G0,{children:[O("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(n?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...v},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":M?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?M&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(r)=>B(r,X,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),I)M&&Z(w);else H(X);else if(r.key==="F2"&&R&&!I)r.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[M?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(E9,{name:_B0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>h(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:m,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")m();else if(r.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(r)=>{r.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),_(w)},children:z(E9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(X)},children:z(E9,{name:n?"eye-off":"eye",size:13})}):null]}),M&&!P?X.children.map((r,a)=>z(l00,{node:r,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${r.id}:${r.index}`)):null]})}function EB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),O("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?gQ(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 O(G0,{children:[G?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function p00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var PB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],RB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function TB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=p00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=g00(X.file,J),B=m00(J,U,q),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((a)=>({name:a,value:r.vals?.[a]||""}))),D=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let a of B){let c=a.vals?.[r[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(v,r)=>{if(!K)return;let a=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(a==null&&c==null)return;Q?.(K,a,c)},M=Object.entries(_5).find(([,v])=>v.width===_&&v.height===R)?.[0],P=Object.entries(_5).find(([,v])=>v.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!h){let a={paper:"a4"};try{let c=D2(a);if(c)r={defaults:a,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&I)Y?.(K,!1,void 0)},n=(v)=>{if(!K)return;let r={paper:"a4",...h,...v},a;try{a=D2(r)}catch{return}Q?.(K,a.widthPx,a.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let a=Number.isFinite(r)?r:R,c=v&&Number.isFinite(a)?Math.round(a):void 0;Y?.(K,v,c)},m=(v)=>{let r=LS(I,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return O("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),O("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?O("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(v)=>n({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),L2.map((v)=>O("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?O("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${_5[P].label} — ≤ ${_5[P].width}px`:"Breakpoint…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):O("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:M??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:M?_5[M].label:"Preset size…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(IW,{value:f,ariaLabel:"artboard kind",options:RB0.map(([v,r])=>({value:v,label:r})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:O("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,f==="print"?O(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>n({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(h?.bleedMm)?h.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>n({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),O("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=D(k),r=/var\(\s*--/.test(k),a=r?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:v,seedHex:kF(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:a,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(IW,{value:C,ariaLabel:"artboard body layout",options:PB0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),O("div",{style:{display:"flex",gap:8},children:[z(WN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(WN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var zT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,IB0=new RegExp(zT.source,"gi");function kB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(IB0)||[])],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=zT.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function CB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:f,onTabChange:h,width:d,resizing:n,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:a,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:o,onSetCpMode:Z0}){let[e,N0]=u.useState("inspect"),K0=c?"layers":f??e,u0=(w0)=>{N0(w0),h?.(w0)},[Q8,o0]=u.useState(()=>new Set),[_8,A0]=u.useState(()=>new Map);u.useEffect(()=>{let w0=Array.isArray(J)?J[0]:J,L0=w0?.id;if(!L0||!Y?.nodes)return;let d0=w0.index,V8=null,O8=[];if(function a8(E8,N9){for(let Y9 of E8||[]){let e7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===L0&&(d0==null||Y9.index===d0))return V8=e7,O8.push(...N9),!0;if(Y9.children&&Y9.children.length&&a8(Y9.children,[...N9,e7]))return!0}return!1}(Y.nodes,[]),!V8)return;if(O8.length)o0((a8)=>{let E8=!1,N9=new Set(a8);for(let Y9 of O8)if(N9.delete(Y9))E8=!0;return E8?N9:a8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${V8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let r0=(w0)=>{let L0=`${w0.id}:${w0.index}`;return _8.has(L0)?_8.get(L0):!!w0.hidden},[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),W8=(w0,L0)=>{if(!K||!w0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:w0.id,attr:"data-dc-element",value:L0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:w0.id,key:"data-dc-element",before:w0.dcElement??null,after:L0})}).catch(()=>{})},A8=B?(w0,L0,d0)=>{if(N?.current)return;if(w0?.synthetic||L0?.synthetic)return;let V8=d0==="before"?`before ${L0.label}`:d0==="after"?`after ${L0.label}`:`into ${L0.label}`;D8(`Moved ${w0.label} ${V8}`),B(w0.id,L0.id,d0,{idIndex:w0.index,refIndex:L0.index})}:void 0,i8=()=>{let w0=[];return function L0(d0,V8,O8){(d0||[]).forEach((a8,E8)=>{if(w0.push({node:a8,depth:V8,parentNode:O8,siblings:d0,pos:E8}),a8.children&&a8.children.length&&!Q8.has(`${a8.id}:${a8.index}`))L0(a8.children,V8+1,a8)})}(Y?.nodes,0,null),w0},P9=(w0)=>{if(w0.key!=="ArrowUp"&&w0.key!=="ArrowDown")return;if(!Z8)return;let L0=i8(),d0=L0.findIndex((E8)=>E8.node.id===Z8.id&&E8.node.index===Z8.index);if(d0<0)return;let V8=w0.key==="ArrowDown"?1:-1,O8=L0[d0];if(!w0.altKey){let E8=L0[d0+V8];if(E8)w0.preventDefault(),U?.(E8.node);return}if(!A8||!Array.isArray(O8.siblings))return;w0.preventDefault();let a8=(E8)=>E8&&E8.children&&E8.children.length&&!Q8.has(`${E8.id}:${E8.index}`);if(!w0.shiftKey){if(V8<0&&O8.pos>0)A8(O8.node,O8.siblings[O8.pos-1],"before");else if(V8>0&&O8.pos<O8.siblings.length-1)A8(O8.node,O8.siblings[O8.pos+1],"after");return}if(V8>0){let E8=O8.siblings[O8.pos+1];if(E8)A8(O8.node,E8,a8(E8)?"inside-start":"after");else if(O8.parentNode)A8(O8.node,O8.parentNode,"after")}else{let E8=O8.siblings[O8.pos-1];if(E8)A8(O8.node,E8,a8(E8)?"inside-end":"before");else if(O8.parentNode)A8(O8.node,O8.parentNode,"before")}},l0=u.useRef(null),i0=u.useRef(null),j0=(w0,L0,d0)=>{if(!A8||w0.button!==0||w0.metaKey||w0.ctrlKey||w0.shiftKey||w0.altKey)return;if(N?.current)return;let{clientX:V8,clientY:O8}=w0,a8=new Set([d0]);(function p8(H7){(H7.children||[]).forEach((z7)=>{a8.add(`${z7.id}:${z7.index}`),p8(z7)})})(L0);let E8=14,N9=6,Y9=[];(function p8(H7,z7){(H7||[]).forEach((P7)=>{let T9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:T9,id:P7.id,depth:z7,tag:P7.tag}),P7.children&&P7.children.length&&!Q8.has(T9))p8(P7.children,z7+1)})})(Y?.nodes,0);let e7=new Map(Y9.map((p8)=>[p8.key,p8])),E0=!1,h8=(p8)=>{if(!E0){if(Math.hypot(p8.clientX-V8,p8.clientY-O8)<4)return;E0=!0}let H7=p8.clientX-V8,z7=p8.clientY-O8,P7=null,T9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((X0)=>({rect:X0.getBoundingClientRect(),it:e7.get(X0.getAttribute("data-layer-key"))})).filter((X0)=>X0.it&&X0.it.key!==d0);if(T9.length){let X0=T9[0].rect.left,_0=T9[0].rect.right,B0=T9.length;for(let L7=0;L7<T9.length;L7++)if(p8.clientY<T9[L7].rect.top+T9[L7].rect.height/2){B0=L7;break}let S0=T9[B0-1]?.it||null,t0=T9[B0]?.it||null,j8=Math.round((p8.clientX-X0-N9)/E8),g8=S0?S0.depth+(wB0.has(S0.tag)?0:1):0,t8=t0?t0.depth:0,G9=Math.max(t8,Math.min(j8,g8)),w9=null,F7="before",g9=0;if(!S0){if(t0)w9=t0,F7="before",g9=t0.depth}else if(G9>S0.depth)w9=S0,F7="inside-start",g9=S0.depth+1;else if(G9===S0.depth)w9=S0,F7="after",g9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(T9[L7].it.depth===G9){w9=T9[L7].it;break}if(!w9)w9=S0;F7="after",g9=G9}if(w9&&w9.key!==d0&&!a8.has(w9.key)){let L7=S0?T9[B0-1].rect.bottom:T9[0].rect.top,mX=X0+N9+g9*E8;P7={refId:w9.id,position:F7,node:w9.node,y:L7,left:mX,w:Math.max(24,_0-mX)}}}let S6={key:d0,node:L0,dx:H7,dy:z7,target:P7};l0.current=S6,K8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",l7),window.removeEventListener("keydown",c6,!0)},b9=()=>{let p8=(H7)=>{H7.preventDefault(),H7.stopImmediatePropagation(),document.removeEventListener("click",p8,!0)};document.addEventListener("click",p8,!0),setTimeout(()=>document.removeEventListener("click",p8,!0),300)},l7=()=>{F9();let p8=l0.current;if(l0.current=null,K8(null),E0&&p8?.target)b9(),A8(p8.node,p8.target.node,p8.target.position)},c6=(p8)=>{if(p8.key!=="Escape")return;if(p8.preventDefault(),p8.stopImmediatePropagation(),F9(),l0.current=null,K8(null),E0)b9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",l7),window.addEventListener("keydown",c6,!0)},I0=(w0)=>o0((L0)=>{let d0=new Set(L0);if(d0.has(w0))d0.delete(w0);else d0.add(w0);return d0}),T8=(w0)=>{let L0=`${w0.id}:${w0.index}`,d0=r0(w0),V8=!d0;if(A0((O8)=>new Map(O8).set(L0,V8)),D?.({id:w0.id,artboardId:Y?.artboardId??null,index:w0.index,prop:"display",value:V8?"none":null}),!K||!w0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V8?{canvas:K,id:w0.id,property:"display",value:"none"}:{canvas:K,id:w0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:w0.id,key:"display",before:d0?"none":null,after:V8?"none":null})},Z8=Array.isArray(J)?J[0]:J,z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let w0=kB0(Z8);return w0?{asset:w0,kind:"artboard-img"}:null})(),f0=z0?.kind==="annotation-image",L8=(w0)=>{if(!(w0.metaKey||w0.ctrlKey)||w0.altKey)return;let L0=w0.key.toLowerCase();if(L0==="z")w0.preventDefault(),a?.(w0.shiftKey?"redo":"undo");else if(L0==="y")w0.preventDefault(),a?.("redo")},n8=f0?"photo":K0==="photo"&&!z0?"inspect":K0,k8=(w0,L0,d0)=>O("button",{type:"button",className:"st-rp-tab"+(n8===w0?" is-active":""),onClick:()=>u0(w0),children:[z(E9,{name:d0,size:14}),L0]}),q8=Z8?.bounds||null;return O("aside",{className:"st-rpanel"+(n?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[O("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[f0?k8("photo","Photo","image"):O(G0,{children:[k8("inspect","Inspect","sliders"),!U0&&k8("layers","Layers","layers"),k8("css","CSS","code"),z0?k8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(E9,{name:"x",size:14})})]}),Z8?.id&&!(Array.isArray(J)&&J.length>1)&&y?O("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(Z8.id,Z8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:n8==="photo"&&z0?z("div",{onKeyDown:L8,children:z(_h,{asset:z0.asset,ColorPicker:u00,StIcon:E9,onEdit:(w0)=>p?.(z0.asset,w0),onRemoveBackground:v,onRecordEdit:(w0,L0)=>r?.(z0.asset,w0,L0)},`${z0.asset}:${m??0}`)}):!Z8&&!(n8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:O("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):Z8&&n8==="inspect"?O(G0,{children:[z("div",{className:"st-rp-hd",children:Z8.selector||Z8.tag||"element"}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z8.tag||"—"})})]}),Z8.classes?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z8.classes})})]}):null,z(EB0,{el:Z8})]}):n8==="layers"?O(G0,{children:[O("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?O(G0,{children:[A8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:i0,onKeyDown:P9,children:Y.nodes.map((w0,L0)=>z(l00,{node:w0,depth:0,selectedId:Z8?.id,selectedIndex:Z8?.index,collapsed:Q8,hiddenOverride:_8,onToggle:I0,onSelect:(d0)=>{U?.(d0),i0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:T8,onReorder:A8,onRowPointerDown:j0,dragState:P0,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${w0.id}:${w0.index}`))}),P0?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:P0.target.left,top:P0.target.y-1,width:P0.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:F8})]}):Z8&&Array.isArray(Z8.dom_path)&&Z8.dom_path.length?Z8.dom_path.map((w0,L0)=>O("div",{className:"st-layer"+(L0===Z8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+L0*12},children:[z(E9,{name:"square",size:13}),w0]},L0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z8.id&&p00(Z8)?z(TB0,{el:Z8,cfg:F,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(DB0,{el:Z8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:o,onSetMode:Z0})})]})}function $B0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),M=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let q0=m8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),f=u.useRef(!1),h=u.useRef(null),[d,n]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[v,r]=u.useState(!1),[a,c]=u.useState(null),[U0,o]=u.useState(null),[Z0,e]=u.useState(null),[N0,K0]=u.useState(null),[u0,Q8]=u.useState(null),[o0,_8]=u.useState(!1),[A0,r0]=u.useState(!1),[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),[W8,A8]=u.useState(null),[i8,P9]=u.useState(null),l0=u.useRef(null),i0=N00("maude-sb-w",{min:200,max:420,def:252}),j0=N00("maude-rp-w",{min:260,max:480,def:304}),[I0,T8]=u.useState(null),Z8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(t)=>{let W0=Z8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")i0.setW(t.clientX-W0.left);else j0.setW(W0.right-t.clientX)},b=()=>T8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,i0.setW,j0.setW]);let z0=u.useCallback((j)=>{clearTimeout(l0.current),l0.current=setTimeout(()=>{P9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>P9(null),15000);return()=>clearTimeout(j)},[i8]);let[f0,L8]=u.useState({designRel:".design",cloud:void 0}),n8=!!f0.cloud,k8=!f0.cloud&&!!Z0?.credentialed,q8=n8||k8,w0=q8?0:N0?.files?.length||0,L0=u.useRef(q8);L0.current=q8;let d0=!!f0.readOnly,V8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");L8((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{V8()},[V8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;o(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(q8){K0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)K0(b)}).catch(()=>{}),()=>{j=!0}},[q8]);let[O8,a8]=u.useState({}),[E8,N9]=u.useState(null),[Y9,e7]=u.useState(!1),[E0,h8]=u.useState("open"),[F9,b9]=u.useState(D20),[l7,c6]=u.useState(()=>{return JT(Y00,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Y00,JSON.stringify(l7))}catch{}},[l7]);let[p8,H7]=u.useState(null),[z7,P7]=u.useState(()=>XH(W00,!0)),[T9,S6]=u.useState(()=>XH(J00,!1)),[X0,_0]=u.useState(()=>JT(Q00,{})),[B0,S0]=u.useState(!1),[t0,j8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=mf(()=>j8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[g8,t8]=u.useState(!1),[G9,w9]=u.useState(!1),[F7,g9]=u.useState(!1),[L7,mX]=u.useState(!1),[mQ,uQ]=u.useState(!1),{report:ZQ}=vA(W9()),[HQ,k9]=u.useState(!1),[X6,lQ]=u.useState(!1),[D7,A6]=u.useState(null),[EX,A5]=u.useState(!1),[j7,KX]=u.useState(!1),[PX,v7]=u.useState(!1),[r4,H6]=u.useState(!1),[C9,RX]=u.useState(()=>JT(z00,$K)),[I9,l9]=u.useState(()=>{try{let j=localStorage.getItem(K00);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[i6,zQ]=u.useState(!1),[J6,vJ]=u.useState([]),[HJ,TX]=u.useState(0),[w5,uX]=u.useState(!1),[E5,a4]=u.useState(!1),[i,Q0]=u.useState(!1),[D0,v0]=u.useState(1),[T0,H8]=u.useState(216),[Y8,V9]=u.useState(null),[s8,o6]=u.useState([]),[lX,b6]=u.useState([]),[P5,pQ]=u.useState([]),[R5,s4]=u.useState(0),T5=u.useRef(0);u.useEffect(()=>{T5.current=HJ},[HJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let f7=u.useMemo(()=>lA(J6,{artboardId:[o9,Y8],total:R5}),[J6,o9,Y8,R5]),P8=u.useRef(null);u.useEffect(()=>{P8.current=f7},[f7]);let y9=u.useMemo(()=>GK(J6,f7)?.fps||30,[J6,f7]),[j9,pX]=u.useState(null),[VX,dW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))l8("Timeline changed — reloaded, try again."),dW((t)=>t+1);else l8(`${j}: ${b||"failed"}`)},[]),[zJ,I5]=u.useState(!1),[jK,t4]=u.useState(!1),[vK,KJ]=u.useState(!1),cW=u.useRef(zJ);u.useEffect(()=>{if(cW.current=zJ,zJ){KJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[zJ]);let QH=u.useCallback(()=>{if(!cW.current||document.hidden)KJ(!0),V00("Claude finished","Your assistant turn is ready in Maude.")},[]),xJ=u.useRef(0),e4=u.useCallback(()=>{if(!cW.current||document.hidden){KJ(!0);let j=Date.now();if(j-xJ.current<N20)return;xJ.current=j,V00("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[k5,KQ]=u.useState("inspect"),[fK,XY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[xK,hK]=u.useState(0),[gJ,iW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),YH=u.useRef(gJ);u.useEffect(()=>{YH.current=gJ;try{localStorage.setItem("maude-auto-open-inspector",gJ?"1":"0")}catch{}},[gJ]);let WH=u.useRef(!1);u.useEffect(()=>{WH.current=PX||Y9||o0||A0||zJ},[PX,Y9,o0,A0,zJ]);let oW=u.useRef({open:{},side:$K});oW.current={open:{tree:z7,layers:r4,inspector:PX,comments:Y9,changes:o0,sync:A0,assistant:zJ},side:C9};let dQ=u.useCallback((j,b)=>{if(j==="tree")P7(b);else if(j==="layers")H6(b);else if(j==="inspector")v7(b);else if(j==="comments")e7(b);else if(j==="changes")_8(b);else if(j==="sync")r0(b);else if(j==="assistant")I5(b)},[]),nW=u.useCallback((j)=>oW.current.side?.[j]||$K[j],[]),IX=u.useCallback((j)=>{let b=nW(j);dQ(j,!0);for(let t of GT)if(t.id!==j&&nW(t.id)===b)dQ(t.id,!1)},[dQ,nW]),C5=u.useCallback((j)=>{if(oW.current.open?.[j])dQ(j,!1);else IX(j)},[IX,dQ]),mJ=IX,z6=C5,cQ=u.useCallback((j)=>{if(!YH.current)return;if(d0)return;if(!j||!j.id)return;if(WH.current)return;mJ("inspector"),KQ("css")},[mJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=mh(HT),JY=Ph({enabled:f0.cloud===null||f0.exportLane==="remote"}),[QY,rW]=u.useState(!1),[dX,GH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return df().then((b)=>{if(!j)return;if(rW(!!b),!b&&!XH(X00,!1))GH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let YY=u.useCallback(()=>{GH(!1);try{localStorage.setItem(X00,"1")}catch{}},[]),[gK,ZH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return rf((b)=>ZH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,HH]=u.useState(null),[$5,aW]=u.useState(()=>!XH(ee,!1)),S5=u.useCallback((j)=>{HH(Array.isArray(j)&&j.length?j:null)},[]),mK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)mJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)mJ("changes")}},sW=u.useCallback(()=>{aW(!1);try{localStorage.setItem(ee,"1")}catch{}},[]),[BQ,zH]=u.useState(()=>XH(H00,!0)),[KH,uK]=u.useState(!1),[uJ,UH]=u.useState(()=>XH(G00,!1)),[j6,qX]=u.useState(()=>XH(Z00,!1)),[n6,tW]=u.useState(!1),[lK,lJ]=u.useState(!1),[iQ,NQ]=u.useState(0),[oQ,eW]=u.useState(null),[XG,WY]=u.useState(!1),nQ=u.useRef(null),GY=u.useRef(null),m8=u.useRef(new Map),S8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),ZY=u.useRef(0),cX=u.useCallback(({format:j,artboardIds:b=null,scale:t=1,onProgress:W0,timeoutMs:F0=120000})=>new Promise((q0,k0)=>{let l=Z?m8.current.get(Z):null;if(!l||!l.contentWindow){k0(Error("no active canvas to capture"));return}let M0=l.contentWindow;ZY.current+=1;let O0=`cap-${Date.now().toString(36)}-${ZY.current}`,c0=!1,z8=(M9,k7)=>{if(c0)return;c0=!0,window.removeEventListener("message",B8),clearTimeout(Q6),M9(k7)},B8=(M9)=>{if(M9.source!==M0)return;let k7=M9.data;if(!k7||k7.id!==O0)return;if(k7.dgn==="export-capture-progress")W0?.(k7.current,k7.total);else if(k7.dgn==="export-capture-done")z8(q0,Array.isArray(k7.items)?k7.items:[]);else if(k7.dgn==="export-capture-error")z8(k0,Error(k7.message||"capture failed"))},Q6=setTimeout(()=>z8(k0,Error("capture timed out — the canvas did not answer")),F0);window.addEventListener("message",B8);try{M0.postMessage({dgn:"export-capture",id:O0,format:j,artboardIds:b,scale:t},"*")}catch(M9){z8(k0,M9)}}),[Z]),H0=u.useCallback((j,b)=>S8({dgn:"photo-preview",asset:j,edit:b}),[S8]),pK=u.useCallback((j,b,t)=>{hJ.current.undo.push({asset:j,before:b,after:t}),hJ.current.redo.length=0},[]),rQ=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let t=b.pop();(j?hJ.current.undo:hJ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return H0(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),hK((F0)=>F0+1),!0},[H0]),JG=u.useCallback(async(j)=>{S8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (te(),se)),F0=await W0(t),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await q0.json().catch(()=>({}));if(q0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{S8({dgn:"photo-busy",asset:j,busy:!1})}},[S8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let R7=u.useRef({});R7.current={open:i6,comps:J6,frame:HJ,total:R5,playing:w5,compId:f7,muted:i,loop:E5,sequences:s8,post:S8,canvas:Z};let O7=u.useRef({undo:[],redo:[]}),T7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(O7.current.undo.push({canvas:j,seq:b,label:t}),O7.current.redo=[],O7.current.undo.length>50)O7.current.undo.shift()},[]),aQ=u.useCallback((j)=>{let b=O7.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=R7.current.canvas,q0=-1;for(let l=t.length-1;l>=0;l--)if(t[l].canvas===F0){q0=l;break}if(q0<0){l8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(t.splice(q0,1),l?.ok)W0.push(k0),l8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else l8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>l8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),w6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),HY=u.useCallback((j)=>{let b=R7.current.canvas;if(!b||b===c8)return;let t=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let q0=w6(F0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),y6("Remove refused",F0.error);else if(F0?.ok){if(l8("Clip removed.",!0),F0.seq!=null)T7(b,F0.seq,"remove clip");pX(null)}}).catch(()=>l8("Remove failed: network error"))},[w6,T7]),FQ=u.useCallback((j,b,t)=>{let W0=R7.current.canvas;if(!W0||W0===c8)return;let F0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(q0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let l=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],M0=j?.transition?l.find((O0)=>O0.kind==="transition"&&O0.stableId===j.stableId)||null:w6(k0,j);if(!M0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:M0.stableId,contentHash:M0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),y6(`${b} refused`,k0.error);else if(k0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(l8(`Applied: ${l[b]||b}.`,!0),k0.seq!=null)T7(W0,k0.seq,l[b]||b)}}).catch(()=>l8(`${b} failed: network error`))},[w6,T7,y6]),[pJ,zY]=u.useState(null),dJ=u.useCallback((j,b="")=>new Promise((t)=>{zY({title:j,value:b,resolve:t})}),[]),a0=u.useCallback((j)=>{zY((b)=>{return b?.resolve?.(j),null})},[]),iX=u.useCallback((j,b)=>{let t=R7.current.canvas;if(!t||t===c8||!b||!String(b).trim())return;I7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),l8("Comment added.",!0)},[]);R7.current.selected=j9,R7.current.setSelected=pX,R7.current.removeClip=HY,R7.current.clipVerb=FQ,R7.current.addComment=iX,R7.current.askText=dJ,u.useEffect(()=>{let j=(b)=>{let t=R7.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let q0=GK(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),l=(O0)=>{let c0=Math.max(0,Math.min(k0-1,Math.round(O0)));TX(c0),uX(!1),t.post({dgn:"timeline-seek",frame:c0,id:t.compId})},M0=()=>{let O0=new Set([0,k0-1]);for(let c0 of t.sequences||[]){O0.add(c0.from);for(let z8 of c0.keyframes||[])O0.add(z8.from),O0.add(z8.to)}return[...O0].filter((c0)=>c0>=0&&c0<k0).sort((c0,z8)=>c0-z8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),aQ(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let O0=t.selected!=null?{stableId:t.selected}:null;if(!O0){let c0=t.sequences||[],z8=c0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||c0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(z8?.stableId)O0={stableId:z8.stableId}}if(O0)t.clipVerb?.(O0,"split",{atFrame:t.frame});else l8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(t.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(t.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l(k0-1);else if(b.key==="."){b.preventDefault();let O0=M0().find((c0)=>c0>t.frame);if(O0!=null)l(O0)}else if(b.key===","){b.preventDefault();let O0=M0().reverse().find((c0)=>c0<t.frame);if(O0!=null)l(O0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{vJ([]),TX(0),uX(!1),pX(null),UX(null);let j=setTimeout(()=>S8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,S8]);let[b5,n0]=u.useState(""),[LQ,s0]=u.useState([]),[QG,KY]=u.useState([]);u.useEffect(()=>{if(!i6||J6.length===0||!Z||Z===c8){n0(""),s0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")n0(b.source)}).catch(()=>{}),()=>{j=!1}},[i6,J6,Z,VX]),u.useEffect(()=>{if(!i6||!Z||Z===c8||!b5){s0([]),KY([]);return}let j=!0,b=o9||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];s0(F0.filter((q0)=>q0.kind==="sequence")),KY(F0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[i6,Z,b5,o9,VX]),u.useEffect(()=>{if(!b5){o6([]),b6([]),pQ([]),s4(0);return}let j=Y8??B?.artboardId??null,t=(j&&J6.find((q0)=>q0.artboardId===j||q0.id===j)||J6[0])?.durationInFrames||0,W0=Nh(b5,t,j);UX(W0.artboardId??j??null);let F0=W0.sequences.map((q0,k0)=>{let l=LQ[k0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});o6(F0),b6(W0.audio||[]),pQ(W0.transitions||[]),s4(W0.total)},[b5,LQ,B,J6,Y8]);let UY=u.useCallback(()=>{zH((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{UH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),sQ=u.useCallback(()=>{tW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{tW(!1),BX({present:!1})},[BX]),YG=u.useCallback(()=>{if(!Z||Z===c8)return;lJ((j)=>{let b=!j;return S8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,S8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)eW(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===c8){NQ(0),lJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(t),lJ(b?.overlays?.print===!0),X4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),lJ(!1),X4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===c8||!Y8)return;let j=setTimeout(()=>{S8({dgn:"request-layers",artboardId:Y8})},250);return()=>clearTimeout(j)},[Z,Y8,S8]);let[eQ,X4]=u.useState(()=>new Set),WG=u.useCallback((j)=>{if(!Z||Z===c8)return;X4((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),S8({dgn:"locked-set",locked:W0}),t})},[Z,S8]);u.useEffect(()=>{if(!Z||Z===c8)return;S8({dgn:"locked-set",locked:[...eQ]})},[eQ,Z,S8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(j00,F9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(W00,z7?"1":"0")}catch{}},[z7]),u.useEffect(()=>{try{localStorage.setItem(J00,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(Q00,JSON.stringify(X0))}catch{}},[X0]),u.useEffect(()=>{try{localStorage.setItem(G00,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(Z00,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(H00,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")b9(b.theme);if(typeof b.minimap==="boolean")UH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")zH(b.annotations);if(typeof b.autoOpenInspector==="boolean")iW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...$K,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")l9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)uK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!KH)return;F20({theme:F9,minimap:uJ,zoom:j6,annotations:BQ,autoOpenInspector:gJ,panelSides:C9,layersMode:I9})},[KH,F9,uJ,j6,BQ,gJ,C9,I9]),u.useEffect(()=>{try{localStorage.setItem(z00,JSON.stringify(C9))}catch{}},[C9]),u.useEffect(()=>{try{localStorage.setItem(K00,I9)}catch{}},[I9]);let GG=u.useCallback((j,b)=>{_0((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),J4=u.useCallback(()=>{b9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:w20(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),L8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let cJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){A8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)A8(await F0.json());return}A8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();a8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");GY.current=W0,W0.addEventListener("open",()=>{r(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{r(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let q0=JSON.parse(F0.data);if(q0.type==="snapshot"&&q0.state)N((k0)=>$00(q0.state.selected,k0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=q0.selected,l=Array.isArray(k0)?k0[0]:k0,M0=F.current,O0=Array.isArray(M0)?M0[0]:M0;if(N((c0)=>$00(k0,c0)),l?.id&&l.file&&(!O0||O0.id!==l.id||O0.file!==l.file))M(l)}else if(q0.type==="comments"&&typeof q0.file==="string")a8((k0)=>({...k0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(WY(!0),nQ.current)clearTimeout(nQ.current);nQ.current=setTimeout(()=>WY(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)JY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)o(q0.payload);else if(q0.type==="canvas-list-update"){if(W7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let k0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${k0}/${q0.payload.fromRel}`,M0=`${k0}/${q0.payload.rel}`;G((O0)=>O0.map((c0)=>c0.path===l?{path:M0}:c0)),H((O0)=>O0===l?M0:O0)}}else if(q0.type==="config-updated")V8();else if(q0.type==="acp-focus"){if(W9())mJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!L0.current)K0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),GY.current)GY.current.close()}},[W7,V8]);function I7(j){let b=GY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)K0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)Q8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),ZG=u.useCallback(async(j,b)=>{let t=await FX("/_api/git/commit",{message:j,files:b});if(t.ok)await NX();return t},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),HG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)K8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),zG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),[KG,UG]=u.useState(null),VG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return null;let W0=await t.json();if(!W0?.ok)return null;return UG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),qG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(q8)return b;for(let t of N0?.files||[])b.set(t.path,j[t.status]);return b},[N0,q8]);u.useEffect(()=>{if(q8){Q8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[q8,N0?.repo,o0,kX]);let K6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),N9(null),U(null),j!==c8)P9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!f0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!GQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;DY.current=!0,K6(j)},[f0.cloud,X,W.length,K6]);let iJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)cJ(b);else if(!W8)cJ();K6(c8)},[W8,cJ,K6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==c8)})},[W]),u.useEffect(()=>{if(Z&&Z!==c8)I7({type:"active",file:Z});else if(Z===c8)I7({type:"active",file:""});else I7({type:"active",file:""})},[Z]);let Q4=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),P9((b)=>b===j?null:b)},[Z]),UJ=u.useCallback(()=>{if(!Z||Z===c8){if(Z===c8)cJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,cJ]),OY=u.useCallback(()=>W7(),[W7]),[BG,MY]=u.useState(!1),Y4=u.useRef(!1),W4=u.useCallback(async()=>{if(Y4.current)return;Y4.current=!0,MY(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{Y4.current=!1,MY(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,OY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[OY]);let NG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),K6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,K6]),_Y=u.useCallback(async()=>{let j=await dJ("New video name");if(!j)return;let t=(await dJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,q0=Math.max(1,Math.min(60,Number(await dJ("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:F0})}),l=await k0.json().catch(()=>({}));if(!k0.ok||!l.ok){l8(`New video failed: ${l.error||`error ${k0.status}`}`);return}await W7(),K6(l.file),zQ(!0),l8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){l8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,K6,dJ]),FG=u.useCallback(async()=>{if(!Z||Z===c8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let M0 of l.querySelectorAll('[data-tool="mediaref"]')){let O0=M0.getAttribute("data-src");if(!O0)continue;t.push({src:O0,mediaKind:M0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${pW(JH(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await q0.json().catch(()=>({}));if(!q0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${q0.status}`}`);return}await W7(),K6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,K6]),G4=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=o9||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let q0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(q0(),!k0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{let O0=b(M0);if(!O0)return l8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return l8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:O0.cdId,attr:"src",value:c0.path})})})}).then((M0)=>M0?M0.json():null).then((M0)=>{if(M0&&!M0.ok)l8(`Replace refused: ${M0.error||"failed"}`);else if(M0&&M0.ok){if(l8("Media replaced.",!0),M0.seq!=null)T7(t,M0.seq,"replace media")}}).catch(()=>l8("Replace failed: network error"))}),F0.click()},[Z,o9,T7]),LG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
5654
5654
 
5655
5655
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let W0=await fetch(`/_api/canvas?file=${encodeURIComponent(j)}`,{method:"DELETE"}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok){window.alert(`Could not delete: ${F0.error||`error ${W0.status}`}`);return}if(await W7(),Z===j)G([]),H(null)}catch(W0){window.alert(`Delete failed: ${W0 instanceof Error?W0.message:"network error"}`)}},[W7,Z]),DG=u.useCallback(async function j(b,t){try{let W0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:t})}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok)return l8(`Could not move: ${F0.error||`error ${W0.status}`}`),{ok:!1,error:F0.error};let q0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),k0=`${q0}/${F0.fromRel}`,l=`${q0}/${F0.toRel}`;await W7(),G((O0)=>O0.map((c0)=>c0.path===k0?{path:l}:c0)),H((O0)=>O0===k0?l:O0);let M0=k0.split("/").slice(0,-1).join("/");return l8(`Moved to ${F0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{j(l,M0)}}),{ok:!0}}catch(W0){return l8(`Move failed: ${W0 instanceof Error?W0.message:"network error"}`),{ok:!1,error:"network error"}}},[W7,f0]),OG=u.useCallback(async(j,b)=>{try{let t=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:j,name:b})}),W0=await t.json().catch(()=>({}));if(!t.ok||!W0.ok){let F0=W0.error||`error ${t.status}`;return l8(`Could not create folder: ${F0}`),{ok:!1,error:F0}}return await W7(),{ok:!0,dir:W0.dir}}catch(t){let W0=t instanceof Error?t.message:"network error";return l8(`Create folder failed: ${W0}`),{ok:!1,error:W0}}},[W7]),MG=u.useCallback(async(j,b)=>{if(!window.confirm(`Delete folder "${b}"?
5656
5656