@1agh/maude 0.48.0 → 0.49.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.
- package/apps/studio/api.ts +18 -2
- package/apps/studio/assets-s3.ts +291 -0
- package/apps/studio/collab/origins.ts +150 -0
- package/apps/studio/collab/protocol.ts +36 -9
- package/apps/studio/collab/room.ts +124 -0
- package/apps/studio/context.ts +9 -0
- package/apps/studio/dist/client.bundle.js +1 -1
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/http.ts +45 -0
- package/apps/studio/server.ts +75 -2
- package/apps/studio/sync/autocommit.ts +299 -0
- package/apps/studio/sync/doc-name.ts +228 -0
- package/apps/studio/sync/index.ts +95 -1
- package/apps/studio/sync/workspace-signin.ts +301 -0
- package/apps/studio/test/assets-s3.test.ts +249 -0
- package/apps/studio/test/canvas-origin-gate.test.ts +7 -0
- package/apps/studio/test/collab-origin-gate.test.ts +323 -0
- package/apps/studio/test/sync-autocommit.test.ts +334 -0
- package/apps/studio/test/sync-doc-name.test.ts +281 -0
- package/apps/studio/test/workspace-containment.test.ts +258 -0
- package/apps/studio/test/workspace-signin.test.ts +270 -0
- package/apps/studio/use-collab.tsx +28 -1
- package/apps/studio/workspace-mode.ts +210 -0
- package/apps/studio/ws.ts +11 -2
- package/cli/commands/hub-workspace.mjs +341 -0
- package/cli/commands/hub.mjs +325 -3
- package/cli/commands/hub.test.mjs +14 -1
- package/cli/lib/cell-plan.mjs +302 -0
- package/cli/lib/cell-plan.test.mjs +225 -0
- package/cli/lib/gitignore-block.mjs +12 -1
- package/cli/lib/workspace-plan.mjs +422 -0
- package/cli/lib/workspace-plan.test.mjs +223 -0
- package/package.json +8 -8
|
@@ -5645,6 +5645,6 @@ ${B.block}`:V,L=[],M=new Map;for await(let w of X.prompt(F,J(),q,Q?.(),Y?.(),Z?.
|
|
|
5645
5645
|
z-index: 8;
|
|
5646
5646
|
}
|
|
5647
5647
|
.dc-context-menu .dc-menu-flyout.is-flip { left: auto; right: calc(100% + 3px); }
|
|
5648
|
-
`.trim();function r40(){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=n40,document.head.appendChild(X)}function yf({target:X,sections:J,onClose:Q}){r40();let Y=h6.useRef(null),[W,G]=h6.useState({x:X.clientX,y:X.clientY});h6.useEffect(()=>{let H=Y.current;if(!H)return;let q=H.getBoundingClientRect(),K=window.innerWidth,V=window.innerHeight,B=X.clientX,F=X.clientY;if(B+q.width>K-8)B=Math.max(8,K-q.width-8);if(F+q.height>V-8)F=Math.max(8,V-q.height-8);if(B!==W.x||F!==W.y)G({x:B,y:F});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let M=(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 D=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(D.length===0)return;let P=D.indexOf(document.activeElement),T=A.key==="ArrowDown"?(P+1)%D.length:(P-1+D.length)%D.length;D[T]?.focus()}},R=()=>Q();return document.addEventListener("pointerdown",M,!0),document.addEventListener("keydown",w,!0),document.addEventListener("scroll",R,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("scroll",R,!0),window.removeEventListener("blur",Q)}},[X.clientX,X.clientY,Q,W.x,W.y]);let Z=J.map((H)=>H.filter((q)=>{return!(typeof q.hidden==="function"?q.hidden(X):q.hidden)})).filter((H)=>H.length>0);return z("div",{ref:Y,className:"dc-context-menu",role:"menu",style:{left:W.x,top:W.y},children:Z.map((H,q)=>{let K=H.map((V)=>V.id).join("|")||`s${q}`;return _("div",{role:"group",children:[q>0?z("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((V)=>z(a40,{item:V,target:X,onClose:Q},V.id))]},K)})})}function a40({item:X,target:J,onClose:Q}){let[Y,W]=h6.useState(!1),[G,Z]=h6.useState(!1),H=h6.useRef(null),q=h6.useRef(null),K=h6.useRef(null),V=typeof X.submenu==="function"?X.submenu(J):X.submenu,B=typeof X.disabled==="function"?X.disabled(J):X.disabled;if(!V||V.length===0)return _("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:[z("span",{children:X.label}),X.shortcut?z("span",{className:"dc-menu-shortcut",children:X.shortcut}):null]});let F=()=>{if(K.current)clearTimeout(K.current),K.current=null},L=(w=!1)=>{F();let R=H.current?.getBoundingClientRect();if(R&&typeof window<"u")Z(R.right+200>window.innerWidth);if(W(!0),w)setTimeout(()=>{q.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},M=()=>{F(),K.current=setTimeout(()=>W(!1),140)};return _("div",{className:"dc-menu-sub",onMouseEnter:()=>L(),onMouseLeave:M,children:[_("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:[z("span",{children:X.label}),z("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?z("div",{ref:q,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:F,onMouseLeave:M,children:V.map((w)=>_("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:(R)=>{if(R.key==="ArrowLeft"||R.key==="Escape")R.preventDefault(),R.stopPropagation(),W(!1),H.current?.focus()},children:[z("span",{children:w.label}),w.shortcut?z("span",{className:"dc-menu-shortcut",children:w.shortcut}):null]},w.id))}):null]})}function aH(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 s40(X){let J=aH(X);if(J==="video")return"▶";if(J==="image")return"◫";if(J==="audio")return"♪";return"ƒ"}function ff(X){let J=aH(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 c2({name:X,size:J=15}){return z("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:z("path",{d:"M4 3l9 5-9 5z",fill:"currentColor",stroke:"none"}),pause:_(W0,{children:[z("rect",{x:"4",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"}),z("rect",{x:"9",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"})]}),loop:_(W0,{children:[z("polyline",{points:"4 4 4 7 7 7"}),z("path",{d:"M4 7a4.5 4.5 0 1 1 1.3 4.6"})]}),start:_(W0,{children:[z("line",{x1:"4.5",y1:"3.5",x2:"4.5",y2:"12.5"}),z("path",{d:"M12 3.5l-6 4.5 6 4.5z",fill:"currentColor",stroke:"none"})]}),sound:_(W0,{children:[z("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),z("path",{d:"M10.5 5.5a3.2 3.2 0 0 1 0 5"}),z("path",{d:"M12.3 3.7a5.6 5.6 0 0 1 0 8.6"})]}),muted:_(W0,{children:[z("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),z("line",{x1:"10.7",y1:"6",x2:"13.7",y2:"10"}),z("line",{x1:"13.7",y1:"6",x2:"10.7",y2:"10"})]})}[X]})}var XU=(X,J,Q)=>Math.max(J,Math.min(Q,X));function t40(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 Uw({comps:X=[],sequences:J=[],audio:Q=[],total:Y=0,frame:W=0,playing:G=!1,loop:Z=!1,onSeek:H,onPlay:q,onPause:K,onToggleLoop:V,muted:B=!1,onToggleMute:F,volume:L=1,onVolume:M,height:w,resizing:R,onResize:A,onRetime:D,onRemove:P,onReplace:T,onReplaceAudio:I,onReplaceLayer:S,onReorder:C,onToggleHide:j,onDropMedia:f,onClose:m}){let[o,n]=T7.useState(()=>new Set),[x,i]=T7.useState(!1),a=X[0]??null,h=Math.max(1,Y||a?.durationInFrames||1),s=a?.fps??30,X0=XU(Math.round(W),0,h-1),c=T7.useRef(null),V0=T7.useRef(!1),p=T7.useRef(null);T7.useEffect(()=>{p.current?.focus()},[]);let[g,d]=T7.useState(null),[K0,u0]=T7.useState(null),[J8,G8]=T7.useState(null),s0=T7.useRef(!1),D8=T7.useCallback((F0)=>{F0.preventDefault(),F0.stopPropagation(),F0.currentTarget.setPointerCapture?.(F0.pointerId);let U0=F0.clientY,k0=w||216,H0=(N0)=>{A?.(XU(k0+(U0-N0.clientY),140,640))},L0=()=>{window.removeEventListener("pointermove",H0),window.removeEventListener("pointerup",L0)};window.addEventListener("pointermove",H0),window.addEventListener("pointerup",L0)},[w,A]),U8=96,q8=T7.useCallback((F0)=>{let U0=c.current;if(!U0)return;let k0=U0.getBoundingClientRect(),H0=Math.max(1,k0.width-U8),L0=XU((F0-k0.left-U8)/H0,0,1);H?.(Math.round(L0*(h-1)))},[H,h]);T7.useEffect(()=>{if(!V0.current)return;let F0=(k0)=>q8(k0.clientX),U0=()=>{V0.current=!1};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}});let m8=(F0)=>{if(g)return;F0.preventDefault(),V0.current=!0,q8(F0.clientX),F0.currentTarget.setPointerCapture?.(F0.pointerId)};T7.useEffect(()=>{if(!g)return;let F0=(k0)=>{let H0=(k0.clientX-g.startX)/Math.max(1,g.rowW)*(h-1),L0=g.startFrom+Math.round(g.startDur+H0),N0=k0.altKey?0:Kw(g.rowW,h);L0=zw(L0,g.targets,N0);let t0=Math.max(1,L0-g.startFrom);d(($8)=>$8?{...$8,curDur:t0}:$8)},U0=()=>{d((k0)=>{if(k0&&k0.curDur!==k0.startDur)D?.(k0.index,{durationInFrames:k0.curDur});return null})};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}},[g,h,D]),T7.useEffect(()=>{if(!K0)return;let F0=(k0)=>{let H0=(k0.clientX-K0.startX)/Math.max(1,K0.rowW)*(h-1),L0=Math.max(0,Math.round(K0.startFrom+H0)),N0=k0.altKey?0:Kw(K0.rowW,h);if(L0=Math.max(0,zw(L0,K0.targets,N0)),Math.abs(L0-K0.startFrom)>=1)s0.current=!0;u0((t0)=>t0?{...t0,curFrom:L0}:t0)},U0=()=>{u0((k0)=>{if(k0&&k0.curFrom!==k0.startFrom)D?.(k0.index,{from:k0.curFrom});return null})};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}},[K0,h,D]);let _8=(F0)=>jf({fps:s,totalFrames:h,clips:J,movingIndex:F0,playhead:X0}),G9=(F0,U0,k0)=>{if(!D)return;if(J[U0]?.series)return;F0.stopPropagation();let H0=F0.currentTarget.closest(".tl-row-track"),L0=H0?H0.getBoundingClientRect().width:300;s0.current=!1,u0({index:U0,startX:F0.clientX,startFrom:k0,rowW:L0,curFrom:k0,targets:_8(U0)})},Z9=(F0,U0,k0)=>{F0.stopPropagation(),F0.preventDefault();let H0=F0.currentTarget.closest(".tl-row-track"),L0=H0?H0.getBoundingClientRect().width:300,N0=J[U0]?.from??0;d({index:U0,startX:F0.clientX,startDur:k0,startFrom:N0,rowW:L0,curDur:k0,targets:_8(U0)})},e0=Math.max(1,Math.floor((h-1)/s)),p8=Array.from({length:e0+1},(F0,U0)=>U0*s/(h-1)),o8=(F0)=>`${XU(F0,0,h-1)/(h-1)*100}%`,$9=(F0)=>Array.from(F0?.types??[]).includes("Files"),j0=(F0)=>{if(!f||!$9(F0.dataTransfer))return;F0.preventDefault(),F0.stopPropagation(),i(!1);let U0=F0.dataTransfer.files?.[0];if(U0)f(U0)};return _("aside",{ref:p,tabIndex:-1,className:`tl-panel${R?" is-resizing":""}${x?" is-drop":""}`,style:{...w?{height:w}:{},outline:"none"},onDragOver:(F0)=>{if(!f||!$9(F0.dataTransfer))return;if(F0.preventDefault(),F0.dataTransfer.dropEffect="copy",!x)i(!0)},onDragLeave:(F0)=>{if(F0.relatedTarget==null)i(!1)},onDrop:j0,"aria-label":"Timeline","data-testid":"timeline-panel",children:[z("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:D8}),_("div",{className:"tl-head",children:[a?_(W0,{children:[z("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":G?"Pause":"Play","aria-pressed":G,"data-testid":"timeline-playpause",onClick:()=>G?K?.():q?.(),children:z(c2,{name:G?"pause":"play"})}),z("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>H?.(0),children:z(c2,{name:"start"})}),z("button",{type:"button",className:`tl-btn${Z?" is-on":""}`,"aria-label":"Loop","aria-pressed":Z,"data-testid":"timeline-loop",onClick:()=>V?.(),children:z(c2,{name:"loop"})}),Q.length>0?z("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:z(c2,{name:B?"muted":"sound"})}):null,Q.length>0?z("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:(F0)=>M?.(Number(F0.target.value)/100)}):null,_("span",{className:"tl-readout","data-testid":"timeline-readout",children:[z("b",{children:X0}),z("span",{className:"tl-sep",children:"/"}),h-1,z("span",{className:"tl-time",children:t40(X0,s)})]})]}):z("span",{className:"tl-title",children:"Timeline"}),z("span",{className:"tl-spacer"}),a?_("span",{className:"tl-meta",children:[s," fps · ",h,"f"]}):null,z("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:m,children:"×"})]}),!a?_("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No animation on this canvas. Make an artboard a ",z("b",{children:"video-comp"}),"(",z("code",{children:"<VideoComp>"}),") to scrub and export it — or drop clips on the canvas and ",z("b",{children:"File → Assemble dropped clips → video"}),"."]}):z("div",{className:"tl-scroll",children:_("div",{className:"tl-tracks",ref:c,"data-testid":"timeline-track",onPointerDown:m8,children:[z("div",{className:"tl-ruler",children:p8.map((F0,U0)=>z("span",{className:"tl-tick",style:{left:`${F0*100}%`},children:_("span",{className:"tl-tick-label",children:[U0,"s"]})},U0))}),J.length===0?_("div",{className:"tl-row",children:[z("span",{className:"tl-row-label",children:"comp"}),z("div",{className:"tl-row-track",children:z("div",{className:"tl-seq-block",style:{left:"0%",width:"100%"},children:z("span",{className:"tl-seq-name",children:"whole composition"})})})]}):J.map((F0,U0)=>{let k0=g&&g.index===U0?g.curDur:F0.duration,H0=!!(g&&g.index===U0),L0=K0&&K0.index===U0?K0.curFrom:F0.from,N0=!!(K0&&K0.index===U0),t0=Array.isArray(F0.layers)?F0.layers:[],$8=t0.length>=2,y0=$8&&!o.has(U0);return _(T7.Fragment,{children:[_("div",{className:"tl-row","data-testid":`timeline-row-${U0}`,children:[_("span",{className:"tl-row-label",title:F0.label,children:[$8?z("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${U0}`,title:y0?"Collapse layers":"Show layers","aria-label":y0?`Collapse ${F0.label} layers`:`Show ${F0.label} layers`,"aria-expanded":y0,onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),v0.preventDefault(),n((O0)=>{let n0=new Set(O0);if(n0.has(U0))n0.delete(U0);else n0.add(U0);return n0})},children:y0?"▾":"▸"}):z("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),C?_("span",{className:"tl-seq-reorder",role:"group","aria-label":`${F0.series?"Play order":"Stacking order"} for ${F0.label}`,children:[z("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-raise-${U0}`,title:F0.series?"Move earlier (plays sooner)":"Bring forward (render on top)","aria-label":F0.series?`Move ${F0.label} earlier`:`Bring ${F0.label} forward`,disabled:F0.series?U0<=0:U0>=J.length-1,onClick:(v0)=>{v0.stopPropagation(),C(U0,F0.series?"backward":"forward")},children:"▲"}),z("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-lower-${U0}`,title:F0.series?"Move later (plays after)":"Send backward (render underneath)","aria-label":F0.series?`Move ${F0.label} later`:`Send ${F0.label} backward`,disabled:F0.series?U0>=J.length-1:U0<=0,onClick:(v0)=>{v0.stopPropagation(),C(U0,F0.series?"forward":"backward")},children:"▼"})]}):null,z("span",{className:"tl-kind","data-kind":aH(F0),title:ff(F0),"aria-label":ff(F0),children:s40(F0)}),z("span",{className:"tl-row-label-text",children:F0.label})]}),_("div",{className:"tl-row-track",children:[_("button",{type:"button",className:`tl-seq-block${H0?" is-resizing":""}${N0?" is-moving":""}${F0.hidden?" is-hidden":""}`,"data-testid":`timeline-seq-${U0}`,"data-kind":aH(F0),"data-hidden":F0.hidden?"1":void 0,title:F0.series?`${F0.label} · ${L0}–${L0+k0}f (${k0}f) · position computed by the series — trim the right edge to retime`:`${F0.label} · ${L0}–${L0+k0}f (${k0}f) · drag to move (Alt = no snap)`,"aria-label":F0.series?`${F0.label}, series beat, frames ${L0} to ${L0+k0}. Click to seek; trim its edge to retime.`:`${F0.label}, from frame ${L0} to ${L0+k0}, ${k0} frames. Click to seek; drag to move.`,style:{left:o8(L0),width:`${k0/(h-1)*100}%`,cursor:D&&!F0.series?"grab":void 0},onContextMenu:(v0)=>{v0.preventDefault(),v0.stopPropagation(),G8({index:U0,x:v0.clientX,y:v0.clientY})},onPointerDown:(v0)=>G9(v0,U0,F0.from),onClick:(v0)=>{if(v0.stopPropagation(),s0.current){s0.current=!1;return}H?.(F0.from)},children:[_("span",{className:"tl-seq-name",children:[F0.label,H0?` · ${k0}f`:"",N0?` · @${L0}f`:""]}),F0.keyframes.map((v0,O0)=>{let n0=(v0.from-F0.from)/Math.max(1,F0.duration)*100,Q8=(v0.to-v0.from)/Math.max(1,F0.duration)*100;return z("span",{className:"tl-kf","data-testid":`timeline-kf-${U0}-${O0}`,style:{left:`${XU(n0,0,100)}%`,width:`${Math.max(1.5,Q8)}%`},title:`seek to keyframe ${v0.from}f (animates ${v0.from}–${v0.to}f)`,onPointerDown:(w0)=>w0.stopPropagation(),onClick:(w0)=>{w0.stopPropagation(),H?.(v0.from)}},O0)})]}),D?z("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${U0}`,title:"Drag to retime this sequence",style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 5px)`},onPointerDown:(v0)=>Z9(v0,U0,F0.duration),onClick:(v0)=>v0.stopPropagation()}):null,T&&F0.replaceable&&!$8?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${U0}`,title:`Replace this ${aH(F0)}`,"aria-label":`Replace media in ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 34px)`},onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),T(U0)},children:"⇄"}):null,P?z("button",{type:"button",className:"tl-seq-remove","data-testid":`timeline-remove-${U0}`,title:"Remove this clip","aria-label":`Remove ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 17px)`},onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),P(U0)},children:"×"}):null]})]}),y0?t0.map((v0,O0)=>{let n0=v0.kind==="video"?"video":v0.kind==="image"?"image":v0.kind==="audio"?"audio":"jsx",Q8=v0.kind==="video"?"▶":v0.kind==="image"?"◫":v0.kind==="audio"?"♪":"ƒ",w0=!!(v0.mediaCdId||v0.mediaArrayRef);return _("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${U0}-${O0}`,children:[_("span",{className:"tl-row-label",title:v0.label,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":n0,children:Q8}),z("span",{className:"tl-row-label-text",children:v0.label})]}),_("div",{className:"tl-row-track",children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":n0,"data-testid":`timeline-layer-block-${U0}-${O0}`,title:`${v0.label} (${v0.kind} layer)`,style:{left:o8(F0.from),width:`${k0/(h-1)*100}%`},onContextMenu:(i0)=>{i0.preventDefault(),i0.stopPropagation(),G8({index:U0,layerIndex:O0,x:i0.clientX,y:i0.clientY})},children:z("span",{className:"tl-seq-name",children:v0.label})}),S&&w0?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${U0}-${O0}`,title:`Replace this ${v0.kind}`,"aria-label":`Replace ${v0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 20px)`},onPointerDown:(i0)=>i0.stopPropagation(),onClick:(i0)=>{i0.stopPropagation(),S(U0,O0)},children:"⇄"}):null]})]},`l${O0}`)}):null]},U0)}),Q.map((F0,U0)=>_("div",{className:"tl-row","data-testid":`timeline-audio-${U0}`,children:[_("span",{className:"tl-row-label",title:F0.label,children:[z("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${F0.label}`,"aria-label":`Audio · ${F0.label}`,children:"♪"}),z("span",{className:"tl-row-label-text",children:F0.label})]}),_("div",{className:"tl-row-track",children:[_("div",{className:"tl-audio-block",title:`${F0.label} · ${F0.from}–${F0.from+F0.duration}f`,style:{left:o8(F0.from),width:`${F0.duration/(h-1)*100}%`},children:[z("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:z("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"})}),z("span",{className:"tl-seq-name",children:F0.label})]}),I?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${U0}`,title:"Replace this audio","aria-label":`Replace audio ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${F0.duration/(h-1)*100}% - 20px)`},onPointerDown:(k0)=>k0.stopPropagation(),onClick:(k0)=>{k0.stopPropagation(),I(U0)},children:"⇄"}):null]})]},`a${U0}`)),z("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:`calc(96px + (100% - 96px) * ${X0/(h-1)||0})`}})]})}),J8&&J[J8.index]?(()=>{let F0=J[J8.index],U0=J8.index,k0=J8.layerIndex,H0;if(k0!=null){let L0=(Array.isArray(F0.layers)?F0.layers:[])[k0],N0=[];if(S&&L0&&(L0.mediaCdId||L0.mediaArrayRef))N0.push({id:"replace-layer",label:`Replace ${L0.kind}…`,onSelect:()=>S(U0,k0)});if(N0.length===0)N0.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});H0=[N0]}else{let L0=[];if(T&&F0.replaceable&&!(Array.isArray(F0.layers)&&F0.layers.length>=2))L0.push({id:"replace",label:`Replace ${aH(F0)}…`,onSelect:()=>T(U0)});if(C)L0.push({id:"earlier",label:F0.series?"Move earlier":"Bring forward",disabled:F0.series?U0<=0:U0>=J.length-1,onSelect:()=>C(U0,F0.series?"backward":"forward")}),L0.push({id:"later",label:F0.series?"Move later":"Send backward",disabled:F0.series?U0>=J.length-1:U0<=0,onSelect:()=>C(U0,F0.series?"forward":"backward")});H0=[L0];let N0=[];if(j)N0.push({id:"hide",label:F0.hidden?"Show clip":"Hide clip",onSelect:()=>j(U0)});if(P)N0.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>P(U0)});if(N0.length)H0.push(N0)}return z(yf,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:J8.x,clientY:J8.y},sections:H0,onClose:()=>G8(null)})})():null]})}function e40(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=r5(Y[2],J);if(G!=null)J[W]=G}return J}function r5(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 XW0(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),Z=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,Z>0?Z:2400),q=[];for(let K of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let V=r5(K[1],Q),B=r5(K[2],Q);if(V!=null&&B!=null&&B>=V)q.push({from:Y+V,to:Y+B})}return q}function JW0(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 QW0(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:r5(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],J),fps:r5(W.match(/fps=\{([^}]+)\}/)?.[1],J)||30})}return Q}function vf(X,J,Q){let Y=String(X??""),W=e40(Y),G=Y,Z=J,H=0,q=null,K=QW0(Y,W).map((D)=>({...D,body:JW0(Y,D.compName)})).filter((D)=>D.body);if(K.length){let D=Q&&K.find((P)=>P.artboardId===Q)||K.find((P)=>/<(?:Audio|OffthreadVideo|Video)\b/.test(P.body))||K.find((P)=>P.duration!=null&&P.duration===J)||K[0];if(G=D.body,D.duration!=null)Z=D.duration;H=D.fps,q=D.artboardId??null}let V=[],B=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=B.exec(G)){let D=F[1],P=F[2],T=B.lastIndex;if(/Transition$/.test(D)){let I=P.match(/durationInFrames:\s*([^,}\s)]+)/);V.push({type:"transition",dur:r5(I?.[1],W)??0})}else{let I=P.match(/durationInFrames=\{([^}]+)\}/),S=P.match(/from=\{([^}]+)\}/),C=G.indexOf(`</${D}>`,T),j=C>=0?Math.min(C,T+400):T+240,f=G.slice(T,j),m=f.match(/<([A-Z][A-Za-z0-9]*)\b/),o=f.match(/<(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),n=P.match(/name=["']([^"']+)["']/);V.push({type:"seq",series:D!=="Sequence",dur:r5(I?.[1],W),from:D==="Sequence"&&S?r5(S[1],W):null,compName:n?n[1]:m?m[1]:null,mediaTag:o?o[1]:null,mediaSrc:o?o[2]:null})}}let L=0,M=[];for(let D of V){if(D.type==="transition"){L-=D.dur||0;continue}let P=D.from!=null?D.from:L,T=D.dur!=null?D.dur:30;M.push({label:D.compName??`Seq ${M.length+1}`,series:!!D.series,mediaTag:D.mediaTag,mediaSrc:D.mediaSrc,from:Math.max(0,P),duration:Math.max(1,T),keyframes:XW0(Y,D.compName,W,Math.max(0,P))}),L=P+T}let w=M.length?Math.max(...M.map((D)=>D.from+D.duration)):30,R=Number.isFinite(Z)&&Z>0?Z:w,A=[];for(let D of G.matchAll(/<Audio\b([^>]*)>/g)){let P=D[1],T=P.match(/src=["']([^"']+)["']/),I=P.match(/from=\{([^}]+)\}/),S=P.match(/durationInFrames=\{([^}]+)\}/),C=I?r5(I[1],W)??0:0,j=S?r5(S[1],W):null,f=T?String(T[1]).split(/[\\/]/).pop():"audio";A.push({kind:"audio",label:f,from:Math.max(0,C),duration:j!=null?Math.max(1,j):Math.max(1,R-C)})}return{total:R,fps:H||void 0,sequences:M,audio:A,artboardId:q}}var K7=S8(v8(),1);function Vw({name:X,size:J=16}){let Q={x:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),sparkle:z("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:_(W0,{children:[z("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),z("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]})}[X];return z("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 YW0=["1:1","16:9","9:16","4:3","3:4","4:5"];function Bw({onClose:X,onInsert:J}){let[Q,Y]=K7.useState([]),[W,G]=K7.useState(""),[Z,H]=K7.useState([]),[q,K]=K7.useState(""),[V,B]=K7.useState("1:1"),[F,L]=K7.useState(""),[M,w]=K7.useState(!1),[R,A]=K7.useState(null),[D,P]=K7.useState(null),[T,I]=K7.useState(!0),[S,C]=K7.useState(null),j=K7.useRef(null),f=K7.useRef(null);K7.useEffect(()=>{fetch("/_api/generate/providers").then((i)=>i.json()).then((i)=>{let a=(i?.providers??[]).filter((s)=>s.modalities?.includes("image"));Y(a);let h=a.find((s)=>s.configured)??a[0];if(h)G(h.id)}).catch(()=>A({ok:!1,msg:"failed to load providers"}))},[]),K7.useEffect(()=>{if(!W)return;H([]),K("")},[W]),K7.useEffect(()=>{function i(a){if(a.key==="Escape")a.preventDefault(),X()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[X]),K7.useEffect(()=>()=>clearInterval(j.current),[]),K7.useEffect(()=>{if(!D||!T||typeof J!=="function")return;if(f.current===D)return;f.current=D;let i=J(D)===!0;if(C(i),i)A({ok:!0,msg:"Placed on canvas ✓"});else A({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[D,T,J]);let m=Q.find((i)=>i.id===W),o=m&&!m.configured,n=K7.useCallback((i)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let h=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((s)=>s.id===i);if(!h)return;if(h.status==="done"){clearInterval(j.current),w(!1);let s=h.assets?.[0]??null;P(s),A({ok:!0,msg:s?`Generated ${s}`:"Done (no asset)"})}else if(h.status==="failed")clearInterval(j.current),w(!1),A({ok:!1,msg:h.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),w((a)=>{if(a)A({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function x(){if(!F.trim()||!W)return;w(!0),A(null),P(null),C(null),f.current=null;try{let i={modality:"image",provider:W,prompt:F.trim(),aspectRatio:V,...q?{model:q}:{}},a=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(i)});if(a.status===202){let{jobId:h}=await a.json();A({ok:!0,msg:"Generating…"}),n(h)}else w(!1),A({ok:!1,msg:await a.text()})}catch(i){w(!1),A({ok:!1,msg:i&&i.message?i.message:"request failed"})}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)X()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Generate with AI"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:z(Vw,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:"Prompt"}),z("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:(i)=>L(i.target.value)}),_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-provider",children:"Provider"}),z("select",{id:"st-gen-provider",className:"st-select",value:W,onChange:(i)=>G(i.target.value),children:Q.map((i)=>_("option",{value:i.id,children:[i.label,i.configured?"":" — no key"]},i.id))})]}),Z.length>0&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-model",children:"Model"}),z("select",{id:"st-gen-model",className:"st-select",value:q,onChange:(i)=>K(i.target.value),children:Z.map((i)=>z("option",{value:i.id,children:i.label},i.id))})]}),_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-aspect",children:"Aspect"}),z("select",{id:"st-gen-aspect",className:"st-select",value:V,onChange:(i)=>B(i.target.value),children:YW0.map((i)=>z("option",{value:i,children:i},i))})]}),J&&_("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[z("input",{type:"checkbox",checked:T,onChange:(i)=>I(i.target.checked),"aria-label":"Place the generated image on the canvas"}),z("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),o&&_("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",m.label," — add one in Settings (⌘,)."]}),D&&_("div",{className:"st-gen-result",children:[z("img",{className:"st-gen-thumb",src:`/${D}`,alt:"generated"}),_("div",{className:"st-gen-result-actions",children:[_("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${D}`),children:[z(Vw,{name:"copy",size:13})," Copy path"]}),J&&S!==!0&&z("button",{type:"button",className:"st-btn",onClick:()=>{let i=J(D)===!0;C(i),A(i?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),R&&z("div",{className:"st-provider-status",style:{color:R.ok?"var(--accent)":"var(--danger, #e5484d)"},children:R.msg}),z("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:_("button",{type:"button",className:"st-btn st-gen-go",disabled:M||!F.trim()||!W,onClick:x,children:[z(Vw,{name:"sparkle",size:14})," ",M?"Generating…":"Generate"]})})]})]})})}var p9=S8(v8(),1);var i2=new Set(["main","master"]);function x9({name:X,size:J=16,className:Q}){let Y={check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),"chevron-up":z("polyline",{points:"3.5 10 8 5.5 12.5 10"}),"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-open":_(W0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14"}),z("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:_(W0,{children:[z("circle",{cx:"4",cy:"8",r:"1.6"}),z("circle",{cx:"12",cy:"4",r:"1.6"}),z("circle",{cx:"12",cy:"12",r:"1.6"}),z("line",{x1:"5.4",y1:"7.2",x2:"10.6",y2:"4.6"}),z("line",{x1:"5.4",y1:"8.8",x2:"10.6",y2:"11.4"})]}),draft:_(W0,{children:[z("path",{d:"M3 11.5 11 3.5l1.5 1.5L4.5 13l-2 .5z"}),z("line",{x1:"9.5",y1:"5",x2:"11",y2:"6.5"})]}),branch:_(W0,{children:[z("circle",{cx:"4.5",cy:"4",r:"1.4"}),z("circle",{cx:"4.5",cy:"12",r:"1.4"}),z("circle",{cx:"11.5",cy:"6.5",r:"1.4"}),z("line",{x1:"4.5",y1:"5.4",x2:"4.5",y2:"10.6"}),z("path",{d:"M4.5 8.6h2.6a3 3 0 0 0 3-1.6"})]}),plus:_(W0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),"arrow-up-to-line":_(W0,{children:[z("line",{x1:"3.5",y1:"3",x2:"12.5",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"6"}),z("polyline",{points:"5 8.5 8 5.5 11 8.5"})]}),cloud:z("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:_(W0,{children:[z("path",{d:"M12.5 8a4.5 4.5 0 1 1-1.3-3.2"}),z("polyline",{points:"12.8 2.5 12.8 5 10.3 5"})]}),spinner:z("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10.5"}),z("polyline",{points:"5 7.5 8 10.5 11 7.5"}),z("line",{x1:"3.5",y1:"13.2",x2:"12.5",y2:"13.2"})]}),close:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[X];return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function o2(X){return String(X).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(X)}function xf(X){return X.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Fw(X){return String(X).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function WW0(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 Nw(X){return(await fetch(X)).json()}async function n2(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}),Z=null;try{Z=await G.json()}catch{}return{ok:G.ok,status:G.status,json:Z}}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 Lw({project:X,liveBranch:J,remoteSync:Q,onGetLatest:Y}){let W=K9(),[G,Z]=p9.useState(null),[H,q]=p9.useState([]),[K,V]=p9.useState([]),[B,F]=p9.useState(!1),[L,M]=p9.useState(!1),[w,R]=p9.useState(""),[A,D]=p9.useState(!1),[P,T]=p9.useState(""),[I,S]=p9.useState(null),[C,j]=p9.useState(!1),[f,m]=p9.useState(!1),[o,n]=p9.useState(!1);async function x(w0){if(!K9()){window.open(w0,"_blank","noopener,noreferrer");return}try{await hy(w0)}catch{try{await navigator.clipboard.writeText(w0),j(!0)}catch{}}}let[i,a]=p9.useState(!1),[h,s]=p9.useState(""),[X0,c]=p9.useState(""),[V0,p]=p9.useState(""),[g,d]=p9.useState(!1),[K0,u0]=p9.useState(0),[J8,G8]=p9.useState(!1),s0=p9.useRef(null);if(p9.useEffect(()=>{let w0=!0;if((async()=>{try{let i0=await Nw("/_api/git/status");if(!w0)return;if(Z(i0),i0.repo&&W){let H9=await Nw("/_api/git/branches");if(w0)q(H9.branches||[])}}catch{}})(),W)cy().then((i0)=>w0&&V(i0||[])).catch(()=>{});return()=>{w0=!1}},[W]),p9.useEffect(()=>{if(!B||!W||!G?.repo)return;c(""),F0()},[B]),p9.useEffect(()=>{if(!B&&!L)return;let w0=(i0)=>{if(s0.current&&!s0.current.contains(i0.target))F(!1),M(!1),p("")};return document.addEventListener("mousedown",w0),()=>document.removeEventListener("mousedown",w0)},[B,L]),!G?.repo)return null;let D8=J||G.branch||"main",U8=i2.has(D8),q8=H.find((w0)=>i2.has(w0.name))?.name||"main",m8=(w0,i0)=>(i0.updatedAt||0)-(w0.updatedAt||0)||w0.name.localeCompare(i0.name),_8=V0.trim().toLowerCase(),G9=(w0)=>!_8||w0.name.toLowerCase().includes(_8),Z9=H.filter((w0)=>!i2.has(w0.name)).sort(m8),e0=Z9.filter(G9),p8=e0.filter((w0)=>w0.name!==D8),o8=!_8||q8.toLowerCase().includes(_8)||"shared version".includes(_8),$9=Z9.length>6,j0=X||o2(K[0]||"Project");if(!W)return z("div",{className:"rb-dock-wrap",children:z("div",{className:"rb-dock rb-dock--ro",children:_("span",{className:"rb-trigger rb-trigger--ro",title:`${j0} · branch: ${D8} — switch branches in your terminal`,children:[z("span",{className:"rb-trigger-icon",children:z(x9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),_("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[z(x9,{name:"branch",size:12}),_("span",{className:"rb-trigger-ver-name",children:["branch: ",D8]})]})]})})});async function F0(){try{let w0=await Nw("/_api/git/branches");q(w0.branches||[])}catch{}}async function U0(w0,i0){if(F(!1),w0===D8)return;s(w0),G8(i0==="remote"),c("");let H9=await n2("/_api/git/checkout",{name:w0});if(H9.ok&&H9.json?.ok)window.location.reload();else c(H9.json?.error||"Could not switch."),s(""),G8(!1)}async function k0(){if(g)return;d(!0),c("");let w0=await n2("/_api/git/fetch",{},{timeoutMs:45000});if(w0.ok&&w0.json?.ok){if(w0.json.fetchedAt)u0(w0.json.fetchedAt);await F0()}else if(w0.timedOut||w0.json?.timedOut)c("Couldn’t reach the remote — your local branches are still listed above.");else c(w0.status===401||w0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":w0.json?.error||"Could not fetch remote branches.");d(!1)}async function H0(){let w0=xf(w);if(!w0)return;a(!0),c("");let i0=await n2("/_api/git/branch",{name:w0});if(i0.ok&&i0.json?.ok)window.location.reload();else c(i0.json?.error||"Could not create the draft."),a(!1)}async function L0(){if(f||!Y)return;m(!0),c("");let w0=await Y();if(m(!1),w0&&!w0.ok&&!w0.conflict)c(w0.status===401||w0.authRequired?"Sign in with GitHub to get the latest.":w0.error||"Could not get the latest.")}async function N0(){T(D8),c("");let w0=await n2("/_api/git/fold",{name:D8},{timeoutMs:45000}),i0=w0.json;if(w0.ok&&i0?.ok&&i0.prUrl){S({url:i0.prUrl,number:i0.prNumber,repo:i0.repo}),T(""),F0();return}if(w0.ok&&i0?.ok&&i0.prUnavailable){S({message:i0.error||"Draft published, but the pull request could not be opened."}),T(""),F0();return}if(w0.ok&&i0?.ok){window.location.reload();return}c(w0.status===401?`Sign in with GitHub to add “${D8}” to ${q8}.`:i0?.error||"Could not add the branch."),T("")}async function t0(w0){if(F(!1),!W)return;s(o2(w0));try{await RJ(w0)}catch(i0){c(String(i0?.message||i0||"Could not open that project.")),s("")}}async function $8(){if(F(!1),!W)return;try{let w0=await YY();if(!w0)return;s(o2(w0)),await RJ(w0)}catch(w0){c(String(w0?.message||w0||"Could not open that folder.")),s("")}}let y0=xf(w),v0=U8?null:H.find((w0)=>w0.current),O0=U8&&!o&&!h&&!P?[...H].filter((w0)=>!i2.has(w0.name)&&w0.where!=="remote").sort((w0,i0)=>(i0.updatedAt||0)-(w0.updatedAt||0))[0]:null,n0=_(W0,{children:[_("div",{className:"rb-pop-empty",children:["No branch matches “",V0.trim(),"”."]}),_("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:k0,disabled:g,children:[z("span",{className:"rb-pop-icon"+(g?" rb-pop-icon--spin":""),children:z(x9,{name:g?"spinner":"refresh",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:g?"Searching the remote…":"Search the remote for it"})})]})]}),Q8=(w0)=>{let i0=w0.where==="remote";return _("button",{type:"button","data-testid":`branch-row-${Fw(w0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>U0(w0.name,w0.where),children:[z("span",{className:"rb-pop-icon "+(i0?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:z(x9,{name:i0?"cloud":"draft",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:w0.name}),i0&&z("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},w0.name)};return _("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!h&&!P&&_("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:L0,disabled:f,title:`Get the latest ${q8}`,children:[z(x9,{name:f?"spinner":"download",size:14,className:f?"rb-spin":""}),z("span",{className:"rb-getlatest-tx",children:f?"Getting the latest…":"Get latest"}),!f&&Q.behind>0&&_("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",q8]})]}),O0&&_("div",{className:"rb-resume","data-testid":"switcher-resume",children:[_("button",{type:"button",className:"rb-resume-go",onClick:()=>U0(O0.name),title:`Switch to ${O0.name}`,children:[z("span",{className:"rb-resume-icon",children:z(x9,{name:"draft",size:13})}),_("span",{className:"rb-resume-tx",children:["Continue on ",z("b",{children:O0.name})]}),z(x9,{name:"chevron-right",size:12,className:"rb-resume-arrow"})]}),z("button",{type:"button",className:"rb-resume-x","data-testid":"switcher-resume-dismiss","aria-label":"Dismiss",onClick:()=>n(!0),children:z(x9,{name:"close",size:12})})]}),_("div",{className:"rb-dock",ref:s0,children:[B&&_("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:[z("div",{className:"rb-pop-hd",children:"Project"}),W&&K.length>0?K.map((w0,i0)=>_("button",{type:"button",className:"rb-pop-item"+(i0===0?" is-current":""),role:"menuitem",onClick:()=>t0(w0),children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"folder",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:o2(w0)}),z("span",{className:"rb-pop-sub",children:w0})]}),i0===0?z(x9,{name:"check",size:14,className:"rb-pop-check"}):null]},w0)):z("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&&_("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:$8,children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"folder-open",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open another folder…"})})]}),z("div",{className:"rb-pop-sep"}),z("div",{className:"rb-pop-hd",children:"Branch"}),U8?_(W0,{children:[_("button",{type:"button","data-testid":`branch-row-${Fw(q8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>U0(q8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(x9,{name:"share",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:q8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),z(x9,{name:"check",size:14,className:"rb-pop-check"})]}),Z9.length>0&&z("div",{className:"rb-pop-grouplabel",children:"Other branches"}),$9&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:V0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(w0)=>p(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Escape")p("")}})}),e0.map(Q8),$9&&_8&&e0.length===0&&!o8&&n0]}):_(W0,{children:[_("button",{type:"button",className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",children:[z("span",{className:"rb-pop-icon rb-pop-icon--draft",children:z(x9,{name:"draft",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:v0?.name||D8}),z("span",{className:"rb-pop-sub",children:"your branch"})]}),z(x9,{name:"check",size:14,className:"rb-pop-check"})]}),_("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{F(!1),c(""),S(null),j(!1),D(!0)},children:[z("span",{className:"rb-fold-icon",children:z(x9,{name:"arrow-up-to-line",size:15})}),_("span",{className:"rb-fold-tx",children:[_("span",{className:"rb-fold-title",children:["Merge this branch → ",q8]}),z("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),z("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),$9&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:V0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(w0)=>p(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Escape")p("")}})}),o8&&_("button",{type:"button","data-testid":`branch-row-${Fw(q8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>U0(q8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(x9,{name:"share",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:q8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),p8.map(Q8),$9&&_8&&p8.length===0&&!o8&&n0]}),_("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:k0,disabled:g,children:[z("span",{className:"rb-pop-icon"+(g?" rb-pop-icon--spin":""),children:z(x9,{name:g?"spinner":"refresh",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:g?"Fetching…":"Fetch remote branches"}),z("span",{className:"rb-pop-sub",children:K0?`as of ${WW0(K0)}`:"check the remote for new branches"})]})]}),X0&&!h&&z("div",{className:"rb-pop-notice",role:"alert",children:X0}),_("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{F(!1),M(!0)},children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"plus",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:"New branch"}),z("span",{className:"rb-pop-sub",children:"a separate line of work off what you're looking at now"})]})]})]}),L&&_("div",{className:"rb-newdraft rb-newdraft--up",children:[_("label",{className:"rb-newdraft-field",children:[z("span",{className:"rb-newdraft-label",children:"Name your branch"}),z("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:(w0)=>R(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Enter"&&y0)H0();if(w0.key==="Escape")M(!1),R("")}}),y0&&_("span",{className:"rb-pop-sub",children:["Creates branch ",z("b",{children:y0})]})]}),X0&&z("span",{className:"rb-newdraft-err",children:X0}),_("div",{className:"rb-newdraft-actions",children:[z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{M(!1),R(""),c("")},disabled:i,children:"Cancel"}),_("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:H0,disabled:i||!y0,children:[z(x9,{name:"draft",size:13})," ",i?"Creating…":"Create branch"]})]}),_("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."]})]}),h||P?_("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(x9,{name:"spinner",size:14,className:"rb-spin"}),z("span",{children:P?_(W0,{children:["Merging ",z("b",{children:P})," → ",q8,"…"]}):J8?_(W0,{children:["Downloading ",z("b",{children:h}),"…"]}):_(W0,{children:["Opening ",z("b",{children:h}),"…"]})})]}):_("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((w0)=>{if(w0)p("");return!w0}),M(!1)},title:`${j0} · ${D8}`,children:[z("span",{className:"rb-trigger-icon",children:z(x9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),_("span",{className:"rb-trigger-ver"+(U8?"":" is-draft"),children:[z(x9,{name:U8?"share":"draft",size:12}),z("span",{className:"rb-trigger-ver-name",children:D8})]}),z(x9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),X0&&!B&&!L&&!h&&z("div",{className:"rb-switcher-err",role:"alert",children:X0})]}),A&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>{D(!1),S(null),j(!1)},children:z("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(w0)=>w0.stopPropagation(),onKeyDown:(w0)=>{if(w0.key==="Escape")D(!1),S(null),j(!1)},children:I?I.url?_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"share",size:20})}),_("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",I.number?` #${I.number}`:""]}),_("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",_("b",{children:["“",D8,"”"]})," is up as a pull request into ",z("b",{children:q8}),I.repo?_(W0,{children:[" of ",z("b",{children:I.repo})]}):null,". Review and merge it on GitHub — that keeps your team's review rules."]}),z("p",{className:"rb-sheet-meta rb-pr-url",children:I.url}),_("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{D(!1),S(null),j(!1)},children:"Close"}),_("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>x(I.url),children:[z(x9,{name:"share",size:15})," ",C?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"share",size:20})}),z("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:"Draft published"}),z("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:I.message}),z("div",{className:"rb-sheet-actions",children:z("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{D(!1),S(null),j(!1)},children:"Got it"})})]}):_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"arrow-up-to-line",size:20})}),_("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",q8]}),_("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",_("b",{children:["“",v0?.name||D8,"”"]})," to ",z("b",{children:q8})," — the default branch everyone shares."]}),z("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."}),X0&&z("p",{className:"rb-newdraft-err",children:X0}),_("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{D(!1),c("")},children:"Cancel"}),_("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!P,onClick:N0,children:[z(x9,{name:"arrow-up-to-line",size:15})," ",P?"Adding…":`Add to ${q8}`]})]})]})})})]})}var k9=S8(v8(),1);function EG({name:X,size:J=16}){let Q={x:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:_(W0,{children:[z("circle",{cx:"5.5",cy:"5.5",r:"3"}),z("path",{d:"M7.6 7.6 13 13"}),z("line",{x1:"11",y1:"11",x2:"12.5",y2:"9.5"})]}),check:z("polyline",{points:"3.5 8.5 6.5 11.5 12.5 4.5"}),external:_(W0,{children:[z("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"}),z("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),z("polyline",{points:"9.5 3 13 3 13 6.5"})]}),cloud:z("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 z("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 GW0({provider:X,onChanged:J}){let[Q,Y]=k9.useState(""),[W,G]=k9.useState(!1),[Z,H]=k9.useState(null),q=X.configured;async function K(){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 V(){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 _("div",{className:"st-provider-card",children:[_("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:X.label}),z("span",{className:"st-pill"+(X.kind==="local"?" is-local":""),children:X.kind==="local"?"Local":_(W0,{children:[z(EG,{name:"cloud",size:12})," Cloud"]})}),q&&_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," configured"]})]}),z("div",{className:"st-provider-modalities",children:X.modalities.join(" · ")}),X.notes&&z("div",{className:"st-provider-notes",children:X.notes}),X.keyUrl&&_("a",{className:"st-provider-keylink",href:X.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",z(EG,{name:"external",size:12})]}),X.auth==="api-key"&&_("div",{className:"st-provider-keyrow",children:[z("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:q?"•••••••• 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")K()}}),_("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:K,children:[z(EG,{name:"key",size:13})," Save"]}),q&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:V,children:"Remove"})]}),Z&&z("div",{className:"st-provider-status",style:{color:Z.ok?"var(--accent)":"var(--danger, #e5484d)"},children:Z.msg})]})}var ZW0=[{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 HW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(!1),[W,G]=k9.useState(null);k9.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 Z(H){if(H===X)return;let q=X;J(H),Y(!0),G(null);try{let K=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:H})});if(!K.ok)throw Error(await K.text());G({ok:!0,msg:"Saved."})}catch(K){J(q),G({ok:!1,msg:K&&K.message?K.message:"save failed"})}finally{Y(!1)}}return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:ZW0.map((H)=>_("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"transcription-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>Z(H.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:H.label}),z("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function qW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(null),W=k9.useCallback(()=>{fetch("/_api/generate/whisper-model").then((K)=>K.ok?K.json():Promise.reject(Error(`HTTP ${K.status}`))).then(J).catch((K)=>Y(K&&K.message?K.message:"failed to load models"))},[]);k9.useEffect(()=>{W()},[W]),k9.useEffect(()=>{if(!X?.downloading)return;let K=setInterval(W,1000);return()=>clearInterval(K)},[X?.downloading,W]);async function G(K){Y(null);try{let V=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:K})});if(!V.ok)throw Error(await V.text());W()}catch(V){Y(V&&V.message?V.message:"download failed")}}async function Z(K){Y(null);try{let V=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:K})});if(!V.ok)throw Error(await V.text());W()}catch(V){Y(V&&V.message?V.message:"remove failed")}}let H=X?.downloading,q=(K,V)=>V>0?Math.min(100,Math.round(K/V*100)):0;return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Local subtitle models (whisper.cpp)"})}),_("div",{className:"st-provider-notes",children:["Download a model once and local subtitles work offline, free, with no key. Requires the whisper.cpp binary (",z("code",{children:"brew install whisper-cpp"}),"). Models are stored on this machine only and never committed."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&_("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),X===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(X?.models||[]).map((K)=>{let V=H&&!H.error&&H.id===K.id;return _("div",{className:"st-model-row",children:[_("div",{className:"st-model-info",children:[_("span",{className:"st-model-label",children:[K.label,z("span",{className:"st-pill"+(K.multilingual?"":" is-local"),children:K.multilingual?"multilingual":"English-only"}),_("span",{className:"st-model-size",children:["~",K.sizeMB," MB"]})]}),z("span",{className:"st-engine-radio-note",children:K.note}),V&&_("span",{className:"st-model-progress",children:["Downloading… ",q(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:K.downloaded?_(W0,{children:[_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," ready"]}),z("button",{type:"button",className:"st-btn",onClick:()=>Z(K.id),children:"Remove"})]}):z("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(K.id),children:V?"Downloading…":"Download"})})]},K.id)})})]})}var zW0=[{id:"auto",label:"Auto",note:"Use the best available: Gemma scout → ffmpeg → blind."},{id:"gemma",label:"Gemma scout",note:"Semantic action beats. Needs Apple Silicon + mlx-vlm + a model."},{id:"ffmpeg",label:"ffmpeg scene-detect",note:"Scene cuts + endpoints. Needs ffmpeg. No model download."},{id:"blind",label:"Blind (even-spaced)",note:"Chromium fallback — works with neither ffmpeg nor Gemma."}];function KW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(!1),[W,G]=k9.useState(null);k9.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>J(H?.keyframeEngine||"auto")).catch(()=>J("auto"))},[]);async function Z(H){if(H===X)return;let q=X;J(H),Y(!0),G(null);try{let K=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({keyframeEngine:H})});if(!K.ok)throw Error(await K.text());G({ok:!0,msg:"Saved."})}catch(K){J(q),G({ok:!1,msg:K&&K.message?K.message:"save failed"})}finally{Y(!1)}}return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Scene-aware keyframes — analysis engine"})}),_("div",{className:"st-provider-notes",children:["How Maude picks frames when it analyzes a video (`/design:video-analyze`, `/design:reel`). Scene-aware beats a blind frame rate. This is an explicit choice — a chosen-but-unavailable engine tells you how to fix it; ",z("strong",{children:"Auto"})," just uses the best you have installed."]}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Keyframe engine",children:zW0.map((H)=>_("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"keyframe-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>Z(H.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:H.label}),z("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function UW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(null),W=k9.useCallback(()=>{fetch("/_api/generate/keyframe-model").then((B)=>B.ok?B.json():Promise.reject(Error(`HTTP ${B.status}`))).then(J).catch((B)=>Y(B&&B.message?B.message:"failed to load models"))},[]);k9.useEffect(()=>{W()},[W]),k9.useEffect(()=>{if(!X?.downloading)return;let B=setInterval(W,1500);return()=>clearInterval(B)},[X?.downloading,W]);async function G(B){Y(null);try{let F=await fetch("/_api/generate/keyframe-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:B})});if(!F.ok)throw Error(await F.text());W()}catch(F){Y(F&&F.message?F.message:"download failed")}}let Z=X?.downloading,H=X?.mlxVlmAvailable,q=X?.ffmpegAvailable,K=(B,F)=>F>0?Math.min(100,Math.round(B/F*100)):0;return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Gemma scout model (optional)"})}),_("div",{className:"st-provider-notes",children:["The ",z("strong",{children:"Gemma"})," tier adds semantic action-beat detection on top of scene cuts. It needs an ",z("strong",{children:"Apple-Silicon Mac"})," and the ",z("code",{children:"mlx-vlm"})," runtime (",z("code",{children:"pip install mlx-vlm"})," — a manual step Maude can’t do for you). Downloading a model below is the one-click half. Models live in your HuggingFace cache, never committed."]}),X&&_("div",{className:"st-provider-notes",children:["On this machine the active tier is ",z("strong",{children:H?"Gemma scout":q?"ffmpeg scene-detect":"blind (even-spaced)"}),!H&&q&&" — install mlx-vlm + download a model to unlock the Gemma scout.",!H&&!q&&" — install ffmpeg for scene-aware frames, or mlx-vlm for the Gemma scout."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),Z?.error&&_("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",Z.id," failed: ",Z.error]}),X===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(X?.models||[]).map((B)=>{let F=Z&&!Z.error&&Z.id===B.id;return _("div",{className:"st-model-row",children:[_("div",{className:"st-model-info",children:[_("span",{className:"st-model-label",children:[B.label,_("span",{className:"st-model-size",children:["~",Math.round(B.sizeMB/100)/10," GB"]})]}),z("span",{className:"st-engine-radio-note",children:B.note}),F&&_("span",{className:"st-model-progress",children:["Downloading… ",K(Z.received,Z.total),"%"]})]}),z("div",{className:"st-model-actions",children:B.downloaded?_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," ready"]}):z("button",{type:"button",className:"st-btn",disabled:!H||!!(Z&&!Z.error),title:H?"":"Install mlx-vlm first (pip install mlx-vlm)",onClick:()=>G(B.id),children:F?"Downloading…":H?"Download":"Needs mlx-vlm"})})]},B.id)})})]})}var kJ=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation"},{id:"subtitles",label:"Subtitles"},{id:"video",label:"Video"}],hf="mdcc-settings-tab",VW0=[{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 BW0({value:X,disabled:J,onChange:Q}){return z("span",{className:"st-sidetoggle",role:"radiogroup","aria-label":"Panel side",children:["left","right"].map((Y)=>z("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 FW0=[{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 NW0({panelSide:X,onSetPanelSide:J,layersMode:Q,onSetLayersMode:Y}){return _(W0,{children:[_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Layers panel"})}),z("div",{className:"st-provider-notes",children:"Show Layers as its own dockable panel, or as a tab inside the Inspector."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Layers mode",children:FW0.map((W)=>_("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"layers-mode",checked:Q===W.id,onChange:()=>Y(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Panel positions"})}),z("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."}),VW0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return _("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[_("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:W.label}),G&&z("span",{className:"st-pref-note",children:"Layers is inside the Inspector — choose “Separate panel” above to dock it."})]}),z(BW0,{value:X?.[W.id]||"left",disabled:G,onChange:(Z)=>J(W.id,Z)})]},W.id)})]})]})}function r2({label:X,note:J,checked:Q,disabled:Y,reason:W,onChange:G}){return _("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[_("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:X}),(W||J)&&z("span",{className:"st-pref-note",children:Y&&W?W:J})]}),z("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(Z)=>G?.(Z.target.checked)})]})}var LW0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],DW0=[{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 MW0({theme:X,onSetTheme:J,cpMode:Q,onSetCpMode:Y}){return _(W0,{children:[_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Theme"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Theme",children:LW0.map((W)=>_("label",{className:"st-engine-radio"+(X===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-theme",value:W.id,checked:X===W.id,onChange:()=>J?.(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Inspector vocabulary"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Inspector vocabulary",children:DW0.map((W)=>_("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-cp-mode",value:W.id,checked:Q===W.id,onChange:()=>Y?.(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]})]})}function Dw({onClose:X,initialTab:J,theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G,minimapVisible:Z,onToggleMinimap:H,zoomCtlVisible:q,onToggleZoomCtl:K,annotationsVisible:V,onToggleAnnotations:B,autoOpenInspector:F,onToggleAutoOpenInspector:L,hasCanvas:M=!1,panelSide:w,onSetPanelSide:R,layersMode:A,onSetLayersMode:D}){let[P,T]=k9.useState(null),[I,S]=k9.useState(null),[C,j]=k9.useState(()=>{if(J&&kJ.some((n)=>n.id===J))return J;try{let n=localStorage.getItem(hf);if(n&&kJ.some((x)=>x.id===n))return n}catch{}return"appearance"});k9.useEffect(()=>{try{localStorage.setItem(hf,C)}catch{}},[C]);let f=k9.useCallback(()=>{fetch("/_api/generate/providers").then((n)=>{if(!n.ok)throw Error(`HTTP ${n.status}`);return n.json()}).then((n)=>T(Array.isArray(n?.providers)?n.providers:[])).catch((n)=>S(n&&n.message?n.message:"failed to load providers"))},[]);k9.useEffect(()=>{f()},[f]),k9.useEffect(()=>{function n(x){if(x.key==="Escape")x.preventDefault(),X()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[X]);function m(n){let x=kJ.findIndex((i)=>i.id===C);if(n.key==="ArrowDown"||n.key==="ArrowRight")n.preventDefault(),j(kJ[(x+1)%kJ.length].id);else if(n.key==="ArrowUp"||n.key==="ArrowLeft")n.preventDefault(),j(kJ[(x-1+kJ.length)%kJ.length].id);else if(n.key==="Home")n.preventDefault(),j(kJ[0].id);else if(n.key==="End")n.preventDefault(),j(kJ[kJ.length-1].id)}let o=!M?"Open a canvas to use this.":void 0;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)X()},children:_("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Settings"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:z(EG,{name:"x",size:15})})]}),_("div",{className:"st-settings-tabs",children:[z("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:m,children:kJ.map((n)=>z("button",{type:"button",role:"tab",id:`st-stab-${n.id}`,"aria-controls":`st-spanel-${n.id}`,"aria-selected":C===n.id,tabIndex:C===n.id?0:-1,className:"st-settings-tab"+(C===n.id?" is-active":""),onClick:()=>j(n.id),children:n.label},n.id))}),_("div",{className:"st-settings-pane",children:[_("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:C!=="appearance",children:[z("div",{className:"st-rp-hd",children:"Appearance"}),z(MW0,{theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G})]}),_("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:C!=="canvas-view",children:[z("div",{className:"st-rp-hd",children:"Canvas & View"}),z(r2,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:Z,disabled:!M,reason:o,onChange:()=>H?.()}),z(r2,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:q,disabled:!M,reason:o,onChange:()=>K?.()}),z(r2,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:V,onChange:()=>B?.()}),z(r2,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>L?.()})]}),_("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:C!=="layout",children:[z("div",{className:"st-rp-hd",children:"Layout"}),z(NW0,{panelSide:w,onSetPanelSide:R,layersMode:A,onSetLayersMode:D})]}),_("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:C!=="ai-generation",children:[z("div",{className:"st-rp-hd",children:"Provider keys"}),_("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"," ",z("code",{children:"~/.config/maude/keys.json"})," (mode 0600) — sent straight to the provider, and never committed, logged, or exposed to a canvas."]}),I&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:I}),P===null&&!I&&z("div",{className:"st-settings-intro",children:"Loading…"}),P?.map((n)=>z(GW0,{provider:n,onChanged:f},n.id)),P?.length===0&&z("div",{className:"st-settings-intro",children:"No providers registered."})]}),_("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:C!=="subtitles",children:[z("div",{className:"st-rp-hd",children:"Subtitles"}),z(HW0,{}),z(qW0,{})]}),_("section",{role:"tabpanel",id:"st-spanel-video","aria-labelledby":"st-stab-video",hidden:C!=="video",children:[z("div",{className:"st-rp-hd",children:"Video"}),z(KW0,{}),z(UW0,{})]})]})]})]})})}var y4=S8(v8(),1);function OW0({name:X,size:J=15}){if(X==="x")return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})});return null}function Mw({onPick:X,onClose:J}){let[Q,Y]=y4.useState(null),[W,G]=y4.useState("");y4.useEffect(()=>{let q=!0;return fetch("/_api/stickers").then((K)=>K.json()).then((K)=>q&&Y(K.ok?K.packs:[])).catch(()=>q&&Y([])),()=>{q=!1}},[]),y4.useEffect(()=>{let q=(K)=>{if(K.key==="Escape")K.stopPropagation(),J()};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[J]);let Z=y4.useMemo(()=>{if(!Q)return[];let q=W.trim().toLowerCase();if(!q)return Q;return Q.map((K)=>({...K,stickers:K.stickers.filter((V)=>V.file.toLowerCase().includes(q)||(V.keywords||[]).some((B)=>B.toLowerCase().includes(q)))})).filter((K)=>K.stickers.length>0)},[Q,W]),H=Z.reduce((q,K)=>q+K.stickers.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:_("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Stickers"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:J,children:z(OW0,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("input",{className:"input",type:"text",value:W,onChange:(q)=>G(q.target.value),placeholder:"Search stickers…","aria-label":"Search stickers",autoFocus:!0}),z("div",{className:"st-sp-body",children:Q==null?z("div",{className:"st-sp-empty",children:"Loading…"}):H===0?z("div",{className:"st-sp-empty",children:W.trim()?`No stickers match "${W.trim()}"`:"No stickers bundled"}):Z.map((q)=>_("div",{children:[_("div",{className:"st-sp-pack-hd",children:[z("span",{className:"st-sp-pack-name",children:q.name}),q.author&&_("span",{className:"st-sp-pack-author",children:["by ",q.author]})]}),z("div",{className:"st-sp-grid",children:q.stickers.map((K)=>z("button",{type:"button",className:"st-sp-cell",title:K.keywords?.[0]||K.file,onClick:()=>X(K),children:z("img",{className:"st-sp-thumb",src:K.url,alt:K.keywords?.[0]||K.file,loading:"lazy"})},K.file))})]},q.slug))})]}),Q&&Q.length>0&&z("div",{className:"st-sp-ft",children:Q.map((q)=>_("span",{children:[q.name,q.author?` — ${q.author}`:"",q.attributionUrl?_(W0,{children:[" ","(",z("a",{href:q.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},q.slug))})]})})}var g6=S8(v8(),1);var t2=S8(v8(),1);var a2=(...X)=>X.filter((J,Q,Y)=>{return Boolean(J)&&J.trim()!==""&&Y.indexOf(J)===Q}).join(" ").trim();var gf=(X)=>X.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var mf=(X)=>X.replace(/^([A-Z])|[\s-_]+(\w)/g,(J,Q,Y)=>Y?Y.toUpperCase():Q.toLowerCase());var Ow=(X)=>{let J=mf(X);return J.charAt(0).toUpperCase()+J.slice(1)};var JU=S8(v8(),1);var s2={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 uf=(X)=>{for(let J in X)if(J.startsWith("aria-")||J==="role"||J==="title")return!0;return!1};var sH=S8(v8(),1),wW0=sH.createContext({});var lf=()=>sH.useContext(wW0);var df=JU.forwardRef(({color:X,size:J,strokeWidth:Q,absoluteStrokeWidth:Y,className:W="",children:G,iconNode:Z,...H},q)=>{let{size:K=24,strokeWidth:V=2,absoluteStrokeWidth:B=!1,color:F="currentColor",className:L=""}=lf()??{},M=Y??B?Number(Q??V)*24/Number(J??K):Q??V;return JU.createElement("svg",{ref:q,...s2,width:J??K??s2.width,height:J??K??s2.height,stroke:X??F,strokeWidth:M,className:a2("lucide",L,W),...!G&&!uf(H)&&{"aria-hidden":"true"},...H},[...Z.map(([w,R])=>JU.createElement(w,R)),...Array.isArray(G)?G:[G]])});var Y8=(X,J)=>{let Q=t2.forwardRef(({className:Y,...W},G)=>t2.createElement(df,{ref:G,iconNode:J,className:a2(`lucide-${gf(Ow(X))}`,`lucide-${X}`,Y),...W}));return Q.displayName=Ow(X),Q};var AW0=[["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"}]],QU=Y8("a-large-small",AW0);var _W0=[["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"}]],YU=Y8("align-horizontal-justify-center",_W0);var EW0=[["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"}]],WU=Y8("align-horizontal-justify-end",EW0);var PW0=[["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"}]],GU=Y8("align-horizontal-justify-start",PW0);var RW0=[["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"}]],tH=Y8("align-horizontal-space-between",RW0);var kW0=[["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"}]],ZU=Y8("align-vertical-justify-center",kW0);var TW0=[["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"}]],HU=Y8("align-vertical-justify-end",TW0);var IW0=[["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"}]],qU=Y8("align-vertical-justify-start",IW0);var CW0=[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]],zU=Y8("baseline",CW0);var SW0=[["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"}]],KU=Y8("bold",SW0);var $W0=[["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"}]],f4=Y8("braces",$W0);var bW0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],UU=Y8("chevron-down",bW0);var jW0=[["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"}]],v4=Y8("columns-3",jW0);var yW0=[["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"}]],VU=Y8("diamond",yW0);var fW0=[["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"}]],BU=Y8("eye-off",fW0);var vW0=[["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"}]],PG=Y8("eye",vW0);var xW0=[["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"}]],FU=Y8("italic",xW0);var hW0=[["path",{d:"M5 12h14",key:"1ays0h"}]],NU=Y8("minus",hW0);var gW0=[["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"}]],LU=Y8("move-horizontal",gW0);var mW0=[["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"}]],DU=Y8("rotate-ccw",mW0);var uW0=[["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"}]],RG=Y8("rotate-cw",uW0);var lW0=[["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"}]],x4=Y8("rows-3",lW0);var dW0=[["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"}]],MU=Y8("scissors",dW0);var pW0=[["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"}]],OU=Y8("scroll-text",pW0);var cW0=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],wU=Y8("search",cW0);var iW0=[["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"}]],AU=Y8("spline",iW0);var oW0=[["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"}]],h4=Y8("square-dashed",oW0);var nW0=[["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"}]],_U=Y8("stretch-horizontal",nW0);var rW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],g4=Y8("text-align-center",rW0);var aW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],m4=Y8("text-align-end",aW0);var sW0=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],u4=Y8("text-align-justify",sW0);var tW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],J5=Y8("text-align-start",tW0);var eW0=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],EU=Y8("underline",eW0);var XG0=[["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"}]],l4=Y8("wand-sparkles",XG0);var JG0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],PU=Y8("x",JG0);var d4=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block",flex:"none"}}),ww=(X)=>X.replace(/^--/,"").replace(/-/g," "),p4=(X,J,Q)=>{let Y=X;if(J!=null&&Y<J)Y=J;if(Q!=null&&Y>Q)Y=Q;return Y},QG0=(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},eH=(X,J)=>{let Q=QG0(J);return Number(X.toFixed(Q))};function Aw({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return(q)=>{if(q.button!==0)return;let K=q.clientX,V=Number.parseFloat(X())||0,B=!1,F=V,L=(R)=>{if(!H)return;if(R.altKey&&R.shiftKey)return H.all;if(R.altKey)return H.pair;return},M=(R)=>{let A=R.clientX-K;if(!B&&Math.abs(A)<3)return;if(!B)B=!0,document.body.classList.add("st-scrubbing");R.preventDefault();let D=H?1:R.shiftKey?10:R.altKey?0.1:1;F=eH(p4(V+A*Y*Z*D,J,Q),Y),W?.(F,L(R))},w=(R)=>{if(document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",w),!B)return;document.body.classList.remove("st-scrubbing"),G?.(F,L(R))};document.addEventListener("pointermove",M),document.addEventListener("pointerup",w)}}function YG0({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return g6.useCallback(Aw({getBase:X,min:J,max:Q,step:Y,onInput:W,onCommit:G,sensitivity:Z,sides:H}),[X,J,Q,Y,W,G,Z,H])}function Q5({value:X,min:J,max:Q,step:Y=1,lead:W,scrub:G=!0,steppers:Z=!0,unitSlot:H,sensitivity:q=1,sides:K,format:V,parse:B,onInput:F,onCommit:L,ariaLabel:M,className:w=""}){let R=g6.useRef(null),A=g6.useCallback((m)=>V?V(m):String(eH(Number(m)||0,Y)),[V,Y]),D=(m)=>(typeof m==="number"?m:Number.parseFloat(m))||0;g6.useEffect(()=>{if(R.current&&document.activeElement!==R.current)R.current.value=A(X)},[X,A]);let P=(m,o)=>{let n=eH(p4(m,J,Q),Y);if(R.current)R.current.value=A(n);L?.(n,o)},I=YG0({getBase:()=>R.current?R.current.value:D(X),min:J,max:Q,step:Y,sensitivity:q,sides:K,onInput:(m,o)=>{let n=eH(p4(m,J,Q),Y);if(R.current)R.current.value=A(n);F?.(n,o)},onCommit:P}),S=(m,o)=>P(D(R.current?.value??X)+m*Y*o),C=(m)=>{let o=m.shiftKey?10:1;if(m.key==="ArrowUp")m.preventDefault(),S(1,o);else if(m.key==="ArrowDown")m.preventDefault(),S(-1,o);else if(m.key==="PageUp")m.preventDefault(),S(1,10);else if(m.key==="PageDown")m.preventDefault(),S(-1,10);else if(m.key==="Home"&&J!=null)m.preventDefault(),P(J);else if(m.key==="End"&&Q!=null)m.preventDefault(),P(Q);else if(m.key==="Enter")m.currentTarget.blur()},j=(m)=>{let o=m.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===o)o.select()})},f=(m)=>{let o=String(m.currentTarget.value).trim();if(o==="")return;let n=B?B(o):Number.parseFloat(o);if(n==null||Number.isNaN(n)){m.currentTarget.value=A(X);return}P(n)};return _("div",{className:`st-cp-num ${w}`.trim(),children:[G?z("span",{className:"st-cp-numlead st-cp-handle",role:"presentation","aria-hidden":"true",title:"Drag to change · Shift ×10 · Alt fine",onPointerDown:I,children:W??z("span",{className:"st-cp-grip"})}):W?z("span",{className:"st-cp-numlead","aria-hidden":"true",children:W}):null,z("input",{ref:R,className:"st-cp-numin",role:"spinbutton","aria-label":M,"aria-valuenow":D(X),"aria-valuemin":J,"aria-valuemax":Q,defaultValue:A(X),inputMode:"decimal",onFocus:j,onKeyDown:C,onBlur:f}),Z?_("span",{className:"st-cp-step",children:[z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`increase ${M||"value"}`,onClick:()=>S(1,1),children:"▲"}),z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`decrease ${M||"value"}`,onClick:()=>S(-1,1),children:"▼"})]}):null,H??null]})}function WG0({value:X,min:J=0,max:Q=1,step:Y=0.01,onInput:W,onCommit:G,ariaLabel:Z}){let H=g6.useRef(null),q=p4(X??(J<0?0:J),J,Q),K=Q-J||1,V=(q-J)/K,B=J<0&&Q>0?(0-J)/K:0,F=Math.min(V,B),L=Math.abs(V-B),M=(A)=>{let D=H.current?.getBoundingClientRect();if(!D||D.width===0)return q;let P=p4((A-D.left)/D.width,0,1);return eH(J+P*K,Y)};return z("div",{className:"st-cp-slider",children:_("div",{ref:H,className:"st-cp-track",role:"slider",tabIndex:0,"aria-label":Z,"aria-valuemin":J,"aria-valuemax":Q,"aria-valuenow":q,onPointerDown:(A)=>{if(A.button!==0)return;A.preventDefault(),H.current?.focus();let D=M(A.clientX);W?.(D);let P=(I)=>{D=M(I.clientX),W?.(D)},T=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",T),G?.(D)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",T)},onKeyDown:(A)=>{let D=A.shiftKey?10:1,P=null;if(A.key==="ArrowRight"||A.key==="ArrowUp")P=q+Y*D;else if(A.key==="ArrowLeft"||A.key==="ArrowDown")P=q-Y*D;else if(A.key==="PageUp")P=q+Y*10;else if(A.key==="PageDown")P=q-Y*10;else if(A.key==="Home")P=J;else if(A.key==="End")P=Q;if(P!=null)A.preventDefault(),G?.(eH(p4(P,J,Q),Y))},children:[J<0&&Q>0?z("span",{className:"st-cp-zero",style:{left:`${B*100}%`}}):null,z("span",{className:"st-cp-fill",style:{left:`${F*100}%`,width:`${L*100}%`}}),z("span",{className:"st-cp-thumb",style:{left:`${V*100}%`}})]})})}function a5({value:X,min:J=0,max:Q=1,step:Y=0.01,unit:W="",onInput:G,onCommit:Z,ariaLabel:H}){let q=X??(J<0?0:J);return _("div",{className:"st-cp-sfield",children:[z(WG0,{value:q,min:J,max:Q,step:Y,onInput:G,onCommit:Z,ariaLabel:H}),z(Q5,{className:"st-cp-num--compact",value:q,min:J,max:Q,step:Y,scrub:!1,steppers:!1,unitSlot:W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null,onInput:G,onCommit:Z,ariaLabel:H})]})}function e2({value:X,units:J,onChange:Q,ariaLabel:Y}){return z("select",{className:"st-cp-unitsel","aria-label":Y,value:X,onChange:(W)=>Q(W.target.value),children:J.map((W)=>z("option",{value:W,children:W},W))})}function XB({value:X,options:J,onChange:Q,ariaLabel:Y}){return z("div",{className:"st-cp-seg",role:"radiogroup","aria-label":Y,children:J.map((W)=>{let G=typeof W==="string"?W:W.value,Z=typeof W==="string"?W:W.label??W.value;return z("button",{type:"button",role:"radio","aria-checked":X===G,className:`st-cp-segbtn${X===G?" is-active":""}`,onClick:()=>Q(G),children:Z},G)})})}function c4({value:X,options:J,onChange:Q,ariaLabel:Y,mini:W=!1}){return z("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 Z=typeof G==="string"?G:G.value,H=typeof G==="string"?G:G.label??G.value;return z("option",{value:Z,children:H},Z)})})}function i4({checked:X,onChange:J,label:Q,ariaLabel:Y}){return _("label",{className:"st-cp-toggle",children:[z("input",{type:"checkbox",className:"st-cp-switch",checked:!!X,"aria-label":Y||Q,onChange:(W)=>J(W.target.checked)}),Q?z("span",{className:"st-cp-toggle-lbl",children:Q}):null]})}function _w({value:X,options:J,ariaLabel:Q,onChange:Y}){return z("div",{className:"st-cp-iconseg",role:"radiogroup","aria-label":Q,children:J.map((W)=>z("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 pf({value:X,options:J,ariaLabel:Q,onToggle:Y}){return z("div",{className:"st-cp-iconseg",role:"group","aria-label":Q,children:J.map((W)=>z("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 GG0=["tl","tc","tr","cl","cc","cr","bl","bc","br"];function cf({value:X,onChange:J,ariaLabel:Q="alignment"}){return z("div",{className:"st-cp-alignpad",role:"radiogroup","aria-label":Q,children:GG0.map((Y)=>z("button",{type:"button",role:"radio","aria-checked":X===Y,"aria-label":`align ${Y}`,className:X===Y?"is-active":"",onClick:()=>J(Y)},Y))})}function of({value:X,onChange:J,ariaLabel:Q="rotation"}){let Y=g6.useRef(null),W=(q,K)=>{let V=Y.current?.getBoundingClientRect();if(!V)return X;let B=Math.round(Math.atan2(K-(V.top+V.height/2),q-(V.left+V.width/2))*180/Math.PI);if(B<0)B+=360;return B},G=(q)=>{if(q.button!==0)return;q.preventDefault(),document.body.classList.add("st-scrubbing","st-scrubbing--dial"),J(W(q.clientX,q.clientY));let K=(B)=>J(W(B.clientX,B.clientY)),V=()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",V),document.body.classList.remove("st-scrubbing","st-scrubbing--dial")};document.addEventListener("pointermove",K),document.addEventListener("pointerup",V)},Z=X??0,H=(q)=>{let K=q.shiftKey?10:1,V=null;if(q.key==="ArrowRight"||q.key==="ArrowUp")V=Z+K;else if(q.key==="ArrowLeft"||q.key==="ArrowDown")V=Z-K;else if(q.key==="PageUp")V=Z+15;else if(q.key==="PageDown")V=Z-15;else if(q.key==="Home")V=0;else if(q.key==="End")V=360;if(V!=null)q.preventDefault(),J(p4(V,0,360))};return z("button",{ref:Y,type:"button",className:"st-cp-dial",role:"slider","aria-label":Q,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Z,"aria-valuetext":`${Z}°`,title:"drag to rotate · arrows to nudge",onPointerDown:G,onKeyDown:H,children:z("span",{className:"st-cp-dial-needle",style:{"--angle":`${X}deg`}})})}function nf({title:X,defaultOpen:J=!0,onReset:Q,right:Y,children:W}){let[G,Z]=g6.useState(J);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":G,onClick:()=>Z((H)=>!H),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:z(d4,{as:UU,size:12})}),X]}),Y??null,Q?z("button",{type:"button",className:"st-cp-secreset","aria-label":`reset ${X} section`,title:`reset ${X}`,onClick:Q,children:z(d4,{as:DU,size:12})}):null]}),z("div",{className:`st-cp-sec-anim${G?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:W})})]})}function RU({swatch:X,displayValue:J,bound:Q,alpha:Y,visible:W,ariaLabel:G,onValue:Z,onAlpha:H,onVisible:q}){return _("span",{className:"st-cp-cf",children:[X,z("input",{className:`st-cp-cf-in${Q?" is-bound":""}`,"aria-label":G,value:J,onChange:(K)=>Z?.(K.target.value),onFocus:(K)=>K.currentTarget.select(),readOnly:!Z}),H?z("input",{className:"st-cp-cf-alpha","aria-label":`${G||"colour"} alpha`,value:`${Y}`,onChange:(K)=>H(p4(Number.parseFloat(K.target.value)||0,0,100)),onFocus:(K)=>K.currentTarget.select()}):null,q?z("button",{type:"button",className:`st-cp-cf-eye${W?"":" is-off"}`,"aria-pressed":W,"aria-label":`${G||"colour"} visibility`,onClick:()=>q(!W),children:W?z(d4,{as:PG}):z(d4,{as:BU})}):null]})}function JB({value:X,tokens:J,ariaLabel:Q,lead:Y,unit:W,unitSlot:G,min:Z=0,max:H,step:q=1,onChange:K}){let[V,B]=g6.useState(!1),[F,L]=g6.useState(""),M=g6.useRef(null),w=typeof X==="string"&&X.startsWith("var("),R=w?X.replace(/^var\(\s*|\s*\)$/g,""):"",A=w?J.find((P)=>P.name===R)?.value??"":"";g6.useEffect(()=>{if(!V){L("");return}let P=(T)=>{if(!M.current?.contains(T.target))B(!1)};return document.addEventListener("pointerdown",P,!0),()=>document.removeEventListener("pointerdown",P,!0)},[V]);let D=F?J.filter((P)=>ww(P.name).includes(F)||(P.value||"").toLowerCase().includes(F)):J;return _("div",{className:"st-cp-tokfield",children:[w?_("div",{className:"st-cp-boundchip",title:`${R} = ${A}`,children:[Y?z("span",{className:"st-cp-boundchip-lead","aria-hidden":"true",children:Y}):null,z("span",{className:"st-cp-boundchip-name",children:ww(R)}),z("button",{type:"button",className:"st-cp-boundchip-x","aria-label":"detach token",title:"detach — back to a raw value",onClick:()=>K(Number.parseFloat(A)||0),children:z(d4,{as:PU,size:12})})]}):z(Q5,{value:typeof X==="number"?X:0,min:Z,max:H,step:q,ariaLabel:Q,lead:Y,steppers:!1,unitSlot:G??(W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null),onCommit:(P)=>K(P)}),_("span",{ref:M,style:{position:"relative",display:"inline-flex"},children:[z("button",{type:"button",className:`st-cp-tokbtn${w?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":V,"aria-label":`${Q} — bind a design token`,title:"bind a design token",onClick:()=>B((P)=>!P),children:z(d4,{as:VU,size:13})}),V?_("div",{className:"st-cp-pop",role:"dialog","aria-label":"design tokens",style:{left:"auto",right:0},children:[_("div",{className:"st-cp-pop-search",children:[z(d4,{as:wU,size:12}),z("input",{value:F,onChange:(P)=>L(P.target.value.toLowerCase()),placeholder:"Search variables","aria-label":"search variables"})]}),D.length?D.map((P)=>_("button",{type:"button",className:`st-cp-pop-row${R===P.name?" is-on":""}`,onClick:()=>{K(`var(${P.name})`),B(!1)},children:[z("span",{className:"st-cp-pop-name",children:ww(P.name)}),z("span",{className:"st-cp-pop-val",children:P.value})]},P.name)):z("div",{className:"st-cp-pop-empty",children:"No match"})]}):null]})]})}function rf({corners:X,lead:J,onCorners:Q}){let[Y,W]=g6.useState(!1),G=(H)=>Q({tl:H,tr:H,bl:H,br:H}),Z=(H)=>_("label",{className:"st-cp-corner",children:[z("span",{className:`st-cp-cnr st-cp-cnr--${H}`,"aria-hidden":"true"}),z("input",{"aria-label":`${H} radius`,value:X[H],onChange:(q)=>Q({...X,[H]:Number.parseFloat(q.target.value)||0}),onFocus:(q)=>q.currentTarget.select()})]});return _("div",{className:"st-cp-radius",children:[_("div",{className:"st-cp-radius-main",children:[z(Q5,{value:X.tl,min:0,max:200,ariaLabel:"border-radius",lead:J,steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(H)=>Y?Q({...X,tl:H}):G(H)}),z("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:z(d4,{as:h4,size:14})})]}),Y?_("div",{className:"st-cp-corners",children:[Z("tl"),Z("tr"),Z("bl"),Z("br")]}):null]})}var A6=S8(v8(),1);var ZG0=["dots","grid","lines","diagonal","crosshatch"],HG0=["normal","multiply","screen","overlay","soft-light"],qG0=["none","vignette","radial-reveal","edge-fade"],zG0=[{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}],af=(X)=>X?JSON.parse(JSON.stringify(X)):{};function KG0(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,Z]of Object.entries(Y))if(Z!=null&&Z!=="")W[G]=Z;if(Object.keys(W).length)J[Q]=W}else J[Q]=Y}return J}var o4={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 Xq({title:X,right:J,onReset:Q,children:Y}){return z(nf,{title:X,right:J,onReset:Q,children:Y})}function lX({label:X,tip:J,children:Q}){return _(W0,{children:[_("div",{style:o4.row,children:[z("span",{style:o4.label,children:X}),Q]}),J?z("div",{style:o4.tipBelow,children:J}):null]})}function Ew({value:X,fallback:J,label:Q,ColorPicker:Y,onApply:W}){let[G,Z]=A6.useState(!1),H=A6.useRef(null),q=X||J;return A6.useEffect(()=>{if(!G)return;let K=(V)=>{if(!H.current?.contains(V.target))Z(!1)};return document.addEventListener("pointerdown",K,!0),()=>document.removeEventListener("pointerdown",K,!0)},[G]),z(RU,{swatch:_("span",{className:"st-cp-tokwrap",ref:H,children:[z("button",{type:"button",className:"st-cp-cf-sw",style:{background:q},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:q,onClick:()=>Z((K)=>!K)}),G?z("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?z(Y,{seed:q,label:Q,onApply:W}):z("input",{type:"color",value:q,"aria-label":Q,onChange:(K)=>W(K.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(q||"").replace("#",""),ariaLabel:Q,onValue:(K)=>W(K.startsWith("#")?K:`#${K.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function sf({asset:X,initialEdit:J,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:Z}){let[H,q]=A6.useState(()=>af(J)),[K,V]=A6.useState(!J),[B,F]=A6.useState("idle"),[L,M]=A6.useState(!1),[w,R]=A6.useState(""),A=A6.useRef(null),D=A6.useRef(H);D.current=H,A6.useEffect(()=>{if(J||!X)return;let h=!1;return V(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`).then((s)=>s.ok?s.json():{}).then((s)=>{if(h)return;q(s&&typeof s==="object"?s:{}),V(!1)}).catch(()=>!h&&V(!1)),()=>{h=!0}},[X,J]);let P=A6.useCallback((h)=>{clearTimeout(A.current),A.current=setTimeout(async()=>{F("saving");try{let s=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(KG0(h))});F(s.ok?"saved":"error")}catch{F("error")}},160)},[X]),T=A6.useCallback((h,{commit:s=!1}={})=>{let X0=D.current,c=af(X0);if(h(c),q(c),Y?.(c),P(c),s)G?.(X0,c)},[Y,P,G]),I=(h,s,X0)=>T((c)=>{if(c.adjustments=c.adjustments||{},s===0||s==null)delete c.adjustments[h];else c.adjustments[h]=s;if(Object.keys(c.adjustments).length===0)delete c.adjustments},{commit:X0}),S=(h,s,X0)=>T((c)=>{c[h]={...c[h]||{},...s}},{commit:X0}),C=()=>T((h)=>delete h.adjustments,{commit:!0}),j=(h)=>T((s)=>{delete s[h]},{commit:!0}),f=async()=>{if(!W)return;M(!0),R("Removing background…");try{let h=await W(X);if(h?.maskAsset)S("backgroundRemoved",{enabled:!0,maskAsset:h.maskAsset},!0),R("Background removed");else R("Background removal failed")}catch{R("Background removal failed")}finally{M(!1)}};if(K)return z("div",{style:{...o4.body,opacity:0.6},children:"Loading photo edit…"});let m=H.adjustments||{},o=H.duotone||{},n=H.grain||{},x=H.pattern||{},i=H.mask||{},a=H.backgroundRemoved||{};return _("div",{style:o4.body,"data-testid":"photo-knobs",children:[_("div",{style:{...o4.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[z("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:X}),z("span",{style:{fontSize:10,color:B==="error"?"var(--status-error)":void 0},children:B==="saving"?"saving…":B==="error"?"⚠ save failed":B==="saved"?"saved":""})]}),z(Xq,{title:"Adjustments",onReset:C,children:zG0.map((h)=>z(lX,{label:h.label,children:z(a5,{value:m[h.key],min:h.min,max:h.max,step:h.step??0.01,unit:h.unit??"",ariaLabel:h.label,onInput:(s)=>I(h.key,s),onCommit:(s)=>I(h.key,s,!0)})},h.key))}),z(Xq,{title:"Duotone",right:z(i4,{checked:o.enabled,onChange:(h)=>S("duotone",{enabled:h},!0),label:"on"}),onReset:()=>j("duotone"),children:o.enabled&&_(W0,{children:[z(lX,{label:"Shadow",children:z(Ew,{value:o.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(h)=>S("duotone",{colorA:h},!0)})}),z(lX,{label:"Highlight",children:z(Ew,{value:o.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(h)=>S("duotone",{colorB:h},!0)})}),z(lX,{label:"Intensity",children:z(a5,{value:o.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(h)=>S("duotone",{intensity:h}),onCommit:(h)=>S("duotone",{intensity:h},!0)})})]})}),z(Xq,{title:"Grain",right:z(i4,{checked:n.enabled,onChange:(h)=>S("grain",{enabled:h},!0),label:"on"}),onReset:()=>j("grain"),children:n.enabled&&_(W0,{children:[z(lX,{label:"Amount",children:z(a5,{value:n.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(h)=>S("grain",{amount:h}),onCommit:(h)=>S("grain",{amount:h},!0)})}),z(lX,{label:"Size",children:z(a5,{value:n.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(h)=>S("grain",{size:h}),onCommit:(h)=>S("grain",{size:h},!0)})})]})}),z(Xq,{title:"Pattern",right:z(i4,{checked:x.enabled,onChange:(h)=>S("pattern",{enabled:h},!0),label:"on"}),onReset:()=>j("pattern"),children:x.enabled&&_(W0,{children:[z(lX,{label:"Type",children:z(c4,{value:x.type||"dots",options:ZG0,ariaLabel:"Pattern type",onChange:(h)=>S("pattern",{type:h},!0)})}),z(lX,{label:"Blend",children:z(c4,{value:x.blend||"normal",options:HG0,ariaLabel:"Pattern blend",onChange:(h)=>S("pattern",{blend:h},!0)})}),z(lX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:z(Ew,{value:x.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(h)=>S("pattern",{color:h},!0)})}),z(lX,{label:"Scale",children:z(a5,{value:x.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(h)=>S("pattern",{scale:h}),onCommit:(h)=>S("pattern",{scale:h},!0)})}),z(lX,{label:"Opacity",children:z(a5,{value:x.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(h)=>S("pattern",{opacity:h}),onCommit:(h)=>S("pattern",{opacity:h},!0)})})]})}),_(Xq,{title:"Mask",onReset:()=>j("mask"),children:[z(lX,{label:"Preset",children:z(c4,{value:i.preset||"none",options:qG0,ariaLabel:"Mask preset",onChange:(h)=>S("mask",{preset:h},!0)})}),i.preset&&i.preset!=="none"&&z(lX,{label:"Strength",children:z(a5,{value:i.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(h)=>S("mask",{strength:h}),onCommit:(h)=>S("mask",{strength:h},!0)})})]}),_(Xq,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[z("div",{style:{...o4.row,gap:10},"aria-busy":L||void 0,children:a.maskAsset?_(W0,{children:[z(i4,{checked:a.enabled,onChange:(h)=>S("backgroundRemoved",{enabled:h},!0),label:"applied"}),z("button",{type:"button",style:{...o4.reset,opacity:L?0.6:1},disabled:L||!W,title:"Run background removal again",onClick:()=>f(),children:L?"removing…":"redo"})]}):_("button",{type:"button",className:"st-btn",style:{opacity:L?0.6:1},disabled:L||!W,"data-testid":"photo-remove-bg",onClick:()=>f(),children:[Z?z(Z,{name:"sparkle",size:14}):null,L?"Removing…":"Remove Background"]})}),z("span",{"aria-live":"polite",className:"sr-only",children:w})]})]})}function Jq({name:X,size:J=16}){let Q={cursor:z("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:_(W0,{children:[z("circle",{cx:"6",cy:"6",r:"2.2"}),z("path",{d:"M2.4 13a3.6 3.6 0 0 1 7.2 0"}),z("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:z(W0,{children:z("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:_(W0,{children:[z("path",{d:"M3 2.5h7.5L13.5 5.5V13.5H3z"}),z("path",{d:"M5 2.5V6h5V2.5"}),z("rect",{x:"5.5",y:"9",width:"5",height:"3"})]}),publish:_(W0,{children:[z("line",{x1:"8",y1:"13.4",x2:"8",y2:"6"}),z("polyline",{points:"5 9 8 6 11 9"}),z("polyline",{points:"3 4 3 2.6 13 2.6 13 4"})]}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),"arrow-right":_(W0,{children:[z("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),z("polyline",{points:"9 4 13 8 9 12"})]})}[X];return z("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 Pw({icon:X,label:J,sub:Q}){return _("span",{className:"cm-step",children:[z("span",{className:"cm-step-icon",children:z(Jq,{name:X,size:16})}),z("span",{className:"cm-step-label",children:J}),z("span",{className:"cm-step-sub",children:Q})]})}function Rw(){return _("div",{className:"cm-info",children:[_("div",{className:"cm-live",children:[_("div",{className:"cm-live-hd",children:[z("span",{className:"cm-live-dot","aria-hidden":"true"}),_("span",{children:[z("b",{children:"Together"})," · automatic — no buttons"]})]}),_("div",{className:"cm-live-items",children:[_("span",{className:"cm-live-item",children:[z(Jq,{name:"cursor",size:13})," cursors"]}),_("span",{className:"cm-live-item",children:[z(Jq,{name:"people",size:13})," who's here"]}),_("span",{className:"cm-live-item",children:[z(Jq,{name:"comment",size:13})," comments"]})]}),z("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),_("div",{className:"cm-bridge","aria-hidden":"true",children:[z("span",{className:"cm-bridge-line"}),z("span",{className:"cm-bridge-label",children:"the work itself"}),z("span",{className:"cm-bridge-line"})]}),_("div",{className:"cm-cycle",children:[z(Pw,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(Jq,{name:"arrow-right",size:15})}),z(Pw,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(Jq,{name:"arrow-right",size:15})}),z(Pw,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var kw=[{render:Rw,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 i7=S8(v8(),1);function UG0(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 kG=320,Tw=184;function VG0(X){if(typeof window>"u"||!X)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:kG};let{innerWidth:J,innerHeight:Q}=window;if(X.left>kG+36&&J-X.right<kG+36)return{top:Math.min(Math.max(12,X.top),Q-Tw-12),left:Math.max(12,X.left-kG-16),width:kG};let G=Q-X.bottom>Tw+24?X.bottom+12:Math.max(12,X.top-Tw-12),Z=Math.min(Math.max(12,X.left),J-kG-12);return{top:G,left:Z,width:kG}}function tf({steps:X,open:J,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:Z}){let[H,q]=i7.useState(0),[K,V]=i7.useState(null),B=i7.useRef(null),F=i7.useRef(null),L=i7.useRef(null),M=i7.useRef(W);M.current=W;let w=X[H]||null,R=i7.useCallback(()=>{if(!w)return V(null),null;let f=UG0(w.target);return V(f),f},[w]);i7.useEffect(()=>{if(J)q(0)},[J]),i7.useLayoutEffect(()=>{if(!J||!w)return;let f=!1;V(null);try{M.current?.setup?.(w)}catch{}let m=0,o=24,n=()=>{if(f)return;let x=R();if(x||m>=o){if(x){try{document.querySelector(w.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!f)R()})}return}m+=1,L.current=setTimeout(n,130)};return n(),()=>{if(f=!0,L.current)clearTimeout(L.current)}},[J,H,G]),i7.useEffect(()=>{if(!J)return;F.current=document.activeElement;let f=()=>R();return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0);try{F.current?.focus?.()}catch{}}},[J,R]);let A=H>=X.length-1,D=i7.useCallback(()=>{if(A)Y?.(),Q?.();else q((f)=>Math.min(f+1,X.length-1))},[A,Y,Q,X.length]),P=i7.useCallback(()=>q((f)=>Math.max(0,f-1)),[]);if(i7.useEffect(()=>{if(!J)return;function f(m){if(m.key==="Escape")m.preventDefault(),Q?.();else if(m.key==="ArrowRight")m.preventDefault(),D();else if(m.key==="ArrowLeft")m.preventDefault(),P();else if(m.key==="Tab"){let o=B.current;if(!o)return;let n=o.querySelectorAll("button");if(!n.length)return;let x=n[0],i=n[n.length-1];if(m.shiftKey&&document.activeElement===x)m.preventDefault(),i.focus();else if(!m.shiftKey&&document.activeElement===i)m.preventDefault(),x.focus()}}return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[J,D,P,Q]),i7.useEffect(()=>{if(!J)return;let f=setTimeout(()=>{let m=B.current?.querySelector("[data-tour-primary]");try{m?.focus()}catch{}},0);return()=>clearTimeout(f)},[J,H]),!J||!X.length||!w)return null;let T=6,I=K?{top:K.top-T,left:K.left-T,width:K.width+T*2,height:K.height+T*2}:null,S=!!w.requireSelection&&!G,C=(!!w.canvas||!!w.requireSelection)&&Z===!1,j=w.render||null;return _("div",{className:"mdcc-tour",role:"presentation",children:[I?z("div",{className:"mdcc-tour__spot",style:I,"aria-hidden":"true"}):z("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),_("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:VG0(K),children:[_("div",{className:"mdcc-tour__step",children:[H+1," / ",X.length]}),j&&z("div",{className:"mdcc-tour__graphic",children:z(j,{})}),z("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:w.title}),z("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:w.body}),(C||S)&&_("div",{className:"mdcc-tour__hint",role:"status","aria-live":"polite",children:[z("span",{className:"mdcc-tour__hint-dot","aria-hidden":"true"}),C?"Open any canvas from the sidebar to follow along.":"Hold ⌘ and click an element in the canvas — the panel fills in live."]}),_("div",{className:"mdcc-tour__actions",children:[z("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),_("div",{className:"mdcc-tour__nav",children:[H>0&&z("button",{type:"button",className:"mdcc-tour__back",onClick:P,children:"Back"}),z("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:D,children:A?"Done":"Next"})]})]})]})]})}var ef=[{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 QB=[{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 U7=S8(v8(),1);var BG0={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},FG0={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function NG0(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 Xv(X,J){let Q=await NG0(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 LG0(X,J){return iy(J||"export",X)}function Jv(){let[X,J]=U7.useState(()=>new Map),[Q,Y]=U7.useState(!1),[W,G]=U7.useState([]),[Z,H]=U7.useState(()=>new Set),q=U7.useRef(new Map),K=U7.useRef(new Set),V=U7.useRef(new Set);U7.useEffect(()=>{let S=!0;return fetch("/_api/export-jobs").then((C)=>C.json()).then((C)=>{if(!S)return;let j=new Map;for(let f of Array.isArray(C?.jobs)?C.jobs:[])j.set(f.id,f),q.current.set(f.id,f.status),V.current.add(f.id);J(j)}).catch(()=>{}),()=>{S=!1}},[]);let B=U7.useCallback((S)=>{if(!S||typeof S.id!=="string")return;J((C)=>{let j=new Map(C);return j.set(S.id,S),j})},[]);U7.useEffect(()=>{let S=q.current,C=[],j=[];for(let f of X.values()){let m=S.get(f.id),o=f.status==="queued"||f.status==="running",n=f.status==="done"||f.status==="failed";if(m===void 0&&o&&!V.current.has(f.id))V.current.add(f.id),C.push(f.id);else if(m!==f.status&&n)C.push(f.id),j.push(f)}for(let f of X.values())S.set(f.id,f.status);if(C.length)G((f)=>{let m=f.filter((o)=>!C.includes(o));return[...C,...m].slice(0,8)});if(K9()||!j.length)return;for(let f of j){if(f.status!=="done")continue;if(K.current.has(f.id))continue;if(!document.hasFocus())continue;K.current.add(f.id),Xv(f.id,f.filename)}},[X]);let F=U7.useMemo(()=>Array.from(X.values()).sort((S,C)=>(C.createdAt||"").localeCompare(S.createdAt||"")),[X]),L=F.filter((S)=>S.status==="running").length,M=F.filter((S)=>S.status==="queued").length,w=U7.useCallback(()=>G((S)=>S.slice(1)),[]),R=U7.useCallback(()=>Y(!0),[]),A=U7.useCallback(()=>Y(!1),[]),D=U7.useCallback(async(S,C)=>{H((j)=>new Set(j).add(S.id));try{await C()}finally{H((j)=>{let f=new Set(j);return f.delete(S.id),f})}},[]),P=U7.useCallback(async(S)=>{K.current.add(S.id),await D(S,()=>Xv(S.id,S.filename))},[D]),T=U7.useCallback(async(S)=>{K.current.add(S.id),await D(S,()=>LG0(S.id,S.filename))},[D]),I=Q?null:W[0]??null;return{jobs:F,upsert:B,runningCount:L,queuedCount:M,busyCount:L+M,panelOpen:Q,openPanel:R,closePanel:A,showToast:!!I,toastJob:I?X.get(I)??null:null,dismissToast:w,download:P,save:T,savingIds:Z}}function Qv(X){let J=BG0[X.format]||String(X.format||"").toUpperCase(),Q=FG0[X.scope]||X.scope;return`${J} · ${Q}`}function Yv(X){if(K9())return X?"Saving…":"Save…";return X?"Downloading…":"Download"}function Wv({progress:X}){if(!X||!X.total)return z("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 z("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":J,"aria-valuemin":0,"aria-valuemax":100,children:z("div",{className:"st-export-progress-bar",style:{width:`${J}%`}})})}var Iw=new Map;function DG0(X){let J=X.progress?.current,Q=X.progress?.total;if(!J||!Q||J>=Q)return Iw.delete(X.id),null;let Y=Iw.get(X.id);if(!Y||J<Y.c)Y={t:Date.now(),c:J},Iw.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 MG0({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"?DG0(X):null;return _("span",{className:`st-export-pill st-export-pill--${X.status}`,children:[J,Q?` · ${Q}`:""]})}function Gv({center:X}){let J=X.busyCount>0;return _("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:[z("span",{"aria-hidden":"true",children:"⬇"}),J&&z("span",{className:"st-exports__count","aria-hidden":"true",children:X.busyCount})]})}function Zv({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(K9())X.save(J);else X.download(J)};return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:Q?"⋯":Y?"⬇":"⚠"}),Q?"Exporting…":Y?"Export ready":"Export failed"]}),z("div",{className:"st-toast-title",children:Qv(J)}),Q?_(W0,{children:[z("div",{className:"st-toast-txt",children:"Running in the background — you can keep working."}),z(Wv,{progress:J.progress})]}):z("div",{className:"st-toast-txt",children:Y?J.filename??"Ready to download.":J.error??"Something went wrong."}),Y&&_("div",{className:"st-toast-actions",children:[_("button",{type:"button",className:"btn btn--primary btn--sm",onClick:G,disabled:W,children:[W&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),Yv(W)]}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Hv({center:X}){let{panelOpen:J,closePanel:Q}=X;if(U7.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 z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)Q()},children:_("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"st-export-panel-title",children:"Exports"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Q,children:"×"})]}),z("div",{className:"st-export-panel__body",children:X.jobs.length===0?z("p",{className:"mdcc-wn-empty",children:"No exports yet."}):z("ul",{className:"st-export-list",children:X.jobs.map((Y)=>_("li",{className:"st-export-item",children:[_("div",{className:"st-export-item__hd",children:[z("span",{className:"st-export-item__label",children:Qv(Y)}),z(MG0,{job:Y})]}),(Y.status==="queued"||Y.status==="running")&&z(Wv,{progress:Y.progress}),Y.status==="done"&&_("div",{className:"st-export-item__ft",children:[z("span",{className:"st-export-item__filename",children:Y.filename}),_("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:X.savingIds.has(Y.id),onClick:()=>K9()?X.save(Y):X.download(Y),children:[X.savingIds.has(Y.id)&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),Yv(X.savingIds.has(Y.id))]})]}),Y.status==="failed"&&z("div",{className:"st-export-item__ft",children:z("span",{className:"st-export-item__error",children:Y.error??"Export failed."})})]},Y.id))})})]})})}var MX=S8(v8(),1);function qv(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 zv(X,J){let Q=qv(X),Y=qv(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 Kv(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||zv(Q.version,J)))}function Uv(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&zv(Y.version,Q))Q=Y.version}return Q}var Cw="mdcc-whatsnew-seen",Sw="mdcc-whatsnew-toast-dismissed";function OG0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function wG0(X){try{let J=localStorage.getItem(Cw);if(J)return J;localStorage.setItem(Cw,X)}catch{}return X}function AG0(){try{return localStorage.getItem(Sw)}catch{return null}}function Vv(X){let[J,Q]=MX.useState([]),[Y,W]=MX.useState(X),[G,Z]=MX.useState(()=>wG0(X)),[H,q]=MX.useState(()=>AG0()),[K,V]=MX.useState(!1);MX.useEffect(()=>{let D=!1,P=()=>{fetch("/_api/whats-new").then((S)=>S.json()).then((S)=>{if(D)return;if(Q(Array.isArray(S?.entries)?S.entries:[]),typeof S?.version==="string")W(S.version)}).catch(()=>{})};P();let T=()=>P(),I=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",I),()=>{D=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",I)}},[]);let B=Kv(J,G),F=B.length>0&&H!==Y&&!K,L=B[0]??null,M=MX.useCallback(()=>{let D=Uv(J,Y);Z(D),q(Y);try{localStorage.setItem(Cw,D),localStorage.setItem(Sw,Y)}catch{}},[J,Y]),w=MX.useCallback(()=>{q(Y);try{localStorage.setItem(Sw,Y)}catch{}},[Y]),R=MX.useCallback(()=>V(!0),[]),A=MX.useCallback(()=>{V(!1),M()},[M]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:K,openPanel:R,closePanel:A,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:M}}function Bv({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),_("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Fv({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(MX.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:_("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>_("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[_("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),OG0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var C9=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Rs="mdcc-usage-tour-seen",ks="mdcc-collab-tour-seen",g8="__system__",Zt="mdcc-theme",Ts="mdcc-show-hidden",Is="mdcc-sections-expanded",Cs="maude-cp-mode",Ss="mdcc-sidebar-open",$s="mdcc-minimap-visible",bs="mdcc-zoomctl-visible",js="mdcc-annotations-visible";var SU0=30000;function $U0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var AP=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],Aq={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},ys="mdcc-panel-sides",fs="mdcc-layers-mode";function vs({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return _("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>z("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(AP.find((q)=>q.id===H)||{}).label||H},H))}),Z]})}var VY=/\.(tsx|html?)$/i,EP="0.48.0";function xs(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function bU0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Zt);if(X==="light"||X==="dark")return X}catch{}return"dark"}function QZ(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 LP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function jU0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function VF(X){return X.split("/").pop()}function l7(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(l7._t),l7._t=setTimeout(()=>{Q.style.opacity="0"},3200)}var hs="maude-browse-hint-seen";function yU0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(hs)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let X=document.createElement("div");X.id="st-browse-hint",X.setAttribute("role","status"),X.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;",X.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd> to select & edit like Figma.</span><button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let J=()=>{try{localStorage.setItem(hs,"1")}catch{}X.style.opacity="0",setTimeout(()=>X.remove(),200),document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)J()};X.querySelector("button")?.addEventListener("click",J),document.addEventListener("keydown",Q,!0),document.body.appendChild(X),requestAnimationFrame(()=>{X.style.opacity="1"}),setTimeout(J,9000)}function Pq(X){return X.replace(VY,"")}function fU0(X){return X.replace(VY,"")}function vU0(X){let J=new Map;for(let G of X){if(!VY.test(G.name))continue;let Z=fU0(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(VY.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((q,K)=>q.name.localeCompare(K.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function xU0(X,J){let Q={};for(let Y of X){let G=(Y.startsWith(J)?Y.slice(J.length).replace(/^\/+/,""):Y).split("/"),Z=Q;for(let H=0;H<G.length;H++){let q=G[H];if(H===G.length-1)Z._files=Z._files||[],Z._files.push({name:q,path:Y});else Z[q]=Z[q]||{},Z=Z[q]}}return Q}function Ht(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=Ht(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function gs(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function hU0(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 qt(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 gU0({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var mU0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:_(W0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),lock:_(W0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:_(W0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:_(W0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:_(W0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:_(W0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:_(W0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:_(W0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:_(W0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:_(W0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:_(W0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:_(W0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:_(W0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:_(W0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:_(W0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:_(W0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":_(W0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":_(W0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":_(W0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":_(W0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":_(W0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":_(W0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:_(W0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:_(W0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:_(W0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:_(W0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:_(W0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:_(W0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:_(W0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function uU0({open:X,onClose:J,actions:Q}){let[Y,W]=l.useState(""),[G,Z]=l.useState(0),H=l.useRef(null);l.useEffect(()=>{if(X)W(""),Z(0)},[X]),l.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let q=l.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(l.useEffect(()=>{if(G>=q.length)Z(0)},[q.length,G]),!X)return null;let K=(V)=>{J(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)J()},children:_("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[_("div",{className:"st-pal-search",children:[z(s8,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),J();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(q.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),q[G])K(q[G])}}}),z(l6,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:q.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):q.map((V,B)=>{let F=V.group&&(B===0||q[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return _(W0,{children:[F,_("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>K(V),children:[z("span",{className:"st-pal-icon",children:z(s8,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(l6,{children:V.kbd})}):null]})]},V.id)})})]})})}function s8({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:mU0[X]})}function lU0(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 ms({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function l6({children:X}){return z("span",{className:"kbd",children:X})}function us(X,{min:J,max:Q,def:Y}){let W=l.useCallback((q)=>Math.min(Q,Math.max(J,q)),[J,Q]),[G,Z]=l.useState(()=>{try{let q=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(q)?W(q):Y}catch{return Y}});l.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=l.useCallback((q)=>Z((K)=>W(typeof q==="function"?q(K):q)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ls({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:q,def:K}=J,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":q,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(K),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((L)=>L+F*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((L)=>L-F*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(q)},children:_("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var DP=[{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}],MP={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},dU0={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"]},pU0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],kV=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],cU0="2x",ds=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],iU0="auto",oU0={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 nU0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return oU0[J]||"application/octet-stream"}function rU0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=l.useState(null),[q,K]=l.useState(!1),[V,B]=l.useState(null),[F,L]=l.useState(()=>new Set),[M,w]=l.useState({}),[R,A]=l.useState(W?"artboard":"annotation");l.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((i)=>i.json()).then((i)=>{if(!x)return;let a=i.ok?i.assets:[];H(a),w((h)=>{let s={...h};for(let X0 of a)s[X0.path]=X0.kind;return s})}).catch(()=>x&&H([])),()=>{x=!1}},[]),l.useEffect(()=>{let x=(i)=>{if(i.key==="Escape")i.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let D=Array.from(F).some((x)=>(M[x]||"image")!=="image"),P=!W||D,T=!W?"No artboard on this canvas":D?"Video/audio can only be added as annotations":"";l.useEffect(()=>{if(P&&R==="artboard")A("annotation")},[P,R]);let I=(x)=>{L((i)=>{let a=new Set(i);if(a.has(x))a.delete(x);else a.add(x);return a})},S=async(x)=>{let i=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),a=await i.json().catch(()=>({}));if(i.ok&&a.path)return{ok:!0,path:a.path};return{ok:!1,error:a.error||`upload failed (HTTP ${i.status})`}},C=async(x)=>{if(!x)return;K(!0),B(null);let i=await S(x);if(K(!1),i.ok)J(i.path);else B(i.error)},j=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;K(!0),B(null);let i=await Promise.all(x.map((s)=>S(s).then((X0)=>({...X0,file:s}))));K(!1);let a=i.filter((s)=>s.ok),h=i.length-a.length;if(h>0)B(`${h} of ${i.length} uploads failed`);if(a.length)w((s)=>{let X0={...s};for(let c of a)X0[c.path]=j(c.file.type);return X0}),L((s)=>{let X0=new Set(s);for(let c of a)X0.add(c.path);return X0})},m=async()=>{K(!0),B(null);try{if(Y){let a=(await oy()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:nU0(h.name)}));if(K(!1),a.length)await f(a);return}let x=await f2();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}K(!1)},o=()=>{if(K9()){m();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let i=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(i,300),{once:!0}),x.addEventListener("change",()=>{let a=x.files?Array.from(x.files):[];if(i(),!a.length)return;if(Y)f(a);else C(a[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:_("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(s8,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[_("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:o,disabled:q,children:q?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let i=Y&&F.has(x.path);return _("button",{type:"button",className:"st-ap-cell","data-selected":i?"true":void 0,"aria-pressed":Y?i:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?I(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:i?z(s8,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&F.size>0&&_("div",{className:"st-dialog-ft st-ap-confirm",children:[_("span",{className:"st-ap-count",children:[F.size," selected"]}),_("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>A("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>A("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),R),children:"Insert"})]})]})})}function aU0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:Z}){let[H,q]=l.useState(X==="handoff"?"shadcn":"png"),[K,V]=l.useState(J&&MP[J]?J:"artboard"),[B,F]=l.useState(2),[L,M]=l.useState(cU0),[w,R]=l.useState(!0),[A,D]=l.useState(!1),[P,T]=l.useState(!1),[I,S]=l.useState(!1),[C,j]=l.useState(iU0),[f,m]=l.useState(!0),[o,n]=l.useState(!1),[x,i]=l.useState(null),[a,h]=l.useState([]),s=DP.find((p)=>p.id===H)||DP[0],X0=s.handoff?[]:dU0[s.format]||["artboard"];l.useEffect(()=>{if(X0.length&&!X0.includes(K))V(X0[0])},[X0,K]);let c=l.useCallback(()=>{fetch("/_api/export-history").then((p)=>p.json()).then((p)=>h(Array.isArray(p?.history)?p.history.slice(0,6):[])).catch(()=>{})},[]);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{function p(g){if(g.key==="Escape")g.preventDefault(),Z()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Z]);async function V0(){if(s.handoff){let d=`/design:handoff ${Q&&Q!==g8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(d)}catch{}i({ok:!0,msg:`Copied: ${d} — run it in Claude Code.`});return}n(!0),i(null);let p=s.temporal?{scale:B}:{};if(s.format==="png"){let g=kV.find((d)=>d.id===L)||kV[1];if(g.kind==="dpi")p.dpi=g.value;else p.scale=g.value}if(s.format==="mp4"||s.format==="webm")p.audio=f;if(s.format==="pdf"){p.pdfPrint={includeBleed:w,marks:{crop:P,registration:I}};let g=ds.find((d)=>d.id===C)?.value;if(g!==void 0)p.dpi=g}if(W)p.artboardId=W;if(G?.selector)p.selection=G;try{let g=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:K,options:p})});if(!g.ok){i({ok:!1,msg:await g.text()||`Export failed (${g.status})`}),n(!1);return}Z()}catch(g){i({ok:!1,msg:g&&g.message?g.message:String(g)}),n(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(p)=>{if(p.target===p.currentTarget)Z()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Z,children:z(s8,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==g8?`Format · ${Pq(VF(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:DP.filter((p)=>!p.temporal||Y).map((p)=>_("button",{type:"button",className:"st-fmt"+(p.id===H?" is-on":""),onClick:()=>{q(p.id),i(null)},children:[z(s8,{name:p.icon,size:16}),z("span",{className:"st-fmt-name",children:p.label}),z("span",{className:"st-fmt-sub",children:p.sub})]},p.id))}),!s.handoff&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:K,onChange:(p)=>V(p.target.value),children:X0.map((p)=>z("option",{value:p,children:MP[p]},p))})]}),!s.handoff&&s.format==="png"&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:L,onChange:(p)=>M(p.target.value),children:kV.map((p)=>z("option",{value:p.id,children:p.label},p.id))})]}),!s.handoff&&s.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let p=kV.find((d)=>d.id===L)||kV[1],g=p.kind==="dpi"?p.value/96:p.value;return`${p.label} ≈ ${Math.round(1440*g)}×${Math.round(900*g)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:B,onChange:(p)=>F(Number(p.target.value)),children:pU0.map((p)=>z("option",{value:p.value,children:p.label},p.value))})]}),!s.handoff&&s.temporal&&_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!s.handoff&&s.format==="pdf"&&_(W0,{children:[_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:C,onChange:(p)=>j(p.target.value),children:ds.map((p)=>z("option",{value:p.id,children:p.label},p.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:w,onChange:(p)=>R(p.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:_("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>D((p)=>!p),"aria-expanded":A,children:[A?"▾":"▸"," Marks"]})}),A&&_("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:P,onChange:(p)=>T(p.target.checked)}),"Crop marks"]}),_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:(p)=>S(p.target.checked)}),"Registration marks"]})]}),_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",K==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&z("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:f,onChange:(p)=>m(p.target.checked)}),"Export with audio"]})}),s.handoff&&_("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),x&&z("div",{className:"callout "+(x.ok?"callout--success":"callout--error"),style:{fontSize:12},children:x.msg}),a.length>0&&_("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((p,g)=>_("div",{className:"st-export-recent-row",children:[_("span",{children:[String(p.format||"").toUpperCase()," ·"," ",MP[p.scope]||p.scope]}),z("span",{className:"st-mono",children:p.filename})]},g))]})]}),_("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:Z,children:"Cancel"}),_("button",{type:"button",className:"btn btn--primary",disabled:o,onClick:V0,children:[z(s8,{name:"download",size:14}),s.handoff?"Copy handoff command":o?"Exporting…":`Export ${s.label}`]})]})]})})}var BF=12,FF=16;function sU0({name:X,depth:J,defaultOpen:Q,children:Y}){let[W,G]=l.useState(Q);return _(W0,{children:[_("button",{type:"button",role:"treeitem","aria-expanded":W,tabIndex:-1,className:"st-row",style:{paddingLeft:BF+J*FF+"px"},onClick:()=>G((Z)=>!Z),children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"chevron-right",className:"st-chev"+(W?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]}),W&&Y]})}function tU0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,q]=l.useState(Y);return _(W0,{children:[_("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:BF+Q*FF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>q((K)=>!K),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(s8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),_("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function _P({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:q,experimentalKind:K}){let V=X.path===J,B=VY.test(X.name),F=!B,L=B?Pq(X.name):X.name,M=B&&typeof Y==="function"&&Z!=="runtime",w=B?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(VY,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,R=_("button",{type:"button",role:"treeitem","data-testid":w,"aria-selected":V,"aria-disabled":F?"true":void 0,tabIndex:V?0:-1,className:"st-row"+(V?" is-sel":"")+(Z==="runtime"?" is-muted":""),style:{paddingLeft:BF+G*FF+"px"},title:X.path+(W?` — ${W} open`:F?" (file index only)":""),onClick:()=>{if(!F)Q(X.path)},children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"file",size:13})}),z("span",{className:"st-row-name",children:L}),K==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),W>0&&z("span",{className:"st-row-badge",children:W})]});if(!M)return R;return _("div",{className:"st-row-wrap",role:"none",children:[R,z("button",{type:"button",className:"st-row-del",title:`Delete ${L}`,"aria-label":`Delete canvas ${L}`,onClick:(A)=>{A.stopPropagation(),Y(X.path,L)},children:z(gU0,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function eU0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:q,forceOpen:K,dirtyByPath:V,experimentalKind:B}){let F=V?.get(X.path),L=J.length>0,[M,w]=l.useState(!1),R=K||M,A=X.path===W;if(!(L&&q))return z(_P,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:F,experimentalKind:B});return _(W0,{children:[_("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":R,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":""),style:{paddingLeft:BF+Q*FF+"px"},title:X.path,onClick:(P)=>{if(P.target.closest(".st-canvas-chev")){w((T)=>!T);return}G(X.path)},children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(P)=>{P.stopPropagation(),w((T)=>!T)},children:z(s8,{name:"chevron-right",className:"st-chev"+(R?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:Pq(X.name)}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F&&z("span",{className:"st-git-badge","data-kind":F,title:`Unsaved (${F})`,"aria-label":`Unsaved, ${F}`,children:F}),H>0&&z("span",{className:"st-row-badge",children:H})]}),R&&J.map((P)=>z(_P,{file:P,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},P.path))]})}function zt({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:q,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L}){let M=Object.keys(X).filter((T)=>T!=="_files").sort(),w=X._files||[],{canvases:R,orphans:A}=l.useMemo(()=>vU0(w),[w]),D=!!(H&&H.trim()),P=l.useMemo(()=>{if(!q||W!==1)return null;let T=new Map;for(let I of q)T.set(I.folder,I);return T},[q,W]);return _(W0,{children:[R.map((T)=>{let I=D&&T.sidecars.some((S)=>{let C=H.toLowerCase();return S.name.toLowerCase().includes(C)||S.path.toLowerCase().includes(C)});return z(eU0,{primary:T.primary,sidecars:T.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:gs(Y[T.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:I,dirtyByPath:F,experimentalKind:L?.[T.primary.path]},T.primary.path)}),Z&&A.map((T)=>z(_P,{file:T.primary,activePath:J,onOpen:Q,openCount:gs(Y[T.primary.path]),depth:W,kind:G},T.primary.path)),M.map((T)=>{let I=P?.get(T),S=z(zt,{node:X[T],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L});if(I&&V)return z(tU0,{name:T,dsName:I.name,depth:W,defaultOpen:!0,active:J===g8&&I.name===K,onOpenSystem:V,children:S},T);return z(sU0,{name:T,depth:W,defaultOpen:!0,children:S},T)})]})}var qF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function XV0(X){if(X.kind==="project")return qF.project;if(X.kind==="runtime")return qF.runtime;if(X.label==="Design system")return qF.ds;if(X.label==="UI kit")return qF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function JV0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:q,showHidden:K,sectionsExpanded:V,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:M,refreshing:w,collapsed:R,onCollapse:A,width:D,resizing:P,dirtyByPath:T,project:I,gitBranch:S,remoteSync:C,onGetLatest:j,canvasKinds:f}){let m=l.useMemo(()=>{if(!Z)return X;return X.map((g)=>({...g,tree:Ht(g.tree,Z),filtered:!!Z}))},[X,Z]),[o,n]=l.useState(!1),[x,i]=l.useState(""),[a,h]=l.useState(""),[s,X0]=l.useState(!1),c=l.useCallback(async()=>{let g=x.trim();if(!g||s)return;X0(!0),h("");let d=await F(g);if(X0(!1),d?.ok)n(!1),i("");else h(d?.error||"could not create board")},[x,s,F]),V0=l.useMemo(()=>{let g=0;for(let d of X)for(let K0 of d.paths||[])if(VY.test(K0))g++;return g},[X]),p=l.useMemo(()=>{let g=0;for(let d of m)for(let K0 of d.paths||[])if(VY.test(K0))g++;return g},[m]);return _("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(P?" is-resizing":""),style:R||!D?void 0:{width:D,flexBasis:D},"aria-label":"Files","data-tour":"sidebar",children:[_("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),_("div",{className:"st-sb-hd-actions",children:[z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":o,onClick:()=>{h(""),n((g)=>!g)},children:z(s8,{name:"plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>M(),children:z(s8,{name:"reload",size:15})}),_("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),p," / ",V0]}),A&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:A,children:z(s8,{name:"panel-left",size:15})})]})]}),o?_("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:"brief board name…",value:x,maxLength:60,disabled:s,"aria-label":"New brief board name",onChange:(g)=>i(g.target.value),onKeyDown:(g)=>{if(g.key==="Enter")g.preventDefault(),c();else if(g.key==="Escape")g.preventDefault(),n(!1),i(""),h("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:s||!x.trim(),"data-tip":"Create · Enter","aria-label":"Create brief board",onClick:c,children:s?"…":"↵"})]}):null,a?z("div",{className:"st-newboard-err",role:"alert",children:a}):null,z("div",{className:"st-search",children:_("div",{className:"st-search-box",children:[z(s8,{name:"search",size:13}),z("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(g)=>H(g.target.value),onKeyDown:(g)=>{if(g.key==="Escape")if(g.preventDefault(),Z)H("");else g.currentTarget.blur()},"aria-label":"Filter files"}),Z?z("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(l6,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:m.map((g)=>{if(!K&&!Z&&g.kind==="runtime")return null;let d=XV0(g),K0=(g.paths||[]).filter((m8)=>VY.test(m8)).length,u0=d.pill||(d.pillFromDsCount?String(g.dsFolders?.length||0):null)||(d.pillFromCount?String(K0||g.paths?.length||0):null),J8=g.tree&&Object.keys(g.tree).length>0,G8=g.label==="Design system",s0=g.kind==="project";if(!K&&!Z&&s0&&K0===0)return null;let D8=jU0(g),U8=V[g.label],q8=!!Z||(U8===void 0?D8:U8);return _("div",{className:"st-tree-section",children:[_("button",{type:"button",className:"st-tree-sec-hd",onClick:()=>B(g.label,D8),"aria-expanded":q8,title:q8?"Collapse section":"Expand section",children:[z(s8,{name:"chevron-right",className:"st-chev"+(q8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:d.title}),u0&&z("span",{className:"st-pill",children:u0})]}),q8&&(J8?z(zt,{node:g.tree,activePath:J,onOpen:Y,commentsByFile:q,depth:1,kind:g.kind,showHidden:K,search:Z,dsFolders:g.dsFolders,activeDsName:Q,onOpenSystem:G8?W:void 0,onDelete:G8?void 0:L,dirtyByPath:T,canvasKinds:f}):z("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},g.label)})}),z(Lw,{project:I,liveBranch:S,remoteSync:C,onGetLatest:j}),z(Yw,{})]})}function QV0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:_("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(s8,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(s8,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(s8,{name:"folder",size:15})})]})})}function YV0({open:X,onClose:J,onStartTour:Q}){if(l.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),_("span",{className:"sku",children:["MAUDE-DEV-SRV / v",EP]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),_("div",{className:"help-modal-body",children:[_("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),_("ul",{children:[_("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),_("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),_("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),_("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),_("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),_("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),_("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),_("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),_("details",{children:[z("summary",{children:"Annotation tools"}),_("ul",{children:[_("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),_("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),_("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),_("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),_("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),_("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),_("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),_("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),_("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),_("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),_("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),_("details",{children:[z("summary",{children:"Canvas & panels"}),_("ul",{children:[_("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),_("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),_("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),_("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),_("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),_("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),_("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),_("details",{children:[z("summary",{children:"Slash commands"}),_("ul",{className:"cmds",children:[_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),_("li",{children:[_("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),_("li",{children:[_("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),_("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),_("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),_("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),_("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),_("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),_("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),_("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),_("details",{children:[z("summary",{children:"Opt-out scope"}),_("ul",{children:[_("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),_("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),_("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),_("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),_("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),_("details",{children:[z("summary",{children:"Auto-critic loop"}),_("ul",{children:[_("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),_("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),_("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),_("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),_("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),_("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),_("details",{children:[z("summary",{children:"Pin-to-element flow"}),_("ol",{children:[z("li",{children:"Open a canvas"}),_("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),_("li",{children:["Run"," ",_("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),_("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),_("details",{children:[z("summary",{children:"Comments"}),_("ol",{children:[_("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),_("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),_("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),_("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var OP=[{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 WV0({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(l6,{children:G},`${G}-${Z}`))},W);return _("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>_(W0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function GV0({open:X,onClose:J}){if(l.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=OP.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[_("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),_("span",{className:"so-trigger",children:["press ",z(l6,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:OP.map((Y)=>_("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>_("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(WV0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),_("div",{className:"so-overlay-ft",children:[_("span",{children:["close with ",z(l6,{children:"Esc"})]}),_("span",{className:"so-count",children:[Q," bindings · ",OP.length," groups"]})]})]})})}var ZV0=["File","Edit","View","Selection","Tools","Help"];function Kt(X){l.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 HV0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Kt(Q),_("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(s8,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(l6,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(l6,{children:G.shortcut})]},G.label))]})}function CV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Kt(G),_("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(l6,{children:Z.shortcut}):null]},Z.id))]})}function qV0({onAction:X,onClose:J}){return z(CV,{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"},...K9()?[{id:"collab-tour",label:"How sharing works"}]:[],...K9()?[{id:"quick-setup",label:"Quick setup"}]:[],...K9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function zV0({onAction:X,onClose:J}){return z(CV,{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 KV0({onAction:X,onClose:J}){return z(CV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]})}function UV0({onAction:X,onClose:J,hasCanvas:Q}){return z(CV,{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 VV0({onAction:X,onClose:J,hasCanvas:Q}){return z(CV,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function BV0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:q,onToggleChanges:K,onOpenSystem:V,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:M,onOpenHelp:w,onOpenShortcuts:R,onStartTour:A,onStartCollabTour:D,annotationsVisible:P,onToggleAnnotations:T,minimapVisible:I,onToggleMinimap:S,zoomCtlVisible:C,onToggleZoomCtl:j,presentMode:f,onTogglePresent:m,printGuidesVisible:o,onTogglePrintGuides:n,postToActiveCanvas:x,onOpenWhatsNew:i,onOpenReadiness:a,onOpenQuickSetup:h,onWatchIntro:s,whatsNewCount:X0,exportCenter:c,artboardCount:V0=0,presence:p=null,inspectorOpen:g,inspectorTab:d,onToggleInspector:K0,autoOpenInspector:u0,onToggleAutoOpenInspector:J8,onOpenLayers:G8,timelineOpen:s0,onToggleTimeline:D8,hasComps:U8=!1,assistantOpen:q8,onToggleAssistant:m8,assistantBusy:_8,assistantUnseen:G9,onNewCanvas:Z9,onAssembleVideo:e0,onOpenExport:p8,onOpenSettings:o8,onOpenGenerate:$9,onReload:j0,onCloseCanvas:F0,onInsertArtboard:U0}){let k0=X===g8,H0=k0?"SYSTEM":X?"CANVAS":"IDLE",L0=k0?z("b",{children:"design system"}):X?_(W0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:Pq(VF(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),N0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:q>0?`Changes · ${q} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:g&&d==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:g,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!u0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:U8?"video":void 0,checked:s0,disabled:!1},...K9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:q8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:P,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:I,disabled:!X||k0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:C,disabled:!X||k0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!X||k0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:o,disabled:!X||k0}],t0=["file","edit","view","selection","tools","help"];function $8(y0){if(t0.includes(y0))W(Y===y0?null:y0)}return l.useEffect(()=>{if(!Y||!t0.includes(Y))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function v0(O0){let n0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!n0.length)return;let Q8=n0.indexOf(document.activeElement);if(O0.key==="ArrowDown")O0.preventDefault(),n0[(Q8+1)%n0.length].focus();else if(O0.key==="ArrowUp")O0.preventDefault(),n0[(Q8-1+n0.length)%n0.length].focus();else if(O0.key==="Home")O0.preventDefault(),n0[0].focus();else if(O0.key==="End")O0.preventDefault(),n0[n0.length-1].focus();else if(O0.key==="ArrowRight"||O0.key==="ArrowLeft"){O0.preventDefault();let w0=O0.key==="ArrowRight"?1:-1,i0=t0.indexOf(Y);W(t0[(i0+w0+t0.length)%t0.length])}else if(O0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",v0),()=>{clearTimeout(y0),window.removeEventListener("keydown",v0)}},[Y,W]),_("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[_("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:ZV0.map((y0)=>{let v0=y0.toLowerCase(),O0=t0.includes(v0),n0=O0||v0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":v0==="help"?"help":void 0,"aria-haspopup":O0?"menu":void 0,"aria-expanded":O0?Y===v0:void 0,onClick:()=>$8(v0),onMouseEnter:()=>{if(Y!==null&&O0)W(v0)},children:y0},v0)})}),Y==="file"&&z(UV0,{hasCanvas:!!X,onAction:(y0)=>{if(y0==="new")Z9?.();else if(y0==="assemble")e0?.();else if(y0==="export")p8?.("export");else if(y0==="handoff")p8?.("handoff");else if(y0==="generate")$9?.();else if(y0==="settings")o8?.();else if(y0==="reload")j0?.();else if(y0==="close")F0?.()},onClose:()=>W(null)}),Y==="edit"&&z(VV0,{hasCanvas:!!X&&!k0,onAction:(y0)=>{if(y0==="undo")x({dgn:"undo"});else if(y0==="redo")x({dgn:"redo"});else if(y0==="deselect-all")x({dgn:"selection-clear"});else if(y0==="select-all-annotations")x({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))U0?.(y0.slice(13))},onClose:()=>W(null)}),Y==="view"&&z(HV0,{panels:N0,onToggle:(y0)=>{if(y0==="tree")F();else if(y0==="changes")K();else if(y0==="comments")Z();else if(y0==="hidden")M();else if(y0==="annotate")T();else if(y0==="inspector")K0();else if(y0==="autoopen")J8?.();else if(y0==="timeline")D8?.();else if(y0==="assistant")m8?.();else if(y0==="layers")G8?.();else if(y0==="minimap")S?.();else if(y0==="zoomctl")j?.();else if(y0==="present")m?.();else if(y0==="print-guides")n?.()},onZoom:(y0)=>x({dgn:"zoom",op:y0}),hasCanvas:!!X&&!k0,onClose:()=>W(null)}),Y==="selection"&&z(zV0,{onAction:(y0)=>{if(y0==="deselect-all")x({dgn:"selection-clear"});else if(y0==="select-all-annotations")x({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&z(KV0,{onAction:(y0)=>x({dgn:"tool-set",tool:y0}),onClose:()=>W(null)}),Y==="help"&&z(qV0,{onAction:(y0)=>{if(y0==="shortcuts")R?.();else if(y0==="help")w?.();else if(y0==="tour")A?.();else if(y0==="collab-tour")D?.();else if(y0==="quick-setup")h?.();else if(y0==="readiness")a?.();else if(y0==="whatsnew")i?.();else if(y0==="watch-intro")s?.()},onClose:()=>W(null)}),_("div",{className:"st-mb-right","data-tour":"status",children:[p?z("div",{className:"st-presence",children:p}):null,K9()&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":q8?"true":"false","data-busy":_8?"true":"false","data-unseen":G9?"true":"false","aria-label":`Assistant${_8?" — working":G9?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:m8,children:z(s8,{name:"sparkle",size:15})}),c&&z(Gv,{center:c}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":X0>0?"true":"false","aria-label":`What's new${X0>0?` — ${X0} unseen`:""}`,"data-tip":"What's new",onClick:i,children:z(s8,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:H0}),z("span",{className:"st-mb-file",title:X||"",children:L0}),z("span",{className:"st-mb-sep"}),_("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),V0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function FV0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:q,onIframeLoad:K,showQuickSetup:V,onStartQuickSetup:B}){return _("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&_("div",{className:"st-empty",children:[_("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),_("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",EP," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),_("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(l6,{children:"⌘"})," and hover to preview an element, click to select it — ",z(l6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",K9()?_(W0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),V&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((F)=>{if(F.path===g8)return z("div",{className:"system-view"+(F.path===J?" active":""),children:z(_V0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return z("iframe",{ref:(L)=>Q(F.path,L),src:_H(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>K?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),q&&q===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:_("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var NV0=["color","space","radius","shadow","leading","weight","motion","font","other"],LV0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function DV0(X){return X==="color"}function MV0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return _("section",{className:"sv-section sv-section-tokens",children:[_("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:_("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...NV0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(W0,{children:W.map((G)=>{let Z=Y[G],H=DV0(G);return _("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[_("h2",{children:["tokens · ",LV0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((q)=>_("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:q.value}}):null,_("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:q.name}),z("span",{className:"sv-tok-value",children:q.value||"—"})]})]},q.name+"|"+q.value))})]},G)})})}function OV0(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 wV0(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 AV0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=wV0(X?.font);return _("section",{className:"sv-section sv-section-type",children:[_("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=OV0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return _("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function _V0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:q,tokensPath:K,ds:V,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return _("div",{className:"sv",children:[_("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),L?_("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>z("option",{value:w.name,children:w.name},w.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(MV0,{tokens:H,tokenGroups:q,tokensPath:K}),z(AV0,{tokenGroups:q}),F?z("div",{className:"sv-empty",children:_("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):_(W0,{children:[z(ps,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(ps,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function ps({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return _("section",{className:"sv-section",children:[_("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>_("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:_H(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),_("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function EV0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:q=0,unpushed:K=0,changesOpen:V=!1,onOpenChanges:B}){let F=X===g8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",R=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let 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 _("footer",{className:"st-statusbar",role:"contentinfo",children:[_("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&_("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:M,children:L}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),_("span",{className:"val",children:[Y," open"]})]}),B&&_("button",{type:"button",className:"st-sb-slot st-sb-changes"+(V?" is-open":"")+(q>0?" has-changes":K>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":V,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:q>0?`${q} unsaved`:K>0?`${K} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&_("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]}),_("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[z(s8,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function PV0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:q,width:K,resizing:V}){let B=qt(X),F=Object.keys(X||{}).sort(),L=[];for(let M of F){let w=X[M]||[],R=w.filter((D)=>{if(J==="open")return D.status!=="resolved";if(J==="resolved")return D.status==="resolved";return!0});if(R.length===0)continue;let A=w.filter((D)=>D.selector);L.push({file:M,comments:R.map((D)=>({...D,n:A.findIndex((P)=>P.id===D.id)+1}))})}return _("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:K?{width:K,flexBasis:K}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:_("div",{className:"st-cm-filters",role:"tablist",children:[_("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),_("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),_("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:L.length===0?_("div",{className:"st-rp-empty",children:[_("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),_("p",{children:["Open a canvas, hold ",z(l6,{children:"⌘"})," and click an element, then press ",z(l6,{children:"C"})," — or hold ",z(l6,{children:"⌘⇧"})," and click directly."]})]}):L.map((M)=>_(W0,{children:[_("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:Pq(VF(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((w)=>_("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(M.file,w.id),children:[_("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),z("span",{className:"st-comment-time",children:hU0(w.created)})]}),z("div",{className:"st-comment-txt",children:w.text}),_("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),_("span",{className:"st-mini-act",children:[w.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(w.id)},children:z(s8,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(w.id)},children:z(s8,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),q(w.id)},children:z(s8,{name:"x",size:14})})]})]})]},w.id))]},M.file))})]})}function RV0({update:X,onDismiss:J}){let[Q,Y]=l.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return _("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),_("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),ry().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function kV0({status:X}){let[J,Q]=l.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",q=Y==="offline"||Y==="offline-long",K=X.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!q&&!H&&!V&&K===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(q){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;L=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",F=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;L=`diverged:${V.slug}:${V.at}`}else B="warn",F=`${K} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${K}`;if(J===L)return null;return _("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:F}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var TV0=["block","inline-block","flex","inline-flex","grid","inline","none"],cs=["px","%","fr","em","auto","min-content","max-content"];var IV0=["auto","stretch","flex-start","center","flex-end","baseline"];var is=["300","400","500","600","700","800"],os=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],ns=["none","solid","dashed","dotted","double"],rs=["px","rem","em","%","vw","vh","auto"],as=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),wP={"font-size":{node:z(C9,{as:QU,size:12})},"line-height":{node:z(C9,{as:zU,size:12})},"letter-spacing":{node:z(C9,{as:LU,size:12})},gap:{node:z(C9,{as:tH,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(C9,{as:AU,size:12})},"border-width":{node:z(C9,{as:NU,size:12})}};var ss=["static","relative","absolute","fixed","sticky"],CV0=["normal","italic","oblique"],ts=["none","uppercase","lowercase","capitalize"];var es=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],SV0=["fill","contain","cover","none","scale-down"];var Xt=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Jt=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],yJ={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}},_q=null;function UF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!_q)_q=document.createElement("canvas").getContext("2d");if(!_q)return"";_q.fillStyle="#000000",_q.fillStyle=X;let J=_q.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 UY=(X)=>Math.min(1,Math.max(0,X));function zF(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 TV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function IV({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function Eq({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,q=0;if(X<60)[Z,H,q]=[Y,W,0];else if(X<120)[Z,H,q]=[W,Y,0];else if(X<180)[Z,H,q]=[0,Y,W];else if(X<240)[Z,H,q]=[0,W,Y];else if(X<300)[Z,H,q]=[W,0,Y];else[Z,H,q]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(q+G)*255}}function S9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function JQ(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 Qt(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function Ut(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function $V0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],q=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=q&&J[q[1]]?J[q[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function Vt(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=l.useState([]);return l.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(q)=>{if(!q.tokensCssRel)return null;try{let K=await fetch(`/${J}/${q.tokensCssRel}`),V=K.ok?await K.text():"";return{name:q.name,...$V0(V)}}catch{return null}})).then((q)=>{if(H)return;let K=q.filter(Boolean);K.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(K)}),()=>{H=!0}},[W,J,Q]),G}function Bt({seed:X,label:J,onApply:Q}){let[Y,W]=l.useState(()=>IV(zF(X||"#000000"))),G=l.useRef(Y);G.current=Y;let Z=l.useRef(null),H=l.useRef(null),q=l.useRef(X);l.useEffect(()=>{if(X&&X!==q.current)q.current=X,W(IV(zF(X)))},[X]);let K=TV(Eq(Y)),V=(D)=>{D.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,I=(C)=>{W({h:T,s:UY((C.clientX-P.left)/P.width),v:UY(1-(C.clientY-P.top)/P.height)})};I(D);let S=()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",S),Q(TV(Eq(G.current)))};document.addEventListener("pointermove",I),document.addEventListener("pointerup",S)},B=(D)=>{D.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:I}=G.current,S=(j)=>{W({h:UY((j.clientX-P.left)/P.width)*360,s:T,v:I})};S(D);let C=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),Q(TV(Eq(G.current)))};document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)},F=(D)=>{let P={...G.current,...D};W(P),Q(TV(Eq(P)))},L=(D)=>{let P=D.shiftKey?0.1:0.02,I={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[D.key];if(!I)return;D.preventDefault(),F({s:UY(G.current.s+I[0]),v:UY(G.current.v+I[1])})},M=(D)=>{let P=D.shiftKey?20:2,I={ArrowLeft:-P,ArrowRight:P}[D.key];if(I==null)return;D.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+I))})},w=async()=>{try{let D=window.EyeDropper;if(!D)return;let P=await new D().open();if(P?.sRGBHex)W(IV(zF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=Eq(Y),A=(D)=>{let P={...R,...D},T=IV({r:UY(P.r/255)*255,g:UY(P.g/255)*255,b:UY(P.b/255)*255});W(T),Q(TV(Eq(T)))};return _("div",{className:"st-cp-cpick",children:[_("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:K}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:K,"aria-label":J?`${J} hex value`:"hex value",onChange:(D)=>{let P=D.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(IV(zF(P)))},onKeyDown:(D)=>{if(D.key==="Enter")Q(D.currentTarget.value)},onBlur:(D)=>Q(D.currentTarget.value),onFocus:(D)=>D.currentTarget.select()})]}),_("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:L,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:K}})]}),_("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:z(s8,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:K},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((D)=>_("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":D.toUpperCase(),value:Math.round(R[D]),onChange:(P)=>A({[D]:UY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:D.toUpperCase()})]},D))})]})}function KF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:q}){let[K,V]=l.useState(!1),[B,F]=l.useState(null),[L,M]=l.useState("custom"),[w,R]=l.useState(""),A=l.useRef(null),D=l.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(X0)=>Q===`var(${X0})`,I=(X0)=>X0.replace(/^--/,"").replace(/-/g," "),S=J||[],C=S.reduce((X0,c)=>X0+(c.names?.length||0),0),j=S.length>1,f=w.trim().toLowerCase(),m=!f?S:S.map((X0)=>({...X0,names:(X0.names||[]).filter((c)=>I(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(X0.vals?.[c]||"").toLowerCase().includes(f))})).filter((X0)=>X0.names.length);l.useEffect(()=>{if(!K){R("");return}let X0=()=>{let g=A.current?.getBoundingClientRect();if(!g)return;let d=224,K0=300,u0=Math.min(g.right-d,window.innerWidth-d-8);if(u0<8)u0=8;let G8=window.innerHeight-g.bottom>K0+8?g.bottom+4:Math.max(8,g.top-K0-4);F({left:u0,top:G8,width:d,maxHeight:K0})};X0();let c=(g)=>{if(D.current?.contains(g.target)||A.current?.contains(g.target))return;V(!1)},V0=(g)=>{if(g.key==="Escape")V(!1)},p=(g)=>{if(D.current?.contains(g.target))return;X0()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",V0),window.addEventListener("resize",X0),document.addEventListener("scroll",p,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",V0),window.removeEventListener("resize",X0),document.removeEventListener("scroll",p,!0)}},[K]),l.useEffect(()=>{if(!K||!B||!D.current)return;let X0=D.current.getBoundingClientRect(),c=B.left-X0.left,V0=B.top-X0.top;if(Math.abs(c)>0.5||Math.abs(V0)>0.5)F((p)=>p?{...p,left:p.left+c,top:p.top+V0}:p)},[K,B]);let o=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(X0,c,V0)=>{if(H&&X0&&X0!==H&&V0&&!o.test(V0))Y(V0);else Y(`var(${c})`);V(!1)},x=(X0)=>{let c=(X0||"").trim();if(c)Y(c)},i=_("div",{className:"st-cp-pop-search",children:[z(s8,{name:"search",size:12}),z("input",{value:w,onChange:(X0)=>R(X0.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),a=(X0)=>X0.map((c)=>_("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((V0)=>_("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(V0)?" is-on":""}`,onClick:()=>n(c.ds,V0,c.vals?.[V0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[V0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:I(V0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[V0]||""})]},`${c.ds}:${V0}`))})]},c.ds)),h=(X0)=>X0.map((c)=>_("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((V0)=>_("button",{type:"button",className:`st-cp-pop-row${T(V0)?" is-on":""}`,onClick:()=>n(c.ds,V0,c.vals?.[V0]),children:[z("span",{className:"st-cp-pop-name",children:I(V0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[V0]||""})]},`${c.ds}:${V0}`))})]},c.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return _(W0,{children:[G!==void 0?z("button",{type:"button",ref:A,className:`${q||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!q?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((X0)=>!X0),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:A,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((X0)=>!X0),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),K&&B?Wt.createPortal(z("div",{ref:D,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"?_(W0,{children:[_("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),L==="custom"?z(Bt,{seed:Z||UF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):_(W0,{children:[i,m.length?a(m):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):_(W0,{children:[i,m.length?h(m):s]})}),document.body):null]})}function Yt({label:X,tracks:J,editable:Q,onChange:Y}){let W=(q,K)=>{let V=J[q];Y(J.map((B,F)=>F===q?zK.has(K)?{value:0,unit:K}:{value:V.value||1,unit:K}:B))},G=(q,K)=>{Y(J.map((V,B)=>B===q?{...V,value:K}:V))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(q)=>Y(J.filter((K,V)=>V!==q));return _("div",{className:"st-cp-gridtracks",children:[_("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?_("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((q,K)=>{let V=zK.has(q.unit);return _("div",{className:"st-cp-gridtrack-row",children:[V?z(c4,{value:q.unit,ariaLabel:`${X} track ${K+1}`,options:cs.map((B)=>({value:B,label:B})),onChange:(B)=>W(K,B)}):z(Q5,{value:q.value,min:q.unit==="fr"?0.1:0,step:q.unit==="fr"?0.1:1,ariaLabel:`${X} track ${K+1} value`,lead:String(K+1),unitSlot:z(e2,{value:q.unit,units:cs,ariaLabel:`${X} track ${K+1} unit`,onChange:(B)=>W(K,B)}),onCommit:(B)=>G(K,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${K+1}`,disabled:!Q||J.length<=1,onClick:()=>H(K),children:"×"})]},K)})]})}function bV0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let q=!!X.id,K=X.computed||{},[V,B]=l.useState({a:{},c:{},t:{}});l.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,B0)=>{let q0={...t||{}};for(let[C0,r0]of Object.entries(B0))if(r0===null)delete q0[C0];else q0[C0]=r0;return q0},L=F(X.authored,V.a),M=F(X.customStyles,V.c),w=F(X.attrs,V.t),R=(t,B0)=>B((q0)=>({...q0,a:{...q0.a,[t]:B0}})),A=(t,B0)=>B((q0)=>({...q0,c:{...q0.c,[t]:B0}})),D=(t,B0)=>B((q0)=>({...q0,t:{...q0.t,[t]:B0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Ut(X.file,J),I=Vt(J,P,T),S=(t)=>I.map((B0)=>({ds:B0.name,names:B0[t]||[],vals:B0.vals})).filter((B0)=>B0.names.length),[C,j]=l.useState({}),[f,m]=l.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),o=Object.keys(M).length>0||Object.keys(w).length>0;l.useEffect(()=>{if(o)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,o]);let n=(L.position||S9(K.position)||"static")!=="static";l.useEffect(()=>{if(n)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,n]);let x=H,[i,a]=l.useState({});async function h(t,B0,q0){j((C0)=>({...C0,[q0]:"saving"}));try{let C0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B0)}),r0=await C0.json().catch(()=>({}));j((F8)=>({...F8,[q0]:!C0.ok||!r0.ok?`err:${r0&&r0.error||`HTTP ${C0.status}`}`:"saved"}))}catch(C0){j((r0)=>({...r0,[q0]:`err:${C0&&C0.message?C0.message:String(C0)}`}))}}let s=(t,B0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:B0})},X0=(t,B0,q0,C0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:B0,before:q0==null||q0===""?null:q0,after:C0==null||C0===""?null:C0})},c=(t,B0)=>{let q0=(B0||"").trim();if(!q||!q0)return;let C0=L[t]??null;if(q0===(C0??"").trim())return;s(t,q0),R(t,q0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:q0},t),X0("css",t,C0,q0)},V0=(t,B0)=>{let q0=(B0||"").trim(),C0=t.trim();if(!q||!C0||!q0)return;let r0=M[C0]??null;s(C0,q0),A(C0,q0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:C0,value:q0},C0),X0("css",C0,r0,q0)},p=(t,B0)=>{let q0=(t||"").trim(),C0=(B0||"").trim();if(!q||!q0||!C0)return;let r0=w[q0]??null;D(q0,C0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:q0,value:C0},`@${q0}`),X0("attr",q0,r0,C0)},g=(t)=>{if(!q)return;let B0=L[t]??null;s(t,null),R(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,B0,null)},d=(t)=>{if(!q)return;let B0=M[t]??null;s(t,null),A(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,B0,null)},K0=(t)=>{if(!q)return;let B0=w[t]??null;D(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),X0("attr",t,B0,null)},u0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,B0)=>{if(!q)return;let q0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),C0=IC(t,B0,u0,q0);for(let r0 of C0.reset)if(L[r0])g(r0);for(let[r0,F8]of C0.set)c(r0,F8)},G8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",s0=(t)=>{let B0=TC(t,L,K,u0);return _("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(XB,{value:B0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(q0)=>J8(t,q0)})})]},`mode-${t}`)},D8=["flex-start","center","flex-end"],U8=["flex-start","center","flex-end"],q8=["t","c","b"],m8=["l","c","r"],_8=()=>{let t=!(L["flex-direction"]||S9(K["flex-direction"])||"row").startsWith("column"),B0=Math.max(0,D8.indexOf(L["justify-content"]||S9(K["justify-content"])||"flex-start")),q0=L["align-items"]||S9(K["align-items"])||"stretch",C0=q0==="stretch"?1:Math.max(0,U8.indexOf(q0)),[r0,F8]=t?[B0,C0]:[C0,B0];return q8[F8]+m8[r0]},G9=(t)=>{let B0=q8.indexOf(t[0]),q0=m8.indexOf(t[1]),C0=!(L["flex-direction"]||S9(K["flex-direction"])||"row").startsWith("column"),[r0,F8]=C0?[q0,B0]:[B0,q0];c("justify-content",D8[r0]),c("align-items",U8[F8])},Z9=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let B0=t.key.toLowerCase();if(B0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(B0==="y")t.preventDefault(),G?.("redo")},e0=(t)=>{let B0=L[t];if(!B0)return"inherit";return/var\(\s*--/.test(B0)?"bound":"raw"};if(!q)return _("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),_("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let p8={bound:"token-bound",raw:"raw override",inherit:"inherited"},o8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":p8[t]}),$9=(t,B0)=>{let q0=B0??e0(t),C0=C[t],r0=typeof C0==="string"&&C0.startsWith("err:")?C0.slice(4):"",F8=r0?" is-err":C0==="saved"?" is-saved":C0==="saving"?" is-saving":"",k8=!!L[t],P8=r0?`error: ${r0}`:k8?`${p8[q0]} · double-click to reset`:p8[q0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${q0}${F8}${k8?" is-resettable":""}`,"aria-label":P8,title:P8,tabIndex:k8?0:-1,onDoubleClick:k8?()=>g(t):void 0,onKeyDown:k8?(f8)=>{if(f8.key==="Backspace"||f8.key==="Delete")f8.preventDefault(),g(t)}:void 0})},j0=(t,B0,q0,C0)=>{let r0=q0===void 0&&!L[t],F8=C0??t;return _("div",{className:`st-cp-row${r0?" is-unset":""}`,children:[$9(t,q0),z("label",{className:"st-cp-label",title:F8,children:F8}),z("div",{className:"st-cp-ctl",children:B0})]},t)},F0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},U0=(t)=>{(F0[t]||[]).forEach((B0)=>{if(L[B0])g(B0)})},k0=(t,B0)=>{let q0=(F0[t]||[]).some((C0)=>L[C0]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[t],onClick:()=>m((C0)=>({...C0,[t]:!C0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${q0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!q0,onClick:()=>U0(t),children:z(C9,{as:RG,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t)},H0=(t,B0,q0,C0=!0)=>{let r0=`d:${t}`,F8=f[r0]===void 0?C0:f[r0],k8=B0.some((P8)=>L[P8]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":F8,onClick:()=>m((P8)=>({...P8,[r0]:!F8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:F8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${k8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!k8,onClick:()=>B0.forEach((P8)=>{if(L[P8])g(P8)}),children:z(C9,{as:RG,size:12})})]}),z("div",{className:`st-cp-sec-anim${F8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:q0})})]},r0)},L0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!i[t],"aria-label":i[t]?`${t} — fewer options`:`${t} — more options`,title:i[t]?"fewer":"more",onClick:()=>a((B0)=>({...B0,[t]:!B0[t]})),children:i[t]?"▴":"···"}),N0=(t,B0)=>_("select",{className:"st-cp-nsel","aria-label":t,value:B0.includes(L[t])?L[t]:"",onChange:(q0)=>c(t,q0.target.value),children:[z("option",{value:"",disabled:!0,children:S9(K[t])||"—"}),B0.map((q0)=>z("option",{value:q0,children:q0},q0))]}),t0=(t)=>S(t).flatMap((B0)=>(B0.names||[]).map((q0)=>({name:q0,value:B0.vals?.[q0]||""}))),$8=(t,B0)=>z(_w,{value:L[t]||S9(K[t])||B0[0].value,ariaLabel:t,options:B0,onChange:(q0)=>c(t,q0)}),y0=(t,B0,q0={})=>{let C0=JQ(L[t]??""),r0=as.has(t),F8=L[t]??"",k8=typeof F8==="string"&&/var\(\s*--/.test(F8),P8=r0?"":C0.unit&&C0.unit!=="auto"?C0.unit:"px",f8=Number.parseFloat(JQ(S9(K[t])??"").n)||0,U9=C0.n!==""&&C0.n!=null?Number.parseFloat(C0.n)||0:f8,b9=wP[t];return z(JB,{value:k8?F8:U9,tokens:t0(B0),ariaLabel:t,min:q0.min??0,lead:b9?b9.node??b9.t:void 0,unitSlot:r0?null:z(e2,{units:rs,value:C0.unit||"px",ariaLabel:`${t} unit`,onChange:(D9)=>c(t,D9==="auto"?"auto":`${C0.n||"0"}${D9}`)}),onChange:(D9)=>c(t,typeof D9==="string"?D9:r0?`${D9}`:`${D9}${P8}`)})},v0=()=>{let t=(r0)=>Number.parseFloat(JQ(L[r0]??L["border-radius"]??S9(K[r0])??S9(K["border-radius"])??"0").n)||0,B0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},q0=(r0)=>{if(r0.tl===r0.tr&&r0.tr===r0.bl&&r0.bl===r0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((k8)=>{if(L[k8])g(k8)}),c("border-radius",`${r0.tl}px`);else c("border-top-left-radius",`${r0.tl}px`),c("border-top-right-radius",`${r0.tr}px`),c("border-bottom-left-radius",`${r0.bl}px`),c("border-bottom-right-radius",`${r0.br}px`)},C0=wP["border-radius"];return z(rf,{corners:B0,lead:C0?C0.node??C0.t:void 0,onCorners:q0})},O0=()=>_("div",{className:"st-cp-border",children:[_9("border-width",null,{fixedUnit:"px"}),_("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:ns.includes(L["border-style"])?L["border-style"]:"",onChange:(t)=>c("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),ns.map((t)=>z("option",{value:t,children:t},t))]}),z(KF,{kind:"color",groups:S("color"),current:L["border-color"],activeDs:T,swatchBg:K["border-color"]||L["border-color"]||"",seedHex:UF(K["border-color"]||L["border-color"])||"#000000",onPick:(t)=>c("border-color",t),label:"border colour"})]}),n0=()=>{let t=L.transform||S9(K.transform)||"",B0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),q0=((B0?Number.parseFloat(B0[1]):0)%360+360)%360,C0=(r0)=>{let F8=(r0%360+360)%360,k8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${k8?`${k8} `:""}rotate(${F8}deg)`.trim())};return _("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(of,{value:q0,onChange:C0}),z(Q5,{value:q0,min:0,max:360,ariaLabel:"rotation",lead:z(C9,{as:RG}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:C0})]})},Q8=()=>{let t=L.filter||S9(K.filter)||"",B0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),q0=B0?Number.parseFloat(B0[1]):0;return z(Q5,{value:q0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(r0)=>{let F8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",r0>0?`${F8?`${F8} `:""}blur(${r0}px)`.trim():F8||"none")}})},w0=()=>{let t=L.opacity,B0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(S9(K.opacity))||1,q0=Math.round((Number.isNaN(B0)?1:B0)*100);return z(a5,{value:q0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(C0)=>s("opacity",String(C0/100)),onCommit:(C0)=>c("opacity",String(C0/100))},`opacity:${t??""}`)},i0=()=>{let t=Number.parseInt(L["font-weight"]||S9(K["font-weight"])||"400",10)>=600,B0=(L["font-style"]||S9(K["font-style"]))==="italic",q0=/underline/.test(L["text-decoration"]||S9(K["text-decoration"])||"");return z(pf,{value:{b:t,i:B0,u:q0},ariaLabel:"text style",options:[{value:"b",node:z(C9,{as:KU}),label:"Bold"},{value:"i",node:z(C9,{as:FU}),label:"Italic"},{value:"u",node:z(C9,{as:EU}),label:"Underline"}],onToggle:(C0)=>{if(C0==="b")c("font-weight",t?"400":"700");else if(C0==="i")c("font-style",B0?"normal":"italic");else c("text-decoration",q0?"none":"underline")}})},H9=[{value:"row",node:z(C9,{as:v4}),label:"Row"},{value:"column",node:z(C9,{as:x4}),label:"Column"}],u8=[{value:"flex-start",node:z(C9,{as:GU}),label:"Start"},{value:"center",node:z(C9,{as:YU}),label:"Center"},{value:"flex-end",node:z(C9,{as:WU}),label:"End"},{value:"space-between",node:z(C9,{as:tH}),label:"Space between"}],R6=[{value:"flex-start",node:z(C9,{as:qU}),label:"Start"},{value:"center",node:z(C9,{as:ZU}),label:"Center"},{value:"flex-end",node:z(C9,{as:HU}),label:"End"},{value:"stretch",node:z(C9,{as:_U}),label:"Stretch"}],o9=[{value:"left",node:z(C9,{as:J5}),label:"Left"},{value:"center",node:z(C9,{as:g4}),label:"Center"},{value:"right",node:z(C9,{as:m4}),label:"Right"},{value:"justify",node:z(C9,{as:u4}),label:"Justify"}],d7=[{value:"visible",node:z(C9,{as:PG}),label:"Visible"},{value:"hidden",node:z(C9,{as:MU}),label:"Hidden"},{value:"scroll",node:z(C9,{as:OU}),label:"Scroll"}],k6=(t,B0)=>{let q0=S(B0);return q0.length?z(KF,{kind:"value",groups:q0,current:L[t],activeDs:T,onPick:(C0)=>c(t,C0),label:`${t} design token`}):null},F7=(t)=>{let B0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===B0)B0.select()})},fJ=(t,B0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let q0=t.shiftKey?10:1,C0=t.key==="ArrowUp"?1:-1,r0=(Number.parseFloat(t.currentTarget.value)||0)+C0*q0;return t.currentTarget.value=String(r0),B0(r0),!0},l9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:L[t]??"",placeholder:S9(K[t])||"—",onFocus:F7,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>c(t,B0.currentTarget.value)},`${t}:${L[t]??""}`),_9=(t,B0,q0={})=>{let C0=JQ(L[t]??""),r0=as.has(t),F8=r0?"":q0.fixedUnit||(C0.unit&&C0.unit!=="auto"?C0.unit:"px"),k8=wP[t],P8=Number.parseFloat(JQ(S9(K[t])??"").n)||0,f8=C0.n!==""&&C0.n!=null?Number.parseFloat(C0.n)||0:P8;return _(W0,{children:[z(Q5,{value:f8,min:q0.min??0,step:1,ariaLabel:t,lead:k8?k8.node??k8.t:void 0,onCommit:(U9)=>c(t,r0?`${U9}`:`${U9}${F8}`),unitSlot:r0||q0.fixedUnit?null:z(e2,{units:rs,value:C0.unit||"px",ariaLabel:`${t} unit`,onChange:(U9)=>c(t,U9==="auto"?"auto":`${C0.n||"0"}${U9}`)})},`${t}:${L[t]??""}`),k6(t,B0)]})},s7=(t)=>{let B0=K[t]||L[t]||"",q0=L[t]??"",C0=typeof q0==="string"&&/var\(\s*--/.test(q0),r0=C0?q0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):q0;return z(RU,{swatch:z(KF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:S("color"),current:L[t],activeDs:T,swatchBg:B0,seedHex:UF(K[t]||L[t])||"#000000",onPick:(F8)=>c(t,F8),label:`${t} colour`}),displayValue:r0,bound:C0,ariaLabel:t,onValue:(F8)=>c(t,F8)})},q9=(t,B0)=>{let q0=null,C0=B0.unitless?"":"px",r0=(P8)=>B0.unitless?`${P8}`:`${P8}${C0}`,F8=(P8,f8,U9)=>{for(let b9 of f8??[t])U9(b9,r0(P8))},k8=Aw({getBase:()=>q0?.value??"0",min:B0.min??0,step:1,sides:B0.sides,onInput:(P8,f8)=>{if(q0)q0.value=String(P8);if(f8){let U9=q0?.closest(".st-cp-box");for(let b9 of f8){if(b9===t)continue;let D9=U9?.querySelector(`.st-cp-boxv[aria-label="${b9}"]`);if(D9)D9.value=String(P8)}}F8(P8,f8,s)},onCommit:(P8,f8)=>F8(P8,f8,c)});return{onPointerDown:(P8)=>{q0=P8.currentTarget,k8(P8)}}},w9=(t,B0)=>{let q0=L[t],C0=q0!=null&&q0!==""?JQ(q0).n||q0:JQ(S9(K[t])??"").n||"0",r0=!q0||q0==="0"||q0==="0px"||q0==="auto",F8=t.split("-").pop(),k8=F8==="top"||F8==="bottom"?[`${B0}-top`,`${B0}-bottom`]:[`${B0}-left`,`${B0}-right`],P8=[`${B0}-top`,`${B0}-right`,`${B0}-bottom`,`${B0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${B0[0]}${t.split("-").pop()[0]}${r0?" is-zero":""}`,"aria-label":t,defaultValue:C0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...q9(t,{sides:{pair:k8,all:P8}}),onFocus:F7,onKeyDown:(f8)=>{if(fJ(f8,(U9)=>c(t,`${U9}px`)))return;if(f8.key==="Enter")f8.currentTarget.blur()},onBlur:(f8)=>{let U9=f8.currentTarget.value.trim();if(!U9)return;let b9=/[a-z%]/i.test(U9)?U9:`${U9}px`;c(t,b9)}},`${t}:${q0??""}`)},H7=(t)=>{let B0=L[t],q0=B0!=null&&B0!==""&&B0!=="auto"?JQ(B0).n||B0:JQ(S9(K[t])??"").n||"",C0=!B0||B0==="auto"||B0==="0"||B0==="0px",r0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],F8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${C0?" is-zero":""}`,"aria-label":t,defaultValue:q0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...q9(t,{sides:{pair:r0,all:F8},min:-1/0}),onFocus:F7,onKeyDown:(k8)=>{if(fJ(k8,(P8)=>c(t,`${P8}px`)))return;if(k8.key==="Enter")k8.currentTarget.blur()},onBlur:(k8)=>{let P8=k8.currentTarget.value.trim();if(!P8)return;let f8=/[a-z%]/i.test(P8)?P8:`${P8}px`;c(t,f8)}},`${t}:${B0??""}`)},N7=Object.entries(M),n9=Object.entries(w),WX=()=>{let t=(X.tag||"").toLowerCase(),q0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],C0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:q0,canReplace:C0}},I7=(t)=>_(W0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),j0("object-fit",N0("object-fit",SV0)),j0("object-position",l9("object-position")),j0("aspect-ratio",_("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:Jt.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(B0)=>{let q0=B0.target.value;if(c("aspect-ratio",q0),q0&&q0!=="auto"&&L.height)g("height")},children:[z("option",{value:"",disabled:!0,children:S9(K["aspect-ratio"])||"—"}),Jt.map((B0)=>z("option",{value:B0,children:B0},B0))]}))]});return _("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Z9,children:[_("div",{className:"st-cp-id",children:[_("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?_("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(_w,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(C9,{as:f4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(C9,{as:l4,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?_(W0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(L.display||S9(K.display)||"").trim();return t==="flex"||t==="inline-flex"?_(W0,{children:[j0("flex-direction",$8("flex-direction",H9),void 0,"Direction"),j0("align-items",z(cf,{value:_8(),onChange:G9,ariaLabel:"auto-layout alignment"}),e0("align-items"),"Alignment"),j0("gap",y0("gap","space"),void 0,"Gap"),_("div",{className:"st-cp-modes",children:[s0("width"),s0("height")]}),_("div",{className:"st-cp-box","aria-label":"padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(e0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:L0("Auto layout")}),i["Auto layout"]?j0("flex-wrap",z(i4,{checked:/^wrap/.test(L["flex-wrap"]||S9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(q0)=>c("flex-wrap",q0?"wrap":"nowrap")}),e0("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],_(W0,{children:[j0("width",_9("width"),void 0,"Width"),j0("height",_9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:L0("Size")}),i.Size?_(W0,{children:[j0("min-width",_9("min-width"),void 0,"Min width"),j0("max-width",_9("max-width"),void 0,"Max width"),j0("min-height",_9("min-height"),void 0,"Min height"),j0("max-height",_9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],_(W0,{children:[j0("position",N0("position",ss),void 0,"Position"),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(e0("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||S9(K.position)||"static"})]}),(L.position||S9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:L0("Position")}),i.Position?j0("z-index",_9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],j0("background-color",s7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],j0("border",O0(),e0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],j0("border-radius",v0(),e0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],_(W0,{children:[j0("box-shadow",k6("box-shadow","shadow")||l9("box-shadow"),void 0,"Shadow"),j0("filter",Q8(),e0("filter"),"Blur"),j0("mix-blend-mode",N0("mix-blend-mode",Xt),void 0,"Blend")]})),H0("Opacity",["opacity"],j0("opacity",w0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],_(W0,{children:[j0("font-family",N0("font-family",os),void 0,"Font"),j0("color",s7("color"),void 0,"Color"),j0("font-size",y0("font-size","type"),void 0,"Size"),j0("font-weight",N0("font-weight",is),void 0,"Weight"),j0("line-height",_9("line-height","lh"),void 0,"Line height"),j0("text-align",$8("text-align",o9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:L0("Text")}),i.Text?_(W0,{children:[j0("letter-spacing",_9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),j0("font-style",N0("font-style",CV0),void 0,"Style"),j0("text-transform",N0("text-transform",ts),void 0,"Case"),j0("white-space",N0("white-space",es),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],_("div",{className:"st-cp-box","aria-label":"margin",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(e0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:B0}=WX();return t?H0("Media",["object-fit","object-position","aspect-ratio"],I7(B0)):null})()]}):_(W0,{children:[k0("Layout",(()=>{let t=(L.display||S9(K.display)||"").trim(),B0=t==="flex"||t==="inline-flex",q0=t==="grid"||t==="inline-grid";return _(W0,{children:[j0("display",N0("display",TV0)),B0?_(W0,{children:[j0("flex-direction",$8("flex-direction",H9)),j0("flex-wrap",z(i4,{checked:/^wrap/.test(L["flex-wrap"]||S9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(C0)=>c("flex-wrap",C0?"wrap":"nowrap")}),e0("flex-wrap"))]}):null,B0||q0?_(W0,{children:[j0("align-items",$8("align-items",R6)),j0("justify-content",$8("justify-content",u8)),j0("gap",y0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(L.display||S9(K.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let q0=L["grid-template-columns"]||"",C0=L["grid-template-rows"]||"",r0=_D(q0),F8=_D(C0),k8=r0.length>0||!q0.trim(),P8=F8.length>0||!C0.trim();return k0("Grid",_(W0,{children:[k8?z(Yt,{label:"Columns",tracks:r0,editable:q,onChange:(f8)=>c("grid-template-columns",ED(f8))}):_("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:q0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),P8?z(Yt,{label:"Rows",tracks:F8,editable:q,onChange:(f8)=>c("grid-template-rows",ED(f8))}):_("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:C0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),k0("Position",_(W0,{children:[j0("position",N0("position",ss)),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(e0("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||S9(K.position)||"static"})]}),(L.position||S9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,j0("z-index",_9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&k0("Grid item",_(W0,{children:[_("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),j0("grid-column",l9("grid-column")),j0("grid-row",l9("grid-row"))]})),k0("Typography",_(W0,{children:[j0("font-family",N0("font-family",os)),j0("color",s7("color")),j0("font-size",y0("font-size","type")),j0("font-weight",N0("font-weight",is)),j0("line-height",_9("line-height","lh")),j0("letter-spacing",_9("letter-spacing",null,{min:-1/0})),j0("text-align",$8("text-align",o9)),j0("font-style",i0(),e0("font-style")),j0("text-transform",N0("text-transform",ts)),j0("white-space",N0("white-space",es))]})),k0("Spacing",z(W0,{children:_("div",{className:"st-cp-box","aria-label":"margin and padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(e0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin"),_("div",{className:"st-cp-boxpad",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(e0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding"),_("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)]})]})]})})),k0("Size",_(W0,{children:[_("div",{className:"st-cp-modes",children:[s0("width"),s0("height")]}),j0("width",_9("width")),j0("height",_9("height")),j0("min-width",_9("min-width")),j0("max-width",_9("max-width")),j0("min-height",_9("min-height")),j0("max-height",_9("max-height")),j0("overflow",$8("overflow",d7)),G8?_(W0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),j0("align-self",N0("align-self",IV0)),j0("flex-grow",_9("flex-grow",null,{unitless:!0})),j0("flex-shrink",_9("flex-shrink",null,{unitless:!0})),j0("flex-basis",_9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:B0}=WX();return t?k0("Media",I7(B0)):null})(),k0("Appearance",_(W0,{children:[j0("background-color",s7("background-color")),j0("border-radius",v0(),e0("border-radius")),j0("border",O0(),e0("border-width")),j0("box-shadow",k6("box-shadow","shadow")||l9("box-shadow")),j0("filter",Q8(),e0("filter")),j0("mix-blend-mode",N0("mix-blend-mode",Xt)),j0("opacity",w0()),j0("rotation",n0(),e0("transform")),j0("transform",l9("transform")),j0("transform-origin",l9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,B0])=>typeof B0==="string"&&B0.startsWith("err:"));return t?_("div",{className:"st-cp-save is-err",role:"status",children:[z(s8,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),k0("Advanced",_("div",{className:"st-cp-advbody",children:[N7.length?_(W0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),N7.map(([t,B0])=>_("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${t} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>V0(t,q0.currentTarget.value)},`cs:${t}:${B0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>d(t),children:z(s8,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(jV0,{commit:V0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),n9.length?_(W0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),n9.map(([t,B0])=>_("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${t} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>p(t,q0.currentTarget.value)},`at:${t}:${B0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>K0(t),children:z(s8,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(yV0,{commit:p})]}))]}),_("div",{className:"st-cp-legend",children:[_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function jV0({commit:X}){let[J,Q]=l.useState(""),[Y,W]=l.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function yV0({commit:X}){let[J,Q]=l.useState(""),[Y,W]=l.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var fV0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function vV0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===J)return G=q[K],q.splice(K,1),!0;if(q[K].children&&Z(q[K].children))return!0}return!1};if(Z(W),!G)return X;let H=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===Q){if(Y==="inside-start"||Y==="inside-end")if(q[K].children=q[K].children||[],Y==="inside-start")q[K].children.unshift(G);else q[K].children.push(G);else q.splice(Y==="before"?K:K+1,0,G);return!0}if(q[K].children&&H(q[K].children))return!0}return!1};return H(W)?W:X}var xV0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Ft({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:M,onToggleLock:w,onRename:R}){let A=`${X.id}:${X.index}`,D=X.children&&X.children.length>0,P=W.has(A),T=!!X.synthetic,I=!T&&L?L[X.id]:null,S=!T&&!!M?.has(A),[C,j]=l.useState(!1),[f,m]=l.useState(""),o=!T&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(A)?G.get(A):!!X.hidden,x=!!V&&!T&&!S,i=()=>{j(!1);let s=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},a=F?.key===A,h=a?{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 _(W0,{children:[_("div",{className:"st-layer st-layer--row"+(o?" is-sel":"")+(n?" is-hidden":"")+(T?" is-group":"")+(I?" is-instance":"")+(S?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:o,"aria-expanded":D?!P:void 0,"aria-grabbed":x?a:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":A,onClick:()=>T?D&&Z(A):H(X),onMouseEnter:()=>!T&&q(X),onMouseLeave:()=>q(null),onPointerDown:x?(s)=>B(s,X,A):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)D&&Z(A);else H(X);else if(s.key==="F2"&&R&&!T)s.preventDefault(),m(X.dcElement||X.label||""),j(!0)},children:[D?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(A)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),I?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:I.root?"◆":"◇"}):z(s8,{name:fV0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>m(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:i,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")i();else if(s.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!T?(s)=>{s.stopPropagation(),m(X.dcElement||X.label||""),j(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:I?I.component:X.type}),w&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":S?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":S,title:S?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),w(A)},children:z(s8,{name:S?"lock":"unlock",size:12})}):null,K&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),K(X)},children:z(s8,{name:n?"eye-off":"eye",size:13})}):null]}),D&&!P?X.children.map((s,X0)=>z(Ft,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:M,onToggleLock:w,onRename:R},`${s.id}:${s.index}`)):null]})}function hV0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(K)=>{let V=Q[K];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return J[K]||V||""},W=(K,V)=>{let B=J[V]||Q[V];if(!B)return null;return _("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:K}),_("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},K)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?JQ(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 _(W0,{children:[G?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Nt(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var gV0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],mV0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function uV0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let q=Nt(X),K=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=Ut(X.file,J),B=Vt(J,K,V),F=(a)=>B.map((h)=>({ds:h.name,names:h[a]||[],vals:h.vals})).filter((h)=>h.names.length),L=(a)=>F(a).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),M=(a)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(a||"");if(!h)return a||"";for(let s of B){let X0=s.vals?.[h[1]];if(X0)return X0}return""},w=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,A=(a,h)=>{if(!q)return;let s=Number.isFinite(a)&&a>0?Math.round(a):void 0,X0=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&X0==null)return;Q?.(q,s,X0)},D=Object.entries(yJ).find(([,a])=>a.width===w&&a.height===R)?.[0],P=Object.entries(yJ).find(([,a])=>a.width===w)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",I=X.attrs?.["data-dc-bg"]??"",S=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",j=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",m=null;try{m=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let o=(a)=>{if(!q)return;let h=null;if(a==="print"&&!m){let s={paper:"a4"};try{let X0=U3(s);if(X0)h={defaults:s,widthPx:X0.widthPx,heightPx:X0.heightPx}}catch{}}if(G?.(q,a==="digital"?null:a,h),a==="web"&&T)Y?.(q,!1,void 0)},n=(a)=>{if(!q)return;let h={paper:"a4",...m,...a},s;try{s=U3(h)}catch{return}Q?.(q,s.widthPx,s.heightPx),Z?.(q,h)},x=(a)=>{if(!q)return;let h=a&&Number.isFinite(R)?Math.round(R):void 0;Y?.(q,a,h)},i=(a)=>{if(!q)return;W?.(q,a)};return _("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),_("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(Q5,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(a)=>A(a,null)}),z(Q5,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(a)=>{if(T)A(null,a)}})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?_("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(a)=>n({paper:a.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),K3.map((a)=>_("option",{value:a.id,children:[a.label," — ",a.width,"×",a.height,a.unit]},a.id))]}):f==="web"?_("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)A(h.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${yJ[P].label} — ≤ ${yJ[P].width}px`:"Breakpoint…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ≤ ",h.width,"px breakpoint"]},a))]}):_("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:D??"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)A(h.width,h.height)},children:[z("option",{value:"",disabled:!0,children:D?yJ[D].label:"Preset size…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ",h.width,"×",h.height]},a))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(XB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(a)=>x(a==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(c4,{value:f,ariaLabel:"artboard kind",options:mV0.map(([a,h])=>({value:a,label:h})),onChange:o})}),f!=="print"&&q&&H?z("div",{style:{padding:"0 12px 8px"},children:_("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)H(q,h.width);a.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ",h.width,"px"]},a))]})}):null,f==="print"?_(W0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(XB,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(a)=>n({orientation:a})})}),z("div",{style:{padding:"0 12px 8px"},children:z(Q5,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(a)=>n({bleedMm:a})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),_("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let a=M(I),h=/var\(\s*--/.test(I),s=h?I.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):I;return z(RU,{swatch:z(KF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:I,activeDs:V,swatchBg:a,seedHex:UF(a)||"#000000",onPick:(X0)=>i({background:X0||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(X0)=>i({background:(X0||"").trim()||null})})})(),z(c4,{value:C,ariaLabel:"artboard body layout",options:gV0.map(([a,h])=>({value:a,label:h})),onChange:(a)=>i({layout:a||null})}),_("div",{style:{display:"flex",gap:8},children:[z(JB,{value:/^var\(/.test(S)?S:Number.parseFloat(S)||0,tokens:L("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(a)=>i({padding:typeof a==="string"?a:a>0?a:null})}),z(JB,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:L("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(a)=>i({gap:typeof a==="string"?a:a>0?a:null})})]})]})]})}var PP=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,lV0=new RegExp(PP.source,"gi");function dV0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(lV0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=PP.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function pV0({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:q,onHoverLayer:K,onReorderLayer:V,layersBusyRef:B,cfg:F,onOptimistic:L,onRecordEdit:M,onReplaceMedia:w,onResizeArtboard:R,onSetArtboardHug:A,onSetArtboardStyle:D,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I,onUndoRedo:S,editScope:C,tab:j,onTabChange:f,width:m,resizing:o,photoSel:n,photoRev:x,onPhotoEdit:i,onPhotoRemoveBackground:a,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:X0=!1,hideLayersTab:c=!1,cpMode:V0,onSetCpMode:p}){let[g,d]=l.useState("inspect"),K0=X0?"layers":j??g,u0=(O0)=>{d(O0),f?.(O0)},[J8,G8]=l.useState(()=>new Set),[s0,D8]=l.useState(()=>new Map);l.useEffect(()=>{let O0=Array.isArray(X)?X[0]:X,n0=O0?.id;if(!n0||!Q?.nodes)return;let Q8=O0.index,w0=null,i0=[];if(function H9(u8,R6){for(let o9 of u8||[]){let d7=`${o9.id}:${o9.index}`;if(!o9.synthetic&&o9.id===n0&&(Q8==null||o9.index===Q8))return w0=d7,i0.push(...R6),!0;if(o9.children&&o9.children.length&&H9(o9.children,[...R6,d7]))return!0}return!1}(Q.nodes,[]),!w0)return;if(i0.length)G8((H9)=>{let u8=!1,R6=new Set(H9);for(let o9 of i0)if(R6.delete(o9))u8=!0;return u8?R6:H9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${w0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let U8=(O0)=>{let n0=`${O0.id}:${O0.index}`;return s0.has(n0)?s0.get(n0):!!O0.hidden},[q8,m8]=l.useState(null),[_8,G9]=l.useState(""),Z9=(O0,n0)=>{if(!H||!O0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:O0.id,attr:"data-dc-element",value:n0})}).then((Q8)=>Q8.json().catch(()=>({}))).then((Q8)=>{if(!Q8.ok)return;M?.({op:"attr",canvas:H,id:O0.id,key:"data-dc-element",before:O0.dcElement??null,after:n0})}).catch(()=>{})},e0=V?(O0,n0,Q8)=>{if(B?.current)return;if(O0?.synthetic||n0?.synthetic)return;let w0=Q8==="before"?`before ${n0.label}`:Q8==="after"?`after ${n0.label}`:`into ${n0.label}`;G9(`Moved ${O0.label} ${w0}`),V(O0.id,n0.id,Q8,{idIndex:O0.index,refIndex:n0.index})}:void 0,p8=()=>{let O0=[];return function n0(Q8,w0,i0){(Q8||[]).forEach((H9,u8)=>{if(O0.push({node:H9,depth:w0,parentNode:i0,siblings:Q8,pos:u8}),H9.children&&H9.children.length&&!J8.has(`${H9.id}:${H9.index}`))n0(H9.children,w0+1,H9)})}(Q?.nodes,0,null),O0},o8=(O0)=>{if(O0.key!=="ArrowUp"&&O0.key!=="ArrowDown")return;if(!H0)return;let n0=p8(),Q8=n0.findIndex((u8)=>u8.node.id===H0.id&&u8.node.index===H0.index);if(Q8<0)return;let w0=O0.key==="ArrowDown"?1:-1,i0=n0[Q8];if(!O0.altKey){let u8=n0[Q8+w0];if(u8)O0.preventDefault(),q?.(u8.node);return}if(!e0||!Array.isArray(i0.siblings))return;O0.preventDefault();let H9=(u8)=>u8&&u8.children&&u8.children.length&&!J8.has(`${u8.id}:${u8.index}`);if(!O0.shiftKey){if(w0<0&&i0.pos>0)e0(i0.node,i0.siblings[i0.pos-1],"before");else if(w0>0&&i0.pos<i0.siblings.length-1)e0(i0.node,i0.siblings[i0.pos+1],"after");return}if(w0>0){let u8=i0.siblings[i0.pos+1];if(u8)e0(i0.node,u8,H9(u8)?"inside-start":"after");else if(i0.parentNode)e0(i0.node,i0.parentNode,"after")}else{let u8=i0.siblings[i0.pos-1];if(u8)e0(i0.node,u8,H9(u8)?"inside-end":"before");else if(i0.parentNode)e0(i0.node,i0.parentNode,"before")}},$9=l.useRef(null),j0=l.useRef(null),F0=(O0,n0,Q8)=>{if(!e0||O0.button!==0||O0.metaKey||O0.ctrlKey||O0.shiftKey||O0.altKey)return;if(B?.current)return;let{clientX:w0,clientY:i0}=O0,H9=new Set([Q8]);(function q9(w9){(w9.children||[]).forEach((H7)=>{H9.add(`${H7.id}:${H7.index}`),q9(H7)})})(n0);let u8=14,R6=6,o9=[];(function q9(w9,H7){(w9||[]).forEach((N7)=>{let n9=`${N7.id}:${N7.index}`;if(o9.push({node:N7,key:n9,id:N7.id,depth:H7,tag:N7.tag}),N7.children&&N7.children.length&&!J8.has(n9))q9(N7.children,H7+1)})})(Q?.nodes,0);let d7=new Map(o9.map((q9)=>[q9.key,q9])),k6=!1,F7=(q9)=>{if(!k6){if(Math.hypot(q9.clientX-w0,q9.clientY-i0)<4)return;k6=!0}let w9=q9.clientX-w0,H7=q9.clientY-i0,N7=null,n9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((I7)=>({rect:I7.getBoundingClientRect(),it:d7.get(I7.getAttribute("data-layer-key"))})).filter((I7)=>I7.it&&I7.it.key!==Q8);if(n9.length){let I7=n9[0].rect.left,t=n9[0].rect.right,B0=n9.length;for(let D9=0;D9<n9.length;D9++)if(q9.clientY<n9[D9].rect.top+n9[D9].rect.height/2){B0=D9;break}let q0=n9[B0-1]?.it||null,C0=n9[B0]?.it||null,r0=Math.round((q9.clientX-I7-R6)/u8),F8=q0?q0.depth+(xV0.has(q0.tag)?0:1):0,k8=C0?C0.depth:0,P8=Math.max(k8,Math.min(r0,F8)),f8=null,U9="before",b9=0;if(!q0){if(C0)f8=C0,U9="before",b9=C0.depth}else if(P8>q0.depth)f8=q0,U9="inside-start",b9=q0.depth+1;else if(P8===q0.depth)f8=q0,U9="after",b9=q0.depth;else{for(let D9=B0-1;D9>=0;D9--)if(n9[D9].it.depth===P8){f8=n9[D9].it;break}if(!f8)f8=q0;U9="after",b9=P8}if(f8&&f8.key!==Q8&&!H9.has(f8.key)){let D9=q0?n9[B0-1].rect.bottom:n9[0].rect.top,vJ=I7+R6+b9*u8;N7={refId:f8.id,position:U9,node:f8.node,y:D9,left:vJ,w:Math.max(24,t-vJ)}}}let WX={key:Q8,node:n0,dx:w9,dy:H7,target:N7};$9.current=WX,m8(WX)},fJ=()=>{window.removeEventListener("pointermove",F7),window.removeEventListener("pointerup",_9),window.removeEventListener("keydown",s7,!0)},l9=()=>{let q9=(w9)=>{w9.preventDefault(),w9.stopImmediatePropagation(),document.removeEventListener("click",q9,!0)};document.addEventListener("click",q9,!0),setTimeout(()=>document.removeEventListener("click",q9,!0),300)},_9=()=>{fJ();let q9=$9.current;if($9.current=null,m8(null),k6&&q9?.target)l9(),e0(q9.node,q9.target.node,q9.target.position)},s7=(q9)=>{if(q9.key!=="Escape")return;if(q9.preventDefault(),q9.stopImmediatePropagation(),fJ(),$9.current=null,m8(null),k6)l9()};window.addEventListener("pointermove",F7),window.addEventListener("pointerup",_9),window.addEventListener("keydown",s7,!0)},U0=(O0)=>G8((n0)=>{let Q8=new Set(n0);if(Q8.has(O0))Q8.delete(O0);else Q8.add(O0);return Q8}),k0=(O0)=>{let n0=`${O0.id}:${O0.index}`,Q8=U8(O0),w0=!Q8;if(D8((i0)=>new Map(i0).set(n0,w0)),L?.({id:O0.id,artboardId:Q?.artboardId??null,index:O0.index,prop:"display",value:w0?"none":null}),!H||!O0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w0?{canvas:H,id:O0.id,property:"display",value:"none"}:{canvas:H,id:O0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:O0.id,key:"display",before:Q8?"none":null,after:w0?"none":null})},H0=Array.isArray(X)?X[0]:X,L0=n?{asset:n.asset,kind:"annotation-image"}:(()=>{let O0=dV0(H0);return O0?{asset:O0,kind:"artboard-img"}:null})(),N0=L0?.kind==="annotation-image",t0=(O0)=>{if(!(O0.metaKey||O0.ctrlKey)||O0.altKey)return;let n0=O0.key.toLowerCase();if(n0==="z")O0.preventDefault(),s?.(O0.shiftKey?"redo":"undo");else if(n0==="y")O0.preventDefault(),s?.("redo")},$8=N0?"photo":K0==="photo"&&!L0?"inspect":K0,y0=(O0,n0,Q8)=>_("button",{type:"button",className:"st-rp-tab"+($8===O0?" is-active":""),onClick:()=>u0(O0),children:[z(s8,{name:Q8,size:14}),n0]}),v0=H0?.bounds||null;return _("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:m?{width:m,flexBasis:m}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[_("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:X0?{display:"none"}:void 0,children:[N0?y0("photo","Photo","image"):_(W0,{children:[y0("inspect","Inspect","sliders"),!c&&y0("layers","Layers","layers"),y0("css","CSS","code"),L0?y0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:z(s8,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&C?_("div",{className:`st-scope st-scope--${C.scope}`,title:C.scope==="shared"?`Editing this element's style changes ${C.affects} place${C.affects===1?"":"s"}${C.componentName?` (component ${C.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),C.scope==="shared"?`Shared${C.componentName?` · ${C.componentName}`:""} · edits ${C.affects} place${C.affects===1?"":"s"}`:"Local · this element only",C.scope==="shared"&&Z?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:$8==="photo"&&L0?z("div",{onKeyDown:t0,children:z(sf,{asset:L0.asset,ColorPicker:Bt,StIcon:s8,onEdit:(O0)=>i?.(L0.asset,O0),onRemoveBackground:a,onRecordEdit:(O0,n0)=>h?.(L0.asset,O0,n0)},`${L0.asset}:${x??0}`)}):!H0&&!($8==="layers"&&Q?.nodes?.length)?z("div",{className:"st-rp-empty",children:_("p",{children:["Press ",z(l6,{children:"V"}),", then click an element to select it — or ",z(l6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&$8==="inspect"?_(W0,{children:[z("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:v0?Math.round(v0.x):"—",readOnly:!0,"aria-label":"x position"})]}),_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:v0?Math.round(v0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:v0?Math.round(v0.w):"—",readOnly:!0,"aria-label":"width"})]}),_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:v0?Math.round(v0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H0.tag||"—"})})]}),H0.classes?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:H0.classes})})]}):null,z(hV0,{el:H0})]}):$8==="layers"?_(W0,{children:[_("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?_(W0,{children:[e0?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:j0,onKeyDown:o8,children:Q.nodes.map((O0,n0)=>z(Ft,{node:O0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:s0,onToggle:U0,onSelect:(Q8)=>{q?.(Q8),j0.current?.focus()},onHover:(Q8)=>K?.(Q8),onToggleVisibility:k0,onReorder:e0,onRowPointerDown:F0,dragState:q8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:Z9},`${O0.id}:${O0.index}`))}),q8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:q8.target.left,top:q8.target.y-1,width:q8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:_8})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((O0,n0)=>_("div",{className:"st-layer"+(n0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+n0*12},children:[z(s8,{name:"square",size:13}),O0]},n0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&Nt(H0)?z(uV0,{el:H0,cfg:F,onResizeArtboard:R,onSetArtboardHug:A,onSetArtboardStyle:D,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I}):z(bV0,{el:H0,cfg:F,onOptimistic:L,onRecordEdit:M,onReplaceMedia:w,onUndoRedo:S,mode:V0,onSetMode:p})})]})}function cV0(){let[X,J]=l.useState([]),[Q,Y]=l.useState("Design"),[W,G]=l.useState([]),[Z,H]=l.useState(null),[q,K]=l.useState(null),V=l.useRef(null);l.useEffect(()=>{V.current=q},[q]);let[B,F]=l.useState(null);l.useEffect(()=>{let y=Array.isArray(q)?q.length===1?q[0]:null:q,b=y&&typeof y.id==="string"?y.id:null;if(!b||!Z){F(null);return}let Q0=new AbortController,z0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${z0}`,{signal:Q0.signal}).then((G0)=>G0.ok?G0.json():null).then((G0)=>{if(G0?.ok)F(G0)}).catch(()=>{}),()=>Q0.abort()},[q,Z]);let L=l.useRef(0),M=l.useRef([]),w=l.useCallback((y)=>{if(!y?.id||!y.file)return;for(let b of M.current)clearTimeout(b);M.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let Q0=V.current,z0=Array.isArray(Q0)?Q0[0]:Q0;if(!z0||z0.id!==y.id||z0.file!==y.file)return;let G0=R8.current.get(y.file);if(!G0?.contentWindow)return;try{G0.contentWindow.postMessage({dgn:"select-by-id",id:y.id,artboardId:y.artboardId??null,index:y.index??0},"*")}catch{}},b))},[]),R=l.useRef([]),A=l.useCallback((y,b)=>{if(!y||!b)return;for(let Q0 of R.current)clearTimeout(Q0);R.current=[50,450,1200,2500,5000].map((Q0)=>setTimeout(()=>{let z0=V.current,G0=Array.isArray(z0)?z0[0]:z0;if(!G0||G0.artboardId!==y||G0.file!==b)return;let f0=R8.current.get(b);if(!f0?.contentWindow)return;try{f0.contentWindow.postMessage({dgn:"select-by-id",artboardId:y},"*")}catch{}},Q0))},[]),D=l.useRef(null),P=l.useRef(null),T=l.useRef(null),I=l.useRef(null),S=l.useRef(!1),C=l.useRef(null),[j,f]=l.useState(null),[m,o]=l.useState(null),n=l.useRef({canvas:null,at:0});l.useEffect(()=>{if(!Z||!j)return;let y=Date.now(),b=n.current;if(b.canvas===Z&&y-b.at<1500)return;n.current={canvas:Z,at:y},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((Q0)=>Q0.json()).then((Q0)=>{if(Q0?.ok&&Q0.map&&typeof Q0.map==="object")o(Q0.map);else o(null)}).catch(()=>o(null))},[Z,j]);let[x,i]=l.useState(!1),[a,h]=l.useState(null),[s,X0]=l.useState(null),[c,V0]=l.useState(null),[p,g]=l.useState(null),[d,K0]=l.useState(!1),[u0,J8]=l.useState(null),[G8,s0]=l.useState(""),[D8,U8]=l.useState(null),[q8,m8]=l.useState(null),_8=l.useRef(null),G9=us("maude-sb-w",{min:200,max:420,def:252}),Z9=us("maude-rp-w",{min:260,max:480,def:304}),[e0,p8]=l.useState(null),o8=l.useRef(null);l.useEffect(()=>{if(!e0)return;let y=(Q0)=>{let z0=o8.current?.getBoundingClientRect();if(!z0)return;if(e0==="sb")G9.setW(Q0.clientX-z0.left);else Z9.setW(z0.right-Q0.clientX)},b=()=>p8(null);return window.addEventListener("pointermove",y),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",b)}},[e0,G9.setW,Z9.setW]);let $9=l.useCallback((y)=>{clearTimeout(_8.current),_8.current=setTimeout(()=>{m8((b)=>b===y?null:b)},2500)},[]);l.useEffect(()=>{if(!q8)return;let y=setTimeout(()=>m8(null),15000);return()=>clearTimeout(y)},[q8]);let[j0,F0]=l.useState({designRel:".design"}),U0=l.useCallback(()=>{fetch("/_config").then((y)=>y.json()).then((y)=>{let b=(y.designRoot||".design").replace(/^\/+|\/+$/g,"");F0((Q0)=>({...Q0,designRel:b,tokensCssRel:y.tokensCssRel,designSystems:y.designSystems,canvasOrigin:y.canvasOrigin}))}).catch(()=>{})},[]);l.useEffect(()=>{U0()},[U0]),l.useEffect(()=>{let y=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(y||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{y=!0}},[]),l.useEffect(()=>{let y=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!y&&b)V0(b)}).catch(()=>{}),()=>{y=!0}},[]);let[k0,H0]=l.useState({}),[L0,N0]=l.useState(null),[t0,$8]=l.useState(!1),[y0,v0]=l.useState("open"),[O0,n0]=l.useState(bU0),[Q8,w0]=l.useState(()=>{return LP(Cs,"advanced")==="designer"?"designer":"advanced"});l.useEffect(()=>{try{localStorage.setItem(Cs,JSON.stringify(Q8))}catch{}},[Q8]);let[i0,H9]=l.useState(null),[u8,R6]=l.useState(()=>QZ(Ss,!0)),[o9,d7]=l.useState(()=>QZ(Ts,!1)),[k6,F7]=l.useState(()=>LP(Is,{})),[fJ,l9]=l.useState(!1),[_9,s7]=l.useState(!1),[q9,w9]=l.useState(!1),[H7,N7]=l.useState(!1),[n9,WX]=l.useState(!1),{report:I7}=Hw(K9()),[t,B0]=l.useState(!1),[q0,C0]=l.useState(!1),[r0,F8]=l.useState(null),[k8,P8]=l.useState(!1),[f8,U9]=l.useState(!1),[b9,D9]=l.useState(!1),[vJ,QQ]=l.useState(!1),[T6,BY]=l.useState(()=>LP(ys,Aq)),[GX,FY]=l.useState(()=>{try{let y=localStorage.getItem(fs);if(y==="separate"||y==="in-inspector")return y}catch{}return"separate"}),[wX,w7]=l.useState(!1),[q6,X7]=l.useState([]),[rX,aX]=l.useState(0),[YZ,h9]=l.useState(!1),[YQ,Rq]=l.useState(!1),[L7,WZ]=l.useState(!1),[WQ,A7]=l.useState(1),[GQ,j9]=l.useState(216),[X9,A5]=l.useState(null),[NY,GZ]=l.useState([]),[kq,ZZ]=l.useState([]),[ZQ,HZ]=l.useState(0),I6=l.useMemo(()=>{if(!q6.length)return null;return(q6.find((b)=>b.durationInFrames===ZQ)??q6[0]).id},[q6,ZQ]),sX=l.useRef(null);l.useEffect(()=>{sX.current=I6},[I6]);let ZW=l.useRef(0);l.useEffect(()=>{ZW.current=rX},[rX]);let[d6,Tq]=l.useState(null),Iq=l.useRef(null);l.useEffect(()=>{Iq.current=d6},[d6]);let[AX,HW]=l.useState(!1),[Cq,qZ]=l.useState(!1),[Sq,xJ]=l.useState(!1),hJ=l.useRef(AX);l.useEffect(()=>{if(hJ.current=AX,AX){xJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[AX]);let tX=l.useCallback(()=>{if(!hJ.current||document.hidden)xJ(!0),xs("Claude finished","Your assistant turn is ready in Maude.")},[]),zZ=l.useRef(0),eX=l.useCallback(()=>{if(!hJ.current||document.hidden){xJ(!0);let y=Date.now();if(y-zZ.current<SU0)return;zZ.current=y,xs("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[HQ,_5]=l.useState("inspect"),[$q,LY]=l.useState(null),C6=l.useRef({undo:[],redo:[]}),[qW,bq]=l.useState(0),[XJ,_X]=l.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),C7=l.useRef(XJ);l.useEffect(()=>{C7.current=XJ;try{localStorage.setItem("maude-auto-open-inspector",XJ?"1":"0")}catch{}},[XJ]);let J7=l.useRef(!1);l.useEffect(()=>{J7.current=b9||t0||d||AX},[b9,t0,d,AX]);let qQ=l.useRef({open:{},side:Aq});qQ.current={open:{tree:u8,layers:vJ,inspector:b9,comments:t0,changes:d,assistant:AX},side:T6};let p6=l.useCallback((y,b)=>{if(y==="tree")R6(b);else if(y==="layers")QQ(b);else if(y==="inspector")D9(b);else if(y==="comments")$8(b);else if(y==="changes")K0(b);else if(y==="assistant")HW(b)},[]),zQ=l.useCallback((y)=>qQ.current.side?.[y]||Aq[y],[]),z6=l.useCallback((y)=>{let b=zQ(y);p6(y,!0);for(let Q0 of AP)if(Q0.id!==y&&zQ(Q0.id)===b)p6(Q0.id,!1)},[p6,zQ]),gJ=l.useCallback((y)=>{if(qQ.current.open?.[y])p6(y,!1);else z6(y)},[z6,p6]),S6=z6,K6=gJ,KQ=l.useCallback((y)=>{if(!C7.current)return;if(!y||!y.id)return;if(J7.current)return;S6("inspector"),_5("css")},[S6]),DY=l.useCallback(()=>w7((y)=>!y),[]),$6=Vv(EP),MY=Jv(),[jq,mJ]=l.useState(!1),[KZ,OY]=l.useState(!1);l.useEffect(()=>{if(!K9())return;let y=!0;return py().then((b)=>{if(!y)return;if(mJ(!!b),!b&&!QZ(ks,!1))OY(!0)}).catch(()=>{}),()=>{y=!1}},[]);let UZ=l.useCallback(()=>{OY(!1);try{localStorage.setItem(ks,"1")}catch{}},[]),[yq,VZ]=l.useState(null);l.useEffect(()=>{if(!K9())return;let y;return ny((b)=>VZ(b&&typeof b==="object"?b:{})).then((b)=>{y=b}).catch(()=>{}),()=>{try{y?.()}catch{}}},[]);let[JJ,BZ]=l.useState(null),[zW,fq]=l.useState(()=>!QZ(Rs,!1)),uJ=l.useCallback((y)=>{BZ(Array.isArray(y)&&y.length?y:null)},[]),vq={setup:(y)=>{if(!y)return;if((y.canvas||y.requireSelection)&&W.length===0)z6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(y.inspector||y.tab||y.requireSelection)S6("inspector");if(y.tab)_5(y.tab);if(y.changes)S6("changes")}},KW=l.useCallback(()=>{fq(!1);try{localStorage.setItem(Rs,"1")}catch{}},[]),[E5,FZ]=l.useState(()=>QZ(js,!0)),[NZ,xq]=l.useState(!1),[QJ,LZ]=l.useState(()=>QZ($s,!1)),[ZX,wY]=l.useState(()=>QZ(bs,!1)),[U6,UW]=l.useState(!1),[hq,P5]=l.useState(!1),[VW,b6]=l.useState(0),[BW,FW]=l.useState(null),[gq,DZ]=l.useState(!1),NW=l.useRef(null),AY=l.useRef(null),R8=l.useRef(new Map),Z8=l.useCallback((y)=>{let b=Z?R8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(y,"*")}catch{}},[Z]),LW=l.useCallback((y,b)=>Z8({dgn:"photo-preview",asset:y,edit:b}),[Z8]),mq=l.useCallback((y,b,Q0)=>{C6.current.undo.push({asset:y,before:b,after:Q0}),C6.current.redo.length=0},[]),DW=l.useCallback((y)=>{let b=y?C6.current.redo:C6.current.undo;if(!b.length)return!1;let Q0=b.pop();(y?C6.current.undo:C6.current.redo).push(Q0);let z0=(y?Q0.after:Q0.before)||{};return LW(Q0.asset,z0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(Q0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(z0)}).catch(()=>{}),bq((G0)=>G0+1),!0},[LW]),uq=l.useCallback(async(y)=>{Z8({dgn:"photo-busy",asset:y,busy:!0});try{let b=await fetch(`/${y.replace(/^\/+/,"")}`);if(!b.ok)return null;let Q0=await b.blob(),{removeBackground:z0}=await Promise.resolve().then(() => (Ps(),Es)),G0=await z0(Q0),f0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":G0.type||"image/png"},body:G0}),u=await f0.json().catch(()=>({}));if(f0.ok&&u.path)return{maskAsset:u.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{Z8({dgn:"photo-busy",asset:y,busy:!1})}},[Z8]);l.useEffect(()=>{let y=(z0)=>Array.from(z0.dataTransfer?.types??[]).includes("Files"),b=(z0)=>{if(y(z0))z0.preventDefault()},Q0=(z0)=>{if(y(z0))z0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",Q0),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",Q0)}},[]);let UQ=l.useRef({});UQ.current={open:wX,comps:q6,frame:rX,total:ZQ,playing:YZ,compId:I6,muted:L7,loop:YQ,sequences:NY,post:Z8,canvas:Z};let VQ=l.useRef({undo:[],redo:[]}),lJ=l.useCallback((y,b,Q0)=>{if(typeof b!=="number")return;if(VQ.current.undo.push({canvas:y,seq:b,label:Q0}),VQ.current.redo=[],VQ.current.undo.length>50)VQ.current.undo.shift()},[]),lq=l.useCallback((y)=>{let b=VQ.current,Q0=y==="undo"?b.undo:b.redo,z0=y==="undo"?b.redo:b.undo,G0=UQ.current.canvas,f0=-1;for(let M0=Q0.length-1;M0>=0;M0--)if(Q0[M0].canvas===G0){f0=M0;break}if(f0<0){l7(y==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let u=Q0[f0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u.canvas,seq:u.seq,dir:y})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(Q0.splice(f0,1),M0?.ok)z0.push(u),l7(`${y==="undo"?"Undid":"Redid"}: ${u.label}`,!0);else l7(`${y==="undo"?"Undo":"Redo"} skipped: ${M0?.error||"failed"}`)}).catch(()=>l7(`${y==="undo"?"Undo":"Redo"} failed: network error`))},[]);l.useEffect(()=>{let y=(b)=>{let Q0=UQ.current;if(!Q0.open||!Q0.comps?.length)return;let z0=b.target,G0=z0?.tagName;if(G0==="INPUT"||G0==="TEXTAREA"||G0==="SELECT"||z0?.isContentEditable)return;let f0=Q0.comps[0]?.fps||30,u=Math.max(1,Q0.total),M0=(g0)=>{let M8=Math.max(0,Math.min(u-1,Math.round(g0)));aX(M8),h9(!1),Q0.post({dgn:"timeline-seek",frame:M8,id:Q0.compId})},R0=()=>{let g0=new Set([0,u-1]);for(let M8 of Q0.sequences||[]){g0.add(M8.from);for(let w8 of M8.keyframes||[])g0.add(w8.from),g0.add(w8.to)}return[...g0].filter((M8)=>M8>=0&&M8<u).sort((M8,w8)=>M8-w8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),lq(b.shiftKey?"redo":"undo");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),Q0.playing)h9(!1),Q0.post({dgn:"timeline-pause",id:Q0.compId});else h9(!0),Q0.post({dgn:"timeline-mute",muted:Q0.muted,id:Q0.compId}),Q0.post({dgn:"timeline-loop",loop:Q0.loop,id:Q0.compId}),Q0.post({dgn:"timeline-play",id:Q0.compId});else if(b.key==="ArrowRight")b.preventDefault(),M0(Q0.frame+(b.shiftKey?f0:1));else if(b.key==="ArrowLeft")b.preventDefault(),M0(Q0.frame-(b.shiftKey?f0:1));else if(b.key==="Home")b.preventDefault(),M0(0);else if(b.key==="End")b.preventDefault(),M0(u-1);else if(b.key==="."){b.preventDefault();let g0=R0().find((M8)=>M8>Q0.frame);if(g0!=null)M0(g0)}else if(b.key===","){b.preventDefault();let g0=R0().reverse().find((M8)=>M8<Q0.frame);if(g0!=null)M0(g0)}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]),l.useEffect(()=>{X7([]),aX(0),h9(!1);let y=setTimeout(()=>Z8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(y)},[Z,Z8]);let[BQ,YJ]=l.useState(""),[j6,FQ]=l.useState([]);l.useEffect(()=>{if(!wX||q6.length===0||!Z||Z===g8){YJ(""),FQ([]);return}let y=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(y&&b?.ok&&typeof b.source==="string")YJ(b.source)}).catch(()=>{}),()=>{y=!1}},[wX,q6,Z]),l.useEffect(()=>{if(!wX||!Z||Z===g8||!BQ){FQ([]);return}let y=!0,b=d6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(Q0).then((z0)=>z0.ok?z0.json():null).then((z0)=>{if(!y)return;let G0=z0?.ok&&Array.isArray(z0.clips)?z0.clips.filter((f0)=>f0.kind==="sequence"):[];FQ(G0)}).catch(()=>{}),()=>{y=!1}},[wX,Z,BQ,d6]),l.useEffect(()=>{if(!BQ){GZ([]),ZZ([]),HZ(0);return}let y=q6[0]?.durationInFrames||0,b=X9??q?.artboardId??null,Q0=vf(BQ,y,b);Tq(Q0.artboardId??b??null);let z0=Q0.sequences.map((G0,f0)=>{let u=j6[f0];if(!u)return G0;return{...G0,mediaTag:u.mediaTag??G0.mediaTag,mediaSrc:u.mediaSrc??G0.mediaSrc,replaceable:!!(u.mediaCdId||u.mediaArrayRef),layers:Array.isArray(u.layers)?u.layers:[],hidden:!!u.hidden}});GZ(z0),ZZ(Q0.audio||[]),HZ(Q0.total)},[BQ,j6,q,q6,X9]);let MZ=l.useCallback(()=>{FZ((y)=>{let b=!y,Q0=Z?R8.current.get(Z):null;if(Q0&&Q0.contentWindow)try{Q0.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),HX=l.useCallback((y)=>{for(let b of R8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...y},"*")}catch{}},[]),R5=l.useCallback(()=>{LZ((y)=>{let b=!y;return HX({minimap:b}),b})},[HX]),k5=l.useCallback(()=>{wY((y)=>{let b=!y;return HX({zoom:b}),b})},[HX]),MW=l.useCallback(()=>{UW((y)=>{let b=!y;return HX({present:b}),b})},[HX]),NQ=l.useCallback(()=>{UW(!1),HX({present:!1})},[HX]),OW=l.useCallback(()=>{if(!Z||Z===g8)return;P5((y)=>{let b=!y;return Z8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,Z8]);l.useEffect(()=>{let y=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(y)return;let Q0=b&&typeof b.name==="string"?b.name.trim():"";if(Q0)FW(Q0)}).catch(()=>{}),()=>{y=!0}},[]),l.useEffect(()=>{if(!Z||Z===g8){b6(0),P5(!1);return}let y=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(y)return;let Q0=Array.isArray(b?.artboards)?b.artboards.length:0;b6(Q0),P5(b?.overlays?.print===!0),DQ(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!y)b6(0),P5(!1),DQ(new Set)}),()=>{y=!0}},[Z]),l.useEffect(()=>{if(!Z||Z===g8||!X9)return;let y=setTimeout(()=>{Z8({dgn:"request-layers",artboardId:X9})},250);return()=>clearTimeout(y)},[Z,X9,Z8]);let[LQ,DQ]=l.useState(()=>new Set),wW=l.useCallback((y)=>{if(!Z||Z===g8)return;DQ((b)=>{let Q0=new Set(b);if(Q0.has(y))Q0.delete(y);else Q0.add(y);let z0=[...Q0];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:z0}})}).catch(()=>{}),Z8({dgn:"locked-set",locked:z0}),Q0})},[Z,Z8]);l.useEffect(()=>{if(!Z||Z===g8)return;Z8({dgn:"locked-set",locked:[...LQ]})},[LQ,Z,Z8]),l.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",O0),localStorage.setItem(Zt,O0)}catch{}for(let y of R8.current.values())try{y.contentWindow.postMessage({dgn:"theme",theme:O0},"*")}catch{}},[O0]),l.useEffect(()=>{try{localStorage.setItem(Ss,u8?"1":"0")}catch{}},[u8]),l.useEffect(()=>{try{localStorage.setItem(Ts,o9?"1":"0")}catch{}},[o9]),l.useEffect(()=>{try{localStorage.setItem(Is,JSON.stringify(k6))}catch{}},[k6]),l.useEffect(()=>{try{localStorage.setItem($s,QJ?"1":"0")}catch{}},[QJ]),l.useEffect(()=>{try{localStorage.setItem(bs,ZX?"1":"0")}catch{}},[ZX]),l.useEffect(()=>{try{localStorage.setItem(js,E5?"1":"0")}catch{}},[E5]),l.useEffect(()=>{let y=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(y||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")n0(b.theme);if(typeof b.minimap==="boolean")LZ(b.minimap);if(typeof b.zoom==="boolean")wY(b.zoom);if(typeof b.annotations==="boolean")FZ(b.annotations);if(typeof b.autoOpenInspector==="boolean")_X(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")BY({...Aq,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")FY(b.layersMode)}).catch(()=>{}).finally(()=>{if(!y)xq(!0)}),()=>{y=!0}},[]),l.useEffect(()=>{if(!NZ)return;$U0({theme:O0,minimap:QJ,zoom:ZX,annotations:E5,autoOpenInspector:XJ,panelSides:T6,layersMode:GX})},[NZ,O0,QJ,ZX,E5,XJ,T6,GX]),l.useEffect(()=>{try{localStorage.setItem(ys,JSON.stringify(T6))}catch{}},[T6]),l.useEffect(()=>{try{localStorage.setItem(fs,GX)}catch{}},[GX]);let dq=l.useCallback((y,b)=>{F7((Q0)=>{let z0=Q0[y],G0=z0===void 0?b:z0;return{...Q0,[y]:!G0}})},[]),MQ=l.useCallback(()=>{n0((y)=>y==="dark"?"light":"dark")},[]),t7=l.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let Q0=b.groups.map((z0)=>({...z0,tree:xU0(z0.paths,z0.stripPrefix)}));J(Q0),F0((z0)=>({...z0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(y){console.error("failed to load tree",y)}},[]);l.useEffect(()=>{t7()},[t7]);let WJ=l.useCallback(async(y)=>{try{let b=y?`/_system-data?ds=${encodeURIComponent(y)}`:"/_system-data",Q0=await fetch(b);if(!Q0.ok){console.error("failed to load system-data",Q0.status);return}let z0=await Q0.json();if(!y&&z0?.defaultDesignSystem&&!z0.ds){U8(z0);let G0=await fetch(`/_system-data?ds=${encodeURIComponent(z0.defaultDesignSystem)}`);if(G0.ok)U8(await G0.json());return}U8(z0)}catch(b){console.error("failed to load system-data",b)}},[]),GJ=l.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();H0(b||{})}catch(y){console.error("failed to load comments",y)}},[]);l.useEffect(()=>{GJ()},[GJ]),l.useEffect(()=>{function y(){let b=location.protocol==="https:"?"wss:":"ws:",Q0=new WebSocket(b+"//"+location.host+"/_ws");AY.current=Q0,Q0.addEventListener("open",()=>i(!0)),Q0.addEventListener("close",()=>{i(!1),setTimeout(y,1000)}),Q0.addEventListener("error",()=>{}),Q0.addEventListener("message",(z0)=>{try{let G0=JSON.parse(z0.data);if(G0.type==="snapshot"&&G0.state)K((f0)=>Qt(G0.state.selected,f0));else if(G0.type==="selected"){if(Date.now()-L.current<2000)return;let f0=G0.selected,u=Array.isArray(f0)?f0[0]:f0,M0=V.current,R0=Array.isArray(M0)?M0[0]:M0;if(K((g0)=>Qt(f0,g0)),u?.id&&u.file&&(!R0||R0.id!==u.id||R0.file!==u.file))w(u)}else if(G0.type==="comments"&&typeof G0.file==="string")H0((f0)=>({...f0,[G0.file]:G0.comments||[]}));else if(G0.type==="ai-activity"&&typeof G0.file==="string"){if(DZ(!0),NW.current)clearTimeout(NW.current);NW.current=setTimeout(()=>DZ(!1),8000);for(let f0 of R8.current.values())try{f0.contentWindow.postMessage({dgn:"ai-activity",file:G0.file,entry:G0.entry},"*")}catch{}}else if(G0.type==="export:job"&&G0.payload)MY.upsert(G0.payload);else if(G0.type==="sync:status"&&G0.payload)X0(G0.payload);else if(G0.type==="canvas-list-update")t7();else if(G0.type==="config-updated")U0();else if(G0.type==="acp-focus"){if(K9())S6("assistant")}else if(G0.type==="git-status"&&G0.payload)V0(G0.payload);else if(G0.type==="git-lifecycle"&&G0.payload){h(G0.payload);for(let f0 of R8.current.values())try{f0.contentWindow.postMessage({dgn:"git-lifecycle",payload:G0.payload},"*")}catch{}}}catch{}})}return y(),()=>AY.current&&AY.current.close()},[t7,U0]);function Y0(y){let b=AY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(y))}catch{}}let qX=l.useCallback(async()=>{try{let y=await fetch("/_api/git/status");if(y.ok)V0(await y.json())}catch{}},[]),c6=l.useCallback(async()=>{try{let y=await fetch("/_api/git/status?remote=1");if(!y.ok)return;let b=await y.json();if(b&&b.repo!==!1)g({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),y6=l.useCallback(async(y,b)=>{try{let Q0=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),z0=await Q0.json().catch(()=>({}));return{ok:Q0.ok,...z0}}catch(Q0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),dJ=l.useCallback(async(y,b)=>{let Q0=await y6("/_api/git/commit",{message:y,files:b});if(Q0.ok)await qX();return Q0},[y6,qX]),Q7=l.useCallback(async(y)=>{let b=await y6("/_api/git/discard",{files:y});if(b.ok)await qX();return b},[y6,qX]),pJ=l.useCallback(async()=>{let y=await y6("/_api/git/push",{});if(y.ok)await qX(),c6();return y},[y6,qX,c6]),T5=l.useCallback(async()=>{let y=await y6("/_api/git/pull",{});if(y.ok)await qX(),c6();if(y.conflict&&Array.isArray(y.files)&&y.files.length)J8({file:y.files[0],conflict:!0});return y},[y6,qX,c6]),AW=l.useCallback(async(y)=>{let b=await y6("/_api/git/resolve",{choice:y});if(b.ok)await qX(),c6();return b},[y6,qX,c6]),_Y=l.useCallback(async(y)=>{try{let b="/_api/git/log?limit=40"+(y?`&path=${encodeURIComponent(y)}`:""),Q0=await fetch(b);if(!Q0.ok)return[];return(await Q0.json()).entries||[]}catch{return[]}},[]),_W=l.useMemo(()=>{let y={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;for(let Q0 of c?.files||[])b.set(Q0.path,y[Q0.status]);return b},[c]),I5=c?.files?.length||0;l.useEffect(()=>{if(c?.repo===!1)return;c6();let y=setInterval(c6,d?60000:120000);return()=>clearInterval(y)},[c?.repo,d,c6]);let i6=l.useCallback((y)=>{if(G((b)=>{for(let Q0 of b)if(Q0.path!==y)R8.current.delete(Q0.path);return[{path:y}]}),H(y),N0(null),y!==g8)m8(y)},[]),ZJ=l.useCallback((y)=>{let b=typeof y==="string"?y:void 0;if(b)WJ(b);else if(!D8)WJ();i6(g8)},[D8,WJ,i6]);l.useEffect(()=>{Y0({type:"tabs",tabs:W.map((y)=>y.path).filter((y)=>y!==g8)})},[W]),l.useEffect(()=>{if(Z&&Z!==g8)Y0({type:"active",file:Z});else if(Z===g8)Y0({type:"active",file:""});else Y0({type:"active",file:""})},[Z]);let m0=l.useCallback((y)=>{G((b)=>{let Q0=b.findIndex((G0)=>G0.path===y);if(Q0<0)return b;let z0=b.filter((G0)=>G0.path!==y);if(y===Z)if(z0.length===0)H(null);else H(z0[Math.max(0,Q0-1)].path);return z0}),R8.current.delete(y),m8((b)=>b===y?null:b)},[Z]),p7=l.useCallback(()=>{if(!Z||Z===g8){if(Z===g8)WJ();return}let y=R8.current.get(Z);if(y)y.src=y.src},[Z,WJ]),EY=l.useCallback(()=>t7(),[t7]),[x0,C5]=l.useState(!1),h0=l.useRef(!1),OQ=l.useCallback(async()=>{if(h0.current)return;h0.current=!0,C5(!0);try{await Promise.all([t7(),new Promise((y)=>setTimeout(y,550))])}finally{h0.current=!1,C5(!1)}},[t7]);l.useEffect(()=>{let y=null,b=()=>{if(y)clearTimeout(y);y=setTimeout(()=>{y=null,EY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),y)clearTimeout(y)}},[EY]);let EW=l.useCallback(async(y)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,kind:"brief-board"})}),Q0=await b.json().catch(()=>({}));if(!b.ok||!Q0.ok)return{ok:!1,error:Q0.error||`create failed (${b.status})`};return await t7(),i6(Q0.file),{ok:!0,file:Q0.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[t7,i6]),PW=l.useCallback(async()=>{if(!Z||Z===g8)return;try{let y=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=y.ok?await y.text():"",Q0=[];if(b){let M0=new DOMParser().parseFromString(b,"image/svg+xml");for(let R0 of M0.querySelectorAll('[data-tool="mediaref"]')){let g0=R0.getAttribute("data-src");if(!g0)continue;Q0.push({src:g0,mediaKind:R0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Q0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let G0=`${Pq(VF(Z)).replace(/\.tsx$/i,"")} Video`,f0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G0,kind:"video-comp",clips:Q0})}),u=await f0.json().catch(()=>({}));if(!f0.ok||!u.ok){window.alert(`Assemble failed: ${u.error||`error ${f0.status}`}`);return}await t7(),i6(u.file)}catch(y){window.alert(`Assemble failed: ${y instanceof Error?y.message:"network error"}`)}},[Z,t7,i6]),wQ=l.useCallback(({accept:y,resolveTarget:b})=>{let Q0=Z,z0=d6||void 0,G0=document.createElement("input");G0.type="file",G0.accept=y,G0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(G0);let f0=()=>{if(G0.isConnected)G0.remove()};window.addEventListener("focus",()=>setTimeout(f0,300),{once:!0}),G0.addEventListener("change",()=>{let u=G0.files?.[0];if(f0(),!u)return;let M0=`/_api/comp-clips?canvas=${encodeURIComponent(Q0)}${z0?`&artboardId=${encodeURIComponent(z0)}`:""}`;fetch(M0).then((R0)=>R0.json().catch(()=>({}))).then((R0)=>{let g0=b(R0);if(!g0)return l7("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":u.type||"application/octet-stream"},body:u}).then((M8)=>M8.json().catch(()=>({}))).then((M8)=>{if(!M8?.path)return l7(`Upload failed: ${M8?.error||"unknown error"}`),null;if(g0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,arrayName:g0.arrayRef.arrayName,index:g0.arrayRef.index,field:g0.arrayRef.field,value:M8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,id:g0.cdId,attr:"src",value:M8.path})})})}).then((R0)=>R0?R0.json():null).then((R0)=>{if(R0&&!R0.ok)l7(`Replace refused: ${R0.error||"failed"}`);else if(R0&&R0.ok){if(l7("Media replaced.",!0),R0.seq!=null)lJ(Q0,R0.seq,"replace media")}}).catch(()=>l7("Replace failed: network error"))}),G0.click()},[Z,d6,lJ]),RW=l.useCallback(async(y,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5648
|
+
`.trim();function r40(){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=n40,document.head.appendChild(X)}function yf({target:X,sections:J,onClose:Q}){r40();let Y=h6.useRef(null),[W,G]=h6.useState({x:X.clientX,y:X.clientY});h6.useEffect(()=>{let H=Y.current;if(!H)return;let q=H.getBoundingClientRect(),K=window.innerWidth,V=window.innerHeight,B=X.clientX,F=X.clientY;if(B+q.width>K-8)B=Math.max(8,K-q.width-8);if(F+q.height>V-8)F=Math.max(8,V-q.height-8);if(B!==W.x||F!==W.y)G({x:B,y:F});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let M=(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 D=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(D.length===0)return;let P=D.indexOf(document.activeElement),T=A.key==="ArrowDown"?(P+1)%D.length:(P-1+D.length)%D.length;D[T]?.focus()}},R=()=>Q();return document.addEventListener("pointerdown",M,!0),document.addEventListener("keydown",w,!0),document.addEventListener("scroll",R,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("scroll",R,!0),window.removeEventListener("blur",Q)}},[X.clientX,X.clientY,Q,W.x,W.y]);let Z=J.map((H)=>H.filter((q)=>{return!(typeof q.hidden==="function"?q.hidden(X):q.hidden)})).filter((H)=>H.length>0);return z("div",{ref:Y,className:"dc-context-menu",role:"menu",style:{left:W.x,top:W.y},children:Z.map((H,q)=>{let K=H.map((V)=>V.id).join("|")||`s${q}`;return _("div",{role:"group",children:[q>0?z("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((V)=>z(a40,{item:V,target:X,onClose:Q},V.id))]},K)})})}function a40({item:X,target:J,onClose:Q}){let[Y,W]=h6.useState(!1),[G,Z]=h6.useState(!1),H=h6.useRef(null),q=h6.useRef(null),K=h6.useRef(null),V=typeof X.submenu==="function"?X.submenu(J):X.submenu,B=typeof X.disabled==="function"?X.disabled(J):X.disabled;if(!V||V.length===0)return _("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:[z("span",{children:X.label}),X.shortcut?z("span",{className:"dc-menu-shortcut",children:X.shortcut}):null]});let F=()=>{if(K.current)clearTimeout(K.current),K.current=null},L=(w=!1)=>{F();let R=H.current?.getBoundingClientRect();if(R&&typeof window<"u")Z(R.right+200>window.innerWidth);if(W(!0),w)setTimeout(()=>{q.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},M=()=>{F(),K.current=setTimeout(()=>W(!1),140)};return _("div",{className:"dc-menu-sub",onMouseEnter:()=>L(),onMouseLeave:M,children:[_("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:[z("span",{children:X.label}),z("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?z("div",{ref:q,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:F,onMouseLeave:M,children:V.map((w)=>_("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:(R)=>{if(R.key==="ArrowLeft"||R.key==="Escape")R.preventDefault(),R.stopPropagation(),W(!1),H.current?.focus()},children:[z("span",{children:w.label}),w.shortcut?z("span",{className:"dc-menu-shortcut",children:w.shortcut}):null]},w.id))}):null]})}function aH(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 s40(X){let J=aH(X);if(J==="video")return"▶";if(J==="image")return"◫";if(J==="audio")return"♪";return"ƒ"}function ff(X){let J=aH(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 c2({name:X,size:J=15}){return z("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:z("path",{d:"M4 3l9 5-9 5z",fill:"currentColor",stroke:"none"}),pause:_(W0,{children:[z("rect",{x:"4",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"}),z("rect",{x:"9",y:"3.5",width:"3",height:"9",fill:"currentColor",stroke:"none"})]}),loop:_(W0,{children:[z("polyline",{points:"4 4 4 7 7 7"}),z("path",{d:"M4 7a4.5 4.5 0 1 1 1.3 4.6"})]}),start:_(W0,{children:[z("line",{x1:"4.5",y1:"3.5",x2:"4.5",y2:"12.5"}),z("path",{d:"M12 3.5l-6 4.5 6 4.5z",fill:"currentColor",stroke:"none"})]}),sound:_(W0,{children:[z("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),z("path",{d:"M10.5 5.5a3.2 3.2 0 0 1 0 5"}),z("path",{d:"M12.3 3.7a5.6 5.6 0 0 1 0 8.6"})]}),muted:_(W0,{children:[z("path",{d:"M3 6h2.2L8 3.3v9.4L5.2 10H3z",fill:"currentColor",stroke:"none"}),z("line",{x1:"10.7",y1:"6",x2:"13.7",y2:"10"}),z("line",{x1:"13.7",y1:"6",x2:"10.7",y2:"10"})]})}[X]})}var XU=(X,J,Q)=>Math.max(J,Math.min(Q,X));function t40(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 Uw({comps:X=[],sequences:J=[],audio:Q=[],total:Y=0,frame:W=0,playing:G=!1,loop:Z=!1,onSeek:H,onPlay:q,onPause:K,onToggleLoop:V,muted:B=!1,onToggleMute:F,volume:L=1,onVolume:M,height:w,resizing:R,onResize:A,onRetime:D,onRemove:P,onReplace:T,onReplaceAudio:I,onReplaceLayer:S,onReorder:C,onToggleHide:j,onDropMedia:f,onClose:m}){let[o,n]=T7.useState(()=>new Set),[x,i]=T7.useState(!1),a=X[0]??null,h=Math.max(1,Y||a?.durationInFrames||1),s=a?.fps??30,X0=XU(Math.round(W),0,h-1),c=T7.useRef(null),V0=T7.useRef(!1),p=T7.useRef(null);T7.useEffect(()=>{p.current?.focus()},[]);let[g,d]=T7.useState(null),[K0,u0]=T7.useState(null),[J8,G8]=T7.useState(null),s0=T7.useRef(!1),D8=T7.useCallback((F0)=>{F0.preventDefault(),F0.stopPropagation(),F0.currentTarget.setPointerCapture?.(F0.pointerId);let U0=F0.clientY,k0=w||216,H0=(N0)=>{A?.(XU(k0+(U0-N0.clientY),140,640))},L0=()=>{window.removeEventListener("pointermove",H0),window.removeEventListener("pointerup",L0)};window.addEventListener("pointermove",H0),window.addEventListener("pointerup",L0)},[w,A]),U8=96,q8=T7.useCallback((F0)=>{let U0=c.current;if(!U0)return;let k0=U0.getBoundingClientRect(),H0=Math.max(1,k0.width-U8),L0=XU((F0-k0.left-U8)/H0,0,1);H?.(Math.round(L0*(h-1)))},[H,h]);T7.useEffect(()=>{if(!V0.current)return;let F0=(k0)=>q8(k0.clientX),U0=()=>{V0.current=!1};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}});let m8=(F0)=>{if(g)return;F0.preventDefault(),V0.current=!0,q8(F0.clientX),F0.currentTarget.setPointerCapture?.(F0.pointerId)};T7.useEffect(()=>{if(!g)return;let F0=(k0)=>{let H0=(k0.clientX-g.startX)/Math.max(1,g.rowW)*(h-1),L0=g.startFrom+Math.round(g.startDur+H0),N0=k0.altKey?0:Kw(g.rowW,h);L0=zw(L0,g.targets,N0);let t0=Math.max(1,L0-g.startFrom);d(($8)=>$8?{...$8,curDur:t0}:$8)},U0=()=>{d((k0)=>{if(k0&&k0.curDur!==k0.startDur)D?.(k0.index,{durationInFrames:k0.curDur});return null})};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}},[g,h,D]),T7.useEffect(()=>{if(!K0)return;let F0=(k0)=>{let H0=(k0.clientX-K0.startX)/Math.max(1,K0.rowW)*(h-1),L0=Math.max(0,Math.round(K0.startFrom+H0)),N0=k0.altKey?0:Kw(K0.rowW,h);if(L0=Math.max(0,zw(L0,K0.targets,N0)),Math.abs(L0-K0.startFrom)>=1)s0.current=!0;u0((t0)=>t0?{...t0,curFrom:L0}:t0)},U0=()=>{u0((k0)=>{if(k0&&k0.curFrom!==k0.startFrom)D?.(k0.index,{from:k0.curFrom});return null})};return window.addEventListener("pointermove",F0),window.addEventListener("pointerup",U0,{once:!0}),()=>{window.removeEventListener("pointermove",F0),window.removeEventListener("pointerup",U0)}},[K0,h,D]);let _8=(F0)=>jf({fps:s,totalFrames:h,clips:J,movingIndex:F0,playhead:X0}),G9=(F0,U0,k0)=>{if(!D)return;if(J[U0]?.series)return;F0.stopPropagation();let H0=F0.currentTarget.closest(".tl-row-track"),L0=H0?H0.getBoundingClientRect().width:300;s0.current=!1,u0({index:U0,startX:F0.clientX,startFrom:k0,rowW:L0,curFrom:k0,targets:_8(U0)})},Z9=(F0,U0,k0)=>{F0.stopPropagation(),F0.preventDefault();let H0=F0.currentTarget.closest(".tl-row-track"),L0=H0?H0.getBoundingClientRect().width:300,N0=J[U0]?.from??0;d({index:U0,startX:F0.clientX,startDur:k0,startFrom:N0,rowW:L0,curDur:k0,targets:_8(U0)})},e0=Math.max(1,Math.floor((h-1)/s)),p8=Array.from({length:e0+1},(F0,U0)=>U0*s/(h-1)),o8=(F0)=>`${XU(F0,0,h-1)/(h-1)*100}%`,$9=(F0)=>Array.from(F0?.types??[]).includes("Files"),j0=(F0)=>{if(!f||!$9(F0.dataTransfer))return;F0.preventDefault(),F0.stopPropagation(),i(!1);let U0=F0.dataTransfer.files?.[0];if(U0)f(U0)};return _("aside",{ref:p,tabIndex:-1,className:`tl-panel${R?" is-resizing":""}${x?" is-drop":""}`,style:{...w?{height:w}:{},outline:"none"},onDragOver:(F0)=>{if(!f||!$9(F0.dataTransfer))return;if(F0.preventDefault(),F0.dataTransfer.dropEffect="copy",!x)i(!0)},onDragLeave:(F0)=>{if(F0.relatedTarget==null)i(!1)},onDrop:j0,"aria-label":"Timeline","data-testid":"timeline-panel",children:[z("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:D8}),_("div",{className:"tl-head",children:[a?_(W0,{children:[z("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":G?"Pause":"Play","aria-pressed":G,"data-testid":"timeline-playpause",onClick:()=>G?K?.():q?.(),children:z(c2,{name:G?"pause":"play"})}),z("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>H?.(0),children:z(c2,{name:"start"})}),z("button",{type:"button",className:`tl-btn${Z?" is-on":""}`,"aria-label":"Loop","aria-pressed":Z,"data-testid":"timeline-loop",onClick:()=>V?.(),children:z(c2,{name:"loop"})}),Q.length>0?z("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:z(c2,{name:B?"muted":"sound"})}):null,Q.length>0?z("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:(F0)=>M?.(Number(F0.target.value)/100)}):null,_("span",{className:"tl-readout","data-testid":"timeline-readout",children:[z("b",{children:X0}),z("span",{className:"tl-sep",children:"/"}),h-1,z("span",{className:"tl-time",children:t40(X0,s)})]})]}):z("span",{className:"tl-title",children:"Timeline"}),z("span",{className:"tl-spacer"}),a?_("span",{className:"tl-meta",children:[s," fps · ",h,"f"]}):null,z("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:m,children:"×"})]}),!a?_("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No animation on this canvas. Make an artboard a ",z("b",{children:"video-comp"}),"(",z("code",{children:"<VideoComp>"}),") to scrub and export it — or drop clips on the canvas and ",z("b",{children:"File → Assemble dropped clips → video"}),"."]}):z("div",{className:"tl-scroll",children:_("div",{className:"tl-tracks",ref:c,"data-testid":"timeline-track",onPointerDown:m8,children:[z("div",{className:"tl-ruler",children:p8.map((F0,U0)=>z("span",{className:"tl-tick",style:{left:`${F0*100}%`},children:_("span",{className:"tl-tick-label",children:[U0,"s"]})},U0))}),J.length===0?_("div",{className:"tl-row",children:[z("span",{className:"tl-row-label",children:"comp"}),z("div",{className:"tl-row-track",children:z("div",{className:"tl-seq-block",style:{left:"0%",width:"100%"},children:z("span",{className:"tl-seq-name",children:"whole composition"})})})]}):J.map((F0,U0)=>{let k0=g&&g.index===U0?g.curDur:F0.duration,H0=!!(g&&g.index===U0),L0=K0&&K0.index===U0?K0.curFrom:F0.from,N0=!!(K0&&K0.index===U0),t0=Array.isArray(F0.layers)?F0.layers:[],$8=t0.length>=2,y0=$8&&!o.has(U0);return _(T7.Fragment,{children:[_("div",{className:"tl-row","data-testid":`timeline-row-${U0}`,children:[_("span",{className:"tl-row-label",title:F0.label,children:[$8?z("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${U0}`,title:y0?"Collapse layers":"Show layers","aria-label":y0?`Collapse ${F0.label} layers`:`Show ${F0.label} layers`,"aria-expanded":y0,onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),v0.preventDefault(),n((O0)=>{let n0=new Set(O0);if(n0.has(U0))n0.delete(U0);else n0.add(U0);return n0})},children:y0?"▾":"▸"}):z("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),C?_("span",{className:"tl-seq-reorder",role:"group","aria-label":`${F0.series?"Play order":"Stacking order"} for ${F0.label}`,children:[z("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-raise-${U0}`,title:F0.series?"Move earlier (plays sooner)":"Bring forward (render on top)","aria-label":F0.series?`Move ${F0.label} earlier`:`Bring ${F0.label} forward`,disabled:F0.series?U0<=0:U0>=J.length-1,onClick:(v0)=>{v0.stopPropagation(),C(U0,F0.series?"backward":"forward")},children:"▲"}),z("button",{type:"button",className:"tl-reorder-btn","data-testid":`timeline-lower-${U0}`,title:F0.series?"Move later (plays after)":"Send backward (render underneath)","aria-label":F0.series?`Move ${F0.label} later`:`Send ${F0.label} backward`,disabled:F0.series?U0>=J.length-1:U0<=0,onClick:(v0)=>{v0.stopPropagation(),C(U0,F0.series?"forward":"backward")},children:"▼"})]}):null,z("span",{className:"tl-kind","data-kind":aH(F0),title:ff(F0),"aria-label":ff(F0),children:s40(F0)}),z("span",{className:"tl-row-label-text",children:F0.label})]}),_("div",{className:"tl-row-track",children:[_("button",{type:"button",className:`tl-seq-block${H0?" is-resizing":""}${N0?" is-moving":""}${F0.hidden?" is-hidden":""}`,"data-testid":`timeline-seq-${U0}`,"data-kind":aH(F0),"data-hidden":F0.hidden?"1":void 0,title:F0.series?`${F0.label} · ${L0}–${L0+k0}f (${k0}f) · position computed by the series — trim the right edge to retime`:`${F0.label} · ${L0}–${L0+k0}f (${k0}f) · drag to move (Alt = no snap)`,"aria-label":F0.series?`${F0.label}, series beat, frames ${L0} to ${L0+k0}. Click to seek; trim its edge to retime.`:`${F0.label}, from frame ${L0} to ${L0+k0}, ${k0} frames. Click to seek; drag to move.`,style:{left:o8(L0),width:`${k0/(h-1)*100}%`,cursor:D&&!F0.series?"grab":void 0},onContextMenu:(v0)=>{v0.preventDefault(),v0.stopPropagation(),G8({index:U0,x:v0.clientX,y:v0.clientY})},onPointerDown:(v0)=>G9(v0,U0,F0.from),onClick:(v0)=>{if(v0.stopPropagation(),s0.current){s0.current=!1;return}H?.(F0.from)},children:[_("span",{className:"tl-seq-name",children:[F0.label,H0?` · ${k0}f`:"",N0?` · @${L0}f`:""]}),F0.keyframes.map((v0,O0)=>{let n0=(v0.from-F0.from)/Math.max(1,F0.duration)*100,Q8=(v0.to-v0.from)/Math.max(1,F0.duration)*100;return z("span",{className:"tl-kf","data-testid":`timeline-kf-${U0}-${O0}`,style:{left:`${XU(n0,0,100)}%`,width:`${Math.max(1.5,Q8)}%`},title:`seek to keyframe ${v0.from}f (animates ${v0.from}–${v0.to}f)`,onPointerDown:(w0)=>w0.stopPropagation(),onClick:(w0)=>{w0.stopPropagation(),H?.(v0.from)}},O0)})]}),D?z("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${U0}`,title:"Drag to retime this sequence",style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 5px)`},onPointerDown:(v0)=>Z9(v0,U0,F0.duration),onClick:(v0)=>v0.stopPropagation()}):null,T&&F0.replaceable&&!$8?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${U0}`,title:`Replace this ${aH(F0)}`,"aria-label":`Replace media in ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 34px)`},onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),T(U0)},children:"⇄"}):null,P?z("button",{type:"button",className:"tl-seq-remove","data-testid":`timeline-remove-${U0}`,title:"Remove this clip","aria-label":`Remove ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 17px)`},onPointerDown:(v0)=>v0.stopPropagation(),onClick:(v0)=>{v0.stopPropagation(),P(U0)},children:"×"}):null]})]}),y0?t0.map((v0,O0)=>{let n0=v0.kind==="video"?"video":v0.kind==="image"?"image":v0.kind==="audio"?"audio":"jsx",Q8=v0.kind==="video"?"▶":v0.kind==="image"?"◫":v0.kind==="audio"?"♪":"ƒ",w0=!!(v0.mediaCdId||v0.mediaArrayRef);return _("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${U0}-${O0}`,children:[_("span",{className:"tl-row-label",title:v0.label,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":n0,children:Q8}),z("span",{className:"tl-row-label-text",children:v0.label})]}),_("div",{className:"tl-row-track",children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":n0,"data-testid":`timeline-layer-block-${U0}-${O0}`,title:`${v0.label} (${v0.kind} layer)`,style:{left:o8(F0.from),width:`${k0/(h-1)*100}%`},onContextMenu:(i0)=>{i0.preventDefault(),i0.stopPropagation(),G8({index:U0,layerIndex:O0,x:i0.clientX,y:i0.clientY})},children:z("span",{className:"tl-seq-name",children:v0.label})}),S&&w0?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${U0}-${O0}`,title:`Replace this ${v0.kind}`,"aria-label":`Replace ${v0.label}`,style:{left:`calc(${o8(F0.from)} + ${k0/(h-1)*100}% - 20px)`},onPointerDown:(i0)=>i0.stopPropagation(),onClick:(i0)=>{i0.stopPropagation(),S(U0,O0)},children:"⇄"}):null]})]},`l${O0}`)}):null]},U0)}),Q.map((F0,U0)=>_("div",{className:"tl-row","data-testid":`timeline-audio-${U0}`,children:[_("span",{className:"tl-row-label",title:F0.label,children:[z("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${F0.label}`,"aria-label":`Audio · ${F0.label}`,children:"♪"}),z("span",{className:"tl-row-label-text",children:F0.label})]}),_("div",{className:"tl-row-track",children:[_("div",{className:"tl-audio-block",title:`${F0.label} · ${F0.from}–${F0.from+F0.duration}f`,style:{left:o8(F0.from),width:`${F0.duration/(h-1)*100}%`},children:[z("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:z("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"})}),z("span",{className:"tl-seq-name",children:F0.label})]}),I?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${U0}`,title:"Replace this audio","aria-label":`Replace audio ${F0.label}`,style:{left:`calc(${o8(F0.from)} + ${F0.duration/(h-1)*100}% - 20px)`},onPointerDown:(k0)=>k0.stopPropagation(),onClick:(k0)=>{k0.stopPropagation(),I(U0)},children:"⇄"}):null]})]},`a${U0}`)),z("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:`calc(96px + (100% - 96px) * ${X0/(h-1)||0})`}})]})}),J8&&J[J8.index]?(()=>{let F0=J[J8.index],U0=J8.index,k0=J8.layerIndex,H0;if(k0!=null){let L0=(Array.isArray(F0.layers)?F0.layers:[])[k0],N0=[];if(S&&L0&&(L0.mediaCdId||L0.mediaArrayRef))N0.push({id:"replace-layer",label:`Replace ${L0.kind}…`,onSelect:()=>S(U0,k0)});if(N0.length===0)N0.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});H0=[N0]}else{let L0=[];if(T&&F0.replaceable&&!(Array.isArray(F0.layers)&&F0.layers.length>=2))L0.push({id:"replace",label:`Replace ${aH(F0)}…`,onSelect:()=>T(U0)});if(C)L0.push({id:"earlier",label:F0.series?"Move earlier":"Bring forward",disabled:F0.series?U0<=0:U0>=J.length-1,onSelect:()=>C(U0,F0.series?"backward":"forward")}),L0.push({id:"later",label:F0.series?"Move later":"Send backward",disabled:F0.series?U0>=J.length-1:U0<=0,onSelect:()=>C(U0,F0.series?"forward":"backward")});H0=[L0];let N0=[];if(j)N0.push({id:"hide",label:F0.hidden?"Show clip":"Hide clip",onSelect:()=>j(U0)});if(P)N0.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>P(U0)});if(N0.length)H0.push(N0)}return z(yf,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:J8.x,clientY:J8.y},sections:H0,onClose:()=>G8(null)})})():null]})}function e40(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=r5(Y[2],J);if(G!=null)J[W]=G}return J}function r5(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 XW0(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),Z=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,Z>0?Z:2400),q=[];for(let K of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let V=r5(K[1],Q),B=r5(K[2],Q);if(V!=null&&B!=null&&B>=V)q.push({from:Y+V,to:Y+B})}return q}function JW0(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 QW0(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:r5(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],J),fps:r5(W.match(/fps=\{([^}]+)\}/)?.[1],J)||30})}return Q}function vf(X,J,Q){let Y=String(X??""),W=e40(Y),G=Y,Z=J,H=0,q=null,K=QW0(Y,W).map((D)=>({...D,body:JW0(Y,D.compName)})).filter((D)=>D.body);if(K.length){let D=Q&&K.find((P)=>P.artboardId===Q)||K.find((P)=>/<(?:Audio|OffthreadVideo|Video)\b/.test(P.body))||K.find((P)=>P.duration!=null&&P.duration===J)||K[0];if(G=D.body,D.duration!=null)Z=D.duration;H=D.fps,q=D.artboardId??null}let V=[],B=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=B.exec(G)){let D=F[1],P=F[2],T=B.lastIndex;if(/Transition$/.test(D)){let I=P.match(/durationInFrames:\s*([^,}\s)]+)/);V.push({type:"transition",dur:r5(I?.[1],W)??0})}else{let I=P.match(/durationInFrames=\{([^}]+)\}/),S=P.match(/from=\{([^}]+)\}/),C=G.indexOf(`</${D}>`,T),j=C>=0?Math.min(C,T+400):T+240,f=G.slice(T,j),m=f.match(/<([A-Z][A-Za-z0-9]*)\b/),o=f.match(/<(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),n=P.match(/name=["']([^"']+)["']/);V.push({type:"seq",series:D!=="Sequence",dur:r5(I?.[1],W),from:D==="Sequence"&&S?r5(S[1],W):null,compName:n?n[1]:m?m[1]:null,mediaTag:o?o[1]:null,mediaSrc:o?o[2]:null})}}let L=0,M=[];for(let D of V){if(D.type==="transition"){L-=D.dur||0;continue}let P=D.from!=null?D.from:L,T=D.dur!=null?D.dur:30;M.push({label:D.compName??`Seq ${M.length+1}`,series:!!D.series,mediaTag:D.mediaTag,mediaSrc:D.mediaSrc,from:Math.max(0,P),duration:Math.max(1,T),keyframes:XW0(Y,D.compName,W,Math.max(0,P))}),L=P+T}let w=M.length?Math.max(...M.map((D)=>D.from+D.duration)):30,R=Number.isFinite(Z)&&Z>0?Z:w,A=[];for(let D of G.matchAll(/<Audio\b([^>]*)>/g)){let P=D[1],T=P.match(/src=["']([^"']+)["']/),I=P.match(/from=\{([^}]+)\}/),S=P.match(/durationInFrames=\{([^}]+)\}/),C=I?r5(I[1],W)??0:0,j=S?r5(S[1],W):null,f=T?String(T[1]).split(/[\\/]/).pop():"audio";A.push({kind:"audio",label:f,from:Math.max(0,C),duration:j!=null?Math.max(1,j):Math.max(1,R-C)})}return{total:R,fps:H||void 0,sequences:M,audio:A,artboardId:q}}var K7=S8(v8(),1);function Vw({name:X,size:J=16}){let Q={x:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),sparkle:z("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:_(W0,{children:[z("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),z("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]})}[X];return z("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 YW0=["1:1","16:9","9:16","4:3","3:4","4:5"];function Bw({onClose:X,onInsert:J}){let[Q,Y]=K7.useState([]),[W,G]=K7.useState(""),[Z,H]=K7.useState([]),[q,K]=K7.useState(""),[V,B]=K7.useState("1:1"),[F,L]=K7.useState(""),[M,w]=K7.useState(!1),[R,A]=K7.useState(null),[D,P]=K7.useState(null),[T,I]=K7.useState(!0),[S,C]=K7.useState(null),j=K7.useRef(null),f=K7.useRef(null);K7.useEffect(()=>{fetch("/_api/generate/providers").then((i)=>i.json()).then((i)=>{let a=(i?.providers??[]).filter((s)=>s.modalities?.includes("image"));Y(a);let h=a.find((s)=>s.configured)??a[0];if(h)G(h.id)}).catch(()=>A({ok:!1,msg:"failed to load providers"}))},[]),K7.useEffect(()=>{if(!W)return;H([]),K("")},[W]),K7.useEffect(()=>{function i(a){if(a.key==="Escape")a.preventDefault(),X()}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[X]),K7.useEffect(()=>()=>clearInterval(j.current),[]),K7.useEffect(()=>{if(!D||!T||typeof J!=="function")return;if(f.current===D)return;f.current=D;let i=J(D)===!0;if(C(i),i)A({ok:!0,msg:"Placed on canvas ✓"});else A({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[D,T,J]);let m=Q.find((i)=>i.id===W),o=m&&!m.configured,n=K7.useCallback((i)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let h=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((s)=>s.id===i);if(!h)return;if(h.status==="done"){clearInterval(j.current),w(!1);let s=h.assets?.[0]??null;P(s),A({ok:!0,msg:s?`Generated ${s}`:"Done (no asset)"})}else if(h.status==="failed")clearInterval(j.current),w(!1),A({ok:!1,msg:h.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),w((a)=>{if(a)A({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function x(){if(!F.trim()||!W)return;w(!0),A(null),P(null),C(null),f.current=null;try{let i={modality:"image",provider:W,prompt:F.trim(),aspectRatio:V,...q?{model:q}:{}},a=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(i)});if(a.status===202){let{jobId:h}=await a.json();A({ok:!0,msg:"Generating…"}),n(h)}else w(!1),A({ok:!1,msg:await a.text()})}catch(i){w(!1),A({ok:!1,msg:i&&i.message?i.message:"request failed"})}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(i)=>{if(i.target===i.currentTarget)X()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Generate with AI"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:z(Vw,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:"Prompt"}),z("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:(i)=>L(i.target.value)}),_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-provider",children:"Provider"}),z("select",{id:"st-gen-provider",className:"st-select",value:W,onChange:(i)=>G(i.target.value),children:Q.map((i)=>_("option",{value:i.id,children:[i.label,i.configured?"":" — no key"]},i.id))})]}),Z.length>0&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-model",children:"Model"}),z("select",{id:"st-gen-model",className:"st-select",value:q,onChange:(i)=>K(i.target.value),children:Z.map((i)=>z("option",{value:i.id,children:i.label},i.id))})]}),_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-gen-aspect",children:"Aspect"}),z("select",{id:"st-gen-aspect",className:"st-select",value:V,onChange:(i)=>B(i.target.value),children:YW0.map((i)=>z("option",{value:i,children:i},i))})]}),J&&_("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[z("input",{type:"checkbox",checked:T,onChange:(i)=>I(i.target.checked),"aria-label":"Place the generated image on the canvas"}),z("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),o&&_("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",m.label," — add one in Settings (⌘,)."]}),D&&_("div",{className:"st-gen-result",children:[z("img",{className:"st-gen-thumb",src:`/${D}`,alt:"generated"}),_("div",{className:"st-gen-result-actions",children:[_("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${D}`),children:[z(Vw,{name:"copy",size:13})," Copy path"]}),J&&S!==!0&&z("button",{type:"button",className:"st-btn",onClick:()=>{let i=J(D)===!0;C(i),A(i?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),R&&z("div",{className:"st-provider-status",style:{color:R.ok?"var(--accent)":"var(--danger, #e5484d)"},children:R.msg}),z("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:_("button",{type:"button",className:"st-btn st-gen-go",disabled:M||!F.trim()||!W,onClick:x,children:[z(Vw,{name:"sparkle",size:14})," ",M?"Generating…":"Generate"]})})]})]})})}var p9=S8(v8(),1);var i2=new Set(["main","master"]);function x9({name:X,size:J=16,className:Q}){let Y={check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),"chevron-up":z("polyline",{points:"3.5 10 8 5.5 12.5 10"}),"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-open":_(W0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14"}),z("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:_(W0,{children:[z("circle",{cx:"4",cy:"8",r:"1.6"}),z("circle",{cx:"12",cy:"4",r:"1.6"}),z("circle",{cx:"12",cy:"12",r:"1.6"}),z("line",{x1:"5.4",y1:"7.2",x2:"10.6",y2:"4.6"}),z("line",{x1:"5.4",y1:"8.8",x2:"10.6",y2:"11.4"})]}),draft:_(W0,{children:[z("path",{d:"M3 11.5 11 3.5l1.5 1.5L4.5 13l-2 .5z"}),z("line",{x1:"9.5",y1:"5",x2:"11",y2:"6.5"})]}),branch:_(W0,{children:[z("circle",{cx:"4.5",cy:"4",r:"1.4"}),z("circle",{cx:"4.5",cy:"12",r:"1.4"}),z("circle",{cx:"11.5",cy:"6.5",r:"1.4"}),z("line",{x1:"4.5",y1:"5.4",x2:"4.5",y2:"10.6"}),z("path",{d:"M4.5 8.6h2.6a3 3 0 0 0 3-1.6"})]}),plus:_(W0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),"arrow-up-to-line":_(W0,{children:[z("line",{x1:"3.5",y1:"3",x2:"12.5",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"6"}),z("polyline",{points:"5 8.5 8 5.5 11 8.5"})]}),cloud:z("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:_(W0,{children:[z("path",{d:"M12.5 8a4.5 4.5 0 1 1-1.3-3.2"}),z("polyline",{points:"12.8 2.5 12.8 5 10.3 5"})]}),spinner:z("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10.5"}),z("polyline",{points:"5 7.5 8 10.5 11 7.5"}),z("line",{x1:"3.5",y1:"13.2",x2:"12.5",y2:"13.2"})]}),close:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[X];return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function o2(X){return String(X).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(X)}function xf(X){return X.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Fw(X){return String(X).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function WW0(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 Nw(X){return(await fetch(X)).json()}async function n2(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}),Z=null;try{Z=await G.json()}catch{}return{ok:G.ok,status:G.status,json:Z}}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 Lw({project:X,liveBranch:J,remoteSync:Q,onGetLatest:Y}){let W=K9(),[G,Z]=p9.useState(null),[H,q]=p9.useState([]),[K,V]=p9.useState([]),[B,F]=p9.useState(!1),[L,M]=p9.useState(!1),[w,R]=p9.useState(""),[A,D]=p9.useState(!1),[P,T]=p9.useState(""),[I,S]=p9.useState(null),[C,j]=p9.useState(!1),[f,m]=p9.useState(!1),[o,n]=p9.useState(!1);async function x(w0){if(!K9()){window.open(w0,"_blank","noopener,noreferrer");return}try{await hy(w0)}catch{try{await navigator.clipboard.writeText(w0),j(!0)}catch{}}}let[i,a]=p9.useState(!1),[h,s]=p9.useState(""),[X0,c]=p9.useState(""),[V0,p]=p9.useState(""),[g,d]=p9.useState(!1),[K0,u0]=p9.useState(0),[J8,G8]=p9.useState(!1),s0=p9.useRef(null);if(p9.useEffect(()=>{let w0=!0;if((async()=>{try{let i0=await Nw("/_api/git/status");if(!w0)return;if(Z(i0),i0.repo&&W){let H9=await Nw("/_api/git/branches");if(w0)q(H9.branches||[])}}catch{}})(),W)cy().then((i0)=>w0&&V(i0||[])).catch(()=>{});return()=>{w0=!1}},[W]),p9.useEffect(()=>{if(!B||!W||!G?.repo)return;c(""),F0()},[B]),p9.useEffect(()=>{if(!B&&!L)return;let w0=(i0)=>{if(s0.current&&!s0.current.contains(i0.target))F(!1),M(!1),p("")};return document.addEventListener("mousedown",w0),()=>document.removeEventListener("mousedown",w0)},[B,L]),!G?.repo)return null;let D8=J||G.branch||"main",U8=i2.has(D8),q8=H.find((w0)=>i2.has(w0.name))?.name||"main",m8=(w0,i0)=>(i0.updatedAt||0)-(w0.updatedAt||0)||w0.name.localeCompare(i0.name),_8=V0.trim().toLowerCase(),G9=(w0)=>!_8||w0.name.toLowerCase().includes(_8),Z9=H.filter((w0)=>!i2.has(w0.name)).sort(m8),e0=Z9.filter(G9),p8=e0.filter((w0)=>w0.name!==D8),o8=!_8||q8.toLowerCase().includes(_8)||"shared version".includes(_8),$9=Z9.length>6,j0=X||o2(K[0]||"Project");if(!W)return z("div",{className:"rb-dock-wrap",children:z("div",{className:"rb-dock rb-dock--ro",children:_("span",{className:"rb-trigger rb-trigger--ro",title:`${j0} · branch: ${D8} — switch branches in your terminal`,children:[z("span",{className:"rb-trigger-icon",children:z(x9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),_("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[z(x9,{name:"branch",size:12}),_("span",{className:"rb-trigger-ver-name",children:["branch: ",D8]})]})]})})});async function F0(){try{let w0=await Nw("/_api/git/branches");q(w0.branches||[])}catch{}}async function U0(w0,i0){if(F(!1),w0===D8)return;s(w0),G8(i0==="remote"),c("");let H9=await n2("/_api/git/checkout",{name:w0});if(H9.ok&&H9.json?.ok)window.location.reload();else c(H9.json?.error||"Could not switch."),s(""),G8(!1)}async function k0(){if(g)return;d(!0),c("");let w0=await n2("/_api/git/fetch",{},{timeoutMs:45000});if(w0.ok&&w0.json?.ok){if(w0.json.fetchedAt)u0(w0.json.fetchedAt);await F0()}else if(w0.timedOut||w0.json?.timedOut)c("Couldn’t reach the remote — your local branches are still listed above.");else c(w0.status===401||w0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":w0.json?.error||"Could not fetch remote branches.");d(!1)}async function H0(){let w0=xf(w);if(!w0)return;a(!0),c("");let i0=await n2("/_api/git/branch",{name:w0});if(i0.ok&&i0.json?.ok)window.location.reload();else c(i0.json?.error||"Could not create the draft."),a(!1)}async function L0(){if(f||!Y)return;m(!0),c("");let w0=await Y();if(m(!1),w0&&!w0.ok&&!w0.conflict)c(w0.status===401||w0.authRequired?"Sign in with GitHub to get the latest.":w0.error||"Could not get the latest.")}async function N0(){T(D8),c("");let w0=await n2("/_api/git/fold",{name:D8},{timeoutMs:45000}),i0=w0.json;if(w0.ok&&i0?.ok&&i0.prUrl){S({url:i0.prUrl,number:i0.prNumber,repo:i0.repo}),T(""),F0();return}if(w0.ok&&i0?.ok&&i0.prUnavailable){S({message:i0.error||"Draft published, but the pull request could not be opened."}),T(""),F0();return}if(w0.ok&&i0?.ok){window.location.reload();return}c(w0.status===401?`Sign in with GitHub to add “${D8}” to ${q8}.`:i0?.error||"Could not add the branch."),T("")}async function t0(w0){if(F(!1),!W)return;s(o2(w0));try{await RJ(w0)}catch(i0){c(String(i0?.message||i0||"Could not open that project.")),s("")}}async function $8(){if(F(!1),!W)return;try{let w0=await YY();if(!w0)return;s(o2(w0)),await RJ(w0)}catch(w0){c(String(w0?.message||w0||"Could not open that folder.")),s("")}}let y0=xf(w),v0=U8?null:H.find((w0)=>w0.current),O0=U8&&!o&&!h&&!P?[...H].filter((w0)=>!i2.has(w0.name)&&w0.where!=="remote").sort((w0,i0)=>(i0.updatedAt||0)-(w0.updatedAt||0))[0]:null,n0=_(W0,{children:[_("div",{className:"rb-pop-empty",children:["No branch matches “",V0.trim(),"”."]}),_("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:k0,disabled:g,children:[z("span",{className:"rb-pop-icon"+(g?" rb-pop-icon--spin":""),children:z(x9,{name:g?"spinner":"refresh",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:g?"Searching the remote…":"Search the remote for it"})})]})]}),Q8=(w0)=>{let i0=w0.where==="remote";return _("button",{type:"button","data-testid":`branch-row-${Fw(w0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>U0(w0.name,w0.where),children:[z("span",{className:"rb-pop-icon "+(i0?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:z(x9,{name:i0?"cloud":"draft",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:w0.name}),i0&&z("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},w0.name)};return _("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!h&&!P&&_("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:L0,disabled:f,title:`Get the latest ${q8}`,children:[z(x9,{name:f?"spinner":"download",size:14,className:f?"rb-spin":""}),z("span",{className:"rb-getlatest-tx",children:f?"Getting the latest…":"Get latest"}),!f&&Q.behind>0&&_("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",q8]})]}),O0&&_("div",{className:"rb-resume","data-testid":"switcher-resume",children:[_("button",{type:"button",className:"rb-resume-go",onClick:()=>U0(O0.name),title:`Switch to ${O0.name}`,children:[z("span",{className:"rb-resume-icon",children:z(x9,{name:"draft",size:13})}),_("span",{className:"rb-resume-tx",children:["Continue on ",z("b",{children:O0.name})]}),z(x9,{name:"chevron-right",size:12,className:"rb-resume-arrow"})]}),z("button",{type:"button",className:"rb-resume-x","data-testid":"switcher-resume-dismiss","aria-label":"Dismiss",onClick:()=>n(!0),children:z(x9,{name:"close",size:12})})]}),_("div",{className:"rb-dock",ref:s0,children:[B&&_("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:[z("div",{className:"rb-pop-hd",children:"Project"}),W&&K.length>0?K.map((w0,i0)=>_("button",{type:"button",className:"rb-pop-item"+(i0===0?" is-current":""),role:"menuitem",onClick:()=>t0(w0),children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"folder",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:o2(w0)}),z("span",{className:"rb-pop-sub",children:w0})]}),i0===0?z(x9,{name:"check",size:14,className:"rb-pop-check"}):null]},w0)):z("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&&_("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:$8,children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"folder-open",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open another folder…"})})]}),z("div",{className:"rb-pop-sep"}),z("div",{className:"rb-pop-hd",children:"Branch"}),U8?_(W0,{children:[_("button",{type:"button","data-testid":`branch-row-${Fw(q8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>U0(q8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(x9,{name:"share",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:q8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),z(x9,{name:"check",size:14,className:"rb-pop-check"})]}),Z9.length>0&&z("div",{className:"rb-pop-grouplabel",children:"Other branches"}),$9&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:V0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(w0)=>p(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Escape")p("")}})}),e0.map(Q8),$9&&_8&&e0.length===0&&!o8&&n0]}):_(W0,{children:[_("button",{type:"button",className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",children:[z("span",{className:"rb-pop-icon rb-pop-icon--draft",children:z(x9,{name:"draft",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:v0?.name||D8}),z("span",{className:"rb-pop-sub",children:"your branch"})]}),z(x9,{name:"check",size:14,className:"rb-pop-check"})]}),_("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{F(!1),c(""),S(null),j(!1),D(!0)},children:[z("span",{className:"rb-fold-icon",children:z(x9,{name:"arrow-up-to-line",size:15})}),_("span",{className:"rb-fold-tx",children:[_("span",{className:"rb-fold-title",children:["Merge this branch → ",q8]}),z("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),z("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),$9&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:V0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(w0)=>p(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Escape")p("")}})}),o8&&_("button",{type:"button","data-testid":`branch-row-${Fw(q8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>U0(q8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(x9,{name:"share",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:q8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),p8.map(Q8),$9&&_8&&p8.length===0&&!o8&&n0]}),_("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:k0,disabled:g,children:[z("span",{className:"rb-pop-icon"+(g?" rb-pop-icon--spin":""),children:z(x9,{name:g?"spinner":"refresh",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:g?"Fetching…":"Fetch remote branches"}),z("span",{className:"rb-pop-sub",children:K0?`as of ${WW0(K0)}`:"check the remote for new branches"})]})]}),X0&&!h&&z("div",{className:"rb-pop-notice",role:"alert",children:X0}),_("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{F(!1),M(!0)},children:[z("span",{className:"rb-pop-icon",children:z(x9,{name:"plus",size:14})}),_("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:"New branch"}),z("span",{className:"rb-pop-sub",children:"a separate line of work off what you're looking at now"})]})]})]}),L&&_("div",{className:"rb-newdraft rb-newdraft--up",children:[_("label",{className:"rb-newdraft-field",children:[z("span",{className:"rb-newdraft-label",children:"Name your branch"}),z("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:(w0)=>R(w0.target.value),onKeyDown:(w0)=>{if(w0.key==="Enter"&&y0)H0();if(w0.key==="Escape")M(!1),R("")}}),y0&&_("span",{className:"rb-pop-sub",children:["Creates branch ",z("b",{children:y0})]})]}),X0&&z("span",{className:"rb-newdraft-err",children:X0}),_("div",{className:"rb-newdraft-actions",children:[z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{M(!1),R(""),c("")},disabled:i,children:"Cancel"}),_("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:H0,disabled:i||!y0,children:[z(x9,{name:"draft",size:13})," ",i?"Creating…":"Create branch"]})]}),_("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."]})]}),h||P?_("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(x9,{name:"spinner",size:14,className:"rb-spin"}),z("span",{children:P?_(W0,{children:["Merging ",z("b",{children:P})," → ",q8,"…"]}):J8?_(W0,{children:["Downloading ",z("b",{children:h}),"…"]}):_(W0,{children:["Opening ",z("b",{children:h}),"…"]})})]}):_("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((w0)=>{if(w0)p("");return!w0}),M(!1)},title:`${j0} · ${D8}`,children:[z("span",{className:"rb-trigger-icon",children:z(x9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),_("span",{className:"rb-trigger-ver"+(U8?"":" is-draft"),children:[z(x9,{name:U8?"share":"draft",size:12}),z("span",{className:"rb-trigger-ver-name",children:D8})]}),z(x9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),X0&&!B&&!L&&!h&&z("div",{className:"rb-switcher-err",role:"alert",children:X0})]}),A&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>{D(!1),S(null),j(!1)},children:z("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(w0)=>w0.stopPropagation(),onKeyDown:(w0)=>{if(w0.key==="Escape")D(!1),S(null),j(!1)},children:I?I.url?_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"share",size:20})}),_("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",I.number?` #${I.number}`:""]}),_("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",_("b",{children:["“",D8,"”"]})," is up as a pull request into ",z("b",{children:q8}),I.repo?_(W0,{children:[" of ",z("b",{children:I.repo})]}):null,". Review and merge it on GitHub — that keeps your team's review rules."]}),z("p",{className:"rb-sheet-meta rb-pr-url",children:I.url}),_("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{D(!1),S(null),j(!1)},children:"Close"}),_("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>x(I.url),children:[z(x9,{name:"share",size:15})," ",C?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"share",size:20})}),z("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:"Draft published"}),z("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:I.message}),z("div",{className:"rb-sheet-actions",children:z("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{D(!1),S(null),j(!1)},children:"Got it"})})]}):_(W0,{children:[z("span",{className:"rb-sheet-icon",children:z(x9,{name:"arrow-up-to-line",size:20})}),_("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",q8]}),_("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",_("b",{children:["“",v0?.name||D8,"”"]})," to ",z("b",{children:q8})," — the default branch everyone shares."]}),z("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."}),X0&&z("p",{className:"rb-newdraft-err",children:X0}),_("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{D(!1),c("")},children:"Cancel"}),_("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!P,onClick:N0,children:[z(x9,{name:"arrow-up-to-line",size:15})," ",P?"Adding…":`Add to ${q8}`]})]})]})})})]})}var k9=S8(v8(),1);function EG({name:X,size:J=16}){let Q={x:_(W0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:_(W0,{children:[z("circle",{cx:"5.5",cy:"5.5",r:"3"}),z("path",{d:"M7.6 7.6 13 13"}),z("line",{x1:"11",y1:"11",x2:"12.5",y2:"9.5"})]}),check:z("polyline",{points:"3.5 8.5 6.5 11.5 12.5 4.5"}),external:_(W0,{children:[z("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"}),z("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),z("polyline",{points:"9.5 3 13 3 13 6.5"})]}),cloud:z("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 z("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 GW0({provider:X,onChanged:J}){let[Q,Y]=k9.useState(""),[W,G]=k9.useState(!1),[Z,H]=k9.useState(null),q=X.configured;async function K(){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 V(){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 _("div",{className:"st-provider-card",children:[_("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:X.label}),z("span",{className:"st-pill"+(X.kind==="local"?" is-local":""),children:X.kind==="local"?"Local":_(W0,{children:[z(EG,{name:"cloud",size:12})," Cloud"]})}),q&&_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," configured"]})]}),z("div",{className:"st-provider-modalities",children:X.modalities.join(" · ")}),X.notes&&z("div",{className:"st-provider-notes",children:X.notes}),X.keyUrl&&_("a",{className:"st-provider-keylink",href:X.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",z(EG,{name:"external",size:12})]}),X.auth==="api-key"&&_("div",{className:"st-provider-keyrow",children:[z("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:q?"•••••••• 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")K()}}),_("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:K,children:[z(EG,{name:"key",size:13})," Save"]}),q&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:V,children:"Remove"})]}),Z&&z("div",{className:"st-provider-status",style:{color:Z.ok?"var(--accent)":"var(--danger, #e5484d)"},children:Z.msg})]})}var ZW0=[{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 HW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(!1),[W,G]=k9.useState(null);k9.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 Z(H){if(H===X)return;let q=X;J(H),Y(!0),G(null);try{let K=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:H})});if(!K.ok)throw Error(await K.text());G({ok:!0,msg:"Saved."})}catch(K){J(q),G({ok:!1,msg:K&&K.message?K.message:"save failed"})}finally{Y(!1)}}return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:ZW0.map((H)=>_("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"transcription-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>Z(H.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:H.label}),z("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function qW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(null),W=k9.useCallback(()=>{fetch("/_api/generate/whisper-model").then((K)=>K.ok?K.json():Promise.reject(Error(`HTTP ${K.status}`))).then(J).catch((K)=>Y(K&&K.message?K.message:"failed to load models"))},[]);k9.useEffect(()=>{W()},[W]),k9.useEffect(()=>{if(!X?.downloading)return;let K=setInterval(W,1000);return()=>clearInterval(K)},[X?.downloading,W]);async function G(K){Y(null);try{let V=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:K})});if(!V.ok)throw Error(await V.text());W()}catch(V){Y(V&&V.message?V.message:"download failed")}}async function Z(K){Y(null);try{let V=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:K})});if(!V.ok)throw Error(await V.text());W()}catch(V){Y(V&&V.message?V.message:"remove failed")}}let H=X?.downloading,q=(K,V)=>V>0?Math.min(100,Math.round(K/V*100)):0;return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Local subtitle models (whisper.cpp)"})}),_("div",{className:"st-provider-notes",children:["Download a model once and local subtitles work offline, free, with no key. Requires the whisper.cpp binary (",z("code",{children:"brew install whisper-cpp"}),"). Models are stored on this machine only and never committed."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&_("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),X===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(X?.models||[]).map((K)=>{let V=H&&!H.error&&H.id===K.id;return _("div",{className:"st-model-row",children:[_("div",{className:"st-model-info",children:[_("span",{className:"st-model-label",children:[K.label,z("span",{className:"st-pill"+(K.multilingual?"":" is-local"),children:K.multilingual?"multilingual":"English-only"}),_("span",{className:"st-model-size",children:["~",K.sizeMB," MB"]})]}),z("span",{className:"st-engine-radio-note",children:K.note}),V&&_("span",{className:"st-model-progress",children:["Downloading… ",q(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:K.downloaded?_(W0,{children:[_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," ready"]}),z("button",{type:"button",className:"st-btn",onClick:()=>Z(K.id),children:"Remove"})]}):z("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(K.id),children:V?"Downloading…":"Download"})})]},K.id)})})]})}var zW0=[{id:"auto",label:"Auto",note:"Use the best available: Gemma scout → ffmpeg → blind."},{id:"gemma",label:"Gemma scout",note:"Semantic action beats. Needs Apple Silicon + mlx-vlm + a model."},{id:"ffmpeg",label:"ffmpeg scene-detect",note:"Scene cuts + endpoints. Needs ffmpeg. No model download."},{id:"blind",label:"Blind (even-spaced)",note:"Chromium fallback — works with neither ffmpeg nor Gemma."}];function KW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(!1),[W,G]=k9.useState(null);k9.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>J(H?.keyframeEngine||"auto")).catch(()=>J("auto"))},[]);async function Z(H){if(H===X)return;let q=X;J(H),Y(!0),G(null);try{let K=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({keyframeEngine:H})});if(!K.ok)throw Error(await K.text());G({ok:!0,msg:"Saved."})}catch(K){J(q),G({ok:!1,msg:K&&K.message?K.message:"save failed"})}finally{Y(!1)}}return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Scene-aware keyframes — analysis engine"})}),_("div",{className:"st-provider-notes",children:["How Maude picks frames when it analyzes a video (`/design:video-analyze`, `/design:reel`). Scene-aware beats a blind frame rate. This is an explicit choice — a chosen-but-unavailable engine tells you how to fix it; ",z("strong",{children:"Auto"})," just uses the best you have installed."]}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Keyframe engine",children:zW0.map((H)=>_("label",{className:"st-engine-radio"+(X===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"keyframe-engine",value:H.id,checked:X===H.id,disabled:Q||X===null,onChange:()=>Z(H.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:H.label}),z("span",{className:"st-engine-radio-note",children:H.note})]})]},H.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function UW0(){let[X,J]=k9.useState(null),[Q,Y]=k9.useState(null),W=k9.useCallback(()=>{fetch("/_api/generate/keyframe-model").then((B)=>B.ok?B.json():Promise.reject(Error(`HTTP ${B.status}`))).then(J).catch((B)=>Y(B&&B.message?B.message:"failed to load models"))},[]);k9.useEffect(()=>{W()},[W]),k9.useEffect(()=>{if(!X?.downloading)return;let B=setInterval(W,1500);return()=>clearInterval(B)},[X?.downloading,W]);async function G(B){Y(null);try{let F=await fetch("/_api/generate/keyframe-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:B})});if(!F.ok)throw Error(await F.text());W()}catch(F){Y(F&&F.message?F.message:"download failed")}}let Z=X?.downloading,H=X?.mlxVlmAvailable,q=X?.ffmpegAvailable,K=(B,F)=>F>0?Math.min(100,Math.round(B/F*100)):0;return _("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Gemma scout model (optional)"})}),_("div",{className:"st-provider-notes",children:["The ",z("strong",{children:"Gemma"})," tier adds semantic action-beat detection on top of scene cuts. It needs an ",z("strong",{children:"Apple-Silicon Mac"})," and the ",z("code",{children:"mlx-vlm"})," runtime (",z("code",{children:"pip install mlx-vlm"})," — a manual step Maude can’t do for you). Downloading a model below is the one-click half. Models live in your HuggingFace cache, never committed."]}),X&&_("div",{className:"st-provider-notes",children:["On this machine the active tier is ",z("strong",{children:H?"Gemma scout":q?"ffmpeg scene-detect":"blind (even-spaced)"}),!H&&q&&" — install mlx-vlm + download a model to unlock the Gemma scout.",!H&&!q&&" — install ffmpeg for scene-aware frames, or mlx-vlm for the Gemma scout."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),Z?.error&&_("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",Z.id," failed: ",Z.error]}),X===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(X?.models||[]).map((B)=>{let F=Z&&!Z.error&&Z.id===B.id;return _("div",{className:"st-model-row",children:[_("div",{className:"st-model-info",children:[_("span",{className:"st-model-label",children:[B.label,_("span",{className:"st-model-size",children:["~",Math.round(B.sizeMB/100)/10," GB"]})]}),z("span",{className:"st-engine-radio-note",children:B.note}),F&&_("span",{className:"st-model-progress",children:["Downloading… ",K(Z.received,Z.total),"%"]})]}),z("div",{className:"st-model-actions",children:B.downloaded?_("span",{className:"st-provider-configured",children:[z(EG,{name:"check",size:12})," ready"]}):z("button",{type:"button",className:"st-btn",disabled:!H||!!(Z&&!Z.error),title:H?"":"Install mlx-vlm first (pip install mlx-vlm)",onClick:()=>G(B.id),children:F?"Downloading…":H?"Download":"Needs mlx-vlm"})})]},B.id)})})]})}var kJ=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation"},{id:"subtitles",label:"Subtitles"},{id:"video",label:"Video"}],hf="mdcc-settings-tab",VW0=[{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 BW0({value:X,disabled:J,onChange:Q}){return z("span",{className:"st-sidetoggle",role:"radiogroup","aria-label":"Panel side",children:["left","right"].map((Y)=>z("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 FW0=[{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 NW0({panelSide:X,onSetPanelSide:J,layersMode:Q,onSetLayersMode:Y}){return _(W0,{children:[_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Layers panel"})}),z("div",{className:"st-provider-notes",children:"Show Layers as its own dockable panel, or as a tab inside the Inspector."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Layers mode",children:FW0.map((W)=>_("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"layers-mode",checked:Q===W.id,onChange:()=>Y(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Panel positions"})}),z("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."}),VW0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return _("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[_("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:W.label}),G&&z("span",{className:"st-pref-note",children:"Layers is inside the Inspector — choose “Separate panel” above to dock it."})]}),z(BW0,{value:X?.[W.id]||"left",disabled:G,onChange:(Z)=>J(W.id,Z)})]},W.id)})]})]})}function r2({label:X,note:J,checked:Q,disabled:Y,reason:W,onChange:G}){return _("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[_("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:X}),(W||J)&&z("span",{className:"st-pref-note",children:Y&&W?W:J})]}),z("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(Z)=>G?.(Z.target.checked)})]})}var LW0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],DW0=[{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 MW0({theme:X,onSetTheme:J,cpMode:Q,onSetCpMode:Y}){return _(W0,{children:[_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Theme"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Theme",children:LW0.map((W)=>_("label",{className:"st-engine-radio"+(X===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-theme",value:W.id,checked:X===W.id,onChange:()=>J?.(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]}),_("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Inspector vocabulary"})}),z("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."}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Inspector vocabulary",children:DW0.map((W)=>_("label",{className:"st-engine-radio"+(Q===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-cp-mode",value:W.id,checked:Q===W.id,onChange:()=>Y?.(W.id)}),_("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:W.label}),z("span",{className:"st-engine-radio-note",children:W.note})]})]},W.id))})]})]})}function Dw({onClose:X,initialTab:J,theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G,minimapVisible:Z,onToggleMinimap:H,zoomCtlVisible:q,onToggleZoomCtl:K,annotationsVisible:V,onToggleAnnotations:B,autoOpenInspector:F,onToggleAutoOpenInspector:L,hasCanvas:M=!1,panelSide:w,onSetPanelSide:R,layersMode:A,onSetLayersMode:D}){let[P,T]=k9.useState(null),[I,S]=k9.useState(null),[C,j]=k9.useState(()=>{if(J&&kJ.some((n)=>n.id===J))return J;try{let n=localStorage.getItem(hf);if(n&&kJ.some((x)=>x.id===n))return n}catch{}return"appearance"});k9.useEffect(()=>{try{localStorage.setItem(hf,C)}catch{}},[C]);let f=k9.useCallback(()=>{fetch("/_api/generate/providers").then((n)=>{if(!n.ok)throw Error(`HTTP ${n.status}`);return n.json()}).then((n)=>T(Array.isArray(n?.providers)?n.providers:[])).catch((n)=>S(n&&n.message?n.message:"failed to load providers"))},[]);k9.useEffect(()=>{f()},[f]),k9.useEffect(()=>{function n(x){if(x.key==="Escape")x.preventDefault(),X()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[X]);function m(n){let x=kJ.findIndex((i)=>i.id===C);if(n.key==="ArrowDown"||n.key==="ArrowRight")n.preventDefault(),j(kJ[(x+1)%kJ.length].id);else if(n.key==="ArrowUp"||n.key==="ArrowLeft")n.preventDefault(),j(kJ[(x-1+kJ.length)%kJ.length].id);else if(n.key==="Home")n.preventDefault(),j(kJ[0].id);else if(n.key==="End")n.preventDefault(),j(kJ[kJ.length-1].id)}let o=!M?"Open a canvas to use this.":void 0;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)X()},children:_("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Settings"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:X,children:z(EG,{name:"x",size:15})})]}),_("div",{className:"st-settings-tabs",children:[z("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:m,children:kJ.map((n)=>z("button",{type:"button",role:"tab",id:`st-stab-${n.id}`,"aria-controls":`st-spanel-${n.id}`,"aria-selected":C===n.id,tabIndex:C===n.id?0:-1,className:"st-settings-tab"+(C===n.id?" is-active":""),onClick:()=>j(n.id),children:n.label},n.id))}),_("div",{className:"st-settings-pane",children:[_("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:C!=="appearance",children:[z("div",{className:"st-rp-hd",children:"Appearance"}),z(MW0,{theme:Q,onSetTheme:Y,cpMode:W,onSetCpMode:G})]}),_("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:C!=="canvas-view",children:[z("div",{className:"st-rp-hd",children:"Canvas & View"}),z(r2,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:Z,disabled:!M,reason:o,onChange:()=>H?.()}),z(r2,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:q,disabled:!M,reason:o,onChange:()=>K?.()}),z(r2,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:V,onChange:()=>B?.()}),z(r2,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>L?.()})]}),_("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:C!=="layout",children:[z("div",{className:"st-rp-hd",children:"Layout"}),z(NW0,{panelSide:w,onSetPanelSide:R,layersMode:A,onSetLayersMode:D})]}),_("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:C!=="ai-generation",children:[z("div",{className:"st-rp-hd",children:"Provider keys"}),_("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"," ",z("code",{children:"~/.config/maude/keys.json"})," (mode 0600) — sent straight to the provider, and never committed, logged, or exposed to a canvas."]}),I&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:I}),P===null&&!I&&z("div",{className:"st-settings-intro",children:"Loading…"}),P?.map((n)=>z(GW0,{provider:n,onChanged:f},n.id)),P?.length===0&&z("div",{className:"st-settings-intro",children:"No providers registered."})]}),_("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:C!=="subtitles",children:[z("div",{className:"st-rp-hd",children:"Subtitles"}),z(HW0,{}),z(qW0,{})]}),_("section",{role:"tabpanel",id:"st-spanel-video","aria-labelledby":"st-stab-video",hidden:C!=="video",children:[z("div",{className:"st-rp-hd",children:"Video"}),z(KW0,{}),z(UW0,{})]})]})]})]})})}var y4=S8(v8(),1);function OW0({name:X,size:J=15}){if(X==="x")return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})});return null}function Mw({onPick:X,onClose:J}){let[Q,Y]=y4.useState(null),[W,G]=y4.useState("");y4.useEffect(()=>{let q=!0;return fetch("/_api/stickers").then((K)=>K.json()).then((K)=>q&&Y(K.ok?K.packs:[])).catch(()=>q&&Y([])),()=>{q=!1}},[]),y4.useEffect(()=>{let q=(K)=>{if(K.key==="Escape")K.stopPropagation(),J()};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[J]);let Z=y4.useMemo(()=>{if(!Q)return[];let q=W.trim().toLowerCase();if(!q)return Q;return Q.map((K)=>({...K,stickers:K.stickers.filter((V)=>V.file.toLowerCase().includes(q)||(V.keywords||[]).some((B)=>B.toLowerCase().includes(q)))})).filter((K)=>K.stickers.length>0)},[Q,W]),H=Z.reduce((q,K)=>q+K.stickers.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:_("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Stickers"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:J,children:z(OW0,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("input",{className:"input",type:"text",value:W,onChange:(q)=>G(q.target.value),placeholder:"Search stickers…","aria-label":"Search stickers",autoFocus:!0}),z("div",{className:"st-sp-body",children:Q==null?z("div",{className:"st-sp-empty",children:"Loading…"}):H===0?z("div",{className:"st-sp-empty",children:W.trim()?`No stickers match "${W.trim()}"`:"No stickers bundled"}):Z.map((q)=>_("div",{children:[_("div",{className:"st-sp-pack-hd",children:[z("span",{className:"st-sp-pack-name",children:q.name}),q.author&&_("span",{className:"st-sp-pack-author",children:["by ",q.author]})]}),z("div",{className:"st-sp-grid",children:q.stickers.map((K)=>z("button",{type:"button",className:"st-sp-cell",title:K.keywords?.[0]||K.file,onClick:()=>X(K),children:z("img",{className:"st-sp-thumb",src:K.url,alt:K.keywords?.[0]||K.file,loading:"lazy"})},K.file))})]},q.slug))})]}),Q&&Q.length>0&&z("div",{className:"st-sp-ft",children:Q.map((q)=>_("span",{children:[q.name,q.author?` — ${q.author}`:"",q.attributionUrl?_(W0,{children:[" ","(",z("a",{href:q.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},q.slug))})]})})}var g6=S8(v8(),1);var t2=S8(v8(),1);var a2=(...X)=>X.filter((J,Q,Y)=>{return Boolean(J)&&J.trim()!==""&&Y.indexOf(J)===Q}).join(" ").trim();var gf=(X)=>X.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var mf=(X)=>X.replace(/^([A-Z])|[\s-_]+(\w)/g,(J,Q,Y)=>Y?Y.toUpperCase():Q.toLowerCase());var Ow=(X)=>{let J=mf(X);return J.charAt(0).toUpperCase()+J.slice(1)};var JU=S8(v8(),1);var s2={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 uf=(X)=>{for(let J in X)if(J.startsWith("aria-")||J==="role"||J==="title")return!0;return!1};var sH=S8(v8(),1),wW0=sH.createContext({});var lf=()=>sH.useContext(wW0);var df=JU.forwardRef(({color:X,size:J,strokeWidth:Q,absoluteStrokeWidth:Y,className:W="",children:G,iconNode:Z,...H},q)=>{let{size:K=24,strokeWidth:V=2,absoluteStrokeWidth:B=!1,color:F="currentColor",className:L=""}=lf()??{},M=Y??B?Number(Q??V)*24/Number(J??K):Q??V;return JU.createElement("svg",{ref:q,...s2,width:J??K??s2.width,height:J??K??s2.height,stroke:X??F,strokeWidth:M,className:a2("lucide",L,W),...!G&&!uf(H)&&{"aria-hidden":"true"},...H},[...Z.map(([w,R])=>JU.createElement(w,R)),...Array.isArray(G)?G:[G]])});var Y8=(X,J)=>{let Q=t2.forwardRef(({className:Y,...W},G)=>t2.createElement(df,{ref:G,iconNode:J,className:a2(`lucide-${gf(Ow(X))}`,`lucide-${X}`,Y),...W}));return Q.displayName=Ow(X),Q};var AW0=[["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"}]],QU=Y8("a-large-small",AW0);var _W0=[["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"}]],YU=Y8("align-horizontal-justify-center",_W0);var EW0=[["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"}]],WU=Y8("align-horizontal-justify-end",EW0);var PW0=[["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"}]],GU=Y8("align-horizontal-justify-start",PW0);var RW0=[["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"}]],tH=Y8("align-horizontal-space-between",RW0);var kW0=[["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"}]],ZU=Y8("align-vertical-justify-center",kW0);var TW0=[["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"}]],HU=Y8("align-vertical-justify-end",TW0);var IW0=[["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"}]],qU=Y8("align-vertical-justify-start",IW0);var CW0=[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]],zU=Y8("baseline",CW0);var SW0=[["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"}]],KU=Y8("bold",SW0);var $W0=[["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"}]],f4=Y8("braces",$W0);var bW0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],UU=Y8("chevron-down",bW0);var jW0=[["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"}]],v4=Y8("columns-3",jW0);var yW0=[["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"}]],VU=Y8("diamond",yW0);var fW0=[["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"}]],BU=Y8("eye-off",fW0);var vW0=[["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"}]],PG=Y8("eye",vW0);var xW0=[["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"}]],FU=Y8("italic",xW0);var hW0=[["path",{d:"M5 12h14",key:"1ays0h"}]],NU=Y8("minus",hW0);var gW0=[["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"}]],LU=Y8("move-horizontal",gW0);var mW0=[["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"}]],DU=Y8("rotate-ccw",mW0);var uW0=[["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"}]],RG=Y8("rotate-cw",uW0);var lW0=[["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"}]],x4=Y8("rows-3",lW0);var dW0=[["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"}]],MU=Y8("scissors",dW0);var pW0=[["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"}]],OU=Y8("scroll-text",pW0);var cW0=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],wU=Y8("search",cW0);var iW0=[["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"}]],AU=Y8("spline",iW0);var oW0=[["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"}]],h4=Y8("square-dashed",oW0);var nW0=[["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"}]],_U=Y8("stretch-horizontal",nW0);var rW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],g4=Y8("text-align-center",rW0);var aW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],m4=Y8("text-align-end",aW0);var sW0=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],u4=Y8("text-align-justify",sW0);var tW0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],J5=Y8("text-align-start",tW0);var eW0=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],EU=Y8("underline",eW0);var XG0=[["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"}]],l4=Y8("wand-sparkles",XG0);var JG0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],PU=Y8("x",JG0);var d4=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block",flex:"none"}}),ww=(X)=>X.replace(/^--/,"").replace(/-/g," "),p4=(X,J,Q)=>{let Y=X;if(J!=null&&Y<J)Y=J;if(Q!=null&&Y>Q)Y=Q;return Y},QG0=(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},eH=(X,J)=>{let Q=QG0(J);return Number(X.toFixed(Q))};function Aw({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return(q)=>{if(q.button!==0)return;let K=q.clientX,V=Number.parseFloat(X())||0,B=!1,F=V,L=(R)=>{if(!H)return;if(R.altKey&&R.shiftKey)return H.all;if(R.altKey)return H.pair;return},M=(R)=>{let A=R.clientX-K;if(!B&&Math.abs(A)<3)return;if(!B)B=!0,document.body.classList.add("st-scrubbing");R.preventDefault();let D=H?1:R.shiftKey?10:R.altKey?0.1:1;F=eH(p4(V+A*Y*Z*D,J,Q),Y),W?.(F,L(R))},w=(R)=>{if(document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",w),!B)return;document.body.classList.remove("st-scrubbing"),G?.(F,L(R))};document.addEventListener("pointermove",M),document.addEventListener("pointerup",w)}}function YG0({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return g6.useCallback(Aw({getBase:X,min:J,max:Q,step:Y,onInput:W,onCommit:G,sensitivity:Z,sides:H}),[X,J,Q,Y,W,G,Z,H])}function Q5({value:X,min:J,max:Q,step:Y=1,lead:W,scrub:G=!0,steppers:Z=!0,unitSlot:H,sensitivity:q=1,sides:K,format:V,parse:B,onInput:F,onCommit:L,ariaLabel:M,className:w=""}){let R=g6.useRef(null),A=g6.useCallback((m)=>V?V(m):String(eH(Number(m)||0,Y)),[V,Y]),D=(m)=>(typeof m==="number"?m:Number.parseFloat(m))||0;g6.useEffect(()=>{if(R.current&&document.activeElement!==R.current)R.current.value=A(X)},[X,A]);let P=(m,o)=>{let n=eH(p4(m,J,Q),Y);if(R.current)R.current.value=A(n);L?.(n,o)},I=YG0({getBase:()=>R.current?R.current.value:D(X),min:J,max:Q,step:Y,sensitivity:q,sides:K,onInput:(m,o)=>{let n=eH(p4(m,J,Q),Y);if(R.current)R.current.value=A(n);F?.(n,o)},onCommit:P}),S=(m,o)=>P(D(R.current?.value??X)+m*Y*o),C=(m)=>{let o=m.shiftKey?10:1;if(m.key==="ArrowUp")m.preventDefault(),S(1,o);else if(m.key==="ArrowDown")m.preventDefault(),S(-1,o);else if(m.key==="PageUp")m.preventDefault(),S(1,10);else if(m.key==="PageDown")m.preventDefault(),S(-1,10);else if(m.key==="Home"&&J!=null)m.preventDefault(),P(J);else if(m.key==="End"&&Q!=null)m.preventDefault(),P(Q);else if(m.key==="Enter")m.currentTarget.blur()},j=(m)=>{let o=m.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===o)o.select()})},f=(m)=>{let o=String(m.currentTarget.value).trim();if(o==="")return;let n=B?B(o):Number.parseFloat(o);if(n==null||Number.isNaN(n)){m.currentTarget.value=A(X);return}P(n)};return _("div",{className:`st-cp-num ${w}`.trim(),children:[G?z("span",{className:"st-cp-numlead st-cp-handle",role:"presentation","aria-hidden":"true",title:"Drag to change · Shift ×10 · Alt fine",onPointerDown:I,children:W??z("span",{className:"st-cp-grip"})}):W?z("span",{className:"st-cp-numlead","aria-hidden":"true",children:W}):null,z("input",{ref:R,className:"st-cp-numin",role:"spinbutton","aria-label":M,"aria-valuenow":D(X),"aria-valuemin":J,"aria-valuemax":Q,defaultValue:A(X),inputMode:"decimal",onFocus:j,onKeyDown:C,onBlur:f}),Z?_("span",{className:"st-cp-step",children:[z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`increase ${M||"value"}`,onClick:()=>S(1,1),children:"▲"}),z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`decrease ${M||"value"}`,onClick:()=>S(-1,1),children:"▼"})]}):null,H??null]})}function WG0({value:X,min:J=0,max:Q=1,step:Y=0.01,onInput:W,onCommit:G,ariaLabel:Z}){let H=g6.useRef(null),q=p4(X??(J<0?0:J),J,Q),K=Q-J||1,V=(q-J)/K,B=J<0&&Q>0?(0-J)/K:0,F=Math.min(V,B),L=Math.abs(V-B),M=(A)=>{let D=H.current?.getBoundingClientRect();if(!D||D.width===0)return q;let P=p4((A-D.left)/D.width,0,1);return eH(J+P*K,Y)};return z("div",{className:"st-cp-slider",children:_("div",{ref:H,className:"st-cp-track",role:"slider",tabIndex:0,"aria-label":Z,"aria-valuemin":J,"aria-valuemax":Q,"aria-valuenow":q,onPointerDown:(A)=>{if(A.button!==0)return;A.preventDefault(),H.current?.focus();let D=M(A.clientX);W?.(D);let P=(I)=>{D=M(I.clientX),W?.(D)},T=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",T),G?.(D)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",T)},onKeyDown:(A)=>{let D=A.shiftKey?10:1,P=null;if(A.key==="ArrowRight"||A.key==="ArrowUp")P=q+Y*D;else if(A.key==="ArrowLeft"||A.key==="ArrowDown")P=q-Y*D;else if(A.key==="PageUp")P=q+Y*10;else if(A.key==="PageDown")P=q-Y*10;else if(A.key==="Home")P=J;else if(A.key==="End")P=Q;if(P!=null)A.preventDefault(),G?.(eH(p4(P,J,Q),Y))},children:[J<0&&Q>0?z("span",{className:"st-cp-zero",style:{left:`${B*100}%`}}):null,z("span",{className:"st-cp-fill",style:{left:`${F*100}%`,width:`${L*100}%`}}),z("span",{className:"st-cp-thumb",style:{left:`${V*100}%`}})]})})}function a5({value:X,min:J=0,max:Q=1,step:Y=0.01,unit:W="",onInput:G,onCommit:Z,ariaLabel:H}){let q=X??(J<0?0:J);return _("div",{className:"st-cp-sfield",children:[z(WG0,{value:q,min:J,max:Q,step:Y,onInput:G,onCommit:Z,ariaLabel:H}),z(Q5,{className:"st-cp-num--compact",value:q,min:J,max:Q,step:Y,scrub:!1,steppers:!1,unitSlot:W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null,onInput:G,onCommit:Z,ariaLabel:H})]})}function e2({value:X,units:J,onChange:Q,ariaLabel:Y}){return z("select",{className:"st-cp-unitsel","aria-label":Y,value:X,onChange:(W)=>Q(W.target.value),children:J.map((W)=>z("option",{value:W,children:W},W))})}function XB({value:X,options:J,onChange:Q,ariaLabel:Y}){return z("div",{className:"st-cp-seg",role:"radiogroup","aria-label":Y,children:J.map((W)=>{let G=typeof W==="string"?W:W.value,Z=typeof W==="string"?W:W.label??W.value;return z("button",{type:"button",role:"radio","aria-checked":X===G,className:`st-cp-segbtn${X===G?" is-active":""}`,onClick:()=>Q(G),children:Z},G)})})}function c4({value:X,options:J,onChange:Q,ariaLabel:Y,mini:W=!1}){return z("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 Z=typeof G==="string"?G:G.value,H=typeof G==="string"?G:G.label??G.value;return z("option",{value:Z,children:H},Z)})})}function i4({checked:X,onChange:J,label:Q,ariaLabel:Y}){return _("label",{className:"st-cp-toggle",children:[z("input",{type:"checkbox",className:"st-cp-switch",checked:!!X,"aria-label":Y||Q,onChange:(W)=>J(W.target.checked)}),Q?z("span",{className:"st-cp-toggle-lbl",children:Q}):null]})}function _w({value:X,options:J,ariaLabel:Q,onChange:Y}){return z("div",{className:"st-cp-iconseg",role:"radiogroup","aria-label":Q,children:J.map((W)=>z("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 pf({value:X,options:J,ariaLabel:Q,onToggle:Y}){return z("div",{className:"st-cp-iconseg",role:"group","aria-label":Q,children:J.map((W)=>z("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 GG0=["tl","tc","tr","cl","cc","cr","bl","bc","br"];function cf({value:X,onChange:J,ariaLabel:Q="alignment"}){return z("div",{className:"st-cp-alignpad",role:"radiogroup","aria-label":Q,children:GG0.map((Y)=>z("button",{type:"button",role:"radio","aria-checked":X===Y,"aria-label":`align ${Y}`,className:X===Y?"is-active":"",onClick:()=>J(Y)},Y))})}function of({value:X,onChange:J,ariaLabel:Q="rotation"}){let Y=g6.useRef(null),W=(q,K)=>{let V=Y.current?.getBoundingClientRect();if(!V)return X;let B=Math.round(Math.atan2(K-(V.top+V.height/2),q-(V.left+V.width/2))*180/Math.PI);if(B<0)B+=360;return B},G=(q)=>{if(q.button!==0)return;q.preventDefault(),document.body.classList.add("st-scrubbing","st-scrubbing--dial"),J(W(q.clientX,q.clientY));let K=(B)=>J(W(B.clientX,B.clientY)),V=()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",V),document.body.classList.remove("st-scrubbing","st-scrubbing--dial")};document.addEventListener("pointermove",K),document.addEventListener("pointerup",V)},Z=X??0,H=(q)=>{let K=q.shiftKey?10:1,V=null;if(q.key==="ArrowRight"||q.key==="ArrowUp")V=Z+K;else if(q.key==="ArrowLeft"||q.key==="ArrowDown")V=Z-K;else if(q.key==="PageUp")V=Z+15;else if(q.key==="PageDown")V=Z-15;else if(q.key==="Home")V=0;else if(q.key==="End")V=360;if(V!=null)q.preventDefault(),J(p4(V,0,360))};return z("button",{ref:Y,type:"button",className:"st-cp-dial",role:"slider","aria-label":Q,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Z,"aria-valuetext":`${Z}°`,title:"drag to rotate · arrows to nudge",onPointerDown:G,onKeyDown:H,children:z("span",{className:"st-cp-dial-needle",style:{"--angle":`${X}deg`}})})}function nf({title:X,defaultOpen:J=!0,onReset:Q,right:Y,children:W}){let[G,Z]=g6.useState(J);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":G,onClick:()=>Z((H)=>!H),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:z(d4,{as:UU,size:12})}),X]}),Y??null,Q?z("button",{type:"button",className:"st-cp-secreset","aria-label":`reset ${X} section`,title:`reset ${X}`,onClick:Q,children:z(d4,{as:DU,size:12})}):null]}),z("div",{className:`st-cp-sec-anim${G?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:W})})]})}function RU({swatch:X,displayValue:J,bound:Q,alpha:Y,visible:W,ariaLabel:G,onValue:Z,onAlpha:H,onVisible:q}){return _("span",{className:"st-cp-cf",children:[X,z("input",{className:`st-cp-cf-in${Q?" is-bound":""}`,"aria-label":G,value:J,onChange:(K)=>Z?.(K.target.value),onFocus:(K)=>K.currentTarget.select(),readOnly:!Z}),H?z("input",{className:"st-cp-cf-alpha","aria-label":`${G||"colour"} alpha`,value:`${Y}`,onChange:(K)=>H(p4(Number.parseFloat(K.target.value)||0,0,100)),onFocus:(K)=>K.currentTarget.select()}):null,q?z("button",{type:"button",className:`st-cp-cf-eye${W?"":" is-off"}`,"aria-pressed":W,"aria-label":`${G||"colour"} visibility`,onClick:()=>q(!W),children:W?z(d4,{as:PG}):z(d4,{as:BU})}):null]})}function JB({value:X,tokens:J,ariaLabel:Q,lead:Y,unit:W,unitSlot:G,min:Z=0,max:H,step:q=1,onChange:K}){let[V,B]=g6.useState(!1),[F,L]=g6.useState(""),M=g6.useRef(null),w=typeof X==="string"&&X.startsWith("var("),R=w?X.replace(/^var\(\s*|\s*\)$/g,""):"",A=w?J.find((P)=>P.name===R)?.value??"":"";g6.useEffect(()=>{if(!V){L("");return}let P=(T)=>{if(!M.current?.contains(T.target))B(!1)};return document.addEventListener("pointerdown",P,!0),()=>document.removeEventListener("pointerdown",P,!0)},[V]);let D=F?J.filter((P)=>ww(P.name).includes(F)||(P.value||"").toLowerCase().includes(F)):J;return _("div",{className:"st-cp-tokfield",children:[w?_("div",{className:"st-cp-boundchip",title:`${R} = ${A}`,children:[Y?z("span",{className:"st-cp-boundchip-lead","aria-hidden":"true",children:Y}):null,z("span",{className:"st-cp-boundchip-name",children:ww(R)}),z("button",{type:"button",className:"st-cp-boundchip-x","aria-label":"detach token",title:"detach — back to a raw value",onClick:()=>K(Number.parseFloat(A)||0),children:z(d4,{as:PU,size:12})})]}):z(Q5,{value:typeof X==="number"?X:0,min:Z,max:H,step:q,ariaLabel:Q,lead:Y,steppers:!1,unitSlot:G??(W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null),onCommit:(P)=>K(P)}),_("span",{ref:M,style:{position:"relative",display:"inline-flex"},children:[z("button",{type:"button",className:`st-cp-tokbtn${w?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":V,"aria-label":`${Q} — bind a design token`,title:"bind a design token",onClick:()=>B((P)=>!P),children:z(d4,{as:VU,size:13})}),V?_("div",{className:"st-cp-pop",role:"dialog","aria-label":"design tokens",style:{left:"auto",right:0},children:[_("div",{className:"st-cp-pop-search",children:[z(d4,{as:wU,size:12}),z("input",{value:F,onChange:(P)=>L(P.target.value.toLowerCase()),placeholder:"Search variables","aria-label":"search variables"})]}),D.length?D.map((P)=>_("button",{type:"button",className:`st-cp-pop-row${R===P.name?" is-on":""}`,onClick:()=>{K(`var(${P.name})`),B(!1)},children:[z("span",{className:"st-cp-pop-name",children:ww(P.name)}),z("span",{className:"st-cp-pop-val",children:P.value})]},P.name)):z("div",{className:"st-cp-pop-empty",children:"No match"})]}):null]})]})}function rf({corners:X,lead:J,onCorners:Q}){let[Y,W]=g6.useState(!1),G=(H)=>Q({tl:H,tr:H,bl:H,br:H}),Z=(H)=>_("label",{className:"st-cp-corner",children:[z("span",{className:`st-cp-cnr st-cp-cnr--${H}`,"aria-hidden":"true"}),z("input",{"aria-label":`${H} radius`,value:X[H],onChange:(q)=>Q({...X,[H]:Number.parseFloat(q.target.value)||0}),onFocus:(q)=>q.currentTarget.select()})]});return _("div",{className:"st-cp-radius",children:[_("div",{className:"st-cp-radius-main",children:[z(Q5,{value:X.tl,min:0,max:200,ariaLabel:"border-radius",lead:J,steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(H)=>Y?Q({...X,tl:H}):G(H)}),z("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:z(d4,{as:h4,size:14})})]}),Y?_("div",{className:"st-cp-corners",children:[Z("tl"),Z("tr"),Z("bl"),Z("br")]}):null]})}var A6=S8(v8(),1);var ZG0=["dots","grid","lines","diagonal","crosshatch"],HG0=["normal","multiply","screen","overlay","soft-light"],qG0=["none","vignette","radial-reveal","edge-fade"],zG0=[{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}],af=(X)=>X?JSON.parse(JSON.stringify(X)):{};function KG0(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,Z]of Object.entries(Y))if(Z!=null&&Z!=="")W[G]=Z;if(Object.keys(W).length)J[Q]=W}else J[Q]=Y}return J}var o4={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 Xq({title:X,right:J,onReset:Q,children:Y}){return z(nf,{title:X,right:J,onReset:Q,children:Y})}function lX({label:X,tip:J,children:Q}){return _(W0,{children:[_("div",{style:o4.row,children:[z("span",{style:o4.label,children:X}),Q]}),J?z("div",{style:o4.tipBelow,children:J}):null]})}function Ew({value:X,fallback:J,label:Q,ColorPicker:Y,onApply:W}){let[G,Z]=A6.useState(!1),H=A6.useRef(null),q=X||J;return A6.useEffect(()=>{if(!G)return;let K=(V)=>{if(!H.current?.contains(V.target))Z(!1)};return document.addEventListener("pointerdown",K,!0),()=>document.removeEventListener("pointerdown",K,!0)},[G]),z(RU,{swatch:_("span",{className:"st-cp-tokwrap",ref:H,children:[z("button",{type:"button",className:"st-cp-cf-sw",style:{background:q},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:q,onClick:()=>Z((K)=>!K)}),G?z("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?z(Y,{seed:q,label:Q,onApply:W}):z("input",{type:"color",value:q,"aria-label":Q,onChange:(K)=>W(K.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(q||"").replace("#",""),ariaLabel:Q,onValue:(K)=>W(K.startsWith("#")?K:`#${K.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function sf({asset:X,initialEdit:J,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:Z}){let[H,q]=A6.useState(()=>af(J)),[K,V]=A6.useState(!J),[B,F]=A6.useState("idle"),[L,M]=A6.useState(!1),[w,R]=A6.useState(""),A=A6.useRef(null),D=A6.useRef(H);D.current=H,A6.useEffect(()=>{if(J||!X)return;let h=!1;return V(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`).then((s)=>s.ok?s.json():{}).then((s)=>{if(h)return;q(s&&typeof s==="object"?s:{}),V(!1)}).catch(()=>!h&&V(!1)),()=>{h=!0}},[X,J]);let P=A6.useCallback((h)=>{clearTimeout(A.current),A.current=setTimeout(async()=>{F("saving");try{let s=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(X)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(KG0(h))});F(s.ok?"saved":"error")}catch{F("error")}},160)},[X]),T=A6.useCallback((h,{commit:s=!1}={})=>{let X0=D.current,c=af(X0);if(h(c),q(c),Y?.(c),P(c),s)G?.(X0,c)},[Y,P,G]),I=(h,s,X0)=>T((c)=>{if(c.adjustments=c.adjustments||{},s===0||s==null)delete c.adjustments[h];else c.adjustments[h]=s;if(Object.keys(c.adjustments).length===0)delete c.adjustments},{commit:X0}),S=(h,s,X0)=>T((c)=>{c[h]={...c[h]||{},...s}},{commit:X0}),C=()=>T((h)=>delete h.adjustments,{commit:!0}),j=(h)=>T((s)=>{delete s[h]},{commit:!0}),f=async()=>{if(!W)return;M(!0),R("Removing background…");try{let h=await W(X);if(h?.maskAsset)S("backgroundRemoved",{enabled:!0,maskAsset:h.maskAsset},!0),R("Background removed");else R("Background removal failed")}catch{R("Background removal failed")}finally{M(!1)}};if(K)return z("div",{style:{...o4.body,opacity:0.6},children:"Loading photo edit…"});let m=H.adjustments||{},o=H.duotone||{},n=H.grain||{},x=H.pattern||{},i=H.mask||{},a=H.backgroundRemoved||{};return _("div",{style:o4.body,"data-testid":"photo-knobs",children:[_("div",{style:{...o4.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[z("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:X}),z("span",{style:{fontSize:10,color:B==="error"?"var(--status-error)":void 0},children:B==="saving"?"saving…":B==="error"?"⚠ save failed":B==="saved"?"saved":""})]}),z(Xq,{title:"Adjustments",onReset:C,children:zG0.map((h)=>z(lX,{label:h.label,children:z(a5,{value:m[h.key],min:h.min,max:h.max,step:h.step??0.01,unit:h.unit??"",ariaLabel:h.label,onInput:(s)=>I(h.key,s),onCommit:(s)=>I(h.key,s,!0)})},h.key))}),z(Xq,{title:"Duotone",right:z(i4,{checked:o.enabled,onChange:(h)=>S("duotone",{enabled:h},!0),label:"on"}),onReset:()=>j("duotone"),children:o.enabled&&_(W0,{children:[z(lX,{label:"Shadow",children:z(Ew,{value:o.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(h)=>S("duotone",{colorA:h},!0)})}),z(lX,{label:"Highlight",children:z(Ew,{value:o.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(h)=>S("duotone",{colorB:h},!0)})}),z(lX,{label:"Intensity",children:z(a5,{value:o.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(h)=>S("duotone",{intensity:h}),onCommit:(h)=>S("duotone",{intensity:h},!0)})})]})}),z(Xq,{title:"Grain",right:z(i4,{checked:n.enabled,onChange:(h)=>S("grain",{enabled:h},!0),label:"on"}),onReset:()=>j("grain"),children:n.enabled&&_(W0,{children:[z(lX,{label:"Amount",children:z(a5,{value:n.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(h)=>S("grain",{amount:h}),onCommit:(h)=>S("grain",{amount:h},!0)})}),z(lX,{label:"Size",children:z(a5,{value:n.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(h)=>S("grain",{size:h}),onCommit:(h)=>S("grain",{size:h},!0)})})]})}),z(Xq,{title:"Pattern",right:z(i4,{checked:x.enabled,onChange:(h)=>S("pattern",{enabled:h},!0),label:"on"}),onReset:()=>j("pattern"),children:x.enabled&&_(W0,{children:[z(lX,{label:"Type",children:z(c4,{value:x.type||"dots",options:ZG0,ariaLabel:"Pattern type",onChange:(h)=>S("pattern",{type:h},!0)})}),z(lX,{label:"Blend",children:z(c4,{value:x.blend||"normal",options:HG0,ariaLabel:"Pattern blend",onChange:(h)=>S("pattern",{blend:h},!0)})}),z(lX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:z(Ew,{value:x.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(h)=>S("pattern",{color:h},!0)})}),z(lX,{label:"Scale",children:z(a5,{value:x.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(h)=>S("pattern",{scale:h}),onCommit:(h)=>S("pattern",{scale:h},!0)})}),z(lX,{label:"Opacity",children:z(a5,{value:x.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(h)=>S("pattern",{opacity:h}),onCommit:(h)=>S("pattern",{opacity:h},!0)})})]})}),_(Xq,{title:"Mask",onReset:()=>j("mask"),children:[z(lX,{label:"Preset",children:z(c4,{value:i.preset||"none",options:qG0,ariaLabel:"Mask preset",onChange:(h)=>S("mask",{preset:h},!0)})}),i.preset&&i.preset!=="none"&&z(lX,{label:"Strength",children:z(a5,{value:i.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(h)=>S("mask",{strength:h}),onCommit:(h)=>S("mask",{strength:h},!0)})})]}),_(Xq,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[z("div",{style:{...o4.row,gap:10},"aria-busy":L||void 0,children:a.maskAsset?_(W0,{children:[z(i4,{checked:a.enabled,onChange:(h)=>S("backgroundRemoved",{enabled:h},!0),label:"applied"}),z("button",{type:"button",style:{...o4.reset,opacity:L?0.6:1},disabled:L||!W,title:"Run background removal again",onClick:()=>f(),children:L?"removing…":"redo"})]}):_("button",{type:"button",className:"st-btn",style:{opacity:L?0.6:1},disabled:L||!W,"data-testid":"photo-remove-bg",onClick:()=>f(),children:[Z?z(Z,{name:"sparkle",size:14}):null,L?"Removing…":"Remove Background"]})}),z("span",{"aria-live":"polite",className:"sr-only",children:w})]})]})}function Jq({name:X,size:J=16}){let Q={cursor:z("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:_(W0,{children:[z("circle",{cx:"6",cy:"6",r:"2.2"}),z("path",{d:"M2.4 13a3.6 3.6 0 0 1 7.2 0"}),z("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:z(W0,{children:z("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:_(W0,{children:[z("path",{d:"M3 2.5h7.5L13.5 5.5V13.5H3z"}),z("path",{d:"M5 2.5V6h5V2.5"}),z("rect",{x:"5.5",y:"9",width:"5",height:"3"})]}),publish:_(W0,{children:[z("line",{x1:"8",y1:"13.4",x2:"8",y2:"6"}),z("polyline",{points:"5 9 8 6 11 9"}),z("polyline",{points:"3 4 3 2.6 13 2.6 13 4"})]}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),"arrow-right":_(W0,{children:[z("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),z("polyline",{points:"9 4 13 8 9 12"})]})}[X];return z("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 Pw({icon:X,label:J,sub:Q}){return _("span",{className:"cm-step",children:[z("span",{className:"cm-step-icon",children:z(Jq,{name:X,size:16})}),z("span",{className:"cm-step-label",children:J}),z("span",{className:"cm-step-sub",children:Q})]})}function Rw(){return _("div",{className:"cm-info",children:[_("div",{className:"cm-live",children:[_("div",{className:"cm-live-hd",children:[z("span",{className:"cm-live-dot","aria-hidden":"true"}),_("span",{children:[z("b",{children:"Together"})," · automatic — no buttons"]})]}),_("div",{className:"cm-live-items",children:[_("span",{className:"cm-live-item",children:[z(Jq,{name:"cursor",size:13})," cursors"]}),_("span",{className:"cm-live-item",children:[z(Jq,{name:"people",size:13})," who's here"]}),_("span",{className:"cm-live-item",children:[z(Jq,{name:"comment",size:13})," comments"]})]}),z("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),_("div",{className:"cm-bridge","aria-hidden":"true",children:[z("span",{className:"cm-bridge-line"}),z("span",{className:"cm-bridge-label",children:"the work itself"}),z("span",{className:"cm-bridge-line"})]}),_("div",{className:"cm-cycle",children:[z(Pw,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(Jq,{name:"arrow-right",size:15})}),z(Pw,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(Jq,{name:"arrow-right",size:15})}),z(Pw,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var kw=[{render:Rw,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 i7=S8(v8(),1);function UG0(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 kG=320,Tw=184;function VG0(X){if(typeof window>"u"||!X)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:kG};let{innerWidth:J,innerHeight:Q}=window;if(X.left>kG+36&&J-X.right<kG+36)return{top:Math.min(Math.max(12,X.top),Q-Tw-12),left:Math.max(12,X.left-kG-16),width:kG};let G=Q-X.bottom>Tw+24?X.bottom+12:Math.max(12,X.top-Tw-12),Z=Math.min(Math.max(12,X.left),J-kG-12);return{top:G,left:Z,width:kG}}function tf({steps:X,open:J,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:Z}){let[H,q]=i7.useState(0),[K,V]=i7.useState(null),B=i7.useRef(null),F=i7.useRef(null),L=i7.useRef(null),M=i7.useRef(W);M.current=W;let w=X[H]||null,R=i7.useCallback(()=>{if(!w)return V(null),null;let f=UG0(w.target);return V(f),f},[w]);i7.useEffect(()=>{if(J)q(0)},[J]),i7.useLayoutEffect(()=>{if(!J||!w)return;let f=!1;V(null);try{M.current?.setup?.(w)}catch{}let m=0,o=24,n=()=>{if(f)return;let x=R();if(x||m>=o){if(x){try{document.querySelector(w.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!f)R()})}return}m+=1,L.current=setTimeout(n,130)};return n(),()=>{if(f=!0,L.current)clearTimeout(L.current)}},[J,H,G]),i7.useEffect(()=>{if(!J)return;F.current=document.activeElement;let f=()=>R();return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0);try{F.current?.focus?.()}catch{}}},[J,R]);let A=H>=X.length-1,D=i7.useCallback(()=>{if(A)Y?.(),Q?.();else q((f)=>Math.min(f+1,X.length-1))},[A,Y,Q,X.length]),P=i7.useCallback(()=>q((f)=>Math.max(0,f-1)),[]);if(i7.useEffect(()=>{if(!J)return;function f(m){if(m.key==="Escape")m.preventDefault(),Q?.();else if(m.key==="ArrowRight")m.preventDefault(),D();else if(m.key==="ArrowLeft")m.preventDefault(),P();else if(m.key==="Tab"){let o=B.current;if(!o)return;let n=o.querySelectorAll("button");if(!n.length)return;let x=n[0],i=n[n.length-1];if(m.shiftKey&&document.activeElement===x)m.preventDefault(),i.focus();else if(!m.shiftKey&&document.activeElement===i)m.preventDefault(),x.focus()}}return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[J,D,P,Q]),i7.useEffect(()=>{if(!J)return;let f=setTimeout(()=>{let m=B.current?.querySelector("[data-tour-primary]");try{m?.focus()}catch{}},0);return()=>clearTimeout(f)},[J,H]),!J||!X.length||!w)return null;let T=6,I=K?{top:K.top-T,left:K.left-T,width:K.width+T*2,height:K.height+T*2}:null,S=!!w.requireSelection&&!G,C=(!!w.canvas||!!w.requireSelection)&&Z===!1,j=w.render||null;return _("div",{className:"mdcc-tour",role:"presentation",children:[I?z("div",{className:"mdcc-tour__spot",style:I,"aria-hidden":"true"}):z("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),_("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:VG0(K),children:[_("div",{className:"mdcc-tour__step",children:[H+1," / ",X.length]}),j&&z("div",{className:"mdcc-tour__graphic",children:z(j,{})}),z("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:w.title}),z("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:w.body}),(C||S)&&_("div",{className:"mdcc-tour__hint",role:"status","aria-live":"polite",children:[z("span",{className:"mdcc-tour__hint-dot","aria-hidden":"true"}),C?"Open any canvas from the sidebar to follow along.":"Hold ⌘ and click an element in the canvas — the panel fills in live."]}),_("div",{className:"mdcc-tour__actions",children:[z("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),_("div",{className:"mdcc-tour__nav",children:[H>0&&z("button",{type:"button",className:"mdcc-tour__back",onClick:P,children:"Back"}),z("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:D,children:A?"Done":"Next"})]})]})]})]})}var ef=[{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 QB=[{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 U7=S8(v8(),1);var BG0={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},FG0={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function NG0(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 Xv(X,J){let Q=await NG0(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 LG0(X,J){return iy(J||"export",X)}function Jv(){let[X,J]=U7.useState(()=>new Map),[Q,Y]=U7.useState(!1),[W,G]=U7.useState([]),[Z,H]=U7.useState(()=>new Set),q=U7.useRef(new Map),K=U7.useRef(new Set),V=U7.useRef(new Set);U7.useEffect(()=>{let S=!0;return fetch("/_api/export-jobs").then((C)=>C.json()).then((C)=>{if(!S)return;let j=new Map;for(let f of Array.isArray(C?.jobs)?C.jobs:[])j.set(f.id,f),q.current.set(f.id,f.status),V.current.add(f.id);J(j)}).catch(()=>{}),()=>{S=!1}},[]);let B=U7.useCallback((S)=>{if(!S||typeof S.id!=="string")return;J((C)=>{let j=new Map(C);return j.set(S.id,S),j})},[]);U7.useEffect(()=>{let S=q.current,C=[],j=[];for(let f of X.values()){let m=S.get(f.id),o=f.status==="queued"||f.status==="running",n=f.status==="done"||f.status==="failed";if(m===void 0&&o&&!V.current.has(f.id))V.current.add(f.id),C.push(f.id);else if(m!==f.status&&n)C.push(f.id),j.push(f)}for(let f of X.values())S.set(f.id,f.status);if(C.length)G((f)=>{let m=f.filter((o)=>!C.includes(o));return[...C,...m].slice(0,8)});if(K9()||!j.length)return;for(let f of j){if(f.status!=="done")continue;if(K.current.has(f.id))continue;if(!document.hasFocus())continue;K.current.add(f.id),Xv(f.id,f.filename)}},[X]);let F=U7.useMemo(()=>Array.from(X.values()).sort((S,C)=>(C.createdAt||"").localeCompare(S.createdAt||"")),[X]),L=F.filter((S)=>S.status==="running").length,M=F.filter((S)=>S.status==="queued").length,w=U7.useCallback(()=>G((S)=>S.slice(1)),[]),R=U7.useCallback(()=>Y(!0),[]),A=U7.useCallback(()=>Y(!1),[]),D=U7.useCallback(async(S,C)=>{H((j)=>new Set(j).add(S.id));try{await C()}finally{H((j)=>{let f=new Set(j);return f.delete(S.id),f})}},[]),P=U7.useCallback(async(S)=>{K.current.add(S.id),await D(S,()=>Xv(S.id,S.filename))},[D]),T=U7.useCallback(async(S)=>{K.current.add(S.id),await D(S,()=>LG0(S.id,S.filename))},[D]),I=Q?null:W[0]??null;return{jobs:F,upsert:B,runningCount:L,queuedCount:M,busyCount:L+M,panelOpen:Q,openPanel:R,closePanel:A,showToast:!!I,toastJob:I?X.get(I)??null:null,dismissToast:w,download:P,save:T,savingIds:Z}}function Qv(X){let J=BG0[X.format]||String(X.format||"").toUpperCase(),Q=FG0[X.scope]||X.scope;return`${J} · ${Q}`}function Yv(X){if(K9())return X?"Saving…":"Save…";return X?"Downloading…":"Download"}function Wv({progress:X}){if(!X||!X.total)return z("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 z("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":J,"aria-valuemin":0,"aria-valuemax":100,children:z("div",{className:"st-export-progress-bar",style:{width:`${J}%`}})})}var Iw=new Map;function DG0(X){let J=X.progress?.current,Q=X.progress?.total;if(!J||!Q||J>=Q)return Iw.delete(X.id),null;let Y=Iw.get(X.id);if(!Y||J<Y.c)Y={t:Date.now(),c:J},Iw.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 MG0({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"?DG0(X):null;return _("span",{className:`st-export-pill st-export-pill--${X.status}`,children:[J,Q?` · ${Q}`:""]})}function Gv({center:X}){let J=X.busyCount>0;return _("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:[z("span",{"aria-hidden":"true",children:"⬇"}),J&&z("span",{className:"st-exports__count","aria-hidden":"true",children:X.busyCount})]})}function Zv({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(K9())X.save(J);else X.download(J)};return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:Q?"⋯":Y?"⬇":"⚠"}),Q?"Exporting…":Y?"Export ready":"Export failed"]}),z("div",{className:"st-toast-title",children:Qv(J)}),Q?_(W0,{children:[z("div",{className:"st-toast-txt",children:"Running in the background — you can keep working."}),z(Wv,{progress:J.progress})]}):z("div",{className:"st-toast-txt",children:Y?J.filename??"Ready to download.":J.error??"Something went wrong."}),Y&&_("div",{className:"st-toast-actions",children:[_("button",{type:"button",className:"btn btn--primary btn--sm",onClick:G,disabled:W,children:[W&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),Yv(W)]}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Hv({center:X}){let{panelOpen:J,closePanel:Q}=X;if(U7.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 z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)Q()},children:_("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"st-export-panel-title",children:"Exports"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Q,children:"×"})]}),z("div",{className:"st-export-panel__body",children:X.jobs.length===0?z("p",{className:"mdcc-wn-empty",children:"No exports yet."}):z("ul",{className:"st-export-list",children:X.jobs.map((Y)=>_("li",{className:"st-export-item",children:[_("div",{className:"st-export-item__hd",children:[z("span",{className:"st-export-item__label",children:Qv(Y)}),z(MG0,{job:Y})]}),(Y.status==="queued"||Y.status==="running")&&z(Wv,{progress:Y.progress}),Y.status==="done"&&_("div",{className:"st-export-item__ft",children:[z("span",{className:"st-export-item__filename",children:Y.filename}),_("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:X.savingIds.has(Y.id),onClick:()=>K9()?X.save(Y):X.download(Y),children:[X.savingIds.has(Y.id)&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),Yv(X.savingIds.has(Y.id))]})]}),Y.status==="failed"&&z("div",{className:"st-export-item__ft",children:z("span",{className:"st-export-item__error",children:Y.error??"Export failed."})})]},Y.id))})})]})})}var MX=S8(v8(),1);function qv(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 zv(X,J){let Q=qv(X),Y=qv(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 Kv(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||zv(Q.version,J)))}function Uv(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&zv(Y.version,Q))Q=Y.version}return Q}var Cw="mdcc-whatsnew-seen",Sw="mdcc-whatsnew-toast-dismissed";function OG0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function wG0(X){try{let J=localStorage.getItem(Cw);if(J)return J;localStorage.setItem(Cw,X)}catch{}return X}function AG0(){try{return localStorage.getItem(Sw)}catch{return null}}function Vv(X){let[J,Q]=MX.useState([]),[Y,W]=MX.useState(X),[G,Z]=MX.useState(()=>wG0(X)),[H,q]=MX.useState(()=>AG0()),[K,V]=MX.useState(!1);MX.useEffect(()=>{let D=!1,P=()=>{fetch("/_api/whats-new").then((S)=>S.json()).then((S)=>{if(D)return;if(Q(Array.isArray(S?.entries)?S.entries:[]),typeof S?.version==="string")W(S.version)}).catch(()=>{})};P();let T=()=>P(),I=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",I),()=>{D=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",I)}},[]);let B=Kv(J,G),F=B.length>0&&H!==Y&&!K,L=B[0]??null,M=MX.useCallback(()=>{let D=Uv(J,Y);Z(D),q(Y);try{localStorage.setItem(Cw,D),localStorage.setItem(Sw,Y)}catch{}},[J,Y]),w=MX.useCallback(()=>{q(Y);try{localStorage.setItem(Sw,Y)}catch{}},[Y]),R=MX.useCallback(()=>V(!0),[]),A=MX.useCallback(()=>{V(!1),M()},[M]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:K,openPanel:R,closePanel:A,showToast:F,toastEntry:L,dismissToast:w,markAllSeen:M}}function Bv({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return _("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),_("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),_("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Fv({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(MX.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:_("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>_("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[_("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),OG0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var C9=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Rs="mdcc-usage-tour-seen",ks="mdcc-collab-tour-seen",g8="__system__",Zt="mdcc-theme",Ts="mdcc-show-hidden",Is="mdcc-sections-expanded",Cs="maude-cp-mode",Ss="mdcc-sidebar-open",$s="mdcc-minimap-visible",bs="mdcc-zoomctl-visible",js="mdcc-annotations-visible";var SU0=30000;function $U0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var AP=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],Aq={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},ys="mdcc-panel-sides",fs="mdcc-layers-mode";function vs({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return _("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>z("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(AP.find((q)=>q.id===H)||{}).label||H},H))}),Z]})}var VY=/\.(tsx|html?)$/i,EP="0.49.1";function xs(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function bU0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Zt);if(X==="light"||X==="dark")return X}catch{}return"dark"}function QZ(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 LP(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function jU0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function VF(X){return X.split("/").pop()}function l7(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(l7._t),l7._t=setTimeout(()=>{Q.style.opacity="0"},3200)}var hs="maude-browse-hint-seen";function yU0(){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(hs)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let X=document.createElement("div");X.id="st-browse-hint",X.setAttribute("role","status"),X.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;",X.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd> to select & edit like Figma.</span><button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let J=()=>{try{localStorage.setItem(hs,"1")}catch{}X.style.opacity="0",setTimeout(()=>X.remove(),200),document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)J()};X.querySelector("button")?.addEventListener("click",J),document.addEventListener("keydown",Q,!0),document.body.appendChild(X),requestAnimationFrame(()=>{X.style.opacity="1"}),setTimeout(J,9000)}function Pq(X){return X.replace(VY,"")}function fU0(X){return X.replace(VY,"")}function vU0(X){let J=new Map;for(let G of X){if(!VY.test(G.name))continue;let Z=fU0(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(VY.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((q,K)=>q.name.localeCompare(K.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function xU0(X,J){let Q={};for(let Y of X){let G=(Y.startsWith(J)?Y.slice(J.length).replace(/^\/+/,""):Y).split("/"),Z=Q;for(let H=0;H<G.length;H++){let q=G[H];if(H===G.length-1)Z._files=Z._files||[],Z._files.push({name:q,path:Y});else Z[q]=Z[q]||{},Z=Z[q]}}return Q}function Ht(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=Ht(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function gs(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function hU0(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 qt(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 gU0({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var mU0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:_(W0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),lock:_(W0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:_(W0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:_(W0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:_(W0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:_(W0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:_(W0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:_(W0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:_(W0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:_(W0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:_(W0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:_(W0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:_(W0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:_(W0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:_(W0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:_(W0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":_(W0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":_(W0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":_(W0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":_(W0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":_(W0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":_(W0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:_(W0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:_(W0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:_(W0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:_(W0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:_(W0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:_(W0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:_(W0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:_(W0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:_(W0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:_(W0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function uU0({open:X,onClose:J,actions:Q}){let[Y,W]=l.useState(""),[G,Z]=l.useState(0),H=l.useRef(null);l.useEffect(()=>{if(X)W(""),Z(0)},[X]),l.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let q=l.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(l.useEffect(()=>{if(G>=q.length)Z(0)},[q.length,G]),!X)return null;let K=(V)=>{J(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)J()},children:_("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[_("div",{className:"st-pal-search",children:[z(s8,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),J();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(q.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),q[G])K(q[G])}}}),z(l6,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:q.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):q.map((V,B)=>{let F=V.group&&(B===0||q[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return _(W0,{children:[F,_("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>K(V),children:[z("span",{className:"st-pal-icon",children:z(s8,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(l6,{children:V.kbd})}):null]})]},V.id)})})]})})}function s8({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:mU0[X]})}function lU0(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 ms({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function l6({children:X}){return z("span",{className:"kbd",children:X})}function us(X,{min:J,max:Q,def:Y}){let W=l.useCallback((q)=>Math.min(Q,Math.max(J,q)),[J,Q]),[G,Z]=l.useState(()=>{try{let q=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(q)?W(q):Y}catch{return Y}});l.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=l.useCallback((q)=>Z((K)=>W(typeof q==="function"?q(K):q)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ls({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:q,def:K}=J,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":q,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(K),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((L)=>L+F*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((L)=>L-F*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(q)},children:_("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var DP=[{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}],MP={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},dU0={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"]},pU0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],kV=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],cU0="2x",ds=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],iU0="auto",oU0={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 nU0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return oU0[J]||"application/octet-stream"}function rU0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=l.useState(null),[q,K]=l.useState(!1),[V,B]=l.useState(null),[F,L]=l.useState(()=>new Set),[M,w]=l.useState({}),[R,A]=l.useState(W?"artboard":"annotation");l.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((i)=>i.json()).then((i)=>{if(!x)return;let a=i.ok?i.assets:[];H(a),w((h)=>{let s={...h};for(let X0 of a)s[X0.path]=X0.kind;return s})}).catch(()=>x&&H([])),()=>{x=!1}},[]),l.useEffect(()=>{let x=(i)=>{if(i.key==="Escape")i.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let D=Array.from(F).some((x)=>(M[x]||"image")!=="image"),P=!W||D,T=!W?"No artboard on this canvas":D?"Video/audio can only be added as annotations":"";l.useEffect(()=>{if(P&&R==="artboard")A("annotation")},[P,R]);let I=(x)=>{L((i)=>{let a=new Set(i);if(a.has(x))a.delete(x);else a.add(x);return a})},S=async(x)=>{let i=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),a=await i.json().catch(()=>({}));if(i.ok&&a.path)return{ok:!0,path:a.path};return{ok:!1,error:a.error||`upload failed (HTTP ${i.status})`}},C=async(x)=>{if(!x)return;K(!0),B(null);let i=await S(x);if(K(!1),i.ok)J(i.path);else B(i.error)},j=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;K(!0),B(null);let i=await Promise.all(x.map((s)=>S(s).then((X0)=>({...X0,file:s}))));K(!1);let a=i.filter((s)=>s.ok),h=i.length-a.length;if(h>0)B(`${h} of ${i.length} uploads failed`);if(a.length)w((s)=>{let X0={...s};for(let c of a)X0[c.path]=j(c.file.type);return X0}),L((s)=>{let X0=new Set(s);for(let c of a)X0.add(c.path);return X0})},m=async()=>{K(!0),B(null);try{if(Y){let a=(await oy()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:nU0(h.name)}));if(K(!1),a.length)await f(a);return}let x=await f2();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}K(!1)},o=()=>{if(K9()){m();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let i=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(i,300),{once:!0}),x.addEventListener("change",()=>{let a=x.files?Array.from(x.files):[];if(i(),!a.length)return;if(Y)f(a);else C(a[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:_("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(s8,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[_("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:o,disabled:q,children:q?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let i=Y&&F.has(x.path);return _("button",{type:"button",className:"st-ap-cell","data-selected":i?"true":void 0,"aria-pressed":Y?i:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?I(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:i?z(s8,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&F.size>0&&_("div",{className:"st-dialog-ft st-ap-confirm",children:[_("span",{className:"st-ap-count",children:[F.size," selected"]}),_("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>A("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>A("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),R),children:"Insert"})]})]})})}function aU0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,activeArtboardId:W=null,selection:G=null,onClose:Z}){let[H,q]=l.useState(X==="handoff"?"shadcn":"png"),[K,V]=l.useState(J&&MP[J]?J:"artboard"),[B,F]=l.useState(2),[L,M]=l.useState(cU0),[w,R]=l.useState(!0),[A,D]=l.useState(!1),[P,T]=l.useState(!1),[I,S]=l.useState(!1),[C,j]=l.useState(iU0),[f,m]=l.useState(!0),[o,n]=l.useState(!1),[x,i]=l.useState(null),[a,h]=l.useState([]),s=DP.find((p)=>p.id===H)||DP[0],X0=s.handoff?[]:dU0[s.format]||["artboard"];l.useEffect(()=>{if(X0.length&&!X0.includes(K))V(X0[0])},[X0,K]);let c=l.useCallback(()=>{fetch("/_api/export-history").then((p)=>p.json()).then((p)=>h(Array.isArray(p?.history)?p.history.slice(0,6):[])).catch(()=>{})},[]);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{function p(g){if(g.key==="Escape")g.preventDefault(),Z()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Z]);async function V0(){if(s.handoff){let d=`/design:handoff ${Q&&Q!==g8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(d)}catch{}i({ok:!0,msg:`Copied: ${d} — run it in Claude Code.`});return}n(!0),i(null);let p=s.temporal?{scale:B}:{};if(s.format==="png"){let g=kV.find((d)=>d.id===L)||kV[1];if(g.kind==="dpi")p.dpi=g.value;else p.scale=g.value}if(s.format==="mp4"||s.format==="webm")p.audio=f;if(s.format==="pdf"){p.pdfPrint={includeBleed:w,marks:{crop:P,registration:I}};let g=ds.find((d)=>d.id===C)?.value;if(g!==void 0)p.dpi=g}if(W)p.artboardId=W;if(G?.selector)p.selection=G;try{let g=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:s.format,scope:K,options:p})});if(!g.ok){i({ok:!1,msg:await g.text()||`Export failed (${g.status})`}),n(!1);return}Z()}catch(g){i({ok:!1,msg:g&&g.message?g.message:String(g)}),n(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(p)=>{if(p.target===p.currentTarget)Z()},children:_("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[_("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Z,children:z(s8,{name:"x",size:15})})]}),_("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==g8?`Format · ${Pq(VF(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:DP.filter((p)=>!p.temporal||Y).map((p)=>_("button",{type:"button",className:"st-fmt"+(p.id===H?" is-on":""),onClick:()=>{q(p.id),i(null)},children:[z(s8,{name:p.icon,size:16}),z("span",{className:"st-fmt-name",children:p.label}),z("span",{className:"st-fmt-sub",children:p.sub})]},p.id))}),!s.handoff&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:K,onChange:(p)=>V(p.target.value),children:X0.map((p)=>z("option",{value:p,children:MP[p]},p))})]}),!s.handoff&&s.format==="png"&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:L,onChange:(p)=>M(p.target.value),children:kV.map((p)=>z("option",{value:p.id,children:p.label},p.id))})]}),!s.handoff&&s.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let p=kV.find((d)=>d.id===L)||kV[1],g=p.kind==="dpi"?p.value/96:p.value;return`${p.label} ≈ ${Math.round(1440*g)}×${Math.round(900*g)} for a 1440×900 artboard.`})()}),!s.handoff&&s.temporal&&_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:B,onChange:(p)=>F(Number(p.target.value)),children:pU0.map((p)=>z("option",{value:p.value,children:p.label},p.value))})]}),!s.handoff&&s.temporal&&_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[B,"× the artboard's native resolution (e.g. 960×540 → ",960*B,"×",540*B,")."]}),!s.handoff&&s.format==="pdf"&&_(W0,{children:[_("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:C,onChange:(p)=>j(p.target.value),children:ds.map((p)=>z("option",{value:p.id,children:p.label},p.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:w,onChange:(p)=>R(p.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:_("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>D((p)=>!p),"aria-expanded":A,children:[A?"▾":"▸"," Marks"]})}),A&&_("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:P,onChange:(p)=>T(p.target.checked)}),"Crop marks"]}),_("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:(p)=>S(p.target.checked)}),"Registration marks"]})]}),_("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",K==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!s.handoff&&(s.format==="mp4"||s.format==="webm")&&z("div",{className:"st-dialog-row",children:_("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:f,onChange:(p)=>m(p.target.checked)}),"Export with audio"]})}),s.handoff&&_("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),x&&z("div",{className:"callout "+(x.ok?"callout--success":"callout--error"),style:{fontSize:12},children:x.msg}),a.length>0&&_("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((p,g)=>_("div",{className:"st-export-recent-row",children:[_("span",{children:[String(p.format||"").toUpperCase()," ·"," ",MP[p.scope]||p.scope]}),z("span",{className:"st-mono",children:p.filename})]},g))]})]}),_("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:Z,children:"Cancel"}),_("button",{type:"button",className:"btn btn--primary",disabled:o,onClick:V0,children:[z(s8,{name:"download",size:14}),s.handoff?"Copy handoff command":o?"Exporting…":`Export ${s.label}`]})]})]})})}var BF=12,FF=16;function sU0({name:X,depth:J,defaultOpen:Q,children:Y}){let[W,G]=l.useState(Q);return _(W0,{children:[_("button",{type:"button",role:"treeitem","aria-expanded":W,tabIndex:-1,className:"st-row",style:{paddingLeft:BF+J*FF+"px"},onClick:()=>G((Z)=>!Z),children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"chevron-right",className:"st-chev"+(W?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]}),W&&Y]})}function tU0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,q]=l.useState(Y);return _(W0,{children:[_("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:BF+Q*FF+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>q((K)=>!K),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(s8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),_("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function _P({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:q,experimentalKind:K}){let V=X.path===J,B=VY.test(X.name),F=!B,L=B?Pq(X.name):X.name,M=B&&typeof Y==="function"&&Z!=="runtime",w=B?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(VY,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,R=_("button",{type:"button",role:"treeitem","data-testid":w,"aria-selected":V,"aria-disabled":F?"true":void 0,tabIndex:V?0:-1,className:"st-row"+(V?" is-sel":"")+(Z==="runtime"?" is-muted":""),style:{paddingLeft:BF+G*FF+"px"},title:X.path+(W?` — ${W} open`:F?" (file index only)":""),onClick:()=>{if(!F)Q(X.path)},children:[z("span",{className:"st-row-glyph",children:z(s8,{name:"file",size:13})}),z("span",{className:"st-row-name",children:L}),K==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),W>0&&z("span",{className:"st-row-badge",children:W})]});if(!M)return R;return _("div",{className:"st-row-wrap",role:"none",children:[R,z("button",{type:"button",className:"st-row-del",title:`Delete ${L}`,"aria-label":`Delete canvas ${L}`,onClick:(A)=>{A.stopPropagation(),Y(X.path,L)},children:z(gU0,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function eU0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:q,forceOpen:K,dirtyByPath:V,experimentalKind:B}){let F=V?.get(X.path),L=J.length>0,[M,w]=l.useState(!1),R=K||M,A=X.path===W;if(!(L&&q))return z(_P,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:F,experimentalKind:B});return _(W0,{children:[_("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":R,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":""),style:{paddingLeft:BF+Q*FF+"px"},title:X.path,onClick:(P)=>{if(P.target.closest(".st-canvas-chev")){w((T)=>!T);return}G(X.path)},children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(P)=>{P.stopPropagation(),w((T)=>!T)},children:z(s8,{name:"chevron-right",className:"st-chev"+(R?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:Pq(X.name)}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F&&z("span",{className:"st-git-badge","data-kind":F,title:`Unsaved (${F})`,"aria-label":`Unsaved, ${F}`,children:F}),H>0&&z("span",{className:"st-row-badge",children:H})]}),R&&J.map((P)=>z(_P,{file:P,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},P.path))]})}function zt({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:q,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L}){let M=Object.keys(X).filter((T)=>T!=="_files").sort(),w=X._files||[],{canvases:R,orphans:A}=l.useMemo(()=>vU0(w),[w]),D=!!(H&&H.trim()),P=l.useMemo(()=>{if(!q||W!==1)return null;let T=new Map;for(let I of q)T.set(I.folder,I);return T},[q,W]);return _(W0,{children:[R.map((T)=>{let I=D&&T.sidecars.some((S)=>{let C=H.toLowerCase();return S.name.toLowerCase().includes(C)||S.path.toLowerCase().includes(C)});return z(eU0,{primary:T.primary,sidecars:T.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:gs(Y[T.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:I,dirtyByPath:F,experimentalKind:L?.[T.primary.path]},T.primary.path)}),Z&&A.map((T)=>z(_P,{file:T.primary,activePath:J,onOpen:Q,openCount:gs(Y[T.primary.path]),depth:W,kind:G},T.primary.path)),M.map((T)=>{let I=P?.get(T),S=z(zt,{node:X[T],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:K,onOpenSystem:V,onDelete:B,dirtyByPath:F,canvasKinds:L});if(I&&V)return z(tU0,{name:T,dsName:I.name,depth:W,defaultOpen:!0,active:J===g8&&I.name===K,onOpenSystem:V,children:S},T);return z(sU0,{name:T,depth:W,defaultOpen:!0,children:S},T)})]})}var qF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function XV0(X){if(X.kind==="project")return qF.project;if(X.kind==="runtime")return qF.runtime;if(X.label==="Design system")return qF.ds;if(X.label==="UI kit")return qF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function JV0({groups:X,activePath:J,activeDsName:Q,onOpen:Y,onOpenSystem:W,wsConnected:G,search:Z,setSearch:H,commentsByFile:q,showHidden:K,sectionsExpanded:V,onToggleSection:B,onNewBoard:F,onDeleteBoard:L,onRefresh:M,refreshing:w,collapsed:R,onCollapse:A,width:D,resizing:P,dirtyByPath:T,project:I,gitBranch:S,remoteSync:C,onGetLatest:j,canvasKinds:f}){let m=l.useMemo(()=>{if(!Z)return X;return X.map((g)=>({...g,tree:Ht(g.tree,Z),filtered:!!Z}))},[X,Z]),[o,n]=l.useState(!1),[x,i]=l.useState(""),[a,h]=l.useState(""),[s,X0]=l.useState(!1),c=l.useCallback(async()=>{let g=x.trim();if(!g||s)return;X0(!0),h("");let d=await F(g);if(X0(!1),d?.ok)n(!1),i("");else h(d?.error||"could not create board")},[x,s,F]),V0=l.useMemo(()=>{let g=0;for(let d of X)for(let K0 of d.paths||[])if(VY.test(K0))g++;return g},[X]),p=l.useMemo(()=>{let g=0;for(let d of m)for(let K0 of d.paths||[])if(VY.test(K0))g++;return g},[m]);return _("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(P?" is-resizing":""),style:R||!D?void 0:{width:D,flexBasis:D},"aria-label":"Files","data-tour":"sidebar",children:[_("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),_("div",{className:"st-sb-hd-actions",children:[z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":o,onClick:()=>{h(""),n((g)=>!g)},children:z(s8,{name:"plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(w?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":w||void 0,disabled:w,onClick:()=>M(),children:z(s8,{name:"reload",size:15})}),_("span",{className:"st-live","data-tip":G?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(G?" is-connected":""),"aria-hidden":"true"}),p," / ",V0]}),A&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:A,children:z(s8,{name:"panel-left",size:15})})]})]}),o?_("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:"brief board name…",value:x,maxLength:60,disabled:s,"aria-label":"New brief board name",onChange:(g)=>i(g.target.value),onKeyDown:(g)=>{if(g.key==="Enter")g.preventDefault(),c();else if(g.key==="Escape")g.preventDefault(),n(!1),i(""),h("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:s||!x.trim(),"data-tip":"Create · Enter","aria-label":"Create brief board",onClick:c,children:s?"…":"↵"})]}):null,a?z("div",{className:"st-newboard-err",role:"alert",children:a}):null,z("div",{className:"st-search",children:_("div",{className:"st-search-box",children:[z(s8,{name:"search",size:13}),z("input",{type:"search",placeholder:"Search canvases…",value:Z,onChange:(g)=>H(g.target.value),onKeyDown:(g)=>{if(g.key==="Escape")if(g.preventDefault(),Z)H("");else g.currentTarget.blur()},"aria-label":"Filter files"}),Z?z("button",{className:"st-search-clear",onClick:()=>H(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(l6,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:m.map((g)=>{if(!K&&!Z&&g.kind==="runtime")return null;let d=XV0(g),K0=(g.paths||[]).filter((m8)=>VY.test(m8)).length,u0=d.pill||(d.pillFromDsCount?String(g.dsFolders?.length||0):null)||(d.pillFromCount?String(K0||g.paths?.length||0):null),J8=g.tree&&Object.keys(g.tree).length>0,G8=g.label==="Design system",s0=g.kind==="project";if(!K&&!Z&&s0&&K0===0)return null;let D8=jU0(g),U8=V[g.label],q8=!!Z||(U8===void 0?D8:U8);return _("div",{className:"st-tree-section",children:[_("button",{type:"button",className:"st-tree-sec-hd",onClick:()=>B(g.label,D8),"aria-expanded":q8,title:q8?"Collapse section":"Expand section",children:[z(s8,{name:"chevron-right",className:"st-chev"+(q8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:d.title}),u0&&z("span",{className:"st-pill",children:u0})]}),q8&&(J8?z(zt,{node:g.tree,activePath:J,onOpen:Y,commentsByFile:q,depth:1,kind:g.kind,showHidden:K,search:Z,dsFolders:g.dsFolders,activeDsName:Q,onOpenSystem:G8?W:void 0,onDelete:G8?void 0:L,dirtyByPath:T,canvasKinds:f}):z("div",{className:"st-tree-empty",children:Z?"No matches.":"Empty."}))]},g.label)})}),z(Lw,{project:I,liveBranch:S,remoteSync:C,onGetLatest:j}),z(Yw,{})]})}function QV0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:_("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(s8,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(s8,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(s8,{name:"folder",size:15})})]})})}function YV0({open:X,onClose:J,onStartTour:Q}){if(l.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[_("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),_("span",{className:"sku",children:["MAUDE-DEV-SRV / v",EP]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),_("div",{className:"help-modal-body",children:[_("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),_("ul",{children:[_("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),_("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),_("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),_("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),_("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),_("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),_("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),_("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),_("details",{children:[z("summary",{children:"Annotation tools"}),_("ul",{children:[_("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),_("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),_("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),_("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),_("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),_("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),_("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),_("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),_("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),_("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),_("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),_("details",{children:[z("summary",{children:"Canvas & panels"}),_("ul",{children:[_("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),_("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),_("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),_("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),_("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),_("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),_("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),_("details",{children:[z("summary",{children:"Slash commands"}),_("ul",{className:"cmds",children:[_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),_("li",{children:[_("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),_("li",{children:[_("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),_("li",{children:[_("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),_("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),_("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),_("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),_("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),_("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),_("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),_("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),_("details",{children:[z("summary",{children:"Opt-out scope"}),_("ul",{children:[_("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),_("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),_("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),_("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),_("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),_("details",{children:[z("summary",{children:"Auto-critic loop"}),_("ul",{children:[_("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),_("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),_("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),_("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),_("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),_("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),_("details",{children:[z("summary",{children:"Pin-to-element flow"}),_("ol",{children:[z("li",{children:"Open a canvas"}),_("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),_("li",{children:["Run"," ",_("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),_("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),_("details",{children:[z("summary",{children:"Comments"}),_("ol",{children:[_("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),_("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),_("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),_("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var OP=[{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 WV0({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(l6,{children:G},`${G}-${Z}`))},W);return _("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>_(W0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function GV0({open:X,onClose:J}){if(l.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=OP.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:_("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[_("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),_("span",{className:"so-trigger",children:["press ",z(l6,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:OP.map((Y)=>_("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>_("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(WV0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),_("div",{className:"so-overlay-ft",children:[_("span",{children:["close with ",z(l6,{children:"Esc"})]}),_("span",{className:"so-count",children:[Q," bindings · ",OP.length," groups"]})]})]})})}var ZV0=["File","Edit","View","Selection","Tools","Help"];function Kt(X){l.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 HV0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Kt(Q),_("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(s8,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(l6,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(l6,{children:G.shortcut})]},G.label))]})}function CV({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Kt(G),_("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):_("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[_("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(l6,{children:Z.shortcut}):null]},Z.id))]})}function qV0({onAction:X,onClose:J}){return z(CV,{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"},...K9()?[{id:"collab-tour",label:"How sharing works"}]:[],...K9()?[{id:"quick-setup",label:"Quick setup"}]:[],...K9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function zV0({onAction:X,onClose:J}){return z(CV,{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 KV0({onAction:X,onClose:J}){return z(CV,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]})}function UV0({onAction:X,onClose:J,hasCanvas:Q}){return z(CV,{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 VV0({onAction:X,onClose:J,hasCanvas:Q}){return z(CV,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function BV0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:q,onToggleChanges:K,onOpenSystem:V,sidebarOpen:B,onToggleSidebar:F,showHidden:L,onToggleShowHidden:M,onOpenHelp:w,onOpenShortcuts:R,onStartTour:A,onStartCollabTour:D,annotationsVisible:P,onToggleAnnotations:T,minimapVisible:I,onToggleMinimap:S,zoomCtlVisible:C,onToggleZoomCtl:j,presentMode:f,onTogglePresent:m,printGuidesVisible:o,onTogglePrintGuides:n,postToActiveCanvas:x,onOpenWhatsNew:i,onOpenReadiness:a,onOpenQuickSetup:h,onWatchIntro:s,whatsNewCount:X0,exportCenter:c,artboardCount:V0=0,presence:p=null,inspectorOpen:g,inspectorTab:d,onToggleInspector:K0,autoOpenInspector:u0,onToggleAutoOpenInspector:J8,onOpenLayers:G8,timelineOpen:s0,onToggleTimeline:D8,hasComps:U8=!1,assistantOpen:q8,onToggleAssistant:m8,assistantBusy:_8,assistantUnseen:G9,onNewCanvas:Z9,onAssembleVideo:e0,onOpenExport:p8,onOpenSettings:o8,onOpenGenerate:$9,onReload:j0,onCloseCanvas:F0,onInsertArtboard:U0}){let k0=X===g8,H0=k0?"SYSTEM":X?"CANVAS":"IDLE",L0=k0?z("b",{children:"design system"}):X?_(W0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:Pq(VF(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),N0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:q>0?`Changes · ${q} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:L,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:g&&d==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:g,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!u0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:U8?"video":void 0,checked:s0,disabled:!1},...K9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:q8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:P,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:I,disabled:!X||k0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:C,disabled:!X||k0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!X||k0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:o,disabled:!X||k0}],t0=["file","edit","view","selection","tools","help"];function $8(y0){if(t0.includes(y0))W(Y===y0?null:y0)}return l.useEffect(()=>{if(!Y||!t0.includes(Y))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function v0(O0){let n0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!n0.length)return;let Q8=n0.indexOf(document.activeElement);if(O0.key==="ArrowDown")O0.preventDefault(),n0[(Q8+1)%n0.length].focus();else if(O0.key==="ArrowUp")O0.preventDefault(),n0[(Q8-1+n0.length)%n0.length].focus();else if(O0.key==="Home")O0.preventDefault(),n0[0].focus();else if(O0.key==="End")O0.preventDefault(),n0[n0.length-1].focus();else if(O0.key==="ArrowRight"||O0.key==="ArrowLeft"){O0.preventDefault();let w0=O0.key==="ArrowRight"?1:-1,i0=t0.indexOf(Y);W(t0[(i0+w0+t0.length)%t0.length])}else if(O0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",v0),()=>{clearTimeout(y0),window.removeEventListener("keydown",v0)}},[Y,W]),_("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[_("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:ZV0.map((y0)=>{let v0=y0.toLowerCase(),O0=t0.includes(v0),n0=O0||v0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":v0==="help"?"help":void 0,"aria-haspopup":O0?"menu":void 0,"aria-expanded":O0?Y===v0:void 0,onClick:()=>$8(v0),onMouseEnter:()=>{if(Y!==null&&O0)W(v0)},children:y0},v0)})}),Y==="file"&&z(UV0,{hasCanvas:!!X,onAction:(y0)=>{if(y0==="new")Z9?.();else if(y0==="assemble")e0?.();else if(y0==="export")p8?.("export");else if(y0==="handoff")p8?.("handoff");else if(y0==="generate")$9?.();else if(y0==="settings")o8?.();else if(y0==="reload")j0?.();else if(y0==="close")F0?.()},onClose:()=>W(null)}),Y==="edit"&&z(VV0,{hasCanvas:!!X&&!k0,onAction:(y0)=>{if(y0==="undo")x({dgn:"undo"});else if(y0==="redo")x({dgn:"redo"});else if(y0==="deselect-all")x({dgn:"selection-clear"});else if(y0==="select-all-annotations")x({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))U0?.(y0.slice(13))},onClose:()=>W(null)}),Y==="view"&&z(HV0,{panels:N0,onToggle:(y0)=>{if(y0==="tree")F();else if(y0==="changes")K();else if(y0==="comments")Z();else if(y0==="hidden")M();else if(y0==="annotate")T();else if(y0==="inspector")K0();else if(y0==="autoopen")J8?.();else if(y0==="timeline")D8?.();else if(y0==="assistant")m8?.();else if(y0==="layers")G8?.();else if(y0==="minimap")S?.();else if(y0==="zoomctl")j?.();else if(y0==="present")m?.();else if(y0==="print-guides")n?.()},onZoom:(y0)=>x({dgn:"zoom",op:y0}),hasCanvas:!!X&&!k0,onClose:()=>W(null)}),Y==="selection"&&z(zV0,{onAction:(y0)=>{if(y0==="deselect-all")x({dgn:"selection-clear"});else if(y0==="select-all-annotations")x({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&z(KV0,{onAction:(y0)=>x({dgn:"tool-set",tool:y0}),onClose:()=>W(null)}),Y==="help"&&z(qV0,{onAction:(y0)=>{if(y0==="shortcuts")R?.();else if(y0==="help")w?.();else if(y0==="tour")A?.();else if(y0==="collab-tour")D?.();else if(y0==="quick-setup")h?.();else if(y0==="readiness")a?.();else if(y0==="whatsnew")i?.();else if(y0==="watch-intro")s?.()},onClose:()=>W(null)}),_("div",{className:"st-mb-right","data-tour":"status",children:[p?z("div",{className:"st-presence",children:p}):null,K9()&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":q8?"true":"false","data-busy":_8?"true":"false","data-unseen":G9?"true":"false","aria-label":`Assistant${_8?" — working":G9?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:m8,children:z(s8,{name:"sparkle",size:15})}),c&&z(Gv,{center:c}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":X0>0?"true":"false","aria-label":`What's new${X0>0?` — ${X0} unseen`:""}`,"data-tip":"What's new",onClick:i,children:z(s8,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:H0}),z("span",{className:"st-mb-file",title:X||"",children:L0}),z("span",{className:"st-mb-sep"}),_("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),V0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function FV0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:q,onIframeLoad:K,showQuickSetup:V,onStartQuickSetup:B}){return _("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&_("div",{className:"st-empty",children:[_("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),_("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",EP," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),_("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(l6,{children:"⌘"})," and hover to preview an element, click to select it — ",z(l6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",K9()?_(W0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),V&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((F)=>{if(F.path===g8)return z("div",{className:"system-view"+(F.path===J?" active":""),children:z(_V0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return z("iframe",{ref:(L)=>Q(F.path,L),src:_H(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>K?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),q&&q===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:_("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var NV0=["color","space","radius","shadow","leading","weight","motion","font","other"],LV0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function DV0(X){return X==="color"}function MV0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return _("section",{className:"sv-section sv-section-tokens",children:[_("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:_("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...NV0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(W0,{children:W.map((G)=>{let Z=Y[G],H=DV0(G);return _("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[_("h2",{children:["tokens · ",LV0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((q)=>_("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:q.value}}):null,_("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:q.name}),z("span",{className:"sv-tok-value",children:q.value||"—"})]})]},q.name+"|"+q.value))})]},G)})})}function OV0(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 wV0(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 AV0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=wV0(X?.font);return _("section",{className:"sv-section sv-section-type",children:[_("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=OV0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return _("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function _V0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:q,tokensPath:K,ds:V,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),L=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return _("div",{className:"sv",children:[_("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),L?_("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(w)=>Y&&Y(w.target.value),children:B.map((w)=>z("option",{value:w.name,children:w.name},w.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(MV0,{tokens:H,tokenGroups:q,tokensPath:K}),z(AV0,{tokenGroups:q}),F?z("div",{className:"sv-empty",children:_("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):_(W0,{children:[z(ps,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(ps,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function ps({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return _("section",{className:"sv-section",children:[_("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>_("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:_H(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),_("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function EV0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:q=0,unpushed:K=0,changesOpen:V=!1,onOpenChanges:B}){let F=X===g8,L=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",w=W==="dark"?"light":"dark",R=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let 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 _("footer",{className:"st-statusbar",role:"contentinfo",children:[_("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&_("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:M,children:L}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),_("span",{className:"val",children:[Y," open"]})]}),B&&_("button",{type:"button",className:"st-sb-slot st-sb-changes"+(V?" is-open":"")+(q>0?" has-changes":K>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":V,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:q>0?`${q} unsaved`:K>0?`${K} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),_("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&_("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]}),_("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${w} theme`,"data-tip-pos":"top","aria-label":`Switch to ${w} theme`,children:[z(s8,{name:W==="dark"?"sun":"moon",size:13}),w]})]})}function PV0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:q,width:K,resizing:V}){let B=qt(X),F=Object.keys(X||{}).sort(),L=[];for(let M of F){let w=X[M]||[],R=w.filter((D)=>{if(J==="open")return D.status!=="resolved";if(J==="resolved")return D.status==="resolved";return!0});if(R.length===0)continue;let A=w.filter((D)=>D.selector);L.push({file:M,comments:R.map((D)=>({...D,n:A.findIndex((P)=>P.id===D.id)+1}))})}return _("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:K?{width:K,flexBasis:K}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:_("div",{className:"st-cm-filters",role:"tablist",children:[_("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),_("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),_("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:L.length===0?_("div",{className:"st-rp-empty",children:[_("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),_("p",{children:["Open a canvas, hold ",z(l6,{children:"⌘"})," and click an element, then press ",z(l6,{children:"C"})," — or hold ",z(l6,{children:"⌘⇧"})," and click directly."]})]}):L.map((M)=>_(W0,{children:[_("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:Pq(VF(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((w)=>_("div",{className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===W?" is-active":""),onClick:()=>G(M.file,w.id),children:[_("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),z("span",{className:"st-comment-time",children:hU0(w.created)})]}),z("div",{className:"st-comment-txt",children:w.text}),_("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),_("span",{className:"st-mini-act",children:[w.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(w.id)},children:z(s8,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(w.id)},children:z(s8,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),q(w.id)},children:z(s8,{name:"x",size:14})})]})]})]},w.id))]},M.file))})]})}function RV0({update:X,onDismiss:J}){let[Q,Y]=l.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return _("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),_("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),ry().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function kV0({status:X}){let[J,Q]=l.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",q=Y==="offline"||Y==="offline-long",K=X.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!q&&!H&&!V&&K===0)return null;let B,F,L;if(H)B="success",F="Synced with hub",L=`${Y}:flash`;else if(q){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;L=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",F=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",F=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;L=`diverged:${V.slug}:${V.at}`}else B="warn",F=`${K} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,L=`rejected:${K}`;if(J===L)return null;return _("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:F}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(L),children:"×"})]})}var TV0=["block","inline-block","flex","inline-flex","grid","inline","none"],cs=["px","%","fr","em","auto","min-content","max-content"];var IV0=["auto","stretch","flex-start","center","flex-end","baseline"];var is=["300","400","500","600","700","800"],os=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],ns=["none","solid","dashed","dotted","double"],rs=["px","rem","em","%","vw","vh","auto"],as=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),wP={"font-size":{node:z(C9,{as:QU,size:12})},"line-height":{node:z(C9,{as:zU,size:12})},"letter-spacing":{node:z(C9,{as:LU,size:12})},gap:{node:z(C9,{as:tH,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(C9,{as:AU,size:12})},"border-width":{node:z(C9,{as:NU,size:12})}};var ss=["static","relative","absolute","fixed","sticky"],CV0=["normal","italic","oblique"],ts=["none","uppercase","lowercase","capitalize"];var es=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],SV0=["fill","contain","cover","none","scale-down"];var Xt=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Jt=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],yJ={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}},_q=null;function UF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!_q)_q=document.createElement("canvas").getContext("2d");if(!_q)return"";_q.fillStyle="#000000",_q.fillStyle=X;let J=_q.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 UY=(X)=>Math.min(1,Math.max(0,X));function zF(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 TV({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function IV({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function Eq({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,q=0;if(X<60)[Z,H,q]=[Y,W,0];else if(X<120)[Z,H,q]=[W,Y,0];else if(X<180)[Z,H,q]=[0,Y,W];else if(X<240)[Z,H,q]=[0,W,Y];else if(X<300)[Z,H,q]=[W,0,Y];else[Z,H,q]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(q+G)*255}}function S9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function JQ(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 Qt(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function Ut(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function $V0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],q=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=q&&J[q[1]]?J[q[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function Vt(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=l.useState([]);return l.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(q)=>{if(!q.tokensCssRel)return null;try{let K=await fetch(`/${J}/${q.tokensCssRel}`),V=K.ok?await K.text():"";return{name:q.name,...$V0(V)}}catch{return null}})).then((q)=>{if(H)return;let K=q.filter(Boolean);K.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(K)}),()=>{H=!0}},[W,J,Q]),G}function Bt({seed:X,label:J,onApply:Q}){let[Y,W]=l.useState(()=>IV(zF(X||"#000000"))),G=l.useRef(Y);G.current=Y;let Z=l.useRef(null),H=l.useRef(null),q=l.useRef(X);l.useEffect(()=>{if(X&&X!==q.current)q.current=X,W(IV(zF(X)))},[X]);let K=TV(Eq(Y)),V=(D)=>{D.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,I=(C)=>{W({h:T,s:UY((C.clientX-P.left)/P.width),v:UY(1-(C.clientY-P.top)/P.height)})};I(D);let S=()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",S),Q(TV(Eq(G.current)))};document.addEventListener("pointermove",I),document.addEventListener("pointerup",S)},B=(D)=>{D.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:I}=G.current,S=(j)=>{W({h:UY((j.clientX-P.left)/P.width)*360,s:T,v:I})};S(D);let C=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),Q(TV(Eq(G.current)))};document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)},F=(D)=>{let P={...G.current,...D};W(P),Q(TV(Eq(P)))},L=(D)=>{let P=D.shiftKey?0.1:0.02,I={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[D.key];if(!I)return;D.preventDefault(),F({s:UY(G.current.s+I[0]),v:UY(G.current.v+I[1])})},M=(D)=>{let P=D.shiftKey?20:2,I={ArrowLeft:-P,ArrowRight:P}[D.key];if(I==null)return;D.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+I))})},w=async()=>{try{let D=window.EyeDropper;if(!D)return;let P=await new D().open();if(P?.sRGBHex)W(IV(zF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=Eq(Y),A=(D)=>{let P={...R,...D},T=IV({r:UY(P.r/255)*255,g:UY(P.g/255)*255,b:UY(P.b/255)*255});W(T),Q(TV(Eq(T)))};return _("div",{className:"st-cp-cpick",children:[_("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:K}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:K,"aria-label":J?`${J} hex value`:"hex value",onChange:(D)=>{let P=D.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(IV(zF(P)))},onKeyDown:(D)=>{if(D.key==="Enter")Q(D.currentTarget.value)},onBlur:(D)=>Q(D.currentTarget.value),onFocus:(D)=>D.currentTarget.select()})]}),_("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:L,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:K}})]}),_("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:z(s8,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:K},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((D)=>_("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":D.toUpperCase(),value:Math.round(R[D]),onChange:(P)=>A({[D]:UY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:D.toUpperCase()})]},D))})]})}function KF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:q}){let[K,V]=l.useState(!1),[B,F]=l.useState(null),[L,M]=l.useState("custom"),[w,R]=l.useState(""),A=l.useRef(null),D=l.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(X0)=>Q===`var(${X0})`,I=(X0)=>X0.replace(/^--/,"").replace(/-/g," "),S=J||[],C=S.reduce((X0,c)=>X0+(c.names?.length||0),0),j=S.length>1,f=w.trim().toLowerCase(),m=!f?S:S.map((X0)=>({...X0,names:(X0.names||[]).filter((c)=>I(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(X0.vals?.[c]||"").toLowerCase().includes(f))})).filter((X0)=>X0.names.length);l.useEffect(()=>{if(!K){R("");return}let X0=()=>{let g=A.current?.getBoundingClientRect();if(!g)return;let d=224,K0=300,u0=Math.min(g.right-d,window.innerWidth-d-8);if(u0<8)u0=8;let G8=window.innerHeight-g.bottom>K0+8?g.bottom+4:Math.max(8,g.top-K0-4);F({left:u0,top:G8,width:d,maxHeight:K0})};X0();let c=(g)=>{if(D.current?.contains(g.target)||A.current?.contains(g.target))return;V(!1)},V0=(g)=>{if(g.key==="Escape")V(!1)},p=(g)=>{if(D.current?.contains(g.target))return;X0()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",V0),window.addEventListener("resize",X0),document.addEventListener("scroll",p,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",V0),window.removeEventListener("resize",X0),document.removeEventListener("scroll",p,!0)}},[K]),l.useEffect(()=>{if(!K||!B||!D.current)return;let X0=D.current.getBoundingClientRect(),c=B.left-X0.left,V0=B.top-X0.top;if(Math.abs(c)>0.5||Math.abs(V0)>0.5)F((p)=>p?{...p,left:p.left+c,top:p.top+V0}:p)},[K,B]);let o=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(X0,c,V0)=>{if(H&&X0&&X0!==H&&V0&&!o.test(V0))Y(V0);else Y(`var(${c})`);V(!1)},x=(X0)=>{let c=(X0||"").trim();if(c)Y(c)},i=_("div",{className:"st-cp-pop-search",children:[z(s8,{name:"search",size:12}),z("input",{value:w,onChange:(X0)=>R(X0.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),a=(X0)=>X0.map((c)=>_("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((V0)=>_("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(V0)?" is-on":""}`,onClick:()=>n(c.ds,V0,c.vals?.[V0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[V0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:I(V0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[V0]||""})]},`${c.ds}:${V0}`))})]},c.ds)),h=(X0)=>X0.map((c)=>_("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((V0)=>_("button",{type:"button",className:`st-cp-pop-row${T(V0)?" is-on":""}`,onClick:()=>n(c.ds,V0,c.vals?.[V0]),children:[z("span",{className:"st-cp-pop-name",children:I(V0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[V0]||""})]},`${c.ds}:${V0}`))})]},c.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return _(W0,{children:[G!==void 0?z("button",{type:"button",ref:A,className:`${q||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!q?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((X0)=>!X0),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:A,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":K,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((X0)=>!X0),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),K&&B?Wt.createPortal(z("div",{ref:D,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"?_(W0,{children:[_("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":L==="custom",className:`st-cp-poptab${L==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":L==="vars",className:`st-cp-poptab${L==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),L==="custom"?z(Bt,{seed:Z||UF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):_(W0,{children:[i,m.length?a(m):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):_(W0,{children:[i,m.length?h(m):s]})}),document.body):null]})}function Yt({label:X,tracks:J,editable:Q,onChange:Y}){let W=(q,K)=>{let V=J[q];Y(J.map((B,F)=>F===q?zK.has(K)?{value:0,unit:K}:{value:V.value||1,unit:K}:B))},G=(q,K)=>{Y(J.map((V,B)=>B===q?{...V,value:K}:V))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(q)=>Y(J.filter((K,V)=>V!==q));return _("div",{className:"st-cp-gridtracks",children:[_("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?_("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((q,K)=>{let V=zK.has(q.unit);return _("div",{className:"st-cp-gridtrack-row",children:[V?z(c4,{value:q.unit,ariaLabel:`${X} track ${K+1}`,options:cs.map((B)=>({value:B,label:B})),onChange:(B)=>W(K,B)}):z(Q5,{value:q.value,min:q.unit==="fr"?0.1:0,step:q.unit==="fr"?0.1:1,ariaLabel:`${X} track ${K+1} value`,lead:String(K+1),unitSlot:z(e2,{value:q.unit,units:cs,ariaLabel:`${X} track ${K+1} unit`,onChange:(B)=>W(K,B)}),onCommit:(B)=>G(K,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${K+1}`,disabled:!Q||J.length<=1,onClick:()=>H(K),children:"×"})]},K)})]})}function bV0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let q=!!X.id,K=X.computed||{},[V,B]=l.useState({a:{},c:{},t:{}});l.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,B0)=>{let q0={...t||{}};for(let[C0,r0]of Object.entries(B0))if(r0===null)delete q0[C0];else q0[C0]=r0;return q0},L=F(X.authored,V.a),M=F(X.customStyles,V.c),w=F(X.attrs,V.t),R=(t,B0)=>B((q0)=>({...q0,a:{...q0.a,[t]:B0}})),A=(t,B0)=>B((q0)=>({...q0,c:{...q0.c,[t]:B0}})),D=(t,B0)=>B((q0)=>({...q0,t:{...q0.t,[t]:B0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Ut(X.file,J),I=Vt(J,P,T),S=(t)=>I.map((B0)=>({ds:B0.name,names:B0[t]||[],vals:B0.vals})).filter((B0)=>B0.names.length),[C,j]=l.useState({}),[f,m]=l.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),o=Object.keys(M).length>0||Object.keys(w).length>0;l.useEffect(()=>{if(o)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,o]);let n=(L.position||S9(K.position)||"static")!=="static";l.useEffect(()=>{if(n)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,n]);let x=H,[i,a]=l.useState({});async function h(t,B0,q0){j((C0)=>({...C0,[q0]:"saving"}));try{let C0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B0)}),r0=await C0.json().catch(()=>({}));j((F8)=>({...F8,[q0]:!C0.ok||!r0.ok?`err:${r0&&r0.error||`HTTP ${C0.status}`}`:"saved"}))}catch(C0){j((r0)=>({...r0,[q0]:`err:${C0&&C0.message?C0.message:String(C0)}`}))}}let s=(t,B0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:B0})},X0=(t,B0,q0,C0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:B0,before:q0==null||q0===""?null:q0,after:C0==null||C0===""?null:C0})},c=(t,B0)=>{let q0=(B0||"").trim();if(!q||!q0)return;let C0=L[t]??null;if(q0===(C0??"").trim())return;s(t,q0),R(t,q0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:q0},t),X0("css",t,C0,q0)},V0=(t,B0)=>{let q0=(B0||"").trim(),C0=t.trim();if(!q||!C0||!q0)return;let r0=M[C0]??null;s(C0,q0),A(C0,q0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:C0,value:q0},C0),X0("css",C0,r0,q0)},p=(t,B0)=>{let q0=(t||"").trim(),C0=(B0||"").trim();if(!q||!q0||!C0)return;let r0=w[q0]??null;D(q0,C0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:q0,value:C0},`@${q0}`),X0("attr",q0,r0,C0)},g=(t)=>{if(!q)return;let B0=L[t]??null;s(t,null),R(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,B0,null)},d=(t)=>{if(!q)return;let B0=M[t]??null;s(t,null),A(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),X0("css",t,B0,null)},K0=(t)=>{if(!q)return;let B0=w[t]??null;D(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),X0("attr",t,B0,null)},u0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,B0)=>{if(!q)return;let q0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),C0=IC(t,B0,u0,q0);for(let r0 of C0.reset)if(L[r0])g(r0);for(let[r0,F8]of C0.set)c(r0,F8)},G8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",s0=(t)=>{let B0=TC(t,L,K,u0);return _("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(XB,{value:B0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(q0)=>J8(t,q0)})})]},`mode-${t}`)},D8=["flex-start","center","flex-end"],U8=["flex-start","center","flex-end"],q8=["t","c","b"],m8=["l","c","r"],_8=()=>{let t=!(L["flex-direction"]||S9(K["flex-direction"])||"row").startsWith("column"),B0=Math.max(0,D8.indexOf(L["justify-content"]||S9(K["justify-content"])||"flex-start")),q0=L["align-items"]||S9(K["align-items"])||"stretch",C0=q0==="stretch"?1:Math.max(0,U8.indexOf(q0)),[r0,F8]=t?[B0,C0]:[C0,B0];return q8[F8]+m8[r0]},G9=(t)=>{let B0=q8.indexOf(t[0]),q0=m8.indexOf(t[1]),C0=!(L["flex-direction"]||S9(K["flex-direction"])||"row").startsWith("column"),[r0,F8]=C0?[q0,B0]:[B0,q0];c("justify-content",D8[r0]),c("align-items",U8[F8])},Z9=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let B0=t.key.toLowerCase();if(B0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(B0==="y")t.preventDefault(),G?.("redo")},e0=(t)=>{let B0=L[t];if(!B0)return"inherit";return/var\(\s*--/.test(B0)?"bound":"raw"};if(!q)return _("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),_("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let p8={bound:"token-bound",raw:"raw override",inherit:"inherited"},o8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":p8[t]}),$9=(t,B0)=>{let q0=B0??e0(t),C0=C[t],r0=typeof C0==="string"&&C0.startsWith("err:")?C0.slice(4):"",F8=r0?" is-err":C0==="saved"?" is-saved":C0==="saving"?" is-saving":"",k8=!!L[t],P8=r0?`error: ${r0}`:k8?`${p8[q0]} · double-click to reset`:p8[q0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${q0}${F8}${k8?" is-resettable":""}`,"aria-label":P8,title:P8,tabIndex:k8?0:-1,onDoubleClick:k8?()=>g(t):void 0,onKeyDown:k8?(f8)=>{if(f8.key==="Backspace"||f8.key==="Delete")f8.preventDefault(),g(t)}:void 0})},j0=(t,B0,q0,C0)=>{let r0=q0===void 0&&!L[t],F8=C0??t;return _("div",{className:`st-cp-row${r0?" is-unset":""}`,children:[$9(t,q0),z("label",{className:"st-cp-label",title:F8,children:F8}),z("div",{className:"st-cp-ctl",children:B0})]},t)},F0={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},U0=(t)=>{(F0[t]||[]).forEach((B0)=>{if(L[B0])g(B0)})},k0=(t,B0)=>{let q0=(F0[t]||[]).some((C0)=>L[C0]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[t],onClick:()=>m((C0)=>({...C0,[t]:!C0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${q0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!q0,onClick:()=>U0(t),children:z(C9,{as:RG,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t)},H0=(t,B0,q0,C0=!0)=>{let r0=`d:${t}`,F8=f[r0]===void 0?C0:f[r0],k8=B0.some((P8)=>L[P8]);return _("section",{className:"st-cp-sec",children:[_("div",{className:"st-cp-sechd-row",children:[_("button",{type:"button",className:"st-cp-sechd","aria-expanded":F8,onClick:()=>m((P8)=>({...P8,[r0]:!F8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:F8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${k8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!k8,onClick:()=>B0.forEach((P8)=>{if(L[P8])g(P8)}),children:z(C9,{as:RG,size:12})})]}),z("div",{className:`st-cp-sec-anim${F8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:q0})})]},r0)},L0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!i[t],"aria-label":i[t]?`${t} — fewer options`:`${t} — more options`,title:i[t]?"fewer":"more",onClick:()=>a((B0)=>({...B0,[t]:!B0[t]})),children:i[t]?"▴":"···"}),N0=(t,B0)=>_("select",{className:"st-cp-nsel","aria-label":t,value:B0.includes(L[t])?L[t]:"",onChange:(q0)=>c(t,q0.target.value),children:[z("option",{value:"",disabled:!0,children:S9(K[t])||"—"}),B0.map((q0)=>z("option",{value:q0,children:q0},q0))]}),t0=(t)=>S(t).flatMap((B0)=>(B0.names||[]).map((q0)=>({name:q0,value:B0.vals?.[q0]||""}))),$8=(t,B0)=>z(_w,{value:L[t]||S9(K[t])||B0[0].value,ariaLabel:t,options:B0,onChange:(q0)=>c(t,q0)}),y0=(t,B0,q0={})=>{let C0=JQ(L[t]??""),r0=as.has(t),F8=L[t]??"",k8=typeof F8==="string"&&/var\(\s*--/.test(F8),P8=r0?"":C0.unit&&C0.unit!=="auto"?C0.unit:"px",f8=Number.parseFloat(JQ(S9(K[t])??"").n)||0,U9=C0.n!==""&&C0.n!=null?Number.parseFloat(C0.n)||0:f8,b9=wP[t];return z(JB,{value:k8?F8:U9,tokens:t0(B0),ariaLabel:t,min:q0.min??0,lead:b9?b9.node??b9.t:void 0,unitSlot:r0?null:z(e2,{units:rs,value:C0.unit||"px",ariaLabel:`${t} unit`,onChange:(D9)=>c(t,D9==="auto"?"auto":`${C0.n||"0"}${D9}`)}),onChange:(D9)=>c(t,typeof D9==="string"?D9:r0?`${D9}`:`${D9}${P8}`)})},v0=()=>{let t=(r0)=>Number.parseFloat(JQ(L[r0]??L["border-radius"]??S9(K[r0])??S9(K["border-radius"])??"0").n)||0,B0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},q0=(r0)=>{if(r0.tl===r0.tr&&r0.tr===r0.bl&&r0.bl===r0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((k8)=>{if(L[k8])g(k8)}),c("border-radius",`${r0.tl}px`);else c("border-top-left-radius",`${r0.tl}px`),c("border-top-right-radius",`${r0.tr}px`),c("border-bottom-left-radius",`${r0.bl}px`),c("border-bottom-right-radius",`${r0.br}px`)},C0=wP["border-radius"];return z(rf,{corners:B0,lead:C0?C0.node??C0.t:void 0,onCorners:q0})},O0=()=>_("div",{className:"st-cp-border",children:[_9("border-width",null,{fixedUnit:"px"}),_("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:ns.includes(L["border-style"])?L["border-style"]:"",onChange:(t)=>c("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),ns.map((t)=>z("option",{value:t,children:t},t))]}),z(KF,{kind:"color",groups:S("color"),current:L["border-color"],activeDs:T,swatchBg:K["border-color"]||L["border-color"]||"",seedHex:UF(K["border-color"]||L["border-color"])||"#000000",onPick:(t)=>c("border-color",t),label:"border colour"})]}),n0=()=>{let t=L.transform||S9(K.transform)||"",B0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),q0=((B0?Number.parseFloat(B0[1]):0)%360+360)%360,C0=(r0)=>{let F8=(r0%360+360)%360,k8=(L.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${k8?`${k8} `:""}rotate(${F8}deg)`.trim())};return _("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(of,{value:q0,onChange:C0}),z(Q5,{value:q0,min:0,max:360,ariaLabel:"rotation",lead:z(C9,{as:RG}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:C0})]})},Q8=()=>{let t=L.filter||S9(K.filter)||"",B0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),q0=B0?Number.parseFloat(B0[1]):0;return z(Q5,{value:q0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(r0)=>{let F8=(L.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",r0>0?`${F8?`${F8} `:""}blur(${r0}px)`.trim():F8||"none")}})},w0=()=>{let t=L.opacity,B0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(S9(K.opacity))||1,q0=Math.round((Number.isNaN(B0)?1:B0)*100);return z(a5,{value:q0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(C0)=>s("opacity",String(C0/100)),onCommit:(C0)=>c("opacity",String(C0/100))},`opacity:${t??""}`)},i0=()=>{let t=Number.parseInt(L["font-weight"]||S9(K["font-weight"])||"400",10)>=600,B0=(L["font-style"]||S9(K["font-style"]))==="italic",q0=/underline/.test(L["text-decoration"]||S9(K["text-decoration"])||"");return z(pf,{value:{b:t,i:B0,u:q0},ariaLabel:"text style",options:[{value:"b",node:z(C9,{as:KU}),label:"Bold"},{value:"i",node:z(C9,{as:FU}),label:"Italic"},{value:"u",node:z(C9,{as:EU}),label:"Underline"}],onToggle:(C0)=>{if(C0==="b")c("font-weight",t?"400":"700");else if(C0==="i")c("font-style",B0?"normal":"italic");else c("text-decoration",q0?"none":"underline")}})},H9=[{value:"row",node:z(C9,{as:v4}),label:"Row"},{value:"column",node:z(C9,{as:x4}),label:"Column"}],u8=[{value:"flex-start",node:z(C9,{as:GU}),label:"Start"},{value:"center",node:z(C9,{as:YU}),label:"Center"},{value:"flex-end",node:z(C9,{as:WU}),label:"End"},{value:"space-between",node:z(C9,{as:tH}),label:"Space between"}],R6=[{value:"flex-start",node:z(C9,{as:qU}),label:"Start"},{value:"center",node:z(C9,{as:ZU}),label:"Center"},{value:"flex-end",node:z(C9,{as:HU}),label:"End"},{value:"stretch",node:z(C9,{as:_U}),label:"Stretch"}],o9=[{value:"left",node:z(C9,{as:J5}),label:"Left"},{value:"center",node:z(C9,{as:g4}),label:"Center"},{value:"right",node:z(C9,{as:m4}),label:"Right"},{value:"justify",node:z(C9,{as:u4}),label:"Justify"}],d7=[{value:"visible",node:z(C9,{as:PG}),label:"Visible"},{value:"hidden",node:z(C9,{as:MU}),label:"Hidden"},{value:"scroll",node:z(C9,{as:OU}),label:"Scroll"}],k6=(t,B0)=>{let q0=S(B0);return q0.length?z(KF,{kind:"value",groups:q0,current:L[t],activeDs:T,onPick:(C0)=>c(t,C0),label:`${t} design token`}):null},F7=(t)=>{let B0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===B0)B0.select()})},fJ=(t,B0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let q0=t.shiftKey?10:1,C0=t.key==="ArrowUp"?1:-1,r0=(Number.parseFloat(t.currentTarget.value)||0)+C0*q0;return t.currentTarget.value=String(r0),B0(r0),!0},l9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:L[t]??"",placeholder:S9(K[t])||"—",onFocus:F7,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>c(t,B0.currentTarget.value)},`${t}:${L[t]??""}`),_9=(t,B0,q0={})=>{let C0=JQ(L[t]??""),r0=as.has(t),F8=r0?"":q0.fixedUnit||(C0.unit&&C0.unit!=="auto"?C0.unit:"px"),k8=wP[t],P8=Number.parseFloat(JQ(S9(K[t])??"").n)||0,f8=C0.n!==""&&C0.n!=null?Number.parseFloat(C0.n)||0:P8;return _(W0,{children:[z(Q5,{value:f8,min:q0.min??0,step:1,ariaLabel:t,lead:k8?k8.node??k8.t:void 0,onCommit:(U9)=>c(t,r0?`${U9}`:`${U9}${F8}`),unitSlot:r0||q0.fixedUnit?null:z(e2,{units:rs,value:C0.unit||"px",ariaLabel:`${t} unit`,onChange:(U9)=>c(t,U9==="auto"?"auto":`${C0.n||"0"}${U9}`)})},`${t}:${L[t]??""}`),k6(t,B0)]})},s7=(t)=>{let B0=K[t]||L[t]||"",q0=L[t]??"",C0=typeof q0==="string"&&/var\(\s*--/.test(q0),r0=C0?q0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):q0;return z(RU,{swatch:z(KF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:S("color"),current:L[t],activeDs:T,swatchBg:B0,seedHex:UF(K[t]||L[t])||"#000000",onPick:(F8)=>c(t,F8),label:`${t} colour`}),displayValue:r0,bound:C0,ariaLabel:t,onValue:(F8)=>c(t,F8)})},q9=(t,B0)=>{let q0=null,C0=B0.unitless?"":"px",r0=(P8)=>B0.unitless?`${P8}`:`${P8}${C0}`,F8=(P8,f8,U9)=>{for(let b9 of f8??[t])U9(b9,r0(P8))},k8=Aw({getBase:()=>q0?.value??"0",min:B0.min??0,step:1,sides:B0.sides,onInput:(P8,f8)=>{if(q0)q0.value=String(P8);if(f8){let U9=q0?.closest(".st-cp-box");for(let b9 of f8){if(b9===t)continue;let D9=U9?.querySelector(`.st-cp-boxv[aria-label="${b9}"]`);if(D9)D9.value=String(P8)}}F8(P8,f8,s)},onCommit:(P8,f8)=>F8(P8,f8,c)});return{onPointerDown:(P8)=>{q0=P8.currentTarget,k8(P8)}}},w9=(t,B0)=>{let q0=L[t],C0=q0!=null&&q0!==""?JQ(q0).n||q0:JQ(S9(K[t])??"").n||"0",r0=!q0||q0==="0"||q0==="0px"||q0==="auto",F8=t.split("-").pop(),k8=F8==="top"||F8==="bottom"?[`${B0}-top`,`${B0}-bottom`]:[`${B0}-left`,`${B0}-right`],P8=[`${B0}-top`,`${B0}-right`,`${B0}-bottom`,`${B0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${B0[0]}${t.split("-").pop()[0]}${r0?" is-zero":""}`,"aria-label":t,defaultValue:C0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...q9(t,{sides:{pair:k8,all:P8}}),onFocus:F7,onKeyDown:(f8)=>{if(fJ(f8,(U9)=>c(t,`${U9}px`)))return;if(f8.key==="Enter")f8.currentTarget.blur()},onBlur:(f8)=>{let U9=f8.currentTarget.value.trim();if(!U9)return;let b9=/[a-z%]/i.test(U9)?U9:`${U9}px`;c(t,b9)}},`${t}:${q0??""}`)},H7=(t)=>{let B0=L[t],q0=B0!=null&&B0!==""&&B0!=="auto"?JQ(B0).n||B0:JQ(S9(K[t])??"").n||"",C0=!B0||B0==="auto"||B0==="0"||B0==="0px",r0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],F8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${C0?" is-zero":""}`,"aria-label":t,defaultValue:q0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...q9(t,{sides:{pair:r0,all:F8},min:-1/0}),onFocus:F7,onKeyDown:(k8)=>{if(fJ(k8,(P8)=>c(t,`${P8}px`)))return;if(k8.key==="Enter")k8.currentTarget.blur()},onBlur:(k8)=>{let P8=k8.currentTarget.value.trim();if(!P8)return;let f8=/[a-z%]/i.test(P8)?P8:`${P8}px`;c(t,f8)}},`${t}:${B0??""}`)},N7=Object.entries(M),n9=Object.entries(w),WX=()=>{let t=(X.tag||"").toLowerCase(),q0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!L["object-fit"]||!!L["object-position"]||!!L["aspect-ratio"],C0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:q0,canReplace:C0}},I7=(t)=>_(W0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),j0("object-fit",N0("object-fit",SV0)),j0("object-position",l9("object-position")),j0("aspect-ratio",_("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:Jt.includes(L["aspect-ratio"])?L["aspect-ratio"]:"",onChange:(B0)=>{let q0=B0.target.value;if(c("aspect-ratio",q0),q0&&q0!=="auto"&&L.height)g("height")},children:[z("option",{value:"",disabled:!0,children:S9(K["aspect-ratio"])||"—"}),Jt.map((B0)=>z("option",{value:B0,children:B0},B0))]}))]});return _("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Z9,children:[_("div",{className:"st-cp-id",children:[_("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?_("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(_w,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(C9,{as:f4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(C9,{as:l4,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?_(W0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(L.display||S9(K.display)||"").trim();return t==="flex"||t==="inline-flex"?_(W0,{children:[j0("flex-direction",$8("flex-direction",H9),void 0,"Direction"),j0("align-items",z(cf,{value:_8(),onChange:G9,ariaLabel:"auto-layout alignment"}),e0("align-items"),"Alignment"),j0("gap",y0("gap","space"),void 0,"Gap"),_("div",{className:"st-cp-modes",children:[s0("width"),s0("height")]}),_("div",{className:"st-cp-box","aria-label":"padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(e0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:L0("Auto layout")}),i["Auto layout"]?j0("flex-wrap",z(i4,{checked:/^wrap/.test(L["flex-wrap"]||S9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(q0)=>c("flex-wrap",q0?"wrap":"nowrap")}),e0("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],_(W0,{children:[j0("width",_9("width"),void 0,"Width"),j0("height",_9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:L0("Size")}),i.Size?_(W0,{children:[j0("min-width",_9("min-width"),void 0,"Min width"),j0("max-width",_9("max-width"),void 0,"Max width"),j0("min-height",_9("min-height"),void 0,"Min height"),j0("max-height",_9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],_(W0,{children:[j0("position",N0("position",ss),void 0,"Position"),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(e0("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||S9(K.position)||"static"})]}),(L.position||S9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:L0("Position")}),i.Position?j0("z-index",_9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],j0("background-color",s7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],j0("border",O0(),e0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],j0("border-radius",v0(),e0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],_(W0,{children:[j0("box-shadow",k6("box-shadow","shadow")||l9("box-shadow"),void 0,"Shadow"),j0("filter",Q8(),e0("filter"),"Blur"),j0("mix-blend-mode",N0("mix-blend-mode",Xt),void 0,"Blend")]})),H0("Opacity",["opacity"],j0("opacity",w0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],_(W0,{children:[j0("font-family",N0("font-family",os),void 0,"Font"),j0("color",s7("color"),void 0,"Color"),j0("font-size",y0("font-size","type"),void 0,"Size"),j0("font-weight",N0("font-weight",is),void 0,"Weight"),j0("line-height",_9("line-height","lh"),void 0,"Line height"),j0("text-align",$8("text-align",o9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:L0("Text")}),i.Text?_(W0,{children:[j0("letter-spacing",_9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),j0("font-style",N0("font-style",CV0),void 0,"Style"),j0("text-transform",N0("text-transform",ts),void 0,"Case"),j0("white-space",N0("white-space",es),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],_("div",{className:"st-cp-box","aria-label":"margin",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(e0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:B0}=WX();return t?H0("Media",["object-fit","object-position","aspect-ratio"],I7(B0)):null})()]}):_(W0,{children:[k0("Layout",(()=>{let t=(L.display||S9(K.display)||"").trim(),B0=t==="flex"||t==="inline-flex",q0=t==="grid"||t==="inline-grid";return _(W0,{children:[j0("display",N0("display",TV0)),B0?_(W0,{children:[j0("flex-direction",$8("flex-direction",H9)),j0("flex-wrap",z(i4,{checked:/^wrap/.test(L["flex-wrap"]||S9(K["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(C0)=>c("flex-wrap",C0?"wrap":"nowrap")}),e0("flex-wrap"))]}):null,B0||q0?_(W0,{children:[j0("align-items",$8("align-items",R6)),j0("justify-content",$8("justify-content",u8)),j0("gap",y0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!q,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(L.display||S9(K.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let q0=L["grid-template-columns"]||"",C0=L["grid-template-rows"]||"",r0=_D(q0),F8=_D(C0),k8=r0.length>0||!q0.trim(),P8=F8.length>0||!C0.trim();return k0("Grid",_(W0,{children:[k8?z(Yt,{label:"Columns",tracks:r0,editable:q,onChange:(f8)=>c("grid-template-columns",ED(f8))}):_("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:q0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),P8?z(Yt,{label:"Rows",tracks:F8,editable:q,onChange:(f8)=>c("grid-template-rows",ED(f8))}):_("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:C0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),k0("Position",_(W0,{children:[j0("position",N0("position",ss)),_("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[o8(e0("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:L.position||S9(K.position)||"static"})]}),(L.position||S9(K.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,j0("z-index",_9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&k0("Grid item",_(W0,{children:[_("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),j0("grid-column",l9("grid-column")),j0("grid-row",l9("grid-row"))]})),k0("Typography",_(W0,{children:[j0("font-family",N0("font-family",os)),j0("color",s7("color")),j0("font-size",y0("font-size","type")),j0("font-weight",N0("font-weight",is)),j0("line-height",_9("line-height","lh")),j0("letter-spacing",_9("letter-spacing",null,{min:-1/0})),j0("text-align",$8("text-align",o9)),j0("font-style",i0(),e0("font-style")),j0("text-transform",N0("text-transform",ts)),j0("white-space",N0("white-space",es))]})),k0("Spacing",z(W0,{children:_("div",{className:"st-cp-box","aria-label":"margin and padding",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[o8(e0("margin-top")),"margin"]}),w9("margin-top","margin"),w9("margin-right","margin"),w9("margin-bottom","margin"),w9("margin-left","margin"),_("div",{className:"st-cp-boxpad",children:[_("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[o8(e0("padding-top")),"padding"]}),w9("padding-top","padding"),w9("padding-right","padding"),w9("padding-bottom","padding"),w9("padding-left","padding"),_("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)]})]})]})})),k0("Size",_(W0,{children:[_("div",{className:"st-cp-modes",children:[s0("width"),s0("height")]}),j0("width",_9("width")),j0("height",_9("height")),j0("min-width",_9("min-width")),j0("max-width",_9("max-width")),j0("min-height",_9("min-height")),j0("max-height",_9("max-height")),j0("overflow",$8("overflow",d7)),G8?_(W0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),j0("align-self",N0("align-self",IV0)),j0("flex-grow",_9("flex-grow",null,{unitless:!0})),j0("flex-shrink",_9("flex-shrink",null,{unitless:!0})),j0("flex-basis",_9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:B0}=WX();return t?k0("Media",I7(B0)):null})(),k0("Appearance",_(W0,{children:[j0("background-color",s7("background-color")),j0("border-radius",v0(),e0("border-radius")),j0("border",O0(),e0("border-width")),j0("box-shadow",k6("box-shadow","shadow")||l9("box-shadow")),j0("filter",Q8(),e0("filter")),j0("mix-blend-mode",N0("mix-blend-mode",Xt)),j0("opacity",w0()),j0("rotation",n0(),e0("transform")),j0("transform",l9("transform")),j0("transform-origin",l9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,B0])=>typeof B0==="string"&&B0.startsWith("err:"));return t?_("div",{className:"st-cp-save is-err",role:"status",children:[z(s8,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),k0("Advanced",_("div",{className:"st-cp-advbody",children:[N7.length?_(W0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),N7.map(([t,B0])=>_("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${t} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>V0(t,q0.currentTarget.value)},`cs:${t}:${B0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>d(t),children:z(s8,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(jV0,{commit:V0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),n9.length?_(W0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),n9.map(([t,B0])=>_("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:B0,"aria-label":`${t} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>p(t,q0.currentTarget.value)},`at:${t}:${B0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>K0(t),children:z(s8,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(yV0,{commit:p})]}))]}),_("div",{className:"st-cp-legend",children:[_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),_("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function jV0({commit:X}){let[J,Q]=l.useState(""),[Y,W]=l.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function yV0({commit:X}){let[J,Q]=l.useState(""),[Y,W]=l.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return _("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var fV0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function vV0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===J)return G=q[K],q.splice(K,1),!0;if(q[K].children&&Z(q[K].children))return!0}return!1};if(Z(W),!G)return X;let H=(q)=>{for(let K=0;K<q.length;K++){if(q[K].id===Q){if(Y==="inside-start"||Y==="inside-end")if(q[K].children=q[K].children||[],Y==="inside-start")q[K].children.unshift(G);else q[K].children.push(G);else q.splice(Y==="before"?K:K+1,0,G);return!0}if(q[K].children&&H(q[K].children))return!0}return!1};return H(W)?W:X}var xV0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Ft({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:M,onToggleLock:w,onRename:R}){let A=`${X.id}:${X.index}`,D=X.children&&X.children.length>0,P=W.has(A),T=!!X.synthetic,I=!T&&L?L[X.id]:null,S=!T&&!!M?.has(A),[C,j]=l.useState(!1),[f,m]=l.useState(""),o=!T&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(A)?G.get(A):!!X.hidden,x=!!V&&!T&&!S,i=()=>{j(!1);let s=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},a=F?.key===A,h=a?{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 _(W0,{children:[_("div",{className:"st-layer st-layer--row"+(o?" is-sel":"")+(n?" is-hidden":"")+(T?" is-group":"")+(I?" is-instance":"")+(S?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:o,"aria-expanded":D?!P:void 0,"aria-grabbed":x?a:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":A,onClick:()=>T?D&&Z(A):H(X),onMouseEnter:()=>!T&&q(X),onMouseLeave:()=>q(null),onPointerDown:x?(s)=>B(s,X,A):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)D&&Z(A);else H(X);else if(s.key==="F2"&&R&&!T)s.preventDefault(),m(X.dcElement||X.label||""),j(!0)},children:[D?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(A)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),I?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:I.root?"◆":"◇"}):z(s8,{name:fV0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>m(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:i,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")i();else if(s.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!T?(s)=>{s.stopPropagation(),m(X.dcElement||X.label||""),j(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:I?I.component:X.type}),w&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":S?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":S,title:S?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),w(A)},children:z(s8,{name:S?"lock":"unlock",size:12})}):null,K&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),K(X)},children:z(s8,{name:n?"eye-off":"eye",size:13})}):null]}),D&&!P?X.children.map((s,X0)=>z(Ft,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:q,onToggleVisibility:K,onReorder:V,onRowPointerDown:B,dragState:F,componentMap:L,lockedKeys:M,onToggleLock:w,onRename:R},`${s.id}:${s.index}`)):null]})}function hV0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(K)=>{let V=Q[K];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return J[K]||V||""},W=(K,V)=>{let B=J[V]||Q[V];if(!B)return null;return _("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:K}),_("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},K)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?JQ(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 _(W0,{children:[G?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Nt(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var gV0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],mV0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function uV0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let q=Nt(X),K=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=Ut(X.file,J),B=Vt(J,K,V),F=(a)=>B.map((h)=>({ds:h.name,names:h[a]||[],vals:h.vals})).filter((h)=>h.names.length),L=(a)=>F(a).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),M=(a)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(a||"");if(!h)return a||"";for(let s of B){let X0=s.vals?.[h[1]];if(X0)return X0}return""},w=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,A=(a,h)=>{if(!q)return;let s=Number.isFinite(a)&&a>0?Math.round(a):void 0,X0=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&X0==null)return;Q?.(q,s,X0)},D=Object.entries(yJ).find(([,a])=>a.width===w&&a.height===R)?.[0],P=Object.entries(yJ).find(([,a])=>a.width===w)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",I=X.attrs?.["data-dc-bg"]??"",S=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",j=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",m=null;try{m=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let o=(a)=>{if(!q)return;let h=null;if(a==="print"&&!m){let s={paper:"a4"};try{let X0=U3(s);if(X0)h={defaults:s,widthPx:X0.widthPx,heightPx:X0.heightPx}}catch{}}if(G?.(q,a==="digital"?null:a,h),a==="web"&&T)Y?.(q,!1,void 0)},n=(a)=>{if(!q)return;let h={paper:"a4",...m,...a},s;try{s=U3(h)}catch{return}Q?.(q,s.widthPx,s.heightPx),Z?.(q,h)},x=(a)=>{if(!q)return;let h=a&&Number.isFinite(R)?Math.round(R):void 0;Y?.(q,a,h)},i=(a)=>{if(!q)return;W?.(q,a)};return _("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),_("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(Q5,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(a)=>A(a,null)}),z(Q5,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(a)=>{if(T)A(null,a)}})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?_("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(a)=>n({paper:a.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),K3.map((a)=>_("option",{value:a.id,children:[a.label," — ",a.width,"×",a.height,a.unit]},a.id))]}):f==="web"?_("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)A(h.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${yJ[P].label} — ≤ ${yJ[P].width}px`:"Breakpoint…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ≤ ",h.width,"px breakpoint"]},a))]}):_("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:D??"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)A(h.width,h.height)},children:[z("option",{value:"",disabled:!0,children:D?yJ[D].label:"Preset size…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ",h.width,"×",h.height]},a))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(XB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(a)=>x(a==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(c4,{value:f,ariaLabel:"artboard kind",options:mV0.map(([a,h])=>({value:a,label:h})),onChange:o})}),f!=="print"&&q&&H?z("div",{style:{padding:"0 12px 8px"},children:_("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(a)=>{let h=yJ[a.currentTarget.value];if(h)H(q,h.width);a.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(yJ).map(([a,h])=>_("option",{value:a,children:[h.label," — ",h.width,"px"]},a))]})}):null,f==="print"?_(W0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(XB,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(a)=>n({orientation:a})})}),z("div",{style:{padding:"0 12px 8px"},children:z(Q5,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(a)=>n({bleedMm:a})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),_("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let a=M(I),h=/var\(\s*--/.test(I),s=h?I.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):I;return z(RU,{swatch:z(KF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:I,activeDs:V,swatchBg:a,seedHex:UF(a)||"#000000",onPick:(X0)=>i({background:X0||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(X0)=>i({background:(X0||"").trim()||null})})})(),z(c4,{value:C,ariaLabel:"artboard body layout",options:gV0.map(([a,h])=>({value:a,label:h})),onChange:(a)=>i({layout:a||null})}),_("div",{style:{display:"flex",gap:8},children:[z(JB,{value:/^var\(/.test(S)?S:Number.parseFloat(S)||0,tokens:L("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(a)=>i({padding:typeof a==="string"?a:a>0?a:null})}),z(JB,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:L("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(a)=>i({gap:typeof a==="string"?a:a>0?a:null})})]})]})]})}var PP=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,lV0=new RegExp(PP.source,"gi");function dV0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(lV0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=PP.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function pV0({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:q,onHoverLayer:K,onReorderLayer:V,layersBusyRef:B,cfg:F,onOptimistic:L,onRecordEdit:M,onReplaceMedia:w,onResizeArtboard:R,onSetArtboardHug:A,onSetArtboardStyle:D,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I,onUndoRedo:S,editScope:C,tab:j,onTabChange:f,width:m,resizing:o,photoSel:n,photoRev:x,onPhotoEdit:i,onPhotoRemoveBackground:a,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:X0=!1,hideLayersTab:c=!1,cpMode:V0,onSetCpMode:p}){let[g,d]=l.useState("inspect"),K0=X0?"layers":j??g,u0=(O0)=>{d(O0),f?.(O0)},[J8,G8]=l.useState(()=>new Set),[s0,D8]=l.useState(()=>new Map);l.useEffect(()=>{let O0=Array.isArray(X)?X[0]:X,n0=O0?.id;if(!n0||!Q?.nodes)return;let Q8=O0.index,w0=null,i0=[];if(function H9(u8,R6){for(let o9 of u8||[]){let d7=`${o9.id}:${o9.index}`;if(!o9.synthetic&&o9.id===n0&&(Q8==null||o9.index===Q8))return w0=d7,i0.push(...R6),!0;if(o9.children&&o9.children.length&&H9(o9.children,[...R6,d7]))return!0}return!1}(Q.nodes,[]),!w0)return;if(i0.length)G8((H9)=>{let u8=!1,R6=new Set(H9);for(let o9 of i0)if(R6.delete(o9))u8=!0;return u8?R6:H9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${w0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let U8=(O0)=>{let n0=`${O0.id}:${O0.index}`;return s0.has(n0)?s0.get(n0):!!O0.hidden},[q8,m8]=l.useState(null),[_8,G9]=l.useState(""),Z9=(O0,n0)=>{if(!H||!O0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:O0.id,attr:"data-dc-element",value:n0})}).then((Q8)=>Q8.json().catch(()=>({}))).then((Q8)=>{if(!Q8.ok)return;M?.({op:"attr",canvas:H,id:O0.id,key:"data-dc-element",before:O0.dcElement??null,after:n0})}).catch(()=>{})},e0=V?(O0,n0,Q8)=>{if(B?.current)return;if(O0?.synthetic||n0?.synthetic)return;let w0=Q8==="before"?`before ${n0.label}`:Q8==="after"?`after ${n0.label}`:`into ${n0.label}`;G9(`Moved ${O0.label} ${w0}`),V(O0.id,n0.id,Q8,{idIndex:O0.index,refIndex:n0.index})}:void 0,p8=()=>{let O0=[];return function n0(Q8,w0,i0){(Q8||[]).forEach((H9,u8)=>{if(O0.push({node:H9,depth:w0,parentNode:i0,siblings:Q8,pos:u8}),H9.children&&H9.children.length&&!J8.has(`${H9.id}:${H9.index}`))n0(H9.children,w0+1,H9)})}(Q?.nodes,0,null),O0},o8=(O0)=>{if(O0.key!=="ArrowUp"&&O0.key!=="ArrowDown")return;if(!H0)return;let n0=p8(),Q8=n0.findIndex((u8)=>u8.node.id===H0.id&&u8.node.index===H0.index);if(Q8<0)return;let w0=O0.key==="ArrowDown"?1:-1,i0=n0[Q8];if(!O0.altKey){let u8=n0[Q8+w0];if(u8)O0.preventDefault(),q?.(u8.node);return}if(!e0||!Array.isArray(i0.siblings))return;O0.preventDefault();let H9=(u8)=>u8&&u8.children&&u8.children.length&&!J8.has(`${u8.id}:${u8.index}`);if(!O0.shiftKey){if(w0<0&&i0.pos>0)e0(i0.node,i0.siblings[i0.pos-1],"before");else if(w0>0&&i0.pos<i0.siblings.length-1)e0(i0.node,i0.siblings[i0.pos+1],"after");return}if(w0>0){let u8=i0.siblings[i0.pos+1];if(u8)e0(i0.node,u8,H9(u8)?"inside-start":"after");else if(i0.parentNode)e0(i0.node,i0.parentNode,"after")}else{let u8=i0.siblings[i0.pos-1];if(u8)e0(i0.node,u8,H9(u8)?"inside-end":"before");else if(i0.parentNode)e0(i0.node,i0.parentNode,"before")}},$9=l.useRef(null),j0=l.useRef(null),F0=(O0,n0,Q8)=>{if(!e0||O0.button!==0||O0.metaKey||O0.ctrlKey||O0.shiftKey||O0.altKey)return;if(B?.current)return;let{clientX:w0,clientY:i0}=O0,H9=new Set([Q8]);(function q9(w9){(w9.children||[]).forEach((H7)=>{H9.add(`${H7.id}:${H7.index}`),q9(H7)})})(n0);let u8=14,R6=6,o9=[];(function q9(w9,H7){(w9||[]).forEach((N7)=>{let n9=`${N7.id}:${N7.index}`;if(o9.push({node:N7,key:n9,id:N7.id,depth:H7,tag:N7.tag}),N7.children&&N7.children.length&&!J8.has(n9))q9(N7.children,H7+1)})})(Q?.nodes,0);let d7=new Map(o9.map((q9)=>[q9.key,q9])),k6=!1,F7=(q9)=>{if(!k6){if(Math.hypot(q9.clientX-w0,q9.clientY-i0)<4)return;k6=!0}let w9=q9.clientX-w0,H7=q9.clientY-i0,N7=null,n9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((I7)=>({rect:I7.getBoundingClientRect(),it:d7.get(I7.getAttribute("data-layer-key"))})).filter((I7)=>I7.it&&I7.it.key!==Q8);if(n9.length){let I7=n9[0].rect.left,t=n9[0].rect.right,B0=n9.length;for(let D9=0;D9<n9.length;D9++)if(q9.clientY<n9[D9].rect.top+n9[D9].rect.height/2){B0=D9;break}let q0=n9[B0-1]?.it||null,C0=n9[B0]?.it||null,r0=Math.round((q9.clientX-I7-R6)/u8),F8=q0?q0.depth+(xV0.has(q0.tag)?0:1):0,k8=C0?C0.depth:0,P8=Math.max(k8,Math.min(r0,F8)),f8=null,U9="before",b9=0;if(!q0){if(C0)f8=C0,U9="before",b9=C0.depth}else if(P8>q0.depth)f8=q0,U9="inside-start",b9=q0.depth+1;else if(P8===q0.depth)f8=q0,U9="after",b9=q0.depth;else{for(let D9=B0-1;D9>=0;D9--)if(n9[D9].it.depth===P8){f8=n9[D9].it;break}if(!f8)f8=q0;U9="after",b9=P8}if(f8&&f8.key!==Q8&&!H9.has(f8.key)){let D9=q0?n9[B0-1].rect.bottom:n9[0].rect.top,vJ=I7+R6+b9*u8;N7={refId:f8.id,position:U9,node:f8.node,y:D9,left:vJ,w:Math.max(24,t-vJ)}}}let WX={key:Q8,node:n0,dx:w9,dy:H7,target:N7};$9.current=WX,m8(WX)},fJ=()=>{window.removeEventListener("pointermove",F7),window.removeEventListener("pointerup",_9),window.removeEventListener("keydown",s7,!0)},l9=()=>{let q9=(w9)=>{w9.preventDefault(),w9.stopImmediatePropagation(),document.removeEventListener("click",q9,!0)};document.addEventListener("click",q9,!0),setTimeout(()=>document.removeEventListener("click",q9,!0),300)},_9=()=>{fJ();let q9=$9.current;if($9.current=null,m8(null),k6&&q9?.target)l9(),e0(q9.node,q9.target.node,q9.target.position)},s7=(q9)=>{if(q9.key!=="Escape")return;if(q9.preventDefault(),q9.stopImmediatePropagation(),fJ(),$9.current=null,m8(null),k6)l9()};window.addEventListener("pointermove",F7),window.addEventListener("pointerup",_9),window.addEventListener("keydown",s7,!0)},U0=(O0)=>G8((n0)=>{let Q8=new Set(n0);if(Q8.has(O0))Q8.delete(O0);else Q8.add(O0);return Q8}),k0=(O0)=>{let n0=`${O0.id}:${O0.index}`,Q8=U8(O0),w0=!Q8;if(D8((i0)=>new Map(i0).set(n0,w0)),L?.({id:O0.id,artboardId:Q?.artboardId??null,index:O0.index,prop:"display",value:w0?"none":null}),!H||!O0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w0?{canvas:H,id:O0.id,property:"display",value:"none"}:{canvas:H,id:O0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:O0.id,key:"display",before:Q8?"none":null,after:w0?"none":null})},H0=Array.isArray(X)?X[0]:X,L0=n?{asset:n.asset,kind:"annotation-image"}:(()=>{let O0=dV0(H0);return O0?{asset:O0,kind:"artboard-img"}:null})(),N0=L0?.kind==="annotation-image",t0=(O0)=>{if(!(O0.metaKey||O0.ctrlKey)||O0.altKey)return;let n0=O0.key.toLowerCase();if(n0==="z")O0.preventDefault(),s?.(O0.shiftKey?"redo":"undo");else if(n0==="y")O0.preventDefault(),s?.("redo")},$8=N0?"photo":K0==="photo"&&!L0?"inspect":K0,y0=(O0,n0,Q8)=>_("button",{type:"button",className:"st-rp-tab"+($8===O0?" is-active":""),onClick:()=>u0(O0),children:[z(s8,{name:Q8,size:14}),n0]}),v0=H0?.bounds||null;return _("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:m?{width:m,flexBasis:m}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[_("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:X0?{display:"none"}:void 0,children:[N0?y0("photo","Photo","image"):_(W0,{children:[y0("inspect","Inspect","sliders"),!c&&y0("layers","Layers","layers"),y0("css","CSS","code"),L0?y0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:z(s8,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&C?_("div",{className:`st-scope st-scope--${C.scope}`,title:C.scope==="shared"?`Editing this element's style changes ${C.affects} place${C.affects===1?"":"s"}${C.componentName?` (component ${C.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),C.scope==="shared"?`Shared${C.componentName?` · ${C.componentName}`:""} · edits ${C.affects} place${C.affects===1?"":"s"}`:"Local · this element only",C.scope==="shared"&&Z?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:$8==="photo"&&L0?z("div",{onKeyDown:t0,children:z(sf,{asset:L0.asset,ColorPicker:Bt,StIcon:s8,onEdit:(O0)=>i?.(L0.asset,O0),onRemoveBackground:a,onRecordEdit:(O0,n0)=>h?.(L0.asset,O0,n0)},`${L0.asset}:${x??0}`)}):!H0&&!($8==="layers"&&Q?.nodes?.length)?z("div",{className:"st-rp-empty",children:_("p",{children:["Press ",z(l6,{children:"V"}),", then click an element to select it — or ",z(l6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&$8==="inspect"?_(W0,{children:[z("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:v0?Math.round(v0.x):"—",readOnly:!0,"aria-label":"x position"})]}),_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:v0?Math.round(v0.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),_("div",{className:"st-insp-fields",children:[_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:v0?Math.round(v0.w):"—",readOnly:!0,"aria-label":"width"})]}),_("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:v0?Math.round(v0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H0.tag||"—"})})]}),H0.classes?_("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:H0.classes})})]}):null,z(hV0,{el:H0})]}):$8==="layers"?_(W0,{children:[_("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?_(W0,{children:[e0?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:j0,onKeyDown:o8,children:Q.nodes.map((O0,n0)=>z(Ft,{node:O0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:s0,onToggle:U0,onSelect:(Q8)=>{q?.(Q8),j0.current?.focus()},onHover:(Q8)=>K?.(Q8),onToggleVisibility:k0,onReorder:e0,onRowPointerDown:F0,dragState:q8,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:Z9},`${O0.id}:${O0.index}`))}),q8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:q8.target.left,top:q8.target.y-1,width:q8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:_8})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((O0,n0)=>_("div",{className:"st-layer"+(n0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+n0*12},children:[z(s8,{name:"square",size:13}),O0]},n0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&Nt(H0)?z(uV0,{el:H0,cfg:F,onResizeArtboard:R,onSetArtboardHug:A,onSetArtboardStyle:D,onSetArtboardKind:P,onSetArtboardPrint:T,onDuplicateArtboard:I}):z(bV0,{el:H0,cfg:F,onOptimistic:L,onRecordEdit:M,onReplaceMedia:w,onUndoRedo:S,mode:V0,onSetMode:p})})]})}function cV0(){let[X,J]=l.useState([]),[Q,Y]=l.useState("Design"),[W,G]=l.useState([]),[Z,H]=l.useState(null),[q,K]=l.useState(null),V=l.useRef(null);l.useEffect(()=>{V.current=q},[q]);let[B,F]=l.useState(null);l.useEffect(()=>{let y=Array.isArray(q)?q.length===1?q[0]:null:q,b=y&&typeof y.id==="string"?y.id:null;if(!b||!Z){F(null);return}let Q0=new AbortController,z0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${z0}`,{signal:Q0.signal}).then((G0)=>G0.ok?G0.json():null).then((G0)=>{if(G0?.ok)F(G0)}).catch(()=>{}),()=>Q0.abort()},[q,Z]);let L=l.useRef(0),M=l.useRef([]),w=l.useCallback((y)=>{if(!y?.id||!y.file)return;for(let b of M.current)clearTimeout(b);M.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let Q0=V.current,z0=Array.isArray(Q0)?Q0[0]:Q0;if(!z0||z0.id!==y.id||z0.file!==y.file)return;let G0=R8.current.get(y.file);if(!G0?.contentWindow)return;try{G0.contentWindow.postMessage({dgn:"select-by-id",id:y.id,artboardId:y.artboardId??null,index:y.index??0},"*")}catch{}},b))},[]),R=l.useRef([]),A=l.useCallback((y,b)=>{if(!y||!b)return;for(let Q0 of R.current)clearTimeout(Q0);R.current=[50,450,1200,2500,5000].map((Q0)=>setTimeout(()=>{let z0=V.current,G0=Array.isArray(z0)?z0[0]:z0;if(!G0||G0.artboardId!==y||G0.file!==b)return;let f0=R8.current.get(b);if(!f0?.contentWindow)return;try{f0.contentWindow.postMessage({dgn:"select-by-id",artboardId:y},"*")}catch{}},Q0))},[]),D=l.useRef(null),P=l.useRef(null),T=l.useRef(null),I=l.useRef(null),S=l.useRef(!1),C=l.useRef(null),[j,f]=l.useState(null),[m,o]=l.useState(null),n=l.useRef({canvas:null,at:0});l.useEffect(()=>{if(!Z||!j)return;let y=Date.now(),b=n.current;if(b.canvas===Z&&y-b.at<1500)return;n.current={canvas:Z,at:y},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((Q0)=>Q0.json()).then((Q0)=>{if(Q0?.ok&&Q0.map&&typeof Q0.map==="object")o(Q0.map);else o(null)}).catch(()=>o(null))},[Z,j]);let[x,i]=l.useState(!1),[a,h]=l.useState(null),[s,X0]=l.useState(null),[c,V0]=l.useState(null),[p,g]=l.useState(null),[d,K0]=l.useState(!1),[u0,J8]=l.useState(null),[G8,s0]=l.useState(""),[D8,U8]=l.useState(null),[q8,m8]=l.useState(null),_8=l.useRef(null),G9=us("maude-sb-w",{min:200,max:420,def:252}),Z9=us("maude-rp-w",{min:260,max:480,def:304}),[e0,p8]=l.useState(null),o8=l.useRef(null);l.useEffect(()=>{if(!e0)return;let y=(Q0)=>{let z0=o8.current?.getBoundingClientRect();if(!z0)return;if(e0==="sb")G9.setW(Q0.clientX-z0.left);else Z9.setW(z0.right-Q0.clientX)},b=()=>p8(null);return window.addEventListener("pointermove",y),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",b)}},[e0,G9.setW,Z9.setW]);let $9=l.useCallback((y)=>{clearTimeout(_8.current),_8.current=setTimeout(()=>{m8((b)=>b===y?null:b)},2500)},[]);l.useEffect(()=>{if(!q8)return;let y=setTimeout(()=>m8(null),15000);return()=>clearTimeout(y)},[q8]);let[j0,F0]=l.useState({designRel:".design"}),U0=l.useCallback(()=>{fetch("/_config").then((y)=>y.json()).then((y)=>{let b=(y.designRoot||".design").replace(/^\/+|\/+$/g,"");F0((Q0)=>({...Q0,designRel:b,tokensCssRel:y.tokensCssRel,designSystems:y.designSystems,canvasOrigin:y.canvasOrigin}))}).catch(()=>{})},[]);l.useEffect(()=>{U0()},[U0]),l.useEffect(()=>{let y=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(y||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{y=!0}},[]),l.useEffect(()=>{let y=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!y&&b)V0(b)}).catch(()=>{}),()=>{y=!0}},[]);let[k0,H0]=l.useState({}),[L0,N0]=l.useState(null),[t0,$8]=l.useState(!1),[y0,v0]=l.useState("open"),[O0,n0]=l.useState(bU0),[Q8,w0]=l.useState(()=>{return LP(Cs,"advanced")==="designer"?"designer":"advanced"});l.useEffect(()=>{try{localStorage.setItem(Cs,JSON.stringify(Q8))}catch{}},[Q8]);let[i0,H9]=l.useState(null),[u8,R6]=l.useState(()=>QZ(Ss,!0)),[o9,d7]=l.useState(()=>QZ(Ts,!1)),[k6,F7]=l.useState(()=>LP(Is,{})),[fJ,l9]=l.useState(!1),[_9,s7]=l.useState(!1),[q9,w9]=l.useState(!1),[H7,N7]=l.useState(!1),[n9,WX]=l.useState(!1),{report:I7}=Hw(K9()),[t,B0]=l.useState(!1),[q0,C0]=l.useState(!1),[r0,F8]=l.useState(null),[k8,P8]=l.useState(!1),[f8,U9]=l.useState(!1),[b9,D9]=l.useState(!1),[vJ,QQ]=l.useState(!1),[T6,BY]=l.useState(()=>LP(ys,Aq)),[GX,FY]=l.useState(()=>{try{let y=localStorage.getItem(fs);if(y==="separate"||y==="in-inspector")return y}catch{}return"separate"}),[wX,w7]=l.useState(!1),[q6,X7]=l.useState([]),[rX,aX]=l.useState(0),[YZ,h9]=l.useState(!1),[YQ,Rq]=l.useState(!1),[L7,WZ]=l.useState(!1),[WQ,A7]=l.useState(1),[GQ,j9]=l.useState(216),[X9,A5]=l.useState(null),[NY,GZ]=l.useState([]),[kq,ZZ]=l.useState([]),[ZQ,HZ]=l.useState(0),I6=l.useMemo(()=>{if(!q6.length)return null;return(q6.find((b)=>b.durationInFrames===ZQ)??q6[0]).id},[q6,ZQ]),sX=l.useRef(null);l.useEffect(()=>{sX.current=I6},[I6]);let ZW=l.useRef(0);l.useEffect(()=>{ZW.current=rX},[rX]);let[d6,Tq]=l.useState(null),Iq=l.useRef(null);l.useEffect(()=>{Iq.current=d6},[d6]);let[AX,HW]=l.useState(!1),[Cq,qZ]=l.useState(!1),[Sq,xJ]=l.useState(!1),hJ=l.useRef(AX);l.useEffect(()=>{if(hJ.current=AX,AX){xJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[AX]);let tX=l.useCallback(()=>{if(!hJ.current||document.hidden)xJ(!0),xs("Claude finished","Your assistant turn is ready in Maude.")},[]),zZ=l.useRef(0),eX=l.useCallback(()=>{if(!hJ.current||document.hidden){xJ(!0);let y=Date.now();if(y-zZ.current<SU0)return;zZ.current=y,xs("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[HQ,_5]=l.useState("inspect"),[$q,LY]=l.useState(null),C6=l.useRef({undo:[],redo:[]}),[qW,bq]=l.useState(0),[XJ,_X]=l.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),C7=l.useRef(XJ);l.useEffect(()=>{C7.current=XJ;try{localStorage.setItem("maude-auto-open-inspector",XJ?"1":"0")}catch{}},[XJ]);let J7=l.useRef(!1);l.useEffect(()=>{J7.current=b9||t0||d||AX},[b9,t0,d,AX]);let qQ=l.useRef({open:{},side:Aq});qQ.current={open:{tree:u8,layers:vJ,inspector:b9,comments:t0,changes:d,assistant:AX},side:T6};let p6=l.useCallback((y,b)=>{if(y==="tree")R6(b);else if(y==="layers")QQ(b);else if(y==="inspector")D9(b);else if(y==="comments")$8(b);else if(y==="changes")K0(b);else if(y==="assistant")HW(b)},[]),zQ=l.useCallback((y)=>qQ.current.side?.[y]||Aq[y],[]),z6=l.useCallback((y)=>{let b=zQ(y);p6(y,!0);for(let Q0 of AP)if(Q0.id!==y&&zQ(Q0.id)===b)p6(Q0.id,!1)},[p6,zQ]),gJ=l.useCallback((y)=>{if(qQ.current.open?.[y])p6(y,!1);else z6(y)},[z6,p6]),S6=z6,K6=gJ,KQ=l.useCallback((y)=>{if(!C7.current)return;if(!y||!y.id)return;if(J7.current)return;S6("inspector"),_5("css")},[S6]),DY=l.useCallback(()=>w7((y)=>!y),[]),$6=Vv(EP),MY=Jv(),[jq,mJ]=l.useState(!1),[KZ,OY]=l.useState(!1);l.useEffect(()=>{if(!K9())return;let y=!0;return py().then((b)=>{if(!y)return;if(mJ(!!b),!b&&!QZ(ks,!1))OY(!0)}).catch(()=>{}),()=>{y=!1}},[]);let UZ=l.useCallback(()=>{OY(!1);try{localStorage.setItem(ks,"1")}catch{}},[]),[yq,VZ]=l.useState(null);l.useEffect(()=>{if(!K9())return;let y;return ny((b)=>VZ(b&&typeof b==="object"?b:{})).then((b)=>{y=b}).catch(()=>{}),()=>{try{y?.()}catch{}}},[]);let[JJ,BZ]=l.useState(null),[zW,fq]=l.useState(()=>!QZ(Rs,!1)),uJ=l.useCallback((y)=>{BZ(Array.isArray(y)&&y.length?y:null)},[]),vq={setup:(y)=>{if(!y)return;if((y.canvas||y.requireSelection)&&W.length===0)z6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(y.inspector||y.tab||y.requireSelection)S6("inspector");if(y.tab)_5(y.tab);if(y.changes)S6("changes")}},KW=l.useCallback(()=>{fq(!1);try{localStorage.setItem(Rs,"1")}catch{}},[]),[E5,FZ]=l.useState(()=>QZ(js,!0)),[NZ,xq]=l.useState(!1),[QJ,LZ]=l.useState(()=>QZ($s,!1)),[ZX,wY]=l.useState(()=>QZ(bs,!1)),[U6,UW]=l.useState(!1),[hq,P5]=l.useState(!1),[VW,b6]=l.useState(0),[BW,FW]=l.useState(null),[gq,DZ]=l.useState(!1),NW=l.useRef(null),AY=l.useRef(null),R8=l.useRef(new Map),Z8=l.useCallback((y)=>{let b=Z?R8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(y,"*")}catch{}},[Z]),LW=l.useCallback((y,b)=>Z8({dgn:"photo-preview",asset:y,edit:b}),[Z8]),mq=l.useCallback((y,b,Q0)=>{C6.current.undo.push({asset:y,before:b,after:Q0}),C6.current.redo.length=0},[]),DW=l.useCallback((y)=>{let b=y?C6.current.redo:C6.current.undo;if(!b.length)return!1;let Q0=b.pop();(y?C6.current.undo:C6.current.redo).push(Q0);let z0=(y?Q0.after:Q0.before)||{};return LW(Q0.asset,z0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(Q0.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(z0)}).catch(()=>{}),bq((G0)=>G0+1),!0},[LW]),uq=l.useCallback(async(y)=>{Z8({dgn:"photo-busy",asset:y,busy:!0});try{let b=await fetch(`/${y.replace(/^\/+/,"")}`);if(!b.ok)return null;let Q0=await b.blob(),{removeBackground:z0}=await Promise.resolve().then(() => (Ps(),Es)),G0=await z0(Q0),f0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":G0.type||"image/png"},body:G0}),u=await f0.json().catch(()=>({}));if(f0.ok&&u.path)return{maskAsset:u.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{Z8({dgn:"photo-busy",asset:y,busy:!1})}},[Z8]);l.useEffect(()=>{let y=(z0)=>Array.from(z0.dataTransfer?.types??[]).includes("Files"),b=(z0)=>{if(y(z0))z0.preventDefault()},Q0=(z0)=>{if(y(z0))z0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",Q0),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",Q0)}},[]);let UQ=l.useRef({});UQ.current={open:wX,comps:q6,frame:rX,total:ZQ,playing:YZ,compId:I6,muted:L7,loop:YQ,sequences:NY,post:Z8,canvas:Z};let VQ=l.useRef({undo:[],redo:[]}),lJ=l.useCallback((y,b,Q0)=>{if(typeof b!=="number")return;if(VQ.current.undo.push({canvas:y,seq:b,label:Q0}),VQ.current.redo=[],VQ.current.undo.length>50)VQ.current.undo.shift()},[]),lq=l.useCallback((y)=>{let b=VQ.current,Q0=y==="undo"?b.undo:b.redo,z0=y==="undo"?b.redo:b.undo,G0=UQ.current.canvas,f0=-1;for(let M0=Q0.length-1;M0>=0;M0--)if(Q0[M0].canvas===G0){f0=M0;break}if(f0<0){l7(y==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let u=Q0[f0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u.canvas,seq:u.seq,dir:y})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(Q0.splice(f0,1),M0?.ok)z0.push(u),l7(`${y==="undo"?"Undid":"Redid"}: ${u.label}`,!0);else l7(`${y==="undo"?"Undo":"Redo"} skipped: ${M0?.error||"failed"}`)}).catch(()=>l7(`${y==="undo"?"Undo":"Redo"} failed: network error`))},[]);l.useEffect(()=>{let y=(b)=>{let Q0=UQ.current;if(!Q0.open||!Q0.comps?.length)return;let z0=b.target,G0=z0?.tagName;if(G0==="INPUT"||G0==="TEXTAREA"||G0==="SELECT"||z0?.isContentEditable)return;let f0=Q0.comps[0]?.fps||30,u=Math.max(1,Q0.total),M0=(g0)=>{let M8=Math.max(0,Math.min(u-1,Math.round(g0)));aX(M8),h9(!1),Q0.post({dgn:"timeline-seek",frame:M8,id:Q0.compId})},R0=()=>{let g0=new Set([0,u-1]);for(let M8 of Q0.sequences||[]){g0.add(M8.from);for(let w8 of M8.keyframes||[])g0.add(w8.from),g0.add(w8.to)}return[...g0].filter((M8)=>M8>=0&&M8<u).sort((M8,w8)=>M8-w8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),lq(b.shiftKey?"redo":"undo");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),Q0.playing)h9(!1),Q0.post({dgn:"timeline-pause",id:Q0.compId});else h9(!0),Q0.post({dgn:"timeline-mute",muted:Q0.muted,id:Q0.compId}),Q0.post({dgn:"timeline-loop",loop:Q0.loop,id:Q0.compId}),Q0.post({dgn:"timeline-play",id:Q0.compId});else if(b.key==="ArrowRight")b.preventDefault(),M0(Q0.frame+(b.shiftKey?f0:1));else if(b.key==="ArrowLeft")b.preventDefault(),M0(Q0.frame-(b.shiftKey?f0:1));else if(b.key==="Home")b.preventDefault(),M0(0);else if(b.key==="End")b.preventDefault(),M0(u-1);else if(b.key==="."){b.preventDefault();let g0=R0().find((M8)=>M8>Q0.frame);if(g0!=null)M0(g0)}else if(b.key===","){b.preventDefault();let g0=R0().reverse().find((M8)=>M8<Q0.frame);if(g0!=null)M0(g0)}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]),l.useEffect(()=>{X7([]),aX(0),h9(!1);let y=setTimeout(()=>Z8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(y)},[Z,Z8]);let[BQ,YJ]=l.useState(""),[j6,FQ]=l.useState([]);l.useEffect(()=>{if(!wX||q6.length===0||!Z||Z===g8){YJ(""),FQ([]);return}let y=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(y&&b?.ok&&typeof b.source==="string")YJ(b.source)}).catch(()=>{}),()=>{y=!1}},[wX,q6,Z]),l.useEffect(()=>{if(!wX||!Z||Z===g8||!BQ){FQ([]);return}let y=!0,b=d6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(Q0).then((z0)=>z0.ok?z0.json():null).then((z0)=>{if(!y)return;let G0=z0?.ok&&Array.isArray(z0.clips)?z0.clips.filter((f0)=>f0.kind==="sequence"):[];FQ(G0)}).catch(()=>{}),()=>{y=!1}},[wX,Z,BQ,d6]),l.useEffect(()=>{if(!BQ){GZ([]),ZZ([]),HZ(0);return}let y=q6[0]?.durationInFrames||0,b=X9??q?.artboardId??null,Q0=vf(BQ,y,b);Tq(Q0.artboardId??b??null);let z0=Q0.sequences.map((G0,f0)=>{let u=j6[f0];if(!u)return G0;return{...G0,mediaTag:u.mediaTag??G0.mediaTag,mediaSrc:u.mediaSrc??G0.mediaSrc,replaceable:!!(u.mediaCdId||u.mediaArrayRef),layers:Array.isArray(u.layers)?u.layers:[],hidden:!!u.hidden}});GZ(z0),ZZ(Q0.audio||[]),HZ(Q0.total)},[BQ,j6,q,q6,X9]);let MZ=l.useCallback(()=>{FZ((y)=>{let b=!y,Q0=Z?R8.current.get(Z):null;if(Q0&&Q0.contentWindow)try{Q0.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),HX=l.useCallback((y)=>{for(let b of R8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...y},"*")}catch{}},[]),R5=l.useCallback(()=>{LZ((y)=>{let b=!y;return HX({minimap:b}),b})},[HX]),k5=l.useCallback(()=>{wY((y)=>{let b=!y;return HX({zoom:b}),b})},[HX]),MW=l.useCallback(()=>{UW((y)=>{let b=!y;return HX({present:b}),b})},[HX]),NQ=l.useCallback(()=>{UW(!1),HX({present:!1})},[HX]),OW=l.useCallback(()=>{if(!Z||Z===g8)return;P5((y)=>{let b=!y;return Z8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,Z8]);l.useEffect(()=>{let y=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(y)return;let Q0=b&&typeof b.name==="string"?b.name.trim():"";if(Q0)FW(Q0)}).catch(()=>{}),()=>{y=!0}},[]),l.useEffect(()=>{if(!Z||Z===g8){b6(0),P5(!1);return}let y=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(y)return;let Q0=Array.isArray(b?.artboards)?b.artboards.length:0;b6(Q0),P5(b?.overlays?.print===!0),DQ(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!y)b6(0),P5(!1),DQ(new Set)}),()=>{y=!0}},[Z]),l.useEffect(()=>{if(!Z||Z===g8||!X9)return;let y=setTimeout(()=>{Z8({dgn:"request-layers",artboardId:X9})},250);return()=>clearTimeout(y)},[Z,X9,Z8]);let[LQ,DQ]=l.useState(()=>new Set),wW=l.useCallback((y)=>{if(!Z||Z===g8)return;DQ((b)=>{let Q0=new Set(b);if(Q0.has(y))Q0.delete(y);else Q0.add(y);let z0=[...Q0];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:z0}})}).catch(()=>{}),Z8({dgn:"locked-set",locked:z0}),Q0})},[Z,Z8]);l.useEffect(()=>{if(!Z||Z===g8)return;Z8({dgn:"locked-set",locked:[...LQ]})},[LQ,Z,Z8]),l.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",O0),localStorage.setItem(Zt,O0)}catch{}for(let y of R8.current.values())try{y.contentWindow.postMessage({dgn:"theme",theme:O0},"*")}catch{}},[O0]),l.useEffect(()=>{try{localStorage.setItem(Ss,u8?"1":"0")}catch{}},[u8]),l.useEffect(()=>{try{localStorage.setItem(Ts,o9?"1":"0")}catch{}},[o9]),l.useEffect(()=>{try{localStorage.setItem(Is,JSON.stringify(k6))}catch{}},[k6]),l.useEffect(()=>{try{localStorage.setItem($s,QJ?"1":"0")}catch{}},[QJ]),l.useEffect(()=>{try{localStorage.setItem(bs,ZX?"1":"0")}catch{}},[ZX]),l.useEffect(()=>{try{localStorage.setItem(js,E5?"1":"0")}catch{}},[E5]),l.useEffect(()=>{let y=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(y||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")n0(b.theme);if(typeof b.minimap==="boolean")LZ(b.minimap);if(typeof b.zoom==="boolean")wY(b.zoom);if(typeof b.annotations==="boolean")FZ(b.annotations);if(typeof b.autoOpenInspector==="boolean")_X(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")BY({...Aq,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")FY(b.layersMode)}).catch(()=>{}).finally(()=>{if(!y)xq(!0)}),()=>{y=!0}},[]),l.useEffect(()=>{if(!NZ)return;$U0({theme:O0,minimap:QJ,zoom:ZX,annotations:E5,autoOpenInspector:XJ,panelSides:T6,layersMode:GX})},[NZ,O0,QJ,ZX,E5,XJ,T6,GX]),l.useEffect(()=>{try{localStorage.setItem(ys,JSON.stringify(T6))}catch{}},[T6]),l.useEffect(()=>{try{localStorage.setItem(fs,GX)}catch{}},[GX]);let dq=l.useCallback((y,b)=>{F7((Q0)=>{let z0=Q0[y],G0=z0===void 0?b:z0;return{...Q0,[y]:!G0}})},[]),MQ=l.useCallback(()=>{n0((y)=>y==="dark"?"light":"dark")},[]),t7=l.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let Q0=b.groups.map((z0)=>({...z0,tree:xU0(z0.paths,z0.stripPrefix)}));J(Q0),F0((z0)=>({...z0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(y){console.error("failed to load tree",y)}},[]);l.useEffect(()=>{t7()},[t7]);let WJ=l.useCallback(async(y)=>{try{let b=y?`/_system-data?ds=${encodeURIComponent(y)}`:"/_system-data",Q0=await fetch(b);if(!Q0.ok){console.error("failed to load system-data",Q0.status);return}let z0=await Q0.json();if(!y&&z0?.defaultDesignSystem&&!z0.ds){U8(z0);let G0=await fetch(`/_system-data?ds=${encodeURIComponent(z0.defaultDesignSystem)}`);if(G0.ok)U8(await G0.json());return}U8(z0)}catch(b){console.error("failed to load system-data",b)}},[]),GJ=l.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();H0(b||{})}catch(y){console.error("failed to load comments",y)}},[]);l.useEffect(()=>{GJ()},[GJ]),l.useEffect(()=>{function y(){let b=location.protocol==="https:"?"wss:":"ws:",Q0=new WebSocket(b+"//"+location.host+"/_ws");AY.current=Q0,Q0.addEventListener("open",()=>i(!0)),Q0.addEventListener("close",()=>{i(!1),setTimeout(y,1000)}),Q0.addEventListener("error",()=>{}),Q0.addEventListener("message",(z0)=>{try{let G0=JSON.parse(z0.data);if(G0.type==="snapshot"&&G0.state)K((f0)=>Qt(G0.state.selected,f0));else if(G0.type==="selected"){if(Date.now()-L.current<2000)return;let f0=G0.selected,u=Array.isArray(f0)?f0[0]:f0,M0=V.current,R0=Array.isArray(M0)?M0[0]:M0;if(K((g0)=>Qt(f0,g0)),u?.id&&u.file&&(!R0||R0.id!==u.id||R0.file!==u.file))w(u)}else if(G0.type==="comments"&&typeof G0.file==="string")H0((f0)=>({...f0,[G0.file]:G0.comments||[]}));else if(G0.type==="ai-activity"&&typeof G0.file==="string"){if(DZ(!0),NW.current)clearTimeout(NW.current);NW.current=setTimeout(()=>DZ(!1),8000);for(let f0 of R8.current.values())try{f0.contentWindow.postMessage({dgn:"ai-activity",file:G0.file,entry:G0.entry},"*")}catch{}}else if(G0.type==="export:job"&&G0.payload)MY.upsert(G0.payload);else if(G0.type==="sync:status"&&G0.payload)X0(G0.payload);else if(G0.type==="canvas-list-update")t7();else if(G0.type==="config-updated")U0();else if(G0.type==="acp-focus"){if(K9())S6("assistant")}else if(G0.type==="git-status"&&G0.payload)V0(G0.payload);else if(G0.type==="git-lifecycle"&&G0.payload){h(G0.payload);for(let f0 of R8.current.values())try{f0.contentWindow.postMessage({dgn:"git-lifecycle",payload:G0.payload},"*")}catch{}}}catch{}})}return y(),()=>AY.current&&AY.current.close()},[t7,U0]);function Y0(y){let b=AY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(y))}catch{}}let qX=l.useCallback(async()=>{try{let y=await fetch("/_api/git/status");if(y.ok)V0(await y.json())}catch{}},[]),c6=l.useCallback(async()=>{try{let y=await fetch("/_api/git/status?remote=1");if(!y.ok)return;let b=await y.json();if(b&&b.repo!==!1)g({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),y6=l.useCallback(async(y,b)=>{try{let Q0=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),z0=await Q0.json().catch(()=>({}));return{ok:Q0.ok,...z0}}catch(Q0){return{ok:!1,error:"Network error — is the project still open?"}}},[]),dJ=l.useCallback(async(y,b)=>{let Q0=await y6("/_api/git/commit",{message:y,files:b});if(Q0.ok)await qX();return Q0},[y6,qX]),Q7=l.useCallback(async(y)=>{let b=await y6("/_api/git/discard",{files:y});if(b.ok)await qX();return b},[y6,qX]),pJ=l.useCallback(async()=>{let y=await y6("/_api/git/push",{});if(y.ok)await qX(),c6();return y},[y6,qX,c6]),T5=l.useCallback(async()=>{let y=await y6("/_api/git/pull",{});if(y.ok)await qX(),c6();if(y.conflict&&Array.isArray(y.files)&&y.files.length)J8({file:y.files[0],conflict:!0});return y},[y6,qX,c6]),AW=l.useCallback(async(y)=>{let b=await y6("/_api/git/resolve",{choice:y});if(b.ok)await qX(),c6();return b},[y6,qX,c6]),_Y=l.useCallback(async(y)=>{try{let b="/_api/git/log?limit=40"+(y?`&path=${encodeURIComponent(y)}`:""),Q0=await fetch(b);if(!Q0.ok)return[];return(await Q0.json()).entries||[]}catch{return[]}},[]),_W=l.useMemo(()=>{let y={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;for(let Q0 of c?.files||[])b.set(Q0.path,y[Q0.status]);return b},[c]),I5=c?.files?.length||0;l.useEffect(()=>{if(c?.repo===!1)return;c6();let y=setInterval(c6,d?60000:120000);return()=>clearInterval(y)},[c?.repo,d,c6]);let i6=l.useCallback((y)=>{if(G((b)=>{for(let Q0 of b)if(Q0.path!==y)R8.current.delete(Q0.path);return[{path:y}]}),H(y),N0(null),y!==g8)m8(y)},[]),ZJ=l.useCallback((y)=>{let b=typeof y==="string"?y:void 0;if(b)WJ(b);else if(!D8)WJ();i6(g8)},[D8,WJ,i6]);l.useEffect(()=>{Y0({type:"tabs",tabs:W.map((y)=>y.path).filter((y)=>y!==g8)})},[W]),l.useEffect(()=>{if(Z&&Z!==g8)Y0({type:"active",file:Z});else if(Z===g8)Y0({type:"active",file:""});else Y0({type:"active",file:""})},[Z]);let m0=l.useCallback((y)=>{G((b)=>{let Q0=b.findIndex((G0)=>G0.path===y);if(Q0<0)return b;let z0=b.filter((G0)=>G0.path!==y);if(y===Z)if(z0.length===0)H(null);else H(z0[Math.max(0,Q0-1)].path);return z0}),R8.current.delete(y),m8((b)=>b===y?null:b)},[Z]),p7=l.useCallback(()=>{if(!Z||Z===g8){if(Z===g8)WJ();return}let y=R8.current.get(Z);if(y)y.src=y.src},[Z,WJ]),EY=l.useCallback(()=>t7(),[t7]),[x0,C5]=l.useState(!1),h0=l.useRef(!1),OQ=l.useCallback(async()=>{if(h0.current)return;h0.current=!0,C5(!0);try{await Promise.all([t7(),new Promise((y)=>setTimeout(y,550))])}finally{h0.current=!1,C5(!1)}},[t7]);l.useEffect(()=>{let y=null,b=()=>{if(y)clearTimeout(y);y=setTimeout(()=>{y=null,EY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),y)clearTimeout(y)}},[EY]);let EW=l.useCallback(async(y)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,kind:"brief-board"})}),Q0=await b.json().catch(()=>({}));if(!b.ok||!Q0.ok)return{ok:!1,error:Q0.error||`create failed (${b.status})`};return await t7(),i6(Q0.file),{ok:!0,file:Q0.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[t7,i6]),PW=l.useCallback(async()=>{if(!Z||Z===g8)return;try{let y=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=y.ok?await y.text():"",Q0=[];if(b){let M0=new DOMParser().parseFromString(b,"image/svg+xml");for(let R0 of M0.querySelectorAll('[data-tool="mediaref"]')){let g0=R0.getAttribute("data-src");if(!g0)continue;Q0.push({src:g0,mediaKind:R0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Q0.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let G0=`${Pq(VF(Z)).replace(/\.tsx$/i,"")} Video`,f0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G0,kind:"video-comp",clips:Q0})}),u=await f0.json().catch(()=>({}));if(!f0.ok||!u.ok){window.alert(`Assemble failed: ${u.error||`error ${f0.status}`}`);return}await t7(),i6(u.file)}catch(y){window.alert(`Assemble failed: ${y instanceof Error?y.message:"network error"}`)}},[Z,t7,i6]),wQ=l.useCallback(({accept:y,resolveTarget:b})=>{let Q0=Z,z0=d6||void 0,G0=document.createElement("input");G0.type="file",G0.accept=y,G0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(G0);let f0=()=>{if(G0.isConnected)G0.remove()};window.addEventListener("focus",()=>setTimeout(f0,300),{once:!0}),G0.addEventListener("change",()=>{let u=G0.files?.[0];if(f0(),!u)return;let M0=`/_api/comp-clips?canvas=${encodeURIComponent(Q0)}${z0?`&artboardId=${encodeURIComponent(z0)}`:""}`;fetch(M0).then((R0)=>R0.json().catch(()=>({}))).then((R0)=>{let g0=b(R0);if(!g0)return l7("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":u.type||"application/octet-stream"},body:u}).then((M8)=>M8.json().catch(()=>({}))).then((M8)=>{if(!M8?.path)return l7(`Upload failed: ${M8?.error||"unknown error"}`),null;if(g0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,arrayName:g0.arrayRef.arrayName,index:g0.arrayRef.index,field:g0.arrayRef.field,value:M8.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,id:g0.cdId,attr:"src",value:M8.path})})})}).then((R0)=>R0?R0.json():null).then((R0)=>{if(R0&&!R0.ok)l7(`Replace refused: ${R0.error||"failed"}`);else if(R0&&R0.ok){if(l7("Media replaced.",!0),R0.seq!=null)lJ(Q0,R0.seq,"replace media")}}).catch(()=>l7("Replace failed: network error"))}),G0.click()},[Z,d6,lJ]),RW=l.useCallback(async(y,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5649
5649
|
|
|
5650
5650
|
Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let z0=await fetch(`/_api/canvas?file=${encodeURIComponent(y)}`,{method:"DELETE"}),G0=await z0.json().catch(()=>({}));if(!z0.ok||!G0.ok){window.alert(`Could not delete: ${G0.error||`error ${z0.status}`}`);return}if(await t7(),Z===y)G([]),H(null)}catch(z0){window.alert(`Delete failed: ${z0 instanceof Error?z0.message:"network error"}`)}},[t7,Z]),kW=l.useCallback(()=>{if(Y0({type:"clear-select"}),K(null),Z&&Z!==g8){let y=R8.current.get(Z);if(y&&y.contentWindow)try{y.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[Z]);l.useEffect(()=>{if(!Z||Z===g8)return;let y=R8.current.get(Z);if(!y||!y.contentWindow)return;let b=U6?[]:k0[Z]||[];try{y.contentWindow.postMessage({dgn:"comments-set",comments:b},"*")}catch{}},[Z,k0,U6]),l.useEffect(()=>{function y(G0){let f0=j0?.canvasOrigin||window.location.origin;if(G0.origin!==f0)return;let u=G0.data;if(!u||typeof u!=="object"||!u.dgn)return;if(u.dgn==="tool-cursor"){if(u.tool==="browse"){document.body.style.cursor="";let R0=document.getElementById("dc-app-cursor");if(R0)R0.textContent="";yU0();return}let M0=PC(u.tool);if(M0){document.body.style.cursor=M0;let R0=document.getElementById("dc-app-cursor");if(!R0)R0=document.createElement("style"),R0.id="dc-app-cursor",document.head.appendChild(R0);R0.textContent=`* { cursor: ${M0} !important; }`}return}if(u.dgn==="select"||u.dgn==="select-set"||u.dgn==="clear-select"||u.dgn==="edit-text"||u.dgn==="apply-edit"){let M0=Z&&Z!==g8?R8.current.get(Z)?.contentWindow:null;if(G0.source!==M0)return}if(u.dgn==="select"&&u.selection)LY(null),L.current=Date.now(),Y0({type:"select",selection:u.selection}),K(u.selection),KQ(u.selection);else if(u.dgn==="select-set"){LY(null),L.current=Date.now();let M0=u.selection;if(M0==null)Y0({type:"clear-select"}),K(null);else if(Array.isArray(M0)){let R0=M0[0]??null;if(R0)Y0({type:"select",selection:R0});if(K(R0),M0.length===1)KQ(R0)}else Y0({type:"select",selection:M0}),K(M0),KQ(M0)}else if(u.dgn==="clear-select")LY(null),L.current=Date.now(),Y0({type:"clear-select"}),K(null);else if(u.dgn==="edit-text"&&u.id){let M0=G0.source,R0=(g0)=>{try{M0?.postMessage({dgn:"edit-reverted",op:"text",id:u.id,reason:g0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u.file,id:u.id,text:u.text??"",...typeof u.occurrence==="number"?{occurrence:u.occurrence}:{},...typeof u.before==="string"?{before:u.before}:{}})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)R0(g0.error||"this element can't be edited inline")}).catch(()=>R0("network error"))}else if(u.dgn==="apply-edit"&&u.id&&(u.op==="css"||u.op==="text"||u.op==="attr")){let M0=u.op,R0=typeof u.value==="string"?u.value:null,g0,M8;if(M0==="css")g0="/_api/edit-css",M8=R0==null?{canvas:u.canvas,id:u.id,property:u.key,reset:!0}:{canvas:u.canvas,id:u.id,property:u.key,value:R0},o6({id:u.id,prop:u.key,value:R0});else if(M0==="attr")g0="/_api/edit-attr",M8=R0==null?{canvas:u.canvas,id:u.id,attr:u.key,reset:!0}:{canvas:u.canvas,id:u.id,attr:u.key,value:R0};else{if(g0="/_api/edit-text",M8={canvas:u.canvas,id:u.id,text:R0??""},typeof u.occurrence==="number")M8.occurrence=u.occurrence;if(typeof u.from==="string")M8.before=u.from}S7.current=S7.current.catch(()=>{}).then(()=>fetch(g0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M8)}).then((w8)=>w8.json().catch(()=>({}))).then((w8)=>{if(!w8.ok)console.warn("[apply-edit]",M0,w8.error||"failed")}).catch(()=>{}))}else if(u.dgn==="layers-tree"){if(f({artboardId:u.artboardId,nodes:Array.isArray(u.tree)?u.tree:[]}),S.current=!1,C.current)clearTimeout(C.current),C.current=null;let M0=D.current;if(M0&&M0.movedId){if(function g0(M8){return(M8||[]).some((w8)=>w8.id===M0.movedId||g0(w8.children))}(u.tree)){D.current=null;let g0=Z?R8.current.get(Z)?.contentWindow:null;if(g0)try{g0.postMessage({dgn:"select-by-id",id:M0.movedId,artboardId:u.artboardId??null,index:0},"*")}catch{}}}}else if(u.dgn==="reorder-revert"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.seq==="number"&&(u.dir==="undo"||u.dir==="redo");if(G0.source===M0&&R0&&Z){if(S.current=!0,C.current)clearTimeout(C.current);C.current=setTimeout(()=>{S.current=!1,C.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Z,seq:u.seq,dir:u.dir})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)console.warn("[reorder-revert]",g0.error||"failed")}).catch(()=>{})}}else if(u.dgn==="reorder-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.id==="string"&&typeof u.refId==="string"&&(u.position==="before"||u.position==="after"||u.position==="inside-start"||u.position==="inside-end");if(G0.source===M0&&R0)P.current?.(u.id,u.refId,u.position,{idIndex:Number.isInteger(u.idIndex)?u.idIndex:void 0,refIndex:Number.isInteger(u.refIndex)?u.refIndex:void 0})}else if(u.dgn==="reposition-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.id==="string"&&Number.isFinite(u.left)&&Number.isFinite(u.top)&&Number.isFinite(u.beforeLeft)&&Number.isFinite(u.beforeTop);if(G0.source===M0&&R0)T.current?.(u.id,u.left,u.top,u.beforeLeft,u.beforeTop,Number.isInteger(u.idIndex)?u.idIndex:void 0)}else if(u.dgn==="resize-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.id==="string"&&u.patch&&typeof u.patch==="object";if(G0.source===M0&&R0)I.current?.(u.id,u.patch,u.before,Number.isInteger(u.idIndex)?u.idIndex:void 0)}else if(u.dgn==="delete-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.id==="string")jY.current?.(u.id,Number.isInteger(u.idIndex)?u.idIndex:void 0)}else if(u.dgn==="duplicate-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.id==="string")hY.current?.(u.id,Number.isInteger(u.idIndex)?u.idIndex:void 0)}else if(u.dgn==="copy-style"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0)mY.current?.()}else if(u.dgn==="paste-style"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.id==="string")uY.current?.(u.id)}else if(u.dgn==="insert-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.refId==="string",g0=typeof u.artboardId==="string",M8=u.position==="before"||u.position==="after"||u.position==="inside-start"||u.position==="inside-end",w8=R0!==g0&&(u.kind==="div"||u.kind==="text"||u.kind==="image")&&M8&&(!g0||u.position==="inside-start"||u.position==="inside-end");if(G0.source===M0&&w8)yY.current?.(u.refId,u.position,u.kind,{artboardId:g0?u.artboardId:void 0,src:typeof u.src==="string"?u.src:void 0,refIndex:Number.isInteger(u.refIndex)?u.refIndex:void 0})}else if(u.dgn==="insert-image-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.refId==="string",g0=typeof u.artboardId==="string",M8=!R0&&!g0,w8=(R0!==g0||M8)&&(M8||u.position==="before"||u.position==="after"||u.position==="inside-start"||u.position==="inside-end")&&(!g0||u.position==="inside-start"||u.position==="inside-end");if(G0.source===M0&&w8)b5.current?.({purpose:"insert-image",canvas:Z,refId:u.refId,artboardId:g0?u.artboardId:void 0,position:M8?void 0:u.position,refIndex:Number.isInteger(u.refIndex)?u.refIndex:void 0,multiple:!0,hasArtboardAnchor:!M8})}else if(u.dgn==="replace-media-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.id==="string")b5.current?.({purpose:"replace-src",canvas:Z,id:u.id,before:typeof u.before==="string"?u.before:null})}else if(u.dgn==="convert-to-absolute-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=Array.isArray(u.containers)&&u.containers.length>0,g0=typeof u.containerId==="string"&&Array.isArray(u.children)&&u.children.length>0;if(G0.source===M0&&(R0||g0)){let M8=R0?u.containers.reduce((w8,dY)=>w8+(Array.isArray(dY?.children)?dY.children.length:0),0):u.children.length;kY.current?.("/_api/convert-to-absolute",R0?{allowShared:u.allowShared===!0,containers:u.containers,...Array.isArray(u.dissolve)&&u.dissolve.length>0?{dissolve:u.dissolve}:{}}:{containerId:u.containerId,containerSetRelative:u.containerSetRelative===!0,allowShared:u.allowShared===!0,children:u.children},{label:"convert to absolute",onOk:()=>{Z8({dgn:"selection-clear"}),Z8({dgn:"op-toast",message:`Converted ${M8} element${M8===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(w8)=>Z8({dgn:"op-toast",message:`Convert failed: ${w8?.error||"unknown error"}`})})}}else if(u.dgn==="replace-annotation-media-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.id==="string")b5.current?.({purpose:"replace-annotation-media",canvas:Z,id:u.id,before:typeof u.before==="string"?u.before:null})}else if(u.dgn==="edit-annotation-photo-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=PP.exec(typeof u.asset==="string"?u.asset:"")?.[0]||null;if(G0.source===M0&&typeof u.id==="string"&&R0)LY({asset:R0,strokeId:u.id}),S6("inspector"),_5("photo")}else if(u.dgn==="open-sticker-picker"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0)lY.current?.({canvas:Z})}else if(u.dgn==="insert-artboard-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.id==="string"&&Number.isFinite(u.width)&&Number.isFinite(u.height);if(G0.source===M0&&R0)fY.current?.({id:u.id,label:typeof u.label==="string"?u.label:u.id,width:u.width,height:u.height})}else if(u.dgn==="resize-artboard-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=typeof u.artboardId==="string"&&(Number.isFinite(u.width)||Number.isFinite(u.height));if(G0.source===M0&&R0)vY.current?.(u.artboardId,Number.isFinite(u.width)?u.width:void 0,Number.isFinite(u.height)?u.height:void 0)}else if(u.dgn==="delete-artboard-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.artboardId==="string")xY.current?.(u.artboardId)}else if(u.dgn==="set-artboard-kind-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=u.kind===null||typeof u.kind==="string";if(G0.source===M0&&typeof u.artboardId==="string"&&R0)bY.current?.(u.artboardId,u.kind)}else if(u.dgn==="duplicate-artboard-request"){let M0=Z?R8.current.get(Z)?.contentWindow:null;if(G0.source===M0&&typeof u.artboardId==="string"&&Number.isFinite(u.width))gY.current?.(u.artboardId,u.width)}else if(u.dgn==="open-inspector"){if(S6("inspector"),typeof u.tab==="string")_5(u.tab)}else if(u.dgn==="present-enter"){let M0=Z?R8.current.get(Z)?.contentWindow:null,R0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(G0.source===M0&&!R0&&!U6)UW(!0),HX({present:!0})}else if(u.dgn==="comment-compose"&&u.selection)K(u.selection);else if(u.dgn==="comment-submit"&&u.payload&&typeof u.payload.text==="string"){let M0=u.payload,R0=String(M0.text).trim();if(R0)Y0({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:R0}})}else if(u.dgn==="comment-patch"&&u.id&&u.patch&&typeof u.patch==="object")Y0({type:"comments-patch",id:u.id,patch:u.patch});else if(u.dgn==="comment-delete"&&u.id)Y0({type:"comments-delete",id:u.id}),N0((M0)=>M0===u.id?null:M0);else if(u.dgn==="comment-click"&&u.id)N0(u.id);else if(u.dgn==="artboards"&&typeof u.count==="number"){let M0=Math.round(u.count);if(Number.isFinite(M0)&&M0>=0&&M0<=999)b6(M0)}else if(u.dgn==="active-artboard"){let M0=Z&&Z!==g8?R8.current.get(Z)?.contentWindow:null;if(G0.source!==M0)return;A5(typeof u.id==="string"?u.id.slice(0,120):null)}else if(u.dgn==="timeline-comps"&&Array.isArray(u.comps)){let M0=Z&&Z!==g8?R8.current.get(Z)?.contentWindow:null;if(G0.source!==M0)return;let R0=u.comps.filter((w8)=>w8&&typeof w8.id==="string").slice(0,32).map((w8)=>({id:String(w8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(w8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(w8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(w8.width)||0)),height:Math.max(1,Math.round(Number(w8.height)||0))}));X7(R0);let g0=sX.current;if(g0&&R0.some((w8)=>w8.id===g0)&&ZW.current>0)Z8({dgn:"timeline-seek",frame:ZW.current,id:g0})}else if(u.dgn==="timeline-frame"&&typeof u.frame==="number"){let M0=Z&&Z!==g8?R8.current.get(Z)?.contentWindow:null;if(G0.source!==M0)return;if(u.id&&sX.current&&u.id!==sX.current)return;if(Number.isFinite(u.frame))aX(Math.max(0,Math.round(u.frame)))}else if(u.dgn==="timeline-ended"){let M0=Z&&Z!==g8?R8.current.get(Z)?.contentWindow:null;if(G0.source!==M0)return;if(u.id&&sX.current&&u.id!==sX.current)return;h9(!1)}else if(u.dgn==="toggle-palette")C0((M0)=>!M0);else if(u.dgn==="shell-shortcut"){if(u.id==="reload")p7();else if(u.id==="inspector")K6("inspector");else if(u.id==="assistant"&&K9())K6("assistant");else if(u.id==="comments")K6("comments");else if(u.id==="changes")K6("changes");else if(u.id==="timeline")DY();else if(u.id==="export")F8({mode:"export"});else if(u.id==="handoff")F8({mode:"handoff"})}else if(u.dgn==="open-export")F8({mode:"export",scope:u.detail&&typeof u.detail.scope==="string"?u.detail.scope:void 0});else if(u.dgn==="open-timeline-request"){if(typeof u.artboardId==="string")A5(u.artboardId.slice(0,120));w7(!0)}else if(u.dgn==="loaded"&&u.file){m8((g0)=>g0===u.file?null:g0);let M0=U6?[]:k0[u.file]||[],R0=[...R8.current.entries()].find(([g0])=>g0===u.file)?.[1];if(R0&&R0.contentWindow){try{R0.contentWindow.postMessage({dgn:"comments-set",comments:M0},"*")}catch{}try{R0.contentWindow.postMessage({dgn:"theme",theme:O0},"*")}catch{}try{R0.contentWindow.postMessage({dgn:"view-chrome",minimap:QJ,zoom:ZX,present:U6},"*")}catch{}if(L0&&M0.some((M8)=>M8.id===L0))try{R0.contentWindow.postMessage({dgn:"comment-focus",id:L0},"*")}catch{}let g0=D.current;if(g0&&g0.file===u.file){D.current=null;try{R0.contentWindow.postMessage({dgn:"request-layers",artboardId:g0.artboardId??null},"*")}catch{}if(g0.movedId)try{R0.contentWindow.postMessage({dgn:"select-by-id",id:g0.movedId,artboardId:g0.artboardId??null,index:0},"*")}catch{}}else{let M8=V.current,w8=Array.isArray(M8)?M8[0]:M8;if(w8&&w8.id&&w8.file===u.file)w(w8)}}}else if(u.dgn==="export-request"&&u.id&&u.payload)Q0(G0.source,u.id,u.payload);else if(u.dgn==="export-history-request"&&u.id)z0(G0.source,u.id)}let b=j0?.canvasOrigin||window.location.origin;async function Q0(G0,f0,u){let M0=(R0)=>{try{if(G0)G0.postMessage({dgn:"export-result",id:f0,...R0},b)}catch{}};try{let R0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(!R0.ok){M0({ok:!1,error:await R0.text()||String(R0.status)});return}let{jobId:g0}=await R0.json();M0({ok:!0,jobId:g0})}catch(R0){M0({ok:!1,error:R0&&R0.message?R0.message:String(R0)})}}async function z0(G0,f0){let u=[];try{let M0=await fetch("/_api/export-history");if(M0.ok){let R0=await M0.json();if(Array.isArray(R0.history))u=R0.history}}catch{}try{if(G0)G0.postMessage({dgn:"export-history-result",id:f0,history:u},b)}catch{}}return window.addEventListener("message",y),()=>window.removeEventListener("message",y)},[k0,L0,j0,O0,p7,U6,QJ,ZX,HX,Z,Z8]);let AQ=l.useCallback(()=>{if(!Z||Z===g8)return;let y=R8.current.get(Z);if(y&&y.contentWindow)try{y.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[Z]),o6=l.useCallback((y)=>{if(!Z||Z===g8)return;let b=R8.current.get(Z);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"apply-style",...y},"*")}catch{}},[Z]),f6=l.useCallback((y)=>{if(!Z||Z===g8||!y)return;let b=R8.current.get(Z);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"record-edit",payload:y},"*")}catch{}},[Z]),S7=l.useRef(Promise.resolve()),_Q=l.useCallback((y,b,Q0,z0)=>{let G0=Number.isInteger(z0?.idIndex)?z0.idIndex:void 0,f0=Number.isInteger(z0?.refIndex)?z0.refIndex:void 0;if(!y||!b)return;if(y===b&&(G0??0)===(f0??0))return;let u=V.current,M0=Array.isArray(u)?u[0]:u,R0=Z;if(!R0)return;let g0=Z,M8=j?.artboardId??M0?.artboardId??null;if(f((w8)=>w8?{...w8,nodes:vV0(w8.nodes,y,b,Q0)}:w8),S.current=!0,C.current)clearTimeout(C.current);C.current=setTimeout(()=>{S.current=!1,C.current=null},700),S7.current=S7.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:R0,id:y,refId:b,position:Q0,idIndex:G0,refIndex:f0})}).then((w8)=>w8.json().catch(()=>({}))).then((w8)=>{if(!w8.ok){if(console.warn("[reorder]",w8.error||"failed"),Z8({dgn:"reorder-failed"}),Z8({dgn:"request-layers",artboardId:M8}),S.current=!1,C.current)clearTimeout(C.current),C.current=null;return}if(D.current={file:g0,movedId:w8.movedId||null,artboardId:M8},typeof w8.seq==="number")Z8({dgn:"record-edit",payload:{op:"reorder",canvas:R0,seq:w8.seq,label:"move element"}})}).catch(()=>{}))},[Z,j,Z8]);l.useEffect(()=>{P.current=_Q},[_Q]);let PY=l.useCallback((y,b,Q0,z0,G0,f0)=>{if(!y||!Z)return;let u=Z,M0=Number.isInteger(f0)?f0:void 0;o6({id:y,prop:"left",value:`${b}px`}),o6({id:y,prop:"top",value:`${Q0}px`});let R0=(g0,M8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u,id:y,property:g0,value:`${M8}px`,idIndex:M0})}).then((w8)=>w8.json().catch(()=>({})));S7.current=S7.current.catch(()=>{}).then(()=>R0("left",b)).then((g0)=>{if(!g0.ok)throw Error(g0.error||"left write failed");return R0("top",Q0)}).then((g0)=>{if(!g0.ok)throw Error(g0.error||"top write failed");f6({op:"css",canvas:u,id:y,key:"left",before:`${z0}px`,after:`${b}px`}),f6({op:"css",canvas:u,id:y,key:"top",before:`${G0}px`,after:`${Q0}px`})}).catch((g0)=>{console.warn("[reposition]",g0?.message||g0),Z8({dgn:"reposition-failed"})})},[Z,Z8,f6,o6]);l.useEffect(()=>{T.current=PY},[PY]);let RY=l.useCallback((y,b,Q0,z0)=>{if(!y||!Z||!b||typeof b!=="object")return;let G0=Z,f0=Q0&&typeof Q0==="object"?Q0:{},u=Number.isInteger(z0)?z0:void 0,M0=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((D7)=>typeof b[D7]==="string"&&b[D7]);if(!M0.length)return;let R0=V.current,g0=Array.isArray(R0)?R0.length===1?R0[0]:null:R0,M8=g0&&g0.id===y?g0.artboardId??null:null,w8=g0&&g0.id===y?g0.index??0:0;for(let D7 of M0)o6({id:y,artboardId:M8,index:w8,prop:D7,value:b[D7]});let dY=(D7,RX)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:G0,id:y,property:D7,value:RX,idIndex:u})}).then((Qz)=>Qz.json().catch(()=>({}))),fW=S7.current.catch(()=>{});for(let D7 of M0)fW=fW.then((RX)=>{if(RX&&RX.ok===!1)throw Error(RX.error||`${D7} write failed`);return dY(D7,b[D7])});S7.current=fW.then((D7)=>{if(D7&&D7.ok===!1)throw Error(D7.error||"resize write failed");for(let RX of M0)f6({op:"css",canvas:G0,id:y,key:RX,before:f0[RX]??null,after:b[RX]});w({id:y,file:G0,artboardId:M8,index:w8})}).catch((D7)=>{console.warn("[resize]",D7?.message||D7),Z8({dgn:"resize-failed"})})},[Z,Z8,f6,o6,w]);l.useEffect(()=>{I.current=RY},[RY]);let kY=l.useRef(null),V9=l.useCallback((y,b,{label:Q0,onOk:z0,onFail:G0}={})=>{if(!Z)return;let f0=Z;S7.current=S7.current.catch(()=>{}).then(()=>fetch(y,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...b,canvas:f0})}).then((u)=>u.json().catch(()=>({}))).then((u)=>{if(!u.ok){console.warn(`[${y}]`,u.error||"failed"),G0?.(u);return}if(typeof u.seq==="number")Z8({dgn:"record-edit",payload:{op:"reorder",canvas:f0,seq:u.seq,label:Q0||"edit"}});z0?.(u,f0)}).catch((u)=>G0?.({error:u?.message})))},[Z,Z8]);l.useEffect(()=>{kY.current=V9},[V9]);let TY=l.useCallback((y,b)=>{V9("/_api/delete-element",{id:y,idIndex:Number.isInteger(b)?b:void 0},{label:"delete element",onOk:()=>Z8({dgn:"selection-clear"})})},[V9,Z8]),zX=l.useCallback((y,b,Q0,z0={})=>{V9("/_api/insert-element",{refId:y,artboardId:typeof z0.artboardId==="string"?z0.artboardId:void 0,position:b,kind:Q0,src:typeof z0.src==="string"?z0.src:void 0,refIndex:Number.isInteger(z0.refIndex)?z0.refIndex:void 0},{label:`insert ${Q0}`,onOk:(G0,f0)=>{if(G0.newId)D.current={file:f0,movedId:G0.newId,artboardId:null}}})},[V9]),TW=l.useCallback((y)=>{if(typeof y!=="string"||!y)return!1;if(!Z)return!1;let b=V.current?.artboardId??X9??null;if(!b)return!1;return zX(void 0,"inside-end","image",{artboardId:b,src:y}),!0},[Z,X9,zX]),IW=l.useCallback((y,b)=>{V9("/_api/detach-component",{id:y,idIndex:Number.isInteger(b)?b:void 0},{label:"detach instance",onOk:(Q0)=>{Z8({dgn:"selection-clear"}),Z8({dgn:"op-toast",message:`Detached — this instance is now ${Q0.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(Q0)=>Z8({dgn:"op-toast",message:`Detach failed: ${Q0?.error||"unknown error"}`})})},[V9,Z8]),IY=l.useCallback((y,b)=>{V9("/_api/duplicate-element",{id:y,idIndex:Number.isInteger(b)?b:void 0},{label:"duplicate element",onOk:(Q0,z0)=>{if(Q0.newId)D.current={file:z0,movedId:Q0.newId,artboardId:null}}})},[V9]),CY=l.useRef(null),EQ=l.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"]),[]),SY=l.useCallback(()=>{let y=V.current,b=Array.isArray(y)?y.length===1?y[0]:null:y;if(!b)return;let Q0={};for(let[z0,G0]of Object.entries(b.authored||{}))if(!EQ.has(z0))Q0[z0]=G0;for(let[z0,G0]of Object.entries(b.customStyles||{}))if(!EQ.has(z0))Q0[z0]=G0;CY.current=Object.keys(Q0).length?Q0:null},[EQ]),$Y=l.useCallback((y)=>{let b=Z,Q0=CY.current;if(!b||!y||!Q0)return;let z0=Object.entries(Q0),G0=S7.current.catch(()=>{});for(let[f0,u]of z0)o6({id:y,prop:f0,value:u}),G0=G0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,id:y,property:f0,value:u})}).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{if(M0.ok)f6({op:"css",canvas:b,id:y,key:f0,before:null,after:u})}).catch(()=>{}));S7.current=G0},[Z,o6,f6]),cJ=l.useCallback(({id:y,label:b,width:Q0,height:z0})=>{V9("/_api/insert-artboard",{id:y,label:b,width:Q0,height:z0},{label:"insert artboard"})},[V9]),PQ=l.useCallback((y,b,Q0)=>{V9("/_api/resize-artboard",{artboardId:y,width:b,height:Q0},{label:"resize artboard",onFail:()=>Z8({dgn:"resize-artboard-failed"}),onOk:()=>A(y,Z)})},[V9,Z8,A,Z]),S5=l.useCallback((y)=>{V9("/_api/delete-artboard",{artboardId:y},{label:"delete artboard"})},[V9]),RQ=l.useCallback((y,b)=>{V9("/_api/duplicate-artboard",{artboardId:y,width:b},{label:"duplicate artboard at width"})},[V9]),CW=l.useCallback((y,b,Q0)=>{V9("/_api/set-artboard-hug",{artboardId:y,fixed:b,freezeHeight:Q0},{label:b?"pin artboard height":"hug artboard height",onOk:()=>A(y,Z)})},[V9,A,Z]),SW=l.useCallback((y,b)=>{V9("/_api/set-artboard-style",{artboardId:y,...b},{label:"artboard style",onOk:()=>A(y,Z)})},[V9,A,Z]),kQ=l.useRef(null),$5=l.useCallback((y,b)=>{V9("/_api/set-artboard-kind",{artboardId:y,kind:b},{label:"artboard kind",onOk:()=>A(y,Z)});let Q0=kQ.current;if(b==="print"&&Q0&&Q0.artboardId===y)kQ.current=null,V9("/_api/resize-artboard",{artboardId:y,width:Q0.widthPx,height:Q0.heightPx},{label:"artboard size"}),V9("/_api/set-artboard-print",{artboardId:y,print:Q0.defaults},{label:"artboard print"})},[V9,A,Z]),bY=l.useRef(null);l.useEffect(()=>{bY.current=$5},[$5]);let iJ=l.useCallback((y,b,Q0)=>{if(b==="print"||b==null||b==="digital"){if(Q0)kQ.current={artboardId:y,...Q0};Z8({dgn:"freeze-and-set-kind",artboardId:y,kind:b==="digital"?null:b,ask:!0});return}$5(y,b)},[$5,Z8]),TQ=l.useCallback((y,b)=>{V9("/_api/set-artboard-print",{artboardId:y,print:b},{label:"artboard print",onOk:()=>A(y,Z)})},[V9,A,Z]),$W=l.useCallback((y)=>{let b=`s${Math.random().toString(36).slice(2,8)}`;if(y.startsWith("print-")){let z0=y.slice(6),G0;try{G0=U3({paper:z0})}catch{return}let f0=K3.find((u)=>u.id===z0);cJ({id:b,label:f0?f0.label:z0.toUpperCase(),width:G0.widthPx,height:G0.heightPx}),iJ(b,"print"),TQ(b,{paper:z0});return}let Q0=yJ[y];if(!Q0)return;cJ({id:b,label:Q0.label,width:Q0.width,height:Q0.height})},[cJ,iJ,TQ]),jY=l.useRef(null),yY=l.useRef(null),fY=l.useRef(null),vY=l.useRef(null),xY=l.useRef(null),bW=l.useRef(null),hY=l.useRef(null),gY=l.useRef(null),mY=l.useRef(null),uY=l.useRef(null);l.useEffect(()=>{jY.current=TY,yY.current=zX,fY.current=cJ,vY.current=PQ,xY.current=S5,bW.current=iJ,hY.current=IY,gY.current=RQ,mY.current=SY,uY.current=$Y},[TY,zX,cJ,PQ,S5,iJ,IY,RQ,SY,$Y]),l.useEffect(()=>{let y=(b)=>{if(b.key!=="Backspace"&&b.key!=="Delete")return;if(b.metaKey||b.ctrlKey||b.altKey)return;let Q0=b.target;if(Q0&&(Q0.tagName==="INPUT"||Q0.tagName==="TEXTAREA"||Q0.tagName==="SELECT"||Q0.isContentEditable))return;if(b.preventDefault(),!Z||Z===g8)return;let G0=Array.isArray(q)?q.length===1?q[0]:null:q;if(G0?.artboardId&&!G0.id)S5(G0.artboardId)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[Z,q,S5]);let[EX,oJ]=l.useState(null),b5=l.useRef(null);l.useEffect(()=>{b5.current=(y)=>oJ(y)},[]);let[IQ,CQ]=l.useState(null),lY=l.useRef(null);l.useEffect(()=>{lY.current=(y)=>CQ(y)},[]);let jW=l.useCallback((y)=>{let b=EX;if(oJ(null),!b||!y)return;if(b.canvas&&b.canvas!==Z){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(b.purpose==="insert-image"){zX(b.refId,b.position||"after","image",{artboardId:b.artboardId,src:y,refIndex:b.refIndex});return}if(b.purpose==="replace-src"){let Q0=Z;if(!Q0||!b.id)return;S7.current=S7.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q0,id:b.id,attr:"src",value:y})}).then((z0)=>z0.json().catch(()=>({}))).then((z0)=>{if(z0.ok)f6({op:"attr",canvas:Q0,id:b.id,key:"src",before:b.before??null,after:y});else console.warn("[replace-src]",z0.error||"failed")}).catch(()=>{}));return}if(b.purpose==="replace-annotation-media")Z8({dgn:"replace-annotation-media",id:b.id,path:y})},[EX,zX,Z,f6,Z8]),pq=l.useCallback((y,b)=>{let Q0=EX;if(oJ(null),!Q0||!Array.isArray(y)||!y.length)return;if(Q0.canvas&&Q0.canvas!==Z){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(b==="artboard"){let z0=V.current?.artboardId??X9??null;if(!z0)return;for(let G0 of y)zX(void 0,"inside-end","image",{artboardId:z0,src:G0});return}Z8({dgn:"insert-annotation-media",paths:y})},[EX,Z,zX,X9,Z8]),cq=l.useCallback(async(y)=>{let b=IQ;if(CQ(null),!b||!y?.url)return;if(b.canvas&&b.canvas!==Z){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let Q0=await fetch(y.url).then((f0)=>f0.ok?f0.blob():Promise.reject(Error(`HTTP ${f0.status}`))),z0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":Q0.type||"image/png"},body:Q0}),G0=await z0.json().catch(()=>({}));if(!z0.ok||!G0.path){console.warn("[sticker-picker]",G0.error||`upload failed (HTTP ${z0.status})`);return}Z8({dgn:"insert-sticker",path:G0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[IQ,Z,Z8]),iq=l.useCallback((y)=>{if(!y?.id)return;oJ({purpose:"replace-src",canvas:Z,id:y.id,before:y.attrs?.src??null})},[Z]),oq=l.useCallback((y)=>{Y0({type:"comments-patch",id:y,patch:{status:"resolved"}})},[]),nq=l.useCallback((y)=>{Y0({type:"comments-patch",id:y,patch:{status:"open"}})},[]),rq=l.useCallback((y)=>{Y0({type:"comments-delete",id:y}),N0((b)=>b===y?null:b)},[]),aq=l.useCallback((y,b)=>{if(y&&y!==Z)G((z0)=>z0.find((G0)=>G0.path===y)?z0:[...z0,{path:y}]),H(y);if(b==null){N0(null);return}N0(b);let Q0=()=>{let z0=R8.current.get(y);if(z0&&z0.contentWindow)try{z0.contentWindow.postMessage({dgn:"comment-focus",id:b},"*")}catch{}};Q0(),setTimeout(Q0,200)},[Z]);l.useEffect(()=>{function y(b){let Q0=b.metaKey||b.ctrlKey,z0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,G0=document.activeElement?.tagName==="IFRAME";if(U6&&b.key==="Escape"){b.preventDefault(),NQ();return}if(Q0&&(b.key==="k"||b.key==="K")){b.preventDefault(),C0((f0)=>!f0);return}if(Q0&&!b.altKey&&(b.key==="z"||b.key==="Z"||b.key==="y"||b.key==="Y")){if(!z0&&!G0&&Z&&Z!==g8){if((b.key==="z"||b.key==="Z")&&UQ.current.open&&UQ.current.comps?.length)return;let f0=b.key==="y"||b.key==="Y"||b.shiftKey;if(HQ==="photo"&&DW(f0)){b.preventDefault();return}b.preventDefault(),Z8({dgn:f0?"redo":"undo"});return}}if(Q0&&b.shiftKey&&(b.key==="r"||b.key==="R")){b.preventDefault(),OQ();return}if(Q0&&(b.key==="r"||b.key==="R")){b.preventDefault(),p7();return}if(Q0&&b.shiftKey&&(b.key==="m"||b.key==="M")){b.preventDefault(),K6("comments");return}if(Q0&&b.shiftKey&&(b.key==="g"||b.key==="G")){b.preventDefault(),K6("changes");return}if(Q0&&b.shiftKey&&(b.key==="i"||b.key==="I")){b.preventDefault(),K6("inspector");return}if(Q0&&b.shiftKey&&(b.key==="a"||b.key==="A")&&K9()){b.preventDefault(),K6("assistant");return}if(Q0&&b.shiftKey&&(b.key==="e"||b.key==="E")){b.preventDefault(),F8({mode:"export"});return}if(Q0&&b.shiftKey&&(b.key==="h"||b.key==="H")){b.preventDefault(),F8({mode:"handoff"});return}if(Q0&&!b.shiftKey&&!b.altKey&&b.key===","){b.preventDefault(),P8(!0);return}if(Q0&&b.shiftKey&&(b.key==="t"||b.key==="T")){b.preventDefault(),DY();return}if(Q0&&!b.shiftKey&&!b.altKey&&(b.key==="c"||b.key==="C")){if(q&&q.selector&&Z&&Z!==g8&&!z0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(z0)return;if(b.key==="/"){b.preventDefault();let f0=document.querySelector(".st-search input");if(f0)f0.focus();return}if(Q0&&(b.key==="f"||b.key==="F")){if(b.preventDefault(),!u8)z6("tree");setTimeout(()=>{let f0=document.querySelector(".st-search input");if(f0)f0.focus()},0);return}if(G0){if(b.key!=="Escape")return}if(b.key==="t"||b.key==="T"){if(b.shiftKey||Q0)return;b.preventDefault(),gJ("tree");return}if(b.key==="h"||b.key==="H"){if(b.shiftKey||Q0)return;b.preventDefault(),d7((f0)=>!f0);return}if((b.key==="s"||b.key==="S")&&!Q0&&!b.shiftKey){if(b.preventDefault(),Z===g8)m0(g8);else ZJ();return}if((b.key==="n"||b.key==="N")&&!Q0&&!b.shiftKey){b.preventDefault(),z6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(b.key==="?"){b.preventDefault(),B0((f0)=>!f0);return}if(b.key==="F1"){b.preventDefault(),l9(!0);return}if(b.key==="Escape"){if(L0){N0(null);return}}}return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[p7,OQ,q,Z,L0,u8,ZJ,m0,AQ,U6,NQ,DY,HQ,DW]);let sq=l.useCallback((y,b)=>{if(b)R8.current.set(y,b)},[]),tq=qt(k0).open,eq=l.useCallback((y)=>{let b=y.target;if(b&&(b.tagName==="INPUT"||b.tagName==="TEXTAREA"||b.isContentEditable))return;y.preventDefault()},[]),Xz=l.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{z6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>F8({mode:"export"})},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"share",kbd:"⇧⌘H",run:()=>F8({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>U9(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>P8(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>ZJ()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>K6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>S6("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>p7()},{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:()=>MQ()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>$6.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>B0(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>l9(!0)}],[ZJ,MQ,p7,$6]),Jz=(y)=>y==="assistant"?K9():y==="layers"?GX==="separate":!0,OZ=(y)=>AP.filter((b)=>Jz(b.id)&&(T6[b.id]||Aq[b.id])===y).map((b)=>b.id),wZ={tree:u8,layers:vJ,inspector:b9,comments:t0,changes:d,assistant:AX},AZ=OZ("left"),_Z=OZ("right"),PX=AZ.find((y)=>wZ[y])||null,HJ=_Z.find((y)=>wZ[y])||null,EZ=K9()&&(T6.assistant||"right")==="left",PZ=K9()&&(T6.assistant||"right")==="right",j5=(y)=>(T6[y]||Aq[y])==="left"?e0==="sb":e0==="rp",yW=Z&&Z!==g8&&/\.(tsx|html)$/i.test(Z)?Z:null,RZ=(y)=>{if(y==="tree")return z(JV0,{groups:X,activePath:Z,activeDsName:Z===g8?D8?.ds?.name??null:null,onOpen:i6,onOpenSystem:ZJ,wsConnected:x,search:G8,setSearch:s0,commentsByFile:k0,showHidden:o9,sectionsExpanded:k6,onToggleSection:dq,onNewBoard:EW,onDeleteBoard:RW,onRefresh:OQ,refreshing:x0,collapsed:!1,onCollapse:()=>gJ("tree"),resizing:j5("tree"),dirtyByPath:_W,project:Q,gitBranch:c?.branch,remoteSync:p,onGetLatest:T5,canvasKinds:j0?.canvasKinds});if(y==="changes")return z(Jw,{status:c&&p?{...c,...p}:c,project:Q,readOnly:!K9(),resizing:j5("changes"),onClose:()=>K0(!1),onCommit:dJ,onDiscard:Q7,onPublish:pJ,onGetLatest:T5,loadLog:_Y,onOpenCanvas:(b)=>i6(b),onOpenDiff:(b)=>J8({file:b,beforeSha:"HEAD",conflict:!1}),activeCanvas:yW,onPreviewVersion:(b)=>J8({file:Z,beforeSha:b,conflict:!1}),designRel:(j0?.designRel||j0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(y==="inspector"||y==="layers")return z(pV0,{layersOnly:y==="layers",hideLayersTab:GX==="separate",cpMode:Q8,onSetCpMode:w0,selected:q,cfg:j0,tab:y==="layers"?"layers":HQ,onTabChange:_5,onClose:()=>y==="layers"?QQ(!1):D9(!1),onOptimistic:o6,onRecordEdit:f6,onReplaceMedia:iq,onResizeArtboard:PQ,onSetArtboardHug:CW,onSetArtboardStyle:SW,onSetArtboardKind:iJ,onSetArtboardPrint:TQ,onDuplicateArtboard:RQ,editScope:B,onUndoRedo:(b)=>Z8({dgn:b}),photoSel:$q,photoRev:qW,onPhotoEdit:LW,onPhotoRemoveBackground:uq,onPhotoRecordEdit:mq,onPhotoUndoRedo:(b)=>DW(b==="redo"),layersTree:j,componentMap:m,lockedKeys:LQ,onToggleLock:wW,onDetachInstance:IW,canvasFile:Z,onSelectLayer:(b)=>Z8({dgn:"select-by-id",id:b.id,artboardId:j?.artboardId,index:b.index}),onHoverLayer:(b)=>Z8({dgn:"highlight",id:b?b.id:null,artboardId:j?.artboardId,index:b?b.index:0}),onReorderLayer:_Q,layersBusyRef:S,resizing:j5(y)});if(y==="comments")return z(PV0,{commentsByFile:k0,filter:y0,setFilter:v0,activePath:Z,focusedId:L0,onJump:aq,onResolve:oq,onReopen:nq,onDelete:rq,resizing:j5("comments")});return null};return _("div",{className:"maude"+(U6?" is-present":""),"data-theme":O0,onContextMenu:eq,children:[jq&&z(Gw,{}),z(RV0,{update:yq,onDismiss:()=>VZ(null)}),z(kV0,{status:s}),!zW&&!JJ&&z(Bv,{wn:$6}),!zW&&!JJ&&z(Zv,{center:MY}),a&&_("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:"Repo state changed — reload to sync?"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>h(null),children:"Dismiss"})]}),_("div",{className:"st-shell",children:[z(BV0,{activePath:Z,project:Q,tabsCount:W.length,openMenu:i0,setOpenMenu:H9,commentsPanelOpen:t0,onToggleComments:()=>K6("comments"),changesOpen:d,changesCount:I5,onToggleChanges:()=>K6("changes"),onOpenSystem:ZJ,sidebarOpen:u8,onToggleSidebar:()=>gJ("tree"),showHidden:o9,onToggleShowHidden:()=>d7((y)=>!y),onOpenHelp:()=>l9(!0),onOpenShortcuts:()=>B0(!0),onStartTour:()=>uJ(QB),onStartCollabTour:()=>uJ(kw),annotationsVisible:E5,onToggleAnnotations:MZ,minimapVisible:QJ,onToggleMinimap:R5,zoomCtlVisible:ZX,onToggleZoomCtl:k5,presentMode:U6,onTogglePresent:MW,printGuidesVisible:hq,onTogglePrintGuides:OW,postToActiveCanvas:Z8,onOpenReadiness:()=>s7(!0),onOpenQuickSetup:()=>N7(!0),onWatchIntro:()=>w9(!0),onOpenWhatsNew:$6.openPanel,whatsNewCount:$6.unseen.length,exportCenter:MY,artboardCount:VW,inspectorOpen:b9,inspectorTab:HQ,onToggleInspector:()=>K6("inspector"),autoOpenInspector:XJ,onToggleAutoOpenInspector:()=>_X((y)=>!y),onInsertArtboard:$W,timelineOpen:wX,onToggleTimeline:DY,hasComps:q6.length>0,assistantOpen:AX,onToggleAssistant:()=>K6("assistant"),assistantBusy:Cq,assistantUnseen:Sq,onOpenLayers:()=>{if(GX==="separate")gJ("layers");else if(b9&&HQ==="layers")D9(!1);else _5("layers"),z6("inspector")},onNewCanvas:()=>{z6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:PW,onOpenExport:(y)=>F8({mode:y}),onOpenSettings:()=>P8(!0),onOpenGenerate:()=>U9(!0),onReload:p7,onCloseCanvas:()=>Z&&m0(Z),presence:_(W0,{children:[z(ms,{initials:lU0(BW||"you"),hue:"var(--accent)",title:BW?`${BW} (you)`:"You"}),gq&&z(ms,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),_("div",{className:"st-body"+(e0?" is-resizing":""),ref:o8,children:[z(QV0,{shown:!PX,onExpand:()=>z6("tree"),onSearch:()=>{z6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(PX||EZ)&&_(vs,{side:"left",width:G9.w,open:!!PX,ids:AZ,activeId:PX,onPick:gJ,children:[EZ&&z(g2,{hidden:PX!=="assistant",activeCanvas:yW,selected:q,designRel:(j0?.designRel||j0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:j5("assistant"),onClose:()=>HW(!1),onBusyChange:qZ,onFinished:tX,onPermissionRequest:eX,onElicitationRequest:eX}),PX&&PX!=="assistant"&&RZ(PX)]}),PX&&z(ls,{label:"Resize left panel",size:G9,active:e0==="sb",onPointerDown:(y)=>{y.preventDefault(),y.currentTarget.setPointerCapture?.(y.pointerId),p8("sb")}}),z("div",{className:"main",children:z(FV0,{tabs:W,activePath:Z,registerIframe:sq,systemData:D8,onOpenFromSystem:i6,onSelectDs:WJ,project:Q,cfg:j0,loadingPath:q8,onIframeLoad:$9,showQuickSetup:K9()&&!!I7&&!I7.ready,onStartQuickSetup:()=>N7(!0)})}),HJ&&z(ls,{label:"Resize right panel",dir:"rtl",size:Z9,active:e0==="rp",onPointerDown:(y)=>{y.preventDefault(),y.currentTarget.setPointerCapture?.(y.pointerId),p8("rp")}}),(HJ||PZ)&&_(vs,{side:"right",width:Z9.w,open:!!HJ,ids:_Z,activeId:HJ,onPick:gJ,children:[PZ&&z(g2,{hidden:HJ!=="assistant",activeCanvas:yW,selected:q,designRel:(j0?.designRel||j0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:j5("assistant"),onClose:()=>HW(!1),onBusyChange:qZ,onFinished:tX,onPermissionRequest:eX,onElicitationRequest:eX}),HJ&&HJ!=="assistant"&&RZ(HJ)]})]}),wX&&z(Uw,{comps:q6,sequences:NY,audio:kq,total:ZQ,frame:rX,playing:YZ,loop:YQ,onSeek:(y)=>{aX(y),h9(!1),Z8({dgn:"timeline-seek",frame:y,id:I6})},onPlay:()=>{h9(!0),Z8({dgn:"timeline-mute",muted:L7,id:I6}),Z8({dgn:"timeline-loop",loop:YQ,id:I6}),Z8({dgn:"timeline-play",id:I6})},onPause:()=>{h9(!1),Z8({dgn:"timeline-pause",id:I6})},onToggleLoop:()=>Rq((y)=>{let b=!y;return Z8({dgn:"timeline-loop",loop:b,id:I6}),b}),muted:L7,onToggleMute:()=>{WZ((y)=>{let b=!y;return Z8({dgn:"timeline-mute",muted:b,id:I6}),b})},volume:WQ,onVolume:(y)=>{if(A7(y),y>0&&L7)WZ(!1),Z8({dgn:"timeline-mute",muted:!1,id:I6});Z8({dgn:"timeline-volume",volume:y,id:I6})},onRetime:(y,b)=>{if(!Z||Z===g8)return;let Q0=d6||void 0,z0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${Q0?`&artboardId=${encodeURIComponent(Q0)}`:""}`;fetch(z0).then((G0)=>G0.json().catch(()=>({}))).then((G0)=>{let u=(G0?.ok&&Array.isArray(G0.clips)?G0.clips.filter((R0)=>R0.kind==="sequence"):[])[y]||null,M0=u?.stableId?{canvas:Z,artboardId:Q0,stableId:u.stableId,contentHash:u.contentHash,...b}:{canvas:Z,index:y,...b};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)})}).then((G0)=>G0.json()).then((G0)=>{if(!G0?.ok)console.warn("[retime]",G0?.error||"failed"),l7(`Retime refused: ${G0?.error||"failed"}`);else if(G0?.seq!=null)lJ(Z,G0.seq,b.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:(y)=>{if(!Z||Z===g8)return;let b=d6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;fetch(Q0).then((z0)=>z0.json().catch(()=>({}))).then((z0)=>{let f0=(z0?.ok&&Array.isArray(z0.clips)?z0.clips.filter((u)=>u.kind==="sequence"):[])[y]||null;if(!f0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Z,artboardId:b,stableId:f0.stableId,contentHash:f0.contentHash})})}).then((z0)=>z0?z0.json():null).then((z0)=>{if(z0&&!z0.ok)console.warn("[remove-clip]",z0.error||"failed"),l7(`Remove refused: ${z0.error||"failed"}`);else if(z0?.seq!=null)lJ(Z,z0.seq,"remove clip")}).catch(()=>{})},onReplace:(y)=>{if(!Z||Z===g8)return;wQ({accept:"video/*,image/*",resolveTarget:(b)=>{let z0=(b?.ok&&Array.isArray(b.clips)?b.clips.filter((G0)=>G0.kind==="sequence"):[])[y];if(z0?.mediaArrayRef)return{arrayRef:z0.mediaArrayRef};if(z0?.mediaCdId)return{cdId:z0.mediaCdId};return null}})},onReplaceAudio:(y)=>{if(!Z||Z===g8)return;wQ({accept:"audio/*",resolveTarget:(b)=>{let Q0=b?.ok&&Array.isArray(b.media)?b.media.filter((z0)=>z0.tag==="Audio"):[];return Q0[y]?.cdId?{cdId:Q0[y].cdId}:null}})},onReplaceLayer:(y,b)=>{if(!Z||Z===g8)return;let Q0=NY[y]?.layers?.[b]?.kind==="audio"?"audio/*":NY[y]?.layers?.[b]?.kind==="image"?"image/*":"video/*";wQ({accept:Q0,resolveTarget:(z0)=>{let f0=(z0?.ok&&Array.isArray(z0.clips)?z0.clips.filter((u)=>u.kind==="sequence"):[])[y]?.layers?.[b];if(f0?.mediaArrayRef)return{arrayRef:f0.mediaArrayRef};if(f0?.mediaCdId)return{cdId:f0.mediaCdId};return null}})},onReorder:(y,b)=>{if(!Z||Z===g8)return;let Q0=d6||void 0,z0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${Q0?`&artboardId=${encodeURIComponent(Q0)}`:""}`;fetch(z0).then((G0)=>G0.json().catch(()=>({}))).then((G0)=>{let f0=G0?.ok&&Array.isArray(G0.clips)?G0.clips.filter((M8)=>M8.kind==="sequence"):[],u=f0[y]||null,M0=b==="forward"?y+1:y-1,R0=f0[M0]||null,g0=b==="forward"?"after":"before";if(!u?.stableId||!R0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Z,artboardId:Q0,stableId:u.stableId,contentHash:u.contentHash,refStableId:R0.stableId,refContentHash:R0.contentHash,position:g0})})}).then((G0)=>G0?G0.json():null).then((G0)=>{if(G0&&!G0.ok)console.warn("[reorder-clip]",G0.error||"failed"),l7(`Reorder refused: ${G0.error||"failed"}`);else if(G0?.seq!=null)lJ(Z,G0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(y)=>{if(!Z||Z===g8)return;let b=d6||void 0,Q0=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;fetch(Q0).then((z0)=>z0.json().catch(()=>({}))).then((z0)=>{let f0=(z0?.ok&&Array.isArray(z0.clips)?z0.clips.filter((u)=>u.kind==="sequence"):[])[y]||null;if(!f0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Z,artboardId:b,stableId:f0.stableId,contentHash:f0.contentHash})})}).then((z0)=>z0?z0.json():null).then((z0)=>{if(z0&&!z0.ok)l7(`Hide refused: ${z0.error||"failed"}`);else if(z0&&z0.ok){if(l7(z0.hidden?"Clip hidden.":"Clip shown.",!0),z0.seq!=null)lJ(Z,z0.seq,z0.hidden?"hide clip":"show clip")}}).catch(()=>l7("Hide failed: network error"))},onDropMedia:(y)=>{if(!Z||Z===g8)return;let b=d6||void 0,Q0=y.type.startsWith("video/")?"Video":y.type.startsWith("audio/")?"Audio":y.type.startsWith("image/")?"Img":null,z0=q6[0]?.fps||30;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":y.type||"application/octet-stream"},body:y}).then((G0)=>G0.json().catch(()=>({}))).then((G0)=>{if(!G0?.path)return console.warn("[insert] upload failed",G0?.error),l7(`Upload failed: ${G0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Z,artboardId:b,from:Math.max(0,ZQ),durationInFrames:Math.round(z0*3),mediaTag:Q0,src:G0.path})})}).then((G0)=>G0?G0.json():null).then((G0)=>{if(G0&&!G0.ok)console.warn("[insert-clip]",G0.error||"failed"),l7(`Insert refused: ${G0.error||"failed"}`);else if(G0&&G0.ok){if(l7("Clip added to the timeline.",!0),G0.seq!=null)lJ(Z,G0.seq,"add clip")}}).catch(()=>{})},height:GQ,onResize:j9,onClose:()=>w7(!1)}),z(EV0,{activePath:Z,selected:q,wsConnected:x,openCount:tq,theme:O0,onToggleTheme:MQ,onClearSelected:kW,syncStatus:s,changesCount:I5,unpushed:c?.unpushed||0,changesOpen:d,onOpenChanges:c?.repo?()=>K0(!0):void 0})]}),U6&&_("button",{type:"button",className:"st-present-exit",onClick:NQ,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[z("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),z("span",{children:"Exit presentation"}),z("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),z(uU0,{open:q0,onClose:()=>C0(!1),actions:Xz}),r0&&z(aU0,{mode:r0.mode,initialScope:r0.scope,activePath:Z,hasComps:q6.length>0,activeArtboardId:q?.artboardId??X9??null,selection:q?.selector?{selector:q.selector,file:q.file}:null,onClose:()=>F8(null)}),k8&&z(Dw,{onClose:()=>P8(!1),initialTab:typeof k8==="string"?k8:void 0,theme:O0,onSetTheme:n0,cpMode:Q8,onSetCpMode:w0,minimapVisible:QJ,onToggleMinimap:R5,zoomCtlVisible:ZX,onToggleZoomCtl:k5,annotationsVisible:E5,onToggleAnnotations:MZ,autoOpenInspector:XJ,onToggleAutoOpenInspector:()=>_X((y)=>!y),hasCanvas:!!Z&&Z!==g8,panelSide:T6,onSetPanelSide:(y,b)=>BY((Q0)=>({...Q0,[y]:b})),layersMode:GX,onSetLayersMode:(y)=>{if(FY(y),y!=="separate")QQ(!1)}}),f8&&z(Bw,{onClose:()=>U9(!1),onInsert:TW}),EX&&z(rU0,{designRel:(j0?.designRel||j0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:jW,onClose:()=>oJ(null),multiple:!!EX.multiple,hasArtboardAnchor:!!EX.hasArtboardAnchor,onPickMany:pq}),IQ&&z(Mw,{onPick:cq,onClose:()=>CQ(null)}),u0&&z(Xw,{target:u0,cfg:j0,loadLog:_Y,onClose:()=>J8(null),onRestore:async(y)=>{let b=await Q7([y]);if(b?.ok)J8(null);else window.alert(b?.error||"Could not restore that version. Try again.")},onResolve:async(y)=>{let b=await AW(y);if(b.ok)J8(null);else window.alert(b.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(GV0,{open:t,onClose:()=>B0(!1)}),z(YV0,{open:fJ,onClose:()=>l9(!1),onStartTour:()=>{l9(!1),uJ(QB)}}),z(Fv,{wn:$6,onStartTour:uJ}),z(Hv,{center:MY}),z(Qf,{open:_9,onClose:()=>s7(!1)}),z(eK,{open:q9,onClose:()=>w9(!1)}),z(qw,{open:H7,onClose:()=>N7(!1),onStartTour:()=>uJ(ef),onBringBrand:()=>WX(!0)}),z(Zw,{open:n9,onClose:()=>WX(!1)}),zW&&!JJ&&!KZ&&_("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{KW(),uJ(QB)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:KW,children:"×"})]}),KZ&&!JJ&&_("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{UZ(),uJ(kw)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:UZ,children:"×"})]}),z(tf,{steps:JJ??[],open:!!JJ,onClose:()=>BZ(null),onComplete:KW,bus:vq,hasSelection:!!q,hasCanvas:W.length>0})]})}Gt.createRoot(document.getElementById("root")).render(z(cV0,{}));
|