@1agh/maude 0.45.0 → 0.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5643,6 +5643,6 @@ ${U.block}`:z,F=[],L=new Map;for await(let D of X.prompt(B,J(),H,Q?.(),Y?.())){i
5643
5643
  z-index: 8;
5644
5644
  }
5645
5645
  .dc-context-menu .dc-menu-flyout.is-flip { left: auto; right: calc(100% + 3px); }
5646
- `.trim();function bQ0(){if(typeof document>"u")return;if(document.getElementById("dc-context-menu-css"))return;let X=document.createElement("style");X.id="dc-context-menu-css",X.textContent=$Q0,document.head.appendChild(X)}function Ry({target:X,sections:J,onClose:Q}){bQ0();let Y=C6.useRef(null),[W,G]=C6.useState({x:X.clientX,y:X.clientY});C6.useEffect(()=>{let H=Y.current;if(!H)return;let Z=H.getBoundingClientRect(),z=window.innerWidth,U=window.innerHeight,B=X.clientX,F=X.clientY;if(B+Z.width>z-8)B=Math.max(8,z-Z.width-8);if(F+Z.height>U-8)F=Math.max(8,U-Z.height-8);if(B!==W.x||F!==W.y)G({x:B,y:F});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let D=(A)=>{if(!H.contains(A.target))Q()},w=(A)=>{if(A.key==="Escape"){A.preventDefault(),Q();return}if(A.key==="ArrowDown"||A.key==="ArrowUp"){A.preventDefault();let O=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(O.length===0)return;let P=O.indexOf(document.activeElement),I=A.key==="ArrowDown"?(P+1)%O.length:(P-1+O.length)%O.length;O[I]?.focus()}},E=()=>Q();return document.addEventListener("pointerdown",D,!0),document.addEventListener("keydown",w,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",Q)}},[X.clientX,X.clientY,Q,W.x,W.y]);let q=J.map((H)=>H.filter((Z)=>{return!(typeof Z.hidden==="function"?Z.hidden(X):Z.hidden)})).filter((H)=>H.length>0);return K("div",{ref:Y,className:"dc-context-menu",role:"menu",style:{left:W.x,top:W.y},children:q.map((H,Z)=>{let z=H.map((U)=>U.id).join("|")||`s${Z}`;return R("div",{role:"group",children:[Z>0?K("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((U)=>K(jQ0,{item:U,target:X,onClose:Q},U.id))]},z)})})}function jQ0({item:X,target:J,onClose:Q}){let[Y,W]=C6.useState(!1),[G,q]=C6.useState(!1),H=C6.useRef(null),Z=C6.useRef(null),z=C6.useRef(null),U=typeof X.submenu==="function"?X.submenu(J):X.submenu,B=typeof X.disabled==="function"?X.disabled(J):X.disabled;if(!U||U.length===0)return R("button",{type:"button",role:"menuitem",disabled:B,title:B?X.disabledHint:void 0,className:`dc-menu-item${X.destructive?" is-destructive":""}`,onClick:()=>{if(B)return;X.onSelect(J),Q()},children:[K("span",{children:X.label}),X.shortcut?K("span",{className:"dc-menu-shortcut",children:X.shortcut}):null]});let F=()=>{if(z.current)clearTimeout(z.current),z.current=null},L=(w=!1)=>{F();let E=H.current?.getBoundingClientRect();if(E&&typeof window<"u")q(E.right+200>window.innerWidth);if(W(!0),w)setTimeout(()=>{Z.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},D=()=>{F(),z.current=setTimeout(()=>W(!1),140)};return R("div",{className:"dc-menu-sub",onMouseEnter:()=>L(),onMouseLeave:D,children:[R("button",{ref:H,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":Y,disabled:B,className:"dc-menu-item",onClick:()=>Y?W(!1):L(),onKeyDown:(w)=>{if(w.key==="ArrowRight"||w.key==="Enter"||w.key===" ")w.preventDefault(),L(!0);else if(w.key==="ArrowLeft"||w.key==="Escape"){if(Y)w.stopPropagation(),W(!1)}},children:[K("span",{children:X.label}),K("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?K("div",{ref:Z,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:F,onMouseLeave:D,children:U.map((w)=>R("button",{type:"button",role:"menuitem",disabled:w.disabled,title:w.disabled?w.disabledHint:void 0,className:`dc-menu-item${w.destructive?" is-destructive":""}`,onClick:()=>{if(w.disabled)return;w.onSelect(J),Q()},onKeyDown:(E)=>{if(E.key==="ArrowLeft"||E.key==="Escape")E.preventDefault(),E.stopPropagation(),W(!1),H.current?.focus()},children:[K("span",{children:w.label}),w.shortcut?K("span",{className:"dc-menu-shortcut",children:w.shortcut}):null]},w.id))}):null]})}function yH(X){let J=X.mediaTag;if(J==="Video"||J==="OffthreadVideo")return"video";if(J==="Img")return"image";if(J==="Audio")return"audio";return"jsx"}function yQ0(X){let J=yH(X);if(J==="video")return"▶";if(J==="image")return"◫";if(J==="audio")return"♪";return"ƒ"}function ky(X){let J=yH(X),Q=X.mediaSrc?` · ${String(X.mediaSrc).split("/").pop()}`:"";if(J==="video")return`Video clip${Q}`;if(J==="image")return`Image${Q}`;if(J==="audio")return`Audio${Q}`;return"Animated JSX (code-driven)"}function W2({name:X,size:J=15}){return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:{play:K("path",{d:"M4 3l9 5-9 5z",fill:"currentColor",stroke:"none"}),pause:R(Q0,{children:[K("rect",{x:"4",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"}),K("rect",{x:"9",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"})]}),loop:R(Q0,{children:[K("polyline",{points:"4 4 4 7 7 7"}),K("path",{d:"M4 7a4.5 4.5 0 1 1 1.3 4.6"})]}),start:R(Q0,{children:[K("line",{x1:"4.5",y1:"3.5",x2:"4.5",y2:"12.5"}),K("path",{d:"M12 3.5l-6 4.5 6 4.5z",fill:"currentColor",stroke:"none"})]}),sound:R(Q0,{children:[K("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),K("path",{d:"M10.5 5.5a3.2 3.2 0 0 1 0 5"}),K("path",{d:"M12.3 3.7a5.6 5.6 0 0 1 0 8.6"})]}),muted:R(Q0,{children:[K("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),K("line",{x1:"10.7",y1:"6",x2:"13.7",y2:"10"}),K("line",{x1:"13.7",y1:"6",x2:"10.7",y2:"10"})]})}[X]})}var Ez=(X,J,Q)=>Math.max(J,Math.min(Q,X));function fQ0(X,J){let Q=X/(J||30),Y=Math.floor(Q),W=Math.round((Q-Y)*100);return`${Y}.${String(W).padStart(2,"0")}s`}function FM({comps:X=[],sequences:J=[],audio:Q=[],total:Y=0,frame:W=0,playing:G=!1,loop:q=!1,onSeek:H,onPlay:Z,onPause:z,onToggleLoop:U,muted:B=!1,onToggleMute:F,volume:L=1,onVolume:D,height:w,resizing:E,onResize:A,onRetime:O,onRemove:P,onReplace:I,onReplaceAudio:T,onReplaceLayer:C,onReorder:S,onToggleHide:j,onDropMedia:b,onClose:h}){let[d,i]=k7.useState(()=>new Set),[v,n]=k7.useState(!1),Y0=X[0]??null,g=Math.max(1,Y||Y0?.durationInFrames||1),G0=Y0?.fps??30,e=Ez(Math.round(W),0,g-1),l=k7.useRef(null),Z0=k7.useRef(!1),r=k7.useRef(null);k7.useEffect(()=>{r.current?.focus()},[]);let[a,c]=k7.useState(null),[V0,o0]=k7.useState(null),[U8,V8]=k7.useState(null),L0=k7.useRef(!1),t0=k7.useCallback((z0)=>{z0.preventDefault(),z0.stopPropagation(),z0.currentTarget.setPointerCapture?.(z0.pointerId);let F0=z0.clientY,U0=w||216,y0=(R0)=>{A?.(Ez(U0+(F0-R0.clientY),140,640))},w0=()=>{window.removeEventListener("pointermove",y0),window.removeEventListener("pointerup",w0)};window.addEventListener("pointermove",y0),window.addEventListener("pointerup",w0)},[w,A]),n0=96,Q8=k7.useCallback((z0)=>{let F0=l.current;if(!F0)return;let U0=F0.getBoundingClientRect(),y0=Math.max(1,U0.width-n0),w0=Ez((z0-U0.left-n0)/y0,0,1);H?.(Math.round(w0*(g-1)))},[H,g]);k7.useEffect(()=>{if(!Z0.current)return;let z0=(U0)=>Q8(U0.clientX),F0=()=>{Z0.current=!1};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}});let v8=(z0)=>{if(a)return;z0.preventDefault(),Z0.current=!0,Q8(z0.clientX),z0.currentTarget.setPointerCapture?.(z0.pointerId)};k7.useEffect(()=>{if(!a)return;let z0=(U0)=>{let y0=(U0.clientX-a.startX)/Math.max(1,a.rowW)*(g-1),w0=a.startFrom+Math.round(a.startDur+y0),R0=U0.altKey?0:BM(a.rowW,g);w0=UM(w0,a.targets,R0);let I0=Math.max(1,w0-a.startFrom);c((O8)=>O8?{...O8,curDur:I0}:O8)},F0=()=>{c((U0)=>{if(U0&&U0.curDur!==U0.startDur)O?.(U0.index,{durationInFrames:U0.curDur});return null})};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}},[a,g,O]),k7.useEffect(()=>{if(!V0)return;let z0=(U0)=>{let y0=(U0.clientX-V0.startX)/Math.max(1,V0.rowW)*(g-1),w0=Math.max(0,Math.round(V0.startFrom+y0)),R0=U0.altKey?0:BM(V0.rowW,g);if(w0=Math.max(0,UM(w0,V0.targets,R0)),Math.abs(w0-V0.startFrom)>=1)L0.current=!0;o0((I0)=>I0?{...I0,curFrom:w0}:I0)},F0=()=>{o0((U0)=>{if(U0&&U0.curFrom!==U0.startFrom)O?.(U0.index,{from:U0.curFrom});return null})};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}},[V0,g,O]);let i8=(z0)=>Py({fps:G0,totalFrames:g,clips:J,movingIndex:z0,playhead:e}),g8=(z0,F0,U0)=>{if(!O)return;if(J[F0]?.series)return;z0.stopPropagation();let y0=z0.currentTarget.closest(".tl-row-track"),w0=y0?y0.getBoundingClientRect().width:300;L0.current=!1,o0({index:F0,startX:z0.clientX,startFrom:U0,rowW:w0,curFrom:U0,targets:i8(F0)})},z9=(z0,F0,U0)=>{z0.stopPropagation(),z0.preventDefault();let y0=z0.currentTarget.closest(".tl-row-track"),w0=y0?y0.getBoundingClientRect().width:300,R0=J[F0]?.from??0;c({index:F0,startX:z0.clientX,startDur:U0,startFrom:R0,rowW:w0,curDur:U0,targets:i8(F0)})},c0=Math.max(1,Math.floor((g-1)/G0)),d8=Array.from({length:c0+1},(z0,F0)=>F0*G0/(g-1)),o8=(z0)=>`${Ez(z0,0,g-1)/(g-1)*100}%`,j9=(z0)=>Array.from(z0?.types??[]).includes("Files"),f0=(z0)=>{if(!b||!j9(z0.dataTransfer))return;z0.preventDefault(),z0.stopPropagation(),n(!1);let F0=z0.dataTransfer.files?.[0];if(F0)b(F0)};return R("aside",{ref:r,tabIndex:-1,className:`tl-panel${E?" is-resizing":""}${v?" is-drop":""}`,style:{...w?{height:w}:{},outline:"none"},onDragOver:(z0)=>{if(!b||!j9(z0.dataTransfer))return;if(z0.preventDefault(),z0.dataTransfer.dropEffect="copy",!v)n(!0)},onDragLeave:(z0)=>{if(z0.relatedTarget==null)n(!1)},onDrop:f0,"aria-label":"Timeline","data-testid":"timeline-panel",children:[K("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:t0}),R("div",{className:"tl-head",children:[Y0?R(Q0,{children:[K("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":G?"Pause":"Play","aria-pressed":G,"data-testid":"timeline-playpause",onClick:()=>G?z?.():Z?.(),children:K(W2,{name:G?"pause":"play"})}),K("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>H?.(0),children:K(W2,{name:"start"})}),K("button",{type:"button",className:`tl-btn${q?" is-on":""}`,"aria-label":"Loop","aria-pressed":q,"data-testid":"timeline-loop",onClick:()=>U?.(),children:K(W2,{name:"loop"})}),Q.length>0?K("button",{type:"button",className:`tl-btn${B?"":" is-on"}`,"aria-label":B?"Unmute":"Mute","aria-pressed":!B,"data-testid":"timeline-mute",title:B?"Unmute audio":"Mute audio",onClick:()=>F?.(),children:K(W2,{name:B?"muted":"sound"})}):null,Q.length>0?K("input",{type:"range",className:"tl-volume",min:"0",max:"100",value:Math.round((B?0:L)*100),"data-testid":"timeline-volume","aria-label":"Volume",title:"Volume",onChange:(z0)=>D?.(Number(z0.target.value)/100)}):null,R("span",{className:"tl-readout","data-testid":"timeline-readout",children:[K("b",{children:e}),K("span",{className:"tl-sep",children:"/"}),g-1,K("span",{className:"tl-time",children:fQ0(e,G0)})]})]}):K("span",{className:"tl-title",children:"Timeline"}),K("span",{className:"tl-spacer"}),Y0?R("span",{className:"tl-meta",children:[G0," fps · ",g,"f"]}):null,K("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:h,children:"×"})]}),!Y0?R("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No animation on this canvas. Make an artboard a ",K("b",{children:"video-comp"}),"(",K("code",{children:"<VideoComp>"}),") to scrub and export it — or drop clips on the canvas and ",K("b",{children:"File → Assemble dropped clips → video"}),"."]}):K("div",{className:"tl-scroll",children:R("div",{className:"tl-tracks",ref:l,"data-testid":"timeline-track",onPointerDown:v8,children:[K("div",{className:"tl-ruler",children:d8.map((z0,F0)=>K("span",{className:"tl-tick",style:{left:`${z0*100}%`},children:R("span",{className:"tl-tick-label",children:[F0,"s"]})},F0))}),J.length===0?R("div",{className:"tl-row",children:[K("span",{className:"tl-row-label",children:"comp"}),K("div",{className:"tl-row-track",children:K("div",{className:"tl-seq-block",style:{left:"0%",width:"100%"},children:K("span",{className:"tl-seq-name",children:"whole composition"})})})]}):J.map((z0,F0)=>{let U0=a&&a.index===F0?a.curDur:z0.duration,y0=!!(a&&a.index===F0),w0=V0&&V0.index===F0?V0.curFrom:z0.from,R0=!!(V0&&V0.index===F0),I0=Array.isArray(z0.layers)?z0.layers:[],O8=I0.length>=2,r0=O8&&!d.has(F0);return R(k7.Fragment,{children:[R("div",{className:"tl-row","data-testid":`timeline-row-${F0}`,children:[R("span",{className:"tl-row-label",title:z0.label,children:[O8?K("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${F0}`,title:r0?"Collapse layers":"Show layers","aria-label":r0?`Collapse ${z0.label} layers`:`Show ${z0.label} layers`,"aria-expanded":r0,onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),d0.preventDefault(),i(($8)=>{let v9=new Set($8);if(v9.has(F0))v9.delete(F0);else v9.add(F0);return v9})},children:r0?"▾":"▸"}):K("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),S?R("span",{className:"tl-seq-reorder",role:"group","aria-label":`${z0.series?"Play order":"Stacking order"} for ${z0.label}`,children:[K("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-raise-${F0}`,title:z0.series?"Move earlier (plays sooner)":"Bring forward (render on top)","aria-label":z0.series?`Move ${z0.label} earlier`:`Bring ${z0.label} forward`,disabled:z0.series?F0<=0:F0>=J.length-1,onClick:(d0)=>{d0.stopPropagation(),S(F0,z0.series?"backward":"forward")},children:"▲"}),K("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-lower-${F0}`,title:z0.series?"Move later (plays after)":"Send backward (render underneath)","aria-label":z0.series?`Move ${z0.label} later`:`Send ${z0.label} backward`,disabled:z0.series?F0>=J.length-1:F0<=0,onClick:(d0)=>{d0.stopPropagation(),S(F0,z0.series?"forward":"backward")},children:"▼"})]}):null,K("span",{className:"tl-kind","data-kind":yH(z0),title:ky(z0),"aria-label":ky(z0),children:yQ0(z0)}),K("span",{className:"tl-row-label-text",children:z0.label})]}),R("div",{className:"tl-row-track",children:[R("button",{type:"button",className:`tl-seq-block${y0?" is-resizing":""}${R0?" is-moving":""}${z0.hidden?" is-hidden":""}`,"data-testid":`timeline-seq-${F0}`,"data-kind":yH(z0),"data-hidden":z0.hidden?"1":void 0,title:z0.series?`${z0.label} · ${w0}–${w0+U0}f (${U0}f) · position computed by the series — trim the right edge to retime`:`${z0.label} · ${w0}–${w0+U0}f (${U0}f) · drag to move (Alt = no snap)`,"aria-label":z0.series?`${z0.label}, series beat, frames ${w0} to ${w0+U0}. Click to seek; trim its edge to retime.`:`${z0.label}, from frame ${w0} to ${w0+U0}, ${U0} frames. Click to seek; drag to move.`,style:{left:o8(w0),width:`${U0/(g-1)*100}%`,cursor:O&&!z0.series?"grab":void 0},onContextMenu:(d0)=>{d0.preventDefault(),d0.stopPropagation(),V8({index:F0,x:d0.clientX,y:d0.clientY})},onPointerDown:(d0)=>g8(d0,F0,z0.from),onClick:(d0)=>{if(d0.stopPropagation(),L0.current){L0.current=!1;return}H?.(z0.from)},children:[R("span",{className:"tl-seq-name",children:[z0.label,y0?` · ${U0}f`:"",R0?` · @${w0}f`:""]}),z0.keyframes.map((d0,$8)=>{let v9=(d0.from-z0.from)/Math.max(1,z0.duration)*100,r8=(d0.to-d0.from)/Math.max(1,z0.duration)*100;return K("span",{className:"tl-kf","data-testid":`timeline-kf-${F0}-${$8}`,style:{left:`${Ez(v9,0,100)}%`,width:`${Math.max(1.5,r8)}%`},title:`seek to keyframe ${d0.from}f (animates ${d0.from}–${d0.to}f)`,onPointerDown:(k0)=>k0.stopPropagation(),onClick:(k0)=>{k0.stopPropagation(),H?.(d0.from)}},$8)})]}),O?K("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${F0}`,title:"Drag to retime this sequence",style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 5px)`},onPointerDown:(d0)=>z9(d0,F0,z0.duration),onClick:(d0)=>d0.stopPropagation()}):null,I&&z0.replaceable&&!O8?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${F0}`,title:`Replace this ${yH(z0)}`,"aria-label":`Replace media in ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 34px)`},onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),I(F0)},children:"⇄"}):null,P?K("button",{type:"button",className:"tl-seq-remove","data-testid":`timeline-remove-${F0}`,title:"Remove this clip","aria-label":`Remove ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 17px)`},onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),P(F0)},children:"×"}):null]})]}),r0?I0.map((d0,$8)=>{let v9=d0.kind==="video"?"video":d0.kind==="image"?"image":d0.kind==="audio"?"audio":"jsx",r8=d0.kind==="video"?"▶":d0.kind==="image"?"◫":d0.kind==="audio"?"♪":"ƒ",k0=!!(d0.mediaCdId||d0.mediaArrayRef);return R("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${F0}-${$8}`,children:[R("span",{className:"tl-row-label",title:d0.label,children:[K("span",{className:"tl-layer-indent","aria-hidden":"true"}),K("span",{className:"tl-kind","data-kind":v9,children:r8}),K("span",{className:"tl-row-label-text",children:d0.label})]}),R("div",{className:"tl-row-track",children:[K("div",{className:"tl-seq-block tl-layer-block","data-kind":v9,"data-testid":`timeline-layer-block-${F0}-${$8}`,title:`${d0.label} (${d0.kind} layer)`,style:{left:o8(z0.from),width:`${U0/(g-1)*100}%`},onContextMenu:(z8)=>{z8.preventDefault(),z8.stopPropagation(),V8({index:F0,layerIndex:$8,x:z8.clientX,y:z8.clientY})},children:K("span",{className:"tl-seq-name",children:d0.label})}),C&&k0?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${F0}-${$8}`,title:`Replace this ${d0.kind}`,"aria-label":`Replace ${d0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 20px)`},onPointerDown:(z8)=>z8.stopPropagation(),onClick:(z8)=>{z8.stopPropagation(),C(F0,$8)},children:"⇄"}):null]})]},`l${$8}`)}):null]},F0)}),Q.map((z0,F0)=>R("div",{className:"tl-row","data-testid":`timeline-audio-${F0}`,children:[R("span",{className:"tl-row-label",title:z0.label,children:[K("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${z0.label}`,"aria-label":`Audio · ${z0.label}`,children:"♪"}),K("span",{className:"tl-row-label-text",children:z0.label})]}),R("div",{className:"tl-row-track",children:[R("div",{className:"tl-audio-block",title:`${z0.label} · ${z0.from}–${z0.from+z0.duration}f`,style:{left:o8(z0.from),width:`${z0.duration/(g-1)*100}%`},children:[K("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:K("path",{d:"M0 6 Q2 1 4 6 T8 6 T12 6 T16 6 T20 6 T24 6 T28 6 T32 6 T36 6 T40 6 T44 6 T48 6 T52 6 T56 6 T60 6 T64 6 T68 6 T72 6 T76 6 T80 6 T84 6 T88 6 T92 6 T96 6 T100 6"})}),K("span",{className:"tl-seq-name",children:z0.label})]}),T?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${F0}`,title:"Replace this audio","aria-label":`Replace audio ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${z0.duration/(g-1)*100}% - 20px)`},onPointerDown:(U0)=>U0.stopPropagation(),onClick:(U0)=>{U0.stopPropagation(),T(F0)},children:"⇄"}):null]})]},`a${F0}`)),K("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:`calc(96px + (100% - 96px) * ${e/(g-1)||0})`}})]})}),U8&&J[U8.index]?(()=>{let z0=J[U8.index],F0=U8.index,U0=U8.layerIndex,y0;if(U0!=null){let w0=(Array.isArray(z0.layers)?z0.layers:[])[U0],R0=[];if(C&&w0&&(w0.mediaCdId||w0.mediaArrayRef))R0.push({id:"replace-layer",label:`Replace ${w0.kind}…`,onSelect:()=>C(F0,U0)});if(R0.length===0)R0.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});y0=[R0]}else{let w0=[];if(I&&z0.replaceable&&!(Array.isArray(z0.layers)&&z0.layers.length>=2))w0.push({id:"replace",label:`Replace ${yH(z0)}…`,onSelect:()=>I(F0)});if(S)w0.push({id:"earlier",label:z0.series?"Move earlier":"Bring forward",disabled:z0.series?F0<=0:F0>=J.length-1,onSelect:()=>S(F0,z0.series?"backward":"forward")}),w0.push({id:"later",label:z0.series?"Move later":"Send backward",disabled:z0.series?F0>=J.length-1:F0<=0,onSelect:()=>S(F0,z0.series?"forward":"backward")});y0=[w0];let R0=[];if(j)R0.push({id:"hide",label:z0.hidden?"Show clip":"Hide clip",onSelect:()=>j(F0)});if(P)R0.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>P(F0)});if(R0.length)y0.push(R0)}return K(Ry,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:U8.x,clientY:U8.y},sections:y0,onClose:()=>V8(null)})})():null]})}function vQ0(X){let J={};for(let Q of X.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*(-?\d+)\s*;/g))J[Q[1]]=Number(Q[2]);for(let Q=0;Q<3;Q+=1)for(let Y of X.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);/g)){let W=Y[1];if(Object.hasOwn(J,W))continue;let G=g5(Y[2],J);if(G!=null)J[W]=G}return J}function g5(X,J){if(X==null)return null;let Q=String(X).trim();if(/^-?\d+$/.test(Q))return Number(Q);if(Object.hasOwn(J,Q))return J[Q];let Y=Q.replace(/[A-Za-z_$][\w$]*/g,(W)=>Object.hasOwn(J,W)?String(J[W]):W);if(/^[-+*/()\d\s.]+$/.test(Y)&&/\d/.test(Y))try{let W=Function(`"use strict";return (${Y});`)();if(Number.isFinite(W))return Math.round(W)}catch{}return null}function xQ0(X,J,Q,Y){if(!J)return[];let W=X.search(new RegExp(`\\b(?:const|function)\\s+${J}\\b`));if(W<0)return[];let G=X.slice(W+J.length),q=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,q>0?q:2400),Z=[];for(let z of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let U=g5(z[1],Q),B=g5(z[2],Q);if(U!=null&&B!=null&&B>=U)Z.push({from:Y+U,to:Y+B})}return Z}function hQ0(X,J){if(!J)return null;let Q=X.search(new RegExp(`\\b(?:const|function)\\s+${J}\\b`));if(Q<0)return null;let Y=X.slice(Q+J.length+1),W=Y.search(/\n(?:const|function|export)\s+[A-Za-z]/);return Y.slice(0,W>0?W:Y.length)}function gQ0(X,J){let Q=[];for(let Y of X.matchAll(/<VideoComp\b([^>]*?)\/?>/g)){let W=Y[1],G=W.match(/component=\{([A-Za-z_$][\w$]*)\}/);if(!G)continue;let H=[...X.slice(0,Y.index).matchAll(/<DCArtboard\b[^>]*?\bid=["']([^"']+)["']/g)];Q.push({compName:G[1],artboardId:H.length?H[H.length-1][1]:null,duration:g5(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],J),fps:g5(W.match(/fps=\{([^}]+)\}/)?.[1],J)||30})}return Q}function Iy(X,J,Q){let Y=String(X??""),W=vQ0(Y),G=Y,q=J,H=0,Z=null,z=gQ0(Y,W).map((O)=>({...O,body:hQ0(Y,O.compName)})).filter((O)=>O.body);if(z.length){let O=Q&&z.find((P)=>P.artboardId===Q)||z.find((P)=>/<(?:Audio|OffthreadVideo|Video)\b/.test(P.body))||z.find((P)=>P.duration!=null&&P.duration===J)||z[0];if(G=O.body,O.duration!=null)q=O.duration;H=O.fps,Z=O.artboardId??null}let U=[],B=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=B.exec(G)){let O=F[1],P=F[2],I=B.lastIndex;if(/Transition$/.test(O)){let T=P.match(/durationInFrames:\s*([^,}\s)]+)/);U.push({type:"transition",dur:g5(T?.[1],W)??0})}else{let T=P.match(/durationInFrames=\{([^}]+)\}/),C=P.match(/from=\{([^}]+)\}/),S=G.indexOf(`</${O}>`,I),j=S>=0?Math.min(S,I+400):I+240,b=G.slice(I,j),h=b.match(/<([A-Z][A-Za-z0-9]*)\b/),d=b.match(/<(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),i=P.match(/name=["']([^"']+)["']/);U.push({type:"seq",series:O!=="Sequence",dur:g5(T?.[1],W),from:O==="Sequence"&&C?g5(C[1],W):null,compName:i?i[1]:h?h[1]:null,mediaTag:d?d[1]:null,mediaSrc:d?d[2]:null})}}let L=0,D=[];for(let O of U){if(O.type==="transition"){L-=O.dur||0;continue}let P=O.from!=null?O.from:L,I=O.dur!=null?O.dur:30;D.push({label:O.compName??`Seq ${D.length+1}`,series:!!O.series,mediaTag:O.mediaTag,mediaSrc:O.mediaSrc,from:Math.max(0,P),duration:Math.max(1,I),keyframes:xQ0(Y,O.compName,W,Math.max(0,P))}),L=P+I}let w=D.length?Math.max(...D.map((O)=>O.from+O.duration)):30,E=Number.isFinite(q)&&q>0?q:w,A=[];for(let O of G.matchAll(/<Audio\b([^>]*)>/g)){let P=O[1],I=P.match(/src=["']([^"']+)["']/),T=P.match(/from=\{([^}]+)\}/),C=P.match(/durationInFrames=\{([^}]+)\}/),S=T?g5(T[1],W)??0:0,j=C?g5(C[1],W):null,b=I?String(I[1]).split(/[\\/]/).pop():"audio";A.push({kind:"audio",label:b,from:Math.max(0,S),duration:j!=null?Math.max(1,j):Math.max(1,E-S)})}return{total:E,fps:H||void 0,sequences:D,audio:A,artboardId:Z}}var z7=R8(x8(),1);function NM({name:X,size:J=16}){let Q={x:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),sparkle:K("path",{d:"M8 2.5l1.2 3.3L12.5 7 9.2 8.2 8 11.5 6.8 8.2 3.5 7l3.3-1.2z"}),copy:R(Q0,{children:[K("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),K("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}var mQ0=["1:1","16:9","9:16","4:3","3:4","4:5"];function LM({onClose:X,onInsert:J}){let[Q,Y]=z7.useState([]),[W,G]=z7.useState(""),[q,H]=z7.useState([]),[Z,z]=z7.useState(""),[U,B]=z7.useState("1:1"),[F,L]=z7.useState(""),[D,w]=z7.useState(!1),[E,A]=z7.useState(null),[O,P]=z7.useState(null),[I,T]=z7.useState(!0),[C,S]=z7.useState(null),j=z7.useRef(null),b=z7.useRef(null);z7.useEffect(()=>{fetch("/_api/generate/providers").then((n)=>n.json()).then((n)=>{let Y0=(n?.providers??[]).filter((G0)=>G0.modalities?.includes("image"));Y(Y0);let g=Y0.find((G0)=>G0.configured)??Y0[0];if(g)G(g.id)}).catch(()=>A({ok:!1,msg:"failed to load providers"}))},[]),z7.useEffect(()=>{if(!W)return;H([]),z("")},[W]),z7.useEffect(()=>{function n(Y0){if(Y0.key==="Escape")Y0.preventDefault(),X()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[X]),z7.useEffect(()=>()=>clearInterval(j.current),[]),z7.useEffect(()=>{if(!O||!I||typeof J!=="function")return;if(b.current===O)return;b.current=O;let n=J(O)===!0;if(S(n),n)A({ok:!0,msg:"Placed on canvas ✓"});else A({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[O,I,J]);let h=Q.find((n)=>n.id===W),d=h&&!h.configured,i=z7.useCallback((n)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let g=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((G0)=>G0.id===n);if(!g)return;if(g.status==="done"){clearInterval(j.current),w(!1);let G0=g.assets?.[0]??null;P(G0),A({ok:!0,msg:G0?`Generated ${G0}`:"Done (no asset)"})}else if(g.status==="failed")clearInterval(j.current),w(!1),A({ok:!1,msg:g.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),w((Y0)=>{if(Y0)A({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function v(){if(!F.trim()||!W)return;w(!0),A(null),P(null),S(null),b.current=null;try{let n={modality:"image",provider:W,prompt:F.trim(),aspectRatio:U,...Z?{model:Z}:{}},Y0=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(n)});if(Y0.status===202){let{jobId:g}=await Y0.json();A({ok:!0,msg:"Generating…"}),i(g)}else w(!1),A({ok:!1,msg:await Y0.text()})}catch(n){w(!1),A({ok:!1,msg:n&&n.message?n.message:"request failed"})}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)X()},children:R("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Generate with AI"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:K(NM,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:"Prompt"}),K("textarea",{className:"input st-gen-prompt",rows:3,value:F,placeholder:"a minimal hero image of a mountain lake at dawn, soft light","aria-label":"Generation prompt",onChange:(n)=>L(n.target.value)}),R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-provider",children:"Provider"}),K("select",{id:"st-gen-provider",className:"st-select",value:W,onChange:(n)=>G(n.target.value),children:Q.map((n)=>R("option",{value:n.id,children:[n.label,n.configured?"":" — no key"]},n.id))})]}),q.length>0&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-model",children:"Model"}),K("select",{id:"st-gen-model",className:"st-select",value:Z,onChange:(n)=>z(n.target.value),children:q.map((n)=>K("option",{value:n.id,children:n.label},n.id))})]}),R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-aspect",children:"Aspect"}),K("select",{id:"st-gen-aspect",className:"st-select",value:U,onChange:(n)=>B(n.target.value),children:mQ0.map((n)=>K("option",{value:n,children:n},n))})]}),J&&R("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[K("input",{type:"checkbox",checked:I,onChange:(n)=>T(n.target.checked),"aria-label":"Place the generated image on the canvas"}),K("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),d&&R("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",h.label," — add one in Settings (⌘,)."]}),O&&R("div",{className:"st-gen-result",children:[K("img",{className:"st-gen-thumb",src:`/${O}`,alt:"generated"}),R("div",{className:"st-gen-result-actions",children:[R("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${O}`),children:[K(NM,{name:"copy",size:13})," Copy path"]}),J&&C!==!0&&K("button",{type:"button",className:"st-btn",onClick:()=>{let n=J(O)===!0;S(n),A(n?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),E&&K("div",{className:"st-provider-status",style:{color:E.ok?"var(--accent)":"var(--danger, #e5484d)"},children:E.msg}),K("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:R("button",{type:"button",className:"st-btn st-gen-go",disabled:D||!F.trim()||!W,onClick:v,children:[K(NM,{name:"sparkle",size:14})," ",D?"Generating…":"Generate"]})})]})]})})}var u9=R8(x8(),1);var G2=new Set(["main","master"]);function T9({name:X,size:J=16,className:Q}){let Y={check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),"chevron-up":K("polyline",{points:"3.5 10 8 5.5 12.5 10"}),"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-open":R(Q0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14"}),K("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:R(Q0,{children:[K("circle",{cx:"4",cy:"8",r:"1.6"}),K("circle",{cx:"12",cy:"4",r:"1.6"}),K("circle",{cx:"12",cy:"12",r:"1.6"}),K("line",{x1:"5.4",y1:"7.2",x2:"10.6",y2:"4.6"}),K("line",{x1:"5.4",y1:"8.8",x2:"10.6",y2:"11.4"})]}),draft:R(Q0,{children:[K("path",{d:"M3 11.5 11 3.5l1.5 1.5L4.5 13l-2 .5z"}),K("line",{x1:"9.5",y1:"5",x2:"11",y2:"6.5"})]}),branch:R(Q0,{children:[K("circle",{cx:"4.5",cy:"4",r:"1.4"}),K("circle",{cx:"4.5",cy:"12",r:"1.4"}),K("circle",{cx:"11.5",cy:"6.5",r:"1.4"}),K("line",{x1:"4.5",y1:"5.4",x2:"4.5",y2:"10.6"}),K("path",{d:"M4.5 8.6h2.6a3 3 0 0 0 3-1.6"})]}),plus:R(Q0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),"arrow-up-to-line":R(Q0,{children:[K("line",{x1:"3.5",y1:"3",x2:"12.5",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"6"}),K("polyline",{points:"5 8.5 8 5.5 11 8.5"})]}),cloud:K("path",{d:"M4.5 12h6a2.5 2.5 0 0 0 .3-5A3.5 3.5 0 0 0 4 6.4 2.8 2.8 0 0 0 4.5 12z"}),refresh:R(Q0,{children:[K("path",{d:"M12.5 8a4.5 4.5 0 1 1-1.3-3.2"}),K("polyline",{points:"12.8 2.5 12.8 5 10.3 5"})]}),spinner:K("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10.5"}),K("polyline",{points:"5 7.5 8 10.5 11 7.5"}),K("line",{x1:"3.5",y1:"13.2",x2:"12.5",y2:"13.2"})]}),close:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[X];return K("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function q2(X){return String(X).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(X)}function Ty(X){return X.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function DM(X){return String(X).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function uQ0(X){if(!X)return"";let J=Math.max(0,Math.floor(Date.now()/1000)-X);if(J<45)return"just now";if(J<3600)return`${Math.round(J/60)} min ago`;if(J<86400)return`${Math.round(J/3600)} h ago`;return`${Math.round(J/86400)} d ago`}async function OM(X){return(await fetch(X)).json()}async function H2(X,J,Q={}){let Y=Q.timeoutMs?new AbortController:null,W=Y?setTimeout(()=>Y.abort(),Q.timeoutMs):null;try{let G=await fetch(X,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J),signal:Y?.signal}),q=null;try{q=await G.json()}catch{}return{ok:G.ok,status:G.status,json:q}}catch(G){if(G?.name==="AbortError")return{ok:!1,status:0,json:null,timedOut:!0};return{ok:!1,status:0,json:null,error:String(G?.message||G)}}finally{if(W)clearTimeout(W)}}function MM({project:X,liveBranch:J,remoteSync:Q,onGetLatest:Y}){let W=G9(),[G,q]=u9.useState(null),[H,Z]=u9.useState([]),[z,U]=u9.useState([]),[B,F]=u9.useState(!1),[L,D]=u9.useState(!1),[w,E]=u9.useState(""),[A,O]=u9.useState(!1),[P,I]=u9.useState(""),[T,C]=u9.useState(null),[S,j]=u9.useState(!1),[b,h]=u9.useState(!1),[d,i]=u9.useState(!1);async function v(k0){if(!G9()){window.open(k0,"_blank","noopener,noreferrer");return}try{await jj(k0)}catch{try{await navigator.clipboard.writeText(k0),j(!0)}catch{}}}let[n,Y0]=u9.useState(!1),[g,G0]=u9.useState(""),[e,l]=u9.useState(""),[Z0,r]=u9.useState(""),[a,c]=u9.useState(!1),[V0,o0]=u9.useState(0),[U8,V8]=u9.useState(!1),L0=u9.useRef(null);if(u9.useEffect(()=>{let k0=!0;if((async()=>{try{let z8=await OM("/_api/git/status");if(!k0)return;if(q(z8),z8.repo&&W){let m7=await OM("/_api/git/branches");if(k0)Z(m7.branches||[])}}catch{}})(),W)mj().then((z8)=>k0&&U(z8||[])).catch(()=>{});return()=>{k0=!1}},[W]),u9.useEffect(()=>{if(!B||!W||!G?.repo)return;l(""),z0()},[B]),u9.useEffect(()=>{if(!B&&!L)return;let k0=(z8)=>{if(L0.current&&!L0.current.contains(z8.target))F(!1),D(!1),r("")};return document.addEventListener("mousedown",k0),()=>document.removeEventListener("mousedown",k0)},[B,L]),!G?.repo)return null;let t0=J||G.branch||"main",n0=G2.has(t0),Q8=H.find((k0)=>G2.has(k0.name))?.name||"main",v8=(k0,z8)=>(z8.updatedAt||0)-(k0.updatedAt||0)||k0.name.localeCompare(z8.name),i8=Z0.trim().toLowerCase(),g8=(k0)=>!i8||k0.name.toLowerCase().includes(i8),z9=H.filter((k0)=>!G2.has(k0.name)).sort(v8),c0=z9.filter(g8),d8=c0.filter((k0)=>k0.name!==t0),o8=!i8||Q8.toLowerCase().includes(i8)||"shared version".includes(i8),j9=z9.length>6,f0=X||q2(z[0]||"Project");if(!W)return K("div",{className:"rb-dock-wrap",children:K("div",{className:"rb-dock rb-dock--ro",children:R("span",{className:"rb-trigger rb-trigger--ro",title:`${f0} · branch: ${t0} — switch branches in your terminal`,children:[K("span",{className:"rb-trigger-icon",children:K(T9,{name:"folder",size:14})}),K("span",{className:"rb-trigger-proj",children:f0}),K("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),R("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[K(T9,{name:"branch",size:12}),R("span",{className:"rb-trigger-ver-name",children:["branch: ",t0]})]})]})})});async function z0(){try{let k0=await OM("/_api/git/branches");Z(k0.branches||[])}catch{}}async function F0(k0,z8){if(F(!1),k0===t0)return;G0(k0),V8(z8==="remote"),l("");let m7=await H2("/_api/git/checkout",{name:k0});if(m7.ok&&m7.json?.ok)window.location.reload();else l(m7.json?.error||"Could not switch."),G0(""),V8(!1)}async function U0(){if(a)return;c(!0),l("");let k0=await H2("/_api/git/fetch",{},{timeoutMs:45000});if(k0.ok&&k0.json?.ok){if(k0.json.fetchedAt)o0(k0.json.fetchedAt);await z0()}else if(k0.timedOut||k0.json?.timedOut)l("Couldn’t reach the remote — your local branches are still listed above.");else l(k0.status===401||k0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":k0.json?.error||"Could not fetch remote branches.");c(!1)}async function y0(){let k0=Ty(w);if(!k0)return;Y0(!0),l("");let z8=await H2("/_api/git/branch",{name:k0});if(z8.ok&&z8.json?.ok)window.location.reload();else l(z8.json?.error||"Could not create the draft."),Y0(!1)}async function w0(){if(b||!Y)return;h(!0),l("");let k0=await Y();if(h(!1),k0&&!k0.ok&&!k0.conflict)l(k0.status===401||k0.authRequired?"Sign in with GitHub to get the latest.":k0.error||"Could not get the latest.")}async function R0(){I(t0),l("");let k0=await H2("/_api/git/fold",{name:t0},{timeoutMs:45000}),z8=k0.json;if(k0.ok&&z8?.ok&&z8.prUrl){C({url:z8.prUrl,number:z8.prNumber,repo:z8.repo}),I(""),z0();return}if(k0.ok&&z8?.ok&&z8.prUnavailable){C({message:z8.error||"Draft published, but the pull request could not be opened."}),I(""),z0();return}if(k0.ok&&z8?.ok){window.location.reload();return}l(k0.status===401?`Sign in with GitHub to add “${t0}” to ${Q8}.`:z8?.error||"Could not add the branch."),I("")}async function I0(k0){if(F(!1),!W)return;G0(q2(k0));try{await AJ(k0)}catch(z8){l(String(z8?.message||z8||"Could not open that project.")),G0("")}}async function O8(){if(F(!1),!W)return;try{let k0=await vQ();if(!k0)return;G0(q2(k0)),await AJ(k0)}catch(k0){l(String(k0?.message||k0||"Could not open that folder.")),G0("")}}let r0=Ty(w),d0=n0?null:H.find((k0)=>k0.current),$8=n0&&!d&&!g&&!P?[...H].filter((k0)=>!G2.has(k0.name)&&k0.where!=="remote").sort((k0,z8)=>(z8.updatedAt||0)-(k0.updatedAt||0))[0]:null,v9=R(Q0,{children:[R("div",{className:"rb-pop-empty",children:["No branch matches “",Z0.trim(),"”."]}),R("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:U0,disabled:a,children:[K("span",{className:"rb-pop-icon"+(a?" rb-pop-icon--spin":""),children:K(T9,{name:a?"spinner":"refresh",size:14})}),K("span",{className:"rb-pop-tx",children:K("span",{className:"rb-pop-name",children:a?"Searching the remote…":"Search the remote for it"})})]})]}),r8=(k0)=>{let z8=k0.where==="remote";return R("button",{type:"button","data-testid":`branch-row-${DM(k0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>F0(k0.name,k0.where),children:[K("span",{className:"rb-pop-icon "+(z8?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:K(T9,{name:z8?"cloud":"draft",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:k0.name}),z8&&K("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},k0.name)};return R("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!g&&!P&&R("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:w0,disabled:b,title:`Get the latest ${Q8}`,children:[K(T9,{name:b?"spinner":"download",size:14,className:b?"rb-spin":""}),K("span",{className:"rb-getlatest-tx",children:b?"Getting the latest…":"Get latest"}),!b&&Q.behind>0&&R("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",Q8]})]}),$8&&R("div",{className:"rb-resume","data-testid":"switcher-resume",children:[R("button",{type:"button",className:"rb-resume-go",onClick:()=>F0($8.name),title:`Switch to ${$8.name}`,children:[K("span",{className:"rb-resume-icon",children:K(T9,{name:"draft",size:13})}),R("span",{className:"rb-resume-tx",children:["Continue on ",K("b",{children:$8.name})]}),K(T9,{name:"chevron-right",size:12,className:"rb-resume-arrow"})]}),K("button",{type:"button",className:"rb-resume-x","data-testid":"switcher-resume-dismiss","aria-label":"Dismiss",onClick:()=>i(!0),children:K(T9,{name:"close",size:12})})]}),R("div",{className:"rb-dock",ref:L0,children:[B&&R("div",{className:"rb-pop rb-pop--up",id:"rb-switch-pop",role:"menu","aria-label":"Switch project or version","data-testid":"repo-switcher-popup",children:[K("div",{className:"rb-pop-hd",children:"Project"}),W&&z.length>0?z.map((k0,z8)=>R("button",{type:"button",className:"rb-pop-item"+(z8===0?" is-current":""),role:"menuitem",onClick:()=>I0(k0),children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"folder",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:q2(k0)}),K("span",{className:"rb-pop-sub",children:k0})]}),z8===0?K(T9,{name:"check",size:14,className:"rb-pop-check"}):null]},k0)):K("div",{className:"rb-pop-sub",style:{padding:"var(--space-2) var(--space-3)"},children:W?"No other recent projects.":"Open another project from the desktop app."}),W&&R("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:O8,children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"folder-open",size:14})}),K("span",{className:"rb-pop-tx",children:K("span",{className:"rb-pop-name",children:"Open another folder…"})})]}),K("div",{className:"rb-pop-sep"}),K("div",{className:"rb-pop-hd",children:"Branch"}),n0?R(Q0,{children:[R("button",{type:"button","data-testid":`branch-row-${DM(Q8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>F0(Q8),children:[K("span",{className:"rb-pop-icon rb-pop-icon--shared",children:K(T9,{name:"share",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:Q8}),K("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),K(T9,{name:"check",size:14,className:"rb-pop-check"})]}),z9.length>0&&K("div",{className:"rb-pop-grouplabel",children:"Other branches"}),j9&&K("div",{className:"rb-search",children:K("input",{className:"input rb-search-input",type:"text",value:Z0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(k0)=>r(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")r("")}})}),c0.map(r8),j9&&i8&&c0.length===0&&!o8&&v9]}):R(Q0,{children:[R("button",{type:"button",className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",children:[K("span",{className:"rb-pop-icon rb-pop-icon--draft",children:K(T9,{name:"draft",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:d0?.name||t0}),K("span",{className:"rb-pop-sub",children:"your branch"})]}),K(T9,{name:"check",size:14,className:"rb-pop-check"})]}),R("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{F(!1),l(""),C(null),j(!1),O(!0)},children:[K("span",{className:"rb-fold-icon",children:K(T9,{name:"arrow-up-to-line",size:15})}),R("span",{className:"rb-fold-tx",children:[R("span",{className:"rb-fold-title",children:["Merge this branch → ",Q8]}),K("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),K("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),j9&&K("div",{className:"rb-search",children:K("input",{className:"input rb-search-input",type:"text",value:Z0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(k0)=>r(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")r("")}})}),o8&&R("button",{type:"button","data-testid":`branch-row-${DM(Q8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>F0(Q8),children:[K("span",{className:"rb-pop-icon rb-pop-icon--shared",children:K(T9,{name:"share",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:Q8}),K("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),d8.map(r8),j9&&i8&&d8.length===0&&!o8&&v9]}),R("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:U0,disabled:a,children:[K("span",{className:"rb-pop-icon"+(a?" rb-pop-icon--spin":""),children:K(T9,{name:a?"spinner":"refresh",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:a?"Fetching…":"Fetch remote branches"}),K("span",{className:"rb-pop-sub",children:V0?`as of ${uQ0(V0)}`:"check the remote for new branches"})]})]}),e&&!g&&K("div",{className:"rb-pop-notice",role:"alert",children:e}),R("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{F(!1),D(!0)},children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"plus",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:"New branch"}),K("span",{className:"rb-pop-sub",children:"a separate line of work off what you're looking at now"})]})]})]}),L&&R("div",{className:"rb-newdraft rb-newdraft--up",children:[R("label",{className:"rb-newdraft-field",children:[K("span",{className:"rb-newdraft-label",children:"Name your branch"}),K("input",{className:"input rb-newdraft-input","data-testid":"switcher-new-branch-input",type:"text",value:w,placeholder:"nav-redesign","aria-label":"Branch name",autoFocus:!0,onChange:(k0)=>E(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter"&&r0)y0();if(k0.key==="Escape")D(!1),E("")}}),r0&&R("span",{className:"rb-pop-sub",children:["Creates branch ",K("b",{children:r0})]})]}),e&&K("span",{className:"rb-newdraft-err",children:e}),R("div",{className:"rb-newdraft-actions",children:[K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{D(!1),E(""),l("")},disabled:n,children:"Cancel"}),R("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:y0,disabled:n||!r0,children:[K(T9,{name:"draft",size:13})," ",n?"Creating…":"Create branch"]})]}),R("p",{className:"rb-newdraft-hint",children:["A branch is your own line of work off what you're looking at now. Merge it into ",Q8," when you're happy, or throw it away — nothing else changes."]})]}),g||P?R("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[K(T9,{name:"spinner",size:14,className:"rb-spin"}),K("span",{children:P?R(Q0,{children:["Merging ",K("b",{children:P})," → ",Q8,"…"]}):U8?R(Q0,{children:["Downloading ",K("b",{children:g}),"…"]}):R(Q0,{children:["Opening ",K("b",{children:g}),"…"]})})]}):R("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(B?" is-open":""),"aria-expanded":B,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>{F((k0)=>{if(k0)r("");return!k0}),D(!1)},title:`${f0} · ${t0}`,children:[K("span",{className:"rb-trigger-icon",children:K(T9,{name:"folder",size:14})}),K("span",{className:"rb-trigger-proj",children:f0}),K("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),R("span",{className:"rb-trigger-ver"+(n0?"":" is-draft"),children:[K(T9,{name:n0?"share":"draft",size:12}),K("span",{className:"rb-trigger-ver-name",children:t0})]}),K(T9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),e&&!B&&!L&&!g&&K("div",{className:"rb-switcher-err",role:"alert",children:e})]}),A&&K("div",{className:"rb-scrim",role:"presentation",onClick:()=>{O(!1),C(null),j(!1)},children:K("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(k0)=>k0.stopPropagation(),onKeyDown:(k0)=>{if(k0.key==="Escape")O(!1),C(null),j(!1)},children:T?T.url?R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"share",size:20})}),R("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",T.number?` #${T.number}`:""]}),R("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",R("b",{children:["“",t0,"”"]})," is up as a pull request into ",K("b",{children:Q8}),T.repo?R(Q0,{children:[" of ",K("b",{children:T.repo})]}):null,". Review and merge it on GitHub — that keeps your team's review rules."]}),K("p",{className:"rb-sheet-meta rb-pr-url",children:T.url}),R("div",{className:"rb-sheet-actions",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:()=>{O(!1),C(null),j(!1)},children:"Close"}),R("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>v(T.url),children:[K(T9,{name:"share",size:15})," ",S?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"share",size:20})}),K("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:"Draft published"}),K("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:T.message}),K("div",{className:"rb-sheet-actions",children:K("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{O(!1),C(null),j(!1)},children:"Got it"})})]}):R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"arrow-up-to-line",size:20})}),R("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",Q8]}),R("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",R("b",{children:["“",d0?.name||t0,"”"]})," to ",K("b",{children:Q8})," — the default branch everyone shares."]}),K("p",{className:"rb-sheet-meta",children:"On a shared GitHub project this opens a pull request for review; a local project merges directly. Nothing is lost — your work is kept in History."}),e&&K("p",{className:"rb-newdraft-err",children:e}),R("div",{className:"rb-sheet-actions",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:()=>{O(!1),l("")},children:"Cancel"}),R("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!P,onClick:R0,children:[K(T9,{name:"arrow-up-to-line",size:15})," ",P?"Adding…":`Add to ${Q8}`]})]})]})})})]})}var M7=R8(x8(),1);function fH({name:X,size:J=16}){let Q={x:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:R(Q0,{children:[K("circle",{cx:"5.5",cy:"5.5",r:"3"}),K("path",{d:"M7.6 7.6 13 13"}),K("line",{x1:"11",y1:"11",x2:"12.5",y2:"9.5"})]}),check:K("polyline",{points:"3.5 8.5 6.5 11.5 12.5 4.5"}),external:R(Q0,{children:[K("path",{d:"M6 3.5H3.2A.7.7 0 0 0 2.5 4.2v8.6a.7.7 0 0 0 .7.7h8.6a.7.7 0 0 0 .7-.7V10"}),K("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),K("polyline",{points:"9.5 3 13 3 13 6.5"})]}),cloud:K("path",{d:"M4.5 12h6a2.5 2.5 0 0 0 .2-5 3.5 3.5 0 0 0-6.7-1A2.75 2.75 0 0 0 4.5 12Z"})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function lQ0({provider:X,onChanged:J}){let[Q,Y]=M7.useState(""),[W,G]=M7.useState(!1),[q,H]=M7.useState(null),Z=X.configured;async function z(){let B=Q.trim();if(!B)return;G(!0),H(null);try{let F=await fetch("/_api/generate/keys",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:X.id,key:B})});if(!F.ok)throw Error(await F.text());let L=await F.json();Y(""),H({ok:!0,msg:L.configured?"Key saved.":"Saved."}),J()}catch(F){H({ok:!1,msg:F&&F.message?F.message:"save failed"})}finally{G(!1)}}async function U(){G(!0),H(null);try{let B=await fetch("/_api/generate/keys",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:X.id})});if(!B.ok)throw Error(await B.text());H({ok:!0,msg:"Key removed."}),J()}catch(B){H({ok:!1,msg:B&&B.message?B.message:"remove failed"})}finally{G(!1)}}return R("div",{className:"st-provider-card",children:[R("div",{className:"st-provider-hd",children:[K("span",{className:"st-provider-name",children:X.label}),K("span",{className:"st-pill"+(X.kind==="local"?" is-local":""),children:X.kind==="local"?"Local":R(Q0,{children:[K(fH,{name:"cloud",size:12})," Cloud"]})}),Z&&R("span",{className:"st-provider-configured",children:[K(fH,{name:"check",size:12})," configured"]})]}),K("div",{className:"st-provider-modalities",children:X.modalities.join(" · ")}),X.notes&&K("div",{className:"st-provider-notes",children:X.notes}),X.keyUrl&&R("a",{className:"st-provider-keylink",href:X.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",K(fH,{name:"external",size:12})]}),X.auth==="api-key"&&R("div",{className:"st-provider-keyrow",children:[K("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:Z?"•••••••• configured — paste to replace":"paste API key","aria-label":`${X.label} API key`,onChange:(B)=>Y(B.target.value),onKeyDown:(B)=>{if(B.key==="Enter")z()}}),R("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:z,children:[K(fH,{name:"key",size:13})," Save"]}),Z&&K("button",{type:"button",className:"st-btn",disabled:W,onClick:U,children:"Remove"})]}),q&&K("div",{className:"st-provider-status",style:{color:q.ok?"var(--accent)":"var(--danger, #e5484d)"},children:q.msg})]})}var dQ0=[{id:"whisper",label:"Local whisper.cpp",note:"Free · offline · no key · runs on your hardware"},{id:"elevenlabs",label:"ElevenLabs Scribe",note:"Cloud · accuracy · needs an ElevenLabs key"},{id:"groq",label:"Groq Whisper",note:"Cloud · fast · needs a Groq key"}];function pQ0(){let[X,J]=M7.useState(null),[Q,Y]=M7.useState(!1),[W,G]=M7.useState(null);M7.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>J(H?.transcriptionProvider||"whisper")).catch(()=>J("whisper"))},[]);async function q(H){if(H===X)return;let Z=X;J(H),Y(!0),G(null);try{let z=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:H})});if(!z.ok)throw Error(await z.text());G({ok:!0,msg:"Saved."})}catch(z){J(Z),G({ok:!1,msg:z&&z.message?z.message:"save failed"})}finally{Y(!1)}}return R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),K("div",{className:"st-provider-notes",children:"Which engine turns audio into subtitles. This is an explicit choice — Maude never silently switches engines; a chosen-but-unavailable engine tells you how to fix it."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:dQ0.map((H)=>R("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[K("input",{type:"radio",name:"transcription-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>q(H.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:H.label}),K("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&K("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function cQ0(){let[X,J]=M7.useState(null),[Q,Y]=M7.useState(null),W=M7.useCallback(()=>{fetch("/_api/generate/whisper-model").then((z)=>z.ok?z.json():Promise.reject(Error(`HTTP ${z.status}`))).then(J).catch((z)=>Y(z&&z.message?z.message:"failed to load models"))},[]);M7.useEffect(()=>{W()},[W]),M7.useEffect(()=>{if(!X?.downloading)return;let z=setInterval(W,1000);return()=>clearInterval(z)},[X?.downloading,W]);async function G(z){Y(null);try{let U=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:z})});if(!U.ok)throw Error(await U.text());W()}catch(U){Y(U&&U.message?U.message:"download failed")}}async function q(z){Y(null);try{let U=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:z})});if(!U.ok)throw Error(await U.text());W()}catch(U){Y(U&&U.message?U.message:"remove failed")}}let H=X?.downloading,Z=(z,U)=>U>0?Math.min(100,Math.round(z/U*100)):0;return R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Local subtitle models (whisper.cpp)"})}),R("div",{className:"st-provider-notes",children:["Download a model once and local subtitles work offline, free, with no key. Requires the whisper.cpp binary (",K("code",{children:"brew install whisper-cpp"}),"). Models are stored on this machine only and never committed."]}),Q&&K("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&R("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),X===null&&!Q&&K("div",{className:"st-settings-intro",children:"Loading…"}),K("div",{className:"st-model-list",children:(X?.models||[]).map((z)=>{let U=H&&!H.error&&H.id===z.id;return R("div",{className:"st-model-row",children:[R("div",{className:"st-model-info",children:[R("span",{className:"st-model-label",children:[z.label,K("span",{className:"st-pill"+(z.multilingual?"":" is-local"),children:z.multilingual?"multilingual":"English-only"}),R("span",{className:"st-model-size",children:["~",z.sizeMB," MB"]})]}),K("span",{className:"st-engine-radio-note",children:z.note}),U&&R("span",{className:"st-model-progress",children:["Downloading… ",Z(H.received,H.total),"%"]})]}),K("div",{className:"st-model-actions",children:z.downloaded?R(Q0,{children:[R("span",{className:"st-provider-configured",children:[K(fH,{name:"check",size:12})," ready"]}),K("button",{type:"button",className:"st-btn",onClick:()=>q(z.id),children:"Remove"})]}):K("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(z.id),children:U?"Downloading…":"Download"})})]},z.id)})})]})}var _J=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation"},{id:"subtitles",label:"Subtitles"}],Cy="mdcc-settings-tab",iQ0=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}];function oQ0({value:X,disabled:J,onChange:Q}){return K("span",{className:"st-sidetoggle",role:"radiogroup","aria-label":"Panel side",children:["left","right"].map((Y)=>K("button",{type:"button",role:"radio","aria-checked":X===Y,disabled:J,className:"st-sidebtn"+(X===Y?" is-active":""),onClick:()=>Q(Y),children:Y==="left"?"Left":"Right"},Y))})}var nQ0=[{id:"separate",label:"Separate panel",note:"Layers docks on its own (default: left)."},{id:"in-inspector",label:"Inside Inspector",note:"Layers is a tab within the Inspector."}];function rQ0({panelSide:X,onSetPanelSide:J,layersMode:Q,onSetLayersMode:Y}){return R(Q0,{children:[R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Layers panel"})}),K("div",{className:"st-provider-notes",children:"Show Layers as its own dockable panel, or as a tab inside the Inspector."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Layers mode",children:nQ0.map((W)=>R("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"layers-mode",checked:Q===W.id,onChange:()=>Y(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Panel positions"})}),K("div",{className:"st-provider-notes",children:"Dock each panel to the left or right side. Each side shows one panel at a time, with tabs to switch between the panels docked there."}),iQ0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return R("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[R("span",{className:"st-pref-body",children:[K("span",{className:"st-pref-label",children:W.label}),G&&K("span",{className:"st-pref-note",children:"Layers is inside the Inspector — choose “Separate panel” above to dock it."})]}),K(oQ0,{value:X?.[W.id]||"left",disabled:G,onChange:(q)=>J(W.id,q)})]},W.id)})]})]})}function Z2({label:X,note:J,checked:Q,disabled:Y,reason:W,onChange:G}){return R("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[R("span",{className:"st-pref-body",children:[K("span",{className:"st-pref-label",children:X}),(W||J)&&K("span",{className:"st-pref-note",children:Y&&W?W:J})]}),K("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(q)=>G?.(q.target.checked)})]})}var aQ0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],sQ0=[{id:"advanced",label:"Advanced",note:"Raw CSS property names — border-radius, flex-direction…"},{id:"designer",label:"Designer",note:"Figma vocabulary — Fill, Stroke, Corner radius, Auto layout…"}];function tQ0({theme:X,onSetTheme:J,cpMode:Q,onSetCpMode:Y}){return R(Q0,{children:[R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Theme"})}),K("div",{className:"st-provider-notes",children:"Controls Maude’s own chrome — menubar, sidebar, canvas plane, minimap, zoom HUD. Artboards keep their own design-system theme."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Theme",children:aQ0.map((W)=>R("label",{className:"st-engine-radio"+(X===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"maude-theme",value:W.id,checked:X===W.id,onChange:()=>J?.(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Inspector vocabulary"})}),K("div",{className:"st-provider-notes",children:"How the CSS panel labels controls. You can also flip this from the small toggle in the panel’s own corner — this choice is remembered."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Inspector vocabulary",children:sQ0.map((W)=>R("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"maude-cp-mode",value:W.id,checked:Q===W.id,onChange:()=>Y?.(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]})]})}function wM({onClose:X,initialTab:J,theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G,minimapVisible:q,onToggleMinimap:H,zoomCtlVisible:Z,onToggleZoomCtl:z,annotationsVisible:U,onToggleAnnotations:B,autoOpenInspector:F,onToggleAutoOpenInspector:L,hasCanvas:D=!1,panelSide:w,onSetPanelSide:E,layersMode:A,onSetLayersMode:O}){let[P,I]=M7.useState(null),[T,C]=M7.useState(null),[S,j]=M7.useState(()=>{if(J&&_J.some((i)=>i.id===J))return J;try{let i=localStorage.getItem(Cy);if(i&&_J.some((v)=>v.id===i))return i}catch{}return"appearance"});M7.useEffect(()=>{try{localStorage.setItem(Cy,S)}catch{}},[S]);let b=M7.useCallback(()=>{fetch("/_api/generate/providers").then((i)=>{if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}).then((i)=>I(Array.isArray(i?.providers)?i.providers:[])).catch((i)=>C(i&&i.message?i.message:"failed to load providers"))},[]);M7.useEffect(()=>{b()},[b]),M7.useEffect(()=>{function i(v){if(v.key==="Escape")v.preventDefault(),X()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[X]);function h(i){let v=_J.findIndex((n)=>n.id===S);if(i.key==="ArrowDown"||i.key==="ArrowRight")i.preventDefault(),j(_J[(v+1)%_J.length].id);else if(i.key==="ArrowUp"||i.key==="ArrowLeft")i.preventDefault(),j(_J[(v-1+_J.length)%_J.length].id);else if(i.key==="Home")i.preventDefault(),j(_J[0].id);else if(i.key==="End")i.preventDefault(),j(_J[_J.length-1].id)}let d=!D?"Open a canvas to use this.":void 0;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)X()},children:R("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Settings"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:K(fH,{name:"x",size:15})})]}),R("div",{className:"st-settings-tabs",children:[K("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:h,children:_J.map((i)=>K("button",{type:"button",role:"tab",id:`st-stab-${i.id}`,"aria-controls":`st-spanel-${i.id}`,"aria-selected":S===i.id,tabIndex:S===i.id?0:-1,className:"st-settings-tab"+(S===i.id?" is-active":""),onClick:()=>j(i.id),children:i.label},i.id))}),R("div",{className:"st-settings-pane",children:[R("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:S!=="appearance",children:[K("div",{className:"st-rp-hd",children:"Appearance"}),K(tQ0,{theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G})]}),R("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:S!=="canvas-view",children:[K("div",{className:"st-rp-hd",children:"Canvas & View"}),K(Z2,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:q,disabled:!D,reason:d,onChange:()=>H?.()}),K(Z2,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:Z,disabled:!D,reason:d,onChange:()=>z?.()}),K(Z2,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:U,onChange:()=>B?.()}),K(Z2,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>L?.()})]}),R("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:S!=="layout",children:[K("div",{className:"st-rp-hd",children:"Layout"}),K(rQ0,{panelSide:w,onSetPanelSide:E,layersMode:A,onSetLayersMode:O})]}),R("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:S!=="ai-generation",children:[K("div",{className:"st-rp-hd",children:"Provider keys"}),R("p",{className:"st-settings-intro",children:["Bring your own API keys to generate images (and, soon, audio + video) inside Maude. Keys are stored on this machine only — in your OS keychain or a private"," ",K("code",{children:"~/.config/maude/keys.json"})," (mode 0600) — sent straight to the provider, and never committed, logged, or exposed to a canvas."]}),T&&K("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:T}),P===null&&!T&&K("div",{className:"st-settings-intro",children:"Loading…"}),P?.map((i)=>K(lQ0,{provider:i,onChanged:b},i.id)),P?.length===0&&K("div",{className:"st-settings-intro",children:"No providers registered."})]}),R("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:S!=="subtitles",children:[K("div",{className:"st-rp-hd",children:"Subtitles"}),K(pQ0,{}),K(cQ0,{})]})]})]})]})})}var UY=R8(x8(),1);function eQ0({name:X,size:J=15}){if(X==="x")return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:K("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})});return null}function AM({onPick:X,onClose:J}){let[Q,Y]=UY.useState(null),[W,G]=UY.useState("");UY.useEffect(()=>{let Z=!0;return fetch("/_api/stickers").then((z)=>z.json()).then((z)=>Z&&Y(z.ok?z.packs:[])).catch(()=>Z&&Y([])),()=>{Z=!1}},[]),UY.useEffect(()=>{let Z=(z)=>{if(z.key==="Escape")z.stopPropagation(),J()};return window.addEventListener("keydown",Z,!0),()=>window.removeEventListener("keydown",Z,!0)},[J]);let q=UY.useMemo(()=>{if(!Q)return[];let Z=W.trim().toLowerCase();if(!Z)return Q;return Q.map((z)=>({...z,stickers:z.stickers.filter((U)=>U.file.toLowerCase().includes(Z)||(U.keywords||[]).some((B)=>B.toLowerCase().includes(Z)))})).filter((z)=>z.stickers.length>0)},[Q,W]),H=q.reduce((Z,z)=>Z+z.stickers.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Z)=>{if(Z.target===Z.currentTarget)J()},children:R("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Stickers"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:J,children:K(eQ0,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("input",{className:"input",type:"text",value:W,onChange:(Z)=>G(Z.target.value),placeholder:"Search stickers…","aria-label":"Search stickers",autoFocus:!0}),K("div",{className:"st-sp-body",children:Q==null?K("div",{className:"st-sp-empty",children:"Loading…"}):H===0?K("div",{className:"st-sp-empty",children:W.trim()?`No stickers match "${W.trim()}"`:"No stickers bundled"}):q.map((Z)=>R("div",{children:[R("div",{className:"st-sp-pack-hd",children:[K("span",{className:"st-sp-pack-name",children:Z.name}),Z.author&&R("span",{className:"st-sp-pack-author",children:["by ",Z.author]})]}),K("div",{className:"st-sp-grid",children:Z.stickers.map((z)=>K("button",{type:"button",className:"st-sp-cell",title:z.keywords?.[0]||z.file,onClick:()=>X(z),children:K("img",{className:"st-sp-thumb",src:z.url,alt:z.keywords?.[0]||z.file,loading:"lazy"})},z.file))})]},Z.slug))})]}),Q&&Q.length>0&&K("div",{className:"st-sp-ft",children:Q.map((Z)=>R("span",{children:[Z.name,Z.author?` — ${Z.author}`:"",Z.attributionUrl?R(Q0,{children:[" ","(",K("a",{href:Z.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},Z.slug))})]})})}var S6=R8(x8(),1);var V2=R8(x8(),1);var K2=(...X)=>X.filter((J,Q,Y)=>{return Boolean(J)&&J.trim()!==""&&Y.indexOf(J)===Q}).join(" ").trim();var Sy=(X)=>X.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var $y=(X)=>X.replace(/^([A-Z])|[\s-_]+(\w)/g,(J,Q,Y)=>Y?Y.toUpperCase():Q.toLowerCase());var _M=(X)=>{let J=$y(X);return J.charAt(0).toUpperCase()+J.slice(1)};var Pz=R8(x8(),1);var z2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var by=(X)=>{for(let J in X)if(J.startsWith("aria-")||J==="role"||J==="title")return!0;return!1};var vH=R8(x8(),1),X40=vH.createContext({});var jy=()=>vH.useContext(X40);var yy=Pz.forwardRef(({color:X,size:J,strokeWidth:Q,absoluteStrokeWidth:Y,className:W="",children:G,iconNode:q,...H},Z)=>{let{size:z=24,strokeWidth:U=2,absoluteStrokeWidth:B=!1,color:F="currentColor",className:L=""}=jy()??{},D=Y??B?Number(Q??U)*24/Number(J??z):Q??U;return Pz.createElement("svg",{ref:Z,...z2,width:J??z??z2.width,height:J??z??z2.height,stroke:X??F,strokeWidth:D,className:K2("lucide",L,W),...!G&&!by(H)&&{"aria-hidden":"true"},...H},[...q.map(([w,E])=>Pz.createElement(w,E)),...Array.isArray(G)?G:[G]])});var X8=(X,J)=>{let Q=V2.forwardRef(({className:Y,...W},G)=>V2.createElement(yy,{ref:G,iconNode:J,className:K2(`lucide-${Sy(_M(X))}`,`lucide-${X}`,Y),...W}));return Q.displayName=_M(X),Q};var J40=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Rz=X8("a-large-small",J40);var Q40=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]],kz=X8("align-horizontal-justify-center",Q40);var Y40=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]],Iz=X8("align-horizontal-justify-end",Y40);var W40=[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],Tz=X8("align-horizontal-justify-start",W40);var G40=[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]],xH=X8("align-horizontal-space-between",G40);var q40=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Cz=X8("align-vertical-justify-center",q40);var H40=[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]],Sz=X8("align-vertical-justify-end",H40);var Z40=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]],$z=X8("align-vertical-justify-start",Z40);var K40=[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]],bz=X8("baseline",K40);var z40=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],jz=X8("bold",z40);var V40=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],BY=X8("braces",V40);var U40=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],yz=X8("chevron-down",U40);var B40=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],FY=X8("columns-3",B40);var F40=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],fz=X8("diamond",F40);var N40=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],vz=X8("eye-off",N40);var L40=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],zG=X8("eye",L40);var D40=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],xz=X8("italic",D40);var O40=[["path",{d:"M5 12h14",key:"1ays0h"}]],hz=X8("minus",O40);var M40=[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]],gz=X8("move-horizontal",M40);var w40=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],mz=X8("rotate-ccw",w40);var A40=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],VG=X8("rotate-cw",A40);var _40=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],NY=X8("rows-3",_40);var E40=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],uz=X8("scissors",E40);var P40=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],lz=X8("scroll-text",P40);var R40=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],dz=X8("search",R40);var k40=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],pz=X8("spline",k40);var I40=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],LY=X8("square-dashed",I40);var T40=[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]],cz=X8("stretch-horizontal",T40);var C40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],DY=X8("text-align-center",C40);var S40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],OY=X8("text-align-end",S40);var $40=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],MY=X8("text-align-justify",$40);var b40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],dJ=X8("text-align-start",b40);var j40=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],iz=X8("underline",j40);var y40=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],wY=X8("wand-sparkles",y40);var f40=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],oz=X8("x",f40);var AY=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block",flex:"none"}}),EM=(X)=>X.replace(/^--/,"").replace(/-/g," "),_Y=(X,J,Q)=>{let Y=X;if(J!=null&&Y<J)Y=J;if(Q!=null&&Y>Q)Y=Q;return Y},v40=(X)=>{if(!(X>0))return 2;if(X>=1)return 0;let J=String(X),Q=J.indexOf(".");return Q===-1?0:J.length-Q-1},hH=(X,J)=>{let Q=v40(J);return Number(X.toFixed(Q))};function PM({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:q=1,sides:H}){return(Z)=>{if(Z.button!==0)return;let z=Z.clientX,U=Number.parseFloat(X())||0,B=!1,F=U,L=(E)=>{if(!H)return;if(E.altKey&&E.shiftKey)return H.all;if(E.altKey)return H.pair;return},D=(E)=>{let A=E.clientX-z;if(!B&&Math.abs(A)<3)return;if(!B)B=!0,document.body.classList.add("st-scrubbing");E.preventDefault();let O=H?1:E.shiftKey?10:E.altKey?0.1:1;F=hH(_Y(U+A*Y*q*O,J,Q),Y),W?.(F,L(E))},w=(E)=>{if(document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",w),!B)return;document.body.classList.remove("st-scrubbing"),G?.(F,L(E))};document.addEventListener("pointermove",D),document.addEventListener("pointerup",w)}}function x40({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:q=1,sides:H}){return S6.useCallback(PM({getBase:X,min:J,max:Q,step:Y,onInput:W,onCommit:G,sensitivity:q,sides:H}),[X,J,Q,Y,W,G,q,H])}function UG({value:X,min:J,max:Q,step:Y=1,lead:W,scrub:G=!0,steppers:q=!0,unitSlot:H,sensitivity:Z=1,sides:z,format:U,parse:B,onInput:F,onCommit:L,ariaLabel:D,className:w=""}){let E=S6.useRef(null),A=S6.useCallback((h)=>U?U(h):String(hH(Number(h)||0,Y)),[U,Y]),O=(h)=>(typeof h==="number"?h:Number.parseFloat(h))||0;S6.useEffect(()=>{if(E.current&&document.activeElement!==E.current)E.current.value=A(X)},[X,A]);let P=(h,d)=>{let i=hH(_Y(h,J,Q),Y);if(E.current)E.current.value=A(i);L?.(i,d)},T=x40({getBase:()=>E.current?E.current.value:O(X),min:J,max:Q,step:Y,sensitivity:Z,sides:z,onInput:(h,d)=>{let i=hH(_Y(h,J,Q),Y);if(E.current)E.current.value=A(i);F?.(i,d)},onCommit:P}),C=(h,d)=>P(O(E.current?.value??X)+h*Y*d),S=(h)=>{let d=h.shiftKey?10:1;if(h.key==="ArrowUp")h.preventDefault(),C(1,d);else if(h.key==="ArrowDown")h.preventDefault(),C(-1,d);else if(h.key==="PageUp")h.preventDefault(),C(1,10);else if(h.key==="PageDown")h.preventDefault(),C(-1,10);else if(h.key==="Home"&&J!=null)h.preventDefault(),P(J);else if(h.key==="End"&&Q!=null)h.preventDefault(),P(Q);else if(h.key==="Enter")h.currentTarget.blur()},j=(h)=>{let d=h.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===d)d.select()})},b=(h)=>{let d=String(h.currentTarget.value).trim();if(d==="")return;let i=B?B(d):Number.parseFloat(d);if(i==null||Number.isNaN(i)){h.currentTarget.value=A(X);return}P(i)};return R("div",{className:`st-cp-num ${w}`.trim(),children:[G?K("span",{className:"st-cp-numlead st-cp-handle",role:"presentation","aria-hidden":"true",title:"Drag to change · Shift ×10 · Alt fine",onPointerDown:T,children:W??K("span",{className:"st-cp-grip"})}):W?K("span",{className:"st-cp-numlead","aria-hidden":"true",children:W}):null,K("input",{ref:E,className:"st-cp-numin",role:"spinbutton","aria-label":D,"aria-valuenow":O(X),"aria-valuemin":J,"aria-valuemax":Q,defaultValue:A(X),inputMode:"decimal",onFocus:j,onKeyDown:S,onBlur:b}),q?R("span",{className:"st-cp-step",children:[K("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`increase ${D||"value"}`,onClick:()=>C(1,1),children:"▲"}),K("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`decrease ${D||"value"}`,onClick:()=>C(-1,1),children:"▼"})]}):null,H??null]})}function h40({value:X,min:J=0,max:Q=1,step:Y=0.01,onInput:W,onCommit:G,ariaLabel:q}){let H=S6.useRef(null),Z=_Y(X??(J<0?0:J),J,Q),z=Q-J||1,U=(Z-J)/z,B=J<0&&Q>0?(0-J)/z:0,F=Math.min(U,B),L=Math.abs(U-B),D=(A)=>{let O=H.current?.getBoundingClientRect();if(!O||O.width===0)return Z;let P=_Y((A-O.left)/O.width,0,1);return hH(J+P*z,Y)};return K("div",{className:"st-cp-slider",children:R("div",{ref:H,className:"st-cp-track",role:"slider",tabIndex:0,"aria-label":q,"aria-valuemin":J,"aria-valuemax":Q,"aria-valuenow":Z,onPointerDown:(A)=>{if(A.button!==0)return;A.preventDefault(),H.current?.focus();let O=D(A.clientX);W?.(O);let P=(T)=>{O=D(T.clientX),W?.(O)},I=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",I),G?.(O)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",I)},onKeyDown:(A)=>{let O=A.shiftKey?10:1,P=null;if(A.key==="ArrowRight"||A.key==="ArrowUp")P=Z+Y*O;else if(A.key==="ArrowLeft"||A.key==="ArrowDown")P=Z-Y*O;else if(A.key==="PageUp")P=Z+Y*10;else if(A.key==="PageDown")P=Z-Y*10;else if(A.key==="Home")P=J;else if(A.key==="End")P=Q;if(P!=null)A.preventDefault(),G?.(hH(_Y(P,J,Q),Y))},children:[J<0&&Q>0?K("span",{className:"st-cp-zero",style:{left:`${B*100}%`}}):null,K("span",{className:"st-cp-fill",style:{left:`${F*100}%`,width:`${L*100}%`}}),K("span",{className:"st-cp-thumb",style:{left:`${U*100}%`}})]})})}function m5({value:X,min:J=0,max:Q=1,step:Y=0.01,unit:W="",onInput:G,onCommit:q,ariaLabel:H}){let Z=X??(J<0?0:J);return R("div",{className:"st-cp-sfield",children:[K(h40,{value:Z,min:J,max:Q,step:Y,onInput:G,onCommit:q,ariaLabel:H}),K(UG,{className:"st-cp-num--compact",value:Z,min:J,max:Q,step:Y,scrub:!1,steppers:!1,unitSlot:W?K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null,onInput:G,onCommit:q,ariaLabel:H})]})}function RM({value:X,units:J,onChange:Q,ariaLabel:Y}){return K("select",{className:"st-cp-unitsel","aria-label":Y,value:X,onChange:(W)=>Q(W.target.value),children:J.map((W)=>K("option",{value:W,children:W},W))})}function fy({value:X,options:J,onChange:Q,ariaLabel:Y}){return K("div",{className:"st-cp-seg",role:"radiogroup","aria-label":Y,children:J.map((W)=>{let G=typeof W==="string"?W:W.value,q=typeof W==="string"?W:W.label??W.value;return K("button",{type:"button",role:"radio","aria-checked":X===G,className:`st-cp-segbtn${X===G?" is-active":""}`,onClick:()=>Q(G),children:q},G)})})}function U2({value:X,options:J,onChange:Q,ariaLabel:Y,mini:W=!1}){return K("select",{className:`st-cp-nsel${W?" st-cp-nsel--mini":""}`,"aria-label":Y,value:X,onChange:(G)=>Q(G.target.value),children:J.map((G)=>{let q=typeof G==="string"?G:G.value,H=typeof G==="string"?G:G.label??G.value;return K("option",{value:q,children:H},q)})})}function EY({checked:X,onChange:J,label:Q,ariaLabel:Y}){return R("label",{className:"st-cp-toggle",children:[K("input",{type:"checkbox",className:"st-cp-switch",checked:!!X,"aria-label":Y||Q,onChange:(W)=>J(W.target.checked)}),Q?K("span",{className:"st-cp-toggle-lbl",children:Q}):null]})}function kM({value:X,options:J,ariaLabel:Q,onChange:Y}){return K("div",{className:"st-cp-iconseg",role:"radiogroup","aria-label":Q,children:J.map((W)=>K("button",{type:"button",role:"radio","aria-checked":X===W.value,"aria-label":W.label,title:W.label,className:X===W.value?"is-active":"",onClick:()=>Y(W.value),children:W.node},W.value))})}function vy({value:X,options:J,ariaLabel:Q,onToggle:Y}){return K("div",{className:"st-cp-iconseg",role:"group","aria-label":Q,children:J.map((W)=>K("button",{type:"button","aria-pressed":!!X[W.value],"aria-label":W.label,title:W.label,onClick:()=>Y(W.value),children:W.node},W.value))})}var g40=["tl","tc","tr","cl","cc","cr","bl","bc","br"];function xy({value:X,onChange:J,ariaLabel:Q="alignment"}){return K("div",{className:"st-cp-alignpad",role:"radiogroup","aria-label":Q,children:g40.map((Y)=>K("button",{type:"button",role:"radio","aria-checked":X===Y,"aria-label":`align ${Y}`,className:X===Y?"is-active":"",onClick:()=>J(Y)},Y))})}function hy({value:X,onChange:J,ariaLabel:Q="rotation"}){let Y=S6.useRef(null),W=(Z,z)=>{let U=Y.current?.getBoundingClientRect();if(!U)return X;let B=Math.round(Math.atan2(z-(U.top+U.height/2),Z-(U.left+U.width/2))*180/Math.PI);if(B<0)B+=360;return B},G=(Z)=>{if(Z.button!==0)return;Z.preventDefault(),document.body.classList.add("st-scrubbing","st-scrubbing--dial"),J(W(Z.clientX,Z.clientY));let z=(B)=>J(W(B.clientX,B.clientY)),U=()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",U),document.body.classList.remove("st-scrubbing","st-scrubbing--dial")};document.addEventListener("pointermove",z),document.addEventListener("pointerup",U)},q=X??0,H=(Z)=>{let z=Z.shiftKey?10:1,U=null;if(Z.key==="ArrowRight"||Z.key==="ArrowUp")U=q+z;else if(Z.key==="ArrowLeft"||Z.key==="ArrowDown")U=q-z;else if(Z.key==="PageUp")U=q+15;else if(Z.key==="PageDown")U=q-15;else if(Z.key==="Home")U=0;else if(Z.key==="End")U=360;if(U!=null)Z.preventDefault(),J(_Y(U,0,360))};return K("button",{ref:Y,type:"button",className:"st-cp-dial",role:"slider","aria-label":Q,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":q,"aria-valuetext":`${q}°`,title:"drag to rotate · arrows to nudge",onPointerDown:G,onKeyDown:H,children:K("span",{className:"st-cp-dial-needle",style:{"--angle":`${X}deg`}})})}function gy({title:X,defaultOpen:J=!0,onReset:Q,right:Y,children:W}){let[G,q]=S6.useState(J);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":G,onClick:()=>q((H)=>!H),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:K(AY,{as:yz,size:12})}),X]}),Y??null,Q?K("button",{type:"button",className:"st-cp-secreset","aria-label":`reset ${X} section`,title:`reset ${X}`,onClick:Q,children:K(AY,{as:mz,size:12})}):null]}),K("div",{className:`st-cp-sec-anim${G?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:W})})]})}function B2({swatch:X,displayValue:J,bound:Q,alpha:Y,visible:W,ariaLabel:G,onValue:q,onAlpha:H,onVisible:Z}){return R("span",{className:"st-cp-cf",children:[X,K("input",{className:`st-cp-cf-in${Q?" is-bound":""}`,"aria-label":G,value:J,onChange:(z)=>q?.(z.target.value),onFocus:(z)=>z.currentTarget.select(),readOnly:!q}),H?K("input",{className:"st-cp-cf-alpha","aria-label":`${G||"colour"} alpha`,value:`${Y}`,onChange:(z)=>H(_Y(Number.parseFloat(z.target.value)||0,0,100)),onFocus:(z)=>z.currentTarget.select()}):null,Z?K("button",{type:"button",className:`st-cp-cf-eye${W?"":" is-off"}`,"aria-pressed":W,"aria-label":`${G||"colour"} visibility`,onClick:()=>Z(!W),children:W?K(AY,{as:zG}):K(AY,{as:vz})}):null]})}function my({value:X,tokens:J,ariaLabel:Q,lead:Y,unit:W,unitSlot:G,min:q=0,max:H,step:Z=1,onChange:z}){let[U,B]=S6.useState(!1),[F,L]=S6.useState(""),D=S6.useRef(null),w=typeof X==="string"&&X.startsWith("var("),E=w?X.replace(/^var\(\s*|\s*\)$/g,""):"",A=w?J.find((P)=>P.name===E)?.value??"":"";S6.useEffect(()=>{if(!U){L("");return}let P=(I)=>{if(!D.current?.contains(I.target))B(!1)};return document.addEventListener("pointerdown",P,!0),()=>document.removeEventListener("pointerdown",P,!0)},[U]);let O=F?J.filter((P)=>EM(P.name).includes(F)||(P.value||"").toLowerCase().includes(F)):J;return R("div",{className:"st-cp-tokfield",children:[w?R("div",{className:"st-cp-boundchip",title:`${E} = ${A}`,children:[Y?K("span",{className:"st-cp-boundchip-lead","aria-hidden":"true",children:Y}):null,K("span",{className:"st-cp-boundchip-name",children:EM(E)}),K("button",{type:"button",className:"st-cp-boundchip-x","aria-label":"detach token",title:"detach — back to a raw value",onClick:()=>z(Number.parseFloat(A)||0),children:K(AY,{as:oz,size:12})})]}):K(UG,{value:typeof X==="number"?X:0,min:q,max:H,step:Z,ariaLabel:Q,lead:Y,steppers:!1,unitSlot:G??(W?K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null),onCommit:(P)=>z(P)}),R("span",{ref:D,style:{position:"relative",display:"inline-flex"},children:[K("button",{type:"button",className:`st-cp-tokbtn${w?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":`${Q} — bind a design token`,title:"bind a design token",onClick:()=>B((P)=>!P),children:K(AY,{as:fz,size:13})}),U?R("div",{className:"st-cp-pop",role:"dialog","aria-label":"design tokens",style:{left:"auto",right:0},children:[R("div",{className:"st-cp-pop-search",children:[K(AY,{as:dz,size:12}),K("input",{value:F,onChange:(P)=>L(P.target.value.toLowerCase()),placeholder:"Search variables","aria-label":"search variables"})]}),O.length?O.map((P)=>R("button",{type:"button",className:`st-cp-pop-row${E===P.name?" is-on":""}`,onClick:()=>{z(`var(${P.name})`),B(!1)},children:[K("span",{className:"st-cp-pop-name",children:EM(P.name)}),K("span",{className:"st-cp-pop-val",children:P.value})]},P.name)):K("div",{className:"st-cp-pop-empty",children:"No match"})]}):null]})]})}function uy({corners:X,lead:J,onCorners:Q}){let[Y,W]=S6.useState(!1),G=(H)=>Q({tl:H,tr:H,bl:H,br:H}),q=(H)=>R("label",{className:"st-cp-corner",children:[K("span",{className:`st-cp-cnr st-cp-cnr--${H}`,"aria-hidden":"true"}),K("input",{"aria-label":`${H} radius`,value:X[H],onChange:(Z)=>Q({...X,[H]:Number.parseFloat(Z.target.value)||0}),onFocus:(Z)=>Z.currentTarget.select()})]});return R("div",{className:"st-cp-radius",children:[R("div",{className:"st-cp-radius-main",children:[K(UG,{value:X.tl,min:0,max:200,ariaLabel:"border-radius",lead:J,steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(H)=>Y?Q({...X,tl:H}):G(H)}),K("button",{type:"button",className:`st-cp-splitbtn${Y?" is-on":""}`,"aria-pressed":Y,"aria-label":"detach corners",title:"detach corners — edit each independently",onClick:()=>W((H)=>!H),children:K(AY,{as:LY,size:14})})]}),Y?R("div",{className:"st-cp-corners",children:[q("tl"),q("tr"),q("bl"),q("br")]}):null]})}var O6=R8(x8(),1);var m40=["dots","grid","lines","diagonal","crosshatch"],u40=["normal","multiply","screen","overlay","soft-light"],l40=["none","vignette","radial-reveal","edge-fade"],d40=[{key:"brightness",label:"Brightness",min:-1,max:1},{key:"contrast",label:"Contrast",min:-1,max:1},{key:"saturation",label:"Saturation",min:-1,max:1},{key:"exposure",label:"Exposure",min:-1,max:1},{key:"hue",label:"Hue",min:-180,max:180,step:1,unit:"°"},{key:"sepia",label:"Sepia",min:0,max:1},{key:"grayscale",label:"Grayscale",min:0,max:1},{key:"invert",label:"Invert",min:0,max:1}],ly=(X)=>X?JSON.parse(JSON.stringify(X)):{};function p40(X){let J={};for(let[Q,Y]of Object.entries(X)){if(Y==null)continue;if(typeof Y==="object"&&!Array.isArray(Y)){let W={};for(let[G,q]of Object.entries(Y))if(q!=null&&q!=="")W[G]=q;if(Object.keys(W).length)J[Q]=W}else J[Q]=Y}return J}var PY={body:{fontSize:12,color:"var(--fg-0)",overflowY:"auto"},sec:{marginBottom:"var(--space-4)"},secHead:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,textTransform:"uppercase",letterSpacing:"var(--tracking-wide)",color:"var(--fg-2)",margin:"4px 0 8px"},row:{display:"flex",alignItems:"center",gap:8,margin:"var(--space-2) 0"},label:{flex:"0 0 72px",fontSize:11,color:"var(--fg-1)"},tip:{flex:1,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10,color:"var(--fg-2)",textAlign:"left"},tipBelow:{marginLeft:80,marginTop:2,marginBottom:"var(--space-2)",fontSize:10,color:"var(--fg-2)",lineHeight:1.4},reset:{font:"inherit",fontSize:10,padding:"1px 6px",borderRadius:"var(--radius-xs)",border:"1px solid transparent",background:"transparent",color:"var(--fg-2)",cursor:"pointer"}};function gH({title:X,right:J,onReset:Q,children:Y}){return K(gy,{title:X,right:J,onReset:Q,children:Y})}function uX({label:X,tip:J,children:Q}){return R(Q0,{children:[R("div",{style:PY.row,children:[K("span",{style:PY.label,children:X}),Q]}),J?K("div",{style:PY.tipBelow,children:J}):null]})}function IM({value:X,fallback:J,label:Q,ColorPicker:Y,onApply:W}){let[G,q]=O6.useState(!1),H=O6.useRef(null),Z=X||J;return O6.useEffect(()=>{if(!G)return;let z=(U)=>{if(!H.current?.contains(U.target))q(!1)};return document.addEventListener("pointerdown",z,!0),()=>document.removeEventListener("pointerdown",z,!0)},[G]),K(B2,{swatch:R("span",{className:"st-cp-tokwrap",ref:H,children:[K("button",{type:"button",className:"st-cp-cf-sw",style:{background:Z},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:Z,onClick:()=>q((z)=>!z)}),G?K("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?K(Y,{seed:Z,label:Q,onApply:W}):K("input",{type:"color",value:Z,"aria-label":Q,onChange:(z)=>W(z.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(Z||"").replace("#",""),ariaLabel:Q,onValue:(z)=>W(z.startsWith("#")?z:`#${z.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function dy({asset:X,initialEdit:J,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:q}){let[H,Z]=O6.useState(()=>ly(J)),[z,U]=O6.useState(!J),[B,F]=O6.useState("idle"),[L,D]=O6.useState(!1),[w,E]=O6.useState(""),A=O6.useRef(null),O=O6.useRef(H);O.current=H,O6.useEffect(()=>{if(J||!X)return;let g=!1;return U(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`).then((G0)=>G0.ok?G0.json():{}).then((G0)=>{if(g)return;Z(G0&&typeof G0==="object"?G0:{}),U(!1)}).catch(()=>!g&&U(!1)),()=>{g=!0}},[X,J]);let P=O6.useCallback((g)=>{clearTimeout(A.current),A.current=setTimeout(async()=>{F("saving");try{let G0=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p40(g))});F(G0.ok?"saved":"error")}catch{F("error")}},160)},[X]),I=O6.useCallback((g,{commit:G0=!1}={})=>{let e=O.current,l=ly(e);if(g(l),Z(l),Y?.(l),P(l),G0)G?.(e,l)},[Y,P,G]),T=(g,G0,e)=>I((l)=>{if(l.adjustments=l.adjustments||{},G0===0||G0==null)delete l.adjustments[g];else l.adjustments[g]=G0;if(Object.keys(l.adjustments).length===0)delete l.adjustments},{commit:e}),C=(g,G0,e)=>I((l)=>{l[g]={...l[g]||{},...G0}},{commit:e}),S=()=>I((g)=>delete g.adjustments,{commit:!0}),j=(g)=>I((G0)=>{delete G0[g]},{commit:!0}),b=async()=>{if(!W)return;D(!0),E("Removing background…");try{let g=await W(X);if(g?.maskAsset)C("backgroundRemoved",{enabled:!0,maskAsset:g.maskAsset},!0),E("Background removed");else E("Background removal failed")}catch{E("Background removal failed")}finally{D(!1)}};if(z)return K("div",{style:{...PY.body,opacity:0.6},children:"Loading photo edit…"});let h=H.adjustments||{},d=H.duotone||{},i=H.grain||{},v=H.pattern||{},n=H.mask||{},Y0=H.backgroundRemoved||{};return R("div",{style:PY.body,"data-testid":"photo-knobs",children:[R("div",{style:{...PY.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[K("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:X}),K("span",{style:{fontSize:10,color:B==="error"?"var(--status-error)":void 0},children:B==="saving"?"saving…":B==="error"?"⚠ save failed":B==="saved"?"saved":""})]}),K(gH,{title:"Adjustments",onReset:S,children:d40.map((g)=>K(uX,{label:g.label,children:K(m5,{value:h[g.key],min:g.min,max:g.max,step:g.step??0.01,unit:g.unit??"",ariaLabel:g.label,onInput:(G0)=>T(g.key,G0),onCommit:(G0)=>T(g.key,G0,!0)})},g.key))}),K(gH,{title:"Duotone",right:K(EY,{checked:d.enabled,onChange:(g)=>C("duotone",{enabled:g},!0),label:"on"}),onReset:()=>j("duotone"),children:d.enabled&&R(Q0,{children:[K(uX,{label:"Shadow",children:K(IM,{value:d.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(g)=>C("duotone",{colorA:g},!0)})}),K(uX,{label:"Highlight",children:K(IM,{value:d.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(g)=>C("duotone",{colorB:g},!0)})}),K(uX,{label:"Intensity",children:K(m5,{value:d.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(g)=>C("duotone",{intensity:g}),onCommit:(g)=>C("duotone",{intensity:g},!0)})})]})}),K(gH,{title:"Grain",right:K(EY,{checked:i.enabled,onChange:(g)=>C("grain",{enabled:g},!0),label:"on"}),onReset:()=>j("grain"),children:i.enabled&&R(Q0,{children:[K(uX,{label:"Amount",children:K(m5,{value:i.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(g)=>C("grain",{amount:g}),onCommit:(g)=>C("grain",{amount:g},!0)})}),K(uX,{label:"Size",children:K(m5,{value:i.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(g)=>C("grain",{size:g}),onCommit:(g)=>C("grain",{size:g},!0)})})]})}),K(gH,{title:"Pattern",right:K(EY,{checked:v.enabled,onChange:(g)=>C("pattern",{enabled:g},!0),label:"on"}),onReset:()=>j("pattern"),children:v.enabled&&R(Q0,{children:[K(uX,{label:"Type",children:K(U2,{value:v.type||"dots",options:m40,ariaLabel:"Pattern type",onChange:(g)=>C("pattern",{type:g},!0)})}),K(uX,{label:"Blend",children:K(U2,{value:v.blend||"normal",options:u40,ariaLabel:"Pattern blend",onChange:(g)=>C("pattern",{blend:g},!0)})}),K(uX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:K(IM,{value:v.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(g)=>C("pattern",{color:g},!0)})}),K(uX,{label:"Scale",children:K(m5,{value:v.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(g)=>C("pattern",{scale:g}),onCommit:(g)=>C("pattern",{scale:g},!0)})}),K(uX,{label:"Opacity",children:K(m5,{value:v.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(g)=>C("pattern",{opacity:g}),onCommit:(g)=>C("pattern",{opacity:g},!0)})})]})}),R(gH,{title:"Mask",onReset:()=>j("mask"),children:[K(uX,{label:"Preset",children:K(U2,{value:n.preset||"none",options:l40,ariaLabel:"Mask preset",onChange:(g)=>C("mask",{preset:g},!0)})}),n.preset&&n.preset!=="none"&&K(uX,{label:"Strength",children:K(m5,{value:n.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(g)=>C("mask",{strength:g}),onCommit:(g)=>C("mask",{strength:g},!0)})})]}),R(gH,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[K("div",{style:{...PY.row,gap:10},"aria-busy":L||void 0,children:Y0.maskAsset?R(Q0,{children:[K(EY,{checked:Y0.enabled,onChange:(g)=>C("backgroundRemoved",{enabled:g},!0),label:"applied"}),K("button",{type:"button",style:{...PY.reset,opacity:L?0.6:1},disabled:L||!W,title:"Run background removal again",onClick:()=>b(),children:L?"removing…":"redo"})]}):R("button",{type:"button",className:"st-btn",style:{opacity:L?0.6:1},disabled:L||!W,"data-testid":"photo-remove-bg",onClick:()=>b(),children:[q?K(q,{name:"sparkle",size:14}):null,L?"Removing…":"Remove Background"]})}),K("span",{"aria-live":"polite",className:"sr-only",children:w})]})]})}function mH({name:X,size:J=16}){let Q={cursor:K("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:R(Q0,{children:[K("circle",{cx:"6",cy:"6",r:"2.2"}),K("path",{d:"M2.4 13a3.6 3.6 0 0 1 7.2 0"}),K("path",{d:"M11 4.2a2.2 2.2 0 0 1 0 4.1M11.5 13a3.6 3.6 0 0 0-2-3.2"})]}),comment:K(Q0,{children:K("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:R(Q0,{children:[K("path",{d:"M3 2.5h7.5L13.5 5.5V13.5H3z"}),K("path",{d:"M5 2.5V6h5V2.5"}),K("rect",{x:"5.5",y:"9",width:"5",height:"3"})]}),publish:R(Q0,{children:[K("line",{x1:"8",y1:"13.4",x2:"8",y2:"6"}),K("polyline",{points:"5 9 8 6 11 9"}),K("polyline",{points:"3 4 3 2.6 13 2.6 13 4"})]}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),"arrow-right":R(Q0,{children:[K("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),K("polyline",{points:"9 4 13 8 9 12"})]})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:X==="cursor"?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function TM({icon:X,label:J,sub:Q}){return R("span",{className:"cm-step",children:[K("span",{className:"cm-step-icon",children:K(mH,{name:X,size:16})}),K("span",{className:"cm-step-label",children:J}),K("span",{className:"cm-step-sub",children:Q})]})}function CM(){return R("div",{className:"cm-info",children:[R("div",{className:"cm-live",children:[R("div",{className:"cm-live-hd",children:[K("span",{className:"cm-live-dot","aria-hidden":"true"}),R("span",{children:[K("b",{children:"Together"})," · automatic — no buttons"]})]}),R("div",{className:"cm-live-items",children:[R("span",{className:"cm-live-item",children:[K(mH,{name:"cursor",size:13})," cursors"]}),R("span",{className:"cm-live-item",children:[K(mH,{name:"people",size:13})," who's here"]}),R("span",{className:"cm-live-item",children:[K(mH,{name:"comment",size:13})," comments"]})]}),K("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),R("div",{className:"cm-bridge","aria-hidden":"true",children:[K("span",{className:"cm-bridge-line"}),K("span",{className:"cm-bridge-label",children:"the work itself"}),K("span",{className:"cm-bridge-line"})]}),R("div",{className:"cm-cycle",children:[K(TM,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),K("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:K(mH,{name:"arrow-right",size:15})}),K(TM,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),K("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:K(mH,{name:"arrow-right",size:15})}),K(TM,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var SM=[{render:CM,title:"Working together, in one picture",body:"There are two layers. Up top, being together just happens. Below, your work moves through three simple steps. Let’s walk them."},{target:"[data-tour='save-local']",changes:!0,title:"Save changes locally",body:"When something looks right, save it. That keeps a version on your computer you can always come back to — like a checkpoint, just for you.",placement:"left"},{target:"[data-tour='publish']",changes:!0,title:"Publish for everyone",body:"Ready to share? Publish sends your saved work to the whole team. Think of it as putting your version on the shared shelf.",placement:"left"},{target:"[data-tour='pull']",changes:!0,title:"Get latest",body:"When teammates publish, Get latest brings their work onto your computer so you’re both looking at the same thing.",placement:"left"},{target:"[data-tour='status']",title:"Being together is automatic",body:"Cursors, who’s here, and comments need no buttons at all. When you’re both in a canvas, you see each other live — that’s the top layer, always on.",placement:"bottom"},{title:"The one thing worth knowing",body:"When you’re here together, publishing already covers your teammate — they’ve seen it live, so Publish is just dropping a bookmark. Only when you work apart can two versions drift. If that happens, Maude shows you both and lets you pick — keep mine, keep theirs, or keep both. Never a confusing merge."}];var p7=R8(x8(),1);function c40(X){if(typeof document>"u"||!X)return null;try{let J=document.querySelector(X);if(!J)return null;let Q=J.getBoundingClientRect();if(Q.width===0&&Q.height===0)return null;return Q}catch{return null}}var BG=320,$M=184;function i40(X){if(typeof window>"u"||!X)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:BG};let{innerWidth:J,innerHeight:Q}=window;if(X.left>BG+36&&J-X.right<BG+36)return{top:Math.min(Math.max(12,X.top),Q-$M-12),left:Math.max(12,X.left-BG-16),width:BG};let G=Q-X.bottom>$M+24?X.bottom+12:Math.max(12,X.top-$M-12),q=Math.min(Math.max(12,X.left),J-BG-12);return{top:G,left:q,width:BG}}function py({steps:X,open:J,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:q}){let[H,Z]=p7.useState(0),[z,U]=p7.useState(null),B=p7.useRef(null),F=p7.useRef(null),L=p7.useRef(null),D=p7.useRef(W);D.current=W;let w=X[H]||null,E=p7.useCallback(()=>{if(!w)return U(null),null;let b=c40(w.target);return U(b),b},[w]);p7.useEffect(()=>{if(J)Z(0)},[J]),p7.useLayoutEffect(()=>{if(!J||!w)return;let b=!1;U(null);try{D.current?.setup?.(w)}catch{}let h=0,d=24,i=()=>{if(b)return;let v=E();if(v||h>=d){if(v){try{document.querySelector(w.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!b)E()})}return}h+=1,L.current=setTimeout(i,130)};return i(),()=>{if(b=!0,L.current)clearTimeout(L.current)}},[J,H,G]),p7.useEffect(()=>{if(!J)return;F.current=document.activeElement;let b=()=>E();return window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0);try{F.current?.focus?.()}catch{}}},[J,E]);let A=H>=X.length-1,O=p7.useCallback(()=>{if(A)Y?.(),Q?.();else Z((b)=>Math.min(b+1,X.length-1))},[A,Y,Q,X.length]),P=p7.useCallback(()=>Z((b)=>Math.max(0,b-1)),[]);if(p7.useEffect(()=>{if(!J)return;function b(h){if(h.key==="Escape")h.preventDefault(),Q?.();else if(h.key==="ArrowRight")h.preventDefault(),O();else if(h.key==="ArrowLeft")h.preventDefault(),P();else if(h.key==="Tab"){let d=B.current;if(!d)return;let i=d.querySelectorAll("button");if(!i.length)return;let v=i[0],n=i[i.length-1];if(h.shiftKey&&document.activeElement===v)h.preventDefault(),n.focus();else if(!h.shiftKey&&document.activeElement===n)h.preventDefault(),v.focus()}}return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[J,O,P,Q]),p7.useEffect(()=>{if(!J)return;let b=setTimeout(()=>{let h=B.current?.querySelector("[data-tour-primary]");try{h?.focus()}catch{}},0);return()=>clearTimeout(b)},[J,H]),!J||!X.length||!w)return null;let I=6,T=z?{top:z.top-I,left:z.left-I,width:z.width+I*2,height:z.height+I*2}:null,C=!!w.requireSelection&&!G,S=(!!w.canvas||!!w.requireSelection)&&q===!1,j=w.render||null;return R("div",{className:"mdcc-tour",role:"presentation",children:[T?K("div",{className:"mdcc-tour__spot",style:T,"aria-hidden":"true"}):K("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),R("div",{className:"mdcc-tour__card"+(j?" mdcc-tour__card--graphic":""),ref:B,role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-tour-title","aria-describedby":"mdcc-tour-body",style:i40(z),children:[R("div",{className:"mdcc-tour__step",children:[H+1," / ",X.length]}),j&&K("div",{className:"mdcc-tour__graphic",children:K(j,{})}),K("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:w.title}),K("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:w.body}),(S||C)&&R("div",{className:"mdcc-tour__hint",role:"status","aria-live":"polite",children:[K("span",{className:"mdcc-tour__hint-dot","aria-hidden":"true"}),S?"Open any canvas from the sidebar to follow along.":"Hold ⌘ and click an element in the canvas — the panel fills in live."]}),R("div",{className:"mdcc-tour__actions",children:[K("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),R("div",{className:"mdcc-tour__nav",children:[H>0&&K("button",{type:"button",className:"mdcc-tour__back",onClick:P,children:"Back"}),K("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:O,children:A?"Done":"Next"})]})]})]})]})}var cy=[{title:"Let's get you set up",body:"Three short steps: a design system for your brand, a first canvas, then your first AI edit. Everything after this happens right here — no terminal."},{target:"[data-tour='sidebar']",title:"Your canvases will live here",body:"Empty for now. Once you have a design system, this fills up with real screens — click any one to open it.",placement:"right"},{target:"[data-testid='assistant-toggle']",title:"Ask the Assistant to build your design system",body:"Open the Assistant and describe your brand — colors, type, the vibe you want. It sets up a real design system for you. Already have one? Say so and it can bring it in.",placement:"left"},{target:"[data-tour='viewport']",title:"Your first canvas appears here",body:"Once the design system is ready, ask for a first screen and watch it land right in this space, ready to edit."},{title:"You're ready",body:"Hold ⌘ and click anything on a canvas to point at it, describe the change in the Assistant, and watch it update live. Restart this tour any time from Help ▸ Quick setup."}];var F2=[{target:"[data-tour='sidebar']",title:"Your canvases live here",body:"Every mock in the project shows up in this tree. Click one to open it in a tab — or use “+ board” to spin up a blank brief-board, no command needed.",placement:"right"},{target:"[data-tour='viewport']",title:"The canvas",body:"Open a canvas, then ⌘-hover to preview the element under your cursor and ⌘-click to select it. Right-click for Copy CSS / Fit / Reset."},{target:"[data-tour='menus']",title:"Menus & tools",body:"View toggles panels (tree, comments, Inspector); Selection and Tools act on the active canvas. Press ? for every shortcut.",placement:"bottom"},{target:"[data-tour='inspector']",inspector:!0,title:"The Inspector",body:"Opened from View → Inspector (or press I). Inspect · Layers · CSS — ⌘-click any element and edit its CSS against your design tokens, right here. No AI round-trip.",placement:"left"},{target:"[data-tour='whatsnew']",title:"What’s new",body:"New features land here. Click the ✦ badge any time to catch up on what shipped — some entries come with a guided tour like this one.",placement:"bottom"},{target:"[data-tour='help']",title:"Help is one key away",body:"Press ? for the full keyboard cheat-sheet — and you can restart this tour from the Help menu whenever you like.",placement:"bottom"}];var V7=R8(x8(),1);var o40={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},n40={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function oy(X){let J=await fetch(`/_api/export-jobs/download?id=${encodeURIComponent(X)}`);if(!J.ok)return null;let Q=J.headers.get("Content-Disposition")||"",Y=/filename="([^"]+)"/.exec(Q)?.[1]||null;return{blob:await J.blob(),filename:Y}}async function iy(X,J){let Q=await oy(X);if(!Q)return;let Y=Q.filename||J||"export",W=URL.createObjectURL(Q.blob),G=document.createElement("a");G.href=W,G.download=Y,document.body.appendChild(G),G.click(),G.remove(),URL.revokeObjectURL(W)}async function r40(X,J){let Q=await oy(X);if(!Q)return null;let Y=Q.filename||J||"export",W=Array.from(new Uint8Array(await Q.blob.arrayBuffer()));return uj(Y,W)}function ny(){let[X,J]=V7.useState(()=>new Map),[Q,Y]=V7.useState(!1),[W,G]=V7.useState([]),[q,H]=V7.useState(()=>new Set),Z=V7.useRef(new Map),z=V7.useRef(new Set),U=V7.useRef(new Set);V7.useEffect(()=>{let C=!0;return fetch("/_api/export-jobs").then((S)=>S.json()).then((S)=>{if(!C)return;let j=new Map;for(let b of Array.isArray(S?.jobs)?S.jobs:[])j.set(b.id,b),Z.current.set(b.id,b.status),U.current.add(b.id);J(j)}).catch(()=>{}),()=>{C=!1}},[]);let B=V7.useCallback((C)=>{if(!C||typeof C.id!=="string")return;J((S)=>{let j=new Map(S);return j.set(C.id,C),j})},[]);V7.useEffect(()=>{let C=Z.current,S=[],j=[];for(let b of X.values()){let h=C.get(b.id),d=b.status==="queued"||b.status==="running",i=b.status==="done"||b.status==="failed";if(h===void 0&&d&&!U.current.has(b.id))U.current.add(b.id),S.push(b.id);else if(h!==b.status&&i)S.push(b.id),j.push(b)}for(let b of X.values())C.set(b.id,b.status);if(S.length)G((b)=>{let h=b.filter((d)=>!S.includes(d));return[...S,...h].slice(0,8)});if(G9()||!j.length)return;for(let b of j){if(b.status!=="done")continue;if(z.current.has(b.id))continue;if(!document.hasFocus())continue;z.current.add(b.id),iy(b.id,b.filename)}},[X]);let F=V7.useMemo(()=>Array.from(X.values()).sort((C,S)=>(S.createdAt||"").localeCompare(C.createdAt||"")),[X]),L=F.filter((C)=>C.status==="running").length,D=F.filter((C)=>C.status==="queued").length,w=V7.useCallback(()=>G((C)=>C.slice(1)),[]),E=V7.useCallback(()=>Y(!0),[]),A=V7.useCallback(()=>Y(!1),[]),O=V7.useCallback(async(C,S)=>{H((j)=>new Set(j).add(C.id));try{await S()}finally{H((j)=>{let b=new Set(j);return b.delete(C.id),b})}},[]),P=V7.useCallback(async(C)=>{z.current.add(C.id),await O(C,()=>iy(C.id,C.filename))},[O]),I=V7.useCallback(async(C)=>{z.current.add(C.id),await O(C,()=>r40(C.id,C.filename))},[O]),T=Q?null:W[0]??null;return{jobs:F,upsert:B,runningCount:L,queuedCount:D,busyCount:L+D,panelOpen:Q,openPanel:E,closePanel:A,showToast:!!T,toastJob:T?X.get(T)??null:null,dismissToast:w,download:P,save:I,savingIds:q}}function ry(X){let J=o40[X.format]||String(X.format||"").toUpperCase(),Q=n40[X.scope]||X.scope;return`${J} · ${Q}`}function ay(X){if(G9())return X?"Saving…":"Save…";return X?"Downloading…":"Download"}function sy({progress:X}){if(!X||!X.total)return K("div",{className:"st-export-progress st-export-progress--indeterminate","aria-hidden":"true"});let J=Math.max(0,Math.min(100,Math.round(X.current/X.total*100)));return K("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":J,"aria-valuemin":0,"aria-valuemax":100,children:K("div",{className:"st-export-progress-bar",style:{width:`${J}%`}})})}var bM=new Map;function a40(X){let J=X.progress?.current,Q=X.progress?.total;if(!J||!Q||J>=Q)return bM.delete(X.id),null;let Y=bM.get(X.id);if(!Y||J<Y.c)Y={t:Date.now(),c:J},bM.set(X.id,Y);let W=J-Y.c;if(W<3)return null;let G=(Date.now()-Y.t)/W*(Q-J);if(G<45000)return"<1 min left";return`~${Math.round(G/60000)} min left`}function s40({job:X}){let J=X.status==="queued"?"Queued":X.status==="running"?X.progress?.total?`${X.progress.current} of ${X.progress.total}`:"Rendering…":X.status==="done"?"Ready":"Failed",Q=X.status==="running"?a40(X):null;return R("span",{className:`st-export-pill st-export-pill--${X.status}`,children:[J,Q?` · ${Q}`:""]})}function ty({center:X}){let J=X.busyCount>0;return R("button",{type:"button",className:"st-exports","data-tour":"exports","data-busy":J?"true":"false","aria-label":J?`Exports — ${X.busyCount} running`:"Exports","data-tip":"Exports",onClick:X.openPanel,children:[K("span",{"aria-hidden":"true",children:"⬇"}),J&&K("span",{className:"st-exports__count","aria-hidden":"true",children:X.busyCount})]})}function ey({center:X}){if(!X.showToast||!X.toastJob)return null;let J=X.toastJob,Q=J.status==="queued"||J.status==="running",Y=J.status==="done",W=X.savingIds.has(J.id),G=()=>{if(G9())X.save(J);else X.download(J)};return R("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),R("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:Q?"⋯":Y?"⬇":"⚠"}),Q?"Exporting…":Y?"Export ready":"Export failed"]}),K("div",{className:"st-toast-title",children:ry(J)}),Q?R(Q0,{children:[K("div",{className:"st-toast-txt",children:"Running in the background — you can keep working."}),K(sy,{progress:J.progress})]}):K("div",{className:"st-toast-txt",children:Y?J.filename??"Ready to download.":J.error??"Something went wrong."}),Y&&R("div",{className:"st-toast-actions",children:[R("button",{type:"button",className:"btn btn--primary btn--sm",onClick:G,disabled:W,children:[W&&K("span",{className:"st-btn-spin","aria-hidden":"true"}),ay(W)]}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Xf({center:X}){let{panelOpen:J,closePanel:Q}=X;if(V7.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")Q()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,Q]),!J)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)Q()},children:R("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"st-export-panel-title",children:"Exports"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Q,children:"×"})]}),K("div",{className:"st-export-panel__body",children:X.jobs.length===0?K("p",{className:"mdcc-wn-empty",children:"No exports yet."}):K("ul",{className:"st-export-list",children:X.jobs.map((Y)=>R("li",{className:"st-export-item",children:[R("div",{className:"st-export-item__hd",children:[K("span",{className:"st-export-item__label",children:ry(Y)}),K(s40,{job:Y})]}),(Y.status==="queued"||Y.status==="running")&&K(sy,{progress:Y.progress}),Y.status==="done"&&R("div",{className:"st-export-item__ft",children:[K("span",{className:"st-export-item__filename",children:Y.filename}),R("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:X.savingIds.has(Y.id),onClick:()=>G9()?X.save(Y):X.download(Y),children:[X.savingIds.has(Y.id)&&K("span",{className:"st-btn-spin","aria-hidden":"true"}),ay(X.savingIds.has(Y.id))]})]}),Y.status==="failed"&&K("div",{className:"st-export-item__ft",children:K("span",{className:"st-export-item__error",children:Y.error??"Export failed."})})]},Y.id))})})]})})}var BX=R8(x8(),1);function Jf(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 Qf(X,J){let Q=Jf(X),Y=Jf(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 Yf(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Qf(Q.version,J)))}function Wf(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Qf(Y.version,Q))Q=Y.version}return Q}var jM="mdcc-whatsnew-seen",yM="mdcc-whatsnew-toast-dismissed";function t40(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function e40(X){try{let J=localStorage.getItem(jM);if(J)return J;localStorage.setItem(jM,X)}catch{}return X}function XY0(){try{return localStorage.getItem(yM)}catch{return null}}function Gf(X){let[J,Q]=BX.useState([]),[Y,W]=BX.useState(X),[G,q]=BX.useState(()=>e40(X)),[H,Z]=BX.useState(()=>XY0()),[z,U]=BX.useState(!1);BX.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then((C)=>C.json()).then((C)=>{if(O)return;if(Q(Array.isArray(C?.entries)?C.entries:[]),typeof C?.version==="string")W(C.version)}).catch(()=>{})};P();let I=()=>P(),T=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",T),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",T)}},[]);let B=Yf(J,G),F=B.length>0&&H!==Y&&!z,L=B[0]??null,D=BX.useCallback(()=>{let O=Wf(J,Y);q(O),Z(Y);try{localStorage.setItem(jM,O),localStorage.setItem(yM,Y)}catch{}},[J,Y]),w=BX.useCallback(()=>{Z(Y);try{localStorage.setItem(yM,Y)}catch{}},[Y]),E=BX.useCallback(()=>U(!0),[]),A=BX.useCallback(()=>{U(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:z,openPanel:E,closePanel:A,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:D}}function qf({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return R("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),R("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),R("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Hf({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(BX.useEffect(()=>{if(!Q)return;function G(q){if(q.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:R("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>R("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[R("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),t40(G.learnMore)&&K("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var E9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ma="mdcc-usage-tour-seen",wa="mdcc-collab-tour-seen",h8="__system__",ra="mdcc-theme",Aa="mdcc-show-hidden",_a="mdcc-sections-expanded",Ea="maude-cp-mode",Pa="mdcc-sidebar-open",Ra="mdcc-minimap-visible",ka="mdcc-zoomctl-visible",Ia="mdcc-annotations-visible";function KK0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var kE=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],qZ={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},Ta="mdcc-panel-sides",Ca="mdcc-layers-mode";function Sa({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:q}){return R("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(kE.find((Z)=>Z.id===H)||{}).label||H},H))}),q]})}var cQ=/\.(tsx|html?)$/i,CE="0.45.0";function zK0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(ra);if(X==="light"||X==="dark")return X}catch{}return"dark"}function dG(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 wE(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function VK0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function _B(X){return X.split("/").pop()}function g7(X,J=!1){if(typeof document>"u")return;let Q=document.getElementById("st-op-toast");if(!Q)Q=document.createElement("div"),Q.id="st-op-toast",Q.setAttribute("role","status"),Q.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;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(Q);Q.style.background=J?"#1d3524":"#3a1d1d",Q.style.color=J?"#b7e4c0":"#f1b8b8",Q.textContent=X,Q.style.opacity="1",clearTimeout(g7._t),g7._t=setTimeout(()=>{Q.style.opacity="0"},3200)}function KZ(X){return X.replace(cQ,"")}function UK0(X){return X.replace(cQ,"")}function BK0(X){let J=new Map;for(let G of X){if(!cQ.test(G.name))continue;let q=UK0(G.name);if(!J.has(q)||/\.tsx$/i.test(G.name))J.set(q,G)}let Q=new Map,Y=[];for(let G of X){if(cQ.test(G.name))continue;let q=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!q||H.length>q.length)q=H}}if(q){let H=Q.get(q)||[];H.push(G),Q.set(q,H)}else Y.push(G)}let W=[];for(let[G,q]of J){let H=(Q.get(G)||[]).sort((Z,z)=>Z.name.localeCompare(z.name));W.push({primary:q,sidecars:H,orphan:!1})}return W.sort((G,q)=>G.primary.name.localeCompare(q.primary.name)),Y.sort((G,q)=>G.name.localeCompare(q.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function FK0(X,J){let Q={};for(let Y of X){let G=(Y.startsWith(J)?Y.slice(J.length).replace(/^\/+/,""):Y).split("/"),q=Q;for(let H=0;H<G.length;H++){let Z=G[H];if(H===G.length-1)q._files=q._files||[],q._files.push({name:Z,path:Y});else q[Z]=q[Z]||{},q=q[Z]}}return Q}function aa(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((q)=>q!=="_files");for(let q of G){let H=aa(X[q],J);if(H)Y[q]=H,W=!0}if(X._files){let q=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(q.length)Y._files=q,W=!0}return W?Y:null}function $a(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function NK0(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 sa(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 LK0({d:X,size:J=14,color:Q}){return K("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:K("path",{d:X})})}var DK0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:R(Q0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),search:R(Q0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:R(Q0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:R(Q0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:R(Q0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:R(Q0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:R(Q0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:R(Q0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:R(Q0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:R(Q0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:R(Q0,{children:[K("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),K("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:R(Q0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:R(Q0,{children:[K("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:R(Q0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":R(Q0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":R(Q0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":R(Q0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":R(Q0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":R(Q0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":R(Q0,{children:[K("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:R(Q0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:R(Q0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:R(Q0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:R(Q0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:R(Q0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:R(Q0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:R(Q0,{children:[K("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function OK0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,q]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),q(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let Z=u.useMemo(()=>{let U=Y.trim().toLowerCase();if(!U)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(U)||B.group&&B.group.toLowerCase().includes(U))},[Y,Q]);if(u.useEffect(()=>{if(G>=Z.length)q(0)},[Z.length,G]),!X)return null;let z=(U)=>{J(),U.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(U)=>{if(U.target===U.currentTarget)J()},children:R("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[R("div",{className:"st-pal-search",children:[K(n8,{name:"search",size:18}),K("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(U)=>W(U.target.value),onKeyDown:(U)=>{if(U.key==="Escape")U.preventDefault(),J();else if(U.key==="ArrowDown")U.preventDefault(),q((B)=>Math.min(Z.length-1,B+1));else if(U.key==="ArrowUp")U.preventDefault(),q((B)=>Math.max(0,B-1));else if(U.key==="Enter"){if(U.preventDefault(),Z[G])z(Z[G])}}}),K(s6,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:Z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):Z.map((U,B)=>{let F=U.group&&(B===0||Z[B-1].group!==U.group)?K("div",{className:"st-pal-group",children:U.group},"g-"+U.group):null;return R(Q0,{children:[F,R("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>q(B),onClick:()=>z(U),children:[K("span",{className:"st-pal-icon",children:K(n8,{name:U.icon,size:15})}),K("span",{className:"st-pal-label",children:U.label}),U.kbd?K("span",{className:"st-pal-kbd",children:K(s6,{children:U.kbd})}):null]})]},U.id)})})]})})}function n8({name:X,size:J=16,className:Q}){return K("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:DK0[X]})}function MK0(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 ba({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function s6({children:X}){return K("span",{className:"kbd",children:X})}function ja(X,{min:J,max:Q,def:Y}){let W=u.useCallback((Z)=>Math.min(Q,Math.max(J,Z)),[J,Q]),[G,q]=u.useState(()=>{try{let Z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(Z)?W(Z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((Z)=>q((z)=>W(typeof Z==="function"?Z(z):Z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ya({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:q,min:H,max:Z,def:z}=J,U=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":Z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>q(z),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),q((L)=>L+F*U);else if(B.key==="ArrowLeft")B.preventDefault(),q((L)=>L-F*U);else if(B.key==="Home")B.preventDefault(),q(H);else if(B.key==="End")B.preventDefault(),q(Z)},children:R("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var AE=[{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}],_E={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},wK0={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},AK0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],_K0={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 EK0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return _K0[J]||"application/octet-stream"}function PK0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[q,H]=u.useState(null),[Z,z]=u.useState(!1),[U,B]=u.useState(null),[F,L]=u.useState(()=>new Set),[D,w]=u.useState({}),[E,A]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let v=!0;return fetch("/_api/assets").then((n)=>n.json()).then((n)=>{if(!v)return;let Y0=n.ok?n.assets:[];H(Y0),w((g)=>{let G0={...g};for(let e of Y0)G0[e.path]=e.kind;return G0})}).catch(()=>v&&H([])),()=>{v=!1}},[]),u.useEffect(()=>{let v=(n)=>{if(n.key==="Escape")n.stopPropagation(),Q()};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[Q]);let O=Array.from(F).some((v)=>(D[v]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&E==="artboard")A("annotation")},[P,E]);let T=(v)=>{L((n)=>{let Y0=new Set(n);if(Y0.has(v))Y0.delete(v);else Y0.add(v);return Y0})},C=async(v)=>{let n=await fetch("/_api/asset",{method:"POST",headers:{"content-type":v.type||"application/octet-stream"},body:v}),Y0=await n.json().catch(()=>({}));if(n.ok&&Y0.path)return{ok:!0,path:Y0.path};return{ok:!1,error:Y0.error||`upload failed (HTTP ${n.status})`}},S=async(v)=>{if(!v)return;z(!0),B(null);let n=await C(v);if(z(!1),n.ok)J(n.path);else B(n.error)},j=(v)=>{if(typeof v==="string"&&v.startsWith("video/"))return"video";if(typeof v==="string"&&v.startsWith("audio/"))return"audio";return"image"},b=async(v)=>{if(!v.length)return;z(!0),B(null);let n=await Promise.all(v.map((G0)=>C(G0).then((e)=>({...e,file:G0}))));z(!1);let Y0=n.filter((G0)=>G0.ok),g=n.length-Y0.length;if(g>0)B(`${g} of ${n.length} uploads failed`);if(Y0.length)w((G0)=>{let e={...G0};for(let l of Y0)e[l.path]=j(l.file.type);return e}),L((G0)=>{let e=new Set(G0);for(let l of Y0)e.add(l.path);return e})},h=async()=>{z(!0),B(null);try{if(Y){let Y0=(await lj()||[]).map((g)=>new File([new Uint8Array(g.bytes)],g.name,{type:EK0(g.name)}));if(z(!1),Y0.length)await b(Y0);return}let v=await a3();if(v?.bytes){await S(new Blob([new Uint8Array(v.bytes)]));return}}catch(v){B(v?.message||"open failed")}z(!1)},d=()=>{if(G9()){h();return}let v=document.createElement("input");if(v.type="file",v.accept="image/*,video/*",Y)v.multiple=!0;v.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(v);let n=()=>{if(v.isConnected)v.remove()};window.addEventListener("focus",()=>setTimeout(n,300),{once:!0}),v.addEventListener("change",()=>{let Y0=v.files?Array.from(v.files):[];if(n(),!Y0.length)return;if(Y)b(Y0);else S(Y0[0])}),v.click()},i=(v)=>`/${X}/${v}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(v)=>{if(v.target===v.currentTarget)Q()},children:R("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(n8,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[R("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:d,disabled:Z,children:Z?"Uploading…":"Upload…"}),U&&K("span",{className:"st-ap-err",children:U})]}),K("div",{className:"st-ap-grid",children:q==null?K("div",{className:"st-ap-empty",children:"Loading…"}):q.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):q.map((v)=>{let n=Y&&F.has(v.path);return R("button",{type:"button",className:"st-ap-cell","data-selected":n?"true":void 0,"aria-pressed":Y?n:void 0,title:`${v.name} · ${Math.max(1,Math.round(v.size/1024))} KB`,onClick:()=>Y?T(v.path):J(v.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:n?K(n8,{name:"check",size:12}):null}),v.kind==="video"?K("video",{className:"st-ap-thumb",src:i(v.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:i(v.path),alt:v.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:v.name})]},v.path)})})]}),Y&&F.size>0&&R("div",{className:"st-dialog-ft st-ap-confirm",children:[R("span",{className:"st-ap-count",children:[F.size," selected"]}),R("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:P,onClick:()=>A("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>A("annotation"),children:"Add as annotation"})]}),P&&K("span",{className:"st-ap-dest-note",children:I}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),E),children:"Insert"})]})]})})}function RK0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:q}){let[H,Z]=u.useState(X==="handoff"?"shadcn":"png"),[z,U]=u.useState(J&&_E[J]?J:"artboard"),[B,F]=u.useState(2),[L,D]=u.useState(!0),[w,E]=u.useState(!1),[A,O]=u.useState(null),[P,I]=u.useState([]),T=AE.find((b)=>b.id===H)||AE[0],C=T.handoff?[]:wK0[T.format]||["artboard"];u.useEffect(()=>{if(C.length&&!C.includes(z))U(C[0])},[C,z]);let S=u.useCallback(()=>{fetch("/_api/export-history").then((b)=>b.json()).then((b)=>I(Array.isArray(b?.history)?b.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{S()},[S]),u.useEffect(()=>{function b(h){if(h.key==="Escape")h.preventDefault(),q()}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[q]);async function j(){if(T.handoff){let d=`/design:handoff ${Q&&Q!==h8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(d)}catch{}O({ok:!0,msg:`Copied: ${d} — run it in Claude Code.`});return}E(!0),O(null);let b=T.format==="png"||T.temporal?{scale:B}:{};if(T.format==="mp4"||T.format==="webm")b.audio=L;if(W)b.artboardId=W;if(G?.selector)b.selection=G;try{let h=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:T.format,scope:z,options:b})});if(!h.ok){O({ok:!1,msg:await h.text()||`Export failed (${h.status})`}),E(!1);return}q()}catch(h){O({ok:!1,msg:h&&h.message?h.message:String(h)}),E(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)q()},children:R("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:q,children:K(n8,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==h8?`Format · ${KZ(_B(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:AE.filter((b)=>!b.temporal||Y).map((b)=>R("button",{type:"button",className:"st-fmt"+(b.id===H?" is-on":""),onClick:()=>{Z(b.id),O(null)},children:[K(n8,{name:b.icon,size:16}),K("span",{className:"st-fmt-name",children:b.label}),K("span",{className:"st-fmt-sub",children:b.sub})]},b.id))}),!T.handoff&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:z,onChange:(b)=>U(b.target.value),children:C.map((b)=>K("option",{value:b,children:_E[b]},b))})]}),!T.handoff&&(T.format==="png"||T.temporal)&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:T.temporal?"Resolution":"Size"}),K("select",{id:"st-export-size",className:"st-select",value:B,onChange:(b)=>F(Number(b.target.value)),children:AK0.map((b)=>K("option",{value:b.value,children:b.label},b.value))})]}),!T.handoff&&T.format==="png"&&R("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Resolution multiplier — ",B,"× ≈ ",1440*B,"×",900*B," for a 1440×900 artboard."]}),!T.handoff&&T.temporal&&R("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!T.handoff&&(T.format==="mp4"||T.format==="webm")&&K("div",{className:"st-dialog-row",children:R("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:L,onChange:(b)=>D(b.target.checked)}),"Export with audio"]})}),T.handoff&&R("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),A&&K("div",{className:"callout "+(A.ok?"callout--success":"callout--error"),style:{fontSize:12},children:A.msg}),P.length>0&&R("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),P.map((b,h)=>R("div",{className:"st-export-recent-row",children:[R("span",{children:[String(b.format||"").toUpperCase()," ·"," ",_E[b.scope]||b.scope]}),K("span",{className:"st-mono",children:b.filename})]},h))]})]}),R("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:q,children:"Cancel"}),R("button",{type:"button",className:"btn btn--primary",disabled:w,onClick:j,children:[K(n8,{name:"download",size:14}),T.handoff?"Copy handoff command":w?"Exporting…":`Export ${T.label}`]})]})]})})}var EB=12,PB=16;function kK0({name:X,depth:J,defaultOpen:Q,children:Y}){let[W,G]=u.useState(Q);return R(Q0,{children:[R("button",{type:"button",role:"treeitem","aria-expanded":W,tabIndex:-1,className:"st-row",style:{paddingLeft:EB+J*PB+"px"},onClick:()=>G((q)=>!q),children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"chevron-right",className:"st-chev"+(W?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]}),W&&Y]})}function IK0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:q}){let[H,Z]=u.useState(Y);return R(Q0,{children:[R("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:EB+Q*PB+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>Z((z)=>!z),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(n8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),R("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&q]})}function IE({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:q,sidecar:H,dirty:Z,experimentalKind:z}){let U=X.path===J,B=cQ.test(X.name),F=!B,L=B?KZ(X.name):X.name,D=B&&typeof Y==="function"&&q!=="runtime",w=B?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(cQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,E=R("button",{type:"button",role:"treeitem","data-testid":w,"aria-selected":U,"aria-disabled":F?"true":void 0,tabIndex:U?0:-1,className:"st-row"+(U?" is-sel":"")+(q==="runtime"?" is-muted":""),style:{paddingLeft:EB+G*PB+"px"},title:X.path+(W?` — ${W} open`:F?" (file index only)":""),onClick:()=>{if(!F)Q(X.path)},children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"file",size:13})}),K("span",{className:"st-row-name",children:L}),z==="reconstructed-experimental"&&K("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),Z&&K("span",{className:"st-git-badge","data-kind":Z,title:`Unsaved (${Z})`,"aria-label":`Unsaved, ${Z}`,children:Z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!D)return E;return R("div",{className:"st-row-wrap",role:"none",children:[E,K("button",{type:"button",className:"st-row-del",title:`Delete ${L}`,"aria-label":`Delete canvas ${L}`,onClick:(A)=>{A.stopPropagation(),Y(X.path,L)},children:K(LK0,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function TK0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:q,openCount:H,showHidden:Z,forceOpen:z,dirtyByPath:U,experimentalKind:B}){let F=U?.get(X.path),L=J.length>0,[D,w]=u.useState(!1),E=z||D,A=X.path===W;if(!(L&&Z))return K(IE,{file:X,activePath:W,onOpen:G,onDelete:q,openCount:H,depth:Q,kind:Y,dirty:F,experimentalKind:B});return R(Q0,{children:[R("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":E,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":""),style:{paddingLeft:EB+Q*PB+"px"},title:X.path,onClick:(P)=>{if(P.target.closest(".st-canvas-chev")){w((I)=>!I);return}G(X.path)},children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(P)=>{P.stopPropagation(),w((I)=>!I)},children:K(n8,{name:"chevron-right",className:"st-chev"+(E?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:KZ(X.name)}),B==="reconstructed-experimental"&&K("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F&&K("span",{className:"st-git-badge","data-kind":F,title:`Unsaved (${F})`,"aria-label":`Unsaved, ${F}`,children:F}),H>0&&K("span",{className:"st-row-badge",children:H})]}),E&&J.map((P)=>K(IE,{file:P,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},P.path))]})}function ta({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:q,search:H,dsFolders:Z,activeDsName:z,onOpenSystem:U,onDelete:B,dirtyByPath:F,canvasKinds:L}){let D=Object.keys(X).filter((I)=>I!=="_files").sort(),w=X._files||[],{canvases:E,orphans:A}=u.useMemo(()=>BK0(w),[w]),O=!!(H&&H.trim()),P=u.useMemo(()=>{if(!Z||W!==1)return null;let I=new Map;for(let T of Z)I.set(T.folder,T);return I},[Z,W]);return R(Q0,{children:[E.map((I)=>{let T=O&&I.sidecars.some((C)=>{let S=H.toLowerCase();return C.name.toLowerCase().includes(S)||C.path.toLowerCase().includes(S)});return K(TK0,{primary:I.primary,sidecars:I.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:$a(Y[I.primary.path]),depth:W,kind:G,showHidden:q,forceOpen:T,dirtyByPath:F,experimentalKind:L?.[I.primary.path]},I.primary.path)}),q&&A.map((I)=>K(IE,{file:I.primary,activePath:J,onOpen:Q,openCount:$a(Y[I.primary.path]),depth:W,kind:G},I.primary.path)),D.map((I)=>{let T=P?.get(I),C=K(ta,{node:X[I],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:q,search:H,activeDsName:z,onOpenSystem:U,onDelete:B,dirtyByPath:F,canvasKinds:L});if(T&&U)return K(IK0,{name:I,dsName:T.name,depth:W,defaultOpen:!0,active:J===h8&&T.name===z,onOpenSystem:U,children:C},I);return K(kK0,{name:I,depth:W,defaultOpen:!0,children:C},I)})]})}var wB={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function CK0(X){if(X.kind==="project")return wB.project;if(X.kind==="runtime")return wB.runtime;if(X.label==="Design system")return wB.ds;if(X.label==="UI kit")return wB.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function SK0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:q,setSearch:H,commentsByFile:Z,showHidden:z,sectionsExpanded:U,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:D,refreshing:w,collapsed:E,onCollapse:A,width:O,resizing:P,dirtyByPath:I,project:T,gitBranch:C,remoteSync:S,onGetLatest:j,canvasKinds:b}){let h=u.useMemo(()=>{if(!q)return X;return X.map((a)=>({...a,tree:aa(a.tree,q),filtered:!!q}))},[X,q]),[d,i]=u.useState(!1),[v,n]=u.useState(""),[Y0,g]=u.useState(""),[G0,e]=u.useState(!1),l=u.useCallback(async()=>{let a=v.trim();if(!a||G0)return;e(!0),g("");let c=await F(a);if(e(!1),c?.ok)i(!1),n("");else g(c?.error||"could not create board")},[v,G0,F]),Z0=u.useMemo(()=>{let a=0;for(let c of X)for(let V0 of c.paths||[])if(cQ.test(V0))a++;return a},[X]),r=u.useMemo(()=>{let a=0;for(let c of h)for(let V0 of c.paths||[])if(cQ.test(V0))a++;return a},[h]);return R("nav",{className:"st-sidebar"+(E?" is-collapsed":"")+(P?" is-resizing":""),style:E||!O?void 0:{width:O,flexBasis:O},"aria-label":"Files","data-tour":"sidebar",children:[R("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),R("div",{className:"st-sb-hd-actions",children:[K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":d,onClick:()=>{g(""),i((a)=>!a)},children:K(n8,{name:"plus",size:15})}),D&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>D(),children:K(n8,{name:"reload",size:15})}),R("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),r," / ",Z0]}),A&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:A,children:K(n8,{name:"panel-left",size:15})})]})]}),d?R("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:"brief board name…",value:v,maxLength:60,disabled:G0,"aria-label":"New brief board name",onChange:(a)=>n(a.target.value),onKeyDown:(a)=>{if(a.key==="Enter")a.preventDefault(),l();else if(a.key==="Escape")a.preventDefault(),i(!1),n(""),g("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:G0||!v.trim(),"data-tip":"Create · Enter","aria-label":"Create brief board",onClick:l,children:G0?"…":"↵"})]}):null,Y0?K("div",{className:"st-newboard-err",role:"alert",children:Y0}):null,K("div",{className:"st-search",children:R("div",{className:"st-search-box",children:[K(n8,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:q,onChange:(a)=>H(a.target.value),onKeyDown:(a)=>{if(a.key==="Escape")if(a.preventDefault(),q)H("");else a.currentTarget.blur()},"aria-label":"Filter files"}),q?K("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(s6,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:h.map((a)=>{if(!z&&!q&&a.kind==="runtime")return null;let c=CK0(a),V0=(a.paths||[]).filter((v8)=>cQ.test(v8)).length,o0=c.pill||(c.pillFromDsCount?String(a.dsFolders?.length||0):null)||(c.pillFromCount?String(V0||a.paths?.length||0):null),U8=a.tree&&Object.keys(a.tree).length>0,V8=a.label==="Design system",L0=a.kind==="project";if(!z&&!q&&L0&&V0===0)return null;let t0=VK0(a),n0=U[a.label],Q8=!!q||(n0===void 0?t0:n0);return R("div",{className:"st-tree-section",children:[R("button",{type:"button",className:"st-tree-sec-hd",onClick:()=>B(a.label,t0),"aria-expanded":Q8,title:Q8?"Collapse section":"Expand section",children:[K(n8,{name:"chevron-right",className:"st-chev"+(Q8?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:c.title}),o0&&K("span",{className:"st-pill",children:o0})]}),Q8&&(U8?K(ta,{node:a.tree,activePath:J,onOpen:Y,commentsByFile:Z,depth:1,kind:a.kind,showHidden:z,search:q,dsFolders:a.dsFolders,activeDsName:Q,onOpenSystem:V8?W:void 0,onDelete:V8?void 0:L,dirtyByPath:I,canvasKinds:b}):K("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},a.label)})}),K(MM,{project:T,liveBranch:C,remoteSync:S,onGetLatest:j}),K(qM,{})]})}function $K0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:R("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(n8,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(n8,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(n8,{name:"folder",size:15})})]})})}function bK0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:R("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),R("span",{className:"sku",children:["MAUDE-DEV-SRV / v",CE]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),R("div",{className:"help-modal-body",children:[R("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),R("ul",{children:[R("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),R("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),R("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),R("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),R("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),R("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),R("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),R("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),R("details",{children:[K("summary",{children:"Annotation tools"}),R("ul",{children:[R("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),R("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),R("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),R("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),R("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),R("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),R("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),R("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),R("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),R("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),R("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),R("details",{children:[K("summary",{children:"Canvas & panels"}),R("ul",{children:[R("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),R("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),R("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),R("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),R("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),R("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),R("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),R("details",{children:[K("summary",{children:"Slash commands"}),R("ul",{className:"cmds",children:[R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),R("li",{children:[R("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),R("li",{children:[R("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),R("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),R("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),R("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),R("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),R("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),R("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),R("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),R("details",{children:[K("summary",{children:"Opt-out scope"}),R("ul",{children:[R("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),R("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),R("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),R("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),R("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),R("details",{children:[K("summary",{children:"Auto-critic loop"}),R("ul",{children:[R("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),R("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),R("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),R("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),R("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),R("li",{children:["When ",K("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),R("details",{children:[K("summary",{children:"Pin-to-element flow"}),R("ol",{children:[K("li",{children:"Open a canvas"}),R("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),R("li",{children:["Run"," ",R("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),R("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),R("details",{children:[K("summary",{children:"Comments"}),R("ol",{children:[R("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),R("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),R("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),R("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var EE=[{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 jK0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,q)=>K(s6,{children:G},`${G}-${q}`))},W);return R("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>R(Q0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function yK0({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=EE.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:R("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[R("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),R("span",{className:"so-trigger",children:["press ",K(s6,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:EE.map((Y)=>R("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>R("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(jK0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),R("div",{className:"so-overlay-ft",children:[R("span",{children:["close with ",K(s6,{children:"Esc"})]}),R("span",{className:"so-count",children:[Q," bindings · ",EE.length," groups"]})]})]})})}var fK0=["File","Edit","View","Selection","Tools","Help"];function ea(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 vK0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return ea(Q),R("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>R("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(n8,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(s6,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>R("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(s6,{children:G.shortcut})]},G.label))]})}function sV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return ea(G),R("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((q,H)=>q.sep?K("div",{className:"st-dd-sep"},"s"+H):R("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":q.disabled?"true":void 0,onClick:()=>{if(q.disabled)return;W(q.id),G()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:q.label})]}),q.shortcut?K(s6,{children:q.shortcut}):null]},q.id))]})}function xK0({onAction:X,onClose:J}){return K(sV,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function hK0({onAction:X,onClose:J}){return K(sV,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]})}function gK0({onAction:X,onClose:J}){return K(sV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"move",label:"Move",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]})}function mK0({onAction:X,onClose:J,hasCanvas:Q}){return K(sV,{label:"File",left:40,onAction:X,onClose:J,items:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function uK0({onAction:X,onClose:J,hasCanvas:Q}){return K(sV,{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"}]:[]]})}function lK0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:q,changesOpen:H,changesCount:Z,onToggleChanges:z,onOpenSystem:U,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:D,onOpenHelp:w,onOpenShortcuts:E,onStartTour:A,onStartCollabTour:O,annotationsVisible:P,onToggleAnnotations:I,minimapVisible:T,onToggleMinimap:C,zoomCtlVisible:S,onToggleZoomCtl:j,presentMode:b,onTogglePresent:h,postToActiveCanvas:d,onOpenWhatsNew:i,onOpenReadiness:v,onOpenQuickSetup:n,onWatchIntro:Y0,whatsNewCount:g,exportCenter:G0,artboardCount:e=0,presence:l=null,inspectorOpen:Z0,inspectorTab:r,onToggleInspector:a,autoOpenInspector:c,onToggleAutoOpenInspector:V0,onOpenLayers:o0,timelineOpen:U8,onToggleTimeline:V8,hasComps:L0=!1,assistantOpen:t0,onToggleAssistant:n0,assistantBusy:Q8,assistantUnseen:v8,onNewCanvas:i8,onAssembleVideo:g8,onOpenExport:z9,onOpenSettings:c0,onOpenGenerate:d8,onReload:o8,onCloseCanvas:j9,onInsertArtboard:f0}){let z0=X===h8,F0=z0?"SYSTEM":X?"CANVAS":"IDLE",U0=z0?K("b",{children:"design system"}):X?R(Q0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:KZ(_B(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),y0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:Z>0?`Changes · ${Z} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:Z0&&r==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:Z0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!c,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:L0?"video":void 0,checked:U8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:t0,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:P,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:T,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:S,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:b,disabled:!X||z0}],w0=["file","edit","view","selection","tools","help"];function R0(I0){if(w0.includes(I0))W(Y===I0?null:I0)}return u.useEffect(()=>{if(!Y||!w0.includes(Y))return;let I0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function O8(r0){let d0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!d0.length)return;let $8=d0.indexOf(document.activeElement);if(r0.key==="ArrowDown")r0.preventDefault(),d0[($8+1)%d0.length].focus();else if(r0.key==="ArrowUp")r0.preventDefault(),d0[($8-1+d0.length)%d0.length].focus();else if(r0.key==="Home")r0.preventDefault(),d0[0].focus();else if(r0.key==="End")r0.preventDefault(),d0[d0.length-1].focus();else if(r0.key==="ArrowRight"||r0.key==="ArrowLeft"){r0.preventDefault();let v9=r0.key==="ArrowRight"?1:-1,r8=w0.indexOf(Y);W(w0[(r8+v9+w0.length)%w0.length])}else if(r0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",O8),()=>{clearTimeout(I0),window.removeEventListener("keydown",O8)}},[Y,W]),R("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[R("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:fK0.map((I0)=>{let O8=I0.toLowerCase(),r0=w0.includes(O8),d0=r0||O8==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":O8==="help"?"help":void 0,"aria-haspopup":r0?"menu":void 0,"aria-expanded":r0?Y===O8:void 0,onClick:()=>R0(O8),onMouseEnter:()=>{if(Y!==null&&r0)W(O8)},children:I0},O8)})}),Y==="file"&&K(mK0,{hasCanvas:!!X,onAction:(I0)=>{if(I0==="new")i8?.();else if(I0==="assemble")g8?.();else if(I0==="export")z9?.("export");else if(I0==="handoff")z9?.("handoff");else if(I0==="generate")d8?.();else if(I0==="settings")c0?.();else if(I0==="reload")o8?.();else if(I0==="close")j9?.()},onClose:()=>W(null)}),Y==="edit"&&K(uK0,{hasCanvas:!!X&&!z0,onAction:(I0)=>{if(I0==="undo")d({dgn:"undo"});else if(I0==="redo")d({dgn:"redo"});else if(I0==="deselect-all")d({dgn:"selection-clear"});else if(I0==="select-all-annotations")d({dgn:"annotation-select-all"});else if(I0.startsWith("new-artboard:"))f0?.(I0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(vK0,{panels:y0,onToggle:(I0)=>{if(I0==="tree")F();else if(I0==="changes")z();else if(I0==="comments")q();else if(I0==="hidden")D();else if(I0==="annotate")I();else if(I0==="inspector")a();else if(I0==="autoopen")V0?.();else if(I0==="timeline")V8?.();else if(I0==="assistant")n0?.();else if(I0==="layers")o0?.();else if(I0==="minimap")C?.();else if(I0==="zoomctl")j?.();else if(I0==="present")h?.()},onZoom:(I0)=>d({dgn:"zoom",op:I0}),hasCanvas:!!X&&!z0,onClose:()=>W(null)}),Y==="selection"&&K(hK0,{onAction:(I0)=>{if(I0==="deselect-all")d({dgn:"selection-clear"});else if(I0==="select-all-annotations")d({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K(gK0,{onAction:(I0)=>d({dgn:"tool-set",tool:I0}),onClose:()=>W(null)}),Y==="help"&&K(xK0,{onAction:(I0)=>{if(I0==="shortcuts")E?.();else if(I0==="help")w?.();else if(I0==="tour")A?.();else if(I0==="collab-tour")O?.();else if(I0==="quick-setup")n?.();else if(I0==="readiness")v?.();else if(I0==="whatsnew")i?.();else if(I0==="watch-intro")Y0?.()},onClose:()=>W(null)}),R("div",{className:"st-mb-right","data-tour":"status",children:[l?K("div",{className:"st-presence",children:l}):null,G9()&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":t0?"true":"false","data-busy":Q8?"true":"false","data-unseen":v8?"true":"false","aria-label":`Assistant${Q8?" — working":v8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:n0,children:K(n8,{name:"sparkle",size:15})}),G0&&K(ty,{center:G0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":g>0?"true":"false","aria-label":`What's new${g>0?` — ${g} unseen`:""}`,"data-tip":"What's new",onClick:i,children:K(n8,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:F0}),K("span",{className:"st-mb-file",title:X||"",children:U0}),K("span",{className:"st-mb-sep"}),R("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function dK0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:q,cfg:H,loadingPath:Z,onIframeLoad:z,showQuickSetup:U,onStartQuickSetup:B}){return R("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&R("div",{className:"st-empty",children:[R("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),R("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(q||"MAUDE").toUpperCase()," / v",CE," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),R("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(s6,{children:"⌘"})," and hover to preview an element, click to select it — ",K(s6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?R(Q0,{children:[K("br",{}),K("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),U&&K("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((F)=>{if(F.path===h8)return K("div",{className:"system-view"+(F.path===J?" active":""),children:K(sK0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return K("iframe",{ref:(L)=>Q(F.path,L),src:GH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>z?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),Z&&Z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:R("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var pK0=["color","space","radius","shadow","leading","weight","motion","font","other"],cK0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function iK0(X){return X==="color"}function oK0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return R("section",{className:"sv-section sv-section-tokens",children:[R("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:R("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...pK0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(Q0,{children:W.map((G)=>{let q=Y[G],H=iK0(G);return R("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[R("h2",{children:["tokens · ",cK0[G]||G,K("span",{className:"sv-h-num",children:q.length})]}),K("div",{className:"sv-tokens-ladder",children:q.map((Z)=>R("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:Z.value}}):null,R("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:Z.name}),K("span",{className:"sv-tok-value",children:Z.value||"—"})]})]},Z.name+"|"+Z.value))})]},G)})})}function nK0(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 rK0(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 aK0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=rK0(X?.font);return R("section",{className:"sv-section sv-section-type",children:[R("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=nK0(W,Q),q={fontSize:W.value};if(G)q.lineHeight=G;if(Y)q.fontFamily=Y;return R("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:q,children:"The catalog is the system."})]},W.name)})})]})}function sK0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:q,tokens:H,tokenGroups:Z,tokensPath:z,ds:U,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,D=U?.name??B?.[0]?.name??"";return R("div",{className:"sv",children:[R("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),L?R("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:D,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>K("option",{value:w.name,children:w.name},w.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:q})})]}),U?.description?K("p",{className:"sv-ds-description",children:U.description}):null,K(oK0,{tokens:H,tokenGroups:Z,tokensPath:z}),K(aK0,{tokenGroups:Z}),F?K("div",{className:"sv-empty",children:R("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:q}),"."]})}):R(Q0,{children:[K(fa,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(fa,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function fa({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return R("section",{className:"sv-section",children:[R("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>R("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:GH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),R("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function tK0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:q,syncStatus:H,changesCount:Z=0,unpushed:z=0,changesOpen:U=!1,onOpenChanges:B}){let F=X===h8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",D=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",E=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let A=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:A>0?`${A} ↑`:"synced",title:A>0?`${A} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${A} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return R("footer",{className:"st-statusbar",role:"contentinfo",children:[R("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&R("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:D,children:L}),K("button",{type:"button",className:"st-sb-sel-clear",onClick:q,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),R("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),R("span",{className:"val",children:[Y," open"]})]}),B&&R("button",{type:"button",className:"st-sb-slot st-sb-changes"+(U?" is-open":"")+(Z>0?" has-changes":z>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":U,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:Z>0?`${Z} unsaved`:z>0?`${z} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),R("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),E&&R("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(E.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:E.title,children:E.label})]}),R("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[K(n8,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function eK0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:q,onReopen:H,onDelete:Z,width:z,resizing:U}){let B=sa(X),F=Object.keys(X||{}).sort(),L=[];for(let D of F){let w=X[D]||[],E=w.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let A=w.filter((O)=>O.selector);L.push({file:D,comments:E.map((O)=>({...O,n:A.findIndex((P)=>P.id===O.id)+1}))})}return R("aside",{className:"st-rpanel"+(U?" is-resizing":""),style:z?{width:z,flexBasis:z}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:R("div",{className:"st-cm-filters",role:"tablist",children:[R("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),R("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),R("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:L.length===0?R("div",{className:"st-rp-empty",children:[R("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),R("p",{children:["Open a canvas, hold ",K(s6,{children:"⌘"})," and click an element, then press ",K(s6,{children:"C"})," — or hold ",K(s6,{children:"⌘⇧"})," and click directly."]})]}):L.map((D)=>R(Q0,{children:[R("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[K("span",{children:KZ(_B(D.file))}),K("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((w)=>R("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(D.file,w.id),children:[R("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),K("span",{className:"st-comment-time",children:NK0(w.created)})]}),K("div",{className:"st-comment-txt",children:w.text}),R("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),R("span",{className:"st-mini-act",children:[w.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(w.id)},children:K(n8,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),q(w.id)},children:K(n8,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),Z(w.id)},children:K(n8,{name:"x",size:14})})]})]})]},w.id))]},D.file))})]})}function Xz0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return R("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),R("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),pj().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function Jz0({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:q}=X,H=G==="synced",Z=Y==="offline"||Y==="offline-long",z=X.docs?.rejected??0,U=Array.isArray(q)?[...q].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!Z&&!H&&!U&&z===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(Z){let D=q&&q.length>0?` (${q.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;L=`${Y}:offline`}else if(U){if(U.snapshotFailed)B="error",F=`Diverged on ${U.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${U.slug}: kept the ${U.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${U.slug}`;L=`diverged:${U.slug}:${U.at}`}else B="warn",F=`${z} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${z}`;if(J===L)return null;return R("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:F}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var Qz0=["block","inline-block","flex","inline-flex","grid","inline","none"];var Yz0=["auto","stretch","flex-start","center","flex-end","baseline"];var va=["300","400","500","600","700","800"],xa=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],ha=["none","solid","dashed","dotted","double"],ga=["px","rem","em","%","vw","vh","auto"],ma=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),PE={"font-size":{node:K(E9,{as:Rz,size:12})},"line-height":{node:K(E9,{as:bz,size:12})},"letter-spacing":{node:K(E9,{as:gz,size:12})},gap:{node:K(E9,{as:xH,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(E9,{as:pz,size:12})},"border-width":{node:K(E9,{as:hz,size:12})}};var ua=["static","relative","absolute","fixed","sticky"],Wz0=["normal","italic","oblique"],la=["none","uppercase","lowercase","capitalize"];var da=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],Gz0=["fill","contain","cover","none","scale-down"];var pa=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ca=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],aV={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}},HZ=null;function TE(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!HZ)HZ=document.createElement("canvas").getContext("2d");if(!HZ)return"";HZ.fillStyle="#000000",HZ.fillStyle=X;let J=HZ.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 pQ=(X)=>Math.min(1,Math.max(0,X));function AB(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 nV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function rV({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,q=0;if(G){if(Y===X)q=(J-Q)/G%6;else if(Y===J)q=(Q-X)/G+2;else q=(X-J)/G+4;if(q*=60,q<0)q+=360}return{h:q,s:Y?G/Y:0,v:Y}}function ZZ({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,q=0,H=0,Z=0;if(X<60)[q,H,Z]=[Y,W,0];else if(X<120)[q,H,Z]=[W,Y,0];else if(X<180)[q,H,Z]=[0,Y,W];else if(X<240)[q,H,Z]=[0,W,Y];else if(X<300)[q,H,Z]=[W,0,Y];else[q,H,Z]=[Y,0,W];return{r:(q+G)*255,g:(H+G)*255,b:(Z+G)*255}}function C9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function c5(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 ia(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)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 qz0(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function Hz0(X){let J={};for(let q of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(q[1]in J))J[q[1]]=q[2].trim();let Q={};for(let q of Object.keys(J)){let H=J[q],Z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[q]=Z&&J[Z[1]]?J[Z[1]]:H}let Y=Object.keys(J),W=(q)=>Y.filter((H)=>q.test(H)),G=(q)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(q)||/^(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(q);return{color:Y.filter((q)=>G(Q[q])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function Zz0(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,q]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(Z)=>{if(!Z.tokensCssRel)return null;try{let z=await fetch(`/${J}/${Z.tokensCssRel}`),U=z.ok?await z.text():"";return{name:Z.name,...Hz0(U)}}catch{return null}})).then((Z)=>{if(H)return;let z=Z.filter(Boolean);z.sort((U,B)=>U.name===Q?-1:B.name===Q?1:0),q(z)}),()=>{H=!0}},[W,J,Q]),G}function Xs({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>rV(AB(X||"#000000"))),G=u.useRef(Y);G.current=Y;let q=u.useRef(null),H=u.useRef(null),Z=u.useRef(X);u.useEffect(()=>{if(X&&X!==Z.current)Z.current=X,W(rV(AB(X)))},[X]);let z=nV(ZZ(Y)),U=(O)=>{O.preventDefault();let P=q.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,T=(S)=>{W({h:I,s:pQ((S.clientX-P.left)/P.width),v:pQ(1-(S.clientY-P.top)/P.height)})};T(O);let C=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",C),Q(nV(ZZ(G.current)))};document.addEventListener("pointermove",T),document.addEventListener("pointerup",C)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:T}=G.current,C=(j)=>{W({h:pQ((j.clientX-P.left)/P.width)*360,s:I,v:T})};C(O);let S=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",S),Q(nV(ZZ(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",S)},F=(O)=>{let P={...G.current,...O};W(P),Q(nV(ZZ(P)))},L=(O)=>{let P=O.shiftKey?0.1:0.02,T={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!T)return;O.preventDefault(),F({s:pQ(G.current.s+T[0]),v:pQ(G.current.v+T[1])})},D=(O)=>{let P=O.shiftKey?20:2,T={ArrowLeft:-P,ArrowRight:P}[O.key];if(T==null)return;O.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+T))})},w=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(rV(AB(P.sRGBHex))),Q(P.sRGBHex)}catch{}},E=ZZ(Y),A=(O)=>{let P={...E,...O},I=rV({r:pQ(P.r/255)*255,g:pQ(P.g/255)*255,b:pQ(P.b/255)*255});W(I),Q(nV(ZZ(I)))};return R("div",{className:"st-cp-cpick",children:[R("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:z}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:z,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(rV(AB(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),R("button",{type:"button",ref:q,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:U,onKeyDown:L,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:z}})]}),R("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:K(n8,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:z},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>R("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(P)=>A({[O]:pQ((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),K("span",{children:O.toUpperCase()})]},O))})]})}function RE({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:q,activeDs:H,swatchClassName:Z}){let[z,U]=u.useState(!1),[B,F]=u.useState(null),[L,D]=u.useState("custom"),[w,E]=u.useState(""),A=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(e)=>Q===`var(${e})`,T=(e)=>e.replace(/^--/,"").replace(/-/g," "),C=J||[],S=C.reduce((e,l)=>e+(l.names?.length||0),0),j=C.length>1,b=w.trim().toLowerCase(),h=!b?C:C.map((e)=>({...e,names:(e.names||[]).filter((l)=>T(l).toLowerCase().includes(b)||l.toLowerCase().includes(b)||(e.vals?.[l]||"").toLowerCase().includes(b))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!z){E("");return}let e=()=>{let a=A.current?.getBoundingClientRect();if(!a)return;let c=224,V0=300,o0=Math.min(a.right-c,window.innerWidth-c-8);if(o0<8)o0=8;let V8=window.innerHeight-a.bottom>V0+8?a.bottom+4:Math.max(8,a.top-V0-4);F({left:o0,top:V8,width:c,maxHeight:V0})};e();let l=(a)=>{if(O.current?.contains(a.target)||A.current?.contains(a.target))return;U(!1)},Z0=(a)=>{if(a.key==="Escape")U(!1)},r=(a)=>{if(O.current?.contains(a.target))return;e()};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",Z0),window.addEventListener("resize",e),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",Z0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[z]),u.useEffect(()=>{if(!z||!B||!O.current)return;let e=O.current.getBoundingClientRect(),l=B.left-e.left,Z0=B.top-e.top;if(Math.abs(l)>0.5||Math.abs(Z0)>0.5)F((r)=>r?{...r,left:r.left+l,top:r.top+Z0}:r)},[z,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,i=(e,l,Z0)=>{if(H&&e&&e!==H&&Z0&&!d.test(Z0))Y(Z0);else Y(`var(${l})`);U(!1)},v=(e)=>{let l=(e||"").trim();if(l)Y(l)},n=R("div",{className:"st-cp-pop-search",children:[K(n8,{name:"search",size:12}),K("input",{value:w,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),Y0=(e)=>e.map((l)=>R("div",{className:"st-cp-pop-group",children:[j?K("div",{className:"st-cp-pop-ds",children:l.ds}):null,K("div",{className:"st-cp-pop-list",children:l.names.map((Z0)=>R("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(Z0)?" is-on":""}`,onClick:()=>i(l.ds,Z0,l.vals?.[Z0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:l.vals?.[Z0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:T(Z0)}),K("span",{className:"st-cp-pop-val",children:l.vals?.[Z0]||""})]},`${l.ds}:${Z0}`))})]},l.ds)),g=(e)=>e.map((l)=>R("div",{className:"st-cp-pop-group",children:[j?K("div",{className:"st-cp-pop-ds",children:l.ds}):null,K("div",{className:"st-cp-pop-list",children:l.names.map((Z0)=>R("button",{type:"button",className:`st-cp-pop-row${I(Z0)?" is-on":""}`,onClick:()=>i(l.ds,Z0,l.vals?.[Z0]),children:[K("span",{className:"st-cp-pop-name",children:T(Z0)}),K("span",{className:"st-cp-pop-val",children:l.vals?.[Z0]||""})]},`${l.ds}:${Z0}`))})]},l.ds)),G0=K("div",{className:"st-cp-pop-empty",children:"No match"});return R(Q0,{children:[G!==void 0?K("button",{type:"button",ref:A,className:`${Z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!Z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":z,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>U((e)=>!e),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:A,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":z,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>U((e)=>!e),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),z&&B?oa.createPortal(K("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?R(Q0,{children:[R("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),L==="custom"?K(Xs,{seed:q||TE(Q)||"#000000",onApply:v}):!S?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):R(Q0,{children:[n,h.length?Y0(h):G0]})]}):!S?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):R(Q0,{children:[n,h.length?g(h):G0]})}),document.body):null]})}function Kz0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:q,onSetMode:H}){let Z=!!X.id,z=X.computed||{},[U,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(o,B0)=>{let H0={...o||{}};for(let[A0,p0]of Object.entries(B0))if(p0===null)delete H0[A0];else H0[A0]=p0;return H0},L=F(X.authored,U.a),D=F(X.customStyles,U.c),w=F(X.attrs,U.t),E=(o,B0)=>B((H0)=>({...H0,a:{...H0.a,[o]:B0}})),A=(o,B0)=>B((H0)=>({...H0,c:{...H0.c,[o]:B0}})),O=(o,B0)=>B((H0)=>({...H0,t:{...H0.t,[o]:B0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=qz0(X.file,J),T=Zz0(J,P,I),C=(o)=>T.map((B0)=>({ds:B0.name,names:B0[o]||[],vals:B0.vals})).filter((B0)=>B0.names.length),[S,j]=u.useState({}),[b,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(w).length>0;u.useEffect(()=>{if(d)h((o)=>o.Advanced?o:{...o,Advanced:!0})},[X.id,d]);let i=(L.position||C9(z.position)||"static")!=="static";u.useEffect(()=>{if(i)h((o)=>o["d:Position"]?o:{...o,"d:Position":!0})},[X.id,i]);let v=H,[n,Y0]=u.useState({});async function g(o,B0,H0){j((A0)=>({...A0,[H0]:"saving"}));try{let A0=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B0)}),p0=await A0.json().catch(()=>({}));j((M8)=>({...M8,[H0]:!A0.ok||!p0.ok?`err:${p0&&p0.error||`HTTP ${A0.status}`}`:"saved"}))}catch(A0){j((p0)=>({...p0,[H0]:`err:${A0&&A0.message?A0.message:String(A0)}`}))}}let G0=(o,B0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:o,value:B0})},e=(o,B0,H0,A0)=>{Y?.({op:o,canvas:X.file,id:X.id,key:B0,before:H0==null||H0===""?null:H0,after:A0==null||A0===""?null:A0})},l=(o,B0)=>{let H0=(B0||"").trim();if(!Z||!H0)return;let A0=L[o]??null;if(H0===(A0??"").trim())return;G0(o,H0),E(o,H0),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,value:H0},o),e("css",o,A0,H0)},Z0=(o,B0)=>{let H0=(B0||"").trim(),A0=o.trim();if(!Z||!A0||!H0)return;let p0=D[A0]??null;G0(A0,H0),A(A0,H0),g("/_api/edit-css",{canvas:X.file,id:X.id,property:A0,value:H0},A0),e("css",A0,p0,H0)},r=(o,B0)=>{let H0=(o||"").trim(),A0=(B0||"").trim();if(!Z||!H0||!A0)return;let p0=w[H0]??null;O(H0,A0),g("/_api/edit-attr",{canvas:X.file,id:X.id,attr:H0,value:A0},`@${H0}`),e("attr",H0,p0,A0)},a=(o)=>{if(!Z)return;let B0=L[o]??null;G0(o,null),E(o,null),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,reset:!0},o),e("css",o,B0,null)},c=(o)=>{if(!Z)return;let B0=D[o]??null;G0(o,null),A(o,null),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,reset:!0},o),e("css",o,B0,null)},V0=(o)=>{if(!Z)return;let B0=w[o]??null;O(o,null),g("/_api/edit-attr",{canvas:X.file,id:X.id,attr:o,reset:!0},`@${o}`),e("attr",o,B0,null)},o0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},U8=(o,B0)=>{if(!Z)return;let H0=Math.round((o==="width"?X.bounds?.w:X.bounds?.h)||0),A0=jT(o,B0,o0,H0);for(let p0 of A0.reset)if(L[p0])a(p0);for(let[p0,M8]of A0.set)l(p0,M8)},V8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",L0=(o)=>{let B0=bT(o,L,z,o0);return R("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:o==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${o} sizing mode`,children:K(fy,{value:B0,ariaLabel:`${o} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(H0)=>U8(o,H0)})})]},`mode-${o}`)},t0=["flex-start","center","flex-end"],n0=["flex-start","center","flex-end"],Q8=["t","c","b"],v8=["l","c","r"],i8=()=>{let o=!(L["flex-direction"]||C9(z["flex-direction"])||"row").startsWith("column"),B0=Math.max(0,t0.indexOf(L["justify-content"]||C9(z["justify-content"])||"flex-start")),H0=L["align-items"]||C9(z["align-items"])||"stretch",A0=H0==="stretch"?1:Math.max(0,n0.indexOf(H0)),[p0,M8]=o?[B0,A0]:[A0,B0];return Q8[M8]+v8[p0]},g8=(o)=>{let B0=Q8.indexOf(o[0]),H0=v8.indexOf(o[1]),A0=!(L["flex-direction"]||C9(z["flex-direction"])||"row").startsWith("column"),[p0,M8]=A0?[H0,B0]:[B0,H0];l("justify-content",t0[p0]),l("align-items",n0[M8])},z9=(o)=>{if(!(o.metaKey||o.ctrlKey)||o.altKey)return;let B0=o.key.toLowerCase();if(B0==="z")o.preventDefault(),G?.(o.shiftKey?"redo":"undo");else if(B0==="y")o.preventDefault(),G?.("redo")},c0=(o)=>{let B0=L[o];if(!B0)return"inherit";return/var\(\s*--/.test(B0)?"bound":"raw"};if(!Z)return R("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),R("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let d8={bound:"token-bound",raw:"raw override",inherit:"inherited"},o8=(o)=>K("span",{className:`st-cp-prov st-cp-prov--${o}`,role:"img","aria-label":d8[o]}),j9=(o,B0)=>{let H0=B0??c0(o),A0=S[o],p0=typeof A0==="string"&&A0.startsWith("err:")?A0.slice(4):"",M8=p0?" is-err":A0==="saved"?" is-saved":A0==="saving"?" is-saving":"",T8=!!L[o],b8=p0?`error: ${p0}`:T8?`${d8[H0]} · double-click to reset`:d8[H0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${H0}${M8}${T8?" is-resettable":""}`,"aria-label":b8,title:b8,tabIndex:T8?0:-1,onDoubleClick:T8?()=>a(o):void 0,onKeyDown:T8?(p8)=>{if(p8.key==="Backspace"||p8.key==="Delete")p8.preventDefault(),a(o)}:void 0})},f0=(o,B0,H0,A0)=>{let p0=H0===void 0&&!L[o],M8=A0??o;return R("div",{className:`st-cp-row${p0?" is-unset":""}`,children:[j9(o,H0),K("label",{className:"st-cp-label",title:M8,children:M8}),K("div",{className:"st-cp-ctl",children:B0})]},o)},z0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],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"]},F0=(o)=>{(z0[o]||[]).forEach((B0)=>{if(L[B0])a(B0)})},U0=(o,B0)=>{let H0=(z0[o]||[]).some((A0)=>L[A0]);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!b[o],onClick:()=>h((A0)=>({...A0,[o]:!A0[o]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:b[o]?"▾":"▸"}),o]}),K("button",{type:"button",className:`st-cp-secreset${H0?"":" is-quiet"}`,"aria-label":`reset ${o} section to original`,title:`reset ${o}`,disabled:!H0,onClick:()=>F0(o),children:K(E9,{as:VG,size:12})})]}),K("div",{className:`st-cp-sec-anim${b[o]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:B0})})]},o)},y0=(o,B0,H0,A0=!0)=>{let p0=`d:${o}`,M8=b[p0]===void 0?A0:b[p0],T8=B0.some((b8)=>L[b8]);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":M8,onClick:()=>h((b8)=>({...b8,[p0]:!M8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:M8?"▾":"▸"}),o]}),K("button",{type:"button",className:`st-cp-secreset${T8?"":" is-quiet"}`,"aria-label":`reset ${o} to original`,title:`reset ${o}`,disabled:!T8,onClick:()=>B0.forEach((b8)=>{if(L[b8])a(b8)}),children:K(E9,{as:VG,size:12})})]}),K("div",{className:`st-cp-sec-anim${M8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:H0})})]},p0)},w0=(o)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!n[o],"aria-label":n[o]?`${o} — fewer options`:`${o} — more options`,title:n[o]?"fewer":"more",onClick:()=>Y0((B0)=>({...B0,[o]:!B0[o]})),children:n[o]?"▴":"···"}),R0=(o,B0)=>R("select",{className:"st-cp-nsel","aria-label":o,value:B0.includes(L[o])?L[o]:"",onChange:(H0)=>l(o,H0.target.value),children:[K("option",{value:"",disabled:!0,children:C9(z[o])||"—"}),B0.map((H0)=>K("option",{value:H0,children:H0},H0))]}),I0=(o)=>C(o).flatMap((B0)=>(B0.names||[]).map((H0)=>({name:H0,value:B0.vals?.[H0]||""}))),O8=(o,B0)=>K(kM,{value:L[o]||C9(z[o])||B0[0].value,ariaLabel:o,options:B0,onChange:(H0)=>l(o,H0)}),r0=(o,B0,H0={})=>{let A0=c5(L[o]??""),p0=ma.has(o),M8=L[o]??"",T8=typeof M8==="string"&&/var\(\s*--/.test(M8),b8=p0?"":A0.unit&&A0.unit!=="auto"?A0.unit:"px",p8=Number.parseFloat(c5(C9(z[o])??"").n)||0,y9=A0.n!==""&&A0.n!=null?Number.parseFloat(A0.n)||0:p8,c9=PE[o];return K(my,{value:T8?M8:y9,tokens:I0(B0),ariaLabel:o,min:H0.min??0,lead:c9?c9.node??c9.t:void 0,unitSlot:p0?null:K(RM,{units:ga,value:A0.unit||"px",ariaLabel:`${o} unit`,onChange:(u7)=>l(o,u7==="auto"?"auto":`${A0.n||"0"}${u7}`)}),onChange:(u7)=>l(o,typeof u7==="string"?u7:p0?`${u7}`:`${u7}${b8}`)})},d0=()=>{let o=(p0)=>Number.parseFloat(c5(L[p0]??L["border-radius"]??C9(z[p0])??C9(z["border-radius"])??"0").n)||0,B0={tl:o("border-top-left-radius"),tr:o("border-top-right-radius"),bl:o("border-bottom-left-radius"),br:o("border-bottom-right-radius")},H0=(p0)=>{if(p0.tl===p0.tr&&p0.tr===p0.bl&&p0.bl===p0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((T8)=>{if(L[T8])a(T8)}),l("border-radius",`${p0.tl}px`);else l("border-top-left-radius",`${p0.tl}px`),l("border-top-right-radius",`${p0.tr}px`),l("border-bottom-left-radius",`${p0.bl}px`),l("border-bottom-right-radius",`${p0.br}px`)},A0=PE["border-radius"];return K(uy,{corners:B0,lead:A0?A0.node??A0.t:void 0,onCorners:H0})},$8=()=>R("div",{className:"st-cp-border",children:[a8("border-width",null,{fixedUnit:"px"}),R("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:ha.includes(L["border-style"])?L["border-style"]:"",onChange:(o)=>l("border-style",o.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),ha.map((o)=>K("option",{value:o,children:o},o))]}),K(RE,{kind:"color",groups:C("color"),current:L["border-color"],activeDs:I,swatchBg:z["border-color"]||L["border-color"]||"",seedHex:TE(z["border-color"]||L["border-color"])||"#000000",onPick:(o)=>l("border-color",o),label:"border colour"})]}),v9=()=>{let o=L.transform||C9(z.transform)||"",B0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(o),H0=((B0?Number.parseFloat(B0[1]):0)%360+360)%360,A0=(p0)=>{let M8=(p0%360+360)%360,T8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();l("transform",`${T8?`${T8} `:""}rotate(${M8}deg)`.trim())};return R("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(hy,{value:H0,onChange:A0}),K(UG,{value:H0,min:0,max:360,ariaLabel:"rotation",lead:K(E9,{as:VG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:A0})]})},r8=()=>{let o=L.filter||C9(z.filter)||"",B0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(o),H0=B0?Number.parseFloat(B0[1]):0;return K(UG,{value:H0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(p0)=>{let M8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();l("filter",p0>0?`${M8?`${M8} `:""}blur(${p0}px)`.trim():M8||"none")}})},k0=()=>{let o=L.opacity,B0=o!=null&&o!==""?Number.parseFloat(o):Number.parseFloat(C9(z.opacity))||1,H0=Math.round((Number.isNaN(B0)?1:B0)*100);return K(m5,{value:H0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(A0)=>G0("opacity",String(A0/100)),onCommit:(A0)=>l("opacity",String(A0/100))},`opacity:${o??""}`)},z8=()=>{let o=Number.parseInt(L["font-weight"]||C9(z["font-weight"])||"400",10)>=600,B0=(L["font-style"]||C9(z["font-style"]))==="italic",H0=/underline/.test(L["text-decoration"]||C9(z["text-decoration"])||"");return K(vy,{value:{b:o,i:B0,u:H0},ariaLabel:"text style",options:[{value:"b",node:K(E9,{as:jz}),label:"Bold"},{value:"i",node:K(E9,{as:xz}),label:"Italic"},{value:"u",node:K(E9,{as:iz}),label:"Underline"}],onToggle:(A0)=>{if(A0==="b")l("font-weight",o?"400":"700");else if(A0==="i")l("font-style",B0?"normal":"italic");else l("text-decoration",H0?"none":"underline")}})},m7=[{value:"row",node:K(E9,{as:FY}),label:"Row"},{value:"column",node:K(E9,{as:NY}),label:"Column"}],nX=[{value:"flex-start",node:K(E9,{as:Tz}),label:"Start"},{value:"center",node:K(E9,{as:kz}),label:"Center"},{value:"flex-end",node:K(E9,{as:Iz}),label:"End"},{value:"space-between",node:K(E9,{as:xH}),label:"Space between"}],t6=[{value:"flex-start",node:K(E9,{as:$z}),label:"Start"},{value:"center",node:K(E9,{as:Cz}),label:"Center"},{value:"flex-end",node:K(E9,{as:Sz}),label:"End"},{value:"stretch",node:K(E9,{as:cz}),label:"Stretch"}],Q9=[{value:"left",node:K(E9,{as:dJ}),label:"Left"},{value:"center",node:K(E9,{as:DY}),label:"Center"},{value:"right",node:K(E9,{as:OY}),label:"Right"},{value:"justify",node:K(E9,{as:MY}),label:"Justify"}],G7=[{value:"visible",node:K(E9,{as:zG}),label:"Visible"},{value:"hidden",node:K(E9,{as:uz}),label:"Hidden"},{value:"scroll",node:K(E9,{as:lz}),label:"Scroll"}],r7=(o,B0)=>{let H0=C(B0);return H0.length?K(RE,{kind:"value",groups:H0,current:L[o],activeDs:I,onPick:(A0)=>l(o,A0),label:`${o} design token`}):null},B9=(o)=>{let B0=o.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===B0)B0.select()})},p9=(o,B0)=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return!1;o.preventDefault();let H0=o.shiftKey?10:1,A0=o.key==="ArrowUp"?1:-1,p0=(Number.parseFloat(o.currentTarget.value)||0)+A0*H0;return o.currentTarget.value=String(p0),B0(p0),!0},F7=(o)=>K("input",{className:"st-cp-fin","aria-label":o,defaultValue:L[o]??"",placeholder:C9(z[o])||"—",onFocus:B9,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>l(o,B0.currentTarget.value)},`${o}:${L[o]??""}`),a8=(o,B0,H0={})=>{let A0=c5(L[o]??""),p0=ma.has(o),M8=p0?"":H0.fixedUnit||(A0.unit&&A0.unit!=="auto"?A0.unit:"px"),T8=PE[o],b8=Number.parseFloat(c5(C9(z[o])??"").n)||0,p8=A0.n!==""&&A0.n!=null?Number.parseFloat(A0.n)||0:b8;return R(Q0,{children:[K(UG,{value:p8,min:H0.min??0,step:1,ariaLabel:o,lead:T8?T8.node??T8.t:void 0,onCommit:(y9)=>l(o,p0?`${y9}`:`${y9}${M8}`),unitSlot:p0||H0.fixedUnit?null:K(RM,{units:ga,value:A0.unit||"px",ariaLabel:`${o} unit`,onChange:(y9)=>l(o,y9==="auto"?"auto":`${A0.n||"0"}${y9}`)})},`${o}:${L[o]??""}`),r7(o,B0)]})},H6=(o)=>{let B0=z[o]||L[o]||"",H0=L[o]??"",A0=typeof H0==="string"&&/var\(\s*--/.test(H0),p0=A0?H0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):H0;return K(B2,{swatch:K(RE,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:C("color"),current:L[o],activeDs:I,swatchBg:B0,seedHex:TE(z[o]||L[o])||"#000000",onPick:(M8)=>l(o,M8),label:`${o} colour`}),displayValue:p0,bound:A0,ariaLabel:o,onValue:(M8)=>l(o,M8)})},j6=(o,B0)=>{let H0=null,A0=B0.unitless?"":"px",p0=(b8)=>B0.unitless?`${b8}`:`${b8}${A0}`,M8=(b8,p8,y9)=>{for(let c9 of p8??[o])y9(c9,p0(b8))},T8=PM({getBase:()=>H0?.value??"0",min:B0.min??0,step:1,sides:B0.sides,onInput:(b8,p8)=>{if(H0)H0.value=String(b8);if(p8){let y9=H0?.closest(".st-cp-box");for(let c9 of p8){if(c9===o)continue;let u7=y9?.querySelector(`.st-cp-boxv[aria-label="${c9}"]`);if(u7)u7.value=String(b8)}}M8(b8,p8,G0)},onCommit:(b8,p8)=>M8(b8,p8,l)});return{onPointerDown:(b8)=>{H0=b8.currentTarget,T8(b8)}}},Y9=(o,B0)=>{let H0=L[o],A0=H0!=null&&H0!==""?c5(H0).n||H0:c5(C9(z[o])??"").n||"0",p0=!H0||H0==="0"||H0==="0px"||H0==="auto",M8=o.split("-").pop(),T8=M8==="top"||M8==="bottom"?[`${B0}-top`,`${B0}-bottom`]:[`${B0}-left`,`${B0}-right`],b8=[`${B0}-top`,`${B0}-right`,`${B0}-bottom`,`${B0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${B0[0]}${o.split("-").pop()[0]}${p0?" is-zero":""}`,"aria-label":o,defaultValue:A0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...j6(o,{sides:{pair:T8,all:b8}}),onFocus:B9,onKeyDown:(p8)=>{if(p9(p8,(y9)=>l(o,`${y9}px`)))return;if(p8.key==="Enter")p8.currentTarget.blur()},onBlur:(p8)=>{let y9=p8.currentTarget.value.trim();if(!y9)return;let c9=/[a-z%]/i.test(y9)?y9:`${y9}px`;l(o,c9)}},`${o}:${H0??""}`)},q7=(o)=>{let B0=L[o],H0=B0!=null&&B0!==""&&B0!=="auto"?c5(B0).n||B0:c5(C9(z[o])??"").n||"",A0=!B0||B0==="auto"||B0==="0"||B0==="0px",p0=o==="top"||o==="bottom"?["top","bottom"]:["left","right"],M8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${o[0]}${A0?" is-zero":""}`,"aria-label":o,defaultValue:H0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...j6(o,{sides:{pair:p0,all:M8},min:-1/0}),onFocus:B9,onKeyDown:(T8)=>{if(p9(T8,(b8)=>l(o,`${b8}px`)))return;if(T8.key==="Enter")T8.currentTarget.blur()},onBlur:(T8)=>{let b8=T8.currentTarget.value.trim();if(!b8)return;let p8=/[a-z%]/i.test(b8)?b8:`${b8}px`;l(o,p8)}},`${o}:${B0??""}`)},Z5=Object.entries(D),rX=Object.entries(w),e6=()=>{let o=(X.tag||"").toLowerCase(),H0=o==="img"||o==="video"||o==="picture"||o==="svg"||o==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],A0=(o==="img"||o==="video")&&!!X.attrs?.src&&!!W;return{showMedia:H0,canReplace:A0}},H7=(o)=>R(Q0,{children:[o&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),f0("object-fit",R0("object-fit",Gz0)),f0("object-position",F7("object-position")),f0("aspect-ratio",R("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:ca.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(B0)=>{let H0=B0.target.value;if(l("aspect-ratio",H0),H0&&H0!=="auto"&&L.height)a("height")},children:[K("option",{value:"",disabled:!0,children:C9(z["aspect-ratio"])||"—"}),ca.map((B0)=>K("option",{value:B0,children:B0},B0))]}))]});return R("div",{className:`st-cp${q==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:z9,children:[R("div",{className:"st-cp-id",children:[R("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?R("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(kM,{value:q,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(E9,{as:BY,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(E9,{as:wY,size:12}),label:"Designer — Figma vocabulary"}],onChange:v})})]}),q==="designer"?R(Q0,{children:[y0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let o=(L.display||C9(z.display)||"").trim();return o==="flex"||o==="inline-flex"?R(Q0,{children:[f0("flex-direction",O8("flex-direction",m7),void 0,"Direction"),f0("align-items",K(xy,{value:i8(),onChange:g8,ariaLabel:"auto-layout alignment"}),c0("align-items"),"Alignment"),f0("gap",r0("gap","space"),void 0,"Gap"),R("div",{className:"st-cp-modes",children:[L0("width"),L0("height")]}),R("div",{className:"st-cp-box","aria-label":"padding",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(c0("padding-top")),"padding"]}),Y9("padding-top","padding"),Y9("padding-right","padding"),Y9("padding-bottom","padding"),Y9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:w0("Auto layout")}),n["Auto layout"]?f0("flex-wrap",K(EY,{checked:/^wrap/.test(L["flex-wrap"]||C9(z["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(H0)=>l("flex-wrap",H0?"wrap":"nowrap")}),c0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!Z,onClick:()=>l("display","flex"),children:"+ Auto layout (flex)"})})()),y0("Size",["width","height","min-width","max-width","min-height","max-height"],R(Q0,{children:[f0("width",a8("width"),void 0,"Width"),f0("height",a8("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:w0("Size")}),n.Size?R(Q0,{children:[f0("min-width",a8("min-width"),void 0,"Min width"),f0("max-width",a8("max-width"),void 0,"Max width"),f0("min-height",a8("min-height"),void 0,"Min height"),f0("max-height",a8("max-height"),void 0,"Max height")]}):null]})),y0("Position",["position","top","right","bottom","left","z-index"],R(Q0,{children:[f0("position",R0("position",ua),void 0,"Position"),R("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(c0("top")),"inset"]}),q7("top"),q7("right"),q7("bottom"),q7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||C9(z.position)||"static"})]}),(L.position||C9(z.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:w0("Position")}),n.Position?f0("z-index",a8("z-index"),void 0,"Layer order"):null]}),!1),y0("Fill",["background-color"],f0("background-color",H6("background-color"),void 0,"Fill")),y0("Stroke",["border-width","border-style","border-color"],f0("border",$8(),c0("border-width"),"Stroke")),y0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],f0("border-radius",d0(),c0("border-radius"),"Corner radius")),y0("Effects",["box-shadow","filter","mix-blend-mode"],R(Q0,{children:[f0("box-shadow",r7("box-shadow","shadow")||F7("box-shadow"),void 0,"Shadow"),f0("filter",r8(),c0("filter"),"Blur"),f0("mix-blend-mode",R0("mix-blend-mode",pa),void 0,"Blend")]})),y0("Opacity",["opacity"],f0("opacity",k0(),void 0,"Opacity")),y0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],R(Q0,{children:[f0("font-family",R0("font-family",xa),void 0,"Font"),f0("color",H6("color"),void 0,"Color"),f0("font-size",r0("font-size","type"),void 0,"Size"),f0("font-weight",R0("font-weight",va),void 0,"Weight"),f0("line-height",a8("line-height","lh"),void 0,"Line height"),f0("text-align",O8("text-align",Q9),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:w0("Text")}),n.Text?R(Q0,{children:[f0("letter-spacing",a8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),f0("font-style",R0("font-style",Wz0),void 0,"Style"),f0("text-transform",R0("text-transform",la),void 0,"Case"),f0("white-space",R0("white-space",da),void 0,"Whitespace")]}):null]})),y0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],R("div",{className:"st-cp-box","aria-label":"margin",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(c0("margin-top")),"margin"]}),Y9("margin-top","margin"),Y9("margin-right","margin"),Y9("margin-bottom","margin"),Y9("margin-left","margin")]})),(()=>{let{showMedia:o,canReplace:B0}=e6();return o?y0("Media",["object-fit","object-position","aspect-ratio"],H7(B0)):null})()]}):R(Q0,{children:[U0("Layout",(()=>{let o=(L.display||C9(z.display)||"").trim(),B0=o==="flex"||o==="inline-flex",H0=o==="grid"||o==="inline-grid";return R(Q0,{children:[f0("display",R0("display",Qz0)),B0?R(Q0,{children:[f0("flex-direction",O8("flex-direction",m7)),f0("flex-wrap",K(EY,{checked:/^wrap/.test(L["flex-wrap"]||C9(z["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(A0)=>l("flex-wrap",A0?"wrap":"nowrap")}),c0("flex-wrap"))]}):null,B0||H0?R(Q0,{children:[f0("align-items",O8("align-items",t6)),f0("justify-content",O8("justify-content",nX)),f0("gap",r0("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!Z,onClick:()=>l("display","flex"),children:"+ Auto layout (flex)"})]})})()),U0("Position",R(Q0,{children:[f0("position",R0("position",ua)),R("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(c0("top")),"inset"]}),q7("top"),q7("right"),q7("bottom"),q7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||C9(z.position)||"static"})]}),(L.position||C9(z.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,f0("z-index",a8("z-index"))]})),U0("Typography",R(Q0,{children:[f0("font-family",R0("font-family",xa)),f0("color",H6("color")),f0("font-size",r0("font-size","type")),f0("font-weight",R0("font-weight",va)),f0("line-height",a8("line-height","lh")),f0("letter-spacing",a8("letter-spacing",null,{min:-1/0})),f0("text-align",O8("text-align",Q9)),f0("font-style",z8(),c0("font-style")),f0("text-transform",R0("text-transform",la)),f0("white-space",R0("white-space",da))]})),U0("Spacing",K(Q0,{children:R("div",{className:"st-cp-box","aria-label":"margin and padding",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(c0("margin-top")),"margin"]}),Y9("margin-top","margin"),Y9("margin-right","margin"),Y9("margin-bottom","margin"),Y9("margin-left","margin"),R("div",{className:"st-cp-boxpad",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(c0("padding-top")),"padding"]}),Y9("padding-top","padding"),Y9("padding-right","padding"),Y9("padding-bottom","padding"),Y9("padding-left","padding"),R("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(L.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(L.height)||X.bounds?.h||0)]})]})]})})),U0("Size",R(Q0,{children:[R("div",{className:"st-cp-modes",children:[L0("width"),L0("height")]}),f0("width",a8("width")),f0("height",a8("height")),f0("min-width",a8("min-width")),f0("max-width",a8("max-width")),f0("min-height",a8("min-height")),f0("max-height",a8("max-height")),f0("overflow",O8("overflow",G7)),V8?R(Q0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),f0("align-self",R0("align-self",Yz0)),f0("flex-grow",a8("flex-grow",null,{unitless:!0})),f0("flex-shrink",a8("flex-shrink",null,{unitless:!0})),f0("flex-basis",a8("flex-basis"))]}):null]})),(()=>{let{showMedia:o,canReplace:B0}=e6();return o?U0("Media",H7(B0)):null})(),U0("Appearance",R(Q0,{children:[f0("background-color",H6("background-color")),f0("border-radius",d0(),c0("border-radius")),f0("border",$8(),c0("border-width")),f0("box-shadow",r7("box-shadow","shadow")||F7("box-shadow")),f0("filter",r8(),c0("filter")),f0("mix-blend-mode",R0("mix-blend-mode",pa)),f0("opacity",k0()),f0("rotation",v9(),c0("transform")),f0("transform",F7("transform")),f0("transform-origin",F7("transform-origin"))]})),(()=>{let o=Object.entries(S).find(([,B0])=>typeof B0==="string"&&B0.startsWith("err:"));return o?R("div",{className:"st-cp-save is-err",role:"status",children:[K(n8,{name:"x",size:12}),o[0],": ",o[1].slice(4)]}):null})(),U0("Advanced",R("div",{className:"st-cp-advbody",children:[Z5.length?R(Q0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),Z5.map(([o,B0])=>R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:o,"aria-label":`custom property ${o} name`}),K("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${o} value`,onKeyDown:(H0)=>{if(H0.key==="Enter")H0.currentTarget.blur()},onBlur:(H0)=>Z0(o,H0.currentTarget.value)},`cs:${o}:${B0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${o}`,title:"remove",onClick:()=>c(o),children:K(n8,{name:"x",size:11})})]},`cs:${o}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(zz0,{commit:Z0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),rX.length?R(Q0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),rX.map(([o,B0])=>R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:o,"aria-label":`attribute ${o} name`}),K("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${o} value`,onKeyDown:(H0)=>{if(H0.key==="Enter")H0.currentTarget.blur()},onBlur:(H0)=>r(o,H0.currentTarget.value)},`at:${o}:${B0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${o}`,title:"remove",onClick:()=>V0(o),children:K(n8,{name:"x",size:11})})]},`at:${o}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(Vz0,{commit:r})]}))]}),R("div",{className:"st-cp-legend",children:[R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function zz0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(q)=>Q(q.target.value)}),K("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")G()},onBlur:G})]})}function Vz0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(q)=>Q(q.target.value)}),K("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")G()},onBlur:G})]})}var Uz0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box"};function Bz0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,q=(Z)=>{for(let z=0;z<Z.length;z++){if(Z[z].id===J)return G=Z[z],Z.splice(z,1),!0;if(Z[z].children&&q(Z[z].children))return!0}return!1};if(q(W),!G)return X;let H=(Z)=>{for(let z=0;z<Z.length;z++){if(Z[z].id===Q){if(Y==="inside-start"||Y==="inside-end")if(Z[z].children=Z[z].children||[],Y==="inside-start")Z[z].children.unshift(G);else Z[z].children.push(G);else Z.splice(Y==="before"?z:z+1,0,G);return!0}if(Z[z].children&&H(Z[z].children))return!0}return!1};return H(W)?W:X}var Fz0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Js({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:q,onSelect:H,onHover:Z,onToggleVisibility:z,onReorder:U,onRowPointerDown:B,dragState:F}){let L=`${X.id}:${X.index}`,D=X.children&&X.children.length>0,w=W.has(L),E=X.id===Q&&(Y==null||X.index===Y),A=G?.has(L)?G.get(L):!!X.hidden,O=!!U,P=F?.key===L,I=P?{transform:`translate(${F.dx}px, ${F.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return R(Q0,{children:[R("div",{className:"st-layer st-layer--row"+(E?" is-sel":"")+(A?" is-hidden":""),style:{paddingLeft:6+J*14,...I},role:"treeitem","aria-selected":E,"aria-expanded":D?!w:void 0,"aria-grabbed":O?P:void 0,tabIndex:0,title:`${X.tag} · ${X.type}`,"data-layer-key":L,onClick:()=>H(X),onMouseEnter:()=>Z(X),onMouseLeave:()=>Z(null),onPointerDown:O?(T)=>B(T,X,L):void 0,onKeyDown:(T)=>{if(T.key==="Enter"||T.key===" ")T.preventDefault(),H(X)},children:[D?K("button",{type:"button",className:"st-layer-caret","aria-label":w?"Expand":"Collapse",onClick:(T)=>{T.stopPropagation(),q(L)},children:w?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),K(n8,{name:Uz0[X.type]||"box",size:12,className:"st-layer-ticon"}),K("span",{className:"st-layer-label",children:X.label}),K("span",{className:"st-layer-type",children:X.type}),z?K("button",{type:"button",className:"st-layer-eye","aria-label":A?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":A,title:A?"Show":"Hide",onClick:(T)=>{T.stopPropagation(),z(X)},children:K(n8,{name:A?"eye-off":"eye",size:13})}):null]}),D&&!w?X.children.map((T,C)=>K(Js,{node:T,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:q,onSelect:H,onHover:Z,onToggleVisibility:z,onReorder:U,onRowPointerDown:B,dragState:F},`${T.id}:${T.index}`)):null]})}function Nz0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(z)=>{let U=Q[z];if(U&&/var\(\s*--/.test(U))return U.replace(/^var\(\s*|\s*\)$/g,"");return J[z]||U||""},W=(z,U)=>{let B=J[U]||Q[U];if(!B)return null;return R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:z}),R("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(U)})]})]},z)},G=J["border-radius"]&&J["border-radius"]!=="0px",q=G?c5(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 R(Q0,{children:[G?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:q,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Qs(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var Lz0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]];function Dz0({el:X,onResizeArtboard:J,onSetArtboardHug:Q,onSetArtboardStyle:Y}){let W=Qs(X),G=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,q=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,H=(E,A)=>{if(!W)return;let O=Number.isFinite(E)&&E>0?Math.round(E):void 0,P=Number.isFinite(A)&&A>0?Math.round(A):void 0;if(O==null&&P==null)return;J?.(W,O,P)},Z=Object.entries(aV).find(([,E])=>E.width===G&&E.height===q)?.[0],z=X.attrs?.["data-dc-fixed"]==="true",U=X.attrs?.["data-dc-bg"]??"",B=X.attrs?.["data-dc-padding"]??"",F=X.attrs?.["data-dc-layout"]??"",L=X.attrs?.["data-dc-gap"]??"",D=(E)=>{if(!W)return;let A=E&&Number.isFinite(q)?Math.round(q):void 0;Q?.(W,E,A)},w=(E)=>{if(!W)return;Y?.(W,E)};return R("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),R("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"W"}),K("input",{className:"st-cp-numin",type:"number",min:"1","aria-label":"artboard width",defaultValue:G??"",onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>H(Number.parseFloat(E.currentTarget.value),null)},`w:${G??""}`)]}),R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"H"}),K("input",{className:"st-cp-numin",type:"number",min:"1","aria-label":"artboard height",readOnly:!z,title:z?void 0:"Hug — grows to fit content. Switch to Fixed to set an exact height.",defaultValue:q??"",onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{if(!z)return;H(null,Number.parseFloat(E.currentTarget.value))}},`h:${q??""}:${z}`)]})]}),K("div",{style:{padding:"0 12px 8px"},children:R("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:Z??"",onChange:(E)=>{let A=aV[E.currentTarget.value];if(A)H(A.width,A.height)},children:[K("option",{value:"",disabled:!0,children:Z?aV[Z].label:"Preset size…"}),Object.entries(aV).map(([E,A])=>R("option",{value:E,children:[A.label," — ",A.width,"×",A.height]},E))]})}),K("div",{style:{padding:"0 12px 8px"},children:R("div",{className:"st-cp-modeseg",role:"group","aria-label":"artboard height sizing mode",children:[K("span",{className:"st-cp-modeax","aria-hidden":"true",children:"H"}),[[!1,"Hug"],[!0,"Fixed"]].map(([E,A])=>K("button",{type:"button",className:`st-cp-modebtn${z===E?" is-active":""}`,"aria-pressed":z===E,onClick:()=>D(E),title:`${A} height`,children:A},A))]})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),R("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[R("div",{className:"st-cp-num",style:{width:"100%"},children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Bg"}),K("input",{className:"st-cp-numin",type:"text","aria-label":"artboard background",placeholder:"var(--bg-1)",defaultValue:U,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>w({background:E.currentTarget.value.trim()||null})},`bg:${U}`)]}),K("select",{className:"st-cp-nsel","aria-label":"artboard body layout",value:F,onChange:(E)=>w({layout:E.currentTarget.value||null}),children:Lz0.map(([E,A])=>K("option",{value:E,children:A},E))}),R("div",{style:{display:"flex",gap:8},children:[R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Pad"}),K("input",{className:"st-cp-numin",type:"number",min:"0","aria-label":"artboard padding",defaultValue:B,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{let A=E.currentTarget.value;w({padding:A===""?null:Number.parseFloat(A)})}},`pad:${B}`)]}),R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Gap"}),K("input",{className:"st-cp-numin",type:"number",min:"0","aria-label":"artboard gap",defaultValue:L,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{let A=E.currentTarget.value;w({gap:A===""?null:Number.parseFloat(A)})}},`gap:${L}`)]})]})]})]})}var Ys=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i;function Oz0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;if((X.tag||"").toLowerCase()!=="img")return null;let J=X.html||"",Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=Ys.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function Mz0({selected:X,onClose:J,layersTree:Q,canvasFile:Y,onSelectLayer:W,onHoverLayer:G,onReorderLayer:q,layersBusyRef:H,cfg:Z,onOptimistic:z,onRecordEdit:U,onReplaceMedia:B,onResizeArtboard:F,onSetArtboardHug:L,onSetArtboardStyle:D,onUndoRedo:w,editScope:E,tab:A,onTabChange:O,width:P,resizing:I,photoSel:T,photoRev:C,onPhotoEdit:S,onPhotoRemoveBackground:j,onPhotoRecordEdit:b,onPhotoUndoRedo:h,layersOnly:d=!1,hideLayersTab:i=!1,cpMode:v,onSetCpMode:n}){let[Y0,g]=u.useState("inspect"),G0=d?"layers":A??Y0,e=(U0)=>{g(U0),O?.(U0)},[l,Z0]=u.useState(()=>new Set),[r,a]=u.useState(()=>new Map),c=(U0)=>{let y0=`${U0.id}:${U0.index}`;return r.has(y0)?r.get(y0):!!U0.hidden},[V0,o0]=u.useState(null),[U8,V8]=u.useState(""),L0=q?(U0,y0,w0)=>{if(H?.current)return;let R0=w0==="before"?`before ${y0.label}`:w0==="after"?`after ${y0.label}`:`into ${y0.label}`;V8(`Moved ${U0.label} ${R0}`),q(U0.id,y0.id,w0,{idIndex:U0.index,refIndex:y0.index})}:void 0,t0=()=>{let U0=[];return function y0(w0,R0,I0){(w0||[]).forEach((O8,r0)=>{if(U0.push({node:O8,depth:R0,parentNode:I0,siblings:w0,pos:r0}),O8.children&&O8.children.length&&!l.has(`${O8.id}:${O8.index}`))y0(O8.children,R0+1,O8)})}(Q?.nodes,0,null),U0},n0=(U0)=>{if(U0.key!=="ArrowUp"&&U0.key!=="ArrowDown")return;if(!c0)return;let y0=t0(),w0=y0.findIndex((r0)=>r0.node.id===c0.id&&r0.node.index===c0.index);if(w0<0)return;let R0=U0.key==="ArrowDown"?1:-1,I0=y0[w0];if(!U0.altKey){let r0=y0[w0+R0];if(r0)U0.preventDefault(),W?.(r0.node);return}if(!L0||!Array.isArray(I0.siblings))return;U0.preventDefault();let O8=(r0)=>r0&&r0.children&&r0.children.length&&!l.has(`${r0.id}:${r0.index}`);if(!U0.shiftKey){if(R0<0&&I0.pos>0)L0(I0.node,I0.siblings[I0.pos-1],"before");else if(R0>0&&I0.pos<I0.siblings.length-1)L0(I0.node,I0.siblings[I0.pos+1],"after");return}if(R0>0){let r0=I0.siblings[I0.pos+1];if(r0)L0(I0.node,r0,O8(r0)?"inside-start":"after");else if(I0.parentNode)L0(I0.node,I0.parentNode,"after")}else{let r0=I0.siblings[I0.pos-1];if(r0)L0(I0.node,r0,O8(r0)?"inside-end":"before");else if(I0.parentNode)L0(I0.node,I0.parentNode,"before")}},Q8=u.useRef(null),v8=u.useRef(null),i8=(U0,y0,w0)=>{if(!L0||U0.button!==0||U0.metaKey||U0.ctrlKey||U0.shiftKey||U0.altKey)return;if(H?.current)return;let{clientX:R0,clientY:I0}=U0,O8=new Set([w0]);(function Q9(G7){(G7.children||[]).forEach((r7)=>{O8.add(`${r7.id}:${r7.index}`),Q9(r7)})})(y0);let r0=14,d0=6,$8=[];(function Q9(G7,r7){(G7||[]).forEach((B9)=>{let p9=`${B9.id}:${B9.index}`;if($8.push({node:B9,key:p9,id:B9.id,depth:r7,tag:B9.tag}),B9.children&&B9.children.length&&!l.has(p9))Q9(B9.children,r7+1)})})(Q?.nodes,0);let v9=new Map($8.map((Q9)=>[Q9.key,Q9])),r8=!1,k0=(Q9)=>{if(!r8){if(Math.hypot(Q9.clientX-R0,Q9.clientY-I0)<4)return;r8=!0}let G7=Q9.clientX-R0,r7=Q9.clientY-I0,B9=null,p9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((a8)=>({rect:a8.getBoundingClientRect(),it:v9.get(a8.getAttribute("data-layer-key"))})).filter((a8)=>a8.it&&a8.it.key!==w0);if(p9.length){let a8=p9[0].rect.left,H6=p9[0].rect.right,j6=p9.length;for(let A0=0;A0<p9.length;A0++)if(Q9.clientY<p9[A0].rect.top+p9[A0].rect.height/2){j6=A0;break}let Y9=p9[j6-1]?.it||null,q7=p9[j6]?.it||null,Z5=Math.round((Q9.clientX-a8-d0)/r0),rX=Y9?Y9.depth+(Fz0.has(Y9.tag)?0:1):0,e6=q7?q7.depth:0,H7=Math.max(e6,Math.min(Z5,rX)),o=null,B0="before",H0=0;if(!Y9){if(q7)o=q7,B0="before",H0=q7.depth}else if(H7>Y9.depth)o=Y9,B0="inside-start",H0=Y9.depth+1;else if(H7===Y9.depth)o=Y9,B0="after",H0=Y9.depth;else{for(let A0=j6-1;A0>=0;A0--)if(p9[A0].it.depth===H7){o=p9[A0].it;break}if(!o)o=Y9;B0="after",H0=H7}if(o&&o.key!==w0&&!O8.has(o.key)){let A0=Y9?p9[j6-1].rect.bottom:p9[0].rect.top,p0=a8+d0+H0*r0;B9={refId:o.id,position:B0,node:o.node,y:A0,left:p0,w:Math.max(24,H6-p0)}}}let F7={key:w0,node:y0,dx:G7,dy:r7,target:B9};Q8.current=F7,o0(F7)},z8=()=>{window.removeEventListener("pointermove",k0),window.removeEventListener("pointerup",nX),window.removeEventListener("keydown",t6,!0)},m7=()=>{let Q9=(G7)=>{G7.preventDefault(),G7.stopImmediatePropagation(),document.removeEventListener("click",Q9,!0)};document.addEventListener("click",Q9,!0),setTimeout(()=>document.removeEventListener("click",Q9,!0),300)},nX=()=>{z8();let Q9=Q8.current;if(Q8.current=null,o0(null),r8&&Q9?.target)m7(),L0(Q9.node,Q9.target.node,Q9.target.position)},t6=(Q9)=>{if(Q9.key!=="Escape")return;if(Q9.preventDefault(),Q9.stopImmediatePropagation(),z8(),Q8.current=null,o0(null),r8)m7()};window.addEventListener("pointermove",k0),window.addEventListener("pointerup",nX),window.addEventListener("keydown",t6,!0)},g8=(U0)=>Z0((y0)=>{let w0=new Set(y0);if(w0.has(U0))w0.delete(U0);else w0.add(U0);return w0}),z9=(U0)=>{let y0=`${U0.id}:${U0.index}`,w0=c(U0),R0=!w0;if(a((I0)=>new Map(I0).set(y0,R0)),z?.({id:U0.id,artboardId:Q?.artboardId??null,index:U0.index,prop:"display",value:R0?"none":null}),!Y||!U0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(R0?{canvas:Y,id:U0.id,property:"display",value:"none"}:{canvas:Y,id:U0.id,property:"display",reset:!0})}).catch(()=>{}),U?.({op:"css",canvas:Y,id:U0.id,key:"display",before:w0?"none":null,after:R0?"none":null})},c0=Array.isArray(X)?X[0]:X,d8=T?{asset:T.asset,kind:"annotation-image"}:(()=>{let U0=Oz0(c0);return U0?{asset:U0,kind:"artboard-img"}:null})(),o8=d8?.kind==="annotation-image",j9=(U0)=>{if(!(U0.metaKey||U0.ctrlKey)||U0.altKey)return;let y0=U0.key.toLowerCase();if(y0==="z")U0.preventDefault(),h?.(U0.shiftKey?"redo":"undo");else if(y0==="y")U0.preventDefault(),h?.("redo")},f0=o8?"photo":G0==="photo"&&!d8?"inspect":G0,z0=(U0,y0,w0)=>R("button",{type:"button",className:"st-rp-tab"+(f0===U0?" is-active":""),onClick:()=>e(U0),children:[K(n8,{name:w0,size:14}),y0]}),F0=c0?.bounds||null;return R("aside",{className:"st-rpanel"+(I?" is-resizing":""),style:P?{width:P,flexBasis:P}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[R("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:d?{display:"none"}:void 0,children:[o8?z0("photo","Photo","image"):R(Q0,{children:[z0("inspect","Inspect","sliders"),!i&&z0("layers","Layers","layers"),z0("css","CSS","code"),d8?z0("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(n8,{name:"x",size:14})})]}),c0?.id&&!(Array.isArray(X)&&X.length>1)&&E?R("div",{className:`st-scope st-scope--${E.scope}`,title:E.scope==="shared"?`Editing this element's style changes ${E.affects} place${E.affects===1?"":"s"}${E.componentName?` (component ${E.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),E.scope==="shared"?`Shared${E.componentName?` · ${E.componentName}`:""} · edits ${E.affects} place${E.affects===1?"":"s"}`:"Local · this element only"]}):null,K("div",{className:"st-rp-body",children:f0==="photo"&&d8?K("div",{onKeyDown:j9,children:K(dy,{asset:d8.asset,ColorPicker:Xs,StIcon:n8,onEdit:(U0)=>S?.(d8.asset,U0),onRemoveBackground:j,onRecordEdit:(U0,y0)=>b?.(d8.asset,U0,y0)},`${d8.asset}:${C??0}`)}):!c0?K("div",{className:"st-rp-empty",children:R("p",{children:["Hold ",K(s6,{children:"⌘"})," inside the canvas and click an element to inspect it."]})}):f0==="inspect"?R(Q0,{children:[K("div",{className:"st-rp-hd",children:c0.selector||c0.tag||"element"}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:F0?Math.round(F0.x):"—",readOnly:!0,"aria-label":"x position"})]}),R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:F0?Math.round(F0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:F0?Math.round(F0.w):"—",readOnly:!0,"aria-label":"width"})]}),R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:F0?Math.round(F0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:c0.tag||"—"})})]}),c0.classes?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:c0.classes})})]}):null,K(Nz0,{el:c0})]}):f0==="layers"?R(Q0,{children:[R("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?R(Q0,{children:[L0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:v8,onKeyDown:n0,children:Q.nodes.map((U0,y0)=>K(Js,{node:U0,depth:0,selectedId:c0.id,selectedIndex:c0.index,collapsed:l,hiddenOverride:r,onToggle:g8,onSelect:(w0)=>{W?.(w0),v8.current?.focus()},onHover:(w0)=>G?.(w0),onToggleVisibility:z9,onReorder:L0,onRowPointerDown:i8,dragState:V0},`${U0.id}:${U0.index}`))}),V0?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:V0.target.left,top:V0.target.y-1,width:V0.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:U8})]}):Array.isArray(c0.dom_path)&&c0.dom_path.length?c0.dom_path.map((U0,y0)=>R("div",{className:"st-layer"+(y0===c0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+y0*12},children:[K(n8,{name:"square",size:13}),U0]},y0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!c0.id&&Qs(c0)?K(Dz0,{el:c0,onResizeArtboard:F,onSetArtboardHug:L,onSetArtboardStyle:D}):K(Kz0,{el:c0,cfg:Z,onOptimistic:z,onRecordEdit:U,onReplaceMedia:B,onUndoRedo:w,mode:v,onSetMode:n})})]})}function wz0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[q,H]=u.useState(null),[Z,z]=u.useState(null),U=u.useRef(null);u.useEffect(()=>{U.current=Z},[Z]);let[B,F]=u.useState(null);u.useEffect(()=>{let x=Array.isArray(Z)?Z.length===1?Z[0]:null:Z,y=x&&typeof x.id==="string"?x.id:null;if(!y||!q){F(null);return}let X0=new AbortController,K0=new URLSearchParams({canvas:q,id:y});return fetch(`/_api/edit-scope?${K0}`,{signal:X0.signal}).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(W0?.ok)F(W0)}).catch(()=>{}),()=>X0.abort()},[Z,q]);let L=u.useRef([]),D=u.useCallback((x)=>{if(!x?.id||!x.file)return;for(let y of L.current)clearTimeout(y);L.current=[50,450,1200,2500,5000].map((y)=>setTimeout(()=>{let X0=U.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.id!==x.id||K0.file!==x.file)return;let W0=j8.current.get(x.file);if(!W0?.contentWindow)return;try{W0.contentWindow.postMessage({dgn:"select-by-id",id:x.id,artboardId:x.artboardId??null,index:x.index??0},"*")}catch{}},y))},[]),w=u.useRef(null),E=u.useRef(null),A=u.useRef(null),O=u.useRef(null),P=u.useRef(!1),I=u.useRef(null),[T,C]=u.useState(null),[S,j]=u.useState(!1),[b,h]=u.useState(null),[d,i]=u.useState(null),[v,n]=u.useState(null),[Y0,g]=u.useState(null),[G0,e]=u.useState(!1),[l,Z0]=u.useState(null),[r,a]=u.useState(""),[c,V0]=u.useState(null),[o0,U8]=u.useState(null),V8=u.useRef(null),L0=ja("maude-sb-w",{min:200,max:420,def:252}),t0=ja("maude-rp-w",{min:260,max:480,def:304}),[n0,Q8]=u.useState(null),v8=u.useRef(null);u.useEffect(()=>{if(!n0)return;let x=(X0)=>{let K0=v8.current?.getBoundingClientRect();if(!K0)return;if(n0==="sb")L0.setW(X0.clientX-K0.left);else t0.setW(K0.right-X0.clientX)},y=()=>Q8(null);return window.addEventListener("pointermove",x),window.addEventListener("pointerup",y),()=>{window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",y)}},[n0,L0.setW,t0.setW]);let i8=u.useCallback((x)=>{clearTimeout(V8.current),V8.current=setTimeout(()=>{U8((y)=>y===x?null:y)},2500)},[]);u.useEffect(()=>{if(!o0)return;let x=setTimeout(()=>U8(null),15000);return()=>clearTimeout(x)},[o0]);let[g8,z9]=u.useState({designRel:".design"}),c0=u.useCallback(()=>{fetch("/_config").then((x)=>x.json()).then((x)=>{let y=(x.designRoot||".design").replace(/^\/+|\/+$/g,"");z9((X0)=>({...X0,designRel:y,tokensCssRel:x.tokensCssRel,designSystems:x.designSystems,canvasOrigin:x.canvasOrigin}))}).catch(()=>{})},[]);u.useEffect(()=>{c0()},[c0]),u.useEffect(()=>{let x=!1;return fetch("/_sync-status").then((y)=>y.json()).then((y)=>{if(x||!y||y.linked===!1)return;i(y)}).catch(()=>{}),()=>{x=!0}},[]),u.useEffect(()=>{let x=!1;return fetch("/_api/git/status").then((y)=>y.json()).then((y)=>{if(!x&&y)n(y)}).catch(()=>{}),()=>{x=!0}},[]);let[d8,o8]=u.useState({}),[j9,f0]=u.useState(null),[z0,F0]=u.useState(!1),[U0,y0]=u.useState("open"),[w0,R0]=u.useState(zK0),[I0,O8]=u.useState(()=>{return wE(Ea,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Ea,JSON.stringify(I0))}catch{}},[I0]);let[r0,d0]=u.useState(null),[$8,v9]=u.useState(()=>dG(Pa,!0)),[r8,k0]=u.useState(()=>dG(Aa,!1)),[z8,m7]=u.useState(()=>wE(_a,{})),[nX,t6]=u.useState(!1),[Q9,G7]=u.useState(!1),[r7,B9]=u.useState(!1),[p9,F7]=u.useState(!1),[a8,H6]=u.useState(!1),{report:j6}=zM(G9()),[Y9,q7]=u.useState(!1),[Z5,rX]=u.useState(!1),[e6,H7]=u.useState(null),[o,B0]=u.useState(!1),[H0,A0]=u.useState(!1),[p0,M8]=u.useState(!1),[T8,b8]=u.useState(!1),[p8,y9]=u.useState(()=>wE(Ta,qZ)),[c9,u7]=u.useState(()=>{try{let x=localStorage.getItem(Ca);if(x==="separate"||x==="in-inspector")return x}catch{}return"separate"}),[NX,i5]=u.useState(!1),[l7,iQ]=u.useState([]),[K5,z5]=u.useState(0),[oQ,x9]=u.useState(!1),[xY,Z7]=u.useState(!1),[aX,V5]=u.useState(!1),[zZ,w7]=u.useState(1),[hY,VZ]=u.useState(216),[i9,pG]=u.useState(null),[sX,N7]=u.useState([]),[o5,P9]=u.useState([]),[N9,U5]=u.useState(0),_6=u.useMemo(()=>{if(!l7.length)return null;return(l7.find((y)=>y.durationInFrames===N9)??l7[0]).id},[l7,N9]),B5=u.useRef(null);u.useEffect(()=>{B5.current=_6},[_6]);let gY=u.useRef(0);u.useEffect(()=>{gY.current=K5},[K5]);let[y6,UZ]=u.useState(null),BZ=u.useRef(null);u.useEffect(()=>{BZ.current=y6},[y6]);let[LX,n5]=u.useState(!1),[FZ,cG]=u.useState(!1),[NZ,iG]=u.useState(!1),oG=u.useRef(LX);u.useEffect(()=>{if(oG.current=LX,LX){iG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[LX]);let nG=u.useCallback(()=>{if(!oG.current||document.hidden){iG(!0);try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification("Claude finished",{body:"Your assistant turn is ready in Maude."})}catch{}}},[]),[r5,F5]=u.useState("inspect"),[LZ,tX]=u.useState(null),XX=u.useRef({undo:[],redo:[]}),[SJ,DZ]=u.useState(0),[E6,mY]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),rG=u.useRef(E6);u.useEffect(()=>{rG.current=E6;try{localStorage.setItem("maude-auto-open-inspector",E6?"1":"0")}catch{}},[E6]);let aG=u.useRef(!1);u.useEffect(()=>{aG.current=p0||z0||G0||LX},[p0,z0,G0,LX]);let uY=u.useRef({open:{},side:qZ});uY.current={open:{tree:$8,layers:T8,inspector:p0,comments:z0,changes:G0,assistant:LX},side:p8};let f6=u.useCallback((x,y)=>{if(x==="tree")v9(y);else if(x==="layers")b8(y);else if(x==="inspector")M8(y);else if(x==="comments")F0(y);else if(x==="changes")e(y);else if(x==="assistant")n5(y)},[]),a5=u.useCallback((x)=>uY.current.side?.[x]||qZ[x],[]),v6=u.useCallback((x)=>{let y=a5(x);f6(x,!0);for(let X0 of kE)if(X0.id!==x&&a5(X0.id)===y)f6(X0.id,!1)},[f6,a5]),$J=u.useCallback((x)=>{if(uY.current.open?.[x])f6(x,!1);else v6(x)},[v6,f6]),a7=v6,L9=$J,o9=u.useCallback((x)=>{if(!rG.current)return;if(!x||!x.id)return;if(aG.current)return;a7("inspector"),F5("css")},[a7]),N5=u.useCallback(()=>i5((x)=>!x),[]),P6=Gf(CE),L5=ny(),[lY,OZ]=u.useState(!1),[D5,sG]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let x=!0;return gj().then((y)=>{if(!x)return;if(OZ(!!y),!y&&!dG(wa,!1))sG(!0)}).catch(()=>{}),()=>{x=!1}},[]);let nQ=u.useCallback(()=>{sG(!1);try{localStorage.setItem(wa,"1")}catch{}},[]),[MZ,eX]=u.useState(null);u.useEffect(()=>{if(!G9())return;let x;return dj((y)=>eX(y&&typeof y==="object"?y:{})).then((y)=>{x=y}).catch(()=>{}),()=>{try{x?.()}catch{}}},[]);let[O5,tG]=u.useState(null),[DX,wZ]=u.useState(()=>!dG(Ma,!1)),OX=u.useCallback((x)=>{tG(Array.isArray(x)&&x.length?x:null)},[]),AZ={setup:(x)=>{if(!x)return;if((x.canvas||x.requireSelection)&&W.length===0)v6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(x.inspector||x.tab||x.requireSelection)a7("inspector");if(x.tab)F5(x.tab);if(x.changes)a7("changes")}},dY=u.useCallback(()=>{wZ(!1);try{localStorage.setItem(Ma,"1")}catch{}},[]),[M5,rQ]=u.useState(()=>dG(Ia,!0)),[eG,_Z]=u.useState(!1),[XJ,Xq]=u.useState(()=>dG(Ra,!1)),[JJ,Jq]=u.useState(()=>dG(ka,!1)),[x6,pY]=u.useState(!1),[EZ,aQ]=u.useState(0),[cY,PZ]=u.useState(null),[iY,sQ]=u.useState(!1),s5=u.useRef(null),tQ=u.useRef(null),j8=u.useRef(new Map),E8=u.useCallback((x)=>{let y=q?j8.current.get(q):null;if(!y||!y.contentWindow)return;try{y.contentWindow.postMessage(x,"*")}catch{}},[q]),t5=u.useCallback((x,y)=>E8({dgn:"photo-preview",asset:x,edit:y}),[E8]),MX=u.useCallback((x,y,X0)=>{XX.current.undo.push({asset:x,before:y,after:X0}),XX.current.redo.length=0},[]),oY=u.useCallback((x)=>{let y=x?XX.current.redo:XX.current.undo;if(!y.length)return!1;let X0=y.pop();(x?XX.current.undo:XX.current.redo).push(X0);let K0=(x?X0.after:X0.before)||{};return t5(X0.asset,K0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(K0)}).catch(()=>{}),DZ((W0)=>W0+1),!0},[t5]),nY=u.useCallback(async(x)=>{E8({dgn:"photo-busy",asset:x,busy:!0});try{let y=await fetch(`/${x.replace(/^\/+/,"")}`);if(!y.ok)return null;let X0=await y.blob(),{removeBackground:K0}=await Promise.resolve().then(() => (Oa(),Da)),W0=await K0(X0),h0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":W0.type||"image/png"},body:W0}),m=await h0.json().catch(()=>({}));if(h0.ok&&m.path)return{maskAsset:m.path};return null}catch(y){return console.error("[photo] background removal failed",y),null}finally{E8({dgn:"photo-busy",asset:x,busy:!1})}},[E8]);u.useEffect(()=>{let x=(K0)=>Array.from(K0.dataTransfer?.types??[]).includes("Files"),y=(K0)=>{if(x(K0))K0.preventDefault()},X0=(K0)=>{if(x(K0))K0.preventDefault()};return document.addEventListener("dragover",y),document.addEventListener("drop",X0),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",X0)}},[]);let e5=u.useRef({});e5.current={open:NX,comps:l7,frame:K5,total:N9,playing:oQ,compId:_6,muted:aX,loop:xY,sequences:sX,post:E8,canvas:q};let XQ=u.useRef({undo:[],redo:[]}),bJ=u.useCallback((x,y,X0)=>{if(typeof y!=="number")return;if(XQ.current.undo.push({canvas:x,seq:y,label:X0}),XQ.current.redo=[],XQ.current.undo.length>50)XQ.current.undo.shift()},[]),RZ=u.useCallback((x)=>{let y=XQ.current,X0=x==="undo"?y.undo:y.redo,K0=x==="undo"?y.redo:y.undo,W0=e5.current.canvas,h0=-1;for(let M0=X0.length-1;M0>=0;M0--)if(X0[M0].canvas===W0){h0=M0;break}if(h0<0){g7(x==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let m=X0[h0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:m.canvas,seq:m.seq,dir:x})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(X0.splice(h0,1),M0?.ok)K0.push(m),g7(`${x==="undo"?"Undid":"Redid"}: ${m.label}`,!0);else g7(`${x==="undo"?"Undo":"Redo"} skipped: ${M0?.error||"failed"}`)}).catch(()=>g7(`${x==="undo"?"Undo":"Redo"} failed: network error`))},[]);u.useEffect(()=>{let x=(y)=>{let X0=e5.current;if(!X0.open||!X0.comps?.length)return;let K0=y.target,W0=K0?.tagName;if(W0==="INPUT"||W0==="TEXTAREA"||W0==="SELECT"||K0?.isContentEditable)return;let h0=X0.comps[0]?.fps||30,m=Math.max(1,X0.total),M0=(x0)=>{let F8=Math.max(0,Math.min(m-1,Math.round(x0)));z5(F8),x9(!1),X0.post({dgn:"timeline-seek",frame:F8,id:X0.compId})},T0=()=>{let x0=new Set([0,m-1]);for(let F8 of X0.sequences||[]){x0.add(F8.from);for(let D8 of F8.keyframes||[])x0.add(D8.from),x0.add(D8.to)}return[...x0].filter((F8)=>F8>=0&&F8<m).sort((F8,D8)=>F8-D8)};if((y.metaKey||y.ctrlKey)&&(y.key==="z"||y.key==="Z")){y.preventDefault(),RZ(y.shiftKey?"redo":"undo");return}if(y.key===" "||y.code==="Space")if(y.preventDefault(),X0.playing)x9(!1),X0.post({dgn:"timeline-pause",id:X0.compId});else x9(!0),X0.post({dgn:"timeline-mute",muted:X0.muted,id:X0.compId}),X0.post({dgn:"timeline-loop",loop:X0.loop,id:X0.compId}),X0.post({dgn:"timeline-play",id:X0.compId});else if(y.key==="ArrowRight")y.preventDefault(),M0(X0.frame+(y.shiftKey?h0:1));else if(y.key==="ArrowLeft")y.preventDefault(),M0(X0.frame-(y.shiftKey?h0:1));else if(y.key==="Home")y.preventDefault(),M0(0);else if(y.key==="End")y.preventDefault(),M0(m-1);else if(y.key==="."){y.preventDefault();let x0=T0().find((F8)=>F8>X0.frame);if(x0!=null)M0(x0)}else if(y.key===","){y.preventDefault();let x0=T0().reverse().find((F8)=>F8<X0.frame);if(x0!=null)M0(x0)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),u.useEffect(()=>{iQ([]),z5(0),x9(!1);let x=setTimeout(()=>E8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(x)},[q,E8]);let[wX,eQ]=u.useState(""),[Qq,rY]=u.useState([]);u.useEffect(()=>{if(!NX||l7.length===0||!q||q===h8){eQ(""),rY([]);return}let x=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(q)}`).then((y)=>y.ok?y.json():null).then((y)=>{if(x&&y?.ok&&typeof y.source==="string")eQ(y.source)}).catch(()=>{}),()=>{x=!1}},[NX,l7,q]),u.useEffect(()=>{if(!NX||!q||q===h8||!wX){rY([]);return}let x=!0,y=y6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${y?`&artboardId=${encodeURIComponent(y)}`:""}`;return fetch(X0).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(!x)return;let W0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((h0)=>h0.kind==="sequence"):[];rY(W0)}).catch(()=>{}),()=>{x=!1}},[NX,q,wX,y6]),u.useEffect(()=>{if(!wX){N7([]),P9([]),U5(0);return}let x=l7[0]?.durationInFrames||0,y=i9??Z?.artboardId??null,X0=Iy(wX,x,y);UZ(X0.artboardId??y??null);let K0=X0.sequences.map((W0,h0)=>{let m=Qq[h0];if(!m)return W0;return{...W0,mediaTag:m.mediaTag??W0.mediaTag,mediaSrc:m.mediaSrc??W0.mediaSrc,replaceable:!!(m.mediaCdId||m.mediaArrayRef),layers:Array.isArray(m.layers)?m.layers:[],hidden:!!m.hidden}});N7(K0),P9(X0.audio||[]),U5(X0.total)},[wX,Qq,Z,l7,i9]);let Yq=u.useCallback(()=>{rQ((x)=>{let y=!x,X0=q?j8.current.get(q):null;if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"view-annotations",visible:y},"*")}catch{}return y})},[q]),JX=u.useCallback((x)=>{for(let y of j8.current.values())try{y.contentWindow.postMessage({dgn:"view-chrome",...x},"*")}catch{}},[]),Wq=u.useCallback(()=>{Xq((x)=>{let y=!x;return JX({minimap:y}),y})},[JX]),Gq=u.useCallback(()=>{Jq((x)=>{let y=!x;return JX({zoom:y}),y})},[JX]),kZ=u.useCallback(()=>{pY((x)=>{let y=!x;return JX({present:y}),y})},[JX]),aY=u.useCallback(()=>{pY(!1),JX({present:!1})},[JX]);u.useEffect(()=>{let x=!1;return fetch("/_api/git-user").then((y)=>y.json()).then((y)=>{if(x)return;let X0=y&&typeof y.name==="string"?y.name.trim():"";if(X0)PZ(X0)}).catch(()=>{}),()=>{x=!0}},[]),u.useEffect(()=>{if(!q||q===h8){aQ(0);return}let x=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(q)).then((y)=>y.json()).then((y)=>{if(x)return;let X0=Array.isArray(y?.artboards)?y.artboards.length:0;aQ(X0)}).catch(()=>{if(!x)aQ(0)}),()=>{x=!0}},[q]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",w0),localStorage.setItem(ra,w0)}catch{}for(let x of j8.current.values())try{x.contentWindow.postMessage({dgn:"theme",theme:w0},"*")}catch{}},[w0]),u.useEffect(()=>{try{localStorage.setItem(Pa,$8?"1":"0")}catch{}},[$8]),u.useEffect(()=>{try{localStorage.setItem(Aa,r8?"1":"0")}catch{}},[r8]),u.useEffect(()=>{try{localStorage.setItem(_a,JSON.stringify(z8))}catch{}},[z8]),u.useEffect(()=>{try{localStorage.setItem(Ra,XJ?"1":"0")}catch{}},[XJ]),u.useEffect(()=>{try{localStorage.setItem(ka,JJ?"1":"0")}catch{}},[JJ]),u.useEffect(()=>{try{localStorage.setItem(Ia,M5?"1":"0")}catch{}},[M5]),u.useEffect(()=>{let x=!1;return fetch("/_api/ui-prefs").then((y)=>y.ok?y.json():Promise.reject(Error(`HTTP ${y.status}`))).then((y)=>{if(x||!y||typeof y!=="object")return;if(y.theme==="light"||y.theme==="dark")R0(y.theme);if(typeof y.minimap==="boolean")Xq(y.minimap);if(typeof y.zoom==="boolean")Jq(y.zoom);if(typeof y.annotations==="boolean")rQ(y.annotations);if(typeof y.autoOpenInspector==="boolean")mY(y.autoOpenInspector);if(y.panelSides&&typeof y.panelSides==="object")y9({...qZ,...y.panelSides});if(y.layersMode==="separate"||y.layersMode==="in-inspector")u7(y.layersMode)}).catch(()=>{}).finally(()=>{if(!x)_Z(!0)}),()=>{x=!0}},[]),u.useEffect(()=>{if(!eG)return;KK0({theme:w0,minimap:XJ,zoom:JJ,annotations:M5,autoOpenInspector:E6,panelSides:p8,layersMode:c9})},[eG,w0,XJ,JJ,M5,E6,p8,c9]),u.useEffect(()=>{try{localStorage.setItem(Ta,JSON.stringify(p8))}catch{}},[p8]),u.useEffect(()=>{try{localStorage.setItem(Ca,c9)}catch{}},[c9]);let IZ=u.useCallback((x,y)=>{m7((X0)=>{let K0=X0[x],W0=K0===void 0?y:K0;return{...X0,[x]:!W0}})},[]),AX=u.useCallback(()=>{R0((x)=>x==="dark"?"light":"dark")},[]),S9=u.useCallback(async()=>{try{let y=await(await fetch("/_index-data")).json();Y(y.project||"Design");let X0=y.groups.map((K0)=>({...K0,tree:FK0(K0.paths,K0.stripPrefix)}));J(X0),z9((K0)=>({...K0,canvasDesignSystems:y.canvasDesignSystems??{},canvasKinds:y.canvasKinds??{}}))}catch(x){console.error("failed to load tree",x)}},[]);u.useEffect(()=>{S9()},[S9]);let QJ=u.useCallback(async(x)=>{try{let y=x?`/_system-data?ds=${encodeURIComponent(x)}`:"/_system-data",X0=await fetch(y);if(!X0.ok){console.error("failed to load system-data",X0.status);return}let K0=await X0.json();if(!x&&K0?.defaultDesignSystem&&!K0.ds){V0(K0);let W0=await fetch(`/_system-data?ds=${encodeURIComponent(K0.defaultDesignSystem)}`);if(W0.ok)V0(await W0.json());return}V0(K0)}catch(y){console.error("failed to load system-data",y)}},[]),qq=u.useCallback(async()=>{try{let y=await(await fetch("/_comments-all")).json();o8(y||{})}catch(x){console.error("failed to load comments",x)}},[]);u.useEffect(()=>{qq()},[qq]),u.useEffect(()=>{function x(){let y=location.protocol==="https:"?"wss:":"ws:",X0=new WebSocket(y+"//"+location.host+"/_ws");tQ.current=X0,X0.addEventListener("open",()=>j(!0)),X0.addEventListener("close",()=>{j(!1),setTimeout(x,1000)}),X0.addEventListener("error",()=>{}),X0.addEventListener("message",(K0)=>{try{let W0=JSON.parse(K0.data);if(W0.type==="snapshot"&&W0.state)z((h0)=>ia(W0.state.selected,h0));else if(W0.type==="selected"){let h0=W0.selected,m=Array.isArray(h0)?h0[0]:h0,M0=U.current,T0=Array.isArray(M0)?M0[0]:M0;if(z((x0)=>ia(h0,x0)),m?.id&&m.file&&(!T0||T0.id!==m.id||T0.file!==m.file))D(m)}else if(W0.type==="comments"&&typeof W0.file==="string")o8((h0)=>({...h0,[W0.file]:W0.comments||[]}));else if(W0.type==="ai-activity"&&typeof W0.file==="string"){if(sQ(!0),s5.current)clearTimeout(s5.current);s5.current=setTimeout(()=>sQ(!1),8000);for(let h0 of j8.current.values())try{h0.contentWindow.postMessage({dgn:"ai-activity",file:W0.file,entry:W0.entry},"*")}catch{}}else if(W0.type==="export:job"&&W0.payload)L5.upsert(W0.payload);else if(W0.type==="sync:status"&&W0.payload)i(W0.payload);else if(W0.type==="canvas-list-update")S9();else if(W0.type==="config-updated")c0();else if(W0.type==="acp-focus"){if(G9())a7("assistant")}else if(W0.type==="git-status"&&W0.payload)n(W0.payload);else if(W0.type==="git-lifecycle"&&W0.payload){h(W0.payload);for(let h0 of j8.current.values())try{h0.contentWindow.postMessage({dgn:"git-lifecycle",payload:W0.payload},"*")}catch{}}}catch{}})}return x(),()=>tQ.current&&tQ.current.close()},[S9,c0]);function I7(x){let y=tQ.current;try{if(y&&y.readyState===1)y.send(JSON.stringify(x))}catch{}}let s7=u.useCallback(async()=>{try{let x=await fetch("/_api/git/status");if(x.ok)n(await x.json())}catch{}},[]),Z6=u.useCallback(async()=>{try{let x=await fetch("/_api/git/status?remote=1");if(!x.ok)return;let y=await x.json();if(y&&y.repo!==!1)g({remoteAhead:!!y.remoteAhead,behind:y.behind||0})}catch{}},[]),R6=u.useCallback(async(x,y)=>{try{let X0=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y||{})}),K0=await X0.json().catch(()=>({}));return{ok:X0.ok,...K0}}catch(X0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),sY=u.useCallback(async(x,y)=>{let X0=await R6("/_api/git/commit",{message:x,files:y});if(X0.ok)await s7();return X0},[R6,s7]),X4=u.useCallback(async(x)=>{let y=await R6("/_api/git/discard",{files:x});if(y.ok)await s7();return y},[R6,s7]),tY=u.useCallback(async()=>{let x=await R6("/_api/git/push",{});if(x.ok)await s7(),Z6();return x},[R6,s7,Z6]),J4=u.useCallback(async()=>{let x=await R6("/_api/git/pull",{});if(x.ok)await s7(),Z6();if(x.conflict&&Array.isArray(x.files)&&x.files.length)Z0({file:x.files[0],conflict:!0});return x},[R6,s7,Z6]),eY=u.useCallback(async(x)=>{let y=await R6("/_api/git/resolve",{choice:x});if(y.ok)await s7(),Z6();return y},[R6,s7,Z6]),Hq=u.useCallback(async(x)=>{try{let y="/_api/git/log?limit=40"+(x?`&path=${encodeURIComponent(x)}`:""),X0=await fetch(y);if(!X0.ok)return[];return(await X0.json()).entries||[]}catch{return[]}},[]),XW=u.useMemo(()=>{let x={modified:"M",added:"A",deleted:"D",untracked:"U"},y=new Map;for(let X0 of v?.files||[])y.set(X0.path,x[X0.status]);return y},[v]),Zq=v?.files?.length||0;u.useEffect(()=>{if(v?.repo===!1)return;Z6();let x=setInterval(Z6,G0?60000:120000);return()=>clearInterval(x)},[v?.repo,G0,Z6]);let h6=u.useCallback((x)=>{if(G((y)=>{for(let X0 of y)if(X0.path!==x)j8.current.delete(X0.path);return[{path:x}]}),H(x),f0(null),x!==h8)U8(x)},[]),k6=u.useCallback((x)=>{let y=typeof x==="string"?x:void 0;if(y)QJ(y);else if(!c)QJ();h6(h8)},[c,QJ,h6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((x)=>x.path).filter((x)=>x!==h8)})},[W]),u.useEffect(()=>{if(q&&q!==h8)I7({type:"active",file:q});else if(q===h8)I7({type:"active",file:""});else I7({type:"active",file:""})},[q]);let J0=u.useCallback((x)=>{G((y)=>{let X0=y.findIndex((W0)=>W0.path===x);if(X0<0)return y;let K0=y.filter((W0)=>W0.path!==x);if(x===q)if(K0.length===0)H(null);else H(K0[Math.max(0,X0-1)].path);return K0}),j8.current.delete(x),U8((y)=>y===x?null:y)},[q]),jJ=u.useCallback(()=>{if(!q||q===h8){if(q===h8)QJ();return}let x=j8.current.get(q);if(x)x.src=x.src},[q,QJ]),Q4=u.useCallback(()=>S9(),[S9]),[JW,YJ]=u.useState(!1),n9=u.useRef(!1),_X=u.useCallback(async()=>{if(n9.current)return;n9.current=!0,YJ(!0);try{await Promise.all([S9(),new Promise((x)=>setTimeout(x,550))])}finally{n9.current=!1,YJ(!1)}},[S9]);u.useEffect(()=>{let x=null,y=()=>{if(x)clearTimeout(x);x=setTimeout(()=>{x=null,Q4()},150)};return window.addEventListener("focus",y),()=>{if(window.removeEventListener("focus",y),x)clearTimeout(x)}},[Q4]);let JQ=u.useCallback(async(x)=>{try{let y=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:x,kind:"brief-board"})}),X0=await y.json().catch(()=>({}));if(!y.ok||!X0.ok)return{ok:!1,error:X0.error||`create failed (${y.status})`};return await S9(),h6(X0.file),{ok:!0,file:X0.file}}catch(y){return{ok:!1,error:y instanceof Error?y.message:"network error"}}},[S9,h6]),QW=u.useCallback(async()=>{if(!q||q===h8)return;try{let x=await fetch(`/_api/annotations?file=${encodeURIComponent(q)}`),y=x.ok?await x.text():"",X0=[];if(y){let M0=new DOMParser().parseFromString(y,"image/svg+xml");for(let T0 of M0.querySelectorAll('[data-tool="mediaref"]')){let x0=T0.getAttribute("data-src");if(!x0)continue;X0.push({src:x0,mediaKind:T0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(X0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let W0=`${KZ(_B(q)).replace(/\.tsx$/i,"")} Video`,h0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W0,kind:"video-comp",clips:X0})}),m=await h0.json().catch(()=>({}));if(!h0.ok||!m.ok){window.alert(`Assemble failed: ${m.error||`error ${h0.status}`}`);return}await S9(),h6(m.file)}catch(x){window.alert(`Assemble failed: ${x instanceof Error?x.message:"network error"}`)}},[q,S9,h6]),QQ=u.useCallback(({accept:x,resolveTarget:y})=>{let X0=q,K0=y6||void 0,W0=document.createElement("input");W0.type="file",W0.accept=x,W0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(W0);let h0=()=>{if(W0.isConnected)W0.remove()};window.addEventListener("focus",()=>setTimeout(h0,300),{once:!0}),W0.addEventListener("change",()=>{let m=W0.files?.[0];if(h0(),!m)return;let M0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(M0).then((T0)=>T0.json().catch(()=>({}))).then((T0)=>{let x0=y(T0);if(!x0)return g7("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":m.type||"application/octet-stream"},body:m}).then((F8)=>F8.json().catch(()=>({}))).then((F8)=>{if(!F8?.path)return g7(`Upload failed: ${F8?.error||"unknown error"}`),null;if(x0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,arrayName:x0.arrayRef.arrayName,index:x0.arrayRef.index,field:x0.arrayRef.field,value:F8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,id:x0.cdId,attr:"src",value:F8.path})})})}).then((T0)=>T0?T0.json():null).then((T0)=>{if(T0&&!T0.ok)g7(`Replace refused: ${T0.error||"failed"}`);else if(T0&&T0.ok){if(g7("Media replaced.",!0),T0.seq!=null)bJ(X0,T0.seq,"replace media")}}).catch(()=>g7("Replace failed: network error"))}),W0.click()},[q,y6,bJ]),YW=u.useCallback(async(x,y)=>{if(!window.confirm(`Move “${y}” to trash?
5646
+ `.trim();function bQ0(){if(typeof document>"u")return;if(document.getElementById("dc-context-menu-css"))return;let X=document.createElement("style");X.id="dc-context-menu-css",X.textContent=$Q0,document.head.appendChild(X)}function Ry({target:X,sections:J,onClose:Q}){bQ0();let Y=C6.useRef(null),[W,G]=C6.useState({x:X.clientX,y:X.clientY});C6.useEffect(()=>{let H=Y.current;if(!H)return;let Z=H.getBoundingClientRect(),z=window.innerWidth,U=window.innerHeight,B=X.clientX,F=X.clientY;if(B+Z.width>z-8)B=Math.max(8,z-Z.width-8);if(F+Z.height>U-8)F=Math.max(8,U-Z.height-8);if(B!==W.x||F!==W.y)G({x:B,y:F});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let D=(A)=>{if(!H.contains(A.target))Q()},w=(A)=>{if(A.key==="Escape"){A.preventDefault(),Q();return}if(A.key==="ArrowDown"||A.key==="ArrowUp"){A.preventDefault();let O=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(O.length===0)return;let P=O.indexOf(document.activeElement),I=A.key==="ArrowDown"?(P+1)%O.length:(P-1+O.length)%O.length;O[I]?.focus()}},E=()=>Q();return document.addEventListener("pointerdown",D,!0),document.addEventListener("keydown",w,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",Q)}},[X.clientX,X.clientY,Q,W.x,W.y]);let q=J.map((H)=>H.filter((Z)=>{return!(typeof Z.hidden==="function"?Z.hidden(X):Z.hidden)})).filter((H)=>H.length>0);return K("div",{ref:Y,className:"dc-context-menu",role:"menu",style:{left:W.x,top:W.y},children:q.map((H,Z)=>{let z=H.map((U)=>U.id).join("|")||`s${Z}`;return R("div",{role:"group",children:[Z>0?K("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((U)=>K(jQ0,{item:U,target:X,onClose:Q},U.id))]},z)})})}function jQ0({item:X,target:J,onClose:Q}){let[Y,W]=C6.useState(!1),[G,q]=C6.useState(!1),H=C6.useRef(null),Z=C6.useRef(null),z=C6.useRef(null),U=typeof X.submenu==="function"?X.submenu(J):X.submenu,B=typeof X.disabled==="function"?X.disabled(J):X.disabled;if(!U||U.length===0)return R("button",{type:"button",role:"menuitem",disabled:B,title:B?X.disabledHint:void 0,className:`dc-menu-item${X.destructive?" is-destructive":""}`,onClick:()=>{if(B)return;X.onSelect(J),Q()},children:[K("span",{children:X.label}),X.shortcut?K("span",{className:"dc-menu-shortcut",children:X.shortcut}):null]});let F=()=>{if(z.current)clearTimeout(z.current),z.current=null},L=(w=!1)=>{F();let E=H.current?.getBoundingClientRect();if(E&&typeof window<"u")q(E.right+200>window.innerWidth);if(W(!0),w)setTimeout(()=>{Z.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},D=()=>{F(),z.current=setTimeout(()=>W(!1),140)};return R("div",{className:"dc-menu-sub",onMouseEnter:()=>L(),onMouseLeave:D,children:[R("button",{ref:H,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":Y,disabled:B,className:"dc-menu-item",onClick:()=>Y?W(!1):L(),onKeyDown:(w)=>{if(w.key==="ArrowRight"||w.key==="Enter"||w.key===" ")w.preventDefault(),L(!0);else if(w.key==="ArrowLeft"||w.key==="Escape"){if(Y)w.stopPropagation(),W(!1)}},children:[K("span",{children:X.label}),K("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?K("div",{ref:Z,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:F,onMouseLeave:D,children:U.map((w)=>R("button",{type:"button",role:"menuitem",disabled:w.disabled,title:w.disabled?w.disabledHint:void 0,className:`dc-menu-item${w.destructive?" is-destructive":""}`,onClick:()=>{if(w.disabled)return;w.onSelect(J),Q()},onKeyDown:(E)=>{if(E.key==="ArrowLeft"||E.key==="Escape")E.preventDefault(),E.stopPropagation(),W(!1),H.current?.focus()},children:[K("span",{children:w.label}),w.shortcut?K("span",{className:"dc-menu-shortcut",children:w.shortcut}):null]},w.id))}):null]})}function yH(X){let J=X.mediaTag;if(J==="Video"||J==="OffthreadVideo")return"video";if(J==="Img")return"image";if(J==="Audio")return"audio";return"jsx"}function yQ0(X){let J=yH(X);if(J==="video")return"▶";if(J==="image")return"◫";if(J==="audio")return"♪";return"ƒ"}function ky(X){let J=yH(X),Q=X.mediaSrc?` · ${String(X.mediaSrc).split("/").pop()}`:"";if(J==="video")return`Video clip${Q}`;if(J==="image")return`Image${Q}`;if(J==="audio")return`Audio${Q}`;return"Animated JSX (code-driven)"}function W2({name:X,size:J=15}){return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:{play:K("path",{d:"M4 3l9 5-9 5z",fill:"currentColor",stroke:"none"}),pause:R(Q0,{children:[K("rect",{x:"4",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"}),K("rect",{x:"9",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"})]}),loop:R(Q0,{children:[K("polyline",{points:"4 4 4 7 7 7"}),K("path",{d:"M4 7a4.5 4.5 0 1 1 1.3 4.6"})]}),start:R(Q0,{children:[K("line",{x1:"4.5",y1:"3.5",x2:"4.5",y2:"12.5"}),K("path",{d:"M12 3.5l-6 4.5 6 4.5z",fill:"currentColor",stroke:"none"})]}),sound:R(Q0,{children:[K("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),K("path",{d:"M10.5 5.5a3.2 3.2 0 0 1 0 5"}),K("path",{d:"M12.3 3.7a5.6 5.6 0 0 1 0 8.6"})]}),muted:R(Q0,{children:[K("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),K("line",{x1:"10.7",y1:"6",x2:"13.7",y2:"10"}),K("line",{x1:"13.7",y1:"6",x2:"10.7",y2:"10"})]})}[X]})}var Ez=(X,J,Q)=>Math.max(J,Math.min(Q,X));function fQ0(X,J){let Q=X/(J||30),Y=Math.floor(Q),W=Math.round((Q-Y)*100);return`${Y}.${String(W).padStart(2,"0")}s`}function FM({comps:X=[],sequences:J=[],audio:Q=[],total:Y=0,frame:W=0,playing:G=!1,loop:q=!1,onSeek:H,onPlay:Z,onPause:z,onToggleLoop:U,muted:B=!1,onToggleMute:F,volume:L=1,onVolume:D,height:w,resizing:E,onResize:A,onRetime:O,onRemove:P,onReplace:I,onReplaceAudio:T,onReplaceLayer:C,onReorder:S,onToggleHide:j,onDropMedia:b,onClose:h}){let[d,i]=k7.useState(()=>new Set),[v,n]=k7.useState(!1),Y0=X[0]??null,g=Math.max(1,Y||Y0?.durationInFrames||1),G0=Y0?.fps??30,e=Ez(Math.round(W),0,g-1),l=k7.useRef(null),Z0=k7.useRef(!1),r=k7.useRef(null);k7.useEffect(()=>{r.current?.focus()},[]);let[a,c]=k7.useState(null),[V0,o0]=k7.useState(null),[U8,V8]=k7.useState(null),L0=k7.useRef(!1),t0=k7.useCallback((z0)=>{z0.preventDefault(),z0.stopPropagation(),z0.currentTarget.setPointerCapture?.(z0.pointerId);let F0=z0.clientY,U0=w||216,y0=(R0)=>{A?.(Ez(U0+(F0-R0.clientY),140,640))},w0=()=>{window.removeEventListener("pointermove",y0),window.removeEventListener("pointerup",w0)};window.addEventListener("pointermove",y0),window.addEventListener("pointerup",w0)},[w,A]),n0=96,Q8=k7.useCallback((z0)=>{let F0=l.current;if(!F0)return;let U0=F0.getBoundingClientRect(),y0=Math.max(1,U0.width-n0),w0=Ez((z0-U0.left-n0)/y0,0,1);H?.(Math.round(w0*(g-1)))},[H,g]);k7.useEffect(()=>{if(!Z0.current)return;let z0=(U0)=>Q8(U0.clientX),F0=()=>{Z0.current=!1};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}});let v8=(z0)=>{if(a)return;z0.preventDefault(),Z0.current=!0,Q8(z0.clientX),z0.currentTarget.setPointerCapture?.(z0.pointerId)};k7.useEffect(()=>{if(!a)return;let z0=(U0)=>{let y0=(U0.clientX-a.startX)/Math.max(1,a.rowW)*(g-1),w0=a.startFrom+Math.round(a.startDur+y0),R0=U0.altKey?0:BM(a.rowW,g);w0=UM(w0,a.targets,R0);let I0=Math.max(1,w0-a.startFrom);c((O8)=>O8?{...O8,curDur:I0}:O8)},F0=()=>{c((U0)=>{if(U0&&U0.curDur!==U0.startDur)O?.(U0.index,{durationInFrames:U0.curDur});return null})};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}},[a,g,O]),k7.useEffect(()=>{if(!V0)return;let z0=(U0)=>{let y0=(U0.clientX-V0.startX)/Math.max(1,V0.rowW)*(g-1),w0=Math.max(0,Math.round(V0.startFrom+y0)),R0=U0.altKey?0:BM(V0.rowW,g);if(w0=Math.max(0,UM(w0,V0.targets,R0)),Math.abs(w0-V0.startFrom)>=1)L0.current=!0;o0((I0)=>I0?{...I0,curFrom:w0}:I0)},F0=()=>{o0((U0)=>{if(U0&&U0.curFrom!==U0.startFrom)O?.(U0.index,{from:U0.curFrom});return null})};return window.addEventListener("pointermove",z0),window.addEventListener("pointerup",F0,{once:!0}),()=>{window.removeEventListener("pointermove",z0),window.removeEventListener("pointerup",F0)}},[V0,g,O]);let i8=(z0)=>Py({fps:G0,totalFrames:g,clips:J,movingIndex:z0,playhead:e}),g8=(z0,F0,U0)=>{if(!O)return;if(J[F0]?.series)return;z0.stopPropagation();let y0=z0.currentTarget.closest(".tl-row-track"),w0=y0?y0.getBoundingClientRect().width:300;L0.current=!1,o0({index:F0,startX:z0.clientX,startFrom:U0,rowW:w0,curFrom:U0,targets:i8(F0)})},z9=(z0,F0,U0)=>{z0.stopPropagation(),z0.preventDefault();let y0=z0.currentTarget.closest(".tl-row-track"),w0=y0?y0.getBoundingClientRect().width:300,R0=J[F0]?.from??0;c({index:F0,startX:z0.clientX,startDur:U0,startFrom:R0,rowW:w0,curDur:U0,targets:i8(F0)})},c0=Math.max(1,Math.floor((g-1)/G0)),d8=Array.from({length:c0+1},(z0,F0)=>F0*G0/(g-1)),o8=(z0)=>`${Ez(z0,0,g-1)/(g-1)*100}%`,j9=(z0)=>Array.from(z0?.types??[]).includes("Files"),f0=(z0)=>{if(!b||!j9(z0.dataTransfer))return;z0.preventDefault(),z0.stopPropagation(),n(!1);let F0=z0.dataTransfer.files?.[0];if(F0)b(F0)};return R("aside",{ref:r,tabIndex:-1,className:`tl-panel${E?" is-resizing":""}${v?" is-drop":""}`,style:{...w?{height:w}:{},outline:"none"},onDragOver:(z0)=>{if(!b||!j9(z0.dataTransfer))return;if(z0.preventDefault(),z0.dataTransfer.dropEffect="copy",!v)n(!0)},onDragLeave:(z0)=>{if(z0.relatedTarget==null)n(!1)},onDrop:f0,"aria-label":"Timeline","data-testid":"timeline-panel",children:[K("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:t0}),R("div",{className:"tl-head",children:[Y0?R(Q0,{children:[K("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":G?"Pause":"Play","aria-pressed":G,"data-testid":"timeline-playpause",onClick:()=>G?z?.():Z?.(),children:K(W2,{name:G?"pause":"play"})}),K("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>H?.(0),children:K(W2,{name:"start"})}),K("button",{type:"button",className:`tl-btn${q?" is-on":""}`,"aria-label":"Loop","aria-pressed":q,"data-testid":"timeline-loop",onClick:()=>U?.(),children:K(W2,{name:"loop"})}),Q.length>0?K("button",{type:"button",className:`tl-btn${B?"":" is-on"}`,"aria-label":B?"Unmute":"Mute","aria-pressed":!B,"data-testid":"timeline-mute",title:B?"Unmute audio":"Mute audio",onClick:()=>F?.(),children:K(W2,{name:B?"muted":"sound"})}):null,Q.length>0?K("input",{type:"range",className:"tl-volume",min:"0",max:"100",value:Math.round((B?0:L)*100),"data-testid":"timeline-volume","aria-label":"Volume",title:"Volume",onChange:(z0)=>D?.(Number(z0.target.value)/100)}):null,R("span",{className:"tl-readout","data-testid":"timeline-readout",children:[K("b",{children:e}),K("span",{className:"tl-sep",children:"/"}),g-1,K("span",{className:"tl-time",children:fQ0(e,G0)})]})]}):K("span",{className:"tl-title",children:"Timeline"}),K("span",{className:"tl-spacer"}),Y0?R("span",{className:"tl-meta",children:[G0," fps · ",g,"f"]}):null,K("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:h,children:"×"})]}),!Y0?R("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No animation on this canvas. Make an artboard a ",K("b",{children:"video-comp"}),"(",K("code",{children:"<VideoComp>"}),") to scrub and export it — or drop clips on the canvas and ",K("b",{children:"File → Assemble dropped clips → video"}),"."]}):K("div",{className:"tl-scroll",children:R("div",{className:"tl-tracks",ref:l,"data-testid":"timeline-track",onPointerDown:v8,children:[K("div",{className:"tl-ruler",children:d8.map((z0,F0)=>K("span",{className:"tl-tick",style:{left:`${z0*100}%`},children:R("span",{className:"tl-tick-label",children:[F0,"s"]})},F0))}),J.length===0?R("div",{className:"tl-row",children:[K("span",{className:"tl-row-label",children:"comp"}),K("div",{className:"tl-row-track",children:K("div",{className:"tl-seq-block",style:{left:"0%",width:"100%"},children:K("span",{className:"tl-seq-name",children:"whole composition"})})})]}):J.map((z0,F0)=>{let U0=a&&a.index===F0?a.curDur:z0.duration,y0=!!(a&&a.index===F0),w0=V0&&V0.index===F0?V0.curFrom:z0.from,R0=!!(V0&&V0.index===F0),I0=Array.isArray(z0.layers)?z0.layers:[],O8=I0.length>=2,r0=O8&&!d.has(F0);return R(k7.Fragment,{children:[R("div",{className:"tl-row","data-testid":`timeline-row-${F0}`,children:[R("span",{className:"tl-row-label",title:z0.label,children:[O8?K("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${F0}`,title:r0?"Collapse layers":"Show layers","aria-label":r0?`Collapse ${z0.label} layers`:`Show ${z0.label} layers`,"aria-expanded":r0,onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),d0.preventDefault(),i(($8)=>{let v9=new Set($8);if(v9.has(F0))v9.delete(F0);else v9.add(F0);return v9})},children:r0?"▾":"▸"}):K("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),S?R("span",{className:"tl-seq-reorder",role:"group","aria-label":`${z0.series?"Play order":"Stacking order"} for ${z0.label}`,children:[K("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-raise-${F0}`,title:z0.series?"Move earlier (plays sooner)":"Bring forward (render on top)","aria-label":z0.series?`Move ${z0.label} earlier`:`Bring ${z0.label} forward`,disabled:z0.series?F0<=0:F0>=J.length-1,onClick:(d0)=>{d0.stopPropagation(),S(F0,z0.series?"backward":"forward")},children:"▲"}),K("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-lower-${F0}`,title:z0.series?"Move later (plays after)":"Send backward (render underneath)","aria-label":z0.series?`Move ${z0.label} later`:`Send ${z0.label} backward`,disabled:z0.series?F0>=J.length-1:F0<=0,onClick:(d0)=>{d0.stopPropagation(),S(F0,z0.series?"forward":"backward")},children:"▼"})]}):null,K("span",{className:"tl-kind","data-kind":yH(z0),title:ky(z0),"aria-label":ky(z0),children:yQ0(z0)}),K("span",{className:"tl-row-label-text",children:z0.label})]}),R("div",{className:"tl-row-track",children:[R("button",{type:"button",className:`tl-seq-block${y0?" is-resizing":""}${R0?" is-moving":""}${z0.hidden?" is-hidden":""}`,"data-testid":`timeline-seq-${F0}`,"data-kind":yH(z0),"data-hidden":z0.hidden?"1":void 0,title:z0.series?`${z0.label} · ${w0}–${w0+U0}f (${U0}f) · position computed by the series — trim the right edge to retime`:`${z0.label} · ${w0}–${w0+U0}f (${U0}f) · drag to move (Alt = no snap)`,"aria-label":z0.series?`${z0.label}, series beat, frames ${w0} to ${w0+U0}. Click to seek; trim its edge to retime.`:`${z0.label}, from frame ${w0} to ${w0+U0}, ${U0} frames. Click to seek; drag to move.`,style:{left:o8(w0),width:`${U0/(g-1)*100}%`,cursor:O&&!z0.series?"grab":void 0},onContextMenu:(d0)=>{d0.preventDefault(),d0.stopPropagation(),V8({index:F0,x:d0.clientX,y:d0.clientY})},onPointerDown:(d0)=>g8(d0,F0,z0.from),onClick:(d0)=>{if(d0.stopPropagation(),L0.current){L0.current=!1;return}H?.(z0.from)},children:[R("span",{className:"tl-seq-name",children:[z0.label,y0?` · ${U0}f`:"",R0?` · @${w0}f`:""]}),z0.keyframes.map((d0,$8)=>{let v9=(d0.from-z0.from)/Math.max(1,z0.duration)*100,r8=(d0.to-d0.from)/Math.max(1,z0.duration)*100;return K("span",{className:"tl-kf","data-testid":`timeline-kf-${F0}-${$8}`,style:{left:`${Ez(v9,0,100)}%`,width:`${Math.max(1.5,r8)}%`},title:`seek to keyframe ${d0.from}f (animates ${d0.from}–${d0.to}f)`,onPointerDown:(k0)=>k0.stopPropagation(),onClick:(k0)=>{k0.stopPropagation(),H?.(d0.from)}},$8)})]}),O?K("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${F0}`,title:"Drag to retime this sequence",style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 5px)`},onPointerDown:(d0)=>z9(d0,F0,z0.duration),onClick:(d0)=>d0.stopPropagation()}):null,I&&z0.replaceable&&!O8?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${F0}`,title:`Replace this ${yH(z0)}`,"aria-label":`Replace media in ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 34px)`},onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),I(F0)},children:"⇄"}):null,P?K("button",{type:"button",className:"tl-seq-remove","data-testid":`timeline-remove-${F0}`,title:"Remove this clip","aria-label":`Remove ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 17px)`},onPointerDown:(d0)=>d0.stopPropagation(),onClick:(d0)=>{d0.stopPropagation(),P(F0)},children:"×"}):null]})]}),r0?I0.map((d0,$8)=>{let v9=d0.kind==="video"?"video":d0.kind==="image"?"image":d0.kind==="audio"?"audio":"jsx",r8=d0.kind==="video"?"▶":d0.kind==="image"?"◫":d0.kind==="audio"?"♪":"ƒ",k0=!!(d0.mediaCdId||d0.mediaArrayRef);return R("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${F0}-${$8}`,children:[R("span",{className:"tl-row-label",title:d0.label,children:[K("span",{className:"tl-layer-indent","aria-hidden":"true"}),K("span",{className:"tl-kind","data-kind":v9,children:r8}),K("span",{className:"tl-row-label-text",children:d0.label})]}),R("div",{className:"tl-row-track",children:[K("div",{className:"tl-seq-block tl-layer-block","data-kind":v9,"data-testid":`timeline-layer-block-${F0}-${$8}`,title:`${d0.label} (${d0.kind} layer)`,style:{left:o8(z0.from),width:`${U0/(g-1)*100}%`},onContextMenu:(z8)=>{z8.preventDefault(),z8.stopPropagation(),V8({index:F0,layerIndex:$8,x:z8.clientX,y:z8.clientY})},children:K("span",{className:"tl-seq-name",children:d0.label})}),C&&k0?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${F0}-${$8}`,title:`Replace this ${d0.kind}`,"aria-label":`Replace ${d0.label}`,style:{left:`calc(${o8(z0.from)} + ${U0/(g-1)*100}% - 20px)`},onPointerDown:(z8)=>z8.stopPropagation(),onClick:(z8)=>{z8.stopPropagation(),C(F0,$8)},children:"⇄"}):null]})]},`l${$8}`)}):null]},F0)}),Q.map((z0,F0)=>R("div",{className:"tl-row","data-testid":`timeline-audio-${F0}`,children:[R("span",{className:"tl-row-label",title:z0.label,children:[K("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${z0.label}`,"aria-label":`Audio · ${z0.label}`,children:"♪"}),K("span",{className:"tl-row-label-text",children:z0.label})]}),R("div",{className:"tl-row-track",children:[R("div",{className:"tl-audio-block",title:`${z0.label} · ${z0.from}–${z0.from+z0.duration}f`,style:{left:o8(z0.from),width:`${z0.duration/(g-1)*100}%`},children:[K("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:K("path",{d:"M0 6 Q2 1 4 6 T8 6 T12 6 T16 6 T20 6 T24 6 T28 6 T32 6 T36 6 T40 6 T44 6 T48 6 T52 6 T56 6 T60 6 T64 6 T68 6 T72 6 T76 6 T80 6 T84 6 T88 6 T92 6 T96 6 T100 6"})}),K("span",{className:"tl-seq-name",children:z0.label})]}),T?K("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${F0}`,title:"Replace this audio","aria-label":`Replace audio ${z0.label}`,style:{left:`calc(${o8(z0.from)} + ${z0.duration/(g-1)*100}% - 20px)`},onPointerDown:(U0)=>U0.stopPropagation(),onClick:(U0)=>{U0.stopPropagation(),T(F0)},children:"⇄"}):null]})]},`a${F0}`)),K("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:`calc(96px + (100% - 96px) * ${e/(g-1)||0})`}})]})}),U8&&J[U8.index]?(()=>{let z0=J[U8.index],F0=U8.index,U0=U8.layerIndex,y0;if(U0!=null){let w0=(Array.isArray(z0.layers)?z0.layers:[])[U0],R0=[];if(C&&w0&&(w0.mediaCdId||w0.mediaArrayRef))R0.push({id:"replace-layer",label:`Replace ${w0.kind}…`,onSelect:()=>C(F0,U0)});if(R0.length===0)R0.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});y0=[R0]}else{let w0=[];if(I&&z0.replaceable&&!(Array.isArray(z0.layers)&&z0.layers.length>=2))w0.push({id:"replace",label:`Replace ${yH(z0)}…`,onSelect:()=>I(F0)});if(S)w0.push({id:"earlier",label:z0.series?"Move earlier":"Bring forward",disabled:z0.series?F0<=0:F0>=J.length-1,onSelect:()=>S(F0,z0.series?"backward":"forward")}),w0.push({id:"later",label:z0.series?"Move later":"Send backward",disabled:z0.series?F0>=J.length-1:F0<=0,onSelect:()=>S(F0,z0.series?"forward":"backward")});y0=[w0];let R0=[];if(j)R0.push({id:"hide",label:z0.hidden?"Show clip":"Hide clip",onSelect:()=>j(F0)});if(P)R0.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>P(F0)});if(R0.length)y0.push(R0)}return K(Ry,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:U8.x,clientY:U8.y},sections:y0,onClose:()=>V8(null)})})():null]})}function vQ0(X){let J={};for(let Q of X.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*(-?\d+)\s*;/g))J[Q[1]]=Number(Q[2]);for(let Q=0;Q<3;Q+=1)for(let Y of X.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);/g)){let W=Y[1];if(Object.hasOwn(J,W))continue;let G=g5(Y[2],J);if(G!=null)J[W]=G}return J}function g5(X,J){if(X==null)return null;let Q=String(X).trim();if(/^-?\d+$/.test(Q))return Number(Q);if(Object.hasOwn(J,Q))return J[Q];let Y=Q.replace(/[A-Za-z_$][\w$]*/g,(W)=>Object.hasOwn(J,W)?String(J[W]):W);if(/^[-+*/()\d\s.]+$/.test(Y)&&/\d/.test(Y))try{let W=Function(`"use strict";return (${Y});`)();if(Number.isFinite(W))return Math.round(W)}catch{}return null}function xQ0(X,J,Q,Y){if(!J)return[];let W=X.search(new RegExp(`\\b(?:const|function)\\s+${J}\\b`));if(W<0)return[];let G=X.slice(W+J.length),q=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,q>0?q:2400),Z=[];for(let z of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let U=g5(z[1],Q),B=g5(z[2],Q);if(U!=null&&B!=null&&B>=U)Z.push({from:Y+U,to:Y+B})}return Z}function hQ0(X,J){if(!J)return null;let Q=X.search(new RegExp(`\\b(?:const|function)\\s+${J}\\b`));if(Q<0)return null;let Y=X.slice(Q+J.length+1),W=Y.search(/\n(?:const|function|export)\s+[A-Za-z]/);return Y.slice(0,W>0?W:Y.length)}function gQ0(X,J){let Q=[];for(let Y of X.matchAll(/<VideoComp\b([^>]*?)\/?>/g)){let W=Y[1],G=W.match(/component=\{([A-Za-z_$][\w$]*)\}/);if(!G)continue;let H=[...X.slice(0,Y.index).matchAll(/<DCArtboard\b[^>]*?\bid=["']([^"']+)["']/g)];Q.push({compName:G[1],artboardId:H.length?H[H.length-1][1]:null,duration:g5(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],J),fps:g5(W.match(/fps=\{([^}]+)\}/)?.[1],J)||30})}return Q}function Iy(X,J,Q){let Y=String(X??""),W=vQ0(Y),G=Y,q=J,H=0,Z=null,z=gQ0(Y,W).map((O)=>({...O,body:hQ0(Y,O.compName)})).filter((O)=>O.body);if(z.length){let O=Q&&z.find((P)=>P.artboardId===Q)||z.find((P)=>/<(?:Audio|OffthreadVideo|Video)\b/.test(P.body))||z.find((P)=>P.duration!=null&&P.duration===J)||z[0];if(G=O.body,O.duration!=null)q=O.duration;H=O.fps,Z=O.artboardId??null}let U=[],B=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=B.exec(G)){let O=F[1],P=F[2],I=B.lastIndex;if(/Transition$/.test(O)){let T=P.match(/durationInFrames:\s*([^,}\s)]+)/);U.push({type:"transition",dur:g5(T?.[1],W)??0})}else{let T=P.match(/durationInFrames=\{([^}]+)\}/),C=P.match(/from=\{([^}]+)\}/),S=G.indexOf(`</${O}>`,I),j=S>=0?Math.min(S,I+400):I+240,b=G.slice(I,j),h=b.match(/<([A-Z][A-Za-z0-9]*)\b/),d=b.match(/<(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),i=P.match(/name=["']([^"']+)["']/);U.push({type:"seq",series:O!=="Sequence",dur:g5(T?.[1],W),from:O==="Sequence"&&C?g5(C[1],W):null,compName:i?i[1]:h?h[1]:null,mediaTag:d?d[1]:null,mediaSrc:d?d[2]:null})}}let L=0,D=[];for(let O of U){if(O.type==="transition"){L-=O.dur||0;continue}let P=O.from!=null?O.from:L,I=O.dur!=null?O.dur:30;D.push({label:O.compName??`Seq ${D.length+1}`,series:!!O.series,mediaTag:O.mediaTag,mediaSrc:O.mediaSrc,from:Math.max(0,P),duration:Math.max(1,I),keyframes:xQ0(Y,O.compName,W,Math.max(0,P))}),L=P+I}let w=D.length?Math.max(...D.map((O)=>O.from+O.duration)):30,E=Number.isFinite(q)&&q>0?q:w,A=[];for(let O of G.matchAll(/<Audio\b([^>]*)>/g)){let P=O[1],I=P.match(/src=["']([^"']+)["']/),T=P.match(/from=\{([^}]+)\}/),C=P.match(/durationInFrames=\{([^}]+)\}/),S=T?g5(T[1],W)??0:0,j=C?g5(C[1],W):null,b=I?String(I[1]).split(/[\\/]/).pop():"audio";A.push({kind:"audio",label:b,from:Math.max(0,S),duration:j!=null?Math.max(1,j):Math.max(1,E-S)})}return{total:E,fps:H||void 0,sequences:D,audio:A,artboardId:Z}}var z7=R8(x8(),1);function NM({name:X,size:J=16}){let Q={x:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),sparkle:K("path",{d:"M8 2.5l1.2 3.3L12.5 7 9.2 8.2 8 11.5 6.8 8.2 3.5 7l3.3-1.2z"}),copy:R(Q0,{children:[K("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),K("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}var mQ0=["1:1","16:9","9:16","4:3","3:4","4:5"];function LM({onClose:X,onInsert:J}){let[Q,Y]=z7.useState([]),[W,G]=z7.useState(""),[q,H]=z7.useState([]),[Z,z]=z7.useState(""),[U,B]=z7.useState("1:1"),[F,L]=z7.useState(""),[D,w]=z7.useState(!1),[E,A]=z7.useState(null),[O,P]=z7.useState(null),[I,T]=z7.useState(!0),[C,S]=z7.useState(null),j=z7.useRef(null),b=z7.useRef(null);z7.useEffect(()=>{fetch("/_api/generate/providers").then((n)=>n.json()).then((n)=>{let Y0=(n?.providers??[]).filter((G0)=>G0.modalities?.includes("image"));Y(Y0);let g=Y0.find((G0)=>G0.configured)??Y0[0];if(g)G(g.id)}).catch(()=>A({ok:!1,msg:"failed to load providers"}))},[]),z7.useEffect(()=>{if(!W)return;H([]),z("")},[W]),z7.useEffect(()=>{function n(Y0){if(Y0.key==="Escape")Y0.preventDefault(),X()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[X]),z7.useEffect(()=>()=>clearInterval(j.current),[]),z7.useEffect(()=>{if(!O||!I||typeof J!=="function")return;if(b.current===O)return;b.current=O;let n=J(O)===!0;if(S(n),n)A({ok:!0,msg:"Placed on canvas ✓"});else A({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[O,I,J]);let h=Q.find((n)=>n.id===W),d=h&&!h.configured,i=z7.useCallback((n)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let g=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((G0)=>G0.id===n);if(!g)return;if(g.status==="done"){clearInterval(j.current),w(!1);let G0=g.assets?.[0]??null;P(G0),A({ok:!0,msg:G0?`Generated ${G0}`:"Done (no asset)"})}else if(g.status==="failed")clearInterval(j.current),w(!1),A({ok:!1,msg:g.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),w((Y0)=>{if(Y0)A({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function v(){if(!F.trim()||!W)return;w(!0),A(null),P(null),S(null),b.current=null;try{let n={modality:"image",provider:W,prompt:F.trim(),aspectRatio:U,...Z?{model:Z}:{}},Y0=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(n)});if(Y0.status===202){let{jobId:g}=await Y0.json();A({ok:!0,msg:"Generating…"}),i(g)}else w(!1),A({ok:!1,msg:await Y0.text()})}catch(n){w(!1),A({ok:!1,msg:n&&n.message?n.message:"request failed"})}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)X()},children:R("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Generate with AI"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:K(NM,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:"Prompt"}),K("textarea",{className:"input st-gen-prompt",rows:3,value:F,placeholder:"a minimal hero image of a mountain lake at dawn, soft light","aria-label":"Generation prompt",onChange:(n)=>L(n.target.value)}),R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-provider",children:"Provider"}),K("select",{id:"st-gen-provider",className:"st-select",value:W,onChange:(n)=>G(n.target.value),children:Q.map((n)=>R("option",{value:n.id,children:[n.label,n.configured?"":" — no key"]},n.id))})]}),q.length>0&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-model",children:"Model"}),K("select",{id:"st-gen-model",className:"st-select",value:Z,onChange:(n)=>z(n.target.value),children:q.map((n)=>K("option",{value:n.id,children:n.label},n.id))})]}),R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-gen-aspect",children:"Aspect"}),K("select",{id:"st-gen-aspect",className:"st-select",value:U,onChange:(n)=>B(n.target.value),children:mQ0.map((n)=>K("option",{value:n,children:n},n))})]}),J&&R("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[K("input",{type:"checkbox",checked:I,onChange:(n)=>T(n.target.checked),"aria-label":"Place the generated image on the canvas"}),K("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),d&&R("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",h.label," — add one in Settings (⌘,)."]}),O&&R("div",{className:"st-gen-result",children:[K("img",{className:"st-gen-thumb",src:`/${O}`,alt:"generated"}),R("div",{className:"st-gen-result-actions",children:[R("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${O}`),children:[K(NM,{name:"copy",size:13})," Copy path"]}),J&&C!==!0&&K("button",{type:"button",className:"st-btn",onClick:()=>{let n=J(O)===!0;S(n),A(n?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),E&&K("div",{className:"st-provider-status",style:{color:E.ok?"var(--accent)":"var(--danger, #e5484d)"},children:E.msg}),K("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:R("button",{type:"button",className:"st-btn st-gen-go",disabled:D||!F.trim()||!W,onClick:v,children:[K(NM,{name:"sparkle",size:14})," ",D?"Generating…":"Generate"]})})]})]})})}var u9=R8(x8(),1);var G2=new Set(["main","master"]);function T9({name:X,size:J=16,className:Q}){let Y={check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),"chevron-up":K("polyline",{points:"3.5 10 8 5.5 12.5 10"}),"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-open":R(Q0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14"}),K("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:R(Q0,{children:[K("circle",{cx:"4",cy:"8",r:"1.6"}),K("circle",{cx:"12",cy:"4",r:"1.6"}),K("circle",{cx:"12",cy:"12",r:"1.6"}),K("line",{x1:"5.4",y1:"7.2",x2:"10.6",y2:"4.6"}),K("line",{x1:"5.4",y1:"8.8",x2:"10.6",y2:"11.4"})]}),draft:R(Q0,{children:[K("path",{d:"M3 11.5 11 3.5l1.5 1.5L4.5 13l-2 .5z"}),K("line",{x1:"9.5",y1:"5",x2:"11",y2:"6.5"})]}),branch:R(Q0,{children:[K("circle",{cx:"4.5",cy:"4",r:"1.4"}),K("circle",{cx:"4.5",cy:"12",r:"1.4"}),K("circle",{cx:"11.5",cy:"6.5",r:"1.4"}),K("line",{x1:"4.5",y1:"5.4",x2:"4.5",y2:"10.6"}),K("path",{d:"M4.5 8.6h2.6a3 3 0 0 0 3-1.6"})]}),plus:R(Q0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),"arrow-up-to-line":R(Q0,{children:[K("line",{x1:"3.5",y1:"3",x2:"12.5",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"6"}),K("polyline",{points:"5 8.5 8 5.5 11 8.5"})]}),cloud:K("path",{d:"M4.5 12h6a2.5 2.5 0 0 0 .3-5A3.5 3.5 0 0 0 4 6.4 2.8 2.8 0 0 0 4.5 12z"}),refresh:R(Q0,{children:[K("path",{d:"M12.5 8a4.5 4.5 0 1 1-1.3-3.2"}),K("polyline",{points:"12.8 2.5 12.8 5 10.3 5"})]}),spinner:K("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10.5"}),K("polyline",{points:"5 7.5 8 10.5 11 7.5"}),K("line",{x1:"3.5",y1:"13.2",x2:"12.5",y2:"13.2"})]}),close:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[X];return K("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function q2(X){return String(X).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(X)}function Ty(X){return X.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function DM(X){return String(X).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function uQ0(X){if(!X)return"";let J=Math.max(0,Math.floor(Date.now()/1000)-X);if(J<45)return"just now";if(J<3600)return`${Math.round(J/60)} min ago`;if(J<86400)return`${Math.round(J/3600)} h ago`;return`${Math.round(J/86400)} d ago`}async function OM(X){return(await fetch(X)).json()}async function H2(X,J,Q={}){let Y=Q.timeoutMs?new AbortController:null,W=Y?setTimeout(()=>Y.abort(),Q.timeoutMs):null;try{let G=await fetch(X,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J),signal:Y?.signal}),q=null;try{q=await G.json()}catch{}return{ok:G.ok,status:G.status,json:q}}catch(G){if(G?.name==="AbortError")return{ok:!1,status:0,json:null,timedOut:!0};return{ok:!1,status:0,json:null,error:String(G?.message||G)}}finally{if(W)clearTimeout(W)}}function MM({project:X,liveBranch:J,remoteSync:Q,onGetLatest:Y}){let W=G9(),[G,q]=u9.useState(null),[H,Z]=u9.useState([]),[z,U]=u9.useState([]),[B,F]=u9.useState(!1),[L,D]=u9.useState(!1),[w,E]=u9.useState(""),[A,O]=u9.useState(!1),[P,I]=u9.useState(""),[T,C]=u9.useState(null),[S,j]=u9.useState(!1),[b,h]=u9.useState(!1),[d,i]=u9.useState(!1);async function v(k0){if(!G9()){window.open(k0,"_blank","noopener,noreferrer");return}try{await jj(k0)}catch{try{await navigator.clipboard.writeText(k0),j(!0)}catch{}}}let[n,Y0]=u9.useState(!1),[g,G0]=u9.useState(""),[e,l]=u9.useState(""),[Z0,r]=u9.useState(""),[a,c]=u9.useState(!1),[V0,o0]=u9.useState(0),[U8,V8]=u9.useState(!1),L0=u9.useRef(null);if(u9.useEffect(()=>{let k0=!0;if((async()=>{try{let z8=await OM("/_api/git/status");if(!k0)return;if(q(z8),z8.repo&&W){let m7=await OM("/_api/git/branches");if(k0)Z(m7.branches||[])}}catch{}})(),W)mj().then((z8)=>k0&&U(z8||[])).catch(()=>{});return()=>{k0=!1}},[W]),u9.useEffect(()=>{if(!B||!W||!G?.repo)return;l(""),z0()},[B]),u9.useEffect(()=>{if(!B&&!L)return;let k0=(z8)=>{if(L0.current&&!L0.current.contains(z8.target))F(!1),D(!1),r("")};return document.addEventListener("mousedown",k0),()=>document.removeEventListener("mousedown",k0)},[B,L]),!G?.repo)return null;let t0=J||G.branch||"main",n0=G2.has(t0),Q8=H.find((k0)=>G2.has(k0.name))?.name||"main",v8=(k0,z8)=>(z8.updatedAt||0)-(k0.updatedAt||0)||k0.name.localeCompare(z8.name),i8=Z0.trim().toLowerCase(),g8=(k0)=>!i8||k0.name.toLowerCase().includes(i8),z9=H.filter((k0)=>!G2.has(k0.name)).sort(v8),c0=z9.filter(g8),d8=c0.filter((k0)=>k0.name!==t0),o8=!i8||Q8.toLowerCase().includes(i8)||"shared version".includes(i8),j9=z9.length>6,f0=X||q2(z[0]||"Project");if(!W)return K("div",{className:"rb-dock-wrap",children:K("div",{className:"rb-dock rb-dock--ro",children:R("span",{className:"rb-trigger rb-trigger--ro",title:`${f0} · branch: ${t0} — switch branches in your terminal`,children:[K("span",{className:"rb-trigger-icon",children:K(T9,{name:"folder",size:14})}),K("span",{className:"rb-trigger-proj",children:f0}),K("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),R("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[K(T9,{name:"branch",size:12}),R("span",{className:"rb-trigger-ver-name",children:["branch: ",t0]})]})]})})});async function z0(){try{let k0=await OM("/_api/git/branches");Z(k0.branches||[])}catch{}}async function F0(k0,z8){if(F(!1),k0===t0)return;G0(k0),V8(z8==="remote"),l("");let m7=await H2("/_api/git/checkout",{name:k0});if(m7.ok&&m7.json?.ok)window.location.reload();else l(m7.json?.error||"Could not switch."),G0(""),V8(!1)}async function U0(){if(a)return;c(!0),l("");let k0=await H2("/_api/git/fetch",{},{timeoutMs:45000});if(k0.ok&&k0.json?.ok){if(k0.json.fetchedAt)o0(k0.json.fetchedAt);await z0()}else if(k0.timedOut||k0.json?.timedOut)l("Couldn’t reach the remote — your local branches are still listed above.");else l(k0.status===401||k0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":k0.json?.error||"Could not fetch remote branches.");c(!1)}async function y0(){let k0=Ty(w);if(!k0)return;Y0(!0),l("");let z8=await H2("/_api/git/branch",{name:k0});if(z8.ok&&z8.json?.ok)window.location.reload();else l(z8.json?.error||"Could not create the draft."),Y0(!1)}async function w0(){if(b||!Y)return;h(!0),l("");let k0=await Y();if(h(!1),k0&&!k0.ok&&!k0.conflict)l(k0.status===401||k0.authRequired?"Sign in with GitHub to get the latest.":k0.error||"Could not get the latest.")}async function R0(){I(t0),l("");let k0=await H2("/_api/git/fold",{name:t0},{timeoutMs:45000}),z8=k0.json;if(k0.ok&&z8?.ok&&z8.prUrl){C({url:z8.prUrl,number:z8.prNumber,repo:z8.repo}),I(""),z0();return}if(k0.ok&&z8?.ok&&z8.prUnavailable){C({message:z8.error||"Draft published, but the pull request could not be opened."}),I(""),z0();return}if(k0.ok&&z8?.ok){window.location.reload();return}l(k0.status===401?`Sign in with GitHub to add “${t0}” to ${Q8}.`:z8?.error||"Could not add the branch."),I("")}async function I0(k0){if(F(!1),!W)return;G0(q2(k0));try{await AJ(k0)}catch(z8){l(String(z8?.message||z8||"Could not open that project.")),G0("")}}async function O8(){if(F(!1),!W)return;try{let k0=await vQ();if(!k0)return;G0(q2(k0)),await AJ(k0)}catch(k0){l(String(k0?.message||k0||"Could not open that folder.")),G0("")}}let r0=Ty(w),d0=n0?null:H.find((k0)=>k0.current),$8=n0&&!d&&!g&&!P?[...H].filter((k0)=>!G2.has(k0.name)&&k0.where!=="remote").sort((k0,z8)=>(z8.updatedAt||0)-(k0.updatedAt||0))[0]:null,v9=R(Q0,{children:[R("div",{className:"rb-pop-empty",children:["No branch matches “",Z0.trim(),"”."]}),R("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:U0,disabled:a,children:[K("span",{className:"rb-pop-icon"+(a?" rb-pop-icon--spin":""),children:K(T9,{name:a?"spinner":"refresh",size:14})}),K("span",{className:"rb-pop-tx",children:K("span",{className:"rb-pop-name",children:a?"Searching the remote…":"Search the remote for it"})})]})]}),r8=(k0)=>{let z8=k0.where==="remote";return R("button",{type:"button","data-testid":`branch-row-${DM(k0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>F0(k0.name,k0.where),children:[K("span",{className:"rb-pop-icon "+(z8?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:K(T9,{name:z8?"cloud":"draft",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:k0.name}),z8&&K("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},k0.name)};return R("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!g&&!P&&R("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:w0,disabled:b,title:`Get the latest ${Q8}`,children:[K(T9,{name:b?"spinner":"download",size:14,className:b?"rb-spin":""}),K("span",{className:"rb-getlatest-tx",children:b?"Getting the latest…":"Get latest"}),!b&&Q.behind>0&&R("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",Q8]})]}),$8&&R("div",{className:"rb-resume","data-testid":"switcher-resume",children:[R("button",{type:"button",className:"rb-resume-go",onClick:()=>F0($8.name),title:`Switch to ${$8.name}`,children:[K("span",{className:"rb-resume-icon",children:K(T9,{name:"draft",size:13})}),R("span",{className:"rb-resume-tx",children:["Continue on ",K("b",{children:$8.name})]}),K(T9,{name:"chevron-right",size:12,className:"rb-resume-arrow"})]}),K("button",{type:"button",className:"rb-resume-x","data-testid":"switcher-resume-dismiss","aria-label":"Dismiss",onClick:()=>i(!0),children:K(T9,{name:"close",size:12})})]}),R("div",{className:"rb-dock",ref:L0,children:[B&&R("div",{className:"rb-pop rb-pop--up",id:"rb-switch-pop",role:"menu","aria-label":"Switch project or version","data-testid":"repo-switcher-popup",children:[K("div",{className:"rb-pop-hd",children:"Project"}),W&&z.length>0?z.map((k0,z8)=>R("button",{type:"button",className:"rb-pop-item"+(z8===0?" is-current":""),role:"menuitem",onClick:()=>I0(k0),children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"folder",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:q2(k0)}),K("span",{className:"rb-pop-sub",children:k0})]}),z8===0?K(T9,{name:"check",size:14,className:"rb-pop-check"}):null]},k0)):K("div",{className:"rb-pop-sub",style:{padding:"var(--space-2) var(--space-3)"},children:W?"No other recent projects.":"Open another project from the desktop app."}),W&&R("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:O8,children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"folder-open",size:14})}),K("span",{className:"rb-pop-tx",children:K("span",{className:"rb-pop-name",children:"Open another folder…"})})]}),K("div",{className:"rb-pop-sep"}),K("div",{className:"rb-pop-hd",children:"Branch"}),n0?R(Q0,{children:[R("button",{type:"button","data-testid":`branch-row-${DM(Q8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>F0(Q8),children:[K("span",{className:"rb-pop-icon rb-pop-icon--shared",children:K(T9,{name:"share",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:Q8}),K("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),K(T9,{name:"check",size:14,className:"rb-pop-check"})]}),z9.length>0&&K("div",{className:"rb-pop-grouplabel",children:"Other branches"}),j9&&K("div",{className:"rb-search",children:K("input",{className:"input rb-search-input",type:"text",value:Z0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(k0)=>r(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")r("")}})}),c0.map(r8),j9&&i8&&c0.length===0&&!o8&&v9]}):R(Q0,{children:[R("button",{type:"button",className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",children:[K("span",{className:"rb-pop-icon rb-pop-icon--draft",children:K(T9,{name:"draft",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:d0?.name||t0}),K("span",{className:"rb-pop-sub",children:"your branch"})]}),K(T9,{name:"check",size:14,className:"rb-pop-check"})]}),R("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{F(!1),l(""),C(null),j(!1),O(!0)},children:[K("span",{className:"rb-fold-icon",children:K(T9,{name:"arrow-up-to-line",size:15})}),R("span",{className:"rb-fold-tx",children:[R("span",{className:"rb-fold-title",children:["Merge this branch → ",Q8]}),K("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),K("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),j9&&K("div",{className:"rb-search",children:K("input",{className:"input rb-search-input",type:"text",value:Z0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(k0)=>r(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")r("")}})}),o8&&R("button",{type:"button","data-testid":`branch-row-${DM(Q8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>F0(Q8),children:[K("span",{className:"rb-pop-icon rb-pop-icon--shared",children:K(T9,{name:"share",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:Q8}),K("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),d8.map(r8),j9&&i8&&d8.length===0&&!o8&&v9]}),R("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:U0,disabled:a,children:[K("span",{className:"rb-pop-icon"+(a?" rb-pop-icon--spin":""),children:K(T9,{name:a?"spinner":"refresh",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:a?"Fetching…":"Fetch remote branches"}),K("span",{className:"rb-pop-sub",children:V0?`as of ${uQ0(V0)}`:"check the remote for new branches"})]})]}),e&&!g&&K("div",{className:"rb-pop-notice",role:"alert",children:e}),R("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{F(!1),D(!0)},children:[K("span",{className:"rb-pop-icon",children:K(T9,{name:"plus",size:14})}),R("span",{className:"rb-pop-tx",children:[K("span",{className:"rb-pop-name",children:"New branch"}),K("span",{className:"rb-pop-sub",children:"a separate line of work off what you're looking at now"})]})]})]}),L&&R("div",{className:"rb-newdraft rb-newdraft--up",children:[R("label",{className:"rb-newdraft-field",children:[K("span",{className:"rb-newdraft-label",children:"Name your branch"}),K("input",{className:"input rb-newdraft-input","data-testid":"switcher-new-branch-input",type:"text",value:w,placeholder:"nav-redesign","aria-label":"Branch name",autoFocus:!0,onChange:(k0)=>E(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter"&&r0)y0();if(k0.key==="Escape")D(!1),E("")}}),r0&&R("span",{className:"rb-pop-sub",children:["Creates branch ",K("b",{children:r0})]})]}),e&&K("span",{className:"rb-newdraft-err",children:e}),R("div",{className:"rb-newdraft-actions",children:[K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{D(!1),E(""),l("")},disabled:n,children:"Cancel"}),R("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:y0,disabled:n||!r0,children:[K(T9,{name:"draft",size:13})," ",n?"Creating…":"Create branch"]})]}),R("p",{className:"rb-newdraft-hint",children:["A branch is your own line of work off what you're looking at now. Merge it into ",Q8," when you're happy, or throw it away — nothing else changes."]})]}),g||P?R("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[K(T9,{name:"spinner",size:14,className:"rb-spin"}),K("span",{children:P?R(Q0,{children:["Merging ",K("b",{children:P})," → ",Q8,"…"]}):U8?R(Q0,{children:["Downloading ",K("b",{children:g}),"…"]}):R(Q0,{children:["Opening ",K("b",{children:g}),"…"]})})]}):R("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(B?" is-open":""),"aria-expanded":B,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>{F((k0)=>{if(k0)r("");return!k0}),D(!1)},title:`${f0} · ${t0}`,children:[K("span",{className:"rb-trigger-icon",children:K(T9,{name:"folder",size:14})}),K("span",{className:"rb-trigger-proj",children:f0}),K("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),R("span",{className:"rb-trigger-ver"+(n0?"":" is-draft"),children:[K(T9,{name:n0?"share":"draft",size:12}),K("span",{className:"rb-trigger-ver-name",children:t0})]}),K(T9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),e&&!B&&!L&&!g&&K("div",{className:"rb-switcher-err",role:"alert",children:e})]}),A&&K("div",{className:"rb-scrim",role:"presentation",onClick:()=>{O(!1),C(null),j(!1)},children:K("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(k0)=>k0.stopPropagation(),onKeyDown:(k0)=>{if(k0.key==="Escape")O(!1),C(null),j(!1)},children:T?T.url?R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"share",size:20})}),R("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",T.number?` #${T.number}`:""]}),R("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",R("b",{children:["“",t0,"”"]})," is up as a pull request into ",K("b",{children:Q8}),T.repo?R(Q0,{children:[" of ",K("b",{children:T.repo})]}):null,". Review and merge it on GitHub — that keeps your team's review rules."]}),K("p",{className:"rb-sheet-meta rb-pr-url",children:T.url}),R("div",{className:"rb-sheet-actions",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:()=>{O(!1),C(null),j(!1)},children:"Close"}),R("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>v(T.url),children:[K(T9,{name:"share",size:15})," ",S?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"share",size:20})}),K("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:"Draft published"}),K("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:T.message}),K("div",{className:"rb-sheet-actions",children:K("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{O(!1),C(null),j(!1)},children:"Got it"})})]}):R(Q0,{children:[K("span",{className:"rb-sheet-icon",children:K(T9,{name:"arrow-up-to-line",size:20})}),R("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",Q8]}),R("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",R("b",{children:["“",d0?.name||t0,"”"]})," to ",K("b",{children:Q8})," — the default branch everyone shares."]}),K("p",{className:"rb-sheet-meta",children:"On a shared GitHub project this opens a pull request for review; a local project merges directly. Nothing is lost — your work is kept in History."}),e&&K("p",{className:"rb-newdraft-err",children:e}),R("div",{className:"rb-sheet-actions",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:()=>{O(!1),l("")},children:"Cancel"}),R("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!P,onClick:R0,children:[K(T9,{name:"arrow-up-to-line",size:15})," ",P?"Adding…":`Add to ${Q8}`]})]})]})})})]})}var M7=R8(x8(),1);function fH({name:X,size:J=16}){let Q={x:R(Q0,{children:[K("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),K("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:R(Q0,{children:[K("circle",{cx:"5.5",cy:"5.5",r:"3"}),K("path",{d:"M7.6 7.6 13 13"}),K("line",{x1:"11",y1:"11",x2:"12.5",y2:"9.5"})]}),check:K("polyline",{points:"3.5 8.5 6.5 11.5 12.5 4.5"}),external:R(Q0,{children:[K("path",{d:"M6 3.5H3.2A.7.7 0 0 0 2.5 4.2v8.6a.7.7 0 0 0 .7.7h8.6a.7.7 0 0 0 .7-.7V10"}),K("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),K("polyline",{points:"9.5 3 13 3 13 6.5"})]}),cloud:K("path",{d:"M4.5 12h6a2.5 2.5 0 0 0 .2-5 3.5 3.5 0 0 0-6.7-1A2.75 2.75 0 0 0 4.5 12Z"})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function lQ0({provider:X,onChanged:J}){let[Q,Y]=M7.useState(""),[W,G]=M7.useState(!1),[q,H]=M7.useState(null),Z=X.configured;async function z(){let B=Q.trim();if(!B)return;G(!0),H(null);try{let F=await fetch("/_api/generate/keys",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:X.id,key:B})});if(!F.ok)throw Error(await F.text());let L=await F.json();Y(""),H({ok:!0,msg:L.configured?"Key saved.":"Saved."}),J()}catch(F){H({ok:!1,msg:F&&F.message?F.message:"save failed"})}finally{G(!1)}}async function U(){G(!0),H(null);try{let B=await fetch("/_api/generate/keys",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:X.id})});if(!B.ok)throw Error(await B.text());H({ok:!0,msg:"Key removed."}),J()}catch(B){H({ok:!1,msg:B&&B.message?B.message:"remove failed"})}finally{G(!1)}}return R("div",{className:"st-provider-card",children:[R("div",{className:"st-provider-hd",children:[K("span",{className:"st-provider-name",children:X.label}),K("span",{className:"st-pill"+(X.kind==="local"?" is-local":""),children:X.kind==="local"?"Local":R(Q0,{children:[K(fH,{name:"cloud",size:12})," Cloud"]})}),Z&&R("span",{className:"st-provider-configured",children:[K(fH,{name:"check",size:12})," configured"]})]}),K("div",{className:"st-provider-modalities",children:X.modalities.join(" · ")}),X.notes&&K("div",{className:"st-provider-notes",children:X.notes}),X.keyUrl&&R("a",{className:"st-provider-keylink",href:X.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",K(fH,{name:"external",size:12})]}),X.auth==="api-key"&&R("div",{className:"st-provider-keyrow",children:[K("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:Z?"•••••••• configured — paste to replace":"paste API key","aria-label":`${X.label} API key`,onChange:(B)=>Y(B.target.value),onKeyDown:(B)=>{if(B.key==="Enter")z()}}),R("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:z,children:[K(fH,{name:"key",size:13})," Save"]}),Z&&K("button",{type:"button",className:"st-btn",disabled:W,onClick:U,children:"Remove"})]}),q&&K("div",{className:"st-provider-status",style:{color:q.ok?"var(--accent)":"var(--danger, #e5484d)"},children:q.msg})]})}var dQ0=[{id:"whisper",label:"Local whisper.cpp",note:"Free · offline · no key · runs on your hardware"},{id:"elevenlabs",label:"ElevenLabs Scribe",note:"Cloud · accuracy · needs an ElevenLabs key"},{id:"groq",label:"Groq Whisper",note:"Cloud · fast · needs a Groq key"}];function pQ0(){let[X,J]=M7.useState(null),[Q,Y]=M7.useState(!1),[W,G]=M7.useState(null);M7.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>J(H?.transcriptionProvider||"whisper")).catch(()=>J("whisper"))},[]);async function q(H){if(H===X)return;let Z=X;J(H),Y(!0),G(null);try{let z=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:H})});if(!z.ok)throw Error(await z.text());G({ok:!0,msg:"Saved."})}catch(z){J(Z),G({ok:!1,msg:z&&z.message?z.message:"save failed"})}finally{Y(!1)}}return R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),K("div",{className:"st-provider-notes",children:"Which engine turns audio into subtitles. This is an explicit choice — Maude never silently switches engines; a chosen-but-unavailable engine tells you how to fix it."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:dQ0.map((H)=>R("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[K("input",{type:"radio",name:"transcription-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>q(H.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:H.label}),K("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&K("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function cQ0(){let[X,J]=M7.useState(null),[Q,Y]=M7.useState(null),W=M7.useCallback(()=>{fetch("/_api/generate/whisper-model").then((z)=>z.ok?z.json():Promise.reject(Error(`HTTP ${z.status}`))).then(J).catch((z)=>Y(z&&z.message?z.message:"failed to load models"))},[]);M7.useEffect(()=>{W()},[W]),M7.useEffect(()=>{if(!X?.downloading)return;let z=setInterval(W,1000);return()=>clearInterval(z)},[X?.downloading,W]);async function G(z){Y(null);try{let U=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:z})});if(!U.ok)throw Error(await U.text());W()}catch(U){Y(U&&U.message?U.message:"download failed")}}async function q(z){Y(null);try{let U=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:z})});if(!U.ok)throw Error(await U.text());W()}catch(U){Y(U&&U.message?U.message:"remove failed")}}let H=X?.downloading,Z=(z,U)=>U>0?Math.min(100,Math.round(z/U*100)):0;return R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Local subtitle models (whisper.cpp)"})}),R("div",{className:"st-provider-notes",children:["Download a model once and local subtitles work offline, free, with no key. Requires the whisper.cpp binary (",K("code",{children:"brew install whisper-cpp"}),"). Models are stored on this machine only and never committed."]}),Q&&K("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&R("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),X===null&&!Q&&K("div",{className:"st-settings-intro",children:"Loading…"}),K("div",{className:"st-model-list",children:(X?.models||[]).map((z)=>{let U=H&&!H.error&&H.id===z.id;return R("div",{className:"st-model-row",children:[R("div",{className:"st-model-info",children:[R("span",{className:"st-model-label",children:[z.label,K("span",{className:"st-pill"+(z.multilingual?"":" is-local"),children:z.multilingual?"multilingual":"English-only"}),R("span",{className:"st-model-size",children:["~",z.sizeMB," MB"]})]}),K("span",{className:"st-engine-radio-note",children:z.note}),U&&R("span",{className:"st-model-progress",children:["Downloading… ",Z(H.received,H.total),"%"]})]}),K("div",{className:"st-model-actions",children:z.downloaded?R(Q0,{children:[R("span",{className:"st-provider-configured",children:[K(fH,{name:"check",size:12})," ready"]}),K("button",{type:"button",className:"st-btn",onClick:()=>q(z.id),children:"Remove"})]}):K("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(z.id),children:U?"Downloading…":"Download"})})]},z.id)})})]})}var _J=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation"},{id:"subtitles",label:"Subtitles"}],Cy="mdcc-settings-tab",iQ0=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}];function oQ0({value:X,disabled:J,onChange:Q}){return K("span",{className:"st-sidetoggle",role:"radiogroup","aria-label":"Panel side",children:["left","right"].map((Y)=>K("button",{type:"button",role:"radio","aria-checked":X===Y,disabled:J,className:"st-sidebtn"+(X===Y?" is-active":""),onClick:()=>Q(Y),children:Y==="left"?"Left":"Right"},Y))})}var nQ0=[{id:"separate",label:"Separate panel",note:"Layers docks on its own (default: left)."},{id:"in-inspector",label:"Inside Inspector",note:"Layers is a tab within the Inspector."}];function rQ0({panelSide:X,onSetPanelSide:J,layersMode:Q,onSetLayersMode:Y}){return R(Q0,{children:[R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Layers panel"})}),K("div",{className:"st-provider-notes",children:"Show Layers as its own dockable panel, or as a tab inside the Inspector."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Layers mode",children:nQ0.map((W)=>R("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"layers-mode",checked:Q===W.id,onChange:()=>Y(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Panel positions"})}),K("div",{className:"st-provider-notes",children:"Dock each panel to the left or right side. Each side shows one panel at a time, with tabs to switch between the panels docked there."}),iQ0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return R("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[R("span",{className:"st-pref-body",children:[K("span",{className:"st-pref-label",children:W.label}),G&&K("span",{className:"st-pref-note",children:"Layers is inside the Inspector — choose “Separate panel” above to dock it."})]}),K(oQ0,{value:X?.[W.id]||"left",disabled:G,onChange:(q)=>J(W.id,q)})]},W.id)})]})]})}function Z2({label:X,note:J,checked:Q,disabled:Y,reason:W,onChange:G}){return R("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[R("span",{className:"st-pref-body",children:[K("span",{className:"st-pref-label",children:X}),(W||J)&&K("span",{className:"st-pref-note",children:Y&&W?W:J})]}),K("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(q)=>G?.(q.target.checked)})]})}var aQ0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],sQ0=[{id:"advanced",label:"Advanced",note:"Raw CSS property names — border-radius, flex-direction…"},{id:"designer",label:"Designer",note:"Figma vocabulary — Fill, Stroke, Corner radius, Auto layout…"}];function tQ0({theme:X,onSetTheme:J,cpMode:Q,onSetCpMode:Y}){return R(Q0,{children:[R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Theme"})}),K("div",{className:"st-provider-notes",children:"Controls Maude’s own chrome — menubar, sidebar, canvas plane, minimap, zoom HUD. Artboards keep their own design-system theme."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Theme",children:aQ0.map((W)=>R("label",{className:"st-engine-radio"+(X===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"maude-theme",value:W.id,checked:X===W.id,onChange:()=>J?.(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),R("div",{className:"st-provider-card",children:[K("div",{className:"st-provider-hd",children:K("span",{className:"st-provider-name",children:"Inspector vocabulary"})}),K("div",{className:"st-provider-notes",children:"How the CSS panel labels controls. You can also flip this from the small toggle in the panel’s own corner — this choice is remembered."}),K("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Inspector vocabulary",children:sQ0.map((W)=>R("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[K("input",{type:"radio",name:"maude-cp-mode",value:W.id,checked:Q===W.id,onChange:()=>Y?.(W.id)}),R("span",{className:"st-engine-radio-body",children:[K("span",{className:"st-engine-radio-label",children:W.label}),K("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]})]})}function wM({onClose:X,initialTab:J,theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G,minimapVisible:q,onToggleMinimap:H,zoomCtlVisible:Z,onToggleZoomCtl:z,annotationsVisible:U,onToggleAnnotations:B,autoOpenInspector:F,onToggleAutoOpenInspector:L,hasCanvas:D=!1,panelSide:w,onSetPanelSide:E,layersMode:A,onSetLayersMode:O}){let[P,I]=M7.useState(null),[T,C]=M7.useState(null),[S,j]=M7.useState(()=>{if(J&&_J.some((i)=>i.id===J))return J;try{let i=localStorage.getItem(Cy);if(i&&_J.some((v)=>v.id===i))return i}catch{}return"appearance"});M7.useEffect(()=>{try{localStorage.setItem(Cy,S)}catch{}},[S]);let b=M7.useCallback(()=>{fetch("/_api/generate/providers").then((i)=>{if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}).then((i)=>I(Array.isArray(i?.providers)?i.providers:[])).catch((i)=>C(i&&i.message?i.message:"failed to load providers"))},[]);M7.useEffect(()=>{b()},[b]),M7.useEffect(()=>{function i(v){if(v.key==="Escape")v.preventDefault(),X()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[X]);function h(i){let v=_J.findIndex((n)=>n.id===S);if(i.key==="ArrowDown"||i.key==="ArrowRight")i.preventDefault(),j(_J[(v+1)%_J.length].id);else if(i.key==="ArrowUp"||i.key==="ArrowLeft")i.preventDefault(),j(_J[(v-1+_J.length)%_J.length].id);else if(i.key==="Home")i.preventDefault(),j(_J[0].id);else if(i.key==="End")i.preventDefault(),j(_J[_J.length-1].id)}let d=!D?"Open a canvas to use this.":void 0;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)X()},children:R("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Settings"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:K(fH,{name:"x",size:15})})]}),R("div",{className:"st-settings-tabs",children:[K("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:h,children:_J.map((i)=>K("button",{type:"button",role:"tab",id:`st-stab-${i.id}`,"aria-controls":`st-spanel-${i.id}`,"aria-selected":S===i.id,tabIndex:S===i.id?0:-1,className:"st-settings-tab"+(S===i.id?" is-active":""),onClick:()=>j(i.id),children:i.label},i.id))}),R("div",{className:"st-settings-pane",children:[R("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:S!=="appearance",children:[K("div",{className:"st-rp-hd",children:"Appearance"}),K(tQ0,{theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G})]}),R("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:S!=="canvas-view",children:[K("div",{className:"st-rp-hd",children:"Canvas & View"}),K(Z2,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:q,disabled:!D,reason:d,onChange:()=>H?.()}),K(Z2,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:Z,disabled:!D,reason:d,onChange:()=>z?.()}),K(Z2,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:U,onChange:()=>B?.()}),K(Z2,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>L?.()})]}),R("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:S!=="layout",children:[K("div",{className:"st-rp-hd",children:"Layout"}),K(rQ0,{panelSide:w,onSetPanelSide:E,layersMode:A,onSetLayersMode:O})]}),R("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:S!=="ai-generation",children:[K("div",{className:"st-rp-hd",children:"Provider keys"}),R("p",{className:"st-settings-intro",children:["Bring your own API keys to generate images (and, soon, audio + video) inside Maude. Keys are stored on this machine only — in your OS keychain or a private"," ",K("code",{children:"~/.config/maude/keys.json"})," (mode 0600) — sent straight to the provider, and never committed, logged, or exposed to a canvas."]}),T&&K("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:T}),P===null&&!T&&K("div",{className:"st-settings-intro",children:"Loading…"}),P?.map((i)=>K(lQ0,{provider:i,onChanged:b},i.id)),P?.length===0&&K("div",{className:"st-settings-intro",children:"No providers registered."})]}),R("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:S!=="subtitles",children:[K("div",{className:"st-rp-hd",children:"Subtitles"}),K(pQ0,{}),K(cQ0,{})]})]})]})]})})}var UY=R8(x8(),1);function eQ0({name:X,size:J=15}){if(X==="x")return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:K("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})});return null}function AM({onPick:X,onClose:J}){let[Q,Y]=UY.useState(null),[W,G]=UY.useState("");UY.useEffect(()=>{let Z=!0;return fetch("/_api/stickers").then((z)=>z.json()).then((z)=>Z&&Y(z.ok?z.packs:[])).catch(()=>Z&&Y([])),()=>{Z=!1}},[]),UY.useEffect(()=>{let Z=(z)=>{if(z.key==="Escape")z.stopPropagation(),J()};return window.addEventListener("keydown",Z,!0),()=>window.removeEventListener("keydown",Z,!0)},[J]);let q=UY.useMemo(()=>{if(!Q)return[];let Z=W.trim().toLowerCase();if(!Z)return Q;return Q.map((z)=>({...z,stickers:z.stickers.filter((U)=>U.file.toLowerCase().includes(Z)||(U.keywords||[]).some((B)=>B.toLowerCase().includes(Z)))})).filter((z)=>z.stickers.length>0)},[Q,W]),H=q.reduce((Z,z)=>Z+z.stickers.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Z)=>{if(Z.target===Z.currentTarget)J()},children:R("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Stickers"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:J,children:K(eQ0,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("input",{className:"input",type:"text",value:W,onChange:(Z)=>G(Z.target.value),placeholder:"Search stickers…","aria-label":"Search stickers",autoFocus:!0}),K("div",{className:"st-sp-body",children:Q==null?K("div",{className:"st-sp-empty",children:"Loading…"}):H===0?K("div",{className:"st-sp-empty",children:W.trim()?`No stickers match "${W.trim()}"`:"No stickers bundled"}):q.map((Z)=>R("div",{children:[R("div",{className:"st-sp-pack-hd",children:[K("span",{className:"st-sp-pack-name",children:Z.name}),Z.author&&R("span",{className:"st-sp-pack-author",children:["by ",Z.author]})]}),K("div",{className:"st-sp-grid",children:Z.stickers.map((z)=>K("button",{type:"button",className:"st-sp-cell",title:z.keywords?.[0]||z.file,onClick:()=>X(z),children:K("img",{className:"st-sp-thumb",src:z.url,alt:z.keywords?.[0]||z.file,loading:"lazy"})},z.file))})]},Z.slug))})]}),Q&&Q.length>0&&K("div",{className:"st-sp-ft",children:Q.map((Z)=>R("span",{children:[Z.name,Z.author?` — ${Z.author}`:"",Z.attributionUrl?R(Q0,{children:[" ","(",K("a",{href:Z.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},Z.slug))})]})})}var S6=R8(x8(),1);var V2=R8(x8(),1);var K2=(...X)=>X.filter((J,Q,Y)=>{return Boolean(J)&&J.trim()!==""&&Y.indexOf(J)===Q}).join(" ").trim();var Sy=(X)=>X.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var $y=(X)=>X.replace(/^([A-Z])|[\s-_]+(\w)/g,(J,Q,Y)=>Y?Y.toUpperCase():Q.toLowerCase());var _M=(X)=>{let J=$y(X);return J.charAt(0).toUpperCase()+J.slice(1)};var Pz=R8(x8(),1);var z2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var by=(X)=>{for(let J in X)if(J.startsWith("aria-")||J==="role"||J==="title")return!0;return!1};var vH=R8(x8(),1),X40=vH.createContext({});var jy=()=>vH.useContext(X40);var yy=Pz.forwardRef(({color:X,size:J,strokeWidth:Q,absoluteStrokeWidth:Y,className:W="",children:G,iconNode:q,...H},Z)=>{let{size:z=24,strokeWidth:U=2,absoluteStrokeWidth:B=!1,color:F="currentColor",className:L=""}=jy()??{},D=Y??B?Number(Q??U)*24/Number(J??z):Q??U;return Pz.createElement("svg",{ref:Z,...z2,width:J??z??z2.width,height:J??z??z2.height,stroke:X??F,strokeWidth:D,className:K2("lucide",L,W),...!G&&!by(H)&&{"aria-hidden":"true"},...H},[...q.map(([w,E])=>Pz.createElement(w,E)),...Array.isArray(G)?G:[G]])});var X8=(X,J)=>{let Q=V2.forwardRef(({className:Y,...W},G)=>V2.createElement(yy,{ref:G,iconNode:J,className:K2(`lucide-${Sy(_M(X))}`,`lucide-${X}`,Y),...W}));return Q.displayName=_M(X),Q};var J40=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Rz=X8("a-large-small",J40);var Q40=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]],kz=X8("align-horizontal-justify-center",Q40);var Y40=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]],Iz=X8("align-horizontal-justify-end",Y40);var W40=[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],Tz=X8("align-horizontal-justify-start",W40);var G40=[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]],xH=X8("align-horizontal-space-between",G40);var q40=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Cz=X8("align-vertical-justify-center",q40);var H40=[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]],Sz=X8("align-vertical-justify-end",H40);var Z40=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]],$z=X8("align-vertical-justify-start",Z40);var K40=[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]],bz=X8("baseline",K40);var z40=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],jz=X8("bold",z40);var V40=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],BY=X8("braces",V40);var U40=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],yz=X8("chevron-down",U40);var B40=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],FY=X8("columns-3",B40);var F40=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],fz=X8("diamond",F40);var N40=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],vz=X8("eye-off",N40);var L40=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],zG=X8("eye",L40);var D40=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],xz=X8("italic",D40);var O40=[["path",{d:"M5 12h14",key:"1ays0h"}]],hz=X8("minus",O40);var M40=[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]],gz=X8("move-horizontal",M40);var w40=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],mz=X8("rotate-ccw",w40);var A40=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],VG=X8("rotate-cw",A40);var _40=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],NY=X8("rows-3",_40);var E40=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],uz=X8("scissors",E40);var P40=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],lz=X8("scroll-text",P40);var R40=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],dz=X8("search",R40);var k40=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],pz=X8("spline",k40);var I40=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],LY=X8("square-dashed",I40);var T40=[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]],cz=X8("stretch-horizontal",T40);var C40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],DY=X8("text-align-center",C40);var S40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],OY=X8("text-align-end",S40);var $40=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],MY=X8("text-align-justify",$40);var b40=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],dJ=X8("text-align-start",b40);var j40=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],iz=X8("underline",j40);var y40=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],wY=X8("wand-sparkles",y40);var f40=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],oz=X8("x",f40);var AY=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block",flex:"none"}}),EM=(X)=>X.replace(/^--/,"").replace(/-/g," "),_Y=(X,J,Q)=>{let Y=X;if(J!=null&&Y<J)Y=J;if(Q!=null&&Y>Q)Y=Q;return Y},v40=(X)=>{if(!(X>0))return 2;if(X>=1)return 0;let J=String(X),Q=J.indexOf(".");return Q===-1?0:J.length-Q-1},hH=(X,J)=>{let Q=v40(J);return Number(X.toFixed(Q))};function PM({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:q=1,sides:H}){return(Z)=>{if(Z.button!==0)return;let z=Z.clientX,U=Number.parseFloat(X())||0,B=!1,F=U,L=(E)=>{if(!H)return;if(E.altKey&&E.shiftKey)return H.all;if(E.altKey)return H.pair;return},D=(E)=>{let A=E.clientX-z;if(!B&&Math.abs(A)<3)return;if(!B)B=!0,document.body.classList.add("st-scrubbing");E.preventDefault();let O=H?1:E.shiftKey?10:E.altKey?0.1:1;F=hH(_Y(U+A*Y*q*O,J,Q),Y),W?.(F,L(E))},w=(E)=>{if(document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",w),!B)return;document.body.classList.remove("st-scrubbing"),G?.(F,L(E))};document.addEventListener("pointermove",D),document.addEventListener("pointerup",w)}}function x40({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:q=1,sides:H}){return S6.useCallback(PM({getBase:X,min:J,max:Q,step:Y,onInput:W,onCommit:G,sensitivity:q,sides:H}),[X,J,Q,Y,W,G,q,H])}function UG({value:X,min:J,max:Q,step:Y=1,lead:W,scrub:G=!0,steppers:q=!0,unitSlot:H,sensitivity:Z=1,sides:z,format:U,parse:B,onInput:F,onCommit:L,ariaLabel:D,className:w=""}){let E=S6.useRef(null),A=S6.useCallback((h)=>U?U(h):String(hH(Number(h)||0,Y)),[U,Y]),O=(h)=>(typeof h==="number"?h:Number.parseFloat(h))||0;S6.useEffect(()=>{if(E.current&&document.activeElement!==E.current)E.current.value=A(X)},[X,A]);let P=(h,d)=>{let i=hH(_Y(h,J,Q),Y);if(E.current)E.current.value=A(i);L?.(i,d)},T=x40({getBase:()=>E.current?E.current.value:O(X),min:J,max:Q,step:Y,sensitivity:Z,sides:z,onInput:(h,d)=>{let i=hH(_Y(h,J,Q),Y);if(E.current)E.current.value=A(i);F?.(i,d)},onCommit:P}),C=(h,d)=>P(O(E.current?.value??X)+h*Y*d),S=(h)=>{let d=h.shiftKey?10:1;if(h.key==="ArrowUp")h.preventDefault(),C(1,d);else if(h.key==="ArrowDown")h.preventDefault(),C(-1,d);else if(h.key==="PageUp")h.preventDefault(),C(1,10);else if(h.key==="PageDown")h.preventDefault(),C(-1,10);else if(h.key==="Home"&&J!=null)h.preventDefault(),P(J);else if(h.key==="End"&&Q!=null)h.preventDefault(),P(Q);else if(h.key==="Enter")h.currentTarget.blur()},j=(h)=>{let d=h.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===d)d.select()})},b=(h)=>{let d=String(h.currentTarget.value).trim();if(d==="")return;let i=B?B(d):Number.parseFloat(d);if(i==null||Number.isNaN(i)){h.currentTarget.value=A(X);return}P(i)};return R("div",{className:`st-cp-num ${w}`.trim(),children:[G?K("span",{className:"st-cp-numlead st-cp-handle",role:"presentation","aria-hidden":"true",title:"Drag to change · Shift ×10 · Alt fine",onPointerDown:T,children:W??K("span",{className:"st-cp-grip"})}):W?K("span",{className:"st-cp-numlead","aria-hidden":"true",children:W}):null,K("input",{ref:E,className:"st-cp-numin",role:"spinbutton","aria-label":D,"aria-valuenow":O(X),"aria-valuemin":J,"aria-valuemax":Q,defaultValue:A(X),inputMode:"decimal",onFocus:j,onKeyDown:S,onBlur:b}),q?R("span",{className:"st-cp-step",children:[K("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`increase ${D||"value"}`,onClick:()=>C(1,1),children:"▲"}),K("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`decrease ${D||"value"}`,onClick:()=>C(-1,1),children:"▼"})]}):null,H??null]})}function h40({value:X,min:J=0,max:Q=1,step:Y=0.01,onInput:W,onCommit:G,ariaLabel:q}){let H=S6.useRef(null),Z=_Y(X??(J<0?0:J),J,Q),z=Q-J||1,U=(Z-J)/z,B=J<0&&Q>0?(0-J)/z:0,F=Math.min(U,B),L=Math.abs(U-B),D=(A)=>{let O=H.current?.getBoundingClientRect();if(!O||O.width===0)return Z;let P=_Y((A-O.left)/O.width,0,1);return hH(J+P*z,Y)};return K("div",{className:"st-cp-slider",children:R("div",{ref:H,className:"st-cp-track",role:"slider",tabIndex:0,"aria-label":q,"aria-valuemin":J,"aria-valuemax":Q,"aria-valuenow":Z,onPointerDown:(A)=>{if(A.button!==0)return;A.preventDefault(),H.current?.focus();let O=D(A.clientX);W?.(O);let P=(T)=>{O=D(T.clientX),W?.(O)},I=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",I),G?.(O)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",I)},onKeyDown:(A)=>{let O=A.shiftKey?10:1,P=null;if(A.key==="ArrowRight"||A.key==="ArrowUp")P=Z+Y*O;else if(A.key==="ArrowLeft"||A.key==="ArrowDown")P=Z-Y*O;else if(A.key==="PageUp")P=Z+Y*10;else if(A.key==="PageDown")P=Z-Y*10;else if(A.key==="Home")P=J;else if(A.key==="End")P=Q;if(P!=null)A.preventDefault(),G?.(hH(_Y(P,J,Q),Y))},children:[J<0&&Q>0?K("span",{className:"st-cp-zero",style:{left:`${B*100}%`}}):null,K("span",{className:"st-cp-fill",style:{left:`${F*100}%`,width:`${L*100}%`}}),K("span",{className:"st-cp-thumb",style:{left:`${U*100}%`}})]})})}function m5({value:X,min:J=0,max:Q=1,step:Y=0.01,unit:W="",onInput:G,onCommit:q,ariaLabel:H}){let Z=X??(J<0?0:J);return R("div",{className:"st-cp-sfield",children:[K(h40,{value:Z,min:J,max:Q,step:Y,onInput:G,onCommit:q,ariaLabel:H}),K(UG,{className:"st-cp-num--compact",value:Z,min:J,max:Q,step:Y,scrub:!1,steppers:!1,unitSlot:W?K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null,onInput:G,onCommit:q,ariaLabel:H})]})}function RM({value:X,units:J,onChange:Q,ariaLabel:Y}){return K("select",{className:"st-cp-unitsel","aria-label":Y,value:X,onChange:(W)=>Q(W.target.value),children:J.map((W)=>K("option",{value:W,children:W},W))})}function fy({value:X,options:J,onChange:Q,ariaLabel:Y}){return K("div",{className:"st-cp-seg",role:"radiogroup","aria-label":Y,children:J.map((W)=>{let G=typeof W==="string"?W:W.value,q=typeof W==="string"?W:W.label??W.value;return K("button",{type:"button",role:"radio","aria-checked":X===G,className:`st-cp-segbtn${X===G?" is-active":""}`,onClick:()=>Q(G),children:q},G)})})}function U2({value:X,options:J,onChange:Q,ariaLabel:Y,mini:W=!1}){return K("select",{className:`st-cp-nsel${W?" st-cp-nsel--mini":""}`,"aria-label":Y,value:X,onChange:(G)=>Q(G.target.value),children:J.map((G)=>{let q=typeof G==="string"?G:G.value,H=typeof G==="string"?G:G.label??G.value;return K("option",{value:q,children:H},q)})})}function EY({checked:X,onChange:J,label:Q,ariaLabel:Y}){return R("label",{className:"st-cp-toggle",children:[K("input",{type:"checkbox",className:"st-cp-switch",checked:!!X,"aria-label":Y||Q,onChange:(W)=>J(W.target.checked)}),Q?K("span",{className:"st-cp-toggle-lbl",children:Q}):null]})}function kM({value:X,options:J,ariaLabel:Q,onChange:Y}){return K("div",{className:"st-cp-iconseg",role:"radiogroup","aria-label":Q,children:J.map((W)=>K("button",{type:"button",role:"radio","aria-checked":X===W.value,"aria-label":W.label,title:W.label,className:X===W.value?"is-active":"",onClick:()=>Y(W.value),children:W.node},W.value))})}function vy({value:X,options:J,ariaLabel:Q,onToggle:Y}){return K("div",{className:"st-cp-iconseg",role:"group","aria-label":Q,children:J.map((W)=>K("button",{type:"button","aria-pressed":!!X[W.value],"aria-label":W.label,title:W.label,onClick:()=>Y(W.value),children:W.node},W.value))})}var g40=["tl","tc","tr","cl","cc","cr","bl","bc","br"];function xy({value:X,onChange:J,ariaLabel:Q="alignment"}){return K("div",{className:"st-cp-alignpad",role:"radiogroup","aria-label":Q,children:g40.map((Y)=>K("button",{type:"button",role:"radio","aria-checked":X===Y,"aria-label":`align ${Y}`,className:X===Y?"is-active":"",onClick:()=>J(Y)},Y))})}function hy({value:X,onChange:J,ariaLabel:Q="rotation"}){let Y=S6.useRef(null),W=(Z,z)=>{let U=Y.current?.getBoundingClientRect();if(!U)return X;let B=Math.round(Math.atan2(z-(U.top+U.height/2),Z-(U.left+U.width/2))*180/Math.PI);if(B<0)B+=360;return B},G=(Z)=>{if(Z.button!==0)return;Z.preventDefault(),document.body.classList.add("st-scrubbing","st-scrubbing--dial"),J(W(Z.clientX,Z.clientY));let z=(B)=>J(W(B.clientX,B.clientY)),U=()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",U),document.body.classList.remove("st-scrubbing","st-scrubbing--dial")};document.addEventListener("pointermove",z),document.addEventListener("pointerup",U)},q=X??0,H=(Z)=>{let z=Z.shiftKey?10:1,U=null;if(Z.key==="ArrowRight"||Z.key==="ArrowUp")U=q+z;else if(Z.key==="ArrowLeft"||Z.key==="ArrowDown")U=q-z;else if(Z.key==="PageUp")U=q+15;else if(Z.key==="PageDown")U=q-15;else if(Z.key==="Home")U=0;else if(Z.key==="End")U=360;if(U!=null)Z.preventDefault(),J(_Y(U,0,360))};return K("button",{ref:Y,type:"button",className:"st-cp-dial",role:"slider","aria-label":Q,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":q,"aria-valuetext":`${q}°`,title:"drag to rotate · arrows to nudge",onPointerDown:G,onKeyDown:H,children:K("span",{className:"st-cp-dial-needle",style:{"--angle":`${X}deg`}})})}function gy({title:X,defaultOpen:J=!0,onReset:Q,right:Y,children:W}){let[G,q]=S6.useState(J);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":G,onClick:()=>q((H)=>!H),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:K(AY,{as:yz,size:12})}),X]}),Y??null,Q?K("button",{type:"button",className:"st-cp-secreset","aria-label":`reset ${X} section`,title:`reset ${X}`,onClick:Q,children:K(AY,{as:mz,size:12})}):null]}),K("div",{className:`st-cp-sec-anim${G?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:W})})]})}function B2({swatch:X,displayValue:J,bound:Q,alpha:Y,visible:W,ariaLabel:G,onValue:q,onAlpha:H,onVisible:Z}){return R("span",{className:"st-cp-cf",children:[X,K("input",{className:`st-cp-cf-in${Q?" is-bound":""}`,"aria-label":G,value:J,onChange:(z)=>q?.(z.target.value),onFocus:(z)=>z.currentTarget.select(),readOnly:!q}),H?K("input",{className:"st-cp-cf-alpha","aria-label":`${G||"colour"} alpha`,value:`${Y}`,onChange:(z)=>H(_Y(Number.parseFloat(z.target.value)||0,0,100)),onFocus:(z)=>z.currentTarget.select()}):null,Z?K("button",{type:"button",className:`st-cp-cf-eye${W?"":" is-off"}`,"aria-pressed":W,"aria-label":`${G||"colour"} visibility`,onClick:()=>Z(!W),children:W?K(AY,{as:zG}):K(AY,{as:vz})}):null]})}function my({value:X,tokens:J,ariaLabel:Q,lead:Y,unit:W,unitSlot:G,min:q=0,max:H,step:Z=1,onChange:z}){let[U,B]=S6.useState(!1),[F,L]=S6.useState(""),D=S6.useRef(null),w=typeof X==="string"&&X.startsWith("var("),E=w?X.replace(/^var\(\s*|\s*\)$/g,""):"",A=w?J.find((P)=>P.name===E)?.value??"":"";S6.useEffect(()=>{if(!U){L("");return}let P=(I)=>{if(!D.current?.contains(I.target))B(!1)};return document.addEventListener("pointerdown",P,!0),()=>document.removeEventListener("pointerdown",P,!0)},[U]);let O=F?J.filter((P)=>EM(P.name).includes(F)||(P.value||"").toLowerCase().includes(F)):J;return R("div",{className:"st-cp-tokfield",children:[w?R("div",{className:"st-cp-boundchip",title:`${E} = ${A}`,children:[Y?K("span",{className:"st-cp-boundchip-lead","aria-hidden":"true",children:Y}):null,K("span",{className:"st-cp-boundchip-name",children:EM(E)}),K("button",{type:"button",className:"st-cp-boundchip-x","aria-label":"detach token",title:"detach — back to a raw value",onClick:()=>z(Number.parseFloat(A)||0),children:K(AY,{as:oz,size:12})})]}):K(UG,{value:typeof X==="number"?X:0,min:q,max:H,step:Z,ariaLabel:Q,lead:Y,steppers:!1,unitSlot:G??(W?K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null),onCommit:(P)=>z(P)}),R("span",{ref:D,style:{position:"relative",display:"inline-flex"},children:[K("button",{type:"button",className:`st-cp-tokbtn${w?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":`${Q} — bind a design token`,title:"bind a design token",onClick:()=>B((P)=>!P),children:K(AY,{as:fz,size:13})}),U?R("div",{className:"st-cp-pop",role:"dialog","aria-label":"design tokens",style:{left:"auto",right:0},children:[R("div",{className:"st-cp-pop-search",children:[K(AY,{as:dz,size:12}),K("input",{value:F,onChange:(P)=>L(P.target.value.toLowerCase()),placeholder:"Search variables","aria-label":"search variables"})]}),O.length?O.map((P)=>R("button",{type:"button",className:`st-cp-pop-row${E===P.name?" is-on":""}`,onClick:()=>{z(`var(${P.name})`),B(!1)},children:[K("span",{className:"st-cp-pop-name",children:EM(P.name)}),K("span",{className:"st-cp-pop-val",children:P.value})]},P.name)):K("div",{className:"st-cp-pop-empty",children:"No match"})]}):null]})]})}function uy({corners:X,lead:J,onCorners:Q}){let[Y,W]=S6.useState(!1),G=(H)=>Q({tl:H,tr:H,bl:H,br:H}),q=(H)=>R("label",{className:"st-cp-corner",children:[K("span",{className:`st-cp-cnr st-cp-cnr--${H}`,"aria-hidden":"true"}),K("input",{"aria-label":`${H} radius`,value:X[H],onChange:(Z)=>Q({...X,[H]:Number.parseFloat(Z.target.value)||0}),onFocus:(Z)=>Z.currentTarget.select()})]});return R("div",{className:"st-cp-radius",children:[R("div",{className:"st-cp-radius-main",children:[K(UG,{value:X.tl,min:0,max:200,ariaLabel:"border-radius",lead:J,steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(H)=>Y?Q({...X,tl:H}):G(H)}),K("button",{type:"button",className:`st-cp-splitbtn${Y?" is-on":""}`,"aria-pressed":Y,"aria-label":"detach corners",title:"detach corners — edit each independently",onClick:()=>W((H)=>!H),children:K(AY,{as:LY,size:14})})]}),Y?R("div",{className:"st-cp-corners",children:[q("tl"),q("tr"),q("bl"),q("br")]}):null]})}var O6=R8(x8(),1);var m40=["dots","grid","lines","diagonal","crosshatch"],u40=["normal","multiply","screen","overlay","soft-light"],l40=["none","vignette","radial-reveal","edge-fade"],d40=[{key:"brightness",label:"Brightness",min:-1,max:1},{key:"contrast",label:"Contrast",min:-1,max:1},{key:"saturation",label:"Saturation",min:-1,max:1},{key:"exposure",label:"Exposure",min:-1,max:1},{key:"hue",label:"Hue",min:-180,max:180,step:1,unit:"°"},{key:"sepia",label:"Sepia",min:0,max:1},{key:"grayscale",label:"Grayscale",min:0,max:1},{key:"invert",label:"Invert",min:0,max:1}],ly=(X)=>X?JSON.parse(JSON.stringify(X)):{};function p40(X){let J={};for(let[Q,Y]of Object.entries(X)){if(Y==null)continue;if(typeof Y==="object"&&!Array.isArray(Y)){let W={};for(let[G,q]of Object.entries(Y))if(q!=null&&q!=="")W[G]=q;if(Object.keys(W).length)J[Q]=W}else J[Q]=Y}return J}var PY={body:{fontSize:12,color:"var(--fg-0)",overflowY:"auto"},sec:{marginBottom:"var(--space-4)"},secHead:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,textTransform:"uppercase",letterSpacing:"var(--tracking-wide)",color:"var(--fg-2)",margin:"4px 0 8px"},row:{display:"flex",alignItems:"center",gap:8,margin:"var(--space-2) 0"},label:{flex:"0 0 72px",fontSize:11,color:"var(--fg-1)"},tip:{flex:1,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10,color:"var(--fg-2)",textAlign:"left"},tipBelow:{marginLeft:80,marginTop:2,marginBottom:"var(--space-2)",fontSize:10,color:"var(--fg-2)",lineHeight:1.4},reset:{font:"inherit",fontSize:10,padding:"1px 6px",borderRadius:"var(--radius-xs)",border:"1px solid transparent",background:"transparent",color:"var(--fg-2)",cursor:"pointer"}};function gH({title:X,right:J,onReset:Q,children:Y}){return K(gy,{title:X,right:J,onReset:Q,children:Y})}function uX({label:X,tip:J,children:Q}){return R(Q0,{children:[R("div",{style:PY.row,children:[K("span",{style:PY.label,children:X}),Q]}),J?K("div",{style:PY.tipBelow,children:J}):null]})}function IM({value:X,fallback:J,label:Q,ColorPicker:Y,onApply:W}){let[G,q]=O6.useState(!1),H=O6.useRef(null),Z=X||J;return O6.useEffect(()=>{if(!G)return;let z=(U)=>{if(!H.current?.contains(U.target))q(!1)};return document.addEventListener("pointerdown",z,!0),()=>document.removeEventListener("pointerdown",z,!0)},[G]),K(B2,{swatch:R("span",{className:"st-cp-tokwrap",ref:H,children:[K("button",{type:"button",className:"st-cp-cf-sw",style:{background:Z},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:Z,onClick:()=>q((z)=>!z)}),G?K("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?K(Y,{seed:Z,label:Q,onApply:W}):K("input",{type:"color",value:Z,"aria-label":Q,onChange:(z)=>W(z.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(Z||"").replace("#",""),ariaLabel:Q,onValue:(z)=>W(z.startsWith("#")?z:`#${z.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function dy({asset:X,initialEdit:J,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:q}){let[H,Z]=O6.useState(()=>ly(J)),[z,U]=O6.useState(!J),[B,F]=O6.useState("idle"),[L,D]=O6.useState(!1),[w,E]=O6.useState(""),A=O6.useRef(null),O=O6.useRef(H);O.current=H,O6.useEffect(()=>{if(J||!X)return;let g=!1;return U(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`).then((G0)=>G0.ok?G0.json():{}).then((G0)=>{if(g)return;Z(G0&&typeof G0==="object"?G0:{}),U(!1)}).catch(()=>!g&&U(!1)),()=>{g=!0}},[X,J]);let P=O6.useCallback((g)=>{clearTimeout(A.current),A.current=setTimeout(async()=>{F("saving");try{let G0=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p40(g))});F(G0.ok?"saved":"error")}catch{F("error")}},160)},[X]),I=O6.useCallback((g,{commit:G0=!1}={})=>{let e=O.current,l=ly(e);if(g(l),Z(l),Y?.(l),P(l),G0)G?.(e,l)},[Y,P,G]),T=(g,G0,e)=>I((l)=>{if(l.adjustments=l.adjustments||{},G0===0||G0==null)delete l.adjustments[g];else l.adjustments[g]=G0;if(Object.keys(l.adjustments).length===0)delete l.adjustments},{commit:e}),C=(g,G0,e)=>I((l)=>{l[g]={...l[g]||{},...G0}},{commit:e}),S=()=>I((g)=>delete g.adjustments,{commit:!0}),j=(g)=>I((G0)=>{delete G0[g]},{commit:!0}),b=async()=>{if(!W)return;D(!0),E("Removing background…");try{let g=await W(X);if(g?.maskAsset)C("backgroundRemoved",{enabled:!0,maskAsset:g.maskAsset},!0),E("Background removed");else E("Background removal failed")}catch{E("Background removal failed")}finally{D(!1)}};if(z)return K("div",{style:{...PY.body,opacity:0.6},children:"Loading photo edit…"});let h=H.adjustments||{},d=H.duotone||{},i=H.grain||{},v=H.pattern||{},n=H.mask||{},Y0=H.backgroundRemoved||{};return R("div",{style:PY.body,"data-testid":"photo-knobs",children:[R("div",{style:{...PY.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[K("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:X}),K("span",{style:{fontSize:10,color:B==="error"?"var(--status-error)":void 0},children:B==="saving"?"saving…":B==="error"?"⚠ save failed":B==="saved"?"saved":""})]}),K(gH,{title:"Adjustments",onReset:S,children:d40.map((g)=>K(uX,{label:g.label,children:K(m5,{value:h[g.key],min:g.min,max:g.max,step:g.step??0.01,unit:g.unit??"",ariaLabel:g.label,onInput:(G0)=>T(g.key,G0),onCommit:(G0)=>T(g.key,G0,!0)})},g.key))}),K(gH,{title:"Duotone",right:K(EY,{checked:d.enabled,onChange:(g)=>C("duotone",{enabled:g},!0),label:"on"}),onReset:()=>j("duotone"),children:d.enabled&&R(Q0,{children:[K(uX,{label:"Shadow",children:K(IM,{value:d.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(g)=>C("duotone",{colorA:g},!0)})}),K(uX,{label:"Highlight",children:K(IM,{value:d.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(g)=>C("duotone",{colorB:g},!0)})}),K(uX,{label:"Intensity",children:K(m5,{value:d.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(g)=>C("duotone",{intensity:g}),onCommit:(g)=>C("duotone",{intensity:g},!0)})})]})}),K(gH,{title:"Grain",right:K(EY,{checked:i.enabled,onChange:(g)=>C("grain",{enabled:g},!0),label:"on"}),onReset:()=>j("grain"),children:i.enabled&&R(Q0,{children:[K(uX,{label:"Amount",children:K(m5,{value:i.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(g)=>C("grain",{amount:g}),onCommit:(g)=>C("grain",{amount:g},!0)})}),K(uX,{label:"Size",children:K(m5,{value:i.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(g)=>C("grain",{size:g}),onCommit:(g)=>C("grain",{size:g},!0)})})]})}),K(gH,{title:"Pattern",right:K(EY,{checked:v.enabled,onChange:(g)=>C("pattern",{enabled:g},!0),label:"on"}),onReset:()=>j("pattern"),children:v.enabled&&R(Q0,{children:[K(uX,{label:"Type",children:K(U2,{value:v.type||"dots",options:m40,ariaLabel:"Pattern type",onChange:(g)=>C("pattern",{type:g},!0)})}),K(uX,{label:"Blend",children:K(U2,{value:v.blend||"normal",options:u40,ariaLabel:"Pattern blend",onChange:(g)=>C("pattern",{blend:g},!0)})}),K(uX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:K(IM,{value:v.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(g)=>C("pattern",{color:g},!0)})}),K(uX,{label:"Scale",children:K(m5,{value:v.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(g)=>C("pattern",{scale:g}),onCommit:(g)=>C("pattern",{scale:g},!0)})}),K(uX,{label:"Opacity",children:K(m5,{value:v.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(g)=>C("pattern",{opacity:g}),onCommit:(g)=>C("pattern",{opacity:g},!0)})})]})}),R(gH,{title:"Mask",onReset:()=>j("mask"),children:[K(uX,{label:"Preset",children:K(U2,{value:n.preset||"none",options:l40,ariaLabel:"Mask preset",onChange:(g)=>C("mask",{preset:g},!0)})}),n.preset&&n.preset!=="none"&&K(uX,{label:"Strength",children:K(m5,{value:n.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(g)=>C("mask",{strength:g}),onCommit:(g)=>C("mask",{strength:g},!0)})})]}),R(gH,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[K("div",{style:{...PY.row,gap:10},"aria-busy":L||void 0,children:Y0.maskAsset?R(Q0,{children:[K(EY,{checked:Y0.enabled,onChange:(g)=>C("backgroundRemoved",{enabled:g},!0),label:"applied"}),K("button",{type:"button",style:{...PY.reset,opacity:L?0.6:1},disabled:L||!W,title:"Run background removal again",onClick:()=>b(),children:L?"removing…":"redo"})]}):R("button",{type:"button",className:"st-btn",style:{opacity:L?0.6:1},disabled:L||!W,"data-testid":"photo-remove-bg",onClick:()=>b(),children:[q?K(q,{name:"sparkle",size:14}):null,L?"Removing…":"Remove Background"]})}),K("span",{"aria-live":"polite",className:"sr-only",children:w})]})]})}function mH({name:X,size:J=16}){let Q={cursor:K("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:R(Q0,{children:[K("circle",{cx:"6",cy:"6",r:"2.2"}),K("path",{d:"M2.4 13a3.6 3.6 0 0 1 7.2 0"}),K("path",{d:"M11 4.2a2.2 2.2 0 0 1 0 4.1M11.5 13a3.6 3.6 0 0 0-2-3.2"})]}),comment:K(Q0,{children:K("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:R(Q0,{children:[K("path",{d:"M3 2.5h7.5L13.5 5.5V13.5H3z"}),K("path",{d:"M5 2.5V6h5V2.5"}),K("rect",{x:"5.5",y:"9",width:"5",height:"3"})]}),publish:R(Q0,{children:[K("line",{x1:"8",y1:"13.4",x2:"8",y2:"6"}),K("polyline",{points:"5 9 8 6 11 9"}),K("polyline",{points:"3 4 3 2.6 13 2.6 13 4"})]}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),"arrow-right":R(Q0,{children:[K("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),K("polyline",{points:"9 4 13 8 9 12"})]})}[X];return K("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:X==="cursor"?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function TM({icon:X,label:J,sub:Q}){return R("span",{className:"cm-step",children:[K("span",{className:"cm-step-icon",children:K(mH,{name:X,size:16})}),K("span",{className:"cm-step-label",children:J}),K("span",{className:"cm-step-sub",children:Q})]})}function CM(){return R("div",{className:"cm-info",children:[R("div",{className:"cm-live",children:[R("div",{className:"cm-live-hd",children:[K("span",{className:"cm-live-dot","aria-hidden":"true"}),R("span",{children:[K("b",{children:"Together"})," · automatic — no buttons"]})]}),R("div",{className:"cm-live-items",children:[R("span",{className:"cm-live-item",children:[K(mH,{name:"cursor",size:13})," cursors"]}),R("span",{className:"cm-live-item",children:[K(mH,{name:"people",size:13})," who's here"]}),R("span",{className:"cm-live-item",children:[K(mH,{name:"comment",size:13})," comments"]})]}),K("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),R("div",{className:"cm-bridge","aria-hidden":"true",children:[K("span",{className:"cm-bridge-line"}),K("span",{className:"cm-bridge-label",children:"the work itself"}),K("span",{className:"cm-bridge-line"})]}),R("div",{className:"cm-cycle",children:[K(TM,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),K("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:K(mH,{name:"arrow-right",size:15})}),K(TM,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),K("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:K(mH,{name:"arrow-right",size:15})}),K(TM,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var SM=[{render:CM,title:"Working together, in one picture",body:"There are two layers. Up top, being together just happens. Below, your work moves through three simple steps. Let’s walk them."},{target:"[data-tour='save-local']",changes:!0,title:"Save changes locally",body:"When something looks right, save it. That keeps a version on your computer you can always come back to — like a checkpoint, just for you.",placement:"left"},{target:"[data-tour='publish']",changes:!0,title:"Publish for everyone",body:"Ready to share? Publish sends your saved work to the whole team. Think of it as putting your version on the shared shelf.",placement:"left"},{target:"[data-tour='pull']",changes:!0,title:"Get latest",body:"When teammates publish, Get latest brings their work onto your computer so you’re both looking at the same thing.",placement:"left"},{target:"[data-tour='status']",title:"Being together is automatic",body:"Cursors, who’s here, and comments need no buttons at all. When you’re both in a canvas, you see each other live — that’s the top layer, always on.",placement:"bottom"},{title:"The one thing worth knowing",body:"When you’re here together, publishing already covers your teammate — they’ve seen it live, so Publish is just dropping a bookmark. Only when you work apart can two versions drift. If that happens, Maude shows you both and lets you pick — keep mine, keep theirs, or keep both. Never a confusing merge."}];var p7=R8(x8(),1);function c40(X){if(typeof document>"u"||!X)return null;try{let J=document.querySelector(X);if(!J)return null;let Q=J.getBoundingClientRect();if(Q.width===0&&Q.height===0)return null;return Q}catch{return null}}var BG=320,$M=184;function i40(X){if(typeof window>"u"||!X)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:BG};let{innerWidth:J,innerHeight:Q}=window;if(X.left>BG+36&&J-X.right<BG+36)return{top:Math.min(Math.max(12,X.top),Q-$M-12),left:Math.max(12,X.left-BG-16),width:BG};let G=Q-X.bottom>$M+24?X.bottom+12:Math.max(12,X.top-$M-12),q=Math.min(Math.max(12,X.left),J-BG-12);return{top:G,left:q,width:BG}}function py({steps:X,open:J,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:q}){let[H,Z]=p7.useState(0),[z,U]=p7.useState(null),B=p7.useRef(null),F=p7.useRef(null),L=p7.useRef(null),D=p7.useRef(W);D.current=W;let w=X[H]||null,E=p7.useCallback(()=>{if(!w)return U(null),null;let b=c40(w.target);return U(b),b},[w]);p7.useEffect(()=>{if(J)Z(0)},[J]),p7.useLayoutEffect(()=>{if(!J||!w)return;let b=!1;U(null);try{D.current?.setup?.(w)}catch{}let h=0,d=24,i=()=>{if(b)return;let v=E();if(v||h>=d){if(v){try{document.querySelector(w.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!b)E()})}return}h+=1,L.current=setTimeout(i,130)};return i(),()=>{if(b=!0,L.current)clearTimeout(L.current)}},[J,H,G]),p7.useEffect(()=>{if(!J)return;F.current=document.activeElement;let b=()=>E();return window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0);try{F.current?.focus?.()}catch{}}},[J,E]);let A=H>=X.length-1,O=p7.useCallback(()=>{if(A)Y?.(),Q?.();else Z((b)=>Math.min(b+1,X.length-1))},[A,Y,Q,X.length]),P=p7.useCallback(()=>Z((b)=>Math.max(0,b-1)),[]);if(p7.useEffect(()=>{if(!J)return;function b(h){if(h.key==="Escape")h.preventDefault(),Q?.();else if(h.key==="ArrowRight")h.preventDefault(),O();else if(h.key==="ArrowLeft")h.preventDefault(),P();else if(h.key==="Tab"){let d=B.current;if(!d)return;let i=d.querySelectorAll("button");if(!i.length)return;let v=i[0],n=i[i.length-1];if(h.shiftKey&&document.activeElement===v)h.preventDefault(),n.focus();else if(!h.shiftKey&&document.activeElement===n)h.preventDefault(),v.focus()}}return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[J,O,P,Q]),p7.useEffect(()=>{if(!J)return;let b=setTimeout(()=>{let h=B.current?.querySelector("[data-tour-primary]");try{h?.focus()}catch{}},0);return()=>clearTimeout(b)},[J,H]),!J||!X.length||!w)return null;let I=6,T=z?{top:z.top-I,left:z.left-I,width:z.width+I*2,height:z.height+I*2}:null,C=!!w.requireSelection&&!G,S=(!!w.canvas||!!w.requireSelection)&&q===!1,j=w.render||null;return R("div",{className:"mdcc-tour",role:"presentation",children:[T?K("div",{className:"mdcc-tour__spot",style:T,"aria-hidden":"true"}):K("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),R("div",{className:"mdcc-tour__card"+(j?" mdcc-tour__card--graphic":""),ref:B,role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-tour-title","aria-describedby":"mdcc-tour-body",style:i40(z),children:[R("div",{className:"mdcc-tour__step",children:[H+1," / ",X.length]}),j&&K("div",{className:"mdcc-tour__graphic",children:K(j,{})}),K("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:w.title}),K("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:w.body}),(S||C)&&R("div",{className:"mdcc-tour__hint",role:"status","aria-live":"polite",children:[K("span",{className:"mdcc-tour__hint-dot","aria-hidden":"true"}),S?"Open any canvas from the sidebar to follow along.":"Hold ⌘ and click an element in the canvas — the panel fills in live."]}),R("div",{className:"mdcc-tour__actions",children:[K("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),R("div",{className:"mdcc-tour__nav",children:[H>0&&K("button",{type:"button",className:"mdcc-tour__back",onClick:P,children:"Back"}),K("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:O,children:A?"Done":"Next"})]})]})]})]})}var cy=[{title:"Let's get you set up",body:"Three short steps: a design system for your brand, a first canvas, then your first AI edit. Everything after this happens right here — no terminal."},{target:"[data-tour='sidebar']",title:"Your canvases will live here",body:"Empty for now. Once you have a design system, this fills up with real screens — click any one to open it.",placement:"right"},{target:"[data-testid='assistant-toggle']",title:"Ask the Assistant to build your design system",body:"Open the Assistant and describe your brand — colors, type, the vibe you want. It sets up a real design system for you. Already have one? Say so and it can bring it in.",placement:"left"},{target:"[data-tour='viewport']",title:"Your first canvas appears here",body:"Once the design system is ready, ask for a first screen and watch it land right in this space, ready to edit."},{title:"You're ready",body:"Hold ⌘ and click anything on a canvas to point at it, describe the change in the Assistant, and watch it update live. Restart this tour any time from Help ▸ Quick setup."}];var F2=[{target:"[data-tour='sidebar']",title:"Your canvases live here",body:"Every mock in the project shows up in this tree. Click one to open it in a tab — or use “+ board” to spin up a blank brief-board, no command needed.",placement:"right"},{target:"[data-tour='viewport']",title:"The canvas",body:"Open a canvas, then ⌘-hover to preview the element under your cursor and ⌘-click to select it. Right-click for Copy CSS / Fit / Reset."},{target:"[data-tour='menus']",title:"Menus & tools",body:"View toggles panels (tree, comments, Inspector); Selection and Tools act on the active canvas. Press ? for every shortcut.",placement:"bottom"},{target:"[data-tour='inspector']",inspector:!0,title:"The Inspector",body:"Opened from View → Inspector (or press I). Inspect · Layers · CSS — ⌘-click any element and edit its CSS against your design tokens, right here. No AI round-trip.",placement:"left"},{target:"[data-tour='whatsnew']",title:"What’s new",body:"New features land here. Click the ✦ badge any time to catch up on what shipped — some entries come with a guided tour like this one.",placement:"bottom"},{target:"[data-tour='help']",title:"Help is one key away",body:"Press ? for the full keyboard cheat-sheet — and you can restart this tour from the Help menu whenever you like.",placement:"bottom"}];var V7=R8(x8(),1);var o40={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},n40={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function oy(X){let J=await fetch(`/_api/export-jobs/download?id=${encodeURIComponent(X)}`);if(!J.ok)return null;let Q=J.headers.get("Content-Disposition")||"",Y=/filename="([^"]+)"/.exec(Q)?.[1]||null;return{blob:await J.blob(),filename:Y}}async function iy(X,J){let Q=await oy(X);if(!Q)return;let Y=Q.filename||J||"export",W=URL.createObjectURL(Q.blob),G=document.createElement("a");G.href=W,G.download=Y,document.body.appendChild(G),G.click(),G.remove(),URL.revokeObjectURL(W)}async function r40(X,J){let Q=await oy(X);if(!Q)return null;let Y=Q.filename||J||"export",W=Array.from(new Uint8Array(await Q.blob.arrayBuffer()));return uj(Y,W)}function ny(){let[X,J]=V7.useState(()=>new Map),[Q,Y]=V7.useState(!1),[W,G]=V7.useState([]),[q,H]=V7.useState(()=>new Set),Z=V7.useRef(new Map),z=V7.useRef(new Set),U=V7.useRef(new Set);V7.useEffect(()=>{let C=!0;return fetch("/_api/export-jobs").then((S)=>S.json()).then((S)=>{if(!C)return;let j=new Map;for(let b of Array.isArray(S?.jobs)?S.jobs:[])j.set(b.id,b),Z.current.set(b.id,b.status),U.current.add(b.id);J(j)}).catch(()=>{}),()=>{C=!1}},[]);let B=V7.useCallback((C)=>{if(!C||typeof C.id!=="string")return;J((S)=>{let j=new Map(S);return j.set(C.id,C),j})},[]);V7.useEffect(()=>{let C=Z.current,S=[],j=[];for(let b of X.values()){let h=C.get(b.id),d=b.status==="queued"||b.status==="running",i=b.status==="done"||b.status==="failed";if(h===void 0&&d&&!U.current.has(b.id))U.current.add(b.id),S.push(b.id);else if(h!==b.status&&i)S.push(b.id),j.push(b)}for(let b of X.values())C.set(b.id,b.status);if(S.length)G((b)=>{let h=b.filter((d)=>!S.includes(d));return[...S,...h].slice(0,8)});if(G9()||!j.length)return;for(let b of j){if(b.status!=="done")continue;if(z.current.has(b.id))continue;if(!document.hasFocus())continue;z.current.add(b.id),iy(b.id,b.filename)}},[X]);let F=V7.useMemo(()=>Array.from(X.values()).sort((C,S)=>(S.createdAt||"").localeCompare(C.createdAt||"")),[X]),L=F.filter((C)=>C.status==="running").length,D=F.filter((C)=>C.status==="queued").length,w=V7.useCallback(()=>G((C)=>C.slice(1)),[]),E=V7.useCallback(()=>Y(!0),[]),A=V7.useCallback(()=>Y(!1),[]),O=V7.useCallback(async(C,S)=>{H((j)=>new Set(j).add(C.id));try{await S()}finally{H((j)=>{let b=new Set(j);return b.delete(C.id),b})}},[]),P=V7.useCallback(async(C)=>{z.current.add(C.id),await O(C,()=>iy(C.id,C.filename))},[O]),I=V7.useCallback(async(C)=>{z.current.add(C.id),await O(C,()=>r40(C.id,C.filename))},[O]),T=Q?null:W[0]??null;return{jobs:F,upsert:B,runningCount:L,queuedCount:D,busyCount:L+D,panelOpen:Q,openPanel:E,closePanel:A,showToast:!!T,toastJob:T?X.get(T)??null:null,dismissToast:w,download:P,save:I,savingIds:q}}function ry(X){let J=o40[X.format]||String(X.format||"").toUpperCase(),Q=n40[X.scope]||X.scope;return`${J} · ${Q}`}function ay(X){if(G9())return X?"Saving…":"Save…";return X?"Downloading…":"Download"}function sy({progress:X}){if(!X||!X.total)return K("div",{className:"st-export-progress st-export-progress--indeterminate","aria-hidden":"true"});let J=Math.max(0,Math.min(100,Math.round(X.current/X.total*100)));return K("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":J,"aria-valuemin":0,"aria-valuemax":100,children:K("div",{className:"st-export-progress-bar",style:{width:`${J}%`}})})}var bM=new Map;function a40(X){let J=X.progress?.current,Q=X.progress?.total;if(!J||!Q||J>=Q)return bM.delete(X.id),null;let Y=bM.get(X.id);if(!Y||J<Y.c)Y={t:Date.now(),c:J},bM.set(X.id,Y);let W=J-Y.c;if(W<3)return null;let G=(Date.now()-Y.t)/W*(Q-J);if(G<45000)return"<1 min left";return`~${Math.round(G/60000)} min left`}function s40({job:X}){let J=X.status==="queued"?"Queued":X.status==="running"?X.progress?.total?`${X.progress.current} of ${X.progress.total}`:"Rendering…":X.status==="done"?"Ready":"Failed",Q=X.status==="running"?a40(X):null;return R("span",{className:`st-export-pill st-export-pill--${X.status}`,children:[J,Q?` · ${Q}`:""]})}function ty({center:X}){let J=X.busyCount>0;return R("button",{type:"button",className:"st-exports","data-tour":"exports","data-busy":J?"true":"false","aria-label":J?`Exports — ${X.busyCount} running`:"Exports","data-tip":"Exports",onClick:X.openPanel,children:[K("span",{"aria-hidden":"true",children:"⬇"}),J&&K("span",{className:"st-exports__count","aria-hidden":"true",children:X.busyCount})]})}function ey({center:X}){if(!X.showToast||!X.toastJob)return null;let J=X.toastJob,Q=J.status==="queued"||J.status==="running",Y=J.status==="done",W=X.savingIds.has(J.id),G=()=>{if(G9())X.save(J);else X.download(J)};return R("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),R("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:Q?"⋯":Y?"⬇":"⚠"}),Q?"Exporting…":Y?"Export ready":"Export failed"]}),K("div",{className:"st-toast-title",children:ry(J)}),Q?R(Q0,{children:[K("div",{className:"st-toast-txt",children:"Running in the background — you can keep working."}),K(sy,{progress:J.progress})]}):K("div",{className:"st-toast-txt",children:Y?J.filename??"Ready to download.":J.error??"Something went wrong."}),Y&&R("div",{className:"st-toast-actions",children:[R("button",{type:"button",className:"btn btn--primary btn--sm",onClick:G,disabled:W,children:[W&&K("span",{className:"st-btn-spin","aria-hidden":"true"}),ay(W)]}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Xf({center:X}){let{panelOpen:J,closePanel:Q}=X;if(V7.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")Q()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,Q]),!J)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)Q()},children:R("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"st-export-panel-title",children:"Exports"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Q,children:"×"})]}),K("div",{className:"st-export-panel__body",children:X.jobs.length===0?K("p",{className:"mdcc-wn-empty",children:"No exports yet."}):K("ul",{className:"st-export-list",children:X.jobs.map((Y)=>R("li",{className:"st-export-item",children:[R("div",{className:"st-export-item__hd",children:[K("span",{className:"st-export-item__label",children:ry(Y)}),K(s40,{job:Y})]}),(Y.status==="queued"||Y.status==="running")&&K(sy,{progress:Y.progress}),Y.status==="done"&&R("div",{className:"st-export-item__ft",children:[K("span",{className:"st-export-item__filename",children:Y.filename}),R("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:X.savingIds.has(Y.id),onClick:()=>G9()?X.save(Y):X.download(Y),children:[X.savingIds.has(Y.id)&&K("span",{className:"st-btn-spin","aria-hidden":"true"}),ay(X.savingIds.has(Y.id))]})]}),Y.status==="failed"&&K("div",{className:"st-export-item__ft",children:K("span",{className:"st-export-item__error",children:Y.error??"Export failed."})})]},Y.id))})})]})})}var BX=R8(x8(),1);function Jf(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 Qf(X,J){let Q=Jf(X),Y=Jf(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 Yf(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Qf(Q.version,J)))}function Wf(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Qf(Y.version,Q))Q=Y.version}return Q}var jM="mdcc-whatsnew-seen",yM="mdcc-whatsnew-toast-dismissed";function t40(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function e40(X){try{let J=localStorage.getItem(jM);if(J)return J;localStorage.setItem(jM,X)}catch{}return X}function XY0(){try{return localStorage.getItem(yM)}catch{return null}}function Gf(X){let[J,Q]=BX.useState([]),[Y,W]=BX.useState(X),[G,q]=BX.useState(()=>e40(X)),[H,Z]=BX.useState(()=>XY0()),[z,U]=BX.useState(!1);BX.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then((C)=>C.json()).then((C)=>{if(O)return;if(Q(Array.isArray(C?.entries)?C.entries:[]),typeof C?.version==="string")W(C.version)}).catch(()=>{})};P();let I=()=>P(),T=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",T),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",T)}},[]);let B=Yf(J,G),F=B.length>0&&H!==Y&&!z,L=B[0]??null,D=BX.useCallback(()=>{let O=Wf(J,Y);q(O),Z(Y);try{localStorage.setItem(jM,O),localStorage.setItem(yM,Y)}catch{}},[J,Y]),w=BX.useCallback(()=>{Z(Y);try{localStorage.setItem(yM,Y)}catch{}},[Y]),E=BX.useCallback(()=>U(!0),[]),A=BX.useCallback(()=>{U(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:z,openPanel:E,closePanel:A,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:D}}function qf({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return R("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),R("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),R("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Hf({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(BX.useEffect(()=>{if(!Q)return;function G(q){if(q.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:R("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>R("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[R("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),t40(G.learnMore)&&K("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var E9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ma="mdcc-usage-tour-seen",wa="mdcc-collab-tour-seen",h8="__system__",ra="mdcc-theme",Aa="mdcc-show-hidden",_a="mdcc-sections-expanded",Ea="maude-cp-mode",Pa="mdcc-sidebar-open",Ra="mdcc-minimap-visible",ka="mdcc-zoomctl-visible",Ia="mdcc-annotations-visible";function KK0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var kE=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],qZ={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},Ta="mdcc-panel-sides",Ca="mdcc-layers-mode";function Sa({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:q}){return R("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(kE.find((Z)=>Z.id===H)||{}).label||H},H))}),q]})}var cQ=/\.(tsx|html?)$/i,CE="0.45.1";function zK0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(ra);if(X==="light"||X==="dark")return X}catch{}return"dark"}function dG(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 wE(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function VK0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function _B(X){return X.split("/").pop()}function g7(X,J=!1){if(typeof document>"u")return;let Q=document.getElementById("st-op-toast");if(!Q)Q=document.createElement("div"),Q.id="st-op-toast",Q.setAttribute("role","status"),Q.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;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(Q);Q.style.background=J?"#1d3524":"#3a1d1d",Q.style.color=J?"#b7e4c0":"#f1b8b8",Q.textContent=X,Q.style.opacity="1",clearTimeout(g7._t),g7._t=setTimeout(()=>{Q.style.opacity="0"},3200)}function KZ(X){return X.replace(cQ,"")}function UK0(X){return X.replace(cQ,"")}function BK0(X){let J=new Map;for(let G of X){if(!cQ.test(G.name))continue;let q=UK0(G.name);if(!J.has(q)||/\.tsx$/i.test(G.name))J.set(q,G)}let Q=new Map,Y=[];for(let G of X){if(cQ.test(G.name))continue;let q=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!q||H.length>q.length)q=H}}if(q){let H=Q.get(q)||[];H.push(G),Q.set(q,H)}else Y.push(G)}let W=[];for(let[G,q]of J){let H=(Q.get(G)||[]).sort((Z,z)=>Z.name.localeCompare(z.name));W.push({primary:q,sidecars:H,orphan:!1})}return W.sort((G,q)=>G.primary.name.localeCompare(q.primary.name)),Y.sort((G,q)=>G.name.localeCompare(q.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function FK0(X,J){let Q={};for(let Y of X){let G=(Y.startsWith(J)?Y.slice(J.length).replace(/^\/+/,""):Y).split("/"),q=Q;for(let H=0;H<G.length;H++){let Z=G[H];if(H===G.length-1)q._files=q._files||[],q._files.push({name:Z,path:Y});else q[Z]=q[Z]||{},q=q[Z]}}return Q}function aa(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((q)=>q!=="_files");for(let q of G){let H=aa(X[q],J);if(H)Y[q]=H,W=!0}if(X._files){let q=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(q.length)Y._files=q,W=!0}return W?Y:null}function $a(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function NK0(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 sa(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 LK0({d:X,size:J=14,color:Q}){return K("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:K("path",{d:X})})}var DK0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:R(Q0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),search:R(Q0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:R(Q0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:R(Q0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:R(Q0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:R(Q0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:R(Q0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:R(Q0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:R(Q0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:R(Q0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:R(Q0,{children:[K("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),K("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:R(Q0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:R(Q0,{children:[K("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:R(Q0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":R(Q0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":R(Q0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":R(Q0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":R(Q0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":R(Q0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":R(Q0,{children:[K("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:R(Q0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:R(Q0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:R(Q0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:R(Q0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:R(Q0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:R(Q0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:R(Q0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:R(Q0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:R(Q0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:R(Q0,{children:[K("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function OK0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,q]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),q(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let Z=u.useMemo(()=>{let U=Y.trim().toLowerCase();if(!U)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(U)||B.group&&B.group.toLowerCase().includes(U))},[Y,Q]);if(u.useEffect(()=>{if(G>=Z.length)q(0)},[Z.length,G]),!X)return null;let z=(U)=>{J(),U.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(U)=>{if(U.target===U.currentTarget)J()},children:R("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[R("div",{className:"st-pal-search",children:[K(n8,{name:"search",size:18}),K("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(U)=>W(U.target.value),onKeyDown:(U)=>{if(U.key==="Escape")U.preventDefault(),J();else if(U.key==="ArrowDown")U.preventDefault(),q((B)=>Math.min(Z.length-1,B+1));else if(U.key==="ArrowUp")U.preventDefault(),q((B)=>Math.max(0,B-1));else if(U.key==="Enter"){if(U.preventDefault(),Z[G])z(Z[G])}}}),K(s6,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:Z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):Z.map((U,B)=>{let F=U.group&&(B===0||Z[B-1].group!==U.group)?K("div",{className:"st-pal-group",children:U.group},"g-"+U.group):null;return R(Q0,{children:[F,R("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>q(B),onClick:()=>z(U),children:[K("span",{className:"st-pal-icon",children:K(n8,{name:U.icon,size:15})}),K("span",{className:"st-pal-label",children:U.label}),U.kbd?K("span",{className:"st-pal-kbd",children:K(s6,{children:U.kbd})}):null]})]},U.id)})})]})})}function n8({name:X,size:J=16,className:Q}){return K("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:DK0[X]})}function MK0(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 ba({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function s6({children:X}){return K("span",{className:"kbd",children:X})}function ja(X,{min:J,max:Q,def:Y}){let W=u.useCallback((Z)=>Math.min(Q,Math.max(J,Z)),[J,Q]),[G,q]=u.useState(()=>{try{let Z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(Z)?W(Z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((Z)=>q((z)=>W(typeof Z==="function"?Z(z):Z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ya({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:q,min:H,max:Z,def:z}=J,U=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":Z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>q(z),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),q((L)=>L+F*U);else if(B.key==="ArrowLeft")B.preventDefault(),q((L)=>L-F*U);else if(B.key==="Home")B.preventDefault(),q(H);else if(B.key==="End")B.preventDefault(),q(Z)},children:R("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var AE=[{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}],_E={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},wK0={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},AK0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],_K0={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 EK0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return _K0[J]||"application/octet-stream"}function PK0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[q,H]=u.useState(null),[Z,z]=u.useState(!1),[U,B]=u.useState(null),[F,L]=u.useState(()=>new Set),[D,w]=u.useState({}),[E,A]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let v=!0;return fetch("/_api/assets").then((n)=>n.json()).then((n)=>{if(!v)return;let Y0=n.ok?n.assets:[];H(Y0),w((g)=>{let G0={...g};for(let e of Y0)G0[e.path]=e.kind;return G0})}).catch(()=>v&&H([])),()=>{v=!1}},[]),u.useEffect(()=>{let v=(n)=>{if(n.key==="Escape")n.stopPropagation(),Q()};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[Q]);let O=Array.from(F).some((v)=>(D[v]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&E==="artboard")A("annotation")},[P,E]);let T=(v)=>{L((n)=>{let Y0=new Set(n);if(Y0.has(v))Y0.delete(v);else Y0.add(v);return Y0})},C=async(v)=>{let n=await fetch("/_api/asset",{method:"POST",headers:{"content-type":v.type||"application/octet-stream"},body:v}),Y0=await n.json().catch(()=>({}));if(n.ok&&Y0.path)return{ok:!0,path:Y0.path};return{ok:!1,error:Y0.error||`upload failed (HTTP ${n.status})`}},S=async(v)=>{if(!v)return;z(!0),B(null);let n=await C(v);if(z(!1),n.ok)J(n.path);else B(n.error)},j=(v)=>{if(typeof v==="string"&&v.startsWith("video/"))return"video";if(typeof v==="string"&&v.startsWith("audio/"))return"audio";return"image"},b=async(v)=>{if(!v.length)return;z(!0),B(null);let n=await Promise.all(v.map((G0)=>C(G0).then((e)=>({...e,file:G0}))));z(!1);let Y0=n.filter((G0)=>G0.ok),g=n.length-Y0.length;if(g>0)B(`${g} of ${n.length} uploads failed`);if(Y0.length)w((G0)=>{let e={...G0};for(let l of Y0)e[l.path]=j(l.file.type);return e}),L((G0)=>{let e=new Set(G0);for(let l of Y0)e.add(l.path);return e})},h=async()=>{z(!0),B(null);try{if(Y){let Y0=(await lj()||[]).map((g)=>new File([new Uint8Array(g.bytes)],g.name,{type:EK0(g.name)}));if(z(!1),Y0.length)await b(Y0);return}let v=await a3();if(v?.bytes){await S(new Blob([new Uint8Array(v.bytes)]));return}}catch(v){B(v?.message||"open failed")}z(!1)},d=()=>{if(G9()){h();return}let v=document.createElement("input");if(v.type="file",v.accept="image/*,video/*",Y)v.multiple=!0;v.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(v);let n=()=>{if(v.isConnected)v.remove()};window.addEventListener("focus",()=>setTimeout(n,300),{once:!0}),v.addEventListener("change",()=>{let Y0=v.files?Array.from(v.files):[];if(n(),!Y0.length)return;if(Y)b(Y0);else S(Y0[0])}),v.click()},i=(v)=>`/${X}/${v}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(v)=>{if(v.target===v.currentTarget)Q()},children:R("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(n8,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[R("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:d,disabled:Z,children:Z?"Uploading…":"Upload…"}),U&&K("span",{className:"st-ap-err",children:U})]}),K("div",{className:"st-ap-grid",children:q==null?K("div",{className:"st-ap-empty",children:"Loading…"}):q.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):q.map((v)=>{let n=Y&&F.has(v.path);return R("button",{type:"button",className:"st-ap-cell","data-selected":n?"true":void 0,"aria-pressed":Y?n:void 0,title:`${v.name} · ${Math.max(1,Math.round(v.size/1024))} KB`,onClick:()=>Y?T(v.path):J(v.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:n?K(n8,{name:"check",size:12}):null}),v.kind==="video"?K("video",{className:"st-ap-thumb",src:i(v.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:i(v.path),alt:v.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:v.name})]},v.path)})})]}),Y&&F.size>0&&R("div",{className:"st-dialog-ft st-ap-confirm",children:[R("span",{className:"st-ap-count",children:[F.size," selected"]}),R("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:P,onClick:()=>A("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>A("annotation"),children:"Add as annotation"})]}),P&&K("span",{className:"st-ap-dest-note",children:I}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),E),children:"Insert"})]})]})})}function RK0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:q}){let[H,Z]=u.useState(X==="handoff"?"shadcn":"png"),[z,U]=u.useState(J&&_E[J]?J:"artboard"),[B,F]=u.useState(2),[L,D]=u.useState(!0),[w,E]=u.useState(!1),[A,O]=u.useState(null),[P,I]=u.useState([]),T=AE.find((b)=>b.id===H)||AE[0],C=T.handoff?[]:wK0[T.format]||["artboard"];u.useEffect(()=>{if(C.length&&!C.includes(z))U(C[0])},[C,z]);let S=u.useCallback(()=>{fetch("/_api/export-history").then((b)=>b.json()).then((b)=>I(Array.isArray(b?.history)?b.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{S()},[S]),u.useEffect(()=>{function b(h){if(h.key==="Escape")h.preventDefault(),q()}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[q]);async function j(){if(T.handoff){let d=`/design:handoff ${Q&&Q!==h8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(d)}catch{}O({ok:!0,msg:`Copied: ${d} — run it in Claude Code.`});return}E(!0),O(null);let b=T.format==="png"||T.temporal?{scale:B}:{};if(T.format==="mp4"||T.format==="webm")b.audio=L;if(W)b.artboardId=W;if(G?.selector)b.selection=G;try{let h=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:T.format,scope:z,options:b})});if(!h.ok){O({ok:!1,msg:await h.text()||`Export failed (${h.status})`}),E(!1);return}q()}catch(h){O({ok:!1,msg:h&&h.message?h.message:String(h)}),E(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)q()},children:R("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[R("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:q,children:K(n8,{name:"x",size:15})})]}),R("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==h8?`Format · ${KZ(_B(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:AE.filter((b)=>!b.temporal||Y).map((b)=>R("button",{type:"button",className:"st-fmt"+(b.id===H?" is-on":""),onClick:()=>{Z(b.id),O(null)},children:[K(n8,{name:b.icon,size:16}),K("span",{className:"st-fmt-name",children:b.label}),K("span",{className:"st-fmt-sub",children:b.sub})]},b.id))}),!T.handoff&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:z,onChange:(b)=>U(b.target.value),children:C.map((b)=>K("option",{value:b,children:_E[b]},b))})]}),!T.handoff&&(T.format==="png"||T.temporal)&&R("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:T.temporal?"Resolution":"Size"}),K("select",{id:"st-export-size",className:"st-select",value:B,onChange:(b)=>F(Number(b.target.value)),children:AK0.map((b)=>K("option",{value:b.value,children:b.label},b.value))})]}),!T.handoff&&T.format==="png"&&R("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Resolution multiplier — ",B,"× ≈ ",1440*B,"×",900*B," for a 1440×900 artboard."]}),!T.handoff&&T.temporal&&R("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!T.handoff&&(T.format==="mp4"||T.format==="webm")&&K("div",{className:"st-dialog-row",children:R("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:L,onChange:(b)=>D(b.target.checked)}),"Export with audio"]})}),T.handoff&&R("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),A&&K("div",{className:"callout "+(A.ok?"callout--success":"callout--error"),style:{fontSize:12},children:A.msg}),P.length>0&&R("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),P.map((b,h)=>R("div",{className:"st-export-recent-row",children:[R("span",{children:[String(b.format||"").toUpperCase()," ·"," ",_E[b.scope]||b.scope]}),K("span",{className:"st-mono",children:b.filename})]},h))]})]}),R("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:q,children:"Cancel"}),R("button",{type:"button",className:"btn btn--primary",disabled:w,onClick:j,children:[K(n8,{name:"download",size:14}),T.handoff?"Copy handoff command":w?"Exporting…":`Export ${T.label}`]})]})]})})}var EB=12,PB=16;function kK0({name:X,depth:J,defaultOpen:Q,children:Y}){let[W,G]=u.useState(Q);return R(Q0,{children:[R("button",{type:"button",role:"treeitem","aria-expanded":W,tabIndex:-1,className:"st-row",style:{paddingLeft:EB+J*PB+"px"},onClick:()=>G((q)=>!q),children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"chevron-right",className:"st-chev"+(W?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]}),W&&Y]})}function IK0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:q}){let[H,Z]=u.useState(Y);return R(Q0,{children:[R("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:EB+Q*PB+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>Z((z)=>!z),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(n8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),R("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&q]})}function IE({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:q,sidecar:H,dirty:Z,experimentalKind:z}){let U=X.path===J,B=cQ.test(X.name),F=!B,L=B?KZ(X.name):X.name,D=B&&typeof Y==="function"&&q!=="runtime",w=B?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(cQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,E=R("button",{type:"button",role:"treeitem","data-testid":w,"aria-selected":U,"aria-disabled":F?"true":void 0,tabIndex:U?0:-1,className:"st-row"+(U?" is-sel":"")+(q==="runtime"?" is-muted":""),style:{paddingLeft:EB+G*PB+"px"},title:X.path+(W?` — ${W} open`:F?" (file index only)":""),onClick:()=>{if(!F)Q(X.path)},children:[K("span",{className:"st-row-glyph",children:K(n8,{name:"file",size:13})}),K("span",{className:"st-row-name",children:L}),z==="reconstructed-experimental"&&K("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),Z&&K("span",{className:"st-git-badge","data-kind":Z,title:`Unsaved (${Z})`,"aria-label":`Unsaved, ${Z}`,children:Z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!D)return E;return R("div",{className:"st-row-wrap",role:"none",children:[E,K("button",{type:"button",className:"st-row-del",title:`Delete ${L}`,"aria-label":`Delete canvas ${L}`,onClick:(A)=>{A.stopPropagation(),Y(X.path,L)},children:K(LK0,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function TK0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:q,openCount:H,showHidden:Z,forceOpen:z,dirtyByPath:U,experimentalKind:B}){let F=U?.get(X.path),L=J.length>0,[D,w]=u.useState(!1),E=z||D,A=X.path===W;if(!(L&&Z))return K(IE,{file:X,activePath:W,onOpen:G,onDelete:q,openCount:H,depth:Q,kind:Y,dirty:F,experimentalKind:B});return R(Q0,{children:[R("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":E,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":""),style:{paddingLeft:EB+Q*PB+"px"},title:X.path,onClick:(P)=>{if(P.target.closest(".st-canvas-chev")){w((I)=>!I);return}G(X.path)},children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(P)=>{P.stopPropagation(),w((I)=>!I)},children:K(n8,{name:"chevron-right",className:"st-chev"+(E?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:KZ(X.name)}),B==="reconstructed-experimental"&&K("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F&&K("span",{className:"st-git-badge","data-kind":F,title:`Unsaved (${F})`,"aria-label":`Unsaved, ${F}`,children:F}),H>0&&K("span",{className:"st-row-badge",children:H})]}),E&&J.map((P)=>K(IE,{file:P,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},P.path))]})}function ta({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:q,search:H,dsFolders:Z,activeDsName:z,onOpenSystem:U,onDelete:B,dirtyByPath:F,canvasKinds:L}){let D=Object.keys(X).filter((I)=>I!=="_files").sort(),w=X._files||[],{canvases:E,orphans:A}=u.useMemo(()=>BK0(w),[w]),O=!!(H&&H.trim()),P=u.useMemo(()=>{if(!Z||W!==1)return null;let I=new Map;for(let T of Z)I.set(T.folder,T);return I},[Z,W]);return R(Q0,{children:[E.map((I)=>{let T=O&&I.sidecars.some((C)=>{let S=H.toLowerCase();return C.name.toLowerCase().includes(S)||C.path.toLowerCase().includes(S)});return K(TK0,{primary:I.primary,sidecars:I.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:$a(Y[I.primary.path]),depth:W,kind:G,showHidden:q,forceOpen:T,dirtyByPath:F,experimentalKind:L?.[I.primary.path]},I.primary.path)}),q&&A.map((I)=>K(IE,{file:I.primary,activePath:J,onOpen:Q,openCount:$a(Y[I.primary.path]),depth:W,kind:G},I.primary.path)),D.map((I)=>{let T=P?.get(I),C=K(ta,{node:X[I],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:q,search:H,activeDsName:z,onOpenSystem:U,onDelete:B,dirtyByPath:F,canvasKinds:L});if(T&&U)return K(IK0,{name:I,dsName:T.name,depth:W,defaultOpen:!0,active:J===h8&&T.name===z,onOpenSystem:U,children:C},I);return K(kK0,{name:I,depth:W,defaultOpen:!0,children:C},I)})]})}var wB={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function CK0(X){if(X.kind==="project")return wB.project;if(X.kind==="runtime")return wB.runtime;if(X.label==="Design system")return wB.ds;if(X.label==="UI kit")return wB.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function SK0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:q,setSearch:H,commentsByFile:Z,showHidden:z,sectionsExpanded:U,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:D,refreshing:w,collapsed:E,onCollapse:A,width:O,resizing:P,dirtyByPath:I,project:T,gitBranch:C,remoteSync:S,onGetLatest:j,canvasKinds:b}){let h=u.useMemo(()=>{if(!q)return X;return X.map((a)=>({...a,tree:aa(a.tree,q),filtered:!!q}))},[X,q]),[d,i]=u.useState(!1),[v,n]=u.useState(""),[Y0,g]=u.useState(""),[G0,e]=u.useState(!1),l=u.useCallback(async()=>{let a=v.trim();if(!a||G0)return;e(!0),g("");let c=await F(a);if(e(!1),c?.ok)i(!1),n("");else g(c?.error||"could not create board")},[v,G0,F]),Z0=u.useMemo(()=>{let a=0;for(let c of X)for(let V0 of c.paths||[])if(cQ.test(V0))a++;return a},[X]),r=u.useMemo(()=>{let a=0;for(let c of h)for(let V0 of c.paths||[])if(cQ.test(V0))a++;return a},[h]);return R("nav",{className:"st-sidebar"+(E?" is-collapsed":"")+(P?" is-resizing":""),style:E||!O?void 0:{width:O,flexBasis:O},"aria-label":"Files","data-tour":"sidebar",children:[R("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),R("div",{className:"st-sb-hd-actions",children:[K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":d,onClick:()=>{g(""),i((a)=>!a)},children:K(n8,{name:"plus",size:15})}),D&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>D(),children:K(n8,{name:"reload",size:15})}),R("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),r," / ",Z0]}),A&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:A,children:K(n8,{name:"panel-left",size:15})})]})]}),d?R("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:"brief board name…",value:v,maxLength:60,disabled:G0,"aria-label":"New brief board name",onChange:(a)=>n(a.target.value),onKeyDown:(a)=>{if(a.key==="Enter")a.preventDefault(),l();else if(a.key==="Escape")a.preventDefault(),i(!1),n(""),g("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:G0||!v.trim(),"data-tip":"Create · Enter","aria-label":"Create brief board",onClick:l,children:G0?"…":"↵"})]}):null,Y0?K("div",{className:"st-newboard-err",role:"alert",children:Y0}):null,K("div",{className:"st-search",children:R("div",{className:"st-search-box",children:[K(n8,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:q,onChange:(a)=>H(a.target.value),onKeyDown:(a)=>{if(a.key==="Escape")if(a.preventDefault(),q)H("");else a.currentTarget.blur()},"aria-label":"Filter files"}),q?K("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(s6,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:h.map((a)=>{if(!z&&!q&&a.kind==="runtime")return null;let c=CK0(a),V0=(a.paths||[]).filter((v8)=>cQ.test(v8)).length,o0=c.pill||(c.pillFromDsCount?String(a.dsFolders?.length||0):null)||(c.pillFromCount?String(V0||a.paths?.length||0):null),U8=a.tree&&Object.keys(a.tree).length>0,V8=a.label==="Design system",L0=a.kind==="project";if(!z&&!q&&L0&&V0===0)return null;let t0=VK0(a),n0=U[a.label],Q8=!!q||(n0===void 0?t0:n0);return R("div",{className:"st-tree-section",children:[R("button",{type:"button",className:"st-tree-sec-hd",onClick:()=>B(a.label,t0),"aria-expanded":Q8,title:Q8?"Collapse section":"Expand section",children:[K(n8,{name:"chevron-right",className:"st-chev"+(Q8?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:c.title}),o0&&K("span",{className:"st-pill",children:o0})]}),Q8&&(U8?K(ta,{node:a.tree,activePath:J,onOpen:Y,commentsByFile:Z,depth:1,kind:a.kind,showHidden:z,search:q,dsFolders:a.dsFolders,activeDsName:Q,onOpenSystem:V8?W:void 0,onDelete:V8?void 0:L,dirtyByPath:I,canvasKinds:b}):K("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},a.label)})}),K(MM,{project:T,liveBranch:C,remoteSync:S,onGetLatest:j}),K(qM,{})]})}function $K0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:R("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(n8,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(n8,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(n8,{name:"folder",size:15})})]})})}function bK0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:R("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[R("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),R("span",{className:"sku",children:["MAUDE-DEV-SRV / v",CE]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),R("div",{className:"help-modal-body",children:[R("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),R("ul",{children:[R("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),R("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),R("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),R("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),R("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),R("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),R("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),R("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),R("details",{children:[K("summary",{children:"Annotation tools"}),R("ul",{children:[R("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),R("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),R("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),R("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),R("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),R("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),R("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),R("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),R("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),R("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),R("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),R("details",{children:[K("summary",{children:"Canvas & panels"}),R("ul",{children:[R("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),R("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),R("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),R("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),R("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),R("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),R("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),R("details",{children:[K("summary",{children:"Slash commands"}),R("ul",{className:"cmds",children:[R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),R("li",{children:[R("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),R("li",{children:[R("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),R("li",{children:[R("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),R("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),R("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),R("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),R("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),R("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),R("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),R("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),R("details",{children:[K("summary",{children:"Opt-out scope"}),R("ul",{children:[R("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),R("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),R("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),R("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),R("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),R("details",{children:[K("summary",{children:"Auto-critic loop"}),R("ul",{children:[R("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),R("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),R("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),R("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),R("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),R("li",{children:["When ",K("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),R("details",{children:[K("summary",{children:"Pin-to-element flow"}),R("ol",{children:[K("li",{children:"Open a canvas"}),R("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),R("li",{children:["Run"," ",R("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),R("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),R("details",{children:[K("summary",{children:"Comments"}),R("ol",{children:[R("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),R("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),R("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),R("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var EE=[{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 jK0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,q)=>K(s6,{children:G},`${G}-${q}`))},W);return R("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>R(Q0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function yK0({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=EE.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:R("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[R("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),R("span",{className:"so-trigger",children:["press ",K(s6,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:EE.map((Y)=>R("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>R("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(jK0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),R("div",{className:"so-overlay-ft",children:[R("span",{children:["close with ",K(s6,{children:"Esc"})]}),R("span",{className:"so-count",children:[Q," bindings · ",EE.length," groups"]})]})]})})}var fK0=["File","Edit","View","Selection","Tools","Help"];function ea(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 vK0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return ea(Q),R("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>R("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(n8,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(s6,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>R("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(s6,{children:G.shortcut})]},G.label))]})}function sV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return ea(G),R("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((q,H)=>q.sep?K("div",{className:"st-dd-sep"},"s"+H):R("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":q.disabled?"true":void 0,onClick:()=>{if(q.disabled)return;W(q.id),G()},children:[R("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:q.label})]}),q.shortcut?K(s6,{children:q.shortcut}):null]},q.id))]})}function xK0({onAction:X,onClose:J}){return K(sV,{label:"Help",left:320,onAction:X,onClose:J,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function hK0({onAction:X,onClose:J}){return K(sV,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]})}function gK0({onAction:X,onClose:J}){return K(sV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"move",label:"Move",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]})}function mK0({onAction:X,onClose:J,hasCanvas:Q}){return K(sV,{label:"File",left:40,onAction:X,onClose:J,items:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function uK0({onAction:X,onClose:J,hasCanvas:Q}){return K(sV,{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"}]:[]]})}function lK0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:q,changesOpen:H,changesCount:Z,onToggleChanges:z,onOpenSystem:U,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:D,onOpenHelp:w,onOpenShortcuts:E,onStartTour:A,onStartCollabTour:O,annotationsVisible:P,onToggleAnnotations:I,minimapVisible:T,onToggleMinimap:C,zoomCtlVisible:S,onToggleZoomCtl:j,presentMode:b,onTogglePresent:h,postToActiveCanvas:d,onOpenWhatsNew:i,onOpenReadiness:v,onOpenQuickSetup:n,onWatchIntro:Y0,whatsNewCount:g,exportCenter:G0,artboardCount:e=0,presence:l=null,inspectorOpen:Z0,inspectorTab:r,onToggleInspector:a,autoOpenInspector:c,onToggleAutoOpenInspector:V0,onOpenLayers:o0,timelineOpen:U8,onToggleTimeline:V8,hasComps:L0=!1,assistantOpen:t0,onToggleAssistant:n0,assistantBusy:Q8,assistantUnseen:v8,onNewCanvas:i8,onAssembleVideo:g8,onOpenExport:z9,onOpenSettings:c0,onOpenGenerate:d8,onReload:o8,onCloseCanvas:j9,onInsertArtboard:f0}){let z0=X===h8,F0=z0?"SYSTEM":X?"CANVAS":"IDLE",U0=z0?K("b",{children:"design system"}):X?R(Q0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:KZ(_B(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),y0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:Z>0?`Changes · ${Z} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:Z0&&r==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:Z0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!c,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:L0?"video":void 0,checked:U8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:t0,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:P,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:T,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:S,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:b,disabled:!X||z0}],w0=["file","edit","view","selection","tools","help"];function R0(I0){if(w0.includes(I0))W(Y===I0?null:I0)}return u.useEffect(()=>{if(!Y||!w0.includes(Y))return;let I0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function O8(r0){let d0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!d0.length)return;let $8=d0.indexOf(document.activeElement);if(r0.key==="ArrowDown")r0.preventDefault(),d0[($8+1)%d0.length].focus();else if(r0.key==="ArrowUp")r0.preventDefault(),d0[($8-1+d0.length)%d0.length].focus();else if(r0.key==="Home")r0.preventDefault(),d0[0].focus();else if(r0.key==="End")r0.preventDefault(),d0[d0.length-1].focus();else if(r0.key==="ArrowRight"||r0.key==="ArrowLeft"){r0.preventDefault();let v9=r0.key==="ArrowRight"?1:-1,r8=w0.indexOf(Y);W(w0[(r8+v9+w0.length)%w0.length])}else if(r0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",O8),()=>{clearTimeout(I0),window.removeEventListener("keydown",O8)}},[Y,W]),R("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[R("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:fK0.map((I0)=>{let O8=I0.toLowerCase(),r0=w0.includes(O8),d0=r0||O8==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":O8==="help"?"help":void 0,"aria-haspopup":r0?"menu":void 0,"aria-expanded":r0?Y===O8:void 0,onClick:()=>R0(O8),onMouseEnter:()=>{if(Y!==null&&r0)W(O8)},children:I0},O8)})}),Y==="file"&&K(mK0,{hasCanvas:!!X,onAction:(I0)=>{if(I0==="new")i8?.();else if(I0==="assemble")g8?.();else if(I0==="export")z9?.("export");else if(I0==="handoff")z9?.("handoff");else if(I0==="generate")d8?.();else if(I0==="settings")c0?.();else if(I0==="reload")o8?.();else if(I0==="close")j9?.()},onClose:()=>W(null)}),Y==="edit"&&K(uK0,{hasCanvas:!!X&&!z0,onAction:(I0)=>{if(I0==="undo")d({dgn:"undo"});else if(I0==="redo")d({dgn:"redo"});else if(I0==="deselect-all")d({dgn:"selection-clear"});else if(I0==="select-all-annotations")d({dgn:"annotation-select-all"});else if(I0.startsWith("new-artboard:"))f0?.(I0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(vK0,{panels:y0,onToggle:(I0)=>{if(I0==="tree")F();else if(I0==="changes")z();else if(I0==="comments")q();else if(I0==="hidden")D();else if(I0==="annotate")I();else if(I0==="inspector")a();else if(I0==="autoopen")V0?.();else if(I0==="timeline")V8?.();else if(I0==="assistant")n0?.();else if(I0==="layers")o0?.();else if(I0==="minimap")C?.();else if(I0==="zoomctl")j?.();else if(I0==="present")h?.()},onZoom:(I0)=>d({dgn:"zoom",op:I0}),hasCanvas:!!X&&!z0,onClose:()=>W(null)}),Y==="selection"&&K(hK0,{onAction:(I0)=>{if(I0==="deselect-all")d({dgn:"selection-clear"});else if(I0==="select-all-annotations")d({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K(gK0,{onAction:(I0)=>d({dgn:"tool-set",tool:I0}),onClose:()=>W(null)}),Y==="help"&&K(xK0,{onAction:(I0)=>{if(I0==="shortcuts")E?.();else if(I0==="help")w?.();else if(I0==="tour")A?.();else if(I0==="collab-tour")O?.();else if(I0==="quick-setup")n?.();else if(I0==="readiness")v?.();else if(I0==="whatsnew")i?.();else if(I0==="watch-intro")Y0?.()},onClose:()=>W(null)}),R("div",{className:"st-mb-right","data-tour":"status",children:[l?K("div",{className:"st-presence",children:l}):null,G9()&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":t0?"true":"false","data-busy":Q8?"true":"false","data-unseen":v8?"true":"false","aria-label":`Assistant${Q8?" — working":v8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:n0,children:K(n8,{name:"sparkle",size:15})}),G0&&K(ty,{center:G0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":g>0?"true":"false","aria-label":`What's new${g>0?` — ${g} unseen`:""}`,"data-tip":"What's new",onClick:i,children:K(n8,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:F0}),K("span",{className:"st-mb-file",title:X||"",children:U0}),K("span",{className:"st-mb-sep"}),R("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function dK0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:q,cfg:H,loadingPath:Z,onIframeLoad:z,showQuickSetup:U,onStartQuickSetup:B}){return R("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&R("div",{className:"st-empty",children:[R("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),R("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(q||"MAUDE").toUpperCase()," / v",CE," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),R("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(s6,{children:"⌘"})," and hover to preview an element, click to select it — ",K(s6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?R(Q0,{children:[K("br",{}),K("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),U&&K("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((F)=>{if(F.path===h8)return K("div",{className:"system-view"+(F.path===J?" active":""),children:K(sK0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return K("iframe",{ref:(L)=>Q(F.path,L),src:GH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>z?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),Z&&Z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:R("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var pK0=["color","space","radius","shadow","leading","weight","motion","font","other"],cK0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function iK0(X){return X==="color"}function oK0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return R("section",{className:"sv-section sv-section-tokens",children:[R("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:R("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...pK0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(Q0,{children:W.map((G)=>{let q=Y[G],H=iK0(G);return R("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[R("h2",{children:["tokens · ",cK0[G]||G,K("span",{className:"sv-h-num",children:q.length})]}),K("div",{className:"sv-tokens-ladder",children:q.map((Z)=>R("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:Z.value}}):null,R("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:Z.name}),K("span",{className:"sv-tok-value",children:Z.value||"—"})]})]},Z.name+"|"+Z.value))})]},G)})})}function nK0(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 rK0(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 aK0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=rK0(X?.font);return R("section",{className:"sv-section sv-section-type",children:[R("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=nK0(W,Q),q={fontSize:W.value};if(G)q.lineHeight=G;if(Y)q.fontFamily=Y;return R("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:q,children:"The catalog is the system."})]},W.name)})})]})}function sK0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:q,tokens:H,tokenGroups:Z,tokensPath:z,ds:U,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,D=U?.name??B?.[0]?.name??"";return R("div",{className:"sv",children:[R("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),L?R("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:D,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>K("option",{value:w.name,children:w.name},w.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:q})})]}),U?.description?K("p",{className:"sv-ds-description",children:U.description}):null,K(oK0,{tokens:H,tokenGroups:Z,tokensPath:z}),K(aK0,{tokenGroups:Z}),F?K("div",{className:"sv-empty",children:R("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:q}),"."]})}):R(Q0,{children:[K(fa,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(fa,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function fa({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return R("section",{className:"sv-section",children:[R("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>R("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:GH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),R("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function tK0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:q,syncStatus:H,changesCount:Z=0,unpushed:z=0,changesOpen:U=!1,onOpenChanges:B}){let F=X===h8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",D=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",E=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let A=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:A>0?`${A} ↑`:"synced",title:A>0?`${A} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${A} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return R("footer",{className:"st-statusbar",role:"contentinfo",children:[R("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&R("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:D,children:L}),K("button",{type:"button",className:"st-sb-sel-clear",onClick:q,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),R("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),R("span",{className:"val",children:[Y," open"]})]}),B&&R("button",{type:"button",className:"st-sb-slot st-sb-changes"+(U?" is-open":"")+(Z>0?" has-changes":z>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":U,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:Z>0?`${Z} unsaved`:z>0?`${z} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),R("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),E&&R("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(E.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:E.title,children:E.label})]}),R("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[K(n8,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function eK0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:q,onReopen:H,onDelete:Z,width:z,resizing:U}){let B=sa(X),F=Object.keys(X||{}).sort(),L=[];for(let D of F){let w=X[D]||[],E=w.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let A=w.filter((O)=>O.selector);L.push({file:D,comments:E.map((O)=>({...O,n:A.findIndex((P)=>P.id===O.id)+1}))})}return R("aside",{className:"st-rpanel"+(U?" is-resizing":""),style:z?{width:z,flexBasis:z}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:R("div",{className:"st-cm-filters",role:"tablist",children:[R("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),R("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),R("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:L.length===0?R("div",{className:"st-rp-empty",children:[R("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),R("p",{children:["Open a canvas, hold ",K(s6,{children:"⌘"})," and click an element, then press ",K(s6,{children:"C"})," — or hold ",K(s6,{children:"⌘⇧"})," and click directly."]})]}):L.map((D)=>R(Q0,{children:[R("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[K("span",{children:KZ(_B(D.file))}),K("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((w)=>R("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(D.file,w.id),children:[R("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),K("span",{className:"st-comment-time",children:NK0(w.created)})]}),K("div",{className:"st-comment-txt",children:w.text}),R("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),R("span",{className:"st-mini-act",children:[w.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(w.id)},children:K(n8,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),q(w.id)},children:K(n8,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),Z(w.id)},children:K(n8,{name:"x",size:14})})]})]})]},w.id))]},D.file))})]})}function Xz0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return R("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),R("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),pj().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function Jz0({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:q}=X,H=G==="synced",Z=Y==="offline"||Y==="offline-long",z=X.docs?.rejected??0,U=Array.isArray(q)?[...q].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!Z&&!H&&!U&&z===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(Z){let D=q&&q.length>0?` (${q.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;L=`${Y}:offline`}else if(U){if(U.snapshotFailed)B="error",F=`Diverged on ${U.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${U.slug}: kept the ${U.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${U.slug}`;L=`diverged:${U.slug}:${U.at}`}else B="warn",F=`${z} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${z}`;if(J===L)return null;return R("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:F}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var Qz0=["block","inline-block","flex","inline-flex","grid","inline","none"];var Yz0=["auto","stretch","flex-start","center","flex-end","baseline"];var va=["300","400","500","600","700","800"],xa=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],ha=["none","solid","dashed","dotted","double"],ga=["px","rem","em","%","vw","vh","auto"],ma=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),PE={"font-size":{node:K(E9,{as:Rz,size:12})},"line-height":{node:K(E9,{as:bz,size:12})},"letter-spacing":{node:K(E9,{as:gz,size:12})},gap:{node:K(E9,{as:xH,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(E9,{as:pz,size:12})},"border-width":{node:K(E9,{as:hz,size:12})}};var ua=["static","relative","absolute","fixed","sticky"],Wz0=["normal","italic","oblique"],la=["none","uppercase","lowercase","capitalize"];var da=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],Gz0=["fill","contain","cover","none","scale-down"];var pa=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ca=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],aV={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}},HZ=null;function TE(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!HZ)HZ=document.createElement("canvas").getContext("2d");if(!HZ)return"";HZ.fillStyle="#000000",HZ.fillStyle=X;let J=HZ.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 pQ=(X)=>Math.min(1,Math.max(0,X));function AB(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 nV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function rV({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,q=0;if(G){if(Y===X)q=(J-Q)/G%6;else if(Y===J)q=(Q-X)/G+2;else q=(X-J)/G+4;if(q*=60,q<0)q+=360}return{h:q,s:Y?G/Y:0,v:Y}}function ZZ({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,q=0,H=0,Z=0;if(X<60)[q,H,Z]=[Y,W,0];else if(X<120)[q,H,Z]=[W,Y,0];else if(X<180)[q,H,Z]=[0,Y,W];else if(X<240)[q,H,Z]=[0,W,Y];else if(X<300)[q,H,Z]=[W,0,Y];else[q,H,Z]=[Y,0,W];return{r:(q+G)*255,g:(H+G)*255,b:(Z+G)*255}}function C9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function c5(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 ia(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)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 qz0(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function Hz0(X){let J={};for(let q of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(q[1]in J))J[q[1]]=q[2].trim();let Q={};for(let q of Object.keys(J)){let H=J[q],Z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[q]=Z&&J[Z[1]]?J[Z[1]]:H}let Y=Object.keys(J),W=(q)=>Y.filter((H)=>q.test(H)),G=(q)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(q)||/^(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(q);return{color:Y.filter((q)=>G(Q[q])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function Zz0(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,q]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(Z)=>{if(!Z.tokensCssRel)return null;try{let z=await fetch(`/${J}/${Z.tokensCssRel}`),U=z.ok?await z.text():"";return{name:Z.name,...Hz0(U)}}catch{return null}})).then((Z)=>{if(H)return;let z=Z.filter(Boolean);z.sort((U,B)=>U.name===Q?-1:B.name===Q?1:0),q(z)}),()=>{H=!0}},[W,J,Q]),G}function Xs({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>rV(AB(X||"#000000"))),G=u.useRef(Y);G.current=Y;let q=u.useRef(null),H=u.useRef(null),Z=u.useRef(X);u.useEffect(()=>{if(X&&X!==Z.current)Z.current=X,W(rV(AB(X)))},[X]);let z=nV(ZZ(Y)),U=(O)=>{O.preventDefault();let P=q.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,T=(S)=>{W({h:I,s:pQ((S.clientX-P.left)/P.width),v:pQ(1-(S.clientY-P.top)/P.height)})};T(O);let C=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",C),Q(nV(ZZ(G.current)))};document.addEventListener("pointermove",T),document.addEventListener("pointerup",C)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:T}=G.current,C=(j)=>{W({h:pQ((j.clientX-P.left)/P.width)*360,s:I,v:T})};C(O);let S=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",S),Q(nV(ZZ(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",S)},F=(O)=>{let P={...G.current,...O};W(P),Q(nV(ZZ(P)))},L=(O)=>{let P=O.shiftKey?0.1:0.02,T={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!T)return;O.preventDefault(),F({s:pQ(G.current.s+T[0]),v:pQ(G.current.v+T[1])})},D=(O)=>{let P=O.shiftKey?20:2,T={ArrowLeft:-P,ArrowRight:P}[O.key];if(T==null)return;O.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+T))})},w=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(rV(AB(P.sRGBHex))),Q(P.sRGBHex)}catch{}},E=ZZ(Y),A=(O)=>{let P={...E,...O},I=rV({r:pQ(P.r/255)*255,g:pQ(P.g/255)*255,b:pQ(P.b/255)*255});W(I),Q(nV(ZZ(I)))};return R("div",{className:"st-cp-cpick",children:[R("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:z}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:z,"aria-label":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(rV(AB(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),R("button",{type:"button",ref:q,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:U,onKeyDown:L,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:z}})]}),R("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:K(n8,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:z},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>R("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(P)=>A({[O]:pQ((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),K("span",{children:O.toUpperCase()})]},O))})]})}function RE({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:q,activeDs:H,swatchClassName:Z}){let[z,U]=u.useState(!1),[B,F]=u.useState(null),[L,D]=u.useState("custom"),[w,E]=u.useState(""),A=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(e)=>Q===`var(${e})`,T=(e)=>e.replace(/^--/,"").replace(/-/g," "),C=J||[],S=C.reduce((e,l)=>e+(l.names?.length||0),0),j=C.length>1,b=w.trim().toLowerCase(),h=!b?C:C.map((e)=>({...e,names:(e.names||[]).filter((l)=>T(l).toLowerCase().includes(b)||l.toLowerCase().includes(b)||(e.vals?.[l]||"").toLowerCase().includes(b))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!z){E("");return}let e=()=>{let a=A.current?.getBoundingClientRect();if(!a)return;let c=224,V0=300,o0=Math.min(a.right-c,window.innerWidth-c-8);if(o0<8)o0=8;let V8=window.innerHeight-a.bottom>V0+8?a.bottom+4:Math.max(8,a.top-V0-4);F({left:o0,top:V8,width:c,maxHeight:V0})};e();let l=(a)=>{if(O.current?.contains(a.target)||A.current?.contains(a.target))return;U(!1)},Z0=(a)=>{if(a.key==="Escape")U(!1)},r=(a)=>{if(O.current?.contains(a.target))return;e()};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",Z0),window.addEventListener("resize",e),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",Z0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[z]),u.useEffect(()=>{if(!z||!B||!O.current)return;let e=O.current.getBoundingClientRect(),l=B.left-e.left,Z0=B.top-e.top;if(Math.abs(l)>0.5||Math.abs(Z0)>0.5)F((r)=>r?{...r,left:r.left+l,top:r.top+Z0}:r)},[z,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,i=(e,l,Z0)=>{if(H&&e&&e!==H&&Z0&&!d.test(Z0))Y(Z0);else Y(`var(${l})`);U(!1)},v=(e)=>{let l=(e||"").trim();if(l)Y(l)},n=R("div",{className:"st-cp-pop-search",children:[K(n8,{name:"search",size:12}),K("input",{value:w,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),Y0=(e)=>e.map((l)=>R("div",{className:"st-cp-pop-group",children:[j?K("div",{className:"st-cp-pop-ds",children:l.ds}):null,K("div",{className:"st-cp-pop-list",children:l.names.map((Z0)=>R("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(Z0)?" is-on":""}`,onClick:()=>i(l.ds,Z0,l.vals?.[Z0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:l.vals?.[Z0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:T(Z0)}),K("span",{className:"st-cp-pop-val",children:l.vals?.[Z0]||""})]},`${l.ds}:${Z0}`))})]},l.ds)),g=(e)=>e.map((l)=>R("div",{className:"st-cp-pop-group",children:[j?K("div",{className:"st-cp-pop-ds",children:l.ds}):null,K("div",{className:"st-cp-pop-list",children:l.names.map((Z0)=>R("button",{type:"button",className:`st-cp-pop-row${I(Z0)?" is-on":""}`,onClick:()=>i(l.ds,Z0,l.vals?.[Z0]),children:[K("span",{className:"st-cp-pop-name",children:T(Z0)}),K("span",{className:"st-cp-pop-val",children:l.vals?.[Z0]||""})]},`${l.ds}:${Z0}`))})]},l.ds)),G0=K("div",{className:"st-cp-pop-empty",children:"No match"});return R(Q0,{children:[G!==void 0?K("button",{type:"button",ref:A,className:`${Z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!Z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":z,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>U((e)=>!e),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:A,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":z,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>U((e)=>!e),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),z&&B?oa.createPortal(K("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?R(Q0,{children:[R("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),L==="custom"?K(Xs,{seed:q||TE(Q)||"#000000",onApply:v}):!S?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):R(Q0,{children:[n,h.length?Y0(h):G0]})]}):!S?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):R(Q0,{children:[n,h.length?g(h):G0]})}),document.body):null]})}function Kz0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:q,onSetMode:H}){let Z=!!X.id,z=X.computed||{},[U,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(o,B0)=>{let H0={...o||{}};for(let[A0,p0]of Object.entries(B0))if(p0===null)delete H0[A0];else H0[A0]=p0;return H0},L=F(X.authored,U.a),D=F(X.customStyles,U.c),w=F(X.attrs,U.t),E=(o,B0)=>B((H0)=>({...H0,a:{...H0.a,[o]:B0}})),A=(o,B0)=>B((H0)=>({...H0,c:{...H0.c,[o]:B0}})),O=(o,B0)=>B((H0)=>({...H0,t:{...H0.t,[o]:B0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=qz0(X.file,J),T=Zz0(J,P,I),C=(o)=>T.map((B0)=>({ds:B0.name,names:B0[o]||[],vals:B0.vals})).filter((B0)=>B0.names.length),[S,j]=u.useState({}),[b,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(w).length>0;u.useEffect(()=>{if(d)h((o)=>o.Advanced?o:{...o,Advanced:!0})},[X.id,d]);let i=(L.position||C9(z.position)||"static")!=="static";u.useEffect(()=>{if(i)h((o)=>o["d:Position"]?o:{...o,"d:Position":!0})},[X.id,i]);let v=H,[n,Y0]=u.useState({});async function g(o,B0,H0){j((A0)=>({...A0,[H0]:"saving"}));try{let A0=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B0)}),p0=await A0.json().catch(()=>({}));j((M8)=>({...M8,[H0]:!A0.ok||!p0.ok?`err:${p0&&p0.error||`HTTP ${A0.status}`}`:"saved"}))}catch(A0){j((p0)=>({...p0,[H0]:`err:${A0&&A0.message?A0.message:String(A0)}`}))}}let G0=(o,B0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:o,value:B0})},e=(o,B0,H0,A0)=>{Y?.({op:o,canvas:X.file,id:X.id,key:B0,before:H0==null||H0===""?null:H0,after:A0==null||A0===""?null:A0})},l=(o,B0)=>{let H0=(B0||"").trim();if(!Z||!H0)return;let A0=L[o]??null;if(H0===(A0??"").trim())return;G0(o,H0),E(o,H0),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,value:H0},o),e("css",o,A0,H0)},Z0=(o,B0)=>{let H0=(B0||"").trim(),A0=o.trim();if(!Z||!A0||!H0)return;let p0=D[A0]??null;G0(A0,H0),A(A0,H0),g("/_api/edit-css",{canvas:X.file,id:X.id,property:A0,value:H0},A0),e("css",A0,p0,H0)},r=(o,B0)=>{let H0=(o||"").trim(),A0=(B0||"").trim();if(!Z||!H0||!A0)return;let p0=w[H0]??null;O(H0,A0),g("/_api/edit-attr",{canvas:X.file,id:X.id,attr:H0,value:A0},`@${H0}`),e("attr",H0,p0,A0)},a=(o)=>{if(!Z)return;let B0=L[o]??null;G0(o,null),E(o,null),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,reset:!0},o),e("css",o,B0,null)},c=(o)=>{if(!Z)return;let B0=D[o]??null;G0(o,null),A(o,null),g("/_api/edit-css",{canvas:X.file,id:X.id,property:o,reset:!0},o),e("css",o,B0,null)},V0=(o)=>{if(!Z)return;let B0=w[o]??null;O(o,null),g("/_api/edit-attr",{canvas:X.file,id:X.id,attr:o,reset:!0},`@${o}`),e("attr",o,B0,null)},o0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},U8=(o,B0)=>{if(!Z)return;let H0=Math.round((o==="width"?X.bounds?.w:X.bounds?.h)||0),A0=jT(o,B0,o0,H0);for(let p0 of A0.reset)if(L[p0])a(p0);for(let[p0,M8]of A0.set)l(p0,M8)},V8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",L0=(o)=>{let B0=bT(o,L,z,o0);return R("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:o==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${o} sizing mode`,children:K(fy,{value:B0,ariaLabel:`${o} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(H0)=>U8(o,H0)})})]},`mode-${o}`)},t0=["flex-start","center","flex-end"],n0=["flex-start","center","flex-end"],Q8=["t","c","b"],v8=["l","c","r"],i8=()=>{let o=!(L["flex-direction"]||C9(z["flex-direction"])||"row").startsWith("column"),B0=Math.max(0,t0.indexOf(L["justify-content"]||C9(z["justify-content"])||"flex-start")),H0=L["align-items"]||C9(z["align-items"])||"stretch",A0=H0==="stretch"?1:Math.max(0,n0.indexOf(H0)),[p0,M8]=o?[B0,A0]:[A0,B0];return Q8[M8]+v8[p0]},g8=(o)=>{let B0=Q8.indexOf(o[0]),H0=v8.indexOf(o[1]),A0=!(L["flex-direction"]||C9(z["flex-direction"])||"row").startsWith("column"),[p0,M8]=A0?[H0,B0]:[B0,H0];l("justify-content",t0[p0]),l("align-items",n0[M8])},z9=(o)=>{if(!(o.metaKey||o.ctrlKey)||o.altKey)return;let B0=o.key.toLowerCase();if(B0==="z")o.preventDefault(),G?.(o.shiftKey?"redo":"undo");else if(B0==="y")o.preventDefault(),G?.("redo")},c0=(o)=>{let B0=L[o];if(!B0)return"inherit";return/var\(\s*--/.test(B0)?"bound":"raw"};if(!Z)return R("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),R("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let d8={bound:"token-bound",raw:"raw override",inherit:"inherited"},o8=(o)=>K("span",{className:`st-cp-prov st-cp-prov--${o}`,role:"img","aria-label":d8[o]}),j9=(o,B0)=>{let H0=B0??c0(o),A0=S[o],p0=typeof A0==="string"&&A0.startsWith("err:")?A0.slice(4):"",M8=p0?" is-err":A0==="saved"?" is-saved":A0==="saving"?" is-saving":"",T8=!!L[o],b8=p0?`error: ${p0}`:T8?`${d8[H0]} · double-click to reset`:d8[H0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${H0}${M8}${T8?" is-resettable":""}`,"aria-label":b8,title:b8,tabIndex:T8?0:-1,onDoubleClick:T8?()=>a(o):void 0,onKeyDown:T8?(p8)=>{if(p8.key==="Backspace"||p8.key==="Delete")p8.preventDefault(),a(o)}:void 0})},f0=(o,B0,H0,A0)=>{let p0=H0===void 0&&!L[o],M8=A0??o;return R("div",{className:`st-cp-row${p0?" is-unset":""}`,children:[j9(o,H0),K("label",{className:"st-cp-label",title:M8,children:M8}),K("div",{className:"st-cp-ctl",children:B0})]},o)},z0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],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"]},F0=(o)=>{(z0[o]||[]).forEach((B0)=>{if(L[B0])a(B0)})},U0=(o,B0)=>{let H0=(z0[o]||[]).some((A0)=>L[A0]);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!b[o],onClick:()=>h((A0)=>({...A0,[o]:!A0[o]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:b[o]?"▾":"▸"}),o]}),K("button",{type:"button",className:`st-cp-secreset${H0?"":" is-quiet"}`,"aria-label":`reset ${o} section to original`,title:`reset ${o}`,disabled:!H0,onClick:()=>F0(o),children:K(E9,{as:VG,size:12})})]}),K("div",{className:`st-cp-sec-anim${b[o]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:B0})})]},o)},y0=(o,B0,H0,A0=!0)=>{let p0=`d:${o}`,M8=b[p0]===void 0?A0:b[p0],T8=B0.some((b8)=>L[b8]);return R("section",{className:"st-cp-sec",children:[R("div",{className:"st-cp-sechd-row",children:[R("button",{type:"button",className:"st-cp-sechd","aria-expanded":M8,onClick:()=>h((b8)=>({...b8,[p0]:!M8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:M8?"▾":"▸"}),o]}),K("button",{type:"button",className:`st-cp-secreset${T8?"":" is-quiet"}`,"aria-label":`reset ${o} to original`,title:`reset ${o}`,disabled:!T8,onClick:()=>B0.forEach((b8)=>{if(L[b8])a(b8)}),children:K(E9,{as:VG,size:12})})]}),K("div",{className:`st-cp-sec-anim${M8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:H0})})]},p0)},w0=(o)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!n[o],"aria-label":n[o]?`${o} — fewer options`:`${o} — more options`,title:n[o]?"fewer":"more",onClick:()=>Y0((B0)=>({...B0,[o]:!B0[o]})),children:n[o]?"▴":"···"}),R0=(o,B0)=>R("select",{className:"st-cp-nsel","aria-label":o,value:B0.includes(L[o])?L[o]:"",onChange:(H0)=>l(o,H0.target.value),children:[K("option",{value:"",disabled:!0,children:C9(z[o])||"—"}),B0.map((H0)=>K("option",{value:H0,children:H0},H0))]}),I0=(o)=>C(o).flatMap((B0)=>(B0.names||[]).map((H0)=>({name:H0,value:B0.vals?.[H0]||""}))),O8=(o,B0)=>K(kM,{value:L[o]||C9(z[o])||B0[0].value,ariaLabel:o,options:B0,onChange:(H0)=>l(o,H0)}),r0=(o,B0,H0={})=>{let A0=c5(L[o]??""),p0=ma.has(o),M8=L[o]??"",T8=typeof M8==="string"&&/var\(\s*--/.test(M8),b8=p0?"":A0.unit&&A0.unit!=="auto"?A0.unit:"px",p8=Number.parseFloat(c5(C9(z[o])??"").n)||0,y9=A0.n!==""&&A0.n!=null?Number.parseFloat(A0.n)||0:p8,c9=PE[o];return K(my,{value:T8?M8:y9,tokens:I0(B0),ariaLabel:o,min:H0.min??0,lead:c9?c9.node??c9.t:void 0,unitSlot:p0?null:K(RM,{units:ga,value:A0.unit||"px",ariaLabel:`${o} unit`,onChange:(u7)=>l(o,u7==="auto"?"auto":`${A0.n||"0"}${u7}`)}),onChange:(u7)=>l(o,typeof u7==="string"?u7:p0?`${u7}`:`${u7}${b8}`)})},d0=()=>{let o=(p0)=>Number.parseFloat(c5(L[p0]??L["border-radius"]??C9(z[p0])??C9(z["border-radius"])??"0").n)||0,B0={tl:o("border-top-left-radius"),tr:o("border-top-right-radius"),bl:o("border-bottom-left-radius"),br:o("border-bottom-right-radius")},H0=(p0)=>{if(p0.tl===p0.tr&&p0.tr===p0.bl&&p0.bl===p0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((T8)=>{if(L[T8])a(T8)}),l("border-radius",`${p0.tl}px`);else l("border-top-left-radius",`${p0.tl}px`),l("border-top-right-radius",`${p0.tr}px`),l("border-bottom-left-radius",`${p0.bl}px`),l("border-bottom-right-radius",`${p0.br}px`)},A0=PE["border-radius"];return K(uy,{corners:B0,lead:A0?A0.node??A0.t:void 0,onCorners:H0})},$8=()=>R("div",{className:"st-cp-border",children:[a8("border-width",null,{fixedUnit:"px"}),R("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:ha.includes(L["border-style"])?L["border-style"]:"",onChange:(o)=>l("border-style",o.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),ha.map((o)=>K("option",{value:o,children:o},o))]}),K(RE,{kind:"color",groups:C("color"),current:L["border-color"],activeDs:I,swatchBg:z["border-color"]||L["border-color"]||"",seedHex:TE(z["border-color"]||L["border-color"])||"#000000",onPick:(o)=>l("border-color",o),label:"border colour"})]}),v9=()=>{let o=L.transform||C9(z.transform)||"",B0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(o),H0=((B0?Number.parseFloat(B0[1]):0)%360+360)%360,A0=(p0)=>{let M8=(p0%360+360)%360,T8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();l("transform",`${T8?`${T8} `:""}rotate(${M8}deg)`.trim())};return R("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(hy,{value:H0,onChange:A0}),K(UG,{value:H0,min:0,max:360,ariaLabel:"rotation",lead:K(E9,{as:VG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:A0})]})},r8=()=>{let o=L.filter||C9(z.filter)||"",B0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(o),H0=B0?Number.parseFloat(B0[1]):0;return K(UG,{value:H0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(p0)=>{let M8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();l("filter",p0>0?`${M8?`${M8} `:""}blur(${p0}px)`.trim():M8||"none")}})},k0=()=>{let o=L.opacity,B0=o!=null&&o!==""?Number.parseFloat(o):Number.parseFloat(C9(z.opacity))||1,H0=Math.round((Number.isNaN(B0)?1:B0)*100);return K(m5,{value:H0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(A0)=>G0("opacity",String(A0/100)),onCommit:(A0)=>l("opacity",String(A0/100))},`opacity:${o??""}`)},z8=()=>{let o=Number.parseInt(L["font-weight"]||C9(z["font-weight"])||"400",10)>=600,B0=(L["font-style"]||C9(z["font-style"]))==="italic",H0=/underline/.test(L["text-decoration"]||C9(z["text-decoration"])||"");return K(vy,{value:{b:o,i:B0,u:H0},ariaLabel:"text style",options:[{value:"b",node:K(E9,{as:jz}),label:"Bold"},{value:"i",node:K(E9,{as:xz}),label:"Italic"},{value:"u",node:K(E9,{as:iz}),label:"Underline"}],onToggle:(A0)=>{if(A0==="b")l("font-weight",o?"400":"700");else if(A0==="i")l("font-style",B0?"normal":"italic");else l("text-decoration",H0?"none":"underline")}})},m7=[{value:"row",node:K(E9,{as:FY}),label:"Row"},{value:"column",node:K(E9,{as:NY}),label:"Column"}],nX=[{value:"flex-start",node:K(E9,{as:Tz}),label:"Start"},{value:"center",node:K(E9,{as:kz}),label:"Center"},{value:"flex-end",node:K(E9,{as:Iz}),label:"End"},{value:"space-between",node:K(E9,{as:xH}),label:"Space between"}],t6=[{value:"flex-start",node:K(E9,{as:$z}),label:"Start"},{value:"center",node:K(E9,{as:Cz}),label:"Center"},{value:"flex-end",node:K(E9,{as:Sz}),label:"End"},{value:"stretch",node:K(E9,{as:cz}),label:"Stretch"}],Q9=[{value:"left",node:K(E9,{as:dJ}),label:"Left"},{value:"center",node:K(E9,{as:DY}),label:"Center"},{value:"right",node:K(E9,{as:OY}),label:"Right"},{value:"justify",node:K(E9,{as:MY}),label:"Justify"}],G7=[{value:"visible",node:K(E9,{as:zG}),label:"Visible"},{value:"hidden",node:K(E9,{as:uz}),label:"Hidden"},{value:"scroll",node:K(E9,{as:lz}),label:"Scroll"}],r7=(o,B0)=>{let H0=C(B0);return H0.length?K(RE,{kind:"value",groups:H0,current:L[o],activeDs:I,onPick:(A0)=>l(o,A0),label:`${o} design token`}):null},B9=(o)=>{let B0=o.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===B0)B0.select()})},p9=(o,B0)=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return!1;o.preventDefault();let H0=o.shiftKey?10:1,A0=o.key==="ArrowUp"?1:-1,p0=(Number.parseFloat(o.currentTarget.value)||0)+A0*H0;return o.currentTarget.value=String(p0),B0(p0),!0},F7=(o)=>K("input",{className:"st-cp-fin","aria-label":o,defaultValue:L[o]??"",placeholder:C9(z[o])||"—",onFocus:B9,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>l(o,B0.currentTarget.value)},`${o}:${L[o]??""}`),a8=(o,B0,H0={})=>{let A0=c5(L[o]??""),p0=ma.has(o),M8=p0?"":H0.fixedUnit||(A0.unit&&A0.unit!=="auto"?A0.unit:"px"),T8=PE[o],b8=Number.parseFloat(c5(C9(z[o])??"").n)||0,p8=A0.n!==""&&A0.n!=null?Number.parseFloat(A0.n)||0:b8;return R(Q0,{children:[K(UG,{value:p8,min:H0.min??0,step:1,ariaLabel:o,lead:T8?T8.node??T8.t:void 0,onCommit:(y9)=>l(o,p0?`${y9}`:`${y9}${M8}`),unitSlot:p0||H0.fixedUnit?null:K(RM,{units:ga,value:A0.unit||"px",ariaLabel:`${o} unit`,onChange:(y9)=>l(o,y9==="auto"?"auto":`${A0.n||"0"}${y9}`)})},`${o}:${L[o]??""}`),r7(o,B0)]})},H6=(o)=>{let B0=z[o]||L[o]||"",H0=L[o]??"",A0=typeof H0==="string"&&/var\(\s*--/.test(H0),p0=A0?H0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):H0;return K(B2,{swatch:K(RE,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:C("color"),current:L[o],activeDs:I,swatchBg:B0,seedHex:TE(z[o]||L[o])||"#000000",onPick:(M8)=>l(o,M8),label:`${o} colour`}),displayValue:p0,bound:A0,ariaLabel:o,onValue:(M8)=>l(o,M8)})},j6=(o,B0)=>{let H0=null,A0=B0.unitless?"":"px",p0=(b8)=>B0.unitless?`${b8}`:`${b8}${A0}`,M8=(b8,p8,y9)=>{for(let c9 of p8??[o])y9(c9,p0(b8))},T8=PM({getBase:()=>H0?.value??"0",min:B0.min??0,step:1,sides:B0.sides,onInput:(b8,p8)=>{if(H0)H0.value=String(b8);if(p8){let y9=H0?.closest(".st-cp-box");for(let c9 of p8){if(c9===o)continue;let u7=y9?.querySelector(`.st-cp-boxv[aria-label="${c9}"]`);if(u7)u7.value=String(b8)}}M8(b8,p8,G0)},onCommit:(b8,p8)=>M8(b8,p8,l)});return{onPointerDown:(b8)=>{H0=b8.currentTarget,T8(b8)}}},Y9=(o,B0)=>{let H0=L[o],A0=H0!=null&&H0!==""?c5(H0).n||H0:c5(C9(z[o])??"").n||"0",p0=!H0||H0==="0"||H0==="0px"||H0==="auto",M8=o.split("-").pop(),T8=M8==="top"||M8==="bottom"?[`${B0}-top`,`${B0}-bottom`]:[`${B0}-left`,`${B0}-right`],b8=[`${B0}-top`,`${B0}-right`,`${B0}-bottom`,`${B0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${B0[0]}${o.split("-").pop()[0]}${p0?" is-zero":""}`,"aria-label":o,defaultValue:A0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...j6(o,{sides:{pair:T8,all:b8}}),onFocus:B9,onKeyDown:(p8)=>{if(p9(p8,(y9)=>l(o,`${y9}px`)))return;if(p8.key==="Enter")p8.currentTarget.blur()},onBlur:(p8)=>{let y9=p8.currentTarget.value.trim();if(!y9)return;let c9=/[a-z%]/i.test(y9)?y9:`${y9}px`;l(o,c9)}},`${o}:${H0??""}`)},q7=(o)=>{let B0=L[o],H0=B0!=null&&B0!==""&&B0!=="auto"?c5(B0).n||B0:c5(C9(z[o])??"").n||"",A0=!B0||B0==="auto"||B0==="0"||B0==="0px",p0=o==="top"||o==="bottom"?["top","bottom"]:["left","right"],M8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${o[0]}${A0?" is-zero":""}`,"aria-label":o,defaultValue:H0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...j6(o,{sides:{pair:p0,all:M8},min:-1/0}),onFocus:B9,onKeyDown:(T8)=>{if(p9(T8,(b8)=>l(o,`${b8}px`)))return;if(T8.key==="Enter")T8.currentTarget.blur()},onBlur:(T8)=>{let b8=T8.currentTarget.value.trim();if(!b8)return;let p8=/[a-z%]/i.test(b8)?b8:`${b8}px`;l(o,p8)}},`${o}:${B0??""}`)},Z5=Object.entries(D),rX=Object.entries(w),e6=()=>{let o=(X.tag||"").toLowerCase(),H0=o==="img"||o==="video"||o==="picture"||o==="svg"||o==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],A0=(o==="img"||o==="video")&&!!X.attrs?.src&&!!W;return{showMedia:H0,canReplace:A0}},H7=(o)=>R(Q0,{children:[o&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),f0("object-fit",R0("object-fit",Gz0)),f0("object-position",F7("object-position")),f0("aspect-ratio",R("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:ca.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(B0)=>{let H0=B0.target.value;if(l("aspect-ratio",H0),H0&&H0!=="auto"&&L.height)a("height")},children:[K("option",{value:"",disabled:!0,children:C9(z["aspect-ratio"])||"—"}),ca.map((B0)=>K("option",{value:B0,children:B0},B0))]}))]});return R("div",{className:`st-cp${q==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:z9,children:[R("div",{className:"st-cp-id",children:[R("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?R("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(kM,{value:q,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(E9,{as:BY,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(E9,{as:wY,size:12}),label:"Designer — Figma vocabulary"}],onChange:v})})]}),q==="designer"?R(Q0,{children:[y0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let o=(L.display||C9(z.display)||"").trim();return o==="flex"||o==="inline-flex"?R(Q0,{children:[f0("flex-direction",O8("flex-direction",m7),void 0,"Direction"),f0("align-items",K(xy,{value:i8(),onChange:g8,ariaLabel:"auto-layout alignment"}),c0("align-items"),"Alignment"),f0("gap",r0("gap","space"),void 0,"Gap"),R("div",{className:"st-cp-modes",children:[L0("width"),L0("height")]}),R("div",{className:"st-cp-box","aria-label":"padding",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(c0("padding-top")),"padding"]}),Y9("padding-top","padding"),Y9("padding-right","padding"),Y9("padding-bottom","padding"),Y9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:w0("Auto layout")}),n["Auto layout"]?f0("flex-wrap",K(EY,{checked:/^wrap/.test(L["flex-wrap"]||C9(z["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(H0)=>l("flex-wrap",H0?"wrap":"nowrap")}),c0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!Z,onClick:()=>l("display","flex"),children:"+ Auto layout (flex)"})})()),y0("Size",["width","height","min-width","max-width","min-height","max-height"],R(Q0,{children:[f0("width",a8("width"),void 0,"Width"),f0("height",a8("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:w0("Size")}),n.Size?R(Q0,{children:[f0("min-width",a8("min-width"),void 0,"Min width"),f0("max-width",a8("max-width"),void 0,"Max width"),f0("min-height",a8("min-height"),void 0,"Min height"),f0("max-height",a8("max-height"),void 0,"Max height")]}):null]})),y0("Position",["position","top","right","bottom","left","z-index"],R(Q0,{children:[f0("position",R0("position",ua),void 0,"Position"),R("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(c0("top")),"inset"]}),q7("top"),q7("right"),q7("bottom"),q7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||C9(z.position)||"static"})]}),(L.position||C9(z.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:w0("Position")}),n.Position?f0("z-index",a8("z-index"),void 0,"Layer order"):null]}),!1),y0("Fill",["background-color"],f0("background-color",H6("background-color"),void 0,"Fill")),y0("Stroke",["border-width","border-style","border-color"],f0("border",$8(),c0("border-width"),"Stroke")),y0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],f0("border-radius",d0(),c0("border-radius"),"Corner radius")),y0("Effects",["box-shadow","filter","mix-blend-mode"],R(Q0,{children:[f0("box-shadow",r7("box-shadow","shadow")||F7("box-shadow"),void 0,"Shadow"),f0("filter",r8(),c0("filter"),"Blur"),f0("mix-blend-mode",R0("mix-blend-mode",pa),void 0,"Blend")]})),y0("Opacity",["opacity"],f0("opacity",k0(),void 0,"Opacity")),y0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],R(Q0,{children:[f0("font-family",R0("font-family",xa),void 0,"Font"),f0("color",H6("color"),void 0,"Color"),f0("font-size",r0("font-size","type"),void 0,"Size"),f0("font-weight",R0("font-weight",va),void 0,"Weight"),f0("line-height",a8("line-height","lh"),void 0,"Line height"),f0("text-align",O8("text-align",Q9),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:w0("Text")}),n.Text?R(Q0,{children:[f0("letter-spacing",a8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),f0("font-style",R0("font-style",Wz0),void 0,"Style"),f0("text-transform",R0("text-transform",la),void 0,"Case"),f0("white-space",R0("white-space",da),void 0,"Whitespace")]}):null]})),y0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],R("div",{className:"st-cp-box","aria-label":"margin",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(c0("margin-top")),"margin"]}),Y9("margin-top","margin"),Y9("margin-right","margin"),Y9("margin-bottom","margin"),Y9("margin-left","margin")]})),(()=>{let{showMedia:o,canReplace:B0}=e6();return o?y0("Media",["object-fit","object-position","aspect-ratio"],H7(B0)):null})()]}):R(Q0,{children:[U0("Layout",(()=>{let o=(L.display||C9(z.display)||"").trim(),B0=o==="flex"||o==="inline-flex",H0=o==="grid"||o==="inline-grid";return R(Q0,{children:[f0("display",R0("display",Qz0)),B0?R(Q0,{children:[f0("flex-direction",O8("flex-direction",m7)),f0("flex-wrap",K(EY,{checked:/^wrap/.test(L["flex-wrap"]||C9(z["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(A0)=>l("flex-wrap",A0?"wrap":"nowrap")}),c0("flex-wrap"))]}):null,B0||H0?R(Q0,{children:[f0("align-items",O8("align-items",t6)),f0("justify-content",O8("justify-content",nX)),f0("gap",r0("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!Z,onClick:()=>l("display","flex"),children:"+ Auto layout (flex)"})]})})()),U0("Position",R(Q0,{children:[f0("position",R0("position",ua)),R("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(c0("top")),"inset"]}),q7("top"),q7("right"),q7("bottom"),q7("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||C9(z.position)||"static"})]}),(L.position||C9(z.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,f0("z-index",a8("z-index"))]})),U0("Typography",R(Q0,{children:[f0("font-family",R0("font-family",xa)),f0("color",H6("color")),f0("font-size",r0("font-size","type")),f0("font-weight",R0("font-weight",va)),f0("line-height",a8("line-height","lh")),f0("letter-spacing",a8("letter-spacing",null,{min:-1/0})),f0("text-align",O8("text-align",Q9)),f0("font-style",z8(),c0("font-style")),f0("text-transform",R0("text-transform",la)),f0("white-space",R0("white-space",da))]})),U0("Spacing",K(Q0,{children:R("div",{className:"st-cp-box","aria-label":"margin and padding",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(c0("margin-top")),"margin"]}),Y9("margin-top","margin"),Y9("margin-right","margin"),Y9("margin-bottom","margin"),Y9("margin-left","margin"),R("div",{className:"st-cp-boxpad",children:[R("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(c0("padding-top")),"padding"]}),Y9("padding-top","padding"),Y9("padding-right","padding"),Y9("padding-bottom","padding"),Y9("padding-left","padding"),R("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(L.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(L.height)||X.bounds?.h||0)]})]})]})})),U0("Size",R(Q0,{children:[R("div",{className:"st-cp-modes",children:[L0("width"),L0("height")]}),f0("width",a8("width")),f0("height",a8("height")),f0("min-width",a8("min-width")),f0("max-width",a8("max-width")),f0("min-height",a8("min-height")),f0("max-height",a8("max-height")),f0("overflow",O8("overflow",G7)),V8?R(Q0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),f0("align-self",R0("align-self",Yz0)),f0("flex-grow",a8("flex-grow",null,{unitless:!0})),f0("flex-shrink",a8("flex-shrink",null,{unitless:!0})),f0("flex-basis",a8("flex-basis"))]}):null]})),(()=>{let{showMedia:o,canReplace:B0}=e6();return o?U0("Media",H7(B0)):null})(),U0("Appearance",R(Q0,{children:[f0("background-color",H6("background-color")),f0("border-radius",d0(),c0("border-radius")),f0("border",$8(),c0("border-width")),f0("box-shadow",r7("box-shadow","shadow")||F7("box-shadow")),f0("filter",r8(),c0("filter")),f0("mix-blend-mode",R0("mix-blend-mode",pa)),f0("opacity",k0()),f0("rotation",v9(),c0("transform")),f0("transform",F7("transform")),f0("transform-origin",F7("transform-origin"))]})),(()=>{let o=Object.entries(S).find(([,B0])=>typeof B0==="string"&&B0.startsWith("err:"));return o?R("div",{className:"st-cp-save is-err",role:"status",children:[K(n8,{name:"x",size:12}),o[0],": ",o[1].slice(4)]}):null})(),U0("Advanced",R("div",{className:"st-cp-advbody",children:[Z5.length?R(Q0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),Z5.map(([o,B0])=>R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:o,"aria-label":`custom property ${o} name`}),K("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${o} value`,onKeyDown:(H0)=>{if(H0.key==="Enter")H0.currentTarget.blur()},onBlur:(H0)=>Z0(o,H0.currentTarget.value)},`cs:${o}:${B0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${o}`,title:"remove",onClick:()=>c(o),children:K(n8,{name:"x",size:11})})]},`cs:${o}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(zz0,{commit:Z0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),rX.length?R(Q0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),rX.map(([o,B0])=>R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:o,"aria-label":`attribute ${o} name`}),K("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${o} value`,onKeyDown:(H0)=>{if(H0.key==="Enter")H0.currentTarget.blur()},onBlur:(H0)=>r(o,H0.currentTarget.value)},`at:${o}:${B0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${o}`,title:"remove",onClick:()=>V0(o),children:K(n8,{name:"x",size:11})})]},`at:${o}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(Vz0,{commit:r})]}))]}),R("div",{className:"st-cp-legend",children:[R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),R("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function zz0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(q)=>Q(q.target.value)}),K("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")G()},onBlur:G})]})}function Vz0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return R("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(q)=>Q(q.target.value)}),K("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")G()},onBlur:G})]})}var Uz0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box"};function Bz0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,q=(Z)=>{for(let z=0;z<Z.length;z++){if(Z[z].id===J)return G=Z[z],Z.splice(z,1),!0;if(Z[z].children&&q(Z[z].children))return!0}return!1};if(q(W),!G)return X;let H=(Z)=>{for(let z=0;z<Z.length;z++){if(Z[z].id===Q){if(Y==="inside-start"||Y==="inside-end")if(Z[z].children=Z[z].children||[],Y==="inside-start")Z[z].children.unshift(G);else Z[z].children.push(G);else Z.splice(Y==="before"?z:z+1,0,G);return!0}if(Z[z].children&&H(Z[z].children))return!0}return!1};return H(W)?W:X}var Fz0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Js({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:q,onSelect:H,onHover:Z,onToggleVisibility:z,onReorder:U,onRowPointerDown:B,dragState:F}){let L=`${X.id}:${X.index}`,D=X.children&&X.children.length>0,w=W.has(L),E=X.id===Q&&(Y==null||X.index===Y),A=G?.has(L)?G.get(L):!!X.hidden,O=!!U,P=F?.key===L,I=P?{transform:`translate(${F.dx}px, ${F.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return R(Q0,{children:[R("div",{className:"st-layer st-layer--row"+(E?" is-sel":"")+(A?" is-hidden":""),style:{paddingLeft:6+J*14,...I},role:"treeitem","aria-selected":E,"aria-expanded":D?!w:void 0,"aria-grabbed":O?P:void 0,tabIndex:0,title:`${X.tag} · ${X.type}`,"data-layer-key":L,onClick:()=>H(X),onMouseEnter:()=>Z(X),onMouseLeave:()=>Z(null),onPointerDown:O?(T)=>B(T,X,L):void 0,onKeyDown:(T)=>{if(T.key==="Enter"||T.key===" ")T.preventDefault(),H(X)},children:[D?K("button",{type:"button",className:"st-layer-caret","aria-label":w?"Expand":"Collapse",onClick:(T)=>{T.stopPropagation(),q(L)},children:w?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),K(n8,{name:Uz0[X.type]||"box",size:12,className:"st-layer-ticon"}),K("span",{className:"st-layer-label",children:X.label}),K("span",{className:"st-layer-type",children:X.type}),z?K("button",{type:"button",className:"st-layer-eye","aria-label":A?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":A,title:A?"Show":"Hide",onClick:(T)=>{T.stopPropagation(),z(X)},children:K(n8,{name:A?"eye-off":"eye",size:13})}):null]}),D&&!w?X.children.map((T,C)=>K(Js,{node:T,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:q,onSelect:H,onHover:Z,onToggleVisibility:z,onReorder:U,onRowPointerDown:B,dragState:F},`${T.id}:${T.index}`)):null]})}function Nz0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(z)=>{let U=Q[z];if(U&&/var\(\s*--/.test(U))return U.replace(/^var\(\s*|\s*\)$/g,"");return J[z]||U||""},W=(z,U)=>{let B=J[U]||Q[U];if(!B)return null;return R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:z}),R("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(U)})]})]},z)},G=J["border-radius"]&&J["border-radius"]!=="0px",q=G?c5(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 R(Q0,{children:[G?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:q,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Qs(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var Lz0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]];function Dz0({el:X,onResizeArtboard:J,onSetArtboardHug:Q,onSetArtboardStyle:Y}){let W=Qs(X),G=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,q=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,H=(E,A)=>{if(!W)return;let O=Number.isFinite(E)&&E>0?Math.round(E):void 0,P=Number.isFinite(A)&&A>0?Math.round(A):void 0;if(O==null&&P==null)return;J?.(W,O,P)},Z=Object.entries(aV).find(([,E])=>E.width===G&&E.height===q)?.[0],z=X.attrs?.["data-dc-fixed"]==="true",U=X.attrs?.["data-dc-bg"]??"",B=X.attrs?.["data-dc-padding"]??"",F=X.attrs?.["data-dc-layout"]??"",L=X.attrs?.["data-dc-gap"]??"",D=(E)=>{if(!W)return;let A=E&&Number.isFinite(q)?Math.round(q):void 0;Q?.(W,E,A)},w=(E)=>{if(!W)return;Y?.(W,E)};return R("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),R("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"W"}),K("input",{className:"st-cp-numin",type:"number",min:"1","aria-label":"artboard width",defaultValue:G??"",onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>H(Number.parseFloat(E.currentTarget.value),null)},`w:${G??""}`)]}),R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"H"}),K("input",{className:"st-cp-numin",type:"number",min:"1","aria-label":"artboard height",readOnly:!z,title:z?void 0:"Hug — grows to fit content. Switch to Fixed to set an exact height.",defaultValue:q??"",onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{if(!z)return;H(null,Number.parseFloat(E.currentTarget.value))}},`h:${q??""}:${z}`)]})]}),K("div",{style:{padding:"0 12px 8px"},children:R("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:Z??"",onChange:(E)=>{let A=aV[E.currentTarget.value];if(A)H(A.width,A.height)},children:[K("option",{value:"",disabled:!0,children:Z?aV[Z].label:"Preset size…"}),Object.entries(aV).map(([E,A])=>R("option",{value:E,children:[A.label," — ",A.width,"×",A.height]},E))]})}),K("div",{style:{padding:"0 12px 8px"},children:R("div",{className:"st-cp-modeseg",role:"group","aria-label":"artboard height sizing mode",children:[K("span",{className:"st-cp-modeax","aria-hidden":"true",children:"H"}),[[!1,"Hug"],[!0,"Fixed"]].map(([E,A])=>K("button",{type:"button",className:`st-cp-modebtn${z===E?" is-active":""}`,"aria-pressed":z===E,onClick:()=>D(E),title:`${A} height`,children:A},A))]})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),R("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[R("div",{className:"st-cp-num",style:{width:"100%"},children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Bg"}),K("input",{className:"st-cp-numin",type:"text","aria-label":"artboard background",placeholder:"var(--bg-1)",defaultValue:U,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>w({background:E.currentTarget.value.trim()||null})},`bg:${U}`)]}),K("select",{className:"st-cp-nsel","aria-label":"artboard body layout",value:F,onChange:(E)=>w({layout:E.currentTarget.value||null}),children:Lz0.map(([E,A])=>K("option",{value:E,children:A},E))}),R("div",{style:{display:"flex",gap:8},children:[R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Pad"}),K("input",{className:"st-cp-numin",type:"number",min:"0","aria-label":"artboard padding",defaultValue:B,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{let A=E.currentTarget.value;w({padding:A===""?null:Number.parseFloat(A)})}},`pad:${B}`)]}),R("div",{className:"st-cp-num",children:[K("span",{className:"st-cp-numlead","aria-hidden":"true",children:"Gap"}),K("input",{className:"st-cp-numin",type:"number",min:"0","aria-label":"artboard gap",defaultValue:L,onKeyDown:(E)=>{if(E.key==="Enter")E.currentTarget.blur()},onBlur:(E)=>{let A=E.currentTarget.value;w({gap:A===""?null:Number.parseFloat(A)})}},`gap:${L}`)]})]})]})]})}var Ys=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i;function Oz0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;if((X.tag||"").toLowerCase()!=="img")return null;let J=X.html||"",Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=Ys.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function Mz0({selected:X,onClose:J,layersTree:Q,canvasFile:Y,onSelectLayer:W,onHoverLayer:G,onReorderLayer:q,layersBusyRef:H,cfg:Z,onOptimistic:z,onRecordEdit:U,onReplaceMedia:B,onResizeArtboard:F,onSetArtboardHug:L,onSetArtboardStyle:D,onUndoRedo:w,editScope:E,tab:A,onTabChange:O,width:P,resizing:I,photoSel:T,photoRev:C,onPhotoEdit:S,onPhotoRemoveBackground:j,onPhotoRecordEdit:b,onPhotoUndoRedo:h,layersOnly:d=!1,hideLayersTab:i=!1,cpMode:v,onSetCpMode:n}){let[Y0,g]=u.useState("inspect"),G0=d?"layers":A??Y0,e=(U0)=>{g(U0),O?.(U0)},[l,Z0]=u.useState(()=>new Set),[r,a]=u.useState(()=>new Map),c=(U0)=>{let y0=`${U0.id}:${U0.index}`;return r.has(y0)?r.get(y0):!!U0.hidden},[V0,o0]=u.useState(null),[U8,V8]=u.useState(""),L0=q?(U0,y0,w0)=>{if(H?.current)return;let R0=w0==="before"?`before ${y0.label}`:w0==="after"?`after ${y0.label}`:`into ${y0.label}`;V8(`Moved ${U0.label} ${R0}`),q(U0.id,y0.id,w0,{idIndex:U0.index,refIndex:y0.index})}:void 0,t0=()=>{let U0=[];return function y0(w0,R0,I0){(w0||[]).forEach((O8,r0)=>{if(U0.push({node:O8,depth:R0,parentNode:I0,siblings:w0,pos:r0}),O8.children&&O8.children.length&&!l.has(`${O8.id}:${O8.index}`))y0(O8.children,R0+1,O8)})}(Q?.nodes,0,null),U0},n0=(U0)=>{if(U0.key!=="ArrowUp"&&U0.key!=="ArrowDown")return;if(!c0)return;let y0=t0(),w0=y0.findIndex((r0)=>r0.node.id===c0.id&&r0.node.index===c0.index);if(w0<0)return;let R0=U0.key==="ArrowDown"?1:-1,I0=y0[w0];if(!U0.altKey){let r0=y0[w0+R0];if(r0)U0.preventDefault(),W?.(r0.node);return}if(!L0||!Array.isArray(I0.siblings))return;U0.preventDefault();let O8=(r0)=>r0&&r0.children&&r0.children.length&&!l.has(`${r0.id}:${r0.index}`);if(!U0.shiftKey){if(R0<0&&I0.pos>0)L0(I0.node,I0.siblings[I0.pos-1],"before");else if(R0>0&&I0.pos<I0.siblings.length-1)L0(I0.node,I0.siblings[I0.pos+1],"after");return}if(R0>0){let r0=I0.siblings[I0.pos+1];if(r0)L0(I0.node,r0,O8(r0)?"inside-start":"after");else if(I0.parentNode)L0(I0.node,I0.parentNode,"after")}else{let r0=I0.siblings[I0.pos-1];if(r0)L0(I0.node,r0,O8(r0)?"inside-end":"before");else if(I0.parentNode)L0(I0.node,I0.parentNode,"before")}},Q8=u.useRef(null),v8=u.useRef(null),i8=(U0,y0,w0)=>{if(!L0||U0.button!==0||U0.metaKey||U0.ctrlKey||U0.shiftKey||U0.altKey)return;if(H?.current)return;let{clientX:R0,clientY:I0}=U0,O8=new Set([w0]);(function Q9(G7){(G7.children||[]).forEach((r7)=>{O8.add(`${r7.id}:${r7.index}`),Q9(r7)})})(y0);let r0=14,d0=6,$8=[];(function Q9(G7,r7){(G7||[]).forEach((B9)=>{let p9=`${B9.id}:${B9.index}`;if($8.push({node:B9,key:p9,id:B9.id,depth:r7,tag:B9.tag}),B9.children&&B9.children.length&&!l.has(p9))Q9(B9.children,r7+1)})})(Q?.nodes,0);let v9=new Map($8.map((Q9)=>[Q9.key,Q9])),r8=!1,k0=(Q9)=>{if(!r8){if(Math.hypot(Q9.clientX-R0,Q9.clientY-I0)<4)return;r8=!0}let G7=Q9.clientX-R0,r7=Q9.clientY-I0,B9=null,p9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((a8)=>({rect:a8.getBoundingClientRect(),it:v9.get(a8.getAttribute("data-layer-key"))})).filter((a8)=>a8.it&&a8.it.key!==w0);if(p9.length){let a8=p9[0].rect.left,H6=p9[0].rect.right,j6=p9.length;for(let A0=0;A0<p9.length;A0++)if(Q9.clientY<p9[A0].rect.top+p9[A0].rect.height/2){j6=A0;break}let Y9=p9[j6-1]?.it||null,q7=p9[j6]?.it||null,Z5=Math.round((Q9.clientX-a8-d0)/r0),rX=Y9?Y9.depth+(Fz0.has(Y9.tag)?0:1):0,e6=q7?q7.depth:0,H7=Math.max(e6,Math.min(Z5,rX)),o=null,B0="before",H0=0;if(!Y9){if(q7)o=q7,B0="before",H0=q7.depth}else if(H7>Y9.depth)o=Y9,B0="inside-start",H0=Y9.depth+1;else if(H7===Y9.depth)o=Y9,B0="after",H0=Y9.depth;else{for(let A0=j6-1;A0>=0;A0--)if(p9[A0].it.depth===H7){o=p9[A0].it;break}if(!o)o=Y9;B0="after",H0=H7}if(o&&o.key!==w0&&!O8.has(o.key)){let A0=Y9?p9[j6-1].rect.bottom:p9[0].rect.top,p0=a8+d0+H0*r0;B9={refId:o.id,position:B0,node:o.node,y:A0,left:p0,w:Math.max(24,H6-p0)}}}let F7={key:w0,node:y0,dx:G7,dy:r7,target:B9};Q8.current=F7,o0(F7)},z8=()=>{window.removeEventListener("pointermove",k0),window.removeEventListener("pointerup",nX),window.removeEventListener("keydown",t6,!0)},m7=()=>{let Q9=(G7)=>{G7.preventDefault(),G7.stopImmediatePropagation(),document.removeEventListener("click",Q9,!0)};document.addEventListener("click",Q9,!0),setTimeout(()=>document.removeEventListener("click",Q9,!0),300)},nX=()=>{z8();let Q9=Q8.current;if(Q8.current=null,o0(null),r8&&Q9?.target)m7(),L0(Q9.node,Q9.target.node,Q9.target.position)},t6=(Q9)=>{if(Q9.key!=="Escape")return;if(Q9.preventDefault(),Q9.stopImmediatePropagation(),z8(),Q8.current=null,o0(null),r8)m7()};window.addEventListener("pointermove",k0),window.addEventListener("pointerup",nX),window.addEventListener("keydown",t6,!0)},g8=(U0)=>Z0((y0)=>{let w0=new Set(y0);if(w0.has(U0))w0.delete(U0);else w0.add(U0);return w0}),z9=(U0)=>{let y0=`${U0.id}:${U0.index}`,w0=c(U0),R0=!w0;if(a((I0)=>new Map(I0).set(y0,R0)),z?.({id:U0.id,artboardId:Q?.artboardId??null,index:U0.index,prop:"display",value:R0?"none":null}),!Y||!U0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(R0?{canvas:Y,id:U0.id,property:"display",value:"none"}:{canvas:Y,id:U0.id,property:"display",reset:!0})}).catch(()=>{}),U?.({op:"css",canvas:Y,id:U0.id,key:"display",before:w0?"none":null,after:R0?"none":null})},c0=Array.isArray(X)?X[0]:X,d8=T?{asset:T.asset,kind:"annotation-image"}:(()=>{let U0=Oz0(c0);return U0?{asset:U0,kind:"artboard-img"}:null})(),o8=d8?.kind==="annotation-image",j9=(U0)=>{if(!(U0.metaKey||U0.ctrlKey)||U0.altKey)return;let y0=U0.key.toLowerCase();if(y0==="z")U0.preventDefault(),h?.(U0.shiftKey?"redo":"undo");else if(y0==="y")U0.preventDefault(),h?.("redo")},f0=o8?"photo":G0==="photo"&&!d8?"inspect":G0,z0=(U0,y0,w0)=>R("button",{type:"button",className:"st-rp-tab"+(f0===U0?" is-active":""),onClick:()=>e(U0),children:[K(n8,{name:w0,size:14}),y0]}),F0=c0?.bounds||null;return R("aside",{className:"st-rpanel"+(I?" is-resizing":""),style:P?{width:P,flexBasis:P}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[R("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:d?{display:"none"}:void 0,children:[o8?z0("photo","Photo","image"):R(Q0,{children:[z0("inspect","Inspect","sliders"),!i&&z0("layers","Layers","layers"),z0("css","CSS","code"),d8?z0("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(n8,{name:"x",size:14})})]}),c0?.id&&!(Array.isArray(X)&&X.length>1)&&E?R("div",{className:`st-scope st-scope--${E.scope}`,title:E.scope==="shared"?`Editing this element's style changes ${E.affects} place${E.affects===1?"":"s"}${E.componentName?` (component ${E.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),E.scope==="shared"?`Shared${E.componentName?` · ${E.componentName}`:""} · edits ${E.affects} place${E.affects===1?"":"s"}`:"Local · this element only"]}):null,K("div",{className:"st-rp-body",children:f0==="photo"&&d8?K("div",{onKeyDown:j9,children:K(dy,{asset:d8.asset,ColorPicker:Xs,StIcon:n8,onEdit:(U0)=>S?.(d8.asset,U0),onRemoveBackground:j,onRecordEdit:(U0,y0)=>b?.(d8.asset,U0,y0)},`${d8.asset}:${C??0}`)}):!c0?K("div",{className:"st-rp-empty",children:R("p",{children:["Hold ",K(s6,{children:"⌘"})," inside the canvas and click an element to inspect it."]})}):f0==="inspect"?R(Q0,{children:[K("div",{className:"st-rp-hd",children:c0.selector||c0.tag||"element"}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:F0?Math.round(F0.x):"—",readOnly:!0,"aria-label":"x position"})]}),R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:F0?Math.round(F0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),R("div",{className:"st-insp-fields",children:[R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:F0?Math.round(F0.w):"—",readOnly:!0,"aria-label":"width"})]}),R("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:F0?Math.round(F0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:c0.tag||"—"})})]}),c0.classes?R("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:c0.classes})})]}):null,K(Nz0,{el:c0})]}):f0==="layers"?R(Q0,{children:[R("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?R(Q0,{children:[L0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:v8,onKeyDown:n0,children:Q.nodes.map((U0,y0)=>K(Js,{node:U0,depth:0,selectedId:c0.id,selectedIndex:c0.index,collapsed:l,hiddenOverride:r,onToggle:g8,onSelect:(w0)=>{W?.(w0),v8.current?.focus()},onHover:(w0)=>G?.(w0),onToggleVisibility:z9,onReorder:L0,onRowPointerDown:i8,dragState:V0},`${U0.id}:${U0.index}`))}),V0?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:V0.target.left,top:V0.target.y-1,width:V0.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:U8})]}):Array.isArray(c0.dom_path)&&c0.dom_path.length?c0.dom_path.map((U0,y0)=>R("div",{className:"st-layer"+(y0===c0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+y0*12},children:[K(n8,{name:"square",size:13}),U0]},y0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!c0.id&&Qs(c0)?K(Dz0,{el:c0,onResizeArtboard:F,onSetArtboardHug:L,onSetArtboardStyle:D}):K(Kz0,{el:c0,cfg:Z,onOptimistic:z,onRecordEdit:U,onReplaceMedia:B,onUndoRedo:w,mode:v,onSetMode:n})})]})}function wz0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[q,H]=u.useState(null),[Z,z]=u.useState(null),U=u.useRef(null);u.useEffect(()=>{U.current=Z},[Z]);let[B,F]=u.useState(null);u.useEffect(()=>{let x=Array.isArray(Z)?Z.length===1?Z[0]:null:Z,y=x&&typeof x.id==="string"?x.id:null;if(!y||!q){F(null);return}let X0=new AbortController,K0=new URLSearchParams({canvas:q,id:y});return fetch(`/_api/edit-scope?${K0}`,{signal:X0.signal}).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(W0?.ok)F(W0)}).catch(()=>{}),()=>X0.abort()},[Z,q]);let L=u.useRef([]),D=u.useCallback((x)=>{if(!x?.id||!x.file)return;for(let y of L.current)clearTimeout(y);L.current=[50,450,1200,2500,5000].map((y)=>setTimeout(()=>{let X0=U.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.id!==x.id||K0.file!==x.file)return;let W0=j8.current.get(x.file);if(!W0?.contentWindow)return;try{W0.contentWindow.postMessage({dgn:"select-by-id",id:x.id,artboardId:x.artboardId??null,index:x.index??0},"*")}catch{}},y))},[]),w=u.useRef(null),E=u.useRef(null),A=u.useRef(null),O=u.useRef(null),P=u.useRef(!1),I=u.useRef(null),[T,C]=u.useState(null),[S,j]=u.useState(!1),[b,h]=u.useState(null),[d,i]=u.useState(null),[v,n]=u.useState(null),[Y0,g]=u.useState(null),[G0,e]=u.useState(!1),[l,Z0]=u.useState(null),[r,a]=u.useState(""),[c,V0]=u.useState(null),[o0,U8]=u.useState(null),V8=u.useRef(null),L0=ja("maude-sb-w",{min:200,max:420,def:252}),t0=ja("maude-rp-w",{min:260,max:480,def:304}),[n0,Q8]=u.useState(null),v8=u.useRef(null);u.useEffect(()=>{if(!n0)return;let x=(X0)=>{let K0=v8.current?.getBoundingClientRect();if(!K0)return;if(n0==="sb")L0.setW(X0.clientX-K0.left);else t0.setW(K0.right-X0.clientX)},y=()=>Q8(null);return window.addEventListener("pointermove",x),window.addEventListener("pointerup",y),()=>{window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",y)}},[n0,L0.setW,t0.setW]);let i8=u.useCallback((x)=>{clearTimeout(V8.current),V8.current=setTimeout(()=>{U8((y)=>y===x?null:y)},2500)},[]);u.useEffect(()=>{if(!o0)return;let x=setTimeout(()=>U8(null),15000);return()=>clearTimeout(x)},[o0]);let[g8,z9]=u.useState({designRel:".design"}),c0=u.useCallback(()=>{fetch("/_config").then((x)=>x.json()).then((x)=>{let y=(x.designRoot||".design").replace(/^\/+|\/+$/g,"");z9((X0)=>({...X0,designRel:y,tokensCssRel:x.tokensCssRel,designSystems:x.designSystems,canvasOrigin:x.canvasOrigin}))}).catch(()=>{})},[]);u.useEffect(()=>{c0()},[c0]),u.useEffect(()=>{let x=!1;return fetch("/_sync-status").then((y)=>y.json()).then((y)=>{if(x||!y||y.linked===!1)return;i(y)}).catch(()=>{}),()=>{x=!0}},[]),u.useEffect(()=>{let x=!1;return fetch("/_api/git/status").then((y)=>y.json()).then((y)=>{if(!x&&y)n(y)}).catch(()=>{}),()=>{x=!0}},[]);let[d8,o8]=u.useState({}),[j9,f0]=u.useState(null),[z0,F0]=u.useState(!1),[U0,y0]=u.useState("open"),[w0,R0]=u.useState(zK0),[I0,O8]=u.useState(()=>{return wE(Ea,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Ea,JSON.stringify(I0))}catch{}},[I0]);let[r0,d0]=u.useState(null),[$8,v9]=u.useState(()=>dG(Pa,!0)),[r8,k0]=u.useState(()=>dG(Aa,!1)),[z8,m7]=u.useState(()=>wE(_a,{})),[nX,t6]=u.useState(!1),[Q9,G7]=u.useState(!1),[r7,B9]=u.useState(!1),[p9,F7]=u.useState(!1),[a8,H6]=u.useState(!1),{report:j6}=zM(G9()),[Y9,q7]=u.useState(!1),[Z5,rX]=u.useState(!1),[e6,H7]=u.useState(null),[o,B0]=u.useState(!1),[H0,A0]=u.useState(!1),[p0,M8]=u.useState(!1),[T8,b8]=u.useState(!1),[p8,y9]=u.useState(()=>wE(Ta,qZ)),[c9,u7]=u.useState(()=>{try{let x=localStorage.getItem(Ca);if(x==="separate"||x==="in-inspector")return x}catch{}return"separate"}),[NX,i5]=u.useState(!1),[l7,iQ]=u.useState([]),[K5,z5]=u.useState(0),[oQ,x9]=u.useState(!1),[xY,Z7]=u.useState(!1),[aX,V5]=u.useState(!1),[zZ,w7]=u.useState(1),[hY,VZ]=u.useState(216),[i9,pG]=u.useState(null),[sX,N7]=u.useState([]),[o5,P9]=u.useState([]),[N9,U5]=u.useState(0),_6=u.useMemo(()=>{if(!l7.length)return null;return(l7.find((y)=>y.durationInFrames===N9)??l7[0]).id},[l7,N9]),B5=u.useRef(null);u.useEffect(()=>{B5.current=_6},[_6]);let gY=u.useRef(0);u.useEffect(()=>{gY.current=K5},[K5]);let[y6,UZ]=u.useState(null),BZ=u.useRef(null);u.useEffect(()=>{BZ.current=y6},[y6]);let[LX,n5]=u.useState(!1),[FZ,cG]=u.useState(!1),[NZ,iG]=u.useState(!1),oG=u.useRef(LX);u.useEffect(()=>{if(oG.current=LX,LX){iG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[LX]);let nG=u.useCallback(()=>{if(!oG.current||document.hidden){iG(!0);try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification("Claude finished",{body:"Your assistant turn is ready in Maude."})}catch{}}},[]),[r5,F5]=u.useState("inspect"),[LZ,tX]=u.useState(null),XX=u.useRef({undo:[],redo:[]}),[SJ,DZ]=u.useState(0),[E6,mY]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),rG=u.useRef(E6);u.useEffect(()=>{rG.current=E6;try{localStorage.setItem("maude-auto-open-inspector",E6?"1":"0")}catch{}},[E6]);let aG=u.useRef(!1);u.useEffect(()=>{aG.current=p0||z0||G0||LX},[p0,z0,G0,LX]);let uY=u.useRef({open:{},side:qZ});uY.current={open:{tree:$8,layers:T8,inspector:p0,comments:z0,changes:G0,assistant:LX},side:p8};let f6=u.useCallback((x,y)=>{if(x==="tree")v9(y);else if(x==="layers")b8(y);else if(x==="inspector")M8(y);else if(x==="comments")F0(y);else if(x==="changes")e(y);else if(x==="assistant")n5(y)},[]),a5=u.useCallback((x)=>uY.current.side?.[x]||qZ[x],[]),v6=u.useCallback((x)=>{let y=a5(x);f6(x,!0);for(let X0 of kE)if(X0.id!==x&&a5(X0.id)===y)f6(X0.id,!1)},[f6,a5]),$J=u.useCallback((x)=>{if(uY.current.open?.[x])f6(x,!1);else v6(x)},[v6,f6]),a7=v6,L9=$J,o9=u.useCallback((x)=>{if(!rG.current)return;if(!x||!x.id)return;if(aG.current)return;a7("inspector"),F5("css")},[a7]),N5=u.useCallback(()=>i5((x)=>!x),[]),P6=Gf(CE),L5=ny(),[lY,OZ]=u.useState(!1),[D5,sG]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let x=!0;return gj().then((y)=>{if(!x)return;if(OZ(!!y),!y&&!dG(wa,!1))sG(!0)}).catch(()=>{}),()=>{x=!1}},[]);let nQ=u.useCallback(()=>{sG(!1);try{localStorage.setItem(wa,"1")}catch{}},[]),[MZ,eX]=u.useState(null);u.useEffect(()=>{if(!G9())return;let x;return dj((y)=>eX(y&&typeof y==="object"?y:{})).then((y)=>{x=y}).catch(()=>{}),()=>{try{x?.()}catch{}}},[]);let[O5,tG]=u.useState(null),[DX,wZ]=u.useState(()=>!dG(Ma,!1)),OX=u.useCallback((x)=>{tG(Array.isArray(x)&&x.length?x:null)},[]),AZ={setup:(x)=>{if(!x)return;if((x.canvas||x.requireSelection)&&W.length===0)v6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(x.inspector||x.tab||x.requireSelection)a7("inspector");if(x.tab)F5(x.tab);if(x.changes)a7("changes")}},dY=u.useCallback(()=>{wZ(!1);try{localStorage.setItem(Ma,"1")}catch{}},[]),[M5,rQ]=u.useState(()=>dG(Ia,!0)),[eG,_Z]=u.useState(!1),[XJ,Xq]=u.useState(()=>dG(Ra,!1)),[JJ,Jq]=u.useState(()=>dG(ka,!1)),[x6,pY]=u.useState(!1),[EZ,aQ]=u.useState(0),[cY,PZ]=u.useState(null),[iY,sQ]=u.useState(!1),s5=u.useRef(null),tQ=u.useRef(null),j8=u.useRef(new Map),E8=u.useCallback((x)=>{let y=q?j8.current.get(q):null;if(!y||!y.contentWindow)return;try{y.contentWindow.postMessage(x,"*")}catch{}},[q]),t5=u.useCallback((x,y)=>E8({dgn:"photo-preview",asset:x,edit:y}),[E8]),MX=u.useCallback((x,y,X0)=>{XX.current.undo.push({asset:x,before:y,after:X0}),XX.current.redo.length=0},[]),oY=u.useCallback((x)=>{let y=x?XX.current.redo:XX.current.undo;if(!y.length)return!1;let X0=y.pop();(x?XX.current.undo:XX.current.redo).push(X0);let K0=(x?X0.after:X0.before)||{};return t5(X0.asset,K0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(K0)}).catch(()=>{}),DZ((W0)=>W0+1),!0},[t5]),nY=u.useCallback(async(x)=>{E8({dgn:"photo-busy",asset:x,busy:!0});try{let y=await fetch(`/${x.replace(/^\/+/,"")}`);if(!y.ok)return null;let X0=await y.blob(),{removeBackground:K0}=await Promise.resolve().then(() => (Oa(),Da)),W0=await K0(X0),h0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":W0.type||"image/png"},body:W0}),m=await h0.json().catch(()=>({}));if(h0.ok&&m.path)return{maskAsset:m.path};return null}catch(y){return console.error("[photo] background removal failed",y),null}finally{E8({dgn:"photo-busy",asset:x,busy:!1})}},[E8]);u.useEffect(()=>{let x=(K0)=>Array.from(K0.dataTransfer?.types??[]).includes("Files"),y=(K0)=>{if(x(K0))K0.preventDefault()},X0=(K0)=>{if(x(K0))K0.preventDefault()};return document.addEventListener("dragover",y),document.addEventListener("drop",X0),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",X0)}},[]);let e5=u.useRef({});e5.current={open:NX,comps:l7,frame:K5,total:N9,playing:oQ,compId:_6,muted:aX,loop:xY,sequences:sX,post:E8,canvas:q};let XQ=u.useRef({undo:[],redo:[]}),bJ=u.useCallback((x,y,X0)=>{if(typeof y!=="number")return;if(XQ.current.undo.push({canvas:x,seq:y,label:X0}),XQ.current.redo=[],XQ.current.undo.length>50)XQ.current.undo.shift()},[]),RZ=u.useCallback((x)=>{let y=XQ.current,X0=x==="undo"?y.undo:y.redo,K0=x==="undo"?y.redo:y.undo,W0=e5.current.canvas,h0=-1;for(let M0=X0.length-1;M0>=0;M0--)if(X0[M0].canvas===W0){h0=M0;break}if(h0<0){g7(x==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let m=X0[h0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:m.canvas,seq:m.seq,dir:x})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(X0.splice(h0,1),M0?.ok)K0.push(m),g7(`${x==="undo"?"Undid":"Redid"}: ${m.label}`,!0);else g7(`${x==="undo"?"Undo":"Redo"} skipped: ${M0?.error||"failed"}`)}).catch(()=>g7(`${x==="undo"?"Undo":"Redo"} failed: network error`))},[]);u.useEffect(()=>{let x=(y)=>{let X0=e5.current;if(!X0.open||!X0.comps?.length)return;let K0=y.target,W0=K0?.tagName;if(W0==="INPUT"||W0==="TEXTAREA"||W0==="SELECT"||K0?.isContentEditable)return;let h0=X0.comps[0]?.fps||30,m=Math.max(1,X0.total),M0=(x0)=>{let F8=Math.max(0,Math.min(m-1,Math.round(x0)));z5(F8),x9(!1),X0.post({dgn:"timeline-seek",frame:F8,id:X0.compId})},T0=()=>{let x0=new Set([0,m-1]);for(let F8 of X0.sequences||[]){x0.add(F8.from);for(let D8 of F8.keyframes||[])x0.add(D8.from),x0.add(D8.to)}return[...x0].filter((F8)=>F8>=0&&F8<m).sort((F8,D8)=>F8-D8)};if((y.metaKey||y.ctrlKey)&&(y.key==="z"||y.key==="Z")){y.preventDefault(),RZ(y.shiftKey?"redo":"undo");return}if(y.key===" "||y.code==="Space")if(y.preventDefault(),X0.playing)x9(!1),X0.post({dgn:"timeline-pause",id:X0.compId});else x9(!0),X0.post({dgn:"timeline-mute",muted:X0.muted,id:X0.compId}),X0.post({dgn:"timeline-loop",loop:X0.loop,id:X0.compId}),X0.post({dgn:"timeline-play",id:X0.compId});else if(y.key==="ArrowRight")y.preventDefault(),M0(X0.frame+(y.shiftKey?h0:1));else if(y.key==="ArrowLeft")y.preventDefault(),M0(X0.frame-(y.shiftKey?h0:1));else if(y.key==="Home")y.preventDefault(),M0(0);else if(y.key==="End")y.preventDefault(),M0(m-1);else if(y.key==="."){y.preventDefault();let x0=T0().find((F8)=>F8>X0.frame);if(x0!=null)M0(x0)}else if(y.key===","){y.preventDefault();let x0=T0().reverse().find((F8)=>F8<X0.frame);if(x0!=null)M0(x0)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),u.useEffect(()=>{iQ([]),z5(0),x9(!1);let x=setTimeout(()=>E8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(x)},[q,E8]);let[wX,eQ]=u.useState(""),[Qq,rY]=u.useState([]);u.useEffect(()=>{if(!NX||l7.length===0||!q||q===h8){eQ(""),rY([]);return}let x=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(q)}`).then((y)=>y.ok?y.json():null).then((y)=>{if(x&&y?.ok&&typeof y.source==="string")eQ(y.source)}).catch(()=>{}),()=>{x=!1}},[NX,l7,q]),u.useEffect(()=>{if(!NX||!q||q===h8||!wX){rY([]);return}let x=!0,y=y6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${y?`&artboardId=${encodeURIComponent(y)}`:""}`;return fetch(X0).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(!x)return;let W0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((h0)=>h0.kind==="sequence"):[];rY(W0)}).catch(()=>{}),()=>{x=!1}},[NX,q,wX,y6]),u.useEffect(()=>{if(!wX){N7([]),P9([]),U5(0);return}let x=l7[0]?.durationInFrames||0,y=i9??Z?.artboardId??null,X0=Iy(wX,x,y);UZ(X0.artboardId??y??null);let K0=X0.sequences.map((W0,h0)=>{let m=Qq[h0];if(!m)return W0;return{...W0,mediaTag:m.mediaTag??W0.mediaTag,mediaSrc:m.mediaSrc??W0.mediaSrc,replaceable:!!(m.mediaCdId||m.mediaArrayRef),layers:Array.isArray(m.layers)?m.layers:[],hidden:!!m.hidden}});N7(K0),P9(X0.audio||[]),U5(X0.total)},[wX,Qq,Z,l7,i9]);let Yq=u.useCallback(()=>{rQ((x)=>{let y=!x,X0=q?j8.current.get(q):null;if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"view-annotations",visible:y},"*")}catch{}return y})},[q]),JX=u.useCallback((x)=>{for(let y of j8.current.values())try{y.contentWindow.postMessage({dgn:"view-chrome",...x},"*")}catch{}},[]),Wq=u.useCallback(()=>{Xq((x)=>{let y=!x;return JX({minimap:y}),y})},[JX]),Gq=u.useCallback(()=>{Jq((x)=>{let y=!x;return JX({zoom:y}),y})},[JX]),kZ=u.useCallback(()=>{pY((x)=>{let y=!x;return JX({present:y}),y})},[JX]),aY=u.useCallback(()=>{pY(!1),JX({present:!1})},[JX]);u.useEffect(()=>{let x=!1;return fetch("/_api/git-user").then((y)=>y.json()).then((y)=>{if(x)return;let X0=y&&typeof y.name==="string"?y.name.trim():"";if(X0)PZ(X0)}).catch(()=>{}),()=>{x=!0}},[]),u.useEffect(()=>{if(!q||q===h8){aQ(0);return}let x=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(q)).then((y)=>y.json()).then((y)=>{if(x)return;let X0=Array.isArray(y?.artboards)?y.artboards.length:0;aQ(X0)}).catch(()=>{if(!x)aQ(0)}),()=>{x=!0}},[q]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",w0),localStorage.setItem(ra,w0)}catch{}for(let x of j8.current.values())try{x.contentWindow.postMessage({dgn:"theme",theme:w0},"*")}catch{}},[w0]),u.useEffect(()=>{try{localStorage.setItem(Pa,$8?"1":"0")}catch{}},[$8]),u.useEffect(()=>{try{localStorage.setItem(Aa,r8?"1":"0")}catch{}},[r8]),u.useEffect(()=>{try{localStorage.setItem(_a,JSON.stringify(z8))}catch{}},[z8]),u.useEffect(()=>{try{localStorage.setItem(Ra,XJ?"1":"0")}catch{}},[XJ]),u.useEffect(()=>{try{localStorage.setItem(ka,JJ?"1":"0")}catch{}},[JJ]),u.useEffect(()=>{try{localStorage.setItem(Ia,M5?"1":"0")}catch{}},[M5]),u.useEffect(()=>{let x=!1;return fetch("/_api/ui-prefs").then((y)=>y.ok?y.json():Promise.reject(Error(`HTTP ${y.status}`))).then((y)=>{if(x||!y||typeof y!=="object")return;if(y.theme==="light"||y.theme==="dark")R0(y.theme);if(typeof y.minimap==="boolean")Xq(y.minimap);if(typeof y.zoom==="boolean")Jq(y.zoom);if(typeof y.annotations==="boolean")rQ(y.annotations);if(typeof y.autoOpenInspector==="boolean")mY(y.autoOpenInspector);if(y.panelSides&&typeof y.panelSides==="object")y9({...qZ,...y.panelSides});if(y.layersMode==="separate"||y.layersMode==="in-inspector")u7(y.layersMode)}).catch(()=>{}).finally(()=>{if(!x)_Z(!0)}),()=>{x=!0}},[]),u.useEffect(()=>{if(!eG)return;KK0({theme:w0,minimap:XJ,zoom:JJ,annotations:M5,autoOpenInspector:E6,panelSides:p8,layersMode:c9})},[eG,w0,XJ,JJ,M5,E6,p8,c9]),u.useEffect(()=>{try{localStorage.setItem(Ta,JSON.stringify(p8))}catch{}},[p8]),u.useEffect(()=>{try{localStorage.setItem(Ca,c9)}catch{}},[c9]);let IZ=u.useCallback((x,y)=>{m7((X0)=>{let K0=X0[x],W0=K0===void 0?y:K0;return{...X0,[x]:!W0}})},[]),AX=u.useCallback(()=>{R0((x)=>x==="dark"?"light":"dark")},[]),S9=u.useCallback(async()=>{try{let y=await(await fetch("/_index-data")).json();Y(y.project||"Design");let X0=y.groups.map((K0)=>({...K0,tree:FK0(K0.paths,K0.stripPrefix)}));J(X0),z9((K0)=>({...K0,canvasDesignSystems:y.canvasDesignSystems??{},canvasKinds:y.canvasKinds??{}}))}catch(x){console.error("failed to load tree",x)}},[]);u.useEffect(()=>{S9()},[S9]);let QJ=u.useCallback(async(x)=>{try{let y=x?`/_system-data?ds=${encodeURIComponent(x)}`:"/_system-data",X0=await fetch(y);if(!X0.ok){console.error("failed to load system-data",X0.status);return}let K0=await X0.json();if(!x&&K0?.defaultDesignSystem&&!K0.ds){V0(K0);let W0=await fetch(`/_system-data?ds=${encodeURIComponent(K0.defaultDesignSystem)}`);if(W0.ok)V0(await W0.json());return}V0(K0)}catch(y){console.error("failed to load system-data",y)}},[]),qq=u.useCallback(async()=>{try{let y=await(await fetch("/_comments-all")).json();o8(y||{})}catch(x){console.error("failed to load comments",x)}},[]);u.useEffect(()=>{qq()},[qq]),u.useEffect(()=>{function x(){let y=location.protocol==="https:"?"wss:":"ws:",X0=new WebSocket(y+"//"+location.host+"/_ws");tQ.current=X0,X0.addEventListener("open",()=>j(!0)),X0.addEventListener("close",()=>{j(!1),setTimeout(x,1000)}),X0.addEventListener("error",()=>{}),X0.addEventListener("message",(K0)=>{try{let W0=JSON.parse(K0.data);if(W0.type==="snapshot"&&W0.state)z((h0)=>ia(W0.state.selected,h0));else if(W0.type==="selected"){let h0=W0.selected,m=Array.isArray(h0)?h0[0]:h0,M0=U.current,T0=Array.isArray(M0)?M0[0]:M0;if(z((x0)=>ia(h0,x0)),m?.id&&m.file&&(!T0||T0.id!==m.id||T0.file!==m.file))D(m)}else if(W0.type==="comments"&&typeof W0.file==="string")o8((h0)=>({...h0,[W0.file]:W0.comments||[]}));else if(W0.type==="ai-activity"&&typeof W0.file==="string"){if(sQ(!0),s5.current)clearTimeout(s5.current);s5.current=setTimeout(()=>sQ(!1),8000);for(let h0 of j8.current.values())try{h0.contentWindow.postMessage({dgn:"ai-activity",file:W0.file,entry:W0.entry},"*")}catch{}}else if(W0.type==="export:job"&&W0.payload)L5.upsert(W0.payload);else if(W0.type==="sync:status"&&W0.payload)i(W0.payload);else if(W0.type==="canvas-list-update")S9();else if(W0.type==="config-updated")c0();else if(W0.type==="acp-focus"){if(G9())a7("assistant")}else if(W0.type==="git-status"&&W0.payload)n(W0.payload);else if(W0.type==="git-lifecycle"&&W0.payload){h(W0.payload);for(let h0 of j8.current.values())try{h0.contentWindow.postMessage({dgn:"git-lifecycle",payload:W0.payload},"*")}catch{}}}catch{}})}return x(),()=>tQ.current&&tQ.current.close()},[S9,c0]);function I7(x){let y=tQ.current;try{if(y&&y.readyState===1)y.send(JSON.stringify(x))}catch{}}let s7=u.useCallback(async()=>{try{let x=await fetch("/_api/git/status");if(x.ok)n(await x.json())}catch{}},[]),Z6=u.useCallback(async()=>{try{let x=await fetch("/_api/git/status?remote=1");if(!x.ok)return;let y=await x.json();if(y&&y.repo!==!1)g({remoteAhead:!!y.remoteAhead,behind:y.behind||0})}catch{}},[]),R6=u.useCallback(async(x,y)=>{try{let X0=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y||{})}),K0=await X0.json().catch(()=>({}));return{ok:X0.ok,...K0}}catch(X0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),sY=u.useCallback(async(x,y)=>{let X0=await R6("/_api/git/commit",{message:x,files:y});if(X0.ok)await s7();return X0},[R6,s7]),X4=u.useCallback(async(x)=>{let y=await R6("/_api/git/discard",{files:x});if(y.ok)await s7();return y},[R6,s7]),tY=u.useCallback(async()=>{let x=await R6("/_api/git/push",{});if(x.ok)await s7(),Z6();return x},[R6,s7,Z6]),J4=u.useCallback(async()=>{let x=await R6("/_api/git/pull",{});if(x.ok)await s7(),Z6();if(x.conflict&&Array.isArray(x.files)&&x.files.length)Z0({file:x.files[0],conflict:!0});return x},[R6,s7,Z6]),eY=u.useCallback(async(x)=>{let y=await R6("/_api/git/resolve",{choice:x});if(y.ok)await s7(),Z6();return y},[R6,s7,Z6]),Hq=u.useCallback(async(x)=>{try{let y="/_api/git/log?limit=40"+(x?`&path=${encodeURIComponent(x)}`:""),X0=await fetch(y);if(!X0.ok)return[];return(await X0.json()).entries||[]}catch{return[]}},[]),XW=u.useMemo(()=>{let x={modified:"M",added:"A",deleted:"D",untracked:"U"},y=new Map;for(let X0 of v?.files||[])y.set(X0.path,x[X0.status]);return y},[v]),Zq=v?.files?.length||0;u.useEffect(()=>{if(v?.repo===!1)return;Z6();let x=setInterval(Z6,G0?60000:120000);return()=>clearInterval(x)},[v?.repo,G0,Z6]);let h6=u.useCallback((x)=>{if(G((y)=>{for(let X0 of y)if(X0.path!==x)j8.current.delete(X0.path);return[{path:x}]}),H(x),f0(null),x!==h8)U8(x)},[]),k6=u.useCallback((x)=>{let y=typeof x==="string"?x:void 0;if(y)QJ(y);else if(!c)QJ();h6(h8)},[c,QJ,h6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((x)=>x.path).filter((x)=>x!==h8)})},[W]),u.useEffect(()=>{if(q&&q!==h8)I7({type:"active",file:q});else if(q===h8)I7({type:"active",file:""});else I7({type:"active",file:""})},[q]);let J0=u.useCallback((x)=>{G((y)=>{let X0=y.findIndex((W0)=>W0.path===x);if(X0<0)return y;let K0=y.filter((W0)=>W0.path!==x);if(x===q)if(K0.length===0)H(null);else H(K0[Math.max(0,X0-1)].path);return K0}),j8.current.delete(x),U8((y)=>y===x?null:y)},[q]),jJ=u.useCallback(()=>{if(!q||q===h8){if(q===h8)QJ();return}let x=j8.current.get(q);if(x)x.src=x.src},[q,QJ]),Q4=u.useCallback(()=>S9(),[S9]),[JW,YJ]=u.useState(!1),n9=u.useRef(!1),_X=u.useCallback(async()=>{if(n9.current)return;n9.current=!0,YJ(!0);try{await Promise.all([S9(),new Promise((x)=>setTimeout(x,550))])}finally{n9.current=!1,YJ(!1)}},[S9]);u.useEffect(()=>{let x=null,y=()=>{if(x)clearTimeout(x);x=setTimeout(()=>{x=null,Q4()},150)};return window.addEventListener("focus",y),()=>{if(window.removeEventListener("focus",y),x)clearTimeout(x)}},[Q4]);let JQ=u.useCallback(async(x)=>{try{let y=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:x,kind:"brief-board"})}),X0=await y.json().catch(()=>({}));if(!y.ok||!X0.ok)return{ok:!1,error:X0.error||`create failed (${y.status})`};return await S9(),h6(X0.file),{ok:!0,file:X0.file}}catch(y){return{ok:!1,error:y instanceof Error?y.message:"network error"}}},[S9,h6]),QW=u.useCallback(async()=>{if(!q||q===h8)return;try{let x=await fetch(`/_api/annotations?file=${encodeURIComponent(q)}`),y=x.ok?await x.text():"",X0=[];if(y){let M0=new DOMParser().parseFromString(y,"image/svg+xml");for(let T0 of M0.querySelectorAll('[data-tool="mediaref"]')){let x0=T0.getAttribute("data-src");if(!x0)continue;X0.push({src:x0,mediaKind:T0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(X0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let W0=`${KZ(_B(q)).replace(/\.tsx$/i,"")} Video`,h0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W0,kind:"video-comp",clips:X0})}),m=await h0.json().catch(()=>({}));if(!h0.ok||!m.ok){window.alert(`Assemble failed: ${m.error||`error ${h0.status}`}`);return}await S9(),h6(m.file)}catch(x){window.alert(`Assemble failed: ${x instanceof Error?x.message:"network error"}`)}},[q,S9,h6]),QQ=u.useCallback(({accept:x,resolveTarget:y})=>{let X0=q,K0=y6||void 0,W0=document.createElement("input");W0.type="file",W0.accept=x,W0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(W0);let h0=()=>{if(W0.isConnected)W0.remove()};window.addEventListener("focus",()=>setTimeout(h0,300),{once:!0}),W0.addEventListener("change",()=>{let m=W0.files?.[0];if(h0(),!m)return;let M0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(M0).then((T0)=>T0.json().catch(()=>({}))).then((T0)=>{let x0=y(T0);if(!x0)return g7("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":m.type||"application/octet-stream"},body:m}).then((F8)=>F8.json().catch(()=>({}))).then((F8)=>{if(!F8?.path)return g7(`Upload failed: ${F8?.error||"unknown error"}`),null;if(x0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,arrayName:x0.arrayRef.arrayName,index:x0.arrayRef.index,field:x0.arrayRef.field,value:F8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,id:x0.cdId,attr:"src",value:F8.path})})})}).then((T0)=>T0?T0.json():null).then((T0)=>{if(T0&&!T0.ok)g7(`Replace refused: ${T0.error||"failed"}`);else if(T0&&T0.ok){if(g7("Media replaced.",!0),T0.seq!=null)bJ(X0,T0.seq,"replace media")}}).catch(()=>g7("Replace failed: network error"))}),W0.click()},[q,y6,bJ]),YW=u.useCallback(async(x,y)=>{if(!window.confirm(`Move “${y}” to trash?
5647
5647
 
5648
5648
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let K0=await fetch(`/_api/canvas?file=${encodeURIComponent(x)}`,{method:"DELETE"}),W0=await K0.json().catch(()=>({}));if(!K0.ok||!W0.ok){window.alert(`Could not delete: ${W0.error||`error ${K0.status}`}`);return}if(await S9(),q===x)G([]),H(null)}catch(K0){window.alert(`Delete failed: ${K0 instanceof Error?K0.message:"network error"}`)}},[S9,q]),YQ=u.useCallback(()=>{if(I7({type:"clear-select"}),z(null),q&&q!==h8){let x=j8.current.get(q);if(x&&x.contentWindow)try{x.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[q]);u.useEffect(()=>{if(!q||q===h8)return;let x=j8.current.get(q);if(!x||!x.contentWindow)return;let y=x6?[]:d8[q]||[];try{x.contentWindow.postMessage({dgn:"comments-set",comments:y},"*")}catch{}},[q,d8,x6]),u.useEffect(()=>{function x(W0){let h0=g8?.canvasOrigin||window.location.origin;if(W0.origin!==h0)return;let m=W0.data;if(!m||typeof m!=="object"||!m.dgn)return;if(m.dgn==="tool-cursor"){let M0=CT(m.tool);if(M0){document.body.style.cursor=M0;let T0=document.getElementById("dc-app-cursor");if(!T0)T0=document.createElement("style"),T0.id="dc-app-cursor",document.head.appendChild(T0);T0.textContent=`* { cursor: ${M0} !important; }`}return}if(m.dgn==="select"||m.dgn==="select-set"||m.dgn==="clear-select"||m.dgn==="edit-text"||m.dgn==="apply-edit"){let M0=q&&q!==h8?j8.current.get(q)?.contentWindow:null;if(W0.source!==M0)return}if(m.dgn==="select"&&m.selection)tX(null),I7({type:"select",selection:m.selection}),z(m.selection),o9(m.selection);else if(m.dgn==="select-set"){tX(null);let M0=m.selection;if(M0==null)I7({type:"clear-select"}),z(null);else if(Array.isArray(M0)){let T0=M0[0]??null;if(T0)I7({type:"select",selection:T0});if(z(T0),M0.length===1)o9(T0)}else I7({type:"select",selection:M0}),z(M0),o9(M0)}else if(m.dgn==="clear-select")tX(null),I7({type:"clear-select"}),z(null);else if(m.dgn==="edit-text"&&m.id){let M0=W0.source,T0=(x0)=>{try{M0?.postMessage({dgn:"edit-reverted",op:"text",id:m.id,reason:x0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:m.file,id:m.id,text:m.text??"",...typeof m.occurrence==="number"?{occurrence:m.occurrence}:{},...typeof m.before==="string"?{before:m.before}:{}})}).then((x0)=>x0.json().catch(()=>({}))).then((x0)=>{if(!x0.ok)T0(x0.error||"this element can't be edited inline")}).catch(()=>T0("network error"))}else if(m.dgn==="apply-edit"&&m.id&&(m.op==="css"||m.op==="text"||m.op==="attr")){let M0=m.op,T0=typeof m.value==="string"?m.value:null,x0,F8;if(M0==="css")x0="/_api/edit-css",F8=T0==null?{canvas:m.canvas,id:m.id,property:m.key,reset:!0}:{canvas:m.canvas,id:m.id,property:m.key,value:T0},g6({id:m.id,prop:m.key,value:T0});else if(M0==="attr")x0="/_api/edit-attr",F8=T0==null?{canvas:m.canvas,id:m.id,attr:m.key,reset:!0}:{canvas:m.canvas,id:m.id,attr:m.key,value:T0};else{if(x0="/_api/edit-text",F8={canvas:m.canvas,id:m.id,text:T0??""},typeof m.occurrence==="number")F8.occurrence=m.occurrence;if(typeof m.from==="string")F8.before=m.from}h9.current=h9.current.catch(()=>{}).then(()=>fetch(x0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(F8)}).then((D8)=>D8.json().catch(()=>({}))).then((D8)=>{if(!D8.ok)console.warn("[apply-edit]",M0,D8.error||"failed")}).catch(()=>{}))}else if(m.dgn==="layers-tree"){if(C({artboardId:m.artboardId,nodes:Array.isArray(m.tree)?m.tree:[]}),P.current=!1,I.current)clearTimeout(I.current),I.current=null;let M0=w.current;if(M0&&M0.movedId){if(function x0(F8){return(F8||[]).some((D8)=>D8.id===M0.movedId||x0(D8.children))}(m.tree)){w.current=null;let x0=q?j8.current.get(q)?.contentWindow:null;if(x0)try{x0.postMessage({dgn:"select-by-id",id:M0.movedId,artboardId:m.artboardId??null,index:0},"*")}catch{}}}}else if(m.dgn==="reorder-revert"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.seq==="number"&&(m.dir==="undo"||m.dir==="redo");if(W0.source===M0&&T0&&q){if(P.current=!0,I.current)clearTimeout(I.current);I.current=setTimeout(()=>{P.current=!1,I.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:q,seq:m.seq,dir:m.dir})}).then((x0)=>x0.json().catch(()=>({}))).then((x0)=>{if(!x0.ok)console.warn("[reorder-revert]",x0.error||"failed")}).catch(()=>{})}}else if(m.dgn==="reorder-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.id==="string"&&typeof m.refId==="string"&&(m.position==="before"||m.position==="after"||m.position==="inside-start"||m.position==="inside-end");if(W0.source===M0&&T0)E.current?.(m.id,m.refId,m.position,{idIndex:Number.isInteger(m.idIndex)?m.idIndex:void 0,refIndex:Number.isInteger(m.refIndex)?m.refIndex:void 0})}else if(m.dgn==="reposition-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.id==="string"&&Number.isFinite(m.left)&&Number.isFinite(m.top)&&Number.isFinite(m.beforeLeft)&&Number.isFinite(m.beforeTop);if(W0.source===M0&&T0)A.current?.(m.id,m.left,m.top,m.beforeLeft,m.beforeTop,Number.isInteger(m.idIndex)?m.idIndex:void 0)}else if(m.dgn==="resize-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.id==="string"&&m.patch&&typeof m.patch==="object";if(W0.source===M0&&T0)O.current?.(m.id,m.patch,m.before,Number.isInteger(m.idIndex)?m.idIndex:void 0)}else if(m.dgn==="delete-request"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.id==="string")Z4.current?.(m.id,Number.isInteger(m.idIndex)?m.idIndex:void 0)}else if(m.dgn==="duplicate-request"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.id==="string")B4.current?.(m.id,Number.isInteger(m.idIndex)?m.idIndex:void 0)}else if(m.dgn==="copy-style"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0)F4.current?.()}else if(m.dgn==="paste-style"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.id==="string")N4.current?.(m.id)}else if(m.dgn==="insert-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.refId==="string",x0=typeof m.artboardId==="string",F8=m.position==="before"||m.position==="after"||m.position==="inside-start"||m.position==="inside-end",D8=T0!==x0&&(m.kind==="div"||m.kind==="text"||m.kind==="image")&&F8&&(!x0||m.position==="inside-start"||m.position==="inside-end");if(W0.source===M0&&D8)K4.current?.(m.refId,m.position,m.kind,{artboardId:x0?m.artboardId:void 0,src:typeof m.src==="string"?m.src:void 0,refIndex:Number.isInteger(m.refIndex)?m.refIndex:void 0})}else if(m.dgn==="insert-image-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.refId==="string",x0=typeof m.artboardId==="string",F8=!T0&&!x0,D8=(T0!==x0||F8)&&(F8||m.position==="before"||m.position==="after"||m.position==="inside-start"||m.position==="inside-end")&&(!x0||m.position==="inside-start"||m.position==="inside-end");if(W0.source===M0&&D8)E5.current?.({purpose:"insert-image",canvas:q,refId:m.refId,artboardId:x0?m.artboardId:void 0,position:F8?void 0:m.position,refIndex:Number.isInteger(m.refIndex)?m.refIndex:void 0,multiple:!0,hasArtboardAnchor:!F8})}else if(m.dgn==="replace-media-request"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.id==="string")E5.current?.({purpose:"replace-src",canvas:q,id:m.id,before:typeof m.before==="string"?m.before:null})}else if(m.dgn==="replace-annotation-media-request"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.id==="string")E5.current?.({purpose:"replace-annotation-media",canvas:q,id:m.id,before:typeof m.before==="string"?m.before:null})}else if(m.dgn==="edit-annotation-photo-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=Ys.exec(typeof m.asset==="string"?m.asset:"")?.[0]||null;if(W0.source===M0&&typeof m.id==="string"&&T0)tX({asset:T0,strokeId:m.id}),a7("inspector"),F5("photo")}else if(m.dgn==="open-sticker-picker"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0)L4.current?.({canvas:q})}else if(m.dgn==="insert-artboard-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.id==="string"&&Number.isFinite(m.width)&&Number.isFinite(m.height);if(W0.source===M0&&T0)z4.current?.({id:m.id,label:typeof m.label==="string"?m.label:m.id,width:m.width,height:m.height})}else if(m.dgn==="resize-artboard-request"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=typeof m.artboardId==="string"&&(Number.isFinite(m.width)||Number.isFinite(m.height));if(W0.source===M0&&T0)V4.current?.(m.artboardId,Number.isFinite(m.width)?m.width:void 0,Number.isFinite(m.height)?m.height:void 0)}else if(m.dgn==="delete-artboard-request"){let M0=q?j8.current.get(q)?.contentWindow:null;if(W0.source===M0&&typeof m.artboardId==="string")U4.current?.(m.artboardId)}else if(m.dgn==="open-inspector"){if(a7("inspector"),typeof m.tab==="string")F5(m.tab)}else if(m.dgn==="present-enter"){let M0=q?j8.current.get(q)?.contentWindow:null,T0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(W0.source===M0&&!T0&&!x6)pY(!0),JX({present:!0})}else if(m.dgn==="comment-compose"&&m.selection)z(m.selection);else if(m.dgn==="comment-submit"&&m.payload&&typeof m.payload.text==="string"){let M0=m.payload,T0=String(M0.text).trim();if(T0)I7({type:"comments-add",payload:{file:M0.file,selector:M0.selector,index:M0.index,dom_path:M0.dom_path,tag:M0.tag,classes:M0.classes,bounds:M0.bounds,html_excerpt:M0.html_excerpt,text:T0}})}else if(m.dgn==="comment-patch"&&m.id&&m.patch&&typeof m.patch==="object")I7({type:"comments-patch",id:m.id,patch:m.patch});else if(m.dgn==="comment-delete"&&m.id)I7({type:"comments-delete",id:m.id}),f0((M0)=>M0===m.id?null:M0);else if(m.dgn==="comment-click"&&m.id)f0(m.id);else if(m.dgn==="artboards"&&typeof m.count==="number"){let M0=Math.round(m.count);if(Number.isFinite(M0)&&M0>=0&&M0<=999)aQ(M0)}else if(m.dgn==="active-artboard"){let M0=q&&q!==h8?j8.current.get(q)?.contentWindow:null;if(W0.source!==M0)return;pG(typeof m.id==="string"?m.id.slice(0,120):null)}else if(m.dgn==="timeline-comps"&&Array.isArray(m.comps)){let M0=q&&q!==h8?j8.current.get(q)?.contentWindow:null;if(W0.source!==M0)return;let T0=m.comps.filter((D8)=>D8&&typeof D8.id==="string").slice(0,32).map((D8)=>({id:String(D8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(D8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(D8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(D8.width)||0)),height:Math.max(1,Math.round(Number(D8.height)||0))}));iQ(T0);let x0=B5.current;if(x0&&T0.some((D8)=>D8.id===x0)&&gY.current>0)E8({dgn:"timeline-seek",frame:gY.current,id:x0})}else if(m.dgn==="timeline-frame"&&typeof m.frame==="number"){let M0=q&&q!==h8?j8.current.get(q)?.contentWindow:null;if(W0.source!==M0)return;if(m.id&&B5.current&&m.id!==B5.current)return;if(Number.isFinite(m.frame))z5(Math.max(0,Math.round(m.frame)))}else if(m.dgn==="timeline-ended"){let M0=q&&q!==h8?j8.current.get(q)?.contentWindow:null;if(W0.source!==M0)return;if(m.id&&B5.current&&m.id!==B5.current)return;x9(!1)}else if(m.dgn==="toggle-palette")rX((M0)=>!M0);else if(m.dgn==="shell-shortcut"){if(m.id==="reload")jJ();else if(m.id==="inspector")L9("inspector");else if(m.id==="assistant"&&G9())L9("assistant");else if(m.id==="comments")L9("comments");else if(m.id==="changes")L9("changes");else if(m.id==="timeline")N5();else if(m.id==="export")H7({mode:"export"});else if(m.id==="handoff")H7({mode:"handoff"})}else if(m.dgn==="open-export")H7({mode:"export",scope:m.detail&&typeof m.detail.scope==="string"?m.detail.scope:void 0});else if(m.dgn==="open-timeline-request"){if(typeof m.artboardId==="string")pG(m.artboardId.slice(0,120));i5(!0)}else if(m.dgn==="loaded"&&m.file){U8((x0)=>x0===m.file?null:x0);let M0=x6?[]:d8[m.file]||[],T0=[...j8.current.entries()].find(([x0])=>x0===m.file)?.[1];if(T0&&T0.contentWindow){try{T0.contentWindow.postMessage({dgn:"comments-set",comments:M0},"*")}catch{}try{T0.contentWindow.postMessage({dgn:"theme",theme:w0},"*")}catch{}try{T0.contentWindow.postMessage({dgn:"view-chrome",minimap:XJ,zoom:JJ,present:x6},"*")}catch{}if(j9&&M0.some((F8)=>F8.id===j9))try{T0.contentWindow.postMessage({dgn:"comment-focus",id:j9},"*")}catch{}let x0=w.current;if(x0&&x0.file===m.file){w.current=null;try{T0.contentWindow.postMessage({dgn:"request-layers",artboardId:x0.artboardId??null},"*")}catch{}if(x0.movedId)try{T0.contentWindow.postMessage({dgn:"select-by-id",id:x0.movedId,artboardId:x0.artboardId??null,index:0},"*")}catch{}}else{let F8=U.current,D8=Array.isArray(F8)?F8[0]:F8;if(D8&&D8.id&&D8.file===m.file)D(D8)}}}else if(m.dgn==="export-request"&&m.id&&m.payload)X0(W0.source,m.id,m.payload);else if(m.dgn==="export-history-request"&&m.id)K0(W0.source,m.id)}let y=g8?.canvasOrigin||window.location.origin;async function X0(W0,h0,m){let M0=(T0)=>{try{if(W0)W0.postMessage({dgn:"export-result",id:h0,...T0},y)}catch{}};try{let T0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m)});if(!T0.ok){M0({ok:!1,error:await T0.text()||String(T0.status)});return}let{jobId:x0}=await T0.json();M0({ok:!0,jobId:x0})}catch(T0){M0({ok:!1,error:T0&&T0.message?T0.message:String(T0)})}}async function K0(W0,h0){let m=[];try{let M0=await fetch("/_api/export-history");if(M0.ok){let T0=await M0.json();if(Array.isArray(T0.history))m=T0.history}}catch{}try{if(W0)W0.postMessage({dgn:"export-history-result",id:h0,history:m},y)}catch{}}return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[d8,j9,g8,w0,jJ,x6,XJ,JJ,JX,q,E8]);let WW=u.useCallback(()=>{if(!q||q===h8)return;let x=j8.current.get(q);if(x&&x.contentWindow)try{x.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[q]),g6=u.useCallback((x)=>{if(!q||q===h8)return;let y=j8.current.get(q);if(y&&y.contentWindow)try{y.contentWindow.postMessage({dgn:"apply-style",...x},"*")}catch{}},[q]),b0=u.useCallback((x)=>{if(!q||q===h8||!x)return;let y=j8.current.get(q);if(y&&y.contentWindow)try{y.contentWindow.postMessage({dgn:"record-edit",payload:x},"*")}catch{}},[q]),h9=u.useRef(Promise.resolve()),WQ=u.useCallback((x,y,X0,K0)=>{let W0=Number.isInteger(K0?.idIndex)?K0.idIndex:void 0,h0=Number.isInteger(K0?.refIndex)?K0.refIndex:void 0;if(!x||!y)return;if(x===y&&(W0??0)===(h0??0))return;let m=U.current,M0=Array.isArray(m)?m[0]:m,T0=q;if(!T0)return;let x0=q,F8=T?.artboardId??M0?.artboardId??null;if(C((D8)=>D8?{...D8,nodes:Bz0(D8.nodes,x,y,X0)}:D8),P.current=!0,I.current)clearTimeout(I.current);I.current=setTimeout(()=>{P.current=!1,I.current=null},700),h9.current=h9.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:T0,id:x,refId:y,position:X0,idIndex:W0,refIndex:h0})}).then((D8)=>D8.json().catch(()=>({}))).then((D8)=>{if(!D8.ok){if(console.warn("[reorder]",D8.error||"failed"),E8({dgn:"reorder-failed"}),E8({dgn:"request-layers",artboardId:F8}),P.current=!1,I.current)clearTimeout(I.current),I.current=null;return}if(w.current={file:x0,movedId:D8.movedId||null,artboardId:F8},typeof D8.seq==="number")E8({dgn:"record-edit",payload:{op:"reorder",canvas:T0,seq:D8.seq,label:"move element"}})}).catch(()=>{}))},[q,T,E8]);u.useEffect(()=>{E.current=WQ},[WQ]);let j0=u.useCallback((x,y,X0,K0,W0,h0)=>{if(!x||!q)return;let m=q,M0=Number.isInteger(h0)?h0:void 0;g6({id:x,prop:"left",value:`${y}px`}),g6({id:x,prop:"top",value:`${X0}px`});let T0=(x0,F8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:m,id:x,property:x0,value:`${F8}px`,idIndex:M0})}).then((D8)=>D8.json().catch(()=>({})));h9.current=h9.current.catch(()=>{}).then(()=>T0("left",y)).then((x0)=>{if(!x0.ok)throw Error(x0.error||"left write failed");return T0("top",X0)}).then((x0)=>{if(!x0.ok)throw Error(x0.error||"top write failed");b0({op:"css",canvas:m,id:x,key:"left",before:`${K0}px`,after:`${y}px`}),b0({op:"css",canvas:m,id:x,key:"top",before:`${W0}px`,after:`${X0}px`})}).catch((x0)=>{console.warn("[reposition]",x0?.message||x0),E8({dgn:"reposition-failed"})})},[q,E8,b0,g6]);u.useEffect(()=>{A.current=j0},[j0]);let w5=u.useCallback((x,y,X0,K0)=>{if(!x||!q||!y||typeof y!=="object")return;let W0=q,h0=X0&&typeof X0==="object"?X0:{},m=Number.isInteger(K0)?K0:void 0,M0=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap"].filter((L7)=>typeof y[L7]==="string"&&y[L7]);if(!M0.length)return;let T0=U.current,x0=Array.isArray(T0)?T0.length===1?T0[0]:null:T0,F8=x0&&x0.id===x?x0.artboardId??null:null,D8=x0&&x0.id===x?x0.index??0:0;for(let L7 of M0)g6({id:x,artboardId:F8,index:D8,prop:L7,value:y[L7]});let TZ=(L7,PX)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,id:x,property:L7,value:PX,idIndex:m})}).then((CZ)=>CZ.json().catch(()=>({}))),_W=h9.current.catch(()=>{});for(let L7 of M0)_W=_W.then((PX)=>{if(PX&&PX.ok===!1)throw Error(PX.error||`${L7} write failed`);return TZ(L7,y[L7])});h9.current=_W.then((L7)=>{if(L7&&L7.ok===!1)throw Error(L7.error||"resize write failed");for(let PX of M0)b0({op:"css",canvas:W0,id:x,key:PX,before:h0[PX]??null,after:y[PX]});D({id:x,file:W0,artboardId:F8,index:D8})}).catch((L7)=>{console.warn("[resize]",L7?.message||L7),E8({dgn:"resize-failed"})})},[q,E8,b0,g6,D]);u.useEffect(()=>{O.current=w5},[w5]);let v0=u.useRef(null),X7=u.useCallback((x,y,{label:X0,onOk:K0,onFail:W0}={})=>{if(!q)return;let h0=q;h9.current=h9.current.catch(()=>{}).then(()=>fetch(x,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...y,canvas:h0})}).then((m)=>m.json().catch(()=>({}))).then((m)=>{if(!m.ok){console.warn(`[${x}]`,m.error||"failed"),W0?.(m);return}if(typeof m.seq==="number")E8({dgn:"record-edit",payload:{op:"reorder",canvas:h0,seq:m.seq,label:X0||"edit"}});K0?.(m,h0)}).catch((m)=>W0?.({error:m?.message})))},[q,E8]);u.useEffect(()=>{v0.current=X7},[X7]);let Y4=u.useCallback((x,y)=>{X7("/_api/delete-element",{id:x,idIndex:Number.isInteger(y)?y:void 0},{label:"delete element",onOk:()=>E8({dgn:"selection-clear"})})},[X7,E8]),QX=u.useCallback((x,y,X0,K0={})=>{X7("/_api/insert-element",{refId:x,artboardId:typeof K0.artboardId==="string"?K0.artboardId:void 0,position:y,kind:X0,src:typeof K0.src==="string"?K0.src:void 0,refIndex:Number.isInteger(K0.refIndex)?K0.refIndex:void 0},{label:`insert ${X0}`,onOk:(W0,h0)=>{if(W0.newId)w.current={file:h0,movedId:W0.newId,artboardId:null}}})},[X7]),GW=u.useCallback((x)=>{if(typeof x!=="string"||!x)return!1;if(!q)return!1;let y=U.current?.artboardId??i9??null;if(!y)return!1;return QX(void 0,"inside-end","image",{artboardId:y,src:x}),!0},[q,i9,QX]),W4=u.useCallback((x,y)=>{X7("/_api/duplicate-element",{id:x,idIndex:Number.isInteger(y)?y:void 0},{label:"duplicate element",onOk:(X0,K0)=>{if(X0.newId)w.current={file:K0,movedId:X0.newId,artboardId:null}}})},[X7]),G4=u.useRef(null),yJ=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),q4=u.useCallback(()=>{let x=U.current,y=Array.isArray(x)?x.length===1?x[0]:null:x;if(!y)return;let X0={};for(let[K0,W0]of Object.entries(y.authored||{}))if(!yJ.has(K0))X0[K0]=W0;for(let[K0,W0]of Object.entries(y.customStyles||{}))if(!yJ.has(K0))X0[K0]=W0;G4.current=Object.keys(X0).length?X0:null},[yJ]),H4=u.useCallback((x)=>{let y=q,X0=G4.current;if(!y||!x||!X0)return;let K0=Object.entries(X0),W0=h9.current.catch(()=>{});for(let[h0,m]of K0)g6({id:x,prop:h0,value:m}),W0=W0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:y,id:x,property:h0,value:m})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(M0.ok)b0({op:"css",canvas:y,id:x,key:h0,before:null,after:m})}).catch(()=>{}));h9.current=W0},[q,g6,b0]),A5=u.useCallback(({id:x,label:y,width:X0,height:K0})=>{X7("/_api/insert-artboard",{id:x,label:y,width:X0,height:K0},{label:"insert artboard"})},[X7]),qW=u.useCallback((x)=>{let y=aV[x];if(!y)return;let X0=`s${Math.random().toString(36).slice(2,8)}`;A5({id:X0,label:y.label,width:y.width,height:y.height})},[A5]),GQ=u.useCallback((x,y,X0)=>{X7("/_api/resize-artboard",{artboardId:x,width:y,height:X0},{label:"resize artboard",onFail:()=>E8({dgn:"resize-artboard-failed"})})},[X7,E8]),_5=u.useCallback((x)=>{X7("/_api/delete-artboard",{artboardId:x},{label:"delete artboard"})},[X7]),HW=u.useCallback((x,y,X0)=>{X7("/_api/set-artboard-hug",{artboardId:x,fixed:y,freezeHeight:X0},{label:y?"pin artboard height":"hug artboard height"})},[X7]),ZW=u.useCallback((x,y)=>{X7("/_api/set-artboard-style",{artboardId:x,...y},{label:"artboard style"})},[X7]),Z4=u.useRef(null),K4=u.useRef(null),z4=u.useRef(null),V4=u.useRef(null),U4=u.useRef(null),B4=u.useRef(null),F4=u.useRef(null),N4=u.useRef(null);u.useEffect(()=>{Z4.current=Y4,K4.current=QX,z4.current=A5,V4.current=GQ,U4.current=_5,B4.current=W4,F4.current=q4,N4.current=H4},[Y4,QX,A5,GQ,_5,W4,q4,H4]),u.useEffect(()=>{let x=(y)=>{if(y.key!=="Backspace"&&y.key!=="Delete")return;if(y.metaKey||y.ctrlKey||y.altKey)return;let X0=y.target;if(X0&&(X0.tagName==="INPUT"||X0.tagName==="TEXTAREA"||X0.tagName==="SELECT"||X0.isContentEditable))return;if(y.preventDefault(),!q||q===h8)return;let W0=Array.isArray(Z)?Z.length===1?Z[0]:null:Z;if(W0?.artboardId&&!W0.id)_5(W0.artboardId)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[q,Z,_5]);let[EX,fJ]=u.useState(null),E5=u.useRef(null);u.useEffect(()=>{E5.current=(x)=>fJ(x)},[]);let[qQ,HQ]=u.useState(null),L4=u.useRef(null);u.useEffect(()=>{L4.current=(x)=>HQ(x)},[]);let KW=u.useCallback((x)=>{let y=EX;if(fJ(null),!y||!x)return;if(y.canvas&&y.canvas!==q){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(y.purpose==="insert-image"){QX(y.refId,y.position||"after","image",{artboardId:y.artboardId,src:x,refIndex:y.refIndex});return}if(y.purpose==="replace-src"){let X0=q;if(!X0||!y.id)return;h9.current=h9.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,id:y.id,attr:"src",value:x})}).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{if(K0.ok)b0({op:"attr",canvas:X0,id:y.id,key:"src",before:y.before??null,after:x});else console.warn("[replace-src]",K0.error||"failed")}).catch(()=>{}));return}if(y.purpose==="replace-annotation-media")E8({dgn:"replace-annotation-media",id:y.id,path:x})},[EX,QX,q,b0,E8]),zW=u.useCallback((x,y)=>{let X0=EX;if(fJ(null),!X0||!Array.isArray(x)||!x.length)return;if(X0.canvas&&X0.canvas!==q){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(y==="artboard"){let K0=U.current?.artboardId??i9??null;if(!K0)return;for(let W0 of x)QX(void 0,"inside-end","image",{artboardId:K0,src:W0});return}E8({dgn:"insert-annotation-media",paths:x})},[EX,q,QX,i9,E8]),VW=u.useCallback(async(x)=>{let y=qQ;if(HQ(null),!y||!x?.url)return;if(y.canvas&&y.canvas!==q){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let X0=await fetch(x.url).then((h0)=>h0.ok?h0.blob():Promise.reject(Error(`HTTP ${h0.status}`))),K0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":X0.type||"image/png"},body:X0}),W0=await K0.json().catch(()=>({}));if(!K0.ok||!W0.path){console.warn("[sticker-picker]",W0.error||`upload failed (HTTP ${K0.status})`);return}E8({dgn:"insert-sticker",path:W0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[qQ,q,E8]),UW=u.useCallback((x)=>{if(!x?.id)return;fJ({purpose:"replace-src",canvas:q,id:x.id,before:x.attrs?.src??null})},[q]),BW=u.useCallback((x)=>{I7({type:"comments-patch",id:x,patch:{status:"resolved"}})},[]),FW=u.useCallback((x)=>{I7({type:"comments-patch",id:x,patch:{status:"open"}})},[]),NW=u.useCallback((x)=>{I7({type:"comments-delete",id:x}),f0((y)=>y===x?null:y)},[]),LW=u.useCallback((x,y)=>{if(x&&x!==q)G((K0)=>K0.find((W0)=>W0.path===x)?K0:[...K0,{path:x}]),H(x);if(y==null){f0(null);return}f0(y);let X0=()=>{let K0=j8.current.get(x);if(K0&&K0.contentWindow)try{K0.contentWindow.postMessage({dgn:"comment-focus",id:y},"*")}catch{}};X0(),setTimeout(X0,200)},[q]);u.useEffect(()=>{function x(y){let X0=y.metaKey||y.ctrlKey,K0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,W0=document.activeElement?.tagName==="IFRAME";if(x6&&y.key==="Escape"){y.preventDefault(),aY();return}if(X0&&(y.key==="k"||y.key==="K")){y.preventDefault(),rX((h0)=>!h0);return}if(X0&&!y.altKey&&(y.key==="z"||y.key==="Z"||y.key==="y"||y.key==="Y")){if(!K0&&!W0&&q&&q!==h8){if((y.key==="z"||y.key==="Z")&&e5.current.open&&e5.current.comps?.length)return;let h0=y.key==="y"||y.key==="Y"||y.shiftKey;if(r5==="photo"&&oY(h0)){y.preventDefault();return}y.preventDefault(),E8({dgn:h0?"redo":"undo"});return}}if(X0&&y.shiftKey&&(y.key==="r"||y.key==="R")){y.preventDefault(),_X();return}if(X0&&(y.key==="r"||y.key==="R")){y.preventDefault(),jJ();return}if(X0&&y.shiftKey&&(y.key==="m"||y.key==="M")){y.preventDefault(),L9("comments");return}if(X0&&y.shiftKey&&(y.key==="g"||y.key==="G")){y.preventDefault(),L9("changes");return}if(X0&&y.shiftKey&&(y.key==="i"||y.key==="I")){y.preventDefault(),L9("inspector");return}if(X0&&y.shiftKey&&(y.key==="a"||y.key==="A")&&G9()){y.preventDefault(),L9("assistant");return}if(X0&&y.shiftKey&&(y.key==="e"||y.key==="E")){y.preventDefault(),H7({mode:"export"});return}if(X0&&y.shiftKey&&(y.key==="h"||y.key==="H")){y.preventDefault(),H7({mode:"handoff"});return}if(X0&&!y.shiftKey&&!y.altKey&&y.key===","){y.preventDefault(),B0(!0);return}if(X0&&y.shiftKey&&(y.key==="t"||y.key==="T")){y.preventDefault(),N5();return}if(X0&&!y.shiftKey&&!y.altKey&&(y.key==="c"||y.key==="C")){if(Z&&Z.selector&&q&&q!==h8&&!K0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(K0)return;if(y.key==="/"){y.preventDefault();let h0=document.querySelector(".st-search input");if(h0)h0.focus();return}if(X0&&(y.key==="f"||y.key==="F")){if(y.preventDefault(),!$8)v6("tree");setTimeout(()=>{let h0=document.querySelector(".st-search input");if(h0)h0.focus()},0);return}if(W0){if(y.key!=="Escape")return}if(y.key==="t"||y.key==="T"){if(y.shiftKey||X0)return;y.preventDefault(),$J("tree");return}if(y.key==="h"||y.key==="H"){if(y.shiftKey||X0)return;y.preventDefault(),k0((h0)=>!h0);return}if((y.key==="s"||y.key==="S")&&!X0&&!y.shiftKey){if(y.preventDefault(),q===h8)J0(h8);else k6();return}if((y.key==="n"||y.key==="N")&&!X0&&!y.shiftKey){y.preventDefault(),v6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(y.key==="?"){y.preventDefault(),q7((h0)=>!h0);return}if(y.key==="F1"){y.preventDefault(),t6(!0);return}if(y.key==="Escape"){if(j9){f0(null);return}}}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[jJ,_X,Z,q,j9,$8,k6,J0,WW,x6,aY,N5,r5,oY]);let DW=u.useCallback((x,y)=>{if(y)j8.current.set(x,y)},[]),OW=sa(d8).open,MW=u.useCallback((x)=>{let y=x.target;if(y&&(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.isContentEditable))return;x.preventDefault()},[]),wW=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{v6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>H7({mode:"export"})},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"share",kbd:"⇧⌘H",run:()=>H7({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>A0(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>B0(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>k6()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>L9("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>a7("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>jJ()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>AX()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>P6.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>q7(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>t6(!0)}],[k6,AX,jJ,P6]),AW=(x)=>x==="assistant"?G9():x==="layers"?c9==="separate":!0,D4=(x)=>kE.filter((y)=>AW(y.id)&&(p8[y.id]||qZ[y.id])===x).map((y)=>y.id),O4={tree:$8,layers:T8,inspector:p0,comments:z0,changes:G0,assistant:LX},M4=D4("left"),w4=D4("right"),m6=M4.find((x)=>O4[x])||null,YX=w4.find((x)=>O4[x])||null,A4=G9()&&(p8.assistant||"right")==="left",_4=G9()&&(p8.assistant||"right")==="right",WJ=(x)=>(p8[x]||qZ[x])==="left"?n0==="sb":n0==="rp",ZQ=q&&q!==h8&&/\.(tsx|html)$/i.test(q)?q:null,E4=(x)=>{if(x==="tree")return K(SK0,{groups:X,activePath:q,activeDsName:q===h8?c?.ds?.name??null:null,onOpen:h6,onOpenSystem:k6,wsConnected:S,search:r,setSearch:a,commentsByFile:d8,showHidden:r8,sectionsExpanded:z8,onToggleSection:IZ,onNewBoard:JQ,onDeleteBoard:YW,onRefresh:_X,refreshing:JW,collapsed:!1,onCollapse:()=>$J("tree"),resizing:WJ("tree"),dirtyByPath:XW,project:Q,gitBranch:v?.branch,remoteSync:Y0,onGetLatest:J4,canvasKinds:g8?.canvasKinds});if(x==="changes")return K(WM,{status:v&&Y0?{...v,...Y0}:v,project:Q,readOnly:!G9(),resizing:WJ("changes"),onClose:()=>e(!1),onCommit:sY,onDiscard:X4,onPublish:tY,onGetLatest:J4,loadLog:Hq,onOpenCanvas:(y)=>h6(y),onOpenDiff:(y)=>Z0({file:y,beforeSha:"HEAD",conflict:!1}),activeCanvas:ZQ,onPreviewVersion:(y)=>Z0({file:q,beforeSha:y,conflict:!1}),designRel:(g8?.designRel||g8?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(x==="inspector"||x==="layers")return K(Mz0,{layersOnly:x==="layers",hideLayersTab:c9==="separate",cpMode:I0,onSetCpMode:O8,selected:Z,cfg:g8,tab:x==="layers"?"layers":r5,onTabChange:F5,onClose:()=>x==="layers"?b8(!1):M8(!1),onOptimistic:g6,onRecordEdit:b0,onReplaceMedia:UW,onResizeArtboard:GQ,onSetArtboardHug:HW,onSetArtboardStyle:ZW,editScope:B,onUndoRedo:(y)=>E8({dgn:y}),photoSel:LZ,photoRev:SJ,onPhotoEdit:t5,onPhotoRemoveBackground:nY,onPhotoRecordEdit:MX,onPhotoUndoRedo:(y)=>oY(y==="redo"),layersTree:T,canvasFile:q,onSelectLayer:(y)=>E8({dgn:"select-by-id",id:y.id,artboardId:T?.artboardId,index:y.index}),onHoverLayer:(y)=>E8({dgn:"highlight",id:y?y.id:null,artboardId:T?.artboardId,index:y?y.index:0}),onReorderLayer:WQ,layersBusyRef:P,resizing:WJ(x)});if(x==="comments")return K(eK0,{commentsByFile:d8,filter:U0,setFilter:y0,activePath:q,focusedId:j9,onJump:LW,onResolve:BW,onReopen:FW,onDelete:NW,resizing:WJ("comments")});return null};return R("div",{className:"maude"+(x6?" is-present":""),"data-theme":w0,onContextMenu:MW,children:[lY&&K(ZM,{}),K(Xz0,{update:MZ,onDismiss:()=>eX(null)}),K(Jz0,{status:d}),!DX&&!O5&&K(qf,{wn:P6}),!DX&&!O5&&K(ey,{center:L5}),b&&R("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:"Repo state changed — reload to sync?"}),K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>h(null),children:"Dismiss"})]}),R("div",{className:"st-shell",children:[K(lK0,{activePath:q,project:Q,tabsCount:W.length,openMenu:r0,setOpenMenu:d0,commentsPanelOpen:z0,onToggleComments:()=>L9("comments"),changesOpen:G0,changesCount:Zq,onToggleChanges:()=>L9("changes"),onOpenSystem:k6,sidebarOpen:$8,onToggleSidebar:()=>$J("tree"),showHidden:r8,onToggleShowHidden:()=>k0((x)=>!x),onOpenHelp:()=>t6(!0),onOpenShortcuts:()=>q7(!0),onStartTour:()=>OX(F2),onStartCollabTour:()=>OX(SM),annotationsVisible:M5,onToggleAnnotations:Yq,minimapVisible:XJ,onToggleMinimap:Wq,zoomCtlVisible:JJ,onToggleZoomCtl:Gq,presentMode:x6,onTogglePresent:kZ,postToActiveCanvas:E8,onOpenReadiness:()=>G7(!0),onOpenQuickSetup:()=>F7(!0),onWatchIntro:()=>B9(!0),onOpenWhatsNew:P6.openPanel,whatsNewCount:P6.unseen.length,exportCenter:L5,artboardCount:EZ,inspectorOpen:p0,inspectorTab:r5,onToggleInspector:()=>L9("inspector"),autoOpenInspector:E6,onToggleAutoOpenInspector:()=>mY((x)=>!x),onInsertArtboard:qW,timelineOpen:NX,onToggleTimeline:N5,hasComps:l7.length>0,assistantOpen:LX,onToggleAssistant:()=>L9("assistant"),assistantBusy:FZ,assistantUnseen:NZ,onOpenLayers:()=>{if(c9==="separate")$J("layers");else if(p0&&r5==="layers")M8(!1);else F5("layers"),v6("inspector")},onNewCanvas:()=>{v6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:QW,onOpenExport:(x)=>H7({mode:x}),onOpenSettings:()=>B0(!0),onOpenGenerate:()=>A0(!0),onReload:jJ,onCloseCanvas:()=>q&&J0(q),presence:R(Q0,{children:[K(ba,{initials:MK0(cY||"you"),hue:"var(--accent)",title:cY?`${cY} (you)`:"You"}),iY&&K(ba,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),R("div",{className:"st-body"+(n0?" is-resizing":""),ref:v8,children:[K($K0,{shown:!m6,onExpand:()=>v6("tree"),onSearch:()=>{v6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(m6||A4)&&R(Sa,{side:"left",width:L0.w,open:!!m6,ids:M4,activeId:m6,onPick:$J,children:[A4&&K(t3,{hidden:m6!=="assistant",activeCanvas:ZQ,selected:Z,designRel:(g8?.designRel||g8?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:WJ("assistant"),onClose:()=>n5(!1),onBusyChange:cG,onFinished:nG}),m6&&m6!=="assistant"&&E4(m6)]}),m6&&K(ya,{label:"Resize left panel",size:L0,active:n0==="sb",onPointerDown:(x)=>{x.preventDefault(),x.currentTarget.setPointerCapture?.(x.pointerId),Q8("sb")}}),K("div",{className:"main",children:K(dK0,{tabs:W,activePath:q,registerIframe:DW,systemData:c,onOpenFromSystem:h6,onSelectDs:QJ,project:Q,cfg:g8,loadingPath:o0,onIframeLoad:i8,showQuickSetup:G9()&&!!j6&&!j6.ready,onStartQuickSetup:()=>F7(!0)})}),YX&&K(ya,{label:"Resize right panel",dir:"rtl",size:t0,active:n0==="rp",onPointerDown:(x)=>{x.preventDefault(),x.currentTarget.setPointerCapture?.(x.pointerId),Q8("rp")}}),(YX||_4)&&R(Sa,{side:"right",width:t0.w,open:!!YX,ids:w4,activeId:YX,onPick:$J,children:[_4&&K(t3,{hidden:YX!=="assistant",activeCanvas:ZQ,selected:Z,designRel:(g8?.designRel||g8?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:WJ("assistant"),onClose:()=>n5(!1),onBusyChange:cG,onFinished:nG}),YX&&YX!=="assistant"&&E4(YX)]})]}),NX&&K(FM,{comps:l7,sequences:sX,audio:o5,total:N9,frame:K5,playing:oQ,loop:xY,onSeek:(x)=>{z5(x),x9(!1),E8({dgn:"timeline-seek",frame:x,id:_6})},onPlay:()=>{x9(!0),E8({dgn:"timeline-mute",muted:aX,id:_6}),E8({dgn:"timeline-loop",loop:xY,id:_6}),E8({dgn:"timeline-play",id:_6})},onPause:()=>{x9(!1),E8({dgn:"timeline-pause",id:_6})},onToggleLoop:()=>Z7((x)=>{let y=!x;return E8({dgn:"timeline-loop",loop:y,id:_6}),y}),muted:aX,onToggleMute:()=>{V5((x)=>{let y=!x;return E8({dgn:"timeline-mute",muted:y,id:_6}),y})},volume:zZ,onVolume:(x)=>{if(w7(x),x>0&&aX)V5(!1),E8({dgn:"timeline-mute",muted:!1,id:_6});E8({dgn:"timeline-volume",volume:x,id:_6})},onRetime:(x,y)=>{if(!q||q===h8)return;let X0=y6||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((W0)=>W0.json().catch(()=>({}))).then((W0)=>{let m=(W0?.ok&&Array.isArray(W0.clips)?W0.clips.filter((T0)=>T0.kind==="sequence"):[])[x]||null,M0=m?.stableId?{canvas:q,artboardId:X0,stableId:m.stableId,contentHash:m.contentHash,...y}:{canvas:q,index:x,...y};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)})}).then((W0)=>W0.json()).then((W0)=>{if(!W0?.ok)console.warn("[retime]",W0?.error||"failed"),g7(`Retime refused: ${W0?.error||"failed"}`);else if(W0?.seq!=null)bJ(q,W0.seq,y.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:(x)=>{if(!q||q===h8)return;let y=y6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${y?`&artboardId=${encodeURIComponent(y)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let h0=(K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((m)=>m.kind==="sequence"):[])[x]||null;if(!h0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:q,artboardId:y,stableId:h0.stableId,contentHash:h0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),g7(`Remove refused: ${K0.error||"failed"}`);else if(K0?.seq!=null)bJ(q,K0.seq,"remove clip")}).catch(()=>{})},onReplace:(x)=>{if(!q||q===h8)return;QQ({accept:"video/*,image/*",resolveTarget:(y)=>{let K0=(y?.ok&&Array.isArray(y.clips)?y.clips.filter((W0)=>W0.kind==="sequence"):[])[x];if(K0?.mediaArrayRef)return{arrayRef:K0.mediaArrayRef};if(K0?.mediaCdId)return{cdId:K0.mediaCdId};return null}})},onReplaceAudio:(x)=>{if(!q||q===h8)return;QQ({accept:"audio/*",resolveTarget:(y)=>{let X0=y?.ok&&Array.isArray(y.media)?y.media.filter((K0)=>K0.tag==="Audio"):[];return X0[x]?.cdId?{cdId:X0[x].cdId}:null}})},onReplaceLayer:(x,y)=>{if(!q||q===h8)return;let X0=sX[x]?.layers?.[y]?.kind==="audio"?"audio/*":sX[x]?.layers?.[y]?.kind==="image"?"image/*":"video/*";QQ({accept:X0,resolveTarget:(K0)=>{let h0=(K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((m)=>m.kind==="sequence"):[])[x]?.layers?.[y];if(h0?.mediaArrayRef)return{arrayRef:h0.mediaArrayRef};if(h0?.mediaCdId)return{cdId:h0.mediaCdId};return null}})},onReorder:(x,y)=>{if(!q||q===h8)return;let X0=y6||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((W0)=>W0.json().catch(()=>({}))).then((W0)=>{let h0=W0?.ok&&Array.isArray(W0.clips)?W0.clips.filter((F8)=>F8.kind==="sequence"):[],m=h0[x]||null,M0=y==="forward"?x+1:x-1,T0=h0[M0]||null,x0=y==="forward"?"after":"before";if(!m?.stableId||!T0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:q,artboardId:X0,stableId:m.stableId,contentHash:m.contentHash,refStableId:T0.stableId,refContentHash:T0.contentHash,position:x0})})}).then((W0)=>W0?W0.json():null).then((W0)=>{if(W0&&!W0.ok)console.warn("[reorder-clip]",W0.error||"failed"),g7(`Reorder refused: ${W0.error||"failed"}`);else if(W0?.seq!=null)bJ(q,W0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(x)=>{if(!q||q===h8)return;let y=y6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(q)}${y?`&artboardId=${encodeURIComponent(y)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let h0=(K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((m)=>m.kind==="sequence"):[])[x]||null;if(!h0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:q,artboardId:y,stableId:h0.stableId,contentHash:h0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)g7(`Hide refused: ${K0.error||"failed"}`);else if(K0&&K0.ok){if(g7(K0.hidden?"Clip hidden.":"Clip shown.",!0),K0.seq!=null)bJ(q,K0.seq,K0.hidden?"hide clip":"show clip")}}).catch(()=>g7("Hide failed: network error"))},onDropMedia:(x)=>{if(!q||q===h8)return;let y=y6||void 0,X0=x.type.startsWith("video/")?"Video":x.type.startsWith("audio/")?"Audio":x.type.startsWith("image/")?"Img":null,K0=l7[0]?.fps||30;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":x.type||"application/octet-stream"},body:x}).then((W0)=>W0.json().catch(()=>({}))).then((W0)=>{if(!W0?.path)return console.warn("[insert] upload failed",W0?.error),g7(`Upload failed: ${W0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:q,artboardId:y,from:Math.max(0,N9),durationInFrames:Math.round(K0*3),mediaTag:X0,src:W0.path})})}).then((W0)=>W0?W0.json():null).then((W0)=>{if(W0&&!W0.ok)console.warn("[insert-clip]",W0.error||"failed"),g7(`Insert refused: ${W0.error||"failed"}`);else if(W0&&W0.ok){if(g7("Clip added to the timeline.",!0),W0.seq!=null)bJ(q,W0.seq,"add clip")}}).catch(()=>{})},height:hY,onResize:VZ,onClose:()=>i5(!1)}),K(tK0,{activePath:q,selected:Z,wsConnected:S,openCount:OW,theme:w0,onToggleTheme:AX,onClearSelected:YQ,syncStatus:d,changesCount:Zq,unpushed:v?.unpushed||0,changesOpen:G0,onOpenChanges:v?.repo?()=>e(!0):void 0})]}),x6&&R("button",{type:"button",className:"st-present-exit",onClick:aY,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[K("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:K("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),K("span",{children:"Exit presentation"}),K("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),K(OK0,{open:Z5,onClose:()=>rX(!1),actions:wW}),e6&&K(RK0,{mode:e6.mode,initialScope:e6.scope,activePath:q,hasComps:l7.length>0,activeArtboardId:Z?.artboardId??i9??null,selection:Z?.selector?{selector:Z.selector,file:Z.file}:null,onClose:()=>H7(null)}),o&&K(wM,{onClose:()=>B0(!1),initialTab:typeof o==="string"?o:void 0,theme:w0,onSetTheme:R0,cpMode:I0,onSetCpMode:O8,minimapVisible:XJ,onToggleMinimap:Wq,zoomCtlVisible:JJ,onToggleZoomCtl:Gq,annotationsVisible:M5,onToggleAnnotations:Yq,autoOpenInspector:E6,onToggleAutoOpenInspector:()=>mY((x)=>!x),hasCanvas:!!q&&q!==h8,panelSide:p8,onSetPanelSide:(x,y)=>y9((X0)=>({...X0,[x]:y})),layersMode:c9,onSetLayersMode:(x)=>{if(u7(x),x!=="separate")b8(!1)}}),H0&&K(LM,{onClose:()=>A0(!1),onInsert:GW}),EX&&K(PK0,{designRel:(g8?.designRel||g8?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:KW,onClose:()=>fJ(null),multiple:!!EX.multiple,hasArtboardAnchor:!!EX.hasArtboardAnchor,onPickMany:zW}),qQ&&K(AM,{onPick:VW,onClose:()=>HQ(null)}),l&&K(YM,{target:l,cfg:g8,loadLog:Hq,onClose:()=>Z0(null),onRestore:async(x)=>{let y=await X4([x]);if(y?.ok)Z0(null);else window.alert(y?.error||"Could not restore that version. Try again.")},onResolve:async(x)=>{let y=await eY(x);if(y.ok)Z0(null);else window.alert(y.error||"Could not finish the merge. Get the latest again, then retry.")}}),K(yK0,{open:Y9,onClose:()=>q7(!1)}),K(bK0,{open:nX,onClose:()=>t6(!1),onStartTour:()=>{t6(!1),OX(F2)}}),K(Hf,{wn:P6,onStartTour:OX}),K(Xf,{center:L5}),K(aj,{open:Q9,onClose:()=>G7(!1)}),K(_z,{open:r7,onClose:()=>B9(!1)}),K(VM,{open:p9,onClose:()=>F7(!1),onStartTour:()=>OX(cy),onBringBrand:()=>H6(!0)}),K(KM,{open:a8,onClose:()=>H6(!1)}),DX&&!O5&&!D5&&R("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[K("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),K("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{dY(),OX(F2)},children:"Start"}),K("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:dY,children:"×"})]}),D5&&!O5&&R("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[K("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),K("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{nQ(),OX(SM)},children:"Start"}),K("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:nQ,children:"×"})]}),K(py,{steps:O5??[],open:!!O5,onClose:()=>tG(null),onComplete:dY,bus:AZ,hasSelection:!!Z,hasCanvas:W.length>0})]})}na.createRoot(document.getElementById("root")).render(K(wz0,{}));