@1agh/maude 1.4.5 → 1.4.6

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.
@@ -11,7 +11,7 @@ Error generating stack: `+Y.message+`
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
13
13
  */SP=Object.defineProperty,VV0=Object.getOwnPropertyDescriptor,qV0=Object.getOwnPropertyNames,BV0=Object.prototype.hasOwnProperty,NV0=((J)=>sH)(function(J){return sH.apply(this,arguments)}),Dd=U8(()=>{F3=new Map,rW=[],GH=(J,X,Q)=>{if(X&&typeof X.init=="function"&&typeof X.createInferenceSessionHandler=="function"){let Y=F3.get(J);if(Y===void 0)F3.set(J,{backend:X,priority:Q});else{if(Y.priority>Q)return;if(Y.priority===Q&&Y.backend!==X)throw Error(`cannot register backend "${J}" using priority ${Q}`)}if(Q>=0){let W=rW.indexOf(J);W!==-1&&rW.splice(W,1);for(let G=0;G<rW.length;G++)if(F3.get(rW[G]).priority<=Q){rW.splice(G,0,J);return}rW.push(J)}return}throw TypeError("not a valid backend")},hm=async(J)=>{let X=F3.get(J);if(!X)return"backend not found.";if(X.initialized)return X.backend;if(X.aborted)return X.error;{let Q=!!X.initPromise;try{return Q||(X.initPromise=X.backend.init(J)),await X.initPromise,X.initialized=!0,X.backend}catch(Y){return Q||(X.error=`${Y}`,X.aborted=!0),X.error}finally{delete X.initPromise}}},Ld=async(J)=>{let X=J.executionProviders||[],Q=X.map((K)=>typeof K=="string"?K:K.name),Y=Q.length===0?rW:Q,W,G=[],Z=new Set;for(let K of Y){let U=await hm(K);typeof U=="string"?G.push({name:K,err:U}):(W||(W=U),W===U&&Z.add(K))}if(!W)throw Error(`no available backend found. ERR: ${G.map((K)=>`[${K.name}] ${K.err}`).join(", ")}`);for(let{name:K,err:U}of G)Q.includes(K)&&console.warn(`removing requested execution provider "${K}" from session options because it is not available: ${U}`);let H=X.filter((K)=>Z.has(typeof K=="string"?K:K.name));return[W,new Proxy(J,{get:(K,U)=>U==="executionProviders"?H:Reflect.get(K,U)})]}}),LV0=U8(()=>{Dd()}),DV0=U8(()=>{Md="1.21.0"}),Od=U8(()=>{DV0(),wE="warning",I5={wasm:{},webgl:{},webgpu:{},versions:{common:Md},set logLevel(J){if(J!==void 0){if(typeof J!="string"||["verbose","info","warning","error","fatal"].indexOf(J)===-1)throw Error(`Unsupported logging level: ${J}`);wE=J}},get logLevel(){return wE}},Object.defineProperty(I5,"logLevel",{enumerable:!0})}),MV0=U8(()=>{Od(),k7=I5}),OV0=U8(()=>{Ad=(J,X)=>{let Q=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);Q.width=J.dims[3],Q.height=J.dims[2];let Y=Q.getContext("2d");if(Y!=null){let W,G;X?.tensorLayout!==void 0&&X.tensorLayout==="NHWC"?(W=J.dims[2],G=J.dims[3]):(W=J.dims[3],G=J.dims[2]);let Z=X?.format!==void 0?X.format:"RGB",H=X?.norm,K,U;H===void 0||H.mean===void 0?K=[255,255,255,255]:typeof H.mean=="number"?K=[H.mean,H.mean,H.mean,H.mean]:(K=[H.mean[0],H.mean[1],H.mean[2],0],H.mean[3]!==void 0&&(K[3]=H.mean[3])),H===void 0||H.bias===void 0?U=[0,0,0,0]:typeof H.bias=="number"?U=[H.bias,H.bias,H.bias,H.bias]:(U=[H.bias[0],H.bias[1],H.bias[2],0],H.bias[3]!==void 0&&(U[3]=H.bias[3]));let V=G*W,B=0,N=V,F=V*2,M=-1;Z==="RGBA"?(B=0,N=V,F=V*2,M=V*3):Z==="RGB"?(B=0,N=V,F=V*2):Z==="RBG"&&(B=0,F=V,N=V*2);for(let O=0;O<G;O++)for(let E=0;E<W;E++){let w=(J.data[B++]-U[0])*K[0],A=(J.data[N++]-U[1])*K[1],I=(J.data[F++]-U[2])*K[2],T=M===-1?255:(J.data[M++]-U[3])*K[3];Y.fillStyle="rgba("+w+","+A+","+I+","+T+")",Y.fillRect(E,O,1,1)}if("toDataURL"in Q)return Q.toDataURL();throw Error("toDataURL is not supported")}else throw Error("Can not access image data")},_d=(J,X)=>{let Q=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Y;if(Q!=null){let W,G,Z;X?.tensorLayout!==void 0&&X.tensorLayout==="NHWC"?(W=J.dims[2],G=J.dims[1],Z=J.dims[3]):(W=J.dims[3],G=J.dims[2],Z=J.dims[1]);let H=X!==void 0&&X.format!==void 0?X.format:"RGB",K=X?.norm,U,V;K===void 0||K.mean===void 0?U=[255,255,255,255]:typeof K.mean=="number"?U=[K.mean,K.mean,K.mean,K.mean]:(U=[K.mean[0],K.mean[1],K.mean[2],255],K.mean[3]!==void 0&&(U[3]=K.mean[3])),K===void 0||K.bias===void 0?V=[0,0,0,0]:typeof K.bias=="number"?V=[K.bias,K.bias,K.bias,K.bias]:(V=[K.bias[0],K.bias[1],K.bias[2],0],K.bias[3]!==void 0&&(V[3]=K.bias[3]));let B=G*W;if(X!==void 0&&(X.format!==void 0&&Z===4&&X.format!=="RGBA"||Z===3&&X.format!=="RGB"&&X.format!=="BGR"))throw Error("Tensor format doesn't match input tensor dims");let N=4,F=0,M=1,O=2,E=3,w=0,A=B,I=B*2,T=-1;H==="RGBA"?(w=0,A=B,I=B*2,T=B*3):H==="RGB"?(w=0,A=B,I=B*2):H==="RBG"&&(w=0,I=B,A=B*2),Y=Q.createImageData(W,G);for(let R=0;R<G*W;F+=N,M+=N,O+=N,E+=N,R++)Y.data[F]=(J.data[w++]-V[0])*U[0],Y.data[M]=(J.data[A++]-V[1])*U[1],Y.data[O]=(J.data[I++]-V[2])*U[2],Y.data[E]=T===-1?255:(J.data[T++]-V[3])*U[3]}else throw Error("Can not access image data");return Y}}),AV0=U8(()=>{bP(),GF=(J,X)=>{if(J===void 0)throw Error("Image buffer must be defined");if(X.height===void 0||X.width===void 0)throw Error("Image height and width must be defined");if(X.tensorLayout==="NHWC")throw Error("NHWC Tensor layout is not supported yet");let{height:Q,width:Y}=X,W=X.norm??{mean:255,bias:0},G,Z;typeof W.mean=="number"?G=[W.mean,W.mean,W.mean,W.mean]:G=[W.mean[0],W.mean[1],W.mean[2],W.mean[3]??255],typeof W.bias=="number"?Z=[W.bias,W.bias,W.bias,W.bias]:Z=[W.bias[0],W.bias[1],W.bias[2],W.bias[3]??0];let H=X.format!==void 0?X.format:"RGBA",K=X.tensorFormat!==void 0&&X.tensorFormat!==void 0?X.tensorFormat:"RGB",U=Q*Y,V=K==="RGBA"?new Float32Array(U*4):new Float32Array(U*3),B=4,N=0,F=1,M=2,O=3,E=0,w=U,A=U*2,I=-1;H==="RGB"&&(B=3,N=0,F=1,M=2,O=-1),K==="RGBA"?I=U*3:K==="RBG"?(E=0,A=U,w=U*2):K==="BGR"&&(A=0,w=U,E=U*2);for(let T=0;T<U;T++,N+=B,M+=B,F+=B,O+=B)V[E++]=(J[N]+Z[0])/G[0],V[w++]=(J[F]+Z[1])/G[1],V[A++]=(J[M]+Z[2])/G[2],I!==-1&&O!==-1&&(V[I++]=(J[O]+Z[3])/G[3]);return K==="RGBA"?new cX("float32",V,[1,4,Q,Y]):new cX("float32",V,[1,3,Q,Y])},wd=async(J,X)=>{let Q=typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement,Y=typeof ImageData<"u"&&J instanceof ImageData,W=typeof ImageBitmap<"u"&&J instanceof ImageBitmap,G=typeof J=="string",Z,H=X??{},K=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw Error("Canvas is not supported")},U=(V)=>typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||V instanceof OffscreenCanvas?V.getContext("2d"):null;if(Q){let V=K();V.width=J.width,V.height=J.height;let B=U(V);if(B!=null){let{height:N,width:F}=J;if(X!==void 0&&X.resizedHeight!==void 0&&X.resizedWidth!==void 0&&(N=X.resizedHeight,F=X.resizedWidth),X!==void 0){if(H=X,X.tensorFormat!==void 0)throw Error("Image input config format must be RGBA for HTMLImageElement");H.tensorFormat="RGBA",H.height=N,H.width=F}else H.tensorFormat="RGBA",H.height=N,H.width=F;B.drawImage(J,0,0),Z=B.getImageData(0,0,F,N).data}else throw Error("Can not access image data")}else if(Y){let V,B;if(X!==void 0&&X.resizedWidth!==void 0&&X.resizedHeight!==void 0?(V=X.resizedHeight,B=X.resizedWidth):(V=J.height,B=J.width),X!==void 0&&(H=X),H.format="RGBA",H.height=V,H.width=B,X!==void 0){let N=K();N.width=B,N.height=V;let F=U(N);if(F!=null)F.putImageData(J,0,0),Z=F.getImageData(0,0,B,V).data;else throw Error("Can not access image data")}else Z=J.data}else if(W){if(X===void 0)throw Error("Please provide image config with format for Imagebitmap");let V=K();V.width=J.width,V.height=J.height;let B=U(V);if(B!=null){let{height:N,width:F}=J;return B.drawImage(J,0,0,F,N),Z=B.getImageData(0,0,F,N).data,H.height=N,H.width=F,GF(Z,H)}else throw Error("Can not access image data")}else{if(G)return new Promise((V,B)=>{let N=K(),F=U(N);if(!J||!F)return B();let M=new Image;M.crossOrigin="Anonymous",M.src=J,M.onload=()=>{N.width=M.width,N.height=M.height,F.drawImage(M,0,0,N.width,N.height);let O=F.getImageData(0,0,N.width,N.height);H.height=N.height,H.width=N.width,V(GF(O.data,H))}});throw Error("Input data provided is not supported - aborted tensor creation")}if(Z!==void 0)return GF(Z,H);throw Error("Input data provided is not supported - aborted tensor creation")},Ed=(J,X)=>{let{width:Q,height:Y,download:W,dispose:G}=X;return new cX({location:"texture",type:"float32",texture:J,dims:[1,Y,Q,4],download:W,dispose:G})},Pd=(J,X)=>{let{dataType:Q,dims:Y,download:W,dispose:G}=X;return new cX({location:"gpu-buffer",type:Q??"float32",gpuBuffer:J,dims:Y,download:W,dispose:G})},Id=(J,X)=>{let{dataType:Q,dims:Y,download:W,dispose:G}=X;return new cX({location:"ml-tensor",type:Q??"float32",mlTensor:J,dims:Y,download:W,dispose:G})},kd=(J,X,Q)=>new cX({location:"cpu-pinned",type:J,data:X,dims:Q??[X.length]})}),_V0=U8(()=>{QH=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),P3=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),EE=!1,Td=()=>{if(!EE){EE=!0;let J=typeof BigInt64Array<"u"&&BigInt64Array.from,X=typeof BigUint64Array<"u"&&BigUint64Array.from,Q=globalThis.Float16Array,Y=typeof Q<"u"&&Q.from;J&&(QH.set("int64",BigInt64Array),P3.set(BigInt64Array,"int64")),X&&(QH.set("uint64",BigUint64Array),P3.set(BigUint64Array,"uint64")),Y?(QH.set("float16",Q),P3.set(Q,"float16")):QH.set("float16",Uint16Array)}}}),wV0=U8(()=>{bP(),Rd=(J)=>{let X=1;for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(typeof Y!="number"||!Number.isSafeInteger(Y))throw TypeError(`dims[${Q}] must be an integer, got: ${Y}`);if(Y<0)throw RangeError(`dims[${Q}] must be a non-negative integer, got: ${Y}`);X*=Y}return X},Cd=(J,X)=>{switch(J.location){case"cpu":return new cX(J.type,J.data,X);case"cpu-pinned":return new cX({location:"cpu-pinned",data:J.data,type:J.type,dims:X});case"texture":return new cX({location:"texture",texture:J.texture,type:J.type,dims:X});case"gpu-buffer":return new cX({location:"gpu-buffer",gpuBuffer:J.gpuBuffer,type:J.type,dims:X});case"ml-tensor":return new cX({location:"ml-tensor",mlTensor:J.mlTensor,type:J.type,dims:X});default:throw Error(`tensorReshape: tensor location ${J.location} is not supported`)}}}),bP=U8(()=>{OV0(),AV0(),_V0(),wV0(),cX=class{constructor(J,X,Q){Td();let Y,W;if(typeof J=="object"&&"location"in J)switch(this.dataLocation=J.location,Y=J.type,W=J.dims,J.location){case"cpu-pinned":{let Z=QH.get(Y);if(!Z)throw TypeError(`unsupported type "${Y}" to create tensor from pinned buffer`);if(!(J.data instanceof Z))throw TypeError(`buffer should be of type ${Z.name}`);this.cpuData=J.data;break}case"texture":{if(Y!=="float32")throw TypeError(`unsupported type "${Y}" to create tensor from texture`);this.gpuTextureData=J.texture,this.downloader=J.download,this.disposer=J.dispose;break}case"gpu-buffer":{if(Y!=="float32"&&Y!=="float16"&&Y!=="int32"&&Y!=="int64"&&Y!=="uint32"&&Y!=="uint8"&&Y!=="bool"&&Y!=="uint4"&&Y!=="int4")throw TypeError(`unsupported type "${Y}" to create tensor from gpu buffer`);this.gpuBufferData=J.gpuBuffer,this.downloader=J.download,this.disposer=J.dispose;break}case"ml-tensor":{if(Y!=="float32"&&Y!=="float16"&&Y!=="int32"&&Y!=="int64"&&Y!=="uint32"&&Y!=="uint64"&&Y!=="int8"&&Y!=="uint8"&&Y!=="bool"&&Y!=="uint4"&&Y!=="int4")throw TypeError(`unsupported type "${Y}" to create tensor from MLTensor`);this.mlTensorData=J.mlTensor,this.downloader=J.download,this.disposer=J.dispose;break}default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Z,H;if(typeof J=="string")if(Y=J,H=Q,J==="string"){if(!Array.isArray(X))throw TypeError("A string tensor's data must be a string array.");Z=X}else{let K=QH.get(J);if(K===void 0)throw TypeError(`Unsupported tensor type: ${J}.`);if(Array.isArray(X)){if(J==="float16"&&K===Uint16Array||J==="uint4"||J==="int4")throw TypeError(`Creating a ${J} tensor from number array is not supported. Please use ${K.name} as data.`);J==="uint64"||J==="int64"?Z=K.from(X,BigInt):Z=K.from(X)}else if(X instanceof K)Z=X;else if(X instanceof Uint8ClampedArray)if(J==="uint8")Z=Uint8Array.from(X);else throw TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(J==="float16"&&X instanceof Uint16Array&&K!==Uint16Array)Z=new globalThis.Float16Array(X.buffer,X.byteOffset,X.length);else throw TypeError(`A ${Y} tensor's data must be type of ${K}`)}else if(H=X,Array.isArray(J)){if(J.length===0)throw TypeError("Tensor type cannot be inferred from an empty array.");let K=typeof J[0];if(K==="string")Y="string",Z=J;else if(K==="boolean")Y="bool",Z=Uint8Array.from(J);else throw TypeError(`Invalid element type of data array: ${K}.`)}else if(J instanceof Uint8ClampedArray)Y="uint8",Z=Uint8Array.from(J);else{let K=P3.get(J.constructor);if(K===void 0)throw TypeError(`Unsupported type for tensor data: ${J.constructor}.`);Y=K,Z=J}if(H===void 0)H=[Z.length];else if(!Array.isArray(H))throw TypeError("A tensor's dims must be a number array");W=H,this.cpuData=Z,this.dataLocation="cpu"}let G=Rd(W);if(this.cpuData&&G!==this.cpuData.length&&!((Y==="uint4"||Y==="int4")&&Math.ceil(G/2)===this.cpuData.length))throw Error(`Tensor's size(${G}) does not match data length(${this.cpuData.length}).`);this.type=Y,this.dims=W,this.size=G}static async fromImage(J,X){return wd(J,X)}static fromTexture(J,X){return Ed(J,X)}static fromGpuBuffer(J,X){return Pd(J,X)}static fromMLTensor(J,X){return Id(J,X)}static fromPinnedBuffer(J,X,Q){return kd(J,X,Q)}toDataURL(J){return Ad(this,J)}toImageData(J){return _d(this,J)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(J){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let X=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=X,J&&this.disposer&&(this.disposer(),this.disposer=void 0),X}finally{this.isDownloading=!1}}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw Error("The tensor is disposed.")}reshape(J){if(this.ensureValid(),this.downloader||this.disposer)throw Error("Cannot reshape a tensor that owns GPU resource.");return Cd(this,J)}}}),$d=U8(()=>{bP(),QQ=cX}),Sd=U8(()=>{Od(),R3=(J,X)=>{(typeof I5.trace>"u"?!I5.wasm.trace:!I5.trace)||console.timeStamp(`${J}::ORT::${X}`)},PE=(J,X)=>{let Q=Error().stack?.split(/\r\n|\r|\n/g)||[],Y=!1;for(let W=0;W<Q.length;W++){if(Y&&!Q[W].includes("TRACE_FUNC")){let G=`FUNC_${J}::${Q[W].trim().split(" ")[1]}`;X&&(G+=`::${X}`),R3("CPU",G);return}Q[W].includes("TRACE_FUNC")&&(Y=!0)}},YQ=(J)=>{(typeof I5.trace>"u"?!I5.wasm.trace:!I5.trace)||PE("BEGIN",J)},k5=(J)=>{(typeof I5.trace>"u"?!I5.wasm.trace:!I5.trace)||PE("END",J)}}),EV0=U8(()=>{Dd(),$d(),Sd(),bd=class J{constructor(X){this.handler=X}async run(X,Q,Y){YQ();let W={},G={};if(typeof X!="object"||X===null||X instanceof QQ||Array.isArray(X))throw TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Z=!0;if(typeof Q=="object"){if(Q===null)throw TypeError("Unexpected argument[1]: cannot be null.");if(Q instanceof QQ)throw TypeError("'fetches' cannot be a Tensor");if(Array.isArray(Q)){if(Q.length===0)throw TypeError("'fetches' cannot be an empty array.");Z=!1;for(let U of Q){if(typeof U!="string")throw TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(U)===-1)throw RangeError(`'fetches' contains invalid output name: ${U}.`);W[U]=null}if(typeof Y=="object"&&Y!==null)G=Y;else if(typeof Y<"u")throw TypeError("'options' must be an object.")}else{let U=!1,V=Object.getOwnPropertyNames(Q);for(let B of this.outputNames)if(V.indexOf(B)!==-1){let N=Q[B];(N===null||N instanceof QQ)&&(U=!0,Z=!1,W[B]=N)}if(U){if(typeof Y=="object"&&Y!==null)G=Y;else if(typeof Y<"u")throw TypeError("'options' must be an object.")}else G=Q}}else if(typeof Q<"u")throw TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let U of this.inputNames)if(typeof X[U]>"u")throw Error(`input '${U}' is missing in 'feeds'.`);if(Z)for(let U of this.outputNames)W[U]=null;let H=await this.handler.run(X,W,G),K={};for(let U in H)if(Object.hasOwnProperty.call(H,U)){let V=H[U];V instanceof QQ?K[U]=V:K[U]=new QQ(V.type,V.data,V.dims)}return k5(),K}async release(){return this.handler.dispose()}static async create(X,Q,Y,W){YQ();let G,Z={};if(typeof X=="string"){if(G=X,typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q<"u")throw TypeError("'options' must be an object.")}else if(X instanceof Uint8Array){if(G=X,typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q<"u")throw TypeError("'options' must be an object.")}else if(X instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&X instanceof SharedArrayBuffer){let V=X,B=0,N=X.byteLength;if(typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q=="number"){if(B=Q,!Number.isSafeInteger(B))throw RangeError("'byteOffset' must be an integer.");if(B<0||B>=V.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${V.byteLength}).`);if(N=X.byteLength-B,typeof Y=="number"){if(N=Y,!Number.isSafeInteger(N))throw RangeError("'byteLength' must be an integer.");if(N<=0||B+N>V.byteLength)throw RangeError(`'byteLength' is out of range (0, ${V.byteLength-B}].`);if(typeof W=="object"&&W!==null)Z=W;else if(typeof W<"u")throw TypeError("'options' must be an object.")}else if(typeof Y<"u")throw TypeError("'byteLength' must be a number.")}else if(typeof Q<"u")throw TypeError("'options' must be an object.");G=new Uint8Array(V,B,N)}else throw TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[H,K]=await Ld(Z),U=await H.createInferenceSessionHandler(G,K);return k5(),new J(U)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),PV0=U8(()=>{EV0(),yP=bd}),IV0=U8(()=>{}),kV0=U8(()=>{}),TV0=U8(()=>{}),RV0=U8(()=>{}),yd={};$3(yd,{InferenceSession:()=>yP,TRACE:()=>R3,TRACE_FUNC_BEGIN:()=>YQ,TRACE_FUNC_END:()=>k5,Tensor:()=>QQ,env:()=>k7,registerBackend:()=>GH});WQ=U8(()=>{LV0(),MV0(),PV0(),$d(),IV0(),kV0(),Sd(),TV0(),RV0()}),jP=U8(()=>{}),jd={};$3(jd,{default:()=>vd});CV0=U8(()=>{xo(),KH(),vP(),IE="ort-wasm-proxy-worker",kE=globalThis.self?.name===IE,kE&&(self.onmessage=(J)=>{let{type:X,in:Q}=J.data;try{switch(X){case"init-wasm":fP(Q.wasm).then(()=>{JI(Q).then(()=>{postMessage({type:X})},(Y)=>{postMessage({type:X,err:Y})})},(Y)=>{postMessage({type:X,err:Y})});break;case"init-ep":{let{epName:Y,env:W}=Q;XI(W,Y).then(()=>{postMessage({type:X})},(G)=>{postMessage({type:X,err:G})});break}case"copy-from":{let{buffer:Y}=Q,W=kF(Y);postMessage({type:X,out:W});break}case"create":{let{model:Y,options:W}=Q;QI(Y,W).then((G)=>{postMessage({type:X,out:G})},(G)=>{postMessage({type:X,err:G})});break}case"release":YI(Q),postMessage({type:X});break;case"run":{let{sessionId:Y,inputIndices:W,inputs:G,outputIndices:Z,options:H}=Q;WI(Y,W,G,Z,Array(Z.length).fill(null),H).then((K)=>{K.some((U)=>U[3]!=="cpu")?postMessage({type:X,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:X,out:K},ZI([...G,...K]))},(K)=>{postMessage({type:X,err:K})});break}case"end-profiling":GI(Q),postMessage({type:X});break;default:}}catch(Y){postMessage({type:X,err:Y})}}),vd=kE?null:(J)=>new Worker(J??dX,{type:"module",name:IE})}),fd={};$3(fd,{default:()=>xd});$V0=U8(()=>{RE=(TE=import.meta.url,async function(J={}){var X,Q,Y=J,W=new Promise((q,L)=>{X=q,Q=L}),G=typeof window=="object",Z=typeof WorkerGlobalScope<"u",H=Z&&self.name?.startsWith("em-pthread");Y.mountExternalData=(q,L)=>{q.startsWith("./")&&(q=q.substring(2)),(Y.Bd||(Y.Bd=new Map)).set(q,L)},Y.unmountExternalData=()=>{delete Y.Bd};var K=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let U=()=>{let q=(_,P,k)=>(...y)=>{let g=R9,J0=P?.();y=_(...y);let W0=P?.();return J0!==W0&&(_=W0,k(J0),P=k=null),R9!=g?new Promise((N0,R0)=>{MX={resolve:N0,reject:R0}}):y},L=(_)=>async(...P)=>{try{if(Y.Cd)throw Error("Session already started");let k=Y.Cd={be:P[0],errors:[]},y=await _(...P);if(Y.Cd!==k)throw Error("Session mismatch");Y.Dd?.flush();let g=k.errors;if(0<g.length){let J0=await Promise.all(g);if(J0=J0.filter((W0)=>W0),0<J0.length)throw Error(J0.join(`
14
- `))}return y}finally{Y.Cd=null}};Y._OrtCreateSession=q(Y._OrtCreateSession,()=>Y._OrtCreateSession,(_)=>Y._OrtCreateSession=_),Y._OrtRun=L(q(Y._OrtRun,()=>Y._OrtRun,(_)=>Y._OrtRun=_)),Y._OrtRunWithBinding=L(q(Y._OrtRunWithBinding,()=>Y._OrtRunWithBinding,(_)=>Y._OrtRunWithBinding=_)),Y._OrtBindInput=q(Y._OrtBindInput,()=>Y._OrtBindInput,(_)=>Y._OrtBindInput=_),U=void 0};Y.jsepInit=(q,L)=>{if(U?.(),q==="webgpu"){[Y.Dd,Y.Rd,Y.Vd,Y.Hd,Y.Ud,Y.hc,Y.Wd,Y.Zd,Y.Sd,Y.Td,Y.Xd]=L;let _=Y.Dd;Y.jsepRegisterBuffer=(P,k,y,g)=>_.registerBuffer(P,k,y,g),Y.jsepGetBuffer=(P)=>_.getBuffer(P),Y.jsepCreateDownloader=(P,k,y)=>_.createDownloader(P,k,y),Y.jsepOnCreateSession=(P)=>{_.onCreateSession(P)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.$d=(P,k)=>{_.upload(P,k)}}else if(q==="webnn"){[Y.Dd,Y.Yd,Y.Id,Y.jsepEnsureTensor,Y.Jd,Y.jsepDownloadTensor]=L,Y.jsepReleaseTensorId=Y.Id,Y.jsepUploadTensor=Y.Jd;let _=Y.Dd;Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.jsepOnRunEnd=_.onRunEnd.bind(_),Y.jsepRegisterMLContext=(P,k)=>{_.registerMLContext(P,k)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepCreateMLTensorDownloader=(P,k)=>_.createMLTensorDownloader(P,k),Y.jsepRegisterMLTensor=(P,k,y,g)=>_.registerMLTensor(P,k,y,g),Y.jsepCreateMLContext=(P)=>_.createMLContext(P),Y.jsepRegisterMLConstant=(P,k,y,g,J0)=>_.registerMLConstant(P,k,y,g,J0,Y.Bd),Y.jsepRegisterGraphInput=_.registerGraphInput.bind(_),Y.jsepIsGraphInput=_.isGraphInput.bind(_),Y.jsepCreateTemporaryTensor=_.createTemporaryTensor.bind(_)}};var V,B,N=Object.assign({},Y),F=(q,L)=>{throw L},M="";(G||Z)&&(Z?M=self.location.href:typeof document<"u"&&document.currentScript&&(M=document.currentScript.src),TE&&(M=TE),M=M.startsWith("blob:")?"":M.slice(0,M.replace(/[?#].*/,"").lastIndexOf("/")+1),Z&&(B=(q)=>{var L=new XMLHttpRequest;return L.open("GET",q,!1),L.responseType="arraybuffer",L.send(null),new Uint8Array(L.response)}),V=async(q)=>{if(e(q))return new Promise((_,P)=>{var k=new XMLHttpRequest;k.open("GET",q,!0),k.responseType="arraybuffer",k.onload=()=>{k.status==200||k.status==0&&k.response?_(k.response):P(k.status)},k.onerror=P,k.send(null)});var L=await fetch(q,{credentials:"same-origin"});if(L.ok)return L.arrayBuffer();throw Error(L.status+" : "+L.url)});var O=console.log.bind(console),E=console.error.bind(console),w=O,A=E;Object.assign(Y,N),N=null;var I,T,R,$,C,j,f,m,d,a,x,h,l,v=Y.wasmBinary,n=!1,e=(q)=>q.startsWith("file://");function s(){return I.buffer!=$.buffer&&D8(),$}function H0(){return I.buffer!=$.buffer&&D8(),C}function r(){return I.buffer!=$.buffer&&D8(),j}function z0(){return I.buffer!=$.buffer&&D8(),f}function i(){return I.buffer!=$.buffer&&D8(),m}function q0(){return I.buffer!=$.buffer&&D8(),d}function Z0(){return I.buffer!=$.buffer&&D8(),a}function I0(){return I.buffer!=$.buffer&&D8(),l}if(H){let q=function(L){try{var _=L.data,P=_.yd;if(P==="load"){let k=[];self.onmessage=(y)=>k.push(y),self.startWorker=()=>{postMessage({yd:"loaded"});for(let y of k)q(y);self.onmessage=q};for(let y of _.Od)Y[y]&&!Y[y].proxy||(Y[y]=(...g)=>{postMessage({yd:"callHandler",Nd:y,args:g})},y=="print"&&(w=Y[y]),y=="printErr"&&(A=Y[y]));I=_.he,D8(),s0(_.ie)}else if(P==="run"){U0(_.xd),h5(_.xd,0,0,1,0,0),_0(),P0(_.xd),e0||(PG(),e0=!0);try{o0(_.de,_.Fd)}catch(k){if(k!="unwind")throw k}}else _.target!=="setimmediate"&&(P==="checkMailbox"?e0&&z8():P&&(A(`worker: received unknown command ${P}`),A(_)))}catch(k){throw IG(),k}};var a0=q,s0,e0=!1;A=function(...L){L=L.join(" "),console.error(L)},self.alert=function(...L){postMessage({yd:"alert",text:L.join(" "),fe:sJ()})},self.onunhandledrejection=(L)=>{throw L.reason||L},self.onmessage=q}function D8(){var q=I.buffer;Y.HEAP8=$=new Int8Array(q),Y.HEAP16=j=new Int16Array(q),Y.HEAPU8=C=new Uint8Array(q),Y.HEAPU16=f=new Uint16Array(q),Y.HEAP32=m=new Int32Array(q),Y.HEAPU32=d=new Uint32Array(q),Y.HEAPF32=a=new Float32Array(q),Y.HEAPF64=l=new Float64Array(q),Y.HEAP64=x=new BigInt64Array(q),Y.HEAPU64=h=new BigUint64Array(q)}function s8(){H?startWorker(Y):V0.Bb()}H||(I=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),D8());var w8,N8=0,C0=null;function A0(){if(--N8==0&&C0){var q=C0;C0=null,q()}}function $0(q){throw A(q="Aborted("+q+")"),n=!0,q=new WebAssembly.RuntimeError(q+". Build with -sASSERTIONS for more info."),Q(q),q}function Q8(){return{a:{Ta:b8,Va:f8,W:J9,la:a7,b:X9,u:d8,R:O0,Za:K8,d:S8,pb:x9,g:v7,T:M0,Ga:E0,lb:g8,nb:t8,Ha:v8,Ea:W9,wb:T9,Da:e9,pa:J7,mb:FQ,jb:aX,Fa:BJ,kb:oJ,Ma:Y4,za:HG,eb:qY,cb:j5,ya:P6,V:W4,N:DQ,db:zG,ma:o,fb:G0,zb:L0,hb:M8,qb:L9,ab:I6,Aa:MQ,yb:P0,Ja:s6,S:RH,Wa:KG,$:CH,G:X6,E:k6,m:rJ,H:BY,B:G1,X:LJ,J:_X,v:UG,O:Z1,D:bH,t:H1,A:VG,z:qG,w:yH,r:jH,tb:LY,ub:DY,vb:AQ,rb:NG,sb:FG,bb:MY,Oa:vH,La:MG,y:EX,ja:g6,Ba:OG,Ka:DG,qa:OY,Ia:_Q,ib:z4,U:LG,fa:fH,Sa:z1,gb:xH,Qa:hH,Pa:K4,Ab:PX,Ca:wG,ob:j0,aa:U4,oa:X5,xb:AY,na:EG,$a:iH,ia:IX,sa:nH,ga:rG,da:M1,ua:sG,p:cH,e:mH,c:cG,ea:L1,f:U1,n:A4,k:fY,Y:vY,ka:l5,j:nG,wa:F1,Ra:rH,ca:E1,Ua:Y7,P:D1,K:pH,_:w1,Q:B1,Z:JX,x:iG,l:K1,va:_1,i:dG,h:uH,ra:tG,ta:oH,o:V6,q:lH,s:oG,I:CQ,C:q1,L:dH,xa:aG,_a:N1,F:P1,Ya:O1,ba:C6,M:V1,Xa:A1,ha:Q5,a:I,Na:J8}}}var Z8={1319426:()=>typeof wasmOffsetConverter<"u",1319483:(q,L,_,P,k)=>{if(Y===void 0||!Y.Bd)return 1;if((q=t(Number(q>>>0))).startsWith("./")&&(q=q.substring(2)),!(q=Y.Bd.get(q)))return 2;if(L=Number(L>>>0),_=Number(_>>>0),P=Number(P>>>0),L+_>q.byteLength)return 3;try{let y=q.subarray(L,L+_);switch(k){case 0:H0().set(y,P>>>0);break;case 1:Y.$d(P,y);break;default:return 4}return 0}catch{return 4}},1320198:(q,L,_)=>{Y.Jd(q,H0().subarray(L>>>0,L+_>>>0))},1320261:()=>Y.Yd(),1320302:(q)=>{Y.Id(q)},1320338:()=>{Y.Sd()},1320369:()=>{Y.Td()},1320398:()=>{Y.Xd()},1320423:(q)=>Y.Rd(q),1320456:(q)=>Y.Vd(q),1320488:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_),!0)},1320551:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_))},1320608:(q)=>{Y.hc("Abs",q,void 0)},1320659:(q)=>{Y.hc("Neg",q,void 0)},1320710:(q)=>{Y.hc("Floor",q,void 0)},1320763:(q)=>{Y.hc("Ceil",q,void 0)},1320815:(q)=>{Y.hc("Reciprocal",q,void 0)},1320873:(q)=>{Y.hc("Sqrt",q,void 0)},1320925:(q)=>{Y.hc("Exp",q,void 0)},1320976:(q)=>{Y.hc("Erf",q,void 0)},1321027:(q)=>{Y.hc("Sigmoid",q,void 0)},1321082:(q,L,_)=>{Y.hc("HardSigmoid",q,{alpha:L,beta:_})},1321161:(q)=>{Y.hc("Log",q,void 0)},1321212:(q)=>{Y.hc("Sin",q,void 0)},1321263:(q)=>{Y.hc("Cos",q,void 0)},1321314:(q)=>{Y.hc("Tan",q,void 0)},1321365:(q)=>{Y.hc("Asin",q,void 0)},1321417:(q)=>{Y.hc("Acos",q,void 0)},1321469:(q)=>{Y.hc("Atan",q,void 0)},1321521:(q)=>{Y.hc("Sinh",q,void 0)},1321573:(q)=>{Y.hc("Cosh",q,void 0)},1321625:(q)=>{Y.hc("Asinh",q,void 0)},1321678:(q)=>{Y.hc("Acosh",q,void 0)},1321731:(q)=>{Y.hc("Atanh",q,void 0)},1321784:(q)=>{Y.hc("Tanh",q,void 0)},1321836:(q)=>{Y.hc("Not",q,void 0)},1321887:(q,L,_)=>{Y.hc("Clip",q,{min:L,max:_})},1321956:(q)=>{Y.hc("Clip",q,void 0)},1322008:(q,L)=>{Y.hc("Elu",q,{alpha:L})},1322066:(q)=>{Y.hc("Gelu",q,void 0)},1322118:(q)=>{Y.hc("Relu",q,void 0)},1322170:(q,L)=>{Y.hc("LeakyRelu",q,{alpha:L})},1322234:(q,L)=>{Y.hc("ThresholdedRelu",q,{alpha:L})},1322304:(q,L)=>{Y.hc("Cast",q,{to:L})},1322362:(q)=>{Y.hc("Add",q,void 0)},1322413:(q)=>{Y.hc("Sub",q,void 0)},1322464:(q)=>{Y.hc("Mul",q,void 0)},1322515:(q)=>{Y.hc("Div",q,void 0)},1322566:(q)=>{Y.hc("Pow",q,void 0)},1322617:(q)=>{Y.hc("Equal",q,void 0)},1322670:(q)=>{Y.hc("Greater",q,void 0)},1322725:(q)=>{Y.hc("GreaterOrEqual",q,void 0)},1322787:(q)=>{Y.hc("Less",q,void 0)},1322839:(q)=>{Y.hc("LessOrEqual",q,void 0)},1322898:(q,L,_,P,k)=>{Y.hc("ReduceMean",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323073:(q,L,_,P,k)=>{Y.hc("ReduceMax",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323247:(q,L,_,P,k)=>{Y.hc("ReduceMin",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323421:(q,L,_,P,k)=>{Y.hc("ReduceProd",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323596:(q,L,_,P,k)=>{Y.hc("ReduceSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323770:(q,L,_,P,k)=>{Y.hc("ReduceL1",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323943:(q,L,_,P,k)=>{Y.hc("ReduceL2",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324116:(q,L,_,P,k)=>{Y.hc("ReduceLogSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324293:(q,L,_,P,k)=>{Y.hc("ReduceSumSquare",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324473:(q,L,_,P,k)=>{Y.hc("ReduceLogSumExp",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324653:(q)=>{Y.hc("Where",q,void 0)},1324706:(q,L,_)=>{Y.hc("Transpose",q,{perm:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[]})},1324830:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1324963:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1325096:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1325529:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1326190:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1326623:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1327284:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327375:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1327854:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327945:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328424:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1328511:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328986:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1329073:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1329548:(q,L,_,P,k)=>{Y.hc("Gemm",q,{alpha:L,beta:_,transA:P,transB:k})},1329652:(q)=>{Y.hc("MatMul",q,void 0)},1329706:(q,L,_,P)=>{Y.hc("ArgMax",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329814:(q,L,_,P)=>{Y.hc("ArgMin",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329922:(q,L)=>{Y.hc("Softmax",q,{axis:L})},1329985:(q,L)=>{Y.hc("Concat",q,{axis:L})},1330045:(q,L,_,P,k)=>{Y.hc("Split",q,{axis:L,numOutputs:_,splitSizes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1330201:(q)=>{Y.hc("Expand",q,void 0)},1330255:(q,L)=>{Y.hc("Gather",q,{axis:Number(L)})},1330326:(q,L)=>{Y.hc("GatherElements",q,{axis:Number(L)})},1330405:(q,L)=>{Y.hc("GatherND",q,{batch_dims:Number(L)})},1330484:(q,L,_,P,k,y,g,J0,W0,N0,R0)=>{Y.hc("Resize",q,{antialias:L,axes:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],coordinateTransformMode:t(k),cubicCoeffA:y,excludeOutside:g,extrapolationValue:J0,keepAspectRatioPolicy:t(W0),mode:t(N0),nearestMode:t(R0)})},1330846:(q,L,_,P,k,y,g)=>{Y.hc("Slice",q,{starts:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[],ends:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[],axes:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[]})},1331110:(q)=>{Y.hc("Tile",q,void 0)},1331162:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331276:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331390:(q)=>{Y.hc("Range",q,void 0)},1331443:(q,L)=>{Y.hc("Einsum",q,{equation:t(L)})},1331524:(q,L,_,P,k)=>{Y.hc("Pad",q,{mode:L,value:_,pads:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1331667:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1331836:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1332005:(q,L,_)=>{Y.hc("CumSum",q,{exclusive:Number(L),reverse:Number(_)})},1332102:(q,L,_)=>{Y.hc("DequantizeLinear",q,{axis:L,blockSize:_})},1332192:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332362:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332532:(q,L)=>{Y.hc("ScatterND",q,{reduction:t(L)})},1332617:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("Attention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y,qkvHiddenSizes:g?Array.from(i().subarray(Number(J0)>>>0,Number(J0)+g>>>0)):[],pastPresentShareBuffer:!!W0})},1332889:(q)=>{Y.hc("BiasAdd",q,void 0)},1332944:(q)=>{Y.hc("BiasSplitGelu",q,void 0)},1333005:(q)=>{Y.hc("FastGelu",q,void 0)},1333061:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7,_J)=>{Y.hc("Conv",q,{format:l0?"NHWC":"NCHW",auto_pad:L,dilations:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],group:k,kernel_shape:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],pads:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],strides:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],w_is_const:()=>!!s()[Number(q8)>>>0],activation:t(Q9),activation_params:B7?Array.from(Z0().subarray(Number(B7)>>>0,Number(_J)>>>0)):[]})},1333645:(q)=>{Y.hc("Gelu",q,void 0)},1333697:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("GroupQueryAttention",q,{numHeads:L,kvNumHeads:_,scale:P,softcap:k,doRotary:y,rotaryInterleaved:g,smoothSoftmax:J0,localWindowSize:W0})},1333914:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334025:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334136:(q,L,_,P,k,y)=>{Y.hc("MatMulNBits",q,{k:L,n:_,accuracyLevel:P,bits:k,blockSize:y})},1334263:(q,L,_,P,k,y)=>{Y.hc("MultiHeadAttention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y})},1334422:(q,L)=>{Y.hc("QuickGelu",q,{alpha:L})},1334486:(q,L,_,P,k)=>{Y.hc("RotaryEmbedding",q,{interleaved:!!L,numHeads:_,rotaryEmbeddingDim:P,scale:k})},1334625:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334727:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334829:(q,L,_,P)=>{Y.hc("GatherBlockQuantized",q,{gatherAxis:L,quantizeAxis:_,blockSize:P})},1334950:(q)=>{Y.Wd(q)},1334984:(q,L)=>Y.Zd(Number(q),Number(L),Y.Cd.be,Y.Cd.errors)};function f8(q,L,_){return sX(async()=>{await Y.Ud(Number(q),Number(L),Number(_))})}function b8(){return typeof wasmOffsetConverter<"u"}class O9{name="ExitStatus";constructor(q){this.message=`Program terminated with exit(${q})`,this.status=q}}var h0=(q)=>{q.terminate(),q.onmessage=()=>{}},C8=[],A9=(q)=>{t0.length==0&&(P8(),X8(t0[0]));var L=t0.pop();if(!L)return 6;H8.push(L),d0[q.xd]=L,L.xd=q.xd;var _={yd:"run",de:q.ce,Fd:q.Fd,xd:q.xd};return L.postMessage(_,q.Ld),0},F8=0,B0=(q,L,..._)=>{for(var P=2*_.length,k=G8(),y=q4(8*P),g=y>>>3,J0=0;J0<_.length;J0++){var W0=_[J0];typeof W0=="bigint"?(x[g+2*J0]=1n,x[g+2*J0+1]=W0):(x[g+2*J0]=0n,I0()[g+2*J0+1>>>0]=W0)}return q=kG(q,0,P,y,L),Y8(k),q};function J8(q){if(H)return B0(0,1,q);if(R=q,!(0<F8)){for(var L of H8)h0(L);for(L of t0)h0(L);t0=[],H8=[],d0={},n=!0}F(0,new O9(q))}function r0(q){if(H)return B0(1,0,q);j0(q)}var j0=(q)=>{if(R=q,H)throw r0(q),"unwind";J8(q)},t0=[],H8=[],p0=[],d0={},k8=(q)=>{var L=q.xd;delete d0[L],t0.push(q),H8.splice(H8.indexOf(q),1),q.xd=0,wY(L)};function _0(){p0.forEach((q)=>q())}var X8=(q)=>new Promise((L)=>{q.onmessage=(k)=>{var y=(k=k.data).yd;if(k.Ed&&k.Ed!=sJ()){var g=d0[k.Ed];g?g.postMessage(k,k.Ld):A(`Internal error! Worker sent a message "${y}" to target pthread ${k.Ed}, but that thread no longer exists!`)}else y==="checkMailbox"?z8():y==="spawnThread"?A9(k):y==="cleanupThread"?k8(d0[k.ee]):y==="loaded"?(q.loaded=!0,L(q)):y==="alert"?alert(`Thread ${k.fe}: ${k.text}`):k.target==="setimmediate"?q.postMessage(k):y==="callHandler"?Y[k.Nd](...k.args):y&&A(`worker sent an unknown command ${y}`)},q.onerror=(k)=>{throw A(`worker sent an error! ${k.filename}:${k.lineno}: ${k.message}`),k};var _,P=[];for(_ of[])Y.propertyIsEnumerable(_)&&P.push(_);q.postMessage({yd:"load",Od:P,he:I,ie:T})});function P8(){var q=new Worker(import.meta.url.startsWith("file:")?new URL("ort.webgpu.bundle.min.mjs",import.meta.url):new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});t0.push(q)}var U0=(q)=>{D8();var L=q0()[q+52>>>2>>>0];q=q0()[q+56>>>2>>>0],IQ(L,L-q),Y8(L)},o0=(q,L)=>{F8=0,q=kQ(q,L),0<F8?R=q:g5(q)},R8=[];function J9(q){var L=new F9(q>>>=0);if(s()[L.wd+12>>>0]==0){var _=1;s()[L.wd+12>>>0]=_}return _=0,s()[L.wd+13>>>0]=_,R8.push(L),Q6(q),Y6(q)}var i0=0,a7=()=>{T0(0,0);var q=R8.pop();TG(q.Gd),i0=0};class F9{constructor(q){this.Gd=q,this.wd=q-24}}function v7(q){throw i0||=q>>>0,i0}var I8=(q)=>{var L=i0;if(!L)return eJ(0),0;var _=new F9(L);q0()[_.wd+16>>>2>>>0]=L;var P=q0()[_.wd+4>>>2>>>0];if(!P)return eJ(0),L;for(var k of q){if(k===0||k===P)break;if(m5(k,P,_.wd+16))return eJ(k),L}return eJ(P),L};function X9(){return I8([])}function d8(q){return I8([q>>>0])}function O0(q,L){return I8([q>>>0,L>>>0])}var K8=()=>{var q=R8.pop();q||$0("no exception to throw");var L=q.Gd;if(s()[q.wd+13>>>0]==0){R8.push(q);var _=1;s()[q.wd+13>>>0]=_,_=0,s()[q.wd+12>>>0]=_}throw i0=L};function S8(q,L,_){var P=new F9(q>>>=0);throw L>>>=0,_>>>=0,q0()[P.wd+16>>>2>>>0]=0,q0()[P.wd+4>>>2>>>0]=L,q0()[P.wd+8>>>2>>>0]=_,i0=q}function V9(q,L,_,P){return H?B0(2,1,q,L,_,P):x9(q,L,_,P)}function x9(q,L,_,P){if(q>>>=0,_>>>=0,P>>>=0,K===void 0)return 6;var k=[];return H&&k.length===0?V9(q,L>>>=0,_,P):(q={ce:_,xd:q,Fd:P,Ld:k},H?(q.yd="spawnThread",postMessage(q,k),0):A9(q))}var i9=typeof TextDecoder<"u"?new TextDecoder:void 0,h9=(q,L=0,_=NaN)=>{var P=(L>>>=0)+_;for(_=L;q[_]&&!(_>=P);)++_;if(16<_-L&&q.buffer&&i9)return i9.decode(q.buffer instanceof ArrayBuffer?q.subarray(L,_):q.slice(L,_));for(P="";L<_;){var k=q[L++];if(128&k){var y=63&q[L++];if((224&k)==192)P+=String.fromCharCode((31&k)<<6|y);else{var g=63&q[L++];65536>(k=(240&k)==224?(15&k)<<12|y<<6|g:(7&k)<<18|y<<12|g<<6|63&q[L++])?P+=String.fromCharCode(k):(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k))}}else P+=String.fromCharCode(k)}return P},t=(q,L)=>(q>>>=0)?h9(H0(),q,L):"";function M0(q,L,_){return H?B0(3,1,q,L,_):0}function E0(q,L){if(H)return B0(4,1,q,L)}var v0=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);127>=P?L++:2047>=P?L+=2:55296<=P&&57343>=P?(L+=4,++_):L+=3}return L},W8=(q,L,_)=>{var P=H0();if(L>>>=0,0<_){var k=L;_=L+_-1;for(var y=0;y<q.length;++y){var g=q.charCodeAt(y);if(55296<=g&&57343>=g&&(g=65536+((1023&g)<<10)|1023&q.charCodeAt(++y)),127>=g){if(L>=_)break;P[L++>>>0]=g}else{if(2047>=g){if(L+1>=_)break;P[L++>>>0]=192|g>>6}else{if(65535>=g){if(L+2>=_)break;P[L++>>>0]=224|g>>12}else{if(L+3>=_)break;P[L++>>>0]=240|g>>18,P[L++>>>0]=128|g>>12&63}P[L++>>>0]=128|g>>6&63}P[L++>>>0]=128|63&g}}P[L>>>0]=0,q=L-k}else q=0;return q};function g8(q,L){if(H)return B0(5,1,q,L)}function t8(q,L,_){if(H)return B0(6,1,q,L,_)}function v8(q,L,_){return H?B0(7,1,q,L,_):0}function W9(q,L){if(H)return B0(8,1,q,L)}function T9(q,L,_){if(H)return B0(9,1,q,L,_)}function e9(q,L,_,P){if(H)return B0(10,1,q,L,_,P)}function J7(q,L,_,P){if(H)return B0(11,1,q,L,_,P)}function FQ(q,L,_,P){if(H)return B0(12,1,q,L,_,P)}function aX(q){if(H)return B0(13,1,q)}function BJ(q,L){if(H)return B0(14,1,q,L)}function oJ(q,L,_){if(H)return B0(15,1,q,L,_)}var nJ,e7,Y4=()=>$0(""),R7=(q)=>{for(var L="";H0()[q>>>0];)L+=nJ[H0()[q++>>>0]];return L},FX={},j9={},VY={};function p7(q,L,_={}){return function(P,k,y={}){var g=k.name;if(!P)throw new e7(`type "${g}" must have a positive integer typeid pointer`);if(j9.hasOwnProperty(P)){if(y.Pd)return;throw new e7(`Cannot register type '${g}' twice`)}j9[P]=k,delete VY[P],FX.hasOwnProperty(P)&&(k=FX[P],delete FX[P],k.forEach((J0)=>J0()))}(q,L,_)}var y5=(q,L,_)=>{switch(L){case 1:return _?(P)=>s()[P>>>0]:(P)=>H0()[P>>>0];case 2:return _?(P)=>r()[P>>>1>>>0]:(P)=>z0()[P>>>1>>>0];case 4:return _?(P)=>i()[P>>>2>>>0]:(P)=>q0()[P>>>2>>>0];case 8:return _?(P)=>x[P>>>3]:(P)=>h[P>>>3];default:throw TypeError(`invalid integer width (${L}): ${q}`)}};function HG(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:function(P,k){if(typeof k!="bigint"&&typeof k!="number")throw k=k===null?"null":(P=typeof k)=="object"||P==="array"||P==="function"?k.toString():""+k,TypeError(`Cannot convert "${k}" to ${this.name}`);return typeof k=="number"&&(k=BigInt(k)),k},zd:f7,readValueFromPointer:y5(L,_,L.indexOf("u")==-1),Ad:null})}var f7=8;function qY(q,L,_,P){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(k){return!!k},toWireType:function(k,y){return y?_:P},zd:f7,readValueFromPointer:function(k){return this.fromWireType(H0()[k>>>0])},Ad:null})}var LX=[],V7=[];function rJ(q){9<(q>>>=0)&&--V7[q+1]==0&&(V7[q]=void 0,LX.push(q))}var l9=(q)=>{if(!q)throw new e7("Cannot use deleted val. handle = "+q);return V7[q]},q7=(q)=>{switch(q){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let L=LX.pop()||V7.length;return V7[L]=q,V7[L+1]=1,L}};function z6(q){return this.fromWireType(q0()[q>>>2>>>0])}var SJ={name:"emscripten::val",fromWireType:(q)=>{var L=l9(q);return rJ(q),L},toWireType:(q,L)=>q7(L),zd:f7,readValueFromPointer:z6,Ad:null};function j5(q){return p7(q>>>0,SJ)}var LQ=(q,L)=>{switch(L){case 4:return function(_){return this.fromWireType(Z0()[_>>>2>>>0])};case 8:return function(_){return this.fromWireType(I0()[_>>>3>>>0])};default:throw TypeError(`invalid float width (${L}): ${q}`)}};function P6(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:(P,k)=>k,zd:f7,readValueFromPointer:LQ(L,_),Ad:null})}function W4(q,L,_,P,k){if(q>>>=0,_>>>=0,L=R7(L>>>0),k===-1&&(k=4294967295),k=(J0)=>J0,P===0){var y=32-8*_;k=(J0)=>J0<<y>>>y}var g=L.includes("unsigned")?function(J0,W0){return W0>>>0}:function(J0,W0){return W0};p7(q,{name:L,fromWireType:k,toWireType:g,zd:f7,readValueFromPointer:y5(L,_,P!==0),Ad:null})}function DQ(q,L,_){function P(y){var g=q0()[y>>>2>>>0];return y=q0()[y+4>>>2>>>0],new k(s().buffer,y,g)}var k=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][L];p7(q>>>=0,{name:_=R7(_>>>0),fromWireType:P,zd:f7,readValueFromPointer:P},{Pd:!0})}function zG(q,L){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(_){for(var P,k=q0()[_>>>2>>>0],y=_+4,g=y,J0=0;J0<=k;++J0){var W0=y+J0;J0!=k&&H0()[W0>>>0]!=0||(g=t(g,W0-g),P===void 0?P=g:(P+="\x00",P+=g),g=W0+1)}return l7(_),P},toWireType:function(_,P){P instanceof ArrayBuffer&&(P=new Uint8Array(P));var k=typeof P=="string";if(!(k||P instanceof Uint8Array||P instanceof Uint8ClampedArray||P instanceof Int8Array))throw new e7("Cannot pass non-string to std::string");var y=k?v0(P):P.length,g=tJ(4+y+1),J0=g+4;if(q0()[g>>>2>>>0]=y,k)W8(P,J0,y+1);else if(k)for(k=0;k<y;++k){var W0=P.charCodeAt(k);if(255<W0)throw l7(g),new e7("String has UTF-16 code units that do not fit in 8 bits");H0()[J0+k>>>0]=W0}else for(k=0;k<y;++k)H0()[J0+k>>>0]=P[k];return _!==null&&_.push(l7,g),g},zd:f7,readValueFromPointer:z6,Ad(_){l7(_)}})}var bJ=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,yJ=(q,L)=>{for(var _=q>>1,P=_+L/2;!(_>=P)&&z0()[_>>>0];)++_;if(32<(_<<=1)-q&&bJ)return bJ.decode(H0().slice(q,_));for(_="",P=0;!(P>=L/2);++P){var k=r()[q+2*P>>>1>>>0];if(k==0)break;_+=String.fromCharCode(k)}return _},aJ=(q,L,_)=>{if(_??=2147483647,2>_)return 0;var P=L;_=(_-=2)<2*q.length?_/2:q.length;for(var k=0;k<_;++k){var y=q.charCodeAt(k);r()[L>>>1>>>0]=y,L+=2}return r()[L>>>1>>>0]=0,L-P},v5=(q)=>2*q.length,G4=(q,L)=>{for(var _=0,P="";!(_>=L/4);){var k=i()[q+4*_>>>2>>>0];if(k==0)break;++_,65536<=k?(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k)):P+=String.fromCharCode(k)}return P},NJ=(q,L,_)=>{if(L>>>=0,_??=2147483647,4>_)return 0;var P=L;_=P+_-4;for(var k=0;k<q.length;++k){var y=q.charCodeAt(k);if(55296<=y&&57343>=y&&(y=65536+((1023&y)<<10)|1023&q.charCodeAt(++k)),i()[L>>>2>>>0]=y,(L+=4)+4>_)break}return i()[L>>>2>>>0]=0,L-P},Z4=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);55296<=P&&57343>=P&&++_,L+=4}return L};function o(q,L,_){if(q>>>=0,L>>>=0,_=R7(_>>>=0),L===2)var P=yJ,k=aJ,y=v5,g=(J0)=>z0()[J0>>>1>>>0];else L===4&&(P=G4,k=NJ,y=Z4,g=(J0)=>q0()[J0>>>2>>>0]);p7(q,{name:_,fromWireType:(J0)=>{for(var W0,N0=q0()[J0>>>2>>>0],R0=J0+4,l0=0;l0<=N0;++l0){var q8=J0+4+l0*L;l0!=N0&&g(q8)!=0||(R0=P(R0,q8-R0),W0===void 0?W0=R0:(W0+="\x00",W0+=R0),R0=q8+L)}return l7(J0),W0},toWireType:(J0,W0)=>{if(typeof W0!="string")throw new e7(`Cannot pass non-string to C++ string type ${_}`);var N0=y(W0),R0=tJ(4+N0+L);return q0()[R0>>>2>>>0]=N0/L,k(W0,R0+4,N0+L),J0!==null&&J0.push(l7,R0),R0},zd:f7,readValueFromPointer:z6,Ad(J0){l7(J0)}})}function G0(q,L){p7(q>>>=0,{Qd:!0,name:L=R7(L>>>0),zd:0,fromWireType:()=>{},toWireType:()=>{}})}function L0(q){h5(q>>>0,!Z,1,!G,131072,!1),_0()}var y0=(q)=>{if(!n)try{if(q(),!(0<F8))try{H?g5(R):j0(R)}catch(L){L instanceof O9||L=="unwind"||F(0,L)}}catch(L){L instanceof O9||L=="unwind"||F(0,L)}};function P0(q){q>>>=0,typeof Atomics.ge=="function"&&(Atomics.ge(i(),q>>>2,q).value.then(z8),q+=128,Atomics.store(i(),q>>>2,1))}var z8=()=>{var q=sJ();q&&(P0(q),y0(c8))};function M8(q,L){(q>>>=0)==L>>>0?setTimeout(z8):H?postMessage({Ed:q,yd:"checkMailbox"}):(q=d0[q])&&q.postMessage({yd:"checkMailbox"})}var Z9=[];function L9(q,L,_,P,k){for(L>>>=0,P/=2,Z9.length=P,_=k>>>0>>>3,k=0;k<P;k++)Z9[k]=x[_+2*k]?x[_+2*k+1]:I0()[_+2*k+1>>>0];return(L?Z8[L]:vJ[q])(...Z9)}var I6=()=>{F8=0};function MQ(q){q>>>=0,H?postMessage({yd:"cleanupThread",ee:q}):k8(d0[q])}function s6(q){}var FJ=(q,L)=>{var _=j9[q];if(_===void 0)throw q=V4(q),_=R7(q),l7(q),new e7(`${L} has unknown type ${_}`);return _},f5=(q,L,_)=>{var P=[];return q=q.toWireType(P,_),P.length&&(q0()[L>>>2>>>0]=q7(P)),q};function RH(q,L,_){return L>>>=0,_>>>=0,q=l9(q>>>0),L=FJ(L,"emval::as"),f5(L,_,q)}function KG(q,L){return L>>>=0,q=l9(q>>>0),(L=FJ(L,"emval::as")).toWireType(null,q)}var jJ=(q)=>{try{q()}catch(L){$0(L)}},C7=0,R9=null,DX=0,K6=[],a8={},J6={},h6=0,MX=null,OQ=[];function sX(q){return function(L){if(!n){if(C7===0){var _=!1,P=!1;L((k=0)=>{if(!n&&(DX=k,_=!0,P)){C7=2,jJ(()=>pG(R9)),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.resume(),k=!1;try{var y=function(){var W0=i()[R9+8>>>2>>>0];return W0=V0[J6[W0]],--F8,W0()}()}catch(W0){y=W0,k=!0}var g=!1;if(!R9){var J0=MX;J0&&(MX=null,(k?J0.reject:J0.resolve)(y),g=!0)}if(k&&!g)throw y}}),P=!0,_||(C7=1,R9=function(){var k=tJ(65548),y=k+12;q0()[k>>>2>>>0]=y,q0()[k+4>>>2>>>0]=y+65536,y=K6[0];var g=a8[y];return g===void 0&&(g=h6++,a8[y]=g,J6[g]=y),y=g,i()[k+8>>>2>>>0]=y,k}(),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.pause(),jJ(()=>mG(R9)))}else C7===2?(C7=0,jJ(lG),l7(R9),R9=null,OQ.forEach(y0)):$0(`invalid state: ${C7}`);return DX}}((L)=>{q().then(L)})}function CH(q){return q>>>=0,sX(async()=>{var L=await l9(q);return q7(L)})}var OX=[];function X6(q,L,_,P){return _>>>=0,P>>>=0,(q=OX[q>>>0])(null,L=l9(L>>>0),_,P)}var $H={},AX=(q)=>{var L=$H[q];return L===void 0?R7(q):L};function k6(q,L,_,P,k){return _>>>=0,P>>>=0,k>>>=0,(q=OX[q>>>0])(L=l9(L>>>0),L[_=AX(_)],P,k)}var tX=()=>typeof globalThis=="object"?globalThis:Function("return this")();function BY(q){return(q>>>=0)==0?q7(tX()):(q=AX(q),q7(tX()[q]))}var SH=(q)=>{var L=OX.length;return OX.push(q),L},NY=(q,L)=>{for(var _=Array(q),P=0;P<q;++P)_[P]=FJ(q0()[L+4*P>>>2>>>0],"parameter "+P);return _},FY=(q,L)=>Object.defineProperty(L,"name",{value:q});function G1(q,L,_){var P=(L=NY(q,L>>>0)).shift();q--;var k=`return function (obj, func, destructorsRef, args) {
14
+ `))}return y}finally{Y.Cd=null}};Y._OrtCreateSession=q(Y._OrtCreateSession,()=>Y._OrtCreateSession,(_)=>Y._OrtCreateSession=_),Y._OrtRun=L(q(Y._OrtRun,()=>Y._OrtRun,(_)=>Y._OrtRun=_)),Y._OrtRunWithBinding=L(q(Y._OrtRunWithBinding,()=>Y._OrtRunWithBinding,(_)=>Y._OrtRunWithBinding=_)),Y._OrtBindInput=q(Y._OrtBindInput,()=>Y._OrtBindInput,(_)=>Y._OrtBindInput=_),U=void 0};Y.jsepInit=(q,L)=>{if(U?.(),q==="webgpu"){[Y.Dd,Y.Rd,Y.Vd,Y.Hd,Y.Ud,Y.hc,Y.Wd,Y.Zd,Y.Sd,Y.Td,Y.Xd]=L;let _=Y.Dd;Y.jsepRegisterBuffer=(P,k,y,g)=>_.registerBuffer(P,k,y,g),Y.jsepGetBuffer=(P)=>_.getBuffer(P),Y.jsepCreateDownloader=(P,k,y)=>_.createDownloader(P,k,y),Y.jsepOnCreateSession=(P)=>{_.onCreateSession(P)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.$d=(P,k)=>{_.upload(P,k)}}else if(q==="webnn"){[Y.Dd,Y.Yd,Y.Id,Y.jsepEnsureTensor,Y.Jd,Y.jsepDownloadTensor]=L,Y.jsepReleaseTensorId=Y.Id,Y.jsepUploadTensor=Y.Jd;let _=Y.Dd;Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.jsepOnRunEnd=_.onRunEnd.bind(_),Y.jsepRegisterMLContext=(P,k)=>{_.registerMLContext(P,k)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepCreateMLTensorDownloader=(P,k)=>_.createMLTensorDownloader(P,k),Y.jsepRegisterMLTensor=(P,k,y,g)=>_.registerMLTensor(P,k,y,g),Y.jsepCreateMLContext=(P)=>_.createMLContext(P),Y.jsepRegisterMLConstant=(P,k,y,g,J0)=>_.registerMLConstant(P,k,y,g,J0,Y.Bd),Y.jsepRegisterGraphInput=_.registerGraphInput.bind(_),Y.jsepIsGraphInput=_.isGraphInput.bind(_),Y.jsepCreateTemporaryTensor=_.createTemporaryTensor.bind(_)}};var V,B,N=Object.assign({},Y),F=(q,L)=>{throw L},M="";(G||Z)&&(Z?M=self.location.href:typeof document<"u"&&document.currentScript&&(M=document.currentScript.src),TE&&(M=TE),M=M.startsWith("blob:")?"":M.slice(0,M.replace(/[?#].*/,"").lastIndexOf("/")+1),Z&&(B=(q)=>{var L=new XMLHttpRequest;return L.open("GET",q,!1),L.responseType="arraybuffer",L.send(null),new Uint8Array(L.response)}),V=async(q)=>{if(e(q))return new Promise((_,P)=>{var k=new XMLHttpRequest;k.open("GET",q,!0),k.responseType="arraybuffer",k.onload=()=>{k.status==200||k.status==0&&k.response?_(k.response):P(k.status)},k.onerror=P,k.send(null)});var L=await fetch(q,{credentials:"same-origin"});if(L.ok)return L.arrayBuffer();throw Error(L.status+" : "+L.url)});var O=console.log.bind(console),E=console.error.bind(console),w=O,A=E;Object.assign(Y,N),N=null;var I,T,R,$,C,j,f,m,d,a,x,h,l,v=Y.wasmBinary,n=!1,e=(q)=>q.startsWith("file://");function s(){return I.buffer!=$.buffer&&D8(),$}function H0(){return I.buffer!=$.buffer&&D8(),C}function r(){return I.buffer!=$.buffer&&D8(),j}function z0(){return I.buffer!=$.buffer&&D8(),f}function i(){return I.buffer!=$.buffer&&D8(),m}function q0(){return I.buffer!=$.buffer&&D8(),d}function Z0(){return I.buffer!=$.buffer&&D8(),a}function I0(){return I.buffer!=$.buffer&&D8(),l}if(H){let q=function(L){try{var _=L.data,P=_.yd;if(P==="load"){let k=[];self.onmessage=(y)=>k.push(y),self.startWorker=()=>{postMessage({yd:"loaded"});for(let y of k)q(y);self.onmessage=q};for(let y of _.Od)Y[y]&&!Y[y].proxy||(Y[y]=(...g)=>{postMessage({yd:"callHandler",Nd:y,args:g})},y=="print"&&(w=Y[y]),y=="printErr"&&(A=Y[y]));I=_.he,D8(),s0(_.ie)}else if(P==="run"){U0(_.xd),h5(_.xd,0,0,1,0,0),_0(),P0(_.xd),e0||(PG(),e0=!0);try{o0(_.de,_.Fd)}catch(k){if(k!="unwind")throw k}}else _.target!=="setimmediate"&&(P==="checkMailbox"?e0&&z8():P&&(A(`worker: received unknown command ${P}`),A(_)))}catch(k){throw IG(),k}};var a0=q,s0,e0=!1;A=function(...L){L=L.join(" "),console.error(L)},self.alert=function(...L){postMessage({yd:"alert",text:L.join(" "),fe:sJ()})},self.onunhandledrejection=(L)=>{throw L.reason||L},self.onmessage=q}function D8(){var q=I.buffer;Y.HEAP8=$=new Int8Array(q),Y.HEAP16=j=new Int16Array(q),Y.HEAPU8=C=new Uint8Array(q),Y.HEAPU16=f=new Uint16Array(q),Y.HEAP32=m=new Int32Array(q),Y.HEAPU32=d=new Uint32Array(q),Y.HEAPF32=a=new Float32Array(q),Y.HEAPF64=l=new Float64Array(q),Y.HEAP64=x=new BigInt64Array(q),Y.HEAPU64=h=new BigUint64Array(q)}function s8(){H?startWorker(Y):V0.Bb()}H||(I=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),D8());var w8,N8=0,C0=null;function A0(){if(--N8==0&&C0){var q=C0;C0=null,q()}}function $0(q){throw A(q="Aborted("+q+")"),n=!0,q=new WebAssembly.RuntimeError(q+". Build with -sASSERTIONS for more info."),Q(q),q}function Q8(){return{a:{Ta:b8,Va:f8,W:J9,la:a7,b:X9,u:d8,R:O0,Za:K8,d:S8,pb:x9,g:v7,T:M0,Ga:E0,lb:g8,nb:t8,Ha:v8,Ea:W9,wb:T9,Da:e9,pa:J7,mb:FQ,jb:aX,Fa:BJ,kb:oJ,Ma:Y4,za:HG,eb:qY,cb:j5,ya:P6,V:W4,N:DQ,db:zG,ma:o,fb:G0,zb:D0,hb:M8,qb:L9,ab:I6,Aa:MQ,yb:P0,Ja:s6,S:RH,Wa:KG,$:CH,G:X6,E:k6,m:rJ,H:BY,B:G1,X:LJ,J:_X,v:UG,O:Z1,D:bH,t:H1,A:VG,z:qG,w:yH,r:jH,tb:LY,ub:DY,vb:AQ,rb:NG,sb:FG,bb:MY,Oa:vH,La:MG,y:EX,ja:g6,Ba:OG,Ka:DG,qa:OY,Ia:_Q,ib:z4,U:LG,fa:fH,Sa:z1,gb:xH,Qa:hH,Pa:K4,Ab:PX,Ca:wG,ob:j0,aa:U4,oa:X5,xb:AY,na:EG,$a:iH,ia:IX,sa:nH,ga:rG,da:M1,ua:sG,p:cH,e:mH,c:cG,ea:L1,f:U1,n:A4,k:fY,Y:vY,ka:l5,j:nG,wa:F1,Ra:rH,ca:E1,Ua:Y7,P:D1,K:pH,_:w1,Q:B1,Z:JX,x:iG,l:K1,va:_1,i:dG,h:uH,ra:tG,ta:oH,o:V6,q:lH,s:oG,I:CQ,C:q1,L:dH,xa:aG,_a:N1,F:P1,Ya:O1,ba:C6,M:V1,Xa:A1,ha:Q5,a:I,Na:J8}}}var Z8={1319426:()=>typeof wasmOffsetConverter<"u",1319483:(q,L,_,P,k)=>{if(Y===void 0||!Y.Bd)return 1;if((q=t(Number(q>>>0))).startsWith("./")&&(q=q.substring(2)),!(q=Y.Bd.get(q)))return 2;if(L=Number(L>>>0),_=Number(_>>>0),P=Number(P>>>0),L+_>q.byteLength)return 3;try{let y=q.subarray(L,L+_);switch(k){case 0:H0().set(y,P>>>0);break;case 1:Y.$d(P,y);break;default:return 4}return 0}catch{return 4}},1320198:(q,L,_)=>{Y.Jd(q,H0().subarray(L>>>0,L+_>>>0))},1320261:()=>Y.Yd(),1320302:(q)=>{Y.Id(q)},1320338:()=>{Y.Sd()},1320369:()=>{Y.Td()},1320398:()=>{Y.Xd()},1320423:(q)=>Y.Rd(q),1320456:(q)=>Y.Vd(q),1320488:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_),!0)},1320551:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_))},1320608:(q)=>{Y.hc("Abs",q,void 0)},1320659:(q)=>{Y.hc("Neg",q,void 0)},1320710:(q)=>{Y.hc("Floor",q,void 0)},1320763:(q)=>{Y.hc("Ceil",q,void 0)},1320815:(q)=>{Y.hc("Reciprocal",q,void 0)},1320873:(q)=>{Y.hc("Sqrt",q,void 0)},1320925:(q)=>{Y.hc("Exp",q,void 0)},1320976:(q)=>{Y.hc("Erf",q,void 0)},1321027:(q)=>{Y.hc("Sigmoid",q,void 0)},1321082:(q,L,_)=>{Y.hc("HardSigmoid",q,{alpha:L,beta:_})},1321161:(q)=>{Y.hc("Log",q,void 0)},1321212:(q)=>{Y.hc("Sin",q,void 0)},1321263:(q)=>{Y.hc("Cos",q,void 0)},1321314:(q)=>{Y.hc("Tan",q,void 0)},1321365:(q)=>{Y.hc("Asin",q,void 0)},1321417:(q)=>{Y.hc("Acos",q,void 0)},1321469:(q)=>{Y.hc("Atan",q,void 0)},1321521:(q)=>{Y.hc("Sinh",q,void 0)},1321573:(q)=>{Y.hc("Cosh",q,void 0)},1321625:(q)=>{Y.hc("Asinh",q,void 0)},1321678:(q)=>{Y.hc("Acosh",q,void 0)},1321731:(q)=>{Y.hc("Atanh",q,void 0)},1321784:(q)=>{Y.hc("Tanh",q,void 0)},1321836:(q)=>{Y.hc("Not",q,void 0)},1321887:(q,L,_)=>{Y.hc("Clip",q,{min:L,max:_})},1321956:(q)=>{Y.hc("Clip",q,void 0)},1322008:(q,L)=>{Y.hc("Elu",q,{alpha:L})},1322066:(q)=>{Y.hc("Gelu",q,void 0)},1322118:(q)=>{Y.hc("Relu",q,void 0)},1322170:(q,L)=>{Y.hc("LeakyRelu",q,{alpha:L})},1322234:(q,L)=>{Y.hc("ThresholdedRelu",q,{alpha:L})},1322304:(q,L)=>{Y.hc("Cast",q,{to:L})},1322362:(q)=>{Y.hc("Add",q,void 0)},1322413:(q)=>{Y.hc("Sub",q,void 0)},1322464:(q)=>{Y.hc("Mul",q,void 0)},1322515:(q)=>{Y.hc("Div",q,void 0)},1322566:(q)=>{Y.hc("Pow",q,void 0)},1322617:(q)=>{Y.hc("Equal",q,void 0)},1322670:(q)=>{Y.hc("Greater",q,void 0)},1322725:(q)=>{Y.hc("GreaterOrEqual",q,void 0)},1322787:(q)=>{Y.hc("Less",q,void 0)},1322839:(q)=>{Y.hc("LessOrEqual",q,void 0)},1322898:(q,L,_,P,k)=>{Y.hc("ReduceMean",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323073:(q,L,_,P,k)=>{Y.hc("ReduceMax",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323247:(q,L,_,P,k)=>{Y.hc("ReduceMin",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323421:(q,L,_,P,k)=>{Y.hc("ReduceProd",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323596:(q,L,_,P,k)=>{Y.hc("ReduceSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323770:(q,L,_,P,k)=>{Y.hc("ReduceL1",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323943:(q,L,_,P,k)=>{Y.hc("ReduceL2",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324116:(q,L,_,P,k)=>{Y.hc("ReduceLogSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324293:(q,L,_,P,k)=>{Y.hc("ReduceSumSquare",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324473:(q,L,_,P,k)=>{Y.hc("ReduceLogSumExp",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324653:(q)=>{Y.hc("Where",q,void 0)},1324706:(q,L,_)=>{Y.hc("Transpose",q,{perm:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[]})},1324830:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1324963:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1325096:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1325529:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1326190:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1326623:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1327284:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327375:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1327854:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327945:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328424:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1328511:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328986:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1329073:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1329548:(q,L,_,P,k)=>{Y.hc("Gemm",q,{alpha:L,beta:_,transA:P,transB:k})},1329652:(q)=>{Y.hc("MatMul",q,void 0)},1329706:(q,L,_,P)=>{Y.hc("ArgMax",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329814:(q,L,_,P)=>{Y.hc("ArgMin",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329922:(q,L)=>{Y.hc("Softmax",q,{axis:L})},1329985:(q,L)=>{Y.hc("Concat",q,{axis:L})},1330045:(q,L,_,P,k)=>{Y.hc("Split",q,{axis:L,numOutputs:_,splitSizes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1330201:(q)=>{Y.hc("Expand",q,void 0)},1330255:(q,L)=>{Y.hc("Gather",q,{axis:Number(L)})},1330326:(q,L)=>{Y.hc("GatherElements",q,{axis:Number(L)})},1330405:(q,L)=>{Y.hc("GatherND",q,{batch_dims:Number(L)})},1330484:(q,L,_,P,k,y,g,J0,W0,N0,R0)=>{Y.hc("Resize",q,{antialias:L,axes:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],coordinateTransformMode:t(k),cubicCoeffA:y,excludeOutside:g,extrapolationValue:J0,keepAspectRatioPolicy:t(W0),mode:t(N0),nearestMode:t(R0)})},1330846:(q,L,_,P,k,y,g)=>{Y.hc("Slice",q,{starts:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[],ends:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[],axes:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[]})},1331110:(q)=>{Y.hc("Tile",q,void 0)},1331162:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331276:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331390:(q)=>{Y.hc("Range",q,void 0)},1331443:(q,L)=>{Y.hc("Einsum",q,{equation:t(L)})},1331524:(q,L,_,P,k)=>{Y.hc("Pad",q,{mode:L,value:_,pads:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1331667:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1331836:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1332005:(q,L,_)=>{Y.hc("CumSum",q,{exclusive:Number(L),reverse:Number(_)})},1332102:(q,L,_)=>{Y.hc("DequantizeLinear",q,{axis:L,blockSize:_})},1332192:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332362:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332532:(q,L)=>{Y.hc("ScatterND",q,{reduction:t(L)})},1332617:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("Attention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y,qkvHiddenSizes:g?Array.from(i().subarray(Number(J0)>>>0,Number(J0)+g>>>0)):[],pastPresentShareBuffer:!!W0})},1332889:(q)=>{Y.hc("BiasAdd",q,void 0)},1332944:(q)=>{Y.hc("BiasSplitGelu",q,void 0)},1333005:(q)=>{Y.hc("FastGelu",q,void 0)},1333061:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7,_J)=>{Y.hc("Conv",q,{format:l0?"NHWC":"NCHW",auto_pad:L,dilations:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],group:k,kernel_shape:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],pads:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],strides:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],w_is_const:()=>!!s()[Number(q8)>>>0],activation:t(Q9),activation_params:B7?Array.from(Z0().subarray(Number(B7)>>>0,Number(_J)>>>0)):[]})},1333645:(q)=>{Y.hc("Gelu",q,void 0)},1333697:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("GroupQueryAttention",q,{numHeads:L,kvNumHeads:_,scale:P,softcap:k,doRotary:y,rotaryInterleaved:g,smoothSoftmax:J0,localWindowSize:W0})},1333914:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334025:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334136:(q,L,_,P,k,y)=>{Y.hc("MatMulNBits",q,{k:L,n:_,accuracyLevel:P,bits:k,blockSize:y})},1334263:(q,L,_,P,k,y)=>{Y.hc("MultiHeadAttention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y})},1334422:(q,L)=>{Y.hc("QuickGelu",q,{alpha:L})},1334486:(q,L,_,P,k)=>{Y.hc("RotaryEmbedding",q,{interleaved:!!L,numHeads:_,rotaryEmbeddingDim:P,scale:k})},1334625:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334727:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334829:(q,L,_,P)=>{Y.hc("GatherBlockQuantized",q,{gatherAxis:L,quantizeAxis:_,blockSize:P})},1334950:(q)=>{Y.Wd(q)},1334984:(q,L)=>Y.Zd(Number(q),Number(L),Y.Cd.be,Y.Cd.errors)};function f8(q,L,_){return sX(async()=>{await Y.Ud(Number(q),Number(L),Number(_))})}function b8(){return typeof wasmOffsetConverter<"u"}class O9{name="ExitStatus";constructor(q){this.message=`Program terminated with exit(${q})`,this.status=q}}var h0=(q)=>{q.terminate(),q.onmessage=()=>{}},C8=[],A9=(q)=>{t0.length==0&&(P8(),X8(t0[0]));var L=t0.pop();if(!L)return 6;H8.push(L),d0[q.xd]=L,L.xd=q.xd;var _={yd:"run",de:q.ce,Fd:q.Fd,xd:q.xd};return L.postMessage(_,q.Ld),0},F8=0,B0=(q,L,..._)=>{for(var P=2*_.length,k=G8(),y=q4(8*P),g=y>>>3,J0=0;J0<_.length;J0++){var W0=_[J0];typeof W0=="bigint"?(x[g+2*J0]=1n,x[g+2*J0+1]=W0):(x[g+2*J0]=0n,I0()[g+2*J0+1>>>0]=W0)}return q=kG(q,0,P,y,L),Y8(k),q};function J8(q){if(H)return B0(0,1,q);if(R=q,!(0<F8)){for(var L of H8)h0(L);for(L of t0)h0(L);t0=[],H8=[],d0={},n=!0}F(0,new O9(q))}function r0(q){if(H)return B0(1,0,q);j0(q)}var j0=(q)=>{if(R=q,H)throw r0(q),"unwind";J8(q)},t0=[],H8=[],p0=[],d0={},k8=(q)=>{var L=q.xd;delete d0[L],t0.push(q),H8.splice(H8.indexOf(q),1),q.xd=0,wY(L)};function _0(){p0.forEach((q)=>q())}var X8=(q)=>new Promise((L)=>{q.onmessage=(k)=>{var y=(k=k.data).yd;if(k.Ed&&k.Ed!=sJ()){var g=d0[k.Ed];g?g.postMessage(k,k.Ld):A(`Internal error! Worker sent a message "${y}" to target pthread ${k.Ed}, but that thread no longer exists!`)}else y==="checkMailbox"?z8():y==="spawnThread"?A9(k):y==="cleanupThread"?k8(d0[k.ee]):y==="loaded"?(q.loaded=!0,L(q)):y==="alert"?alert(`Thread ${k.fe}: ${k.text}`):k.target==="setimmediate"?q.postMessage(k):y==="callHandler"?Y[k.Nd](...k.args):y&&A(`worker sent an unknown command ${y}`)},q.onerror=(k)=>{throw A(`worker sent an error! ${k.filename}:${k.lineno}: ${k.message}`),k};var _,P=[];for(_ of[])Y.propertyIsEnumerable(_)&&P.push(_);q.postMessage({yd:"load",Od:P,he:I,ie:T})});function P8(){var q=new Worker(import.meta.url.startsWith("file:")?new URL("ort.webgpu.bundle.min.mjs",import.meta.url):new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});t0.push(q)}var U0=(q)=>{D8();var L=q0()[q+52>>>2>>>0];q=q0()[q+56>>>2>>>0],IQ(L,L-q),Y8(L)},o0=(q,L)=>{F8=0,q=kQ(q,L),0<F8?R=q:g5(q)},R8=[];function J9(q){var L=new F9(q>>>=0);if(s()[L.wd+12>>>0]==0){var _=1;s()[L.wd+12>>>0]=_}return _=0,s()[L.wd+13>>>0]=_,R8.push(L),Q6(q),Y6(q)}var i0=0,a7=()=>{T0(0,0);var q=R8.pop();TG(q.Gd),i0=0};class F9{constructor(q){this.Gd=q,this.wd=q-24}}function v7(q){throw i0||=q>>>0,i0}var I8=(q)=>{var L=i0;if(!L)return eJ(0),0;var _=new F9(L);q0()[_.wd+16>>>2>>>0]=L;var P=q0()[_.wd+4>>>2>>>0];if(!P)return eJ(0),L;for(var k of q){if(k===0||k===P)break;if(m5(k,P,_.wd+16))return eJ(k),L}return eJ(P),L};function X9(){return I8([])}function d8(q){return I8([q>>>0])}function O0(q,L){return I8([q>>>0,L>>>0])}var K8=()=>{var q=R8.pop();q||$0("no exception to throw");var L=q.Gd;if(s()[q.wd+13>>>0]==0){R8.push(q);var _=1;s()[q.wd+13>>>0]=_,_=0,s()[q.wd+12>>>0]=_}throw i0=L};function S8(q,L,_){var P=new F9(q>>>=0);throw L>>>=0,_>>>=0,q0()[P.wd+16>>>2>>>0]=0,q0()[P.wd+4>>>2>>>0]=L,q0()[P.wd+8>>>2>>>0]=_,i0=q}function V9(q,L,_,P){return H?B0(2,1,q,L,_,P):x9(q,L,_,P)}function x9(q,L,_,P){if(q>>>=0,_>>>=0,P>>>=0,K===void 0)return 6;var k=[];return H&&k.length===0?V9(q,L>>>=0,_,P):(q={ce:_,xd:q,Fd:P,Ld:k},H?(q.yd="spawnThread",postMessage(q,k),0):A9(q))}var i9=typeof TextDecoder<"u"?new TextDecoder:void 0,h9=(q,L=0,_=NaN)=>{var P=(L>>>=0)+_;for(_=L;q[_]&&!(_>=P);)++_;if(16<_-L&&q.buffer&&i9)return i9.decode(q.buffer instanceof ArrayBuffer?q.subarray(L,_):q.slice(L,_));for(P="";L<_;){var k=q[L++];if(128&k){var y=63&q[L++];if((224&k)==192)P+=String.fromCharCode((31&k)<<6|y);else{var g=63&q[L++];65536>(k=(240&k)==224?(15&k)<<12|y<<6|g:(7&k)<<18|y<<12|g<<6|63&q[L++])?P+=String.fromCharCode(k):(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k))}}else P+=String.fromCharCode(k)}return P},t=(q,L)=>(q>>>=0)?h9(H0(),q,L):"";function M0(q,L,_){return H?B0(3,1,q,L,_):0}function E0(q,L){if(H)return B0(4,1,q,L)}var v0=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);127>=P?L++:2047>=P?L+=2:55296<=P&&57343>=P?(L+=4,++_):L+=3}return L},W8=(q,L,_)=>{var P=H0();if(L>>>=0,0<_){var k=L;_=L+_-1;for(var y=0;y<q.length;++y){var g=q.charCodeAt(y);if(55296<=g&&57343>=g&&(g=65536+((1023&g)<<10)|1023&q.charCodeAt(++y)),127>=g){if(L>=_)break;P[L++>>>0]=g}else{if(2047>=g){if(L+1>=_)break;P[L++>>>0]=192|g>>6}else{if(65535>=g){if(L+2>=_)break;P[L++>>>0]=224|g>>12}else{if(L+3>=_)break;P[L++>>>0]=240|g>>18,P[L++>>>0]=128|g>>12&63}P[L++>>>0]=128|g>>6&63}P[L++>>>0]=128|63&g}}P[L>>>0]=0,q=L-k}else q=0;return q};function g8(q,L){if(H)return B0(5,1,q,L)}function t8(q,L,_){if(H)return B0(6,1,q,L,_)}function v8(q,L,_){return H?B0(7,1,q,L,_):0}function W9(q,L){if(H)return B0(8,1,q,L)}function T9(q,L,_){if(H)return B0(9,1,q,L,_)}function e9(q,L,_,P){if(H)return B0(10,1,q,L,_,P)}function J7(q,L,_,P){if(H)return B0(11,1,q,L,_,P)}function FQ(q,L,_,P){if(H)return B0(12,1,q,L,_,P)}function aX(q){if(H)return B0(13,1,q)}function BJ(q,L){if(H)return B0(14,1,q,L)}function oJ(q,L,_){if(H)return B0(15,1,q,L,_)}var nJ,e7,Y4=()=>$0(""),R7=(q)=>{for(var L="";H0()[q>>>0];)L+=nJ[H0()[q++>>>0]];return L},FX={},j9={},VY={};function p7(q,L,_={}){return function(P,k,y={}){var g=k.name;if(!P)throw new e7(`type "${g}" must have a positive integer typeid pointer`);if(j9.hasOwnProperty(P)){if(y.Pd)return;throw new e7(`Cannot register type '${g}' twice`)}j9[P]=k,delete VY[P],FX.hasOwnProperty(P)&&(k=FX[P],delete FX[P],k.forEach((J0)=>J0()))}(q,L,_)}var y5=(q,L,_)=>{switch(L){case 1:return _?(P)=>s()[P>>>0]:(P)=>H0()[P>>>0];case 2:return _?(P)=>r()[P>>>1>>>0]:(P)=>z0()[P>>>1>>>0];case 4:return _?(P)=>i()[P>>>2>>>0]:(P)=>q0()[P>>>2>>>0];case 8:return _?(P)=>x[P>>>3]:(P)=>h[P>>>3];default:throw TypeError(`invalid integer width (${L}): ${q}`)}};function HG(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:function(P,k){if(typeof k!="bigint"&&typeof k!="number")throw k=k===null?"null":(P=typeof k)=="object"||P==="array"||P==="function"?k.toString():""+k,TypeError(`Cannot convert "${k}" to ${this.name}`);return typeof k=="number"&&(k=BigInt(k)),k},zd:f7,readValueFromPointer:y5(L,_,L.indexOf("u")==-1),Ad:null})}var f7=8;function qY(q,L,_,P){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(k){return!!k},toWireType:function(k,y){return y?_:P},zd:f7,readValueFromPointer:function(k){return this.fromWireType(H0()[k>>>0])},Ad:null})}var LX=[],V7=[];function rJ(q){9<(q>>>=0)&&--V7[q+1]==0&&(V7[q]=void 0,LX.push(q))}var l9=(q)=>{if(!q)throw new e7("Cannot use deleted val. handle = "+q);return V7[q]},q7=(q)=>{switch(q){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let L=LX.pop()||V7.length;return V7[L]=q,V7[L+1]=1,L}};function z6(q){return this.fromWireType(q0()[q>>>2>>>0])}var SJ={name:"emscripten::val",fromWireType:(q)=>{var L=l9(q);return rJ(q),L},toWireType:(q,L)=>q7(L),zd:f7,readValueFromPointer:z6,Ad:null};function j5(q){return p7(q>>>0,SJ)}var LQ=(q,L)=>{switch(L){case 4:return function(_){return this.fromWireType(Z0()[_>>>2>>>0])};case 8:return function(_){return this.fromWireType(I0()[_>>>3>>>0])};default:throw TypeError(`invalid float width (${L}): ${q}`)}};function P6(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:(P,k)=>k,zd:f7,readValueFromPointer:LQ(L,_),Ad:null})}function W4(q,L,_,P,k){if(q>>>=0,_>>>=0,L=R7(L>>>0),k===-1&&(k=4294967295),k=(J0)=>J0,P===0){var y=32-8*_;k=(J0)=>J0<<y>>>y}var g=L.includes("unsigned")?function(J0,W0){return W0>>>0}:function(J0,W0){return W0};p7(q,{name:L,fromWireType:k,toWireType:g,zd:f7,readValueFromPointer:y5(L,_,P!==0),Ad:null})}function DQ(q,L,_){function P(y){var g=q0()[y>>>2>>>0];return y=q0()[y+4>>>2>>>0],new k(s().buffer,y,g)}var k=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][L];p7(q>>>=0,{name:_=R7(_>>>0),fromWireType:P,zd:f7,readValueFromPointer:P},{Pd:!0})}function zG(q,L){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(_){for(var P,k=q0()[_>>>2>>>0],y=_+4,g=y,J0=0;J0<=k;++J0){var W0=y+J0;J0!=k&&H0()[W0>>>0]!=0||(g=t(g,W0-g),P===void 0?P=g:(P+="\x00",P+=g),g=W0+1)}return l7(_),P},toWireType:function(_,P){P instanceof ArrayBuffer&&(P=new Uint8Array(P));var k=typeof P=="string";if(!(k||P instanceof Uint8Array||P instanceof Uint8ClampedArray||P instanceof Int8Array))throw new e7("Cannot pass non-string to std::string");var y=k?v0(P):P.length,g=tJ(4+y+1),J0=g+4;if(q0()[g>>>2>>>0]=y,k)W8(P,J0,y+1);else if(k)for(k=0;k<y;++k){var W0=P.charCodeAt(k);if(255<W0)throw l7(g),new e7("String has UTF-16 code units that do not fit in 8 bits");H0()[J0+k>>>0]=W0}else for(k=0;k<y;++k)H0()[J0+k>>>0]=P[k];return _!==null&&_.push(l7,g),g},zd:f7,readValueFromPointer:z6,Ad(_){l7(_)}})}var bJ=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,yJ=(q,L)=>{for(var _=q>>1,P=_+L/2;!(_>=P)&&z0()[_>>>0];)++_;if(32<(_<<=1)-q&&bJ)return bJ.decode(H0().slice(q,_));for(_="",P=0;!(P>=L/2);++P){var k=r()[q+2*P>>>1>>>0];if(k==0)break;_+=String.fromCharCode(k)}return _},aJ=(q,L,_)=>{if(_??=2147483647,2>_)return 0;var P=L;_=(_-=2)<2*q.length?_/2:q.length;for(var k=0;k<_;++k){var y=q.charCodeAt(k);r()[L>>>1>>>0]=y,L+=2}return r()[L>>>1>>>0]=0,L-P},v5=(q)=>2*q.length,G4=(q,L)=>{for(var _=0,P="";!(_>=L/4);){var k=i()[q+4*_>>>2>>>0];if(k==0)break;++_,65536<=k?(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k)):P+=String.fromCharCode(k)}return P},NJ=(q,L,_)=>{if(L>>>=0,_??=2147483647,4>_)return 0;var P=L;_=P+_-4;for(var k=0;k<q.length;++k){var y=q.charCodeAt(k);if(55296<=y&&57343>=y&&(y=65536+((1023&y)<<10)|1023&q.charCodeAt(++k)),i()[L>>>2>>>0]=y,(L+=4)+4>_)break}return i()[L>>>2>>>0]=0,L-P},Z4=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);55296<=P&&57343>=P&&++_,L+=4}return L};function o(q,L,_){if(q>>>=0,L>>>=0,_=R7(_>>>=0),L===2)var P=yJ,k=aJ,y=v5,g=(J0)=>z0()[J0>>>1>>>0];else L===4&&(P=G4,k=NJ,y=Z4,g=(J0)=>q0()[J0>>>2>>>0]);p7(q,{name:_,fromWireType:(J0)=>{for(var W0,N0=q0()[J0>>>2>>>0],R0=J0+4,l0=0;l0<=N0;++l0){var q8=J0+4+l0*L;l0!=N0&&g(q8)!=0||(R0=P(R0,q8-R0),W0===void 0?W0=R0:(W0+="\x00",W0+=R0),R0=q8+L)}return l7(J0),W0},toWireType:(J0,W0)=>{if(typeof W0!="string")throw new e7(`Cannot pass non-string to C++ string type ${_}`);var N0=y(W0),R0=tJ(4+N0+L);return q0()[R0>>>2>>>0]=N0/L,k(W0,R0+4,N0+L),J0!==null&&J0.push(l7,R0),R0},zd:f7,readValueFromPointer:z6,Ad(J0){l7(J0)}})}function G0(q,L){p7(q>>>=0,{Qd:!0,name:L=R7(L>>>0),zd:0,fromWireType:()=>{},toWireType:()=>{}})}function D0(q){h5(q>>>0,!Z,1,!G,131072,!1),_0()}var y0=(q)=>{if(!n)try{if(q(),!(0<F8))try{H?g5(R):j0(R)}catch(L){L instanceof O9||L=="unwind"||F(0,L)}}catch(L){L instanceof O9||L=="unwind"||F(0,L)}};function P0(q){q>>>=0,typeof Atomics.ge=="function"&&(Atomics.ge(i(),q>>>2,q).value.then(z8),q+=128,Atomics.store(i(),q>>>2,1))}var z8=()=>{var q=sJ();q&&(P0(q),y0(c8))};function M8(q,L){(q>>>=0)==L>>>0?setTimeout(z8):H?postMessage({Ed:q,yd:"checkMailbox"}):(q=d0[q])&&q.postMessage({yd:"checkMailbox"})}var Z9=[];function L9(q,L,_,P,k){for(L>>>=0,P/=2,Z9.length=P,_=k>>>0>>>3,k=0;k<P;k++)Z9[k]=x[_+2*k]?x[_+2*k+1]:I0()[_+2*k+1>>>0];return(L?Z8[L]:vJ[q])(...Z9)}var I6=()=>{F8=0};function MQ(q){q>>>=0,H?postMessage({yd:"cleanupThread",ee:q}):k8(d0[q])}function s6(q){}var FJ=(q,L)=>{var _=j9[q];if(_===void 0)throw q=V4(q),_=R7(q),l7(q),new e7(`${L} has unknown type ${_}`);return _},f5=(q,L,_)=>{var P=[];return q=q.toWireType(P,_),P.length&&(q0()[L>>>2>>>0]=q7(P)),q};function RH(q,L,_){return L>>>=0,_>>>=0,q=l9(q>>>0),L=FJ(L,"emval::as"),f5(L,_,q)}function KG(q,L){return L>>>=0,q=l9(q>>>0),(L=FJ(L,"emval::as")).toWireType(null,q)}var jJ=(q)=>{try{q()}catch(L){$0(L)}},C7=0,R9=null,DX=0,K6=[],a8={},J6={},h6=0,MX=null,OQ=[];function sX(q){return function(L){if(!n){if(C7===0){var _=!1,P=!1;L((k=0)=>{if(!n&&(DX=k,_=!0,P)){C7=2,jJ(()=>pG(R9)),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.resume(),k=!1;try{var y=function(){var W0=i()[R9+8>>>2>>>0];return W0=V0[J6[W0]],--F8,W0()}()}catch(W0){y=W0,k=!0}var g=!1;if(!R9){var J0=MX;J0&&(MX=null,(k?J0.reject:J0.resolve)(y),g=!0)}if(k&&!g)throw y}}),P=!0,_||(C7=1,R9=function(){var k=tJ(65548),y=k+12;q0()[k>>>2>>>0]=y,q0()[k+4>>>2>>>0]=y+65536,y=K6[0];var g=a8[y];return g===void 0&&(g=h6++,a8[y]=g,J6[g]=y),y=g,i()[k+8>>>2>>>0]=y,k}(),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.pause(),jJ(()=>mG(R9)))}else C7===2?(C7=0,jJ(lG),l7(R9),R9=null,OQ.forEach(y0)):$0(`invalid state: ${C7}`);return DX}}((L)=>{q().then(L)})}function CH(q){return q>>>=0,sX(async()=>{var L=await l9(q);return q7(L)})}var OX=[];function X6(q,L,_,P){return _>>>=0,P>>>=0,(q=OX[q>>>0])(null,L=l9(L>>>0),_,P)}var $H={},AX=(q)=>{var L=$H[q];return L===void 0?R7(q):L};function k6(q,L,_,P,k){return _>>>=0,P>>>=0,k>>>=0,(q=OX[q>>>0])(L=l9(L>>>0),L[_=AX(_)],P,k)}var tX=()=>typeof globalThis=="object"?globalThis:Function("return this")();function BY(q){return(q>>>=0)==0?q7(tX()):(q=AX(q),q7(tX()[q]))}var SH=(q)=>{var L=OX.length;return OX.push(q),L},NY=(q,L)=>{for(var _=Array(q),P=0;P<q;++P)_[P]=FJ(q0()[L+4*P>>>2>>>0],"parameter "+P);return _},FY=(q,L)=>Object.defineProperty(L,"name",{value:q});function G1(q,L,_){var P=(L=NY(q,L>>>0)).shift();q--;var k=`return function (obj, func, destructorsRef, args) {
15
15
  `,y=0,g=[];_===0&&g.push("obj");for(var J0=["retType"],W0=[P],N0=0;N0<q;++N0)g.push("arg"+N0),J0.push("argType"+N0),W0.push(L[N0]),k+=` var arg${N0} = argType${N0}.readValueFromPointer(args${y?"+"+y:""});
16
16
  `,y+=L[N0].zd;return k+=` var rv = ${_===1?"new func":"func.call"}(${g.join(", ")});
17
17
  `,P.Qd||(J0.push("emval_returnValue"),W0.push(f5),k+=` return emval_returnValue(retType, destructorsRef, rv);
@@ -2777,7 +2777,7 @@ ${G}`,H=Q.createShaderModule({code:Z,label:J.name});u9("verbose",()=>`[WebGPU] $
2777
2777
  * Copyright (c) Microsoft Corporation. All rights reserved.
2778
2778
  * Licensed under the MIT License.
2779
2779
  */Lk=Object.defineProperty,b30=Object.getOwnPropertyDescriptor,y30=Object.getOwnPropertyNames,j30=Object.prototype.hasOwnProperty,v30=((J)=>sH)(function(J){return sH.apply(this,arguments)}),bs=V8(()=>{S3=new Map,JG=[],MH=(J,X,Q)=>{if(X&&typeof X.init=="function"&&typeof X.createInferenceSessionHandler=="function"){let Y=S3.get(J);if(Y===void 0)S3.set(J,{backend:X,priority:Q});else{if(Y.priority>Q)return;if(Y.priority===Q&&Y.backend!==X)throw Error(`cannot register backend "${J}" using priority ${Q}`)}if(Q>=0){let W=JG.indexOf(J);W!==-1&&JG.splice(W,1);for(let G=0;G<JG.length;G++)if(S3.get(JG[G]).priority<=Q){JG.splice(G,0,J);return}JG.push(J)}return}throw TypeError("not a valid backend")},to=async(J)=>{let X=S3.get(J);if(!X)return"backend not found.";if(X.initialized)return X.backend;if(X.aborted)return X.error;{let Q=!!X.initPromise;try{return Q||(X.initPromise=X.backend.init(J)),await X.initPromise,X.initialized=!0,X.backend}catch(Y){return Q||(X.error=`${Y}`,X.aborted=!0),X.error}finally{delete X.initPromise}}},Ss=async(J)=>{let X=J.executionProviders||[],Q=X.map((K)=>typeof K=="string"?K:K.name),Y=Q.length===0?JG:Q,W,G=[],Z=new Set;for(let K of Y){let U=await to(K);typeof U=="string"?G.push({name:K,err:U}):(W||(W=U),W===U&&Z.add(K))}if(!W)throw Error(`no available backend found. ERR: ${G.map((K)=>`[${K.name}] ${K.err}`).join(", ")}`);for(let{name:K,err:U}of G)Q.includes(K)&&console.warn(`removing requested execution provider "${K}" from session options because it is not available: ${U}`);let H=X.filter((K)=>Z.has(typeof K=="string"?K:K.name));return[W,new Proxy(J,{get:(K,U)=>U==="executionProviders"?H:Reflect.get(K,U)})]}}),x30=V8(()=>{bs()}),h30=V8(()=>{ys="1.21.0"}),js=V8(()=>{h30(),HI="warning",R5={wasm:{},webgl:{},webgpu:{},versions:{common:ys},set logLevel(J){if(J!==void 0){if(typeof J!="string"||["verbose","info","warning","error","fatal"].indexOf(J)===-1)throw Error(`Unsupported logging level: ${J}`);HI=J}},get logLevel(){return HI}},Object.defineProperty(R5,"logLevel",{enumerable:!0})}),g30=V8(()=>{js(),T7=R5}),m30=V8(()=>{vs=(J,X)=>{let Q=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);Q.width=J.dims[3],Q.height=J.dims[2];let Y=Q.getContext("2d");if(Y!=null){let W,G;X?.tensorLayout!==void 0&&X.tensorLayout==="NHWC"?(W=J.dims[2],G=J.dims[3]):(W=J.dims[3],G=J.dims[2]);let Z=X?.format!==void 0?X.format:"RGB",H=X?.norm,K,U;H===void 0||H.mean===void 0?K=[255,255,255,255]:typeof H.mean=="number"?K=[H.mean,H.mean,H.mean,H.mean]:(K=[H.mean[0],H.mean[1],H.mean[2],0],H.mean[3]!==void 0&&(K[3]=H.mean[3])),H===void 0||H.bias===void 0?U=[0,0,0,0]:typeof H.bias=="number"?U=[H.bias,H.bias,H.bias,H.bias]:(U=[H.bias[0],H.bias[1],H.bias[2],0],H.bias[3]!==void 0&&(U[3]=H.bias[3]));let V=G*W,B=0,N=V,F=V*2,M=-1;Z==="RGBA"?(B=0,N=V,F=V*2,M=V*3):Z==="RGB"?(B=0,N=V,F=V*2):Z==="RBG"&&(B=0,F=V,N=V*2);for(let O=0;O<G;O++)for(let E=0;E<W;E++){let w=(J.data[B++]-U[0])*K[0],A=(J.data[N++]-U[1])*K[1],I=(J.data[F++]-U[2])*K[2],T=M===-1?255:(J.data[M++]-U[3])*K[3];Y.fillStyle="rgba("+w+","+A+","+I+","+T+")",Y.fillRect(E,O,1,1)}if("toDataURL"in Q)return Q.toDataURL();throw Error("toDataURL is not supported")}else throw Error("Can not access image data")},fs=(J,X)=>{let Q=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Y;if(Q!=null){let W,G,Z;X?.tensorLayout!==void 0&&X.tensorLayout==="NHWC"?(W=J.dims[2],G=J.dims[1],Z=J.dims[3]):(W=J.dims[3],G=J.dims[2],Z=J.dims[1]);let H=X!==void 0&&X.format!==void 0?X.format:"RGB",K=X?.norm,U,V;K===void 0||K.mean===void 0?U=[255,255,255,255]:typeof K.mean=="number"?U=[K.mean,K.mean,K.mean,K.mean]:(U=[K.mean[0],K.mean[1],K.mean[2],255],K.mean[3]!==void 0&&(U[3]=K.mean[3])),K===void 0||K.bias===void 0?V=[0,0,0,0]:typeof K.bias=="number"?V=[K.bias,K.bias,K.bias,K.bias]:(V=[K.bias[0],K.bias[1],K.bias[2],0],K.bias[3]!==void 0&&(V[3]=K.bias[3]));let B=G*W;if(X!==void 0&&(X.format!==void 0&&Z===4&&X.format!=="RGBA"||Z===3&&X.format!=="RGB"&&X.format!=="BGR"))throw Error("Tensor format doesn't match input tensor dims");let N=4,F=0,M=1,O=2,E=3,w=0,A=B,I=B*2,T=-1;H==="RGBA"?(w=0,A=B,I=B*2,T=B*3):H==="RGB"?(w=0,A=B,I=B*2):H==="RBG"&&(w=0,I=B,A=B*2),Y=Q.createImageData(W,G);for(let R=0;R<G*W;F+=N,M+=N,O+=N,E+=N,R++)Y.data[F]=(J.data[w++]-V[0])*U[0],Y.data[M]=(J.data[A++]-V[1])*U[1],Y.data[O]=(J.data[I++]-V[2])*U[2],Y.data[E]=T===-1?255:(J.data[T++]-V[3])*U[3]}else throw Error("Can not access image data");return Y}}),u30=V8(()=>{Dk(),TF=(J,X)=>{if(J===void 0)throw Error("Image buffer must be defined");if(X.height===void 0||X.width===void 0)throw Error("Image height and width must be defined");if(X.tensorLayout==="NHWC")throw Error("NHWC Tensor layout is not supported yet");let{height:Q,width:Y}=X,W=X.norm??{mean:255,bias:0},G,Z;typeof W.mean=="number"?G=[W.mean,W.mean,W.mean,W.mean]:G=[W.mean[0],W.mean[1],W.mean[2],W.mean[3]??255],typeof W.bias=="number"?Z=[W.bias,W.bias,W.bias,W.bias]:Z=[W.bias[0],W.bias[1],W.bias[2],W.bias[3]??0];let H=X.format!==void 0?X.format:"RGBA",K=X.tensorFormat!==void 0&&X.tensorFormat!==void 0?X.tensorFormat:"RGB",U=Q*Y,V=K==="RGBA"?new Float32Array(U*4):new Float32Array(U*3),B=4,N=0,F=1,M=2,O=3,E=0,w=U,A=U*2,I=-1;H==="RGB"&&(B=3,N=0,F=1,M=2,O=-1),K==="RGBA"?I=U*3:K==="RBG"?(E=0,A=U,w=U*2):K==="BGR"&&(A=0,w=U,E=U*2);for(let T=0;T<U;T++,N+=B,M+=B,F+=B,O+=B)V[E++]=(J[N]+Z[0])/G[0],V[w++]=(J[F]+Z[1])/G[1],V[A++]=(J[M]+Z[2])/G[2],I!==-1&&O!==-1&&(V[I++]=(J[O]+Z[3])/G[3]);return K==="RGBA"?new nX("float32",V,[1,4,Q,Y]):new nX("float32",V,[1,3,Q,Y])},xs=async(J,X)=>{let Q=typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement,Y=typeof ImageData<"u"&&J instanceof ImageData,W=typeof ImageBitmap<"u"&&J instanceof ImageBitmap,G=typeof J=="string",Z,H=X??{},K=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw Error("Canvas is not supported")},U=(V)=>typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||V instanceof OffscreenCanvas?V.getContext("2d"):null;if(Q){let V=K();V.width=J.width,V.height=J.height;let B=U(V);if(B!=null){let{height:N,width:F}=J;if(X!==void 0&&X.resizedHeight!==void 0&&X.resizedWidth!==void 0&&(N=X.resizedHeight,F=X.resizedWidth),X!==void 0){if(H=X,X.tensorFormat!==void 0)throw Error("Image input config format must be RGBA for HTMLImageElement");H.tensorFormat="RGBA",H.height=N,H.width=F}else H.tensorFormat="RGBA",H.height=N,H.width=F;B.drawImage(J,0,0),Z=B.getImageData(0,0,F,N).data}else throw Error("Can not access image data")}else if(Y){let V,B;if(X!==void 0&&X.resizedWidth!==void 0&&X.resizedHeight!==void 0?(V=X.resizedHeight,B=X.resizedWidth):(V=J.height,B=J.width),X!==void 0&&(H=X),H.format="RGBA",H.height=V,H.width=B,X!==void 0){let N=K();N.width=B,N.height=V;let F=U(N);if(F!=null)F.putImageData(J,0,0),Z=F.getImageData(0,0,B,V).data;else throw Error("Can not access image data")}else Z=J.data}else if(W){if(X===void 0)throw Error("Please provide image config with format for Imagebitmap");let V=K();V.width=J.width,V.height=J.height;let B=U(V);if(B!=null){let{height:N,width:F}=J;return B.drawImage(J,0,0,F,N),Z=B.getImageData(0,0,F,N).data,H.height=N,H.width=F,TF(Z,H)}else throw Error("Can not access image data")}else{if(G)return new Promise((V,B)=>{let N=K(),F=U(N);if(!J||!F)return B();let M=new Image;M.crossOrigin="Anonymous",M.src=J,M.onload=()=>{N.width=M.width,N.height=M.height,F.drawImage(M,0,0,N.width,N.height);let O=F.getImageData(0,0,N.width,N.height);H.height=N.height,H.width=N.width,V(TF(O.data,H))}});throw Error("Input data provided is not supported - aborted tensor creation")}if(Z!==void 0)return TF(Z,H);throw Error("Input data provided is not supported - aborted tensor creation")},hs=(J,X)=>{let{width:Q,height:Y,download:W,dispose:G}=X;return new nX({location:"texture",type:"float32",texture:J,dims:[1,Y,Q,4],download:W,dispose:G})},gs=(J,X)=>{let{dataType:Q,dims:Y,download:W,dispose:G}=X;return new nX({location:"gpu-buffer",type:Q??"float32",gpuBuffer:J,dims:Y,download:W,dispose:G})},ms=(J,X)=>{let{dataType:Q,dims:Y,download:W,dispose:G}=X;return new nX({location:"ml-tensor",type:Q??"float32",mlTensor:J,dims:Y,download:W,dispose:G})},us=(J,X,Q)=>new nX({location:"cpu-pinned",type:J,data:X,dims:Q??[X.length]})}),p30=V8(()=>{FH=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),m3=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),zI=!1,ps=()=>{if(!zI){zI=!0;let J=typeof BigInt64Array<"u"&&BigInt64Array.from,X=typeof BigUint64Array<"u"&&BigUint64Array.from,Q=globalThis.Float16Array,Y=typeof Q<"u"&&Q.from;J&&(FH.set("int64",BigInt64Array),m3.set(BigInt64Array,"int64")),X&&(FH.set("uint64",BigUint64Array),m3.set(BigUint64Array,"uint64")),Y?(FH.set("float16",Q),m3.set(Q,"float16")):FH.set("float16",Uint16Array)}}}),l30=V8(()=>{Dk(),ls=(J)=>{let X=1;for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(typeof Y!="number"||!Number.isSafeInteger(Y))throw TypeError(`dims[${Q}] must be an integer, got: ${Y}`);if(Y<0)throw RangeError(`dims[${Q}] must be a non-negative integer, got: ${Y}`);X*=Y}return X},ds=(J,X)=>{switch(J.location){case"cpu":return new nX(J.type,J.data,X);case"cpu-pinned":return new nX({location:"cpu-pinned",data:J.data,type:J.type,dims:X});case"texture":return new nX({location:"texture",texture:J.texture,type:J.type,dims:X});case"gpu-buffer":return new nX({location:"gpu-buffer",gpuBuffer:J.gpuBuffer,type:J.type,dims:X});case"ml-tensor":return new nX({location:"ml-tensor",mlTensor:J.mlTensor,type:J.type,dims:X});default:throw Error(`tensorReshape: tensor location ${J.location} is not supported`)}}}),Dk=V8(()=>{m30(),u30(),p30(),l30(),nX=class{constructor(J,X,Q){ps();let Y,W;if(typeof J=="object"&&"location"in J)switch(this.dataLocation=J.location,Y=J.type,W=J.dims,J.location){case"cpu-pinned":{let Z=FH.get(Y);if(!Z)throw TypeError(`unsupported type "${Y}" to create tensor from pinned buffer`);if(!(J.data instanceof Z))throw TypeError(`buffer should be of type ${Z.name}`);this.cpuData=J.data;break}case"texture":{if(Y!=="float32")throw TypeError(`unsupported type "${Y}" to create tensor from texture`);this.gpuTextureData=J.texture,this.downloader=J.download,this.disposer=J.dispose;break}case"gpu-buffer":{if(Y!=="float32"&&Y!=="float16"&&Y!=="int32"&&Y!=="int64"&&Y!=="uint32"&&Y!=="uint8"&&Y!=="bool"&&Y!=="uint4"&&Y!=="int4")throw TypeError(`unsupported type "${Y}" to create tensor from gpu buffer`);this.gpuBufferData=J.gpuBuffer,this.downloader=J.download,this.disposer=J.dispose;break}case"ml-tensor":{if(Y!=="float32"&&Y!=="float16"&&Y!=="int32"&&Y!=="int64"&&Y!=="uint32"&&Y!=="uint64"&&Y!=="int8"&&Y!=="uint8"&&Y!=="bool"&&Y!=="uint4"&&Y!=="int4")throw TypeError(`unsupported type "${Y}" to create tensor from MLTensor`);this.mlTensorData=J.mlTensor,this.downloader=J.download,this.disposer=J.dispose;break}default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Z,H;if(typeof J=="string")if(Y=J,H=Q,J==="string"){if(!Array.isArray(X))throw TypeError("A string tensor's data must be a string array.");Z=X}else{let K=FH.get(J);if(K===void 0)throw TypeError(`Unsupported tensor type: ${J}.`);if(Array.isArray(X)){if(J==="float16"&&K===Uint16Array||J==="uint4"||J==="int4")throw TypeError(`Creating a ${J} tensor from number array is not supported. Please use ${K.name} as data.`);J==="uint64"||J==="int64"?Z=K.from(X,BigInt):Z=K.from(X)}else if(X instanceof K)Z=X;else if(X instanceof Uint8ClampedArray)if(J==="uint8")Z=Uint8Array.from(X);else throw TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(J==="float16"&&X instanceof Uint16Array&&K!==Uint16Array)Z=new globalThis.Float16Array(X.buffer,X.byteOffset,X.length);else throw TypeError(`A ${Y} tensor's data must be type of ${K}`)}else if(H=X,Array.isArray(J)){if(J.length===0)throw TypeError("Tensor type cannot be inferred from an empty array.");let K=typeof J[0];if(K==="string")Y="string",Z=J;else if(K==="boolean")Y="bool",Z=Uint8Array.from(J);else throw TypeError(`Invalid element type of data array: ${K}.`)}else if(J instanceof Uint8ClampedArray)Y="uint8",Z=Uint8Array.from(J);else{let K=m3.get(J.constructor);if(K===void 0)throw TypeError(`Unsupported type for tensor data: ${J.constructor}.`);Y=K,Z=J}if(H===void 0)H=[Z.length];else if(!Array.isArray(H))throw TypeError("A tensor's dims must be a number array");W=H,this.cpuData=Z,this.dataLocation="cpu"}let G=ls(W);if(this.cpuData&&G!==this.cpuData.length&&!((Y==="uint4"||Y==="int4")&&Math.ceil(G/2)===this.cpuData.length))throw Error(`Tensor's size(${G}) does not match data length(${this.cpuData.length}).`);this.type=Y,this.dims=W,this.size=G}static async fromImage(J,X){return xs(J,X)}static fromTexture(J,X){return hs(J,X)}static fromGpuBuffer(J,X){return gs(J,X)}static fromMLTensor(J,X){return ms(J,X)}static fromPinnedBuffer(J,X,Q){return us(J,X,Q)}toDataURL(J){return vs(this,J)}toImageData(J){return fs(this,J)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(J){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let X=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=X,J&&this.disposer&&(this.disposer(),this.disposer=void 0),X}finally{this.isDownloading=!1}}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw Error("The tensor is disposed.")}reshape(J){if(this.ensureValid(),this.downloader||this.disposer)throw Error("Cannot reshape a tensor that owns GPU resource.");return ds(this,J)}}}),cs=V8(()=>{Dk(),UQ=nX}),is=V8(()=>{js(),d3=(J,X)=>{(typeof R5.trace>"u"?!R5.wasm.trace:!R5.trace)||console.timeStamp(`${J}::ORT::${X}`)},KI=(J,X)=>{let Q=Error().stack?.split(/\r\n|\r|\n/g)||[],Y=!1;for(let W=0;W<Q.length;W++){if(Y&&!Q[W].includes("TRACE_FUNC")){let G=`FUNC_${J}::${Q[W].trim().split(" ")[1]}`;X&&(G+=`::${X}`),d3("CPU",G);return}Q[W].includes("TRACE_FUNC")&&(Y=!0)}},VQ=(J)=>{(typeof R5.trace>"u"?!R5.wasm.trace:!R5.trace)||KI("BEGIN",J)},C5=(J)=>{(typeof R5.trace>"u"?!R5.wasm.trace:!R5.trace)||KI("END",J)}}),d30=V8(()=>{bs(),cs(),is(),os=class J{constructor(X){this.handler=X}async run(X,Q,Y){VQ();let W={},G={};if(typeof X!="object"||X===null||X instanceof UQ||Array.isArray(X))throw TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Z=!0;if(typeof Q=="object"){if(Q===null)throw TypeError("Unexpected argument[1]: cannot be null.");if(Q instanceof UQ)throw TypeError("'fetches' cannot be a Tensor");if(Array.isArray(Q)){if(Q.length===0)throw TypeError("'fetches' cannot be an empty array.");Z=!1;for(let U of Q){if(typeof U!="string")throw TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(U)===-1)throw RangeError(`'fetches' contains invalid output name: ${U}.`);W[U]=null}if(typeof Y=="object"&&Y!==null)G=Y;else if(typeof Y<"u")throw TypeError("'options' must be an object.")}else{let U=!1,V=Object.getOwnPropertyNames(Q);for(let B of this.outputNames)if(V.indexOf(B)!==-1){let N=Q[B];(N===null||N instanceof UQ)&&(U=!0,Z=!1,W[B]=N)}if(U){if(typeof Y=="object"&&Y!==null)G=Y;else if(typeof Y<"u")throw TypeError("'options' must be an object.")}else G=Q}}else if(typeof Q<"u")throw TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let U of this.inputNames)if(typeof X[U]>"u")throw Error(`input '${U}' is missing in 'feeds'.`);if(Z)for(let U of this.outputNames)W[U]=null;let H=await this.handler.run(X,W,G),K={};for(let U in H)if(Object.hasOwnProperty.call(H,U)){let V=H[U];V instanceof UQ?K[U]=V:K[U]=new UQ(V.type,V.data,V.dims)}return C5(),K}async release(){return this.handler.dispose()}static async create(X,Q,Y,W){VQ();let G,Z={};if(typeof X=="string"){if(G=X,typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q<"u")throw TypeError("'options' must be an object.")}else if(X instanceof Uint8Array){if(G=X,typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q<"u")throw TypeError("'options' must be an object.")}else if(X instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&X instanceof SharedArrayBuffer){let V=X,B=0,N=X.byteLength;if(typeof Q=="object"&&Q!==null)Z=Q;else if(typeof Q=="number"){if(B=Q,!Number.isSafeInteger(B))throw RangeError("'byteOffset' must be an integer.");if(B<0||B>=V.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${V.byteLength}).`);if(N=X.byteLength-B,typeof Y=="number"){if(N=Y,!Number.isSafeInteger(N))throw RangeError("'byteLength' must be an integer.");if(N<=0||B+N>V.byteLength)throw RangeError(`'byteLength' is out of range (0, ${V.byteLength-B}].`);if(typeof W=="object"&&W!==null)Z=W;else if(typeof W<"u")throw TypeError("'options' must be an object.")}else if(typeof Y<"u")throw TypeError("'byteLength' must be a number.")}else if(typeof Q<"u")throw TypeError("'options' must be an object.");G=new Uint8Array(V,B,N)}else throw TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[H,K]=await Ss(Z),U=await H.createInferenceSessionHandler(G,K);return C5(),new J(U)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),c30=V8(()=>{d30(),Mk=os}),i30=V8(()=>{}),o30=V8(()=>{}),n30=V8(()=>{}),r30=V8(()=>{}),ns={};i3(ns,{InferenceSession:()=>Mk,TRACE:()=>d3,TRACE_FUNC_BEGIN:()=>VQ,TRACE_FUNC_END:()=>C5,Tensor:()=>UQ,env:()=>T7,registerBackend:()=>MH});qQ=V8(()=>{x30(),g30(),c30(),cs(),i30(),o30(),is(),n30(),r30()}),Ok=V8(()=>{}),rs={};i3(rs,{default:()=>as});a30=V8(()=>{t00(),wH(),Ak(),UI="ort-wasm-proxy-worker",VI=globalThis.self?.name===UI,VI&&(self.onmessage=(J)=>{let{type:X,in:Q}=J.data;try{switch(X){case"init-wasm":_k(Q.wasm).then(()=>{gk(Q).then(()=>{postMessage({type:X})},(Y)=>{postMessage({type:X,err:Y})})},(Y)=>{postMessage({type:X,err:Y})});break;case"init-ep":{let{epName:Y,env:W}=Q;mk(W,Y).then(()=>{postMessage({type:X})},(G)=>{postMessage({type:X,err:G})});break}case"copy-from":{let{buffer:Y}=Q,W=nF(Y);postMessage({type:X,out:W});break}case"create":{let{model:Y,options:W}=Q;uk(Y,W).then((G)=>{postMessage({type:X,out:G})},(G)=>{postMessage({type:X,err:G})});break}case"release":pk(Q),postMessage({type:X});break;case"run":{let{sessionId:Y,inputIndices:W,inputs:G,outputIndices:Z,options:H}=Q;lk(Y,W,G,Z,Array(Z.length).fill(null),H).then((K)=>{K.some((U)=>U[3]!=="cpu")?postMessage({type:X,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:X,out:K},ck([...G,...K]))},(K)=>{postMessage({type:X,err:K})});break}case"end-profiling":dk(Q),postMessage({type:X});break;default:}}catch(Y){postMessage({type:X,err:Y})}}),as=VI?null:(J)=>new Worker(J??oX,{type:"module",name:UI})}),ss={};i3(ss,{default:()=>ts});s30=V8(()=>{BI=(qI=import.meta.url,async function(J={}){var X,Q,Y=J,W=new Promise((q,L)=>{X=q,Q=L}),G=typeof window=="object",Z=typeof WorkerGlobalScope<"u",H=Z&&self.name?.startsWith("em-pthread");Y.mountExternalData=(q,L)=>{q.startsWith("./")&&(q=q.substring(2)),(Y.Bd||(Y.Bd=new Map)).set(q,L)},Y.unmountExternalData=()=>{delete Y.Bd};var K=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let U=()=>{let q=(_,P,k)=>(...y)=>{let g=R9,J0=P?.();y=_(...y);let W0=P?.();return J0!==W0&&(_=W0,k(J0),P=k=null),R9!=g?new Promise((N0,R0)=>{MX={resolve:N0,reject:R0}}):y},L=(_)=>async(...P)=>{try{if(Y.Cd)throw Error("Session already started");let k=Y.Cd={be:P[0],errors:[]},y=await _(...P);if(Y.Cd!==k)throw Error("Session mismatch");Y.Dd?.flush();let g=k.errors;if(0<g.length){let J0=await Promise.all(g);if(J0=J0.filter((W0)=>W0),0<J0.length)throw Error(J0.join(`
2780
- `))}return y}finally{Y.Cd=null}};Y._OrtCreateSession=q(Y._OrtCreateSession,()=>Y._OrtCreateSession,(_)=>Y._OrtCreateSession=_),Y._OrtRun=L(q(Y._OrtRun,()=>Y._OrtRun,(_)=>Y._OrtRun=_)),Y._OrtRunWithBinding=L(q(Y._OrtRunWithBinding,()=>Y._OrtRunWithBinding,(_)=>Y._OrtRunWithBinding=_)),Y._OrtBindInput=q(Y._OrtBindInput,()=>Y._OrtBindInput,(_)=>Y._OrtBindInput=_),U=void 0};Y.jsepInit=(q,L)=>{if(U?.(),q==="webgpu"){[Y.Dd,Y.Rd,Y.Vd,Y.Hd,Y.Ud,Y.hc,Y.Wd,Y.Zd,Y.Sd,Y.Td,Y.Xd]=L;let _=Y.Dd;Y.jsepRegisterBuffer=(P,k,y,g)=>_.registerBuffer(P,k,y,g),Y.jsepGetBuffer=(P)=>_.getBuffer(P),Y.jsepCreateDownloader=(P,k,y)=>_.createDownloader(P,k,y),Y.jsepOnCreateSession=(P)=>{_.onCreateSession(P)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.$d=(P,k)=>{_.upload(P,k)}}else if(q==="webnn"){[Y.Dd,Y.Yd,Y.Id,Y.jsepEnsureTensor,Y.Jd,Y.jsepDownloadTensor]=L,Y.jsepReleaseTensorId=Y.Id,Y.jsepUploadTensor=Y.Jd;let _=Y.Dd;Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.jsepOnRunEnd=_.onRunEnd.bind(_),Y.jsepRegisterMLContext=(P,k)=>{_.registerMLContext(P,k)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepCreateMLTensorDownloader=(P,k)=>_.createMLTensorDownloader(P,k),Y.jsepRegisterMLTensor=(P,k,y,g)=>_.registerMLTensor(P,k,y,g),Y.jsepCreateMLContext=(P)=>_.createMLContext(P),Y.jsepRegisterMLConstant=(P,k,y,g,J0)=>_.registerMLConstant(P,k,y,g,J0,Y.Bd),Y.jsepRegisterGraphInput=_.registerGraphInput.bind(_),Y.jsepIsGraphInput=_.isGraphInput.bind(_),Y.jsepCreateTemporaryTensor=_.createTemporaryTensor.bind(_)}};var V,B,N=Object.assign({},Y),F=(q,L)=>{throw L},M="";(G||Z)&&(Z?M=self.location.href:typeof document<"u"&&document.currentScript&&(M=document.currentScript.src),qI&&(M=qI),M=M.startsWith("blob:")?"":M.slice(0,M.replace(/[?#].*/,"").lastIndexOf("/")+1),Z&&(B=(q)=>{var L=new XMLHttpRequest;return L.open("GET",q,!1),L.responseType="arraybuffer",L.send(null),new Uint8Array(L.response)}),V=async(q)=>{if(e(q))return new Promise((_,P)=>{var k=new XMLHttpRequest;k.open("GET",q,!0),k.responseType="arraybuffer",k.onload=()=>{k.status==200||k.status==0&&k.response?_(k.response):P(k.status)},k.onerror=P,k.send(null)});var L=await fetch(q,{credentials:"same-origin"});if(L.ok)return L.arrayBuffer();throw Error(L.status+" : "+L.url)});var O=console.log.bind(console),E=console.error.bind(console),w=O,A=E;Object.assign(Y,N),N=null;var I,T,R,$,C,j,f,m,d,a,x,h,l,v=Y.wasmBinary,n=!1,e=(q)=>q.startsWith("file://");function s(){return I.buffer!=$.buffer&&D8(),$}function H0(){return I.buffer!=$.buffer&&D8(),C}function r(){return I.buffer!=$.buffer&&D8(),j}function z0(){return I.buffer!=$.buffer&&D8(),f}function i(){return I.buffer!=$.buffer&&D8(),m}function q0(){return I.buffer!=$.buffer&&D8(),d}function Z0(){return I.buffer!=$.buffer&&D8(),a}function I0(){return I.buffer!=$.buffer&&D8(),l}if(H){let q=function(L){try{var _=L.data,P=_.yd;if(P==="load"){let k=[];self.onmessage=(y)=>k.push(y),self.startWorker=()=>{postMessage({yd:"loaded"});for(let y of k)q(y);self.onmessage=q};for(let y of _.Od)Y[y]&&!Y[y].proxy||(Y[y]=(...g)=>{postMessage({yd:"callHandler",Nd:y,args:g})},y=="print"&&(w=Y[y]),y=="printErr"&&(A=Y[y]));I=_.he,D8(),s0(_.ie)}else if(P==="run"){U0(_.xd),h5(_.xd,0,0,1,0,0),_0(),P0(_.xd),e0||(PG(),e0=!0);try{o0(_.de,_.Fd)}catch(k){if(k!="unwind")throw k}}else _.target!=="setimmediate"&&(P==="checkMailbox"?e0&&z8():P&&(A(`worker: received unknown command ${P}`),A(_)))}catch(k){throw IG(),k}};var a0=q,s0,e0=!1;A=function(...L){L=L.join(" "),console.error(L)},self.alert=function(...L){postMessage({yd:"alert",text:L.join(" "),fe:sJ()})},self.onunhandledrejection=(L)=>{throw L.reason||L},self.onmessage=q}function D8(){var q=I.buffer;Y.HEAP8=$=new Int8Array(q),Y.HEAP16=j=new Int16Array(q),Y.HEAPU8=C=new Uint8Array(q),Y.HEAPU16=f=new Uint16Array(q),Y.HEAP32=m=new Int32Array(q),Y.HEAPU32=d=new Uint32Array(q),Y.HEAPF32=a=new Float32Array(q),Y.HEAPF64=l=new Float64Array(q),Y.HEAP64=x=new BigInt64Array(q),Y.HEAPU64=h=new BigUint64Array(q)}function s8(){H?startWorker(Y):V0.Bb()}H||(I=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),D8());var w8,N8=0,C0=null;function A0(){if(--N8==0&&C0){var q=C0;C0=null,q()}}function $0(q){throw A(q="Aborted("+q+")"),n=!0,q=new WebAssembly.RuntimeError(q+". Build with -sASSERTIONS for more info."),Q(q),q}function Q8(){return{a:{Ta:b8,Va:f8,W:J9,la:a7,b:X9,u:d8,R:O0,Za:K8,d:S8,pb:x9,g:v7,T:M0,Ga:E0,lb:g8,nb:t8,Ha:v8,Ea:W9,wb:T9,Da:e9,pa:J7,mb:FQ,jb:aX,Fa:BJ,kb:oJ,Ma:Y4,za:HG,eb:qY,cb:j5,ya:P6,V:W4,N:DQ,db:zG,ma:o,fb:G0,zb:L0,hb:M8,qb:L9,ab:I6,Aa:MQ,yb:P0,Ja:s6,S:RH,Wa:KG,$:CH,G:X6,E:k6,m:rJ,H:BY,B:G1,X:LJ,J:_X,v:UG,O:Z1,D:bH,t:H1,A:VG,z:qG,w:yH,r:jH,tb:LY,ub:DY,vb:AQ,rb:NG,sb:FG,bb:MY,Oa:vH,La:MG,y:EX,ja:g6,Ba:OG,Ka:DG,qa:OY,Ia:_Q,ib:z4,U:LG,fa:fH,Sa:z1,gb:xH,Qa:hH,Pa:K4,Ab:PX,Ca:wG,ob:j0,aa:U4,oa:X5,xb:AY,na:EG,$a:iH,ia:IX,sa:nH,ga:rG,da:M1,ua:sG,p:cH,e:mH,c:cG,ea:L1,f:U1,n:A4,k:fY,Y:vY,ka:l5,j:nG,wa:F1,Ra:rH,ca:E1,Ua:Y7,P:D1,K:pH,_:w1,Q:B1,Z:JX,x:iG,l:K1,va:_1,i:dG,h:uH,ra:tG,ta:oH,o:V6,q:lH,s:oG,I:CQ,C:q1,L:dH,xa:aG,_a:N1,F:P1,Ya:O1,ba:C6,M:V1,Xa:A1,ha:Q5,a:I,Na:J8}}}var Z8={1319426:()=>typeof wasmOffsetConverter<"u",1319483:(q,L,_,P,k)=>{if(Y===void 0||!Y.Bd)return 1;if((q=t(Number(q>>>0))).startsWith("./")&&(q=q.substring(2)),!(q=Y.Bd.get(q)))return 2;if(L=Number(L>>>0),_=Number(_>>>0),P=Number(P>>>0),L+_>q.byteLength)return 3;try{let y=q.subarray(L,L+_);switch(k){case 0:H0().set(y,P>>>0);break;case 1:Y.$d(P,y);break;default:return 4}return 0}catch{return 4}},1320198:(q,L,_)=>{Y.Jd(q,H0().subarray(L>>>0,L+_>>>0))},1320261:()=>Y.Yd(),1320302:(q)=>{Y.Id(q)},1320338:()=>{Y.Sd()},1320369:()=>{Y.Td()},1320398:()=>{Y.Xd()},1320423:(q)=>Y.Rd(q),1320456:(q)=>Y.Vd(q),1320488:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_),!0)},1320551:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_))},1320608:(q)=>{Y.hc("Abs",q,void 0)},1320659:(q)=>{Y.hc("Neg",q,void 0)},1320710:(q)=>{Y.hc("Floor",q,void 0)},1320763:(q)=>{Y.hc("Ceil",q,void 0)},1320815:(q)=>{Y.hc("Reciprocal",q,void 0)},1320873:(q)=>{Y.hc("Sqrt",q,void 0)},1320925:(q)=>{Y.hc("Exp",q,void 0)},1320976:(q)=>{Y.hc("Erf",q,void 0)},1321027:(q)=>{Y.hc("Sigmoid",q,void 0)},1321082:(q,L,_)=>{Y.hc("HardSigmoid",q,{alpha:L,beta:_})},1321161:(q)=>{Y.hc("Log",q,void 0)},1321212:(q)=>{Y.hc("Sin",q,void 0)},1321263:(q)=>{Y.hc("Cos",q,void 0)},1321314:(q)=>{Y.hc("Tan",q,void 0)},1321365:(q)=>{Y.hc("Asin",q,void 0)},1321417:(q)=>{Y.hc("Acos",q,void 0)},1321469:(q)=>{Y.hc("Atan",q,void 0)},1321521:(q)=>{Y.hc("Sinh",q,void 0)},1321573:(q)=>{Y.hc("Cosh",q,void 0)},1321625:(q)=>{Y.hc("Asinh",q,void 0)},1321678:(q)=>{Y.hc("Acosh",q,void 0)},1321731:(q)=>{Y.hc("Atanh",q,void 0)},1321784:(q)=>{Y.hc("Tanh",q,void 0)},1321836:(q)=>{Y.hc("Not",q,void 0)},1321887:(q,L,_)=>{Y.hc("Clip",q,{min:L,max:_})},1321956:(q)=>{Y.hc("Clip",q,void 0)},1322008:(q,L)=>{Y.hc("Elu",q,{alpha:L})},1322066:(q)=>{Y.hc("Gelu",q,void 0)},1322118:(q)=>{Y.hc("Relu",q,void 0)},1322170:(q,L)=>{Y.hc("LeakyRelu",q,{alpha:L})},1322234:(q,L)=>{Y.hc("ThresholdedRelu",q,{alpha:L})},1322304:(q,L)=>{Y.hc("Cast",q,{to:L})},1322362:(q)=>{Y.hc("Add",q,void 0)},1322413:(q)=>{Y.hc("Sub",q,void 0)},1322464:(q)=>{Y.hc("Mul",q,void 0)},1322515:(q)=>{Y.hc("Div",q,void 0)},1322566:(q)=>{Y.hc("Pow",q,void 0)},1322617:(q)=>{Y.hc("Equal",q,void 0)},1322670:(q)=>{Y.hc("Greater",q,void 0)},1322725:(q)=>{Y.hc("GreaterOrEqual",q,void 0)},1322787:(q)=>{Y.hc("Less",q,void 0)},1322839:(q)=>{Y.hc("LessOrEqual",q,void 0)},1322898:(q,L,_,P,k)=>{Y.hc("ReduceMean",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323073:(q,L,_,P,k)=>{Y.hc("ReduceMax",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323247:(q,L,_,P,k)=>{Y.hc("ReduceMin",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323421:(q,L,_,P,k)=>{Y.hc("ReduceProd",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323596:(q,L,_,P,k)=>{Y.hc("ReduceSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323770:(q,L,_,P,k)=>{Y.hc("ReduceL1",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323943:(q,L,_,P,k)=>{Y.hc("ReduceL2",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324116:(q,L,_,P,k)=>{Y.hc("ReduceLogSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324293:(q,L,_,P,k)=>{Y.hc("ReduceSumSquare",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324473:(q,L,_,P,k)=>{Y.hc("ReduceLogSumExp",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324653:(q)=>{Y.hc("Where",q,void 0)},1324706:(q,L,_)=>{Y.hc("Transpose",q,{perm:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[]})},1324830:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1324963:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1325096:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1325529:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1326190:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1326623:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1327284:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327375:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1327854:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327945:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328424:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1328511:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328986:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1329073:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1329548:(q,L,_,P,k)=>{Y.hc("Gemm",q,{alpha:L,beta:_,transA:P,transB:k})},1329652:(q)=>{Y.hc("MatMul",q,void 0)},1329706:(q,L,_,P)=>{Y.hc("ArgMax",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329814:(q,L,_,P)=>{Y.hc("ArgMin",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329922:(q,L)=>{Y.hc("Softmax",q,{axis:L})},1329985:(q,L)=>{Y.hc("Concat",q,{axis:L})},1330045:(q,L,_,P,k)=>{Y.hc("Split",q,{axis:L,numOutputs:_,splitSizes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1330201:(q)=>{Y.hc("Expand",q,void 0)},1330255:(q,L)=>{Y.hc("Gather",q,{axis:Number(L)})},1330326:(q,L)=>{Y.hc("GatherElements",q,{axis:Number(L)})},1330405:(q,L)=>{Y.hc("GatherND",q,{batch_dims:Number(L)})},1330484:(q,L,_,P,k,y,g,J0,W0,N0,R0)=>{Y.hc("Resize",q,{antialias:L,axes:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],coordinateTransformMode:t(k),cubicCoeffA:y,excludeOutside:g,extrapolationValue:J0,keepAspectRatioPolicy:t(W0),mode:t(N0),nearestMode:t(R0)})},1330846:(q,L,_,P,k,y,g)=>{Y.hc("Slice",q,{starts:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[],ends:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[],axes:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[]})},1331110:(q)=>{Y.hc("Tile",q,void 0)},1331162:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331276:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331390:(q)=>{Y.hc("Range",q,void 0)},1331443:(q,L)=>{Y.hc("Einsum",q,{equation:t(L)})},1331524:(q,L,_,P,k)=>{Y.hc("Pad",q,{mode:L,value:_,pads:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1331667:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1331836:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1332005:(q,L,_)=>{Y.hc("CumSum",q,{exclusive:Number(L),reverse:Number(_)})},1332102:(q,L,_)=>{Y.hc("DequantizeLinear",q,{axis:L,blockSize:_})},1332192:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332362:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332532:(q,L)=>{Y.hc("ScatterND",q,{reduction:t(L)})},1332617:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("Attention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y,qkvHiddenSizes:g?Array.from(i().subarray(Number(J0)>>>0,Number(J0)+g>>>0)):[],pastPresentShareBuffer:!!W0})},1332889:(q)=>{Y.hc("BiasAdd",q,void 0)},1332944:(q)=>{Y.hc("BiasSplitGelu",q,void 0)},1333005:(q)=>{Y.hc("FastGelu",q,void 0)},1333061:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7,_J)=>{Y.hc("Conv",q,{format:l0?"NHWC":"NCHW",auto_pad:L,dilations:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],group:k,kernel_shape:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],pads:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],strides:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],w_is_const:()=>!!s()[Number(q8)>>>0],activation:t(Q9),activation_params:B7?Array.from(Z0().subarray(Number(B7)>>>0,Number(_J)>>>0)):[]})},1333645:(q)=>{Y.hc("Gelu",q,void 0)},1333697:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("GroupQueryAttention",q,{numHeads:L,kvNumHeads:_,scale:P,softcap:k,doRotary:y,rotaryInterleaved:g,smoothSoftmax:J0,localWindowSize:W0})},1333914:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334025:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334136:(q,L,_,P,k,y)=>{Y.hc("MatMulNBits",q,{k:L,n:_,accuracyLevel:P,bits:k,blockSize:y})},1334263:(q,L,_,P,k,y)=>{Y.hc("MultiHeadAttention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y})},1334422:(q,L)=>{Y.hc("QuickGelu",q,{alpha:L})},1334486:(q,L,_,P,k)=>{Y.hc("RotaryEmbedding",q,{interleaved:!!L,numHeads:_,rotaryEmbeddingDim:P,scale:k})},1334625:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334727:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334829:(q,L,_,P)=>{Y.hc("GatherBlockQuantized",q,{gatherAxis:L,quantizeAxis:_,blockSize:P})},1334950:(q)=>{Y.Wd(q)},1334984:(q,L)=>Y.Zd(Number(q),Number(L),Y.Cd.be,Y.Cd.errors)};function f8(q,L,_){return sX(async()=>{await Y.Ud(Number(q),Number(L),Number(_))})}function b8(){return typeof wasmOffsetConverter<"u"}class O9{name="ExitStatus";constructor(q){this.message=`Program terminated with exit(${q})`,this.status=q}}var h0=(q)=>{q.terminate(),q.onmessage=()=>{}},C8=[],A9=(q)=>{t0.length==0&&(P8(),X8(t0[0]));var L=t0.pop();if(!L)return 6;H8.push(L),d0[q.xd]=L,L.xd=q.xd;var _={yd:"run",de:q.ce,Fd:q.Fd,xd:q.xd};return L.postMessage(_,q.Ld),0},F8=0,B0=(q,L,..._)=>{for(var P=2*_.length,k=G8(),y=q4(8*P),g=y>>>3,J0=0;J0<_.length;J0++){var W0=_[J0];typeof W0=="bigint"?(x[g+2*J0]=1n,x[g+2*J0+1]=W0):(x[g+2*J0]=0n,I0()[g+2*J0+1>>>0]=W0)}return q=kG(q,0,P,y,L),Y8(k),q};function J8(q){if(H)return B0(0,1,q);if(R=q,!(0<F8)){for(var L of H8)h0(L);for(L of t0)h0(L);t0=[],H8=[],d0={},n=!0}F(0,new O9(q))}function r0(q){if(H)return B0(1,0,q);j0(q)}var j0=(q)=>{if(R=q,H)throw r0(q),"unwind";J8(q)},t0=[],H8=[],p0=[],d0={},k8=(q)=>{var L=q.xd;delete d0[L],t0.push(q),H8.splice(H8.indexOf(q),1),q.xd=0,wY(L)};function _0(){p0.forEach((q)=>q())}var X8=(q)=>new Promise((L)=>{q.onmessage=(k)=>{var y=(k=k.data).yd;if(k.Ed&&k.Ed!=sJ()){var g=d0[k.Ed];g?g.postMessage(k,k.Ld):A(`Internal error! Worker sent a message "${y}" to target pthread ${k.Ed}, but that thread no longer exists!`)}else y==="checkMailbox"?z8():y==="spawnThread"?A9(k):y==="cleanupThread"?k8(d0[k.ee]):y==="loaded"?(q.loaded=!0,L(q)):y==="alert"?alert(`Thread ${k.fe}: ${k.text}`):k.target==="setimmediate"?q.postMessage(k):y==="callHandler"?Y[k.Nd](...k.args):y&&A(`worker sent an unknown command ${y}`)},q.onerror=(k)=>{throw A(`worker sent an error! ${k.filename}:${k.lineno}: ${k.message}`),k};var _,P=[];for(_ of[])Y.propertyIsEnumerable(_)&&P.push(_);q.postMessage({yd:"load",Od:P,he:I,ie:T})});function P8(){var q=new Worker(import.meta.url.startsWith("file:")?new URL("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});t0.push(q)}var U0=(q)=>{D8();var L=q0()[q+52>>>2>>>0];q=q0()[q+56>>>2>>>0],IQ(L,L-q),Y8(L)},o0=(q,L)=>{F8=0,q=kQ(q,L),0<F8?R=q:g5(q)},R8=[];function J9(q){var L=new F9(q>>>=0);if(s()[L.wd+12>>>0]==0){var _=1;s()[L.wd+12>>>0]=_}return _=0,s()[L.wd+13>>>0]=_,R8.push(L),Q6(q),Y6(q)}var i0=0,a7=()=>{T0(0,0);var q=R8.pop();TG(q.Gd),i0=0};class F9{constructor(q){this.Gd=q,this.wd=q-24}}function v7(q){throw i0||=q>>>0,i0}var I8=(q)=>{var L=i0;if(!L)return eJ(0),0;var _=new F9(L);q0()[_.wd+16>>>2>>>0]=L;var P=q0()[_.wd+4>>>2>>>0];if(!P)return eJ(0),L;for(var k of q){if(k===0||k===P)break;if(m5(k,P,_.wd+16))return eJ(k),L}return eJ(P),L};function X9(){return I8([])}function d8(q){return I8([q>>>0])}function O0(q,L){return I8([q>>>0,L>>>0])}var K8=()=>{var q=R8.pop();q||$0("no exception to throw");var L=q.Gd;if(s()[q.wd+13>>>0]==0){R8.push(q);var _=1;s()[q.wd+13>>>0]=_,_=0,s()[q.wd+12>>>0]=_}throw i0=L};function S8(q,L,_){var P=new F9(q>>>=0);throw L>>>=0,_>>>=0,q0()[P.wd+16>>>2>>>0]=0,q0()[P.wd+4>>>2>>>0]=L,q0()[P.wd+8>>>2>>>0]=_,i0=q}function V9(q,L,_,P){return H?B0(2,1,q,L,_,P):x9(q,L,_,P)}function x9(q,L,_,P){if(q>>>=0,_>>>=0,P>>>=0,K===void 0)return 6;var k=[];return H&&k.length===0?V9(q,L>>>=0,_,P):(q={ce:_,xd:q,Fd:P,Ld:k},H?(q.yd="spawnThread",postMessage(q,k),0):A9(q))}var i9=typeof TextDecoder<"u"?new TextDecoder:void 0,h9=(q,L=0,_=NaN)=>{var P=(L>>>=0)+_;for(_=L;q[_]&&!(_>=P);)++_;if(16<_-L&&q.buffer&&i9)return i9.decode(q.buffer instanceof ArrayBuffer?q.subarray(L,_):q.slice(L,_));for(P="";L<_;){var k=q[L++];if(128&k){var y=63&q[L++];if((224&k)==192)P+=String.fromCharCode((31&k)<<6|y);else{var g=63&q[L++];65536>(k=(240&k)==224?(15&k)<<12|y<<6|g:(7&k)<<18|y<<12|g<<6|63&q[L++])?P+=String.fromCharCode(k):(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k))}}else P+=String.fromCharCode(k)}return P},t=(q,L)=>(q>>>=0)?h9(H0(),q,L):"";function M0(q,L,_){return H?B0(3,1,q,L,_):0}function E0(q,L){if(H)return B0(4,1,q,L)}var v0=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);127>=P?L++:2047>=P?L+=2:55296<=P&&57343>=P?(L+=4,++_):L+=3}return L},W8=(q,L,_)=>{var P=H0();if(L>>>=0,0<_){var k=L;_=L+_-1;for(var y=0;y<q.length;++y){var g=q.charCodeAt(y);if(55296<=g&&57343>=g&&(g=65536+((1023&g)<<10)|1023&q.charCodeAt(++y)),127>=g){if(L>=_)break;P[L++>>>0]=g}else{if(2047>=g){if(L+1>=_)break;P[L++>>>0]=192|g>>6}else{if(65535>=g){if(L+2>=_)break;P[L++>>>0]=224|g>>12}else{if(L+3>=_)break;P[L++>>>0]=240|g>>18,P[L++>>>0]=128|g>>12&63}P[L++>>>0]=128|g>>6&63}P[L++>>>0]=128|63&g}}P[L>>>0]=0,q=L-k}else q=0;return q};function g8(q,L){if(H)return B0(5,1,q,L)}function t8(q,L,_){if(H)return B0(6,1,q,L,_)}function v8(q,L,_){return H?B0(7,1,q,L,_):0}function W9(q,L){if(H)return B0(8,1,q,L)}function T9(q,L,_){if(H)return B0(9,1,q,L,_)}function e9(q,L,_,P){if(H)return B0(10,1,q,L,_,P)}function J7(q,L,_,P){if(H)return B0(11,1,q,L,_,P)}function FQ(q,L,_,P){if(H)return B0(12,1,q,L,_,P)}function aX(q){if(H)return B0(13,1,q)}function BJ(q,L){if(H)return B0(14,1,q,L)}function oJ(q,L,_){if(H)return B0(15,1,q,L,_)}var nJ,e7,Y4=()=>$0(""),R7=(q)=>{for(var L="";H0()[q>>>0];)L+=nJ[H0()[q++>>>0]];return L},FX={},j9={},VY={};function p7(q,L,_={}){return function(P,k,y={}){var g=k.name;if(!P)throw new e7(`type "${g}" must have a positive integer typeid pointer`);if(j9.hasOwnProperty(P)){if(y.Pd)return;throw new e7(`Cannot register type '${g}' twice`)}j9[P]=k,delete VY[P],FX.hasOwnProperty(P)&&(k=FX[P],delete FX[P],k.forEach((J0)=>J0()))}(q,L,_)}var y5=(q,L,_)=>{switch(L){case 1:return _?(P)=>s()[P>>>0]:(P)=>H0()[P>>>0];case 2:return _?(P)=>r()[P>>>1>>>0]:(P)=>z0()[P>>>1>>>0];case 4:return _?(P)=>i()[P>>>2>>>0]:(P)=>q0()[P>>>2>>>0];case 8:return _?(P)=>x[P>>>3]:(P)=>h[P>>>3];default:throw TypeError(`invalid integer width (${L}): ${q}`)}};function HG(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:function(P,k){if(typeof k!="bigint"&&typeof k!="number")throw k=k===null?"null":(P=typeof k)=="object"||P==="array"||P==="function"?k.toString():""+k,TypeError(`Cannot convert "${k}" to ${this.name}`);return typeof k=="number"&&(k=BigInt(k)),k},zd:f7,readValueFromPointer:y5(L,_,L.indexOf("u")==-1),Ad:null})}var f7=8;function qY(q,L,_,P){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(k){return!!k},toWireType:function(k,y){return y?_:P},zd:f7,readValueFromPointer:function(k){return this.fromWireType(H0()[k>>>0])},Ad:null})}var LX=[],V7=[];function rJ(q){9<(q>>>=0)&&--V7[q+1]==0&&(V7[q]=void 0,LX.push(q))}var l9=(q)=>{if(!q)throw new e7("Cannot use deleted val. handle = "+q);return V7[q]},q7=(q)=>{switch(q){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let L=LX.pop()||V7.length;return V7[L]=q,V7[L+1]=1,L}};function z6(q){return this.fromWireType(q0()[q>>>2>>>0])}var SJ={name:"emscripten::val",fromWireType:(q)=>{var L=l9(q);return rJ(q),L},toWireType:(q,L)=>q7(L),zd:f7,readValueFromPointer:z6,Ad:null};function j5(q){return p7(q>>>0,SJ)}var LQ=(q,L)=>{switch(L){case 4:return function(_){return this.fromWireType(Z0()[_>>>2>>>0])};case 8:return function(_){return this.fromWireType(I0()[_>>>3>>>0])};default:throw TypeError(`invalid float width (${L}): ${q}`)}};function P6(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:(P,k)=>k,zd:f7,readValueFromPointer:LQ(L,_),Ad:null})}function W4(q,L,_,P,k){if(q>>>=0,_>>>=0,L=R7(L>>>0),k===-1&&(k=4294967295),k=(J0)=>J0,P===0){var y=32-8*_;k=(J0)=>J0<<y>>>y}var g=L.includes("unsigned")?function(J0,W0){return W0>>>0}:function(J0,W0){return W0};p7(q,{name:L,fromWireType:k,toWireType:g,zd:f7,readValueFromPointer:y5(L,_,P!==0),Ad:null})}function DQ(q,L,_){function P(y){var g=q0()[y>>>2>>>0];return y=q0()[y+4>>>2>>>0],new k(s().buffer,y,g)}var k=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][L];p7(q>>>=0,{name:_=R7(_>>>0),fromWireType:P,zd:f7,readValueFromPointer:P},{Pd:!0})}function zG(q,L){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(_){for(var P,k=q0()[_>>>2>>>0],y=_+4,g=y,J0=0;J0<=k;++J0){var W0=y+J0;J0!=k&&H0()[W0>>>0]!=0||(g=t(g,W0-g),P===void 0?P=g:(P+="\x00",P+=g),g=W0+1)}return l7(_),P},toWireType:function(_,P){P instanceof ArrayBuffer&&(P=new Uint8Array(P));var k=typeof P=="string";if(!(k||P instanceof Uint8Array||P instanceof Uint8ClampedArray||P instanceof Int8Array))throw new e7("Cannot pass non-string to std::string");var y=k?v0(P):P.length,g=tJ(4+y+1),J0=g+4;if(q0()[g>>>2>>>0]=y,k)W8(P,J0,y+1);else if(k)for(k=0;k<y;++k){var W0=P.charCodeAt(k);if(255<W0)throw l7(g),new e7("String has UTF-16 code units that do not fit in 8 bits");H0()[J0+k>>>0]=W0}else for(k=0;k<y;++k)H0()[J0+k>>>0]=P[k];return _!==null&&_.push(l7,g),g},zd:f7,readValueFromPointer:z6,Ad(_){l7(_)}})}var bJ=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,yJ=(q,L)=>{for(var _=q>>1,P=_+L/2;!(_>=P)&&z0()[_>>>0];)++_;if(32<(_<<=1)-q&&bJ)return bJ.decode(H0().slice(q,_));for(_="",P=0;!(P>=L/2);++P){var k=r()[q+2*P>>>1>>>0];if(k==0)break;_+=String.fromCharCode(k)}return _},aJ=(q,L,_)=>{if(_??=2147483647,2>_)return 0;var P=L;_=(_-=2)<2*q.length?_/2:q.length;for(var k=0;k<_;++k){var y=q.charCodeAt(k);r()[L>>>1>>>0]=y,L+=2}return r()[L>>>1>>>0]=0,L-P},v5=(q)=>2*q.length,G4=(q,L)=>{for(var _=0,P="";!(_>=L/4);){var k=i()[q+4*_>>>2>>>0];if(k==0)break;++_,65536<=k?(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k)):P+=String.fromCharCode(k)}return P},NJ=(q,L,_)=>{if(L>>>=0,_??=2147483647,4>_)return 0;var P=L;_=P+_-4;for(var k=0;k<q.length;++k){var y=q.charCodeAt(k);if(55296<=y&&57343>=y&&(y=65536+((1023&y)<<10)|1023&q.charCodeAt(++k)),i()[L>>>2>>>0]=y,(L+=4)+4>_)break}return i()[L>>>2>>>0]=0,L-P},Z4=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);55296<=P&&57343>=P&&++_,L+=4}return L};function o(q,L,_){if(q>>>=0,L>>>=0,_=R7(_>>>=0),L===2)var P=yJ,k=aJ,y=v5,g=(J0)=>z0()[J0>>>1>>>0];else L===4&&(P=G4,k=NJ,y=Z4,g=(J0)=>q0()[J0>>>2>>>0]);p7(q,{name:_,fromWireType:(J0)=>{for(var W0,N0=q0()[J0>>>2>>>0],R0=J0+4,l0=0;l0<=N0;++l0){var q8=J0+4+l0*L;l0!=N0&&g(q8)!=0||(R0=P(R0,q8-R0),W0===void 0?W0=R0:(W0+="\x00",W0+=R0),R0=q8+L)}return l7(J0),W0},toWireType:(J0,W0)=>{if(typeof W0!="string")throw new e7(`Cannot pass non-string to C++ string type ${_}`);var N0=y(W0),R0=tJ(4+N0+L);return q0()[R0>>>2>>>0]=N0/L,k(W0,R0+4,N0+L),J0!==null&&J0.push(l7,R0),R0},zd:f7,readValueFromPointer:z6,Ad(J0){l7(J0)}})}function G0(q,L){p7(q>>>=0,{Qd:!0,name:L=R7(L>>>0),zd:0,fromWireType:()=>{},toWireType:()=>{}})}function L0(q){h5(q>>>0,!Z,1,!G,131072,!1),_0()}var y0=(q)=>{if(!n)try{if(q(),!(0<F8))try{H?g5(R):j0(R)}catch(L){L instanceof O9||L=="unwind"||F(0,L)}}catch(L){L instanceof O9||L=="unwind"||F(0,L)}};function P0(q){q>>>=0,typeof Atomics.ge=="function"&&(Atomics.ge(i(),q>>>2,q).value.then(z8),q+=128,Atomics.store(i(),q>>>2,1))}var z8=()=>{var q=sJ();q&&(P0(q),y0(c8))};function M8(q,L){(q>>>=0)==L>>>0?setTimeout(z8):H?postMessage({Ed:q,yd:"checkMailbox"}):(q=d0[q])&&q.postMessage({yd:"checkMailbox"})}var Z9=[];function L9(q,L,_,P,k){for(L>>>=0,P/=2,Z9.length=P,_=k>>>0>>>3,k=0;k<P;k++)Z9[k]=x[_+2*k]?x[_+2*k+1]:I0()[_+2*k+1>>>0];return(L?Z8[L]:vJ[q])(...Z9)}var I6=()=>{F8=0};function MQ(q){q>>>=0,H?postMessage({yd:"cleanupThread",ee:q}):k8(d0[q])}function s6(q){}var FJ=(q,L)=>{var _=j9[q];if(_===void 0)throw q=V4(q),_=R7(q),l7(q),new e7(`${L} has unknown type ${_}`);return _},f5=(q,L,_)=>{var P=[];return q=q.toWireType(P,_),P.length&&(q0()[L>>>2>>>0]=q7(P)),q};function RH(q,L,_){return L>>>=0,_>>>=0,q=l9(q>>>0),L=FJ(L,"emval::as"),f5(L,_,q)}function KG(q,L){return L>>>=0,q=l9(q>>>0),(L=FJ(L,"emval::as")).toWireType(null,q)}var jJ=(q)=>{try{q()}catch(L){$0(L)}},C7=0,R9=null,DX=0,K6=[],a8={},J6={},h6=0,MX=null,OQ=[];function sX(q){return function(L){if(!n){if(C7===0){var _=!1,P=!1;L((k=0)=>{if(!n&&(DX=k,_=!0,P)){C7=2,jJ(()=>pG(R9)),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.resume(),k=!1;try{var y=function(){var W0=i()[R9+8>>>2>>>0];return W0=V0[J6[W0]],--F8,W0()}()}catch(W0){y=W0,k=!0}var g=!1;if(!R9){var J0=MX;J0&&(MX=null,(k?J0.reject:J0.resolve)(y),g=!0)}if(k&&!g)throw y}}),P=!0,_||(C7=1,R9=function(){var k=tJ(65548),y=k+12;q0()[k>>>2>>>0]=y,q0()[k+4>>>2>>>0]=y+65536,y=K6[0];var g=a8[y];return g===void 0&&(g=h6++,a8[y]=g,J6[g]=y),y=g,i()[k+8>>>2>>>0]=y,k}(),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.pause(),jJ(()=>mG(R9)))}else C7===2?(C7=0,jJ(lG),l7(R9),R9=null,OQ.forEach(y0)):$0(`invalid state: ${C7}`);return DX}}((L)=>{q().then(L)})}function CH(q){return q>>>=0,sX(async()=>{var L=await l9(q);return q7(L)})}var OX=[];function X6(q,L,_,P){return _>>>=0,P>>>=0,(q=OX[q>>>0])(null,L=l9(L>>>0),_,P)}var $H={},AX=(q)=>{var L=$H[q];return L===void 0?R7(q):L};function k6(q,L,_,P,k){return _>>>=0,P>>>=0,k>>>=0,(q=OX[q>>>0])(L=l9(L>>>0),L[_=AX(_)],P,k)}var tX=()=>typeof globalThis=="object"?globalThis:Function("return this")();function BY(q){return(q>>>=0)==0?q7(tX()):(q=AX(q),q7(tX()[q]))}var SH=(q)=>{var L=OX.length;return OX.push(q),L},NY=(q,L)=>{for(var _=Array(q),P=0;P<q;++P)_[P]=FJ(q0()[L+4*P>>>2>>>0],"parameter "+P);return _},FY=(q,L)=>Object.defineProperty(L,"name",{value:q});function G1(q,L,_){var P=(L=NY(q,L>>>0)).shift();q--;var k=`return function (obj, func, destructorsRef, args) {
2780
+ `))}return y}finally{Y.Cd=null}};Y._OrtCreateSession=q(Y._OrtCreateSession,()=>Y._OrtCreateSession,(_)=>Y._OrtCreateSession=_),Y._OrtRun=L(q(Y._OrtRun,()=>Y._OrtRun,(_)=>Y._OrtRun=_)),Y._OrtRunWithBinding=L(q(Y._OrtRunWithBinding,()=>Y._OrtRunWithBinding,(_)=>Y._OrtRunWithBinding=_)),Y._OrtBindInput=q(Y._OrtBindInput,()=>Y._OrtBindInput,(_)=>Y._OrtBindInput=_),U=void 0};Y.jsepInit=(q,L)=>{if(U?.(),q==="webgpu"){[Y.Dd,Y.Rd,Y.Vd,Y.Hd,Y.Ud,Y.hc,Y.Wd,Y.Zd,Y.Sd,Y.Td,Y.Xd]=L;let _=Y.Dd;Y.jsepRegisterBuffer=(P,k,y,g)=>_.registerBuffer(P,k,y,g),Y.jsepGetBuffer=(P)=>_.getBuffer(P),Y.jsepCreateDownloader=(P,k,y)=>_.createDownloader(P,k,y),Y.jsepOnCreateSession=(P)=>{_.onCreateSession(P)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.$d=(P,k)=>{_.upload(P,k)}}else if(q==="webnn"){[Y.Dd,Y.Yd,Y.Id,Y.jsepEnsureTensor,Y.Jd,Y.jsepDownloadTensor]=L,Y.jsepReleaseTensorId=Y.Id,Y.jsepUploadTensor=Y.Jd;let _=Y.Dd;Y.jsepOnRunStart=(P)=>_.onRunStart(P),Y.jsepOnRunEnd=_.onRunEnd.bind(_),Y.jsepRegisterMLContext=(P,k)=>{_.registerMLContext(P,k)},Y.jsepOnReleaseSession=(P)=>{_.onReleaseSession(P)},Y.jsepCreateMLTensorDownloader=(P,k)=>_.createMLTensorDownloader(P,k),Y.jsepRegisterMLTensor=(P,k,y,g)=>_.registerMLTensor(P,k,y,g),Y.jsepCreateMLContext=(P)=>_.createMLContext(P),Y.jsepRegisterMLConstant=(P,k,y,g,J0)=>_.registerMLConstant(P,k,y,g,J0,Y.Bd),Y.jsepRegisterGraphInput=_.registerGraphInput.bind(_),Y.jsepIsGraphInput=_.isGraphInput.bind(_),Y.jsepCreateTemporaryTensor=_.createTemporaryTensor.bind(_)}};var V,B,N=Object.assign({},Y),F=(q,L)=>{throw L},M="";(G||Z)&&(Z?M=self.location.href:typeof document<"u"&&document.currentScript&&(M=document.currentScript.src),qI&&(M=qI),M=M.startsWith("blob:")?"":M.slice(0,M.replace(/[?#].*/,"").lastIndexOf("/")+1),Z&&(B=(q)=>{var L=new XMLHttpRequest;return L.open("GET",q,!1),L.responseType="arraybuffer",L.send(null),new Uint8Array(L.response)}),V=async(q)=>{if(e(q))return new Promise((_,P)=>{var k=new XMLHttpRequest;k.open("GET",q,!0),k.responseType="arraybuffer",k.onload=()=>{k.status==200||k.status==0&&k.response?_(k.response):P(k.status)},k.onerror=P,k.send(null)});var L=await fetch(q,{credentials:"same-origin"});if(L.ok)return L.arrayBuffer();throw Error(L.status+" : "+L.url)});var O=console.log.bind(console),E=console.error.bind(console),w=O,A=E;Object.assign(Y,N),N=null;var I,T,R,$,C,j,f,m,d,a,x,h,l,v=Y.wasmBinary,n=!1,e=(q)=>q.startsWith("file://");function s(){return I.buffer!=$.buffer&&D8(),$}function H0(){return I.buffer!=$.buffer&&D8(),C}function r(){return I.buffer!=$.buffer&&D8(),j}function z0(){return I.buffer!=$.buffer&&D8(),f}function i(){return I.buffer!=$.buffer&&D8(),m}function q0(){return I.buffer!=$.buffer&&D8(),d}function Z0(){return I.buffer!=$.buffer&&D8(),a}function I0(){return I.buffer!=$.buffer&&D8(),l}if(H){let q=function(L){try{var _=L.data,P=_.yd;if(P==="load"){let k=[];self.onmessage=(y)=>k.push(y),self.startWorker=()=>{postMessage({yd:"loaded"});for(let y of k)q(y);self.onmessage=q};for(let y of _.Od)Y[y]&&!Y[y].proxy||(Y[y]=(...g)=>{postMessage({yd:"callHandler",Nd:y,args:g})},y=="print"&&(w=Y[y]),y=="printErr"&&(A=Y[y]));I=_.he,D8(),s0(_.ie)}else if(P==="run"){U0(_.xd),h5(_.xd,0,0,1,0,0),_0(),P0(_.xd),e0||(PG(),e0=!0);try{o0(_.de,_.Fd)}catch(k){if(k!="unwind")throw k}}else _.target!=="setimmediate"&&(P==="checkMailbox"?e0&&z8():P&&(A(`worker: received unknown command ${P}`),A(_)))}catch(k){throw IG(),k}};var a0=q,s0,e0=!1;A=function(...L){L=L.join(" "),console.error(L)},self.alert=function(...L){postMessage({yd:"alert",text:L.join(" "),fe:sJ()})},self.onunhandledrejection=(L)=>{throw L.reason||L},self.onmessage=q}function D8(){var q=I.buffer;Y.HEAP8=$=new Int8Array(q),Y.HEAP16=j=new Int16Array(q),Y.HEAPU8=C=new Uint8Array(q),Y.HEAPU16=f=new Uint16Array(q),Y.HEAP32=m=new Int32Array(q),Y.HEAPU32=d=new Uint32Array(q),Y.HEAPF32=a=new Float32Array(q),Y.HEAPF64=l=new Float64Array(q),Y.HEAP64=x=new BigInt64Array(q),Y.HEAPU64=h=new BigUint64Array(q)}function s8(){H?startWorker(Y):V0.Bb()}H||(I=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),D8());var w8,N8=0,C0=null;function A0(){if(--N8==0&&C0){var q=C0;C0=null,q()}}function $0(q){throw A(q="Aborted("+q+")"),n=!0,q=new WebAssembly.RuntimeError(q+". Build with -sASSERTIONS for more info."),Q(q),q}function Q8(){return{a:{Ta:b8,Va:f8,W:J9,la:a7,b:X9,u:d8,R:O0,Za:K8,d:S8,pb:x9,g:v7,T:M0,Ga:E0,lb:g8,nb:t8,Ha:v8,Ea:W9,wb:T9,Da:e9,pa:J7,mb:FQ,jb:aX,Fa:BJ,kb:oJ,Ma:Y4,za:HG,eb:qY,cb:j5,ya:P6,V:W4,N:DQ,db:zG,ma:o,fb:G0,zb:D0,hb:M8,qb:L9,ab:I6,Aa:MQ,yb:P0,Ja:s6,S:RH,Wa:KG,$:CH,G:X6,E:k6,m:rJ,H:BY,B:G1,X:LJ,J:_X,v:UG,O:Z1,D:bH,t:H1,A:VG,z:qG,w:yH,r:jH,tb:LY,ub:DY,vb:AQ,rb:NG,sb:FG,bb:MY,Oa:vH,La:MG,y:EX,ja:g6,Ba:OG,Ka:DG,qa:OY,Ia:_Q,ib:z4,U:LG,fa:fH,Sa:z1,gb:xH,Qa:hH,Pa:K4,Ab:PX,Ca:wG,ob:j0,aa:U4,oa:X5,xb:AY,na:EG,$a:iH,ia:IX,sa:nH,ga:rG,da:M1,ua:sG,p:cH,e:mH,c:cG,ea:L1,f:U1,n:A4,k:fY,Y:vY,ka:l5,j:nG,wa:F1,Ra:rH,ca:E1,Ua:Y7,P:D1,K:pH,_:w1,Q:B1,Z:JX,x:iG,l:K1,va:_1,i:dG,h:uH,ra:tG,ta:oH,o:V6,q:lH,s:oG,I:CQ,C:q1,L:dH,xa:aG,_a:N1,F:P1,Ya:O1,ba:C6,M:V1,Xa:A1,ha:Q5,a:I,Na:J8}}}var Z8={1319426:()=>typeof wasmOffsetConverter<"u",1319483:(q,L,_,P,k)=>{if(Y===void 0||!Y.Bd)return 1;if((q=t(Number(q>>>0))).startsWith("./")&&(q=q.substring(2)),!(q=Y.Bd.get(q)))return 2;if(L=Number(L>>>0),_=Number(_>>>0),P=Number(P>>>0),L+_>q.byteLength)return 3;try{let y=q.subarray(L,L+_);switch(k){case 0:H0().set(y,P>>>0);break;case 1:Y.$d(P,y);break;default:return 4}return 0}catch{return 4}},1320198:(q,L,_)=>{Y.Jd(q,H0().subarray(L>>>0,L+_>>>0))},1320261:()=>Y.Yd(),1320302:(q)=>{Y.Id(q)},1320338:()=>{Y.Sd()},1320369:()=>{Y.Td()},1320398:()=>{Y.Xd()},1320423:(q)=>Y.Rd(q),1320456:(q)=>Y.Vd(q),1320488:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_),!0)},1320551:(q,L,_)=>{Y.Hd(Number(q),Number(L),Number(_))},1320608:(q)=>{Y.hc("Abs",q,void 0)},1320659:(q)=>{Y.hc("Neg",q,void 0)},1320710:(q)=>{Y.hc("Floor",q,void 0)},1320763:(q)=>{Y.hc("Ceil",q,void 0)},1320815:(q)=>{Y.hc("Reciprocal",q,void 0)},1320873:(q)=>{Y.hc("Sqrt",q,void 0)},1320925:(q)=>{Y.hc("Exp",q,void 0)},1320976:(q)=>{Y.hc("Erf",q,void 0)},1321027:(q)=>{Y.hc("Sigmoid",q,void 0)},1321082:(q,L,_)=>{Y.hc("HardSigmoid",q,{alpha:L,beta:_})},1321161:(q)=>{Y.hc("Log",q,void 0)},1321212:(q)=>{Y.hc("Sin",q,void 0)},1321263:(q)=>{Y.hc("Cos",q,void 0)},1321314:(q)=>{Y.hc("Tan",q,void 0)},1321365:(q)=>{Y.hc("Asin",q,void 0)},1321417:(q)=>{Y.hc("Acos",q,void 0)},1321469:(q)=>{Y.hc("Atan",q,void 0)},1321521:(q)=>{Y.hc("Sinh",q,void 0)},1321573:(q)=>{Y.hc("Cosh",q,void 0)},1321625:(q)=>{Y.hc("Asinh",q,void 0)},1321678:(q)=>{Y.hc("Acosh",q,void 0)},1321731:(q)=>{Y.hc("Atanh",q,void 0)},1321784:(q)=>{Y.hc("Tanh",q,void 0)},1321836:(q)=>{Y.hc("Not",q,void 0)},1321887:(q,L,_)=>{Y.hc("Clip",q,{min:L,max:_})},1321956:(q)=>{Y.hc("Clip",q,void 0)},1322008:(q,L)=>{Y.hc("Elu",q,{alpha:L})},1322066:(q)=>{Y.hc("Gelu",q,void 0)},1322118:(q)=>{Y.hc("Relu",q,void 0)},1322170:(q,L)=>{Y.hc("LeakyRelu",q,{alpha:L})},1322234:(q,L)=>{Y.hc("ThresholdedRelu",q,{alpha:L})},1322304:(q,L)=>{Y.hc("Cast",q,{to:L})},1322362:(q)=>{Y.hc("Add",q,void 0)},1322413:(q)=>{Y.hc("Sub",q,void 0)},1322464:(q)=>{Y.hc("Mul",q,void 0)},1322515:(q)=>{Y.hc("Div",q,void 0)},1322566:(q)=>{Y.hc("Pow",q,void 0)},1322617:(q)=>{Y.hc("Equal",q,void 0)},1322670:(q)=>{Y.hc("Greater",q,void 0)},1322725:(q)=>{Y.hc("GreaterOrEqual",q,void 0)},1322787:(q)=>{Y.hc("Less",q,void 0)},1322839:(q)=>{Y.hc("LessOrEqual",q,void 0)},1322898:(q,L,_,P,k)=>{Y.hc("ReduceMean",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323073:(q,L,_,P,k)=>{Y.hc("ReduceMax",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323247:(q,L,_,P,k)=>{Y.hc("ReduceMin",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323421:(q,L,_,P,k)=>{Y.hc("ReduceProd",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323596:(q,L,_,P,k)=>{Y.hc("ReduceSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323770:(q,L,_,P,k)=>{Y.hc("ReduceL1",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1323943:(q,L,_,P,k)=>{Y.hc("ReduceL2",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324116:(q,L,_,P,k)=>{Y.hc("ReduceLogSum",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324293:(q,L,_,P,k)=>{Y.hc("ReduceSumSquare",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324473:(q,L,_,P,k)=>{Y.hc("ReduceLogSumExp",q,{keepDims:!!L,noopWithEmptyAxes:!!_,axes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1324653:(q)=>{Y.hc("Where",q,void 0)},1324706:(q,L,_)=>{Y.hc("Transpose",q,{perm:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[]})},1324830:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1324963:(q,L,_,P)=>{Y.hc("DepthToSpace",q,{blocksize:L,mode:t(_),format:P?"NHWC":"NCHW"})},1325096:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1325529:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1326190:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7)=>{Y.hc("ConvTranspose",q,{format:W0?"NHWC":"NCHW",autoPad:L,dilations:[_],group:P,kernelShape:[k],pads:[y,g],strides:[J0],wIsConst:()=>!!s()[N0>>>0],outputPadding:R0?Array.from(i().subarray(Number(R0)>>>0,Number(l0)>>>0)):[],outputShape:q8?Array.from(i().subarray(Number(q8)>>>0,Number(Q9)>>>0)):[],activation:t(B7)})},1326623:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("ConvTranspose",q,{format:J0?"NHWC":"NCHW",autoPad:L,dilations:Array.from(i().subarray(Number(_)>>>0,2+(Number(_)>>>0)>>>0)),group:P,kernelShape:Array.from(i().subarray(Number(k)>>>0,2+(Number(k)>>>0)>>>0)),pads:Array.from(i().subarray(Number(y)>>>0,4+(Number(y)>>>0)>>>0)),strides:Array.from(i().subarray(Number(g)>>>0,2+(Number(g)>>>0)>>>0)),wIsConst:()=>!!s()[W0>>>0],outputPadding:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],outputShape:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[],activation:t(Q9)})},1327284:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327375:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1327854:(q,L)=>{Y.hc("GlobalAveragePool",q,{format:L?"NHWC":"NCHW"})},1327945:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("AveragePool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328424:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1328511:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1328986:(q,L)=>{Y.hc("GlobalMaxPool",q,{format:L?"NHWC":"NCHW"})},1329073:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9)=>{Y.hc("MaxPool",q,{format:Q9?"NHWC":"NCHW",auto_pad:L,ceil_mode:_,count_include_pad:P,storage_order:k,dilations:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],kernel_shape:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],pads:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],strides:l0?Array.from(i().subarray(Number(l0)>>>0,Number(q8)>>>0)):[]})},1329548:(q,L,_,P,k)=>{Y.hc("Gemm",q,{alpha:L,beta:_,transA:P,transB:k})},1329652:(q)=>{Y.hc("MatMul",q,void 0)},1329706:(q,L,_,P)=>{Y.hc("ArgMax",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329814:(q,L,_,P)=>{Y.hc("ArgMin",q,{keepDims:!!L,selectLastIndex:!!_,axis:P})},1329922:(q,L)=>{Y.hc("Softmax",q,{axis:L})},1329985:(q,L)=>{Y.hc("Concat",q,{axis:L})},1330045:(q,L,_,P,k)=>{Y.hc("Split",q,{axis:L,numOutputs:_,splitSizes:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1330201:(q)=>{Y.hc("Expand",q,void 0)},1330255:(q,L)=>{Y.hc("Gather",q,{axis:Number(L)})},1330326:(q,L)=>{Y.hc("GatherElements",q,{axis:Number(L)})},1330405:(q,L)=>{Y.hc("GatherND",q,{batch_dims:Number(L)})},1330484:(q,L,_,P,k,y,g,J0,W0,N0,R0)=>{Y.hc("Resize",q,{antialias:L,axes:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],coordinateTransformMode:t(k),cubicCoeffA:y,excludeOutside:g,extrapolationValue:J0,keepAspectRatioPolicy:t(W0),mode:t(N0),nearestMode:t(R0)})},1330846:(q,L,_,P,k,y,g)=>{Y.hc("Slice",q,{starts:L?Array.from(i().subarray(Number(L)>>>0,Number(_)>>>0)):[],ends:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[],axes:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[]})},1331110:(q)=>{Y.hc("Tile",q,void 0)},1331162:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331276:(q,L,_)=>{Y.hc("InstanceNormalization",q,{epsilon:L,format:_?"NHWC":"NCHW"})},1331390:(q)=>{Y.hc("Range",q,void 0)},1331443:(q,L)=>{Y.hc("Einsum",q,{equation:t(L)})},1331524:(q,L,_,P,k)=>{Y.hc("Pad",q,{mode:L,value:_,pads:P?Array.from(i().subarray(Number(P)>>>0,Number(k)>>>0)):[]})},1331667:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1331836:(q,L,_,P,k,y)=>{Y.hc("BatchNormalization",q,{epsilon:L,momentum:_,spatial:!!k,trainingMode:!!P,format:y?"NHWC":"NCHW"})},1332005:(q,L,_)=>{Y.hc("CumSum",q,{exclusive:Number(L),reverse:Number(_)})},1332102:(q,L,_)=>{Y.hc("DequantizeLinear",q,{axis:L,blockSize:_})},1332192:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332362:(q,L,_,P,k)=>{Y.hc("GridSample",q,{align_corners:L,mode:t(_),padding_mode:t(P),format:k?"NHWC":"NCHW"})},1332532:(q,L)=>{Y.hc("ScatterND",q,{reduction:t(L)})},1332617:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("Attention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y,qkvHiddenSizes:g?Array.from(i().subarray(Number(J0)>>>0,Number(J0)+g>>>0)):[],pastPresentShareBuffer:!!W0})},1332889:(q)=>{Y.hc("BiasAdd",q,void 0)},1332944:(q)=>{Y.hc("BiasSplitGelu",q,void 0)},1333005:(q)=>{Y.hc("FastGelu",q,void 0)},1333061:(q,L,_,P,k,y,g,J0,W0,N0,R0,l0,q8,Q9,B7,_J)=>{Y.hc("Conv",q,{format:l0?"NHWC":"NCHW",auto_pad:L,dilations:_?Array.from(i().subarray(Number(_)>>>0,Number(P)>>>0)):[],group:k,kernel_shape:y?Array.from(i().subarray(Number(y)>>>0,Number(g)>>>0)):[],pads:J0?Array.from(i().subarray(Number(J0)>>>0,Number(W0)>>>0)):[],strides:N0?Array.from(i().subarray(Number(N0)>>>0,Number(R0)>>>0)):[],w_is_const:()=>!!s()[Number(q8)>>>0],activation:t(Q9),activation_params:B7?Array.from(Z0().subarray(Number(B7)>>>0,Number(_J)>>>0)):[]})},1333645:(q)=>{Y.hc("Gelu",q,void 0)},1333697:(q,L,_,P,k,y,g,J0,W0)=>{Y.hc("GroupQueryAttention",q,{numHeads:L,kvNumHeads:_,scale:P,softcap:k,doRotary:y,rotaryInterleaved:g,smoothSoftmax:J0,localWindowSize:W0})},1333914:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334025:(q,L,_,P)=>{Y.hc("LayerNormalization",q,{axis:L,epsilon:_,simplified:!!P})},1334136:(q,L,_,P,k,y)=>{Y.hc("MatMulNBits",q,{k:L,n:_,accuracyLevel:P,bits:k,blockSize:y})},1334263:(q,L,_,P,k,y)=>{Y.hc("MultiHeadAttention",q,{numHeads:L,isUnidirectional:_,maskFilterValue:P,scale:k,doRotary:y})},1334422:(q,L)=>{Y.hc("QuickGelu",q,{alpha:L})},1334486:(q,L,_,P,k)=>{Y.hc("RotaryEmbedding",q,{interleaved:!!L,numHeads:_,rotaryEmbeddingDim:P,scale:k})},1334625:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334727:(q,L,_)=>{Y.hc("SkipLayerNormalization",q,{epsilon:L,simplified:!!_})},1334829:(q,L,_,P)=>{Y.hc("GatherBlockQuantized",q,{gatherAxis:L,quantizeAxis:_,blockSize:P})},1334950:(q)=>{Y.Wd(q)},1334984:(q,L)=>Y.Zd(Number(q),Number(L),Y.Cd.be,Y.Cd.errors)};function f8(q,L,_){return sX(async()=>{await Y.Ud(Number(q),Number(L),Number(_))})}function b8(){return typeof wasmOffsetConverter<"u"}class O9{name="ExitStatus";constructor(q){this.message=`Program terminated with exit(${q})`,this.status=q}}var h0=(q)=>{q.terminate(),q.onmessage=()=>{}},C8=[],A9=(q)=>{t0.length==0&&(P8(),X8(t0[0]));var L=t0.pop();if(!L)return 6;H8.push(L),d0[q.xd]=L,L.xd=q.xd;var _={yd:"run",de:q.ce,Fd:q.Fd,xd:q.xd};return L.postMessage(_,q.Ld),0},F8=0,B0=(q,L,..._)=>{for(var P=2*_.length,k=G8(),y=q4(8*P),g=y>>>3,J0=0;J0<_.length;J0++){var W0=_[J0];typeof W0=="bigint"?(x[g+2*J0]=1n,x[g+2*J0+1]=W0):(x[g+2*J0]=0n,I0()[g+2*J0+1>>>0]=W0)}return q=kG(q,0,P,y,L),Y8(k),q};function J8(q){if(H)return B0(0,1,q);if(R=q,!(0<F8)){for(var L of H8)h0(L);for(L of t0)h0(L);t0=[],H8=[],d0={},n=!0}F(0,new O9(q))}function r0(q){if(H)return B0(1,0,q);j0(q)}var j0=(q)=>{if(R=q,H)throw r0(q),"unwind";J8(q)},t0=[],H8=[],p0=[],d0={},k8=(q)=>{var L=q.xd;delete d0[L],t0.push(q),H8.splice(H8.indexOf(q),1),q.xd=0,wY(L)};function _0(){p0.forEach((q)=>q())}var X8=(q)=>new Promise((L)=>{q.onmessage=(k)=>{var y=(k=k.data).yd;if(k.Ed&&k.Ed!=sJ()){var g=d0[k.Ed];g?g.postMessage(k,k.Ld):A(`Internal error! Worker sent a message "${y}" to target pthread ${k.Ed}, but that thread no longer exists!`)}else y==="checkMailbox"?z8():y==="spawnThread"?A9(k):y==="cleanupThread"?k8(d0[k.ee]):y==="loaded"?(q.loaded=!0,L(q)):y==="alert"?alert(`Thread ${k.fe}: ${k.text}`):k.target==="setimmediate"?q.postMessage(k):y==="callHandler"?Y[k.Nd](...k.args):y&&A(`worker sent an unknown command ${y}`)},q.onerror=(k)=>{throw A(`worker sent an error! ${k.filename}:${k.lineno}: ${k.message}`),k};var _,P=[];for(_ of[])Y.propertyIsEnumerable(_)&&P.push(_);q.postMessage({yd:"load",Od:P,he:I,ie:T})});function P8(){var q=new Worker(import.meta.url.startsWith("file:")?new URL("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});t0.push(q)}var U0=(q)=>{D8();var L=q0()[q+52>>>2>>>0];q=q0()[q+56>>>2>>>0],IQ(L,L-q),Y8(L)},o0=(q,L)=>{F8=0,q=kQ(q,L),0<F8?R=q:g5(q)},R8=[];function J9(q){var L=new F9(q>>>=0);if(s()[L.wd+12>>>0]==0){var _=1;s()[L.wd+12>>>0]=_}return _=0,s()[L.wd+13>>>0]=_,R8.push(L),Q6(q),Y6(q)}var i0=0,a7=()=>{T0(0,0);var q=R8.pop();TG(q.Gd),i0=0};class F9{constructor(q){this.Gd=q,this.wd=q-24}}function v7(q){throw i0||=q>>>0,i0}var I8=(q)=>{var L=i0;if(!L)return eJ(0),0;var _=new F9(L);q0()[_.wd+16>>>2>>>0]=L;var P=q0()[_.wd+4>>>2>>>0];if(!P)return eJ(0),L;for(var k of q){if(k===0||k===P)break;if(m5(k,P,_.wd+16))return eJ(k),L}return eJ(P),L};function X9(){return I8([])}function d8(q){return I8([q>>>0])}function O0(q,L){return I8([q>>>0,L>>>0])}var K8=()=>{var q=R8.pop();q||$0("no exception to throw");var L=q.Gd;if(s()[q.wd+13>>>0]==0){R8.push(q);var _=1;s()[q.wd+13>>>0]=_,_=0,s()[q.wd+12>>>0]=_}throw i0=L};function S8(q,L,_){var P=new F9(q>>>=0);throw L>>>=0,_>>>=0,q0()[P.wd+16>>>2>>>0]=0,q0()[P.wd+4>>>2>>>0]=L,q0()[P.wd+8>>>2>>>0]=_,i0=q}function V9(q,L,_,P){return H?B0(2,1,q,L,_,P):x9(q,L,_,P)}function x9(q,L,_,P){if(q>>>=0,_>>>=0,P>>>=0,K===void 0)return 6;var k=[];return H&&k.length===0?V9(q,L>>>=0,_,P):(q={ce:_,xd:q,Fd:P,Ld:k},H?(q.yd="spawnThread",postMessage(q,k),0):A9(q))}var i9=typeof TextDecoder<"u"?new TextDecoder:void 0,h9=(q,L=0,_=NaN)=>{var P=(L>>>=0)+_;for(_=L;q[_]&&!(_>=P);)++_;if(16<_-L&&q.buffer&&i9)return i9.decode(q.buffer instanceof ArrayBuffer?q.subarray(L,_):q.slice(L,_));for(P="";L<_;){var k=q[L++];if(128&k){var y=63&q[L++];if((224&k)==192)P+=String.fromCharCode((31&k)<<6|y);else{var g=63&q[L++];65536>(k=(240&k)==224?(15&k)<<12|y<<6|g:(7&k)<<18|y<<12|g<<6|63&q[L++])?P+=String.fromCharCode(k):(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k))}}else P+=String.fromCharCode(k)}return P},t=(q,L)=>(q>>>=0)?h9(H0(),q,L):"";function M0(q,L,_){return H?B0(3,1,q,L,_):0}function E0(q,L){if(H)return B0(4,1,q,L)}var v0=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);127>=P?L++:2047>=P?L+=2:55296<=P&&57343>=P?(L+=4,++_):L+=3}return L},W8=(q,L,_)=>{var P=H0();if(L>>>=0,0<_){var k=L;_=L+_-1;for(var y=0;y<q.length;++y){var g=q.charCodeAt(y);if(55296<=g&&57343>=g&&(g=65536+((1023&g)<<10)|1023&q.charCodeAt(++y)),127>=g){if(L>=_)break;P[L++>>>0]=g}else{if(2047>=g){if(L+1>=_)break;P[L++>>>0]=192|g>>6}else{if(65535>=g){if(L+2>=_)break;P[L++>>>0]=224|g>>12}else{if(L+3>=_)break;P[L++>>>0]=240|g>>18,P[L++>>>0]=128|g>>12&63}P[L++>>>0]=128|g>>6&63}P[L++>>>0]=128|63&g}}P[L>>>0]=0,q=L-k}else q=0;return q};function g8(q,L){if(H)return B0(5,1,q,L)}function t8(q,L,_){if(H)return B0(6,1,q,L,_)}function v8(q,L,_){return H?B0(7,1,q,L,_):0}function W9(q,L){if(H)return B0(8,1,q,L)}function T9(q,L,_){if(H)return B0(9,1,q,L,_)}function e9(q,L,_,P){if(H)return B0(10,1,q,L,_,P)}function J7(q,L,_,P){if(H)return B0(11,1,q,L,_,P)}function FQ(q,L,_,P){if(H)return B0(12,1,q,L,_,P)}function aX(q){if(H)return B0(13,1,q)}function BJ(q,L){if(H)return B0(14,1,q,L)}function oJ(q,L,_){if(H)return B0(15,1,q,L,_)}var nJ,e7,Y4=()=>$0(""),R7=(q)=>{for(var L="";H0()[q>>>0];)L+=nJ[H0()[q++>>>0]];return L},FX={},j9={},VY={};function p7(q,L,_={}){return function(P,k,y={}){var g=k.name;if(!P)throw new e7(`type "${g}" must have a positive integer typeid pointer`);if(j9.hasOwnProperty(P)){if(y.Pd)return;throw new e7(`Cannot register type '${g}' twice`)}j9[P]=k,delete VY[P],FX.hasOwnProperty(P)&&(k=FX[P],delete FX[P],k.forEach((J0)=>J0()))}(q,L,_)}var y5=(q,L,_)=>{switch(L){case 1:return _?(P)=>s()[P>>>0]:(P)=>H0()[P>>>0];case 2:return _?(P)=>r()[P>>>1>>>0]:(P)=>z0()[P>>>1>>>0];case 4:return _?(P)=>i()[P>>>2>>>0]:(P)=>q0()[P>>>2>>>0];case 8:return _?(P)=>x[P>>>3]:(P)=>h[P>>>3];default:throw TypeError(`invalid integer width (${L}): ${q}`)}};function HG(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:function(P,k){if(typeof k!="bigint"&&typeof k!="number")throw k=k===null?"null":(P=typeof k)=="object"||P==="array"||P==="function"?k.toString():""+k,TypeError(`Cannot convert "${k}" to ${this.name}`);return typeof k=="number"&&(k=BigInt(k)),k},zd:f7,readValueFromPointer:y5(L,_,L.indexOf("u")==-1),Ad:null})}var f7=8;function qY(q,L,_,P){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(k){return!!k},toWireType:function(k,y){return y?_:P},zd:f7,readValueFromPointer:function(k){return this.fromWireType(H0()[k>>>0])},Ad:null})}var LX=[],V7=[];function rJ(q){9<(q>>>=0)&&--V7[q+1]==0&&(V7[q]=void 0,LX.push(q))}var l9=(q)=>{if(!q)throw new e7("Cannot use deleted val. handle = "+q);return V7[q]},q7=(q)=>{switch(q){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let L=LX.pop()||V7.length;return V7[L]=q,V7[L+1]=1,L}};function z6(q){return this.fromWireType(q0()[q>>>2>>>0])}var SJ={name:"emscripten::val",fromWireType:(q)=>{var L=l9(q);return rJ(q),L},toWireType:(q,L)=>q7(L),zd:f7,readValueFromPointer:z6,Ad:null};function j5(q){return p7(q>>>0,SJ)}var LQ=(q,L)=>{switch(L){case 4:return function(_){return this.fromWireType(Z0()[_>>>2>>>0])};case 8:return function(_){return this.fromWireType(I0()[_>>>3>>>0])};default:throw TypeError(`invalid float width (${L}): ${q}`)}};function P6(q,L,_){_>>>=0,p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:(P)=>P,toWireType:(P,k)=>k,zd:f7,readValueFromPointer:LQ(L,_),Ad:null})}function W4(q,L,_,P,k){if(q>>>=0,_>>>=0,L=R7(L>>>0),k===-1&&(k=4294967295),k=(J0)=>J0,P===0){var y=32-8*_;k=(J0)=>J0<<y>>>y}var g=L.includes("unsigned")?function(J0,W0){return W0>>>0}:function(J0,W0){return W0};p7(q,{name:L,fromWireType:k,toWireType:g,zd:f7,readValueFromPointer:y5(L,_,P!==0),Ad:null})}function DQ(q,L,_){function P(y){var g=q0()[y>>>2>>>0];return y=q0()[y+4>>>2>>>0],new k(s().buffer,y,g)}var k=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][L];p7(q>>>=0,{name:_=R7(_>>>0),fromWireType:P,zd:f7,readValueFromPointer:P},{Pd:!0})}function zG(q,L){p7(q>>>=0,{name:L=R7(L>>>0),fromWireType:function(_){for(var P,k=q0()[_>>>2>>>0],y=_+4,g=y,J0=0;J0<=k;++J0){var W0=y+J0;J0!=k&&H0()[W0>>>0]!=0||(g=t(g,W0-g),P===void 0?P=g:(P+="\x00",P+=g),g=W0+1)}return l7(_),P},toWireType:function(_,P){P instanceof ArrayBuffer&&(P=new Uint8Array(P));var k=typeof P=="string";if(!(k||P instanceof Uint8Array||P instanceof Uint8ClampedArray||P instanceof Int8Array))throw new e7("Cannot pass non-string to std::string");var y=k?v0(P):P.length,g=tJ(4+y+1),J0=g+4;if(q0()[g>>>2>>>0]=y,k)W8(P,J0,y+1);else if(k)for(k=0;k<y;++k){var W0=P.charCodeAt(k);if(255<W0)throw l7(g),new e7("String has UTF-16 code units that do not fit in 8 bits");H0()[J0+k>>>0]=W0}else for(k=0;k<y;++k)H0()[J0+k>>>0]=P[k];return _!==null&&_.push(l7,g),g},zd:f7,readValueFromPointer:z6,Ad(_){l7(_)}})}var bJ=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,yJ=(q,L)=>{for(var _=q>>1,P=_+L/2;!(_>=P)&&z0()[_>>>0];)++_;if(32<(_<<=1)-q&&bJ)return bJ.decode(H0().slice(q,_));for(_="",P=0;!(P>=L/2);++P){var k=r()[q+2*P>>>1>>>0];if(k==0)break;_+=String.fromCharCode(k)}return _},aJ=(q,L,_)=>{if(_??=2147483647,2>_)return 0;var P=L;_=(_-=2)<2*q.length?_/2:q.length;for(var k=0;k<_;++k){var y=q.charCodeAt(k);r()[L>>>1>>>0]=y,L+=2}return r()[L>>>1>>>0]=0,L-P},v5=(q)=>2*q.length,G4=(q,L)=>{for(var _=0,P="";!(_>=L/4);){var k=i()[q+4*_>>>2>>>0];if(k==0)break;++_,65536<=k?(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|1023&k)):P+=String.fromCharCode(k)}return P},NJ=(q,L,_)=>{if(L>>>=0,_??=2147483647,4>_)return 0;var P=L;_=P+_-4;for(var k=0;k<q.length;++k){var y=q.charCodeAt(k);if(55296<=y&&57343>=y&&(y=65536+((1023&y)<<10)|1023&q.charCodeAt(++k)),i()[L>>>2>>>0]=y,(L+=4)+4>_)break}return i()[L>>>2>>>0]=0,L-P},Z4=(q)=>{for(var L=0,_=0;_<q.length;++_){var P=q.charCodeAt(_);55296<=P&&57343>=P&&++_,L+=4}return L};function o(q,L,_){if(q>>>=0,L>>>=0,_=R7(_>>>=0),L===2)var P=yJ,k=aJ,y=v5,g=(J0)=>z0()[J0>>>1>>>0];else L===4&&(P=G4,k=NJ,y=Z4,g=(J0)=>q0()[J0>>>2>>>0]);p7(q,{name:_,fromWireType:(J0)=>{for(var W0,N0=q0()[J0>>>2>>>0],R0=J0+4,l0=0;l0<=N0;++l0){var q8=J0+4+l0*L;l0!=N0&&g(q8)!=0||(R0=P(R0,q8-R0),W0===void 0?W0=R0:(W0+="\x00",W0+=R0),R0=q8+L)}return l7(J0),W0},toWireType:(J0,W0)=>{if(typeof W0!="string")throw new e7(`Cannot pass non-string to C++ string type ${_}`);var N0=y(W0),R0=tJ(4+N0+L);return q0()[R0>>>2>>>0]=N0/L,k(W0,R0+4,N0+L),J0!==null&&J0.push(l7,R0),R0},zd:f7,readValueFromPointer:z6,Ad(J0){l7(J0)}})}function G0(q,L){p7(q>>>=0,{Qd:!0,name:L=R7(L>>>0),zd:0,fromWireType:()=>{},toWireType:()=>{}})}function D0(q){h5(q>>>0,!Z,1,!G,131072,!1),_0()}var y0=(q)=>{if(!n)try{if(q(),!(0<F8))try{H?g5(R):j0(R)}catch(L){L instanceof O9||L=="unwind"||F(0,L)}}catch(L){L instanceof O9||L=="unwind"||F(0,L)}};function P0(q){q>>>=0,typeof Atomics.ge=="function"&&(Atomics.ge(i(),q>>>2,q).value.then(z8),q+=128,Atomics.store(i(),q>>>2,1))}var z8=()=>{var q=sJ();q&&(P0(q),y0(c8))};function M8(q,L){(q>>>=0)==L>>>0?setTimeout(z8):H?postMessage({Ed:q,yd:"checkMailbox"}):(q=d0[q])&&q.postMessage({yd:"checkMailbox"})}var Z9=[];function L9(q,L,_,P,k){for(L>>>=0,P/=2,Z9.length=P,_=k>>>0>>>3,k=0;k<P;k++)Z9[k]=x[_+2*k]?x[_+2*k+1]:I0()[_+2*k+1>>>0];return(L?Z8[L]:vJ[q])(...Z9)}var I6=()=>{F8=0};function MQ(q){q>>>=0,H?postMessage({yd:"cleanupThread",ee:q}):k8(d0[q])}function s6(q){}var FJ=(q,L)=>{var _=j9[q];if(_===void 0)throw q=V4(q),_=R7(q),l7(q),new e7(`${L} has unknown type ${_}`);return _},f5=(q,L,_)=>{var P=[];return q=q.toWireType(P,_),P.length&&(q0()[L>>>2>>>0]=q7(P)),q};function RH(q,L,_){return L>>>=0,_>>>=0,q=l9(q>>>0),L=FJ(L,"emval::as"),f5(L,_,q)}function KG(q,L){return L>>>=0,q=l9(q>>>0),(L=FJ(L,"emval::as")).toWireType(null,q)}var jJ=(q)=>{try{q()}catch(L){$0(L)}},C7=0,R9=null,DX=0,K6=[],a8={},J6={},h6=0,MX=null,OQ=[];function sX(q){return function(L){if(!n){if(C7===0){var _=!1,P=!1;L((k=0)=>{if(!n&&(DX=k,_=!0,P)){C7=2,jJ(()=>pG(R9)),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.resume(),k=!1;try{var y=function(){var W0=i()[R9+8>>>2>>>0];return W0=V0[J6[W0]],--F8,W0()}()}catch(W0){y=W0,k=!0}var g=!1;if(!R9){var J0=MX;J0&&(MX=null,(k?J0.reject:J0.resolve)(y),g=!0)}if(k&&!g)throw y}}),P=!0,_||(C7=1,R9=function(){var k=tJ(65548),y=k+12;q0()[k>>>2>>>0]=y,q0()[k+4>>>2>>>0]=y+65536,y=K6[0];var g=a8[y];return g===void 0&&(g=h6++,a8[y]=g,J6[g]=y),y=g,i()[k+8>>>2>>>0]=y,k}(),typeof MainLoop<"u"&&MainLoop.Md&&MainLoop.pause(),jJ(()=>mG(R9)))}else C7===2?(C7=0,jJ(lG),l7(R9),R9=null,OQ.forEach(y0)):$0(`invalid state: ${C7}`);return DX}}((L)=>{q().then(L)})}function CH(q){return q>>>=0,sX(async()=>{var L=await l9(q);return q7(L)})}var OX=[];function X6(q,L,_,P){return _>>>=0,P>>>=0,(q=OX[q>>>0])(null,L=l9(L>>>0),_,P)}var $H={},AX=(q)=>{var L=$H[q];return L===void 0?R7(q):L};function k6(q,L,_,P,k){return _>>>=0,P>>>=0,k>>>=0,(q=OX[q>>>0])(L=l9(L>>>0),L[_=AX(_)],P,k)}var tX=()=>typeof globalThis=="object"?globalThis:Function("return this")();function BY(q){return(q>>>=0)==0?q7(tX()):(q=AX(q),q7(tX()[q]))}var SH=(q)=>{var L=OX.length;return OX.push(q),L},NY=(q,L)=>{for(var _=Array(q),P=0;P<q;++P)_[P]=FJ(q0()[L+4*P>>>2>>>0],"parameter "+P);return _},FY=(q,L)=>Object.defineProperty(L,"name",{value:q});function G1(q,L,_){var P=(L=NY(q,L>>>0)).shift();q--;var k=`return function (obj, func, destructorsRef, args) {
2781
2781
  `,y=0,g=[];_===0&&g.push("obj");for(var J0=["retType"],W0=[P],N0=0;N0<q;++N0)g.push("arg"+N0),J0.push("argType"+N0),W0.push(L[N0]),k+=` var arg${N0} = argType${N0}.readValueFromPointer(args${y?"+"+y:""});
2782
2782
  `,y+=L[N0].zd;return k+=` var rv = ${_===1?"new func":"func.call"}(${g.join(", ")});
2783
2783
  `,P.Qd||(J0.push("emval_returnValue"),W0.push(f5),k+=` return emval_returnValue(retType, destructorsRef, rv);
@@ -5675,15 +5675,15 @@ ${B.block}`:V,F=[],M=new Map;for await(let O of J.prompt(N,X(),K,Q?.(),Y?.(),Z?.
5675
5675
  z-index: 8;
5676
5676
  }
5677
5677
  .dc-context-menu .dc-menu-flyout.is-flip { left: auto; right: calc(100% + 3px); }
5678
- `.trim();function LU0(){if(typeof document>"u")return;if(document.getElementById("dc-context-menu-css"))return;let J=document.createElement("style");J.id="dc-context-menu-css",J.textContent=FU0,document.head.appendChild(J)}function Hm({target:J,sections:X,onClose:Q}){LU0();let Y=kJ.useRef(null),[W,G]=kJ.useState({x:J.clientX,y:J.clientY});kJ.useEffect(()=>{let H=Y.current;if(!H)return;let K=H.getBoundingClientRect(),U=window.innerWidth,V=window.innerHeight,B=J.clientX,N=J.clientY;if(B+K.width>U-8)B=Math.max(8,U-K.width-8);if(N+K.height>V-8)N=Math.max(8,V-K.height-8);if(B!==W.x||N!==W.y)G({x:B,y:N});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let M=(w)=>{if(!H.contains(w.target))Q()},O=(w)=>{if(w.key==="Escape"){w.preventDefault(),Q();return}if(w.key==="ArrowDown"||w.key==="ArrowUp"){w.preventDefault();let A=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(A.length===0)return;let I=document.activeElement,T=I instanceof HTMLButtonElement?A.indexOf(I):-1,R=w.key==="ArrowDown"?(T+1)%A.length:(T-1+A.length)%A.length;A[R]?.focus()}},E=()=>Q();return document.addEventListener("pointerdown",M,!0),document.addEventListener("keydown",O,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("keydown",O,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",Q)}},[J.clientX,J.clientY,Q,W.x,W.y]);let Z=X.map((H)=>H.filter((K)=>{return!(typeof K.hidden==="function"?K.hidden(J):K.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,K)=>{let U=H.map((V)=>V.id).join("|")||`s${K}`;return D("div",{role:"group",children:[K>0?z("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((V)=>z(DU0,{item:V,target:J,onClose:Q},V.id))]},U)})})}function DU0({item:J,target:X,onClose:Q}){let[Y,W]=kJ.useState(!1),[G,Z]=kJ.useState(!1),H=kJ.useRef(null),K=kJ.useRef(null),U=kJ.useRef(null),V=typeof J.submenu==="function"?J.submenu(X):J.submenu,B=typeof J.disabled==="function"?J.disabled(X):J.disabled;if(!V||V.length===0)return D("button",{type:"button",role:"menuitem",disabled:B,title:B?J.disabledHint:void 0,className:`dc-menu-item${J.destructive?" is-destructive":""}`,onClick:()=>{if(B)return;J.onSelect(X),Q()},children:[z("span",{children:J.label}),J.shortcut?z("span",{className:"dc-menu-shortcut",children:J.shortcut}):null]});let N=()=>{if(U.current)clearTimeout(U.current),U.current=null},F=(O=!1)=>{N();let E=H.current?.getBoundingClientRect();if(E&&typeof window<"u")Z(E.right+200>window.innerWidth);if(W(!0),O)setTimeout(()=>{K.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},M=()=>{N(),U.current=setTimeout(()=>W(!1),140)};return D("div",{className:"dc-menu-sub",onMouseEnter:()=>F(),onMouseLeave:M,children:[D("button",{ref:H,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":Y,disabled:B,className:"dc-menu-item",onClick:()=>Y?W(!1):F(),onKeyDown:(O)=>{if(O.key==="ArrowRight"||O.key==="Enter"||O.key===" ")O.preventDefault(),F(!0);else if(O.key==="ArrowLeft"||O.key==="Escape"){if(Y)O.stopPropagation(),W(!1)}},children:[z("span",{children:J.label}),z("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?z("div",{ref:K,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:N,onMouseLeave:M,children:V.map((O)=>{let E=typeof O.disabled==="function"?O.disabled(X):O.disabled;return D("button",{type:"button",role:"menuitem",disabled:E,title:E?O.disabledHint:void 0,className:`dc-menu-item${O.destructive?" is-destructive":""}`,onClick:()=>{if(E)return;O.onSelect(X),Q()},onKeyDown:(w)=>{if(w.key==="ArrowLeft"||w.key==="Escape")w.preventDefault(),w.stopPropagation(),W(!1),H.current?.focus()},children:[z("span",{children:O.label}),O.shortcut?z("span",{className:"dc-menu-shortcut",children:O.shortcut}):null]},O.id)})}):null]})}function b6(J){if(J.placeholder)return"placeholder";let X=J.mediaTag;if(X==="Video"||X==="OffthreadVideo"||X==="MaudeVideo")return"video";if(X==="Img")return"image";if(X==="Audio")return"audio";return"jsx"}function JE(J){let X=b6(J);if(X==="placeholder")return"✨";if(X==="video")return"▶";if(X==="image")return"◫";if(X==="audio")return"♪";return"ƒ"}function XE(J){let X=b6(J),Q=J.mediaSrc?` · ${String(J.mediaSrc).split("/").pop()}`:"";if(X==="placeholder")return`AI placeholder (${J.placeholder?.kind||"veo"}) · ${J.placeholder?.prompt||""}`;if(X==="video")return`Video clip${Q}`;if(X==="image")return`Image${Q}`;if(X==="audio")return`Audio${Q}`;return"Animated JSX (code-driven)"}function JF({name:J,size:X=15}){return z("svg",{width:X,height:X,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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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"})]})}[J]})}var SK=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block",flex:"none"}}),BX=(J,X,Q)=>Math.max(X,Math.min(Q,J));function QE(J,X){let Q=J/(X||30),Y=Math.floor(Q),W=Math.round((Q-Y)*100);return`${Y}.${String(W).padStart(2,"0")}s`}function B3(J){let[X,Q]=U9.useState(J),Y=U9.useRef(J),W=U9.useCallback((G)=>{Y.current=typeof G==="function"?G(Y.current):G,Q(Y.current)},[]);return[X,W,Y]}var XY=96,MU0=24;function YE({comps:J=[],compId:X=null,sequences:Q=[],audio:Y=[],transitions:W=[],total:G=0,frame:Z=0,playing:H=!1,loop:K=!1,onSeek:U,onPlay:V,onPause:B,onToggleLoop:N,muted:F=!1,onToggleMute:M,volume:O=1,onVolume:E,height:w,resizing:A,onResize:I,onRetime:T,onRemove:R,onReplace:$,onReplaceAudio:C,onReplaceLayer:j,onReorder:f,onReorderMove:m,onToggleHide:d,onDropMedia:a,onClose:x,selectedClipId:h=null,onSelect:l,resolveMediaUrl:v,transitionClips:n=[],onClipVerb:e,onSplitAtPlayhead:s,onAddTitle:H0,onAddImage:r,onAddAiClip:z0,onGeneratePlaceholder:i,comments:q0=[],promptText:Z0,onAddComment:I0,onResolveComment:a0,onDeleteComment:s0}){let[e0,D8]=U9.useState(()=>new Set),[s8,w8]=U9.useState(!1),N8=CK(J,X),C0=N8?.artboardLabel||N8?.artboardId||null,A0=Math.max(1,G||N8?.durationInFrames||1),$0=N8?.fps??30,Q8=BX(Math.round(Z),0,A0-1),Z8=U9.useRef(null),f8=U9.useRef(null),b8=U9.useRef(!1),O9=U9.useRef(null);U9.useEffect(()=>{O9.current?.focus()},[]);let[h0,C8]=U9.useState(null),[A9,F8]=U9.useState(0),[B0,J8]=U9.useState(null),r0=U9.useCallback((o)=>{f8.current=o,J8(o)},[]);U9.useLayoutEffect(()=>{if(!B0)return;let o=()=>F8(B0.clientWidth);o();let G0=0,L0=()=>{if(B0.clientWidth>0)o();else G0=requestAnimationFrame(L0)};if(B0.clientWidth<=0)G0=requestAnimationFrame(L0);let y0=new ResizeObserver(o);return y0.observe(B0),()=>{if(y0.disconnect(),G0)cancelAnimationFrame(G0)}},[B0]);let j0=Math.max(40,A9-XY-MU0),t0=sw(j0,A0),H8=h0==null?t0:tw(h0,j0,A0),p0=Math.ceil(A0*H8),d0=(o)=>o*H8,k8=U9.useRef(null);U9.useLayoutEffect(()=>{if(k8.current==null)return;let o=f8.current;if(o)o.scrollLeft=k8.current;k8.current=null});let _0=U9.useCallback((o,G0)=>{let L0=f8.current,y0=tw(o,j0,A0),P0=G0!=null?G0:Q.find((z8)=>z8.stableId&&z8.stableId===h)?.from??Q8;if(L0)k8.current=Wm(H8,y0,P0,L0.scrollLeft);C8(y0<=t0?null:y0)},[j0,A0,H8,t0,Q8,Q,h]);U9.useEffect(()=>{let o=(G0)=>{let L0=G0.target,y0=L0?.tagName;if(y0==="INPUT"||y0==="TEXTAREA"||y0==="SELECT"||L0?.isContentEditable)return;if((G0.metaKey||G0.ctrlKey)&&(G0.key==="="||G0.key==="+"))G0.preventDefault(),_0(H8*ew);else if((G0.metaKey||G0.ctrlKey)&&G0.key==="-")G0.preventDefault(),_0(H8/ew);else if(G0.key==="0"&&!G0.metaKey&&!G0.ctrlKey&&!G0.altKey)C8(null);else if((G0.key==="c"||G0.key==="C")&&!G0.metaKey&&!G0.ctrlKey&&!G0.altKey)i9((P0)=>!P0);else if(G0.key==="Escape")i9(!1)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[H8,_0]),U9.useEffect(()=>{let o=f8.current;if(!o)return;let G0=(L0)=>{if(!L0.ctrlKey&&!L0.metaKey)return;L0.preventDefault();let y0=Z8.current?.getBoundingClientRect(),P0=y0!=null?BX(Math.round(q3(L0.clientX-y0.left-XY,H8)),0,A0-1):Q8;_0(H8*Math.exp(-L0.deltaY*0.01),P0)};return o.addEventListener("wheel",G0,{passive:!1}),()=>o.removeEventListener("wheel",G0)},[H8,Q8,A0,_0,B0]);let X8=(()=>{let o=Math.log(H8/t0)/Math.log(tN/Math.max(0.000001,t0));return BX(Math.round((Number.isFinite(o)?o:0)*100),0,100)})(),P8=(o)=>{let G0=BX(o,0,100)/100;return t0*Math.pow(tN/Math.max(0.000001,t0),G0)},[U0,o0,R8]=B3(null),[J9,i0,a7]=B3(null),[F9,v7,I8]=B3(null),[X9,d8]=U9.useState(null),O0=U9.useRef(null),K8=U9.useCallback((o)=>{d8({frame:o}),clearTimeout(O0.current),O0.current=setTimeout(()=>d8(null),350)},[]),[S8,V9]=U9.useState(null),[x9,i9]=U9.useState(!1),[h9,t,M0]=B3(null),[E0,v0]=U9.useState(null),[W8,g8]=U9.useState(null),[t8,v8]=U9.useState(null),[W9,T9,e9]=B3(null),J7=U9.useRef(!1),FQ=U9.useCallback((o)=>{o.preventDefault(),o.stopPropagation(),o.currentTarget.setPointerCapture?.(o.pointerId);let G0=o.clientY,L0=w||216,y0=(z8)=>{I?.(BX(L0+(G0-z8.clientY),140,640))},P0=()=>{window.removeEventListener("pointermove",y0),window.removeEventListener("pointerup",P0)};window.addEventListener("pointermove",y0),window.addEventListener("pointerup",P0)},[w,I]),aX=U9.useCallback((o)=>{let G0=Z8.current;if(!G0)return;let L0=G0.getBoundingClientRect(),y0=q3(o-L0.left-XY,H8);U?.(BX(Math.round(y0),0,A0-1))},[U,A0,H8]);U9.useEffect(()=>{if(!b8.current)return;let o=(L0)=>aX(L0.clientX),G0=()=>{b8.current=!1};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}});let[BJ,oJ]=U9.useState(null),nJ=U9.useCallback((o,G0,L0)=>{let y0=Z8.current;if(!y0||!I0)return;let P0=y0.getBoundingClientRect(),z8=BX(Math.round(q3(o.clientX-P0.left-XY,H8)),0,A0-1),M8=G0&&G0.stableId?{clipStableId:G0.stableId,frameOffset:Math.max(0,z8-(G0.from||0)),frame:z8,lane:L0||void 0}:{frame:z8,lane:L0||void 0};oJ({x:BX(o.clientX-130,8,window.innerWidth-280),y:Math.max(48,o.clientY-140),anchor:M8,at:z8}),i9(!1)},[H8,A0,I0]),e7=(o)=>{if(U0)return;if(x9){o.preventDefault(),nJ(o,null,null);return}o.preventDefault(),l?.(null),b8.current=!0,aX(o.clientX),o.currentTarget.setPointerCapture?.(o.pointerId)},Y4=(o)=>o?0:8/H8;U9.useEffect(()=>{if(!U0)return;let o=(L0)=>{let y0=(L0.clientX-U0.startX)/U0.pxf,P0=U0.startFrom+Math.round(U0.startDur+y0),z8=cw(P0,U0.targets,L0.altKey?0:8/U0.pxf);if(z8!==P0)K8(z8);let M8=Math.max(1,z8-U0.startFrom),Z9=M8<=1;if(U0.maxDur>0&&M8>=U0.maxDur)M8=U0.maxDur,Z9=!0;o0((L9)=>L9?{...L9,curDur:M8,atClamp:Z9}:L9)},G0=()=>{let L0=R8.current;if(o0(null),L0&&L0.curDur!==L0.startDur)T?.(L0.ref??L0.index,{durationInFrames:L0.curDur})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[U0,T,K8]),U9.useEffect(()=>{if(!J9)return;let o=(L0)=>{let y0=(L0.clientX-J9.startX)/J9.pxf,P0=Math.max(0,Math.round(J9.startFrom+y0)),z8=Math.max(0,cw(P0,J9.targets,L0.altKey?0:8/J9.pxf));if(z8!==P0)K8(z8);if(Math.abs(z8-J9.startFrom)>=1)J7.current=!0;let M8=document.querySelector(".tl-storyline-track")?.getBoundingClientRect(),Z9=!!(M8&&L0.clientY>=M8.top&&L0.clientY<=M8.bottom);i0((L9)=>L9?{...L9,curFrom:z8,overStory:Z9}:L9)},G0=(L0)=>{let y0=a7.current;if(i0(null),!y0)return;let P0=document.querySelector(".tl-storyline-track")?.getBoundingClientRect();if(P0&&e&&L0.clientY>=P0.top&&L0.clientY<=P0.bottom&&J7.current)e(y0.ref??{index:y0.index},"to-storyline",{});else if(y0.curFrom!==y0.startFrom)T?.(y0.ref??y0.index,{from:y0.curFrom})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[J9,T,e,K8]),U9.useEffect(()=>{if(!W9)return;let o=(L0)=>{let y0=Math.round((L0.clientX-W9.startX)/W9.pxf),P0=Math.min(W9.maxDelta,y0);T9((z8)=>z8?{...z8,delta:P0}:z8)},G0=()=>{let L0=e9.current;if(T9(null),L0&&L0.delta)e?.(L0.ref,"trim-in",{deltaFrames:L0.delta})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[W9,e]);let R7=(o,G0)=>{o.stopPropagation(),o.preventDefault();let L0=Q[G0];if(!L0)return;T9({index:G0,ref:j9(L0,G0),startX:o.clientX,pxf:H8,delta:0,maxDelta:Math.max(0,(L0.duration??1)-1)})},FX=(o)=>ig({fps:$0,totalFrames:A0,clips:Q,movingIndex:o,playhead:Q8}),j9=(o,G0)=>({stableId:o?.stableId??null,index:G0}),VY=(o,G0)=>{if(o.stopPropagation(),!m)return;let y0=Q.map((P0,z8)=>({s:P0,i:z8})).filter(({s:P0})=>P0.series).findIndex(({i:P0})=>P0===G0);if(y0<0)return;J7.current=!1,v7({index:G0,slot:y0,targetSlot:y0,dx:0,startX:o.clientX,pxf:H8})};U9.useEffect(()=>{if(!F9)return;let o=Q.map((y0,P0)=>({s:y0,i:P0})).filter(({s:y0})=>y0.series),G0=(y0)=>{let P0=y0.clientX-F9.startX;if(Math.abs(P0)>3)J7.current=!0;let z8=o[F9.slot];if(!z8)return;let M8=z8.s.from+z8.s.duration/2+P0/F9.pxf,Z9=0;o.forEach(({s:L9},I6)=>{if(I6===F9.slot)return;if(L9.from+L9.duration/2<M8)Z9+=1}),v7((L9)=>L9?{...L9,dx:P0,targetSlot:Z9}:L9)},L0=(y0)=>{let P0=I8.current;if(v7(null),!P0)return;if(J7.current&&e){let z8=document.querySelector(".tl-storyline-track")?.getBoundingClientRect();if(z8&&y0.clientY<z8.top-6){let M8=Q[P0.index];if(M8){e(j9(M8,P0.index),"to-overlay",{});return}}}if(P0.targetSlot!==P0.slot){let z8=o[P0.slot],M8=o.filter((Z9,L9)=>L9!==P0.slot);if(z8&&M8.length)if(P0.targetSlot<=0)m?.(j9(z8.s,z8.i),j9(M8[0].s,M8[0].i),"before");else{let Z9=M8[Math.min(P0.targetSlot,M8.length)-1];m?.(j9(z8.s,z8.i),j9(Z9.s,Z9.i),"after")}}};return window.addEventListener("pointermove",G0),window.addEventListener("pointerup",L0,{once:!0}),()=>{window.removeEventListener("pointermove",G0),window.removeEventListener("pointerup",L0)}},[F9,Q,m,e]);let p7=(o,G0,L0)=>{if(!e)return;o.stopPropagation(),o.preventDefault(),t({index:G0,docIdx:L0,curTarget:L0})};U9.useEffect(()=>{if(!h9)return;let o=(L0)=>{let y0=h9.docIdx;for(let P0 of document.querySelectorAll("[data-layer-doc]")){let z8=P0.getBoundingClientRect();if(L0.clientY>=z8.top&&L0.clientY<=z8.bottom)y0=Number(P0.dataset.layerDoc)}t((P0)=>P0?{...P0,curTarget:y0}:P0)},G0=()=>{let L0=M0.current;if(t(null),L0&&L0.curTarget!==L0.docIdx){let y0=Q[L0.index];if(y0)e?.(j9(y0,L0.index),"layer-order",{toIndex:L0.curTarget})}};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[h9,Q,e]);let y5=(o,G0,L0)=>{if(Q[G0]?.loose)return;if(Q[G0]?.series){VY(o,G0);return}if(!T)return;o.stopPropagation(),J7.current=!1,i0({index:G0,ref:j9(Q[G0],G0),startX:o.clientX,startFrom:L0,pxf:H8,curFrom:L0,targets:FX(G0)})},HG=(o,G0,L0)=>{o.stopPropagation(),o.preventDefault();let y0=Q[G0],P0=y0?.from??0;o0({index:G0,ref:j9(y0,G0),startX:o.clientX,startDur:L0,startFrom:P0,pxf:H8,curDur:L0,atClamp:!1,maxDur:y0?.mediaSrc&&z6[`d|${y0.mediaSrc}`]||0,targets:FX(G0)})},f7=(o)=>{let G0=o>=0?"+":"−",L0=Math.abs(Math.round(o));return`${G0}${L0}f / ${G0}${(L0/($0||30)).toFixed(2)}s`},qY=Gm(H8,$0),LX=[];for(let o=0;o<=A0-1;o+=qY)LX.push(o);let V7=[],rJ=[],l9=[];Q.forEach((o,G0)=>{if(o.series)V7.push({seq:o,i:G0});else if(b6(o)==="audio")l9.push({seq:o,i:G0});else rJ.push({seq:o,i:G0})});let q7=V7.length>0&&Q.some((o)=>b6(o)!=="jsx"),[z6,SJ]=U9.useState({}),j5=U9.useCallback((o)=>{if(!o)return null;if(o.startsWith("//"))return null;if(/^(https?:|data:|blob:)/i.test(o))return null;if(o.startsWith("/"))return o;return v?v(o):null},[v]);U9.useEffect(()=>{let o=!0;for(let G0 of Q){if(b6(G0)!=="video"||!G0.mediaSrc)continue;let L0=j5(G0.mediaSrc);if(!L0)continue;let y0=rw(Math.max(2,G0.duration*H8)),P0=`s|${G0.mediaSrc}|${y0}`;if(z6[P0]!==void 0)continue;SJ((z8)=>z8[P0]!==void 0?z8:{...z8,[P0]:null}),Jm(L0,y0).then((z8)=>{if(o&&z8)SJ((M8)=>({...M8,[P0]:z8}))})}for(let G0 of Y){if(!G0.src)continue;let L0=j5(G0.src);if(!L0)continue;let y0=`p|${G0.src}`;if(z6[y0]!==void 0)continue;SJ((P0)=>P0[y0]!==void 0?P0:{...P0,[y0]:null}),Xm(L0).then((P0)=>{if(o&&P0)SJ((z8)=>({...z8,[y0]:P0}))})}for(let G0 of Q){if(b6(G0)!=="video"||!G0.mediaSrc)continue;let L0=`d|${G0.mediaSrc}`;if(z6[L0]!==void 0)continue;SJ((y0)=>y0[L0]!==void 0?y0:{...y0,[L0]:null}),fetch(`/_api/footage?asset=${encodeURIComponent(G0.mediaSrc)}`).then((y0)=>y0.ok?y0.json():null).then((y0)=>{if(!o)return;let P0=Number(y0?.durationSec),z8=Number.isFinite(P0)&&P0>0?Math.round(P0*($0||30)):0;SJ((M8)=>({...M8,[L0]:z8}))}).catch(()=>{if(o)SJ((y0)=>({...y0,[L0]:0}))})}return()=>{o=!1}},[Q,Y,H8,j5,z6,$0]);let LQ=(()=>{if(!F9)return null;let o=Q.map((Z9,L9)=>({s:Z9,i:L9})).filter(({s:Z9})=>Z9.series),G0=o[F9.slot];if(!G0)return null;let L0=W&&W[0]?.dur||0,y0=o.filter((Z9,L9)=>L9!==F9.slot),P0=[...y0];P0.splice(Math.max(0,Math.min(F9.targetSlot,y0.length)),0,G0);let z8=new Map,M8=o[0]?.s.from??0;for(let{s:Z9,i:L9}of P0)z8.set(L9,M8),M8+=Z9.duration-L0;return z8})(),P6=(o)=>Array.from(o?.types??[]).includes("Files"),W4=(o)=>{if(!a||!P6(o.dataTransfer))return;o.preventDefault(),o.stopPropagation(),w8(!1),V9(null);let G0=Array.from(o.dataTransfer.files||[]);if(G0.length)a(G0,N8?{lane:"overlay",frame:Q8}:null)},DQ=()=>{let o=Q.filter((L0)=>L0.series),G0=o.map((L0)=>d0(L0.from));if(o.length){let L0=o[o.length-1];G0.push(d0(L0.from+L0.duration))}return G0},zG=(o)=>{if(!a||!P6(o.dataTransfer))return;o.preventDefault(),o.stopPropagation(),o.dataTransfer.dropEffect="copy";let G0=o.currentTarget.getBoundingClientRect(),L0=o.clientX-G0.left,y0=DQ(),P0=0,z8=1/0;y0.forEach((M8,Z9)=>{let L9=Math.abs(M8-L0);if(L9<z8)z8=L9,P0=Z9}),V9({lane:"storyline",slot:P0,x:y0[P0]??L0})},bJ=(o,G0)=>(L0)=>{if(!a||!P6(L0.dataTransfer))return;L0.preventDefault(),L0.stopPropagation(),L0.dataTransfer.dropEffect="copy";let y0=L0.currentTarget.getBoundingClientRect(),P0=L0.clientX-y0.left,z8=BX(Math.round(q3(P0,H8)),0,A0-1);V9({lane:o,row:G0,frame:z8,x:P0})},yJ=(o,G0)=>S8&&S8.lane===o&&S8.row===G0?z("span",{className:"tl-drop-caret","data-testid":"timeline-drop-caret",style:{left:S8.x-1}}):null,aJ=(o)=>(G0)=>{if(!a||!P6(G0.dataTransfer))return;G0.preventDefault(),G0.stopPropagation(),w8(!1);let L0=S8;V9(null);let y0=Array.from(G0.dataTransfer.files||[]);if(!y0.length)return;if(o.lane==="storyline")a(y0,{lane:"storyline",index:L0?.slot??void 0});else a(y0,{lane:o.lane,frame:L0?.frame??0})},v5=(o,G0,{lane:L0,laneName:y0})=>{let P0=U0&&U0.index===G0?U0.curDur:o.duration,z8=!!(U0&&U0.index===G0),M8=J9&&J9.index===G0?J9.curFrom:o.from,Z9=!!(J9&&J9.index===G0),L9=0,I6=!1;if(L0==="storyline"&&F9){if(F9.index===G0)I6=!0,L9=F9.dx;else if(LQ?.has(G0))M8=LQ.get(G0)}let s6=(Array.isArray(o.layers)?o.layers:[]).length>=2,FJ=h!=null&&o.stableId===h,f5=["Video","OffthreadVideo","Audio","Img","MaudeVideo","MaudeAudio","MaudeImg"].includes(o.label)&&o.mediaSrc?String(o.mediaSrc).split("/").pop():o.label,KG=/^[a-f0-9]{6,16}\.\w+$/i.test(f5||"")?`Clip ${G0+1}`:f5,jJ=!!(W9&&W9.index===G0),C7=jJ?W9.delta:0,R9=d0(M8)+L9+(jJ?d0(C7):0),DX=Math.max(2,d0(P0-C7)),K6=o.mediaProps||null;return D(U9.Fragment,{children:[D("button",{type:"button",className:`tl-seq-block${z8?" is-resizing":""}${Z9?" is-moving":""}${I6?" is-dragging":""}${o.hidden?" is-hidden":""}${FJ?" is-selected":""}${L0==="storyline"?" tl-beat":""}`,"data-testid":`timeline-seq-${G0}`,"data-clip-id":o.stableId||void 0,"data-kind":b6(o),"data-hidden":o.hidden?"1":void 0,title:o.series?`${o.label} · ${M8}–${M8+P0}f (${P0}f) · series beat — trim the right edge to retime`:`${o.label} · ${M8}–${M8+P0}f (${P0}f) · drag to move (Alt = no snap)`,"aria-label":o.series?`${o.label}, series beat, frames ${M8} to ${M8+P0}. Click to select.`:`${o.label}, from frame ${M8} to ${M8+P0}, ${P0} frames. Click to select; drag to move.`,style:{left:R9,width:DX,cursor:T&&!o.series?"grab":void 0},onContextMenu:(a8)=>{a8.preventDefault(),a8.stopPropagation(),l?.(o.stableId??null),v0({index:G0,x:a8.clientX,y:a8.clientY})},onPointerDown:(a8)=>{if(x9){a8.stopPropagation(),a8.preventDefault(),nJ(a8,o,y0||L0);return}y5(a8,G0,o.from)},onDoubleClick:(a8)=>{if(a8.stopPropagation(),o.loose)return;l?.(o.stableId??null),v8({mode:"clip",index:G0,x:a8.clientX-120,y:Math.max(60,a8.clientY-320)})},onClick:(a8)=>{if(a8.stopPropagation(),J7.current){J7.current=!1;return}l?.(o.stableId??null)},children:[K6?.playbackRate&&K6.playbackRate!==1?D("span",{className:"tl-chip tl-chip-speed","data-testid":`timeline-speed-chip-${G0}`,children:[K6.playbackRate,"×"]}):null,K6?.muted?z("span",{className:"tl-chip tl-chip-mute",title:"Muted","data-testid":`timeline-mute-chip-${G0}`,children:"\uD83D\uDD07"}):null,(()=>{if(b6(o)==="image"&&o.mediaSrc){let h6=j5(o.mediaSrc);if(!h6)return null;return z("span",{className:"tl-strip tl-strip--img","aria-hidden":"true",children:z("img",{src:h6,alt:"",draggable:!1})})}if(b6(o)!=="video"||!o.mediaSrc)return null;let a8=rw(Math.max(2,o.duration*H8)),J6=z6[`s|${o.mediaSrc}|${a8}`];if(!J6)return null;return z("span",{className:"tl-strip","aria-hidden":"true",children:J6.map((h6,MX)=>z("img",{src:h6,alt:"",draggable:!1},MX))})})(),z("span",{className:"tl-kind","data-kind":b6(o),title:XE(o),children:JE(o)}),D("span",{className:"tl-seq-name",children:[KG,z8?` · ${P0}f`:"",Z9?` · @${M8}f`:""]}),o.keyframes.map((a8,J6)=>{let h6=(a8.from-o.from)/Math.max(1,o.duration)*100,MX=(a8.to-a8.from)/Math.max(1,o.duration)*100;return z("span",{className:"tl-kf","data-testid":`timeline-kf-${G0}-${J6}`,style:{left:`${BX(h6,0,100)}%`,width:`${Math.max(1.5,MX)}%`},title:`seek to keyframe ${a8.from}f (animates ${a8.from}–${a8.to}f)`,onPointerDown:(OQ)=>OQ.stopPropagation(),onClick:(OQ)=>{OQ.stopPropagation(),U?.(a8.from)}},J6)}),(q0||[]).filter((a8)=>a8.timeline?.clipStableId&&a8.timeline.clipStableId===o.stableId).map((a8)=>z("span",{role:"button",tabIndex:-1,className:`tl-clip-pin${a8.status==="resolved"?" is-resolved":""}`,"data-testid":`timeline-clip-pin-${a8.id}`,title:`${a8.author||"comment"}: ${a8.text}`,style:{left:d0(BX(a8.timeline.frameOffset||0,0,Math.max(0,P0-1)))},onPointerDown:(J6)=>J6.stopPropagation(),onClick:(J6)=>{J6.stopPropagation(),g8({id:a8.id,x:J6.clientX-130,y:Math.max(60,J6.clientY-180)})},children:"\uD83D\uDCAC"},`cm${a8.id}`)),L0==="storyline"&&s6?z("span",{role:"button",tabIndex:-1,className:"tl-beat-expand","data-testid":`timeline-beat-expand-${G0}`,title:e0.has(G0)?"Show this beat’s layers":"Collapse layers",onPointerDown:(a8)=>a8.stopPropagation(),onClick:(a8)=>{a8.stopPropagation(),D8((J6)=>{let h6=new Set(J6);if(h6.has(G0))h6.delete(G0);else h6.add(G0);return h6})},children:e0.has(G0)?"▸":"▾"}):null]}),T&&!o.loose?z("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${G0}`,title:"Drag to retime this sequence",style:{left:R9+DX-5},onPointerDown:(a8)=>HG(a8,G0,o.duration),onClick:(a8)=>a8.stopPropagation()}):null,e&&!o.loose&&o.mediaSrc&&(b6(o)==="video"||b6(o)==="audio")?z("span",{className:"tl-seq-trim-in","data-testid":`timeline-trim-in-${G0}`,title:"Drag to trim the in-point (left edge)",style:{left:R9-1},onPointerDown:(a8)=>R7(a8,G0),onClick:(a8)=>a8.stopPropagation()}):null,jJ?z("span",{className:`tl-trim-tip${C7>=W9.maxDelta&&C7>0?" is-clamped":""}`,"data-testid":"timeline-trim-in-tip",style:{left:R9},children:f7(C7)}):null,z8?z("span",{className:`tl-trim-tip${U0.atClamp?" is-clamped":""}`,"data-testid":"timeline-trim-tip",style:{left:R9+DX+8},children:f7(P0-U0.startDur)}):null,Z9?z("span",{className:"tl-trim-tip","data-testid":"timeline-move-tip",style:{left:R9},children:f7(M8-J9.startFrom)}):null,$&&o.replaceable&&!s6?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${G0}`,title:`Replace this ${b6(o)}`,"aria-label":`Replace media in ${o.label}`,style:{left:R9+DX-34},onPointerDown:(a8)=>a8.stopPropagation(),onClick:(a8)=>{a8.stopPropagation(),$(j9(o,G0))},children:"⇄"}):null]},`b${G0}`)},G4=()=>{if(!e)return null;let o=new Set((W||[]).map((G0)=>G0.afterIndex));return V7.slice(0,-1).map(({seq:G0,i:L0},y0)=>{if(o.has(L0))return null;let P0=V7[y0+1];if(!P0)return null;return z("button",{type:"button",className:"tl-seam tl-seam-add","data-testid":`timeline-seam-add-${y0}`,title:"Add transition (fade · 15f — click the chip after to change)",style:{left:d0(P0.seq.from)-9},onPointerDown:(z8)=>z8.stopPropagation(),onClick:(z8)=>{z8.stopPropagation(),e(j9(G0,L0),"insert-transition",{presentation:"fade",durationInFrames:15})},children:z(SK,{as:X3,size:13})},`addseam${y0}`)})},NJ=()=>(W||[]).map((o,G0)=>{let L0=Q[o.afterIndex+1];if(!L0)return null;let y0=d0(L0.from+(o.dur||0)/2);return z("button",{type:"button",className:"tl-seam","data-testid":`timeline-seam-${G0}`,title:`Transition · ${o.dur||0}f — click to edit`,style:{left:y0-9},onPointerDown:(P0)=>P0.stopPropagation(),onClick:(P0)=>{P0.stopPropagation(),v8({mode:"transition",seam:G0,x:P0.clientX-120,y:Math.max(60,P0.clientY-260)})},children:"⧓"},`seam${G0}`)}),Z4=(o,G0)=>D("div",{className:"tl-row","data-testid":`timeline-audio-${G0}`,children:[D("span",{className:"tl-row-label",title:o.label,children:[z("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${o.label}`,"aria-label":`Audio · ${o.label}`,children:"♪"}),z("span",{className:"tl-row-label-text",children:o.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("audio",`a${G0}`),onDrop:aJ({lane:"audio"}),children:[yJ("audio",`a${G0}`),D("div",{className:"tl-audio-block",title:`${o.label} · ${o.from}–${o.from+o.duration}f`,style:{left:d0(o.from),width:Math.max(2,d0(o.duration))},children:[z("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:o.src&&z6[`p|${o.src}`]?z("path",{className:"tl-wave-real",d:Qm(z6[`p|${o.src}`])}):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:o.label})]}),C?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${G0}`,title:"Replace this audio","aria-label":`Replace audio ${o.label}`,style:{left:d0(o.from)+Math.max(2,d0(o.duration))-20},onPointerDown:(L0)=>L0.stopPropagation(),onClick:(L0)=>{L0.stopPropagation(),C(G0)},children:"⇄"}):null]})]},`a${G0}`);return D("aside",{ref:O9,tabIndex:-1,className:`tl-panel${A?" is-resizing":""}${s8?" is-drop":""}${x9?" is-commenting":""}`,style:{...w?{height:w}:{},outline:"none"},onPointerEnter:()=>{if(!document.activeElement||document.activeElement===document.body)O9.current?.focus();else{let o=document.activeElement.tagName;if(o!=="INPUT"&&o!=="TEXTAREA"&&o!=="SELECT")O9.current?.focus()}},onDragOver:(o)=>{if(!a||!P6(o.dataTransfer))return;if(o.preventDefault(),o.dataTransfer.dropEffect="copy",!s8)w8(!0)},onDragLeave:(o)=>{if(o.relatedTarget==null)w8(!1),V9(null)},onDrop:W4,"aria-label":"Timeline","data-testid":"timeline-panel",children:[z("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:FQ}),D("div",{className:"tl-head",children:[N8?D(Q0,{children:[z("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":H?"Pause":"Play","aria-pressed":H,"data-testid":"timeline-playpause",onClick:()=>H?B?.():V?.(),children:z(JF,{name:H?"pause":"play"})}),z("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>U?.(0),children:z(JF,{name:"start"})}),z("button",{type:"button",className:`tl-btn${K?" is-on":""}`,"aria-label":"Loop","aria-pressed":K,"data-testid":"timeline-loop",onClick:()=>N?.(),children:z(JF,{name:"loop"})}),N8?z("button",{type:"button",className:`tl-btn${F?"":" is-on"}`,"aria-label":F?"Unmute":"Mute","aria-pressed":!F,"data-testid":"timeline-mute",title:F?"Unmute audio":"Mute audio",onClick:()=>M?.(),children:z(JF,{name:F?"muted":"sound"})}):null,N8?z("input",{type:"range",className:"tl-volume",min:"0",max:"100",value:Math.round((F?0:O)*100),"data-testid":"timeline-volume","aria-label":"Volume",title:"Volume",onChange:(o)=>E?.(Number(o.target.value)/100)}):null,J.length>1?z("span",{className:`tl-artboard${C0?"":" is-unknown"}`,"data-testid":"timeline-artboard",title:C0?`Timeline is scoped to artboard "${C0}" — pan to another artboard to switch`:"This canvas has several video comps and the Timeline couldn't tell which artboard this one sits in — the transport may be moving a comp you're not looking at",children:C0??"artboard ?"}):null,D("span",{className:"tl-readout","data-testid":"timeline-readout",children:[z("b",{children:Q8}),z("span",{className:"tl-sep",children:"/"}),A0-1,z("span",{className:"tl-time",children:QE(Q8,$0)})]}),z("span",{className:"tl-spacer"}),s?z("button",{type:"button",className:"tl-btn","aria-label":"Split at playhead",title:"Split at playhead (⌘B)","data-testid":"timeline-split",onClick:()=>s(),children:z(SK,{as:aZ})}):null,H0?z("button",{type:"button",className:"tl-btn","aria-label":"Add title overlay",title:"Add a title overlay at the playhead","data-testid":"timeline-add-title",onClick:()=>H0(Q8),children:z(SK,{as:H3})}):null,r?z("button",{type:"button",className:"tl-btn","aria-label":"Add image overlay",title:"Add an image overlay at the playhead","data-testid":"timeline-add-image",onClick:()=>r(Q8),children:z(SK,{as:aV})}):null,z0?z("button",{type:"button",className:"tl-btn","aria-label":"Add AI placeholder clip",title:"Add an AI placeholder clip at the end of the storyline","data-testid":"timeline-placeholder-add",onClick:()=>z0(),children:z(SK,{as:xW})}):null,I0?z("button",{type:"button",className:`tl-btn${x9?" is-on":""}`,"aria-label":"Comment tool","aria-pressed":x9,title:"Comment tool — click anywhere on the timeline to pin a comment (C)","data-testid":"timeline-comment-tool",onClick:()=>i9((o)=>!o),children:z(SK,{as:tV})}):null]}):z("span",{className:"tl-title",children:"Timeline"}),z("span",{className:"tl-spacer"}),N8&&A0>900?D("span",{className:"tl-long-badge","data-testid":"timeline-long-badge",title:`Long comp: ${A0} frames (≈${Math.round(A0/($0||30))}s). Exports over 900 frames can take several minutes on the fallback path — see the export dialog.`,children:["⚠ ",Math.round(A0/($0||30)),"s"]}):null,N8?D("span",{className:"tl-meta",children:[$0," fps · ",A0,"f"]}):null,N8?z("input",{type:"range",className:"tl-zoom",min:"0",max:"100",value:X8,"data-testid":"timeline-zoom","aria-label":"Timeline zoom",title:"Zoom (⌘+/⌘−, 0 = fit)",onChange:(o)=>_0(P8(Number(o.target.value)))}):null,z("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:x,children:"×"})]}),!N8?D("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No video-comp on this canvas. ",z("b",{children:"Drop video clips right here"})," to start a new cut, use ",z("b",{children:"⌘K → New video…"})," for an empty one, or make an artboard a",z("code",{children:"<VideoComp>"})," yourself."]}):z("div",{className:"tl-scroll",ref:r0,children:D("div",{className:"tl-tracks",ref:Z8,"data-testid":"timeline-track",style:{width:XY+p0},onPointerDown:e7,onDragOver:bJ("overlay","tracks"),onDrop:aJ({lane:"overlay"}),children:[q0.length?z("div",{className:"tl-comments-strip","data-testid":"timeline-comments-strip",children:q0.map((o)=>{let G0=o.timeline||{},L0=null,y0=!1;if(G0.clipStableId){let P0=Q.find((z8)=>z8.stableId===G0.clipStableId);if(P0)L0=P0.from+Math.min(G0.frameOffset||0,Math.max(0,P0.duration-1));else if(G0.frame!=null)L0=G0.frame,y0=!0}else if(G0.frame!=null)L0=G0.frame;if(L0==null)return null;return z("button",{type:"button",className:`tl-comment-pin${o.status==="resolved"?" is-resolved":""}${y0?" is-detached":""}`,"data-testid":`timeline-comment-${o.id}`,title:`${o.author||"comment"}${y0?" (detached — clip removed)":""}: ${o.text}`,style:{left:XY+d0(BX(L0,0,A0-1))-8},onPointerDown:(P0)=>P0.stopPropagation(),onClick:(P0)=>{P0.stopPropagation(),U?.(BX(L0,0,A0-1)),g8({id:o.id,x:P0.clientX-130,y:Math.max(60,P0.clientY-180)})},children:"\uD83D\uDCAC"},o.id)})}):null,z("div",{className:"tl-ruler",style:{width:p0},children:LX.map((o)=>{let G0=o%($0||30)===0,L0=G0||qY<=5;return z("span",{className:`tl-tick${G0?" is-major":""}`,style:{left:d0(o)},children:L0?z("span",{className:"tl-tick-label",children:Zm(o,$0)}):null},o)})}),yJ("overlay","tracks"),Q.length===0?D("div",{className:"tl-row",children:[z("span",{className:"tl-row-label",children:"comp"}),z("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:z("div",{className:"tl-seq-block",style:{left:0,width:p0},children:z("span",{className:"tl-seq-name",children:"whole composition"})})})]}):q7?D(Q0,{children:[(()=>{let o=rJ.filter(({seq:G0})=>!G0.loose);return[...rJ].reverse().map(({seq:G0,i:L0})=>{let y0=G0.loose?null:o.findIndex((M8)=>M8.i===L0),P0=y0==null?null:y0+2,z8="tl-row tl-row--overlay"+(h9&&h9.index===L0?" is-layer-dragging":"")+(h9&&y0!=null&&h9.index!==L0&&h9.curTarget===y0?" is-layer-target":"");return D("div",{className:z8,"data-testid":`timeline-row-${L0}`,...y0!=null?{"data-layer-doc":y0}:{},children:[D("span",{className:"tl-row-label",title:G0.mediaSrc||G0.label,children:[y0!=null?D("span",{className:"tl-lane-id tl-lane-id--grab","data-testid":`timeline-lane-chip-${L0}`,title:"Drag up/down to reorder layers",onPointerDown:(M8)=>p7(M8,L0,y0),children:["V",P0]}):z("span",{className:"tl-lane-id",title:"Loose media — no layer order",children:"◌"}),z("span",{className:"tl-kind","data-kind":b6(G0),children:JE(G0)})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("overlay",`o${L0}`),onDrop:aJ({lane:"overlay"}),children:[v5(G0,L0,{lane:"overlay",laneName:P0!=null?`V${P0}`:"loose"}),yJ("overlay",`o${L0}`)]})]},`o${L0}`)})})(),D("div",{className:"tl-row tl-row--storyline","data-testid":"timeline-storyline",children:[D("span",{className:"tl-row-label",children:[z("span",{className:"tl-lane-id tl-lane-id--story",children:"V1"}),z("span",{className:"tl-band-tag tl-band-tag--story",children:"storyline"})]}),D("div",{className:`tl-row-track tl-storyline-track${F9?" is-reordering":""}${J9?.overStory?" is-drop-target":""}`,style:{width:p0,flex:"none"},onDragOver:zG,onDrop:aJ({lane:"storyline"}),children:[V7.map(({seq:o,i:G0})=>v5(o,G0,{lane:"storyline",laneName:"V1"})),F9?null:NJ(),F9?null:G4(),S8?.lane==="storyline"?z("span",{className:"tl-drop-caret","data-testid":"timeline-drop-caret",style:{left:S8.x-1}}):null]})]}),V7.filter(({seq:o,i:G0})=>Array.isArray(o.layers)&&o.layers.length>=2&&!e0.has(G0)).map(({seq:o,i:G0})=>o.layers.map((L0,y0)=>{let P0=L0.kind==="video"||L0.kind==="image"||L0.kind==="audio"?L0.kind:"jsx",z8=L0.kind==="video"?"▶":L0.kind==="image"?"◫":L0.kind==="audio"?"♪":"ƒ";return D("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${G0}-${y0}`,children:[D("span",{className:"tl-row-label",title:`${o.label} · ${L0.label}`,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":P0,children:z8}),z("span",{className:"tl-row-label-text",children:L0.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":P0,"data-testid":`timeline-layer-block-${G0}-${y0}`,title:`${o.label} · ${L0.label} (${L0.kind} layer)`,style:{left:d0(o.from),width:Math.max(2,d0(o.duration))},onContextMenu:(M8)=>{M8.preventDefault(),M8.stopPropagation(),v0({index:G0,layerIndex:y0,x:M8.clientX,y:M8.clientY})},children:z("span",{className:"tl-seq-name",children:L0.label})}),j&&(L0.mediaCdId||L0.mediaArrayRef)?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${G0}-${y0}`,title:`Replace this ${L0.kind}`,"aria-label":`Replace ${L0.label}`,style:{left:d0(o.from)+Math.max(2,d0(o.duration))-20},onPointerDown:(M8)=>M8.stopPropagation(),onClick:(M8)=>{M8.stopPropagation(),j(j9(o,G0),y0)},children:"⇄"}):null]})]},`bl${G0}-${y0}`)})),l9.map(({seq:o,i:G0},L0)=>D("div",{className:"tl-row tl-row--overlay tl-row--audio","data-testid":`timeline-row-${G0}`,children:[D("span",{className:"tl-row-label",title:o.mediaSrc||o.label,children:[D("span",{className:"tl-lane-id tl-lane-id--audio",children:["A",L0+1]}),z("span",{className:"tl-kind","data-kind":"audio",children:"♪"})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("audio",`ac${G0}`),onDrop:aJ({lane:"audio"}),children:[v5(o,G0,{lane:"audio",laneName:`A${L0+1}`}),yJ("audio",`ac${G0}`)]})]},`ac${G0}`)),Y.map((o,G0)=>Z4(o,G0)),z("div",{className:`tl-newlayer-zone${S8?.row==="newlayer"?" is-active":""}`,"data-testid":"timeline-newlayer-zone",onDragOver:bJ("overlay","newlayer"),onDrop:aJ({lane:"overlay"}),children:z("span",{style:{marginLeft:XY},children:"Drop clips here — new layer"})})]}):D(Q0,{children:[Q.map((o,G0)=>{let L0=Array.isArray(o.layers)?o.layers:[],y0=L0.length>=2,P0=y0&&!e0.has(G0),z8=U0&&U0.index===G0?U0.curDur:o.duration;return D(U9.Fragment,{children:[D("div",{className:"tl-row","data-testid":`timeline-row-${G0}`,children:[D("span",{className:"tl-row-label",title:o.label,children:[y0?z("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${G0}`,title:P0?"Collapse layers":"Show layers","aria-label":P0?`Collapse ${o.label} layers`:`Show ${o.label} layers`,"aria-expanded":P0,onPointerDown:(M8)=>M8.stopPropagation(),onClick:(M8)=>{M8.stopPropagation(),M8.preventDefault(),D8((Z9)=>{let L9=new Set(Z9);if(L9.has(G0))L9.delete(G0);else L9.add(G0);return L9})},children:P0?"▾":"▸"}):z("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":b6(o),title:XE(o),"aria-label":XE(o),children:JE(o)}),z("span",{className:"tl-row-label-text",children:o.label})]}),z("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:v5(o,G0,{lane:"row"})})]}),P0?L0.map((M8,Z9)=>{let L9=M8.kind==="video"?"video":M8.kind==="image"?"image":M8.kind==="audio"?"audio":"jsx",I6=M8.kind==="video"?"▶":M8.kind==="image"?"◫":M8.kind==="audio"?"♪":"ƒ",MQ=!!(M8.mediaCdId||M8.mediaArrayRef);return D("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${G0}-${Z9}`,children:[D("span",{className:"tl-row-label",title:M8.label,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":L9,children:I6}),z("span",{className:"tl-row-label-text",children:M8.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":L9,"data-testid":`timeline-layer-block-${G0}-${Z9}`,title:`${M8.label} (${M8.kind} layer)`,style:{left:d0(o.from),width:Math.max(2,d0(z8))},onContextMenu:(s6)=>{s6.preventDefault(),s6.stopPropagation(),v0({index:G0,layerIndex:Z9,x:s6.clientX,y:s6.clientY})},children:z("span",{className:"tl-seq-name",children:M8.label})}),j&&MQ?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${G0}-${Z9}`,title:`Replace this ${M8.kind}`,"aria-label":`Replace ${M8.label}`,style:{left:d0(o.from)+Math.max(2,d0(z8))-20},onPointerDown:(s6)=>s6.stopPropagation(),onClick:(s6)=>{s6.stopPropagation(),j(j9(o,G0),Z9)},children:"⇄"}):null]})]},`l${Z9}`)}):null]},G0)}),Y.map((o,G0)=>Z4(o,G0))]}),X9?z("span",{className:"tl-snapline",style:{left:XY+d0(X9.frame)}}):null,z("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:XY+d0(Q8)},children:z("span",{className:"tl-playhead-time",children:QE(Q8,$0)})})]})}),BJ?N3.createPortal(D("div",{className:"tlci tlci--comment",style:{left:BJ.x,top:BJ.y},children:[D("div",{className:"tlci-head",style:{cursor:"default"},children:[D("span",{className:"tlci-title",children:["Comment @ ",QE(BJ.at,$0),BJ.anchor.lane?` · ${BJ.anchor.lane}`:""]}),z("button",{type:"button",className:"tlci-x","aria-label":"Close",onClick:()=>oJ(null),children:"×"})]}),D("div",{className:"tlci-body",children:[z("textarea",{className:"tlci-textarea",rows:3,autoFocus:!0,placeholder:"Comment… (Enter to add)","data-testid":"timeline-comment-composer",onKeyDown:(o)=>{if(o.stopPropagation(),o.key==="Enter"&&!o.shiftKey){o.preventDefault();let G0=o.currentTarget.value.trim();if(G0)I0?.(BJ.anchor,G0);oJ(null)}else if(o.key==="Escape")oJ(null)}}),z("div",{className:"tlci-row",children:z("button",{type:"button",className:"tlci-btn","data-testid":"timeline-comment-submit",onClick:(o)=>{let L0=o.currentTarget.closest(".tlci")?.querySelector("textarea")?.value?.trim();if(L0)I0?.(BJ.anchor,L0);oJ(null)},children:"Add comment"})})]})]}),document.body):null,W8?N3.createPortal((()=>{let o=q0.find((G0)=>G0.id===W8.id);if(!o)return null;return D("div",{className:"tlci",style:{left:W8.x,top:W8.y},role:"dialog","aria-label":"Timeline comment","data-testid":"timeline-comment-popover",onPointerDown:(G0)=>G0.stopPropagation(),children:[D("div",{className:"tlci-head",children:[D("span",{className:"tlci-title",children:["\uD83D\uDCAC ",o.author||"comment"]}),z("button",{type:"button",className:"tlci-x","aria-label":"Close",onClick:()=>g8(null),children:"×"})]}),D("div",{className:"tlci-body",children:[z("p",{className:"tlci-comment-text",children:o.text}),(o.thread||[]).map((G0,L0)=>D("p",{className:"tlci-note",children:["↳ ",G0.author?`${G0.author}: `:"",G0.body]},L0)),D("div",{className:"tlci-presets",children:[o.status!=="resolved"&&a0?z("button",{type:"button",className:"tlci-chip",onClick:()=>{a0(o.id),g8(null)},children:"Resolve"}):null,s0?z("button",{type:"button",className:"tlci-chip",onClick:()=>{s0(o.id),g8(null)},children:"Delete"}):null]})]})]})})(),document.body):null,t8?N3.createPortal((()=>{if(t8.mode==="transition"){let G0=n[t8.seam],L0=(W||[])[t8.seam];if(!G0)return null;return z(aN,{mode:"transition",clipLabel:"Transition",transition:{dur:L0?.dur??15},x:t8.x,y:t8.y,onVerb:(y0,P0)=>e?.({stableId:G0.stableId,transition:!0},y0,P0),onClose:()=>v8(null)})}let o=Q[t8.index];if(!o)return null;return z(aN,{mode:"clip",clipLabel:o.label,kind:b6(o),textValue:o.placeholder?o.placeholder.prompt||"":b6(o)==="jsx"&&!o.series?"":null,mediaProps:o.mediaProps||null,x:t8.x,y:t8.y,onVerb:(G0,L0)=>e?.(j9(o,t8.index),G0,L0),onClose:()=>v8(null)})})(),document.body):null,E0&&Q[E0.index]?N3.createPortal((()=>{let o=Q[E0.index],G0=E0.index,L0=E0.layerIndex,y0;if(o.loose)y0=[[{id:"noop",label:"Loose media (no clip wrapper) — edit via /design:edit",disabled:!0,onSelect:()=>{}}]];else if(L0!=null){let P0=(Array.isArray(o.layers)?o.layers:[])[L0],z8=[];if(j&&P0&&(P0.mediaCdId||P0.mediaArrayRef))z8.push({id:"replace-layer",label:`Replace ${P0.kind}…`,onSelect:()=>j(j9(o,G0),L0)});if(z8.length===0)z8.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});y0=[z8]}else{let P0=[];if(I0)P0.push({id:"comment",label:"Comment on clip…",onSelect:()=>{oJ({x:BX(E0.x-130,8,window.innerWidth-280),y:Math.max(48,E0.y-140),anchor:{clipStableId:o.stableId||void 0,frameOffset:Math.max(0,Q8-(o.from||0)),frame:Q8},at:Q8})}});if(o.placeholder&&i)P0.push({id:"generate",label:`Generate ✨ (${o.placeholder.kind||"veo"})`,onSelect:()=>i(j9(o,G0))});if(e&&o.mediaSrc)if(o.series)P0.push({id:"to-overlay",label:"Move to overlay layer",onSelect:()=>e(j9(o,G0),"to-overlay",{})});else P0.push({id:"to-storyline",label:"Move to storyline",onSelect:()=>e(j9(o,G0),"to-storyline",{})});if(e){if(P0.push({id:"adjust",label:"Adjust… (Speed · Audio · Crop · Grade)",onSelect:()=>{l?.(o.stableId??null),v8({mode:"clip",index:G0,x:E0.x-120,y:Math.max(60,E0.y-320)})}}),o.mediaProps){if(P0.push({id:"mute",label:o.mediaProps.muted?"Unmute clip":"Mute clip",onSelect:()=>e(j9(o,G0),"audio",{muted:!o.mediaProps.muted})}),b6(o)==="video"&&o.mediaSrc)P0.push({id:"detach-audio",label:"Detach audio",onSelect:()=>e(j9(o,G0),"detach-audio",{})})}}if($&&o.replaceable&&!(Array.isArray(o.layers)&&o.layers.length>=2))P0.push({id:"replace",label:`Replace ${b6(o)}…`,onSelect:()=>$(j9(o,G0))});{let M8=rJ.filter((L9)=>!L9.seq.loose),Z9=M8.findIndex((L9)=>L9.i===G0);if(e&&Z9>=0)P0.push({id:"layer-up",label:"Move layer up",disabled:Z9>=M8.length-1,onSelect:()=>e(j9(o,G0),"layer-order",{toIndex:Z9+1})}),P0.push({id:"layer-down",label:"Move layer down",disabled:Z9<=0,onSelect:()=>e(j9(o,G0),"layer-order",{toIndex:Z9-1})})}if(f)P0.push({id:"earlier",label:o.series?"Move earlier":"Bring forward",disabled:o.series?G0<=0:G0>=Q.length-1,onSelect:()=>f(j9(o,G0),o.series?"backward":"forward")}),P0.push({id:"later",label:o.series?"Move later":"Send backward",disabled:o.series?G0>=Q.length-1:G0<=0,onSelect:()=>f(j9(o,G0),o.series?"forward":"backward")});y0=[P0];let z8=[];if(d)z8.push({id:"hide",label:o.hidden?"Show clip":"Hide clip",onSelect:()=>d(j9(o,G0))});if(R)z8.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>R(j9(o,G0))});if(z8.length)y0.push(z8)}return z(Hm,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:E0.x,clientY:E0.y},sections:y0,onClose:()=>v0(null)})})(),document.body):null]})}function OU0(J){let X={};for(let Q of J.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*(-?\d+)\s*;/g))X[Q[1]]=Number(Q[2]);for(let Q=0;Q<3;Q+=1)for(let Y of J.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);/g)){let W=Y[1];if(Object.hasOwn(X,W))continue;let G=rQ(Y[2],X);if(G!=null)X[W]=G}return X}function rQ(J,X){if(J==null)return null;let Q=String(J).trim();if(/^-?\d+$/.test(Q))return Number(Q);if(Object.hasOwn(X,Q))return X[Q];let Y=Q.replace(/[A-Za-z_$][\w$]*/g,(W)=>Object.hasOwn(X,W)?String(X[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 AU0(J,X,Q,Y){if(!X)return[];let W=J.search(new RegExp(`\\b(?:const|function)\\s+${X}\\b`));if(W<0)return[];let G=J.slice(W+X.length),Z=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,Z>0?Z:2400),K=[];for(let U of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let V=rQ(U[1],Q),B=rQ(U[2],Q);if(V!=null&&B!=null&&B>=V)K.push({from:Y+V,to:Y+B})}return K}function _U0(J,X){if(!X)return null;let Q=J.search(new RegExp(`\\b(?:const|function)\\s+${X}\\b`));if(Q<0)return null;let Y=J.slice(Q+X.length+1),W=Y.search(/\n(?:const|function|export)\s+[A-Za-z]/);return Y.slice(0,W>0?W:Y.length)}function wU0(J,X){let Q=[];for(let Y of J.matchAll(/<VideoComp\b([^>]*?)\/?>/g)){let W=Y[1],G=W.match(/component=\{([A-Za-z_$][\w$]*)\}/);if(!G)continue;let H=[...J.slice(0,Y.index).matchAll(/<DCArtboard\b[^>]*?\bid=["']([^"']+)["']/g)];Q.push({compName:G[1],artboardId:H.length?H[H.length-1][1]:null,duration:rQ(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],X),fps:rQ(W.match(/fps=\{([^}]+)\}/)?.[1],X)||30})}return Q}function zm(J,X,Q){let Y=String(J??""),W=OU0(Y),G=Y,Z=X,H=0,K=null,U=wU0(Y,W).map((R)=>({...R,body:_U0(Y,R.compName)})).filter((R)=>R.body);if(U.length){let R=Q&&U.find(($)=>$.artboardId===Q)||U.find(($)=>/<(?:Maude)?(?:Audio|OffthreadVideo|Video)\b/.test($.body))||U.find(($)=>$.duration!=null&&$.duration===X)||U[0];if(G=R.body,R.duration!=null)Z=R.duration;H=R.fps,K=R.artboardId??null}let V=[],B=[],N=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=N.exec(G)){let R=F[1],$=F[2],C=N.lastIndex;if(/Transition$/.test(R)){let j=$.match(/durationInFrames:\s*([^,}\s)]+)/);V.push({type:"transition",dur:rQ(j?.[1],W)??0})}else{let j=$.match(/durationInFrames=\{([^}]+)\}/),f=$.match(/from=\{([^}]+)\}/),m=G.indexOf(`</${R}>`,C);B.push([F.index,m>=0?m:C+240]);let d=m>=0?Math.min(m,C+400):C+240,a=G.slice(C,d),x=a.match(/<([A-Z][A-Za-z0-9]*)\b/),h=a.match(/<(?:Maude)?(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),l=$.match(/name=["']([^"']+)["']/);V.push({type:"seq",series:R!=="Sequence",dur:rQ(j?.[1],W),from:R==="Sequence"&&f?rQ(f[1],W):null,compName:l?l[1]:x?x[1]:null,mediaTag:h?h[1]:null,mediaSrc:h?h[2]:null})}}let M=0,O=[],E=[],w=null;for(let R of V){if(R.type==="transition"){if(M-=R.dur||0,O.length>0)w={afterIndex:O.length-1,dur:R.dur||0};continue}let $=R.from!=null?R.from:M,C=R.dur!=null?R.dur:30;if(w)E.push(w),w=null;O.push({label:R.compName??`Seq ${O.length+1}`,series:!!R.series,mediaTag:R.mediaTag,mediaSrc:R.mediaSrc,from:Math.max(0,$),duration:Math.max(1,C),keyframes:AU0(Y,R.compName,W,Math.max(0,$))}),M=$+C}let A=O.length?Math.max(...O.map((R)=>R.from+R.duration)):30,I=Number.isFinite(Z)&&Z>0?Z:A,T=[];for(let R of G.matchAll(/<Audio\b([^>]*)>/g)){let $=R[1],C=$.match(/src=["']([^"']+)["']/),j=$.match(/from=\{([^}]+)\}/),f=$.match(/durationInFrames=\{([^}]+)\}/),m=j?rQ(j[1],W)??0:0,d=f?rQ(f[1],W):null,a=C?String(C[1]).split(/[\\/]/).pop():"audio";T.push({kind:"audio",label:a,src:C?C[1]:null,from:Math.max(0,m),duration:d!=null?Math.max(1,d):Math.max(1,I-m)})}for(let R of G.matchAll(/<(?:Maude)?(OffthreadVideo|Video|Img)\b([^>]*?)\/?>/g)){let $=R.index??0;if(B.some(([f,m])=>$>=f&&$<=m))continue;let C=R[2].match(/src=["']([^"']+)["']/);if(!C)continue;let j=String(C[1]).split(/[\\/]/).pop();O.push({label:j||R[1],series:!1,loose:!0,mediaTag:R[1],mediaSrc:C[1],from:0,duration:Math.max(1,I),keyframes:[]})}return{total:I,fps:H||void 0,sequences:O,audio:T,transitions:E,artboardId:K}}var i7=y8(i8(),1);function WE({name:J,size:X=16}){let Q={x:D(Q0,{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:D(Q0,{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"})]})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}var EU0=["1:1","16:9","9:16","4:3","3:4","4:5"];function GE({onClose:J,onInsert:X}){let[Q,Y]=i7.useState([]),[W,G]=i7.useState(""),[Z,H]=i7.useState([]),[K,U]=i7.useState(""),[V,B]=i7.useState("1:1"),[N,F]=i7.useState(""),[M,O]=i7.useState(!1),[E,w]=i7.useState(null),[A,I]=i7.useState(null),[T,R]=i7.useState(!0),[$,C]=i7.useState(null),j=i7.useRef(null),f=i7.useRef(null);i7.useEffect(()=>{fetch("/_api/generate/providers").then((h)=>h.json()).then((h)=>{let l=(h?.providers??[]).filter((n)=>n.modalities?.includes("image"));Y(l);let v=l.find((n)=>n.configured)??l[0];if(v)G(v.id)}).catch(()=>w({ok:!1,msg:"failed to load providers"}))},[]),i7.useEffect(()=>{if(!W)return;H([]),U("")},[W]),i7.useEffect(()=>{function h(l){if(l.key==="Escape")l.preventDefault(),J()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[J]),i7.useEffect(()=>()=>clearInterval(j.current),[]),i7.useEffect(()=>{if(!A||!T||typeof X!=="function")return;if(f.current===A)return;f.current=A;let h=X(A)===!0;if(C(h),h)w({ok:!0,msg:"Placed on canvas ✓"});else w({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[A,T,X]);let m=Q.find((h)=>h.id===W),d=m&&!m.configured,a=i7.useCallback((h)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let v=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((n)=>n.id===h);if(!v)return;if(v.status==="done"){clearInterval(j.current),O(!1);let n=v.assets?.[0]??null;I(n),w({ok:!0,msg:n?`Generated ${n}`:"Done (no asset)"})}else if(v.status==="failed")clearInterval(j.current),O(!1),w({ok:!1,msg:v.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),O((l)=>{if(l)w({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function x(){if(!N.trim()||!W)return;O(!0),w(null),I(null),C(null),f.current=null;try{let h={modality:"image",provider:W,prompt:N.trim(),aspectRatio:V,...K?{model:K}:{}},l=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(h)});if(l.status===202){let{jobId:v}=await l.json();w({ok:!0,msg:"Generating…"}),a(v)}else O(!1),w({ok:!1,msg:await l.text()})}catch(h){O(!1),w({ok:!1,msg:h&&h.message?h.message:"request failed"})}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)J()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[D("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:J,children:z(WE,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:"Prompt"}),z("textarea",{className:"input st-gen-prompt",rows:3,value:N,placeholder:"a minimal hero image of a mountain lake at dawn, soft light","aria-label":"Generation prompt",onChange:(h)=>F(h.target.value)}),D("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:(h)=>G(h.target.value),children:Q.map((h)=>D("option",{value:h.id,children:[h.label,h.configured?"":" — no key"]},h.id))})]}),Z.length>0&&D("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:K,onChange:(h)=>U(h.target.value),children:Z.map((h)=>z("option",{value:h.id,children:h.label},h.id))})]}),D("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:(h)=>B(h.target.value),children:EU0.map((h)=>z("option",{value:h,children:h},h))})]}),X&&D("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[z("input",{type:"checkbox",checked:T,onChange:(h)=>R(h.target.checked),"aria-label":"Place the generated image on the canvas"}),z("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),d&&D("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",m.label," — add one in Settings (⌘,)."]}),A&&D("div",{className:"st-gen-result",children:[z("img",{className:"st-gen-thumb",src:`/${A}`,alt:"generated"}),D("div",{className:"st-gen-result-actions",children:[D("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${A}`),children:[z(WE,{name:"copy",size:13})," Copy path"]}),X&&$!==!0&&z("button",{type:"button",className:"st-btn",onClick:()=>{let h=X(A)===!0;C(h),w(h?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),E&&z("div",{className:"st-provider-status",style:{color:E.ok?"var(--accent)":"var(--danger, #e5484d)"},children:E.msg}),z("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:D("button",{type:"button",className:"st-btn st-gen-go",disabled:M||!N.trim()||!W,onClick:x,children:[z(WE,{name:"sparkle",size:14})," ",M?"Generating…":"Generate"]})})]})]})})}var D7=y8(i8(),1);var XF=new Set(["main","master"]);function r9({name:J,size:X=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":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14"}),z("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[J];return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function ZE(J,X){let Q=(X||[]).find((Y)=>Y.path===J);return Q?{name:Q.name,sub:Q.server_url.replace(/^https?:\/\//,"")}:{name:KE(J),sub:J}}function KE(J){return String(J).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(J)}function Km(J){return J.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function HE(J){return String(J).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function PU0(J){if(!J)return"";let X=Math.max(0,Math.floor(Date.now()/1000)-J);if(X<45)return"just now";if(X<3600)return`${Math.round(X/60)} min ago`;if(X<86400)return`${Math.round(X/3600)} h ago`;return`${Math.round(X/86400)} d ago`}async function zE(J){return(await fetch(J)).json()}async function QF(J,X,Q={}){let Y=Q.timeoutMs?new AbortController:null,W=Y?setTimeout(()=>Y.abort(),Q.timeoutMs):null;try{let G=await fetch(J,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X),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 IU0({count:J,branch:X,verb:Q}){return{title:J>1?`${J} chats are working right now`:"A chat is working right now",body:`Claude is editing files on ${X}. If you ${Q} now, those edits can land on the wrong branch — and Maude's History can't undo a cross-branch mix-up.`,meta:"Safest is to wait for the chat to finish, or stop it yourself first.",confirm:"Do it anyway",cancel:"Wait"}}function UE({project:J,liveBranch:X,remoteSync:Q,onGetLatest:Y,projectOnly:W=!1}){let G=G9(),[Z,H]=D7.useState(null),[K,U]=D7.useState([]),[V,B]=D7.useState([]),[N,F]=D7.useState([]),[M,O]=D7.useState(!1),[E,w]=D7.useState(!1),[A,I]=D7.useState(!1),[T,R]=D7.useState(""),[$,C]=D7.useState(!1),[j,f]=D7.useState(""),[m,d]=D7.useState(null),[a,x]=D7.useState(!1),[h,l]=D7.useState(!1),[v,n]=D7.useState(!1),[e,s]=D7.useState(null);async function H0(O0){if(!G9()){window.open(O0,"_blank","noopener,noreferrer");return}try{await wV(O0)}catch{try{await navigator.clipboard.writeText(O0),x(!0)}catch{}}}let[r,z0]=D7.useState(!1),[i,q0]=D7.useState(""),[Z0,I0]=D7.useState(""),[a0,s0]=D7.useState(""),[e0,D8]=D7.useState(!1),[s8,w8]=D7.useState(0),[N8,C0]=D7.useState(!1),A0=D7.useRef(null);D7.useEffect(()=>{let O0=!0;if((async()=>{try{let K8=await zE("/_api/git/status");if(!O0)return;if(H(K8),K8.repo&&G){let S8=await zE("/_api/git/branches");if(O0)U(S8.branches||[])}}catch{}})(),G)Dh().then((K8)=>O0&&B(K8||[])).catch(()=>{});if(G)TN().then((K8)=>O0&&F(Array.isArray(K8)?K8:[])).catch(()=>{});return()=>{O0=!1}},[G]),D7.useEffect(()=>{if(!E||!G||!Z?.repo)return;I0(""),t0()},[E]),D7.useEffect(()=>{if(!E&&!A)return;let O0=(K8)=>{if(A0.current&&!A0.current.contains(K8.target))w(!1),I(!1),s0("")};return document.addEventListener("mousedown",O0),()=>document.removeEventListener("mousedown",O0)},[E,A]);let $0=D(Q0,{children:[z("div",{className:"rb-pop-hd",children:"Project"}),G&&V.length>0?V.map((O0,K8)=>{let S8=ZE(O0,N);return D("button",{type:"button",className:"rb-pop-item"+(K8===0?" is-current":""),role:"menuitem",onClick:()=>J9(O0),children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:N.some((V9)=>V9.path===O0)?"share":"folder",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:S8.name}),z("span",{className:"rb-pop-sub",children:S8.sub})]}),K8===0?z(r9,{name:"check",size:14,className:"rb-pop-check"}):null]},O0)}):z("div",{className:"rb-pop-sub",style:{padding:"var(--space-2) var(--space-3)"},children:G?"No other recent projects.":"Open another project from the desktop app."}),G&&D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem","data-testid":"switcher-open-team",onClick:()=>{w(!1),O(!0)},children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"share",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open a team project…"})})]}),G&&D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:i0,children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"folder-open",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open another folder…"})})]})]}),Q8=M?z(pN,{onClose:()=>O(!1)}):null;if(G&&Z&&(!Z.repo||W)){let O0=J||ZE(V[0]||"Project",N).name;return D("div",{className:"rb-dock-wrap",children:[D("div",{className:"rb-dock",ref:A0,children:[E&&z("div",{className:"rb-pop rb-pop--up",id:"rb-switch-pop",role:"menu","aria-label":"Switch project","data-testid":"repo-switcher-popup",children:$0}),i?D("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(r9,{name:"spinner",size:14,className:"rb-spin"}),D("span",{children:["Opening ",z("b",{children:i}),"…"]})]}):D("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(E?" is-open":""),"aria-expanded":E,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>w((K8)=>!K8),title:O0,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:O0}),z(r9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),Z0&&!E&&!i&&z("div",{className:"rb-switcher-err",role:"alert",children:Z0})]}),Q8]})}if(!Z?.repo||W)return null;let Z8=X||Z.branch||"main",f8=XF.has(Z8),b8=K.find((O0)=>XF.has(O0.name))?.name||"main",O9=(O0,K8)=>(K8.updatedAt||0)-(O0.updatedAt||0)||O0.name.localeCompare(K8.name),h0=a0.trim().toLowerCase(),C8=(O0)=>!h0||O0.name.toLowerCase().includes(h0),A9=K.filter((O0)=>!XF.has(O0.name)).sort(O9),F8=A9.filter(C8),B0=F8.filter((O0)=>O0.name!==Z8),J8=!h0||b8.toLowerCase().includes(h0)||"shared version".includes(h0),r0=A9.length>6,j0=J||KE(V[0]||"Project");if(!G)return z("div",{className:"rb-dock-wrap",children:z("div",{className:"rb-dock rb-dock--ro",children:D("span",{className:"rb-trigger rb-trigger--ro",title:`${j0} · branch: ${Z8} — switch branches in your terminal`,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),D("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[z(r9,{name:"branch",size:12}),D("span",{className:"rb-trigger-ver-name",children:["branch: ",Z8]})]})]})})});async function t0(){try{let O0=await zE("/_api/git/branches");U(O0.branches||[])}catch{}}async function H8(){try{let O0=await fetch("/_api/acp/running");if(!O0.ok)return 0;let K8=await O0.json();return Number(K8?.running)||0}catch{return 0}}async function p0(O0,K8){let S8=await H8();if(S8===0){O0();return}s({count:S8,verb:K8,action:O0})}async function d0(O0,K8){q0(O0),C0(K8==="remote"),I0("");let S8=await QF("/_api/git/checkout",{name:O0});if(S8.ok&&S8.json?.ok)window.location.reload();else I0(S8.json?.error||"Could not switch."),q0(""),C0(!1)}async function k8(O0,K8){if(w(!1),O0===Z8)return;await p0(()=>d0(O0,K8),`switch to “${O0}”`)}async function _0(){if(e0)return;D8(!0),I0("");let O0=await QF("/_api/git/fetch",{},{timeoutMs:45000});if(O0.ok&&O0.json?.ok){if(O0.json.fetchedAt)w8(O0.json.fetchedAt);await t0()}else if(O0.timedOut||O0.json?.timedOut)I0("Couldn’t reach the remote — your local branches are still listed above.");else I0(O0.status===401||O0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":O0.json?.error||"Could not fetch remote branches.");D8(!1)}async function X8(O0){z0(!0),I0("");let K8=await QF("/_api/git/branch",{name:O0});if(K8.ok&&K8.json?.ok)window.location.reload();else I0(K8.json?.error||"Could not create the draft."),z0(!1)}async function P8(){let O0=Km(T);if(!O0)return;await p0(()=>X8(O0),`create “${O0}”`)}async function U0(){if(h||!Y)return;l(!0),I0("");let O0=await Y();if(l(!1),O0&&!O0.ok&&!O0.conflict)I0(O0.status===401||O0.authRequired?"Sign in with GitHub to get the latest.":O0.error||"Could not get the latest.")}async function o0(){await p0(R8,`merge “${Z8}” into ${b8}`)}async function R8(){f(Z8),I0("");let O0=await QF("/_api/git/fold",{name:Z8},{timeoutMs:45000}),K8=O0.json;if(O0.ok&&K8?.ok&&K8.prUrl){d({url:K8.prUrl,number:K8.prNumber,repo:K8.repo}),f(""),t0();return}if(O0.ok&&K8?.ok&&K8.prUnavailable){d({message:K8.error||"Draft published, but the pull request could not be opened."}),f(""),t0();return}if(O0.ok&&K8?.ok){window.location.reload();return}I0(O0.status===401?`Sign in with GitHub to add “${Z8}” to ${b8}.`:K8?.error||"Could not add the branch."),f("")}async function J9(O0){if(w(!1),!G)return;q0(ZE(O0,N).name);try{await KX(O0)}catch(K8){I0(String(K8?.message||K8||"Could not open that project.")),q0("")}}async function i0(){if(w(!1),!G)return;try{let O0=await t4();if(!O0)return;q0(KE(O0)),await KX(O0)}catch(O0){I0(String(O0?.message||O0||"Could not open that folder.")),q0("")}}let a7=Km(T),F9=e?IU0({count:e.count,branch:Z8,verb:e.verb}):null,v7=f8?null:K.find((O0)=>O0.current),I8=f8&&!v&&!i&&!j?[...K].filter((O0)=>!XF.has(O0.name)&&O0.where!=="remote").sort((O0,K8)=>(K8.updatedAt||0)-(O0.updatedAt||0))[0]:null,X9=D(Q0,{children:[D("div",{className:"rb-pop-empty",children:["No branch matches “",a0.trim(),"”."]}),D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:_0,disabled:e0,children:[z("span",{className:"rb-pop-icon"+(e0?" rb-pop-icon--spin":""),children:z(r9,{name:e0?"spinner":"refresh",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:e0?"Searching the remote…":"Search the remote for it"})})]})]}),d8=(O0)=>{let K8=O0.where==="remote";return D("button",{type:"button","data-testid":`branch-row-${HE(O0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>k8(O0.name,O0.where),children:[z("span",{className:"rb-pop-icon "+(K8?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:z(r9,{name:K8?"cloud":"draft",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:O0.name}),K8&&z("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},O0.name)};return D("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!i&&!j&&D("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:U0,disabled:h,title:`Get the latest ${b8}`,children:[z(r9,{name:h?"spinner":"download",size:14,className:h?"rb-spin":""}),z("span",{className:"rb-getlatest-tx",children:h?"Getting the latest…":"Get latest"}),!h&&Q.behind>0&&D("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",b8]})]}),I8&&D("div",{className:"rb-resume","data-testid":"switcher-resume",children:[D("button",{type:"button",className:"rb-resume-go",onClick:()=>k8(I8.name),title:`Switch to ${I8.name}`,children:[z("span",{className:"rb-resume-icon",children:z(r9,{name:"draft",size:13})}),D("span",{className:"rb-resume-tx",children:["Continue on ",z("b",{children:I8.name})]}),z(r9,{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(r9,{name:"close",size:12})})]}),D("div",{className:"rb-dock",ref:A0,children:[E&&D("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:[$0,z("div",{className:"rb-pop-sep"}),z("div",{className:"rb-pop-hd",children:"Branch"}),f8?D(Q0,{children:[D("button",{type:"button","data-testid":`branch-row-${HE(b8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>k8(b8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(r9,{name:"share",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:b8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),z(r9,{name:"check",size:14,className:"rb-pop-check"})]}),A9.length>0&&z("div",{className:"rb-pop-grouplabel",children:"Other branches"}),r0&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:a0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(O0)=>s0(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Escape")s0("")}})}),F8.map(d8),r0&&h0&&F8.length===0&&!J8&&X9]}):D(Q0,{children:[D("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(r9,{name:"draft",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:v7?.name||Z8}),z("span",{className:"rb-pop-sub",children:"your branch"})]}),z(r9,{name:"check",size:14,className:"rb-pop-check"})]}),D("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{w(!1),I0(""),d(null),x(!1),C(!0)},children:[z("span",{className:"rb-fold-icon",children:z(r9,{name:"arrow-up-to-line",size:15})}),D("span",{className:"rb-fold-tx",children:[D("span",{className:"rb-fold-title",children:["Merge this branch → ",b8]}),z("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),z("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),r0&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:a0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(O0)=>s0(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Escape")s0("")}})}),J8&&D("button",{type:"button","data-testid":`branch-row-${HE(b8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>k8(b8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(r9,{name:"share",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:b8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),B0.map(d8),r0&&h0&&B0.length===0&&!J8&&X9]}),D("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:_0,disabled:e0,children:[z("span",{className:"rb-pop-icon"+(e0?" rb-pop-icon--spin":""),children:z(r9,{name:e0?"spinner":"refresh",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:e0?"Fetching…":"Fetch remote branches"}),z("span",{className:"rb-pop-sub",children:s8?`as of ${PU0(s8)}`:"check the remote for new branches"})]})]}),Z0&&!i&&z("div",{className:"rb-pop-notice",role:"alert",children:Z0}),D("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{w(!1),I(!0)},children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"plus",size:14})}),D("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"})]})]})]}),A&&D("div",{className:"rb-newdraft rb-newdraft--up",children:[D("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:T,placeholder:"nav-redesign","aria-label":"Branch name",autoFocus:!0,onChange:(O0)=>R(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Enter"&&a7)P8();if(O0.key==="Escape")I(!1),R("")}}),a7&&D("span",{className:"rb-pop-sub",children:["Creates branch ",z("b",{children:a7})]})]}),Z0&&z("span",{className:"rb-newdraft-err",children:Z0}),D("div",{className:"rb-newdraft-actions",children:[z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{I(!1),R(""),I0("")},disabled:r,children:"Cancel"}),D("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:P8,disabled:r||!a7,children:[z(r9,{name:"draft",size:13})," ",r?"Creating…":"Create branch"]})]}),D("p",{className:"rb-newdraft-hint",children:["A branch is your own line of work off what you're looking at now. Merge it into ",b8," when you're happy, or throw it away — nothing else changes."]})]}),i||j?D("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(r9,{name:"spinner",size:14,className:"rb-spin"}),z("span",{children:j?D(Q0,{children:["Merging ",z("b",{children:j})," → ",b8,"…"]}):N8?D(Q0,{children:["Downloading ",z("b",{children:i}),"…"]}):D(Q0,{children:["Opening ",z("b",{children:i}),"…"]})})]}):D("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(E?" is-open":""),"aria-expanded":E,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>{w((O0)=>{if(O0)s0("");return!O0}),I(!1)},title:`${j0} · ${Z8}`,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),D("span",{className:"rb-trigger-ver"+(f8?"":" is-draft"),children:[z(r9,{name:f8?"share":"draft",size:12}),z("span",{className:"rb-trigger-ver-name",children:Z8})]}),z(r9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),Z0&&!E&&!A&&!i&&z("div",{className:"rb-switcher-err",role:"alert",children:Z0})]}),e&&F9&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>s(null),children:D("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-chatguard-title","aria-describedby":"rb-chatguard-body","data-testid":"switcher-chat-guard",onClick:(O0)=>O0.stopPropagation(),onKeyDown:(O0)=>{if(O0.key==="Escape")s(null)},children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"draft",size:20})}),z("h2",{className:"rb-sheet-title",id:"rb-chatguard-title",children:F9.title}),z("p",{className:"rb-sheet-body",id:"rb-chatguard-body",children:F9.body}),z("p",{className:"rb-sheet-meta",children:F9.meta}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost","data-testid":"switcher-chat-guard-cancel",onClick:()=>s(null),children:F9.cancel}),z("button",{type:"button",className:"btn btn--danger","data-testid":"switcher-chat-guard-confirm",onClick:()=>{let{action:O0}=e;s(null),O0()},children:F9.confirm})]})]})}),$&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>{C(!1),d(null),x(!1)},children:z("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(O0)=>O0.stopPropagation(),onKeyDown:(O0)=>{if(O0.key==="Escape")C(!1),d(null),x(!1)},children:m?m.url?D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"share",size:20})}),D("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",m.number?` #${m.number}`:""]}),D("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",D("b",{children:["“",Z8,"”"]})," is up as a pull request into ",z("b",{children:b8}),m.repo?D(Q0,{children:[" of ",z("b",{children:m.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:m.url}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{C(!1),d(null),x(!1)},children:"Close"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>H0(m.url),children:[z(r9,{name:"share",size:15})," ",a?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{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:m.message}),z("div",{className:"rb-sheet-actions",children:z("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{C(!1),d(null),x(!1)},children:"Got it"})})]}):D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"arrow-up-to-line",size:20})}),D("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",b8]}),D("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",D("b",{children:["“",v7?.name||Z8,"”"]})," to ",z("b",{children:b8})," — 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."}),Z0&&z("p",{className:"rb-newdraft-err",children:Z0}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{C(!1),I0("")},children:"Cancel"}),D("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!j,onClick:o0,children:[z(r9,{name:"arrow-up-to-line",size:15})," ",j?"Adding…":`Add to ${b8}`]})]})]})})}),Q8]})}var P9=y8(i8(),1);function QY({name:J,size:X=16}){let Q={x:D(Q0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:D(Q0,{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:D(Q0,{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"})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function kU0({provider:J,onChanged:X}){let[Q,Y]=P9.useState(""),[W,G]=P9.useState(!1),[Z,H]=P9.useState(null),K=J.configured;async function U(){let B=Q.trim();if(!B)return;G(!0),H(null);try{let N=await fetch("/_api/generate/keys",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:J.id,key:B})});if(!N.ok)throw Error(await N.text());let F=await N.json();Y(""),H({ok:!0,msg:F.configured?"Key saved.":"Saved."}),X()}catch(N){H({ok:!1,msg:N&&N.message?N.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:J.id})});if(!B.ok)throw Error(await B.text());H({ok:!0,msg:"Key removed."}),X()}catch(B){H({ok:!1,msg:B&&B.message?B.message:"remove failed"})}finally{G(!1)}}return D("div",{className:"st-provider-card",children:[D("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:J.label}),z("span",{className:"st-pill"+(J.kind==="local"?" is-local":""),children:J.kind==="local"?"Local":D(Q0,{children:[z(QY,{name:"cloud",size:12})," Cloud"]})}),K&&D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," configured"]})]}),z("div",{className:"st-provider-modalities",children:J.modalities.join(" · ")}),J.notes&&z("div",{className:"st-provider-notes",children:J.notes}),J.keyUrl&&D("a",{className:"st-provider-keylink",href:J.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",z(QY,{name:"external",size:12})]}),J.auth==="api-key"&&D("div",{className:"st-provider-keyrow",children:[z("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:K?"•••••••• configured — paste to replace":"paste API key","aria-label":`${J.label} API key`,onChange:(B)=>Y(B.target.value),onKeyDown:(B)=>{if(B.key==="Enter")U()}}),D("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:U,children:[z(QY,{name:"key",size:13})," Save"]}),K&&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 qm=[{id:"auto",label:"Auto",note:"Use the best engine this machine is set up for — the card says which."},{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"}],TU0=Object.fromEntries(qm.map((J)=>[J.id,J.label]));function RU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(!1),[W,G]=P9.useState(null),[Z,H]=P9.useState(null);P9.useEffect(()=>{fetch("/_api/generate/prefs").then((U)=>U.ok?U.json():Promise.reject(Error(`HTTP ${U.status}`))).then((U)=>X(U?.transcriptionProvider||"whisper")).catch(()=>X("whisper"))},[]),P9.useEffect(()=>{fetch("/_api/generate/whisper-model").then((U)=>U.ok?U.json():null).then((U)=>H(U?.auto||null)).catch(()=>{})},[]);async function K(U){if(U===J)return;let V=J;X(U),Y(!0),G(null);try{let B=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:U})});if(!B.ok)throw Error(await B.text());G({ok:!0,msg:"Saved."})}catch(B){X(V),G({ok:!1,msg:B&&B.message?B.message:"save failed"})}finally{Y(!1)}}return D("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),D("div",{className:"st-provider-notes",children:["Which engine turns audio into subtitles. Maude never switches engines behind your back — pin one, or pick ",z("strong",{children:"Auto"})," and it uses the best you're set up for and says so."]}),J==="auto"&&Z&&D("div",{className:"st-provider-notes",children:["Right now Auto uses ",z("strong",{children:TU0[Z.engine]||Z.engine})," —"," ",Z.reason,Z.cloud&&" Audio is uploaded to that provider and billed to your account."]}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:qm.map((U)=>D("label",{className:"st-engine-radio"+(J===U.id?" is-selected":""),children:[z("input",{type:"radio",name:"transcription-engine",value:U.id,checked:J===U.id,disabled:Q||J===null,onChange:()=>K(U.id)}),D("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:U.label}),z("span",{className:"st-engine-radio-note",children:U.note})]})]},U.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function CU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(null),W=P9.useCallback(()=>{fetch("/_api/generate/whisper-model").then((V)=>V.ok?V.json():Promise.reject(Error(`HTTP ${V.status}`))).then(X).catch((V)=>Y(V&&V.message?V.message:"failed to load models"))},[]);P9.useEffect(()=>{W()},[W]),P9.useEffect(()=>{if(!J?.downloading)return;let V=setInterval(W,1000);return()=>clearInterval(V)},[J?.downloading,W]);async function G(V){Y(null);try{let B=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:V})});if(!B.ok)throw Error(await B.text());W()}catch(B){Y(B&&B.message?B.message:"download failed")}}async function Z(V){Y(null);try{let B=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:V})});if(!B.ok)throw Error(await B.text());W()}catch(B){Y(B&&B.message?B.message:"remove failed")}}let H=J?.downloading,K=(V,B)=>B>0?Math.min(100,Math.round(V/B*100)):0,U=(J?.models||[]).some((V)=>V.downloaded);return D("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)"})}),z("div",{className:"st-provider-notes",children:"Local subtitles need two things: the whisper.cpp engine and one model. Models are stored on this machine only and never committed."}),J&&D("div",{className:"st-setup",children:[D("div",{className:`st-step${J.setup?.installed?" is-done":""}`,children:[z("span",{className:"st-step-n",children:J.setup?.installed?"✓":"1"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:J.setup?.installed?"whisper.cpp engine is installed":"Install the whisper.cpp engine"}),(J.setup?.options||[]).slice(0,1).map((V)=>V.kind==="command"?z(bK,{command:V.command,label:`Copy: ${V.label}`},V.id):z("span",{className:"st-provider-notes",children:V.note},V.id))]})]}),D("div",{className:`st-step${U?" is-done":""}`,children:[z("span",{className:"st-step-n",children:U?"✓":"2"}),z("div",{className:"st-step-body",children:z("span",{className:"st-step-title",children:U?"Model ready":"Download a model (below)"})})]}),(J.setup?.options||[]).length>1&&D("details",{className:"st-setup-more",children:[z("summary",{children:"Other ways to get the engine"}),J.setup.options.slice(1).map((V)=>D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:V.label}),z(bK,{command:V.kind==="command"?V.command:V.url,label:`Copy: ${V.label}`}),V.note?z("span",{className:"st-provider-notes",children:V.note}):null]},V.id))]})]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&D("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),J===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(J?.models||[]).map((V)=>{let B=H&&!H.error&&H.id===V.id;return D("div",{className:"st-model-row",children:[D("div",{className:"st-model-info",children:[D("span",{className:"st-model-label",children:[V.label,z("span",{className:"st-pill"+(V.multilingual?"":" is-local"),children:V.multilingual?"multilingual":"English-only"}),D("span",{className:"st-model-size",children:["~",V.sizeMB," MB"]})]}),z("span",{className:"st-engine-radio-note",children:V.note}),B&&D("span",{className:"st-model-progress",children:["Downloading… ",K(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:V.downloaded?D(Q0,{children:[D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," ready"]}),z("button",{type:"button",className:"st-btn",onClick:()=>Z(V.id),children:"Remove"})]}):z("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(V.id),children:B?"Downloading…":"Download"})})]},V.id)})})]})}var $U0=[{id:"auto",label:"Auto",note:"Use the best available: Gemma scout → ffmpeg → blind."},{id:"gemma",label:"Gemma scout",note:"Semantic action beats. Needs Ollama (gemma3 vision) or 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 SU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(!1),[W,G]=P9.useState(null);P9.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>X(H?.keyframeEngine||"auto")).catch(()=>X("auto"))},[]);async function Z(H){if(H===J)return;let K=J;X(H),Y(!0),G(null);try{let U=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({keyframeEngine:H})});if(!U.ok)throw Error(await U.text());G({ok:!0,msg:"Saved."})}catch(U){X(K),G({ok:!1,msg:U&&U.message?U.message:"save failed"})}finally{Y(!1)}}return D("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"})}),D("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:$U0.map((H)=>D("label",{className:"st-engine-radio"+(J===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"keyframe-engine",value:H.id,checked:J===H.id,disabled:Q||J===null,onChange:()=>Z(H.id)}),D("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 bK({command:J,label:X}){let[Q,Y]=P9.useState(!1);return D("span",{className:"rdy-cmd",children:[z("code",{className:"rdy-cmd-tx",children:J}),z("button",{type:"button",className:"rdy-copy",onClick:()=>{navigator.clipboard?.writeText(J).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)},()=>{})},"aria-label":X||"Copy command",children:Q?"Copied":"Copy"})]})}function bU0({state:J}){let X=J.ollama||{},Q=X.setup||[],[Y,...W]=Q,G=Boolean(X.available),Z=Boolean(X.model),H=G||Y?.id==="pull"?null:Y;return D("div",{className:"st-setup",children:[D("div",{className:`st-step${G?" is-done":""}`,children:[z("span",{className:"st-step-n",children:G?"✓":"1"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:G?"Ollama is running":X.installed?"Start Ollama":"Install Ollama"}),H?.kind==="command"?z(bK,{command:H.command,label:"Copy the install command"}):null]})]}),D("div",{className:`st-step${Z?" is-done":""}`,children:[z("span",{className:"st-step-n",children:Z?"✓":"2"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:Z?`Model ready (${X.model})`:"Download the model"}),Z?null:z(bK,{command:X.pullCommand,label:"Copy the model pull command"})]})]}),D("details",{className:"st-setup-more",children:[z("summary",{children:"Other ways to install"}),W.map((K)=>D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:K.label}),z(bK,{command:K.kind==="command"?K.command:K.url,label:`Copy: ${K.label}`})]},K.id)),D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:"mlx-vlm instead of Ollama — faster, Apple Silicon only"}),J.mlx?.supported?D(Q0,{children:[z(bK,{command:J.mlx.command,label:"Copy the mlx-vlm install command"}),z("span",{className:"st-provider-notes",children:"Then download a model below. Models live in your HuggingFace cache."})]}):z("span",{className:"st-provider-notes",children:J.mlx?.reason})]})]})]})}function yU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(null),W=P9.useCallback(()=>{fetch("/_api/generate/keyframe-model").then((M)=>M.ok?M.json():Promise.reject(Error(`HTTP ${M.status}`))).then(X).catch((M)=>Y(M&&M.message?M.message:"failed to load models"))},[]);P9.useEffect(()=>{W()},[W]),P9.useEffect(()=>{if(!J?.downloading)return;let M=setInterval(W,1500);return()=>clearInterval(M)},[J?.downloading,W]);let G=J?!J.mlxVlmAvailable&&!J.ollama?.model:!1;P9.useEffect(()=>{if(!G)return;let M=setInterval(W,1e4);return()=>clearInterval(M)},[G,W]);async function Z(M){Y(null);try{let O=await fetch("/_api/generate/keyframe-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:M})});if(!O.ok)throw Error(await O.text());W()}catch(O){Y(O&&O.message?O.message:"download failed")}}let H=J?.downloading,K=J?.mlxVlmAvailable,U=J?.ffmpegAvailable,V=J?.ollama,B=Boolean(K||V?.model),N=(M,O)=>O>0?Math.min(100,Math.round(M/O*100)):0,F=B?`Gemma scout${K?"":` (Ollama · ${V.model})`}`:U?"ffmpeg scene-detect":"blind (even-spaced)";return D("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Gemma scout model (optional)"})}),z("div",{className:"st-provider-notes",children:"Adds semantic action-beat detection on top of scene cuts. Two short steps in a terminal — Maude picks the result up on its own."}),J&&!B&&z(bU0,{state:J}),J&&D("div",{className:"st-provider-notes",children:["Active tier on this machine: ",z("strong",{children:F}),B&&!K&&" — Ollama manages its own models, nothing to download below."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&D("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),J===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(J?.models||[]).map((M)=>{let O=H&&!H.error&&H.id===M.id,E=M.runtime==="ollama"?Boolean(V?.available):Boolean(K),w=M.runtime==="ollama"?V?.installed?"start Ollama first":"needs Ollama":"needs mlx-vlm";return D("div",{className:"st-model-row",children:[D("div",{className:"st-model-info",children:[D("span",{className:"st-model-label",children:[M.label,D("span",{className:"st-model-size",children:["~",Math.round(M.sizeMB/100)/10," GB"]})]}),z("span",{className:"st-engine-radio-note",children:M.note}),O&&D("span",{className:"st-model-progress",children:[M.runtime==="ollama"?"Pulling":"Downloading","…"," ",N(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:M.downloaded?D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," ready"]}):D("span",{className:"st-model-action",children:[z("button",{type:"button",className:"st-btn",disabled:!E||!!(H&&!H.error),onClick:()=>Z(M.id),children:O?"Downloading…":"Download"}),E?null:z("span",{className:"st-model-action-note",children:w})]})})]},M.id)})})]})}function jU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(""),[W,G]=P9.useState(!1),[Z,H]=P9.useState(null),[K,U]=P9.useState(null),V=P9.useCallback(()=>{fetch("/_api/figma/status").then((O)=>O.ok?O.json():Promise.reject(Error(`HTTP ${O.status}`))).then(X).catch(()=>X({configured:!1}))},[]);P9.useEffect(()=>{V()},[V]);async function B(){let O=Q.trim();if(!O||W)return;G(!0),H(null);try{let E=await fetch("/_api/figma/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:O})}),w=await E.json().catch(()=>({}));if(!E.ok){H(w.error||"could not save the token");return}Y(""),V(),await N()}finally{G(!1)}}async function N(){H(null);let E=await(await fetch("/_api/figma/probe",{method:"POST"})).json().catch(()=>({}));if(E.ok)U(E.handle||""),H(null);else U(null),H(E.error||"Figma did not accept that token.")}async function F(){if(W)return;G(!0);try{await fetch("/_api/figma/connect",{method:"DELETE"}),U(null),H(null),V()}finally{G(!1)}}let M=Boolean(J?.configured);return D("div",{className:"st-provider-card","data-testid":"figma-connect-card",children:[D("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:"Figma"}),M&&D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," connected"]})]}),z("p",{className:"st-settings-intro",children:"Import real Figma documents — frames become editable canvases, FigJam boards become the whiteboard, and paint/text/effect styles become design tokens. The translation is plain code: no AI reads your file."}),D("p",{className:"st-settings-intro",children:["Create a personal access token with the ",z("code",{children:J?.requiredScope||"file_content:read"})," ","scope. It is stored on this machine only and is never sent anywhere but Figma."]}),J?.tokenUrl&&D("a",{className:"st-provider-keylink",href:J.tokenUrl,target:"_blank",rel:"noreferrer",children:["Get a token ",z(QY,{name:"external",size:12})]}),D("div",{className:"st-provider-keyrow",children:[z("input",{className:"st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,placeholder:M?"•••••••• stored":"figd_…",value:Q,onChange:(O)=>Y(O.target.value),onKeyDown:(O)=>{if(O.key==="Enter")B()},"aria-label":"Figma personal access token","data-testid":"figma-connect-input"}),z("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:B,"data-testid":"figma-connect-save",children:M?"Replace":"Save"}),M&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:F,"data-testid":"figma-disconnect",children:"Remove"})]}),M&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:N,children:"Test connection"}),K!==null&&D("div",{className:"st-provider-status","data-testid":"figma-connected-as",children:["Connected as ",K||"your Figma account"]}),Z&&z("div",{className:"st-provider-status","data-testid":"figma-connect-error",children:Z})]})}var Um=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation",local:!0},{id:"figma",label:"Figma",local:!0},{id:"subtitles",label:"Subtitles",local:!0},{id:"video",label:"Video",local:!0}],Vm="mdcc-settings-tab",vU0=[{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 fU0({value:J,disabled:X,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":J===Y,disabled:X,className:"st-sidebtn"+(J===Y?" is-active":""),onClick:()=>Q(Y),children:Y==="left"?"Left":"Right"},Y))})}var xU0=[{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 hU0({panelSide:J,onSetPanelSide:X,layersMode:Q,onSetLayersMode:Y}){return D(Q0,{children:[D("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:xU0.map((W)=>D("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)}),D("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))})]}),D("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."}),vU0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return D("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[D("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(fU0,{value:J?.[W.id]||"left",disabled:G,onChange:(Z)=>X(W.id,Z)})]},W.id)})]})]})}function YF({label:J,note:X,checked:Q,disabled:Y,reason:W,onChange:G}){return D("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[D("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:J}),(W||X)&&z("span",{className:"st-pref-note",children:Y&&W?W:X})]}),z("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(Z)=>G?.(Z.target.checked)})]})}var gU0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],mU0=[{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 uU0({theme:J,onSetTheme:X,cpMode:Q,onSetCpMode:Y}){return D(Q0,{children:[D("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:gU0.map((W)=>D("label",{className:"st-engine-radio"+(J===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-theme",value:W.id,checked:J===W.id,onChange:()=>X?.(W.id)}),D("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))})]}),D("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:mU0.map((W)=>D("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)}),D("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 VE({cloud:J,onClose:X,initialTab:Q,theme:Y,onSetTheme:W,cpMode:G,onSetCpMode:Z,minimapVisible:H,onToggleMinimap:K,zoomCtlVisible:U,onToggleZoomCtl:V,annotationsVisible:B,onToggleAnnotations:N,autoOpenInspector:F,onToggleAutoOpenInspector:M,hasCanvas:O=!1,panelSide:E,onSetPanelSide:w,layersMode:A,onSetLayersMode:I}){let[T,R]=P9.useState(null),[$,C]=P9.useState(null),j=P9.useMemo(()=>Um.filter((h)=>!(J&&h.local)),[J]),[f,m]=P9.useState(()=>{let h=(l)=>Um.some((v)=>v.id===l&&!(J&&v.local));if(Q&&h(Q))return Q;try{let l=localStorage.getItem(Vm);if(l&&h(l))return l}catch{}return"appearance"});P9.useEffect(()=>{try{localStorage.setItem(Vm,f)}catch{}},[f]);let d=P9.useCallback(()=>{fetch("/_api/generate/providers").then((h)=>{if(!h.ok)throw Error(`HTTP ${h.status}`);return h.json()}).then((h)=>R(Array.isArray(h?.providers)?h.providers:[])).catch((h)=>C(h&&h.message?h.message:"failed to load providers"))},[]);P9.useEffect(()=>{d()},[d]),P9.useEffect(()=>{function h(l){if(l.key==="Escape")l.preventDefault(),X()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[X]);function a(h){let l=j.findIndex((v)=>v.id===f);if(h.key==="ArrowDown"||h.key==="ArrowRight")h.preventDefault(),m(j[(l+1)%j.length].id);else if(h.key==="ArrowUp"||h.key==="ArrowLeft")h.preventDefault(),m(j[(l-1+j.length)%j.length].id);else if(h.key==="Home")h.preventDefault(),m(j[0].id);else if(h.key==="End")h.preventDefault(),m(j[j.length-1].id)}let x=!O?"Open a canvas to use this.":void 0;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)X()},children:D("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[D("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(QY,{name:"x",size:15})})]}),D("div",{className:"st-settings-tabs",children:[z("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:a,children:j.map((h)=>z("button",{type:"button",role:"tab",id:`st-stab-${h.id}`,"aria-controls":`st-spanel-${h.id}`,"aria-selected":f===h.id,tabIndex:f===h.id?0:-1,className:"st-settings-tab"+(f===h.id?" is-active":""),onClick:()=>m(h.id),children:h.label},h.id))}),D("div",{className:"st-settings-pane",children:[D("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:f!=="appearance",children:[z("div",{className:"st-rp-hd",children:"Appearance"}),z(uU0,{theme:Y,onSetTheme:W,cpMode:G,onSetCpMode:Z})]}),D("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:f!=="canvas-view",children:[z("div",{className:"st-rp-hd",children:"Canvas & View"}),z(YF,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:H,disabled:!O,reason:x,onChange:()=>K?.()}),z(YF,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:U,disabled:!O,reason:x,onChange:()=>V?.()}),z(YF,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:B,onChange:()=>N?.()}),z(YF,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>M?.()})]}),D("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:f!=="layout",children:[z("div",{className:"st-rp-hd",children:"Layout"}),z(hU0,{panelSide:E,onSetPanelSide:w,layersMode:A,onSetLayersMode:I})]}),D("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:f!=="ai-generation",children:[z("div",{className:"st-rp-hd",children:"Provider keys"}),D("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."]}),$&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:$}),T===null&&!$&&z("div",{className:"st-settings-intro",children:"Loading…"}),T?.map((h)=>z(kU0,{provider:h,onChanged:d},h.id)),T?.length===0&&z("div",{className:"st-settings-intro",children:"No providers registered."})]}),D("section",{role:"tabpanel",id:"st-spanel-figma","aria-labelledby":"st-stab-figma",hidden:f!=="figma",children:[z("div",{className:"st-rp-hd",children:"Figma"}),z(jU0,{})]}),D("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:f!=="subtitles",children:[z("div",{className:"st-rp-hd",children:"Subtitles"}),z(RU0,{}),z(CU0,{})]}),D("section",{role:"tabpanel",id:"st-spanel-video","aria-labelledby":"st-stab-video",hidden:f!=="video",children:[z("div",{className:"st-rp-hd",children:"Video"}),z(SU0,{}),z(yU0,{})]})]})]})]})})}var oW=y8(i8(),1);function pU0({name:J,size:X=15}){if(J==="x")return z("svg",{width:X,height:X,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 qE({onPick:J,onClose:X}){let[Q,Y]=oW.useState(null),[W,G]=oW.useState("");oW.useEffect(()=>{let K=!0;return fetch("/_api/stickers").then((U)=>U.json()).then((U)=>K&&Y(U.ok?U.packs:[])).catch(()=>K&&Y([])),()=>{K=!1}},[]),oW.useEffect(()=>{let K=(U)=>{if(U.key==="Escape")U.stopPropagation(),X()};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[X]);let Z=oW.useMemo(()=>{if(!Q)return[];let K=W.trim().toLowerCase();if(!K)return Q;return Q.map((U)=>({...U,stickers:U.stickers.filter((V)=>V.file.toLowerCase().includes(K)||(V.keywords||[]).some((B)=>B.toLowerCase().includes(K)))})).filter((U)=>U.stickers.length>0)},[Q,W]),H=Z.reduce((K,U)=>K+U.stickers.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(K)=>{if(K.target===K.currentTarget)X()},children:D("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[D("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:X,children:z(pU0,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"input",type:"text",value:W,onChange:(K)=>G(K.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((K)=>D("div",{children:[D("div",{className:"st-sp-pack-hd",children:[z("span",{className:"st-sp-pack-name",children:K.name}),K.author&&D("span",{className:"st-sp-pack-author",children:["by ",K.author]})]}),z("div",{className:"st-sp-grid",children:K.stickers.map((U)=>z("button",{type:"button",className:"st-sp-cell",title:U.keywords?.[0]||U.file,onClick:()=>J(U),children:z("img",{className:"st-sp-thumb",src:U.url,alt:U.keywords?.[0]||U.file,loading:"lazy"})},U.file))})]},K.slug))})]}),Q&&Q.length>0&&z("div",{className:"st-sp-ft",children:Q.map((K)=>D("span",{children:[K.name,K.author?` — ${K.author}`:"",K.attributionUrl?D(Q0,{children:[" ","(",z("a",{href:K.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},K.slug))})]})})}var KJ=y8(i8(),1);var lU0=["dots","grid","lines","diagonal","crosshatch"],dU0=["normal","multiply","screen","overlay","soft-light"],cU0=["none","vignette","radial-reveal","edge-fade"],iU0=[{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}],Bm=(J)=>J?JSON.parse(JSON.stringify(J)):{};function oU0(J){let X={};for(let[Q,Y]of Object.entries(J)){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)X[Q]=W}else X[Q]=Y}return X}var nW={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 yK({title:J,right:X,onReset:Q,children:Y}){return z(lg,{title:J,right:X,onReset:Q,children:Y})}function lX({label:J,tip:X,children:Q}){return D(Q0,{children:[D("div",{style:nW.row,children:[z("span",{style:nW.label,children:J}),Q]}),X?z("div",{style:nW.tipBelow,children:X}):null]})}function BE({value:J,fallback:X,label:Q,ColorPicker:Y,onApply:W}){let[G,Z]=KJ.useState(!1),H=KJ.useRef(null),K=J||X;return KJ.useEffect(()=>{if(!G)return;let U=(V)=>{if(!H.current?.contains(V.target))Z(!1)};return document.addEventListener("pointerdown",U,!0),()=>document.removeEventListener("pointerdown",U,!0)},[G]),z(U3,{swatch:D("span",{className:"st-cp-tokwrap",ref:H,children:[z("button",{type:"button",className:"st-cp-cf-sw",style:{background:K},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:K,onClick:()=>Z((U)=>!U)}),G?z("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?z(Y,{seed:K,label:Q,onApply:W}):z("input",{type:"color",value:K,"aria-label":Q,onChange:(U)=>W(U.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(K||"").replace("#",""),ariaLabel:Q,onValue:(U)=>W(U.startsWith("#")?U:`#${U.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function Nm({asset:J,initialEdit:X,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:Z}){let[H,K]=KJ.useState(()=>Bm(X)),[U,V]=KJ.useState(!X),[B,N]=KJ.useState("idle"),[F,M]=KJ.useState(!1),[O,E]=KJ.useState(""),w=KJ.useRef(null),A=KJ.useRef(H);A.current=H,KJ.useEffect(()=>{if(X||!J)return;let v=!1;return V(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(J)}`).then((n)=>n.ok?n.json():{}).then((n)=>{if(v)return;K(n&&typeof n==="object"?n:{}),V(!1)}).catch(()=>!v&&V(!1)),()=>{v=!0}},[J,X]);let I=KJ.useCallback((v)=>{clearTimeout(w.current),w.current=setTimeout(async()=>{N("saving");try{let n=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(J)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(oU0(v))});N(n.ok?"saved":"error")}catch{N("error")}},160)},[J]),T=KJ.useCallback((v,{commit:n=!1}={})=>{let e=A.current,s=Bm(e);if(v(s),A.current=s,K(s),Y?.(s),I(s),n)G?.(e,s)},[Y,I,G]),R=(v,n,e)=>T((s)=>{if(s.adjustments=s.adjustments||{},n===0||n==null)delete s.adjustments[v];else s.adjustments[v]=n;if(Object.keys(s.adjustments).length===0)delete s.adjustments},{commit:e}),$=(v,n,e)=>T((s)=>{s[v]={...s[v]||{},...n}},{commit:e}),C=()=>T((v)=>delete v.adjustments,{commit:!0}),j=(v)=>T((n)=>{delete n[v]},{commit:!0}),f=async()=>{if(!W)return;M(!0),E("Removing background…");try{let v=await W(J);if(v?.maskAsset)$("backgroundRemoved",{enabled:!0,maskAsset:v.maskAsset},!0),E("Background removed");else E("Background removal failed")}catch{E("Background removal failed")}finally{M(!1)}};if(U)return z("div",{style:{...nW.body,opacity:0.6},children:"Loading photo edit…"});let m=H.adjustments||{},d=H.duotone||{},a=H.grain||{},x=H.pattern||{},h=H.mask||{},l=H.backgroundRemoved||{};return D("div",{style:nW.body,"data-testid":"photo-knobs",children:[D("div",{style:{...nW.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[z("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:J}),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(yK,{title:"Adjustments",onReset:C,children:iU0.map((v)=>z(lX,{label:v.label,children:z(uX,{value:m[v.key],min:v.min,max:v.max,step:v.step??0.01,unit:v.unit??"",ariaLabel:v.label,onInput:(n)=>R(v.key,n),onCommit:(n)=>R(v.key,n,!0)})},v.key))}),z(yK,{title:"Duotone",right:z(nQ,{checked:d.enabled,onChange:(v)=>$("duotone",{enabled:v},!0),label:"on",ariaLabel:"Duotone on"}),onReset:()=>j("duotone"),children:d.enabled&&D(Q0,{children:[z(lX,{label:"Shadow",children:z(BE,{value:d.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(v)=>$("duotone",{colorA:v},!0)})}),z(lX,{label:"Highlight",children:z(BE,{value:d.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(v)=>$("duotone",{colorB:v},!0)})}),z(lX,{label:"Intensity",children:z(uX,{value:d.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(v)=>$("duotone",{intensity:v}),onCommit:(v)=>$("duotone",{intensity:v},!0)})})]})}),z(yK,{title:"Grain",right:z(nQ,{checked:a.enabled,onChange:(v)=>$("grain",{enabled:v},!0),label:"on",ariaLabel:"Grain on"}),onReset:()=>j("grain"),children:a.enabled&&D(Q0,{children:[z(lX,{label:"Amount",children:z(uX,{value:a.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(v)=>$("grain",{amount:v}),onCommit:(v)=>$("grain",{amount:v},!0)})}),z(lX,{label:"Size",children:z(uX,{value:a.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(v)=>$("grain",{size:v}),onCommit:(v)=>$("grain",{size:v},!0)})})]})}),z(yK,{title:"Pattern",right:z(nQ,{checked:x.enabled,onChange:(v)=>$("pattern",{enabled:v},!0),label:"on",ariaLabel:"Pattern on"}),onReset:()=>j("pattern"),children:x.enabled&&D(Q0,{children:[z(lX,{label:"Type",children:z(cW,{value:x.type||"dots",options:lU0,ariaLabel:"Pattern type",onChange:(v)=>$("pattern",{type:v},!0)})}),z(lX,{label:"Blend",children:z(cW,{value:x.blend||"normal",options:dU0,ariaLabel:"Pattern blend",onChange:(v)=>$("pattern",{blend:v},!0)})}),z(lX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:z(BE,{value:x.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(v)=>$("pattern",{color:v},!0)})}),z(lX,{label:"Scale",children:z(uX,{value:x.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(v)=>$("pattern",{scale:v}),onCommit:(v)=>$("pattern",{scale:v},!0)})}),z(lX,{label:"Opacity",children:z(uX,{value:x.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(v)=>$("pattern",{opacity:v}),onCommit:(v)=>$("pattern",{opacity:v},!0)})})]})}),D(yK,{title:"Mask",onReset:()=>j("mask"),children:[z(lX,{label:"Preset",children:z(cW,{value:h.preset||"none",options:cU0,ariaLabel:"Mask preset",onChange:(v)=>$("mask",{preset:v},!0)})}),h.preset&&h.preset!=="none"&&z(lX,{label:"Strength",children:z(uX,{value:h.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(v)=>$("mask",{strength:v}),onCommit:(v)=>$("mask",{strength:v},!0)})})]}),D(yK,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[z("div",{style:{...nW.row,gap:10},"aria-busy":F||void 0,children:l.maskAsset?D(Q0,{children:[z(nQ,{checked:l.enabled,onChange:(v)=>$("backgroundRemoved",{enabled:v},!0),label:"applied"}),z("button",{type:"button",style:{...nW.reset,opacity:F?0.6:1},disabled:F||!W,title:"Run background removal again",onClick:()=>f(),children:F?"removing…":"redo"})]}):D("button",{type:"button",className:"st-btn",style:{opacity:F?0.6:1},disabled:F||!W,"data-testid":"photo-remove-bg",onClick:()=>f(),children:[Z?z(Z,{name:"sparkle",size:14}):null,F?"Removing…":"Remove Background"]})}),z("span",{"aria-live":"polite",className:"sr-only",children:O})]})]})}function jK({name:J,size:X=16}){let Q={cursor:z("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:D(Q0,{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(Q0,{children:z("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{children:[z("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),z("polyline",{points:"9 4 13 8 9 12"})]})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:J==="cursor"?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function NE({icon:J,label:X,sub:Q}){return D("span",{className:"cm-step",children:[z("span",{className:"cm-step-icon",children:z(jK,{name:J,size:16})}),z("span",{className:"cm-step-label",children:X}),z("span",{className:"cm-step-sub",children:Q})]})}function FE(){return D("div",{className:"cm-info",children:[D("div",{className:"cm-live",children:[D("div",{className:"cm-live-hd",children:[z("span",{className:"cm-live-dot","aria-hidden":"true"}),D("span",{children:[z("b",{children:"Together"})," · automatic — no buttons"]})]}),D("div",{className:"cm-live-items",children:[D("span",{className:"cm-live-item",children:[z(jK,{name:"cursor",size:13})," cursors"]}),D("span",{className:"cm-live-item",children:[z(jK,{name:"people",size:13})," who's here"]}),D("span",{className:"cm-live-item",children:[z(jK,{name:"comment",size:13})," comments"]})]}),z("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),D("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"})]}),D("div",{className:"cm-cycle",children:[z(NE,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(jK,{name:"arrow-right",size:15})}),z(NE,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(jK,{name:"arrow-right",size:15})}),z(NE,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var LE=[{render:FE,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 y6=y8(i8(),1);function nU0(J){if(typeof document>"u"||!J)return null;try{let X=document.querySelector(J);if(!X)return null;let Q=X.getBoundingClientRect();if(Q.width===0&&Q.height===0)return null;return Q}catch{return null}}var sZ=320,DE=184;function rU0(J){if(typeof window>"u"||!J)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:sZ};let{innerWidth:X,innerHeight:Q}=window;if(J.left>sZ+36&&X-J.right<sZ+36)return{top:Math.min(Math.max(12,J.top),Q-DE-12),left:Math.max(12,J.left-sZ-16),width:sZ};let G=Q-J.bottom>DE+24?J.bottom+12:Math.max(12,J.top-DE-12),Z=Math.min(Math.max(12,J.left),X-sZ-12);return{top:G,left:Z,width:sZ}}function Fm({steps:J,open:X,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:Z}){let[H,K]=y6.useState(0),[U,V]=y6.useState(null),B=y6.useRef(null),N=y6.useRef(null),F=y6.useRef(null),M=y6.useRef(W);M.current=W;let O=J[H]||null,E=y6.useCallback(()=>{if(!O)return V(null),null;let f=nU0(O.target);return V(f),f},[O]);y6.useEffect(()=>{if(X)K(0)},[X]),y6.useLayoutEffect(()=>{if(!X||!O)return;let f=!1;V(null);try{M.current?.setup?.(O)}catch{}let m=0,d=24,a=()=>{if(f)return;let x=E();if(x||m>=d){if(x){try{document.querySelector(O.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!f)E()})}return}m+=1,F.current=setTimeout(a,130)};return a(),()=>{if(f=!0,F.current)clearTimeout(F.current)}},[X,H,G]),y6.useEffect(()=>{if(!X)return;N.current=document.activeElement;let f=()=>E();return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0);try{N.current?.focus?.()}catch{}}},[X,E]);let w=H>=J.length-1,A=y6.useCallback(()=>{if(w)Y?.(),Q?.();else K((f)=>Math.min(f+1,J.length-1))},[w,Y,Q,J.length]),I=y6.useCallback(()=>K((f)=>Math.max(0,f-1)),[]);if(y6.useEffect(()=>{if(!X)return;function f(m){if(m.key==="Escape")m.preventDefault(),Q?.();else if(m.key==="ArrowRight")m.preventDefault(),A();else if(m.key==="ArrowLeft")m.preventDefault(),I();else if(m.key==="Tab"){let d=B.current;if(!d)return;let a=d.querySelectorAll("button");if(!a.length)return;let x=a[0],h=a[a.length-1];if(m.shiftKey&&document.activeElement===x)m.preventDefault(),h.focus();else if(!m.shiftKey&&document.activeElement===h)m.preventDefault(),x.focus()}}return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[X,A,I,Q]),y6.useEffect(()=>{if(!X)return;let f=setTimeout(()=>{let m=B.current?.querySelector("[data-tour-primary]");try{m?.focus()}catch{}},0);return()=>clearTimeout(f)},[X,H]),!X||!J.length||!O)return null;let T=6,R=U?{top:U.top-T,left:U.left-T,width:U.width+T*2,height:U.height+T*2}:null,$=!!O.requireSelection&&!G,C=(!!O.canvas||!!O.requireSelection)&&Z===!1,j=O.render||null;return D("div",{className:"mdcc-tour",role:"presentation",children:[R?z("div",{className:"mdcc-tour__spot",style:R,"aria-hidden":"true"}):z("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),D("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:rU0(U),children:[D("div",{className:"mdcc-tour__step",children:[H+1," / ",J.length]}),j&&z("div",{className:"mdcc-tour__graphic",children:z(j,{})}),z("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:O.title}),z("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:O.body}),(C||$)&&D("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."]}),D("div",{className:"mdcc-tour__actions",children:[z("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),D("div",{className:"mdcc-tour__nav",children:[H>0&&z("button",{type:"button",className:"mdcc-tour__back",onClick:I,children:"Back"}),z("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:A,children:w?"Done":"Next"})]})]})]})]})}var Lm=[{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 WF=[{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"}];function Dm(J,X,Q){if(!Q||J.origin!==X||J.source!==Q)return null;let Y=J.data;if(Y?.dgn!=="canvas-notice"||typeof Y.message!=="string"||!Y.message.trim())return null;if(!["info","success","error","warning","undo"].includes(Y.kind))return null;return{title:Y.message.slice(0,4000),kind:Y.kind,group:"canvas"}}var _7=y8(i8(),1);var aU0={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},sU0={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function tU0(J){let X=await fetch(`/_api/export-jobs/download?id=${encodeURIComponent(J)}`);if(!X.ok)return null;let Q=X.headers.get("Content-Disposition")||"",Y=/filename="([^"]+)"/.exec(Q)?.[1]||null;return{blob:await X.blob(),filename:Y}}async function Mm(J,X){let Q=await tU0(J);if(!Q)return;let Y=Q.filename||X||"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 eU0(J,X){return Oh(X||"export",J)}function Om({enabled:J=!0}={}){let[X,Q]=_7.useState(()=>new Map),[Y,W]=_7.useState(!1),[G,Z]=_7.useState(null),[H,K]=_7.useState([]),[U,V]=_7.useState(()=>new Set),B=_7.useRef(new Map),N=_7.useRef(new Set),F=_7.useRef(new Set);_7.useEffect(()=>{if(!J)return;let f=!0;return fetch("/_api/export-jobs").then((m)=>m.json()).then((m)=>{if(!f)return;let d=new Map;for(let a of Array.isArray(m?.jobs)?m.jobs:[])d.set(a.id,a),B.current.set(a.id,a.status),F.current.add(a.id);Q(d)}).catch(()=>{}),()=>{f=!1}},[J]);let M=_7.useCallback((f)=>{if(!f||typeof f.id!=="string")return;Q((m)=>{let d=new Map(m);return d.set(f.id,f),d})},[]);_7.useEffect(()=>{let f=B.current,m=[],d=[];for(let a of X.values()){let x=f.get(a.id),h=a.status==="queued"||a.status==="running",l=a.status==="done"||a.status==="failed";if(x===void 0&&h&&!F.current.has(a.id))F.current.add(a.id),m.push(a.id);else if(x!==a.status&&l)m.push(a.id),d.push(a)}for(let a of X.values())f.set(a.id,a.status);if(m.length)K((a)=>{let x=a.filter((h)=>!m.includes(h));return[...m,...x]});if(G9()||!d.length)return;for(let a of d){if(a.status!=="done")continue;if(N.current.has(a.id))continue;if(!document.hasFocus())continue;N.current.add(a.id),Mm(a.id,a.filename)}},[X]);let O=_7.useMemo(()=>Array.from(X.values()).sort((f,m)=>(m.createdAt||"").localeCompare(f.createdAt||"")),[X]),E=O.filter((f)=>f.status==="running").length,w=O.filter((f)=>f.status==="queued").length,A=_7.useCallback((f)=>K((m)=>m.filter((d)=>d!==(f??m[0]))),[]),I=_7.useCallback((f)=>{Z(typeof f==="string"?f:null),W(!0)},[]),T=_7.useCallback(()=>W(!1),[]),R=_7.useCallback(async(f,m)=>{V((d)=>new Set(d).add(f.id));try{await m()}finally{V((d)=>{let a=new Set(d);return a.delete(f.id),a})}},[]),$=_7.useCallback(async(f)=>{N.current.add(f.id),await R(f,()=>Mm(f.id,f.filename))},[R]),C=_7.useCallback(async(f)=>{N.current.add(f.id),await R(f,()=>eU0(f.id,f.filename))},[R]),j=Y?null:H[0]??null;return{jobs:O,upsert:M,runningCount:E,queuedCount:w,busyCount:E+w,panelOpen:Y,selectedJobId:G,toastJobs:H.map((f)=>X.get(f)).filter(Boolean),openPanel:I,closePanel:T,showToast:!!j,toastJob:j?X.get(j)??null:null,dismissToast:A,download:$,save:C,savingIds:U}}function Am(J){let X=aU0[J.format]||String(J.format||"").toUpperCase(),Q=sU0[J.scope]||J.scope;return`${X} · ${Q}`}function _m(J){if(G9())return J?"Saving…":"Save…";return J?"Downloading…":"Download"}function wm({progress:J}){if(!J||!J.total)return z("div",{className:"st-export-progress st-export-progress--indeterminate","aria-hidden":"true"});let X=Math.max(0,Math.min(100,Math.round(J.current/J.total*100)));return z("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":X,"aria-valuemin":0,"aria-valuemax":100,children:z("div",{className:"st-export-progress-bar",style:{width:`${X}%`}})})}var ME=new Map;function JV0(J){let X=J.progress?.current,Q=J.progress?.total;if(!X||!Q||X>=Q)return ME.delete(J.id),null;let Y=ME.get(J.id);if(!Y||X<Y.c)Y={t:Date.now(),c:X},ME.set(J.id,Y);let W=X-Y.c;if(W<3)return null;let G=(Date.now()-Y.t)/W*(Q-X);if(G<45000)return"<1 min left";return`~${Math.round(G/60000)} min left`}function XV0({job:J}){let X=J.status==="done"&&!!J.degraded,Q=J.status==="queued"?"Queued":J.status==="running"?J.progress?.total?`${J.progress.current} of ${J.progress.total}`:"Rendering…":J.status==="done"?X&&J.degraded.audioDropped?"Ready · no audio":X&&J.degraded.fontsNotEmbedded?.length?"Ready · font warning":X?"Ready · degraded":"Ready":"Failed",Y=J.status==="running"?JV0(J):null;return D("span",{className:`st-export-pill st-export-pill--${J.status}${X?" st-export-pill--degraded":""}`,children:[Q,Y?` · ${Y}`:""]})}function Em({degraded:J,compact:X=!1}){if(!J)return null;let Q=J.fontsNotEmbedded??[],Y=J.audioDropped?"Exported without audio.":Q.length?`Fonts a print shop will reject: ${Q.join(", ")}.`:"Exported with reduced fidelity.";return D("div",{className:"st-export-degraded","data-testid":"export-degraded-note",children:[z("span",{"aria-hidden":"true",children:"!"})," ",X?$V(Y):Y,J.remedy?z("div",{className:"st-export-degraded__fix",children:X?$V(J.remedy):J.remedy}):null]})}function Pm({center:J}){let X=J.busyCount>0;return D("button",{type:"button",className:"st-exports","data-tour":"exports","data-busy":X?"true":"false","aria-label":X?`Exports — ${J.busyCount} running`:"Exports","data-tip":"Exports",onClick:J.openPanel,children:[z("span",{"aria-hidden":"true",children:"⬇"}),X&&z("span",{className:"st-exports__count","aria-hidden":"true",children:J.busyCount})]})}function QV0({job:J,center:X}){let Q=J.status==="queued"||J.status==="running",Y=J.status==="done",W=X.savingIds.has(J.id),G=`export-${J.id}`;return _7.useEffect(()=>{E5({id:G,group:"exports",title:Q?"Exporting…":Y?J.degraded?"Export ready — with a problem":"Export ready":"Export failed",description:Q?"Running in the background — you can keep working.":Y?J.filename??"Ready to download.":J.error??"Something went wrong.",kind:Q?"info":Y?J.degraded?"warning":"success":"error",duration:Q?1/0:void 0,timerKey:Q?"active":J.status,paused:W,onDismiss:()=>X.dismissToast(J.id),content:D(Q0,{children:[z("div",{className:"maude-notice-summary",children:Am(J)}),Q&&z(wm,{progress:J.progress}),Y&&z(Em,{degraded:J.degraded,compact:!0}),D("div",{className:"st-toast-actions",children:[Y&&D("button",{type:"button",className:"btn btn--primary btn--sm",disabled:W,onClick:()=>G9()?void X.save(J):void X.download(J),children:[W&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),_m(W)]}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>X.openPanel(J.id),children:"View in history"})]})]})})},[G,J,Q,Y,W,X.dismissToast,X.openPanel,X.save,X.download]),_7.useEffect(()=>()=>CW(G),[G]),null}function Im({center:J}){return J.toastJobs.map((X)=>z(QV0,{job:X,center:J},X.id))}function km({center:J}){let{panelOpen:X,closePanel:Q,selectedJobId:Y}=J,W=_7.useRef(null);if(_7.useEffect(()=>{if(X&&Y)W.current?.scrollIntoView?.({block:"nearest"}),W.current?.focus()},[X,Y]),_7.useEffect(()=>{if(!X)return;function G(Z){if(Z.key==="Escape")Q()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[X,Q]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Q()},children:D("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[D("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:J.jobs.length===0?z("p",{className:"mdcc-wn-empty",children:"No exports yet."}):z("ul",{className:"st-export-list",children:J.jobs.map((G)=>D("li",{className:"st-export-item","data-testid":`export-job-${G.id}`,ref:G.id===Y?W:null,tabIndex:-1,children:[D("div",{className:"st-export-item__hd",children:[z("span",{className:"st-export-item__label",children:Am(G)}),z(XV0,{job:G})]}),(G.status==="queued"||G.status==="running")&&z(wm,{progress:G.progress}),G.status==="done"&&z(Em,{degraded:G.degraded}),G.status==="done"&&D("div",{className:"st-export-item__ft",children:[z("span",{className:"st-export-item__filename",children:G.filename}),D("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:J.savingIds.has(G.id),onClick:()=>G9()?J.save(G):J.download(G),children:[J.savingIds.has(G.id)&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),_m(J.savingIds.has(G.id))]})]}),G.status==="failed"&&z("div",{className:"st-export-item__ft",children:D("details",{className:"st-export-item__error",children:[z("summary",{children:"Show error details"}),z("pre",{children:G.error??"Export failed."})]})})]},G.id))})})]})})}var o7=y8(i8(),1);var OE=4,YV0="https://github.com/1aGh/maude/issues/new",Tm={shell:"Maude window (auto)",artboard:"Active artboard (auto)",attached:"Attached by you"};function WV0(J){if(J==="darwin")return"⇧⌘4 then Space";if(J==="win32")return"Win+Shift+S";return"your screenshot tool"}function Cm(J){let X=new Uint8Array(J/2);return crypto.getRandomValues(X),Array.from(X,(Q)=>Q.toString(16).padStart(2,"0")).join("")}function GV0(){try{let J=localStorage.getItem("maude-install-id");if(!J)J=`i-${Cm(12)}`,localStorage.setItem("maude-install-id",J);return J}catch{return null}}async function Rm(J){let X=new Image;X.src=J.url,await X.decode();let Q=document.createElement("canvas");Q.width=X.naturalWidth,Q.height=X.naturalHeight;let Y=Q.getContext("2d");Y.drawImage(X,0,0),Y.fillStyle="#000";for(let W of J.rects)Y.fillRect(W.x*X.naturalWidth,W.y*X.naturalHeight,W.w*X.naturalWidth,W.h*X.naturalHeight);return new Promise((W)=>Q.toBlob(W,"image/png"))}var ZV0=(J)=>new Promise((X)=>{let Q=new FileReader;Q.onload=()=>X(Q.result),Q.readAsDataURL(J)});function HV0({shot:J,redacting:X,onRects:Q,onRemove:Y}){let W=o7.useRef(null),G=o7.useRef(null),[Z,H]=o7.useState(null),K=(U)=>{let V=W.current.getBoundingClientRect();return{x:Math.min(Math.max((U.clientX-V.left)/V.width,0),1),y:Math.min(Math.max((U.clientY-V.top)/V.height,0),1)}};return D("div",{className:"rb-shot","data-testid":"report-bug-shot",children:[D("div",{ref:W,className:`rb-shot-box${X?" is-redacting":""}`,onPointerDown:(U)=>{if(!X)return;U.currentTarget.setPointerCapture(U.pointerId),G.current=K(U),H({...G.current,w:0,h:0})},onPointerMove:(U)=>{if(!X||!G.current)return;let V=K(U),B=G.current;H({x:Math.min(B.x,V.x),y:Math.min(B.y,V.y),w:Math.abs(V.x-B.x),h:Math.abs(V.y-B.y)})},onPointerUp:()=>{if(!X||!G.current)return;if(G.current=null,Z&&Z.w>0.005&&Z.h>0.005)Q([...J.rects,Z]);H(null)},children:[z("img",{src:J.url,alt:"screenshot to attach",draggable:!1}),[...J.rects,...Z?[Z]:[]].map((U,V)=>z("div",{className:"rb-redact-rect",style:{left:`${U.x*100}%`,top:`${U.y*100}%`,width:`${U.w*100}%`,height:`${U.h*100}%`}},V))]}),z("div",{className:"rb-shot-src",children:Tm[J.source]??Tm.attached}),D("div",{className:"rb-shot-actions",children:[J.rects.length>0&&z("button",{type:"button",className:"rb-link",onClick:()=>Q([]),children:"Clear redactions"}),z("button",{type:"button",className:"rb-link","data-testid":"report-bug-shot-remove",onClick:Y,children:"Remove"})]})]})}function $m({open:J,onClose:X,activeCanvas:Q=null}){let[Y,W]=o7.useState("describe"),[G,Z]=o7.useState(""),[H,K]=o7.useState(null),[U,V]=o7.useState([]),[B,N]=o7.useState([]),[F,M]=o7.useState({logTail:!0,activeCanvas:!0,projectName:!1,crashLogs:!0}),[O,E]=o7.useState(!1),[w,A]=o7.useState(!1),[I,T]=o7.useState(null),[R,$]=o7.useState(null),C=o7.useCallback(()=>{for(let l of U)URL.revokeObjectURL(l.url);W("describe"),Z(""),K(null),V([]),N([]),E(!1),A(!1),T(null),$(null)},[U]),j=o7.useCallback((l,v="attached")=>{if(!l)return;V((n)=>n.length>=OE?n:[...n,{url:URL.createObjectURL(l),blob:l,source:v,rects:[]}])},[]),f=o7.useCallback(async()=>{if(G9()){try{let v=await cZ();if(v?.bytes)j(new Blob([new Uint8Array(v.bytes)]),"attached")}catch{}return}let l=document.createElement("input");l.type="file",l.accept="image/*",l.style.cssText="position:fixed;left:-9999px;top:0",document.body.appendChild(l),l.addEventListener("change",()=>{let v=l.files?.[0];if(v)j(v,"attached");l.remove()}),l.click()},[j]);if(o7.useEffect(()=>{if(!J)return;let l=!0;if(fetch("/_api/debug-bundle").then((v)=>v.ok?v.json():null).then((v)=>l&&K(v)).catch(()=>{}),Q)fetch("/_api/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:"png",scope:"artboard"})}).then((v)=>v.ok?v.blob():null).then((v)=>l&&v&&j(v,"artboard")).catch(()=>{});if(E(!0),fetch("/_api/shell-shot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({canvas:Q})}).then((v)=>v.ok?v.blob():null).then((v)=>{if(!l)return;if(v)j(v,"shell");E(!1)}).catch(()=>l&&E(!1)),G9())A7("list_crash_logs").then((v)=>l&&N(Array.isArray(v)?v.slice(0,3):[])).catch(()=>{});return()=>{l=!1}},[J,Q]),o7.useEffect(()=>{if(!J)return;function l(v){for(let n of v.clipboardData?.items??[])if(n.type.startsWith("image/"))j(n.getAsFile())}return window.addEventListener("paste",l),()=>window.removeEventListener("paste",l)},[J,j]),!J)return null;let m=()=>{C(),X()};async function d(){let l={schema:"maude-report/v1",reportId:`r-${Cm(8)}`,createdAt:new Date().toISOString(),app:{maudeVersion:H?.app?.maudeVersion??"unknown",surface:G9()?"native":"browser",platform:H?.app?.platform??"unknown",arch:H?.app?.arch??"unknown"},context:{projectName:F.projectName?H?.context?.projectName??null:null,activeCanvas:F.activeCanvas?Q:null},description:G.trim(),attachments:{screenshots:U.length,serverLogTail:F.logTail&&!!H?.logs?.serverLogTail,processStats:F.logTail&&!!H?.process,crashLogs:F.crashLogs?B.length:0},logs:{}},v=GV0();if(v)l.installId=v;if(F.logTail&&H?.logs?.serverLogTail)l.logs.serverLogTail=H.logs.serverLogTail;if(F.logTail&&H?.process)l.process={rssBytes:H.process.rssBytes,heapUsedBytes:H.process.heapUsedBytes,uptimeSeconds:H.process.uptimeSeconds};if(F.crashLogs&&B.length&&G9()){l.logs.crashLogs=[];for(let n of B)try{let e=await A7("read_crash_log",{name:n.name});l.logs.crashLogs.push({name:n.name,body:e})}catch{}}return l}async function a(){W("sending"),$(null);try{let l=await d(),v=new FormData;v.set("report",JSON.stringify(l));for(let s of U)v.append("screenshot",await Rm(s),"screenshot.png");let n=await fetch("/_api/report",{method:"POST",body:v}),e=await n.json().catch(()=>null);if(n.ok&&e?.ok){T(e),W("done");return}$(e?.error??`report failed (HTTP ${n.status})`),W("fallback")}catch{$("Maude could not reach the report service."),W("fallback")}}async function x(){try{let l=await d(),v=[];for(let z0 of U)v.push(await ZV0(await Rm(z0)));let e=await(await fetch("/_api/report-fallback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({report:l,screenshots:v})})).json().catch(()=>null),s=encodeURIComponent(l.description.split(`
5678
+ `.trim();function LU0(){if(typeof document>"u")return;if(document.getElementById("dc-context-menu-css"))return;let J=document.createElement("style");J.id="dc-context-menu-css",J.textContent=FU0,document.head.appendChild(J)}function Hm({target:J,sections:X,onClose:Q}){LU0();let Y=kJ.useRef(null),[W,G]=kJ.useState({x:J.clientX,y:J.clientY});kJ.useEffect(()=>{let H=Y.current;if(!H)return;let K=H.getBoundingClientRect(),U=window.innerWidth,V=window.innerHeight,B=J.clientX,N=J.clientY;if(B+K.width>U-8)B=Math.max(8,U-K.width-8);if(N+K.height>V-8)N=Math.max(8,V-K.height-8);if(B!==W.x||N!==W.y)G({x:B,y:N});H.querySelector("button.dc-menu-item:not([disabled])")?.focus();let M=(w)=>{if(!H.contains(w.target))Q()},O=(w)=>{if(w.key==="Escape"){w.preventDefault(),Q();return}if(w.key==="ArrowDown"||w.key==="ArrowUp"){w.preventDefault();let A=Array.from(H.querySelectorAll("button.dc-menu-item:not([disabled])"));if(A.length===0)return;let I=document.activeElement,T=I instanceof HTMLButtonElement?A.indexOf(I):-1,R=w.key==="ArrowDown"?(T+1)%A.length:(T-1+A.length)%A.length;A[R]?.focus()}},E=()=>Q();return document.addEventListener("pointerdown",M,!0),document.addEventListener("keydown",O,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",Q),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("keydown",O,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",Q)}},[J.clientX,J.clientY,Q,W.x,W.y]);let Z=X.map((H)=>H.filter((K)=>{return!(typeof K.hidden==="function"?K.hidden(J):K.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,K)=>{let U=H.map((V)=>V.id).join("|")||`s${K}`;return D("div",{role:"group",children:[K>0?z("div",{className:"dc-menu-sep","aria-hidden":"true"}):null,H.map((V)=>z(DU0,{item:V,target:J,onClose:Q},V.id))]},U)})})}function DU0({item:J,target:X,onClose:Q}){let[Y,W]=kJ.useState(!1),[G,Z]=kJ.useState(!1),H=kJ.useRef(null),K=kJ.useRef(null),U=kJ.useRef(null),V=typeof J.submenu==="function"?J.submenu(X):J.submenu,B=typeof J.disabled==="function"?J.disabled(X):J.disabled;if(!V||V.length===0)return D("button",{type:"button",role:"menuitem",disabled:B,title:B?J.disabledHint:void 0,className:`dc-menu-item${J.destructive?" is-destructive":""}`,onClick:()=>{if(B)return;J.onSelect(X),Q()},children:[z("span",{children:J.label}),J.shortcut?z("span",{className:"dc-menu-shortcut",children:J.shortcut}):null]});let N=()=>{if(U.current)clearTimeout(U.current),U.current=null},F=(O=!1)=>{N();let E=H.current?.getBoundingClientRect();if(E&&typeof window<"u")Z(E.right+200>window.innerWidth);if(W(!0),O)setTimeout(()=>{K.current?.querySelector("button.dc-menu-item:not([disabled])")?.focus()},0)},M=()=>{N(),U.current=setTimeout(()=>W(!1),140)};return D("div",{className:"dc-menu-sub",onMouseEnter:()=>F(),onMouseLeave:M,children:[D("button",{ref:H,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":Y,disabled:B,className:"dc-menu-item",onClick:()=>Y?W(!1):F(),onKeyDown:(O)=>{if(O.key==="ArrowRight"||O.key==="Enter"||O.key===" ")O.preventDefault(),F(!0);else if(O.key==="ArrowLeft"||O.key==="Escape"){if(Y)O.stopPropagation(),W(!1)}},children:[z("span",{children:J.label}),z("span",{className:"dc-menu-caret","aria-hidden":"true",children:"▸"})]}),Y?z("div",{ref:K,className:`dc-menu-flyout${G?" is-flip":""}`,role:"menu",onMouseEnter:N,onMouseLeave:M,children:V.map((O)=>{let E=typeof O.disabled==="function"?O.disabled(X):O.disabled;return D("button",{type:"button",role:"menuitem",disabled:E,title:E?O.disabledHint:void 0,className:`dc-menu-item${O.destructive?" is-destructive":""}`,onClick:()=>{if(E)return;O.onSelect(X),Q()},onKeyDown:(w)=>{if(w.key==="ArrowLeft"||w.key==="Escape")w.preventDefault(),w.stopPropagation(),W(!1),H.current?.focus()},children:[z("span",{children:O.label}),O.shortcut?z("span",{className:"dc-menu-shortcut",children:O.shortcut}):null]},O.id)})}):null]})}function b6(J){if(J.placeholder)return"placeholder";let X=J.mediaTag;if(X==="Video"||X==="OffthreadVideo"||X==="MaudeVideo")return"video";if(X==="Img")return"image";if(X==="Audio")return"audio";return"jsx"}function JE(J){let X=b6(J);if(X==="placeholder")return"✨";if(X==="video")return"▶";if(X==="image")return"◫";if(X==="audio")return"♪";return"ƒ"}function XE(J){let X=b6(J),Q=J.mediaSrc?` · ${String(J.mediaSrc).split("/").pop()}`:"";if(X==="placeholder")return`AI placeholder (${J.placeholder?.kind||"veo"}) · ${J.placeholder?.prompt||""}`;if(X==="video")return`Video clip${Q}`;if(X==="image")return`Image${Q}`;if(X==="audio")return`Audio${Q}`;return"Animated JSX (code-driven)"}function JF({name:J,size:X=15}){return z("svg",{width:X,height:X,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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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"})]})}[J]})}var SK=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block",flex:"none"}}),BX=(J,X,Q)=>Math.max(X,Math.min(Q,J));function QE(J,X){let Q=J/(X||30),Y=Math.floor(Q),W=Math.round((Q-Y)*100);return`${Y}.${String(W).padStart(2,"0")}s`}function B3(J){let[X,Q]=U9.useState(J),Y=U9.useRef(J),W=U9.useCallback((G)=>{Y.current=typeof G==="function"?G(Y.current):G,Q(Y.current)},[]);return[X,W,Y]}var XY=96,MU0=24;function YE({comps:J=[],compId:X=null,sequences:Q=[],audio:Y=[],transitions:W=[],total:G=0,frame:Z=0,playing:H=!1,loop:K=!1,onSeek:U,onPlay:V,onPause:B,onToggleLoop:N,muted:F=!1,onToggleMute:M,volume:O=1,onVolume:E,height:w,resizing:A,onResize:I,onRetime:T,onRemove:R,onReplace:$,onReplaceAudio:C,onReplaceLayer:j,onReorder:f,onReorderMove:m,onToggleHide:d,onDropMedia:a,onClose:x,selectedClipId:h=null,onSelect:l,resolveMediaUrl:v,transitionClips:n=[],onClipVerb:e,onSplitAtPlayhead:s,onAddTitle:H0,onAddImage:r,onAddAiClip:z0,onGeneratePlaceholder:i,comments:q0=[],promptText:Z0,onAddComment:I0,onResolveComment:a0,onDeleteComment:s0}){let[e0,D8]=U9.useState(()=>new Set),[s8,w8]=U9.useState(!1),N8=CK(J,X),C0=N8?.artboardLabel||N8?.artboardId||null,A0=Math.max(1,G||N8?.durationInFrames||1),$0=N8?.fps??30,Q8=BX(Math.round(Z),0,A0-1),Z8=U9.useRef(null),f8=U9.useRef(null),b8=U9.useRef(!1),O9=U9.useRef(null);U9.useEffect(()=>{O9.current?.focus()},[]);let[h0,C8]=U9.useState(null),[A9,F8]=U9.useState(0),[B0,J8]=U9.useState(null),r0=U9.useCallback((o)=>{f8.current=o,J8(o)},[]);U9.useLayoutEffect(()=>{if(!B0)return;let o=()=>F8(B0.clientWidth);o();let G0=0,D0=()=>{if(B0.clientWidth>0)o();else G0=requestAnimationFrame(D0)};if(B0.clientWidth<=0)G0=requestAnimationFrame(D0);let y0=new ResizeObserver(o);return y0.observe(B0),()=>{if(y0.disconnect(),G0)cancelAnimationFrame(G0)}},[B0]);let j0=Math.max(40,A9-XY-MU0),t0=sw(j0,A0),H8=h0==null?t0:tw(h0,j0,A0),p0=Math.ceil(A0*H8),d0=(o)=>o*H8,k8=U9.useRef(null);U9.useLayoutEffect(()=>{if(k8.current==null)return;let o=f8.current;if(o)o.scrollLeft=k8.current;k8.current=null});let _0=U9.useCallback((o,G0)=>{let D0=f8.current,y0=tw(o,j0,A0),P0=G0!=null?G0:Q.find((z8)=>z8.stableId&&z8.stableId===h)?.from??Q8;if(D0)k8.current=Wm(H8,y0,P0,D0.scrollLeft);C8(y0<=t0?null:y0)},[j0,A0,H8,t0,Q8,Q,h]);U9.useEffect(()=>{let o=(G0)=>{let D0=G0.target,y0=D0?.tagName;if(y0==="INPUT"||y0==="TEXTAREA"||y0==="SELECT"||D0?.isContentEditable)return;if((G0.metaKey||G0.ctrlKey)&&(G0.key==="="||G0.key==="+"))G0.preventDefault(),_0(H8*ew);else if((G0.metaKey||G0.ctrlKey)&&G0.key==="-")G0.preventDefault(),_0(H8/ew);else if(G0.key==="0"&&!G0.metaKey&&!G0.ctrlKey&&!G0.altKey)C8(null);else if((G0.key==="c"||G0.key==="C")&&!G0.metaKey&&!G0.ctrlKey&&!G0.altKey)i9((P0)=>!P0);else if(G0.key==="Escape")i9(!1)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[H8,_0]),U9.useEffect(()=>{let o=f8.current;if(!o)return;let G0=(D0)=>{if(!D0.ctrlKey&&!D0.metaKey)return;D0.preventDefault();let y0=Z8.current?.getBoundingClientRect(),P0=y0!=null?BX(Math.round(q3(D0.clientX-y0.left-XY,H8)),0,A0-1):Q8;_0(H8*Math.exp(-D0.deltaY*0.01),P0)};return o.addEventListener("wheel",G0,{passive:!1}),()=>o.removeEventListener("wheel",G0)},[H8,Q8,A0,_0,B0]);let X8=(()=>{let o=Math.log(H8/t0)/Math.log(tN/Math.max(0.000001,t0));return BX(Math.round((Number.isFinite(o)?o:0)*100),0,100)})(),P8=(o)=>{let G0=BX(o,0,100)/100;return t0*Math.pow(tN/Math.max(0.000001,t0),G0)},[U0,o0,R8]=B3(null),[J9,i0,a7]=B3(null),[F9,v7,I8]=B3(null),[X9,d8]=U9.useState(null),O0=U9.useRef(null),K8=U9.useCallback((o)=>{d8({frame:o}),clearTimeout(O0.current),O0.current=setTimeout(()=>d8(null),350)},[]),[S8,V9]=U9.useState(null),[x9,i9]=U9.useState(!1),[h9,t,M0]=B3(null),[E0,v0]=U9.useState(null),[W8,g8]=U9.useState(null),[t8,v8]=U9.useState(null),[W9,T9,e9]=B3(null),J7=U9.useRef(!1),FQ=U9.useCallback((o)=>{o.preventDefault(),o.stopPropagation(),o.currentTarget.setPointerCapture?.(o.pointerId);let G0=o.clientY,D0=w||216,y0=(z8)=>{I?.(BX(D0+(G0-z8.clientY),140,640))},P0=()=>{window.removeEventListener("pointermove",y0),window.removeEventListener("pointerup",P0)};window.addEventListener("pointermove",y0),window.addEventListener("pointerup",P0)},[w,I]),aX=U9.useCallback((o)=>{let G0=Z8.current;if(!G0)return;let D0=G0.getBoundingClientRect(),y0=q3(o-D0.left-XY,H8);U?.(BX(Math.round(y0),0,A0-1))},[U,A0,H8]);U9.useEffect(()=>{if(!b8.current)return;let o=(D0)=>aX(D0.clientX),G0=()=>{b8.current=!1};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}});let[BJ,oJ]=U9.useState(null),nJ=U9.useCallback((o,G0,D0)=>{let y0=Z8.current;if(!y0||!I0)return;let P0=y0.getBoundingClientRect(),z8=BX(Math.round(q3(o.clientX-P0.left-XY,H8)),0,A0-1),M8=G0&&G0.stableId?{clipStableId:G0.stableId,frameOffset:Math.max(0,z8-(G0.from||0)),frame:z8,lane:D0||void 0}:{frame:z8,lane:D0||void 0};oJ({x:BX(o.clientX-130,8,window.innerWidth-280),y:Math.max(48,o.clientY-140),anchor:M8,at:z8}),i9(!1)},[H8,A0,I0]),e7=(o)=>{if(U0)return;if(x9){o.preventDefault(),nJ(o,null,null);return}o.preventDefault(),l?.(null),b8.current=!0,aX(o.clientX),o.currentTarget.setPointerCapture?.(o.pointerId)},Y4=(o)=>o?0:8/H8;U9.useEffect(()=>{if(!U0)return;let o=(D0)=>{let y0=(D0.clientX-U0.startX)/U0.pxf,P0=U0.startFrom+Math.round(U0.startDur+y0),z8=cw(P0,U0.targets,D0.altKey?0:8/U0.pxf);if(z8!==P0)K8(z8);let M8=Math.max(1,z8-U0.startFrom),Z9=M8<=1;if(U0.maxDur>0&&M8>=U0.maxDur)M8=U0.maxDur,Z9=!0;o0((L9)=>L9?{...L9,curDur:M8,atClamp:Z9}:L9)},G0=()=>{let D0=R8.current;if(o0(null),D0&&D0.curDur!==D0.startDur)T?.(D0.ref??D0.index,{durationInFrames:D0.curDur})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[U0,T,K8]),U9.useEffect(()=>{if(!J9)return;let o=(D0)=>{let y0=(D0.clientX-J9.startX)/J9.pxf,P0=Math.max(0,Math.round(J9.startFrom+y0)),z8=Math.max(0,cw(P0,J9.targets,D0.altKey?0:8/J9.pxf));if(z8!==P0)K8(z8);if(Math.abs(z8-J9.startFrom)>=1)J7.current=!0;let M8=document.querySelector(".tl-storyline-track")?.getBoundingClientRect(),Z9=!!(M8&&D0.clientY>=M8.top&&D0.clientY<=M8.bottom);i0((L9)=>L9?{...L9,curFrom:z8,overStory:Z9}:L9)},G0=(D0)=>{let y0=a7.current;if(i0(null),!y0)return;let P0=document.querySelector(".tl-storyline-track")?.getBoundingClientRect();if(P0&&e&&D0.clientY>=P0.top&&D0.clientY<=P0.bottom&&J7.current)e(y0.ref??{index:y0.index},"to-storyline",{});else if(y0.curFrom!==y0.startFrom)T?.(y0.ref??y0.index,{from:y0.curFrom})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[J9,T,e,K8]),U9.useEffect(()=>{if(!W9)return;let o=(D0)=>{let y0=Math.round((D0.clientX-W9.startX)/W9.pxf),P0=Math.min(W9.maxDelta,y0);T9((z8)=>z8?{...z8,delta:P0}:z8)},G0=()=>{let D0=e9.current;if(T9(null),D0&&D0.delta)e?.(D0.ref,"trim-in",{deltaFrames:D0.delta})};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[W9,e]);let R7=(o,G0)=>{o.stopPropagation(),o.preventDefault();let D0=Q[G0];if(!D0)return;T9({index:G0,ref:j9(D0,G0),startX:o.clientX,pxf:H8,delta:0,maxDelta:Math.max(0,(D0.duration??1)-1)})},FX=(o)=>ig({fps:$0,totalFrames:A0,clips:Q,movingIndex:o,playhead:Q8}),j9=(o,G0)=>({stableId:o?.stableId??null,index:G0}),VY=(o,G0)=>{if(o.stopPropagation(),!m)return;let y0=Q.map((P0,z8)=>({s:P0,i:z8})).filter(({s:P0})=>P0.series).findIndex(({i:P0})=>P0===G0);if(y0<0)return;J7.current=!1,v7({index:G0,slot:y0,targetSlot:y0,dx:0,startX:o.clientX,pxf:H8})};U9.useEffect(()=>{if(!F9)return;let o=Q.map((y0,P0)=>({s:y0,i:P0})).filter(({s:y0})=>y0.series),G0=(y0)=>{let P0=y0.clientX-F9.startX;if(Math.abs(P0)>3)J7.current=!0;let z8=o[F9.slot];if(!z8)return;let M8=z8.s.from+z8.s.duration/2+P0/F9.pxf,Z9=0;o.forEach(({s:L9},I6)=>{if(I6===F9.slot)return;if(L9.from+L9.duration/2<M8)Z9+=1}),v7((L9)=>L9?{...L9,dx:P0,targetSlot:Z9}:L9)},D0=(y0)=>{let P0=I8.current;if(v7(null),!P0)return;if(J7.current&&e){let z8=document.querySelector(".tl-storyline-track")?.getBoundingClientRect();if(z8&&y0.clientY<z8.top-6){let M8=Q[P0.index];if(M8){e(j9(M8,P0.index),"to-overlay",{});return}}}if(P0.targetSlot!==P0.slot){let z8=o[P0.slot],M8=o.filter((Z9,L9)=>L9!==P0.slot);if(z8&&M8.length)if(P0.targetSlot<=0)m?.(j9(z8.s,z8.i),j9(M8[0].s,M8[0].i),"before");else{let Z9=M8[Math.min(P0.targetSlot,M8.length)-1];m?.(j9(z8.s,z8.i),j9(Z9.s,Z9.i),"after")}}};return window.addEventListener("pointermove",G0),window.addEventListener("pointerup",D0,{once:!0}),()=>{window.removeEventListener("pointermove",G0),window.removeEventListener("pointerup",D0)}},[F9,Q,m,e]);let p7=(o,G0,D0)=>{if(!e)return;o.stopPropagation(),o.preventDefault(),t({index:G0,docIdx:D0,curTarget:D0})};U9.useEffect(()=>{if(!h9)return;let o=(D0)=>{let y0=h9.docIdx;for(let P0 of document.querySelectorAll("[data-layer-doc]")){let z8=P0.getBoundingClientRect();if(D0.clientY>=z8.top&&D0.clientY<=z8.bottom)y0=Number(P0.dataset.layerDoc)}t((P0)=>P0?{...P0,curTarget:y0}:P0)},G0=()=>{let D0=M0.current;if(t(null),D0&&D0.curTarget!==D0.docIdx){let y0=Q[D0.index];if(y0)e?.(j9(y0,D0.index),"layer-order",{toIndex:D0.curTarget})}};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",G0,{once:!0}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",G0)}},[h9,Q,e]);let y5=(o,G0,D0)=>{if(Q[G0]?.loose)return;if(Q[G0]?.series){VY(o,G0);return}if(!T)return;o.stopPropagation(),J7.current=!1,i0({index:G0,ref:j9(Q[G0],G0),startX:o.clientX,startFrom:D0,pxf:H8,curFrom:D0,targets:FX(G0)})},HG=(o,G0,D0)=>{o.stopPropagation(),o.preventDefault();let y0=Q[G0],P0=y0?.from??0;o0({index:G0,ref:j9(y0,G0),startX:o.clientX,startDur:D0,startFrom:P0,pxf:H8,curDur:D0,atClamp:!1,maxDur:y0?.mediaSrc&&z6[`d|${y0.mediaSrc}`]||0,targets:FX(G0)})},f7=(o)=>{let G0=o>=0?"+":"−",D0=Math.abs(Math.round(o));return`${G0}${D0}f / ${G0}${(D0/($0||30)).toFixed(2)}s`},qY=Gm(H8,$0),LX=[];for(let o=0;o<=A0-1;o+=qY)LX.push(o);let V7=[],rJ=[],l9=[];Q.forEach((o,G0)=>{if(o.series)V7.push({seq:o,i:G0});else if(b6(o)==="audio")l9.push({seq:o,i:G0});else rJ.push({seq:o,i:G0})});let q7=V7.length>0&&Q.some((o)=>b6(o)!=="jsx"),[z6,SJ]=U9.useState({}),j5=U9.useCallback((o)=>{if(!o)return null;if(o.startsWith("//"))return null;if(/^(https?:|data:|blob:)/i.test(o))return null;if(o.startsWith("/"))return o;return v?v(o):null},[v]);U9.useEffect(()=>{let o=!0;for(let G0 of Q){if(b6(G0)!=="video"||!G0.mediaSrc)continue;let D0=j5(G0.mediaSrc);if(!D0)continue;let y0=rw(Math.max(2,G0.duration*H8)),P0=`s|${G0.mediaSrc}|${y0}`;if(z6[P0]!==void 0)continue;SJ((z8)=>z8[P0]!==void 0?z8:{...z8,[P0]:null}),Jm(D0,y0).then((z8)=>{if(o&&z8)SJ((M8)=>({...M8,[P0]:z8}))})}for(let G0 of Y){if(!G0.src)continue;let D0=j5(G0.src);if(!D0)continue;let y0=`p|${G0.src}`;if(z6[y0]!==void 0)continue;SJ((P0)=>P0[y0]!==void 0?P0:{...P0,[y0]:null}),Xm(D0).then((P0)=>{if(o&&P0)SJ((z8)=>({...z8,[y0]:P0}))})}for(let G0 of Q){if(b6(G0)!=="video"||!G0.mediaSrc)continue;let D0=`d|${G0.mediaSrc}`;if(z6[D0]!==void 0)continue;SJ((y0)=>y0[D0]!==void 0?y0:{...y0,[D0]:null}),fetch(`/_api/footage?asset=${encodeURIComponent(G0.mediaSrc)}`).then((y0)=>y0.ok?y0.json():null).then((y0)=>{if(!o)return;let P0=Number(y0?.durationSec),z8=Number.isFinite(P0)&&P0>0?Math.round(P0*($0||30)):0;SJ((M8)=>({...M8,[D0]:z8}))}).catch(()=>{if(o)SJ((y0)=>({...y0,[D0]:0}))})}return()=>{o=!1}},[Q,Y,H8,j5,z6,$0]);let LQ=(()=>{if(!F9)return null;let o=Q.map((Z9,L9)=>({s:Z9,i:L9})).filter(({s:Z9})=>Z9.series),G0=o[F9.slot];if(!G0)return null;let D0=W&&W[0]?.dur||0,y0=o.filter((Z9,L9)=>L9!==F9.slot),P0=[...y0];P0.splice(Math.max(0,Math.min(F9.targetSlot,y0.length)),0,G0);let z8=new Map,M8=o[0]?.s.from??0;for(let{s:Z9,i:L9}of P0)z8.set(L9,M8),M8+=Z9.duration-D0;return z8})(),P6=(o)=>Array.from(o?.types??[]).includes("Files"),W4=(o)=>{if(!a||!P6(o.dataTransfer))return;o.preventDefault(),o.stopPropagation(),w8(!1),V9(null);let G0=Array.from(o.dataTransfer.files||[]);if(G0.length)a(G0,N8?{lane:"overlay",frame:Q8}:null)},DQ=()=>{let o=Q.filter((D0)=>D0.series),G0=o.map((D0)=>d0(D0.from));if(o.length){let D0=o[o.length-1];G0.push(d0(D0.from+D0.duration))}return G0},zG=(o)=>{if(!a||!P6(o.dataTransfer))return;o.preventDefault(),o.stopPropagation(),o.dataTransfer.dropEffect="copy";let G0=o.currentTarget.getBoundingClientRect(),D0=o.clientX-G0.left,y0=DQ(),P0=0,z8=1/0;y0.forEach((M8,Z9)=>{let L9=Math.abs(M8-D0);if(L9<z8)z8=L9,P0=Z9}),V9({lane:"storyline",slot:P0,x:y0[P0]??D0})},bJ=(o,G0)=>(D0)=>{if(!a||!P6(D0.dataTransfer))return;D0.preventDefault(),D0.stopPropagation(),D0.dataTransfer.dropEffect="copy";let y0=D0.currentTarget.getBoundingClientRect(),P0=D0.clientX-y0.left,z8=BX(Math.round(q3(P0,H8)),0,A0-1);V9({lane:o,row:G0,frame:z8,x:P0})},yJ=(o,G0)=>S8&&S8.lane===o&&S8.row===G0?z("span",{className:"tl-drop-caret","data-testid":"timeline-drop-caret",style:{left:S8.x-1}}):null,aJ=(o)=>(G0)=>{if(!a||!P6(G0.dataTransfer))return;G0.preventDefault(),G0.stopPropagation(),w8(!1);let D0=S8;V9(null);let y0=Array.from(G0.dataTransfer.files||[]);if(!y0.length)return;if(o.lane==="storyline")a(y0,{lane:"storyline",index:D0?.slot??void 0});else a(y0,{lane:o.lane,frame:D0?.frame??0})},v5=(o,G0,{lane:D0,laneName:y0})=>{let P0=U0&&U0.index===G0?U0.curDur:o.duration,z8=!!(U0&&U0.index===G0),M8=J9&&J9.index===G0?J9.curFrom:o.from,Z9=!!(J9&&J9.index===G0),L9=0,I6=!1;if(D0==="storyline"&&F9){if(F9.index===G0)I6=!0,L9=F9.dx;else if(LQ?.has(G0))M8=LQ.get(G0)}let s6=(Array.isArray(o.layers)?o.layers:[]).length>=2,FJ=h!=null&&o.stableId===h,f5=["Video","OffthreadVideo","Audio","Img","MaudeVideo","MaudeAudio","MaudeImg"].includes(o.label)&&o.mediaSrc?String(o.mediaSrc).split("/").pop():o.label,KG=/^[a-f0-9]{6,16}\.\w+$/i.test(f5||"")?`Clip ${G0+1}`:f5,jJ=!!(W9&&W9.index===G0),C7=jJ?W9.delta:0,R9=d0(M8)+L9+(jJ?d0(C7):0),DX=Math.max(2,d0(P0-C7)),K6=o.mediaProps||null;return D(U9.Fragment,{children:[D("button",{type:"button",className:`tl-seq-block${z8?" is-resizing":""}${Z9?" is-moving":""}${I6?" is-dragging":""}${o.hidden?" is-hidden":""}${FJ?" is-selected":""}${D0==="storyline"?" tl-beat":""}`,"data-testid":`timeline-seq-${G0}`,"data-clip-id":o.stableId||void 0,"data-kind":b6(o),"data-hidden":o.hidden?"1":void 0,title:o.series?`${o.label} · ${M8}–${M8+P0}f (${P0}f) · series beat — trim the right edge to retime`:`${o.label} · ${M8}–${M8+P0}f (${P0}f) · drag to move (Alt = no snap)`,"aria-label":o.series?`${o.label}, series beat, frames ${M8} to ${M8+P0}. Click to select.`:`${o.label}, from frame ${M8} to ${M8+P0}, ${P0} frames. Click to select; drag to move.`,style:{left:R9,width:DX,cursor:T&&!o.series?"grab":void 0},onContextMenu:(a8)=>{a8.preventDefault(),a8.stopPropagation(),l?.(o.stableId??null),v0({index:G0,x:a8.clientX,y:a8.clientY})},onPointerDown:(a8)=>{if(x9){a8.stopPropagation(),a8.preventDefault(),nJ(a8,o,y0||D0);return}y5(a8,G0,o.from)},onDoubleClick:(a8)=>{if(a8.stopPropagation(),o.loose)return;l?.(o.stableId??null),v8({mode:"clip",index:G0,x:a8.clientX-120,y:Math.max(60,a8.clientY-320)})},onClick:(a8)=>{if(a8.stopPropagation(),J7.current){J7.current=!1;return}l?.(o.stableId??null)},children:[K6?.playbackRate&&K6.playbackRate!==1?D("span",{className:"tl-chip tl-chip-speed","data-testid":`timeline-speed-chip-${G0}`,children:[K6.playbackRate,"×"]}):null,K6?.muted?z("span",{className:"tl-chip tl-chip-mute",title:"Muted","data-testid":`timeline-mute-chip-${G0}`,children:"\uD83D\uDD07"}):null,(()=>{if(b6(o)==="image"&&o.mediaSrc){let h6=j5(o.mediaSrc);if(!h6)return null;return z("span",{className:"tl-strip tl-strip--img","aria-hidden":"true",children:z("img",{src:h6,alt:"",draggable:!1})})}if(b6(o)!=="video"||!o.mediaSrc)return null;let a8=rw(Math.max(2,o.duration*H8)),J6=z6[`s|${o.mediaSrc}|${a8}`];if(!J6)return null;return z("span",{className:"tl-strip","aria-hidden":"true",children:J6.map((h6,MX)=>z("img",{src:h6,alt:"",draggable:!1},MX))})})(),z("span",{className:"tl-kind","data-kind":b6(o),title:XE(o),children:JE(o)}),D("span",{className:"tl-seq-name",children:[KG,z8?` · ${P0}f`:"",Z9?` · @${M8}f`:""]}),o.keyframes.map((a8,J6)=>{let h6=(a8.from-o.from)/Math.max(1,o.duration)*100,MX=(a8.to-a8.from)/Math.max(1,o.duration)*100;return z("span",{className:"tl-kf","data-testid":`timeline-kf-${G0}-${J6}`,style:{left:`${BX(h6,0,100)}%`,width:`${Math.max(1.5,MX)}%`},title:`seek to keyframe ${a8.from}f (animates ${a8.from}–${a8.to}f)`,onPointerDown:(OQ)=>OQ.stopPropagation(),onClick:(OQ)=>{OQ.stopPropagation(),U?.(a8.from)}},J6)}),(q0||[]).filter((a8)=>a8.timeline?.clipStableId&&a8.timeline.clipStableId===o.stableId).map((a8)=>z("span",{role:"button",tabIndex:-1,className:`tl-clip-pin${a8.status==="resolved"?" is-resolved":""}`,"data-testid":`timeline-clip-pin-${a8.id}`,title:`${a8.author||"comment"}: ${a8.text}`,style:{left:d0(BX(a8.timeline.frameOffset||0,0,Math.max(0,P0-1)))},onPointerDown:(J6)=>J6.stopPropagation(),onClick:(J6)=>{J6.stopPropagation(),g8({id:a8.id,x:J6.clientX-130,y:Math.max(60,J6.clientY-180)})},children:"\uD83D\uDCAC"},`cm${a8.id}`)),D0==="storyline"&&s6?z("span",{role:"button",tabIndex:-1,className:"tl-beat-expand","data-testid":`timeline-beat-expand-${G0}`,title:e0.has(G0)?"Show this beat’s layers":"Collapse layers",onPointerDown:(a8)=>a8.stopPropagation(),onClick:(a8)=>{a8.stopPropagation(),D8((J6)=>{let h6=new Set(J6);if(h6.has(G0))h6.delete(G0);else h6.add(G0);return h6})},children:e0.has(G0)?"▸":"▾"}):null]}),T&&!o.loose?z("span",{className:"tl-seq-resize","data-testid":`timeline-resize-${G0}`,title:"Drag to retime this sequence",style:{left:R9+DX-5},onPointerDown:(a8)=>HG(a8,G0,o.duration),onClick:(a8)=>a8.stopPropagation()}):null,e&&!o.loose&&o.mediaSrc&&(b6(o)==="video"||b6(o)==="audio")?z("span",{className:"tl-seq-trim-in","data-testid":`timeline-trim-in-${G0}`,title:"Drag to trim the in-point (left edge)",style:{left:R9-1},onPointerDown:(a8)=>R7(a8,G0),onClick:(a8)=>a8.stopPropagation()}):null,jJ?z("span",{className:`tl-trim-tip${C7>=W9.maxDelta&&C7>0?" is-clamped":""}`,"data-testid":"timeline-trim-in-tip",style:{left:R9},children:f7(C7)}):null,z8?z("span",{className:`tl-trim-tip${U0.atClamp?" is-clamped":""}`,"data-testid":"timeline-trim-tip",style:{left:R9+DX+8},children:f7(P0-U0.startDur)}):null,Z9?z("span",{className:"tl-trim-tip","data-testid":"timeline-move-tip",style:{left:R9},children:f7(M8-J9.startFrom)}):null,$&&o.replaceable&&!s6?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-replace-${G0}`,title:`Replace this ${b6(o)}`,"aria-label":`Replace media in ${o.label}`,style:{left:R9+DX-34},onPointerDown:(a8)=>a8.stopPropagation(),onClick:(a8)=>{a8.stopPropagation(),$(j9(o,G0))},children:"⇄"}):null]},`b${G0}`)},G4=()=>{if(!e)return null;let o=new Set((W||[]).map((G0)=>G0.afterIndex));return V7.slice(0,-1).map(({seq:G0,i:D0},y0)=>{if(o.has(D0))return null;let P0=V7[y0+1];if(!P0)return null;return z("button",{type:"button",className:"tl-seam tl-seam-add","data-testid":`timeline-seam-add-${y0}`,title:"Add transition (fade · 15f — click the chip after to change)",style:{left:d0(P0.seq.from)-9},onPointerDown:(z8)=>z8.stopPropagation(),onClick:(z8)=>{z8.stopPropagation(),e(j9(G0,D0),"insert-transition",{presentation:"fade",durationInFrames:15})},children:z(SK,{as:X3,size:13})},`addseam${y0}`)})},NJ=()=>(W||[]).map((o,G0)=>{let D0=Q[o.afterIndex+1];if(!D0)return null;let y0=d0(D0.from+(o.dur||0)/2);return z("button",{type:"button",className:"tl-seam","data-testid":`timeline-seam-${G0}`,title:`Transition · ${o.dur||0}f — click to edit`,style:{left:y0-9},onPointerDown:(P0)=>P0.stopPropagation(),onClick:(P0)=>{P0.stopPropagation(),v8({mode:"transition",seam:G0,x:P0.clientX-120,y:Math.max(60,P0.clientY-260)})},children:"⧓"},`seam${G0}`)}),Z4=(o,G0)=>D("div",{className:"tl-row","data-testid":`timeline-audio-${G0}`,children:[D("span",{className:"tl-row-label",title:o.label,children:[z("span",{className:"tl-kind","data-kind":"audio",title:`Audio · ${o.label}`,"aria-label":`Audio · ${o.label}`,children:"♪"}),z("span",{className:"tl-row-label-text",children:o.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("audio",`a${G0}`),onDrop:aJ({lane:"audio"}),children:[yJ("audio",`a${G0}`),D("div",{className:"tl-audio-block",title:`${o.label} · ${o.from}–${o.from+o.duration}f`,style:{left:d0(o.from),width:Math.max(2,d0(o.duration))},children:[z("svg",{className:"tl-wave",viewBox:"0 0 100 12",preserveAspectRatio:"none","aria-hidden":!0,children:o.src&&z6[`p|${o.src}`]?z("path",{className:"tl-wave-real",d:Qm(z6[`p|${o.src}`])}):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:o.label})]}),C?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-audio-replace-${G0}`,title:"Replace this audio","aria-label":`Replace audio ${o.label}`,style:{left:d0(o.from)+Math.max(2,d0(o.duration))-20},onPointerDown:(D0)=>D0.stopPropagation(),onClick:(D0)=>{D0.stopPropagation(),C(G0)},children:"⇄"}):null]})]},`a${G0}`);return D("aside",{ref:O9,tabIndex:-1,className:`tl-panel${A?" is-resizing":""}${s8?" is-drop":""}${x9?" is-commenting":""}`,style:{...w?{height:w}:{},outline:"none"},onPointerEnter:()=>{if(!document.activeElement||document.activeElement===document.body)O9.current?.focus();else{let o=document.activeElement.tagName;if(o!=="INPUT"&&o!=="TEXTAREA"&&o!=="SELECT")O9.current?.focus()}},onDragOver:(o)=>{if(!a||!P6(o.dataTransfer))return;if(o.preventDefault(),o.dataTransfer.dropEffect="copy",!s8)w8(!0)},onDragLeave:(o)=>{if(o.relatedTarget==null)w8(!1),V9(null)},onDrop:W4,"aria-label":"Timeline","data-testid":"timeline-panel",children:[z("div",{className:"tl-resize-handle","data-testid":"timeline-resize-handle",title:"Drag to resize",onPointerDown:FQ}),D("div",{className:"tl-head",children:[N8?D(Q0,{children:[z("button",{type:"button",className:"tl-btn tl-btn-primary","aria-label":H?"Pause":"Play","aria-pressed":H,"data-testid":"timeline-playpause",onClick:()=>H?B?.():V?.(),children:z(JF,{name:H?"pause":"play"})}),z("button",{type:"button",className:"tl-btn","aria-label":"Jump to start",onClick:()=>U?.(0),children:z(JF,{name:"start"})}),z("button",{type:"button",className:`tl-btn${K?" is-on":""}`,"aria-label":"Loop","aria-pressed":K,"data-testid":"timeline-loop",onClick:()=>N?.(),children:z(JF,{name:"loop"})}),N8?z("button",{type:"button",className:`tl-btn${F?"":" is-on"}`,"aria-label":F?"Unmute":"Mute","aria-pressed":!F,"data-testid":"timeline-mute",title:F?"Unmute audio":"Mute audio",onClick:()=>M?.(),children:z(JF,{name:F?"muted":"sound"})}):null,N8?z("input",{type:"range",className:"tl-volume",min:"0",max:"100",value:Math.round((F?0:O)*100),"data-testid":"timeline-volume","aria-label":"Volume",title:"Volume",onChange:(o)=>E?.(Number(o.target.value)/100)}):null,J.length>1?z("span",{className:`tl-artboard${C0?"":" is-unknown"}`,"data-testid":"timeline-artboard",title:C0?`Timeline is scoped to artboard "${C0}" — pan to another artboard to switch`:"This canvas has several video comps and the Timeline couldn't tell which artboard this one sits in — the transport may be moving a comp you're not looking at",children:C0??"artboard ?"}):null,D("span",{className:"tl-readout","data-testid":"timeline-readout",children:[z("b",{children:Q8}),z("span",{className:"tl-sep",children:"/"}),A0-1,z("span",{className:"tl-time",children:QE(Q8,$0)})]}),z("span",{className:"tl-spacer"}),s?z("button",{type:"button",className:"tl-btn","aria-label":"Split at playhead",title:"Split at playhead (⌘B)","data-testid":"timeline-split",onClick:()=>s(),children:z(SK,{as:aZ})}):null,H0?z("button",{type:"button",className:"tl-btn","aria-label":"Add title overlay",title:"Add a title overlay at the playhead","data-testid":"timeline-add-title",onClick:()=>H0(Q8),children:z(SK,{as:H3})}):null,r?z("button",{type:"button",className:"tl-btn","aria-label":"Add image overlay",title:"Add an image overlay at the playhead","data-testid":"timeline-add-image",onClick:()=>r(Q8),children:z(SK,{as:aV})}):null,z0?z("button",{type:"button",className:"tl-btn","aria-label":"Add AI placeholder clip",title:"Add an AI placeholder clip at the end of the storyline","data-testid":"timeline-placeholder-add",onClick:()=>z0(),children:z(SK,{as:xW})}):null,I0?z("button",{type:"button",className:`tl-btn${x9?" is-on":""}`,"aria-label":"Comment tool","aria-pressed":x9,title:"Comment tool — click anywhere on the timeline to pin a comment (C)","data-testid":"timeline-comment-tool",onClick:()=>i9((o)=>!o),children:z(SK,{as:tV})}):null]}):z("span",{className:"tl-title",children:"Timeline"}),z("span",{className:"tl-spacer"}),N8&&A0>900?D("span",{className:"tl-long-badge","data-testid":"timeline-long-badge",title:`Long comp: ${A0} frames (≈${Math.round(A0/($0||30))}s). Exports over 900 frames can take several minutes on the fallback path — see the export dialog.`,children:["⚠ ",Math.round(A0/($0||30)),"s"]}):null,N8?D("span",{className:"tl-meta",children:[$0," fps · ",A0,"f"]}):null,N8?z("input",{type:"range",className:"tl-zoom",min:"0",max:"100",value:X8,"data-testid":"timeline-zoom","aria-label":"Timeline zoom",title:"Zoom (⌘+/⌘−, 0 = fit)",onChange:(o)=>_0(P8(Number(o.target.value)))}):null,z("button",{type:"button",className:"tl-x","aria-label":"Close timeline",onClick:x,children:"×"})]}),!N8?D("div",{className:"tl-empty","data-testid":"timeline-empty",children:["No video-comp on this canvas. ",z("b",{children:"Drop video clips right here"})," to start a new cut, use ",z("b",{children:"⌘K → New video…"})," for an empty one, or make an artboard a",z("code",{children:"<VideoComp>"})," yourself."]}):z("div",{className:"tl-scroll",ref:r0,children:D("div",{className:"tl-tracks",ref:Z8,"data-testid":"timeline-track",style:{width:XY+p0},onPointerDown:e7,onDragOver:bJ("overlay","tracks"),onDrop:aJ({lane:"overlay"}),children:[q0.length?z("div",{className:"tl-comments-strip","data-testid":"timeline-comments-strip",children:q0.map((o)=>{let G0=o.timeline||{},D0=null,y0=!1;if(G0.clipStableId){let P0=Q.find((z8)=>z8.stableId===G0.clipStableId);if(P0)D0=P0.from+Math.min(G0.frameOffset||0,Math.max(0,P0.duration-1));else if(G0.frame!=null)D0=G0.frame,y0=!0}else if(G0.frame!=null)D0=G0.frame;if(D0==null)return null;return z("button",{type:"button",className:`tl-comment-pin${o.status==="resolved"?" is-resolved":""}${y0?" is-detached":""}`,"data-testid":`timeline-comment-${o.id}`,title:`${o.author||"comment"}${y0?" (detached — clip removed)":""}: ${o.text}`,style:{left:XY+d0(BX(D0,0,A0-1))-8},onPointerDown:(P0)=>P0.stopPropagation(),onClick:(P0)=>{P0.stopPropagation(),U?.(BX(D0,0,A0-1)),g8({id:o.id,x:P0.clientX-130,y:Math.max(60,P0.clientY-180)})},children:"\uD83D\uDCAC"},o.id)})}):null,z("div",{className:"tl-ruler",style:{width:p0},children:LX.map((o)=>{let G0=o%($0||30)===0,D0=G0||qY<=5;return z("span",{className:`tl-tick${G0?" is-major":""}`,style:{left:d0(o)},children:D0?z("span",{className:"tl-tick-label",children:Zm(o,$0)}):null},o)})}),yJ("overlay","tracks"),Q.length===0?D("div",{className:"tl-row",children:[z("span",{className:"tl-row-label",children:"comp"}),z("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:z("div",{className:"tl-seq-block",style:{left:0,width:p0},children:z("span",{className:"tl-seq-name",children:"whole composition"})})})]}):q7?D(Q0,{children:[(()=>{let o=rJ.filter(({seq:G0})=>!G0.loose);return[...rJ].reverse().map(({seq:G0,i:D0})=>{let y0=G0.loose?null:o.findIndex((M8)=>M8.i===D0),P0=y0==null?null:y0+2,z8="tl-row tl-row--overlay"+(h9&&h9.index===D0?" is-layer-dragging":"")+(h9&&y0!=null&&h9.index!==D0&&h9.curTarget===y0?" is-layer-target":"");return D("div",{className:z8,"data-testid":`timeline-row-${D0}`,...y0!=null?{"data-layer-doc":y0}:{},children:[D("span",{className:"tl-row-label",title:G0.mediaSrc||G0.label,children:[y0!=null?D("span",{className:"tl-lane-id tl-lane-id--grab","data-testid":`timeline-lane-chip-${D0}`,title:"Drag up/down to reorder layers",onPointerDown:(M8)=>p7(M8,D0,y0),children:["V",P0]}):z("span",{className:"tl-lane-id",title:"Loose media — no layer order",children:"◌"}),z("span",{className:"tl-kind","data-kind":b6(G0),children:JE(G0)})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("overlay",`o${D0}`),onDrop:aJ({lane:"overlay"}),children:[v5(G0,D0,{lane:"overlay",laneName:P0!=null?`V${P0}`:"loose"}),yJ("overlay",`o${D0}`)]})]},`o${D0}`)})})(),D("div",{className:"tl-row tl-row--storyline","data-testid":"timeline-storyline",children:[D("span",{className:"tl-row-label",children:[z("span",{className:"tl-lane-id tl-lane-id--story",children:"V1"}),z("span",{className:"tl-band-tag tl-band-tag--story",children:"storyline"})]}),D("div",{className:`tl-row-track tl-storyline-track${F9?" is-reordering":""}${J9?.overStory?" is-drop-target":""}`,style:{width:p0,flex:"none"},onDragOver:zG,onDrop:aJ({lane:"storyline"}),children:[V7.map(({seq:o,i:G0})=>v5(o,G0,{lane:"storyline",laneName:"V1"})),F9?null:NJ(),F9?null:G4(),S8?.lane==="storyline"?z("span",{className:"tl-drop-caret","data-testid":"timeline-drop-caret",style:{left:S8.x-1}}):null]})]}),V7.filter(({seq:o,i:G0})=>Array.isArray(o.layers)&&o.layers.length>=2&&!e0.has(G0)).map(({seq:o,i:G0})=>o.layers.map((D0,y0)=>{let P0=D0.kind==="video"||D0.kind==="image"||D0.kind==="audio"?D0.kind:"jsx",z8=D0.kind==="video"?"▶":D0.kind==="image"?"◫":D0.kind==="audio"?"♪":"ƒ";return D("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${G0}-${y0}`,children:[D("span",{className:"tl-row-label",title:`${o.label} · ${D0.label}`,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":P0,children:z8}),z("span",{className:"tl-row-label-text",children:D0.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":P0,"data-testid":`timeline-layer-block-${G0}-${y0}`,title:`${o.label} · ${D0.label} (${D0.kind} layer)`,style:{left:d0(o.from),width:Math.max(2,d0(o.duration))},onContextMenu:(M8)=>{M8.preventDefault(),M8.stopPropagation(),v0({index:G0,layerIndex:y0,x:M8.clientX,y:M8.clientY})},children:z("span",{className:"tl-seq-name",children:D0.label})}),j&&(D0.mediaCdId||D0.mediaArrayRef)?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${G0}-${y0}`,title:`Replace this ${D0.kind}`,"aria-label":`Replace ${D0.label}`,style:{left:d0(o.from)+Math.max(2,d0(o.duration))-20},onPointerDown:(M8)=>M8.stopPropagation(),onClick:(M8)=>{M8.stopPropagation(),j(j9(o,G0),y0)},children:"⇄"}):null]})]},`bl${G0}-${y0}`)})),l9.map(({seq:o,i:G0},D0)=>D("div",{className:"tl-row tl-row--overlay tl-row--audio","data-testid":`timeline-row-${G0}`,children:[D("span",{className:"tl-row-label",title:o.mediaSrc||o.label,children:[D("span",{className:"tl-lane-id tl-lane-id--audio",children:["A",D0+1]}),z("span",{className:"tl-kind","data-kind":"audio",children:"♪"})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},onDragOver:bJ("audio",`ac${G0}`),onDrop:aJ({lane:"audio"}),children:[v5(o,G0,{lane:"audio",laneName:`A${D0+1}`}),yJ("audio",`ac${G0}`)]})]},`ac${G0}`)),Y.map((o,G0)=>Z4(o,G0)),z("div",{className:`tl-newlayer-zone${S8?.row==="newlayer"?" is-active":""}`,"data-testid":"timeline-newlayer-zone",onDragOver:bJ("overlay","newlayer"),onDrop:aJ({lane:"overlay"}),children:z("span",{style:{marginLeft:XY},children:"Drop clips here — new layer"})})]}):D(Q0,{children:[Q.map((o,G0)=>{let D0=Array.isArray(o.layers)?o.layers:[],y0=D0.length>=2,P0=y0&&!e0.has(G0),z8=U0&&U0.index===G0?U0.curDur:o.duration;return D(U9.Fragment,{children:[D("div",{className:"tl-row","data-testid":`timeline-row-${G0}`,children:[D("span",{className:"tl-row-label",title:o.label,children:[y0?z("button",{type:"button",className:"tl-expand","data-testid":`timeline-expand-${G0}`,title:P0?"Collapse layers":"Show layers","aria-label":P0?`Collapse ${o.label} layers`:`Show ${o.label} layers`,"aria-expanded":P0,onPointerDown:(M8)=>M8.stopPropagation(),onClick:(M8)=>{M8.stopPropagation(),M8.preventDefault(),D8((Z9)=>{let L9=new Set(Z9);if(L9.has(G0))L9.delete(G0);else L9.add(G0);return L9})},children:P0?"▾":"▸"}):z("span",{className:"tl-expand tl-expand--spacer","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":b6(o),title:XE(o),"aria-label":XE(o),children:JE(o)}),z("span",{className:"tl-row-label-text",children:o.label})]}),z("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:v5(o,G0,{lane:"row"})})]}),P0?D0.map((M8,Z9)=>{let L9=M8.kind==="video"?"video":M8.kind==="image"?"image":M8.kind==="audio"?"audio":"jsx",I6=M8.kind==="video"?"▶":M8.kind==="image"?"◫":M8.kind==="audio"?"♪":"ƒ",MQ=!!(M8.mediaCdId||M8.mediaArrayRef);return D("div",{className:"tl-row tl-row--layer","data-testid":`timeline-layer-${G0}-${Z9}`,children:[D("span",{className:"tl-row-label",title:M8.label,children:[z("span",{className:"tl-layer-indent","aria-hidden":"true"}),z("span",{className:"tl-kind","data-kind":L9,children:I6}),z("span",{className:"tl-row-label-text",children:M8.label})]}),D("div",{className:"tl-row-track",style:{width:p0,flex:"none"},children:[z("div",{className:"tl-seq-block tl-layer-block","data-kind":L9,"data-testid":`timeline-layer-block-${G0}-${Z9}`,title:`${M8.label} (${M8.kind} layer)`,style:{left:d0(o.from),width:Math.max(2,d0(z8))},onContextMenu:(s6)=>{s6.preventDefault(),s6.stopPropagation(),v0({index:G0,layerIndex:Z9,x:s6.clientX,y:s6.clientY})},children:z("span",{className:"tl-seq-name",children:M8.label})}),j&&MQ?z("button",{type:"button",className:"tl-seq-replace","data-testid":`timeline-layer-replace-${G0}-${Z9}`,title:`Replace this ${M8.kind}`,"aria-label":`Replace ${M8.label}`,style:{left:d0(o.from)+Math.max(2,d0(z8))-20},onPointerDown:(s6)=>s6.stopPropagation(),onClick:(s6)=>{s6.stopPropagation(),j(j9(o,G0),Z9)},children:"⇄"}):null]})]},`l${Z9}`)}):null]},G0)}),Y.map((o,G0)=>Z4(o,G0))]}),X9?z("span",{className:"tl-snapline",style:{left:XY+d0(X9.frame)}}):null,z("span",{className:"tl-playhead","data-testid":"timeline-playhead",style:{left:XY+d0(Q8)},children:z("span",{className:"tl-playhead-time",children:QE(Q8,$0)})})]})}),BJ?N3.createPortal(D("div",{className:"tlci tlci--comment",style:{left:BJ.x,top:BJ.y},children:[D("div",{className:"tlci-head",style:{cursor:"default"},children:[D("span",{className:"tlci-title",children:["Comment @ ",QE(BJ.at,$0),BJ.anchor.lane?` · ${BJ.anchor.lane}`:""]}),z("button",{type:"button",className:"tlci-x","aria-label":"Close",onClick:()=>oJ(null),children:"×"})]}),D("div",{className:"tlci-body",children:[z("textarea",{className:"tlci-textarea",rows:3,autoFocus:!0,placeholder:"Comment… (Enter to add)","data-testid":"timeline-comment-composer",onKeyDown:(o)=>{if(o.stopPropagation(),o.key==="Enter"&&!o.shiftKey){o.preventDefault();let G0=o.currentTarget.value.trim();if(G0)I0?.(BJ.anchor,G0);oJ(null)}else if(o.key==="Escape")oJ(null)}}),z("div",{className:"tlci-row",children:z("button",{type:"button",className:"tlci-btn","data-testid":"timeline-comment-submit",onClick:(o)=>{let D0=o.currentTarget.closest(".tlci")?.querySelector("textarea")?.value?.trim();if(D0)I0?.(BJ.anchor,D0);oJ(null)},children:"Add comment"})})]})]}),document.body):null,W8?N3.createPortal((()=>{let o=q0.find((G0)=>G0.id===W8.id);if(!o)return null;return D("div",{className:"tlci",style:{left:W8.x,top:W8.y},role:"dialog","aria-label":"Timeline comment","data-testid":"timeline-comment-popover",onPointerDown:(G0)=>G0.stopPropagation(),children:[D("div",{className:"tlci-head",children:[D("span",{className:"tlci-title",children:["\uD83D\uDCAC ",o.author||"comment"]}),z("button",{type:"button",className:"tlci-x","aria-label":"Close",onClick:()=>g8(null),children:"×"})]}),D("div",{className:"tlci-body",children:[z("p",{className:"tlci-comment-text",children:o.text}),(o.thread||[]).map((G0,D0)=>D("p",{className:"tlci-note",children:["↳ ",G0.author?`${G0.author}: `:"",G0.body]},D0)),D("div",{className:"tlci-presets",children:[o.status!=="resolved"&&a0?z("button",{type:"button",className:"tlci-chip",onClick:()=>{a0(o.id),g8(null)},children:"Resolve"}):null,s0?z("button",{type:"button",className:"tlci-chip",onClick:()=>{s0(o.id),g8(null)},children:"Delete"}):null]})]})]})})(),document.body):null,t8?N3.createPortal((()=>{if(t8.mode==="transition"){let G0=n[t8.seam],D0=(W||[])[t8.seam];if(!G0)return null;return z(aN,{mode:"transition",clipLabel:"Transition",transition:{dur:D0?.dur??15},x:t8.x,y:t8.y,onVerb:(y0,P0)=>e?.({stableId:G0.stableId,transition:!0},y0,P0),onClose:()=>v8(null)})}let o=Q[t8.index];if(!o)return null;return z(aN,{mode:"clip",clipLabel:o.label,kind:b6(o),textValue:o.placeholder?o.placeholder.prompt||"":b6(o)==="jsx"&&!o.series?"":null,mediaProps:o.mediaProps||null,x:t8.x,y:t8.y,onVerb:(G0,D0)=>e?.(j9(o,t8.index),G0,D0),onClose:()=>v8(null)})})(),document.body):null,E0&&Q[E0.index]?N3.createPortal((()=>{let o=Q[E0.index],G0=E0.index,D0=E0.layerIndex,y0;if(o.loose)y0=[[{id:"noop",label:"Loose media (no clip wrapper) — edit via /design:edit",disabled:!0,onSelect:()=>{}}]];else if(D0!=null){let P0=(Array.isArray(o.layers)?o.layers:[])[D0],z8=[];if(j&&P0&&(P0.mediaCdId||P0.mediaArrayRef))z8.push({id:"replace-layer",label:`Replace ${P0.kind}…`,onSelect:()=>j(j9(o,G0),D0)});if(z8.length===0)z8.push({id:"noop",label:"No replaceable media in this layer",disabled:!0,onSelect:()=>{}});y0=[z8]}else{let P0=[];if(I0)P0.push({id:"comment",label:"Comment on clip…",onSelect:()=>{oJ({x:BX(E0.x-130,8,window.innerWidth-280),y:Math.max(48,E0.y-140),anchor:{clipStableId:o.stableId||void 0,frameOffset:Math.max(0,Q8-(o.from||0)),frame:Q8},at:Q8})}});if(o.placeholder&&i)P0.push({id:"generate",label:`Generate ✨ (${o.placeholder.kind||"veo"})`,onSelect:()=>i(j9(o,G0))});if(e&&o.mediaSrc)if(o.series)P0.push({id:"to-overlay",label:"Move to overlay layer",onSelect:()=>e(j9(o,G0),"to-overlay",{})});else P0.push({id:"to-storyline",label:"Move to storyline",onSelect:()=>e(j9(o,G0),"to-storyline",{})});if(e){if(P0.push({id:"adjust",label:"Adjust… (Speed · Audio · Crop · Grade)",onSelect:()=>{l?.(o.stableId??null),v8({mode:"clip",index:G0,x:E0.x-120,y:Math.max(60,E0.y-320)})}}),o.mediaProps){if(P0.push({id:"mute",label:o.mediaProps.muted?"Unmute clip":"Mute clip",onSelect:()=>e(j9(o,G0),"audio",{muted:!o.mediaProps.muted})}),b6(o)==="video"&&o.mediaSrc)P0.push({id:"detach-audio",label:"Detach audio",onSelect:()=>e(j9(o,G0),"detach-audio",{})})}}if($&&o.replaceable&&!(Array.isArray(o.layers)&&o.layers.length>=2))P0.push({id:"replace",label:`Replace ${b6(o)}…`,onSelect:()=>$(j9(o,G0))});{let M8=rJ.filter((L9)=>!L9.seq.loose),Z9=M8.findIndex((L9)=>L9.i===G0);if(e&&Z9>=0)P0.push({id:"layer-up",label:"Move layer up",disabled:Z9>=M8.length-1,onSelect:()=>e(j9(o,G0),"layer-order",{toIndex:Z9+1})}),P0.push({id:"layer-down",label:"Move layer down",disabled:Z9<=0,onSelect:()=>e(j9(o,G0),"layer-order",{toIndex:Z9-1})})}if(f)P0.push({id:"earlier",label:o.series?"Move earlier":"Bring forward",disabled:o.series?G0<=0:G0>=Q.length-1,onSelect:()=>f(j9(o,G0),o.series?"backward":"forward")}),P0.push({id:"later",label:o.series?"Move later":"Send backward",disabled:o.series?G0>=Q.length-1:G0<=0,onSelect:()=>f(j9(o,G0),o.series?"forward":"backward")});y0=[P0];let z8=[];if(d)z8.push({id:"hide",label:o.hidden?"Show clip":"Hide clip",onSelect:()=>d(j9(o,G0))});if(R)z8.push({id:"remove",label:"Remove clip",destructive:!0,onSelect:()=>R(j9(o,G0))});if(z8.length)y0.push(z8)}return z(Hm,{target:{kind:"element",el:null,cdId:null,artboardId:null,clientX:E0.x,clientY:E0.y},sections:y0,onClose:()=>v0(null)})})(),document.body):null]})}function OU0(J){let X={};for(let Q of J.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*(-?\d+)\s*;/g))X[Q[1]]=Number(Q[2]);for(let Q=0;Q<3;Q+=1)for(let Y of J.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);/g)){let W=Y[1];if(Object.hasOwn(X,W))continue;let G=rQ(Y[2],X);if(G!=null)X[W]=G}return X}function rQ(J,X){if(J==null)return null;let Q=String(J).trim();if(/^-?\d+$/.test(Q))return Number(Q);if(Object.hasOwn(X,Q))return X[Q];let Y=Q.replace(/[A-Za-z_$][\w$]*/g,(W)=>Object.hasOwn(X,W)?String(X[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 AU0(J,X,Q,Y){if(!X)return[];let W=J.search(new RegExp(`\\b(?:const|function)\\s+${X}\\b`));if(W<0)return[];let G=J.slice(W+X.length),Z=G.search(/\n(?:const|function)\s+[A-Z]/),H=G.slice(0,Z>0?Z:2400),K=[];for(let U of H.matchAll(/interpolate\(\s*frame\s*,\s*\[\s*([^,\]]+?)\s*,\s*([^,\]]+?)\s*[,\]]/g)){let V=rQ(U[1],Q),B=rQ(U[2],Q);if(V!=null&&B!=null&&B>=V)K.push({from:Y+V,to:Y+B})}return K}function _U0(J,X){if(!X)return null;let Q=J.search(new RegExp(`\\b(?:const|function)\\s+${X}\\b`));if(Q<0)return null;let Y=J.slice(Q+X.length+1),W=Y.search(/\n(?:const|function|export)\s+[A-Za-z]/);return Y.slice(0,W>0?W:Y.length)}function wU0(J,X){let Q=[];for(let Y of J.matchAll(/<VideoComp\b([^>]*?)\/?>/g)){let W=Y[1],G=W.match(/component=\{([A-Za-z_$][\w$]*)\}/);if(!G)continue;let H=[...J.slice(0,Y.index).matchAll(/<DCArtboard\b[^>]*?\bid=["']([^"']+)["']/g)];Q.push({compName:G[1],artboardId:H.length?H[H.length-1][1]:null,duration:rQ(W.match(/durationInFrames=\{([^}]+)\}/)?.[1],X),fps:rQ(W.match(/fps=\{([^}]+)\}/)?.[1],X)||30})}return Q}function zm(J,X,Q){let Y=String(J??""),W=OU0(Y),G=Y,Z=X,H=0,K=null,U=wU0(Y,W).map((R)=>({...R,body:_U0(Y,R.compName)})).filter((R)=>R.body);if(U.length){let R=Q&&U.find(($)=>$.artboardId===Q)||U.find(($)=>/<(?:Maude)?(?:Audio|OffthreadVideo|Video)\b/.test($.body))||U.find(($)=>$.duration!=null&&$.duration===X)||U[0];if(G=R.body,R.duration!=null)Z=R.duration;H=R.fps,K=R.artboardId??null}let V=[],B=[],N=/<(TransitionSeries\.Sequence|TransitionSeries\.Transition|Series\.Sequence|Sequence)\b([^>]*)>/g,F;while(F=N.exec(G)){let R=F[1],$=F[2],C=N.lastIndex;if(/Transition$/.test(R)){let j=$.match(/durationInFrames:\s*([^,}\s)]+)/);V.push({type:"transition",dur:rQ(j?.[1],W)??0})}else{let j=$.match(/durationInFrames=\{([^}]+)\}/),f=$.match(/from=\{([^}]+)\}/),m=G.indexOf(`</${R}>`,C);B.push([F.index,m>=0?m:C+240]);let d=m>=0?Math.min(m,C+400):C+240,a=G.slice(C,d),x=a.match(/<([A-Z][A-Za-z0-9]*)\b/),h=a.match(/<(?:Maude)?(Video|OffthreadVideo|Audio|Img)\b[^>]*src=["']([^"']+)["']/),l=$.match(/name=["']([^"']+)["']/);V.push({type:"seq",series:R!=="Sequence",dur:rQ(j?.[1],W),from:R==="Sequence"&&f?rQ(f[1],W):null,compName:l?l[1]:x?x[1]:null,mediaTag:h?h[1]:null,mediaSrc:h?h[2]:null})}}let M=0,O=[],E=[],w=null;for(let R of V){if(R.type==="transition"){if(M-=R.dur||0,O.length>0)w={afterIndex:O.length-1,dur:R.dur||0};continue}let $=R.from!=null?R.from:M,C=R.dur!=null?R.dur:30;if(w)E.push(w),w=null;O.push({label:R.compName??`Seq ${O.length+1}`,series:!!R.series,mediaTag:R.mediaTag,mediaSrc:R.mediaSrc,from:Math.max(0,$),duration:Math.max(1,C),keyframes:AU0(Y,R.compName,W,Math.max(0,$))}),M=$+C}let A=O.length?Math.max(...O.map((R)=>R.from+R.duration)):30,I=Number.isFinite(Z)&&Z>0?Z:A,T=[];for(let R of G.matchAll(/<Audio\b([^>]*)>/g)){let $=R[1],C=$.match(/src=["']([^"']+)["']/),j=$.match(/from=\{([^}]+)\}/),f=$.match(/durationInFrames=\{([^}]+)\}/),m=j?rQ(j[1],W)??0:0,d=f?rQ(f[1],W):null,a=C?String(C[1]).split(/[\\/]/).pop():"audio";T.push({kind:"audio",label:a,src:C?C[1]:null,from:Math.max(0,m),duration:d!=null?Math.max(1,d):Math.max(1,I-m)})}for(let R of G.matchAll(/<(?:Maude)?(OffthreadVideo|Video|Img)\b([^>]*?)\/?>/g)){let $=R.index??0;if(B.some(([f,m])=>$>=f&&$<=m))continue;let C=R[2].match(/src=["']([^"']+)["']/);if(!C)continue;let j=String(C[1]).split(/[\\/]/).pop();O.push({label:j||R[1],series:!1,loose:!0,mediaTag:R[1],mediaSrc:C[1],from:0,duration:Math.max(1,I),keyframes:[]})}return{total:I,fps:H||void 0,sequences:O,audio:T,transitions:E,artboardId:K}}var i7=y8(i8(),1);function WE({name:J,size:X=16}){let Q={x:D(Q0,{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:D(Q0,{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"})]})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}var EU0=["1:1","16:9","9:16","4:3","3:4","4:5"];function GE({onClose:J,onInsert:X}){let[Q,Y]=i7.useState([]),[W,G]=i7.useState(""),[Z,H]=i7.useState([]),[K,U]=i7.useState(""),[V,B]=i7.useState("1:1"),[N,F]=i7.useState(""),[M,O]=i7.useState(!1),[E,w]=i7.useState(null),[A,I]=i7.useState(null),[T,R]=i7.useState(!0),[$,C]=i7.useState(null),j=i7.useRef(null),f=i7.useRef(null);i7.useEffect(()=>{fetch("/_api/generate/providers").then((h)=>h.json()).then((h)=>{let l=(h?.providers??[]).filter((n)=>n.modalities?.includes("image"));Y(l);let v=l.find((n)=>n.configured)??l[0];if(v)G(v.id)}).catch(()=>w({ok:!1,msg:"failed to load providers"}))},[]),i7.useEffect(()=>{if(!W)return;H([]),U("")},[W]),i7.useEffect(()=>{function h(l){if(l.key==="Escape")l.preventDefault(),J()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[J]),i7.useEffect(()=>()=>clearInterval(j.current),[]),i7.useEffect(()=>{if(!A||!T||typeof X!=="function")return;if(f.current===A)return;f.current=A;let h=X(A)===!0;if(C(h),h)w({ok:!0,msg:"Placed on canvas ✓"});else w({ok:!0,msg:"Generated — open a canvas artboard to place it, or insert below."})},[A,T,X]);let m=Q.find((h)=>h.id===W),d=m&&!m.configured,a=i7.useCallback((h)=>{clearInterval(j.current),j.current=setInterval(async()=>{try{let v=((await(await fetch("/_api/generate-jobs")).json())?.jobs??[]).find((n)=>n.id===h);if(!v)return;if(v.status==="done"){clearInterval(j.current),O(!1);let n=v.assets?.[0]??null;I(n),w({ok:!0,msg:n?`Generated ${n}`:"Done (no asset)"})}else if(v.status==="failed")clearInterval(j.current),O(!1),w({ok:!1,msg:v.error||"generation failed"})}catch{}},1500),setTimeout(()=>{if(j.current)clearInterval(j.current),O((l)=>{if(l)w({ok:!1,msg:"timed out waiting for the job"});return!1})},180000)},[]);async function x(){if(!N.trim()||!W)return;O(!0),w(null),I(null),C(null),f.current=null;try{let h={modality:"image",provider:W,prompt:N.trim(),aspectRatio:V,...K?{model:K}:{}},l=await fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(h)});if(l.status===202){let{jobId:v}=await l.json();w({ok:!0,msg:"Generating…"}),a(v)}else O(!1),w({ok:!1,msg:await l.text()})}catch(h){O(!1),w({ok:!1,msg:h&&h.message?h.message:"request failed"})}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)J()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate media",children:[D("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:J,children:z(WE,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:"Prompt"}),z("textarea",{className:"input st-gen-prompt",rows:3,value:N,placeholder:"a minimal hero image of a mountain lake at dawn, soft light","aria-label":"Generation prompt",onChange:(h)=>F(h.target.value)}),D("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:(h)=>G(h.target.value),children:Q.map((h)=>D("option",{value:h.id,children:[h.label,h.configured?"":" — no key"]},h.id))})]}),Z.length>0&&D("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:K,onChange:(h)=>U(h.target.value),children:Z.map((h)=>z("option",{value:h.id,children:h.label},h.id))})]}),D("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:(h)=>B(h.target.value),children:EU0.map((h)=>z("option",{value:h,children:h},h))})]}),X&&D("label",{className:"st-dialog-row",style:{gap:8,cursor:"pointer"},children:[z("input",{type:"checkbox",checked:T,onChange:(h)=>R(h.target.checked),"aria-label":"Place the generated image on the canvas"}),z("span",{className:"st-dialog-lbl",style:{margin:0},children:"Place on canvas"})]}),d&&D("div",{className:"st-provider-status",style:{color:"var(--fg-3)"},children:["No key for ",m.label," — add one in Settings (⌘,)."]}),A&&D("div",{className:"st-gen-result",children:[z("img",{className:"st-gen-thumb",src:`/${A}`,alt:"generated"}),D("div",{className:"st-gen-result-actions",children:[D("button",{type:"button",className:"st-btn",onClick:()=>navigator.clipboard?.writeText(`/${A}`),children:[z(WE,{name:"copy",size:13})," Copy path"]}),X&&$!==!0&&z("button",{type:"button",className:"st-btn",onClick:()=>{let h=X(A)===!0;C(h),w(h?{ok:!0,msg:"Placed on canvas ✓"}:{ok:!1,msg:"Open a canvas and select an artboard first."})},children:"Insert"})]})]}),E&&z("div",{className:"st-provider-status",style:{color:E.ok?"var(--accent)":"var(--danger, #e5484d)"},children:E.msg}),z("div",{className:"st-dialog-row",style:{justifyContent:"flex-end",marginTop:12},children:D("button",{type:"button",className:"st-btn st-gen-go",disabled:M||!N.trim()||!W,onClick:x,children:[z(WE,{name:"sparkle",size:14})," ",M?"Generating…":"Generate"]})})]})]})})}var D7=y8(i8(),1);var XF=new Set(["main","master"]);function r9({name:J,size:X=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":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14"}),z("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),share:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}[J];return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function ZE(J,X){let Q=(X||[]).find((Y)=>Y.path===J);return Q?{name:Q.name,sub:Q.server_url.replace(/^https?:\/\//,"")}:{name:KE(J),sub:J}}function KE(J){return String(J).replace(/[/\\]+$/,"").split(/[/\\]/).pop()||String(J)}function Km(J){return J.trim().toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function HE(J){return String(J).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function PU0(J){if(!J)return"";let X=Math.max(0,Math.floor(Date.now()/1000)-J);if(X<45)return"just now";if(X<3600)return`${Math.round(X/60)} min ago`;if(X<86400)return`${Math.round(X/3600)} h ago`;return`${Math.round(X/86400)} d ago`}async function zE(J){return(await fetch(J)).json()}async function QF(J,X,Q={}){let Y=Q.timeoutMs?new AbortController:null,W=Y?setTimeout(()=>Y.abort(),Q.timeoutMs):null;try{let G=await fetch(J,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X),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 IU0({count:J,branch:X,verb:Q}){return{title:J>1?`${J} chats are working right now`:"A chat is working right now",body:`Claude is editing files on ${X}. If you ${Q} now, those edits can land on the wrong branch — and Maude's History can't undo a cross-branch mix-up.`,meta:"Safest is to wait for the chat to finish, or stop it yourself first.",confirm:"Do it anyway",cancel:"Wait"}}function UE({project:J,liveBranch:X,remoteSync:Q,onGetLatest:Y,projectOnly:W=!1}){let G=G9(),[Z,H]=D7.useState(null),[K,U]=D7.useState([]),[V,B]=D7.useState([]),[N,F]=D7.useState([]),[M,O]=D7.useState(!1),[E,w]=D7.useState(!1),[A,I]=D7.useState(!1),[T,R]=D7.useState(""),[$,C]=D7.useState(!1),[j,f]=D7.useState(""),[m,d]=D7.useState(null),[a,x]=D7.useState(!1),[h,l]=D7.useState(!1),[v,n]=D7.useState(!1),[e,s]=D7.useState(null);async function H0(O0){if(!G9()){window.open(O0,"_blank","noopener,noreferrer");return}try{await wV(O0)}catch{try{await navigator.clipboard.writeText(O0),x(!0)}catch{}}}let[r,z0]=D7.useState(!1),[i,q0]=D7.useState(""),[Z0,I0]=D7.useState(""),[a0,s0]=D7.useState(""),[e0,D8]=D7.useState(!1),[s8,w8]=D7.useState(0),[N8,C0]=D7.useState(!1),A0=D7.useRef(null);D7.useEffect(()=>{let O0=!0;if((async()=>{try{let K8=await zE("/_api/git/status");if(!O0)return;if(H(K8),K8.repo&&G){let S8=await zE("/_api/git/branches");if(O0)U(S8.branches||[])}}catch{}})(),G)Dh().then((K8)=>O0&&B(K8||[])).catch(()=>{});if(G)TN().then((K8)=>O0&&F(Array.isArray(K8)?K8:[])).catch(()=>{});return()=>{O0=!1}},[G]),D7.useEffect(()=>{if(!E||!G||!Z?.repo)return;I0(""),t0()},[E]),D7.useEffect(()=>{if(!E&&!A)return;let O0=(K8)=>{if(A0.current&&!A0.current.contains(K8.target))w(!1),I(!1),s0("")};return document.addEventListener("mousedown",O0),()=>document.removeEventListener("mousedown",O0)},[E,A]);let $0=D(Q0,{children:[z("div",{className:"rb-pop-hd",children:"Project"}),G&&V.length>0?V.map((O0,K8)=>{let S8=ZE(O0,N);return D("button",{type:"button",className:"rb-pop-item"+(K8===0?" is-current":""),role:"menuitem",onClick:()=>J9(O0),children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:N.some((V9)=>V9.path===O0)?"share":"folder",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:S8.name}),z("span",{className:"rb-pop-sub",children:S8.sub})]}),K8===0?z(r9,{name:"check",size:14,className:"rb-pop-check"}):null]},O0)}):z("div",{className:"rb-pop-sub",style:{padding:"var(--space-2) var(--space-3)"},children:G?"No other recent projects.":"Open another project from the desktop app."}),G&&D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem","data-testid":"switcher-open-team",onClick:()=>{w(!1),O(!0)},children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"share",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open a team project…"})})]}),G&&D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:i0,children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"folder-open",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:"Open another folder…"})})]})]}),Q8=M?z(pN,{onClose:()=>O(!1)}):null;if(G&&Z&&(!Z.repo||W)){let O0=J||ZE(V[0]||"Project",N).name;return D("div",{className:"rb-dock-wrap",children:[D("div",{className:"rb-dock",ref:A0,children:[E&&z("div",{className:"rb-pop rb-pop--up",id:"rb-switch-pop",role:"menu","aria-label":"Switch project","data-testid":"repo-switcher-popup",children:$0}),i?D("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(r9,{name:"spinner",size:14,className:"rb-spin"}),D("span",{children:["Opening ",z("b",{children:i}),"…"]})]}):D("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(E?" is-open":""),"aria-expanded":E,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>w((K8)=>!K8),title:O0,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:O0}),z(r9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),Z0&&!E&&!i&&z("div",{className:"rb-switcher-err",role:"alert",children:Z0})]}),Q8]})}if(!Z?.repo||W)return null;let Z8=X||Z.branch||"main",f8=XF.has(Z8),b8=K.find((O0)=>XF.has(O0.name))?.name||"main",O9=(O0,K8)=>(K8.updatedAt||0)-(O0.updatedAt||0)||O0.name.localeCompare(K8.name),h0=a0.trim().toLowerCase(),C8=(O0)=>!h0||O0.name.toLowerCase().includes(h0),A9=K.filter((O0)=>!XF.has(O0.name)).sort(O9),F8=A9.filter(C8),B0=F8.filter((O0)=>O0.name!==Z8),J8=!h0||b8.toLowerCase().includes(h0)||"shared version".includes(h0),r0=A9.length>6,j0=J||KE(V[0]||"Project");if(!G)return z("div",{className:"rb-dock-wrap",children:z("div",{className:"rb-dock rb-dock--ro",children:D("span",{className:"rb-trigger rb-trigger--ro",title:`${j0} · branch: ${Z8} — switch branches in your terminal`,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),D("span",{className:"rb-trigger-ver rb-trigger-ver--ro",children:[z(r9,{name:"branch",size:12}),D("span",{className:"rb-trigger-ver-name",children:["branch: ",Z8]})]})]})})});async function t0(){try{let O0=await zE("/_api/git/branches");U(O0.branches||[])}catch{}}async function H8(){try{let O0=await fetch("/_api/acp/running");if(!O0.ok)return 0;let K8=await O0.json();return Number(K8?.running)||0}catch{return 0}}async function p0(O0,K8){let S8=await H8();if(S8===0){O0();return}s({count:S8,verb:K8,action:O0})}async function d0(O0,K8){q0(O0),C0(K8==="remote"),I0("");let S8=await QF("/_api/git/checkout",{name:O0});if(S8.ok&&S8.json?.ok)window.location.reload();else I0(S8.json?.error||"Could not switch."),q0(""),C0(!1)}async function k8(O0,K8){if(w(!1),O0===Z8)return;await p0(()=>d0(O0,K8),`switch to “${O0}”`)}async function _0(){if(e0)return;D8(!0),I0("");let O0=await QF("/_api/git/fetch",{},{timeoutMs:45000});if(O0.ok&&O0.json?.ok){if(O0.json.fetchedAt)w8(O0.json.fetchedAt);await t0()}else if(O0.timedOut||O0.json?.timedOut)I0("Couldn’t reach the remote — your local branches are still listed above.");else I0(O0.status===401||O0.json?.authRequired?"Sign in with GitHub to fetch remote branches.":O0.json?.error||"Could not fetch remote branches.");D8(!1)}async function X8(O0){z0(!0),I0("");let K8=await QF("/_api/git/branch",{name:O0});if(K8.ok&&K8.json?.ok)window.location.reload();else I0(K8.json?.error||"Could not create the draft."),z0(!1)}async function P8(){let O0=Km(T);if(!O0)return;await p0(()=>X8(O0),`create “${O0}”`)}async function U0(){if(h||!Y)return;l(!0),I0("");let O0=await Y();if(l(!1),O0&&!O0.ok&&!O0.conflict)I0(O0.status===401||O0.authRequired?"Sign in with GitHub to get the latest.":O0.error||"Could not get the latest.")}async function o0(){await p0(R8,`merge “${Z8}” into ${b8}`)}async function R8(){f(Z8),I0("");let O0=await QF("/_api/git/fold",{name:Z8},{timeoutMs:45000}),K8=O0.json;if(O0.ok&&K8?.ok&&K8.prUrl){d({url:K8.prUrl,number:K8.prNumber,repo:K8.repo}),f(""),t0();return}if(O0.ok&&K8?.ok&&K8.prUnavailable){d({message:K8.error||"Draft published, but the pull request could not be opened."}),f(""),t0();return}if(O0.ok&&K8?.ok){window.location.reload();return}I0(O0.status===401?`Sign in with GitHub to add “${Z8}” to ${b8}.`:K8?.error||"Could not add the branch."),f("")}async function J9(O0){if(w(!1),!G)return;q0(ZE(O0,N).name);try{await KX(O0)}catch(K8){I0(String(K8?.message||K8||"Could not open that project.")),q0("")}}async function i0(){if(w(!1),!G)return;try{let O0=await t4();if(!O0)return;q0(KE(O0)),await KX(O0)}catch(O0){I0(String(O0?.message||O0||"Could not open that folder.")),q0("")}}let a7=Km(T),F9=e?IU0({count:e.count,branch:Z8,verb:e.verb}):null,v7=f8?null:K.find((O0)=>O0.current),I8=f8&&!v&&!i&&!j?[...K].filter((O0)=>!XF.has(O0.name)&&O0.where!=="remote").sort((O0,K8)=>(K8.updatedAt||0)-(O0.updatedAt||0))[0]:null,X9=D(Q0,{children:[D("div",{className:"rb-pop-empty",children:["No branch matches “",a0.trim(),"”."]}),D("button",{type:"button",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:_0,disabled:e0,children:[z("span",{className:"rb-pop-icon"+(e0?" rb-pop-icon--spin":""),children:z(r9,{name:e0?"spinner":"refresh",size:14})}),z("span",{className:"rb-pop-tx",children:z("span",{className:"rb-pop-name",children:e0?"Searching the remote…":"Search the remote for it"})})]})]}),d8=(O0)=>{let K8=O0.where==="remote";return D("button",{type:"button","data-testid":`branch-row-${HE(O0.name)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>k8(O0.name,O0.where),children:[z("span",{className:"rb-pop-icon "+(K8?"rb-pop-icon--remote":"rb-pop-icon--draft"),children:z(r9,{name:K8?"cloud":"draft",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:O0.name}),K8&&z("span",{className:"rb-pop-sub",children:"remote · not downloaded yet"})]})]},O0.name)};return D("div",{className:"rb-dock-wrap",children:[Q?.remoteAhead&&!i&&!j&&D("button",{type:"button","data-testid":"switcher-get-latest",className:"btn btn--primary rb-getlatest",onClick:U0,disabled:h,title:`Get the latest ${b8}`,children:[z(r9,{name:h?"spinner":"download",size:14,className:h?"rb-spin":""}),z("span",{className:"rb-getlatest-tx",children:h?"Getting the latest…":"Get latest"}),!h&&Q.behind>0&&D("span",{className:"rb-getlatest-sub",children:[Q.behind," new on ",b8]})]}),I8&&D("div",{className:"rb-resume","data-testid":"switcher-resume",children:[D("button",{type:"button",className:"rb-resume-go",onClick:()=>k8(I8.name),title:`Switch to ${I8.name}`,children:[z("span",{className:"rb-resume-icon",children:z(r9,{name:"draft",size:13})}),D("span",{className:"rb-resume-tx",children:["Continue on ",z("b",{children:I8.name})]}),z(r9,{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(r9,{name:"close",size:12})})]}),D("div",{className:"rb-dock",ref:A0,children:[E&&D("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:[$0,z("div",{className:"rb-pop-sep"}),z("div",{className:"rb-pop-hd",children:"Branch"}),f8?D(Q0,{children:[D("button",{type:"button","data-testid":`branch-row-${HE(b8)}`,className:"rb-pop-item is-current",role:"menuitem","aria-current":"true",onClick:()=>k8(b8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(r9,{name:"share",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:b8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]}),z(r9,{name:"check",size:14,className:"rb-pop-check"})]}),A9.length>0&&z("div",{className:"rb-pop-grouplabel",children:"Other branches"}),r0&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:a0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(O0)=>s0(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Escape")s0("")}})}),F8.map(d8),r0&&h0&&F8.length===0&&!J8&&X9]}):D(Q0,{children:[D("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(r9,{name:"draft",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:v7?.name||Z8}),z("span",{className:"rb-pop-sub",children:"your branch"})]}),z(r9,{name:"check",size:14,className:"rb-pop-check"})]}),D("button",{type:"button","data-testid":"switcher-merge",className:"rb-fold",role:"menuitem",onClick:()=>{w(!1),I0(""),d(null),x(!1),C(!0)},children:[z("span",{className:"rb-fold-icon",children:z(r9,{name:"arrow-up-to-line",size:15})}),D("span",{className:"rb-fold-tx",children:[D("span",{className:"rb-fold-title",children:["Merge this branch → ",b8]}),z("span",{className:"rb-fold-sub",children:"into the default branch everyone shares"})]})]}),z("div",{className:"rb-pop-grouplabel",children:"Switch branch"}),r0&&z("div",{className:"rb-search",children:z("input",{className:"input rb-search-input",type:"text",value:a0,placeholder:"Search branches…","aria-label":"Search branches",onChange:(O0)=>s0(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Escape")s0("")}})}),J8&&D("button",{type:"button","data-testid":`branch-row-${HE(b8)}`,className:"rb-pop-item",role:"menuitem",onClick:()=>k8(b8),children:[z("span",{className:"rb-pop-icon rb-pop-icon--shared",children:z(r9,{name:"share",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:b8}),z("span",{className:"rb-pop-sub",children:"default branch · what everyone sees"})]})]}),B0.map(d8),r0&&h0&&B0.length===0&&!J8&&X9]}),D("button",{type:"button","data-testid":"switcher-fetch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:_0,disabled:e0,children:[z("span",{className:"rb-pop-icon"+(e0?" rb-pop-icon--spin":""),children:z(r9,{name:e0?"spinner":"refresh",size:14})}),D("span",{className:"rb-pop-tx",children:[z("span",{className:"rb-pop-name",children:e0?"Fetching…":"Fetch remote branches"}),z("span",{className:"rb-pop-sub",children:s8?`as of ${PU0(s8)}`:"check the remote for new branches"})]})]}),Z0&&!i&&z("div",{className:"rb-pop-notice",role:"alert",children:Z0}),D("button",{type:"button","data-testid":"switcher-new-branch",className:"rb-pop-item rb-pop-item--action",role:"menuitem",onClick:()=>{w(!1),I(!0)},children:[z("span",{className:"rb-pop-icon",children:z(r9,{name:"plus",size:14})}),D("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"})]})]})]}),A&&D("div",{className:"rb-newdraft rb-newdraft--up",children:[D("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:T,placeholder:"nav-redesign","aria-label":"Branch name",autoFocus:!0,onChange:(O0)=>R(O0.target.value),onKeyDown:(O0)=>{if(O0.key==="Enter"&&a7)P8();if(O0.key==="Escape")I(!1),R("")}}),a7&&D("span",{className:"rb-pop-sub",children:["Creates branch ",z("b",{children:a7})]})]}),Z0&&z("span",{className:"rb-newdraft-err",children:Z0}),D("div",{className:"rb-newdraft-actions",children:[z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>{I(!1),R(""),I0("")},disabled:r,children:"Cancel"}),D("button",{type:"button","data-testid":"switcher-new-branch-create",className:"btn btn--primary btn--sm",onClick:P8,disabled:r||!a7,children:[z(r9,{name:"draft",size:13})," ",r?"Creating…":"Create branch"]})]}),D("p",{className:"rb-newdraft-hint",children:["A branch is your own line of work off what you're looking at now. Merge it into ",b8," when you're happy, or throw it away — nothing else changes."]})]}),i||j?D("div",{className:"rb-switching",role:"status","aria-live":"polite",children:[z(r9,{name:"spinner",size:14,className:"rb-spin"}),z("span",{children:j?D(Q0,{children:["Merging ",z("b",{children:j})," → ",b8,"…"]}):N8?D(Q0,{children:["Downloading ",z("b",{children:i}),"…"]}):D(Q0,{children:["Opening ",z("b",{children:i}),"…"]})})]}):D("button",{type:"button","data-testid":"repo-switcher-trigger",className:"rb-trigger"+(E?" is-open":""),"aria-expanded":E,"aria-haspopup":"menu","aria-controls":"rb-switch-pop",onClick:()=>{w((O0)=>{if(O0)s0("");return!O0}),I(!1)},title:`${j0} · ${Z8}`,children:[z("span",{className:"rb-trigger-icon",children:z(r9,{name:"folder",size:14})}),z("span",{className:"rb-trigger-proj",children:j0}),z("span",{className:"rb-trigger-sep","aria-hidden":"true",children:"·"}),D("span",{className:"rb-trigger-ver"+(f8?"":" is-draft"),children:[z(r9,{name:f8?"share":"draft",size:12}),z("span",{className:"rb-trigger-ver-name",children:Z8})]}),z(r9,{name:"chevron-up",size:13,className:"rb-trigger-caret"})]}),Z0&&!E&&!A&&!i&&z("div",{className:"rb-switcher-err",role:"alert",children:Z0})]}),e&&F9&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>s(null),children:D("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-chatguard-title","aria-describedby":"rb-chatguard-body","data-testid":"switcher-chat-guard",onClick:(O0)=>O0.stopPropagation(),onKeyDown:(O0)=>{if(O0.key==="Escape")s(null)},children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"draft",size:20})}),z("h2",{className:"rb-sheet-title",id:"rb-chatguard-title",children:F9.title}),z("p",{className:"rb-sheet-body",id:"rb-chatguard-body",children:F9.body}),z("p",{className:"rb-sheet-meta",children:F9.meta}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost","data-testid":"switcher-chat-guard-cancel",onClick:()=>s(null),children:F9.cancel}),z("button",{type:"button",className:"btn btn--danger","data-testid":"switcher-chat-guard-confirm",onClick:()=>{let{action:O0}=e;s(null),O0()},children:F9.confirm})]})]})}),$&&z("div",{className:"rb-scrim",role:"presentation",onClick:()=>{C(!1),d(null),x(!1)},children:z("div",{className:"rb-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"rb-sheet-title","aria-describedby":"rb-sheet-body",onClick:(O0)=>O0.stopPropagation(),onKeyDown:(O0)=>{if(O0.key==="Escape")C(!1),d(null),x(!1)},children:m?m.url?D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"share",size:20})}),D("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Pull request opened",m.number?` #${m.number}`:""]}),D("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Your draft ",D("b",{children:["“",Z8,"”"]})," is up as a pull request into ",z("b",{children:b8}),m.repo?D(Q0,{children:[" of ",z("b",{children:m.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:m.url}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{C(!1),d(null),x(!1)},children:"Close"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"switcher-pr-link",onClick:()=>H0(m.url),children:[z(r9,{name:"share",size:15})," ",a?"Link copied — paste in your browser":"Review on GitHub"]})]})]}):D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{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:m.message}),z("div",{className:"rb-sheet-actions",children:z("button",{type:"button","data-testid":"switcher-pr-dismiss",className:"btn btn--primary",onClick:()=>{C(!1),d(null),x(!1)},children:"Got it"})})]}):D(Q0,{children:[z("span",{className:"rb-sheet-icon",children:z(r9,{name:"arrow-up-to-line",size:20})}),D("h2",{className:"rb-sheet-title",id:"rb-sheet-title",children:["Add this branch to ",b8]}),D("p",{className:"rb-sheet-body",id:"rb-sheet-body",children:["Propose everything in ",D("b",{children:["“",v7?.name||Z8,"”"]})," to ",z("b",{children:b8})," — 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."}),Z0&&z("p",{className:"rb-newdraft-err",children:Z0}),D("div",{className:"rb-sheet-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>{C(!1),I0("")},children:"Cancel"}),D("button",{type:"button","data-testid":"switcher-merge-confirm",className:"btn btn--primary",disabled:!!j,onClick:o0,children:[z(r9,{name:"arrow-up-to-line",size:15})," ",j?"Adding…":`Add to ${b8}`]})]})]})})}),Q8]})}var P9=y8(i8(),1);function QY({name:J,size:X=16}){let Q={x:D(Q0,{children:[z("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),z("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]}),key:D(Q0,{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:D(Q0,{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"})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function kU0({provider:J,onChanged:X}){let[Q,Y]=P9.useState(""),[W,G]=P9.useState(!1),[Z,H]=P9.useState(null),K=J.configured;async function U(){let B=Q.trim();if(!B)return;G(!0),H(null);try{let N=await fetch("/_api/generate/keys",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({provider:J.id,key:B})});if(!N.ok)throw Error(await N.text());let F=await N.json();Y(""),H({ok:!0,msg:F.configured?"Key saved.":"Saved."}),X()}catch(N){H({ok:!1,msg:N&&N.message?N.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:J.id})});if(!B.ok)throw Error(await B.text());H({ok:!0,msg:"Key removed."}),X()}catch(B){H({ok:!1,msg:B&&B.message?B.message:"remove failed"})}finally{G(!1)}}return D("div",{className:"st-provider-card",children:[D("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:J.label}),z("span",{className:"st-pill"+(J.kind==="local"?" is-local":""),children:J.kind==="local"?"Local":D(Q0,{children:[z(QY,{name:"cloud",size:12})," Cloud"]})}),K&&D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," configured"]})]}),z("div",{className:"st-provider-modalities",children:J.modalities.join(" · ")}),J.notes&&z("div",{className:"st-provider-notes",children:J.notes}),J.keyUrl&&D("a",{className:"st-provider-keylink",href:J.keyUrl,target:"_blank",rel:"noreferrer",children:["Get a key ",z(QY,{name:"external",size:12})]}),J.auth==="api-key"&&D("div",{className:"st-provider-keyrow",children:[z("input",{className:"input st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,value:Q,placeholder:K?"•••••••• configured — paste to replace":"paste API key","aria-label":`${J.label} API key`,onChange:(B)=>Y(B.target.value),onKeyDown:(B)=>{if(B.key==="Enter")U()}}),D("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:U,children:[z(QY,{name:"key",size:13})," Save"]}),K&&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 qm=[{id:"auto",label:"Auto",note:"Use the best engine this machine is set up for — the card says which."},{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"}],TU0=Object.fromEntries(qm.map((J)=>[J.id,J.label]));function RU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(!1),[W,G]=P9.useState(null),[Z,H]=P9.useState(null);P9.useEffect(()=>{fetch("/_api/generate/prefs").then((U)=>U.ok?U.json():Promise.reject(Error(`HTTP ${U.status}`))).then((U)=>X(U?.transcriptionProvider||"whisper")).catch(()=>X("whisper"))},[]),P9.useEffect(()=>{fetch("/_api/generate/whisper-model").then((U)=>U.ok?U.json():null).then((U)=>H(U?.auto||null)).catch(()=>{})},[]);async function K(U){if(U===J)return;let V=J;X(U),Y(!0),G(null);try{let B=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({transcriptionProvider:U})});if(!B.ok)throw Error(await B.text());G({ok:!0,msg:"Saved."})}catch(B){X(V),G({ok:!1,msg:B&&B.message?B.message:"save failed"})}finally{Y(!1)}}return D("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Subtitles — transcription engine"})}),D("div",{className:"st-provider-notes",children:["Which engine turns audio into subtitles. Maude never switches engines behind your back — pin one, or pick ",z("strong",{children:"Auto"})," and it uses the best you're set up for and says so."]}),J==="auto"&&Z&&D("div",{className:"st-provider-notes",children:["Right now Auto uses ",z("strong",{children:TU0[Z.engine]||Z.engine})," —"," ",Z.reason,Z.cloud&&" Audio is uploaded to that provider and billed to your account."]}),z("div",{className:"st-engine-radios",role:"radiogroup","aria-label":"Transcription engine",children:qm.map((U)=>D("label",{className:"st-engine-radio"+(J===U.id?" is-selected":""),children:[z("input",{type:"radio",name:"transcription-engine",value:U.id,checked:J===U.id,disabled:Q||J===null,onChange:()=>K(U.id)}),D("span",{className:"st-engine-radio-body",children:[z("span",{className:"st-engine-radio-label",children:U.label}),z("span",{className:"st-engine-radio-note",children:U.note})]})]},U.id))}),W&&z("div",{className:"st-provider-status",style:{color:W.ok?"var(--accent)":"var(--danger, #e5484d)"},children:W.msg})]})}function CU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(null),W=P9.useCallback(()=>{fetch("/_api/generate/whisper-model").then((V)=>V.ok?V.json():Promise.reject(Error(`HTTP ${V.status}`))).then(X).catch((V)=>Y(V&&V.message?V.message:"failed to load models"))},[]);P9.useEffect(()=>{W()},[W]),P9.useEffect(()=>{if(!J?.downloading)return;let V=setInterval(W,1000);return()=>clearInterval(V)},[J?.downloading,W]);async function G(V){Y(null);try{let B=await fetch("/_api/generate/whisper-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:V})});if(!B.ok)throw Error(await B.text());W()}catch(B){Y(B&&B.message?B.message:"download failed")}}async function Z(V){Y(null);try{let B=await fetch("/_api/generate/whisper-model",{method:"DELETE",headers:{"content-type":"text/plain"},body:JSON.stringify({id:V})});if(!B.ok)throw Error(await B.text());W()}catch(B){Y(B&&B.message?B.message:"remove failed")}}let H=J?.downloading,K=(V,B)=>B>0?Math.min(100,Math.round(V/B*100)):0,U=(J?.models||[]).some((V)=>V.downloaded);return D("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)"})}),z("div",{className:"st-provider-notes",children:"Local subtitles need two things: the whisper.cpp engine and one model. Models are stored on this machine only and never committed."}),J&&D("div",{className:"st-setup",children:[D("div",{className:`st-step${J.setup?.installed?" is-done":""}`,children:[z("span",{className:"st-step-n",children:J.setup?.installed?"✓":"1"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:J.setup?.installed?"whisper.cpp engine is installed":"Install the whisper.cpp engine"}),(J.setup?.options||[]).slice(0,1).map((V)=>V.kind==="command"?z(bK,{command:V.command,label:`Copy: ${V.label}`},V.id):z("span",{className:"st-provider-notes",children:V.note},V.id))]})]}),D("div",{className:`st-step${U?" is-done":""}`,children:[z("span",{className:"st-step-n",children:U?"✓":"2"}),z("div",{className:"st-step-body",children:z("span",{className:"st-step-title",children:U?"Model ready":"Download a model (below)"})})]}),(J.setup?.options||[]).length>1&&D("details",{className:"st-setup-more",children:[z("summary",{children:"Other ways to get the engine"}),J.setup.options.slice(1).map((V)=>D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:V.label}),z(bK,{command:V.kind==="command"?V.command:V.url,label:`Copy: ${V.label}`}),V.note?z("span",{className:"st-provider-notes",children:V.note}):null]},V.id))]})]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&D("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),J===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(J?.models||[]).map((V)=>{let B=H&&!H.error&&H.id===V.id;return D("div",{className:"st-model-row",children:[D("div",{className:"st-model-info",children:[D("span",{className:"st-model-label",children:[V.label,z("span",{className:"st-pill"+(V.multilingual?"":" is-local"),children:V.multilingual?"multilingual":"English-only"}),D("span",{className:"st-model-size",children:["~",V.sizeMB," MB"]})]}),z("span",{className:"st-engine-radio-note",children:V.note}),B&&D("span",{className:"st-model-progress",children:["Downloading… ",K(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:V.downloaded?D(Q0,{children:[D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," ready"]}),z("button",{type:"button",className:"st-btn",onClick:()=>Z(V.id),children:"Remove"})]}):z("button",{type:"button",className:"st-btn",disabled:!!(H&&!H.error),onClick:()=>G(V.id),children:B?"Downloading…":"Download"})})]},V.id)})})]})}var $U0=[{id:"auto",label:"Auto",note:"Use the best available: Gemma scout → ffmpeg → blind."},{id:"gemma",label:"Gemma scout",note:"Semantic action beats. Needs Ollama (gemma3 vision) or 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 SU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(!1),[W,G]=P9.useState(null);P9.useEffect(()=>{fetch("/_api/generate/prefs").then((H)=>H.ok?H.json():Promise.reject(Error(`HTTP ${H.status}`))).then((H)=>X(H?.keyframeEngine||"auto")).catch(()=>X("auto"))},[]);async function Z(H){if(H===J)return;let K=J;X(H),Y(!0),G(null);try{let U=await fetch("/_api/generate/prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({keyframeEngine:H})});if(!U.ok)throw Error(await U.text());G({ok:!0,msg:"Saved."})}catch(U){X(K),G({ok:!1,msg:U&&U.message?U.message:"save failed"})}finally{Y(!1)}}return D("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"})}),D("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:$U0.map((H)=>D("label",{className:"st-engine-radio"+(J===H.id?" is-selected":""),children:[z("input",{type:"radio",name:"keyframe-engine",value:H.id,checked:J===H.id,disabled:Q||J===null,onChange:()=>Z(H.id)}),D("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 bK({command:J,label:X}){let[Q,Y]=P9.useState(!1);return D("span",{className:"rdy-cmd",children:[z("code",{className:"rdy-cmd-tx",children:J}),z("button",{type:"button",className:"rdy-copy",onClick:()=>{navigator.clipboard?.writeText(J).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)},()=>{})},"aria-label":X||"Copy command",children:Q?"Copied":"Copy"})]})}function bU0({state:J}){let X=J.ollama||{},Q=X.setup||[],[Y,...W]=Q,G=Boolean(X.available),Z=Boolean(X.model),H=G||Y?.id==="pull"?null:Y;return D("div",{className:"st-setup",children:[D("div",{className:`st-step${G?" is-done":""}`,children:[z("span",{className:"st-step-n",children:G?"✓":"1"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:G?"Ollama is running":X.installed?"Start Ollama":"Install Ollama"}),H?.kind==="command"?z(bK,{command:H.command,label:"Copy the install command"}):null]})]}),D("div",{className:`st-step${Z?" is-done":""}`,children:[z("span",{className:"st-step-n",children:Z?"✓":"2"}),D("div",{className:"st-step-body",children:[z("span",{className:"st-step-title",children:Z?`Model ready (${X.model})`:"Download the model"}),Z?null:z(bK,{command:X.pullCommand,label:"Copy the model pull command"})]})]}),D("details",{className:"st-setup-more",children:[z("summary",{children:"Other ways to install"}),W.map((K)=>D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:K.label}),z(bK,{command:K.kind==="command"?K.command:K.url,label:`Copy: ${K.label}`})]},K.id)),D("div",{className:"st-setup-option",children:[z("span",{className:"st-setup-option-label",children:"mlx-vlm instead of Ollama — faster, Apple Silicon only"}),J.mlx?.supported?D(Q0,{children:[z(bK,{command:J.mlx.command,label:"Copy the mlx-vlm install command"}),z("span",{className:"st-provider-notes",children:"Then download a model below. Models live in your HuggingFace cache."})]}):z("span",{className:"st-provider-notes",children:J.mlx?.reason})]})]})]})}function yU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(null),W=P9.useCallback(()=>{fetch("/_api/generate/keyframe-model").then((M)=>M.ok?M.json():Promise.reject(Error(`HTTP ${M.status}`))).then(X).catch((M)=>Y(M&&M.message?M.message:"failed to load models"))},[]);P9.useEffect(()=>{W()},[W]),P9.useEffect(()=>{if(!J?.downloading)return;let M=setInterval(W,1500);return()=>clearInterval(M)},[J?.downloading,W]);let G=J?!J.mlxVlmAvailable&&!J.ollama?.model:!1;P9.useEffect(()=>{if(!G)return;let M=setInterval(W,1e4);return()=>clearInterval(M)},[G,W]);async function Z(M){Y(null);try{let O=await fetch("/_api/generate/keyframe-model",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify({id:M})});if(!O.ok)throw Error(await O.text());W()}catch(O){Y(O&&O.message?O.message:"download failed")}}let H=J?.downloading,K=J?.mlxVlmAvailable,U=J?.ffmpegAvailable,V=J?.ollama,B=Boolean(K||V?.model),N=(M,O)=>O>0?Math.min(100,Math.round(M/O*100)):0,F=B?`Gemma scout${K?"":` (Ollama · ${V.model})`}`:U?"ffmpeg scene-detect":"blind (even-spaced)";return D("div",{className:"st-provider-card",children:[z("div",{className:"st-provider-hd",children:z("span",{className:"st-provider-name",children:"Gemma scout model (optional)"})}),z("div",{className:"st-provider-notes",children:"Adds semantic action-beat detection on top of scene cuts. Two short steps in a terminal — Maude picks the result up on its own."}),J&&!B&&z(bU0,{state:J}),J&&D("div",{className:"st-provider-notes",children:["Active tier on this machine: ",z("strong",{children:F}),B&&!K&&" — Ollama manages its own models, nothing to download below."]}),Q&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:Q}),H?.error&&D("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:["Download of ",H.id," failed: ",H.error]}),J===null&&!Q&&z("div",{className:"st-settings-intro",children:"Loading…"}),z("div",{className:"st-model-list",children:(J?.models||[]).map((M)=>{let O=H&&!H.error&&H.id===M.id,E=M.runtime==="ollama"?Boolean(V?.available):Boolean(K),w=M.runtime==="ollama"?V?.installed?"start Ollama first":"needs Ollama":"needs mlx-vlm";return D("div",{className:"st-model-row",children:[D("div",{className:"st-model-info",children:[D("span",{className:"st-model-label",children:[M.label,D("span",{className:"st-model-size",children:["~",Math.round(M.sizeMB/100)/10," GB"]})]}),z("span",{className:"st-engine-radio-note",children:M.note}),O&&D("span",{className:"st-model-progress",children:[M.runtime==="ollama"?"Pulling":"Downloading","…"," ",N(H.received,H.total),"%"]})]}),z("div",{className:"st-model-actions",children:M.downloaded?D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," ready"]}):D("span",{className:"st-model-action",children:[z("button",{type:"button",className:"st-btn",disabled:!E||!!(H&&!H.error),onClick:()=>Z(M.id),children:O?"Downloading…":"Download"}),E?null:z("span",{className:"st-model-action-note",children:w})]})})]},M.id)})})]})}function jU0(){let[J,X]=P9.useState(null),[Q,Y]=P9.useState(""),[W,G]=P9.useState(!1),[Z,H]=P9.useState(null),[K,U]=P9.useState(null),V=P9.useCallback(()=>{fetch("/_api/figma/status").then((O)=>O.ok?O.json():Promise.reject(Error(`HTTP ${O.status}`))).then(X).catch(()=>X({configured:!1}))},[]);P9.useEffect(()=>{V()},[V]);async function B(){let O=Q.trim();if(!O||W)return;G(!0),H(null);try{let E=await fetch("/_api/figma/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:O})}),w=await E.json().catch(()=>({}));if(!E.ok){H(w.error||"could not save the token");return}Y(""),V(),await N()}finally{G(!1)}}async function N(){H(null);let E=await(await fetch("/_api/figma/probe",{method:"POST"})).json().catch(()=>({}));if(E.ok)U(E.handle||""),H(null);else U(null),H(E.error||"Figma did not accept that token.")}async function F(){if(W)return;G(!0);try{await fetch("/_api/figma/connect",{method:"DELETE"}),U(null),H(null),V()}finally{G(!1)}}let M=Boolean(J?.configured);return D("div",{className:"st-provider-card","data-testid":"figma-connect-card",children:[D("div",{className:"st-provider-hd",children:[z("span",{className:"st-provider-name",children:"Figma"}),M&&D("span",{className:"st-provider-configured",children:[z(QY,{name:"check",size:12})," connected"]})]}),z("p",{className:"st-settings-intro",children:"Import real Figma documents — frames become editable canvases, FigJam boards become the whiteboard, and paint/text/effect styles become design tokens. The translation is plain code: no AI reads your file."}),D("p",{className:"st-settings-intro",children:["Create a personal access token with the ",z("code",{children:J?.requiredScope||"file_content:read"})," ","scope. It is stored on this machine only and is never sent anywhere but Figma."]}),J?.tokenUrl&&D("a",{className:"st-provider-keylink",href:J.tokenUrl,target:"_blank",rel:"noreferrer",children:["Get a token ",z(QY,{name:"external",size:12})]}),D("div",{className:"st-provider-keyrow",children:[z("input",{className:"st-provider-keyinput",type:"password",autoComplete:"off",spellCheck:!1,placeholder:M?"•••••••• stored":"figd_…",value:Q,onChange:(O)=>Y(O.target.value),onKeyDown:(O)=>{if(O.key==="Enter")B()},"aria-label":"Figma personal access token","data-testid":"figma-connect-input"}),z("button",{type:"button",className:"st-btn",disabled:W||!Q.trim(),onClick:B,"data-testid":"figma-connect-save",children:M?"Replace":"Save"}),M&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:F,"data-testid":"figma-disconnect",children:"Remove"})]}),M&&z("button",{type:"button",className:"st-btn",disabled:W,onClick:N,children:"Test connection"}),K!==null&&D("div",{className:"st-provider-status","data-testid":"figma-connected-as",children:["Connected as ",K||"your Figma account"]}),Z&&z("div",{className:"st-provider-status","data-testid":"figma-connect-error",children:Z})]})}var Um=[{id:"appearance",label:"Appearance"},{id:"canvas-view",label:"Canvas & View"},{id:"layout",label:"Layout"},{id:"ai-generation",label:"AI generation",local:!0},{id:"figma",label:"Figma",local:!0},{id:"subtitles",label:"Subtitles",local:!0},{id:"video",label:"Video",local:!0}],Vm="mdcc-settings-tab",vU0=[{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 fU0({value:J,disabled:X,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":J===Y,disabled:X,className:"st-sidebtn"+(J===Y?" is-active":""),onClick:()=>Q(Y),children:Y==="left"?"Left":"Right"},Y))})}var xU0=[{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 hU0({panelSide:J,onSetPanelSide:X,layersMode:Q,onSetLayersMode:Y}){return D(Q0,{children:[D("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:xU0.map((W)=>D("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)}),D("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))})]}),D("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."}),vU0.map((W)=>{let G=W.id==="layers"&&Q!=="separate";return D("div",{className:"st-pref-row"+(G?" is-disabled":""),children:[D("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(fU0,{value:J?.[W.id]||"left",disabled:G,onChange:(Z)=>X(W.id,Z)})]},W.id)})]})]})}function YF({label:J,note:X,checked:Q,disabled:Y,reason:W,onChange:G}){return D("label",{className:"st-pref-row"+(Y?" is-disabled":""),children:[D("span",{className:"st-pref-body",children:[z("span",{className:"st-pref-label",children:J}),(W||X)&&z("span",{className:"st-pref-note",children:Y&&W?W:X})]}),z("input",{type:"checkbox",className:"st-switch",role:"switch","aria-checked":!!Q,checked:!!Q,disabled:Y,onChange:(Z)=>G?.(Z.target.checked)})]})}var gU0=[{id:"light",label:"Light",note:"Bright shell chrome"},{id:"dark",label:"Dark",note:"Dim shell chrome"}],mU0=[{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 uU0({theme:J,onSetTheme:X,cpMode:Q,onSetCpMode:Y}){return D(Q0,{children:[D("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:gU0.map((W)=>D("label",{className:"st-engine-radio"+(J===W.id?" is-selected":""),children:[z("input",{type:"radio",name:"maude-theme",value:W.id,checked:J===W.id,onChange:()=>X?.(W.id)}),D("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))})]}),D("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:mU0.map((W)=>D("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)}),D("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 VE({cloud:J,onClose:X,initialTab:Q,theme:Y,onSetTheme:W,cpMode:G,onSetCpMode:Z,minimapVisible:H,onToggleMinimap:K,zoomCtlVisible:U,onToggleZoomCtl:V,annotationsVisible:B,onToggleAnnotations:N,autoOpenInspector:F,onToggleAutoOpenInspector:M,hasCanvas:O=!1,panelSide:E,onSetPanelSide:w,layersMode:A,onSetLayersMode:I}){let[T,R]=P9.useState(null),[$,C]=P9.useState(null),j=P9.useMemo(()=>Um.filter((h)=>!(J&&h.local)),[J]),[f,m]=P9.useState(()=>{let h=(l)=>Um.some((v)=>v.id===l&&!(J&&v.local));if(Q&&h(Q))return Q;try{let l=localStorage.getItem(Vm);if(l&&h(l))return l}catch{}return"appearance"});P9.useEffect(()=>{try{localStorage.setItem(Vm,f)}catch{}},[f]);let d=P9.useCallback(()=>{fetch("/_api/generate/providers").then((h)=>{if(!h.ok)throw Error(`HTTP ${h.status}`);return h.json()}).then((h)=>R(Array.isArray(h?.providers)?h.providers:[])).catch((h)=>C(h&&h.message?h.message:"failed to load providers"))},[]);P9.useEffect(()=>{d()},[d]),P9.useEffect(()=>{function h(l){if(l.key==="Escape")l.preventDefault(),X()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[X]);function a(h){let l=j.findIndex((v)=>v.id===f);if(h.key==="ArrowDown"||h.key==="ArrowRight")h.preventDefault(),m(j[(l+1)%j.length].id);else if(h.key==="ArrowUp"||h.key==="ArrowLeft")h.preventDefault(),m(j[(l-1+j.length)%j.length].id);else if(h.key==="Home")h.preventDefault(),m(j[0].id);else if(h.key==="End")h.preventDefault(),m(j[j.length-1].id)}let x=!O?"Open a canvas to use this.":void 0;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(h)=>{if(h.target===h.currentTarget)X()},children:D("div",{className:"st-dialog is-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[D("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(QY,{name:"x",size:15})})]}),D("div",{className:"st-settings-tabs",children:[z("div",{className:"st-settings-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Settings categories",onKeyDown:a,children:j.map((h)=>z("button",{type:"button",role:"tab",id:`st-stab-${h.id}`,"aria-controls":`st-spanel-${h.id}`,"aria-selected":f===h.id,tabIndex:f===h.id?0:-1,className:"st-settings-tab"+(f===h.id?" is-active":""),onClick:()=>m(h.id),children:h.label},h.id))}),D("div",{className:"st-settings-pane",children:[D("section",{role:"tabpanel",id:"st-spanel-appearance","aria-labelledby":"st-stab-appearance",hidden:f!=="appearance",children:[z("div",{className:"st-rp-hd",children:"Appearance"}),z(uU0,{theme:Y,onSetTheme:W,cpMode:G,onSetCpMode:Z})]}),D("section",{role:"tabpanel",id:"st-spanel-canvas-view","aria-labelledby":"st-stab-canvas-view",hidden:f!=="canvas-view",children:[z("div",{className:"st-rp-hd",children:"Canvas & View"}),z(YF,{label:"Minimap",note:"Show the canvas minimap overlay.",checked:H,disabled:!O,reason:x,onChange:()=>K?.()}),z(YF,{label:"Zoom controls",note:"Show the floating zoom controls on the canvas.",checked:U,disabled:!O,reason:x,onChange:()=>V?.()}),z(YF,{label:"Annotations",note:"Show annotation pins and overlays on the canvas.",checked:B,onChange:()=>N?.()}),z(YF,{label:"Auto-open Inspector on select",note:"Open the Inspector automatically when you select an element.",checked:F,onChange:()=>M?.()})]}),D("section",{role:"tabpanel",id:"st-spanel-layout","aria-labelledby":"st-stab-layout",hidden:f!=="layout",children:[z("div",{className:"st-rp-hd",children:"Layout"}),z(hU0,{panelSide:E,onSetPanelSide:w,layersMode:A,onSetLayersMode:I})]}),D("section",{role:"tabpanel",id:"st-spanel-ai-generation","aria-labelledby":"st-stab-ai-generation",hidden:f!=="ai-generation",children:[z("div",{className:"st-rp-hd",children:"Provider keys"}),D("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."]}),$&&z("div",{className:"st-provider-status",style:{color:"var(--danger, #e5484d)"},children:$}),T===null&&!$&&z("div",{className:"st-settings-intro",children:"Loading…"}),T?.map((h)=>z(kU0,{provider:h,onChanged:d},h.id)),T?.length===0&&z("div",{className:"st-settings-intro",children:"No providers registered."})]}),D("section",{role:"tabpanel",id:"st-spanel-figma","aria-labelledby":"st-stab-figma",hidden:f!=="figma",children:[z("div",{className:"st-rp-hd",children:"Figma"}),z(jU0,{})]}),D("section",{role:"tabpanel",id:"st-spanel-subtitles","aria-labelledby":"st-stab-subtitles",hidden:f!=="subtitles",children:[z("div",{className:"st-rp-hd",children:"Subtitles"}),z(RU0,{}),z(CU0,{})]}),D("section",{role:"tabpanel",id:"st-spanel-video","aria-labelledby":"st-stab-video",hidden:f!=="video",children:[z("div",{className:"st-rp-hd",children:"Video"}),z(SU0,{}),z(yU0,{})]})]})]})]})})}var oW=y8(i8(),1);function pU0({name:J,size:X=15}){if(J==="x")return z("svg",{width:X,height:X,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 qE({onPick:J,onClose:X}){let[Q,Y]=oW.useState(null),[W,G]=oW.useState("");oW.useEffect(()=>{let K=!0;return fetch("/_api/stickers").then((U)=>U.json()).then((U)=>K&&Y(U.ok?U.packs:[])).catch(()=>K&&Y([])),()=>{K=!1}},[]),oW.useEffect(()=>{let K=(U)=>{if(U.key==="Escape")U.stopPropagation(),X()};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[X]);let Z=oW.useMemo(()=>{if(!Q)return[];let K=W.trim().toLowerCase();if(!K)return Q;return Q.map((U)=>({...U,stickers:U.stickers.filter((V)=>V.file.toLowerCase().includes(K)||(V.keywords||[]).some((B)=>B.toLowerCase().includes(K)))})).filter((U)=>U.stickers.length>0)},[Q,W]),H=Z.reduce((K,U)=>K+U.stickers.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(K)=>{if(K.target===K.currentTarget)X()},children:D("div",{className:"st-dialog st-sticker-picker",role:"dialog","aria-modal":"true","aria-label":"Stickers",children:[D("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:X,children:z(pU0,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"input",type:"text",value:W,onChange:(K)=>G(K.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((K)=>D("div",{children:[D("div",{className:"st-sp-pack-hd",children:[z("span",{className:"st-sp-pack-name",children:K.name}),K.author&&D("span",{className:"st-sp-pack-author",children:["by ",K.author]})]}),z("div",{className:"st-sp-grid",children:K.stickers.map((U)=>z("button",{type:"button",className:"st-sp-cell",title:U.keywords?.[0]||U.file,onClick:()=>J(U),children:z("img",{className:"st-sp-thumb",src:U.url,alt:U.keywords?.[0]||U.file,loading:"lazy"})},U.file))})]},K.slug))})]}),Q&&Q.length>0&&z("div",{className:"st-sp-ft",children:Q.map((K)=>D("span",{children:[K.name,K.author?` — ${K.author}`:"",K.attributionUrl?D(Q0,{children:[" ","(",z("a",{href:K.attributionUrl,target:"_blank",rel:"noreferrer",children:"source"}),")"]}):null]},K.slug))})]})})}var KJ=y8(i8(),1);var lU0=["dots","grid","lines","diagonal","crosshatch"],dU0=["normal","multiply","screen","overlay","soft-light"],cU0=["none","vignette","radial-reveal","edge-fade"],iU0=[{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}],Bm=(J)=>J?JSON.parse(JSON.stringify(J)):{};function oU0(J){let X={};for(let[Q,Y]of Object.entries(J)){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)X[Q]=W}else X[Q]=Y}return X}var nW={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 yK({title:J,right:X,onReset:Q,children:Y}){return z(lg,{title:J,right:X,onReset:Q,children:Y})}function lX({label:J,tip:X,children:Q}){return D(Q0,{children:[D("div",{style:nW.row,children:[z("span",{style:nW.label,children:J}),Q]}),X?z("div",{style:nW.tipBelow,children:X}):null]})}function BE({value:J,fallback:X,label:Q,ColorPicker:Y,onApply:W}){let[G,Z]=KJ.useState(!1),H=KJ.useRef(null),K=J||X;return KJ.useEffect(()=>{if(!G)return;let U=(V)=>{if(!H.current?.contains(V.target))Z(!1)};return document.addEventListener("pointerdown",U,!0),()=>document.removeEventListener("pointerdown",U,!0)},[G]),z(U3,{swatch:D("span",{className:"st-cp-tokwrap",ref:H,children:[z("button",{type:"button",className:"st-cp-cf-sw",style:{background:K},"aria-haspopup":"dialog","aria-expanded":G,"aria-label":Q,title:K,onClick:()=>Z((U)=>!U)}),G?z("div",{className:"st-cp-pop",role:"dialog","aria-label":Q,style:{padding:"var(--space-2)"},children:Y?z(Y,{seed:K,label:Q,onApply:W}):z("input",{type:"color",value:K,"aria-label":Q,onChange:(U)=>W(U.target.value),style:{width:"100%",height:32}})}):null]}),displayValue:(K||"").replace("#",""),ariaLabel:Q,onValue:(U)=>W(U.startsWith("#")?U:`#${U.replace(/[^0-9a-fA-F]/g,"").slice(0,6)}`)})}function Nm({asset:J,initialEdit:X,ColorPicker:Q,onEdit:Y,onRemoveBackground:W,onRecordEdit:G,StIcon:Z}){let[H,K]=KJ.useState(()=>Bm(X)),[U,V]=KJ.useState(!X),[B,N]=KJ.useState("idle"),[F,M]=KJ.useState(!1),[O,E]=KJ.useState(""),w=KJ.useRef(null),A=KJ.useRef(H);A.current=H,KJ.useEffect(()=>{if(X||!J)return;let v=!1;return V(!0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(J)}`).then((n)=>n.ok?n.json():{}).then((n)=>{if(v)return;K(n&&typeof n==="object"?n:{}),V(!1)}).catch(()=>!v&&V(!1)),()=>{v=!0}},[J,X]);let I=KJ.useCallback((v)=>{clearTimeout(w.current),w.current=setTimeout(async()=>{N("saving");try{let n=await fetch(`/_api/photo-edit?asset=${encodeURIComponent(J)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(oU0(v))});N(n.ok?"saved":"error")}catch{N("error")}},160)},[J]),T=KJ.useCallback((v,{commit:n=!1}={})=>{let e=A.current,s=Bm(e);if(v(s),A.current=s,K(s),Y?.(s),I(s),n)G?.(e,s)},[Y,I,G]),R=(v,n,e)=>T((s)=>{if(s.adjustments=s.adjustments||{},n===0||n==null)delete s.adjustments[v];else s.adjustments[v]=n;if(Object.keys(s.adjustments).length===0)delete s.adjustments},{commit:e}),$=(v,n,e)=>T((s)=>{s[v]={...s[v]||{},...n}},{commit:e}),C=()=>T((v)=>delete v.adjustments,{commit:!0}),j=(v)=>T((n)=>{delete n[v]},{commit:!0}),f=async()=>{if(!W)return;M(!0),E("Removing background…");try{let v=await W(J);if(v?.maskAsset)$("backgroundRemoved",{enabled:!0,maskAsset:v.maskAsset},!0),E("Background removed");else E("Background removal failed")}catch{E("Background removal failed")}finally{M(!1)}};if(U)return z("div",{style:{...nW.body,opacity:0.6},children:"Loading photo edit…"});let m=H.adjustments||{},d=H.duotone||{},a=H.grain||{},x=H.pattern||{},h=H.mask||{},l=H.backgroundRemoved||{};return D("div",{style:nW.body,"data-testid":"photo-knobs",children:[D("div",{style:{...nW.secHead,marginTop:0,color:"var(--fg-2)",textTransform:"none",letterSpacing:0},children:[z("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10},children:J}),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(yK,{title:"Adjustments",onReset:C,children:iU0.map((v)=>z(lX,{label:v.label,children:z(uX,{value:m[v.key],min:v.min,max:v.max,step:v.step??0.01,unit:v.unit??"",ariaLabel:v.label,onInput:(n)=>R(v.key,n),onCommit:(n)=>R(v.key,n,!0)})},v.key))}),z(yK,{title:"Duotone",right:z(nQ,{checked:d.enabled,onChange:(v)=>$("duotone",{enabled:v},!0),label:"on",ariaLabel:"Duotone on"}),onReset:()=>j("duotone"),children:d.enabled&&D(Q0,{children:[z(lX,{label:"Shadow",children:z(BE,{value:d.colorA,fallback:"#111111",label:"Shadow",ColorPicker:Q,onApply:(v)=>$("duotone",{colorA:v},!0)})}),z(lX,{label:"Highlight",children:z(BE,{value:d.colorB,fallback:"#ffffff",label:"Highlight",ColorPicker:Q,onApply:(v)=>$("duotone",{colorB:v},!0)})}),z(lX,{label:"Intensity",children:z(uX,{value:d.intensity??1,min:0,max:1,ariaLabel:"Duotone intensity",onInput:(v)=>$("duotone",{intensity:v}),onCommit:(v)=>$("duotone",{intensity:v},!0)})})]})}),z(yK,{title:"Grain",right:z(nQ,{checked:a.enabled,onChange:(v)=>$("grain",{enabled:v},!0),label:"on",ariaLabel:"Grain on"}),onReset:()=>j("grain"),children:a.enabled&&D(Q0,{children:[z(lX,{label:"Amount",children:z(uX,{value:a.amount??0.4,min:0,max:1,ariaLabel:"Grain amount",onInput:(v)=>$("grain",{amount:v}),onCommit:(v)=>$("grain",{amount:v},!0)})}),z(lX,{label:"Size",children:z(uX,{value:a.size??1,min:1,max:32,step:1,ariaLabel:"Grain size",onInput:(v)=>$("grain",{size:v}),onCommit:(v)=>$("grain",{size:v},!0)})})]})}),z(yK,{title:"Pattern",right:z(nQ,{checked:x.enabled,onChange:(v)=>$("pattern",{enabled:v},!0),label:"on",ariaLabel:"Pattern on"}),onReset:()=>j("pattern"),children:x.enabled&&D(Q0,{children:[z(lX,{label:"Type",children:z(cW,{value:x.type||"dots",options:lU0,ariaLabel:"Pattern type",onChange:(v)=>$("pattern",{type:v},!0)})}),z(lX,{label:"Blend",children:z(cW,{value:x.blend||"normal",options:dU0,ariaLabel:"Pattern blend",onChange:(v)=>$("pattern",{blend:v},!0)})}),z(lX,{label:"Color",tip:"tip: dark colour + Multiply blend reads best",children:z(BE,{value:x.color,fallback:"#ffffff",label:"Pattern color",ColorPicker:Q,onApply:(v)=>$("pattern",{color:v},!0)})}),z(lX,{label:"Scale",children:z(uX,{value:x.scale??1,min:0.1,max:16,step:0.1,ariaLabel:"Pattern scale",onInput:(v)=>$("pattern",{scale:v}),onCommit:(v)=>$("pattern",{scale:v},!0)})}),z(lX,{label:"Opacity",children:z(uX,{value:x.opacity??0.5,min:0,max:1,ariaLabel:"Pattern opacity",onInput:(v)=>$("pattern",{opacity:v}),onCommit:(v)=>$("pattern",{opacity:v},!0)})})]})}),D(yK,{title:"Mask",onReset:()=>j("mask"),children:[z(lX,{label:"Preset",children:z(cW,{value:h.preset||"none",options:cU0,ariaLabel:"Mask preset",onChange:(v)=>$("mask",{preset:v},!0)})}),h.preset&&h.preset!=="none"&&z(lX,{label:"Strength",children:z(uX,{value:h.strength??0.6,min:0,max:1,ariaLabel:"Mask strength",onInput:(v)=>$("mask",{strength:v}),onCommit:(v)=>$("mask",{strength:v},!0)})})]}),D(yK,{title:"Background",onReset:()=>j("backgroundRemoved"),children:[z("div",{style:{...nW.row,gap:10},"aria-busy":F||void 0,children:l.maskAsset?D(Q0,{children:[z(nQ,{checked:l.enabled,onChange:(v)=>$("backgroundRemoved",{enabled:v},!0),label:"applied"}),z("button",{type:"button",style:{...nW.reset,opacity:F?0.6:1},disabled:F||!W,title:"Run background removal again",onClick:()=>f(),children:F?"removing…":"redo"})]}):D("button",{type:"button",className:"st-btn",style:{opacity:F?0.6:1},disabled:F||!W,"data-testid":"photo-remove-bg",onClick:()=>f(),children:[Z?z(Z,{name:"sparkle",size:14}):null,F?"Removing…":"Remove Background"]})}),z("span",{"aria-live":"polite",className:"sr-only",children:O})]})]})}function jK({name:J,size:X=16}){let Q={cursor:z("path",{d:"M3 2.5l9 4.2-3.8 1.2-1.2 3.8z"}),people:D(Q0,{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(Q0,{children:z("path",{d:"M2.5 3.5h11v7h-6l-3 2.2V10.5h-2z"})}),save:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{children:[z("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),z("polyline",{points:"9 4 13 8 9 12"})]})}[J];return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:J==="cursor"?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function NE({icon:J,label:X,sub:Q}){return D("span",{className:"cm-step",children:[z("span",{className:"cm-step-icon",children:z(jK,{name:J,size:16})}),z("span",{className:"cm-step-label",children:X}),z("span",{className:"cm-step-sub",children:Q})]})}function FE(){return D("div",{className:"cm-info",children:[D("div",{className:"cm-live",children:[D("div",{className:"cm-live-hd",children:[z("span",{className:"cm-live-dot","aria-hidden":"true"}),D("span",{children:[z("b",{children:"Together"})," · automatic — no buttons"]})]}),D("div",{className:"cm-live-items",children:[D("span",{className:"cm-live-item",children:[z(jK,{name:"cursor",size:13})," cursors"]}),D("span",{className:"cm-live-item",children:[z(jK,{name:"people",size:13})," who's here"]}),D("span",{className:"cm-live-item",children:[z(jK,{name:"comment",size:13})," comments"]})]}),z("div",{className:"cm-live-note",children:"When you're both here, you see each other instantly."})]}),D("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"})]}),D("div",{className:"cm-cycle",children:[z(NE,{icon:"save",label:"Save changes locally",sub:"keep a version on your machine"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(jK,{name:"arrow-right",size:15})}),z(NE,{icon:"publish",label:"Publish for everyone",sub:"share it with the team"}),z("span",{className:"cm-cyc-arrow","aria-hidden":"true",children:z(jK,{name:"arrow-right",size:15})}),z(NE,{icon:"download",label:"Pull changes",sub:"get everyone else's work"})]})]})}var LE=[{render:FE,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 y6=y8(i8(),1);function nU0(J){if(typeof document>"u"||!J)return null;try{let X=document.querySelector(J);if(!X)return null;let Q=X.getBoundingClientRect();if(Q.width===0&&Q.height===0)return null;return Q}catch{return null}}var sZ=320,DE=184;function rU0(J){if(typeof window>"u"||!J)return{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:sZ};let{innerWidth:X,innerHeight:Q}=window;if(J.left>sZ+36&&X-J.right<sZ+36)return{top:Math.min(Math.max(12,J.top),Q-DE-12),left:Math.max(12,J.left-sZ-16),width:sZ};let G=Q-J.bottom>DE+24?J.bottom+12:Math.max(12,J.top-DE-12),Z=Math.min(Math.max(12,J.left),X-sZ-12);return{top:G,left:Z,width:sZ}}function Fm({steps:J,open:X,onClose:Q,onComplete:Y,bus:W,hasSelection:G,hasCanvas:Z}){let[H,K]=y6.useState(0),[U,V]=y6.useState(null),B=y6.useRef(null),N=y6.useRef(null),F=y6.useRef(null),M=y6.useRef(W);M.current=W;let O=J[H]||null,E=y6.useCallback(()=>{if(!O)return V(null),null;let f=nU0(O.target);return V(f),f},[O]);y6.useEffect(()=>{if(X)K(0)},[X]),y6.useLayoutEffect(()=>{if(!X||!O)return;let f=!1;V(null);try{M.current?.setup?.(O)}catch{}let m=0,d=24,a=()=>{if(f)return;let x=E();if(x||m>=d){if(x){try{document.querySelector(O.target)?.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}requestAnimationFrame(()=>{if(!f)E()})}return}m+=1,F.current=setTimeout(a,130)};return a(),()=>{if(f=!0,F.current)clearTimeout(F.current)}},[X,H,G]),y6.useEffect(()=>{if(!X)return;N.current=document.activeElement;let f=()=>E();return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0);try{N.current?.focus?.()}catch{}}},[X,E]);let w=H>=J.length-1,A=y6.useCallback(()=>{if(w)Y?.(),Q?.();else K((f)=>Math.min(f+1,J.length-1))},[w,Y,Q,J.length]),I=y6.useCallback(()=>K((f)=>Math.max(0,f-1)),[]);if(y6.useEffect(()=>{if(!X)return;function f(m){if(m.key==="Escape")m.preventDefault(),Q?.();else if(m.key==="ArrowRight")m.preventDefault(),A();else if(m.key==="ArrowLeft")m.preventDefault(),I();else if(m.key==="Tab"){let d=B.current;if(!d)return;let a=d.querySelectorAll("button");if(!a.length)return;let x=a[0],h=a[a.length-1];if(m.shiftKey&&document.activeElement===x)m.preventDefault(),h.focus();else if(!m.shiftKey&&document.activeElement===h)m.preventDefault(),x.focus()}}return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[X,A,I,Q]),y6.useEffect(()=>{if(!X)return;let f=setTimeout(()=>{let m=B.current?.querySelector("[data-tour-primary]");try{m?.focus()}catch{}},0);return()=>clearTimeout(f)},[X,H]),!X||!J.length||!O)return null;let T=6,R=U?{top:U.top-T,left:U.left-T,width:U.width+T*2,height:U.height+T*2}:null,$=!!O.requireSelection&&!G,C=(!!O.canvas||!!O.requireSelection)&&Z===!1,j=O.render||null;return D("div",{className:"mdcc-tour",role:"presentation",children:[R?z("div",{className:"mdcc-tour__spot",style:R,"aria-hidden":"true"}):z("div",{className:"mdcc-tour__scrim","aria-hidden":"true"}),D("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:rU0(U),children:[D("div",{className:"mdcc-tour__step",children:[H+1," / ",J.length]}),j&&z("div",{className:"mdcc-tour__graphic",children:z(j,{})}),z("div",{className:"mdcc-tour__title",id:"mdcc-tour-title",children:O.title}),z("div",{className:"mdcc-tour__body",id:"mdcc-tour-body",children:O.body}),(C||$)&&D("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."]}),D("div",{className:"mdcc-tour__actions",children:[z("button",{type:"button",className:"mdcc-tour__skip",onClick:Q,children:"Skip"}),D("div",{className:"mdcc-tour__nav",children:[H>0&&z("button",{type:"button",className:"mdcc-tour__back",onClick:I,children:"Back"}),z("button",{type:"button",className:"mdcc-tour__next","data-tour-primary":!0,onClick:A,children:w?"Done":"Next"})]})]})]})]})}var Lm=[{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 WF=[{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"}];function Dm(J,X,Q){if(!Q||J.origin!==X||J.source!==Q)return null;let Y=J.data;if(Y?.dgn!=="canvas-notice"||typeof Y.message!=="string"||!Y.message.trim())return null;if(!["info","success","error","warning","undo"].includes(Y.kind))return null;return{title:Y.message.slice(0,4000),kind:Y.kind,group:"canvas"}}var _7=y8(i8(),1);var aU0={png:"PNG",pdf:"PDF",svg:"SVG",html:"HTML",pptx:"PPTX",canva:"Canva",zip:"ZIP",mp4:"MP4",webm:"WebM",gif:"GIF"},sU0={selection:"Selection",artboard:"Artboard","canvas-as-separate":"Canvas → separate","project-raw":"Project (raw)"};async function tU0(J){let X=await fetch(`/_api/export-jobs/download?id=${encodeURIComponent(J)}`);if(!X.ok)return null;let Q=X.headers.get("Content-Disposition")||"",Y=/filename="([^"]+)"/.exec(Q)?.[1]||null;return{blob:await X.blob(),filename:Y}}async function Mm(J,X){let Q=await tU0(J);if(!Q)return;let Y=Q.filename||X||"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 eU0(J,X){return Oh(X||"export",J)}function Om({enabled:J=!0}={}){let[X,Q]=_7.useState(()=>new Map),[Y,W]=_7.useState(!1),[G,Z]=_7.useState(null),[H,K]=_7.useState([]),[U,V]=_7.useState(()=>new Set),B=_7.useRef(new Map),N=_7.useRef(new Set),F=_7.useRef(new Set);_7.useEffect(()=>{if(!J)return;let f=!0;return fetch("/_api/export-jobs").then((m)=>m.json()).then((m)=>{if(!f)return;let d=new Map;for(let a of Array.isArray(m?.jobs)?m.jobs:[])d.set(a.id,a),B.current.set(a.id,a.status),F.current.add(a.id);Q(d)}).catch(()=>{}),()=>{f=!1}},[J]);let M=_7.useCallback((f)=>{if(!f||typeof f.id!=="string")return;Q((m)=>{let d=new Map(m);return d.set(f.id,f),d})},[]);_7.useEffect(()=>{let f=B.current,m=[],d=[];for(let a of X.values()){let x=f.get(a.id),h=a.status==="queued"||a.status==="running",l=a.status==="done"||a.status==="failed";if(x===void 0&&h&&!F.current.has(a.id))F.current.add(a.id),m.push(a.id);else if(x!==a.status&&l)m.push(a.id),d.push(a)}for(let a of X.values())f.set(a.id,a.status);if(m.length)K((a)=>{let x=a.filter((h)=>!m.includes(h));return[...m,...x]});if(G9()||!d.length)return;for(let a of d){if(a.status!=="done")continue;if(N.current.has(a.id))continue;if(!document.hasFocus())continue;N.current.add(a.id),Mm(a.id,a.filename)}},[X]);let O=_7.useMemo(()=>Array.from(X.values()).sort((f,m)=>(m.createdAt||"").localeCompare(f.createdAt||"")),[X]),E=O.filter((f)=>f.status==="running").length,w=O.filter((f)=>f.status==="queued").length,A=_7.useCallback((f)=>K((m)=>m.filter((d)=>d!==(f??m[0]))),[]),I=_7.useCallback((f)=>{Z(typeof f==="string"?f:null),W(!0)},[]),T=_7.useCallback(()=>W(!1),[]),R=_7.useCallback(async(f,m)=>{V((d)=>new Set(d).add(f.id));try{await m()}finally{V((d)=>{let a=new Set(d);return a.delete(f.id),a})}},[]),$=_7.useCallback(async(f)=>{N.current.add(f.id),await R(f,()=>Mm(f.id,f.filename))},[R]),C=_7.useCallback(async(f)=>{N.current.add(f.id),await R(f,()=>eU0(f.id,f.filename))},[R]),j=Y?null:H[0]??null;return{jobs:O,upsert:M,runningCount:E,queuedCount:w,busyCount:E+w,panelOpen:Y,selectedJobId:G,toastJobs:H.map((f)=>X.get(f)).filter(Boolean),openPanel:I,closePanel:T,showToast:!!j,toastJob:j?X.get(j)??null:null,dismissToast:A,download:$,save:C,savingIds:U}}function Am(J){let X=aU0[J.format]||String(J.format||"").toUpperCase(),Q=sU0[J.scope]||J.scope;return`${X} · ${Q}`}function _m(J){if(G9())return J?"Saving…":"Save…";return J?"Downloading…":"Download"}function wm({progress:J}){if(!J||!J.total)return z("div",{className:"st-export-progress st-export-progress--indeterminate","aria-hidden":"true"});let X=Math.max(0,Math.min(100,Math.round(J.current/J.total*100)));return z("div",{className:"st-export-progress",role:"progressbar","aria-valuenow":X,"aria-valuemin":0,"aria-valuemax":100,children:z("div",{className:"st-export-progress-bar",style:{width:`${X}%`}})})}var ME=new Map;function JV0(J){let X=J.progress?.current,Q=J.progress?.total;if(!X||!Q||X>=Q)return ME.delete(J.id),null;let Y=ME.get(J.id);if(!Y||X<Y.c)Y={t:Date.now(),c:X},ME.set(J.id,Y);let W=X-Y.c;if(W<3)return null;let G=(Date.now()-Y.t)/W*(Q-X);if(G<45000)return"<1 min left";return`~${Math.round(G/60000)} min left`}function XV0({job:J}){let X=J.status==="done"&&!!J.degraded,Q=J.status==="queued"?"Queued":J.status==="running"?J.progress?.total?`${J.progress.current} of ${J.progress.total}`:"Rendering…":J.status==="done"?X&&J.degraded.audioDropped?"Ready · no audio":X&&J.degraded.fontsNotEmbedded?.length?"Ready · font warning":X?"Ready · degraded":"Ready":"Failed",Y=J.status==="running"?JV0(J):null;return D("span",{className:`st-export-pill st-export-pill--${J.status}${X?" st-export-pill--degraded":""}`,children:[Q,Y?` · ${Y}`:""]})}function Em({degraded:J,compact:X=!1}){if(!J)return null;let Q=J.fontsNotEmbedded??[],Y=J.audioDropped?"Exported without audio.":Q.length?`Fonts a print shop will reject: ${Q.join(", ")}.`:"Exported with reduced fidelity.";return D("div",{className:"st-export-degraded","data-testid":"export-degraded-note",children:[z("span",{"aria-hidden":"true",children:"!"})," ",X?$V(Y):Y,J.remedy?z("div",{className:"st-export-degraded__fix",children:X?$V(J.remedy):J.remedy}):null]})}function Pm({center:J}){let X=J.busyCount>0;return D("button",{type:"button",className:"st-exports","data-tour":"exports","data-busy":X?"true":"false","aria-label":X?`Exports — ${J.busyCount} running`:"Exports","data-tip":"Exports",onClick:J.openPanel,children:[z("span",{"aria-hidden":"true",children:"⬇"}),X&&z("span",{className:"st-exports__count","aria-hidden":"true",children:J.busyCount})]})}function QV0({job:J,center:X}){let Q=J.status==="queued"||J.status==="running",Y=J.status==="done",W=X.savingIds.has(J.id),G=`export-${J.id}`;return _7.useEffect(()=>{E5({id:G,group:"exports",title:Q?"Exporting…":Y?J.degraded?"Export ready — with a problem":"Export ready":"Export failed",description:Q?"Running in the background — you can keep working.":Y?J.filename??"Ready to download.":J.error??"Something went wrong.",kind:Q?"info":Y?J.degraded?"warning":"success":"error",duration:Q?1/0:void 0,timerKey:Q?"active":J.status,paused:W,onDismiss:()=>X.dismissToast(J.id),content:D(Q0,{children:[z("div",{className:"maude-notice-summary",children:Am(J)}),Q&&z(wm,{progress:J.progress}),Y&&z(Em,{degraded:J.degraded,compact:!0}),D("div",{className:"st-toast-actions",children:[Y&&D("button",{type:"button",className:"btn btn--primary btn--sm",disabled:W,onClick:()=>G9()?void X.save(J):void X.download(J),children:[W&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),_m(W)]}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>X.openPanel(J.id),children:"View in history"})]})]})})},[G,J,Q,Y,W,X.dismissToast,X.openPanel,X.save,X.download]),_7.useEffect(()=>()=>CW(G),[G]),null}function Im({center:J}){return J.toastJobs.map((X)=>z(QV0,{job:X,center:J},X.id))}function km({center:J}){let{panelOpen:X,closePanel:Q,selectedJobId:Y}=J,W=_7.useRef(null);if(_7.useEffect(()=>{if(X&&Y)W.current?.scrollIntoView?.({block:"nearest"}),W.current?.focus()},[X,Y]),_7.useEffect(()=>{if(!X)return;function G(Z){if(Z.key==="Escape")Q()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[X,Q]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Q()},children:D("div",{className:"st-export-panel",role:"dialog","aria-modal":"true","aria-labelledby":"st-export-panel-title",children:[D("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:J.jobs.length===0?z("p",{className:"mdcc-wn-empty",children:"No exports yet."}):z("ul",{className:"st-export-list",children:J.jobs.map((G)=>D("li",{className:"st-export-item","data-testid":`export-job-${G.id}`,ref:G.id===Y?W:null,tabIndex:-1,children:[D("div",{className:"st-export-item__hd",children:[z("span",{className:"st-export-item__label",children:Am(G)}),z(XV0,{job:G})]}),(G.status==="queued"||G.status==="running")&&z(wm,{progress:G.progress}),G.status==="done"&&z(Em,{degraded:G.degraded}),G.status==="done"&&D("div",{className:"st-export-item__ft",children:[z("span",{className:"st-export-item__filename",children:G.filename}),D("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:J.savingIds.has(G.id),onClick:()=>G9()?J.save(G):J.download(G),children:[J.savingIds.has(G.id)&&z("span",{className:"st-btn-spin","aria-hidden":"true"}),_m(J.savingIds.has(G.id))]})]}),G.status==="failed"&&z("div",{className:"st-export-item__ft",children:D("details",{className:"st-export-item__error",children:[z("summary",{children:"Show error details"}),z("pre",{children:G.error??"Export failed."})]})})]},G.id))})})]})})}var o7=y8(i8(),1);var OE=4,YV0="https://github.com/1aGh/maude/issues/new",Tm={shell:"Maude window (auto)",artboard:"Active artboard (auto)",attached:"Attached by you"};function WV0(J){if(J==="darwin")return"⇧⌘4 then Space";if(J==="win32")return"Win+Shift+S";return"your screenshot tool"}function Cm(J){let X=new Uint8Array(J/2);return crypto.getRandomValues(X),Array.from(X,(Q)=>Q.toString(16).padStart(2,"0")).join("")}function GV0(){try{let J=localStorage.getItem("maude-install-id");if(!J)J=`i-${Cm(12)}`,localStorage.setItem("maude-install-id",J);return J}catch{return null}}async function Rm(J){let X=new Image;X.src=J.url,await X.decode();let Q=document.createElement("canvas");Q.width=X.naturalWidth,Q.height=X.naturalHeight;let Y=Q.getContext("2d");Y.drawImage(X,0,0),Y.fillStyle="#000";for(let W of J.rects)Y.fillRect(W.x*X.naturalWidth,W.y*X.naturalHeight,W.w*X.naturalWidth,W.h*X.naturalHeight);return new Promise((W)=>Q.toBlob(W,"image/png"))}var ZV0=(J)=>new Promise((X)=>{let Q=new FileReader;Q.onload=()=>X(Q.result),Q.readAsDataURL(J)});function HV0({shot:J,redacting:X,onRects:Q,onRemove:Y}){let W=o7.useRef(null),G=o7.useRef(null),[Z,H]=o7.useState(null),K=(U)=>{let V=W.current.getBoundingClientRect();return{x:Math.min(Math.max((U.clientX-V.left)/V.width,0),1),y:Math.min(Math.max((U.clientY-V.top)/V.height,0),1)}};return D("div",{className:"rb-shot","data-testid":"report-bug-shot",children:[D("div",{ref:W,className:`rb-shot-box${X?" is-redacting":""}`,onPointerDown:(U)=>{if(!X)return;U.currentTarget.setPointerCapture(U.pointerId),G.current=K(U),H({...G.current,w:0,h:0})},onPointerMove:(U)=>{if(!X||!G.current)return;let V=K(U),B=G.current;H({x:Math.min(B.x,V.x),y:Math.min(B.y,V.y),w:Math.abs(V.x-B.x),h:Math.abs(V.y-B.y)})},onPointerUp:()=>{if(!X||!G.current)return;if(G.current=null,Z&&Z.w>0.005&&Z.h>0.005)Q([...J.rects,Z]);H(null)},children:[z("img",{src:J.url,alt:"screenshot to attach",draggable:!1}),[...J.rects,...Z?[Z]:[]].map((U,V)=>z("div",{className:"rb-redact-rect",style:{left:`${U.x*100}%`,top:`${U.y*100}%`,width:`${U.w*100}%`,height:`${U.h*100}%`}},V))]}),z("div",{className:"rb-shot-src",children:Tm[J.source]??Tm.attached}),D("div",{className:"rb-shot-actions",children:[J.rects.length>0&&z("button",{type:"button",className:"rb-link",onClick:()=>Q([]),children:"Clear redactions"}),z("button",{type:"button",className:"rb-link","data-testid":"report-bug-shot-remove",onClick:Y,children:"Remove"})]})]})}function $m({open:J,onClose:X,activeCanvas:Q=null}){let[Y,W]=o7.useState("describe"),[G,Z]=o7.useState(""),[H,K]=o7.useState(null),[U,V]=o7.useState([]),[B,N]=o7.useState([]),[F,M]=o7.useState({logTail:!0,activeCanvas:!0,projectName:!1,crashLogs:!0}),[O,E]=o7.useState(!1),[w,A]=o7.useState(!1),[I,T]=o7.useState(null),[R,$]=o7.useState(null),C=o7.useCallback(()=>{for(let l of U)URL.revokeObjectURL(l.url);W("describe"),Z(""),K(null),V([]),N([]),E(!1),A(!1),T(null),$(null)},[U]),j=o7.useCallback((l,v="attached")=>{if(!l)return;V((n)=>n.length>=OE?n:[...n,{url:URL.createObjectURL(l),blob:l,source:v,rects:[]}])},[]),f=o7.useCallback(async()=>{if(G9()){try{let v=await cZ();if(v?.bytes)j(new Blob([new Uint8Array(v.bytes)]),"attached")}catch{}return}let l=document.createElement("input");l.type="file",l.accept="image/*",l.style.cssText="position:fixed;left:-9999px;top:0",document.body.appendChild(l),l.addEventListener("change",()=>{let v=l.files?.[0];if(v)j(v,"attached");l.remove()}),l.click()},[j]);if(o7.useEffect(()=>{if(!J)return;let l=!0;if(fetch("/_api/debug-bundle").then((v)=>v.ok?v.json():null).then((v)=>l&&K(v)).catch(()=>{}),Q)fetch("/_api/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:"png",scope:"artboard"})}).then((v)=>v.ok?v.blob():null).then((v)=>l&&v&&j(v,"artboard")).catch(()=>{});if(E(!0),fetch("/_api/shell-shot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({canvas:Q})}).then((v)=>v.ok?v.blob():null).then((v)=>{if(!l)return;if(v)j(v,"shell");E(!1)}).catch(()=>l&&E(!1)),G9())A7("list_crash_logs").then((v)=>l&&N(Array.isArray(v)?v.slice(0,3):[])).catch(()=>{});return()=>{l=!1}},[J,Q]),o7.useEffect(()=>{if(!J)return;function l(v){for(let n of v.clipboardData?.items??[])if(n.type.startsWith("image/"))j(n.getAsFile())}return window.addEventListener("paste",l),()=>window.removeEventListener("paste",l)},[J,j]),!J)return null;let m=()=>{C(),X()};async function d(){let l={schema:"maude-report/v1",reportId:`r-${Cm(8)}`,createdAt:new Date().toISOString(),app:{maudeVersion:H?.app?.maudeVersion??"unknown",surface:G9()?"native":"browser",platform:H?.app?.platform??"unknown",arch:H?.app?.arch??"unknown"},context:{projectName:F.projectName?H?.context?.projectName??null:null,activeCanvas:F.activeCanvas?Q:null},description:G.trim(),attachments:{screenshots:U.length,serverLogTail:F.logTail&&!!H?.logs?.serverLogTail,processStats:F.logTail&&!!H?.process,crashLogs:F.crashLogs?B.length:0},logs:{}},v=GV0();if(v)l.installId=v;if(F.logTail&&H?.logs?.serverLogTail)l.logs.serverLogTail=H.logs.serverLogTail;if(F.logTail&&H?.process)l.process={rssBytes:H.process.rssBytes,heapUsedBytes:H.process.heapUsedBytes,uptimeSeconds:H.process.uptimeSeconds};if(F.crashLogs&&B.length&&G9()){l.logs.crashLogs=[];for(let n of B)try{let e=await A7("read_crash_log",{name:n.name});l.logs.crashLogs.push({name:n.name,body:e})}catch{}}return l}async function a(){W("sending"),$(null);try{let l=await d(),v=new FormData;v.set("report",JSON.stringify(l));for(let s of U)v.append("screenshot",await Rm(s),"screenshot.png");let n=await fetch("/_api/report",{method:"POST",body:v}),e=await n.json().catch(()=>null);if(n.ok&&e?.ok){T(e),W("done");return}$(e?.error??`report failed (HTTP ${n.status})`),W("fallback")}catch{$("Maude could not reach the report service."),W("fallback")}}async function x(){try{let l=await d(),v=[];for(let z0 of U)v.push(await ZV0(await Rm(z0)));let e=await(await fetch("/_api/report-fallback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({report:l,screenshots:v})})).json().catch(()=>null),s=encodeURIComponent(l.description.split(`
5679
5679
  `)[0].slice(0,80)),H0=encodeURIComponent(`${l.description}
5680
5680
 
5681
5681
  > Maude ${l.app.maudeVersion} · ${l.app.platform} ${l.app.arch} · ${l.app.surface}
5682
5682
  > Local report bundle: \`${e?.dir??".design/_reports/"}\` (attach its files here)`),r=`${YV0}?title=${s}&body=${H0}&labels=report`;if(G9())try{await wV(r)}catch{window.open(r,"_blank","noopener")}else window.open(r,"_blank","noopener");T({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let h=G.trim().length>0;return z("div",{className:"st-scrim",onClick:m,"data-testid":"report-bug-dialog",children:D("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(l)=>l.stopPropagation(),children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:m,"aria-label":"Close",children:"×"})]}),D("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&D(Q0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(l)=>Z(l.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:m,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!h,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&D(Q0,{children:[D("div",{className:"rb-section",children:[D("div",{className:"rb-section-hd",children:[D("span",{children:["Screenshots (",U.length,")"]}),D("span",{className:"rb-hd-actions",children:[U.length<OE&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:f,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>A((l)=>!l),children:w?"Done redacting":"Redact…"})]})]}),D("p",{className:"rb-hint",children:["Maude captures its own window and the active artboard for you. The window shot is a fresh render, so anything mid-flight — an open menu, a stuck spinner — won't be in it: grab that yourself (",WV0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),O&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!O?D("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",OE,"."]}):D(Q0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((l,v)=>z(HV0,{shot:l,redacting:w,onRects:(n)=>V((e)=>e.map((s,H0)=>H0===v?{...s,rects:n}:s)),onRemove:()=>{URL.revokeObjectURL(l.url),V((n)=>n.filter((e,s)=>s!==v))}},l.url))})]})]}),D("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),D("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",G9()?"desktop app":"browser"]})]}),Q&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(l)=>M({...F,activeCanvas:l.target.checked})}),D("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(l)=>M({...F,projectName:l.target.checked})}),D("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?D("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(l)=>M({...F,logTail:l.target.checked})}),D("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
5683
- `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(l)=>M({...F,crashLogs:l.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((l)=>l.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())wV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=y8(i8(),1);function Sm(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function bm(J,X){let Q=Sm(J),Y=Sm(X);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 ym(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||bm(Q.version,X)))}function jm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&bm(Y.version,Q))Q=Y.version}return Q}var AE="mdcc-whatsnew-seen",_E="mdcc-whatsnew-toast-dismissed";function zV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function KV0(J){try{let X=localStorage.getItem(AE);if(X)return X;localStorage.setItem(AE,J)}catch{}return J}function UV0(){try{return localStorage.getItem(_E)}catch{return null}}function vm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>KV0(J)),[H,K]=TJ.useState(()=>UV0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let A=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(A)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let T=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{A=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let B=ym(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let A=jm(X,Y);Z(A),K(Y);try{localStorage.setItem(AE,A),localStorage.setItem(_E,Y)}catch{}},[X,Y]),O=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(_E,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:O,markAllSeen:M}}function fm({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){CW(X);return}E5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>CW(X),[X]),null}function xm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.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(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("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:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("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}),zV0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),n80="mdcc-usage-tour-seen",r80="mdcc-collab-tour-seen",r8="__system__",C90="mdcc-theme",a80="mdcc-show-hidden",s80="mdcc-sections-expanded",t80="maude-cp-mode",e80="mdcc-sidebar-open",J90="mdcc-minimap-visible",X90="mdcc-zoomctl-visible",Q90="mdcc-annotations-visible";var OF0=30000;function AF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var VT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],J1={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},Y90="mdcc-panel-sides",W90="mdcc-layers-mode";function G90({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(VT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var b5=/\.(tsx|html?)$/i,_F0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function AL(J){for(let[X,Q]of _F0)if(X.test(J))return Q;return null}function Oq(J){return J.replace(/^\.[^/]+\//,"").replace(b5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function wF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var qT="1.4.5";function UL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){A7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function EF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(C90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function TH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function HT(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function PF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Q4(J){return J.split("/").pop()}function h8(J,X=!1,Q){E5({title:J,kind:X?"success":"error",action:Q})}var Z90="maude-mode-hint-seen";function BL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(Z90)==="1")return}catch{return}if(BL.active)return;BL.active=!0;let X=()=>{BL.active=!1;try{localStorage.setItem(Z90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)CW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);E5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function X4(J){return J.replace(b5,"")}function IF0(J){return J.replace(b5,"")}function kF0(J){let X=new Map;for(let G of J){if(!b5.test(G.name))continue;let Z=IF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(b5.test(G.name))continue;let Z=null;for(let H of X.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 X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function TF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function $90(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=$90(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._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 NL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function RF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/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(J).toLocaleDateString()}function S90(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function LL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var CF0={"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:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{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:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{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:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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 $F0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>t2(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(k9,{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(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=jb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z($J,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z($J,{children:V.kbd})}):null]})]},V.id)})})]})})}function k9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:CF0[J]})}function SF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function H90({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function $J({children:J}){return z("span",{className:"kbd",children:J})}function z90(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function K90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("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 zT=[{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}],U90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},bF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Fq=[{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}],yF0="2x",V90=[{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}],jF0="auto",q90=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],vF0="keep",fF0={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 xF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return fF0[X]||"application/octet-stream"}function hF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,O]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!x)return;let l=h.ok?h.assets:[];H(l),O((v)=>{let n={...v};for(let e of l)n[e.path]=e.kind;return n})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let A=Array.from(N).some((x)=>(M[x]||"image")!=="image"),I=!W||A,T=!W?"No artboard on this canvas":A?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(x)=>{F((h)=>{let l=new Set(h);if(l.has(x))l.delete(x);else l.add(x);return l})},$=async(x)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),l=await h.json().catch(()=>({}));if(h.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${h.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let h=await $(x);if(U(!1),h.ok)X(h.path);else B(h.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;U(!0),B(null);let h=await Promise.all(x.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let l=h.filter((n)=>n.ok),v=h.length-l.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(l.length)O((n)=>{let e={...n};for(let s of l)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of l)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let l=(await Ah()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:xF0(v.name)}));if(U(!1),l.length)await f(l);return}let x=await cZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(G9()){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 h=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),x.addEventListener("change",()=>{let l=x.files?Array.from(x.files):[];if(h(),!l.length)return;if(Y)f(l);else C(l[0])}),x.click()},a=(x)=>`/${J}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("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(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"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 h=Y&&N.has(x.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?R(x.path):X(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(k9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:a(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&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(N),E),children:"Insert"})]})]})})}function DL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function gF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((C0)=>H==="none"&&!C0.handoff&&C0.format!=="zip"&&!ob.has(C0.format)||H!=="local"&&C0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&fb("png",X)?X:RO("png")),[O,E]=u.useState(2),[w,A]=u.useState(yF0),[I,T]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[f,m]=u.useState(!1),[d,a]=u.useState(jF0),[x,h]=u.useState(vF0),[l,v]=u.useState(!0),[n,e]=u.useState(!1),[s,H0]=u.useState(null),[r,z0]=u.useState([]),i=zT.find((C0)=>C0.id===B)||zT[0],q0=i.handoff?[]:CO(i.format),Z0=900,I0=3600,a0=CK(W,iw(W,{artboardId:G})),s0=a0?.durationInFrames||0,e0=a0?.fps||30,D8=i.temporal&&s0>900,s8=i.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(RO(i.format))},[q0,F,i.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let w8=u.useCallback(()=>{fetch("/_api/export-history").then((C0)=>C0.json()).then((C0)=>z0(Array.isArray(C0?.history)?C0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{w8()},[w8]),u.useEffect(()=>{function C0(A0){if(A0.key==="Escape")A0.preventDefault(),U()}return window.addEventListener("keydown",C0),()=>window.removeEventListener("keydown",C0)},[U]);async function N8(){if(i.handoff){let Q8=`/design:handoff ${Q&&Q!==r8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(Q8)}catch{}H0({ok:!0,msg:`Copied: ${Q8} — run it in Claude Code.`});return}if(V(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let C0=i.temporal?{scale:O}:{};if(i.format==="png"){let $0=Fq.find((Q8)=>Q8.id===w)||Fq[1];if($0.kind==="dpi")C0.dpi=$0.value;else C0.scale=$0.value}if(i.format==="mp4"||i.format==="webm")C0.audio=l;if(s8)C0.maxFrames=s0;if(i.format==="pdf"){C0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let $0=V90.find((Q8)=>Q8.id===d)?.value;if($0!==void 0)C0.dpi=$0;if(x!=="keep")C0.text=x}if(G)C0.artboardId=G;if(Z?.selector)C0.selection=Z;if(Q&&Q!==r8)C0.canvasFile=Q;if(vU.has(i.format)&&YB({exportLane:H,format:i.format,scope:F,artboardId:C0.artboardId})&&typeof K==="function")try{let $0=fO(C0);H0({ok:!0,msg:"Capturing…"});let Q8=await K({format:i.format,artboardIds:[C0.artboardId],scale:$0,onProgress:(f8,b8)=>H0({ok:!0,msg:`Capturing ${f8}/${b8}…`})}),Z8=await vO(Q8,i.format);for(let f8 of Z8)DL(f8.name,f8.blob);for(let f8 of Z8)await xO({format:i.format,scope:F,filename:f8.name});e(!1),H0({ok:!0,msg:`Saved ${Z8.map((f8)=>f8.name).join(", ")} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(YB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let $0=Q&&Q!==r8?Q4(Q).replace(/\.[^.]+$/,""):"export",{filename:Q8,blob:Z8}=await jO({capture:K,name:$0,onProgress:(f8,b8)=>H0({ok:!0,msg:`Capturing ${f8}/${b8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});DL(Q8,Z8),await xO({format:i.format,scope:F,filename:Q8}),e(!1),H0({ok:!0,msg:`Saved ${Q8} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(H==="none"&&vU.has(i.format)){H0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let $0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:C0})});if(!$0.ok){H0({ok:!1,msg:await $0.text()||`Export failed (${$0.status})`}),e(!1);return}U()}catch($0){H0({ok:!1,msg:$0&&$0.message?$0.message:String($0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(C0)=>{if(C0.target===C0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r8?`Format · ${X4(Q4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:zT.filter((C0)=>!C0.temporal||Y).map((C0)=>D("button",{type:"button","data-testid":`export-format-${C0.id}`,className:"st-fmt"+(C0.id===B?" is-on":""),disabled:V(C0),title:V(C0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(C0.id),H0(null)},children:[z(k9,{name:C0.icon,size:16}),z("span",{className:"st-fmt-name",children:C0.label}),z("span",{className:"st-fmt-sub",children:C0.sub})]},C0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!i.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(C0)=>M(C0.target.value),children:q0.map((C0)=>z("option",{value:C0,children:U90[C0]},C0))})]}),!i.handoff&&i.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(C0)=>A(C0.target.value),children:Fq.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let C0=Fq.find(($0)=>$0.id===w)||Fq[1],A0=C0.kind==="dpi"?C0.value/96:C0.value;return`${C0.label} ≈ ${Math.round(1440*A0)}×${Math.round(900*A0)} for a 1440×900 artboard.`})()}),!i.handoff&&i.temporal&&D("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:O,onChange:(C0)=>E(Number(C0.target.value)),children:bF0.map((C0)=>z("option",{value:C0.value,children:C0.label},C0.value))})]}),!i.handoff&&i.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[O,"× the artboard's native resolution (e.g. 960×540 → ",960*O,"×",540*O,")."]}),D8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/e0),"s).",s8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!i.handoff&&i.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(C0)=>a(C0.target.value),children:V90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.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)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:x,onChange:(C0)=>h(C0.target.value),children:q90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:q90.find((C0)=>C0.id===x)?.description}),z("div",{className:"st-dialog-row",children:D("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:I,onChange:(C0)=>T(C0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((C0)=>!C0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(C0)=>j(C0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(C0)=>m(C0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!i.handoff&&(i.format==="mp4"||i.format==="webm")&&z("div",{className:"st-dialog-row",children:D("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:l,onChange:(C0)=>v(C0.target.checked)}),"Export with audio"]})}),i.handoff&&D("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."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),r.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map((C0,A0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(C0.format||"").toUpperCase()," ·"," ",U90[C0.scope]||C0.scope]}),z("span",{className:"st-mono",children:C0.filename})]},A0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:n,onClick:N8,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var _L=12,wL=16;function mF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Oq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:_L+X*wL+"px"},onClick:()=>K((O)=>!O),onContextMenu:Z?(O)=>Z.openAt(O,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(rz,{label:J,row:M,expanded:H,busy:F,onToggle:()=>K((O)=>!O),actions:Z?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Oq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(O)=>Z.openAt(O,{kind:"dir",dirPath:W}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}):null,children:H&&Y})}function uF0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return z(rz,{label:J,expanded:H,selected:W,onToggle:()=>K((U)=>!U),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:_L+Q*wL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(k9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),children:H&&Z})}function ML({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,O=b5.test(J.name),E=!O&&K!=="runtime"?AL(J.name):null,w=!O&&!E,A=O?X4(J.name):J.name,I=O&&typeof G==="function"&&K!=="runtime",T=O&&!U&&K!=="runtime"&&typeof N<"u",R=T?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=T&&typeof F<"u",f=!O&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=O?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(b5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":a??(f?`file-row-${Oq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:_L+H*wL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(O)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||f,supporting:f,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:A}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(rz,{label:A,row:x,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Oq(J.path)}`,title:`Actions for ${A}`,"aria-label":`Actions for ${A}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||f,supporting:f,name:J.name}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${A}`,"aria-label":`Delete canvas ${A}`,onClick:(h)=>{h.stopPropagation(),G(J.path,A)},children:z(LL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function pF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:O}){let E=N?.get(J.path),w=X.length>0,[A,I]=u.useState(!1),T=B||A,R=J.path===W;if(!(w&&V))return z(ML,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:O});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},f=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof O<"u",a=typeof O<"u"&&Y!=="runtime",x=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":T,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(f?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:_L+Q*wL+"px"},title:J.path,onClick:(l)=>{if(l.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(l)=>O.openAt(l,{kind:"file",path:J.path,dir:x,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(l)=>{l.stopPropagation(),I((v)=>!v)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X4(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return z(rz,{label:X4(J.name),row:h,selected:R,expanded:T,busy:m,onToggle:()=>I((l)=>!l),actions:a?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Oq(J.path)}`,title:`Actions for ${X4(J.name)}`,"aria-label":`Actions for ${X4(J.name)}`,"aria-haspopup":"menu",onClick:(l)=>O.openAt(l,{kind:"file",path:J.path,dir:x,canMove:d}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}):null,children:T&&X.map((l)=>z(ML,{file:l,menu:O,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},l.path))})}function b90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:O,dirPath:E="",drag:w,menu:A}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),T=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>kF0(T),[T]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let x of $){let h=AL(x.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(x)}return{mediaOrphans:d,metaOrphans:a}},[$]),f=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=f&&d.sidecars.some((x)=>{let h=U.toLowerCase();return x.name.toLowerCase().includes(h)||x.path.toLowerCase().includes(h)});return z(pF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:NL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:O?.[d.primary.path],drag:w,menu:A},d.primary.path)}),C.map((d)=>z(ML,{file:d.primary,menu:A,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:NL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(ML,{file:d.primary,menu:A,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:NL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),x=E?`${E}/${d}`:d,h=z(b90,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:O,dirPath:x,drag:w,menu:A});if(a&&N)return z(uF0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r8&&a.name===B,onOpenSystem:N,children:h},d);return z(mF0,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:w?A:void 0,children:h},d)})]})}var VL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function lF0(J){if(J.kind==="project")return VL.project;if(J.kind==="runtime")return VL.runtime;if(J.label==="Design system")return VL.ds;if(J.label==="UI kit")return VL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function dF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:O,onNewBoard:E,onDeleteBoard:w,onRefresh:A,refreshing:I,collapsed:T,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:f,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:x,onMoveCanvas:h,onNewFolder:l,onDeleteFolder:v,onRenameFolder:n,onRenameCanvas:e,onDuplicateCanvas:s,onDeleteFile:H0,syncStatus:r,onLinkedHub:z0,onLocalProject:i,onOpenLinkedFile:q0,filesReady:Z0,onShare:I0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((j0)=>({...j0,tree:$90(j0.tree,V),filtered:!!V}))},[Q,V]),e0=tb(h),D8=rb(),s8=u.useMemo(()=>{let j0=[];for(let t0 of Q){if(t0.label==="Design system"||t0.kind!=="canvas")continue;let H8=t0.fullPath.replace(/^\.[^/]+\//,"")||t0.fullPath;j0.push({path:t0.fullPath,label:H8});for(let p0 of t0.dirs||[])j0.push({path:p0,label:p0.replace(/^\.[^/]+\//,"")})}return j0},[Q]),w8=D8.state?.extra,N8=w8?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{D8.close(),I0(w8.path)}},...e&&/\.tsx$/i.test(w8.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{D8.close();let j0=X4(w8.path.split("/").pop()),t0=window.prompt("Rename canvas to:",j0);if(t0?.trim()&&t0.trim()!==j0)e(w8.path,t0.trim())}}]:[],...s&&/\.tsx$/i.test(w8.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{D8.close(),s(w8.path)}}]:[],...w8.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{D8.close();let j0=w8.name??w8.path.split("/").pop(),t0=j0.includes(".")?j0.slice(j0.lastIndexOf(".")):"",H8=t0?j0.slice(0,-t0.length):j0,p0=window.prompt(`Rename ${j0} to:`,H8);if(p0?.trim()&&p0.trim()!==H8)e(w8.path,p0.trim())}}]:[],...w8.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>D8.showMoveTo()}]:[],...w8.supporting&&H0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{D8.close(),H0(w8.path,w8.name??w8.path.split("/").pop())}}]:[]]:w8?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{D8.close();let j0=window.prompt("New folder name:");if(j0?.trim())l(w8.dirPath,j0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{D8.close();let j0=w8.dirPath.split("/").pop(),t0=window.prompt("Rename folder to:",j0);if(t0?.trim()&&t0.trim()!==j0)n(w8.dirPath,t0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{D8.close(),v(w8.dirPath,w8.dirPath.split("/").pop())}}]:[],C0=w8?.kind==="file"||w8?.kind==="supporting"?s8.filter((j0)=>j0.path!==w8.dir):[],[A0,$0]=u.useState(!1),[Q8,Z8]=u.useState("board"),[f8,b8]=u.useState(""),[O9,h0]=u.useState(""),[C8,A9]=u.useState(!1),F8=u.useMemo(()=>Q.find((j0)=>j0.kind==="canvas"&&j0.label!=="Design system")?.fullPath,[Q]),B0=u.useCallback(async()=>{let j0=f8.trim();if(!j0||C8)return;if(A9(!0),h0(""),Q8==="folder"){if(!F8){A9(!1),h0("no canvas group to create a folder in");return}let H8=await l(F8,j0);if(A9(!1),H8?.ok)$0(!1),b8("");else h0(H8?.error||"could not create folder");return}let t0=await E(j0);if(A9(!1),t0?.ok)$0(!1),b8("");else h0(t0?.error||"could not create board")},[f8,C8,E,l,Q8,F8]),J8=u.useMemo(()=>{let j0=0;for(let t0 of Q)for(let H8 of t0.paths||[])if(b5.test(H8))j0++;return j0},[Q]),r0=u.useMemo(()=>{let j0=0;for(let t0 of s0)for(let H8 of t0.paths||[])if(b5.test(H8))j0++;return j0},[s0]);return D("nav",{className:"st-sidebar"+(T?" is-collapsed":"")+(C?" is-resizing":""),style:T||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":A0&&Q8==="board",onClick:()=>{h0(""),Z8("board"),$0((j0)=>Q8==="board"?!j0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&F8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":A0&&Q8==="folder",onClick:()=>{h0(""),Z8("folder"),$0((j0)=>Q8==="folder"?!j0:!0)},children:z(k9,{name:"folder-plus",size:15})}),A&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>A(),children:z(k9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J8]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(k9,{name:"panel-left",size:15})})]})]}),A0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:Q8==="folder"?"folder name…":"brief board name…",value:f8,maxLength:60,disabled:C8,"aria-label":Q8==="folder"?"New folder name":"New brief board name",onChange:(j0)=>b8(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Enter")j0.preventDefault(),B0();else if(j0.key==="Escape")j0.preventDefault(),$0(!1),b8(""),h0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:C8||!f8.trim(),"data-tip":"Create · Enter","aria-label":Q8==="folder"?"Create folder":"Create brief board",onClick:B0,children:C8?"…":"↵"})]}):null,O9?z("div",{className:"st-newboard-err",role:"alert",children:O9}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(k9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(j0)=>B(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Escape")if(j0.preventDefault(),V)B("");else j0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z($J,{children:"/"})]})}),z(sb,{"aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((j0)=>{if(!F&&!V&&j0.kind==="runtime")return null;let t0=lF0(j0),H8=(j0.paths||[]).filter((i0)=>b5.test(i0)).length,p0=t0.pill||(t0.pillFromDsCount?String(j0.dsFolders?.length||0):null)||(t0.pillFromCount?String(H8||j0.paths?.length||0):null),d0=j0.tree&&Object.keys(j0.tree).length>0,k8=j0.label==="Design system",_0=j0.kind==="project";if(!F&&!V&&_0&&H8===0)return null;let X8=PF0(j0),P8=M[j0.label],U0=!!V||(P8===void 0?X8:P8),o0=!k8&&j0.kind==="canvas"&&!J,R8=o0?e0.dropProps(j0.fullPath,!0):{},J9=e0.overDir===j0.fullPath;return z(rz,{className:"st-tree-section",label:t0.title,expanded:U0,onToggle:()=>O(j0.label,X8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(J9?" is-drop-target":""),"data-testid":`tree-section-${j0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>O(j0.label,X8),"aria-expanded":U0,"aria-dropeffect":o0?"move":void 0,title:U0?"Collapse section":"Expand section",...R8,children:[z(k9,{name:"chevron-right",className:"st-chev"+(U0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:t0.title}),p0&&z("span",{className:"st-pill",children:p0})]}),children:U0&&(d0?z(b90,{node:j0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:j0.kind,showHidden:F,search:V,dsFolders:j0.dsFolders,activeDsName:G,onOpenSystem:k8?K:void 0,onDelete:k8||J?void 0:w,dirtyByPath:j,canvasKinds:x,dirPath:j0.fullPath,drag:!k8&&j0.kind==="canvas"&&!J?e0:void 0,menu:D8}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},j0.label)})}),z(ab,{state:D8.state,onClose:D8.close,rootItems:N8,destinations:C0,onPickDestination:(j0)=>h(w8.path,j0)}),z(UE,{project:f,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(Cw,{syncStatus:r,onLinkedHub:z0,onLocalProject:i,onOpenFile:q0,filesReady:Z0}):null,z(jw,{})]})}function cF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(k9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(k9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(k9,{name:"folder",size:15})})]})})}function iF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",qT]}),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:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("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.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("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."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("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"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var KT=[{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 oF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z($J,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function nF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=KT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z($J,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:KT.map((Y)=>D("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)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(oF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z($J,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",KT.length," groups"]})]})]})})}var rF0=["File","Edit","View","Selection","Tools","Help"];function y90(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function aF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return y90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(k9,{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($J,{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)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z($J,{children:G.shortcut})]},G.label))]})}function W1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return y90(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},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):D("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:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z($J,{children:Z.shortcut}):null]},Z.id))]})}function sF0({onAction:J,onClose:X}){return z(W1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function tF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(W1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function eF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(W1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function JL0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(W1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{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 XL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(W1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(W1,{label:"Edit",left:90,onAction:J,onClose:X,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 QL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:O,showHidden:E,onToggleShowHidden:w,onOpenHelp:A,onOpenShortcuts:I,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:x,onTogglePresent:h,printGuidesVisible:l,onTogglePrintGuides:v,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:r,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:I0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:e0,onToggleAutoOpenInspector:D8,onOpenLayers:s8,timelineOpen:w8,onToggleTimeline:N8,hasComps:C0=!1,assistantOpen:A0,onToggleAssistant:$0,assistantBusy:Q8,assistantUnseen:Z8,onNewCanvas:f8,onAssembleVideo:b8,onOpenExport:O9,onOpenSettings:h0,onOpenGenerate:C8,onReload:A9,onCloseCanvas:F8,onInsertArtboard:B0,readOnly:J8=!1}){let r0=J===r8,j0=r0?"SYSTEM":J?"CANVAS":"IDLE",t0=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(Q4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),H8=new Set(W?["autoopen"]:["assistant","autoopen"]),p0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:I0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:I0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!e0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:C0?"video":void 0,checked:w8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:A0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:f,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:l,disabled:!J||r0}].filter((_0)=>!J8||!H8.has(_0.id)),d0=["file","edit","view","selection","tools","help"];function k8(_0){if(d0.includes(_0))H(Z===_0?null:_0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let _0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function X8(P8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let o0=U0.indexOf(document.activeElement);if(P8.key==="ArrowDown")P8.preventDefault(),U0[(o0+1)%U0.length].focus();else if(P8.key==="ArrowUp")P8.preventDefault(),U0[(o0-1+U0.length)%U0.length].focus();else if(P8.key==="Home")P8.preventDefault(),U0[0].focus();else if(P8.key==="End")P8.preventDefault(),U0[U0.length-1].focus();else if(P8.key==="ArrowRight"||P8.key==="ArrowLeft"){P8.preventDefault();let R8=P8.key==="ArrowRight"?1:-1,J9=d0.indexOf(Z);H(d0[(J9+R8+d0.length)%d0.length])}else if(P8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",X8),()=>{clearTimeout(_0),window.removeEventListener("keydown",X8)}},[Z,H]),D("header",{className:"st-menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("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"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:rF0.map((_0)=>{let X8=_0.toLowerCase(),P8=d0.includes(X8),U0=P8||X8==="help",o0=Z===X8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${X8}`,"data-tour":X8==="help"?"help":void 0,"aria-haspopup":P8?"menu":void 0,"aria-expanded":P8?o0:void 0,onClick:()=>k8(X8),onMouseEnter:()=>{if(Z!==null&&P8)H(X8)},children:_0},X8)})}),Z==="file"&&z(JL0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(_0)=>{if(_0==="new")f8?.();else if(_0==="assemble")b8?.();else if(_0==="export")O9?.("export");else if(_0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(_0==="handoff")O9?.("handoff");else if(_0==="generate")C8?.();else if(_0==="settings")h0?.();else if(_0==="reload")A9?.();else if(_0==="close")F8?.()},onClose:()=>H(null)}),Z==="edit"&&z(XL0,{readOnly:J8,hasCanvas:!!J&&!r0,onAction:(_0)=>{if(_0==="undo")n({dgn:"undo"});else if(_0==="redo")n({dgn:"redo"});else if(_0==="deselect-all")n({dgn:"selection-clear"});else if(_0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(_0.startsWith("new-artboard:"))B0?.(_0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(aF0,{panels:p0,onToggle:(_0)=>{if(_0==="tree")O();else if(_0==="changes")N();else if(_0==="comments")U();else if(_0==="hidden")w();else if(_0==="annotate")j();else if(_0==="inspector")s0();else if(_0==="autoopen")D8?.();else if(_0==="timeline")N8?.();else if(_0==="assistant")$0?.();else if(_0==="layers")s8?.();else if(_0==="minimap")m?.();else if(_0==="zoomctl")a?.();else if(_0==="present")h?.();else if(_0==="print-guides")v?.()},onZoom:(_0)=>n({dgn:"zoom",op:_0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(tF0,{readOnly:J8,onAction:(_0)=>{if(_0==="deselect-all")n({dgn:"selection-clear"});else if(_0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(eF0,{readOnly:J8,onAction:(_0)=>n({dgn:"tool-set",tool:_0}),onClose:()=>H(null)}),Z==="help"&&z(sF0,{onAction:(_0)=>{if(_0==="shortcuts")I?.();else if(_0==="help")A?.();else if(_0==="report-bug")T?.();else if(_0==="tour")R?.();else if(_0==="collab-tour")$?.();else if(_0==="quick-setup")H0?.();else if(_0==="readiness")s?.();else if(_0==="whatsnew")e?.();else if(_0==="watch-intro")r?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":A0?"true":"false","data-busy":Q8?"true":"false","data-unseen":Z8?"true":"false","aria-label":`Assistant${Q8?" — working":Z8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:$0,children:z(k9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(k9,{name:"share",size:15})}),i&&z(Pm,{center:i}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:T,children:z(k9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(k9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:j0}),z("span",{className:"st-mb-file",title:J||"",children:t0}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function YL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:O,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let A=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of A.current)if(!I.has(C.path))A.current.delete($);let T=($)=>{let C=IZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=A.current.get(j);if(!f)f={path:$,src:IZ($,H)},A.current.set(j,f);return f.src},R=V&&V.path===X?"error":X&&X!==r8&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${fV(Q4(E))}`,tabIndex:0,children:z(jg,{path:E,kind:AL(Q4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("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"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",qT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("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($J,{children:"⌘"})," and hover to preview an element, click to select it — ",z($J,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{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]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:O,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(VL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:T($.path),title:`Canvas: ${$.path}`,className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("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%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:fV(Q4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var WL0=["color","space","radius","shadow","leading","weight","motion","font","other"],GL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function ZL0(J){return J==="color"}function HL0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("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=X||{},W=Array.from(new Set([...WL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=ZL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",GL0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function zL0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function KL0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function UL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=KL0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=zL0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("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 VL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(O)=>Y&&Y(O.target.value),children:B.map((O)=>z("option",{value:O.name,children:O.name},O.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(HL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(UL0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(B90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(B90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function B90({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:IZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function qL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:O,version:E}){let w=J===r8,A=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",T=W==="dark"?"light":"dark",R=(()=>{let C=nz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{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})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("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:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("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:I,children:A}),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:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),O&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:O,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("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&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function BL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=S90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let O=J[M]||[],E=O.filter((A)=>{if(X==="open")return A.status!=="resolved";if(X==="resolved")return A.status==="resolved";return!0});if(E.length===0)continue;let w=O.filter((A)=>A.selector);F.push({file:M,comments:E.map((A)=>({...A,n:w.findIndex((I)=>I.id===A.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z($J,{children:"⌘"})," and click an element, then press ",z($J,{children:"C"})," — or hold ",z($J,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:X4(Q4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((O)=>D("div",{"data-testid":`comment-item-${O.id}`,className:"st-comment"+(O.status==="resolved"?" is-resolved":"")+(O.id===W?" is-active":""),onClick:()=>G(M.file,O.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:O.n||"·"}),z("span",{className:"st-comment-time",children:RF0(O.created)})]}),z("div",{className:"st-comment-txt",children:O.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(O.dom_path||[]).join(" > "),children:O.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[O.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(O.id)},children:z(k9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(O.id)},children:z(k9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(O.id)},children:z(k9,{name:"x",size:14})})]}):null]})]},O.id))]},M.file))})]})}var NL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function FL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=NL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function LL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),wh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function DL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`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",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var ML0=["block","inline-block","flex","inline-flex","grid","inline","none"],N90=["px","%","fr","em","auto","min-content","max-content"];var OL0=["auto","stretch","flex-start","center","flex-end","baseline"];var F90=["300","400","500","600","700","800"],Lq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,L90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],D90=["none","solid","dashed","dotted","double"],M90=["px","rem","em","%","vw","vh","auto"],O90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),UT={"font-size":{node:z(K7,{as:hV,size:12})},"line-height":{node:z(K7,{as:cV,size:12})},"letter-spacing":{node:z(K7,{as:J3,size:12})},gap:{node:z(K7,{as:TK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:G3,size:12})},"border-width":{node:z(K7,{as:eV,size:12})}};var A90=["static","relative","absolute","fixed","sticky"],AL0=["normal","italic","oblique"],_90=["none","uppercase","lowercase","capitalize"];var w90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],_L0=["fill","contain","cover","none","scale-down"];var E90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],S5={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}},X1=null;function OL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!X1)X1=document.createElement("canvas").getContext("2d");if(!X1)return"";X1.fillStyle="#000000",X1.fillStyle=J;let X=X1.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.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=(J)=>Math.min(1,Math.max(0,J));function qL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Dq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Mq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function Q1({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function J4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function I90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function j90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function wL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),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 v90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...wL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function f90({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>Mq(qL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(Mq(qL(J)))},[J]);let U=Dq(Q1(Y)),V=(A)=>{A.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let T=G.current.h,R=(C)=>{W({h:T,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(A);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Dq(Q1(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(A)=>{A.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:T,v:R})};$(A);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Dq(Q1(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(A)=>{let I={...G.current,...A};W(I),Q(Dq(Q1(I)))},F=(A)=>{let I=A.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[A.key];if(!R)return;A.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(A)=>{let I=A.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[A.key];if(R==null)return;A.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},O=async()=>{try{let A=window.EyeDropper;if(!A)return;let I=await new A().open();if(I?.sRGBHex)W(Mq(qL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=Q1(Y),w=(A)=>{let I={...E,...A},T=Mq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(T),Q(Dq(Q1(T)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(A)=>{let I=A.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(Mq(qL(I)))},onKeyDown:(A)=>{if(A.key==="Enter")Q(A.currentTarget.value)},onBlur:(A)=>Q(A.currentTarget.value),onFocus:(A)=>A.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("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:O,children:z(k9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} 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((A)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":A.toUpperCase(),value:Math.round(E[A]),onChange:(I)=>w({[A]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:A.toUpperCase()})]},A))})]})}function FL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[O,E]=u.useState(""),w=u.useRef(null),A=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,s)=>e+(s.names?.length||0),0),j=$.length>1,f=O.trim().toLowerCase(),m=!f?$:$.map((e)=>({...e,names:(e.names||[]).filter((s)=>R(s).toLowerCase().includes(f)||s.toLowerCase().includes(f)||(e.vals?.[s]||"").toLowerCase().includes(f))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let i=224,q0=300,Z0=Math.min(z0.right-i,window.innerWidth-i-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(A.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},H0=(z0)=>{if(z0.key==="Escape")V(!1)},r=(z0)=>{if(A.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!A.current)return;let e=A.current.getBoundingClientRect(),s=B.left-e.left,H0=B.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)N((r)=>r?{...r,left:r.left+s,top:r.top+H0}:r)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,s,H0)=>{if(H&&e&&e!==H&&H0&&!d.test(H0))Y(H0);else Y(`var(${s})`);V(!1)},x=(e)=>{let s=(e||"").trim();if(s)Y(s)},h=D("div",{className:"st-cp-pop-search",children:[z(k9,{name:"search",size:12}),z("input",{value:O,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(H0)?" is-on":""}`,onClick:()=>a(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:s.vals?.[H0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),v=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row${T(H0)?" is-on":""}`,onClick:()=>a(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),n=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?T90.createPortal(z("div",{ref:A,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:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(f90,{seed:Z||OL(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?l(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):n]})}),document.body):null]})}function k90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?jU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=jU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:N90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(oN,{value:K.unit,units:N90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}var Y1={pending:0,waiters:[]};function x90(J){Y1.pending+=1;let X=()=>{if(Y1.pending-=1,Y1.pending===0)for(let Q of Y1.waiters.splice(0))Q()};return J.then(X,X),J}function EL0(){return Y1.pending===0?Promise.resolve():new Promise((J)=>Y1.waiters.push(J))}function PL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let E0={...t||{}};for(let[v0,W8]of Object.entries(M0))if(W8===null)delete E0[v0];else E0[v0]=W8;return E0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),O=N(J.attrs,V.t),E=(t,M0)=>B((E0)=>({...E0,a:{...E0.a,[t]:M0}})),w=(t,M0)=>B((E0)=>({...E0,c:{...E0.c,[t]:M0}})),A=(t,M0)=>B((E0)=>({...E0,t:{...E0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=j90(J.file,X),R=v90(X,I,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[f,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(O).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let x=H,[h,l]=u.useState({});async function v(t,M0,E0){j((v0)=>({...v0,[E0]:"saving"}));try{let v0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),W8=await v0.json().catch(()=>({}));return j((g8)=>({...g8,[E0]:!v0.ok||!W8.ok?`err:${W8&&W8.error||`HTTP ${v0.status}`}`:"saved"})),v0.ok?W8:null}catch(v0){return j((W8)=>({...W8,[E0]:`err:${v0&&v0.message?v0.message:String(v0)}`})),null}}let n=u.useRef(Promise.resolve()),e=(t,M0,E0,v0,W8,g8,t8)=>{n.current=x90(n.current.then(async()=>{let v8=await v(t,M0,E0);if(!v8?.ok)return;let W9=Object.hasOwn(v8,"previous")?v8.previous:g8;if((W9??null)===(t8??null))return;H0(v0,W8,W9,t8)}))},s=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},H0=(t,M0,E0,v0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:E0==null||E0===""?null:E0,after:v0==null||v0===""?null:v0})},r=(t,M0)=>{let E0=(M0||"").trim();if(!K||!E0)return;let v0=F[t]??null;if(E0===(v0??"").trim())return;s(t,E0),E(t,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:E0},t,"css",t,v0,E0)},z0=(t,M0)=>{let E0=(M0||"").trim(),v0=t.trim();if(!K||!v0||!E0)return;let W8=M[v0]??null;s(v0,E0),w(v0,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:v0,value:E0},v0,"css",v0,W8,E0)},i=(t,M0)=>{let E0=(t||"").trim(),v0=(M0||"").trim();if(!K||!E0||!v0)return;let W8=O[E0]??null;A(E0,v0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:E0,value:v0},`@${E0}`,"attr",E0,W8,v0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;s(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;s(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},I0=(t)=>{if(!K)return;let M0=O[t]??null;A(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let E0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),v0=ub(t,M0,a0,E0);for(let W8 of v0.reset)if(F[W8])q0(W8);for(let[W8,g8]of v0.set)r(W8,g8)},e0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",D8=(t)=>{let M0=mb(t,F,U,a0);return D("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(nN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(E0)=>s0(t,E0)})})]},`mode-${t}`)},s8=["flex-start","center","flex-end"],w8=["flex-start","center","flex-end"],N8=["t","c","b"],C0=["l","c","r"],A0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,s8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),E0=F["align-items"]||U7(U["align-items"])||"stretch",v0=E0==="stretch"?1:Math.max(0,w8.indexOf(E0)),[W8,g8]=t?[M0,v0]:[v0,M0];return N8[g8]+C0[W8]},$0=(t)=>{let M0=N8.indexOf(t[0]),E0=C0.indexOf(t[1]),v0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[W8,g8]=v0?[E0,M0]:[M0,E0];r("justify-content",s8[W8]),r("align-items",w8[g8])},Q8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},Z8=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let f8={bound:"token-bound",raw:"raw override",inherit:"inherited"},b8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":f8[t]}),O9=(t,M0)=>{let E0=M0??Z8(t),v0=C[t],W8=typeof v0==="string"&&v0.startsWith("err:")?v0.slice(4):"",g8=W8?" is-err":v0==="saved"?" is-saved":v0==="saving"?" is-saving":"",t8=!!F[t],v8=W8?`error: ${W8}`:t8?`${f8[E0]} · double-click to reset`:f8[E0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${E0}${g8}${t8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:t8?0:-1,onDoubleClick:t8?()=>q0(t):void 0,onKeyDown:t8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},h0=(t,M0,E0,v0)=>{let W8=E0===void 0&&!F[t],g8=v0??t;return D("div",{className:`st-cp-row${W8?" is-unset":""}`,children:[O9(t,E0),z("label",{className:"st-cp-label",title:g8,children:g8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},C8={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"]},A9=(t)=>{(C8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},F8=(t,M0)=>{let E0=(C8[t]||[]).some((v0)=>F[v0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!f[t],onClick:()=>m((v0)=>({...v0,[t]:!v0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${E0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!E0,onClick:()=>A9(t),children:z(K7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},B0=(t,M0,E0,v0=!0)=>{let W8=`d:${t}`,g8=f[W8]===void 0?v0:f[W8],t8=M0.some((v8)=>F[v8]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":g8,onClick:()=>m((v8)=>({...v8,[W8]:!g8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:g8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${t8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!t8,onClick:()=>M0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(K7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${g8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:E0})})]},W8)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>l((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(E0)=>r(t,E0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((E0)=>z("option",{value:E0,children:E0},E0))]}),j0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((E0)=>({name:E0,value:M0.vals?.[E0]||""}))),t0=(t,M0)=>z(dw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(E0)=>r(t,E0)}),H8=(t,M0,E0={})=>{let v0=J4(F[t]??""),W8=O90.has(t),g8=F[t]??"",t8=typeof g8==="string"&&/var\(\s*--/.test(g8),v8=W8?"":v0.unit&&v0.unit!=="auto"?v0.unit:"px",W9=Number.parseFloat(J4(U7(U[t])??"").n)||0,T9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:W9,e9=UT[t];return z(rN,{value:t8?g8:T9,tokens:j0(M0),ariaLabel:t,min:E0.min??0,lead:e9?e9.node??e9.t:void 0,unitSlot:W8?null:z(oN,{units:M90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>r(t,J7==="auto"?"auto":`${v0.n||"0"}${J7}`)}),onChange:(J7)=>r(t,typeof J7==="string"?J7:W8?`${J7}`:`${J7}${v8}`)})},p0=()=>{let t=(W8)=>Number.parseFloat(J4(F[W8]??F["border-radius"]??U7(U[W8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},E0=(W8)=>{if(W8.tl===W8.tr&&W8.tr===W8.bl&&W8.bl===W8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((t8)=>{if(F[t8])q0(t8)}),r("border-radius",`${W8.tl}px`);else r("border-top-left-radius",`${W8.tl}px`),r("border-top-right-radius",`${W8.tr}px`),r("border-bottom-left-radius",`${W8.bl}px`),r("border-bottom-right-radius",`${W8.br}px`)},v0=UT["border-radius"];return z(dg,{corners:M0,lead:v0?v0.node??v0.t:void 0,onCorners:E0})},d0=()=>D("div",{className:"st-cp-border",children:[X9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:D90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>r("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),D90.map((t)=>z("option",{value:t,children:t},t))]}),z(FL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:OL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>r("border-color",t),label:"border colour"})]}),k8=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),E0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,v0=(W8)=>{let g8=(W8%360+360)%360,t8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();r("transform",`${t8?`${t8} `:""}rotate(${g8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(pg,{value:E0,onChange:v0}),z(zJ,{value:E0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:rZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:v0})]})},_0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),E0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:E0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(W8)=>{let g8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();r("filter",W8>0?`${g8?`${g8} `:""}blur(${W8}px)`.trim():g8||"none")}})},X8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,E0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(uX,{value:E0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(v0)=>s("opacity",String(v0/100)),onCommit:(v0)=>r("opacity",String(v0/100))},`opacity:${t??""}`)},P8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",E0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(mg,{value:{b:t,i:M0,u:E0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:iV}),label:"Bold"},{value:"i",node:z(K7,{as:sV}),label:"Italic"},{value:"u",node:z(K7,{as:z3}),label:"Underline"}],onToggle:(v0)=>{if(v0==="b")r("font-weight",t?"400":"700");else if(v0==="i")r("font-style",M0?"normal":"italic");else r("text-decoration",E0?"none":"underline")}})},U0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:uV}),label:"Start"},{value:"center",node:z(K7,{as:gV}),label:"Center"},{value:"flex-end",node:z(K7,{as:mV}),label:"End"},{value:"space-between",node:z(K7,{as:TK}),label:"Space between"}],R8=[{value:"flex-start",node:z(K7,{as:dV}),label:"Start"},{value:"center",node:z(K7,{as:pV}),label:"Center"},{value:"flex-end",node:z(K7,{as:lV}),label:"End"},{value:"stretch",node:z(K7,{as:Z3}),label:"Stretch"}],J9=[{value:"left",node:z(K7,{as:a5}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],i0=[{value:"visible",node:z(K7,{as:nZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:aZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:Y3}),label:"Scroll"}],a7=(t,M0)=>{let E0=$(M0);return E0.length?z(FL,{kind:"value",groups:E0,current:F[t],activeDs:T,onPick:(v0)=>r(t,v0),label:`${t} design token`}):null},F9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let E0=t.shiftKey?10:1,v0=t.key==="ArrowUp"?1:-1,W8=(Number.parseFloat(t.currentTarget.value)||0)+v0*E0;return t.currentTarget.value=String(W8),M0(W8),!0},I8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>r(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),X9=(t,M0,E0={})=>{let v0=J4(F[t]??""),W8=O90.has(t),g8=W8?"":E0.fixedUnit||(v0.unit&&v0.unit!=="auto"?v0.unit:"px"),t8=UT[t],v8=Number.parseFloat(J4(U7(U[t])??"").n)||0,W9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:v8;return D(Q0,{children:[z(zJ,{value:W9,min:E0.min??0,step:1,ariaLabel:t,lead:t8?t8.node??t8.t:void 0,onCommit:(T9)=>r(t,W8?`${T9}`:`${T9}${g8}`),unitSlot:W8||E0.fixedUnit?null:z(oN,{units:M90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(T9)=>r(t,T9==="auto"?"auto":`${v0.n||"0"}${T9}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},d8=(t)=>{let M0=U[t]||F[t]||"",E0=F[t]??"",v0=typeof E0==="string"&&/var\(\s*--/.test(E0),W8=v0?E0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):E0;return z(U3,{swatch:z(FL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:OL(U[t]||F[t])||"#000000",onPick:(g8)=>r(t,g8),label:`${t} colour`}),displayValue:W8,bound:v0,ariaLabel:t,onValue:(g8)=>r(t,g8)})},O0=(t,M0)=>{let E0=null,v0=M0.unitless?"":"px",W8=(v8)=>M0.unitless?`${v8}`:`${v8}${v0}`,g8=(v8,W9,T9)=>{for(let e9 of W9??[t])T9(e9,W8(v8))},t8=lw({getBase:()=>E0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(v8,W9)=>{if(E0)E0.value=String(v8);if(W9){let T9=E0?.closest(".st-cp-box");for(let e9 of W9){if(e9===t)continue;let J7=T9?.querySelector(`.st-cp-boxv[aria-label="${e9}"]`);if(J7)J7.value=String(v8)}}g8(v8,W9,s)},onCommit:(v8,W9)=>g8(v8,W9,r)});return{onPointerDown:(v8)=>{E0=v8.currentTarget,t8(v8)}}},K8=(t,M0)=>{let E0=F[t],v0=E0!=null&&E0!==""?J4(E0).n||E0:J4(U7(U[t])??"").n||"0",W8=!E0||E0==="0"||E0==="0px"||E0==="auto",g8=t.split("-").pop(),t8=g8==="top"||g8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],v8=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${W8?" is-zero":""}`,"aria-label":t,defaultValue:v0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:t8,all:v8}}),onFocus:F9,onKeyDown:(W9)=>{if(v7(W9,(T9)=>r(t,`${T9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let T9=W9.currentTarget.value.trim();if(!T9)return;let e9=/[a-z%]/i.test(T9)?T9:`${T9}px`;r(t,e9)}},`${t}:${E0??""}`)},S8=(t)=>{let M0=F[t],E0=M0!=null&&M0!==""&&M0!=="auto"?J4(M0).n||M0:J4(U7(U[t])??"").n||"",v0=!M0||M0==="auto"||M0==="0"||M0==="0px",W8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],g8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${v0?" is-zero":""}`,"aria-label":t,defaultValue:E0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:W8,all:g8},min:-1/0}),onFocus:F9,onKeyDown:(t8)=>{if(v7(t8,(v8)=>r(t,`${v8}px`)))return;if(t8.key==="Enter")t8.currentTarget.blur()},onBlur:(t8)=>{let v8=t8.currentTarget.value.trim();if(!v8)return;let W9=/[a-z%]/i.test(v8)?v8:`${v8}px`;r(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),x9=Object.entries(O),i9=()=>{let t=(J.tag||"").toLowerCase(),E0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],v0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:E0,canReplace:v0}},h9=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),h0("object-fit",r0("object-fit",_L0)),h0("object-position",I8("object-position")),h0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:P90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let E0=M0.target.value;if(r("aspect-ratio",E0),E0&&E0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),P90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Q8,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(dw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?D(Q0,{children:[B0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[h0("flex-direction",t0("flex-direction",U0),void 0,"Direction"),h0("align-items",z(ug,{value:A0(),onChange:$0,ariaLabel:"auto-layout alignment"}),Z8("align-items"),"Alignment"),h0("gap",H8("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[D8("width"),D8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[b8(Z8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>r("flex-wrap",E0?"wrap":"nowrap")}),Z8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[h0("width",X9("width"),void 0,"Width"),h0("height",X9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[h0("min-width",X9("min-width"),void 0,"Min width"),h0("max-width",X9("max-width"),void 0,"Max width"),h0("min-height",X9("min-height"),void 0,"Min height"),h0("max-height",X9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[h0("position",r0("position",A90),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[b8(Z8("top")),"inset"]}),S8("top"),S8("right"),S8("bottom"),S8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?h0("z-index",X9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],h0("background-color",d8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],h0("border",d0(),Z8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],h0("border-radius",p0(),Z8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[h0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow"),void 0,"Shadow"),h0("filter",_0(),Z8("filter"),"Blur"),h0("mix-blend-mode",r0("mix-blend-mode",E90),void 0,"Blend")]})),B0("Opacity",["opacity"],h0("opacity",X8(),void 0,"Opacity")),B0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[h0("font-family",r0("font-family",L90),void 0,"Font"),h0("color",d8("color"),void 0,"Color"),h0("font-size",H8("font-size","type"),void 0,"Size"),h0("font-weight",r0("font-weight",F90),void 0,"Weight"),h0("line-height",X9("line-height","lh"),void 0,"Line height"),h0("text-align",t0("text-align",J9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[h0("letter-spacing",X9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),h0("font-style",r0("font-style",AL0),void 0,"Style"),h0("text-transform",r0("text-transform",_90),void 0,"Case"),h0("white-space",r0("white-space",w90),void 0,"Whitespace")]}):null]})),B0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[b8(Z8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],h9(M0)):null})()]}):D(Q0,{children:[F8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",E0=t==="grid"||t==="inline-grid";return D(Q0,{children:[h0("display",r0("display",ML0)),M0?D(Q0,{children:[h0("flex-direction",t0("flex-direction",U0)),h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(v0)=>r("flex-wrap",v0?"wrap":"nowrap")}),Z8("flex-wrap"))]}):null,M0||E0?D(Q0,{children:[h0("align-items",t0("align-items",R8)),h0("justify-content",t0("justify-content",o0)),h0("gap",H8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let E0=F["grid-template-columns"]||"",v0=F["grid-template-rows"]||"",W8=$O(E0),g8=$O(v0),t8=W8.length>0||!E0.trim(),v8=g8.length>0||!v0.trim();return F8("Grid",D(Q0,{children:[t8?z(k90,{label:"Columns",tracks:W8,editable:K,onChange:(W9)=>r("grid-template-columns",SO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:E0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(k90,{label:"Rows",tracks:g8,editable:K,onChange:(W9)=>r("grid-template-rows",SO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:v0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),F8("Position",D(Q0,{children:[h0("position",r0("position",A90)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[b8(Z8("top")),"inset"]}),S8("top"),S8("right"),S8("bottom"),S8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,h0("z-index",X9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&F8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),h0("grid-column",I8("grid-column")),h0("grid-row",I8("grid-row"))]})),F8("Typography",D(Q0,{children:[h0("font-family",r0("font-family",L90)),h0("color",d8("color")),h0("font-size",H8("font-size","type")),h0("font-weight",r0("font-weight",F90)),h0("line-height",X9("line-height","lh")),h0("letter-spacing",X9("letter-spacing",null,{min:-1/0})),h0("text-align",t0("text-align",J9)),h0("font-style",P8(),Z8("font-style")),h0("text-transform",r0("text-transform",_90)),h0("white-space",r0("white-space",w90))]})),F8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[b8(Z8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[b8(Z8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),F8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[D8("width"),D8("height")]}),h0("width",X9("width")),h0("height",X9("height")),h0("min-width",X9("min-width")),h0("max-width",X9("max-width")),h0("min-height",X9("min-height")),h0("max-height",X9("max-height")),h0("overflow",t0("overflow",i0)),e0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),h0("align-self",r0("align-self",OL0)),h0("flex-grow",X9("flex-grow",null,{unitless:!0})),h0("flex-shrink",X9("flex-shrink",null,{unitless:!0})),h0("flex-basis",X9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?F8("Media",h9(M0)):null})(),F8("Appearance",D(Q0,{children:[h0("background-color",d8("background-color")),h0("border-radius",p0(),Z8("border-radius")),h0("border",d0(),Z8("border-width")),h0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow")),h0("filter",_0(),Z8("filter")),h0("mix-blend-mode",r0("mix-blend-mode",E90)),h0("opacity",X8()),h0("rotation",k8(),Z8("transform")),h0("transform",I8("transform")),h0("transform-origin",I8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(k9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),F8("Advanced",D("div",{className:"st-cp-advbody",children:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("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:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>z0(t,E0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(k9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(IL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x9.map(([t,M0])=>D("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:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>i(t,E0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>I0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(kL0,{commit:i})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function IL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,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 kL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,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 TL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function RL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var CL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function h90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:O,onRename:E}){let w=`${J.id}:${J.index}`,A=J.children&&J.children.length>0,I=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=u.useState(!1),[f,m]=u.useState(""),d=!T&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,x=!!V&&!T&&!$,h=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},l=N?.key===w,v=l?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":T?void 0:d,"aria-expanded":A?!I:void 0,"aria-grabbed":x?l:void 0,tabIndex:0,title:T?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>T?A&&Z(w):H(J),onMouseEnter:()=>!T&&K(J),onMouseLeave:()=>K(null),onPointerDown:x?(n)=>B(n,J,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),T)A&&Z(w);else H(J);else if(n.key==="F2"&&E&&!T)n.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[A?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:TL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>m(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:h,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")h();else if(n.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(n)=>{n.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),O&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),O(w)},children:z(k9,{name:$?"lock":"unlock",size:12})}):null,U&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(J)},children:z(k9,{name:a?"eye-off":"eye",size:13})}):null]}),A&&!I?J.children.map((n,e)=>z(h90,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:O,onRename:E},`${n.id}:${n.index}`)):null]})}function $L0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("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)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?J4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("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?D("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 g90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var SL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],bL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function yL0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=g90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=j90(J.file,X),B=v90(X,U,V),N=(v)=>B.map((n)=>({ds:n.name,names:n[v]||[],vals:n.vals})).filter((n)=>n.names.length),F=(v)=>N(v).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(v)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!n)return v||"";for(let e of B){let s=e.vals?.[n[1]];if(s)return s}return""},O=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,n)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,s=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},A=Object.entries(S5).find(([,v])=>v.width===O&&v.height===E)?.[0],I=Object.entries(S5).find(([,v])=>v.width===O)?.[0],T=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",f=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let n=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=QB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,n),v==="web"&&T)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let n={paper:"a4",...m,...v},e;try{e=QB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},x=(v,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let n=xb(T,v);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")x(!0,n.height)},l=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:O??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),XB.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${S5[I].label} — ≤ ${S5[I].width}px`:"Breakpoint…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ≤ ",n.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:A??"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:A?S5[A].label:"Preset size…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"×",n.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(nN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:f,ariaLabel:"artboard kind",options:bL0.map(([v,n])=>({value:v,label:n})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)H(K,n.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"px"]},v))]})}):null,f==="print"?D(Q0,{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(nN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{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:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(U3,{swatch:z(FL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:OL(v)||"#000000",onPick:(s)=>l({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>l({background:(s||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:SL0.map(([v,n])=>({value:v,label:n})),onChange:(v)=>l({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(rN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>l({padding:typeof v==="string"?v:v>0?v:null})}),z(rN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>l({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var BT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,jL0=new RegExp(BT.source,"gi");function vL0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(jL0)||[])],G=[...new Set([...X.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(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=BT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function fL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:O,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:A,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:d,resizing:a,photoSel:x,photoRev:h,onPhotoEdit:l,onPhotoRemoveBackground:v,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:r,onSetCpMode:z0}){let[i,q0]=u.useState("inspect"),Z0=s?"layers":f??i,I0=(p0)=>{q0(p0),m?.(p0)},[a0,s0]=u.useState(()=>new Set),[e0,D8]=u.useState(()=>new Map);u.useEffect(()=>{let p0=Array.isArray(X)?X[0]:X,d0=p0?.id;if(!d0||!Y?.nodes)return;let k8=p0.index,_0=null,X8=[];if(function P8(U0,o0){for(let R8 of U0||[]){let J9=`${R8.id}:${R8.index}`;if(!R8.synthetic&&R8.id===d0&&(k8==null||R8.index===k8))return _0=J9,X8.push(...o0),!0;if(R8.children&&R8.children.length&&P8(R8.children,[...o0,J9]))return!0}return!1}(Y.nodes,[]),!_0)return;if(X8.length)s0((P8)=>{let U0=!1,o0=new Set(P8);for(let R8 of X8)if(o0.delete(R8))U0=!0;return U0?o0:P8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${_0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let s8=(p0)=>{let d0=`${p0.id}:${p0.index}`;return e0.has(d0)?e0.get(d0):!!p0.hidden},[w8,N8]=u.useState(null),[C0,A0]=u.useState(""),$0=(p0,d0)=>{if(!K||!p0?.id)return;x90(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:p0.id,attr:"data-dc-element",value:d0})}).then((k8)=>k8.json().catch(()=>({}))).then((k8)=>{if(!k8.ok)return;O?.({op:"attr",canvas:K,id:p0.id,key:"data-dc-element",before:p0.dcElement??null,after:d0})}).catch(()=>{}))},Q8=B?(p0,d0,k8)=>{if(N?.current)return;if(p0?.synthetic||d0?.synthetic)return;let _0=k8==="before"?`before ${d0.label}`:k8==="after"?`after ${d0.label}`:`into ${d0.label}`;A0(`Moved ${p0.label} ${_0}`),B(p0.id,d0.id,k8,{idIndex:p0.index,refIndex:d0.index})}:void 0,Z8=()=>{let p0=[];return function d0(k8,_0,X8){(k8||[]).forEach((P8,U0)=>{if(p0.push({node:P8,depth:_0,parentNode:X8,siblings:k8,pos:U0}),P8.children&&P8.children.length&&!a0.has(`${P8.id}:${P8.index}`))d0(P8.children,_0+1,P8)})}(Y?.nodes,0,null),p0},f8=(p0)=>{if(p0.key!=="ArrowUp"&&p0.key!=="ArrowDown")return;if(!F8)return;let d0=Z8(),k8=d0.findIndex((U0)=>U0.node.id===F8.id&&U0.node.index===F8.index);if(k8<0)return;let _0=p0.key==="ArrowDown"?1:-1,X8=d0[k8];if(!p0.altKey){let U0=d0[k8+_0];if(U0)p0.preventDefault(),U?.(U0.node);return}if(!Q8||!Array.isArray(X8.siblings))return;p0.preventDefault();let P8=(U0)=>U0&&U0.children&&U0.children.length&&!a0.has(`${U0.id}:${U0.index}`);if(!p0.shiftKey){if(_0<0&&X8.pos>0)Q8(X8.node,X8.siblings[X8.pos-1],"before");else if(_0>0&&X8.pos<X8.siblings.length-1)Q8(X8.node,X8.siblings[X8.pos+1],"after");return}if(_0>0){let U0=X8.siblings[X8.pos+1];if(U0)Q8(X8.node,U0,P8(U0)?"inside-start":"after");else if(X8.parentNode)Q8(X8.node,X8.parentNode,"after")}else{let U0=X8.siblings[X8.pos-1];if(U0)Q8(X8.node,U0,P8(U0)?"inside-end":"before");else if(X8.parentNode)Q8(X8.node,X8.parentNode,"before")}},b8=u.useRef(null),O9=u.useRef(null),h0=(p0,d0,k8)=>{if(!Q8||p0.button!==0||p0.metaKey||p0.ctrlKey||p0.shiftKey||p0.altKey)return;if(N?.current)return;let{clientX:_0,clientY:X8}=p0,P8=new Set([k8]);(function d8(O0){(O0.children||[]).forEach((K8)=>{P8.add(`${K8.id}:${K8.index}`),d8(K8)})})(d0);let U0=14,o0=6,R8=[];(function d8(O0,K8){(O0||[]).forEach((S8)=>{let V9=`${S8.id}:${S8.index}`;if(R8.push({node:S8,key:V9,id:S8.id,depth:K8,tag:S8.tag}),S8.children&&S8.children.length&&!a0.has(V9))d8(S8.children,K8+1)})})(Y?.nodes,0);let J9=new Map(R8.map((d8)=>[d8.key,d8])),i0=!1,a7=(d8)=>{if(!i0){if(Math.hypot(d8.clientX-_0,d8.clientY-X8)<4)return;i0=!0}let O0=d8.clientX-_0,K8=d8.clientY-X8,S8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i9)=>({rect:i9.getBoundingClientRect(),it:J9.get(i9.getAttribute("data-layer-key"))})).filter((i9)=>i9.it&&i9.it.key!==k8);if(V9.length){let i9=V9[0].rect.left,h9=V9[0].rect.right,t=V9.length;for(let e9=0;e9<V9.length;e9++)if(d8.clientY<V9[e9].rect.top+V9[e9].rect.height/2){t=e9;break}let M0=V9[t-1]?.it||null,E0=V9[t]?.it||null,v0=Math.round((d8.clientX-i9-o0)/U0),W8=M0?M0.depth+(CL0.has(M0.tag)?0:1):0,g8=E0?E0.depth:0,t8=Math.max(g8,Math.min(v0,W8)),v8=null,W9="before",T9=0;if(!M0){if(E0)v8=E0,W9="before",T9=E0.depth}else if(t8>M0.depth)v8=M0,W9="inside-start",T9=M0.depth+1;else if(t8===M0.depth)v8=M0,W9="after",T9=M0.depth;else{for(let e9=t-1;e9>=0;e9--)if(V9[e9].it.depth===t8){v8=V9[e9].it;break}if(!v8)v8=M0;W9="after",T9=t8}if(v8&&v8.key!==k8&&!P8.has(v8.key)){let e9=M0?V9[t-1].rect.bottom:V9[0].rect.top,J7=i9+o0+T9*U0;S8={refId:v8.id,position:W9,node:v8.node,y:e9,left:J7,w:Math.max(24,h9-J7)}}}let x9={key:k8,node:d0,dx:O0,dy:K8,target:S8};b8.current=x9,N8(x9)},F9=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I8),window.removeEventListener("keydown",X9,!0)},v7=()=>{let d8=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",d8,!0)};document.addEventListener("click",d8,!0),setTimeout(()=>document.removeEventListener("click",d8,!0),300)},I8=()=>{F9();let d8=b8.current;if(b8.current=null,N8(null),i0&&d8?.target)v7(),Q8(d8.node,d8.target.node,d8.target.position)},X9=(d8)=>{if(d8.key!=="Escape")return;if(d8.preventDefault(),d8.stopImmediatePropagation(),F9(),b8.current=null,N8(null),i0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I8),window.addEventListener("keydown",X9,!0)},C8=(p0)=>s0((d0)=>{let k8=new Set(d0);if(k8.has(p0))k8.delete(p0);else k8.add(p0);return k8}),A9=(p0)=>{let d0=`${p0.id}:${p0.index}`,k8=s8(p0),_0=!k8;if(D8((X8)=>new Map(X8).set(d0,_0)),M?.({id:p0.id,artboardId:Y?.artboardId??null,index:p0.index,prop:"display",value:_0?"none":null}),!K||!p0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0?{canvas:K,id:p0.id,property:"display",value:"none"}:{canvas:K,id:p0.id,property:"display",reset:!0})}).catch(()=>{}),O?.({op:"css",canvas:K,id:p0.id,key:"display",before:k8?"none":null,after:_0?"none":null})},F8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let p0=vL0(F8);return p0?{asset:p0,kind:"artboard-img"}:null})(),J8=B0?.kind==="annotation-image",r0=(p0)=>{if(!(p0.metaKey||p0.ctrlKey)||p0.altKey)return;let d0=p0.key.toLowerCase();if(d0==="z")p0.preventDefault(),e?.(p0.shiftKey?"redo":"undo");else if(d0==="y")p0.preventDefault(),e?.("redo")},j0=J8?"photo":Z0==="photo"&&!B0?"css":Z0,t0=(p0,d0,k8)=>D("button",{type:"button",className:"st-rp-tab"+(j0===p0?" is-active":""),onClick:()=>I0(p0),children:[z(k9,{name:k8,size:14}),d0]}),H8=F8?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[J8?t0("photo","Photo","image"):D(Q0,{children:[t0("inspect","Inspect","sliders"),!H0&&t0("layers","Layers","layers"),t0("css","CSS","code"),B0?t0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(k9,{name:"x",size:14})})]}),F8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.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"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(F8.id,F8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:j0==="photo"&&B0?z("div",{onKeyDown:r0,children:z(Nm,{asset:B0.asset,ColorPicker:f90,StIcon:k9,onEdit:(p0)=>l?.(B0.asset,p0),onRemoveBackground:v,onRecordEdit:(p0,d0)=>n?.(B0.asset,p0,d0)},`${B0.asset}:${h??0}`)}):!F8&&!(j0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z($J,{children:"V"}),", then click an element to select it — or ",z($J,{children:"⌘"}),"-click straight from Browse."]})}):F8&&j0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:F8.selector||F8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:H8?Math.round(H8.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:H8?Math.round(H8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:H8?Math.round(H8.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:H8?Math.round(H8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("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:F8.tag||"—"})})]}),F8.classes?D("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:F8.classes})})]}):null,z($L0,{el:F8})]}):j0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[Q8?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:O9,onKeyDown:f8,children:Y.nodes.map((p0,d0)=>z(h90,{node:p0,depth:0,selectedId:F8?.id,selectedIndex:F8?.index,collapsed:a0,hiddenOverride:e0,onToggle:C8,onSelect:(k8)=>{U?.(k8),O9.current?.focus()},onHover:(k8)=>V?.(k8),onToggleVisibility:A9,onReorder:Q8,onRowPointerDown:h0,dragState:w8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:$0},`${p0.id}:${p0.index}`))}),w8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:w8.target.left,top:w8.target.y-1,width:w8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:C0})]}):F8&&Array.isArray(F8.dom_path)&&F8.dom_path.length?F8.dom_path.map((p0,d0)=>D("div",{className:"st-layer"+(d0===F8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(k9,{name:"square",size:13}),p0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!F8.id&&g90(F8)?z(yL0,{el:F8,cfg:F,onResizeArtboard:w,onSetArtboardHug:A,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(PL0,{el:F8,cfg:F,onOptimistic:M,onRecordEdit:O,onReplaceMedia:E,onUndoRedo:C,mode:r,onSetMode:z0})})]})}function xL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[O,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=O},[O]);let[A,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(O)?O.length===1?O[0]:null:O,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let c=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:c.signal}).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(K0?.ok)I(K0)}).catch(()=>{}),()=>c.abort()},[O,V]);let T=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let c=w.current,X0=Array.isArray(c)?c[0]:c;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let K0=c8.current.get(b.file);if(!K0?.contentWindow)return;try{K0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let c of C.current)clearTimeout(c);C.current=[50,450,1200,2500,5000].map((c)=>setTimeout(()=>{let X0=w.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.artboardId!==b||K0.file!==S)return;let F0=c8.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},c))},[]),f=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,c)=>{let X0=f.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function w0(p){return(p||[]).some((D0)=>D0.id===X0.movedId||w0(D0.children))}(b))return;f.current=null;let F0=V?c8.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:c,index:0},"*")}catch{}};let a=u.useRef(null),x=u.useRef(null),h=u.useRef(null),l=u.useRef(!1),v=u.useRef(null),[n,e]=u.useState(null),[s,H0]=u.useState(null),r=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!n)return;let b=Date.now(),S=r.current;if(S.canvas===V&&b-S.at<1500)return;r.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((c)=>c.json()).then((c)=>{if(c?.ok&&c.map&&typeof c.map==="object")H0(c.map);else H0(null)}).catch(()=>H0(null))},[V,n]);let[z0,i]=u.useState(!1),[q0,Z0]=u.useState(null),[I0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=I0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))UL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let c=(b.blocked??[]).reduce((X0,K0)=>X0+K0.count,0);UL("Sync needs a decision",`${c} file${c===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[I0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=I0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[I0?.files?.progress]);let[e0,D8]=u.useState(null),[s8,w8]=u.useState(null),[N8,C0]=u.useState(null),[A0,$0]=u.useState(null),[Q8,Z8]=u.useState(!1),[f8,b8]=u.useState(!1),[O9,h0]=u.useState(null),[C8,A9]=u.useState(""),[F8,B0]=u.useState(null),[J8,r0]=u.useState(null),j0=u.useRef(null),[t0,H8]=u.useState(null),[p0,d0]=u.useState(0),[k8,_0]=u.useState(null),X8=z90("maude-sb-w",{min:200,max:420,def:252}),P8=z90("maude-rp-w",{min:260,max:480,def:304}),[U0,o0]=u.useState(null),R8=u.useRef(null);u.useEffect(()=>{if(!U0)return;let b=(c)=>{let X0=R8.current?.getBoundingClientRect();if(!X0)return;if(U0==="sb")X8.setW(c.clientX-X0.left);else P8.setW(X0.right-c.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[U0,X8.setW,P8.setW]);let J9=u.useCallback((b)=>{clearTimeout(j0.current),j0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[i0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let c="compile";try{if(!(await fetch(`${i0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)c="server"}catch{c="server"}H8({path:b,kind:c}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J8,i0?.canvasOrigin]);let F9=!!i0.cloud,v7=!i0.cloud&&!!e0?.credentialed,I8=F9||v7,X9=I8?0:N8?.files?.length||0,d8=u.useRef(I8);d8.current=I8;let O0=!!i0.readOnly,K8=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((c)=>({...c,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K8()},[K8]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I8){C0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)C0(S)}).catch(()=>{}),()=>{b=!0}},[I8]);let[S8,V9]=u.useState({}),[x9,i9]=u.useState(null),[h9,t]=u.useState(!1),[M0,E0]=u.useState("open"),[v0,W8]=u.useState(EF0),[g8,t8]=u.useState(()=>{return HT(t80,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(t80,JSON.stringify(g8))}catch{}},[g8]);let[v8,W9]=u.useState(null),[T9,e9]=u.useState(()=>TH(e80,!0)),[J7,FQ]=u.useState(()=>TH(a80,!1)),[aX,BJ]=u.useState(()=>HT(s80,{})),[oJ,nJ]=u.useState(!1),[e7,Y4]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=qh(()=>Y4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j9,VY]=u.useState(!1),[p7,y5]=u.useState(!1),[HG,f7]=u.useState(!1),[qY,LX]=u.useState(!1),{report:V7}=gw(G9()),[rJ,l9]=u.useState(!1),[q7,z6]=u.useState(!1),[SJ,j5]=u.useState(null),[LQ,P6]=u.useState(null),[W4,DQ]=u.useState(!1),[zG,bJ]=u.useState(!1),[yJ,aJ]=u.useState(!1),[v5,G4]=u.useState(!1),[NJ,Z4]=u.useState(()=>HT(Y90,J1)),[o,G0]=u.useState(()=>{try{let b=localStorage.getItem(W90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[L0,y0]=u.useState(!1),[P0,z8]=u.useState([]),[M8,Z9]=u.useState(0),[L9,I6]=u.useState(!1),[MQ,s6]=u.useState(!1),[FJ,f5]=u.useState(!1),[RH,KG]=u.useState(1),[jJ,C7]=u.useState(216),[R9,DX]=u.useState(null),[K6,a8]=u.useState([]),[J6,h6]=u.useState([]),[MX,OQ]=u.useState([]),[sX,CH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=M8},[M8]);let[X6,$H]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let k6=u.useMemo(()=>iw(P0,{artboardId:[X6,R9],total:sX}),[P0,X6,R9,sX]),tX=u.useRef(null);u.useEffect(()=>{tX.current=k6},[k6]);let BY=u.useMemo(()=>CK(P0,k6)?.fps||30,[P0,k6]),[SH,NY]=u.useState(null),[FY,G1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))h8("Timeline changed — reloaded, try again."),G1((c)=>c+1);else h8(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Z1,bH]=u.useState(!1),[H1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let yH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),UL("Claude finished","Your assistant turn is ready in Maude.")},[]),jH=u.useRef(0),LY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-jH.current<OF0)return;jH.current=b,UL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[x5,eX]=u.useState("inspect"),[BG,DY]=u.useState(null),AQ=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),MY=u.useRef(U6);u.useEffect(()=>{MY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let vH=u.useRef(!1);u.useEffect(()=>{vH.current=yJ||h9||Q8||f8||_X},[yJ,h9,Q8,f8,_X]);let DG=u.useRef({open:{},side:J1});DG.current={open:{tree:T9,layers:v5,inspector:yJ,comments:h9,changes:Q8,sync:f8,assistant:_X},side:NJ};let H4=u.useCallback((b,S)=>{if(b==="tree")e9(S);else if(b==="layers")G4(S);else if(b==="inspector")aJ(S);else if(b==="comments")t(S);else if(b==="changes")Z8(S);else if(b==="sync")b8(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||J1[b],[]),T6=u.useCallback((b)=>{let S=MG(b);H4(b,!0);for(let c of VT)if(c.id!==b&&MG(c.id)===S)H4(c.id,!1)},[H4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])H4(b,!1);else T6(b)},[T6,H4]),EX=T6,g6=wX,OG=u.useCallback((b)=>{if(!MY.current)return;if(O0)return;if(!b||!b.id)return;if(vH.current)return;EX("inspector"),eX("css")},[EX,O0]),OY=u.useCallback(()=>y0((b)=>!b),[]),_Q=vm(qT),z4=Om({enabled:i0.cloud===null||i0.exportLane==="remote"}),[fH,z1]=u.useState(!1),[xH,J5]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=!0;return Lh().then((S)=>{if(!b)return;if(z1(!!S),!S&&!TH(r80,!1))J5(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{J5(!1);try{localStorage.setItem(r80,"1")}catch{}},[]),[AG,hH]=u.useState(null);u.useEffect(()=>{if(!G9())return;let b;return _h((S)=>hH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[K4,wQ]=u.useState(null),[EQ,_G]=u.useState(()=>!TH(n80,!1)),PX=u.useCallback((b)=>{wQ(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)T6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)EX("inspector");if(b.tab)eX(b.tab);if(b.changes)EX("changes")}},U4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(n80,"1")}catch{}},[]),[X5,AY]=u.useState(()=>TH(Q90,!0)),[gH,EG]=u.useState(!1),[Q5,_Y]=u.useState(()=>TH(J90,!1)),[m6,V0]=u.useState(()=>TH(X90,!1)),[vJ,V4]=u.useState(!1),[PG,sJ]=u.useState(!1),[l7,tJ]=u.useState(0),[h5,IG]=u.useState(null),[kG,wY]=u.useState(!1),g5=u.useRef(null),PQ=u.useRef(null),c8=u.useRef(new Map);u.useEffect(()=>{if(!i0?.canvasToken)return;let b=!1,S=null,c=0,X0=(w0)=>{clearTimeout(S);let p=db(w0);c=Date.now()+p,S=setTimeout(K0,p)};async function K0(){let w0=null;try{let D0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(D0.ok)w0=(await D0.json())?.canvasToken}catch{}if(b)return;if(typeof w0!=="string"||!w0){clearTimeout(S),c=Date.now()+30000,S=setTimeout(K0,30000);return}lb(w0);let p=null;try{p=new URL(i0.canvasOrigin,location.href).origin}catch{}if(p)for(let D0 of c8.current.values())try{D0.contentWindow?.postMessage({dgn:"canvas-cap",t:w0},p)}catch{}X0(w0)}X0(i0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=c)K0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[i0?.canvasToken,i0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?c8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),eJ=u.useRef(0),IQ=u.useCallback(({format:b,artboardIds:S=null,scale:c=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,w0)=>{let p=V?c8.current.get(V):null;if(!p||!p.contentWindow){w0(Error("no active canvas to capture"));return}let D0=p.contentWindow;eJ.current+=1;let k0=`cap-${Date.now().toString(36)}-${eJ.current}`,c0=!1,A8=(w7,d9)=>{if(c0)return;c0=!0,window.removeEventListener("message",O8),clearTimeout(q6),w7(d9)},O8=(w7)=>{if(w7.source!==D0)return;let d9=w7.data;if(!d9||d9.id!==k0)return;if(d9.dgn==="export-capture-progress")X0?.(d9.current,d9.total);else if(d9.dgn==="export-capture-done")A8(F0,Array.isArray(d9.items)?d9.items:[]);else if(d9.dgn==="export-capture-error")A8(w0,Error(d9.message||"capture failed"))},q6=setTimeout(()=>A8(w0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",O8);try{D0.postMessage({dgn:"export-capture",id:k0,format:b,artboardIds:S,scale:c},"*")}catch(w7){A8(w0,w7)}}),[V]),Y8=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),q4=u.useCallback((b,S,c)=>{AQ.current.undo.push({asset:b,before:S,after:c}),AQ.current.redo.length=0},[]),G8=u.useCallback((b)=>{let S=b?AQ.current.redo:AQ.current.undo;if(!S.length)return!1;let c=S.pop();(b?AQ.current.undo:AQ.current.redo).push(c);let X0=(b?c.after:c.before)||{};return Y8(c.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(c.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((K0)=>K0+1),!0},[Y8]),TG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let c=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (o80(),i80)),K0=await X0(c),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),w0=await F0.json().catch(()=>({}));if(F0.ok&&w0.path)return{maskAsset:w0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},c=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",c),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",c)}},[]);let Q6=u.useRef({});Q6.current={open:L0,comps:P0,frame:M8,total:sX,playing:L9,compId:k6,muted:FJ,loop:MQ,sequences:K6,post:T0,canvas:V};let m5=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,c)=>{if(typeof S!=="number")return;if(m5.current.undo.push({canvas:b,seq:S,label:c}),m5.current.redo=[],m5.current.undo.length>50)m5.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=m5.current,c=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=Q6.current.canvas,F0=-1;for(let p=c.length-1;p>=0;p--)if(c[p].canvas===K0){F0=p;break}if(F0<0){h8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let w0=c[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:w0.canvas,seq:w0.seq,dir:b})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(c.splice(F0,1),p?.ok)X0.push(w0),h8(`${b==="undo"?"Undid":"Redid"}: ${w0.label}`,!0);else h8(`${b==="undo"?"Undo":"Redo"} skipped: ${p?.error||"failed"}`)}).catch(()=>h8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let c=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?c.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?c[S.index]:null)||null;if(typeof S==="string")return c.find((X0)=>X0.stableId===S)||null;return c[S]||null},[]),kQ=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r8)return;let c=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:c,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),LJ("Remove refused",K0.error);else if(K0?.ok){if(h8("Clip removed.",!0),K0.seq!=null)Y6(S,K0.seq,"remove clip");NY(null)}}).catch(()=>h8("Remove failed: network error"))},[R6,Y6]),TQ=u.useCallback((b,S,c)=>{let X0=Q6.current.canvas;if(!X0||X0===r8)return;let K0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((w0)=>w0.json().catch(()=>({}))).then((w0)=>{let p=w0?.ok&&Array.isArray(w0.clips)?w0.clips:[],D0=b?.transition?p.find((k0)=>k0.kind==="transition"&&k0.stableId===b.stableId)||null:R6(w0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...c})})}).then((w0)=>w0?w0.json():null).then((w0)=>{if(w0&&!w0.ok)console.warn("[clip-edit]",S,w0.error||"failed"),LJ(`${S} refused`,w0.error);else if(w0?.ok){let p={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(h8(`Applied: ${p[S]||S}.`,!0),w0.seq!=null)Y6(X0,w0.seq,p[S]||S)}}).catch(()=>h8(`${S} failed: network error`))},[R6,Y6,LJ]),[RQ,EY]=u.useState(null),Y5=u.useCallback((b,S="")=>new Promise((c)=>{EY({title:b,value:S,resolve:c})}),[]),u5=u.useCallback((b)=>{EY((S)=>{return S?.resolve?.(b),null})},[]),PY=u.useCallback((b,S)=>{let c=Q6.current.canvas;if(!c||c===r8||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:c,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),h8("Comment added.",!0)},[]);Q6.current.selected=SH,Q6.current.setSelected=NY,Q6.current.removeClip=kQ,Q6.current.clipVerb=TQ,Q6.current.addComment=PY,Q6.current.askText=Y5,u.useEffect(()=>{let b=(S)=>{let c=Q6.current;if(!c.open||!c.comps?.length)return;let X0=S.target,K0=X0?.tagName;if(K0==="INPUT"&&X0?.type!=="range")return;if(K0==="TEXTAREA"||K0==="SELECT"||X0?.isContentEditable)return;let F0=CK(c.comps,c.compId)?.fps||30,w0=Math.max(1,c.total),p=(k0)=>{let c0=Math.max(0,Math.min(w0-1,Math.round(k0)));Z9(c0),I6(!1),c.post({dgn:"timeline-seek",frame:c0,id:c.compId})},D0=()=>{let k0=new Set([0,w0-1]);for(let c0 of c.sequences||[]){k0.add(c0.from);for(let A8 of c0.keyframes||[])k0.add(A8.from),k0.add(A8.to)}return[...k0].filter((c0)=>c0>=0&&c0<w0).sort((c0,A8)=>c0-A8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(c.selected!=null)S.preventDefault(),c.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&c.selected!=null){S.preventDefault(),c.removeClip?.({stableId:c.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let k0=c.selected!=null?{stableId:c.selected}:null;if(!k0){let c0=c.sequences||[],A8=c0.find((O8)=>O8.series&&c.frame>=O8.from&&c.frame<O8.from+O8.duration)||c0.find((O8)=>c.frame>=O8.from&&c.frame<O8.from+O8.duration);if(A8?.stableId)k0={stableId:A8.stableId}}if(k0)c.clipVerb?.(k0,"split",{atFrame:c.frame});else h8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),c.playing)I6(!1),c.post({dgn:"timeline-pause",id:c.compId});else I6(!0),c.post({dgn:"timeline-mute",muted:c.muted,id:c.compId}),c.post({dgn:"timeline-loop",loop:c.loop,id:c.compId}),c.post({dgn:"timeline-play",id:c.compId});else if(S.key==="ArrowRight")S.preventDefault(),p(c.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),p(c.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),p(0);else if(S.key==="End")S.preventDefault(),p(w0-1);else if(S.key==="."){S.preventDefault();let k0=D0().find((c0)=>c0>c.frame);if(k0!=null)p(k0)}else if(S.key===","){S.preventDefault();let k0=D0().reverse().find((c0)=>c0<c.frame);if(k0!=null)p(k0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z8([]),Z9(0),I6(!1),NY(null),$H(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[p5,IY]=u.useState(""),[kY,B4]=u.useState([]),[CG,TY]=u.useState([]);u.useEffect(()=>{if(!L0||P0.length===0||!V||V===r8){IY(""),B4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")IY(S.source)}).catch(()=>{}),()=>{b=!1}},[L0,P0,V,FY]),u.useEffect(()=>{if(!L0||!V||V===r8||!p5){B4([]),TY([]);return}let b=!0,S=X6||void 0,c=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(c).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let K0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];B4(K0.filter((F0)=>F0.kind==="sequence")),TY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[L0,V,p5,X6,FY]),u.useEffect(()=>{if(!p5){a8([]),h6([]),OQ([]),CH(0);return}let b=R9??O?.artboardId??null,c=(b&&P0.find((F0)=>F0.artboardId===b||F0.id===b)||P0[0])?.durationInFrames||0,X0=zm(p5,c,b);$H(X0.artboardId??b??null);let K0=X0.sequences.map((F0,w0)=>{let p=kY[w0];if(!p)return F0;return{...F0,stableId:p.stableId,contentHash:p.contentHash,mediaProps:p.mediaProps??null,placeholder:p.placeholder??null,mediaTag:p.mediaTag??F0.mediaTag,mediaSrc:p.mediaSrc??F0.mediaSrc,replaceable:!!(p.mediaCdId||p.mediaArrayRef),layers:Array.isArray(p.layers)?p.layers:[],hidden:!!p.hidden}});a8(K0),h6(X0.audio||[]),OQ(X0.transitions||[]),CH(X0.total)},[p5,kY,O,P0,R9]);let RY=u.useCallback(()=>{AY((b)=>{let S=!b,c=V?c8.current.get(V):null;if(c&&c.contentWindow)try{c.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of c8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),CY=u.useCallback(()=>{_Y((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),$Y=u.useCallback(()=>{V0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{V4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),N4=u.useCallback(()=>{V4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r8)return;sJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let c=S&&typeof S.name==="string"?S.name.trim():"";if(c)IG(c)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r8){tJ(0),sJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let c=Array.isArray(S?.artboards)?S.artboards.length:0;tJ(c),sJ(S?.overlays?.print===!0),L4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)tJ(0),sJ(!1),L4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r8||!R9)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R9})},250);return()=>clearTimeout(b)},[V,R9,T0]);let[F4,L4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r8)return;L4((S)=>{let c=new Set(S);if(c.has(b))c.delete(b);else c.add(b);let X0=[...c];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),c})},[V,T0]);u.useEffect(()=>{if(!V||V===r8)return;T0({dgn:"locked-set",locked:[...F4]})},[F4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",v0),localStorage.setItem(C90,v0)}catch{}for(let b of c8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}},[v0]),u.useEffect(()=>{try{localStorage.setItem(e80,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(a80,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(s80,JSON.stringify(aX))}catch{}},[aX]),u.useEffect(()=>{try{localStorage.setItem(J90,Q5?"1":"0")}catch{}},[Q5]),u.useEffect(()=>{try{localStorage.setItem(X90,m6?"1":"0")}catch{}},[m6]),u.useEffect(()=>{try{localStorage.setItem(Q90,X5?"1":"0")}catch{}},[X5]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")W8(S.theme);if(typeof S.minimap==="boolean")_Y(S.minimap);if(typeof S.zoom==="boolean")V0(S.zoom);if(typeof S.annotations==="boolean")AY(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")Z4({...J1,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")G0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!gH)return;AF0({theme:v0,minimap:Q5,zoom:m6,annotations:X5,autoOpenInspector:U6,panelSides:NJ,layersMode:o})},[gH,v0,Q5,m6,X5,U6,NJ,o]),u.useEffect(()=>{try{localStorage.setItem(Y90,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(W90,o)}catch{}},[o]);let yG=u.useCallback((b,S)=>{BJ((c)=>{let X0=c[b],K0=X0===void 0?S:X0;return{...c,[b]:!K0}})},[]),D4=u.useCallback(()=>{W8((b)=>b==="dark"?"light":"dark")},[]),M4=u.useRef(null),y9=u.useCallback(()=>M4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=ib({read:async(S)=>{let c=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!c.ok)throw Object.assign(Error(`Project index request failed: ${c.status}`),{status:c.status});let X0=await c.json(),K0=X0.groups.map((F0)=>({...F0,tree:TF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:c})=>{H(S.project||"Design"),X(c),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return M4.current=b,y9(),()=>{M4.current=null,b.dispose()}},[y9]);let W5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",c=await fetch(S);if(!c.ok){console.error("failed to load system-data",c.status);return}let X0=await c.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){B0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)B0(await K0.json());return}B0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),SY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{SY()},[SY]);let bY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function c(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");PQ.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)K8();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{i(!1),clearInterval(b),setTimeout(c,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let w0=JSON.parse(F0.data);if(w0.type==="snapshot"&&w0.state)E((p)=>I90(w0.state.selected,p));else if(w0.type==="selected"){if(Date.now()-T.current<2000)return;let p=w0.selected,D0=Array.isArray(p)?p[0]:p,k0=w.current,c0=Array.isArray(k0)?k0[0]:k0;if(E((A8)=>I90(p,A8)),D0?.id&&D0.file&&(!c0||c0.id!==D0.id||c0.file!==D0.file))$(D0)}else if(w0.type==="comments"&&typeof w0.file==="string")V9((p)=>({...p,[w0.file]:w0.comments||[]}));else if(w0.type==="ai-activity"&&typeof w0.file==="string"){if(wY(!0),g5.current)clearTimeout(g5.current);g5.current=setTimeout(()=>wY(!1),8000);for(let p of c8.current.values())try{p.contentWindow.postMessage({dgn:"ai-activity",file:w0.file,entry:w0.entry},"*")}catch{}}else if(w0.type==="export:job"&&w0.payload)z4.upsert(w0.payload);else if(w0.type==="sync:status"&&w0.payload)a0(w0.payload);else if(w0.type==="canvas-list-update")y9(),bY.current(w0.payload);else if(w0.type==="config-updated")K8();else if(w0.type==="acp-focus"){if(G9())EX("assistant")}else if(w0.type==="git-status"&&w0.payload){if(!d8.current)C0(w0.payload)}else if(w0.type==="git-lifecycle"&&w0.payload){Z0(w0.payload);for(let p of c8.current.values())try{p.contentWindow.postMessage({dgn:"git-lifecycle",payload:w0.payload},"*")}catch{}}}catch{}})}return c(),()=>{if(clearInterval(b),PQ.current)PQ.current.close()}},[y9,K8]);function $7(b){let S=PQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)C0(await b.json())}catch{}},[]),fJ=u.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)$0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await c.json().catch(()=>({}));return{ok:c.ok,...X0}}catch(c){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let c=await AJ("/_api/git/commit",{message:b,files:S});if(c.ok)await OJ();return c},[AJ,OJ]),yY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),fJ();return b},[AJ,OJ,fJ]),jY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)h0({file:b.files[0],conflict:!0});return b},[AJ,OJ,fJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),fJ();return S},[AJ,OJ,fJ]),O4=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return[];return(await c.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return null;let X0=await c.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),[pG,lG]=u.useState(0),dG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return"legacy";let X0=await c.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((K0)=>{let F0=b?"":(K0.canvases||[]).map((w0)=>w0.split("/").pop()).join(", ");return{sha:`r${K0.revision}`,message:[K0.label||K0.kind,F0].filter(Boolean).join(" · "),author:K0.actor,date:new Date(K0.committedAt).toISOString(),accepted:{revision:K0.revision,actionId:K0.actionId,mine:!!K0.mine,undo:K0.kind==="undo"||K0.kind==="redo"}}})}catch{return null}},[]),cG=/^r\d+$/.test(O9?.beforeSha||""),K1=u.useCallback(async(b)=>{if(!cG)return O4(b);let S=await dG(b);return Array.isArray(S)?S:[]},[cG,O4,dG]),mH=u.useCallback(async(b,S)=>{if(!b||!Number.isSafeInteger(S)||S<0)return{ok:!1,error:"Choose a saved project version to restore."};let c=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,revision:S})}).catch(()=>null),X0=c?await c.json().catch(()=>null):null;if(c?.ok&&X0?.ok)return lG((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),U1=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I8)return S;for(let c of N8?.files||[])S.set(c.path,b[c.status]);return S},[N8,I8]);u.useEffect(()=>{if(I8){$0(null);return}if(N8?.repo===!1)return;fJ();let b=setInterval(fJ,Q8?60000:120000);return()=>clearInterval(b)},[I8,N8?.repo,Q8,fJ]);let V6=u.useCallback((b)=>{if(W.current="push",i9(null),F(null),b===V)return;if(U((S)=>{for(let c of S)if(c.path!==b)c8.current.delete(c.path);return[{path:b}]}),B(b),H8(null),_0(null),b!==r8)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let c=J.flatMap((X0)=>X0.paths||[]).find((X0)=>RW(X0,i0.designRel)===b);if(c&&b5.test(c))V6(c);else if(c&&AL(Q4(c)))M(c);else U([]),B(null),F(null),E5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,i0.designRel,V6,M]),uH=u.useRef(!1);u.useEffect(()=>{if(!Q||i0.cloud===void 0||uH.current)return;uH.current=!0;let b=CV(location,i0.designRel);if(b)A4(b,"none")},[Q,i0.cloud,i0.designRel,A4]),u.useEffect(()=>{if(!Q||i0.cloud===void 0)return;let b=()=>{let S=CV(location,i0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,i0.cloud,i0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r8?null:V);if(b===G.current)return;G.current=b;let S=RW(b,i0.designRel);if(W.current!=="none"&&CV(location,i0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Gg(location,S));W.current="push"},[V,N,i0.designRel]);let vY=N||(V===r8?null:V),iG=i0.cloud?"cloud":G9()?"native":"local",pH=(b)=>Kg({rel:RW(b,i0.designRel),shell:iG,location,linkedHubUrl:e0?.url,project:i0.cloud?Z:s8,localUrl:location.origin}),lH=(b=vY)=>{let S=RW(b,i0.designRel);if(S)j5({path:b,rel:S,label:Q4(b)})},V1=u.useCallback((b)=>{if(H8(null),_0(null),K8(),d0((S)=>S+1),b&&b!==r8)r0(b)},[K8]),oG=u.useRef(!1);u.useEffect(()=>{if(oG.current)return;if(!i0.cloud)return;if(new URLSearchParams(location.search).has("open")){oG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let c of S.paths||[]){if(!b5.test(c))continue;if(/(^|\/)system\//.test(c))continue;b=c;break}if(b)break}if(!b)return;oG.current=!0,V6(b)},[i0.cloud,J,K.length,V6]);let CQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)W5(S);else if(!F8)W5();V6(r8)},[F8,W5,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r8)})},[K]),u.useEffect(()=>{if(V&&V!==r8)$7({type:"active",file:V});else if(V===r8)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let fY=u.useCallback((b)=>{U((S)=>{let c=S.findIndex((K0)=>K0.path===b);if(c<0)return S;let X0=S.filter((K0)=>K0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,c-1)].path);return X0}),c8.current.delete(b),r0((S)=>S===b?null:S)},[V]);bY.current=(b)=>{if(!b?.rel)return;let S=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),c=`${S}/${b.rel}`;if(b.action==="removed")fY(c);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:c}:F0)),B((K0)=>K0===X0?c:K0),r0((K0)=>K0===X0?null:K0),c8.current.delete(X0)}};let l5=u.useCallback(()=>{if(!V||V===r8){if(V===r8)W5();return}let b=c8.current.get(V);if(b)b.src=b.src},[V,W5]),dH=u.useCallback(()=>y9(),[y9]),[q1,cH]=u.useState(!1),nG=u.useRef(!1),rG=u.useCallback(async()=>{if(nG.current)return;nG.current=!0,cH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{nG.current=!1,cH(!1)}},[y9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,dH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[dH]);let B1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),c=await S.json().catch(()=>({}));if(!S.ok||!c.ok)return{ok:!1,error:c.error||`create failed (${S.status})`};return await y9(),V6(c.file),{ok:!0,file:c.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),iH=u.useCallback(async()=>{let b=await Y5("New video name");if(!b)return;let c=(await Y5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=c?Number(c[1]):1920,K0=c?Number(c[2]):1080,F0=Math.max(1,Math.min(60,Number(await Y5("Frames per second","30"))||30));try{let w0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:K0})}),p=await w0.json().catch(()=>({}));if(!w0.ok||!p.ok){h8(`New video failed: ${p.error||`error ${w0.status}`}`);return}await y9(),V6(p.file),y0(!0),h8("New video created — drop clips on the timeline to start the cut.",!0)}catch(w0){h8(`New video failed: ${w0 instanceof Error?w0.message:"network error"}`)}},[y9,V6,Y5]),N1=u.useCallback(async()=>{if(!V||V===r8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",c=[];if(S){let p=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of p.querySelectorAll('[data-tool="mediaref"]')){let k0=D0.getAttribute("data-src");if(!k0)continue;c.push({src:k0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(c.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let K0=`${X4(Q4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K0,kind:"video-comp",clips:c})}),w0=await F0.json().catch(()=>({}));if(!F0.ok||!w0.ok){window.alert(`Assemble failed: ${w0.error||`error ${F0.status}`}`);return}await y9(),V6(w0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),aG=u.useCallback(({accept:b,resolveTarget:S})=>{let c=V,X0=X6||void 0,K0=document.createElement("input");K0.type="file",K0.accept=b,K0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(K0);let F0=()=>{if(K0.isConnected)K0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),K0.addEventListener("change",()=>{let w0=K0.files?.[0];if(F0(),!w0)return;let p=`/_api/comp-clips?canvas=${encodeURIComponent(c)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(p).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let k0=S(D0);if(!k0)return h8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":w0.type||"application/octet-stream"},body:w0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return h8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(k0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,arrayName:k0.arrayRef.arrayName,index:k0.arrayRef.index,field:k0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,id:k0.cdId,attr:"src",value:c0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)h8(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(h8("Media replaced.",!0),D0.seq!=null)Y6(c,D0.seq,"replace media")}}).catch(()=>h8("Replace failed: network error"))}),K0.click()},[V,X6,Y6]),F1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5683
+ `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(l)=>M({...F,crashLogs:l.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((l)=>l.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())wV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=y8(i8(),1);function Sm(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function bm(J,X){let Q=Sm(J),Y=Sm(X);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 ym(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||bm(Q.version,X)))}function jm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&bm(Y.version,Q))Q=Y.version}return Q}var AE="mdcc-whatsnew-seen",_E="mdcc-whatsnew-toast-dismissed";function zV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function KV0(J){try{let X=localStorage.getItem(AE);if(X)return X;localStorage.setItem(AE,J)}catch{}return J}function UV0(){try{return localStorage.getItem(_E)}catch{return null}}function vm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>KV0(J)),[H,K]=TJ.useState(()=>UV0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let A=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(A)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let T=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{A=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let B=ym(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let A=jm(X,Y);Z(A),K(Y);try{localStorage.setItem(AE,A),localStorage.setItem(_E,Y)}catch{}},[X,Y]),O=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(_E,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:O,markAllSeen:M}}function fm({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){CW(X);return}E5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>CW(X),[X]),null}function xm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.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(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("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:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("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}),zV0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),n80="mdcc-usage-tour-seen",r80="mdcc-collab-tour-seen",r8="__system__",C90="mdcc-theme",a80="mdcc-show-hidden",s80="mdcc-sections-expanded",t80="maude-cp-mode",e80="mdcc-sidebar-open",J90="mdcc-minimap-visible",X90="mdcc-zoomctl-visible",Q90="mdcc-annotations-visible";var OF0=30000;function AF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var VT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],J1={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},Y90="mdcc-panel-sides",W90="mdcc-layers-mode";function G90({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(VT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var b5=/\.(tsx|html?)$/i,_F0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function AL(J){for(let[X,Q]of _F0)if(X.test(J))return Q;return null}function Oq(J){return J.replace(/^\.[^/]+\//,"").replace(b5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function wF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var qT="1.4.6";function UL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){A7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function EF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(C90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function TH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function HT(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function PF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Q4(J){return J.split("/").pop()}function h8(J,X=!1,Q){E5({title:J,kind:X?"success":"error",action:Q})}var Z90="maude-mode-hint-seen";function BL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(Z90)==="1")return}catch{return}if(BL.active)return;BL.active=!0;let X=()=>{BL.active=!1;try{localStorage.setItem(Z90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)CW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);E5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function X4(J){return J.replace(b5,"")}function IF0(J){return J.replace(b5,"")}function kF0(J){let X=new Map;for(let G of J){if(!b5.test(G.name))continue;let Z=IF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(b5.test(G.name))continue;let Z=null;for(let H of X.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 X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function TF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function $90(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=$90(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._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 NL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function RF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/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(J).toLocaleDateString()}function S90(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function LL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var CF0={"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:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{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:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{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":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{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:D(Q0,{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:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{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:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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:D(Q0,{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 $F0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>t2(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(k9,{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(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=jb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z($J,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z($J,{children:V.kbd})}):null]})]},V.id)})})]})})}function k9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:CF0[J]})}function SF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function H90({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function $J({children:J}){return z("span",{className:"kbd",children:J})}function z90(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function K90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("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 zT=[{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}],U90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},bF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Fq=[{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}],yF0="2x",V90=[{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}],jF0="auto",q90=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],vF0="keep",fF0={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 xF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return fF0[X]||"application/octet-stream"}function hF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,O]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!x)return;let l=h.ok?h.assets:[];H(l),O((v)=>{let n={...v};for(let e of l)n[e.path]=e.kind;return n})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let A=Array.from(N).some((x)=>(M[x]||"image")!=="image"),I=!W||A,T=!W?"No artboard on this canvas":A?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(x)=>{F((h)=>{let l=new Set(h);if(l.has(x))l.delete(x);else l.add(x);return l})},$=async(x)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),l=await h.json().catch(()=>({}));if(h.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${h.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let h=await $(x);if(U(!1),h.ok)X(h.path);else B(h.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;U(!0),B(null);let h=await Promise.all(x.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let l=h.filter((n)=>n.ok),v=h.length-l.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(l.length)O((n)=>{let e={...n};for(let s of l)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of l)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let l=(await Ah()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:xF0(v.name)}));if(U(!1),l.length)await f(l);return}let x=await cZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(G9()){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 h=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),x.addEventListener("change",()=>{let l=x.files?Array.from(x.files):[];if(h(),!l.length)return;if(Y)f(l);else C(l[0])}),x.click()},a=(x)=>`/${J}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("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(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"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 h=Y&&N.has(x.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?R(x.path):X(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(k9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:a(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&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(N),E),children:"Insert"})]})]})})}function DL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function gF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((C0)=>H==="none"&&!C0.handoff&&C0.format!=="zip"&&!ob.has(C0.format)||H!=="local"&&C0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&fb("png",X)?X:RO("png")),[O,E]=u.useState(2),[w,A]=u.useState(yF0),[I,T]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[f,m]=u.useState(!1),[d,a]=u.useState(jF0),[x,h]=u.useState(vF0),[l,v]=u.useState(!0),[n,e]=u.useState(!1),[s,H0]=u.useState(null),[r,z0]=u.useState([]),i=zT.find((C0)=>C0.id===B)||zT[0],q0=i.handoff?[]:CO(i.format),Z0=900,I0=3600,a0=CK(W,iw(W,{artboardId:G})),s0=a0?.durationInFrames||0,e0=a0?.fps||30,D8=i.temporal&&s0>900,s8=i.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(RO(i.format))},[q0,F,i.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let w8=u.useCallback(()=>{fetch("/_api/export-history").then((C0)=>C0.json()).then((C0)=>z0(Array.isArray(C0?.history)?C0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{w8()},[w8]),u.useEffect(()=>{function C0(A0){if(A0.key==="Escape")A0.preventDefault(),U()}return window.addEventListener("keydown",C0),()=>window.removeEventListener("keydown",C0)},[U]);async function N8(){if(i.handoff){let Q8=`/design:handoff ${Q&&Q!==r8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(Q8)}catch{}H0({ok:!0,msg:`Copied: ${Q8} — run it in Claude Code.`});return}if(V(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let C0=i.temporal?{scale:O}:{};if(i.format==="png"){let $0=Fq.find((Q8)=>Q8.id===w)||Fq[1];if($0.kind==="dpi")C0.dpi=$0.value;else C0.scale=$0.value}if(i.format==="mp4"||i.format==="webm")C0.audio=l;if(s8)C0.maxFrames=s0;if(i.format==="pdf"){C0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let $0=V90.find((Q8)=>Q8.id===d)?.value;if($0!==void 0)C0.dpi=$0;if(x!=="keep")C0.text=x}if(G)C0.artboardId=G;if(Z?.selector)C0.selection=Z;if(Q&&Q!==r8)C0.canvasFile=Q;if(vU.has(i.format)&&YB({exportLane:H,format:i.format,scope:F,artboardId:C0.artboardId})&&typeof K==="function")try{let $0=fO(C0);H0({ok:!0,msg:"Capturing…"});let Q8=await K({format:i.format,artboardIds:[C0.artboardId],scale:$0,onProgress:(f8,b8)=>H0({ok:!0,msg:`Capturing ${f8}/${b8}…`})}),Z8=await vO(Q8,i.format);for(let f8 of Z8)DL(f8.name,f8.blob);for(let f8 of Z8)await xO({format:i.format,scope:F,filename:f8.name});e(!1),H0({ok:!0,msg:`Saved ${Z8.map((f8)=>f8.name).join(", ")} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(YB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let $0=Q&&Q!==r8?Q4(Q).replace(/\.[^.]+$/,""):"export",{filename:Q8,blob:Z8}=await jO({capture:K,name:$0,onProgress:(f8,b8)=>H0({ok:!0,msg:`Capturing ${f8}/${b8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});DL(Q8,Z8),await xO({format:i.format,scope:F,filename:Q8}),e(!1),H0({ok:!0,msg:`Saved ${Q8} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(H==="none"&&vU.has(i.format)){H0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let $0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:C0})});if(!$0.ok){H0({ok:!1,msg:await $0.text()||`Export failed (${$0.status})`}),e(!1);return}U()}catch($0){H0({ok:!1,msg:$0&&$0.message?$0.message:String($0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(C0)=>{if(C0.target===C0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r8?`Format · ${X4(Q4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:zT.filter((C0)=>!C0.temporal||Y).map((C0)=>D("button",{type:"button","data-testid":`export-format-${C0.id}`,className:"st-fmt"+(C0.id===B?" is-on":""),disabled:V(C0),title:V(C0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(C0.id),H0(null)},children:[z(k9,{name:C0.icon,size:16}),z("span",{className:"st-fmt-name",children:C0.label}),z("span",{className:"st-fmt-sub",children:C0.sub})]},C0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!i.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(C0)=>M(C0.target.value),children:q0.map((C0)=>z("option",{value:C0,children:U90[C0]},C0))})]}),!i.handoff&&i.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(C0)=>A(C0.target.value),children:Fq.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let C0=Fq.find(($0)=>$0.id===w)||Fq[1],A0=C0.kind==="dpi"?C0.value/96:C0.value;return`${C0.label} ≈ ${Math.round(1440*A0)}×${Math.round(900*A0)} for a 1440×900 artboard.`})()}),!i.handoff&&i.temporal&&D("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:O,onChange:(C0)=>E(Number(C0.target.value)),children:bF0.map((C0)=>z("option",{value:C0.value,children:C0.label},C0.value))})]}),!i.handoff&&i.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[O,"× the artboard's native resolution (e.g. 960×540 → ",960*O,"×",540*O,")."]}),D8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/e0),"s).",s8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!i.handoff&&i.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(C0)=>a(C0.target.value),children:V90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.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)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:x,onChange:(C0)=>h(C0.target.value),children:q90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:q90.find((C0)=>C0.id===x)?.description}),z("div",{className:"st-dialog-row",children:D("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:I,onChange:(C0)=>T(C0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((C0)=>!C0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(C0)=>j(C0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(C0)=>m(C0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!i.handoff&&(i.format==="mp4"||i.format==="webm")&&z("div",{className:"st-dialog-row",children:D("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:l,onChange:(C0)=>v(C0.target.checked)}),"Export with audio"]})}),i.handoff&&D("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."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),r.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map((C0,A0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(C0.format||"").toUpperCase()," ·"," ",U90[C0.scope]||C0.scope]}),z("span",{className:"st-mono",children:C0.filename})]},A0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:n,onClick:N8,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var _L=12,wL=16;function mF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Oq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:_L+X*wL+"px"},onClick:()=>K((O)=>!O),onContextMenu:Z?(O)=>Z.openAt(O,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(rz,{label:J,row:M,expanded:H,busy:F,onToggle:()=>K((O)=>!O),actions:Z?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Oq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(O)=>Z.openAt(O,{kind:"dir",dirPath:W}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}):null,children:H&&Y})}function uF0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return z(rz,{label:J,expanded:H,selected:W,onToggle:()=>K((U)=>!U),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:_L+Q*wL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(k9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),children:H&&Z})}function ML({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,O=b5.test(J.name),E=!O&&K!=="runtime"?AL(J.name):null,w=!O&&!E,A=O?X4(J.name):J.name,I=O&&typeof G==="function"&&K!=="runtime",T=O&&!U&&K!=="runtime"&&typeof N<"u",R=T?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=T&&typeof F<"u",f=!O&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=O?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(b5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":a??(f?`file-row-${Oq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:_L+H*wL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(O)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||f,supporting:f,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:A}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(rz,{label:A,row:x,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Oq(J.path)}`,title:`Actions for ${A}`,"aria-label":`Actions for ${A}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||f,supporting:f,name:J.name}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${A}`,"aria-label":`Delete canvas ${A}`,onClick:(h)=>{h.stopPropagation(),G(J.path,A)},children:z(LL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function pF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:O}){let E=N?.get(J.path),w=X.length>0,[A,I]=u.useState(!1),T=B||A,R=J.path===W;if(!(w&&V))return z(ML,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:O});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},f=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof O<"u",a=typeof O<"u"&&Y!=="runtime",x=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":T,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(f?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:_L+Q*wL+"px"},title:J.path,onClick:(l)=>{if(l.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(l)=>O.openAt(l,{kind:"file",path:J.path,dir:x,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(l)=>{l.stopPropagation(),I((v)=>!v)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X4(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return z(rz,{label:X4(J.name),row:h,selected:R,expanded:T,busy:m,onToggle:()=>I((l)=>!l),actions:a?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Oq(J.path)}`,title:`Actions for ${X4(J.name)}`,"aria-label":`Actions for ${X4(J.name)}`,"aria-haspopup":"menu",onClick:(l)=>O.openAt(l,{kind:"file",path:J.path,dir:x,canMove:d}),children:z(LL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}):null,children:T&&X.map((l)=>z(ML,{file:l,menu:O,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},l.path))})}function b90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:O,dirPath:E="",drag:w,menu:A}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),T=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>kF0(T),[T]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let x of $){let h=AL(x.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(x)}return{mediaOrphans:d,metaOrphans:a}},[$]),f=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=f&&d.sidecars.some((x)=>{let h=U.toLowerCase();return x.name.toLowerCase().includes(h)||x.path.toLowerCase().includes(h)});return z(pF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:NL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:O?.[d.primary.path],drag:w,menu:A},d.primary.path)}),C.map((d)=>z(ML,{file:d.primary,menu:A,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:NL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(ML,{file:d.primary,menu:A,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:NL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),x=E?`${E}/${d}`:d,h=z(b90,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:O,dirPath:x,drag:w,menu:A});if(a&&N)return z(uF0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r8&&a.name===B,onOpenSystem:N,children:h},d);return z(mF0,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:w?A:void 0,children:h},d)})]})}var VL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function lF0(J){if(J.kind==="project")return VL.project;if(J.kind==="runtime")return VL.runtime;if(J.label==="Design system")return VL.ds;if(J.label==="UI kit")return VL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function dF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:O,onNewBoard:E,onDeleteBoard:w,onRefresh:A,refreshing:I,collapsed:T,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:f,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:x,onMoveCanvas:h,onNewFolder:l,onDeleteFolder:v,onRenameFolder:n,onRenameCanvas:e,onDuplicateCanvas:s,onDeleteFile:H0,syncStatus:r,onLinkedHub:z0,onLocalProject:i,onOpenLinkedFile:q0,filesReady:Z0,onShare:I0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((j0)=>({...j0,tree:$90(j0.tree,V),filtered:!!V}))},[Q,V]),e0=tb(h),D8=rb(),s8=u.useMemo(()=>{let j0=[];for(let t0 of Q){if(t0.label==="Design system"||t0.kind!=="canvas")continue;let H8=t0.fullPath.replace(/^\.[^/]+\//,"")||t0.fullPath;j0.push({path:t0.fullPath,label:H8});for(let p0 of t0.dirs||[])j0.push({path:p0,label:p0.replace(/^\.[^/]+\//,"")})}return j0},[Q]),w8=D8.state?.extra,N8=w8?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{D8.close(),I0(w8.path)}},...e&&/\.tsx$/i.test(w8.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{D8.close();let j0=X4(w8.path.split("/").pop()),t0=window.prompt("Rename canvas to:",j0);if(t0?.trim()&&t0.trim()!==j0)e(w8.path,t0.trim())}}]:[],...s&&/\.tsx$/i.test(w8.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{D8.close(),s(w8.path)}}]:[],...w8.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{D8.close();let j0=w8.name??w8.path.split("/").pop(),t0=j0.includes(".")?j0.slice(j0.lastIndexOf(".")):"",H8=t0?j0.slice(0,-t0.length):j0,p0=window.prompt(`Rename ${j0} to:`,H8);if(p0?.trim()&&p0.trim()!==H8)e(w8.path,p0.trim())}}]:[],...w8.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>D8.showMoveTo()}]:[],...w8.supporting&&H0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{D8.close(),H0(w8.path,w8.name??w8.path.split("/").pop())}}]:[]]:w8?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{D8.close();let j0=window.prompt("New folder name:");if(j0?.trim())l(w8.dirPath,j0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{D8.close();let j0=w8.dirPath.split("/").pop(),t0=window.prompt("Rename folder to:",j0);if(t0?.trim()&&t0.trim()!==j0)n(w8.dirPath,t0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{D8.close(),v(w8.dirPath,w8.dirPath.split("/").pop())}}]:[],C0=w8?.kind==="file"||w8?.kind==="supporting"?s8.filter((j0)=>j0.path!==w8.dir):[],[A0,$0]=u.useState(!1),[Q8,Z8]=u.useState("board"),[f8,b8]=u.useState(""),[O9,h0]=u.useState(""),[C8,A9]=u.useState(!1),F8=u.useMemo(()=>Q.find((j0)=>j0.kind==="canvas"&&j0.label!=="Design system")?.fullPath,[Q]),B0=u.useCallback(async()=>{let j0=f8.trim();if(!j0||C8)return;if(A9(!0),h0(""),Q8==="folder"){if(!F8){A9(!1),h0("no canvas group to create a folder in");return}let H8=await l(F8,j0);if(A9(!1),H8?.ok)$0(!1),b8("");else h0(H8?.error||"could not create folder");return}let t0=await E(j0);if(A9(!1),t0?.ok)$0(!1),b8("");else h0(t0?.error||"could not create board")},[f8,C8,E,l,Q8,F8]),J8=u.useMemo(()=>{let j0=0;for(let t0 of Q)for(let H8 of t0.paths||[])if(b5.test(H8))j0++;return j0},[Q]),r0=u.useMemo(()=>{let j0=0;for(let t0 of s0)for(let H8 of t0.paths||[])if(b5.test(H8))j0++;return j0},[s0]);return D("nav",{className:"st-sidebar"+(T?" is-collapsed":"")+(C?" is-resizing":""),style:T||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":A0&&Q8==="board",onClick:()=>{h0(""),Z8("board"),$0((j0)=>Q8==="board"?!j0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&F8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":A0&&Q8==="folder",onClick:()=>{h0(""),Z8("folder"),$0((j0)=>Q8==="folder"?!j0:!0)},children:z(k9,{name:"folder-plus",size:15})}),A&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>A(),children:z(k9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J8]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(k9,{name:"panel-left",size:15})})]})]}),A0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:Q8==="folder"?"folder name…":"brief board name…",value:f8,maxLength:60,disabled:C8,"aria-label":Q8==="folder"?"New folder name":"New brief board name",onChange:(j0)=>b8(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Enter")j0.preventDefault(),B0();else if(j0.key==="Escape")j0.preventDefault(),$0(!1),b8(""),h0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:C8||!f8.trim(),"data-tip":"Create · Enter","aria-label":Q8==="folder"?"Create folder":"Create brief board",onClick:B0,children:C8?"…":"↵"})]}):null,O9?z("div",{className:"st-newboard-err",role:"alert",children:O9}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(k9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(j0)=>B(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Escape")if(j0.preventDefault(),V)B("");else j0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z($J,{children:"/"})]})}),z(sb,{"aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((j0)=>{if(!F&&!V&&j0.kind==="runtime")return null;let t0=lF0(j0),H8=(j0.paths||[]).filter((i0)=>b5.test(i0)).length,p0=t0.pill||(t0.pillFromDsCount?String(j0.dsFolders?.length||0):null)||(t0.pillFromCount?String(H8||j0.paths?.length||0):null),d0=j0.tree&&Object.keys(j0.tree).length>0,k8=j0.label==="Design system",_0=j0.kind==="project";if(!F&&!V&&_0&&H8===0)return null;let X8=PF0(j0),P8=M[j0.label],U0=!!V||(P8===void 0?X8:P8),o0=!k8&&j0.kind==="canvas"&&!J,R8=o0?e0.dropProps(j0.fullPath,!0):{},J9=e0.overDir===j0.fullPath;return z(rz,{className:"st-tree-section",label:t0.title,expanded:U0,onToggle:()=>O(j0.label,X8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(J9?" is-drop-target":""),"data-testid":`tree-section-${j0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>O(j0.label,X8),"aria-expanded":U0,"aria-dropeffect":o0?"move":void 0,title:U0?"Collapse section":"Expand section",...R8,children:[z(k9,{name:"chevron-right",className:"st-chev"+(U0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:t0.title}),p0&&z("span",{className:"st-pill",children:p0})]}),children:U0&&(d0?z(b90,{node:j0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:j0.kind,showHidden:F,search:V,dsFolders:j0.dsFolders,activeDsName:G,onOpenSystem:k8?K:void 0,onDelete:k8||J?void 0:w,dirtyByPath:j,canvasKinds:x,dirPath:j0.fullPath,drag:!k8&&j0.kind==="canvas"&&!J?e0:void 0,menu:D8}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},j0.label)})}),z(ab,{state:D8.state,onClose:D8.close,rootItems:N8,destinations:C0,onPickDestination:(j0)=>h(w8.path,j0)}),z(UE,{project:f,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(Cw,{syncStatus:r,onLinkedHub:z0,onLocalProject:i,onOpenFile:q0,filesReady:Z0}):null,z(jw,{})]})}function cF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(k9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(k9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(k9,{name:"folder",size:15})})]})})}function iF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",qT]}),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:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("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.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("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."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("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"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var KT=[{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 oF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z($J,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function nF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=KT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z($J,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:KT.map((Y)=>D("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)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(oF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z($J,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",KT.length," groups"]})]})]})})}var rF0=["File","Edit","View","Selection","Tools","Help"];function y90(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function aF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return y90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(k9,{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($J,{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)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z($J,{children:G.shortcut})]},G.label))]})}function W1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return y90(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},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):D("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:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z($J,{children:Z.shortcut}):null]},Z.id))]})}function sF0({onAction:J,onClose:X}){return z(W1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function tF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(W1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function eF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(W1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function JL0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(W1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{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 XL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(W1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(W1,{label:"Edit",left:90,onAction:J,onClose:X,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 QL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:O,showHidden:E,onToggleShowHidden:w,onOpenHelp:A,onOpenShortcuts:I,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:x,onTogglePresent:h,printGuidesVisible:l,onTogglePrintGuides:v,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:r,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:I0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:e0,onToggleAutoOpenInspector:D8,onOpenLayers:s8,timelineOpen:w8,onToggleTimeline:N8,hasComps:C0=!1,assistantOpen:A0,onToggleAssistant:$0,assistantBusy:Q8,assistantUnseen:Z8,onNewCanvas:f8,onAssembleVideo:b8,onOpenExport:O9,onOpenSettings:h0,onOpenGenerate:C8,onReload:A9,onCloseCanvas:F8,onInsertArtboard:B0,readOnly:J8=!1}){let r0=J===r8,j0=r0?"SYSTEM":J?"CANVAS":"IDLE",t0=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(Q4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),H8=new Set(W?["autoopen"]:["assistant","autoopen"]),p0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:I0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:I0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!e0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:C0?"video":void 0,checked:w8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:A0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:f,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:l,disabled:!J||r0}].filter((_0)=>!J8||!H8.has(_0.id)),d0=["file","edit","view","selection","tools","help"];function k8(_0){if(d0.includes(_0))H(Z===_0?null:_0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let _0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function X8(P8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let o0=U0.indexOf(document.activeElement);if(P8.key==="ArrowDown")P8.preventDefault(),U0[(o0+1)%U0.length].focus();else if(P8.key==="ArrowUp")P8.preventDefault(),U0[(o0-1+U0.length)%U0.length].focus();else if(P8.key==="Home")P8.preventDefault(),U0[0].focus();else if(P8.key==="End")P8.preventDefault(),U0[U0.length-1].focus();else if(P8.key==="ArrowRight"||P8.key==="ArrowLeft"){P8.preventDefault();let R8=P8.key==="ArrowRight"?1:-1,J9=d0.indexOf(Z);H(d0[(J9+R8+d0.length)%d0.length])}else if(P8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",X8),()=>{clearTimeout(_0),window.removeEventListener("keydown",X8)}},[Z,H]),D("header",{className:"st-menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("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"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:rF0.map((_0)=>{let X8=_0.toLowerCase(),P8=d0.includes(X8),U0=P8||X8==="help",o0=Z===X8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${X8}`,"data-tour":X8==="help"?"help":void 0,"aria-haspopup":P8?"menu":void 0,"aria-expanded":P8?o0:void 0,onClick:()=>k8(X8),onMouseEnter:()=>{if(Z!==null&&P8)H(X8)},children:_0},X8)})}),Z==="file"&&z(JL0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(_0)=>{if(_0==="new")f8?.();else if(_0==="assemble")b8?.();else if(_0==="export")O9?.("export");else if(_0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(_0==="handoff")O9?.("handoff");else if(_0==="generate")C8?.();else if(_0==="settings")h0?.();else if(_0==="reload")A9?.();else if(_0==="close")F8?.()},onClose:()=>H(null)}),Z==="edit"&&z(XL0,{readOnly:J8,hasCanvas:!!J&&!r0,onAction:(_0)=>{if(_0==="undo")n({dgn:"undo"});else if(_0==="redo")n({dgn:"redo"});else if(_0==="deselect-all")n({dgn:"selection-clear"});else if(_0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(_0.startsWith("new-artboard:"))B0?.(_0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(aF0,{panels:p0,onToggle:(_0)=>{if(_0==="tree")O();else if(_0==="changes")N();else if(_0==="comments")U();else if(_0==="hidden")w();else if(_0==="annotate")j();else if(_0==="inspector")s0();else if(_0==="autoopen")D8?.();else if(_0==="timeline")N8?.();else if(_0==="assistant")$0?.();else if(_0==="layers")s8?.();else if(_0==="minimap")m?.();else if(_0==="zoomctl")a?.();else if(_0==="present")h?.();else if(_0==="print-guides")v?.()},onZoom:(_0)=>n({dgn:"zoom",op:_0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(tF0,{readOnly:J8,onAction:(_0)=>{if(_0==="deselect-all")n({dgn:"selection-clear"});else if(_0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(eF0,{readOnly:J8,onAction:(_0)=>n({dgn:"tool-set",tool:_0}),onClose:()=>H(null)}),Z==="help"&&z(sF0,{onAction:(_0)=>{if(_0==="shortcuts")I?.();else if(_0==="help")A?.();else if(_0==="report-bug")T?.();else if(_0==="tour")R?.();else if(_0==="collab-tour")$?.();else if(_0==="quick-setup")H0?.();else if(_0==="readiness")s?.();else if(_0==="whatsnew")e?.();else if(_0==="watch-intro")r?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":A0?"true":"false","data-busy":Q8?"true":"false","data-unseen":Z8?"true":"false","aria-label":`Assistant${Q8?" — working":Z8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:$0,children:z(k9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(k9,{name:"share",size:15})}),i&&z(Pm,{center:i}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:T,children:z(k9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(k9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:j0}),z("span",{className:"st-mb-file",title:J||"",children:t0}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function YL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:O,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let A=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of A.current)if(!I.has(C.path))A.current.delete($);let T=($)=>{let C=IZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=A.current.get(j);if(!f)f={path:$,src:IZ($,H)},A.current.set(j,f);return f.src},R=V&&V.path===X?"error":X&&X!==r8&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${fV(Q4(E))}`,tabIndex:0,children:z(jg,{path:E,kind:AL(Q4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("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"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",qT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("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($J,{children:"⌘"})," and hover to preview an element, click to select it — ",z($J,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{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]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:O,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(VL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:T($.path),title:`Canvas: ${$.path}`,className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("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%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:fV(Q4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var WL0=["color","space","radius","shadow","leading","weight","motion","font","other"],GL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function ZL0(J){return J==="color"}function HL0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("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=X||{},W=Array.from(new Set([...WL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=ZL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",GL0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function zL0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function KL0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function UL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=KL0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=zL0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("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 VL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(O)=>Y&&Y(O.target.value),children:B.map((O)=>z("option",{value:O.name,children:O.name},O.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(HL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(UL0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(B90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(B90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function B90({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:IZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function qL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:O,version:E}){let w=J===r8,A=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",T=W==="dark"?"light":"dark",R=(()=>{let C=nz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{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})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("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:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("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:I,children:A}),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:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),O&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:O,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("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&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function BL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=S90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let O=J[M]||[],E=O.filter((A)=>{if(X==="open")return A.status!=="resolved";if(X==="resolved")return A.status==="resolved";return!0});if(E.length===0)continue;let w=O.filter((A)=>A.selector);F.push({file:M,comments:E.map((A)=>({...A,n:w.findIndex((I)=>I.id===A.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z($J,{children:"⌘"})," and click an element, then press ",z($J,{children:"C"})," — or hold ",z($J,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:X4(Q4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((O)=>D("div",{"data-testid":`comment-item-${O.id}`,className:"st-comment"+(O.status==="resolved"?" is-resolved":"")+(O.id===W?" is-active":""),onClick:()=>G(M.file,O.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:O.n||"·"}),z("span",{className:"st-comment-time",children:RF0(O.created)})]}),z("div",{className:"st-comment-txt",children:O.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(O.dom_path||[]).join(" > "),children:O.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[O.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(O.id)},children:z(k9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(O.id)},children:z(k9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(O.id)},children:z(k9,{name:"x",size:14})})]}):null]})]},O.id))]},M.file))})]})}var NL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function FL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=NL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function LL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),wh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function DL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`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",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var ML0=["block","inline-block","flex","inline-flex","grid","inline","none"],N90=["px","%","fr","em","auto","min-content","max-content"];var OL0=["auto","stretch","flex-start","center","flex-end","baseline"];var F90=["300","400","500","600","700","800"],Lq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,L90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],D90=["none","solid","dashed","dotted","double"],M90=["px","rem","em","%","vw","vh","auto"],O90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),UT={"font-size":{node:z(K7,{as:hV,size:12})},"line-height":{node:z(K7,{as:cV,size:12})},"letter-spacing":{node:z(K7,{as:J3,size:12})},gap:{node:z(K7,{as:TK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:G3,size:12})},"border-width":{node:z(K7,{as:eV,size:12})}};var A90=["static","relative","absolute","fixed","sticky"],AL0=["normal","italic","oblique"],_90=["none","uppercase","lowercase","capitalize"];var w90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],_L0=["fill","contain","cover","none","scale-down"];var E90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],S5={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}},X1=null;function OL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!X1)X1=document.createElement("canvas").getContext("2d");if(!X1)return"";X1.fillStyle="#000000",X1.fillStyle=J;let X=X1.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.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=(J)=>Math.min(1,Math.max(0,J));function qL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Dq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Mq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function Q1({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function J4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function I90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function j90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function wL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),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 v90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...wL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function f90({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>Mq(qL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(Mq(qL(J)))},[J]);let U=Dq(Q1(Y)),V=(A)=>{A.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let T=G.current.h,R=(C)=>{W({h:T,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(A);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Dq(Q1(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(A)=>{A.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:T,v:R})};$(A);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Dq(Q1(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(A)=>{let I={...G.current,...A};W(I),Q(Dq(Q1(I)))},F=(A)=>{let I=A.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[A.key];if(!R)return;A.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(A)=>{let I=A.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[A.key];if(R==null)return;A.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},O=async()=>{try{let A=window.EyeDropper;if(!A)return;let I=await new A().open();if(I?.sRGBHex)W(Mq(qL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=Q1(Y),w=(A)=>{let I={...E,...A},T=Mq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(T),Q(Dq(Q1(T)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(A)=>{let I=A.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(Mq(qL(I)))},onKeyDown:(A)=>{if(A.key==="Enter")Q(A.currentTarget.value)},onBlur:(A)=>Q(A.currentTarget.value),onFocus:(A)=>A.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("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:O,children:z(k9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} 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((A)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":A.toUpperCase(),value:Math.round(E[A]),onChange:(I)=>w({[A]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:A.toUpperCase()})]},A))})]})}function FL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[O,E]=u.useState(""),w=u.useRef(null),A=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,s)=>e+(s.names?.length||0),0),j=$.length>1,f=O.trim().toLowerCase(),m=!f?$:$.map((e)=>({...e,names:(e.names||[]).filter((s)=>R(s).toLowerCase().includes(f)||s.toLowerCase().includes(f)||(e.vals?.[s]||"").toLowerCase().includes(f))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let i=224,q0=300,Z0=Math.min(z0.right-i,window.innerWidth-i-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(A.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},H0=(z0)=>{if(z0.key==="Escape")V(!1)},r=(z0)=>{if(A.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!A.current)return;let e=A.current.getBoundingClientRect(),s=B.left-e.left,H0=B.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)N((r)=>r?{...r,left:r.left+s,top:r.top+H0}:r)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,s,H0)=>{if(H&&e&&e!==H&&H0&&!d.test(H0))Y(H0);else Y(`var(${s})`);V(!1)},x=(e)=>{let s=(e||"").trim();if(s)Y(s)},h=D("div",{className:"st-cp-pop-search",children:[z(k9,{name:"search",size:12}),z("input",{value:O,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(H0)?" is-on":""}`,onClick:()=>a(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:s.vals?.[H0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),v=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row${T(H0)?" is-on":""}`,onClick:()=>a(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),n=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?T90.createPortal(z("div",{ref:A,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:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(f90,{seed:Z||OL(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?l(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):n]})}),document.body):null]})}function k90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?jU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=jU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:N90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(oN,{value:K.unit,units:N90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}var Y1={pending:0,waiters:[]};function x90(J){Y1.pending+=1;let X=()=>{if(Y1.pending-=1,Y1.pending===0)for(let Q of Y1.waiters.splice(0))Q()};return J.then(X,X),J}function EL0(){return Y1.pending===0?Promise.resolve():new Promise((J)=>Y1.waiters.push(J))}function PL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let E0={...t||{}};for(let[v0,W8]of Object.entries(M0))if(W8===null)delete E0[v0];else E0[v0]=W8;return E0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),O=N(J.attrs,V.t),E=(t,M0)=>B((E0)=>({...E0,a:{...E0.a,[t]:M0}})),w=(t,M0)=>B((E0)=>({...E0,c:{...E0.c,[t]:M0}})),A=(t,M0)=>B((E0)=>({...E0,t:{...E0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=j90(J.file,X),R=v90(X,I,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[f,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(O).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let x=H,[h,l]=u.useState({});async function v(t,M0,E0){j((v0)=>({...v0,[E0]:"saving"}));try{let v0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),W8=await v0.json().catch(()=>({}));return j((g8)=>({...g8,[E0]:!v0.ok||!W8.ok?`err:${W8&&W8.error||`HTTP ${v0.status}`}`:"saved"})),v0.ok?W8:null}catch(v0){return j((W8)=>({...W8,[E0]:`err:${v0&&v0.message?v0.message:String(v0)}`})),null}}let n=u.useRef(Promise.resolve()),e=(t,M0,E0,v0,W8,g8,t8)=>{n.current=x90(n.current.then(async()=>{let v8=await v(t,M0,E0);if(!v8?.ok)return;let W9=Object.hasOwn(v8,"previous")?v8.previous:g8;if((W9??null)===(t8??null))return;H0(v0,W8,W9,t8)}))},s=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},H0=(t,M0,E0,v0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:E0==null||E0===""?null:E0,after:v0==null||v0===""?null:v0})},r=(t,M0)=>{let E0=(M0||"").trim();if(!K||!E0)return;let v0=F[t]??null;if(E0===(v0??"").trim())return;s(t,E0),E(t,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:E0},t,"css",t,v0,E0)},z0=(t,M0)=>{let E0=(M0||"").trim(),v0=t.trim();if(!K||!v0||!E0)return;let W8=M[v0]??null;s(v0,E0),w(v0,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:v0,value:E0},v0,"css",v0,W8,E0)},i=(t,M0)=>{let E0=(t||"").trim(),v0=(M0||"").trim();if(!K||!E0||!v0)return;let W8=O[E0]??null;A(E0,v0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:E0,value:v0},`@${E0}`,"attr",E0,W8,v0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;s(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;s(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},I0=(t)=>{if(!K)return;let M0=O[t]??null;A(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let E0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),v0=ub(t,M0,a0,E0);for(let W8 of v0.reset)if(F[W8])q0(W8);for(let[W8,g8]of v0.set)r(W8,g8)},e0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",D8=(t)=>{let M0=mb(t,F,U,a0);return D("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(nN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(E0)=>s0(t,E0)})})]},`mode-${t}`)},s8=["flex-start","center","flex-end"],w8=["flex-start","center","flex-end"],N8=["t","c","b"],C0=["l","c","r"],A0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,s8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),E0=F["align-items"]||U7(U["align-items"])||"stretch",v0=E0==="stretch"?1:Math.max(0,w8.indexOf(E0)),[W8,g8]=t?[M0,v0]:[v0,M0];return N8[g8]+C0[W8]},$0=(t)=>{let M0=N8.indexOf(t[0]),E0=C0.indexOf(t[1]),v0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[W8,g8]=v0?[E0,M0]:[M0,E0];r("justify-content",s8[W8]),r("align-items",w8[g8])},Q8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},Z8=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let f8={bound:"token-bound",raw:"raw override",inherit:"inherited"},b8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":f8[t]}),O9=(t,M0)=>{let E0=M0??Z8(t),v0=C[t],W8=typeof v0==="string"&&v0.startsWith("err:")?v0.slice(4):"",g8=W8?" is-err":v0==="saved"?" is-saved":v0==="saving"?" is-saving":"",t8=!!F[t],v8=W8?`error: ${W8}`:t8?`${f8[E0]} · double-click to reset`:f8[E0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${E0}${g8}${t8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:t8?0:-1,onDoubleClick:t8?()=>q0(t):void 0,onKeyDown:t8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},h0=(t,M0,E0,v0)=>{let W8=E0===void 0&&!F[t],g8=v0??t;return D("div",{className:`st-cp-row${W8?" is-unset":""}`,children:[O9(t,E0),z("label",{className:"st-cp-label",title:g8,children:g8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},C8={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"]},A9=(t)=>{(C8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},F8=(t,M0)=>{let E0=(C8[t]||[]).some((v0)=>F[v0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!f[t],onClick:()=>m((v0)=>({...v0,[t]:!v0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${E0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!E0,onClick:()=>A9(t),children:z(K7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},B0=(t,M0,E0,v0=!0)=>{let W8=`d:${t}`,g8=f[W8]===void 0?v0:f[W8],t8=M0.some((v8)=>F[v8]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":g8,onClick:()=>m((v8)=>({...v8,[W8]:!g8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:g8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${t8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!t8,onClick:()=>M0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(K7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${g8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:E0})})]},W8)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>l((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(E0)=>r(t,E0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((E0)=>z("option",{value:E0,children:E0},E0))]}),j0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((E0)=>({name:E0,value:M0.vals?.[E0]||""}))),t0=(t,M0)=>z(dw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(E0)=>r(t,E0)}),H8=(t,M0,E0={})=>{let v0=J4(F[t]??""),W8=O90.has(t),g8=F[t]??"",t8=typeof g8==="string"&&/var\(\s*--/.test(g8),v8=W8?"":v0.unit&&v0.unit!=="auto"?v0.unit:"px",W9=Number.parseFloat(J4(U7(U[t])??"").n)||0,T9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:W9,e9=UT[t];return z(rN,{value:t8?g8:T9,tokens:j0(M0),ariaLabel:t,min:E0.min??0,lead:e9?e9.node??e9.t:void 0,unitSlot:W8?null:z(oN,{units:M90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>r(t,J7==="auto"?"auto":`${v0.n||"0"}${J7}`)}),onChange:(J7)=>r(t,typeof J7==="string"?J7:W8?`${J7}`:`${J7}${v8}`)})},p0=()=>{let t=(W8)=>Number.parseFloat(J4(F[W8]??F["border-radius"]??U7(U[W8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},E0=(W8)=>{if(W8.tl===W8.tr&&W8.tr===W8.bl&&W8.bl===W8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((t8)=>{if(F[t8])q0(t8)}),r("border-radius",`${W8.tl}px`);else r("border-top-left-radius",`${W8.tl}px`),r("border-top-right-radius",`${W8.tr}px`),r("border-bottom-left-radius",`${W8.bl}px`),r("border-bottom-right-radius",`${W8.br}px`)},v0=UT["border-radius"];return z(dg,{corners:M0,lead:v0?v0.node??v0.t:void 0,onCorners:E0})},d0=()=>D("div",{className:"st-cp-border",children:[X9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:D90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>r("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),D90.map((t)=>z("option",{value:t,children:t},t))]}),z(FL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:OL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>r("border-color",t),label:"border colour"})]}),k8=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),E0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,v0=(W8)=>{let g8=(W8%360+360)%360,t8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();r("transform",`${t8?`${t8} `:""}rotate(${g8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(pg,{value:E0,onChange:v0}),z(zJ,{value:E0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:rZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:v0})]})},_0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),E0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:E0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(W8)=>{let g8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();r("filter",W8>0?`${g8?`${g8} `:""}blur(${W8}px)`.trim():g8||"none")}})},X8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,E0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(uX,{value:E0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(v0)=>s("opacity",String(v0/100)),onCommit:(v0)=>r("opacity",String(v0/100))},`opacity:${t??""}`)},P8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",E0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(mg,{value:{b:t,i:M0,u:E0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:iV}),label:"Bold"},{value:"i",node:z(K7,{as:sV}),label:"Italic"},{value:"u",node:z(K7,{as:z3}),label:"Underline"}],onToggle:(v0)=>{if(v0==="b")r("font-weight",t?"400":"700");else if(v0==="i")r("font-style",M0?"normal":"italic");else r("text-decoration",E0?"none":"underline")}})},U0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:uV}),label:"Start"},{value:"center",node:z(K7,{as:gV}),label:"Center"},{value:"flex-end",node:z(K7,{as:mV}),label:"End"},{value:"space-between",node:z(K7,{as:TK}),label:"Space between"}],R8=[{value:"flex-start",node:z(K7,{as:dV}),label:"Start"},{value:"center",node:z(K7,{as:pV}),label:"Center"},{value:"flex-end",node:z(K7,{as:lV}),label:"End"},{value:"stretch",node:z(K7,{as:Z3}),label:"Stretch"}],J9=[{value:"left",node:z(K7,{as:a5}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],i0=[{value:"visible",node:z(K7,{as:nZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:aZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:Y3}),label:"Scroll"}],a7=(t,M0)=>{let E0=$(M0);return E0.length?z(FL,{kind:"value",groups:E0,current:F[t],activeDs:T,onPick:(v0)=>r(t,v0),label:`${t} design token`}):null},F9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let E0=t.shiftKey?10:1,v0=t.key==="ArrowUp"?1:-1,W8=(Number.parseFloat(t.currentTarget.value)||0)+v0*E0;return t.currentTarget.value=String(W8),M0(W8),!0},I8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>r(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),X9=(t,M0,E0={})=>{let v0=J4(F[t]??""),W8=O90.has(t),g8=W8?"":E0.fixedUnit||(v0.unit&&v0.unit!=="auto"?v0.unit:"px"),t8=UT[t],v8=Number.parseFloat(J4(U7(U[t])??"").n)||0,W9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:v8;return D(Q0,{children:[z(zJ,{value:W9,min:E0.min??0,step:1,ariaLabel:t,lead:t8?t8.node??t8.t:void 0,onCommit:(T9)=>r(t,W8?`${T9}`:`${T9}${g8}`),unitSlot:W8||E0.fixedUnit?null:z(oN,{units:M90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(T9)=>r(t,T9==="auto"?"auto":`${v0.n||"0"}${T9}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},d8=(t)=>{let M0=U[t]||F[t]||"",E0=F[t]??"",v0=typeof E0==="string"&&/var\(\s*--/.test(E0),W8=v0?E0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):E0;return z(U3,{swatch:z(FL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:OL(U[t]||F[t])||"#000000",onPick:(g8)=>r(t,g8),label:`${t} colour`}),displayValue:W8,bound:v0,ariaLabel:t,onValue:(g8)=>r(t,g8)})},O0=(t,M0)=>{let E0=null,v0=M0.unitless?"":"px",W8=(v8)=>M0.unitless?`${v8}`:`${v8}${v0}`,g8=(v8,W9,T9)=>{for(let e9 of W9??[t])T9(e9,W8(v8))},t8=lw({getBase:()=>E0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(v8,W9)=>{if(E0)E0.value=String(v8);if(W9){let T9=E0?.closest(".st-cp-box");for(let e9 of W9){if(e9===t)continue;let J7=T9?.querySelector(`.st-cp-boxv[aria-label="${e9}"]`);if(J7)J7.value=String(v8)}}g8(v8,W9,s)},onCommit:(v8,W9)=>g8(v8,W9,r)});return{onPointerDown:(v8)=>{E0=v8.currentTarget,t8(v8)}}},K8=(t,M0)=>{let E0=F[t],v0=E0!=null&&E0!==""?J4(E0).n||E0:J4(U7(U[t])??"").n||"0",W8=!E0||E0==="0"||E0==="0px"||E0==="auto",g8=t.split("-").pop(),t8=g8==="top"||g8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],v8=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${W8?" is-zero":""}`,"aria-label":t,defaultValue:v0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:t8,all:v8}}),onFocus:F9,onKeyDown:(W9)=>{if(v7(W9,(T9)=>r(t,`${T9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let T9=W9.currentTarget.value.trim();if(!T9)return;let e9=/[a-z%]/i.test(T9)?T9:`${T9}px`;r(t,e9)}},`${t}:${E0??""}`)},S8=(t)=>{let M0=F[t],E0=M0!=null&&M0!==""&&M0!=="auto"?J4(M0).n||M0:J4(U7(U[t])??"").n||"",v0=!M0||M0==="auto"||M0==="0"||M0==="0px",W8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],g8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${v0?" is-zero":""}`,"aria-label":t,defaultValue:E0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:W8,all:g8},min:-1/0}),onFocus:F9,onKeyDown:(t8)=>{if(v7(t8,(v8)=>r(t,`${v8}px`)))return;if(t8.key==="Enter")t8.currentTarget.blur()},onBlur:(t8)=>{let v8=t8.currentTarget.value.trim();if(!v8)return;let W9=/[a-z%]/i.test(v8)?v8:`${v8}px`;r(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),x9=Object.entries(O),i9=()=>{let t=(J.tag||"").toLowerCase(),E0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],v0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:E0,canReplace:v0}},h9=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),h0("object-fit",r0("object-fit",_L0)),h0("object-position",I8("object-position")),h0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:P90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let E0=M0.target.value;if(r("aspect-ratio",E0),E0&&E0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),P90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:Q8,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(dw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?D(Q0,{children:[B0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[h0("flex-direction",t0("flex-direction",U0),void 0,"Direction"),h0("align-items",z(ug,{value:A0(),onChange:$0,ariaLabel:"auto-layout alignment"}),Z8("align-items"),"Alignment"),h0("gap",H8("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[D8("width"),D8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[b8(Z8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>r("flex-wrap",E0?"wrap":"nowrap")}),Z8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[h0("width",X9("width"),void 0,"Width"),h0("height",X9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[h0("min-width",X9("min-width"),void 0,"Min width"),h0("max-width",X9("max-width"),void 0,"Max width"),h0("min-height",X9("min-height"),void 0,"Min height"),h0("max-height",X9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[h0("position",r0("position",A90),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[b8(Z8("top")),"inset"]}),S8("top"),S8("right"),S8("bottom"),S8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?h0("z-index",X9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],h0("background-color",d8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],h0("border",d0(),Z8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],h0("border-radius",p0(),Z8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[h0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow"),void 0,"Shadow"),h0("filter",_0(),Z8("filter"),"Blur"),h0("mix-blend-mode",r0("mix-blend-mode",E90),void 0,"Blend")]})),B0("Opacity",["opacity"],h0("opacity",X8(),void 0,"Opacity")),B0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[h0("font-family",r0("font-family",L90),void 0,"Font"),h0("color",d8("color"),void 0,"Color"),h0("font-size",H8("font-size","type"),void 0,"Size"),h0("font-weight",r0("font-weight",F90),void 0,"Weight"),h0("line-height",X9("line-height","lh"),void 0,"Line height"),h0("text-align",t0("text-align",J9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[h0("letter-spacing",X9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),h0("font-style",r0("font-style",AL0),void 0,"Style"),h0("text-transform",r0("text-transform",_90),void 0,"Case"),h0("white-space",r0("white-space",w90),void 0,"Whitespace")]}):null]})),B0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[b8(Z8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],h9(M0)):null})()]}):D(Q0,{children:[F8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",E0=t==="grid"||t==="inline-grid";return D(Q0,{children:[h0("display",r0("display",ML0)),M0?D(Q0,{children:[h0("flex-direction",t0("flex-direction",U0)),h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(v0)=>r("flex-wrap",v0?"wrap":"nowrap")}),Z8("flex-wrap"))]}):null,M0||E0?D(Q0,{children:[h0("align-items",t0("align-items",R8)),h0("justify-content",t0("justify-content",o0)),h0("gap",H8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let E0=F["grid-template-columns"]||"",v0=F["grid-template-rows"]||"",W8=$O(E0),g8=$O(v0),t8=W8.length>0||!E0.trim(),v8=g8.length>0||!v0.trim();return F8("Grid",D(Q0,{children:[t8?z(k90,{label:"Columns",tracks:W8,editable:K,onChange:(W9)=>r("grid-template-columns",SO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:E0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(k90,{label:"Rows",tracks:g8,editable:K,onChange:(W9)=>r("grid-template-rows",SO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:v0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),F8("Position",D(Q0,{children:[h0("position",r0("position",A90)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[b8(Z8("top")),"inset"]}),S8("top"),S8("right"),S8("bottom"),S8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,h0("z-index",X9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&F8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),h0("grid-column",I8("grid-column")),h0("grid-row",I8("grid-row"))]})),F8("Typography",D(Q0,{children:[h0("font-family",r0("font-family",L90)),h0("color",d8("color")),h0("font-size",H8("font-size","type")),h0("font-weight",r0("font-weight",F90)),h0("line-height",X9("line-height","lh")),h0("letter-spacing",X9("letter-spacing",null,{min:-1/0})),h0("text-align",t0("text-align",J9)),h0("font-style",P8(),Z8("font-style")),h0("text-transform",r0("text-transform",_90)),h0("white-space",r0("white-space",w90))]})),F8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[b8(Z8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[b8(Z8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),F8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[D8("width"),D8("height")]}),h0("width",X9("width")),h0("height",X9("height")),h0("min-width",X9("min-width")),h0("max-width",X9("max-width")),h0("min-height",X9("min-height")),h0("max-height",X9("max-height")),h0("overflow",t0("overflow",i0)),e0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),h0("align-self",r0("align-self",OL0)),h0("flex-grow",X9("flex-grow",null,{unitless:!0})),h0("flex-shrink",X9("flex-shrink",null,{unitless:!0})),h0("flex-basis",X9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?F8("Media",h9(M0)):null})(),F8("Appearance",D(Q0,{children:[h0("background-color",d8("background-color")),h0("border-radius",p0(),Z8("border-radius")),h0("border",d0(),Z8("border-width")),h0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow")),h0("filter",_0(),Z8("filter")),h0("mix-blend-mode",r0("mix-blend-mode",E90)),h0("opacity",X8()),h0("rotation",k8(),Z8("transform")),h0("transform",I8("transform")),h0("transform-origin",I8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(k9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),F8("Advanced",D("div",{className:"st-cp-advbody",children:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("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:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>z0(t,E0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(k9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(IL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x9.map(([t,M0])=>D("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:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>i(t,E0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>I0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(kL0,{commit:i})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function IL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,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 kL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,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 TL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function RL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var CL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function h90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:O,onRename:E}){let w=`${J.id}:${J.index}`,A=J.children&&J.children.length>0,I=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=u.useState(!1),[f,m]=u.useState(""),d=!T&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,x=!!V&&!T&&!$,h=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},l=N?.key===w,v=l?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":T?void 0:d,"aria-expanded":A?!I:void 0,"aria-grabbed":x?l:void 0,tabIndex:0,title:T?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>T?A&&Z(w):H(J),onMouseEnter:()=>!T&&K(J),onMouseLeave:()=>K(null),onPointerDown:x?(n)=>B(n,J,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),T)A&&Z(w);else H(J);else if(n.key==="F2"&&E&&!T)n.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[A?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:TL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>m(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:h,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")h();else if(n.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(n)=>{n.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),O&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),O(w)},children:z(k9,{name:$?"lock":"unlock",size:12})}):null,U&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(J)},children:z(k9,{name:a?"eye-off":"eye",size:13})}):null]}),A&&!I?J.children.map((n,e)=>z(h90,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:O,onRename:E},`${n.id}:${n.index}`)):null]})}function $L0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("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)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?J4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("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?D("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 g90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var SL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],bL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function yL0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=g90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=j90(J.file,X),B=v90(X,U,V),N=(v)=>B.map((n)=>({ds:n.name,names:n[v]||[],vals:n.vals})).filter((n)=>n.names.length),F=(v)=>N(v).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(v)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!n)return v||"";for(let e of B){let s=e.vals?.[n[1]];if(s)return s}return""},O=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,n)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,s=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},A=Object.entries(S5).find(([,v])=>v.width===O&&v.height===E)?.[0],I=Object.entries(S5).find(([,v])=>v.width===O)?.[0],T=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",f=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let n=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=QB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,n),v==="web"&&T)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let n={paper:"a4",...m,...v},e;try{e=QB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},x=(v,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let n=xb(T,v);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")x(!0,n.height)},l=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:O??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),XB.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${S5[I].label} — ≤ ${S5[I].width}px`:"Breakpoint…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ≤ ",n.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:A??"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:A?S5[A].label:"Preset size…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"×",n.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(nN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:f,ariaLabel:"artboard kind",options:bL0.map(([v,n])=>({value:v,label:n})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let n=S5[v.currentTarget.value];if(n)H(K,n.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(S5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"px"]},v))]})}):null,f==="print"?D(Q0,{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(nN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{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:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(U3,{swatch:z(FL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:OL(v)||"#000000",onPick:(s)=>l({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>l({background:(s||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:SL0.map(([v,n])=>({value:v,label:n})),onChange:(v)=>l({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(rN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>l({padding:typeof v==="string"?v:v>0?v:null})}),z(rN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>l({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var BT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,jL0=new RegExp(BT.source,"gi");function vL0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(jL0)||[])],G=[...new Set([...X.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(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=BT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function fL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:O,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:A,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:d,resizing:a,photoSel:x,photoRev:h,onPhotoEdit:l,onPhotoRemoveBackground:v,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:r,onSetCpMode:z0}){let[i,q0]=u.useState("inspect"),Z0=s?"layers":f??i,I0=(p0)=>{q0(p0),m?.(p0)},[a0,s0]=u.useState(()=>new Set),[e0,D8]=u.useState(()=>new Map);u.useEffect(()=>{let p0=Array.isArray(X)?X[0]:X,d0=p0?.id;if(!d0||!Y?.nodes)return;let k8=p0.index,_0=null,X8=[];if(function P8(U0,o0){for(let R8 of U0||[]){let J9=`${R8.id}:${R8.index}`;if(!R8.synthetic&&R8.id===d0&&(k8==null||R8.index===k8))return _0=J9,X8.push(...o0),!0;if(R8.children&&R8.children.length&&P8(R8.children,[...o0,J9]))return!0}return!1}(Y.nodes,[]),!_0)return;if(X8.length)s0((P8)=>{let U0=!1,o0=new Set(P8);for(let R8 of X8)if(o0.delete(R8))U0=!0;return U0?o0:P8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${_0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let s8=(p0)=>{let d0=`${p0.id}:${p0.index}`;return e0.has(d0)?e0.get(d0):!!p0.hidden},[w8,N8]=u.useState(null),[C0,A0]=u.useState(""),$0=(p0,d0)=>{if(!K||!p0?.id)return;x90(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:p0.id,attr:"data-dc-element",value:d0})}).then((k8)=>k8.json().catch(()=>({}))).then((k8)=>{if(!k8.ok)return;O?.({op:"attr",canvas:K,id:p0.id,key:"data-dc-element",before:p0.dcElement??null,after:d0})}).catch(()=>{}))},Q8=B?(p0,d0,k8)=>{if(N?.current)return;if(p0?.synthetic||d0?.synthetic)return;let _0=k8==="before"?`before ${d0.label}`:k8==="after"?`after ${d0.label}`:`into ${d0.label}`;A0(`Moved ${p0.label} ${_0}`),B(p0.id,d0.id,k8,{idIndex:p0.index,refIndex:d0.index})}:void 0,Z8=()=>{let p0=[];return function d0(k8,_0,X8){(k8||[]).forEach((P8,U0)=>{if(p0.push({node:P8,depth:_0,parentNode:X8,siblings:k8,pos:U0}),P8.children&&P8.children.length&&!a0.has(`${P8.id}:${P8.index}`))d0(P8.children,_0+1,P8)})}(Y?.nodes,0,null),p0},f8=(p0)=>{if(p0.key!=="ArrowUp"&&p0.key!=="ArrowDown")return;if(!F8)return;let d0=Z8(),k8=d0.findIndex((U0)=>U0.node.id===F8.id&&U0.node.index===F8.index);if(k8<0)return;let _0=p0.key==="ArrowDown"?1:-1,X8=d0[k8];if(!p0.altKey){let U0=d0[k8+_0];if(U0)p0.preventDefault(),U?.(U0.node);return}if(!Q8||!Array.isArray(X8.siblings))return;p0.preventDefault();let P8=(U0)=>U0&&U0.children&&U0.children.length&&!a0.has(`${U0.id}:${U0.index}`);if(!p0.shiftKey){if(_0<0&&X8.pos>0)Q8(X8.node,X8.siblings[X8.pos-1],"before");else if(_0>0&&X8.pos<X8.siblings.length-1)Q8(X8.node,X8.siblings[X8.pos+1],"after");return}if(_0>0){let U0=X8.siblings[X8.pos+1];if(U0)Q8(X8.node,U0,P8(U0)?"inside-start":"after");else if(X8.parentNode)Q8(X8.node,X8.parentNode,"after")}else{let U0=X8.siblings[X8.pos-1];if(U0)Q8(X8.node,U0,P8(U0)?"inside-end":"before");else if(X8.parentNode)Q8(X8.node,X8.parentNode,"before")}},b8=u.useRef(null),O9=u.useRef(null),h0=(p0,d0,k8)=>{if(!Q8||p0.button!==0||p0.metaKey||p0.ctrlKey||p0.shiftKey||p0.altKey)return;if(N?.current)return;let{clientX:_0,clientY:X8}=p0,P8=new Set([k8]);(function d8(O0){(O0.children||[]).forEach((K8)=>{P8.add(`${K8.id}:${K8.index}`),d8(K8)})})(d0);let U0=14,o0=6,R8=[];(function d8(O0,K8){(O0||[]).forEach((S8)=>{let V9=`${S8.id}:${S8.index}`;if(R8.push({node:S8,key:V9,id:S8.id,depth:K8,tag:S8.tag}),S8.children&&S8.children.length&&!a0.has(V9))d8(S8.children,K8+1)})})(Y?.nodes,0);let J9=new Map(R8.map((d8)=>[d8.key,d8])),i0=!1,a7=(d8)=>{if(!i0){if(Math.hypot(d8.clientX-_0,d8.clientY-X8)<4)return;i0=!0}let O0=d8.clientX-_0,K8=d8.clientY-X8,S8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i9)=>({rect:i9.getBoundingClientRect(),it:J9.get(i9.getAttribute("data-layer-key"))})).filter((i9)=>i9.it&&i9.it.key!==k8);if(V9.length){let i9=V9[0].rect.left,h9=V9[0].rect.right,t=V9.length;for(let e9=0;e9<V9.length;e9++)if(d8.clientY<V9[e9].rect.top+V9[e9].rect.height/2){t=e9;break}let M0=V9[t-1]?.it||null,E0=V9[t]?.it||null,v0=Math.round((d8.clientX-i9-o0)/U0),W8=M0?M0.depth+(CL0.has(M0.tag)?0:1):0,g8=E0?E0.depth:0,t8=Math.max(g8,Math.min(v0,W8)),v8=null,W9="before",T9=0;if(!M0){if(E0)v8=E0,W9="before",T9=E0.depth}else if(t8>M0.depth)v8=M0,W9="inside-start",T9=M0.depth+1;else if(t8===M0.depth)v8=M0,W9="after",T9=M0.depth;else{for(let e9=t-1;e9>=0;e9--)if(V9[e9].it.depth===t8){v8=V9[e9].it;break}if(!v8)v8=M0;W9="after",T9=t8}if(v8&&v8.key!==k8&&!P8.has(v8.key)){let e9=M0?V9[t-1].rect.bottom:V9[0].rect.top,J7=i9+o0+T9*U0;S8={refId:v8.id,position:W9,node:v8.node,y:e9,left:J7,w:Math.max(24,h9-J7)}}}let x9={key:k8,node:d0,dx:O0,dy:K8,target:S8};b8.current=x9,N8(x9)},F9=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I8),window.removeEventListener("keydown",X9,!0)},v7=()=>{let d8=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",d8,!0)};document.addEventListener("click",d8,!0),setTimeout(()=>document.removeEventListener("click",d8,!0),300)},I8=()=>{F9();let d8=b8.current;if(b8.current=null,N8(null),i0&&d8?.target)v7(),Q8(d8.node,d8.target.node,d8.target.position)},X9=(d8)=>{if(d8.key!=="Escape")return;if(d8.preventDefault(),d8.stopImmediatePropagation(),F9(),b8.current=null,N8(null),i0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I8),window.addEventListener("keydown",X9,!0)},C8=(p0)=>s0((d0)=>{let k8=new Set(d0);if(k8.has(p0))k8.delete(p0);else k8.add(p0);return k8}),A9=(p0)=>{let d0=`${p0.id}:${p0.index}`,k8=s8(p0),_0=!k8;if(D8((X8)=>new Map(X8).set(d0,_0)),M?.({id:p0.id,artboardId:Y?.artboardId??null,index:p0.index,prop:"display",value:_0?"none":null}),!K||!p0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0?{canvas:K,id:p0.id,property:"display",value:"none"}:{canvas:K,id:p0.id,property:"display",reset:!0})}).catch(()=>{}),O?.({op:"css",canvas:K,id:p0.id,key:"display",before:k8?"none":null,after:_0?"none":null})},F8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let p0=vL0(F8);return p0?{asset:p0,kind:"artboard-img"}:null})(),J8=B0?.kind==="annotation-image",r0=(p0)=>{if(!(p0.metaKey||p0.ctrlKey)||p0.altKey)return;let d0=p0.key.toLowerCase();if(d0==="z")p0.preventDefault(),e?.(p0.shiftKey?"redo":"undo");else if(d0==="y")p0.preventDefault(),e?.("redo")},j0=J8?"photo":Z0==="photo"&&!B0?"css":Z0,t0=(p0,d0,k8)=>D("button",{type:"button",className:"st-rp-tab"+(j0===p0?" is-active":""),onClick:()=>I0(p0),children:[z(k9,{name:k8,size:14}),d0]}),H8=F8?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[J8?t0("photo","Photo","image"):D(Q0,{children:[t0("inspect","Inspect","sliders"),!H0&&t0("layers","Layers","layers"),t0("css","CSS","code"),B0?t0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(k9,{name:"x",size:14})})]}),F8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.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"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(F8.id,F8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:j0==="photo"&&B0?z("div",{onKeyDown:r0,children:z(Nm,{asset:B0.asset,ColorPicker:f90,StIcon:k9,onEdit:(p0)=>l?.(B0.asset,p0),onRemoveBackground:v,onRecordEdit:(p0,d0)=>n?.(B0.asset,p0,d0)},`${B0.asset}:${h??0}`)}):!F8&&!(j0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z($J,{children:"V"}),", then click an element to select it — or ",z($J,{children:"⌘"}),"-click straight from Browse."]})}):F8&&j0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:F8.selector||F8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:H8?Math.round(H8.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:H8?Math.round(H8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:H8?Math.round(H8.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:H8?Math.round(H8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("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:F8.tag||"—"})})]}),F8.classes?D("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:F8.classes})})]}):null,z($L0,{el:F8})]}):j0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[Q8?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:O9,onKeyDown:f8,children:Y.nodes.map((p0,d0)=>z(h90,{node:p0,depth:0,selectedId:F8?.id,selectedIndex:F8?.index,collapsed:a0,hiddenOverride:e0,onToggle:C8,onSelect:(k8)=>{U?.(k8),O9.current?.focus()},onHover:(k8)=>V?.(k8),onToggleVisibility:A9,onReorder:Q8,onRowPointerDown:h0,dragState:w8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:$0},`${p0.id}:${p0.index}`))}),w8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:w8.target.left,top:w8.target.y-1,width:w8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:C0})]}):F8&&Array.isArray(F8.dom_path)&&F8.dom_path.length?F8.dom_path.map((p0,d0)=>D("div",{className:"st-layer"+(d0===F8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(k9,{name:"square",size:13}),p0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!F8.id&&g90(F8)?z(yL0,{el:F8,cfg:F,onResizeArtboard:w,onSetArtboardHug:A,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(PL0,{el:F8,cfg:F,onOptimistic:M,onRecordEdit:O,onReplaceMedia:E,onUndoRedo:C,mode:r,onSetMode:z0})})]})}function xL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[O,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=O},[O]);let[A,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(O)?O.length===1?O[0]:null:O,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let c=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:c.signal}).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(K0?.ok)I(K0)}).catch(()=>{}),()=>c.abort()},[O,V]);let T=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let c=w.current,X0=Array.isArray(c)?c[0]:c;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let K0=c8.current.get(b.file);if(!K0?.contentWindow)return;try{K0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let c of C.current)clearTimeout(c);C.current=[50,450,1200,2500,5000].map((c)=>setTimeout(()=>{let X0=w.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.artboardId!==b||K0.file!==S)return;let F0=c8.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},c))},[]),f=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,c)=>{let X0=f.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function w0(p){return(p||[]).some((L0)=>L0.id===X0.movedId||w0(L0.children))}(b))return;f.current=null;let F0=V?c8.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:c,index:0},"*")}catch{}};let a=u.useRef(null),x=u.useRef(null),h=u.useRef(null),l=u.useRef(!1),v=u.useRef(null),[n,e]=u.useState(null),[s,H0]=u.useState(null),r=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!n)return;let b=Date.now(),S=r.current;if(S.canvas===V&&b-S.at<1500)return;r.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((c)=>c.json()).then((c)=>{if(c?.ok&&c.map&&typeof c.map==="object")H0(c.map);else H0(null)}).catch(()=>H0(null))},[V,n]);let[z0,i]=u.useState(!1),[q0,Z0]=u.useState(null),[I0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=I0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))UL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let c=(b.blocked??[]).reduce((X0,K0)=>X0+K0.count,0);UL("Sync needs a decision",`${c} file${c===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[I0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=I0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[I0?.files?.progress]);let[e0,D8]=u.useState(null),[s8,w8]=u.useState(null),[N8,C0]=u.useState(null),[A0,$0]=u.useState(null),[Q8,Z8]=u.useState(!1),[f8,b8]=u.useState(!1),[O9,h0]=u.useState(null),[C8,A9]=u.useState(""),[F8,B0]=u.useState(null),[J8,r0]=u.useState(null),j0=u.useRef(null),[t0,H8]=u.useState(null),[p0,d0]=u.useState(0),[k8,_0]=u.useState(null),X8=z90("maude-sb-w",{min:200,max:420,def:252}),P8=z90("maude-rp-w",{min:260,max:480,def:304}),[U0,o0]=u.useState(null),R8=u.useRef(null);u.useEffect(()=>{if(!U0)return;let b=(c)=>{let X0=R8.current?.getBoundingClientRect();if(!X0)return;if(U0==="sb")X8.setW(c.clientX-X0.left);else P8.setW(X0.right-c.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[U0,X8.setW,P8.setW]);let J9=u.useCallback((b)=>{clearTimeout(j0.current),j0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[i0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let c="compile";try{if(!(await fetch(`${i0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)c="server"}catch{c="server"}H8({path:b,kind:c}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J8,i0?.canvasOrigin]);let F9=!!i0.cloud,v7=!i0.cloud&&!!e0?.credentialed,I8=F9||v7,X9=I8?0:N8?.files?.length||0,d8=u.useRef(I8);d8.current=I8;let O0=!!i0.readOnly,K8=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((c)=>({...c,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K8()},[K8]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I8){C0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)C0(S)}).catch(()=>{}),()=>{b=!0}},[I8]);let[S8,V9]=u.useState({}),[x9,i9]=u.useState(null),[h9,t]=u.useState(!1),[M0,E0]=u.useState("open"),[v0,W8]=u.useState(EF0),[g8,t8]=u.useState(()=>{return HT(t80,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(t80,JSON.stringify(g8))}catch{}},[g8]);let[v8,W9]=u.useState(null),[T9,e9]=u.useState(()=>TH(e80,!0)),[J7,FQ]=u.useState(()=>TH(a80,!1)),[aX,BJ]=u.useState(()=>HT(s80,{})),[oJ,nJ]=u.useState(!1),[e7,Y4]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=qh(()=>Y4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j9,VY]=u.useState(!1),[p7,y5]=u.useState(!1),[HG,f7]=u.useState(!1),[qY,LX]=u.useState(!1),{report:V7}=gw(G9()),[rJ,l9]=u.useState(!1),[q7,z6]=u.useState(!1),[SJ,j5]=u.useState(null),[LQ,P6]=u.useState(null),[W4,DQ]=u.useState(!1),[zG,bJ]=u.useState(!1),[yJ,aJ]=u.useState(!1),[v5,G4]=u.useState(!1),[NJ,Z4]=u.useState(()=>HT(Y90,J1)),[o,G0]=u.useState(()=>{try{let b=localStorage.getItem(W90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[D0,y0]=u.useState(!1),[P0,z8]=u.useState([]),[M8,Z9]=u.useState(0),[L9,I6]=u.useState(!1),[MQ,s6]=u.useState(!1),[FJ,f5]=u.useState(!1),[RH,KG]=u.useState(1),[jJ,C7]=u.useState(216),[R9,DX]=u.useState(null),[K6,a8]=u.useState([]),[J6,h6]=u.useState([]),[MX,OQ]=u.useState([]),[sX,CH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=M8},[M8]);let[X6,$H]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let k6=u.useMemo(()=>iw(P0,{artboardId:[X6,R9],total:sX}),[P0,X6,R9,sX]),tX=u.useRef(null);u.useEffect(()=>{tX.current=k6},[k6]);let BY=u.useMemo(()=>CK(P0,k6)?.fps||30,[P0,k6]),[SH,NY]=u.useState(null),[FY,G1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))h8("Timeline changed — reloaded, try again."),G1((c)=>c+1);else h8(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Z1,bH]=u.useState(!1),[H1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let yH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),UL("Claude finished","Your assistant turn is ready in Maude.")},[]),jH=u.useRef(0),LY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-jH.current<OF0)return;jH.current=b,UL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[x5,eX]=u.useState("inspect"),[BG,DY]=u.useState(null),AQ=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),MY=u.useRef(U6);u.useEffect(()=>{MY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let vH=u.useRef(!1);u.useEffect(()=>{vH.current=yJ||h9||Q8||f8||_X},[yJ,h9,Q8,f8,_X]);let DG=u.useRef({open:{},side:J1});DG.current={open:{tree:T9,layers:v5,inspector:yJ,comments:h9,changes:Q8,sync:f8,assistant:_X},side:NJ};let H4=u.useCallback((b,S)=>{if(b==="tree")e9(S);else if(b==="layers")G4(S);else if(b==="inspector")aJ(S);else if(b==="comments")t(S);else if(b==="changes")Z8(S);else if(b==="sync")b8(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||J1[b],[]),T6=u.useCallback((b)=>{let S=MG(b);H4(b,!0);for(let c of VT)if(c.id!==b&&MG(c.id)===S)H4(c.id,!1)},[H4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])H4(b,!1);else T6(b)},[T6,H4]),EX=T6,g6=wX,OG=u.useCallback((b)=>{if(!MY.current)return;if(O0)return;if(!b||!b.id)return;if(vH.current)return;EX("inspector"),eX("css")},[EX,O0]),OY=u.useCallback(()=>y0((b)=>!b),[]),_Q=vm(qT),z4=Om({enabled:i0.cloud===null||i0.exportLane==="remote"}),[fH,z1]=u.useState(!1),[xH,J5]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=!0;return Lh().then((S)=>{if(!b)return;if(z1(!!S),!S&&!TH(r80,!1))J5(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{J5(!1);try{localStorage.setItem(r80,"1")}catch{}},[]),[AG,hH]=u.useState(null);u.useEffect(()=>{if(!G9())return;let b;return _h((S)=>hH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[K4,wQ]=u.useState(null),[EQ,_G]=u.useState(()=>!TH(n80,!1)),PX=u.useCallback((b)=>{wQ(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)T6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)EX("inspector");if(b.tab)eX(b.tab);if(b.changes)EX("changes")}},U4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(n80,"1")}catch{}},[]),[X5,AY]=u.useState(()=>TH(Q90,!0)),[gH,EG]=u.useState(!1),[Q5,_Y]=u.useState(()=>TH(J90,!1)),[m6,V0]=u.useState(()=>TH(X90,!1)),[vJ,V4]=u.useState(!1),[PG,sJ]=u.useState(!1),[l7,tJ]=u.useState(0),[h5,IG]=u.useState(null),[kG,wY]=u.useState(!1),g5=u.useRef(null),PQ=u.useRef(null),c8=u.useRef(new Map);u.useEffect(()=>{if(!i0?.canvasToken)return;let b=!1,S=null,c=0,X0=(w0)=>{clearTimeout(S);let p=db(w0);c=Date.now()+p,S=setTimeout(K0,p)};async function K0(){let w0=null;try{let L0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(L0.ok)w0=(await L0.json())?.canvasToken}catch{}if(b)return;if(typeof w0!=="string"||!w0){clearTimeout(S),c=Date.now()+30000,S=setTimeout(K0,30000);return}lb(w0);let p=null;try{p=new URL(i0.canvasOrigin,location.href).origin}catch{}if(p)for(let L0 of c8.current.values())try{L0.contentWindow?.postMessage({dgn:"canvas-cap",t:w0},p)}catch{}X0(w0)}X0(i0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=c)K0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[i0?.canvasToken,i0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?c8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),eJ=u.useRef(0),IQ=u.useCallback(({format:b,artboardIds:S=null,scale:c=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,w0)=>{let p=V?c8.current.get(V):null;if(!p||!p.contentWindow){w0(Error("no active canvas to capture"));return}let L0=p.contentWindow;eJ.current+=1;let k0=`cap-${Date.now().toString(36)}-${eJ.current}`,c0=!1,A8=(w7,d9)=>{if(c0)return;c0=!0,window.removeEventListener("message",O8),clearTimeout(q6),w7(d9)},O8=(w7)=>{if(w7.source!==L0)return;let d9=w7.data;if(!d9||d9.id!==k0)return;if(d9.dgn==="export-capture-progress")X0?.(d9.current,d9.total);else if(d9.dgn==="export-capture-done")A8(F0,Array.isArray(d9.items)?d9.items:[]);else if(d9.dgn==="export-capture-error")A8(w0,Error(d9.message||"capture failed"))},q6=setTimeout(()=>A8(w0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",O8);try{L0.postMessage({dgn:"export-capture",id:k0,format:b,artboardIds:S,scale:c},"*")}catch(w7){A8(w0,w7)}}),[V]),Y8=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),q4=u.useCallback((b,S,c)=>{AQ.current.undo.push({asset:b,before:S,after:c}),AQ.current.redo.length=0},[]),G8=u.useCallback((b)=>{let S=b?AQ.current.redo:AQ.current.undo;if(!S.length)return!1;let c=S.pop();(b?AQ.current.undo:AQ.current.redo).push(c);let X0=(b?c.after:c.before)||{};return Y8(c.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(c.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((K0)=>K0+1),!0},[Y8]),TG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let c=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (o80(),i80)),K0=await X0(c),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),w0=await F0.json().catch(()=>({}));if(F0.ok&&w0.path)return{maskAsset:w0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},c=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",c),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",c)}},[]);let Q6=u.useRef({});Q6.current={open:D0,comps:P0,frame:M8,total:sX,playing:L9,compId:k6,muted:FJ,loop:MQ,sequences:K6,post:T0,canvas:V};let m5=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,c)=>{if(typeof S!=="number")return;if(m5.current.undo.push({canvas:b,seq:S,label:c}),m5.current.redo=[],m5.current.undo.length>50)m5.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=m5.current,c=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=Q6.current.canvas,F0=-1;for(let p=c.length-1;p>=0;p--)if(c[p].canvas===K0){F0=p;break}if(F0<0){h8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let w0=c[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:w0.canvas,seq:w0.seq,dir:b})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(c.splice(F0,1),p?.ok)X0.push(w0),h8(`${b==="undo"?"Undid":"Redid"}: ${w0.label}`,!0);else h8(`${b==="undo"?"Undo":"Redo"} skipped: ${p?.error||"failed"}`)}).catch(()=>h8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let c=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?c.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?c[S.index]:null)||null;if(typeof S==="string")return c.find((X0)=>X0.stableId===S)||null;return c[S]||null},[]),kQ=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r8)return;let c=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:c,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),LJ("Remove refused",K0.error);else if(K0?.ok){if(h8("Clip removed.",!0),K0.seq!=null)Y6(S,K0.seq,"remove clip");NY(null)}}).catch(()=>h8("Remove failed: network error"))},[R6,Y6]),TQ=u.useCallback((b,S,c)=>{let X0=Q6.current.canvas;if(!X0||X0===r8)return;let K0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((w0)=>w0.json().catch(()=>({}))).then((w0)=>{let p=w0?.ok&&Array.isArray(w0.clips)?w0.clips:[],L0=b?.transition?p.find((k0)=>k0.kind==="transition"&&k0.stableId===b.stableId)||null:R6(w0,b);if(!L0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:L0.stableId,contentHash:L0.contentHash,verb:S,...c})})}).then((w0)=>w0?w0.json():null).then((w0)=>{if(w0&&!w0.ok)console.warn("[clip-edit]",S,w0.error||"failed"),LJ(`${S} refused`,w0.error);else if(w0?.ok){let p={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(h8(`Applied: ${p[S]||S}.`,!0),w0.seq!=null)Y6(X0,w0.seq,p[S]||S)}}).catch(()=>h8(`${S} failed: network error`))},[R6,Y6,LJ]),[RQ,EY]=u.useState(null),Y5=u.useCallback((b,S="")=>new Promise((c)=>{EY({title:b,value:S,resolve:c})}),[]),u5=u.useCallback((b)=>{EY((S)=>{return S?.resolve?.(b),null})},[]),PY=u.useCallback((b,S)=>{let c=Q6.current.canvas;if(!c||c===r8||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:c,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),h8("Comment added.",!0)},[]);Q6.current.selected=SH,Q6.current.setSelected=NY,Q6.current.removeClip=kQ,Q6.current.clipVerb=TQ,Q6.current.addComment=PY,Q6.current.askText=Y5,u.useEffect(()=>{let b=(S)=>{let c=Q6.current;if(!c.open||!c.comps?.length)return;let X0=S.target,K0=X0?.tagName;if(K0==="INPUT"&&X0?.type!=="range")return;if(K0==="TEXTAREA"||K0==="SELECT"||X0?.isContentEditable)return;let F0=CK(c.comps,c.compId)?.fps||30,w0=Math.max(1,c.total),p=(k0)=>{let c0=Math.max(0,Math.min(w0-1,Math.round(k0)));Z9(c0),I6(!1),c.post({dgn:"timeline-seek",frame:c0,id:c.compId})},L0=()=>{let k0=new Set([0,w0-1]);for(let c0 of c.sequences||[]){k0.add(c0.from);for(let A8 of c0.keyframes||[])k0.add(A8.from),k0.add(A8.to)}return[...k0].filter((c0)=>c0>=0&&c0<w0).sort((c0,A8)=>c0-A8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(c.selected!=null)S.preventDefault(),c.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&c.selected!=null){S.preventDefault(),c.removeClip?.({stableId:c.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let k0=c.selected!=null?{stableId:c.selected}:null;if(!k0){let c0=c.sequences||[],A8=c0.find((O8)=>O8.series&&c.frame>=O8.from&&c.frame<O8.from+O8.duration)||c0.find((O8)=>c.frame>=O8.from&&c.frame<O8.from+O8.duration);if(A8?.stableId)k0={stableId:A8.stableId}}if(k0)c.clipVerb?.(k0,"split",{atFrame:c.frame});else h8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),c.playing)I6(!1),c.post({dgn:"timeline-pause",id:c.compId});else I6(!0),c.post({dgn:"timeline-mute",muted:c.muted,id:c.compId}),c.post({dgn:"timeline-loop",loop:c.loop,id:c.compId}),c.post({dgn:"timeline-play",id:c.compId});else if(S.key==="ArrowRight")S.preventDefault(),p(c.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),p(c.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),p(0);else if(S.key==="End")S.preventDefault(),p(w0-1);else if(S.key==="."){S.preventDefault();let k0=L0().find((c0)=>c0>c.frame);if(k0!=null)p(k0)}else if(S.key===","){S.preventDefault();let k0=L0().reverse().find((c0)=>c0<c.frame);if(k0!=null)p(k0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z8([]),Z9(0),I6(!1),NY(null),$H(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[p5,IY]=u.useState(""),[kY,B4]=u.useState([]),[CG,TY]=u.useState([]);u.useEffect(()=>{if(!D0||P0.length===0||!V||V===r8){IY(""),B4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")IY(S.source)}).catch(()=>{}),()=>{b=!1}},[D0,P0,V,FY]),u.useEffect(()=>{if(!D0||!V||V===r8||!p5){B4([]),TY([]);return}let b=!0,S=X6||void 0,c=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(c).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let K0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];B4(K0.filter((F0)=>F0.kind==="sequence")),TY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[D0,V,p5,X6,FY]),u.useEffect(()=>{if(!p5){a8([]),h6([]),OQ([]),CH(0);return}let b=R9??O?.artboardId??null,c=(b&&P0.find((F0)=>F0.artboardId===b||F0.id===b)||P0[0])?.durationInFrames||0,X0=zm(p5,c,b);$H(X0.artboardId??b??null);let K0=X0.sequences.map((F0,w0)=>{let p=kY[w0];if(!p)return F0;return{...F0,stableId:p.stableId,contentHash:p.contentHash,mediaProps:p.mediaProps??null,placeholder:p.placeholder??null,mediaTag:p.mediaTag??F0.mediaTag,mediaSrc:p.mediaSrc??F0.mediaSrc,replaceable:!!(p.mediaCdId||p.mediaArrayRef),layers:Array.isArray(p.layers)?p.layers:[],hidden:!!p.hidden}});a8(K0),h6(X0.audio||[]),OQ(X0.transitions||[]),CH(X0.total)},[p5,kY,O,P0,R9]);let RY=u.useCallback(()=>{AY((b)=>{let S=!b,c=V?c8.current.get(V):null;if(c&&c.contentWindow)try{c.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of c8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),CY=u.useCallback(()=>{_Y((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),$Y=u.useCallback(()=>{V0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{V4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),N4=u.useCallback(()=>{V4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r8)return;sJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let c=S&&typeof S.name==="string"?S.name.trim():"";if(c)IG(c)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r8){tJ(0),sJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let c=Array.isArray(S?.artboards)?S.artboards.length:0;tJ(c),sJ(S?.overlays?.print===!0),L4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)tJ(0),sJ(!1),L4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r8||!R9)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R9})},250);return()=>clearTimeout(b)},[V,R9,T0]);let[F4,L4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r8)return;L4((S)=>{let c=new Set(S);if(c.has(b))c.delete(b);else c.add(b);let X0=[...c];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),c})},[V,T0]);u.useEffect(()=>{if(!V||V===r8)return;T0({dgn:"locked-set",locked:[...F4]})},[F4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",v0),localStorage.setItem(C90,v0)}catch{}for(let b of c8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}},[v0]),u.useEffect(()=>{try{localStorage.setItem(e80,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(a80,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(s80,JSON.stringify(aX))}catch{}},[aX]),u.useEffect(()=>{try{localStorage.setItem(J90,Q5?"1":"0")}catch{}},[Q5]),u.useEffect(()=>{try{localStorage.setItem(X90,m6?"1":"0")}catch{}},[m6]),u.useEffect(()=>{try{localStorage.setItem(Q90,X5?"1":"0")}catch{}},[X5]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")W8(S.theme);if(typeof S.minimap==="boolean")_Y(S.minimap);if(typeof S.zoom==="boolean")V0(S.zoom);if(typeof S.annotations==="boolean")AY(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")Z4({...J1,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")G0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!gH)return;AF0({theme:v0,minimap:Q5,zoom:m6,annotations:X5,autoOpenInspector:U6,panelSides:NJ,layersMode:o})},[gH,v0,Q5,m6,X5,U6,NJ,o]),u.useEffect(()=>{try{localStorage.setItem(Y90,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(W90,o)}catch{}},[o]);let yG=u.useCallback((b,S)=>{BJ((c)=>{let X0=c[b],K0=X0===void 0?S:X0;return{...c,[b]:!K0}})},[]),D4=u.useCallback(()=>{W8((b)=>b==="dark"?"light":"dark")},[]),M4=u.useRef(null),y9=u.useCallback(()=>M4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=ib({read:async(S)=>{let c=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!c.ok)throw Object.assign(Error(`Project index request failed: ${c.status}`),{status:c.status});let X0=await c.json(),K0=X0.groups.map((F0)=>({...F0,tree:TF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:c})=>{H(S.project||"Design"),X(c),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return M4.current=b,y9(),()=>{M4.current=null,b.dispose()}},[y9]);let W5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",c=await fetch(S);if(!c.ok){console.error("failed to load system-data",c.status);return}let X0=await c.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){B0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)B0(await K0.json());return}B0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),SY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{SY()},[SY]);let bY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function c(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");PQ.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)K8();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{i(!1),clearInterval(b),setTimeout(c,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let w0=JSON.parse(F0.data);if(w0.type==="snapshot"&&w0.state)E((p)=>I90(w0.state.selected,p));else if(w0.type==="selected"){if(Date.now()-T.current<2000)return;let p=w0.selected,L0=Array.isArray(p)?p[0]:p,k0=w.current,c0=Array.isArray(k0)?k0[0]:k0;if(E((A8)=>I90(p,A8)),L0?.id&&L0.file&&(!c0||c0.id!==L0.id||c0.file!==L0.file))$(L0)}else if(w0.type==="comments"&&typeof w0.file==="string")V9((p)=>({...p,[w0.file]:w0.comments||[]}));else if(w0.type==="ai-activity"&&typeof w0.file==="string"){if(wY(!0),g5.current)clearTimeout(g5.current);g5.current=setTimeout(()=>wY(!1),8000);for(let p of c8.current.values())try{p.contentWindow.postMessage({dgn:"ai-activity",file:w0.file,entry:w0.entry},"*")}catch{}}else if(w0.type==="export:job"&&w0.payload)z4.upsert(w0.payload);else if(w0.type==="sync:status"&&w0.payload)a0(w0.payload);else if(w0.type==="canvas-list-update")y9(),bY.current(w0.payload);else if(w0.type==="config-updated")K8();else if(w0.type==="acp-focus"){if(G9())EX("assistant")}else if(w0.type==="git-status"&&w0.payload){if(!d8.current)C0(w0.payload)}else if(w0.type==="git-lifecycle"&&w0.payload){Z0(w0.payload);for(let p of c8.current.values())try{p.contentWindow.postMessage({dgn:"git-lifecycle",payload:w0.payload},"*")}catch{}}}catch{}})}return c(),()=>{if(clearInterval(b),PQ.current)PQ.current.close()}},[y9,K8]);function $7(b){let S=PQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)C0(await b.json())}catch{}},[]),fJ=u.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)$0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await c.json().catch(()=>({}));return{ok:c.ok,...X0}}catch(c){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let c=await AJ("/_api/git/commit",{message:b,files:S});if(c.ok)await OJ();return c},[AJ,OJ]),yY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),fJ();return b},[AJ,OJ,fJ]),jY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)h0({file:b.files[0],conflict:!0});return b},[AJ,OJ,fJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),fJ();return S},[AJ,OJ,fJ]),O4=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return[];return(await c.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return null;let X0=await c.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),[pG,lG]=u.useState(0),dG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),c=await fetch(S);if(!c.ok)return"legacy";let X0=await c.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((K0)=>{let F0=b?"":(K0.canvases||[]).map((w0)=>w0.split("/").pop()).join(", ");return{sha:`r${K0.revision}`,message:[K0.label||K0.kind,F0].filter(Boolean).join(" · "),author:K0.actor,date:new Date(K0.committedAt).toISOString(),accepted:{revision:K0.revision,actionId:K0.actionId,mine:!!K0.mine,undo:K0.kind==="undo"||K0.kind==="redo"}}})}catch{return null}},[]),cG=/^r\d+$/.test(O9?.beforeSha||""),K1=u.useCallback(async(b)=>{if(!cG)return O4(b);let S=await dG(b);return Array.isArray(S)?S:[]},[cG,O4,dG]),mH=u.useCallback(async(b,S)=>{if(!b||!Number.isSafeInteger(S)||S<0)return{ok:!1,error:"Choose a saved project version to restore."};let c=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,revision:S})}).catch(()=>null),X0=c?await c.json().catch(()=>null):null;if(c?.ok&&X0?.ok)return lG((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),U1=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I8)return S;for(let c of N8?.files||[])S.set(c.path,b[c.status]);return S},[N8,I8]);u.useEffect(()=>{if(I8){$0(null);return}if(N8?.repo===!1)return;fJ();let b=setInterval(fJ,Q8?60000:120000);return()=>clearInterval(b)},[I8,N8?.repo,Q8,fJ]);let V6=u.useCallback((b)=>{if(W.current="push",i9(null),F(null),b===V)return;if(U((S)=>{for(let c of S)if(c.path!==b)c8.current.delete(c.path);return[{path:b}]}),B(b),H8(null),_0(null),b!==r8)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let c=J.flatMap((X0)=>X0.paths||[]).find((X0)=>RW(X0,i0.designRel)===b);if(c&&b5.test(c))V6(c);else if(c&&AL(Q4(c)))M(c);else U([]),B(null),F(null),E5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,i0.designRel,V6,M]),uH=u.useRef(!1);u.useEffect(()=>{if(!Q||i0.cloud===void 0||uH.current)return;uH.current=!0;let b=CV(location,i0.designRel);if(b)A4(b,"none")},[Q,i0.cloud,i0.designRel,A4]),u.useEffect(()=>{if(!Q||i0.cloud===void 0)return;let b=()=>{let S=CV(location,i0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,i0.cloud,i0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r8?null:V);if(b===G.current)return;G.current=b;let S=RW(b,i0.designRel);if(W.current!=="none"&&CV(location,i0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Gg(location,S));W.current="push"},[V,N,i0.designRel]);let vY=N||(V===r8?null:V),iG=i0.cloud?"cloud":G9()?"native":"local",pH=(b)=>Kg({rel:RW(b,i0.designRel),shell:iG,location,linkedHubUrl:e0?.url,project:i0.cloud?Z:s8,localUrl:location.origin}),lH=(b=vY)=>{let S=RW(b,i0.designRel);if(S)j5({path:b,rel:S,label:Q4(b)})},V1=u.useCallback((b)=>{if(H8(null),_0(null),K8(),d0((S)=>S+1),b&&b!==r8)r0(b)},[K8]),oG=u.useRef(!1);u.useEffect(()=>{if(oG.current)return;if(!i0.cloud)return;if(new URLSearchParams(location.search).has("open")){oG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let c of S.paths||[]){if(!b5.test(c))continue;if(/(^|\/)system\//.test(c))continue;b=c;break}if(b)break}if(!b)return;oG.current=!0,V6(b)},[i0.cloud,J,K.length,V6]);let CQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)W5(S);else if(!F8)W5();V6(r8)},[F8,W5,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r8)})},[K]),u.useEffect(()=>{if(V&&V!==r8)$7({type:"active",file:V});else if(V===r8)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let fY=u.useCallback((b)=>{U((S)=>{let c=S.findIndex((K0)=>K0.path===b);if(c<0)return S;let X0=S.filter((K0)=>K0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,c-1)].path);return X0}),c8.current.delete(b),r0((S)=>S===b?null:S)},[V]);bY.current=(b)=>{if(!b?.rel)return;let S=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),c=`${S}/${b.rel}`;if(b.action==="removed")fY(c);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:c}:F0)),B((K0)=>K0===X0?c:K0),r0((K0)=>K0===X0?null:K0),c8.current.delete(X0)}};let l5=u.useCallback(()=>{if(!V||V===r8){if(V===r8)W5();return}let b=c8.current.get(V);if(b)b.src=b.src},[V,W5]),dH=u.useCallback(()=>y9(),[y9]),[q1,cH]=u.useState(!1),nG=u.useRef(!1),rG=u.useCallback(async()=>{if(nG.current)return;nG.current=!0,cH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{nG.current=!1,cH(!1)}},[y9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,dH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[dH]);let B1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),c=await S.json().catch(()=>({}));if(!S.ok||!c.ok)return{ok:!1,error:c.error||`create failed (${S.status})`};return await y9(),V6(c.file),{ok:!0,file:c.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),iH=u.useCallback(async()=>{let b=await Y5("New video name");if(!b)return;let c=(await Y5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=c?Number(c[1]):1920,K0=c?Number(c[2]):1080,F0=Math.max(1,Math.min(60,Number(await Y5("Frames per second","30"))||30));try{let w0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:K0})}),p=await w0.json().catch(()=>({}));if(!w0.ok||!p.ok){h8(`New video failed: ${p.error||`error ${w0.status}`}`);return}await y9(),V6(p.file),y0(!0),h8("New video created — drop clips on the timeline to start the cut.",!0)}catch(w0){h8(`New video failed: ${w0 instanceof Error?w0.message:"network error"}`)}},[y9,V6,Y5]),N1=u.useCallback(async()=>{if(!V||V===r8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",c=[];if(S){let p=new DOMParser().parseFromString(S,"image/svg+xml");for(let L0 of p.querySelectorAll('[data-tool="mediaref"]')){let k0=L0.getAttribute("data-src");if(!k0)continue;c.push({src:k0,mediaKind:L0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(c.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let K0=`${X4(Q4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K0,kind:"video-comp",clips:c})}),w0=await F0.json().catch(()=>({}));if(!F0.ok||!w0.ok){window.alert(`Assemble failed: ${w0.error||`error ${F0.status}`}`);return}await y9(),V6(w0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),aG=u.useCallback(({accept:b,resolveTarget:S})=>{let c=V,X0=X6||void 0,K0=document.createElement("input");K0.type="file",K0.accept=b,K0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(K0);let F0=()=>{if(K0.isConnected)K0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),K0.addEventListener("change",()=>{let w0=K0.files?.[0];if(F0(),!w0)return;let p=`/_api/comp-clips?canvas=${encodeURIComponent(c)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(p).then((L0)=>L0.json().catch(()=>({}))).then((L0)=>{let k0=S(L0);if(!k0)return h8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":w0.type||"application/octet-stream"},body:w0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return h8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(k0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,arrayName:k0.arrayRef.arrayName,index:k0.arrayRef.index,field:k0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,id:k0.cdId,attr:"src",value:c0.path})})})}).then((L0)=>L0?L0.json():null).then((L0)=>{if(L0&&!L0.ok)h8(`Replace refused: ${L0.error||"failed"}`);else if(L0&&L0.ok){if(h8("Media replaced.",!0),L0.seq!=null)Y6(c,L0.seq,"replace media")}}).catch(()=>h8("Replace failed: network error"))}),K0.click()},[V,X6,Y6]),F1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5684
5684
 
5685
- Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){window.alert(`Could not delete: ${K0.error||`error ${X0.status}`}`);return}if(await y9(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9,V]),L1=u.useCallback(async function b(S,c){try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:S,toDir:c})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok)return h8(`Could not move: ${K0.error||`error ${X0.status}`}`),{ok:!1,error:K0.error};let F0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),w0=`${F0}/${K0.fromRel}`,p=`${F0}/${K0.toRel}`;await y9(),U((k0)=>k0.map((c0)=>c0.path===w0?{path:p}:c0)),B((k0)=>k0===w0?p:k0);let D0=w0.split("/").slice(0,-1).join("/");return h8(`Moved to ${K0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(p,D0)}}),{ok:!0}}catch(X0){return h8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[y9,i0]),D1=u.useCallback(async(b,S)=>{try{let c=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:b,name:S})}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){let K0=X0.error||`error ${c.status}`;return h8(`Could not create folder: ${K0}`),{ok:!1,error:K0}}return await y9(),{ok:!0,dir:X0.dir}}catch(c){let X0=c instanceof Error?c.message:"network error";return h8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[y9]),M1=u.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
5685
+ Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){window.alert(`Could not delete: ${K0.error||`error ${X0.status}`}`);return}if(await y9(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9,V]),L1=u.useCallback(async function b(S,c){try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:S,toDir:c})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok)return h8(`Could not move: ${K0.error||`error ${X0.status}`}`),{ok:!1,error:K0.error};let F0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),w0=`${F0}/${K0.fromRel}`,p=`${F0}/${K0.toRel}`;await y9(),U((k0)=>k0.map((c0)=>c0.path===w0?{path:p}:c0)),B((k0)=>k0===w0?p:k0);let L0=w0.split("/").slice(0,-1).join("/");return h8(`Moved to ${K0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(p,L0)}}),{ok:!0}}catch(X0){return h8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[y9,i0]),D1=u.useCallback(async(b,S)=>{try{let c=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:b,name:S})}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){let K0=X0.error||`error ${c.status}`;return h8(`Could not create folder: ${K0}`),{ok:!1,error:K0}}return await y9(),{ok:!0,dir:X0.dir}}catch(c){let X0=c instanceof Error?c.message:"network error";return h8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[y9]),M1=u.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
5686
5686
 
5687
- Every canvas inside moves to trash (recoverable from .design/_trash/); any empty subfolders are removed.`))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){h8(`Could not delete folder: ${K0.error||`error ${X0.status}`}`);return}await y9()}catch(X0){h8(`Delete folder failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9]),O1=u.useCallback(async(b,S)=>{let c=b.split("/").slice(0,-1).join("/");try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:c,toName:S})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){h8(`Could not rename folder: ${K0.error||`error ${X0.status}`}`);return}await y9()}catch(X0){h8(`Rename failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9]),A1=u.useCallback(async(b,S)=>{try{let c=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toName:S})}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){h8(`Could not rename: ${X0.error||`error ${c.status}`}`);return}let K0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),F0=`${K0}/${X0.fromRel}`,w0=`${K0}/${X0.toRel}`;await y9(),U((p)=>p.map((D0)=>D0.path===F0?{path:w0}:D0)),B((p)=>p===F0?w0:p)}catch(c){h8(`Rename failed: ${c instanceof Error?c.message:"network error"}`)}},[y9,i0]),_1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duplicateOf:b})}),c=await S.json().catch(()=>({}));if(!S.ok||!c.ok){h8(`Could not duplicate: ${c.error||`error ${S.status}`}`);return}await y9(),h8(`Duplicated as ${c.rel.split("/").pop().replace(/\.tsx$/i,"")}`,!0)}catch(S){h8(`Duplicate failed: ${S instanceof Error?S.message:"network error"}`)}},[y9]),w1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5687
+ Every canvas inside moves to trash (recoverable from .design/_trash/); any empty subfolders are removed.`))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){h8(`Could not delete folder: ${K0.error||`error ${X0.status}`}`);return}await y9()}catch(X0){h8(`Delete folder failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9]),O1=u.useCallback(async(b,S)=>{let c=b.split("/").slice(0,-1).join("/");try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:c,toName:S})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){h8(`Could not rename folder: ${K0.error||`error ${X0.status}`}`);return}await y9()}catch(X0){h8(`Rename failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9]),A1=u.useCallback(async(b,S)=>{try{let c=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toName:S})}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){h8(`Could not rename: ${X0.error||`error ${c.status}`}`);return}let K0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),F0=`${K0}/${X0.fromRel}`,w0=`${K0}/${X0.toRel}`;await y9(),U((p)=>p.map((L0)=>L0.path===F0?{path:w0}:L0)),B((p)=>p===F0?w0:p)}catch(c){h8(`Rename failed: ${c instanceof Error?c.message:"network error"}`)}},[y9,i0]),_1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duplicateOf:b})}),c=await S.json().catch(()=>({}));if(!S.ok||!c.ok){h8(`Could not duplicate: ${c.error||`error ${S.status}`}`);return}await y9(),h8(`Duplicated as ${c.rel.split("/").pop().replace(/\.tsx$/i,"")}`,!0)}catch(S){h8(`Duplicate failed: ${S instanceof Error?S.message:"network error"}`)}},[y9]),w1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5688
5688
 
5689
- You can restore it from .design/_trash/.`))return;try{let c=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){h8(`Could not delete: ${X0.error||`error ${c.status}`}`);return}await y9()}catch(c){h8(`Delete failed: ${c instanceof Error?c.message:"network error"}`)}},[y9]),E1=u.useCallback(()=>{if($7({type:"clear-select"}),E(null),V&&V!==r8){let b=c8.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===r8)return;let b=c8.current.get(V);if(!b||!b.contentWindow)return;let S=vJ?[]:S8[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,S8,vJ]),u.useEffect(()=>{let b=(F0)=>!!V&&(S8[V]||[]).some((w0)=>w0&&w0.id===F0);function S(F0){let w0=i0?.canvasOrigin||window.location.origin;if(F0.origin!==w0)return;let p=F0.data;if(!p||typeof p!=="object"||!p.dgn)return;if(p.dgn==="canvas-notice"){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null,k0=Dm(F0,w0,D0);if(k0)Og(k0.title,k0.kind);return}if(p.dgn==="tool-cursor"){if(p.tool==="browse"){document.body.style.cursor="";let k0=document.getElementById("dc-app-cursor");if(k0)k0.textContent="";BL(O0);return}let D0=yb(p.tool);if(D0){document.body.style.cursor=D0;let k0=document.getElementById("dc-app-cursor");if(!k0)k0=document.createElement("style"),k0.id="dc-app-cursor",document.head.appendChild(k0);k0.textContent=`* { cursor: ${D0} !important; }`}return}if(p.dgn==="select"||p.dgn==="select-set"||p.dgn==="clear-select"||p.dgn==="edit-text"||p.dgn==="apply-edit"||p.dgn==="undo-barrier"){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return}if(p.dgn==="select"&&p.selection)DY(null),T.current=Date.now(),$7({type:"select",selection:p.selection}),E(p.selection),OG(p.selection);else if(p.dgn==="select-set"){DY(null),T.current=Date.now();let D0=p.selection;if(D0==null)$7({type:"clear-select"}),E(null);else if(Array.isArray(D0)){let k0=D0[0]??null;if(k0)$7({type:"select",selection:k0});if(E(k0),D0.length===1)OG(k0)}else $7({type:"select",selection:D0}),E(D0),OG(D0)}else if(p.dgn==="clear-select")DY(null),T.current=Date.now(),$7({type:"clear-select"}),E(null);else if(p.dgn==="edit-text"&&p.id){let D0=F0.source,k0=(c0)=>{try{D0?.postMessage({dgn:"edit-reverted",op:"text",id:p.id,reason:c0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:p.file,id:p.id,text:p.text??"",...typeof p.occurrence==="number"?{occurrence:p.occurrence}:{},...typeof p.before==="string"?{before:p.before}:{}})}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0.ok)k0(c0.error||"this element can't be edited inline")}).catch(()=>k0("network error"))}else if(p.dgn==="undo-barrier"&&typeof p.requestId==="string"){let D0=F0.source;Promise.all([C6.current.catch(()=>{}),EL0()]).then(()=>{try{D0?.postMessage({dgn:"undo-barrier-ok",requestId:p.requestId},"*")}catch{}})}else if(p.dgn==="apply-edit"&&p.id&&(p.op==="css"||p.op==="text"||p.op==="attr")){let D0=cb(p);if(!D0)return;let k0=F0.source,c0=(O8)=>{if(typeof p.requestId!=="string")return;try{k0?.postMessage({dgn:"apply-edit-result",requestId:p.requestId,...O8},"*")}catch{}},A8=typeof p.value==="string"?p.value:null;C6.current=C6.current.catch(()=>{}).then(()=>fetch(D0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D0.body)}).then((O8)=>O8.json().catch(()=>({}))).then((O8)=>{if(O8.ok){if(D0.op==="css")IX({id:p.id,prop:p.key,value:A8});c0({ok:!0});return}console.warn("[apply-edit]",D0.op,O8.error||"failed"),c0({ok:!1,error:O8.error||"failed",conflict:O8.conflict===!0})}).catch(()=>c0({ok:!1,error:"network error"})))}else if(p.dgn==="layers-tree"){e({artboardId:p.artboardId,nodes:Array.isArray(p.tree)?p.tree:[]});let D0=wF0(p.tree);if(m.current={tree:p.tree,sig:D0,artboardId:p.artboardId??null},l.current=!1,v.current)clearTimeout(v.current),v.current=null;d.current?.(p.tree,D0,p.artboardId??null)}else if(p.dgn==="reorder-revert"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.seq==="number"&&(p.dir==="undo"||p.dir==="redo");if(F0.source===D0&&k0&&V){if(l.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{l.current=!1,v.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:p.seq,dir:p.dir})}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0.ok)console.warn("[reorder-revert]",c0.error||"failed")}).catch(()=>{})}}else if(p.dgn==="reorder-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&typeof p.refId==="string"&&(p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&k0)a.current?.(p.id,p.refId,p.position,{idIndex:Number.isInteger(p.idIndex)?p.idIndex:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="reposition-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&Number.isFinite(p.left)&&Number.isFinite(p.top)&&Number.isFinite(p.beforeLeft)&&Number.isFinite(p.beforeTop);if(F0.source===D0&&k0)x.current?.(p.id,p.left,p.top,p.beforeLeft,p.beforeTop,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="resize-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&p.patch&&typeof p.patch==="object";if(F0.source===D0&&k0)h.current?.(p.id,p.patch,p.before,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="delete-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")FT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="duplicate-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")AT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="copy-style"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0)wT.current?.()}else if(p.dgn==="paste-style"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")ET.current?.(p.id)}else if(p.dgn==="insert-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.refId==="string",c0=typeof p.artboardId==="string",A8=p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end",O8=k0!==c0&&(p.kind==="div"||p.kind==="text"||p.kind==="image")&&A8&&(!c0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&O8)LT.current?.(p.refId,p.position,p.kind,{artboardId:c0?p.artboardId:void 0,src:typeof p.src==="string"?p.src:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="insert-image-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.refId==="string",c0=typeof p.artboardId==="string",A8=!k0&&!c0,O8=(k0!==c0||A8)&&(A8||p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end")&&(!c0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&O8)Aq.current?.({purpose:"insert-image",canvas:V,refId:p.refId,artboardId:c0?p.artboardId:void 0,position:A8?void 0:p.position,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0,multiple:!0,hasArtboardAnchor:!A8})}else if(p.dgn==="replace-media-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Aq.current?.({purpose:"replace-src",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="convert-to-absolute-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=Array.isArray(p.containers)&&p.containers.length>0,c0=typeof p.containerId==="string"&&Array.isArray(p.children)&&p.children.length>0;if(F0.source===D0&&(k0||c0)){let A8=k0?p.containers.reduce((O8,q6)=>O8+(Array.isArray(q6?.children)?q6.children.length:0),0):p.children.length;tG.current?.("/_api/convert-to-absolute",k0?{allowShared:p.allowShared===!0,containers:p.containers,...Array.isArray(p.dissolve)&&p.dissolve.length>0?{dissolve:p.dissolve}:{}}:{containerId:p.containerId,containerSetRelative:p.containerSetRelative===!0,allowShared:p.allowShared===!0,children:p.children},{label:"convert to absolute",onOk:()=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Converted ${A8} element${A8===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(O8)=>T0({dgn:"op-toast",message:`Convert failed: ${O8?.error||"unknown error"}`})})}}else if(p.dgn==="replace-annotation-media-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Aq.current?.({purpose:"replace-annotation-media",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="edit-annotation-photo-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=BT.exec(typeof p.asset==="string"?p.asset:"")?.[0]||null;if(F0.source===D0&&typeof p.id==="string"&&k0)DY({asset:k0,strokeId:p.id}),EX("inspector"),eX("photo")}else if(p.dgn==="open-sticker-picker"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0)PT.current?.({canvas:V})}else if(p.dgn==="insert-artboard-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&Number.isFinite(p.width)&&Number.isFinite(p.height);if(F0.source===D0&&k0)DT.current?.({id:p.id,label:typeof p.label==="string"?p.label:p.id,width:p.width,height:p.height})}else if(p.dgn==="resize-artboard-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.artboardId==="string"&&(Number.isFinite(p.width)||Number.isFinite(p.height));if(F0.source===D0&&k0)MT.current?.(p.artboardId,Number.isFinite(p.width)?p.width:void 0,Number.isFinite(p.height)?p.height:void 0)}else if(p.dgn==="delete-artboard-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string")OT.current?.(p.artboardId)}else if(p.dgn==="rename-artboard-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&typeof p.label==="string"&&p.label.trim())tG.current?.("/_api/set-artboard-label",{artboardId:p.artboardId,label:p.label.slice(0,80)},{label:"rename artboard"})}else if(p.dgn==="set-artboard-kind-request"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=p.kind===null||typeof p.kind==="string";if(F0.source===D0&&typeof p.artboardId==="string"&&k0)NT.current?.(p.artboardId,p.kind)}else if(p.dgn==="duplicate-artboard-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&Number.isFinite(p.width))_T.current?.(p.artboardId,p.width)}else if(p.dgn==="open-inspector"){if(EX("inspector"),typeof p.tab==="string")eX(p.tab)}else if(p.dgn==="present-enter"){let D0=V?c8.current.get(V)?.contentWindow:null,k0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===D0&&!k0&&!vJ)V4(!0),MJ({present:!0})}else if(p.dgn==="comment-compose"&&p.selection)E(p.selection);else if(p.dgn==="comment-submit"&&p.payload&&typeof p.payload.text==="string"){let D0=p.payload,k0=String(D0.text).trim(),c0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===c0&&k0&&V&&V!==r8)$7({type:"comments-add",payload:{file:V,selector:D0.selector,index:D0.index,dom_path:D0.dom_path,tag:D0.tag,classes:D0.classes,bounds:D0.bounds,html_excerpt:D0.html_excerpt,text:k0}})}else if(p.dgn==="comment-patch"&&p.id&&p.patch&&typeof p.patch==="object"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))$7({type:"comments-patch",id:p.id,patch:p.patch})}else if(p.dgn==="comment-delete"&&p.id){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))$7({type:"comments-delete",id:p.id}),i9((k0)=>k0===p.id?null:k0)}else if(p.dgn==="comment-click"&&p.id)i9(p.id);else if(p.dgn==="artboards"&&typeof p.count==="number"){let D0=Math.round(p.count);if(Number.isFinite(D0)&&D0>=0&&D0<=999)tJ(D0)}else if(p.dgn==="active-artboard"){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;DX(sN(p.id))}else if(p.dgn==="timeline-comps"&&Array.isArray(p.comps)){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;let k0=p.comps.filter((O8)=>O8&&typeof O8.id==="string").slice(0,32).map((O8)=>({id:String(O8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(O8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(O8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(O8.width)||0)),height:Math.max(1,Math.round(Number(O8.height)||0)),artboardId:sN(O8.artboardId),artboardLabel:sN(O8.artboardLabel)}));z8(k0);let c0=tX.current;if(c0&&k0.some((O8)=>O8.id===c0)&&OX.current>0)T0({dgn:"timeline-seek",frame:OX.current,id:c0})}else if(p.dgn==="timeline-frame"&&typeof p.frame==="number"){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&tX.current&&p.id!==tX.current)return;if(Number.isFinite(p.frame))Z9(Math.max(0,Math.round(p.frame)))}else if(p.dgn==="timeline-ended"){let D0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&tX.current&&p.id!==tX.current)return;I6(!1)}else if(p.dgn==="toggle-palette")z6((D0)=>!D0);else if(p.dgn==="shell-shortcut"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0){if(p.id==="reload")l5();else if(p.id==="inspector")g6("inspector");else if(p.id==="assistant"&&G9())g6("assistant");else if(p.id==="comments")g6("comments");else if(p.id==="changes")g6("changes");else if(p.id==="timeline")OY();else if(p.id==="export")P6({mode:"export"});else if(p.id==="handoff")P6({mode:"handoff"})}}else if(p.dgn==="open-export"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0)P6({mode:"export",scope:p.detail&&typeof p.detail.scope==="string"?p.detail.scope:void 0})}else if(p.dgn==="open-timeline-request"){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===D0){if(typeof p.artboardId==="string")DX(p.artboardId.slice(0,120));y0(!0)}}else if(p.dgn==="loaded"&&p.file){r0((c0)=>c0===p.file?null:c0),_0(p.file),H8((c0)=>c0&&c0.path===p.file?null:c0);let D0=vJ?[]:S8[p.file]||[],k0=[...c8.current.entries()].find(([c0])=>c0===p.file)?.[1];if(k0&&k0.contentWindow){try{k0.contentWindow.postMessage({dgn:"comments-set",comments:D0},"*")}catch{}try{k0.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}try{k0.contentWindow.postMessage({dgn:"view-chrome",minimap:Q5,zoom:m6,present:vJ},"*")}catch{}if(x9&&D0.some((A8)=>A8.id===x9))try{k0.contentWindow.postMessage({dgn:"comment-focus",id:x9},"*")}catch{}let c0=f.current;if(c0&&c0.file===p.file){f.current=null;try{k0.contentWindow.postMessage({dgn:"request-layers",artboardId:c0.artboardId??null},"*")}catch{}if(c0.movedId)try{k0.contentWindow.postMessage({dgn:"select-by-id",id:c0.movedId,artboardId:c0.artboardId??null,index:0},"*")}catch{}}else{let A8=w.current,O8=Array.isArray(A8)?A8[0]:A8;if(O8&&O8.id&&O8.file===p.file)$(O8)}}}else if(p.dgn==="export-request"&&p.id&&p.payload){let D0=V?c8.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;X0(F0.source,p.id,p.payload)}else if(p.dgn==="export-history-request"&&p.id)K0(F0.source,p.id)}let c=i0?.canvasOrigin||window.location.origin;async function X0(F0,w0,p){if(p?.options&&V&&V!==r8)p.options.canvasFile=V;let D0=(A8)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:w0,...A8},c)}catch{}},k0=p?.options||{};if(YB({exportLane:i0.exportLane||"local",format:p?.format,scope:p?.scope,artboardId:k0.artboardId}))try{if(p.format==="pptx"){let{filename:A8,blob:O8}=await jO({capture:IQ,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});DL(A8,O8)}else{let A8=fO(k0),O8=await IQ({format:p.format,artboardIds:[k0.artboardId],scale:A8}),q6=await vO(O8,p.format);for(let w7 of q6)DL(w7.name,w7.blob)}D0({ok:!0,browser:!0});return}catch{if(i0.exportLane!=="remote"){D0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(i0.exportLane==="none"&&p?.format!=="zip"){D0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let A8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)});if(!A8.ok){D0({ok:!1,error:await A8.text()||String(A8.status)});return}let{jobId:O8}=await A8.json();D0({ok:!0,jobId:O8})}catch(A8){D0({ok:!1,error:A8&&A8.message?A8.message:String(A8)})}}async function K0(F0,w0){let p=[];try{let D0=await fetch("/_api/export-history");if(D0.ok){let k0=await D0.json();if(Array.isArray(k0.history))p=k0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:w0,history:p},c)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[S8,x9,i0,v0,l5,vJ,Q5,m6,MJ,V,T0,IQ]);let P1=u.useCallback(()=>{if(!V||V===r8)return;let b=c8.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),IX=u.useCallback((b)=>{if(!V||V===r8)return;let S=c8.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),JX=u.useCallback((b)=>{if(!V||V===r8||!b)return;let S=c8.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),C6=u.useRef(Promise.resolve()),sG=u.useCallback((b,S,c,X0)=>{let K0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(K0??0)===(F0??0))return;let w0=w.current,p=Array.isArray(w0)?w0[0]:w0,D0=V;if(!D0)return;let k0=V,c0=n?.artboardId??p?.artboardId??null;if(e((A8)=>A8?{...A8,nodes:RL0(A8.nodes,b,S,c)}:A8),l.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{l.current=!1,v.current=null},700),C6.current=C6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:D0,id:b,refId:S,position:c,idIndex:K0,refIndex:F0})}).then((A8)=>A8.json().catch(()=>({}))).then((A8)=>{if(!A8.ok){if(console.warn("[reorder]",A8.error||"failed"),T0({dgn:"reorder-failed"}),T0({dgn:"request-layers",artboardId:c0}),l.current=!1,v.current)clearTimeout(v.current),v.current=null;return}if(f.current={file:k0,movedId:A8.movedId||null,artboardId:c0},typeof A8.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:D0,seq:A8.seq,label:"move element"}})}).catch(()=>{}))},[V,n,T0]);u.useEffect(()=>{a.current=sG},[sG]);let oH=u.useCallback((b,S,c,X0,K0,F0)=>{if(!b||!V)return;let w0=V,p=Number.isInteger(F0)?F0:void 0;IX({id:b,prop:"left",value:`${S}px`}),IX({id:b,prop:"top",value:`${c}px`});let D0=null,k0=(c0,A8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:w0,id:b,property:c0,value:`${A8}px`,idIndex:p})}).then((O8)=>O8.json().catch(()=>({})));C6.current=C6.current.catch(()=>{}).then(()=>k0("left",S)).then((c0)=>{if(!c0.ok)throw Error(c0.error||"left write failed");return D0=c0,k0("top",c)}).then((c0)=>{if(!c0.ok)throw Error(c0.error||"top write failed");JX({op:"css",canvas:w0,id:b,key:"left",before:Lq(D0,`${X0}px`),after:`${S}px`}),JX({op:"css",canvas:w0,id:b,key:"top",before:Lq(c0,`${K0}px`),after:`${c}px`})}).catch((c0)=>{console.warn("[reposition]",c0?.message||c0),T0({dgn:"reposition-failed"})})},[V,T0,JX,IX]);u.useEffect(()=>{x.current=oH},[oH]);let nH=u.useCallback((b,S,c,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let K0=V,F0=c&&typeof c==="object"?c:{},w0=Number.isInteger(X0)?X0:void 0,p=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((d9)=>typeof S[d9]==="string"&&S[d9]);if(!p.length)return;let D0=w.current,k0=Array.isArray(D0)?D0.length===1?D0[0]:null:D0,c0=k0&&k0.id===b?k0.artboardId??null:null,A8=k0&&k0.id===b?k0.index??0:0;for(let d9 of p)IX({id:b,artboardId:c0,index:A8,prop:d9,value:S[d9]});let O8=(d9,wJ)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K0,id:b,property:d9,value:wJ,idIndex:w0})}).then((XZ)=>XZ.json().catch(()=>({}))),q6={},w7=C6.current.catch(()=>{});for(let d9 of p)w7=w7.then((wJ)=>{if(wJ&&wJ.ok===!1)throw Error(wJ.error||`${d9} write failed`);return O8(d9,S[d9]).then((XZ)=>{return q6[d9]=XZ,XZ})});C6.current=w7.then((d9)=>{if(d9&&d9.ok===!1)throw Error(d9.error||"resize write failed");for(let wJ of p)JX({op:"css",canvas:K0,id:b,key:wJ,before:Lq(q6[wJ],F0[wJ]??null),after:S[wJ]});$({id:b,file:K0,artboardId:c0,index:A8})}).catch((d9)=>{console.warn("[resize]",d9?.message||d9),T0({dgn:"resize-failed"})})},[V,T0,JX,IX,$]);u.useEffect(()=>{h.current=nH},[nH]);let tG=u.useRef(null),Y7=u.useCallback((b,S,{label:c,onOk:X0,onFail:K0}={})=>{if(!V)return;let F0=V,w0=K0??((p)=>T0({dgn:"op-toast",message:`Couldn't ${c||"apply the edit"}${p?.error?` — ${p.error}`:""}.`}));C6.current=C6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(!p.ok){console.warn(`[${b}]`,p.error||"failed"),w0?.(p);return}if(typeof p.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:p.seq,label:c||"edit"}});X0?.(p,F0)}).catch((p)=>w0?.({error:p?.message})))},[V,T0]);u.useEffect(()=>{tG.current=Y7},[Y7]);let rH=u.useCallback((b,S)=>{Y7("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>T0({dgn:"selection-clear"})})},[Y7,T0]),q=u.useCallback((b,S,c,X0={})=>{let K0=m.current?.sig??null;Y7("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:c,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${c}`,onOk:(F0,w0)=>{if(!F0.newId)return;f.current={file:w0,movedId:F0.newId,artboardId:null,staleSig:K0};let p=m.current;if(p)d.current?.(p.tree,p.sig,p.artboardId)}})},[Y7]),L=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=w.current?.artboardId??R9??null;if(!S)return!1;return q(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,R9,q]),_=u.useCallback((b,S)=>{Y7("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(c)=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Detached — this instance is now ${c.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(c)=>T0({dgn:"op-toast",message:`Detach failed: ${c?.error||"unknown error"}`})})},[Y7,T0]),P=u.useCallback((b,S)=>{let c=m.current?.sig??null;Y7("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,K0)=>{if(!X0.newId)return;f.current={file:K0,movedId:X0.newId,artboardId:null,staleSig:c};let F0=m.current;if(F0)d.current?.(F0.tree,F0.sig,F0.artboardId)}})},[Y7]),k=u.useRef(null),y=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),g=u.useCallback(()=>{let b=w.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let c={};for(let[X0,K0]of Object.entries(S.authored||{}))if(!y.has(X0))c[X0]=K0;for(let[X0,K0]of Object.entries(S.customStyles||{}))if(!y.has(X0))c[X0]=K0;k.current=Object.keys(c).length?c:null},[y]),J0=u.useCallback((b)=>{let S=V,c=k.current;if(!S||!b||!c)return;let X0=Object.entries(c),K0=C6.current.catch(()=>{});for(let[F0,w0]of X0)IX({id:b,prop:F0,value:w0}),K0=K0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:w0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(p.ok)JX({op:"css",canvas:S,id:b,key:F0,before:Lq(p,null),after:w0})}).catch(()=>{}));C6.current=K0},[V,IX,JX]),W0=u.useCallback(({id:b,label:S,width:c,height:X0})=>{Y7("/_api/insert-artboard",{id:b,label:S,width:c,height:X0},{label:"insert artboard"})},[Y7]),N0=u.useCallback((b,S,c)=>{Y7("/_api/resize-artboard",{artboardId:b,width:S,height:c},{label:"resize artboard",onFail:()=>T0({dgn:"resize-artboard-failed"}),onOk:()=>j(b,V)})},[Y7,T0,j,V]),R0=u.useCallback((b)=>{Y7("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[Y7]),l0=u.useCallback((b,S)=>{Y7("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[Y7]),q8=u.useCallback((b,S,c)=>{Y7("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:c},{label:S?"pin artboard height":"hug artboard height",onOk:()=>j(b,V)})},[Y7,j,V]),Q9=u.useCallback((b,S)=>{Y7("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>j(b,V)})},[Y7,j,V]),B7=u.useRef(null),_J=u.useCallback((b,S)=>{Y7("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>j(b,V)});let c=B7.current;if(S==="print"&&c&&c.artboardId===b)B7.current=null,Y7("/_api/resize-artboard",{artboardId:b,width:c.widthPx,height:c.heightPx},{label:"artboard size"}),Y7("/_api/set-artboard-print",{artboardId:b,print:c.defaults},{label:"artboard print"})},[Y7,j,V]),NT=u.useRef(null);u.useEffect(()=>{NT.current=_J},[_J]);let I1=u.useCallback((b,S,c)=>{if(S==="print"||S==null||S==="digital"){if(c)B7.current={artboardId:b,...c};T0({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}_J(b,S)},[_J,T0]),EL=u.useCallback((b,S)=>{Y7("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>j(b,V)})},[Y7,j,V]),m90=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),K0;try{K0=QB({paper:X0})}catch{return}let F0=XB.find((w0)=>w0.id===X0);W0({id:S,label:F0?F0.label:X0.toUpperCase(),width:K0.widthPx,height:K0.heightPx}),I1(S,"print"),EL(S,{paper:X0});return}let c=S5[b];if(!c)return;W0({id:S,label:c.label,width:c.width,height:c.height})},[W0,I1,EL]),FT=u.useRef(null),LT=u.useRef(null),DT=u.useRef(null),MT=u.useRef(null),OT=u.useRef(null),u90=u.useRef(null),AT=u.useRef(null),_T=u.useRef(null),wT=u.useRef(null),ET=u.useRef(null);u.useEffect(()=>{FT.current=rH,LT.current=q,DT.current=W0,MT.current=N0,OT.current=R0,u90.current=I1,AT.current=P,_T.current=l0,wT.current=g,ET.current=J0},[rH,q,W0,N0,R0,I1,P,l0,g,J0]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let c=S.target;if(c&&(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.tagName==="SELECT"||c.isContentEditable))return;if(S.preventDefault(),!V||V===r8)return;let K0=Array.isArray(O)?O.length===1?O[0]:null:O;if(K0?.artboardId&&!K0.id)R0(K0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,O,R0]);let[eG,k1]=u.useState(null),Aq=u.useRef(null);u.useEffect(()=>{Aq.current=(b)=>k1(b)},[]);let[PL,IL]=u.useState(null),PT=u.useRef(null);u.useEffect(()=>{PT.current=(b)=>IL(b)},[]);let p90=u.useCallback((b)=>{let S=eG;if(k1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){q(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let c=V;if(!c||!S.id)return;C6.current=C6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)JX({op:"attr",canvas:c,id:S.id,key:"src",before:Lq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")T0({dgn:"replace-annotation-media",id:S.id,path:b})},[eG,q,V,JX,T0]),l90=u.useCallback((b,S)=>{let c=eG;if(k1(null),!c||!Array.isArray(b)||!b.length)return;if(c.canvas&&c.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=w.current?.artboardId??R9??null;if(!X0)return;for(let K0 of b)q(void 0,"inside-end","image",{artboardId:X0,src:K0});return}T0({dgn:"insert-annotation-media",paths:b})},[eG,V,q,R9,T0]),d90=u.useCallback(async(b)=>{let S=PL;if(IL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let c=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":c.type||"image/png"},body:c}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.path){console.warn("[sticker-picker]",K0.error||`upload failed (HTTP ${X0.status})`);return}T0({dgn:"insert-sticker",path:K0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[PL,V,T0]),c90=u.useCallback((b)=>{if(!b?.id)return;k1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),i90=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),o90=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),n90=u.useCallback((b)=>{$7({type:"comments-delete",id:b}),i9((S)=>S===b?null:S)},[]),r90=u.useCallback((b,S)=>{if(b&&b!==V)U((X0)=>X0.find((K0)=>K0.path===b)?X0:[...X0,{path:b}]),B(b);if(S==null){i9(null);return}i9(S);let c=()=>{let X0=c8.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};c(),setTimeout(c,200)},[V]);u.useEffect(()=>{function b(S){let c=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,K0=document.activeElement?.tagName==="IFRAME";if(vJ&&S.key==="Escape"){S.preventDefault(),N4();return}if(c&&(S.key==="k"||S.key==="K")){S.preventDefault(),z6((F0)=>!F0);return}if(c&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!K0&&V&&V!==r8){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(x5==="photo"&&G8(F0)){S.preventDefault();return}S.preventDefault(),T0({dgn:F0?"redo":"undo"});return}}if(c&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),rG();return}if(c&&(S.key==="r"||S.key==="R")){S.preventDefault(),l5();return}if(c&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),g6("comments");return}if(c&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),g6("changes");return}if(c&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),g6("inspector");return}if(c&&S.shiftKey&&(S.key==="a"||S.key==="A")&&G9()){if(S.preventDefault(),!O0)g6("assistant");return}if(c&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),P6({mode:"export"});return}if(c&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),P6({mode:"handoff"});return}if(c&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!O0)DQ(!0);return}if(c&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),OY();return}if(c&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(O&&O.selector&&V&&V!==r8&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(c&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!T9)T6("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(K0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||c)return;S.preventDefault(),wX("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||c)return;S.preventDefault(),FQ((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!c&&!S.shiftKey){if(S.preventDefault(),V===r8)fY(r8);else CQ();return}if((S.key==="n"||S.key==="N")&&!c&&!S.shiftKey){S.preventDefault(),T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),l9((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),nJ(!0);return}if(S.key==="Escape"){if(x9){i9(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[l5,rG,O,V,x9,T9,CQ,fY,P1,vJ,N4,OY,x5,G8,O0]);let a90=u.useCallback((b,S)=>{if(S)c8.current.set(b,S)},[]),s90=S90(S8).open,t90=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),e90=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>iH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>P6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=pH(vY),S=b.web??b.app??b.local;if(S)bV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>P6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>bJ(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>DQ(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>CQ()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>g6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>EX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>l5()},{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:()=>D4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>_Q.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>l9(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>nJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>Y4(!0)}],[CQ,D4,l5,_Q,iH,vY,iG,e0,s8,i0.designRel]),J70=(b)=>{if(O0&&b==="assistant")return!1;if(b==="sync")return!!I0;return b==="assistant"?G9():b==="layers"?o==="separate":!0},IT=(b)=>VT.filter((S)=>J70(S.id)&&(NJ[S.id]||J1[S.id])===b).map((S)=>S.id),kT={tree:T9,layers:v5,inspector:yJ,comments:h9,changes:Q8,sync:f8,assistant:_X},TT=i0.cloud?{changes:"History"}:null,RT=IT("left"),CT=IT("right"),_4=RT.find((b)=>kT[b])||null,xY=CT.find((b)=>kT[b])||null,$T=G9()&&!O0&&(NJ.assistant||"right")==="left",ST=G9()&&!O0&&(NJ.assistant||"right")==="right",JZ=(b)=>(NJ[b]||J1[b])==="left"?U0==="sb":U0==="rp",T1=V&&V!==r8&&/\.(tsx|html)$/i.test(V)?V:null,bT=T1?NL(S8[T1]):0,yT=(b)=>{if(b==="tree")return z(dF0,{cloud:i0.cloud,readOnly:O0,groups:J,activePath:V,previewPath:N,activeDsName:V===r8?F8?.ds?.name??null:null,onOpen:V6,onPreview:M,onOpenLinkedFile:A4,filesReady:Q,onShare:lH,onOpenSystem:CQ,wsConnected:z0,search:C8,setSearch:A9,commentsByFile:S8,showHidden:J7,sectionsExpanded:aX,onToggleSection:yG,onNewBoard:B1,onDeleteBoard:F1,onMoveCanvas:L1,onNewFolder:D1,onDeleteFolder:M1,onRenameFolder:O1,onRenameCanvas:A1,onDuplicateCanvas:_1,onDeleteFile:w1,onRefresh:rG,refreshing:q1,collapsed:!1,onCollapse:()=>wX("tree"),resizing:JZ("tree"),dirtyByPath:U1,project:Z,gitBranch:N8?.branch,remoteSync:A0,onGetLatest:jY,canvasKinds:i0?.canvasKinds,syncStatus:I0,onLinkedHub:D8,onLocalProject:w8,savingIsManaged:I8});if(b==="changes")return z(Fw,{status:N8&&A0?{...N8,...A0}:N8,project:Z,readOnly:!G9()||O0,historyOnly:F9,cloudManaged:v7,resizing:JZ("changes"),onClose:()=>Z8(!1),onCommit:jG,onDiscard:yY,onPublish:vG,onGetLatest:jY,loadLog:async(S)=>{let c=await dG(S);if(uG(c!=="legacy"),c!=="legacy")return c;return(v7?gG:O4)(S)},historySource:mG?"project":v7?"cloud":"local",historyRefresh:`${I0?.appliedRevision??0}:${pG}`,onRestoreVersion:(S)=>mH(V,S).then((c)=>!!c.ok),onUndoAction:F9?void 0:async(S)=>{let c=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(c?await c.json().catch(()=>null):null)?.ok},cloudHistory:xG,onOpenCanvas:(S)=>V6(S),onOpenDiff:(S)=>h0({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:T1,onPreviewVersion:(S)=>h0({file:V,beforeSha:S,conflict:!1}),designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(bw,{status:I0,project:i0?.cloud?.projectName||Z,cloud:i0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:JZ("sync"),onClose:()=>b8(!1)});if(b==="inspector"||b==="layers")return z(fL0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:o==="separate",cpMode:g8,onSetCpMode:t8,selected:O,cfg:i0,tab:b==="layers"?"layers":x5,onTabChange:eX,onClose:()=>b==="layers"?G4(!1):aJ(!1),onOptimistic:IX,onRecordEdit:JX,onReplaceMedia:c90,onResizeArtboard:N0,onSetArtboardHug:q8,onSetArtboardStyle:Q9,onSetArtboardKind:I1,onSetArtboardPrint:EL,onDuplicateArtboard:l0,editScope:A,onUndoRedo:(S)=>T0({dgn:S}),photoSel:BG,photoRev:NG,onPhotoEdit:Y8,onPhotoRemoveBackground:TG,onPhotoRecordEdit:q4,onPhotoUndoRedo:(S)=>G8(S==="redo"),layersTree:n,componentMap:s,lockedKeys:F4,onToggleLock:bG,onDetachInstance:_,canvasFile:V,onSelectLayer:(S)=>T0({dgn:"select-by-id",id:S.id,artboardId:n?.artboardId,index:S.index}),onHoverLayer:(S)=>T0({dgn:"highlight",id:S?S.id:null,artboardId:n?.artboardId,index:S?S.index:0}),onReorderLayer:sG,layersBusyRef:l,resizing:JZ(b)});if(b==="comments")return z(BL0,{commentsByFile:S8,filter:M0,setFilter:E0,activePath:V,focusedId:x9,onJump:r90,onResolve:O0?void 0:i90,onReopen:O0?void 0:o90,onDelete:O0?void 0:n90,resizing:JZ("comments")});return null};return D("div",{className:"maude"+(vJ?" is-present":""),"data-theme":v0,onContextMenu:t90,children:[fH&&z(fw,{}),z(FL0,{cloud:i0.cloud}),z(LL0,{update:AG,onDismiss:()=>hH(null)}),z(DL0,{status:I0}),!fH&&z(Dw,{status:I0,cloud:i0.cloud}),z(Ag,{paused:!!EQ||!!K4,hiddenGroups:z4.panelOpen?["exports"]:[]}),z(fm,{wn:_Q}),z(Im,{center:z4}),q0&&D("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:()=>Z0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(QL0,{sharePath:vY,onShare:()=>lH(),readOnly:O0,cloud:i0.cloud,activePath:V,project:Z,tabsCount:K.length,openMenu:v8,setOpenMenu:W9,commentsPanelOpen:h9,onToggleComments:()=>g6("comments"),changesOpen:Q8,changesCount:X9,onToggleChanges:()=>g6("changes"),onOpenSystem:CQ,sidebarOpen:T9,onToggleSidebar:()=>wX("tree"),showHidden:J7,onToggleShowHidden:()=>FQ((b)=>!b),onOpenHelp:()=>nJ(!0),onOpenShortcuts:()=>l9(!0),onReportBug:()=>Y4(!0),onStartTour:()=>PX(WF),onStartCollabTour:()=>PX(LE),annotationsVisible:X5,onToggleAnnotations:RY,minimapVisible:Q5,onToggleMinimap:CY,zoomCtlVisible:m6,onToggleZoomCtl:$Y,presentMode:vJ,onTogglePresent:$G,printGuidesVisible:PG,onTogglePrintGuides:SG,postToActiveCanvas:T0,onOpenReadiness:()=>FX(!0),onOpenQuickSetup:()=>y5(!0),onWatchIntro:()=>VY(!0),onOpenWhatsNew:_Q.openPanel,whatsNewCount:_Q.unseen.length,exportCenter:z4,artboardCount:l7,inspectorOpen:yJ,inspectorTab:x5,onToggleInspector:()=>g6("inspector"),autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),onInsertArtboard:m90,timelineOpen:L0,onToggleTimeline:OY,hasComps:P0.length>0,assistantOpen:_X,onToggleAssistant:()=>g6("assistant"),assistantBusy:Z1,assistantUnseen:H1,onOpenLayers:()=>{if(o==="separate")wX("layers");else if(yJ&&x5==="layers")aJ(!1);else eX("layers"),T6("inspector")},onNewCanvas:()=>{T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:N1,onOpenExport:(b)=>P6({mode:b}),onOpenSettings:()=>DQ(!0),onOpenGenerate:()=>bJ(!0),onReload:l5,onCloseCanvas:()=>V&&fY(V),presence:D(Q0,{children:[z(H90,{initials:SF0(h5||"you"),hue:"var(--accent)",title:h5?`${h5} (you)`:"You"}),kG&&z(H90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(U0?" is-resizing":""),ref:R8,children:[z(cF0,{shown:!_4,onExpand:()=>T6("tree"),onSearch:()=>{T6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(_4||$T)&&D(G90,{side:"left",width:X8.w,open:!!_4,ids:RT,activeId:_4,onPick:wX,labels:TT,children:[$T&&z(SN,{hidden:_4!=="assistant",activeCanvas:T1,selected:O,openComments:bT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>UG(!1),onBusyChange:bH,onFinished:yH,onPermissionRequest:LY,onElicitationRequest:LY}),_4&&_4!=="assistant"&&yT(_4)]}),_4&&z(K90,{label:"Resize left panel",size:X8,active:U0==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("sb")}}),z("div",{className:"main",children:z(YL0,{tabs:K,activePath:V,registerIframe:a90,systemData:F8,onOpenFromSystem:V6,onSelectDs:W5,project:Z,cfg:i0,loadingPath:J8,onIframeLoad:J9,canvasError:t0,canvasReloadNonce:p0,onRetryCanvasLoad:V1,loadedPath:k8,showQuickSetup:G9()&&!O0&&!!V7&&!V7.ready,onStartQuickSetup:()=>y5(!0),previewPath:N})}),xY&&z(K90,{label:"Resize right panel",dir:"rtl",size:P8,active:U0==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("rp")}}),(xY||ST)&&D(G90,{side:"right",width:P8.w,open:!!xY,ids:CT,activeId:xY,onPick:wX,labels:TT,children:[ST&&z(SN,{hidden:xY!=="assistant",activeCanvas:T1,selected:O,openComments:bT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>UG(!1),onBusyChange:bH,onFinished:yH,onPermissionRequest:LY,onElicitationRequest:LY}),xY&&xY!=="assistant"&&yT(xY)]})]}),L0&&z(YE,{comps:P0,compId:k6,sequences:K6,audio:J6,transitions:MX,total:sX,frame:M8,playing:L9,loop:MQ,onSeek:(b)=>{Z9(b),I6(!1),T0({dgn:"timeline-seek",frame:b,id:k6})},onPlay:()=>{I6(!0),T0({dgn:"timeline-mute",muted:FJ,id:k6}),T0({dgn:"timeline-loop",loop:MQ,id:k6}),T0({dgn:"timeline-play",id:k6})},onPause:()=>{I6(!1),T0({dgn:"timeline-pause",id:k6})},onToggleLoop:()=>s6((b)=>{let S=!b;return T0({dgn:"timeline-loop",loop:S,id:k6}),S}),muted:FJ,onToggleMute:()=>{f5((b)=>{let S=!b;return T0({dgn:"timeline-mute",muted:S,id:k6}),S})},volume:RH,onVolume:(b)=>{if(KG(b),b>0&&FJ)f5(!1),T0({dgn:"timeline-mute",muted:!1,id:k6});T0({dgn:"timeline-volume",volume:b,id:k6})},onRetime:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b),w0=b&&typeof b==="object"?b.index:b,p=F0?.stableId?{canvas:V,artboardId:c,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:w0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)})}).then((K0)=>K0.json()).then((K0)=>{if(!K0?.ok)console.warn("[retime]",K0?.error||"failed"),LJ("Retime refused",K0?.error);else if(h8(S.from!=null?"Clip moved.":"Clip trimmed.",!0),K0?.seq!=null)Y6(V,K0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:kQ,onReplace:(b)=>{if(!V||V===r8)return;aG({accept:"video/*,image/*",resolveTarget:(S)=>{let c=R6(S,b);if(c?.mediaArrayRef)return{arrayRef:c.mediaArrayRef};if(c?.mediaCdId)return{cdId:c.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===r8)return;aG({accept:"audio/*",resolveTarget:(S)=>{let c=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return c[b]?.cdId?{cdId:c[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===r8)return;let c=b&&typeof b==="object"?b.index:b,X0=K6[c]?.layers?.[S]?.kind==="audio"?"audio/*":K6[c]?.layers?.[S]?.kind==="image"?"image/*":"video/*";aG({accept:X0,resolveTarget:(K0)=>{let F0=R6(K0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((A8)=>A8.kind==="sequence"):[],w0=R6(K0,b),p=w0?F0.indexOf(w0):-1,D0=S==="forward"?p+1:p-1,k0=p>=0?F0[D0]||null:null,c0=S==="forward"?"after":"before";if(!w0?.stableId||!k0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c,stableId:w0.stableId,contentHash:w0.contentHash,refStableId:k0.stableId,refContentHash:k0.contentHash,position:c0})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[reorder-clip]",K0.error||"failed"),LJ("Reorder refused",K0.error);else if(K0?.seq!=null)Y6(V,K0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===r8)return;let S=X6||void 0,c=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(c).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let K0=R6(X0,b);if(!K0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:K0.stableId,contentHash:K0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)LJ("Hide refused",X0.error);else if(X0&&X0.ok){if(h8(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>h8("Hide failed: network error"))},onReorderMove:(b,S,c)=>{if(!V||V===r8)return;let X0=X6||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let w0=R6(F0,b),p=R6(F0,S);if(!w0?.stableId||!p?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:w0.stableId,contentHash:w0.contentHash,refStableId:p.stableId,refContentHash:p.contentHash,position:c,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),LJ("Reorder refused",F0.error);else if(F0?.ok){if(h8("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>h8("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=BY,K0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!P0.length){let p=[];for(let k0 of F0){let c0=k0.type.startsWith("audio/")?"audio":k0.type.startsWith("video/")?"video":null;if(!c0)continue;try{let A8=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}),O8=await A8.json().catch(()=>({}));if(O8?.path)p.push({src:O8.path,mediaKind:c0});else h8(`Upload failed: ${O8?.error||`HTTP ${A8.status}`}`)}catch{h8("Upload failed: network error")}}if(!p.length){h8("No video/audio files in the drop — nothing to cut.");return}let D0=!1;for(let k0 of p){let c0=await aw(k0.src).catch(()=>null),A8={canvas:K0,lane:k0.mediaKind==="audio"&&D0?"audio":"storyline",durationInFrames:V3(X0,c0),mediaTag:k0.mediaKind==="audio"?"Audio":"Video",src:k0.src};if(A8.lane==="audio")A8.from=0;let O8=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A8)}).catch(()=>null),q6=O8?await O8.json().catch(()=>null):null;if(q6?.ok){if(D0=!0,q6.seq!=null)Y6(K0,q6.seq,"add clip")}else if(!D0)break;else LJ("Insert refused",q6?.error)}if(D0){h8("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let k0=0;k0<8;k0+=1){let c0=k0===0?"New Cut":`New Cut ${k0+1}`,A8=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c0,kind:"video-comp",clips:p})}).catch(()=>null),O8=A8?await A8.json().catch(()=>({})):{};if(A8?.status===409)continue;if(!A8?.ok||!O8.ok){h8(`New cut failed: ${O8.error||"create refused"}`);return}await y9(),V6(O8.file),h8(`Started a new cut from ${p.length} clip${p.length>1?"s":""}.`,!0);return}h8('New cut failed: too many "New Cut" canvases — rename some.');return}let w0=S?.lane==="storyline"?S.index:void 0;for(let p of F0){let D0=p.type.startsWith("video/")?"Video":p.type.startsWith("audio/")?"Audio":p.type.startsWith("image/")?"Img":null;if(!D0)continue;let k0;try{k0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":p.type||"application/octet-stream"},body:p})).json().catch(()=>({}))}catch{k0=null}if(!k0?.path){h8(`Upload failed: ${k0?.error||"server unreachable — retry in a moment"}`);continue}let c0=D0==="Audio",A8=D0==="Video"?await aw(k0.path).catch(()=>null):null,O8={canvas:K0,artboardId:c,mediaTag:D0,src:k0.path};if(S&&(c0||S.lane==="audio"))O8.lane="audio",O8.from=Math.max(0,S.frame??0),O8.durationInFrames=Math.max(X0,sX-O8.from);else if(S?.lane==="storyline"&&!c0){if(O8.lane="storyline",w0!=null)O8.index=w0,w0+=1;O8.durationInFrames=V3(X0,A8)}else if(S?.lane==="overlay"&&!c0){if((K6||[]).length===0)O8.lane="storyline";else O8.lane="overlay",O8.from=Math.max(0,S.frame??0);O8.durationInFrames=V3(X0,A8)}else if(!c0)O8.lane="storyline",O8.durationInFrames=V3(X0,A8);else O8.lane="audio",O8.from=0,O8.durationInFrames=Math.max(X0,sX);try{let w7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O8)})).json().catch(()=>null);if(w7&&!w7.ok)console.warn("[insert-clip]",w7.error||"failed"),LJ("Insert refused",w7.error);else if(w7?.ok){if(h8("Clip added to the timeline.",!0),w7.seq!=null)Y6(K0,w7.seq,"add clip")}}catch{h8("Insert failed: network error")}}})()},height:jJ,onResize:C7,onClose:()=>y0(!1),selectedClipId:SH,onSelect:NY,transitionClips:CG,onClipVerb:TQ,comments:(S8[V]||[]).filter((b)=>b&&b.timeline),promptText:Y5,onAddComment:PY,onResolveComment:(b)=>$7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>$7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let c=b.sequences||[],X0=c.find((K0)=>K0.series&&b.frame>=K0.from&&b.frame<K0.from+K0.duration)||c.find((K0)=>b.frame>=K0.from&&b.frame<K0.from+K0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)TQ(S,"split",{atFrame:b.frame});else h8("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===r8)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(BY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("Title refused",X0.error);else if(X0?.ok){if(h8("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>h8("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===r8)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"storyline",durationInFrames:Math.round(BY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("AI clip refused",X0.error);else if(X0?.ok){if(h8("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>h8("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===r8)return;let S=V,c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b),w0=F0?.placeholder;if(!F0?.stableId||!w0?.prompt){h8("No AI placeholder prompt on this clip.");return}let p=w0.kind==="image"?"image":"video",D0=w0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${w0.prompt}`:w0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:p,prompt:D0})}).then(async(k0)=>k0.ok?k0.json():Promise.reject(Error(await k0.text()))).then((k0)=>{let c0=k0?.id;if(!c0)throw Error("no job id");h8(`Generating ${w0.kind}… (runs in the background)`,!0);let A8=F0.stableId,O8=()=>{fetch("/_api/generate-jobs").then((q6)=>q6.json().catch(()=>({}))).then((q6)=>{let w7=(q6?.jobs||[]).find((wJ)=>wJ.id===c0);if(!w7||w7.status==="failed"){h8(`Generation failed: ${w7?.error||"job lost"}`);return}if(w7.status!=="done"){setTimeout(O8,4000);return}let d9=w7.assets?.[0];if(!d9){h8("Generation finished but produced no asset.");return}fetch(X0).then((wJ)=>wJ.json().catch(()=>({}))).then((wJ)=>{let XZ=R6(wJ,{stableId:A8});if(!XZ?.stableId){h8("Placeholder clip is gone — generated asset kept in assets/.");return}TQ({stableId:XZ.stableId},"resolve-placeholder",{src:d9,mediaKind:p==="image"?"image":"video"})})}).catch(()=>setTimeout(O8,6000))};setTimeout(O8,3000)}).catch((k0)=>h8(`Generate failed: ${k0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>h8("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===r8)return;let S=(X0,K0)=>{let F0=BY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":K0||"application/octet-stream"},body:X0}).then((w0)=>w0.json().catch(()=>({}))).then((w0)=>{if(!w0?.path)return h8(`Upload failed: ${w0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:w0.path})})}).then((w0)=>w0?w0.json():null).then((w0)=>{if(w0&&!w0.ok)LJ("Image refused",w0.error);else if(w0?.ok){if(h8("Image overlay added.",!0),w0.seq!=null)Y6(V,w0.seq,"add image overlay")}}).catch(()=>h8("Image failed: network error"))};if(G9()){cZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>h8(`Image pick failed: ${X0?.message||"dialog error"}`));return}let c=document.createElement("input");c.type="file",c.accept="image/*",c.addEventListener("change",()=>{let X0=c.files?.[0];if(X0)S(X0,X0.type)}),c.click()},resolveMediaUrl:(b)=>`/${(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(qL0,{activePath:V,selected:O,wsConnected:z0,openCount:s90,theme:v0,onToggleTheme:D4,onClearSelected:E1,syncStatus:I0,syncProject:i0?.cloud?.projectName||Z,syncOpen:f8,onOpenSync:I0?()=>g6("sync"):void 0,changesCount:X9,unpushed:I8?0:N8?.unpushed||0,savingIsManaged:I8,changesOpen:Q8,onOpenChanges:N8?.repo||I8?()=>EX("changes"):void 0,version:i0?.version})]}),vJ&&D("button",{type:"button",className:"st-present-exit",onClick:N4,"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($F0,{open:q7,onClose:()=>z6(!1),actions:e90}),RQ&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)u5(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":RQ.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:RQ.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:RQ.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")u5(b.currentTarget.value);else if(b.key==="Escape")u5(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>u5(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>u5(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),SJ&&z(_g,{target:SJ,links:pH(SJ.path),shell:iG,onClose:()=>j5(null),Icon:k9}),LQ&&z(gF0,{mode:LQ.mode,initialScope:LQ.scope,activePath:V,hasComps:P0.length>0,comps:P0,activeArtboardId:O?.artboardId??R9??null,selection:O?.selector?{selector:O.selector,file:O.file}:null,exportLane:i0.exportLane||"local",onBrowserCapture:IQ,onClose:()=>P6(null)}),W4&&z(VE,{cloud:i0.cloud,onClose:()=>DQ(!1),initialTab:typeof W4==="string"?W4:void 0,theme:v0,onSetTheme:W8,cpMode:g8,onSetCpMode:t8,minimapVisible:Q5,onToggleMinimap:CY,zoomCtlVisible:m6,onToggleZoomCtl:$Y,annotationsVisible:X5,onToggleAnnotations:RY,autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),hasCanvas:!!V&&V!==r8,panelSide:NJ,onSetPanelSide:(b,S)=>Z4((c)=>({...c,[b]:S})),layersMode:o,onSetLayersMode:(b)=>{if(G0(b),b!=="separate")G4(!1)}}),zG&&z(GE,{onClose:()=>bJ(!1),onInsert:L}),eG&&z(hF0,{designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:p90,onClose:()=>k1(null),multiple:!!eG.multiple,hasArtboardAnchor:!!eG.hasArtboardAnchor,onPickMany:l90}),PL&&z(qE,{onPick:d90,onClose:()=>IL(null)}),O9&&z(Nw,{target:O9,cfg:i0,loadLog:K1,onClose:()=>h0(null),onRestore:async(b,S)=>{let c=cG?await mH(b,/^r\d+$/.test(S||"")?Number(S.slice(1)):NaN):await yY([b]);if(c?.ok)h0(null);else window.alert(c?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await fG(b);if(S.ok)h0(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(nF0,{open:rJ,onClose:()=>l9(!1)}),z(iF0,{open:oJ,onClose:()=>nJ(!1),onStartTour:()=>{nJ(!1),PX(WF)}}),z($m,{open:e7,activeCanvas:V,onClose:()=>Y4(!1)}),z(xm,{wn:_Q,onStartTour:PX}),z(km,{center:z4}),z(Ch,{open:R7,onClose:()=>FX(!1)}),z(jV,{open:j9,onClose:()=>VY(!1)}),z(mw,{open:p7,onClose:()=>y5(!1),onStartTour:()=>PX(Lm),onBringBrand:()=>f7(!0),onImportFigma:()=>LX(!0)}),z(xw,{open:HG,onClose:()=>f7(!1)}),qY&&z(hw,{onClose:()=>LX(!1),onImported:()=>y9()}),EQ&&!K4&&!xH&&D("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:()=>{U4(),PX(WF)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:U4,children:"×"})]}),xH&&!K4&&D("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:()=>{DJ(),PX(LE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:DJ,children:"×"})]}),z(Fm,{steps:K4??[],open:!!K4,onClose:()=>wQ(null),onComplete:U4,bus:wG,hasSelection:!!O,hasCanvas:K.length>0})]})}R90.createRoot(document.getElementById("root")).render(z(xL0,{}));
5689
+ You can restore it from .design/_trash/.`))return;try{let c=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await c.json().catch(()=>({}));if(!c.ok||!X0.ok){h8(`Could not delete: ${X0.error||`error ${c.status}`}`);return}await y9()}catch(c){h8(`Delete failed: ${c instanceof Error?c.message:"network error"}`)}},[y9]),E1=u.useCallback(()=>{if($7({type:"clear-select"}),E(null),V&&V!==r8){let b=c8.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===r8)return;let b=c8.current.get(V);if(!b||!b.contentWindow)return;let S=vJ?[]:S8[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,S8,vJ]),u.useEffect(()=>{let b=(F0)=>!!V&&(S8[V]||[]).some((w0)=>w0&&w0.id===F0);function S(F0){let w0=i0?.canvasOrigin||window.location.origin;if(F0.origin!==w0)return;let p=F0.data;if(!p||typeof p!=="object"||!p.dgn)return;if(p.dgn==="canvas-notice"){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null,k0=Dm(F0,w0,L0);if(k0)Og(k0.title,k0.kind);return}if(p.dgn==="tool-cursor"){if(p.tool==="browse"){document.body.style.cursor="";let k0=document.getElementById("dc-app-cursor");if(k0)k0.textContent="";BL(O0);return}let L0=yb(p.tool);if(L0){document.body.style.cursor=L0;let k0=document.getElementById("dc-app-cursor");if(!k0)k0=document.createElement("style"),k0.id="dc-app-cursor",document.head.appendChild(k0);k0.textContent=`* { cursor: ${L0} !important; }`}return}if(p.dgn==="select"||p.dgn==="select-set"||p.dgn==="clear-select"||p.dgn==="edit-text"||p.dgn==="apply-edit"||p.dgn==="undo-barrier"){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return}if(p.dgn==="select"&&p.selection)DY(null),T.current=Date.now(),$7({type:"select",selection:p.selection}),E(p.selection),OG(p.selection);else if(p.dgn==="select-set"){DY(null),T.current=Date.now();let L0=p.selection;if(L0==null)$7({type:"clear-select"}),E(null);else if(Array.isArray(L0)){let k0=L0[0]??null;if(k0)$7({type:"select",selection:k0});if(E(k0),L0.length===1)OG(k0)}else $7({type:"select",selection:L0}),E(L0),OG(L0)}else if(p.dgn==="clear-select")DY(null),T.current=Date.now(),$7({type:"clear-select"}),E(null);else if(p.dgn==="edit-text"&&p.id){let L0=F0.source,k0=(c0)=>{try{L0?.postMessage({dgn:"edit-reverted",op:"text",id:p.id,reason:c0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:p.file,id:p.id,text:p.text??"",...typeof p.occurrence==="number"?{occurrence:p.occurrence}:{},...typeof p.before==="string"?{before:p.before}:{}})}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0.ok)k0(c0.error||"this element can't be edited inline")}).catch(()=>k0("network error"))}else if(p.dgn==="undo-barrier"&&typeof p.requestId==="string"){let L0=F0.source;Promise.all([C6.current.catch(()=>{}),EL0()]).then(()=>{try{L0?.postMessage({dgn:"undo-barrier-ok",requestId:p.requestId},"*")}catch{}})}else if(p.dgn==="apply-edit"&&p.id&&(p.op==="css"||p.op==="text"||p.op==="attr")){let L0=cb(p);if(!L0)return;let k0=F0.source,c0=(O8)=>{if(typeof p.requestId!=="string")return;try{k0?.postMessage({dgn:"apply-edit-result",requestId:p.requestId,...O8},"*")}catch{}},A8=typeof p.value==="string"?p.value:null;C6.current=C6.current.catch(()=>{}).then(()=>fetch(L0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(L0.body)}).then((O8)=>O8.json().catch(()=>({}))).then((O8)=>{if(O8.ok){if(L0.op==="css")IX({id:p.id,prop:p.key,value:A8});c0({ok:!0});return}console.warn("[apply-edit]",L0.op,O8.error||"failed"),c0({ok:!1,error:O8.error||"failed",conflict:O8.conflict===!0})}).catch(()=>c0({ok:!1,error:"network error"})))}else if(p.dgn==="layers-tree"){e({artboardId:p.artboardId,nodes:Array.isArray(p.tree)?p.tree:[]});let L0=wF0(p.tree);if(m.current={tree:p.tree,sig:L0,artboardId:p.artboardId??null},l.current=!1,v.current)clearTimeout(v.current),v.current=null;d.current?.(p.tree,L0,p.artboardId??null)}else if(p.dgn==="reorder-revert"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.seq==="number"&&(p.dir==="undo"||p.dir==="redo");if(F0.source===L0&&k0&&V){if(l.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{l.current=!1,v.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:p.seq,dir:p.dir})}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0.ok)console.warn("[reorder-revert]",c0.error||"failed")}).catch(()=>{})}}else if(p.dgn==="reorder-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&typeof p.refId==="string"&&(p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end");if(F0.source===L0&&k0)a.current?.(p.id,p.refId,p.position,{idIndex:Number.isInteger(p.idIndex)?p.idIndex:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="reposition-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&Number.isFinite(p.left)&&Number.isFinite(p.top)&&Number.isFinite(p.beforeLeft)&&Number.isFinite(p.beforeTop);if(F0.source===L0&&k0)x.current?.(p.id,p.left,p.top,p.beforeLeft,p.beforeTop,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="resize-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&p.patch&&typeof p.patch==="object";if(F0.source===L0&&k0)h.current?.(p.id,p.patch,p.before,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="delete-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.id==="string")FT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="duplicate-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.id==="string")AT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="copy-style"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0)wT.current?.()}else if(p.dgn==="paste-style"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.id==="string")ET.current?.(p.id)}else if(p.dgn==="insert-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.refId==="string",c0=typeof p.artboardId==="string",A8=p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end",O8=k0!==c0&&(p.kind==="div"||p.kind==="text"||p.kind==="image")&&A8&&(!c0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===L0&&O8)LT.current?.(p.refId,p.position,p.kind,{artboardId:c0?p.artboardId:void 0,src:typeof p.src==="string"?p.src:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="insert-image-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.refId==="string",c0=typeof p.artboardId==="string",A8=!k0&&!c0,O8=(k0!==c0||A8)&&(A8||p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end")&&(!c0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===L0&&O8)Aq.current?.({purpose:"insert-image",canvas:V,refId:p.refId,artboardId:c0?p.artboardId:void 0,position:A8?void 0:p.position,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0,multiple:!0,hasArtboardAnchor:!A8})}else if(p.dgn==="replace-media-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.id==="string")Aq.current?.({purpose:"replace-src",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="convert-to-absolute-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=Array.isArray(p.containers)&&p.containers.length>0,c0=typeof p.containerId==="string"&&Array.isArray(p.children)&&p.children.length>0;if(F0.source===L0&&(k0||c0)){let A8=k0?p.containers.reduce((O8,q6)=>O8+(Array.isArray(q6?.children)?q6.children.length:0),0):p.children.length;tG.current?.("/_api/convert-to-absolute",k0?{allowShared:p.allowShared===!0,containers:p.containers,...Array.isArray(p.dissolve)&&p.dissolve.length>0?{dissolve:p.dissolve}:{}}:{containerId:p.containerId,containerSetRelative:p.containerSetRelative===!0,allowShared:p.allowShared===!0,children:p.children},{label:"convert to absolute",onOk:()=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Converted ${A8} element${A8===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(O8)=>T0({dgn:"op-toast",message:`Convert failed: ${O8?.error||"unknown error"}`})})}}else if(p.dgn==="replace-annotation-media-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.id==="string")Aq.current?.({purpose:"replace-annotation-media",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="edit-annotation-photo-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=BT.exec(typeof p.asset==="string"?p.asset:"")?.[0]||null;if(F0.source===L0&&typeof p.id==="string"&&k0)DY({asset:k0,strokeId:p.id}),EX("inspector"),eX("photo")}else if(p.dgn==="open-sticker-picker"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0)PT.current?.({canvas:V})}else if(p.dgn==="insert-artboard-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.id==="string"&&Number.isFinite(p.width)&&Number.isFinite(p.height);if(F0.source===L0&&k0)DT.current?.({id:p.id,label:typeof p.label==="string"?p.label:p.id,width:p.width,height:p.height})}else if(p.dgn==="resize-artboard-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=typeof p.artboardId==="string"&&(Number.isFinite(p.width)||Number.isFinite(p.height));if(F0.source===L0&&k0)MT.current?.(p.artboardId,Number.isFinite(p.width)?p.width:void 0,Number.isFinite(p.height)?p.height:void 0)}else if(p.dgn==="delete-artboard-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.artboardId==="string")OT.current?.(p.artboardId)}else if(p.dgn==="rename-artboard-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.artboardId==="string"&&typeof p.label==="string"&&p.label.trim())tG.current?.("/_api/set-artboard-label",{artboardId:p.artboardId,label:p.label.slice(0,80)},{label:"rename artboard"})}else if(p.dgn==="set-artboard-kind-request"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=p.kind===null||typeof p.kind==="string";if(F0.source===L0&&typeof p.artboardId==="string"&&k0)NT.current?.(p.artboardId,p.kind)}else if(p.dgn==="duplicate-artboard-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&typeof p.artboardId==="string"&&Number.isFinite(p.width))_T.current?.(p.artboardId,p.width)}else if(p.dgn==="open-inspector"){if(EX("inspector"),typeof p.tab==="string")eX(p.tab)}else if(p.dgn==="present-enter"){let L0=V?c8.current.get(V)?.contentWindow:null,k0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===L0&&!k0&&!vJ)V4(!0),MJ({present:!0})}else if(p.dgn==="comment-compose"&&p.selection)E(p.selection);else if(p.dgn==="comment-submit"&&p.payload&&typeof p.payload.text==="string"){let L0=p.payload,k0=String(L0.text).trim(),c0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===c0&&k0&&V&&V!==r8)$7({type:"comments-add",payload:{file:V,selector:L0.selector,index:L0.index,dom_path:L0.dom_path,tag:L0.tag,classes:L0.classes,bounds:L0.bounds,html_excerpt:L0.html_excerpt,annotationId:L0.annotationId,world:L0.world,text:k0}})}else if(p.dgn==="comment-patch"&&p.id&&p.patch&&typeof p.patch==="object"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&b(p.id))$7({type:"comments-patch",id:p.id,patch:p.patch})}else if(p.dgn==="comment-delete"&&p.id){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0&&b(p.id))$7({type:"comments-delete",id:p.id}),i9((k0)=>k0===p.id?null:k0)}else if(p.dgn==="comment-click"&&p.id)i9(p.id);else if(p.dgn==="artboards"&&typeof p.count==="number"){let L0=Math.round(p.count);if(Number.isFinite(L0)&&L0>=0&&L0<=999)tJ(L0)}else if(p.dgn==="active-artboard"){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return;DX(sN(p.id))}else if(p.dgn==="timeline-comps"&&Array.isArray(p.comps)){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return;let k0=p.comps.filter((O8)=>O8&&typeof O8.id==="string").slice(0,32).map((O8)=>({id:String(O8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(O8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(O8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(O8.width)||0)),height:Math.max(1,Math.round(Number(O8.height)||0)),artboardId:sN(O8.artboardId),artboardLabel:sN(O8.artboardLabel)}));z8(k0);let c0=tX.current;if(c0&&k0.some((O8)=>O8.id===c0)&&OX.current>0)T0({dgn:"timeline-seek",frame:OX.current,id:c0})}else if(p.dgn==="timeline-frame"&&typeof p.frame==="number"){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return;if(p.id&&tX.current&&p.id!==tX.current)return;if(Number.isFinite(p.frame))Z9(Math.max(0,Math.round(p.frame)))}else if(p.dgn==="timeline-ended"){let L0=V&&V!==r8?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return;if(p.id&&tX.current&&p.id!==tX.current)return;I6(!1)}else if(p.dgn==="toggle-palette")z6((L0)=>!L0);else if(p.dgn==="shell-shortcut"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0){if(p.id==="reload")l5();else if(p.id==="inspector")g6("inspector");else if(p.id==="assistant"&&G9())g6("assistant");else if(p.id==="comments")g6("comments");else if(p.id==="changes")g6("changes");else if(p.id==="timeline")OY();else if(p.id==="export")P6({mode:"export"});else if(p.id==="handoff")P6({mode:"handoff"})}}else if(p.dgn==="open-export"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0)P6({mode:"export",scope:p.detail&&typeof p.detail.scope==="string"?p.detail.scope:void 0})}else if(p.dgn==="open-timeline-request"){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source===L0){if(typeof p.artboardId==="string")DX(p.artboardId.slice(0,120));y0(!0)}}else if(p.dgn==="loaded"&&p.file){r0((c0)=>c0===p.file?null:c0),_0(p.file),H8((c0)=>c0&&c0.path===p.file?null:c0);let L0=vJ?[]:S8[p.file]||[],k0=[...c8.current.entries()].find(([c0])=>c0===p.file)?.[1];if(k0&&k0.contentWindow){try{k0.contentWindow.postMessage({dgn:"comments-set",comments:L0},"*")}catch{}try{k0.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}try{k0.contentWindow.postMessage({dgn:"view-chrome",minimap:Q5,zoom:m6,present:vJ},"*")}catch{}if(x9&&L0.some((A8)=>A8.id===x9))try{k0.contentWindow.postMessage({dgn:"comment-focus",id:x9},"*")}catch{}let c0=f.current;if(c0&&c0.file===p.file){f.current=null;try{k0.contentWindow.postMessage({dgn:"request-layers",artboardId:c0.artboardId??null},"*")}catch{}if(c0.movedId)try{k0.contentWindow.postMessage({dgn:"select-by-id",id:c0.movedId,artboardId:c0.artboardId??null,index:0},"*")}catch{}}else{let A8=w.current,O8=Array.isArray(A8)?A8[0]:A8;if(O8&&O8.id&&O8.file===p.file)$(O8)}}}else if(p.dgn==="export-request"&&p.id&&p.payload){let L0=V?c8.current.get(V)?.contentWindow:null;if(F0.source!==L0)return;X0(F0.source,p.id,p.payload)}else if(p.dgn==="export-history-request"&&p.id)K0(F0.source,p.id)}let c=i0?.canvasOrigin||window.location.origin;async function X0(F0,w0,p){if(p?.options&&V&&V!==r8)p.options.canvasFile=V;let L0=(A8)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:w0,...A8},c)}catch{}},k0=p?.options||{};if(YB({exportLane:i0.exportLane||"local",format:p?.format,scope:p?.scope,artboardId:k0.artboardId}))try{if(p.format==="pptx"){let{filename:A8,blob:O8}=await jO({capture:IQ,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});DL(A8,O8)}else{let A8=fO(k0),O8=await IQ({format:p.format,artboardIds:[k0.artboardId],scale:A8}),q6=await vO(O8,p.format);for(let w7 of q6)DL(w7.name,w7.blob)}L0({ok:!0,browser:!0});return}catch{if(i0.exportLane!=="remote"){L0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(i0.exportLane==="none"&&p?.format!=="zip"){L0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let A8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)});if(!A8.ok){L0({ok:!1,error:await A8.text()||String(A8.status)});return}let{jobId:O8}=await A8.json();L0({ok:!0,jobId:O8})}catch(A8){L0({ok:!1,error:A8&&A8.message?A8.message:String(A8)})}}async function K0(F0,w0){let p=[];try{let L0=await fetch("/_api/export-history");if(L0.ok){let k0=await L0.json();if(Array.isArray(k0.history))p=k0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:w0,history:p},c)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[S8,x9,i0,v0,l5,vJ,Q5,m6,MJ,V,T0,IQ]);let P1=u.useCallback(()=>{if(!V||V===r8)return;let b=c8.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),IX=u.useCallback((b)=>{if(!V||V===r8)return;let S=c8.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),JX=u.useCallback((b)=>{if(!V||V===r8||!b)return;let S=c8.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),C6=u.useRef(Promise.resolve()),sG=u.useCallback((b,S,c,X0)=>{let K0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(K0??0)===(F0??0))return;let w0=w.current,p=Array.isArray(w0)?w0[0]:w0,L0=V;if(!L0)return;let k0=V,c0=n?.artboardId??p?.artboardId??null;if(e((A8)=>A8?{...A8,nodes:RL0(A8.nodes,b,S,c)}:A8),l.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{l.current=!1,v.current=null},700),C6.current=C6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:L0,id:b,refId:S,position:c,idIndex:K0,refIndex:F0})}).then((A8)=>A8.json().catch(()=>({}))).then((A8)=>{if(!A8.ok){if(console.warn("[reorder]",A8.error||"failed"),T0({dgn:"reorder-failed"}),T0({dgn:"request-layers",artboardId:c0}),l.current=!1,v.current)clearTimeout(v.current),v.current=null;return}if(f.current={file:k0,movedId:A8.movedId||null,artboardId:c0},typeof A8.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:L0,seq:A8.seq,label:"move element"}})}).catch(()=>{}))},[V,n,T0]);u.useEffect(()=>{a.current=sG},[sG]);let oH=u.useCallback((b,S,c,X0,K0,F0)=>{if(!b||!V)return;let w0=V,p=Number.isInteger(F0)?F0:void 0;IX({id:b,prop:"left",value:`${S}px`}),IX({id:b,prop:"top",value:`${c}px`});let L0=null,k0=(c0,A8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:w0,id:b,property:c0,value:`${A8}px`,idIndex:p})}).then((O8)=>O8.json().catch(()=>({})));C6.current=C6.current.catch(()=>{}).then(()=>k0("left",S)).then((c0)=>{if(!c0.ok)throw Error(c0.error||"left write failed");return L0=c0,k0("top",c)}).then((c0)=>{if(!c0.ok)throw Error(c0.error||"top write failed");JX({op:"css",canvas:w0,id:b,key:"left",before:Lq(L0,`${X0}px`),after:`${S}px`}),JX({op:"css",canvas:w0,id:b,key:"top",before:Lq(c0,`${K0}px`),after:`${c}px`})}).catch((c0)=>{console.warn("[reposition]",c0?.message||c0),T0({dgn:"reposition-failed"})})},[V,T0,JX,IX]);u.useEffect(()=>{x.current=oH},[oH]);let nH=u.useCallback((b,S,c,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let K0=V,F0=c&&typeof c==="object"?c:{},w0=Number.isInteger(X0)?X0:void 0,p=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((d9)=>typeof S[d9]==="string"&&S[d9]);if(!p.length)return;let L0=w.current,k0=Array.isArray(L0)?L0.length===1?L0[0]:null:L0,c0=k0&&k0.id===b?k0.artboardId??null:null,A8=k0&&k0.id===b?k0.index??0:0;for(let d9 of p)IX({id:b,artboardId:c0,index:A8,prop:d9,value:S[d9]});let O8=(d9,wJ)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K0,id:b,property:d9,value:wJ,idIndex:w0})}).then((XZ)=>XZ.json().catch(()=>({}))),q6={},w7=C6.current.catch(()=>{});for(let d9 of p)w7=w7.then((wJ)=>{if(wJ&&wJ.ok===!1)throw Error(wJ.error||`${d9} write failed`);return O8(d9,S[d9]).then((XZ)=>{return q6[d9]=XZ,XZ})});C6.current=w7.then((d9)=>{if(d9&&d9.ok===!1)throw Error(d9.error||"resize write failed");for(let wJ of p)JX({op:"css",canvas:K0,id:b,key:wJ,before:Lq(q6[wJ],F0[wJ]??null),after:S[wJ]});$({id:b,file:K0,artboardId:c0,index:A8})}).catch((d9)=>{console.warn("[resize]",d9?.message||d9),T0({dgn:"resize-failed"})})},[V,T0,JX,IX,$]);u.useEffect(()=>{h.current=nH},[nH]);let tG=u.useRef(null),Y7=u.useCallback((b,S,{label:c,onOk:X0,onFail:K0}={})=>{if(!V)return;let F0=V,w0=K0??((p)=>T0({dgn:"op-toast",message:`Couldn't ${c||"apply the edit"}${p?.error?` — ${p.error}`:""}.`}));C6.current=C6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(!p.ok){console.warn(`[${b}]`,p.error||"failed"),w0?.(p);return}if(typeof p.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:p.seq,label:c||"edit"}});X0?.(p,F0)}).catch((p)=>w0?.({error:p?.message})))},[V,T0]);u.useEffect(()=>{tG.current=Y7},[Y7]);let rH=u.useCallback((b,S)=>{Y7("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>T0({dgn:"selection-clear"})})},[Y7,T0]),q=u.useCallback((b,S,c,X0={})=>{let K0=m.current?.sig??null;Y7("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:c,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${c}`,onOk:(F0,w0)=>{if(!F0.newId)return;f.current={file:w0,movedId:F0.newId,artboardId:null,staleSig:K0};let p=m.current;if(p)d.current?.(p.tree,p.sig,p.artboardId)}})},[Y7]),L=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=w.current?.artboardId??R9??null;if(!S)return!1;return q(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,R9,q]),_=u.useCallback((b,S)=>{Y7("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(c)=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Detached — this instance is now ${c.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(c)=>T0({dgn:"op-toast",message:`Detach failed: ${c?.error||"unknown error"}`})})},[Y7,T0]),P=u.useCallback((b,S)=>{let c=m.current?.sig??null;Y7("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,K0)=>{if(!X0.newId)return;f.current={file:K0,movedId:X0.newId,artboardId:null,staleSig:c};let F0=m.current;if(F0)d.current?.(F0.tree,F0.sig,F0.artboardId)}})},[Y7]),k=u.useRef(null),y=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),g=u.useCallback(()=>{let b=w.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let c={};for(let[X0,K0]of Object.entries(S.authored||{}))if(!y.has(X0))c[X0]=K0;for(let[X0,K0]of Object.entries(S.customStyles||{}))if(!y.has(X0))c[X0]=K0;k.current=Object.keys(c).length?c:null},[y]),J0=u.useCallback((b)=>{let S=V,c=k.current;if(!S||!b||!c)return;let X0=Object.entries(c),K0=C6.current.catch(()=>{});for(let[F0,w0]of X0)IX({id:b,prop:F0,value:w0}),K0=K0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:w0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(p.ok)JX({op:"css",canvas:S,id:b,key:F0,before:Lq(p,null),after:w0})}).catch(()=>{}));C6.current=K0},[V,IX,JX]),W0=u.useCallback(({id:b,label:S,width:c,height:X0})=>{Y7("/_api/insert-artboard",{id:b,label:S,width:c,height:X0},{label:"insert artboard"})},[Y7]),N0=u.useCallback((b,S,c)=>{Y7("/_api/resize-artboard",{artboardId:b,width:S,height:c},{label:"resize artboard",onFail:()=>T0({dgn:"resize-artboard-failed"}),onOk:()=>j(b,V)})},[Y7,T0,j,V]),R0=u.useCallback((b)=>{Y7("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[Y7]),l0=u.useCallback((b,S)=>{Y7("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[Y7]),q8=u.useCallback((b,S,c)=>{Y7("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:c},{label:S?"pin artboard height":"hug artboard height",onOk:()=>j(b,V)})},[Y7,j,V]),Q9=u.useCallback((b,S)=>{Y7("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>j(b,V)})},[Y7,j,V]),B7=u.useRef(null),_J=u.useCallback((b,S)=>{Y7("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>j(b,V)});let c=B7.current;if(S==="print"&&c&&c.artboardId===b)B7.current=null,Y7("/_api/resize-artboard",{artboardId:b,width:c.widthPx,height:c.heightPx},{label:"artboard size"}),Y7("/_api/set-artboard-print",{artboardId:b,print:c.defaults},{label:"artboard print"})},[Y7,j,V]),NT=u.useRef(null);u.useEffect(()=>{NT.current=_J},[_J]);let I1=u.useCallback((b,S,c)=>{if(S==="print"||S==null||S==="digital"){if(c)B7.current={artboardId:b,...c};T0({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}_J(b,S)},[_J,T0]),EL=u.useCallback((b,S)=>{Y7("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>j(b,V)})},[Y7,j,V]),m90=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),K0;try{K0=QB({paper:X0})}catch{return}let F0=XB.find((w0)=>w0.id===X0);W0({id:S,label:F0?F0.label:X0.toUpperCase(),width:K0.widthPx,height:K0.heightPx}),I1(S,"print"),EL(S,{paper:X0});return}let c=S5[b];if(!c)return;W0({id:S,label:c.label,width:c.width,height:c.height})},[W0,I1,EL]),FT=u.useRef(null),LT=u.useRef(null),DT=u.useRef(null),MT=u.useRef(null),OT=u.useRef(null),u90=u.useRef(null),AT=u.useRef(null),_T=u.useRef(null),wT=u.useRef(null),ET=u.useRef(null);u.useEffect(()=>{FT.current=rH,LT.current=q,DT.current=W0,MT.current=N0,OT.current=R0,u90.current=I1,AT.current=P,_T.current=l0,wT.current=g,ET.current=J0},[rH,q,W0,N0,R0,I1,P,l0,g,J0]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let c=S.target;if(c&&(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.tagName==="SELECT"||c.isContentEditable))return;if(S.preventDefault(),!V||V===r8)return;let K0=Array.isArray(O)?O.length===1?O[0]:null:O;if(K0?.artboardId&&!K0.id)R0(K0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,O,R0]);let[eG,k1]=u.useState(null),Aq=u.useRef(null);u.useEffect(()=>{Aq.current=(b)=>k1(b)},[]);let[PL,IL]=u.useState(null),PT=u.useRef(null);u.useEffect(()=>{PT.current=(b)=>IL(b)},[]);let p90=u.useCallback((b)=>{let S=eG;if(k1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){q(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let c=V;if(!c||!S.id)return;C6.current=C6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:c,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)JX({op:"attr",canvas:c,id:S.id,key:"src",before:Lq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")T0({dgn:"replace-annotation-media",id:S.id,path:b})},[eG,q,V,JX,T0]),l90=u.useCallback((b,S)=>{let c=eG;if(k1(null),!c||!Array.isArray(b)||!b.length)return;if(c.canvas&&c.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=w.current?.artboardId??R9??null;if(!X0)return;for(let K0 of b)q(void 0,"inside-end","image",{artboardId:X0,src:K0});return}T0({dgn:"insert-annotation-media",paths:b})},[eG,V,q,R9,T0]),d90=u.useCallback(async(b)=>{let S=PL;if(IL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let c=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":c.type||"image/png"},body:c}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.path){console.warn("[sticker-picker]",K0.error||`upload failed (HTTP ${X0.status})`);return}T0({dgn:"insert-sticker",path:K0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[PL,V,T0]),c90=u.useCallback((b)=>{if(!b?.id)return;k1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),i90=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),o90=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),n90=u.useCallback((b)=>{$7({type:"comments-delete",id:b}),i9((S)=>S===b?null:S)},[]),r90=u.useCallback((b,S)=>{if(b&&b!==V)U((X0)=>X0.find((K0)=>K0.path===b)?X0:[...X0,{path:b}]),B(b);if(S==null){i9(null);return}i9(S);let c=()=>{let X0=c8.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};c(),setTimeout(c,200)},[V]);u.useEffect(()=>{function b(S){let c=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,K0=document.activeElement?.tagName==="IFRAME";if(vJ&&S.key==="Escape"){S.preventDefault(),N4();return}if(c&&(S.key==="k"||S.key==="K")){S.preventDefault(),z6((F0)=>!F0);return}if(c&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!K0&&V&&V!==r8){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(x5==="photo"&&G8(F0)){S.preventDefault();return}S.preventDefault(),T0({dgn:F0?"redo":"undo"});return}}if(c&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),rG();return}if(c&&(S.key==="r"||S.key==="R")){S.preventDefault(),l5();return}if(c&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),g6("comments");return}if(c&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),g6("changes");return}if(c&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),g6("inspector");return}if(c&&S.shiftKey&&(S.key==="a"||S.key==="A")&&G9()){if(S.preventDefault(),!O0)g6("assistant");return}if(c&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),P6({mode:"export"});return}if(c&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),P6({mode:"handoff"});return}if(c&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!O0)DQ(!0);return}if(c&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),OY();return}if(c&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(O&&O.selector&&V&&V!==r8&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(c&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!T9)T6("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(K0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||c)return;S.preventDefault(),wX("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||c)return;S.preventDefault(),FQ((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!c&&!S.shiftKey){if(S.preventDefault(),V===r8)fY(r8);else CQ();return}if((S.key==="n"||S.key==="N")&&!c&&!S.shiftKey){S.preventDefault(),T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),l9((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),nJ(!0);return}if(S.key==="Escape"){if(x9){i9(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[l5,rG,O,V,x9,T9,CQ,fY,P1,vJ,N4,OY,x5,G8,O0]);let a90=u.useCallback((b,S)=>{if(S)c8.current.set(b,S)},[]),s90=S90(S8).open,t90=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),e90=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>iH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>P6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=pH(vY),S=b.web??b.app??b.local;if(S)bV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>P6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>bJ(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>DQ(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>CQ()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>g6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>EX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>l5()},{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:()=>D4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>_Q.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>l9(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>nJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>Y4(!0)}],[CQ,D4,l5,_Q,iH,vY,iG,e0,s8,i0.designRel]),J70=(b)=>{if(O0&&b==="assistant")return!1;if(b==="sync")return!!I0;return b==="assistant"?G9():b==="layers"?o==="separate":!0},IT=(b)=>VT.filter((S)=>J70(S.id)&&(NJ[S.id]||J1[S.id])===b).map((S)=>S.id),kT={tree:T9,layers:v5,inspector:yJ,comments:h9,changes:Q8,sync:f8,assistant:_X},TT=i0.cloud?{changes:"History"}:null,RT=IT("left"),CT=IT("right"),_4=RT.find((b)=>kT[b])||null,xY=CT.find((b)=>kT[b])||null,$T=G9()&&!O0&&(NJ.assistant||"right")==="left",ST=G9()&&!O0&&(NJ.assistant||"right")==="right",JZ=(b)=>(NJ[b]||J1[b])==="left"?U0==="sb":U0==="rp",T1=V&&V!==r8&&/\.(tsx|html)$/i.test(V)?V:null,bT=T1?NL(S8[T1]):0,yT=(b)=>{if(b==="tree")return z(dF0,{cloud:i0.cloud,readOnly:O0,groups:J,activePath:V,previewPath:N,activeDsName:V===r8?F8?.ds?.name??null:null,onOpen:V6,onPreview:M,onOpenLinkedFile:A4,filesReady:Q,onShare:lH,onOpenSystem:CQ,wsConnected:z0,search:C8,setSearch:A9,commentsByFile:S8,showHidden:J7,sectionsExpanded:aX,onToggleSection:yG,onNewBoard:B1,onDeleteBoard:F1,onMoveCanvas:L1,onNewFolder:D1,onDeleteFolder:M1,onRenameFolder:O1,onRenameCanvas:A1,onDuplicateCanvas:_1,onDeleteFile:w1,onRefresh:rG,refreshing:q1,collapsed:!1,onCollapse:()=>wX("tree"),resizing:JZ("tree"),dirtyByPath:U1,project:Z,gitBranch:N8?.branch,remoteSync:A0,onGetLatest:jY,canvasKinds:i0?.canvasKinds,syncStatus:I0,onLinkedHub:D8,onLocalProject:w8,savingIsManaged:I8});if(b==="changes")return z(Fw,{status:N8&&A0?{...N8,...A0}:N8,project:Z,readOnly:!G9()||O0,historyOnly:F9,cloudManaged:v7,resizing:JZ("changes"),onClose:()=>Z8(!1),onCommit:jG,onDiscard:yY,onPublish:vG,onGetLatest:jY,loadLog:async(S)=>{let c=await dG(S);if(uG(c!=="legacy"),c!=="legacy")return c;return(v7?gG:O4)(S)},historySource:mG?"project":v7?"cloud":"local",historyRefresh:`${I0?.appliedRevision??0}:${pG}`,onRestoreVersion:(S)=>mH(V,S).then((c)=>!!c.ok),onUndoAction:F9?void 0:async(S)=>{let c=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(c?await c.json().catch(()=>null):null)?.ok},cloudHistory:xG,onOpenCanvas:(S)=>V6(S),onOpenDiff:(S)=>h0({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:T1,onPreviewVersion:(S)=>h0({file:V,beforeSha:S,conflict:!1}),designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(bw,{status:I0,project:i0?.cloud?.projectName||Z,cloud:i0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:JZ("sync"),onClose:()=>b8(!1)});if(b==="inspector"||b==="layers")return z(fL0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:o==="separate",cpMode:g8,onSetCpMode:t8,selected:O,cfg:i0,tab:b==="layers"?"layers":x5,onTabChange:eX,onClose:()=>b==="layers"?G4(!1):aJ(!1),onOptimistic:IX,onRecordEdit:JX,onReplaceMedia:c90,onResizeArtboard:N0,onSetArtboardHug:q8,onSetArtboardStyle:Q9,onSetArtboardKind:I1,onSetArtboardPrint:EL,onDuplicateArtboard:l0,editScope:A,onUndoRedo:(S)=>T0({dgn:S}),photoSel:BG,photoRev:NG,onPhotoEdit:Y8,onPhotoRemoveBackground:TG,onPhotoRecordEdit:q4,onPhotoUndoRedo:(S)=>G8(S==="redo"),layersTree:n,componentMap:s,lockedKeys:F4,onToggleLock:bG,onDetachInstance:_,canvasFile:V,onSelectLayer:(S)=>T0({dgn:"select-by-id",id:S.id,artboardId:n?.artboardId,index:S.index}),onHoverLayer:(S)=>T0({dgn:"highlight",id:S?S.id:null,artboardId:n?.artboardId,index:S?S.index:0}),onReorderLayer:sG,layersBusyRef:l,resizing:JZ(b)});if(b==="comments")return z(BL0,{commentsByFile:S8,filter:M0,setFilter:E0,activePath:V,focusedId:x9,onJump:r90,onResolve:O0?void 0:i90,onReopen:O0?void 0:o90,onDelete:O0?void 0:n90,resizing:JZ("comments")});return null};return D("div",{className:"maude"+(vJ?" is-present":""),"data-theme":v0,onContextMenu:t90,children:[fH&&z(fw,{}),z(FL0,{cloud:i0.cloud}),z(LL0,{update:AG,onDismiss:()=>hH(null)}),z(DL0,{status:I0}),!fH&&z(Dw,{status:I0,cloud:i0.cloud}),z(Ag,{paused:!!EQ||!!K4,hiddenGroups:z4.panelOpen?["exports"]:[]}),z(fm,{wn:_Q}),z(Im,{center:z4}),q0&&D("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:()=>Z0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(QL0,{sharePath:vY,onShare:()=>lH(),readOnly:O0,cloud:i0.cloud,activePath:V,project:Z,tabsCount:K.length,openMenu:v8,setOpenMenu:W9,commentsPanelOpen:h9,onToggleComments:()=>g6("comments"),changesOpen:Q8,changesCount:X9,onToggleChanges:()=>g6("changes"),onOpenSystem:CQ,sidebarOpen:T9,onToggleSidebar:()=>wX("tree"),showHidden:J7,onToggleShowHidden:()=>FQ((b)=>!b),onOpenHelp:()=>nJ(!0),onOpenShortcuts:()=>l9(!0),onReportBug:()=>Y4(!0),onStartTour:()=>PX(WF),onStartCollabTour:()=>PX(LE),annotationsVisible:X5,onToggleAnnotations:RY,minimapVisible:Q5,onToggleMinimap:CY,zoomCtlVisible:m6,onToggleZoomCtl:$Y,presentMode:vJ,onTogglePresent:$G,printGuidesVisible:PG,onTogglePrintGuides:SG,postToActiveCanvas:T0,onOpenReadiness:()=>FX(!0),onOpenQuickSetup:()=>y5(!0),onWatchIntro:()=>VY(!0),onOpenWhatsNew:_Q.openPanel,whatsNewCount:_Q.unseen.length,exportCenter:z4,artboardCount:l7,inspectorOpen:yJ,inspectorTab:x5,onToggleInspector:()=>g6("inspector"),autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),onInsertArtboard:m90,timelineOpen:D0,onToggleTimeline:OY,hasComps:P0.length>0,assistantOpen:_X,onToggleAssistant:()=>g6("assistant"),assistantBusy:Z1,assistantUnseen:H1,onOpenLayers:()=>{if(o==="separate")wX("layers");else if(yJ&&x5==="layers")aJ(!1);else eX("layers"),T6("inspector")},onNewCanvas:()=>{T6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:N1,onOpenExport:(b)=>P6({mode:b}),onOpenSettings:()=>DQ(!0),onOpenGenerate:()=>bJ(!0),onReload:l5,onCloseCanvas:()=>V&&fY(V),presence:D(Q0,{children:[z(H90,{initials:SF0(h5||"you"),hue:"var(--accent)",title:h5?`${h5} (you)`:"You"}),kG&&z(H90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(U0?" is-resizing":""),ref:R8,children:[z(cF0,{shown:!_4,onExpand:()=>T6("tree"),onSearch:()=>{T6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(_4||$T)&&D(G90,{side:"left",width:X8.w,open:!!_4,ids:RT,activeId:_4,onPick:wX,labels:TT,children:[$T&&z(SN,{hidden:_4!=="assistant",activeCanvas:T1,selected:O,openComments:bT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>UG(!1),onBusyChange:bH,onFinished:yH,onPermissionRequest:LY,onElicitationRequest:LY}),_4&&_4!=="assistant"&&yT(_4)]}),_4&&z(K90,{label:"Resize left panel",size:X8,active:U0==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("sb")}}),z("div",{className:"main",children:z(YL0,{tabs:K,activePath:V,registerIframe:a90,systemData:F8,onOpenFromSystem:V6,onSelectDs:W5,project:Z,cfg:i0,loadingPath:J8,onIframeLoad:J9,canvasError:t0,canvasReloadNonce:p0,onRetryCanvasLoad:V1,loadedPath:k8,showQuickSetup:G9()&&!O0&&!!V7&&!V7.ready,onStartQuickSetup:()=>y5(!0),previewPath:N})}),xY&&z(K90,{label:"Resize right panel",dir:"rtl",size:P8,active:U0==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("rp")}}),(xY||ST)&&D(G90,{side:"right",width:P8.w,open:!!xY,ids:CT,activeId:xY,onPick:wX,labels:TT,children:[ST&&z(SN,{hidden:xY!=="assistant",activeCanvas:T1,selected:O,openComments:bT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>UG(!1),onBusyChange:bH,onFinished:yH,onPermissionRequest:LY,onElicitationRequest:LY}),xY&&xY!=="assistant"&&yT(xY)]})]}),D0&&z(YE,{comps:P0,compId:k6,sequences:K6,audio:J6,transitions:MX,total:sX,frame:M8,playing:L9,loop:MQ,onSeek:(b)=>{Z9(b),I6(!1),T0({dgn:"timeline-seek",frame:b,id:k6})},onPlay:()=>{I6(!0),T0({dgn:"timeline-mute",muted:FJ,id:k6}),T0({dgn:"timeline-loop",loop:MQ,id:k6}),T0({dgn:"timeline-play",id:k6})},onPause:()=>{I6(!1),T0({dgn:"timeline-pause",id:k6})},onToggleLoop:()=>s6((b)=>{let S=!b;return T0({dgn:"timeline-loop",loop:S,id:k6}),S}),muted:FJ,onToggleMute:()=>{f5((b)=>{let S=!b;return T0({dgn:"timeline-mute",muted:S,id:k6}),S})},volume:RH,onVolume:(b)=>{if(KG(b),b>0&&FJ)f5(!1),T0({dgn:"timeline-mute",muted:!1,id:k6});T0({dgn:"timeline-volume",volume:b,id:k6})},onRetime:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b),w0=b&&typeof b==="object"?b.index:b,p=F0?.stableId?{canvas:V,artboardId:c,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:w0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)})}).then((K0)=>K0.json()).then((K0)=>{if(!K0?.ok)console.warn("[retime]",K0?.error||"failed"),LJ("Retime refused",K0?.error);else if(h8(S.from!=null?"Clip moved.":"Clip trimmed.",!0),K0?.seq!=null)Y6(V,K0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:kQ,onReplace:(b)=>{if(!V||V===r8)return;aG({accept:"video/*,image/*",resolveTarget:(S)=>{let c=R6(S,b);if(c?.mediaArrayRef)return{arrayRef:c.mediaArrayRef};if(c?.mediaCdId)return{cdId:c.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===r8)return;aG({accept:"audio/*",resolveTarget:(S)=>{let c=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return c[b]?.cdId?{cdId:c[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===r8)return;let c=b&&typeof b==="object"?b.index:b,X0=K6[c]?.layers?.[S]?.kind==="audio"?"audio/*":K6[c]?.layers?.[S]?.kind==="image"?"image/*":"video/*";aG({accept:X0,resolveTarget:(K0)=>{let F0=R6(K0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((A8)=>A8.kind==="sequence"):[],w0=R6(K0,b),p=w0?F0.indexOf(w0):-1,L0=S==="forward"?p+1:p-1,k0=p>=0?F0[L0]||null:null,c0=S==="forward"?"after":"before";if(!w0?.stableId||!k0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c,stableId:w0.stableId,contentHash:w0.contentHash,refStableId:k0.stableId,refContentHash:k0.contentHash,position:c0})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[reorder-clip]",K0.error||"failed"),LJ("Reorder refused",K0.error);else if(K0?.seq!=null)Y6(V,K0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===r8)return;let S=X6||void 0,c=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(c).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let K0=R6(X0,b);if(!K0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:K0.stableId,contentHash:K0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)LJ("Hide refused",X0.error);else if(X0&&X0.ok){if(h8(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>h8("Hide failed: network error"))},onReorderMove:(b,S,c)=>{if(!V||V===r8)return;let X0=X6||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let w0=R6(F0,b),p=R6(F0,S);if(!w0?.stableId||!p?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:w0.stableId,contentHash:w0.contentHash,refStableId:p.stableId,refContentHash:p.contentHash,position:c,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),LJ("Reorder refused",F0.error);else if(F0?.ok){if(h8("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>h8("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===r8)return;let c=X6||void 0,X0=BY,K0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!P0.length){let p=[];for(let k0 of F0){let c0=k0.type.startsWith("audio/")?"audio":k0.type.startsWith("video/")?"video":null;if(!c0)continue;try{let A8=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}),O8=await A8.json().catch(()=>({}));if(O8?.path)p.push({src:O8.path,mediaKind:c0});else h8(`Upload failed: ${O8?.error||`HTTP ${A8.status}`}`)}catch{h8("Upload failed: network error")}}if(!p.length){h8("No video/audio files in the drop — nothing to cut.");return}let L0=!1;for(let k0 of p){let c0=await aw(k0.src).catch(()=>null),A8={canvas:K0,lane:k0.mediaKind==="audio"&&L0?"audio":"storyline",durationInFrames:V3(X0,c0),mediaTag:k0.mediaKind==="audio"?"Audio":"Video",src:k0.src};if(A8.lane==="audio")A8.from=0;let O8=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A8)}).catch(()=>null),q6=O8?await O8.json().catch(()=>null):null;if(q6?.ok){if(L0=!0,q6.seq!=null)Y6(K0,q6.seq,"add clip")}else if(!L0)break;else LJ("Insert refused",q6?.error)}if(L0){h8("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let k0=0;k0<8;k0+=1){let c0=k0===0?"New Cut":`New Cut ${k0+1}`,A8=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c0,kind:"video-comp",clips:p})}).catch(()=>null),O8=A8?await A8.json().catch(()=>({})):{};if(A8?.status===409)continue;if(!A8?.ok||!O8.ok){h8(`New cut failed: ${O8.error||"create refused"}`);return}await y9(),V6(O8.file),h8(`Started a new cut from ${p.length} clip${p.length>1?"s":""}.`,!0);return}h8('New cut failed: too many "New Cut" canvases — rename some.');return}let w0=S?.lane==="storyline"?S.index:void 0;for(let p of F0){let L0=p.type.startsWith("video/")?"Video":p.type.startsWith("audio/")?"Audio":p.type.startsWith("image/")?"Img":null;if(!L0)continue;let k0;try{k0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":p.type||"application/octet-stream"},body:p})).json().catch(()=>({}))}catch{k0=null}if(!k0?.path){h8(`Upload failed: ${k0?.error||"server unreachable — retry in a moment"}`);continue}let c0=L0==="Audio",A8=L0==="Video"?await aw(k0.path).catch(()=>null):null,O8={canvas:K0,artboardId:c,mediaTag:L0,src:k0.path};if(S&&(c0||S.lane==="audio"))O8.lane="audio",O8.from=Math.max(0,S.frame??0),O8.durationInFrames=Math.max(X0,sX-O8.from);else if(S?.lane==="storyline"&&!c0){if(O8.lane="storyline",w0!=null)O8.index=w0,w0+=1;O8.durationInFrames=V3(X0,A8)}else if(S?.lane==="overlay"&&!c0){if((K6||[]).length===0)O8.lane="storyline";else O8.lane="overlay",O8.from=Math.max(0,S.frame??0);O8.durationInFrames=V3(X0,A8)}else if(!c0)O8.lane="storyline",O8.durationInFrames=V3(X0,A8);else O8.lane="audio",O8.from=0,O8.durationInFrames=Math.max(X0,sX);try{let w7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O8)})).json().catch(()=>null);if(w7&&!w7.ok)console.warn("[insert-clip]",w7.error||"failed"),LJ("Insert refused",w7.error);else if(w7?.ok){if(h8("Clip added to the timeline.",!0),w7.seq!=null)Y6(K0,w7.seq,"add clip")}}catch{h8("Insert failed: network error")}}})()},height:jJ,onResize:C7,onClose:()=>y0(!1),selectedClipId:SH,onSelect:NY,transitionClips:CG,onClipVerb:TQ,comments:(S8[V]||[]).filter((b)=>b&&b.timeline),promptText:Y5,onAddComment:PY,onResolveComment:(b)=>$7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>$7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let c=b.sequences||[],X0=c.find((K0)=>K0.series&&b.frame>=K0.from&&b.frame<K0.from+K0.duration)||c.find((K0)=>b.frame>=K0.from&&b.frame<K0.from+K0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)TQ(S,"split",{atFrame:b.frame});else h8("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===r8)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(BY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("Title refused",X0.error);else if(X0?.ok){if(h8("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>h8("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===r8)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"storyline",durationInFrames:Math.round(BY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("AI clip refused",X0.error);else if(X0?.ok){if(h8("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>h8("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===r8)return;let S=V,c=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${c?`&artboardId=${encodeURIComponent(c)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=R6(K0,b),w0=F0?.placeholder;if(!F0?.stableId||!w0?.prompt){h8("No AI placeholder prompt on this clip.");return}let p=w0.kind==="image"?"image":"video",L0=w0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${w0.prompt}`:w0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:p,prompt:L0})}).then(async(k0)=>k0.ok?k0.json():Promise.reject(Error(await k0.text()))).then((k0)=>{let c0=k0?.id;if(!c0)throw Error("no job id");h8(`Generating ${w0.kind}… (runs in the background)`,!0);let A8=F0.stableId,O8=()=>{fetch("/_api/generate-jobs").then((q6)=>q6.json().catch(()=>({}))).then((q6)=>{let w7=(q6?.jobs||[]).find((wJ)=>wJ.id===c0);if(!w7||w7.status==="failed"){h8(`Generation failed: ${w7?.error||"job lost"}`);return}if(w7.status!=="done"){setTimeout(O8,4000);return}let d9=w7.assets?.[0];if(!d9){h8("Generation finished but produced no asset.");return}fetch(X0).then((wJ)=>wJ.json().catch(()=>({}))).then((wJ)=>{let XZ=R6(wJ,{stableId:A8});if(!XZ?.stableId){h8("Placeholder clip is gone — generated asset kept in assets/.");return}TQ({stableId:XZ.stableId},"resolve-placeholder",{src:d9,mediaKind:p==="image"?"image":"video"})})}).catch(()=>setTimeout(O8,6000))};setTimeout(O8,3000)}).catch((k0)=>h8(`Generate failed: ${k0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>h8("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===r8)return;let S=(X0,K0)=>{let F0=BY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":K0||"application/octet-stream"},body:X0}).then((w0)=>w0.json().catch(()=>({}))).then((w0)=>{if(!w0?.path)return h8(`Upload failed: ${w0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:w0.path})})}).then((w0)=>w0?w0.json():null).then((w0)=>{if(w0&&!w0.ok)LJ("Image refused",w0.error);else if(w0?.ok){if(h8("Image overlay added.",!0),w0.seq!=null)Y6(V,w0.seq,"add image overlay")}}).catch(()=>h8("Image failed: network error"))};if(G9()){cZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>h8(`Image pick failed: ${X0?.message||"dialog error"}`));return}let c=document.createElement("input");c.type="file",c.accept="image/*",c.addEventListener("change",()=>{let X0=c.files?.[0];if(X0)S(X0,X0.type)}),c.click()},resolveMediaUrl:(b)=>`/${(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(qL0,{activePath:V,selected:O,wsConnected:z0,openCount:s90,theme:v0,onToggleTheme:D4,onClearSelected:E1,syncStatus:I0,syncProject:i0?.cloud?.projectName||Z,syncOpen:f8,onOpenSync:I0?()=>g6("sync"):void 0,changesCount:X9,unpushed:I8?0:N8?.unpushed||0,savingIsManaged:I8,changesOpen:Q8,onOpenChanges:N8?.repo||I8?()=>EX("changes"):void 0,version:i0?.version})]}),vJ&&D("button",{type:"button",className:"st-present-exit",onClick:N4,"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($F0,{open:q7,onClose:()=>z6(!1),actions:e90}),RQ&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)u5(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":RQ.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:RQ.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:RQ.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")u5(b.currentTarget.value);else if(b.key==="Escape")u5(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>u5(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>u5(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),SJ&&z(_g,{target:SJ,links:pH(SJ.path),shell:iG,onClose:()=>j5(null),Icon:k9}),LQ&&z(gF0,{mode:LQ.mode,initialScope:LQ.scope,activePath:V,hasComps:P0.length>0,comps:P0,activeArtboardId:O?.artboardId??R9??null,selection:O?.selector?{selector:O.selector,file:O.file}:null,exportLane:i0.exportLane||"local",onBrowserCapture:IQ,onClose:()=>P6(null)}),W4&&z(VE,{cloud:i0.cloud,onClose:()=>DQ(!1),initialTab:typeof W4==="string"?W4:void 0,theme:v0,onSetTheme:W8,cpMode:g8,onSetCpMode:t8,minimapVisible:Q5,onToggleMinimap:CY,zoomCtlVisible:m6,onToggleZoomCtl:$Y,annotationsVisible:X5,onToggleAnnotations:RY,autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),hasCanvas:!!V&&V!==r8,panelSide:NJ,onSetPanelSide:(b,S)=>Z4((c)=>({...c,[b]:S})),layersMode:o,onSetLayersMode:(b)=>{if(G0(b),b!=="separate")G4(!1)}}),zG&&z(GE,{onClose:()=>bJ(!1),onInsert:L}),eG&&z(hF0,{designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:p90,onClose:()=>k1(null),multiple:!!eG.multiple,hasArtboardAnchor:!!eG.hasArtboardAnchor,onPickMany:l90}),PL&&z(qE,{onPick:d90,onClose:()=>IL(null)}),O9&&z(Nw,{target:O9,cfg:i0,loadLog:K1,onClose:()=>h0(null),onRestore:async(b,S)=>{let c=cG?await mH(b,/^r\d+$/.test(S||"")?Number(S.slice(1)):NaN):await yY([b]);if(c?.ok)h0(null);else window.alert(c?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await fG(b);if(S.ok)h0(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(nF0,{open:rJ,onClose:()=>l9(!1)}),z(iF0,{open:oJ,onClose:()=>nJ(!1),onStartTour:()=>{nJ(!1),PX(WF)}}),z($m,{open:e7,activeCanvas:V,onClose:()=>Y4(!1)}),z(xm,{wn:_Q,onStartTour:PX}),z(km,{center:z4}),z(Ch,{open:R7,onClose:()=>FX(!1)}),z(jV,{open:j9,onClose:()=>VY(!1)}),z(mw,{open:p7,onClose:()=>y5(!1),onStartTour:()=>PX(Lm),onBringBrand:()=>f7(!0),onImportFigma:()=>LX(!0)}),z(xw,{open:HG,onClose:()=>f7(!1)}),qY&&z(hw,{onClose:()=>LX(!1),onImported:()=>y9()}),EQ&&!K4&&!xH&&D("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:()=>{U4(),PX(WF)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:U4,children:"×"})]}),xH&&!K4&&D("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:()=>{DJ(),PX(LE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:DJ,children:"×"})]}),z(Fm,{steps:K4??[],open:!!K4,onClose:()=>wQ(null),onComplete:U4,bus:wG,hasSelection:!!O,hasCanvas:K.length>0})]})}R90.createRoot(document.getElementById("root")).render(z(xL0,{}));