Root cause of the persistent missing Shot/Context combo on task segments 2+: the5e53555rebuild ran before the rebase that brought the normalization source in, so the shipped bundle still contained the pre-fix raw format === 'MiniMax' gates (verified: zero 'Moxie Multimedia' literals in the5e53555chunks). The fix never reached users in that build. - dist/release rebuilt from current source: normalization present, no raw MiniMax gates in the editor chunk, marker 2026-09-28.1, chunk refs intact - speakerReferenceTooltip no longer leaks the internal model name (en+zh) - vitest 566/567 (same pre-existing URL.revokeObjectURL env failure)
59 lines
881 KiB
JavaScript
59 lines
881 KiB
JavaScript
import{$ as OS,A as jA,B as q4,C as vW,D as oS,E as hS,F as E7,G as Bk,H as gS,I as kh,J as WB,K as Qz,L as SI,M as FT,N as Ih,O as MJ,P as Sh,Q as uS,R as Uk,S as _k,T as Lk,U as HB,V as PW,W as PS,X as bI,Y as Zz,Z as qz,_ as wJ,aa as O7,b as P6,ba as CT,c as fW,ca as ZS,d as Z1,da as P4,e as sS,ea as K5,fa as jI,g as UX,ga as SY,h as yZ,ha as ST,i as h$,ia as jS,j as CY,ja as Fk,k as Nz,ka as Th,l as wh,la as vJ,m as FJ,ma as N5,n as VJ,na as FS,o as X6,oa as EI,p as yS,pa as $4,q as AF,qa as EJ,r as NS,ra as a9,s as yW,sa as JJ,t as Hk,ta as G1,u as QU,ua as G,v as LS,va as T,w as j9,wa as PI,x as j4,xa as b0,y as LY,ya as k0,z as rX,za as Fe}from"./index-n4rrew8t.js";import{Aa as v,Ba as J5,Ca as D8}from"./index-1wrhp8dx.js";import{Da as K9,Ea as OZ,Fa as pN,Ha as qZ,La as KI}from"./index-eqdkw1y2.js";import{$a as uJ,$b as zh,Ab as bF,Bb as C9,Cb as p2,Db as fB,Fb as jJ,Gb as Yz,Hb as M6,Ib as j8,Jb as aS,Kb as mS,Lb as xW,Mb as tS,Na as z9,Nb as mJ,Oa as gF,Ob as _8,Pa as Z5,Qa as mT,Qb as eS,Ra as lY,Rb as $h,Sa as X4,Sb as Jh,Ta as Oz,Tb as fT,Ua as gZ,Ub as fZ,Va as hT,Vb as vZ,Wa as Az,Wb as Qh,Xa as b7,Xb as Zh,Ya as fJ,Yb as qh,Za as j7,Zb as Xh,_a as gJ,_b as Yh,ab as y7,ac as Kh,bb as f2,bc as cS,cc as dS,db as kF,dc as CW,eb as wz,ec as AS,fc as wS,gb as kz,gc as jF,hb as xZ,hc as Gh,ib as Iz,ic as Wh,jb as Tz,jc as Hh,kb as S2,kc as Bh,lb as hB,lc as Uh,mb as xB,mc as _h,nb as fQ,nc as oY,ob as e9,oc as kS,pc as Lh,qc as EF,rb as xT,sb as r4,tb as vQ,ub as IF,vb as TF,wb as nS,xb as bZ,yb as RW,zb as XU}from"./index-9zskwz7p.js";import{rc as f1}from"./index-6y5pqcvv.js";import{sc as R,tc as ro,uc as e4,wc as YE}from"./index-xcg45zk8.js";var HL=ro((Zn)=>{var g9=R(v());function so($,J){return $===J&&($!==0||1/$===1/J)||$!==$&&J!==J}var oo=typeof Object.is==="function"?Object.is:so,no=g9.useState,ao=g9.useEffect,to=g9.useLayoutEffect,eo=g9.useDebugValue;function $n($,J){var Q=J(),Z=no({inst:{value:Q,getSnapshot:J}}),q=Z[0].inst,X=Z[1];return to(function(){q.value=Q,q.getSnapshot=J,WL(q)&&X({inst:q})},[$,Q,J]),ao(function(){return WL(q)&&X({inst:q}),$(function(){WL(q)&&X({inst:q})})},[$]),eo(Q),Q}function WL($){var J=$.getSnapshot;$=$.value;try{var Q=J();return!oo($,Q)}catch(Z){return!0}}function Jn($,J){return J()}var Qn=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Jn:$n;Zn.useSyncExternalStore=g9.useSyncExternalStore!==void 0?g9.useSyncExternalStore:Qn});var U8=R(v(),1);var lN=R(v(),1);var N8=R(v(),1);var m0=R(v(),1),cH=R(J5(),1);function u$($,[J,Q]){return Math.min(Q,Math.max(J,$))}var Me=!!(typeof window<"u"&&window.document&&window.document.createElement);function M8($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var W7=R(v(),1);var O4=R(v(),1);function dF($,J=[]){let Q=[];function Z(X,Y){let z=O4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=O4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=O4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return O4.createContext(Y)});return function(z){let K=z?.[$]||X;return O4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,lh(q,...J)]}function lh(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return O4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var lF=R(v(),1);function pF($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function oW(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=pF(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else pF($[q],null)}}}}function nW(...$){return lF.useCallback(oW(...$),$)}var o5=R(v(),1);function aW($){let J=ih($),Q=o5.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=o5.Children.toArray(X),K=z.find(sh);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(o5.Children.count(W)>1)return o5.Children.only(null);return o5.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:o5.isValidElement(W)?o5.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function ih($){let J=o5.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(o5.isValidElement(q)){let Y=nh(q),z=oh(X,q.props);if(q.type!==o5.Fragment)z.ref=Z?oW(Z,Y):Y;return o5.cloneElement(q,z)}return o5.Children.count(q)>1?o5.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var rh=Symbol("radix.slottable");function sh($){return o5.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===rh}function oh($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function nh($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var ah=R(v(),1);function H7($){let J=$+"CollectionProvider",[Q,Z]=dF(J),[q,X]=Q(J,{collectionRef:{current:null},itemMap:new Map}),Y=(F)=>{let{scope:V,children:M}=F,D=W7.default.useRef(null),N=W7.default.useRef(new Map).current;return G(q,{scope:V,itemMap:N,collectionRef:D,children:M})};Y.displayName=J;let z=$+"CollectionSlot",K=aW(z),W=W7.default.forwardRef((F,V)=>{let{scope:M,children:D}=F,N=X(z,M),O=nW(V,N.collectionRef);return G(K,{ref:O,children:D})});W.displayName=z;let H=$+"CollectionItemSlot",B="data-radix-collection-item",U=aW(H),_=W7.default.forwardRef((F,V)=>{let{scope:M,children:D,...N}=F,O=W7.default.useRef(null),I=nW(V,O),A=X(H,M);return W7.default.useEffect(()=>{return A.itemMap.set(O,{ref:O,...N}),()=>void A.itemMap.delete(O)}),G(U,{...{[B]:""},ref:I,children:D})});_.displayName=H;function L(F){let V=X($+"CollectionConsumer",F);return W7.default.useCallback(()=>{let D=V.collectionRef.current;if(!D)return[];let N=Array.from(D.querySelectorAll(`[${B}]`));return Array.from(V.itemMap.values()).sort((A,b)=>N.indexOf(A.ref.current)-N.indexOf(b.ref.current))},[V.collectionRef,V.itemMap])}return[{Provider:Y,Slot:W,ItemSlot:_},L,Z]}var iF=new WeakMap,ye=class $ extends Map{#$;constructor(J){super(J);this.#$=[...super.keys()],iF.set(this,!0)}set(J,Q){if(iF.get(this))if(this.has(J))this.#$[this.#$.indexOf(J)]=J;else this.#$.push(J);return super.set(J,Q),this}insert(J,Q,Z){let q=this.has(Q),X=this.#$.length,Y=rF(J),z=Y>=0?Y:X+Y,K=z<0||z>=X?-1:z;if(K===this.size||q&&K===this.size-1||K===-1)return this.set(Q,Z),this;let W=this.size+(q?0:1);if(Y<0)z++;let H=[...this.#$],B,U=!1;for(let _=z;_<W;_++)if(z===_){let L=H[_];if(H[_]===Q)L=H[_+1];if(q)this.delete(Q);B=this.get(L),this.set(Q,Z)}else{if(!U&&H[_-1]===Q)U=!0;let L=H[U?_:_-1],F=B;B=this.get(L),this.delete(L),this.set(L,F)}return this}with(J,Q,Z){let q=new $(this);return q.insert(J,Q,Z),q}before(J){let Q=this.#$.indexOf(J)-1;if(Q<0)return;return this.entryAt(Q)}setBefore(J,Q,Z){let q=this.#$.indexOf(J);if(q===-1)return this;return this.insert(q,Q,Z)}after(J){let Q=this.#$.indexOf(J);if(Q=Q===-1||Q===this.size-1?-1:Q+1,Q===-1)return;return this.entryAt(Q)}setAfter(J,Q,Z){let q=this.#$.indexOf(J);if(q===-1)return this;return this.insert(q+1,Q,Z)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#$=[],super.clear()}delete(J){let Q=super.delete(J);if(Q)this.#$.splice(this.#$.indexOf(J),1);return Q}deleteAt(J){let Q=this.keyAt(J);if(Q!==void 0)return this.delete(Q);return!1}at(J){let Q=tW(this.#$,J);if(Q!==void 0)return this.get(Q)}entryAt(J){let Q=tW(this.#$,J);if(Q!==void 0)return[Q,this.get(Q)]}indexOf(J){return this.#$.indexOf(J)}keyAt(J){return tW(this.#$,J)}from(J,Q){let Z=this.indexOf(J);if(Z===-1)return;let q=Z+Q;if(q<0)q=0;if(q>=this.size)q=this.size-1;return this.at(q)}keyFrom(J,Q){let Z=this.indexOf(J);if(Z===-1)return;let q=Z+Q;if(q<0)q=0;if(q>=this.size)q=this.size-1;return this.keyAt(q)}find(J,Q){let Z=0;for(let q of this){if(Reflect.apply(J,Q,[q,Z,this]))return q;Z++}return}findIndex(J,Q){let Z=0;for(let q of this){if(Reflect.apply(J,Q,[q,Z,this]))return Z;Z++}return-1}filter(J,Q){let Z=[],q=0;for(let X of this){if(Reflect.apply(J,Q,[X,q,this]))Z.push(X);q++}return new $(Z)}map(J,Q){let Z=[],q=0;for(let X of this)Z.push([X[0],Reflect.apply(J,Q,[X,q,this])]),q++;return new $(Z)}reduce(...J){let[Q,Z]=J,q=0,X=Z??this.at(0);for(let Y of this){if(q===0&&J.length===1)X=Y;else X=Reflect.apply(Q,this,[X,Y,q,this]);q++}return X}reduceRight(...J){let[Q,Z]=J,q=Z??this.at(-1);for(let X=this.size-1;X>=0;X--){let Y=this.at(X);if(X===this.size-1&&J.length===1)q=Y;else q=Reflect.apply(Q,this,[q,Y,X,this])}return q}toSorted(J){let Q=[...this.entries()].sort(J);return new $(Q)}toReversed(){let J=new $;for(let Q=this.size-1;Q>=0;Q--){let Z=this.keyAt(Q),q=this.get(Z);J.set(Z,q)}return J}toSpliced(...J){let Q=[...this.entries()];return Q.splice(...J),new $(Q)}slice(J,Q){let Z=new $,q=this.size-1;if(J===void 0)return Z;if(J<0)J=J+this.size;if(Q!==void 0&&Q>0)q=Q-1;for(let X=J;X<=q;X++){let Y=this.keyAt(X),z=this.get(Y);Z.set(Y,z)}return Z}every(J,Q){let Z=0;for(let q of this){if(!Reflect.apply(J,Q,[q,Z,this]))return!1;Z++}return!0}some(J,Q){let Z=0;for(let q of this){if(Reflect.apply(J,Q,[q,Z,this]))return!0;Z++}return!1}};function tW($,J){if("at"in Array.prototype)return Array.prototype.at.call($,J);let Q=th($,J);return Q===-1?void 0:$[Q]}function th($,J){let Q=$.length,Z=rF(J),q=Z>=0?Z:Q+Z;return q<0||q>=Q?-1:q}function rF($){return $!==$||$===0?0:Math.trunc($)}var oF=R(v(),1);function sF($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function eW(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=sF(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else sF($[q],null)}}}}function A9(...$){return oF.useCallback(eW(...$),$)}var A4=R(v(),1);function nF($,J=[]){let Q=[];function Z(X,Y){let z=A4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=A4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=A4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return A4.createContext(Y)});return function(z){let K=z?.[$]||X;return A4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,eh(q,...J)]}function eh(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return A4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var LX=R(v(),1);var $x=LX.createContext(void 0);function l9($){let J=LX.useContext($x);return $||J||"ltr"}var T5=R(v(),1);var ve=!!(typeof window<"u"&&window.document&&window.document.createElement);function FX($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var $V=R(v(),1),JV=R(J5(),1);var n5=R(v(),1);var tF=R(v(),1);function aF($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function $H(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=aF(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else aF($[q],null)}}}}function JH(...$){return tF.useCallback($H(...$),$)}function eF($){let J=Jx($),Q=n5.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=n5.Children.toArray(X),K=z.find(Zx);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(n5.Children.count(W)>1)return n5.Children.only(null);return n5.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:n5.isValidElement(W)?n5.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function Jx($){let J=n5.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(n5.isValidElement(q)){let Y=Xx(q),z=qx(X,q.props);if(q.type!==n5.Fragment)z.ref=Z?$H(Z,Y):Y;return n5.cloneElement(q,z)}return n5.Children.count(q)>1?n5.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Qx=Symbol("radix.slottable");function Zx($){return n5.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Qx}function qx($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Xx($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Yx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],QH=Yx.reduce(($,J)=>{let Q=eF(`Primitive.${J}`),Z=$V.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});function QV($,J){if($)JV.flushSync(()=>$.dispatchEvent(J))}var m$=R(v(),1);function d5($){let J=m$.useRef($);return m$.useEffect(()=>{J.current=$}),m$.useMemo(()=>(...Q)=>J.current?.(...Q),[])}var ZV=R(v(),1);function qV($,J=globalThis?.document){let Q=d5($);ZV.useEffect(()=>{let Z=(q)=>{if(q.key==="Escape")Q(q)};return J.addEventListener("keydown",Z,{capture:!0}),()=>J.removeEventListener("keydown",Z,{capture:!0})},[Q,J])}var zx="DismissableLayer",ZH="dismissableLayer.update",Kx="dismissableLayer.pointerDownOutside",Gx="dismissableLayer.focusOutside",XV,zV=T5.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),w9=T5.forwardRef(($,J)=>{let{disableOutsidePointerEvents:Q=!1,onEscapeKeyDown:Z,onPointerDownOutside:q,onFocusOutside:X,onInteractOutside:Y,onDismiss:z,...K}=$,W=T5.useContext(zV),[H,B]=T5.useState(null),U=H?.ownerDocument??globalThis?.document,[,_]=T5.useState({}),L=JH(J,(b)=>B(b)),F=Array.from(W.layers),[V]=[...W.layersWithOutsidePointerEventsDisabled].slice(-1),M=F.indexOf(V),D=H?F.indexOf(H):-1,N=W.layersWithOutsidePointerEventsDisabled.size>0,O=D>=M,I=Bx((b)=>{let k=b.target,w=[...W.branches].some((C)=>C.contains(k));if(!O||w)return;if(q?.(b),Y?.(b),!b.defaultPrevented)z?.()},U),A=Ux((b)=>{let k=b.target;if([...W.branches].some((C)=>C.contains(k)))return;if(X?.(b),Y?.(b),!b.defaultPrevented)z?.()},U);return qV((b)=>{if(D!==W.layers.size-1)return;if(Z?.(b),!b.defaultPrevented&&z)b.preventDefault(),z()},U),T5.useEffect(()=>{if(!H)return;if(Q){if(W.layersWithOutsidePointerEventsDisabled.size===0)XV=U.body.style.pointerEvents,U.body.style.pointerEvents="none";W.layersWithOutsidePointerEventsDisabled.add(H)}return W.layers.add(H),YV(),()=>{if(Q&&W.layersWithOutsidePointerEventsDisabled.size===1)U.body.style.pointerEvents=XV}},[H,U,Q,W]),T5.useEffect(()=>{return()=>{if(!H)return;W.layers.delete(H),W.layersWithOutsidePointerEventsDisabled.delete(H),YV()}},[H,W]),T5.useEffect(()=>{let b=()=>_({});return document.addEventListener(ZH,b),()=>document.removeEventListener(ZH,b)},[]),G(QH.div,{...K,ref:L,style:{pointerEvents:N?O?"auto":"none":void 0,...$.style},onFocusCapture:FX($.onFocusCapture,A.onFocusCapture),onBlurCapture:FX($.onBlurCapture,A.onBlurCapture),onPointerDownCapture:FX($.onPointerDownCapture,I.onPointerDownCapture)})});w9.displayName=zx;var Wx="DismissableLayerBranch",Hx=T5.forwardRef(($,J)=>{let Q=T5.useContext(zV),Z=T5.useRef(null),q=JH(J,Z);return T5.useEffect(()=>{let X=Z.current;if(X)return Q.branches.add(X),()=>{Q.branches.delete(X)}},[Q.branches]),G(QH.div,{...$,ref:q})});Hx.displayName=Wx;function Bx($,J=globalThis?.document){let Q=d5($),Z=T5.useRef(!1),q=T5.useRef(()=>{});return T5.useEffect(()=>{let X=(z)=>{if(z.target&&!Z.current){let W=function(){KV(Kx,Q,H,{discrete:!0})};var K=W;let H={originalEvent:z};if(z.pointerType==="touch")J.removeEventListener("click",q.current),q.current=W,J.addEventListener("click",q.current,{once:!0});else W()}else J.removeEventListener("click",q.current);Z.current=!1},Y=window.setTimeout(()=>{J.addEventListener("pointerdown",X)},0);return()=>{window.clearTimeout(Y),J.removeEventListener("pointerdown",X),J.removeEventListener("click",q.current)}},[J,Q]),{onPointerDownCapture:()=>Z.current=!0}}function Ux($,J=globalThis?.document){let Q=d5($),Z=T5.useRef(!1);return T5.useEffect(()=>{let q=(X)=>{if(X.target&&!Z.current)KV(Gx,Q,{originalEvent:X},{discrete:!1})};return J.addEventListener("focusin",q),()=>J.removeEventListener("focusin",q)},[J,Q]),{onFocusCapture:()=>Z.current=!0,onBlurCapture:()=>Z.current=!1}}function YV(){let $=new CustomEvent(ZH);document.dispatchEvent($)}function KV($,J,Q,{discrete:Z}){let q=Q.originalEvent.target,X=new CustomEvent($,{bubbles:!1,cancelable:!0,detail:Q});if(J)q.addEventListener($,J,{once:!0});if(Z)QV(q,X);else q.dispatchEvent(X)}var WV=R(v(),1),qH=0;function B7(){WV.useEffect(()=>{let $=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",$[0]??GV()),document.body.insertAdjacentElement("beforeend",$[1]??GV()),qH++,()=>{if(qH===1)document.querySelectorAll("[data-radix-focus-guard]").forEach((J)=>J.remove());qH--}},[])}function GV(){let $=document.createElement("span");return $.setAttribute("data-radix-focus-guard",""),$.tabIndex=0,$.style.outline="none",$.style.opacity="0",$.style.position="fixed",$.style.pointerEvents="none",$}var m6=R(v(),1);var BV=R(v(),1);function HV($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function XH(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=HV(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else HV($[q],null)}}}}function UV(...$){return BV.useCallback(XH(...$),$)}var LV=R(v(),1),Dx=R(J5(),1);var a5=R(v(),1);function _V($){let J=_x($),Q=a5.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=a5.Children.toArray(X),K=z.find(Fx);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(a5.Children.count(W)>1)return a5.Children.only(null);return a5.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:a5.isValidElement(W)?a5.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function _x($){let J=a5.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(a5.isValidElement(q)){let Y=Mx(q),z=Vx(X,q.props);if(q.type!==a5.Fragment)z.ref=Z?XH(Z,Y):Y;return a5.cloneElement(q,z)}return a5.Children.count(q)>1?a5.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Lx=Symbol("radix.slottable");function Fx($){return a5.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Lx}function Vx($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Mx($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Nx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],FV=Nx.reduce(($,J)=>{let Q=_V(`Primitive.${J}`),Z=LV.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var YH="focusScope.autoFocusOnMount",zH="focusScope.autoFocusOnUnmount",VV={bubbles:!1,cancelable:!0},Ox="FocusScope",w4=m6.forwardRef(($,J)=>{let{loop:Q=!1,trapped:Z=!1,onMountAutoFocus:q,onUnmountAutoFocus:X,...Y}=$,[z,K]=m6.useState(null),W=d5(q),H=d5(X),B=m6.useRef(null),U=UV(J,(F)=>K(F)),_=m6.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m6.useEffect(()=>{if(Z){let D=function(A){if(_.paused||!z)return;let b=A.target;if(z.contains(b))B.current=b;else U7(B.current,{select:!0})},N=function(A){if(_.paused||!z)return;let b=A.relatedTarget;if(b===null)return;if(!z.contains(b))U7(B.current,{select:!0})},O=function(A){if(document.activeElement!==document.body)return;for(let k of A)if(k.removedNodes.length>0)U7(z)};var F=D,V=N,M=O;document.addEventListener("focusin",D),document.addEventListener("focusout",N);let I=new MutationObserver(O);if(z)I.observe(z,{childList:!0,subtree:!0});return()=>{document.removeEventListener("focusin",D),document.removeEventListener("focusout",N),I.disconnect()}}},[Z,z,_.paused]),m6.useEffect(()=>{if(z){DV.add(_);let F=document.activeElement;if(!z.contains(F)){let M=new CustomEvent(YH,VV);if(z.addEventListener(YH,W),z.dispatchEvent(M),!M.defaultPrevented){if(Ax(bx(OV(z)),{select:!0}),document.activeElement===F)U7(z)}}return()=>{z.removeEventListener(YH,W),setTimeout(()=>{let M=new CustomEvent(zH,VV);if(z.addEventListener(zH,H),z.dispatchEvent(M),!M.defaultPrevented)U7(F??document.body,{select:!0});z.removeEventListener(zH,H),DV.remove(_)},0)}}},[z,W,H,_]);let L=m6.useCallback((F)=>{if(!Q&&!Z)return;if(_.paused)return;let V=F.key==="Tab"&&!F.altKey&&!F.ctrlKey&&!F.metaKey,M=document.activeElement;if(V&&M){let D=F.currentTarget,[N,O]=wx(D);if(!(N&&O)){if(M===D)F.preventDefault()}else if(!F.shiftKey&&M===O){if(F.preventDefault(),Q)U7(N,{select:!0})}else if(F.shiftKey&&M===N){if(F.preventDefault(),Q)U7(O,{select:!0})}}},[Q,Z,_.paused]);return G(FV.div,{tabIndex:-1,...Y,ref:U,onKeyDown:L})});w4.displayName=Ox;function Ax($,{select:J=!1}={}){let Q=document.activeElement;for(let Z of $)if(U7(Z,{select:J}),document.activeElement!==Q)return}function wx($){let J=OV($),Q=MV(J,$),Z=MV(J.reverse(),$);return[Q,Z]}function OV($){let J=[],Q=document.createTreeWalker($,NodeFilter.SHOW_ELEMENT,{acceptNode:(Z)=>{let q=Z.tagName==="INPUT"&&Z.type==="hidden";if(Z.disabled||Z.hidden||q)return NodeFilter.FILTER_SKIP;return Z.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});while(Q.nextNode())J.push(Q.currentNode);return J}function MV($,J){for(let Q of $)if(!kx(Q,{upTo:J}))return Q}function kx($,{upTo:J}){if(getComputedStyle($).visibility==="hidden")return!0;while($){if(J!==void 0&&$===J)return!1;if(getComputedStyle($).display==="none")return!0;$=$.parentElement}return!1}function Ix($){return $ instanceof HTMLInputElement&&"select"in $}function U7($,{select:J=!1}={}){if($&&$.focus){let Q=document.activeElement;if($.focus({preventScroll:!0}),$!==Q&&Ix($)&&J)$.select()}}var DV=Tx();function Tx(){let $=[];return{add(J){let Q=$[0];if(J!==Q)Q?.pause();$=NV($,J),$.unshift(J)},remove(J){$=NV($,J),$[0]?.resume()}}}function NV($,J){let Q=[...$],Z=Q.indexOf(J);if(Z!==-1)Q.splice(Z,1);return Q}function bx($){return $.filter((J)=>J.tagName!=="A")}var KH=R(v(),1);var AV=R(v(),1),_1=globalThis?.document?AV.useLayoutEffect:()=>{};var jx=KH[" useId ".trim().toString()]||(()=>{return}),Ex=0;function t5($){let[J,Q]=KH.useState(jx());return _1(()=>{if(!$)Q((Z)=>Z??String(Ex++))},[$]),$||(J?`radix-${J}`:"")}var K6=R(v(),1);var IV=["top","right","bottom","left"];var{min:i9,max:n8,round:_7,floor:mQ}=Math,k9=($)=>({x:$,y:$}),yx={left:"right",right:"left",bottom:"top",top:"bottom"};function c$($,J,Q){return n8($,i9(J,Q))}function c6($,J){return typeof $==="function"?$(J):$}function E8($){return $.split("-")[0]}function d6($){return $.split("-")[1]}function MX($){return $==="x"?"y":"x"}function d$($){return $==="y"?"height":"width"}function z6($){let J=$[0];return J==="t"||J==="b"?"y":"x"}function p$($){return MX(z6($))}function TV($,J,Q){if(Q===void 0)Q=!1;let Z=d6($),q=p$($),X=d$(q),Y=q==="x"?Z===(Q?"end":"start")?"right":"left":Z==="start"?"bottom":"top";if(J.reference[X]>J.floating[X])Y=uQ(Y);return[Y,uQ(Y)]}function bV($){let J=uQ($);return[VX($),J,VX(J)]}function VX($){return $.includes("start")?$.replace("start","end"):$.replace("end","start")}var wV=["left","right"],kV=["right","left"],Px=["top","bottom"],Rx=["bottom","top"];function Cx($,J,Q){switch($){case"top":case"bottom":if(Q)return J?kV:wV;return J?wV:kV;case"left":case"right":return J?Px:Rx;default:return[]}}function jV($,J,Q,Z){let q=d6($),X=Cx(E8($),Q==="start",Z);if(q){if(X=X.map((Y)=>Y+"-"+q),J)X=X.concat(X.map(VX))}return X}function uQ($){let J=E8($);return yx[J]+$.slice(J.length)}function Sx($){return{top:0,right:0,bottom:0,left:0,...$}}function cQ($){return typeof $!=="number"?Sx($):{top:$,right:$,bottom:$,left:$}}function _2($){let{x:J,y:Q,width:Z,height:q}=$;return{width:Z,height:q,top:Q,left:J,right:J+Z,bottom:Q+q,x:J,y:Q}}function EV($,J,Q){let{reference:Z,floating:q}=$,X=z6(J),Y=p$(J),z=d$(Y),K=E8(J),W=X==="y",H=Z.x+Z.width/2-q.width/2,B=Z.y+Z.height/2-q.height/2,U=Z[z]/2-q[z]/2,_;switch(K){case"top":_={x:H,y:Z.y-q.height};break;case"bottom":_={x:H,y:Z.y+Z.height};break;case"right":_={x:Z.x+Z.width,y:B};break;case"left":_={x:Z.x-q.width,y:B};break;default:_={x:Z.x,y:Z.y}}switch(d6(J)){case"start":_[Y]-=U*(Q&&W?-1:1);break;case"end":_[Y]+=U*(Q&&W?-1:1);break}return _}async function RV($,J){var Q;if(J===void 0)J={};let{x:Z,y:q,platform:X,rects:Y,elements:z,strategy:K}=$,{boundary:W="clippingAncestors",rootBoundary:H="viewport",elementContext:B="floating",altBoundary:U=!1,padding:_=0}=c6(J,$),L=cQ(_),V=z[U?B==="floating"?"reference":"floating":B],M=_2(await X.getClippingRect({element:((Q=await(X.isElement==null?void 0:X.isElement(V)))!=null?Q:!0)?V:V.contextElement||await(X.getDocumentElement==null?void 0:X.getDocumentElement(z.floating)),boundary:W,rootBoundary:H,strategy:K})),D=B==="floating"?{x:Z,y:q,width:Y.floating.width,height:Y.floating.height}:Y.reference,N=await(X.getOffsetParent==null?void 0:X.getOffsetParent(z.floating)),O=await(X.isElement==null?void 0:X.isElement(N))?await(X.getScale==null?void 0:X.getScale(N))||{x:1,y:1}:{x:1,y:1},I=_2(X.convertOffsetParentRelativeRectToViewportRelativeRect?await X.convertOffsetParentRelativeRectToViewportRelativeRect({elements:z,rect:D,offsetParent:N,strategy:K}):D);return{top:(M.top-I.top+L.top)/O.y,bottom:(I.bottom-M.bottom+L.bottom)/O.y,left:(M.left-I.left+L.left)/O.x,right:(I.right-M.right+L.right)/O.x}}var hx=50,CV=async($,J,Q)=>{let{placement:Z="bottom",strategy:q="absolute",middleware:X=[],platform:Y}=Q,z=Y.detectOverflow?Y:{...Y,detectOverflow:RV},K=await(Y.isRTL==null?void 0:Y.isRTL(J)),W=await Y.getElementRects({reference:$,floating:J,strategy:q}),{x:H,y:B}=EV(W,Z,K),U=Z,_=0,L={};for(let F=0;F<X.length;F++){let V=X[F];if(!V)continue;let{name:M,fn:D}=V,{x:N,y:O,data:I,reset:A}=await D({x:H,y:B,initialPlacement:Z,placement:U,strategy:q,middlewareData:L,rects:W,platform:z,elements:{reference:$,floating:J}});if(H=N!=null?N:H,B=O!=null?O:B,L[M]={...L[M],...I},A&&_<hx){if(_++,typeof A==="object"){if(A.placement)U=A.placement;if(A.rects)W=A.rects===!0?await Y.getElementRects({reference:$,floating:J,strategy:q}):A.rects;({x:H,y:B}=EV(W,U,K))}F=-1}}return{x:H,y:B,placement:U,strategy:q,middlewareData:L}},SV=($)=>({name:"arrow",options:$,async fn(J){let{x:Q,y:Z,placement:q,rects:X,platform:Y,elements:z,middlewareData:K}=J,{element:W,padding:H=0}=c6($,J)||{};if(W==null)return{};let B=cQ(H),U={x:Q,y:Z},_=p$(q),L=d$(_),F=await Y.getDimensions(W),V=_==="y",M=V?"top":"left",D=V?"bottom":"right",N=V?"clientHeight":"clientWidth",O=X.reference[L]+X.reference[_]-U[_]-X.floating[L],I=U[_]-X.reference[_],A=await(Y.getOffsetParent==null?void 0:Y.getOffsetParent(W)),b=A?A[N]:0;if(!b||!await(Y.isElement==null?void 0:Y.isElement(A)))b=z.floating[N]||X.floating[L];let k=O/2-I/2,w=b/2-F[L]/2-1,C=i9(B[M],w),y=i9(B[D],w),f=C,j=b-F[L]-y,P=b/2-F[L]/2+k,x=c$(f,P,j),p=!K.arrow&&d6(q)!=null&&P!==x&&X.reference[L]/2-(P<f?C:y)-F[L]/2<0,t=p?P<f?P-f:P-j:0;return{[_]:U[_]+t,data:{[_]:x,centerOffset:P-x-t,...p&&{alignmentOffset:t}},reset:p}}});var hV=function($){if($===void 0)$={};return{name:"flip",options:$,async fn(J){var Q,Z;let{placement:q,middlewareData:X,rects:Y,initialPlacement:z,platform:K,elements:W}=J,{mainAxis:H=!0,crossAxis:B=!0,fallbackPlacements:U,fallbackStrategy:_="bestFit",fallbackAxisSideDirection:L="none",flipAlignment:F=!0,...V}=c6($,J);if((Q=X.arrow)!=null&&Q.alignmentOffset)return{};let M=E8(q),D=z6(z),N=E8(z)===z,O=await(K.isRTL==null?void 0:K.isRTL(W.floating)),I=U||(N||!F?[uQ(z)]:bV(z)),A=L!=="none";if(!U&&A)I.push(...jV(z,F,L,O));let b=[z,...I],k=await K.detectOverflow(J,V),w=[],C=((Z=X.flip)==null?void 0:Z.overflows)||[];if(H)w.push(k[M]);if(B){let P=TV(q,Y,O);w.push(k[P[0]],k[P[1]])}if(C=[...C,{placement:q,overflows:w}],!w.every((P)=>P<=0)){var y,f;let P=(((y=X.flip)==null?void 0:y.index)||0)+1,x=b[P];if(x){if(!(B==="alignment"?D!==z6(x):!1)||C.every((h)=>z6(h.placement)===D?h.overflows[0]>0:!0))return{data:{index:P,overflows:C},reset:{placement:x}}}let p=(f=C.filter((t)=>t.overflows[0]<=0).sort((t,h)=>t.overflows[1]-h.overflows[1])[0])==null?void 0:f.placement;if(!p)switch(_){case"bestFit":{var j;let t=(j=C.filter((h)=>{if(A){let r=z6(h.placement);return r===D||r==="y"}return!0}).map((h)=>[h.placement,h.overflows.filter((r)=>r>0).reduce((r,$0)=>r+$0,0)]).sort((h,r)=>h[1]-r[1])[0])==null?void 0:j[0];if(t)p=t;break}case"initialPlacement":p=z;break}if(q!==p)return{reset:{placement:p}}}return{}}}};function yV($,J){return{top:$.top-J.height,right:$.right-J.width,bottom:$.bottom-J.height,left:$.left-J.width}}function PV($){return IV.some((J)=>$[J]>=0)}var xV=function($){if($===void 0)$={};return{name:"hide",options:$,async fn(J){let{rects:Q,platform:Z}=J,{strategy:q="referenceHidden",...X}=c6($,J);switch(q){case"referenceHidden":{let Y=await Z.detectOverflow(J,{...X,elementContext:"reference"}),z=yV(Y,Q.reference);return{data:{referenceHiddenOffsets:z,referenceHidden:PV(z)}}}case"escaped":{let Y=await Z.detectOverflow(J,{...X,altBoundary:!0}),z=yV(Y,Q.floating);return{data:{escapedOffsets:z,escaped:PV(z)}}}default:return{}}}}};var fV=new Set(["left","top"]);async function xx($,J){let{placement:Q,platform:Z,elements:q}=$,X=await(Z.isRTL==null?void 0:Z.isRTL(q.floating)),Y=E8(Q),z=d6(Q),K=z6(Q)==="y",W=fV.has(Y)?-1:1,H=X&&K?-1:1,B=c6(J,$),{mainAxis:U,crossAxis:_,alignmentAxis:L}=typeof B==="number"?{mainAxis:B,crossAxis:0,alignmentAxis:null}:{mainAxis:B.mainAxis||0,crossAxis:B.crossAxis||0,alignmentAxis:B.alignmentAxis};if(z&&typeof L==="number")_=z==="end"?L*-1:L;return K?{x:_*H,y:U*W}:{x:U*W,y:_*H}}var vV=function($){if($===void 0)$=0;return{name:"offset",options:$,async fn(J){var Q,Z;let{x:q,y:X,placement:Y,middlewareData:z}=J,K=await xx(J,$);if(Y===((Q=z.offset)==null?void 0:Q.placement)&&(Z=z.arrow)!=null&&Z.alignmentOffset)return{};return{x:q+K.x,y:X+K.y,data:{...K,placement:Y}}}}},gV=function($){if($===void 0)$={};return{name:"shift",options:$,async fn(J){let{x:Q,y:Z,placement:q,platform:X}=J,{mainAxis:Y=!0,crossAxis:z=!1,limiter:K={fn:(M)=>{let{x:D,y:N}=M;return{x:D,y:N}}},...W}=c6($,J),H={x:Q,y:Z},B=await X.detectOverflow(J,W),U=z6(E8(q)),_=MX(U),L=H[_],F=H[U];if(Y){let M=_==="y"?"top":"left",D=_==="y"?"bottom":"right",N=L+B[M],O=L-B[D];L=c$(N,L,O)}if(z){let M=U==="y"?"top":"left",D=U==="y"?"bottom":"right",N=F+B[M],O=F-B[D];F=c$(N,F,O)}let V=K.fn({...J,[_]:L,[U]:F});return{...V,data:{x:V.x-Q,y:V.y-Z,enabled:{[_]:Y,[U]:z}}}}}},uV=function($){if($===void 0)$={};return{options:$,fn(J){let{x:Q,y:Z,placement:q,rects:X,middlewareData:Y}=J,{offset:z=0,mainAxis:K=!0,crossAxis:W=!0}=c6($,J),H={x:Q,y:Z},B=z6(q),U=MX(B),_=H[U],L=H[B],F=c6(z,J),V=typeof F==="number"?{mainAxis:F,crossAxis:0}:{mainAxis:0,crossAxis:0,...F};if(K){let N=U==="y"?"height":"width",O=X.reference[U]-X.floating[N]+V.mainAxis,I=X.reference[U]+X.reference[N]-V.mainAxis;if(_<O)_=O;else if(_>I)_=I}if(W){var M,D;let N=U==="y"?"width":"height",O=fV.has(E8(q)),I=X.reference[B]-X.floating[N]+(O?((M=Y.offset)==null?void 0:M[B])||0:0)+(O?0:V.crossAxis),A=X.reference[B]+X.reference[N]+(O?0:((D=Y.offset)==null?void 0:D[B])||0)-(O?V.crossAxis:0);if(L<I)L=I;else if(L>A)L=A}return{[U]:_,[B]:L}}}},mV=function($){if($===void 0)$={};return{name:"size",options:$,async fn(J){var Q,Z;let{placement:q,rects:X,platform:Y,elements:z}=J,{apply:K=()=>{},...W}=c6($,J),H=await Y.detectOverflow(J,W),B=E8(q),U=d6(q),_=z6(q)==="y",{width:L,height:F}=X.floating,V,M;if(B==="top"||B==="bottom")V=B,M=U===(await(Y.isRTL==null?void 0:Y.isRTL(z.floating))?"start":"end")?"left":"right";else M=B,V=U==="end"?"top":"bottom";let D=F-H.top-H.bottom,N=L-H.left-H.right,O=i9(F-H[V],D),I=i9(L-H[M],N),A=!J.middlewareData.shift,b=O,k=I;if((Q=J.middlewareData.shift)!=null&&Q.enabled.x)k=N;if((Z=J.middlewareData.shift)!=null&&Z.enabled.y)b=D;if(A&&!U){let C=n8(H.left,0),y=n8(H.right,0),f=n8(H.top,0),j=n8(H.bottom,0);if(_)k=L-2*(C!==0||y!==0?C+y:n8(H.left,H.right));else b=F-2*(f!==0||j!==0?f+j:n8(H.top,H.bottom))}await K({...J,availableWidth:k,availableHeight:b});let w=await Y.getDimensions(z.floating);if(L!==w.width||F!==w.height)return{reset:{rects:!0}};return{}}}};function DX(){return typeof window<"u"}function f5($){if(NX($))return($.nodeName||"").toLowerCase();return"#document"}function h1($){var J;return($==null||(J=$.ownerDocument)==null?void 0:J.defaultView)||window}function I9($){var J;return(J=(NX($)?$.ownerDocument:$.document)||window.document)==null?void 0:J.documentElement}function NX($){if(!DX())return!1;return $ instanceof Node||$ instanceof h1($).Node}function L1($){if(!DX())return!1;return $ instanceof Element||$ instanceof h1($).Element}function P1($){if(!DX())return!1;return $ instanceof HTMLElement||$ instanceof h1($).HTMLElement}function r9($){if(!DX()||typeof ShadowRoot>"u")return!1;return $ instanceof ShadowRoot||$ instanceof h1($).ShadowRoot}function s9($){let{overflow:J,overflowX:Q,overflowY:Z,display:q}=p5($);return/auto|scroll|overlay|hidden|clip/.test(J+Z+Q)&&q!=="inline"&&q!=="contents"}function cV($){return/^(table|td|th)$/.test(f5($))}function dQ($){try{if($.matches(":popover-open"))return!0}catch(J){}try{return $.matches(":modal")}catch(J){return!1}}var fx=/transform|translate|scale|rotate|perspective|filter/,vx=/paint|layout|strict|content/,L2=($)=>!!$&&$!=="none",GH;function OX($){let J=L1($)?p5($):$;return L2(J.transform)||L2(J.translate)||L2(J.scale)||L2(J.rotate)||L2(J.perspective)||!AX()&&(L2(J.backdropFilter)||L2(J.filter))||fx.test(J.willChange||"")||vx.test(J.contain||"")}function dV($){let J=j6($);while(P1(J)&&!E6(J)){if(OX(J))return J;else if(dQ(J))return null;J=j6(J)}return null}function AX(){if(GH==null)GH=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none");return GH}function E6($){return/^(html|body|#document)$/.test(f5($))}function p5($){return h1($).getComputedStyle($)}function pQ($){if(L1($))return{scrollLeft:$.scrollLeft,scrollTop:$.scrollTop};return{scrollLeft:$.scrollX,scrollTop:$.scrollY}}function j6($){if(f5($)==="html")return $;let J=$.assignedSlot||$.parentNode||r9($)&&$.host||I9($);return r9(J)?J.host:J}function pV($){let J=j6($);if(E6(J))return $.ownerDocument?$.ownerDocument.body:$.body;if(P1(J)&&s9(J))return J;return pV(J)}function L7($,J,Q){var Z;if(J===void 0)J=[];if(Q===void 0)Q=!0;let q=pV($),X=q===((Z=$.ownerDocument)==null?void 0:Z.body),Y=h1(q);if(X){let z=wX(Y);return J.concat(Y,Y.visualViewport||[],s9(q)?q:[],z&&Q?L7(z):[])}else return J.concat(q,L7(q,[],Q))}function wX($){return $.parent&&Object.getPrototypeOf($.parent)?$.frameElement:null}function sV($){let J=p5($),Q=parseFloat(J.width)||0,Z=parseFloat(J.height)||0,q=P1($),X=q?$.offsetWidth:Q,Y=q?$.offsetHeight:Z,z=_7(Q)!==X||_7(Z)!==Y;if(z)Q=X,Z=Y;return{width:Q,height:Z,$:z}}function HH($){return!L1($)?$.contextElement:$}function l$($){let J=HH($);if(!P1(J))return k9(1);let Q=J.getBoundingClientRect(),{width:Z,height:q,$:X}=sV(J),Y=(X?_7(Q.width):Q.width)/Z,z=(X?_7(Q.height):Q.height)/q;if(!Y||!Number.isFinite(Y))Y=1;if(!z||!Number.isFinite(z))z=1;return{x:Y,y:z}}var gx=k9(0);function oV($){let J=h1($);if(!AX()||!J.visualViewport)return gx;return{x:J.visualViewport.offsetLeft,y:J.visualViewport.offsetTop}}function ux($,J,Q){if(J===void 0)J=!1;if(!Q||J&&Q!==h1($))return!1;return J}function F2($,J,Q,Z){if(J===void 0)J=!1;if(Q===void 0)Q=!1;let q=$.getBoundingClientRect(),X=HH($),Y=k9(1);if(J)if(Z){if(L1(Z))Y=l$(Z)}else Y=l$($);let z=ux(X,Q,Z)?oV(X):k9(0),K=(q.left+z.x)/Y.x,W=(q.top+z.y)/Y.y,H=q.width/Y.x,B=q.height/Y.y;if(X){let U=h1(X),_=Z&&L1(Z)?h1(Z):Z,L=U,F=wX(L);while(F&&Z&&_!==L){let V=l$(F),M=F.getBoundingClientRect(),D=p5(F),N=M.left+(F.clientLeft+parseFloat(D.paddingLeft))*V.x,O=M.top+(F.clientTop+parseFloat(D.paddingTop))*V.y;K*=V.x,W*=V.y,H*=V.x,B*=V.y,K+=N,W+=O,L=h1(F),F=wX(L)}}return _2({width:H,height:B,x:K,y:W})}function kX($,J){let Q=pQ($).scrollLeft;if(!J)return F2(I9($)).left+Q;return J.left+Q}function nV($,J){let Q=$.getBoundingClientRect(),Z=Q.left+J.scrollLeft-kX($,Q),q=Q.top+J.scrollTop;return{x:Z,y:q}}function mx($){let{elements:J,rect:Q,offsetParent:Z,strategy:q}=$,X=q==="fixed",Y=I9(Z),z=J?dQ(J.floating):!1;if(Z===Y||z&&X)return Q;let K={scrollLeft:0,scrollTop:0},W=k9(1),H=k9(0),B=P1(Z);if(B||!B&&!X){if(f5(Z)!=="body"||s9(Y))K=pQ(Z);if(B){let _=F2(Z);W=l$(Z),H.x=_.x+Z.clientLeft,H.y=_.y+Z.clientTop}}let U=Y&&!B&&!X?nV(Y,K):k9(0);return{width:Q.width*W.x,height:Q.height*W.y,x:Q.x*W.x-K.scrollLeft*W.x+H.x+U.x,y:Q.y*W.y-K.scrollTop*W.y+H.y+U.y}}function cx($){return Array.from($.getClientRects())}function dx($){let J=I9($),Q=pQ($),Z=$.ownerDocument.body,q=n8(J.scrollWidth,J.clientWidth,Z.scrollWidth,Z.clientWidth),X=n8(J.scrollHeight,J.clientHeight,Z.scrollHeight,Z.clientHeight),Y=-Q.scrollLeft+kX($),z=-Q.scrollTop;if(p5(Z).direction==="rtl")Y+=n8(J.clientWidth,Z.clientWidth)-q;return{width:q,height:X,x:Y,y:z}}var lV=25;function px($,J){let Q=h1($),Z=I9($),q=Q.visualViewport,X=Z.clientWidth,Y=Z.clientHeight,z=0,K=0;if(q){X=q.width,Y=q.height;let H=AX();if(!H||H&&J==="fixed")z=q.offsetLeft,K=q.offsetTop}let W=kX(Z);if(W<=0){let H=Z.ownerDocument,B=H.body,U=getComputedStyle(B),_=H.compatMode==="CSS1Compat"?parseFloat(U.marginLeft)+parseFloat(U.marginRight)||0:0,L=Math.abs(Z.clientWidth-B.clientWidth-_);if(L<=lV)X-=L}else if(W<=lV)X+=W;return{width:X,height:Y,x:z,y:K}}function lx($,J){let Q=F2($,!0,J==="fixed"),Z=Q.top+$.clientTop,q=Q.left+$.clientLeft,X=P1($)?l$($):k9(1),Y=$.clientWidth*X.x,z=$.clientHeight*X.y,K=q*X.x,W=Z*X.y;return{width:Y,height:z,x:K,y:W}}function iV($,J,Q){let Z;if(J==="viewport")Z=px($,Q);else if(J==="document")Z=dx(I9($));else if(L1(J))Z=lx(J,Q);else{let q=oV($);Z={x:J.x-q.x,y:J.y-q.y,width:J.width,height:J.height}}return _2(Z)}function aV($,J){let Q=j6($);if(Q===J||!L1(Q)||E6(Q))return!1;return p5(Q).position==="fixed"||aV(Q,J)}function ix($,J){let Q=J.get($);if(Q)return Q;let Z=L7($,[],!1).filter((z)=>L1(z)&&f5(z)!=="body"),q=null,X=p5($).position==="fixed",Y=X?j6($):$;while(L1(Y)&&!E6(Y)){let z=p5(Y),K=OX(Y);if(!K&&z.position==="fixed")q=null;if(X?!K&&!q:!K&&z.position==="static"&&!!q&&(q.position==="absolute"||q.position==="fixed")||s9(Y)&&!K&&aV($,Y))Z=Z.filter((H)=>H!==Y);else q=z;Y=j6(Y)}return J.set($,Z),Z}function rx($){let{element:J,boundary:Q,rootBoundary:Z,strategy:q}=$,Y=[...Q==="clippingAncestors"?dQ(J)?[]:ix(J,this._c):[].concat(Q),Z],z=iV(J,Y[0],q),K=z.top,W=z.right,H=z.bottom,B=z.left;for(let U=1;U<Y.length;U++){let _=iV(J,Y[U],q);K=n8(_.top,K),W=i9(_.right,W),H=i9(_.bottom,H),B=n8(_.left,B)}return{width:W-B,height:H-K,x:B,y:K}}function sx($){let{width:J,height:Q}=sV($);return{width:J,height:Q}}function ox($,J,Q){let Z=P1(J),q=I9(J),X=Q==="fixed",Y=F2($,!0,X,J),z={scrollLeft:0,scrollTop:0},K=k9(0);function W(){K.x=kX(q)}if(Z||!Z&&!X){if(f5(J)!=="body"||s9(q))z=pQ(J);if(Z){let _=F2(J,!0,X,J);K.x=_.x+J.clientLeft,K.y=_.y+J.clientTop}else if(q)W()}if(X&&!Z&&q)W();let H=q&&!Z&&!X?nV(q,z):k9(0),B=Y.left+z.scrollLeft-K.x-H.x,U=Y.top+z.scrollTop-K.y-H.y;return{x:B,y:U,width:Y.width,height:Y.height}}function WH($){return p5($).position==="static"}function rV($,J){if(!P1($)||p5($).position==="fixed")return null;if(J)return J($);let Q=$.offsetParent;if(I9($)===Q)Q=Q.ownerDocument.body;return Q}function tV($,J){let Q=h1($);if(dQ($))return Q;if(!P1($)){let q=j6($);while(q&&!E6(q)){if(L1(q)&&!WH(q))return q;q=j6(q)}return Q}let Z=rV($,J);while(Z&&cV(Z)&&WH(Z))Z=rV(Z,J);if(Z&&E6(Z)&&WH(Z)&&!OX(Z))return Q;return Z||dV($)||Q}var nx=async function($){let J=this.getOffsetParent||tV,Q=this.getDimensions,Z=await Q($.floating);return{reference:ox($.reference,await J($.floating),$.strategy),floating:{x:0,y:0,width:Z.width,height:Z.height}}};function ax($){return p5($).direction==="rtl"}var BH={convertOffsetParentRelativeRectToViewportRelativeRect:mx,getDocumentElement:I9,getClippingRect:rx,getOffsetParent:tV,getElementRects:nx,getClientRects:cx,getDimensions:sx,getScale:l$,isElement:L1,isRTL:ax};function eV($,J){return $.x===J.x&&$.y===J.y&&$.width===J.width&&$.height===J.height}function tx($,J){let Q=null,Z,q=I9($);function X(){var z;clearTimeout(Z),(z=Q)==null||z.disconnect(),Q=null}function Y(z,K){if(z===void 0)z=!1;if(K===void 0)K=1;X();let W=$.getBoundingClientRect(),{left:H,top:B,width:U,height:_}=W;if(!z)J();if(!U||!_)return;let L=mQ(B),F=mQ(q.clientWidth-(H+U)),V=mQ(q.clientHeight-(B+_)),M=mQ(H),N={rootMargin:-L+"px "+-F+"px "+-V+"px "+-M+"px",threshold:n8(0,i9(1,K))||1},O=!0;function I(A){let b=A[0].intersectionRatio;if(b!==K){if(!O)return Y();if(!b)Z=setTimeout(()=>{Y(!1,0.0000001)},1000);else Y(!1,b)}if(b===1&&!eV(W,$.getBoundingClientRect()))Y();O=!1}try{Q=new IntersectionObserver(I,{...N,root:q.ownerDocument})}catch(A){Q=new IntersectionObserver(I,N)}Q.observe($)}return Y(!0),X}function V2($,J,Q,Z){if(Z===void 0)Z={};let{ancestorScroll:q=!0,ancestorResize:X=!0,elementResize:Y=typeof ResizeObserver==="function",layoutShift:z=typeof IntersectionObserver==="function",animationFrame:K=!1}=Z,W=HH($),H=q||X?[...W?L7(W):[],...J?L7(J):[]]:[];H.forEach((M)=>{q&&M.addEventListener("scroll",Q,{passive:!0}),X&&M.addEventListener("resize",Q)});let B=W&&z?tx(W,Q):null,U=-1,_=null;if(Y){if(_=new ResizeObserver((M)=>{let[D]=M;if(D&&D.target===W&&_&&J)_.unobserve(J),cancelAnimationFrame(U),U=requestAnimationFrame(()=>{var N;(N=_)==null||N.observe(J)});Q()}),W&&!K)_.observe(W);if(J)_.observe(J)}let L,F=K?F2($):null;if(K)V();function V(){let M=F2($);if(F&&!eV(F,M))Q();F=M,L=requestAnimationFrame(V)}return Q(),()=>{var M;if(H.forEach((D)=>{q&&D.removeEventListener("scroll",Q),X&&D.removeEventListener("resize",Q)}),B==null||B(),(M=_)==null||M.disconnect(),_=null,K)cancelAnimationFrame(L)}}var $M=vV;var JM=gV,QM=hV,ZM=mV,qM=xV,UH=SV;var XM=uV,IX=($,J,Q)=>{let Z=new Map,q={platform:BH,...Q},X={...q.platform,_c:Z};return CV($,J,{...q,platform:X})};var l5=R(v(),1),zM=R(v(),1),KM=R(J5(),1),$f=typeof document<"u",Jf=function(){},TX=$f?zM.useLayoutEffect:Jf;function bX($,J){if($===J)return!0;if(typeof $!==typeof J)return!1;if(typeof $==="function"&&$.toString()===J.toString())return!0;let Q,Z,q;if($&&J&&typeof $==="object"){if(Array.isArray($)){if(Q=$.length,Q!==J.length)return!1;for(Z=Q;Z--!==0;)if(!bX($[Z],J[Z]))return!1;return!0}if(q=Object.keys($),Q=q.length,Q!==Object.keys(J).length)return!1;for(Z=Q;Z--!==0;)if(!{}.hasOwnProperty.call(J,q[Z]))return!1;for(Z=Q;Z--!==0;){let X=q[Z];if(X==="_owner"&&$.$$typeof)continue;if(!bX($[X],J[X]))return!1}return!0}return $!==$&&J!==J}function GM($){if(typeof window>"u")return 1;return($.ownerDocument.defaultView||window).devicePixelRatio||1}function YM($,J){let Q=GM($);return Math.round(J*Q)/Q}function _H($){let J=l5.useRef($);return TX(()=>{J.current=$}),J}function jX($){if($===void 0)$={};let{placement:J="bottom",strategy:Q="absolute",middleware:Z=[],platform:q,elements:{reference:X,floating:Y}={},transform:z=!0,whileElementsMounted:K,open:W}=$,[H,B]=l5.useState({x:0,y:0,strategy:Q,placement:J,middlewareData:{},isPositioned:!1}),[U,_]=l5.useState(Z);if(!bX(U,Z))_(Z);let[L,F]=l5.useState(null),[V,M]=l5.useState(null),D=l5.useCallback((h)=>{if(h!==A.current)A.current=h,F(h)},[]),N=l5.useCallback((h)=>{if(h!==b.current)b.current=h,M(h)},[]),O=X||L,I=Y||V,A=l5.useRef(null),b=l5.useRef(null),k=l5.useRef(H),w=K!=null,C=_H(K),y=_H(q),f=_H(W),j=l5.useCallback(()=>{if(!A.current||!b.current)return;let h={placement:J,strategy:Q,middleware:U};if(y.current)h.platform=y.current;IX(A.current,b.current,h).then((r)=>{let $0={...r,isPositioned:f.current!==!1};if(P.current&&!bX(k.current,$0))k.current=$0,KM.flushSync(()=>{B($0)})})},[U,J,Q,y,f]);TX(()=>{if(W===!1&&k.current.isPositioned)k.current.isPositioned=!1,B((h)=>({...h,isPositioned:!1}))},[W]);let P=l5.useRef(!1);TX(()=>{return P.current=!0,()=>{P.current=!1}},[]),TX(()=>{if(O)A.current=O;if(I)b.current=I;if(O&&I){if(C.current)return C.current(O,I,j);j()}},[O,I,j,C,w]);let x=l5.useMemo(()=>({reference:A,floating:b,setReference:D,setFloating:N}),[D,N]),p=l5.useMemo(()=>({reference:O,floating:I}),[O,I]),t=l5.useMemo(()=>{let h={position:Q,left:0,top:0};if(!p.floating)return h;let r=YM(p.floating,H.x),$0=YM(p.floating,H.y);if(z)return{...h,transform:"translate("+r+"px, "+$0+"px)",...GM(p.floating)>=1.5&&{willChange:"transform"}};return{position:Q,left:r,top:$0}},[Q,z,p.floating,H.x,H.y]);return l5.useMemo(()=>({...H,update:j,refs:x,elements:p,floatingStyles:t}),[H,j,x,p,t])}var Qf=($)=>{function J(Q){return{}.hasOwnProperty.call(Q,"current")}return{name:"arrow",options:$,fn(Q){let{element:Z,padding:q}=typeof $==="function"?$(Q):$;if(Z&&J(Z)){if(Z.current!=null)return UH({element:Z.current,padding:q}).fn(Q);return{}}if(Z)return UH({element:Z,padding:q}).fn(Q);return{}}}},lQ=($,J)=>{let Q=$M($);return{name:Q.name,fn:Q.fn,options:[$,J]}},iQ=($,J)=>{let Q=JM($);return{name:Q.name,fn:Q.fn,options:[$,J]}},rQ=($,J)=>{return{fn:XM($).fn,options:[$,J]}},sQ=($,J)=>{let Q=QM($);return{name:Q.name,fn:Q.fn,options:[$,J]}},oQ=($,J)=>{let Q=ZM($);return{name:Q.name,fn:Q.fn,options:[$,J]}};var nQ=($,J)=>{let Q=qM($);return{name:Q.name,fn:Q.fn,options:[$,J]}};var LH=($,J)=>{let Q=Qf($);return{name:Q.name,fn:Q.fn,options:[$,J]}};var LM=R(v(),1);var UM=R(v(),1),Gf=R(J5(),1);var e5=R(v(),1);var Zf=R(v(),1);function WM($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function HM(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=WM(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else WM($[q],null)}}}}function BM($){let J=qf($),Q=e5.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=e5.Children.toArray(X),K=z.find(Yf);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(e5.Children.count(W)>1)return e5.Children.only(null);return e5.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:e5.isValidElement(W)?e5.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function qf($){let J=e5.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(e5.isValidElement(q)){let Y=Kf(q),z=zf(X,q.props);if(q.type!==e5.Fragment)z.ref=Z?HM(Z,Y):Y;return e5.cloneElement(q,z)}return e5.Children.count(q)>1?e5.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Xf=Symbol("radix.slottable");function Yf($){return e5.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Xf}function zf($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Kf($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Wf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_M=Wf.reduce(($,J)=>{let Q=BM(`Primitive.${J}`),Z=UM.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var Hf="Arrow",FM=LM.forwardRef(($,J)=>{let{children:Q,width:Z=10,height:q=5,...X}=$;return G(_M.svg,{...X,ref:J,width:Z,height:q,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:$.asChild?Q:G("polygon",{points:"0,0 30,0 15,10"})})});FM.displayName=Hf;var VM=FM;var DM=R(v(),1);function MM($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function FH(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=MM(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else MM($[q],null)}}}}function VH(...$){return DM.useCallback(FH(...$),$)}var k4=R(v(),1);function NM($,J=[]){let Q=[];function Z(X,Y){let z=k4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=k4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=k4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return k4.createContext(Y)});return function(z){let K=z?.[$]||X;return k4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,Uf(q,...J)]}function Uf(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return k4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var AM=R(v(),1),Df=R(J5(),1);var $8=R(v(),1);function OM($){let J=_f($),Q=$8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=$8.Children.toArray(X),K=z.find(Ff);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if($8.Children.count(W)>1)return $8.Children.only(null);return $8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:$8.isValidElement(W)?$8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function _f($){let J=$8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if($8.isValidElement(q)){let Y=Mf(q),z=Vf(X,q.props);if(q.type!==$8.Fragment)z.ref=Z?FH(Z,Y):Y;return $8.cloneElement(q,z)}return $8.Children.count(q)>1?$8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Lf=Symbol("radix.slottable");function Ff($){return $8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Lf}function Vf($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Mf($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Nf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],MH=Nf.reduce(($,J)=>{let Q=OM(`Primitive.${J}`),Z=AM.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var wM=R(v(),1);function kM($){let[J,Q]=wM.useState(void 0);return _1(()=>{if($){Q({width:$.offsetWidth,height:$.offsetHeight});let Z=new ResizeObserver((q)=>{if(!Array.isArray(q))return;if(!q.length)return;let X=q[0],Y,z;if("borderBoxSize"in X){let K=X.borderBoxSize,W=Array.isArray(K)?K[0]:K;Y=W.inlineSize,z=W.blockSize}else Y=$.offsetWidth,z=$.offsetHeight;Q({width:Y,height:z})});return Z.observe($,{box:"border-box"}),()=>Z.unobserve($)}else Q(void 0)},[$]),J}var DH="Popper",[IM,p6]=NM(DH),[Of,TM]=IM(DH),bM=($)=>{let{__scopePopper:J,children:Q}=$,[Z,q]=K6.useState(null);return G(Of,{scope:J,anchor:Z,onAnchorChange:q,children:Q})};bM.displayName=DH;var jM="PopperAnchor",EM=K6.forwardRef(($,J)=>{let{__scopePopper:Q,virtualRef:Z,...q}=$,X=TM(jM,Q),Y=K6.useRef(null),z=VH(J,Y),K=K6.useRef(null);return K6.useEffect(()=>{let W=K.current;if(K.current=Z?.current||Y.current,W!==K.current)X.onAnchorChange(K.current)}),Z?null:G(MH.div,{...q,ref:z})});EM.displayName=jM;var NH="PopperContent",[Af,wf]=IM(NH),yM=K6.forwardRef(($,J)=>{let{__scopePopper:Q,side:Z="bottom",sideOffset:q=0,align:X="center",alignOffset:Y=0,arrowPadding:z=0,avoidCollisions:K=!0,collisionBoundary:W=[],collisionPadding:H=0,sticky:B="partial",hideWhenDetached:U=!1,updatePositionStrategy:_="optimized",onPlaced:L,...F}=$,V=TM(NH,Q),[M,D]=K6.useState(null),N=VH(J,(c)=>D(c)),[O,I]=K6.useState(null),A=kM(O),b=A?.width??0,k=A?.height??0,w=Z+(X!=="center"?"-"+X:""),C=typeof H==="number"?H:{top:0,right:0,bottom:0,left:0,...H},y=Array.isArray(W)?W:[W],f=y.length>0,j={padding:C,boundary:y.filter(If),altBoundary:f},{refs:P,floatingStyles:x,placement:p,isPositioned:t,middlewareData:h}=jX({strategy:"fixed",placement:w,whileElementsMounted:(...c)=>{return V2(...c,{animationFrame:_==="always"})},elements:{reference:V.anchor},middleware:[lQ({mainAxis:q+k,alignmentAxis:Y}),K&&iQ({mainAxis:!0,crossAxis:!1,limiter:B==="partial"?rQ():void 0,...j}),K&&sQ({...j}),oQ({...j,apply:({elements:c,rects:i,availableWidth:u,availableHeight:d})=>{let{width:o,height:S}=i.reference,s=c.floating.style;s.setProperty("--radix-popper-available-width",`${u}px`),s.setProperty("--radix-popper-available-height",`${d}px`),s.setProperty("--radix-popper-anchor-width",`${o}px`),s.setProperty("--radix-popper-anchor-height",`${S}px`)}}),O&&LH({element:O,padding:z}),Tf({arrowWidth:b,arrowHeight:k}),U&&nQ({strategy:"referenceHidden",...j})]}),[r,$0]=CM(p),Y0=d5(L);_1(()=>{if(t)Y0?.()},[t,Y0]);let e=h.arrow?.x,H0=h.arrow?.y,K0=h.arrow?.centerOffset!==0,[E,m]=K6.useState();return _1(()=>{if(M)m(window.getComputedStyle(M).zIndex)},[M]),G("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...x,transform:t?x.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:E,["--radix-popper-transform-origin"]:[h.transformOrigin?.x,h.transformOrigin?.y].join(" "),...h.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:$.dir,children:G(Af,{scope:Q,placedSide:r,onArrowChange:I,arrowX:e,arrowY:H0,shouldHideArrow:K0,children:G(MH.div,{"data-side":r,"data-align":$0,...F,ref:N,style:{...F.style,animation:!t?"none":void 0}})})})});yM.displayName=NH;var PM="PopperArrow",kf={top:"bottom",right:"left",bottom:"top",left:"right"},RM=K6.forwardRef(function(J,Q){let{__scopePopper:Z,...q}=J,X=wf(PM,Z),Y=kf[X.placedSide];return G("span",{ref:X.onArrowChange,style:{position:"absolute",left:X.arrowX,top:X.arrowY,[Y]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[X.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[X.placedSide],visibility:X.shouldHideArrow?"hidden":void 0},children:G(VM,{...q,ref:Q,style:{...q.style,display:"block"}})})});RM.displayName=PM;function If($){return $!==null}var Tf=($)=>({name:"transformOrigin",options:$,fn(J){let{placement:Q,rects:Z,middlewareData:q}=J,Y=q.arrow?.centerOffset!==0,z=Y?0:$.arrowWidth,K=Y?0:$.arrowHeight,[W,H]=CM(Q),B={start:"0%",center:"50%",end:"100%"}[H],U=(q.arrow?.x??0)+z/2,_=(q.arrow?.y??0)+K/2,L="",F="";if(W==="bottom")L=Y?B:`${U}px`,F=`${-K}px`;else if(W==="top")L=Y?B:`${U}px`,F=`${Z.floating.height+K}px`;else if(W==="right")L=`${-K}px`,F=Y?B:`${_}px`;else if(W==="left")L=`${Z.floating.width+K}px`,F=Y?B:`${_}px`;return{data:{x:L,y:F}}}});function CM($){let[J,Q="center"]=$.split("-");return[J,Q]}var I4=bM,T4=EM,F7=yM,V7=RM;var yX=R(v(),1),gM=R(J5(),1);var fM=R(v(),1),Cf=R(J5(),1);var J8=R(v(),1);var bf=R(v(),1);function SM($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function hM(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=SM(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else SM($[q],null)}}}}function xM($){let J=jf($),Q=J8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=J8.Children.toArray(X),K=z.find(yf);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(J8.Children.count(W)>1)return J8.Children.only(null);return J8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:J8.isValidElement(W)?J8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function jf($){let J=J8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(J8.isValidElement(q)){let Y=Rf(q),z=Pf(X,q.props);if(q.type!==J8.Fragment)z.ref=Z?hM(Z,Y):Y;return J8.cloneElement(q,z)}return J8.Children.count(q)>1?J8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Ef=Symbol("radix.slottable");function yf($){return J8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Ef}function Pf($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Rf($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Sf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vM=Sf.reduce(($,J)=>{let Q=xM(`Primitive.${J}`),Z=fM.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var hf="Portal",T9=yX.forwardRef(($,J)=>{let{container:Q,...Z}=$,[q,X]=yX.useState(!1);_1(()=>X(!0),[]);let Y=Q||q&&globalThis?.document?.body;return Y?gM.default.createPortal(G(vM.div,{...Z,ref:J}),Y):null});T9.displayName=hf;var uM=R(v(),1),mf=R(J5(),1);var Q8=R(v(),1);function PX($){let J=xf($),Q=Q8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=Q8.Children.toArray(X),K=z.find(vf);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(Q8.Children.count(W)>1)return Q8.Children.only(null);return Q8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:Q8.isValidElement(W)?Q8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function xf($){let J=Q8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(Q8.isValidElement(q)){let Y=uf(q),z=gf(X,q.props);if(q.type!==Q8.Fragment)z.ref=Z?eW(Z,Y):Y;return Q8.cloneElement(q,z)}return Q8.Children.count(q)>1?Q8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var ff=Symbol("radix.slottable");function vf($){return Q8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===ff}function gf($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function uf($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var cf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],a8=cf.reduce(($,J)=>{let Q=PX(`Primitive.${J}`),Z=uM.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var l6=R(v(),1);var RX=R(v(),1);var df=l6[" useInsertionEffect ".trim().toString()]||_1;function OH({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=pf({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=l6.useRef($!==void 0);l6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=l6.useCallback((H)=>{if(z){let B=lf(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function pf({defaultProp:$,onChange:J}){let[Q,Z]=l6.useState($),q=l6.useRef(Q),X=l6.useRef(J);return df(()=>{X.current=J},[J]),l6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function lf($){return typeof $==="function"}var j10=Symbol("RADIX:SYNC_STATE");var CX=R(v(),1);function SX($){let J=CX.useRef({value:$,previous:$});return CX.useMemo(()=>{if(J.current.value!==$)J.current.previous=J.current.value,J.current.value=$;return J.current.previous},[$])}var iM=R(v(),1);var pM=R(v(),1),ef=R(J5(),1);var Z8=R(v(),1);var rf=R(v(),1);function mM($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function cM(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=mM(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else mM($[q],null)}}}}function dM($){let J=sf($),Q=Z8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=Z8.Children.toArray(X),K=z.find(nf);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(Z8.Children.count(W)>1)return Z8.Children.only(null);return Z8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:Z8.isValidElement(W)?Z8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function sf($){let J=Z8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(Z8.isValidElement(q)){let Y=tf(q),z=af(X,q.props);if(q.type!==Z8.Fragment)z.ref=Z?cM(Z,Y):Y;return Z8.cloneElement(q,z)}return Z8.Children.count(q)>1?Z8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var of=Symbol("radix.slottable");function nf($){return Z8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===of}function af($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function tf($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var $v=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lM=$v.reduce(($,J)=>{let Q=dM(`Primitive.${J}`),Z=pM.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var AH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Jv="VisuallyHidden",rM=iM.forwardRef(($,J)=>{return G(lM.span,{...$,ref:J,style:{...AH,...$.style}})});rM.displayName=Jv;var sM=rM;var Zv=function($){if(typeof document>"u")return null;var J=Array.isArray($)?$[0]:$;return J.ownerDocument.body},i$=new WeakMap,hX=new WeakMap,xX={},wH=0,oM=function($){return $&&($.host||oM($.parentNode))},qv=function($,J){return J.map(function(Q){if($.contains(Q))return Q;var Z=oM(Q);if(Z&&$.contains(Z))return Z;return console.error("aria-hidden",Q,"in not contained inside",$,". Doing nothing"),null}).filter(function(Q){return Boolean(Q)})},Xv=function($,J,Q,Z){var q=qv(J,Array.isArray($)?$:[$]);if(!xX[Q])xX[Q]=new WeakMap;var X=xX[Q],Y=[],z=new Set,K=new Set(q),W=function(B){if(!B||z.has(B))return;z.add(B),W(B.parentNode)};q.forEach(W);var H=function(B){if(!B||K.has(B))return;Array.prototype.forEach.call(B.children,function(U){if(z.has(U))H(U);else try{var _=U.getAttribute(Z),L=_!==null&&_!=="false",F=(i$.get(U)||0)+1,V=(X.get(U)||0)+1;if(i$.set(U,F),X.set(U,V),Y.push(U),F===1&&L)hX.set(U,!0);if(V===1)U.setAttribute(Q,"true");if(!L)U.setAttribute(Z,"true")}catch(M){console.error("aria-hidden: cannot operate on ",U,M)}})};return H(J),z.clear(),wH++,function(){if(Y.forEach(function(B){var U=i$.get(B)-1,_=X.get(B)-1;if(i$.set(B,U),X.set(B,_),!U){if(!hX.has(B))B.removeAttribute(Z);hX.delete(B)}if(!_)B.removeAttribute(Q)}),wH--,!wH)i$=new WeakMap,i$=new WeakMap,hX=new WeakMap,xX={}}},M7=function($,J,Q){if(Q===void 0)Q="data-aria-hidden";var Z=Array.from(Array.isArray($)?$:[$]),q=J||Zv($);if(!q)return function(){return null};return Z.push.apply(Z,Array.from(q.querySelectorAll("[aria-live], script"))),Xv(Z,q,Q,"aria-hidden")};var G6=function(){return G6=Object.assign||function(J){for(var Q,Z=1,q=arguments.length;Z<q;Z++){Q=arguments[Z];for(var X in Q)if(Object.prototype.hasOwnProperty.call(Q,X))J[X]=Q[X]}return J},G6.apply(this,arguments)};function fX($,J){var Q={};for(var Z in $)if(Object.prototype.hasOwnProperty.call($,Z)&&J.indexOf(Z)<0)Q[Z]=$[Z];if($!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var q=0,Z=Object.getOwnPropertySymbols($);q<Z.length;q++)if(J.indexOf(Z[q])<0&&Object.prototype.propertyIsEnumerable.call($,Z[q]))Q[Z[q]]=$[Z[q]]}return Q}function nM($,J,Q){if(Q||arguments.length===2){for(var Z=0,q=J.length,X;Z<q;Z++)if(X||!(Z in J)){if(!X)X=Array.prototype.slice.call(J,0,Z);X[Z]=J[Z]}}return $.concat(X||Array.prototype.slice.call(J))}var cX=R(v(),1);var v8=R(v(),1);var M2="right-scroll-bar-position",D2="width-before-scroll-bar",kH="with-scroll-bars-hidden",IH="--removed-body-scroll-bar-size";var gX=R(v(),1);function vX($,J){if(typeof $==="function")$(J);else if($)$.current=J;return $}var aM=R(v(),1);function tM($,J){var Q=aM.useState(function(){return{value:$,callback:J,facade:{get current(){return Q.value},set current(Z){var q=Q.value;if(q!==Z)Q.value=Z,Q.callback(Z,q)}}}})[0];return Q.callback=J,Q.facade}var Yv=typeof window<"u"?gX.useLayoutEffect:gX.useEffect,eM=new WeakMap;function TH($,J){var Q=tM(J||null,function(Z){return $.forEach(function(q){return vX(q,Z)})});return Yv(function(){var Z=eM.get(Q);if(Z){var q=new Set(Z),X=new Set($),Y=Q.current;q.forEach(function(z){if(!X.has(z))vX(z,null)}),X.forEach(function(z){if(!q.has(z))vX(z,Y)})}eM.set(Q,$)},[$]),Q}function zv($){return $}function Kv($,J){if(J===void 0)J=zv;var Q=[],Z=!1,q={read:function(){if(Z)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");if(Q.length)return Q[Q.length-1];return $},useMedium:function(X){var Y=J(X,Z);return Q.push(Y),function(){Q=Q.filter(function(z){return z!==Y})}},assignSyncMedium:function(X){Z=!0;while(Q.length){var Y=Q;Q=[],Y.forEach(X)}Q={push:function(z){return X(z)},filter:function(){return Q}}},assignMedium:function(X){Z=!0;var Y=[];if(Q.length){var z=Q;Q=[],z.forEach(X),Y=Q}var K=function(){var H=Y;Y=[],H.forEach(X)},W=function(){return Promise.resolve().then(K)};W(),Q={push:function(H){Y.push(H),W()},filter:function(H){return Y=Y.filter(H),Q}}}};return q}function bH($){if($===void 0)$={};var J=Kv(null);return J.options=G6({async:!0,ssr:!1},$),J}var $D=R(v(),1),JD=function($){var J=$.sideCar,Q=fX($,["sideCar"]);if(!J)throw Error("Sidecar: please provide `sideCar` property to import the right car");var Z=J.read();if(!Z)throw Error("Sidecar medium not found");return $D.createElement(Z,G6({},Q))};JD.isSideCarExport=!0;function jH($,J){return $.useMedium(J),JD}var uX=bH();var EH=function(){return},aQ=v8.forwardRef(function($,J){var Q=v8.useRef(null),Z=v8.useState({onScrollCapture:EH,onWheelCapture:EH,onTouchMoveCapture:EH}),q=Z[0],X=Z[1],Y=$.forwardProps,z=$.children,K=$.className,W=$.removeScrollBar,H=$.enabled,B=$.shards,U=$.sideCar,_=$.noRelative,L=$.noIsolation,F=$.inert,V=$.allowPinchZoom,M=$.as,D=M===void 0?"div":M,N=$.gapMode,O=fX($,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=U,A=TH([Q,J]),b=G6(G6({},O),q);return v8.createElement(v8.Fragment,null,H&&v8.createElement(I,{sideCar:uX,removeScrollBar:W,shards:B,noRelative:_,noIsolation:L,inert:F,setCallbacks:X,allowPinchZoom:!!V,lockRef:Q,gapMode:N}),Y?v8.cloneElement(v8.Children.only(z),G6(G6({},b),{ref:A})):v8.createElement(D,G6({},b,{className:K,ref:A}),z))});aQ.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};aQ.classNames={fullWidth:D2,zeroRight:M2};var V5=R(v(),1);var s$=R(v(),1);var qD=R(v(),1);var QD;var ZD=function(){if(QD)return QD;if(typeof __webpack_nonce__<"u")return __webpack_nonce__;return};function Gv(){if(!document)return null;var $=document.createElement("style");$.type="text/css";var J=ZD();if(J)$.setAttribute("nonce",J);return $}function Wv($,J){if($.styleSheet)$.styleSheet.cssText=J;else $.appendChild(document.createTextNode(J))}function Hv($){var J=document.head||document.getElementsByTagName("head")[0];J.appendChild($)}var yH=function(){var $=0,J=null;return{add:function(Q){if($==0){if(J=Gv())Wv(J,Q),Hv(J)}$++},remove:function(){if($--,!$&&J)J.parentNode&&J.parentNode.removeChild(J),J=null}}};var PH=function(){var $=yH();return function(J,Q){qD.useEffect(function(){return $.add(J),function(){$.remove()}},[J&&Q])}};var tQ=function(){var $=PH(),J=function(Q){var{styles:Z,dynamic:q}=Q;return $(Z,q),null};return J};var Bv={left:0,top:0,right:0,gap:0},RH=function($){return parseInt($||"",10)||0},Uv=function($){var J=window.getComputedStyle(document.body),Q=J[$==="padding"?"paddingLeft":"marginLeft"],Z=J[$==="padding"?"paddingTop":"marginTop"],q=J[$==="padding"?"paddingRight":"marginRight"];return[RH(Q),RH(Z),RH(q)]},CH=function($){if($===void 0)$="margin";if(typeof window>"u")return Bv;var J=Uv($),Q=document.documentElement.clientWidth,Z=window.innerWidth;return{left:J[0],top:J[1],right:J[2],gap:Math.max(0,Z-Q+J[2]-J[0])}};var _v=tQ(),r$="data-scroll-locked",Lv=function($,J,Q,Z){var{left:q,top:X,right:Y,gap:z}=$;if(Q===void 0)Q="margin";return`
|
||
.`.concat(kH,` {
|
||
overflow: hidden `).concat(Z,`;
|
||
padding-right: `).concat(z,"px ").concat(Z,`;
|
||
}
|
||
body[`).concat(r$,`] {
|
||
overflow: hidden `).concat(Z,`;
|
||
overscroll-behavior: contain;
|
||
`).concat([J&&"position: relative ".concat(Z,";"),Q==="margin"&&`
|
||
padding-left: `.concat(q,`px;
|
||
padding-top: `).concat(X,`px;
|
||
padding-right: `).concat(Y,`px;
|
||
margin-left:0;
|
||
margin-top:0;
|
||
margin-right: `).concat(z,"px ").concat(Z,`;
|
||
`),Q==="padding"&&"padding-right: ".concat(z,"px ").concat(Z,";")].filter(Boolean).join(""),`
|
||
}
|
||
|
||
.`).concat(M2,` {
|
||
right: `).concat(z,"px ").concat(Z,`;
|
||
}
|
||
|
||
.`).concat(D2,` {
|
||
margin-right: `).concat(z,"px ").concat(Z,`;
|
||
}
|
||
|
||
.`).concat(M2," .").concat(M2,` {
|
||
right: 0 `).concat(Z,`;
|
||
}
|
||
|
||
.`).concat(D2," .").concat(D2,` {
|
||
margin-right: 0 `).concat(Z,`;
|
||
}
|
||
|
||
body[`).concat(r$,`] {
|
||
`).concat(IH,": ").concat(z,`px;
|
||
}
|
||
`)},XD=function(){var $=parseInt(document.body.getAttribute(r$)||"0",10);return isFinite($)?$:0},Fv=function(){s$.useEffect(function(){return document.body.setAttribute(r$,(XD()+1).toString()),function(){var $=XD()-1;if($<=0)document.body.removeAttribute(r$);else document.body.setAttribute(r$,$.toString())}},[])},SH=function($){var{noRelative:J,noImportant:Q,gapMode:Z}=$,q=Z===void 0?"margin":Z;Fv();var X=s$.useMemo(function(){return CH(q)},[q]);return s$.createElement(_v,{styles:Lv(X,!J,q,!Q?"!important":"")})};var hH=!1;if(typeof window<"u")try{o$=Object.defineProperty({},"passive",{get:function(){return hH=!0,!0}}),window.addEventListener("test",o$,o$),window.removeEventListener("test",o$,o$)}catch($){hH=!1}var o$,N2=hH?{passive:!1}:!1;var Vv=function($){return $.tagName==="TEXTAREA"},YD=function($,J){if(!($ instanceof Element))return!1;var Q=window.getComputedStyle($);return Q[J]!=="hidden"&&!(Q.overflowY===Q.overflowX&&!Vv($)&&Q[J]==="visible")},Mv=function($){return YD($,"overflowY")},Dv=function($){return YD($,"overflowX")},xH=function($,J){var Q=J.ownerDocument,Z=J;do{if(typeof ShadowRoot<"u"&&Z instanceof ShadowRoot)Z=Z.host;var q=zD($,Z);if(q){var X=KD($,Z),Y=X[1],z=X[2];if(Y>z)return!0}Z=Z.parentNode}while(Z&&Z!==Q.body);return!1},Nv=function($){var{scrollTop:J,scrollHeight:Q,clientHeight:Z}=$;return[J,Q,Z]},Ov=function($){var{scrollLeft:J,scrollWidth:Q,clientWidth:Z}=$;return[J,Q,Z]},zD=function($,J){return $==="v"?Mv(J):Dv(J)},KD=function($,J){return $==="v"?Nv(J):Ov(J)},Av=function($,J){return $==="h"&&J==="rtl"?-1:1},GD=function($,J,Q,Z,q){var X=Av($,window.getComputedStyle(J).direction),Y=X*Z,z=Q.target,K=J.contains(z),W=!1,H=Y>0,B=0,U=0;do{if(!z)break;var _=KD($,z),L=_[0],F=_[1],V=_[2],M=F-V-X*L;if(L||M){if(zD($,z))B+=M,U+=L}var D=z.parentNode;z=D&&D.nodeType===Node.DOCUMENT_FRAGMENT_NODE?D.host:D}while(!K&&z!==document.body||K&&(J.contains(z)||J===z));if(H&&(q&&Math.abs(B)<1||!q&&Y>B))W=!0;else if(!H&&(q&&Math.abs(U)<1||!q&&-Y>U))W=!0;return W};var mX=function($){return"changedTouches"in $?[$.changedTouches[0].clientX,$.changedTouches[0].clientY]:[0,0]},WD=function($){return[$.deltaX,$.deltaY]},HD=function($){return $&&"current"in $?$.current:$},wv=function($,J){return $[0]===J[0]&&$[1]===J[1]},kv=function($){return`
|
||
.block-interactivity-`.concat($,` {pointer-events: none;}
|
||
.allow-interactivity-`).concat($,` {pointer-events: all;}
|
||
`)},Iv=0,n$=[];function BD($){var J=V5.useRef([]),Q=V5.useRef([0,0]),Z=V5.useRef(),q=V5.useState(Iv++)[0],X=V5.useState(tQ)[0],Y=V5.useRef($);V5.useEffect(function(){Y.current=$},[$]),V5.useEffect(function(){if($.inert){document.body.classList.add("block-interactivity-".concat(q));var F=nM([$.lockRef.current],($.shards||[]).map(HD),!0).filter(Boolean);return F.forEach(function(V){return V.classList.add("allow-interactivity-".concat(q))}),function(){document.body.classList.remove("block-interactivity-".concat(q)),F.forEach(function(V){return V.classList.remove("allow-interactivity-".concat(q))})}}return},[$.inert,$.lockRef.current,$.shards]);var z=V5.useCallback(function(F,V){if("touches"in F&&F.touches.length===2||F.type==="wheel"&&F.ctrlKey)return!Y.current.allowPinchZoom;var M=mX(F),D=Q.current,N="deltaX"in F?F.deltaX:D[0]-M[0],O="deltaY"in F?F.deltaY:D[1]-M[1],I,A=F.target,b=Math.abs(N)>Math.abs(O)?"h":"v";if("touches"in F&&b==="h"&&A.type==="range")return!1;var k=window.getSelection(),w=k&&k.anchorNode,C=w?w===A||w.contains(A):!1;if(C)return!1;var y=xH(b,A);if(!y)return!0;if(y)I=b;else I=b==="v"?"h":"v",y=xH(b,A);if(!y)return!1;if(!Z.current&&"changedTouches"in F&&(N||O))Z.current=I;if(!I)return!0;var f=Z.current||I;return GD(f,V,F,f==="h"?N:O,!0)},[]),K=V5.useCallback(function(F){var V=F;if(!n$.length||n$[n$.length-1]!==X)return;var M="deltaY"in V?WD(V):mX(V),D=J.current.filter(function(I){return I.name===V.type&&(I.target===V.target||V.target===I.shadowParent)&&wv(I.delta,M)})[0];if(D&&D.should){if(V.cancelable)V.preventDefault();return}if(!D){var N=(Y.current.shards||[]).map(HD).filter(Boolean).filter(function(I){return I.contains(V.target)}),O=N.length>0?z(V,N[0]):!Y.current.noIsolation;if(O){if(V.cancelable)V.preventDefault()}}},[]),W=V5.useCallback(function(F,V,M,D){var N={name:F,delta:V,target:M,should:D,shadowParent:Tv(M)};J.current.push(N),setTimeout(function(){J.current=J.current.filter(function(O){return O!==N})},1)},[]),H=V5.useCallback(function(F){Q.current=mX(F),Z.current=void 0},[]),B=V5.useCallback(function(F){W(F.type,WD(F),F.target,z(F,$.lockRef.current))},[]),U=V5.useCallback(function(F){W(F.type,mX(F),F.target,z(F,$.lockRef.current))},[]);V5.useEffect(function(){return n$.push(X),$.setCallbacks({onScrollCapture:B,onWheelCapture:B,onTouchMoveCapture:U}),document.addEventListener("wheel",K,N2),document.addEventListener("touchmove",K,N2),document.addEventListener("touchstart",H,N2),function(){n$=n$.filter(function(F){return F!==X}),document.removeEventListener("wheel",K,N2),document.removeEventListener("touchmove",K,N2),document.removeEventListener("touchstart",H,N2)}},[]);var{removeScrollBar:_,inert:L}=$;return V5.createElement(V5.Fragment,null,L?V5.createElement(X,{styles:kv(q)}):null,_?V5.createElement(SH,{noRelative:$.noRelative,gapMode:$.gapMode}):null)}function Tv($){var J=null;while($!==null){if($ instanceof ShadowRoot)J=$.host,$=$.host;$=$.parentNode}return J}var UD=jH(uX,BD);var _D=cX.forwardRef(function($,J){return cX.createElement(aQ,G6({},$,{ref:J,sideCar:UD}))});_D.classNames=aQ.classNames;var b4=_D;var bv=[" ","Enter","ArrowUp","ArrowDown"],jv=[" ","Enter"],O2="Select",[pX,lX,Ev]=H7(O2),[a$,u80]=nF(O2,[Ev,p6]),iX=p6(),[yv,D7]=a$(O2),[Pv,Rv]=a$(O2),LD=($)=>{let{__scopeSelect:J,children:Q,open:Z,defaultOpen:q,onOpenChange:X,value:Y,defaultValue:z,onValueChange:K,dir:W,name:H,autoComplete:B,disabled:U,required:_,form:L}=$,F=iX(J),[V,M]=m0.useState(null),[D,N]=m0.useState(null),[O,I]=m0.useState(!1),A=l9(W),[b,k]=OH({prop:Z,defaultProp:q??!1,onChange:X,caller:O2}),[w,C]=OH({prop:Y,defaultProp:z,onChange:K,caller:O2}),y=m0.useRef(null),f=V?L||!!V.closest("form"):!0,[j,P]=m0.useState(new Set),x=Array.from(j).map((p)=>p.props.value).join(";");return G(I4,{...F,children:T(yv,{required:_,scope:J,trigger:V,onTriggerChange:M,valueNode:D,onValueNodeChange:N,valueNodeHasChildren:O,onValueNodeHasChildrenChange:I,contentId:t5(),value:w,onValueChange:C,open:b,onOpenChange:k,dir:A,triggerPointerDownPosRef:y,disabled:U,children:[G(pX.Provider,{scope:J,children:G(Pv,{scope:$.__scopeSelect,onNativeOptionAdd:m0.useCallback((p)=>{P((t)=>new Set(t).add(p))},[]),onNativeOptionRemove:m0.useCallback((p)=>{P((t)=>{let h=new Set(t);return h.delete(p),h})},[]),children:Q})}),f?T(gD,{"aria-hidden":!0,required:_,tabIndex:-1,name:H,autoComplete:B,value:w,onChange:(p)=>C(p.target.value),disabled:U,form:L,children:[w===void 0?G("option",{value:""}):null,Array.from(j)]},x):null]})})};LD.displayName=O2;var FD="SelectTrigger",VD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,disabled:Z=!1,...q}=$,X=iX(Q),Y=D7(FD,Q),z=Y.disabled||Z,K=A9(J,Y.onTriggerChange),W=lX(Q),H=m0.useRef("touch"),[B,U,_]=mD((F)=>{let V=W().filter((N)=>!N.disabled),M=V.find((N)=>N.value===Y.value),D=cD(V,F,M);if(D!==void 0)Y.onValueChange(D.value)}),L=(F)=>{if(!z)Y.onOpenChange(!0),_();if(F)Y.triggerPointerDownPosRef.current={x:Math.round(F.pageX),y:Math.round(F.pageY)}};return G(T4,{asChild:!0,...X,children:G(a8.button,{type:"button",role:"combobox","aria-controls":Y.contentId,"aria-expanded":Y.open,"aria-required":Y.required,"aria-autocomplete":"none",dir:Y.dir,"data-state":Y.open?"open":"closed",disabled:z,"data-disabled":z?"":void 0,"data-placeholder":uD(Y.value)?"":void 0,...q,ref:K,onClick:M8(q.onClick,(F)=>{if(F.currentTarget.focus(),H.current!=="mouse")L(F)}),onPointerDown:M8(q.onPointerDown,(F)=>{H.current=F.pointerType;let V=F.target;if(V.hasPointerCapture(F.pointerId))V.releasePointerCapture(F.pointerId);if(F.button===0&&F.ctrlKey===!1&&F.pointerType==="mouse")L(F),F.preventDefault()}),onKeyDown:M8(q.onKeyDown,(F)=>{let V=B.current!=="";if(!(F.ctrlKey||F.altKey||F.metaKey)&&F.key.length===1)U(F.key);if(V&&F.key===" ")return;if(bv.includes(F.key))L(),F.preventDefault()})})})});VD.displayName=FD;var MD="SelectValue",DD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,className:Z,style:q,children:X,placeholder:Y="",...z}=$,K=D7(MD,Q),{onValueNodeHasChildrenChange:W}=K,H=X!==void 0,B=A9(J,K.onValueNodeChange);return _1(()=>{W(H)},[W,H]),G(a8.span,{...z,ref:B,style:{pointerEvents:"none"},children:uD(K.value)?G(G1,{children:Y}):X})});DD.displayName=MD;var Cv="SelectIcon",ND=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,children:Z,...q}=$;return G(a8.span,{"aria-hidden":!0,...q,ref:J,children:Z||"▼"})});ND.displayName=Cv;var Sv="SelectPortal",OD=($)=>{return G(T9,{asChild:!0,...$})};OD.displayName=Sv;var A2="SelectContent",AD=m0.forwardRef(($,J)=>{let Q=D7(A2,$.__scopeSelect),[Z,q]=m0.useState();if(_1(()=>{q(new DocumentFragment)},[]),!Q.open){let X=Z;return X?cH.createPortal(G(wD,{scope:$.__scopeSelect,children:G(pX.Slot,{scope:$.__scopeSelect,children:G("div",{children:$.children})})}),X):null}return G(kD,{...$,ref:J})});AD.displayName=A2;var b9=10,[wD,N7]=a$(A2),hv="SelectContentImpl",xv=PX("SelectContent.RemoveScroll"),kD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,position:Z="item-aligned",onCloseAutoFocus:q,onEscapeKeyDown:X,onPointerDownOutside:Y,side:z,sideOffset:K,align:W,alignOffset:H,arrowPadding:B,collisionBoundary:U,collisionPadding:_,sticky:L,hideWhenDetached:F,avoidCollisions:V,...M}=$,D=D7(A2,Q),[N,O]=m0.useState(null),[I,A]=m0.useState(null),b=A9(J,(c)=>O(c)),[k,w]=m0.useState(null),[C,y]=m0.useState(null),f=lX(Q),[j,P]=m0.useState(!1),x=m0.useRef(!1);m0.useEffect(()=>{if(N)return M7(N)},[N]),B7();let p=m0.useCallback((c)=>{let[i,...u]=f().map((S)=>S.ref.current),[d]=u.slice(-1),o=document.activeElement;for(let S of c){if(S===o)return;if(S?.scrollIntoView({block:"nearest"}),S===i&&I)I.scrollTop=0;if(S===d&&I)I.scrollTop=I.scrollHeight;if(S?.focus(),document.activeElement!==o)return}},[f,I]),t=m0.useCallback(()=>p([k,N]),[p,k,N]);m0.useEffect(()=>{if(j)t()},[j,t]);let{onOpenChange:h,triggerPointerDownPosRef:r}=D;m0.useEffect(()=>{if(N){let c={x:0,y:0},i=(d)=>{c={x:Math.abs(Math.round(d.pageX)-(r.current?.x??0)),y:Math.abs(Math.round(d.pageY)-(r.current?.y??0))}},u=(d)=>{if(c.x<=10&&c.y<=10)d.preventDefault();else if(!N.contains(d.target))h(!1);document.removeEventListener("pointermove",i),r.current=null};if(r.current!==null)document.addEventListener("pointermove",i),document.addEventListener("pointerup",u,{capture:!0,once:!0});return()=>{document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",u,{capture:!0})}}},[N,h,r]),m0.useEffect(()=>{let c=()=>h(!1);return window.addEventListener("blur",c),window.addEventListener("resize",c),()=>{window.removeEventListener("blur",c),window.removeEventListener("resize",c)}},[h]);let[$0,Y0]=mD((c)=>{let i=f().filter((o)=>!o.disabled),u=i.find((o)=>o.ref.current===document.activeElement),d=cD(i,c,u);if(d)setTimeout(()=>d.ref.current.focus())}),e=m0.useCallback((c,i,u)=>{let d=!x.current&&!u;if(D.value!==void 0&&D.value===i||d){if(w(c),d)x.current=!0}},[D.value]),H0=m0.useCallback(()=>N?.focus(),[N]),K0=m0.useCallback((c,i,u)=>{let d=!x.current&&!u;if(D.value!==void 0&&D.value===i||d)y(c)},[D.value]),E=Z==="popper"?fH:ID,m=E===fH?{side:z,sideOffset:K,align:W,alignOffset:H,arrowPadding:B,collisionBoundary:U,collisionPadding:_,sticky:L,hideWhenDetached:F,avoidCollisions:V}:{};return G(wD,{scope:Q,content:N,viewport:I,onViewportChange:A,itemRefCallback:e,selectedItem:k,onItemLeave:H0,itemTextRefCallback:K0,focusSelectedItem:t,selectedItemText:C,position:Z,isPositioned:j,searchRef:$0,children:G(b4,{as:xv,allowPinchZoom:!0,children:G(w4,{asChild:!0,trapped:D.open,onMountAutoFocus:(c)=>{c.preventDefault()},onUnmountAutoFocus:M8(q,(c)=>{D.trigger?.focus({preventScroll:!0}),c.preventDefault()}),children:G(w9,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:X,onPointerDownOutside:Y,onFocusOutside:(c)=>c.preventDefault(),onDismiss:()=>D.onOpenChange(!1),children:G(E,{role:"listbox",id:D.contentId,"data-state":D.open?"open":"closed",dir:D.dir,onContextMenu:(c)=>c.preventDefault(),...M,...m,onPlaced:()=>P(!0),ref:b,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:M8(M.onKeyDown,(c)=>{let i=c.ctrlKey||c.altKey||c.metaKey;if(c.key==="Tab")c.preventDefault();if(!i&&c.key.length===1)Y0(c.key);if(["ArrowUp","ArrowDown","Home","End"].includes(c.key)){let d=f().filter((o)=>!o.disabled).map((o)=>o.ref.current);if(["ArrowUp","End"].includes(c.key))d=d.slice().reverse();if(["ArrowUp","ArrowDown"].includes(c.key)){let o=c.target,S=d.indexOf(o);d=d.slice(S+1)}setTimeout(()=>p(d)),c.preventDefault()}})})})})})})});kD.displayName=hv;var fv="SelectItemAlignedPosition",ID=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,onPlaced:Z,...q}=$,X=D7(A2,Q),Y=N7(A2,Q),[z,K]=m0.useState(null),[W,H]=m0.useState(null),B=A9(J,(b)=>H(b)),U=lX(Q),_=m0.useRef(!1),L=m0.useRef(!0),{viewport:F,selectedItem:V,selectedItemText:M,focusSelectedItem:D}=Y,N=m0.useCallback(()=>{if(X.trigger&&X.valueNode&&z&&W&&F&&V&&M){let b=X.trigger.getBoundingClientRect(),k=W.getBoundingClientRect(),w=X.valueNode.getBoundingClientRect(),C=M.getBoundingClientRect();if(X.dir!=="rtl"){let o=C.left-k.left,S=w.left-o,s=b.left-S,G0=b.width+s,l=Math.max(G0,k.width),Q0=window.innerWidth-b9,J0=u$(S,[b9,Math.max(b9,Q0-l)]);z.style.minWidth=G0+"px",z.style.left=J0+"px"}else{let o=k.right-C.right,S=window.innerWidth-w.right-o,s=window.innerWidth-b.right-S,G0=b.width+s,l=Math.max(G0,k.width),Q0=window.innerWidth-b9,J0=u$(S,[b9,Math.max(b9,Q0-l)]);z.style.minWidth=G0+"px",z.style.right=J0+"px"}let y=U(),f=window.innerHeight-b9*2,j=F.scrollHeight,P=window.getComputedStyle(W),x=parseInt(P.borderTopWidth,10),p=parseInt(P.paddingTop,10),t=parseInt(P.borderBottomWidth,10),h=parseInt(P.paddingBottom,10),r=x+p+j+h+t,$0=Math.min(V.offsetHeight*5,r),Y0=window.getComputedStyle(F),e=parseInt(Y0.paddingTop,10),H0=parseInt(Y0.paddingBottom,10),K0=b.top+b.height/2-b9,E=f-K0,m=V.offsetHeight/2,c=V.offsetTop+m,i=x+p+c,u=r-i;if(i<=K0){let o=y.length>0&&V===y[y.length-1].ref.current;z.style.bottom="0px";let S=W.clientHeight-F.offsetTop-F.offsetHeight,s=Math.max(E,m+(o?H0:0)+S+t),G0=i+s;z.style.height=G0+"px"}else{let o=y.length>0&&V===y[0].ref.current;z.style.top="0px";let s=Math.max(K0,x+F.offsetTop+(o?e:0)+m)+u;z.style.height=s+"px",F.scrollTop=i-K0+F.offsetTop}z.style.margin=`${b9}px 0`,z.style.minHeight=$0+"px",z.style.maxHeight=f+"px",Z?.(),requestAnimationFrame(()=>_.current=!0)}},[U,X.trigger,X.valueNode,z,W,F,V,M,X.dir,Z]);_1(()=>N(),[N]);let[O,I]=m0.useState();_1(()=>{if(W)I(window.getComputedStyle(W).zIndex)},[W]);let A=m0.useCallback((b)=>{if(b&&L.current===!0)N(),D?.(),L.current=!1},[N,D]);return G(gv,{scope:Q,contentWrapper:z,shouldExpandOnScrollRef:_,onScrollButtonChange:A,children:G("div",{ref:K,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:G(a8.div,{...q,ref:B,style:{boxSizing:"border-box",maxHeight:"100%",...q.style}})})})});ID.displayName=fv;var vv="SelectPopperPosition",fH=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,align:Z="start",collisionPadding:q=b9,...X}=$,Y=iX(Q);return G(F7,{...Y,...X,ref:J,align:Z,collisionPadding:q,style:{boxSizing:"border-box",...X.style,...{"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}})});fH.displayName=vv;var[gv,dH]=a$(A2,{}),vH="SelectViewport",TD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,nonce:Z,...q}=$,X=N7(vH,Q),Y=dH(vH,Q),z=A9(J,X.onViewportChange),K=m0.useRef(0);return T(G1,{children:[G("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:Z}),G(pX.Slot,{scope:Q,children:G(a8.div,{"data-radix-select-viewport":"",role:"presentation",...q,ref:z,style:{position:"relative",flex:1,overflow:"hidden auto",...q.style},onScroll:M8(q.onScroll,(W)=>{let H=W.currentTarget,{contentWrapper:B,shouldExpandOnScrollRef:U}=Y;if(U?.current&&B){let _=Math.abs(K.current-H.scrollTop);if(_>0){let L=window.innerHeight-b9*2,F=parseFloat(B.style.minHeight),V=parseFloat(B.style.height),M=Math.max(F,V);if(M<L){let D=M+_,N=Math.min(L,D),O=D-N;if(B.style.height=N+"px",B.style.bottom==="0px")H.scrollTop=O>0?O:0,B.style.justifyContent="flex-end"}}}K.current=H.scrollTop})})})]})});TD.displayName=vH;var bD="SelectGroup",[uv,mv]=a$(bD),cv=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,...Z}=$,q=t5();return G(uv,{scope:Q,id:q,children:G(a8.div,{role:"group","aria-labelledby":q,...Z,ref:J})})});cv.displayName=bD;var jD="SelectLabel",ED=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,...Z}=$,q=mv(jD,Q);return G(a8.div,{id:q.id,...Z,ref:J})});ED.displayName=jD;var dX="SelectItem",[dv,yD]=a$(dX),PD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,value:Z,disabled:q=!1,textValue:X,...Y}=$,z=D7(dX,Q),K=N7(dX,Q),W=z.value===Z,[H,B]=m0.useState(X??""),[U,_]=m0.useState(!1),L=A9(J,(D)=>K.itemRefCallback?.(D,Z,q)),F=t5(),V=m0.useRef("touch"),M=()=>{if(!q)z.onValueChange(Z),z.onOpenChange(!1)};if(Z==="")throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return G(dv,{scope:Q,value:Z,disabled:q,textId:F,isSelected:W,onItemTextChange:m0.useCallback((D)=>{B((N)=>N||(D?.textContent??"").trim())},[]),children:G(pX.ItemSlot,{scope:Q,value:Z,disabled:q,textValue:H,children:G(a8.div,{role:"option","aria-labelledby":F,"data-highlighted":U?"":void 0,"aria-selected":W&&U,"data-state":W?"checked":"unchecked","aria-disabled":q||void 0,"data-disabled":q?"":void 0,tabIndex:q?void 0:-1,...Y,ref:L,onFocus:M8(Y.onFocus,()=>_(!0)),onBlur:M8(Y.onBlur,()=>_(!1)),onClick:M8(Y.onClick,()=>{if(V.current!=="mouse")M()}),onPointerUp:M8(Y.onPointerUp,()=>{if(V.current==="mouse")M()}),onPointerDown:M8(Y.onPointerDown,(D)=>{V.current=D.pointerType}),onPointerMove:M8(Y.onPointerMove,(D)=>{if(V.current=D.pointerType,q)K.onItemLeave?.();else if(V.current==="mouse")D.currentTarget.focus({preventScroll:!0})}),onPointerLeave:M8(Y.onPointerLeave,(D)=>{if(D.currentTarget===document.activeElement)K.onItemLeave?.()}),onKeyDown:M8(Y.onKeyDown,(D)=>{if(K.searchRef?.current!==""&&D.key===" ")return;if(jv.includes(D.key))M();if(D.key===" ")D.preventDefault()})})})})});PD.displayName=dX;var eQ="SelectItemText",RD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,className:Z,style:q,...X}=$,Y=D7(eQ,Q),z=N7(eQ,Q),K=yD(eQ,Q),W=Rv(eQ,Q),[H,B]=m0.useState(null),U=A9(J,(M)=>B(M),K.onItemTextChange,(M)=>z.itemTextRefCallback?.(M,K.value,K.disabled)),_=H?.textContent,L=m0.useMemo(()=>G("option",{value:K.value,disabled:K.disabled,children:_},K.value),[K.disabled,K.value,_]),{onNativeOptionAdd:F,onNativeOptionRemove:V}=W;return _1(()=>{return F(L),()=>V(L)},[F,V,L]),T(G1,{children:[G(a8.span,{id:K.textId,...X,ref:U}),K.isSelected&&Y.valueNode&&!Y.valueNodeHasChildren?cH.createPortal(X.children,Y.valueNode):null]})});RD.displayName=eQ;var CD="SelectItemIndicator",SD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,...Z}=$;return yD(CD,Q).isSelected?G(a8.span,{"aria-hidden":!0,...Z,ref:J}):null});SD.displayName=CD;var gH="SelectScrollUpButton",hD=m0.forwardRef(($,J)=>{let Q=N7(gH,$.__scopeSelect),Z=dH(gH,$.__scopeSelect),[q,X]=m0.useState(!1),Y=A9(J,Z.onScrollButtonChange);return _1(()=>{if(Q.viewport&&Q.isPositioned){let K=function(){let H=W.scrollTop>0;X(H)};var z=K;let W=Q.viewport;return K(),W.addEventListener("scroll",K),()=>W.removeEventListener("scroll",K)}},[Q.viewport,Q.isPositioned]),q?G(fD,{...$,ref:Y,onAutoScroll:()=>{let{viewport:z,selectedItem:K}=Q;if(z&&K)z.scrollTop=z.scrollTop-K.offsetHeight}}):null});hD.displayName=gH;var uH="SelectScrollDownButton",xD=m0.forwardRef(($,J)=>{let Q=N7(uH,$.__scopeSelect),Z=dH(uH,$.__scopeSelect),[q,X]=m0.useState(!1),Y=A9(J,Z.onScrollButtonChange);return _1(()=>{if(Q.viewport&&Q.isPositioned){let K=function(){let H=W.scrollHeight-W.clientHeight,B=Math.ceil(W.scrollTop)<H;X(B)};var z=K;let W=Q.viewport;return K(),W.addEventListener("scroll",K),()=>W.removeEventListener("scroll",K)}},[Q.viewport,Q.isPositioned]),q?G(fD,{...$,ref:Y,onAutoScroll:()=>{let{viewport:z,selectedItem:K}=Q;if(z&&K)z.scrollTop=z.scrollTop+K.offsetHeight}}):null});xD.displayName=uH;var fD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,onAutoScroll:Z,...q}=$,X=N7("SelectScrollButton",Q),Y=m0.useRef(null),z=lX(Q),K=m0.useCallback(()=>{if(Y.current!==null)window.clearInterval(Y.current),Y.current=null},[]);return m0.useEffect(()=>{return()=>K()},[K]),_1(()=>{z().find((H)=>H.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[z]),G(a8.div,{"aria-hidden":!0,...q,ref:J,style:{flexShrink:0,...q.style},onPointerDown:M8(q.onPointerDown,()=>{if(Y.current===null)Y.current=window.setInterval(Z,50)}),onPointerMove:M8(q.onPointerMove,()=>{if(X.onItemLeave?.(),Y.current===null)Y.current=window.setInterval(Z,50)}),onPointerLeave:M8(q.onPointerLeave,()=>{K()})})}),pv="SelectSeparator",vD=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,...Z}=$;return G(a8.div,{"aria-hidden":!0,...Z,ref:J})});vD.displayName=pv;var mH="SelectArrow",lv=m0.forwardRef(($,J)=>{let{__scopeSelect:Q,...Z}=$,q=iX(Q),X=D7(mH,Q),Y=N7(mH,Q);return X.open&&Y.position==="popper"?G(V7,{...q,...Z,ref:J}):null});lv.displayName=mH;var iv="SelectBubbleInput",gD=m0.forwardRef(({__scopeSelect:$,value:J,...Q},Z)=>{let q=m0.useRef(null),X=A9(Z,q),Y=SX(J);return m0.useEffect(()=>{let z=q.current;if(!z)return;let K=window.HTMLSelectElement.prototype,H=Object.getOwnPropertyDescriptor(K,"value").set;if(Y!==J&&H){let B=new Event("change",{bubbles:!0});H.call(z,J),z.dispatchEvent(B)}},[Y,J]),G(a8.select,{...Q,style:{...AH,...Q.style},ref:X,defaultValue:J})});gD.displayName=iv;function uD($){return $===""||$===void 0}function mD($){let J=d5($),Q=m0.useRef(""),Z=m0.useRef(0),q=m0.useCallback((Y)=>{let z=Q.current+Y;J(z),function K(W){if(Q.current=W,window.clearTimeout(Z.current),W!=="")Z.current=window.setTimeout(()=>K(""),1000)}(z)},[J]),X=m0.useCallback(()=>{Q.current="",window.clearTimeout(Z.current)},[]);return m0.useEffect(()=>{return()=>window.clearTimeout(Z.current)},[]),[Q,q,X]}function cD($,J,Q){let q=J.length>1&&Array.from(J).every((W)=>W===J[0])?J[0]:J,X=Q?$.indexOf(Q):-1,Y=rv($,Math.max(X,0));if(q.length===1)Y=Y.filter((W)=>W!==Q);let K=Y.find((W)=>W.textValue.toLowerCase().startsWith(q.toLowerCase()));return K!==Q?K:void 0}function rv($,J){return $.map((Q,Z)=>$[(J+Z)%$.length])}var pH=LD,lH=VD,dD=DD,pD=ND,lD=OD,iH=AD,iD=TD;var rH=ED,sH=PD,rD=RD,sD=SD,oH=hD,nH=xD,aH=vD;var oD=N8.createContext({open:!1,close:()=>{}}),y8=({open:$,defaultOpen:J=!1,onOpenChange:Q,...Z})=>{let[q,X]=N8.useState(J),Y=$??q,z=N8.useCallback((W)=>{if($===void 0)X(W);Q?.(W)},[$,Q]),K=N8.useMemo(()=>({open:Y,close:()=>z(!1)}),[z,Y]);return G(oD.Provider,{value:K,children:G(pH,{...Z,open:Y,onOpenChange:z})})};y8.displayName=pH.displayName;var W6=dD,P8=N8.forwardRef(({className:$,children:J,...Q},Z)=>T(lH,{ref:Z,className:b0("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-border bg-muted pl-2 py-2 text-sm text-foreground shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",$),...Q,children:[J,G(pD,{asChild:!0,children:G(j4,{className:"h-4 w-4 opacity-50"})})]}));P8.displayName=lH.displayName;var nD=N8.forwardRef(({className:$,...J},Q)=>G(oH,{ref:Q,className:b0("flex cursor-default items-center justify-center py-1",$),...J,children:G(rX,{className:"h-4 w-4"})}));nD.displayName=oH.displayName;var aD=N8.forwardRef(({className:$,...J},Q)=>G(nH,{ref:Q,className:b0("flex cursor-default items-center justify-center py-1",$),...J,children:G(j4,{className:"h-4 w-4"})}));aD.displayName=nH.displayName;var R8=N8.forwardRef(({className:$,children:J,position:Q="popper",...Z},q)=>{let X=N8.useContext(oD);return G(lD,{children:T("div",{className:`${D8}`,children:[X.open?G("div",{"aria-hidden":"true","data-easy-media-select-backdrop":"",className:"fixed inset-0 z-[9997]",onPointerDown:X.close}):null,T(iH,{ref:q,className:b0("relative z-[9999] max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",Q==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",$),position:Q,...Z,children:[G(nD,{}),G(iD,{className:b0("p-1",Q==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:J}),G(aD,{})]})]})})});R8.displayName=iH.displayName;var ov=N8.forwardRef(({className:$,...J},Q)=>G(rH,{ref:Q,className:b0("px-2 py-1.5 text-sm font-semibold",$),...J}));ov.displayName=rH.displayName;var i5=N8.forwardRef(({className:$,children:J,...Q},Z)=>T(sH,{ref:Z,className:b0("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",$),...Q,children:[G("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:G(sD,{children:G(j9,{className:"h-4 w-4"})})}),G(rD,{children:J})]}));i5.displayName=sH.displayName;var nv=N8.forwardRef(({className:$,...J},Q)=>G(aH,{ref:Q,className:b0("-mx-1 my-1 h-px bg-muted",$),...J}));nv.displayName=aH.displayName;var t8=R(v(),1);function e8({value:$,onChange:J,min:Q=0,max:Z=1/0,step:q=1,className:X,disabled:Y,commitOnBlur:z=!1,formatValue:K,"aria-label":W}){let H=t8.useRef(null),B=t8.useRef(!1),[U,_]=t8.useState(String($));t8.useEffect(()=>{if(!z)return;_(String($))},[$,z]);let L=t8.useCallback((I)=>{return Math.min(Z,Math.max(Q,I))},[Q,Z]),F=t8.useCallback((I)=>{if(I===""){J(L(0));return}let A=Number.parseFloat(I);if(!Number.isNaN(A))J(L(A))},[J,L]),V=t8.useCallback(()=>{let I=Math.min(Z,$+q);if(J(I),z)_(String(I))},[z,$,q,Z,J]),M=t8.useCallback(()=>{let I=Math.max(Q,$-q);if(J(I),z)_(String(I))},[z,$,q,Q,J]),D=t8.useCallback((I)=>{let A=I.currentTarget.value;if(z)_(A);else{if(A===""){J(0);return}let b=Number.parseFloat(A);if(!Number.isNaN(b))J(L(b))}},[z,J,L]),N=t8.useCallback(()=>{if(z&&!B.current)F(U),_(String($));B.current=!1},[z,F,U,$]),O=t8.useCallback((I)=>{if(I.key==="ArrowUp"){I.preventDefault();let A=Math.min(Z,$+q);if(J(A),z)_(String(A))}else if(I.key==="ArrowDown"){I.preventDefault();let A=Math.max(Q,$-q);if(J(A),z)_(String(A))}else if(z&&I.key==="Enter")I.preventDefault(),B.current=!0,F(U),H.current?.blur()},[z,$,q,Q,Z,J,F,U]);return T("div",{className:b0("flex h-7 items-center rounded-md border border-node-input-border bg-node-input overflow-hidden",X),children:[G("input",{type:"number",value:z?U:K?.($)??$,onChange:D,onKeyDown:O,onBlur:N,ref:H,min:Q,max:Z,step:q,disabled:Y,"aria-label":W,className:b0("w-14 h-full flex-1 bg-muted text-node-foreground text-xs text-center border-0 focus:outline-none focus:ring-0 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none")}),T("div",{className:"flex flex-col h-full border-l ",children:[G("button",{type:"button",onClick:V,disabled:Y||$>=Z,"aria-label":"Increment",className:b0("flex-1 flex items-center justify-center px-1 hover:bg-card cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed bg-muted"),children:G(rX,{className:"size-3 text-node-foreground"})}),G("div",{className:"h-px bg-border"}),G("button",{type:"button",onClick:M,disabled:Y||$<=Q,"aria-label":"Decrement",className:b0("flex-1 flex items-center justify-center px-1 hover:bg-card cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed bg-muted"),children:G(j4,{className:"size-3 text-node-foreground"})})]})]})}var ON=R(v(),1);var z5=R(v(),1);var a80=!!(typeof window<"u"&&window.document&&window.document.createElement);function w2($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var eD=R(v(),1);function tD($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function tH(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=tD(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else tD($[q],null)}}}}function k2(...$){return eD.useCallback(tH(...$),$)}var E4=R(v(),1);function $N($,J=[]){let Q=[];function Z(X,Y){let z=E4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=E4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=E4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return E4.createContext(Y)});return function(z){let K=z?.[$]||X;return E4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,av(q,...J)]}function av(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return E4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var i6=R(v(),1);var sX=R(v(),1);var tv=i6[" useInsertionEffect ".trim().toString()]||_1;function JN({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=ev({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=i6.useRef($!==void 0);i6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=i6.useCallback((H)=>{if(z){let B=$g(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function ev({defaultProp:$,onChange:J}){let[Q,Z]=i6.useState($),q=i6.useRef(Q),X=i6.useRef(J);return tv(()=>{X.current=J},[J]),i6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function $g($){return typeof $==="function"}var Z60=Symbol("RADIX:SYNC_STATE");var QN=R(v(),1);function ZN($){let[J,Q]=QN.useState(void 0);return _1(()=>{if($){Q({width:$.offsetWidth,height:$.offsetHeight});let Z=new ResizeObserver((q)=>{if(!Array.isArray(q))return;if(!q.length)return;let X=q[0],Y,z;if("borderBoxSize"in X){let K=X.borderBoxSize,W=Array.isArray(K)?K[0]:K;Y=W.inlineSize,z=W.blockSize}else Y=$.offsetWidth,z=$.offsetHeight;Q({width:Y,height:z})});return Z.observe($,{box:"border-box"}),()=>Z.unobserve($)}else Q(void 0)},[$]),J}var XN=R(v(),1),Yg=R(J5(),1);var q8=R(v(),1);function qN($){let J=Jg($),Q=q8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=q8.Children.toArray(X),K=z.find(Zg);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(q8.Children.count(W)>1)return q8.Children.only(null);return q8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:q8.isValidElement(W)?q8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function Jg($){let J=q8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(q8.isValidElement(q)){let Y=Xg(q),z=qg(X,q.props);if(q.type!==q8.Fragment)z.ref=Z?tH(Z,Y):Y;return q8.cloneElement(q,z)}return q8.Children.count(q)>1?q8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Qg=Symbol("radix.slottable");function Zg($){return q8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Qg}function qg($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Xg($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var zg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],t$=zg.reduce(($,J)=>{let Q=qN(`Primitive.${J}`),Z=XN.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var YN=["PageUp","PageDown"],zN=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],KN={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},e$="Slider",[eH,Kg,Gg]=H7(e$),[GN,k60]=$N(e$,[Gg]),[Wg,oX]=GN(e$),WN=z5.forwardRef(($,J)=>{let{name:Q,min:Z=0,max:q=100,step:X=1,orientation:Y="horizontal",disabled:z=!1,minStepsBetweenThumbs:K=0,defaultValue:W=[Z],value:H,onValueChange:B=()=>{},onValueCommit:U=()=>{},inverted:_=!1,form:L,...F}=$,V=z5.useRef(new Set),M=z5.useRef(0),N=Y==="horizontal"?Hg:Bg,[O=[],I]=JN({prop:H,defaultProp:W,onChange:(y)=>{[...V.current][M.current]?.focus(),B(y)}}),A=z5.useRef(O);function b(y){let f=Vg(O,y);C(y,f)}function k(y){C(y,M.current)}function w(){let y=A.current[M.current];if(O[M.current]!==y)U(O)}function C(y,f,{commit:j}={commit:!1}){let P=Og(X),x=Ag(Math.round((y-Z)/X)*X+Z,P),p=u$(x,[Z,q]);I((t=[])=>{let h=Lg(t,p,f);if(Ng(h,K*X)){M.current=h.indexOf(p);let r=String(h)!==String(t);if(r&&j)U(h);return r?h:t}else return t})}return G(Wg,{scope:$.__scopeSlider,name:Q,disabled:z,min:Z,max:q,valueIndexToChangeRef:M,thumbs:V.current,values:O,orientation:Y,form:L,children:G(eH.Provider,{scope:$.__scopeSlider,children:G(eH.Slot,{scope:$.__scopeSlider,children:G(N,{"aria-disabled":z,"data-disabled":z?"":void 0,...F,ref:J,onPointerDown:w2(F.onPointerDown,()=>{if(!z)A.current=O}),min:Z,max:q,inverted:_,onSlideStart:z?void 0:b,onSlideMove:z?void 0:k,onSlideEnd:z?void 0:w,onHomeKeyDown:()=>!z&&C(Z,0,{commit:!0}),onEndKeyDown:()=>!z&&C(q,O.length-1,{commit:!0}),onStepKeyDown:({event:y,direction:f})=>{if(!z){let x=YN.includes(y.key)||y.shiftKey&&zN.includes(y.key)?10:1,p=M.current,t=O[p],h=X*x*f;C(t+h,p,{commit:!0})}}})})})})});WN.displayName=e$;var[HN,BN]=GN(e$,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Hg=z5.forwardRef(($,J)=>{let{min:Q,max:Z,dir:q,inverted:X,onSlideStart:Y,onSlideMove:z,onSlideEnd:K,onStepKeyDown:W,...H}=$,[B,U]=z5.useState(null),_=k2(J,(N)=>U(N)),L=z5.useRef(void 0),F=l9(q),V=F==="ltr",M=V&&!X||!V&&X;function D(N){let O=L.current||B.getBoundingClientRect(),I=[0,O.width],b=Q3(I,M?[Q,Z]:[Z,Q]);return L.current=O,b(N-O.left)}return G(HN,{scope:$.__scopeSlider,startEdge:M?"left":"right",endEdge:M?"right":"left",direction:M?1:-1,size:"width",children:G(UN,{dir:F,"data-orientation":"horizontal",...H,ref:_,style:{...H.style,["--radix-slider-thumb-transform"]:"translateX(-50%)"},onSlideStart:(N)=>{let O=D(N.clientX);Y?.(O)},onSlideMove:(N)=>{let O=D(N.clientX);z?.(O)},onSlideEnd:()=>{L.current=void 0,K?.()},onStepKeyDown:(N)=>{let I=KN[M?"from-left":"from-right"].includes(N.key);W?.({event:N,direction:I?-1:1})}})})}),Bg=z5.forwardRef(($,J)=>{let{min:Q,max:Z,inverted:q,onSlideStart:X,onSlideMove:Y,onSlideEnd:z,onStepKeyDown:K,...W}=$,H=z5.useRef(null),B=k2(J,H),U=z5.useRef(void 0),_=!q;function L(F){let V=U.current||H.current.getBoundingClientRect(),M=[0,V.height],N=Q3(M,_?[Z,Q]:[Q,Z]);return U.current=V,N(F-V.top)}return G(HN,{scope:$.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:G(UN,{"data-orientation":"vertical",...W,ref:B,style:{...W.style,["--radix-slider-thumb-transform"]:"translateY(50%)"},onSlideStart:(F)=>{let V=L(F.clientY);X?.(V)},onSlideMove:(F)=>{let V=L(F.clientY);Y?.(V)},onSlideEnd:()=>{U.current=void 0,z?.()},onStepKeyDown:(F)=>{let M=KN[_?"from-bottom":"from-top"].includes(F.key);K?.({event:F,direction:M?-1:1})}})})}),UN=z5.forwardRef(($,J)=>{let{__scopeSlider:Q,onSlideStart:Z,onSlideMove:q,onSlideEnd:X,onHomeKeyDown:Y,onEndKeyDown:z,onStepKeyDown:K,...W}=$,H=oX(e$,Q);return G(t$.span,{...W,ref:J,onKeyDown:w2($.onKeyDown,(B)=>{if(B.key==="Home")Y(B),B.preventDefault();else if(B.key==="End")z(B),B.preventDefault();else if(YN.concat(zN).includes(B.key))K(B),B.preventDefault()}),onPointerDown:w2($.onPointerDown,(B)=>{let U=B.target;if(U.setPointerCapture(B.pointerId),B.preventDefault(),H.thumbs.has(U))U.focus();else Z(B)}),onPointerMove:w2($.onPointerMove,(B)=>{if(B.target.hasPointerCapture(B.pointerId))q(B)}),onPointerUp:w2($.onPointerUp,(B)=>{let U=B.target;if(U.hasPointerCapture(B.pointerId))U.releasePointerCapture(B.pointerId),X(B)})})}),_N="SliderTrack",LN=z5.forwardRef(($,J)=>{let{__scopeSlider:Q,...Z}=$,q=oX(_N,Q);return G(t$.span,{"data-disabled":q.disabled?"":void 0,"data-orientation":q.orientation,...Z,ref:J})});LN.displayName=_N;var $3="SliderRange",FN=z5.forwardRef(($,J)=>{let{__scopeSlider:Q,...Z}=$,q=oX($3,Q),X=BN($3,Q),Y=z5.useRef(null),z=k2(J,Y),K=q.values.length,W=q.values.map((U)=>DN(U,q.min,q.max)),H=K>1?Math.min(...W):0,B=100-Math.max(...W);return G(t$.span,{"data-orientation":q.orientation,"data-disabled":q.disabled?"":void 0,...Z,ref:z,style:{...$.style,[X.startEdge]:H+"%",[X.endEdge]:B+"%"}})});FN.displayName=$3;var J3="SliderThumb",VN=z5.forwardRef(($,J)=>{let Q=Kg($.__scopeSlider),[Z,q]=z5.useState(null),X=k2(J,(z)=>q(z)),Y=z5.useMemo(()=>Z?Q().findIndex((z)=>z.ref.current===Z):-1,[Q,Z]);return G(Ug,{...$,ref:X,index:Y})}),Ug=z5.forwardRef(($,J)=>{let{__scopeSlider:Q,index:Z,name:q,...X}=$,Y=oX(J3,Q),z=BN(J3,Q),[K,W]=z5.useState(null),H=k2(J,(D)=>W(D)),B=K?Y.form||!!K.closest("form"):!0,U=ZN(K),_=Y.values[Z],L=_===void 0?0:DN(_,Y.min,Y.max),F=Fg(Z,Y.values.length),V=U?.[z.size],M=V?Mg(V,L,z.direction):0;return z5.useEffect(()=>{if(K)return Y.thumbs.add(K),()=>{Y.thumbs.delete(K)}},[K,Y.thumbs]),T("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[z.startEdge]:`calc(${L}% + ${M}px)`},children:[G(eH.ItemSlot,{scope:$.__scopeSlider,children:G(t$.span,{role:"slider","aria-label":$["aria-label"]||F,"aria-valuemin":Y.min,"aria-valuenow":_,"aria-valuemax":Y.max,"aria-orientation":Y.orientation,"data-orientation":Y.orientation,"data-disabled":Y.disabled?"":void 0,tabIndex:Y.disabled?void 0:0,...X,ref:H,style:_===void 0?{display:"none"}:$.style,onFocus:w2($.onFocus,()=>{Y.valueIndexToChangeRef.current=Z})})}),B&&G(MN,{name:q??(Y.name?Y.name+(Y.values.length>1?"[]":""):void 0),form:Y.form,value:_},Z)]})});VN.displayName=J3;var _g="RadioBubbleInput",MN=z5.forwardRef(({__scopeSlider:$,value:J,...Q},Z)=>{let q=z5.useRef(null),X=k2(q,Z),Y=SX(J);return z5.useEffect(()=>{let z=q.current;if(!z)return;let K=window.HTMLInputElement.prototype,H=Object.getOwnPropertyDescriptor(K,"value").set;if(Y!==J&&H){let B=new Event("input",{bubbles:!0});H.call(z,J),z.dispatchEvent(B)}},[Y,J]),G(t$.input,{style:{display:"none"},...Q,ref:X,defaultValue:J})});MN.displayName=_g;function Lg($=[],J,Q){let Z=[...$];return Z[Q]=J,Z.sort((q,X)=>q-X)}function DN($,J,Q){let X=100/(Q-J)*($-J);return u$(X,[0,100])}function Fg($,J){if(J>2)return`Value ${$+1} of ${J}`;else if(J===2)return["Minimum","Maximum"][$];else return}function Vg($,J){if($.length===1)return 0;let Q=$.map((q)=>Math.abs(q-J)),Z=Math.min(...Q);return Q.indexOf(Z)}function Mg($,J,Q){let Z=$/2,q=50,X=Q3([0,50],[0,Z]);return(Z-X(J)*Q)*Q}function Dg($){return $.slice(0,-1).map((J,Q)=>$[Q+1]-J)}function Ng($,J){if(J>0){let Q=Dg($);return Math.min(...Q)>=J}return!0}function Q3($,J){return(Q)=>{if($[0]===$[1]||J[0]===J[1])return J[0];let Z=(J[1]-J[0])/($[1]-$[0]);return J[0]+Z*(Q-$[0])}}function Og($){return(String($).split(".")[1]||"").length}function Ag($,J){let Q=Math.pow(10,J);return Math.round($*Q)/Q}var $Z=WN,nX=LN,aX=FN,tX=VN;var O8=ON.forwardRef(({className:$,"aria-label":J,"aria-labelledby":Q,ticks:Z,...q},X)=>{let Y=q.value?.[0]??q.defaultValue?.[0];return G("div",{className:b0("relative",Z&&Z.length>0&&"pb-4"),children:T($Z,{ref:X,className:b0("relative flex w-full touch-none select-none items-center",$),"aria-label":J,"aria-labelledby":Q,...q,children:[G(nX,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:G(aX,{className:"absolute h-full bg-primary"})}),G(tX,{"aria-label":J,"aria-labelledby":Q,className:"block h-3 w-3 rounded-full border border-primary/50 bg-primary shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"}),Z&&Z.length>0&&G("div",{className:"absolute left-0 top-full flex w-full justify-between",children:Z.map((z)=>{let K=z.value===Y;return T("div",{className:"flex flex-col items-center gap-0.5",children:[G("div",{className:b0("h-1.5 w-px bg-muted-foreground/40",K&&"bg-primary")}),G("span",{className:b0("text-[10px] tabular-nums leading-none text-muted-foreground",K&&"font-medium text-foreground"),children:z.label})]},z.value)})})]})})});O8.displayName=$Z.displayName;var dN=R(v(),1);var k1=R(v(),1);var j60=!!(typeof window<"u"&&window.document&&window.document.createElement);function I2($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var wN=R(v(),1);function AN($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function Z3(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=AN(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else AN($[q],null)}}}}function JZ(...$){return wN.useCallback(Z3(...$),$)}var y4=R(v(),1);function kN($,J=[]){let Q=[];function Z(X,Y){let z=y4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=y4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=y4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return y4.createContext(Y)});return function(z){let K=z?.[$]||X;return y4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,wg(q,...J)]}function wg(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return y4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var H6=R(v(),1);var IN=R(v(),1);function kg($,J){return IN.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}var $Y=($)=>{let{present:J,children:Q}=$,Z=Ig(J),q=typeof Q==="function"?Q({present:Z.isPresent}):H6.Children.only(Q),X=JZ(Z.ref,Tg(q));return typeof Q==="function"||Z.isPresent?H6.cloneElement(q,{ref:X}):null};$Y.displayName="Presence";function Ig($){let[J,Q]=H6.useState(),Z=H6.useRef(null),q=H6.useRef($),X=H6.useRef("none"),Y=$?"mounted":"unmounted",[z,K]=kg(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return H6.useEffect(()=>{let W=eX(Z.current);X.current=z==="mounted"?W:"none"},[z]),_1(()=>{let W=Z.current,H=q.current;if(H!==$){let U=X.current,_=eX(W);if($)K("MOUNT");else if(_==="none"||W?.display==="none")K("UNMOUNT");else if(H&&U!==_)K("ANIMATION_OUT");else K("UNMOUNT");q.current=$}},[$,K]),_1(()=>{if(J){let W,H=J.ownerDocument.defaultView??window,B=(_)=>{let F=eX(Z.current).includes(CSS.escape(_.animationName));if(_.target===J&&F){if(K("ANIMATION_END"),!q.current){let V=J.style.animationFillMode;J.style.animationFillMode="forwards",W=H.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=V})}}},U=(_)=>{if(_.target===J)X.current=eX(Z.current)};return J.addEventListener("animationstart",U),J.addEventListener("animationcancel",B),J.addEventListener("animationend",B),()=>{H.clearTimeout(W),J.removeEventListener("animationstart",U),J.removeEventListener("animationcancel",B),J.removeEventListener("animationend",B)}}else K("ANIMATION_END")},[J,K]),{isPresent:["mounted","unmountSuspended"].includes(z),ref:H6.useCallback((W)=>{Z.current=W?getComputedStyle(W):null,Q(W)},[])}}function eX($){return $?.animationName||"none"}function Tg($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var EN=R(v(),1),Pg=R(J5(),1);var X8=R(v(),1);function TN($){let J=bg($),Q=X8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=X8.Children.toArray(X),K=z.find(jg);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(X8.Children.count(W)>1)return X8.Children.only(null);return X8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:X8.isValidElement(W)?X8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function bg($){let J=X8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(X8.isValidElement(q)){let Y=yg(q),z=Eg(X,q.props);if(q.type!==X8.Fragment)z.ref=Z?Z3(Z,Y):Y;return X8.cloneElement(q,z)}return X8.Children.count(q)>1?X8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var bN=Symbol("radix.slottable");function jN($){let J=({children:Q})=>{return G(G1,{children:Q})};return J.displayName=`${$}.Slottable`,J.__radixId=bN,J}function jg($){return X8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===bN}function Eg($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function yg($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Rg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yN=Rg.reduce(($,J)=>{let Q=TN(`Primitive.${J}`),Z=EN.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var r6=R(v(),1);var JY=R(v(),1);var Cg=r6[" useInsertionEffect ".trim().toString()]||_1;function PN({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=Sg({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=r6.useRef($!==void 0);r6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=r6.useCallback((H)=>{if(z){let B=hg(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function Sg({defaultProp:$,onChange:J}){let[Q,Z]=r6.useState($),q=r6.useRef(Q),X=r6.useRef(J);return Cg(()=>{X.current=J},[J]),r6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function hg($){return typeof $==="function"}var d60=Symbol("RADIX:SYNC_STATE");var[QY,Z90]=kN("Tooltip",[p6]),ZY=p6(),RN="TooltipProvider",xg=700,q3="tooltip.open",[fg,Y3]=QY(RN),CN=($)=>{let{__scopeTooltip:J,delayDuration:Q=xg,skipDelayDuration:Z=300,disableHoverableContent:q=!1,children:X}=$,Y=k1.useRef(!0),z=k1.useRef(!1),K=k1.useRef(0);return k1.useEffect(()=>{let W=K.current;return()=>window.clearTimeout(W)},[]),G(fg,{scope:J,isOpenDelayedRef:Y,delayDuration:Q,onOpen:k1.useCallback(()=>{window.clearTimeout(K.current),Y.current=!1},[]),onClose:k1.useCallback(()=>{window.clearTimeout(K.current),K.current=window.setTimeout(()=>Y.current=!0,Z)},[Z]),isPointerInTransitRef:z,onPointerInTransitChange:k1.useCallback((W)=>{z.current=W},[]),disableHoverableContent:q,children:X})};CN.displayName=RN;var QZ="Tooltip",[vg,ZZ]=QY(QZ),SN=($)=>{let{__scopeTooltip:J,children:Q,open:Z,defaultOpen:q,onOpenChange:X,disableHoverableContent:Y,delayDuration:z}=$,K=Y3(QZ,$.__scopeTooltip),W=ZY(J),[H,B]=k1.useState(null),U=t5(),_=k1.useRef(0),L=Y??K.disableHoverableContent,F=z??K.delayDuration,V=k1.useRef(!1),[M,D]=PN({prop:Z,defaultProp:q??!1,onChange:(b)=>{if(b)K.onOpen(),document.dispatchEvent(new CustomEvent(q3));else K.onClose();X?.(b)},caller:QZ}),N=k1.useMemo(()=>{return M?V.current?"delayed-open":"instant-open":"closed"},[M]),O=k1.useCallback(()=>{window.clearTimeout(_.current),_.current=0,V.current=!1,D(!0)},[D]),I=k1.useCallback(()=>{window.clearTimeout(_.current),_.current=0,D(!1)},[D]),A=k1.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{V.current=!0,D(!0),_.current=0},F)},[F,D]);return k1.useEffect(()=>{return()=>{if(_.current)window.clearTimeout(_.current),_.current=0}},[]),G(I4,{...W,children:G(vg,{scope:J,contentId:U,open:M,stateAttribute:N,trigger:H,onTriggerChange:B,onTriggerEnter:k1.useCallback(()=>{if(K.isOpenDelayedRef.current)A();else O()},[K.isOpenDelayedRef,A,O]),onTriggerLeave:k1.useCallback(()=>{if(L)I();else window.clearTimeout(_.current),_.current=0},[I,L]),onOpen:O,onClose:I,disableHoverableContent:L,children:Q})})};SN.displayName=QZ;var X3="TooltipTrigger",hN=k1.forwardRef(($,J)=>{let{__scopeTooltip:Q,...Z}=$,q=ZZ(X3,Q),X=Y3(X3,Q),Y=ZY(Q),z=k1.useRef(null),K=JZ(J,z,q.onTriggerChange),W=k1.useRef(!1),H=k1.useRef(!1),B=k1.useCallback(()=>W.current=!1,[]);return k1.useEffect(()=>{return()=>document.removeEventListener("pointerup",B)},[B]),G(T4,{asChild:!0,...Y,children:G(yN.button,{"aria-describedby":q.open?q.contentId:void 0,"data-state":q.stateAttribute,...Z,ref:K,onPointerMove:I2($.onPointerMove,(U)=>{if(U.pointerType==="touch")return;if(!H.current&&!X.isPointerInTransitRef.current)q.onTriggerEnter(),H.current=!0}),onPointerLeave:I2($.onPointerLeave,()=>{q.onTriggerLeave(),H.current=!1}),onPointerDown:I2($.onPointerDown,()=>{if(q.open)q.onClose();W.current=!0,document.addEventListener("pointerup",B,{once:!0})}),onFocus:I2($.onFocus,()=>{if(!W.current)q.onOpen()}),onBlur:I2($.onBlur,q.onClose),onClick:I2($.onClick,q.onClose)})})});hN.displayName=X3;var z3="TooltipPortal",[gg,ug]=QY(z3,{forceMount:void 0}),xN=($)=>{let{__scopeTooltip:J,forceMount:Q,children:Z,container:q}=$,X=ZZ(z3,J);return G(gg,{scope:J,forceMount:Q,children:G($Y,{present:Q||X.open,children:G(T9,{asChild:!0,container:q,children:Z})})})};xN.displayName=z3;var $J="TooltipContent",fN=k1.forwardRef(($,J)=>{let Q=ug($J,$.__scopeTooltip),{forceMount:Z=Q.forceMount,side:q="top",...X}=$,Y=ZZ($J,$.__scopeTooltip);return G($Y,{present:Z||Y.open,children:Y.disableHoverableContent?G(vN,{side:q,...X,ref:J}):G(mg,{side:q,...X,ref:J})})}),mg=k1.forwardRef(($,J)=>{let Q=ZZ($J,$.__scopeTooltip),Z=Y3($J,$.__scopeTooltip),q=k1.useRef(null),X=JZ(J,q),[Y,z]=k1.useState(null),{trigger:K,onClose:W}=Q,H=q.current,{onPointerInTransitChange:B}=Z,U=k1.useCallback(()=>{z(null),B(!1)},[B]),_=k1.useCallback((L,F)=>{let V=L.currentTarget,M={x:L.clientX,y:L.clientY},D=ig(M,V.getBoundingClientRect()),N=rg(M,D),O=sg(F.getBoundingClientRect()),I=ng([...N,...O]);z(I),B(!0)},[B]);return k1.useEffect(()=>{return()=>U()},[U]),k1.useEffect(()=>{if(K&&H){let L=(V)=>_(V,H),F=(V)=>_(V,K);return K.addEventListener("pointerleave",L),H.addEventListener("pointerleave",F),()=>{K.removeEventListener("pointerleave",L),H.removeEventListener("pointerleave",F)}}},[K,H,_,U]),k1.useEffect(()=>{if(Y){let L=(F)=>{let V=F.target,M={x:F.clientX,y:F.clientY},D=K?.contains(V)||H?.contains(V),N=!og(M,Y);if(D)U();else if(N)U(),W()};return document.addEventListener("pointermove",L),()=>document.removeEventListener("pointermove",L)}},[K,H,Y,W,U]),G(vN,{...$,ref:X})}),[cg,dg]=QY(QZ,{isInside:!1}),pg=jN("TooltipContent"),vN=k1.forwardRef(($,J)=>{let{__scopeTooltip:Q,children:Z,"aria-label":q,onEscapeKeyDown:X,onPointerDownOutside:Y,...z}=$,K=ZZ($J,Q),W=ZY(Q),{onClose:H}=K;return k1.useEffect(()=>{return document.addEventListener(q3,H),()=>document.removeEventListener(q3,H)},[H]),k1.useEffect(()=>{if(K.trigger){let B=(U)=>{if(U.target?.contains(K.trigger))H()};return window.addEventListener("scroll",B,{capture:!0}),()=>window.removeEventListener("scroll",B,{capture:!0})}},[K.trigger,H]),G(w9,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:X,onPointerDownOutside:Y,onFocusOutside:(B)=>B.preventDefault(),onDismiss:H,children:T(F7,{"data-state":K.stateAttribute,...W,...z,ref:J,style:{...z.style,...{"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"}},children:[G(pg,{children:Z}),G(cg,{scope:Q,isInside:!0,children:G(sM,{id:K.contentId,role:"tooltip",children:q||Z})})]})})});fN.displayName=$J;var gN="TooltipArrow",lg=k1.forwardRef(($,J)=>{let{__scopeTooltip:Q,...Z}=$,q=ZY(Q);return dg(gN,Q).isInside?null:G(V7,{...q,...Z,ref:J})});lg.displayName=gN;function ig($,J){let Q=Math.abs(J.top-$.y),Z=Math.abs(J.bottom-$.y),q=Math.abs(J.right-$.x),X=Math.abs(J.left-$.x);switch(Math.min(Q,Z,q,X)){case X:return"left";case q:return"right";case Q:return"top";case Z:return"bottom";default:throw Error("unreachable")}}function rg($,J,Q=5){let Z=[];switch(J){case"top":Z.push({x:$.x-Q,y:$.y+Q},{x:$.x+Q,y:$.y+Q});break;case"bottom":Z.push({x:$.x-Q,y:$.y-Q},{x:$.x+Q,y:$.y-Q});break;case"left":Z.push({x:$.x+Q,y:$.y-Q},{x:$.x+Q,y:$.y+Q});break;case"right":Z.push({x:$.x-Q,y:$.y-Q},{x:$.x-Q,y:$.y+Q});break}return Z}function sg($){let{top:J,right:Q,bottom:Z,left:q}=$;return[{x:q,y:J},{x:Q,y:J},{x:Q,y:Z},{x:q,y:Z}]}function og($,J){let{x:Q,y:Z}=$,q=!1;for(let X=0,Y=J.length-1;X<J.length;Y=X++){let z=J[X],K=J[Y],W=z.x,H=z.y,B=K.x,U=K.y;if(H>Z!==U>Z&&Q<(B-W)*(Z-H)/(U-H)+W)q=!q}return q}function ng($){let J=$.slice();return J.sort((Q,Z)=>{if(Q.x<Z.x)return-1;else if(Q.x>Z.x)return 1;else if(Q.y<Z.y)return-1;else if(Q.y>Z.y)return 1;else return 0}),ag(J)}function ag($){if($.length<=1)return $.slice();let J=[];for(let Z=0;Z<$.length;Z++){let q=$[Z];while(J.length>=2){let X=J[J.length-1],Y=J[J.length-2];if((X.x-Y.x)*(q.y-Y.y)>=(X.y-Y.y)*(q.x-Y.x))J.pop();else break}J.push(q)}J.pop();let Q=[];for(let Z=$.length-1;Z>=0;Z--){let q=$[Z];while(Q.length>=2){let X=Q[Q.length-1],Y=Q[Q.length-2];if((X.x-Y.x)*(q.y-Y.y)>=(X.y-Y.y)*(q.x-Y.x))Q.pop();else break}Q.push(q)}if(Q.pop(),J.length===1&&Q.length===1&&J[0].x===Q[0].x&&J[0].y===Q[0].y)return J;else return J.concat(Q)}var K3=CN,uN=SN,mN=hN,cN=xN,G3=fN;var a1=({disableHoverableContent:$=!0,...J})=>G(K3,{disableHoverableContent:$,...J});a1.displayName=K3.displayName;var H1=uN,B1=mN,W1=dN.forwardRef(({className:$,sideOffset:J=4,...Q},Z)=>G(cN,{children:G("div",{className:`${D8}`,children:G(G3,{ref:Z,sideOffset:J,className:b0("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",$),...Q})})}));W1.displayName=G3.displayName;function eg($,J){let Q=qZ(Math.max($,1),Math.max(J,1));if(Q<=10)return{max:2,step:0.05};if(Q<=30)return{max:3,step:0.05};if(Q<=60)return{max:4,step:0.1};if(Q<=120)return{max:6,step:0.1};if(Q<=300)return{max:8,step:0.2};return{max:10,step:0.25}}function iN({totalLength:$,frameRate:J,displayFormat:Q,onTotalLengthChange:Z,onFrameRateChange:q,onDisplayFormatChange:X,isPlaying:Y,onPlayPause:z,hasSelection:K,canDelete:W=K,onDeleteSelected:H,zoom:B,onZoomChange:U,selectedSegment:_,onSelectedSegmentDurationChange:L}){let F=Z1(),V=eg($,J);lN.useEffect(()=>{if(B>V.max)U(V.max)},[B,V.max,U]);let M=_?_.end_frame-_.start_frame+1:0,D;if(_)D=Q==="seconds"?Math.round(qZ(M,J)*100)/100:M;else D=Q==="seconds"?Math.round(qZ($,J)*100)/100:$;function N(I){if(I<=0)return;let A=Q==="seconds"?pN(I,J):Math.round(I);if(Q==="seconds"){let b=_?_.end_frame-_.start_frame+1:$;if(A===b){let k=qZ(b,J);if(I<k)A=Math.max(1,b-4);else if(I>k)A=b+4;else return}}if(_){let b=_.end_frame-_.start_frame+1;if(A-b===0)return;L(_.id,A)}else Z(A)}function O(I){if(I>0)q(Math.round(I))}return T("div",{className:"flex justify-between items-center gap-2 py-1 border-b border-border text-xs shrink-0",children:[T("div",{className:"flex items-center gap-0.5",children:[T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:z,"aria-label":Y?F("toolbar.pause"):F("toolbar.play"),children:Y?G(O7,{className:"w-2 h-2"}):G(P4,{className:"w-2 h-2"})})}),G(W1,{side:"bottom",children:Y?F("toolbar.pause"):F("toolbar.play")})]}),T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:H,disabled:!W,"aria-label":F("toolbar.deleteSegment"),children:G(N5,{className:"w-2 h-2"})})}),G(W1,{side:"bottom",children:F("toolbar.deleteSegment")})]})]}),T("div",{className:"flex items-center gap-2","data-time-toolbar":!0,children:[T("div",{className:"flex items-center gap-1",children:[G(e8,{value:D,onChange:N,min:1,max:2000,step:Q==="seconds"?1:4,commitOnBlur:!0,className:"h-6 w-18"}),T(y8,{value:Q,onValueChange:(I)=>X(I),children:[G(P8,{className:"h-6 w-10 text-xs",children:(Q==="frames"?F("toolbar.frames"):F("toolbar.seconds")).substring(0,1)}),T(R8,{children:[G(i5,{value:"frames",children:F("toolbar.frames")}),G(i5,{value:"seconds",children:F("toolbar.seconds")})]})]})]}),T("div",{className:"flex items-center gap-1",children:[G(e8,{value:J,onChange:O,min:1,max:60,step:1,commitOnBlur:!0,className:"h-6 w-14"}),G("span",{className:"text-muted-foreground",children:F("toolbar.fps")})]})]}),G("div",{className:"flex items-center gap-1 pr-1",children:T("div",{className:"flex items-center gap-1",children:[T(H1,{children:[G(B1,{asChild:!0,children:G(JJ,{className:"w-4 h-4 text-muted-foreground shrink-0"})}),G(W1,{side:"bottom",children:F("toolbar.zoom")})]}),G(O8,{min:1,max:V.max,step:V.step,value:[Math.min(B,V.max)],onValueChange:([I])=>U(I),className:"w-12 h-3","aria-label":F("toolbar.zoom")})]})})]})}var QJ=R(v(),1);function $u($,J,Q,Z){if(Z==="seconds"){let z=($-1)/Q/J,K=[0.1,0.25,0.5,1,2,5,10,15,30,60,120,300],W=K.reduce((H,B)=>Math.abs(B-z)<Math.abs(H-z)?B:H,K[0]);return Math.max(1,Math.round(W*Q))}let q=$/J,X=[1,2,4,5,6,8,10,12,15,20,24,25,30,48,50,60,100,120,240,300];return X.reduce((Y,z)=>Math.abs(z-q)<Math.abs(Y-q)?z:Y,X[0])}function qY({totalFrames:$,frameRate:J,displayFormat:Q,width:Z,canvasScale:q,playheadFrame:X,showLabel:Y,onSeek:z,onWheel:K}){let W=QJ.useRef(!1);QJ.useEffect(()=>{return()=>{W.current=!1}},[]);function H(F){return Math.max(0,Math.min($-1,Math.round(F/Z*($-1))))}function B(F){if(!z)return;F.preventDefault(),W.current=!0;let V=F.currentTarget.getBoundingClientRect(),M=(F.clientX-V.left)/q;z(H(M));function D(O){if(!W.current)return;let I=(O.clientX-V.left)/q;z(H(I))}function N(){W.current=!1,globalThis.removeEventListener("mousemove",D),globalThis.removeEventListener("mouseup",N)}globalThis.addEventListener("mousemove",D),globalThis.addEventListener("mouseup",N)}let U=X===void 0?void 0:X/Math.max($-1,1)*Z,_=QJ.useMemo(()=>{let F=Math.max(5,Math.floor(Z/60)),V=$u($,F,J,Q),M=[];for(let N=0;N<$;N+=V){let O=Q==="seconds"?`${Math.max(0,N/J).toFixed(1)}s`:`${N}f`;M.push({frame:N,label:O,major:!0})}let D=$-1;if(!M.some((N)=>N.frame===D)){let N=Q==="seconds"?`${Math.max(0,D/J).toFixed(1)}s`:`${D}f`;M.push({frame:D,label:N,major:!1})}return M},[$,J,Q,Z]);function L(F){return F/Math.max($-1,1)*Z}return T("div",{role:"slider","aria-label":"Playhead position","aria-valuenow":X??0,"aria-valuemin":0,"aria-valuemax":$-1,tabIndex:z?0:-1,className:"relative h-6 shrink-0 select-none border-b border-border overflow-hidden cursor-col-resize",style:{width:Z},onMouseDown:B,onWheel:K,onKeyDown:(F)=>{if(!z)return;let V=F.shiftKey?10:1;if(F.key==="ArrowLeft")z(Math.max(0,(X??0)-V));else if(F.key==="ArrowRight")z(Math.min($-1,(X??0)+V))},children:[_.map(({frame:F,label:V,major:M})=>T("div",{className:"absolute top-0 flex flex-col items-start pointer-events-none",style:{left:L(F)},children:[G("div",{className:`w-px ${M?"h-2 bg-border":"h-1.5 bg-border"}`}),M&&G("span",{className:"text-[9px] text-muted-foreground/70 whitespace-nowrap translate-x-1",children:V})]},F)),U!==void 0&&G("div",{className:"absolute top-0 h-full w-px bg-red-400 pointer-events-none z-10",style:{left:U},children:G("div",{className:"absolute top-0 -translate-x-1/2 w-0 h-0 pointer-events-none",style:{borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"6px solid rgb(248 113 113)"}})}),Y&&U!==void 0&&G("div",{className:"absolute top-0 -translate-x-1/2 z-20 pointer-events-none",style:{left:U,top:"-2px"},children:G("div",{className:"bg-red-400 text-white text-[8px] font-medium px-1.5 py-0.5 rounded whitespace-nowrap shadow",children:Q==="seconds"?`${Math.max(0,(X??0)/J).toFixed(1)}s`:`${X??0}f`})})]})}var d4=R(v(),1);var h4=R(v(),1);var B5=R(v(),1);var N90=!!(typeof window<"u"&&window.document&&window.document.createElement);function ZJ($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var R4=R(v(),1);function rN($,J=[]){let Q=[];function Z(X,Y){let z=R4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=R4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=R4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return R4.createContext(Y)});return function(z){let K=z?.[$]||X;return R4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,Ju(q,...J)]}function Ju(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return R4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var aN=R(v(),1),Ku=R(J5(),1);var Y8=R(v(),1);var Qu=R(v(),1);function sN($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function oN(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=sN(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else sN($[q],null)}}}}function nN($){let J=Zu($),Q=Y8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=Y8.Children.toArray(X),K=z.find(Xu);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(Y8.Children.count(W)>1)return Y8.Children.only(null);return Y8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:Y8.isValidElement(W)?Y8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function Zu($){let J=Y8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(Y8.isValidElement(q)){let Y=zu(q),z=Yu(X,q.props);if(q.type!==Y8.Fragment)z.ref=Z?oN(Z,Y):Y;return Y8.cloneElement(q,z)}return Y8.Children.count(q)>1?Y8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var qu=Symbol("radix.slottable");function Xu($){return Y8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===qu}function Yu($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function zu($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Gu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tN=Gu.reduce(($,J)=>{let Q=nN(`Primitive.${J}`),Z=aN.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var q1=R(v(),1);var P90=!!(typeof window<"u"&&window.document&&window.document.createElement);function R5($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var $O=R(v(),1);function eN($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function XZ(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=eN(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else eN($[q],null)}}}}function A7(...$){return $O.useCallback(XZ(...$),$)}var C4=R(v(),1);function JO($,J=[]){let Q=[];function Z(X,Y){let z=C4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=C4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=C4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return C4.createContext(Y)});return function(z){let K=z?.[$]||X;return C4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,Wu(q,...J)]}function Wu(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return C4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var B6=R(v(),1);var QO=R(v(),1);function Hu($,J){return QO.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}var qJ=($)=>{let{present:J,children:Q}=$,Z=Bu(J),q=typeof Q==="function"?Q({present:Z.isPresent}):B6.Children.only(Q),X=A7(Z.ref,Uu(q));return typeof Q==="function"||Z.isPresent?B6.cloneElement(q,{ref:X}):null};qJ.displayName="Presence";function Bu($){let[J,Q]=B6.useState(),Z=B6.useRef(null),q=B6.useRef($),X=B6.useRef("none"),Y=$?"mounted":"unmounted",[z,K]=Hu(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return B6.useEffect(()=>{let W=XY(Z.current);X.current=z==="mounted"?W:"none"},[z]),_1(()=>{let W=Z.current,H=q.current;if(H!==$){let U=X.current,_=XY(W);if($)K("MOUNT");else if(_==="none"||W?.display==="none")K("UNMOUNT");else if(H&&U!==_)K("ANIMATION_OUT");else K("UNMOUNT");q.current=$}},[$,K]),_1(()=>{if(J){let W,H=J.ownerDocument.defaultView??window,B=(_)=>{let F=XY(Z.current).includes(CSS.escape(_.animationName));if(_.target===J&&F){if(K("ANIMATION_END"),!q.current){let V=J.style.animationFillMode;J.style.animationFillMode="forwards",W=H.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=V})}}},U=(_)=>{if(_.target===J)X.current=XY(Z.current)};return J.addEventListener("animationstart",U),J.addEventListener("animationcancel",B),J.addEventListener("animationend",B),()=>{H.clearTimeout(W),J.removeEventListener("animationstart",U),J.removeEventListener("animationcancel",B),J.removeEventListener("animationend",B)}}else K("ANIMATION_END")},[J,K]),{isPresent:["mounted","unmountSuspended"].includes(z),ref:B6.useCallback((W)=>{Z.current=W?getComputedStyle(W):null,Q(W)},[])}}function XY($){return $?.animationName||"none"}function Uu($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var ZO=R(v(),1),qO=R(J5(),1);var z8=R(v(),1);function YY($){let J=_u($),Q=z8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=z8.Children.toArray(X),K=z.find(Fu);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(z8.Children.count(W)>1)return z8.Children.only(null);return z8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:z8.isValidElement(W)?z8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function _u($){let J=z8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(z8.isValidElement(q)){let Y=Mu(q),z=Vu(X,q.props);if(q.type!==z8.Fragment)z.ref=Z?XZ(Z,Y):Y;return z8.cloneElement(q,z)}return z8.Children.count(q)>1?z8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Lu=Symbol("radix.slottable");function Fu($){return z8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Lu}function Vu($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Mu($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Du=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],XJ=Du.reduce(($,J)=>{let Q=YY(`Primitive.${J}`),Z=ZO.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});function XO($,J){if($)qO.flushSync(()=>$.dispatchEvent(J))}var A8=R(v(),1);var l90=!!(typeof window<"u"&&window.document&&window.document.createElement);function T2($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var zO=R(v(),1);function YO($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function W3(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=YO(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else YO($[q],null)}}}}function KO(...$){return zO.useCallback(W3(...$),$)}var S4=R(v(),1);function GO($,J=[]){let Q=[];function Z(X,Y){let z=S4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=S4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=S4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return S4.createContext(Y)});return function(z){let K=z?.[$]||X;return S4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,Nu(q,...J)]}function Nu(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return S4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var HO=R(v(),1),Tu=R(J5(),1);var K8=R(v(),1);function WO($){let J=Ou($),Q=K8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=K8.Children.toArray(X),K=z.find(wu);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(K8.Children.count(W)>1)return K8.Children.only(null);return K8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:K8.isValidElement(W)?K8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function Ou($){let J=K8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(K8.isValidElement(q)){let Y=Iu(q),z=ku(X,q.props);if(q.type!==K8.Fragment)z.ref=Z?W3(Z,Y):Y;return K8.cloneElement(q,z)}return K8.Children.count(q)>1?K8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var Au=Symbol("radix.slottable");function wu($){return K8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===Au}function ku($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function Iu($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var bu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],H3=bu.reduce(($,J)=>{let Q=WO(`Primitive.${J}`),Z=HO.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var s6=R(v(),1);var zY=R(v(),1);var ju=s6[" useInsertionEffect ".trim().toString()]||_1;function BO({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=Eu({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=s6.useRef($!==void 0);s6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=s6.useCallback((H)=>{if(z){let B=yu(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function Eu({defaultProp:$,onChange:J}){let[Q,Z]=s6.useState($),q=s6.useRef(Q),X=s6.useRef(J);return ju(()=>{X.current=J},[J]),s6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function yu($){return typeof $==="function"}var Z40=Symbol("RADIX:SYNC_STATE");var B3="rovingFocusGroup.onEntryFocus",Pu={bubbles:!1,cancelable:!0},YZ="RovingFocusGroup",[U3,UO,Ru]=H7(YZ),[Cu,YJ]=GO(YZ,[Ru]),[Su,hu]=Cu(YZ),_O=A8.forwardRef(($,J)=>{return G(U3.Provider,{scope:$.__scopeRovingFocusGroup,children:G(U3.Slot,{scope:$.__scopeRovingFocusGroup,children:G(xu,{...$,ref:J})})})});_O.displayName=YZ;var xu=A8.forwardRef(($,J)=>{let{__scopeRovingFocusGroup:Q,orientation:Z,loop:q=!1,dir:X,currentTabStopId:Y,defaultCurrentTabStopId:z,onCurrentTabStopIdChange:K,onEntryFocus:W,preventScrollOnEntryFocus:H=!1,...B}=$,U=A8.useRef(null),_=KO(J,U),L=l9(X),[F,V]=BO({prop:Y,defaultProp:z??null,onChange:K,caller:YZ}),[M,D]=A8.useState(!1),N=d5(W),O=UO(Q),I=A8.useRef(!1),[A,b]=A8.useState(0);return A8.useEffect(()=>{let k=U.current;if(k)return k.addEventListener(B3,N),()=>k.removeEventListener(B3,N)},[N]),G(Su,{scope:Q,orientation:Z,dir:L,loop:q,currentTabStopId:F,onItemFocus:A8.useCallback((k)=>V(k),[V]),onItemShiftTab:A8.useCallback(()=>D(!0),[]),onFocusableItemAdd:A8.useCallback(()=>b((k)=>k+1),[]),onFocusableItemRemove:A8.useCallback(()=>b((k)=>k-1),[]),children:G(H3.div,{tabIndex:M||A===0?-1:0,"data-orientation":Z,...B,ref:_,style:{outline:"none",...$.style},onMouseDown:T2($.onMouseDown,()=>{I.current=!0}),onFocus:T2($.onFocus,(k)=>{let w=!I.current;if(k.target===k.currentTarget&&w&&!M){let C=new CustomEvent(B3,Pu);if(k.currentTarget.dispatchEvent(C),!C.defaultPrevented){let y=O().filter((p)=>p.focusable),f=y.find((p)=>p.active),j=y.find((p)=>p.id===F),x=[f,j,...y].filter(Boolean).map((p)=>p.ref.current);VO(x,H)}}I.current=!1}),onBlur:T2($.onBlur,()=>D(!1))})})}),LO="RovingFocusGroupItem",FO=A8.forwardRef(($,J)=>{let{__scopeRovingFocusGroup:Q,focusable:Z=!0,active:q=!1,tabStopId:X,children:Y,...z}=$,K=t5(),W=X||K,H=hu(LO,Q),B=H.currentTabStopId===W,U=UO(Q),{onFocusableItemAdd:_,onFocusableItemRemove:L,currentTabStopId:F}=H;return A8.useEffect(()=>{if(Z)return _(),()=>L()},[Z,_,L]),G(U3.ItemSlot,{scope:Q,id:W,focusable:Z,active:q,children:G(H3.span,{tabIndex:B?0:-1,"data-orientation":H.orientation,...z,ref:J,onMouseDown:T2($.onMouseDown,(V)=>{if(!Z)V.preventDefault();else H.onItemFocus(W)}),onFocus:T2($.onFocus,()=>H.onItemFocus(W)),onKeyDown:T2($.onKeyDown,(V)=>{if(V.key==="Tab"&&V.shiftKey){H.onItemShiftTab();return}if(V.target!==V.currentTarget)return;let M=gu(V,H.orientation,H.dir);if(M!==void 0){if(V.metaKey||V.ctrlKey||V.altKey||V.shiftKey)return;V.preventDefault();let N=U().filter((O)=>O.focusable).map((O)=>O.ref.current);if(M==="last")N.reverse();else if(M==="prev"||M==="next"){if(M==="prev")N.reverse();let O=N.indexOf(V.currentTarget);N=H.loop?uu(N,O+1):N.slice(O+1)}setTimeout(()=>VO(N))}}),children:typeof Y==="function"?Y({isCurrentTabStop:B,hasTabStop:F!=null}):Y})})});FO.displayName=LO;var fu={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function vu($,J){if(J!=="rtl")return $;return $==="ArrowLeft"?"ArrowRight":$==="ArrowRight"?"ArrowLeft":$}function gu($,J,Q){let Z=vu($.key,Q);if(J==="vertical"&&["ArrowLeft","ArrowRight"].includes(Z))return;if(J==="horizontal"&&["ArrowUp","ArrowDown"].includes(Z))return;return fu[Z]}function VO($,J=!1){let Q=document.activeElement;for(let Z of $){if(Z===Q)return;if(Z.focus({preventScroll:J}),document.activeElement!==Q)return}}function uu($,J){return $.map((Q,Z)=>$[(J+Z)%$.length])}var KY=_O,GY=FO;var _3=["Enter"," "],mu=["ArrowDown","PageUp","Home"],NO=["ArrowUp","PageDown","End"],cu=[...mu,...NO],du={ltr:[..._3,"ArrowRight"],rtl:[..._3,"ArrowLeft"]},pu={ltr:["ArrowLeft"],rtl:["ArrowRight"]},WZ="Menu",[KZ,lu,iu]=H7(WZ),[b2,L3]=JO(WZ,[iu,p6,YJ]),HZ=p6(),OO=YJ(),[AO,w7]=b2(WZ),[ru,BZ]=b2(WZ),wO=($)=>{let{__scopeMenu:J,open:Q=!1,children:Z,dir:q,onOpenChange:X,modal:Y=!0}=$,z=HZ(J),[K,W]=q1.useState(null),H=q1.useRef(!1),B=d5(X),U=l9(q);return q1.useEffect(()=>{let _=()=>{H.current=!0,document.addEventListener("pointerdown",L,{capture:!0,once:!0}),document.addEventListener("pointermove",L,{capture:!0,once:!0})},L=()=>H.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",L,{capture:!0}),document.removeEventListener("pointermove",L,{capture:!0})}},[]),G(I4,{...z,children:G(AO,{scope:J,open:Q,onOpenChange:B,content:K,onContentChange:W,children:G(ru,{scope:J,onClose:q1.useCallback(()=>B(!1),[B]),isUsingKeyboardRef:H,dir:U,modal:Y,children:Z})})})};wO.displayName=WZ;var su="MenuAnchor",F3=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,...Z}=$,q=HZ(Q);return G(T4,{...q,...Z,ref:J})});F3.displayName=su;var V3="MenuPortal",[ou,kO]=b2(V3,{forceMount:void 0}),IO=($)=>{let{__scopeMenu:J,forceMount:Q,children:Z,container:q}=$,X=w7(V3,J);return G(ou,{scope:J,forceMount:Q,children:G(qJ,{present:Q||X.open,children:G(T9,{asChild:!0,container:q,children:Z})})})};IO.displayName=V3;var o6="MenuContent",[nu,M3]=b2(o6),TO=q1.forwardRef(($,J)=>{let Q=kO(o6,$.__scopeMenu),{forceMount:Z=Q.forceMount,...q}=$,X=w7(o6,$.__scopeMenu),Y=BZ(o6,$.__scopeMenu);return G(KZ.Provider,{scope:$.__scopeMenu,children:G(qJ,{present:Z||X.open,children:G(KZ.Slot,{scope:$.__scopeMenu,children:Y.modal?G(au,{...q,ref:J}):G(tu,{...q,ref:J})})})})}),au=q1.forwardRef(($,J)=>{let Q=w7(o6,$.__scopeMenu),Z=q1.useRef(null),q=A7(J,Z);return q1.useEffect(()=>{let X=Z.current;if(X)return M7(X)},[]),G(D3,{...$,ref:q,trapFocus:Q.open,disableOutsidePointerEvents:Q.open,disableOutsideScroll:!0,onFocusOutside:R5($.onFocusOutside,(X)=>X.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>Q.onOpenChange(!1)})}),tu=q1.forwardRef(($,J)=>{let Q=w7(o6,$.__scopeMenu);return G(D3,{...$,ref:J,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>Q.onOpenChange(!1)})}),eu=YY("MenuContent.ScrollLock"),D3=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,loop:Z=!1,trapFocus:q,onOpenAutoFocus:X,onCloseAutoFocus:Y,disableOutsidePointerEvents:z,onEntryFocus:K,onEscapeKeyDown:W,onPointerDownOutside:H,onFocusOutside:B,onInteractOutside:U,onDismiss:_,disableOutsideScroll:L,...F}=$,V=w7(o6,Q),M=BZ(o6,Q),D=HZ(Q),N=OO(Q),O=lu(Q),[I,A]=q1.useState(null),b=q1.useRef(null),k=A7(J,b,V.onContentChange),w=q1.useRef(0),C=q1.useRef(""),y=q1.useRef(0),f=q1.useRef(null),j=q1.useRef("right"),P=q1.useRef(0),x=L?b4:q1.Fragment,p=L?{as:eu,allowPinchZoom:!0}:void 0,t=(r)=>{let $0=C.current+r,Y0=O().filter((c)=>!c.disabled),e=document.activeElement,H0=Y0.find((c)=>c.ref.current===e)?.textValue,K0=Y0.map((c)=>c.textValue),E=Hm(K0,$0,H0),m=Y0.find((c)=>c.textValue===E)?.ref.current;if(function c(i){if(C.current=i,window.clearTimeout(w.current),i!=="")w.current=window.setTimeout(()=>c(""),1000)}($0),m)setTimeout(()=>m.focus())};q1.useEffect(()=>{return()=>window.clearTimeout(w.current)},[]),B7();let h=q1.useCallback((r)=>{return j.current===f.current?.side&&Um(r,f.current?.area)},[]);return G(nu,{scope:Q,searchRef:C,onItemEnter:q1.useCallback((r)=>{if(h(r))r.preventDefault()},[h]),onItemLeave:q1.useCallback((r)=>{if(h(r))return;b.current?.focus(),A(null)},[h]),onTriggerLeave:q1.useCallback((r)=>{if(h(r))r.preventDefault()},[h]),pointerGraceTimerRef:y,onPointerGraceIntentChange:q1.useCallback((r)=>{f.current=r},[]),children:G(x,{...p,children:G(w4,{asChild:!0,trapped:q,onMountAutoFocus:R5(X,(r)=>{r.preventDefault(),b.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:Y,children:G(w9,{asChild:!0,disableOutsidePointerEvents:z,onEscapeKeyDown:W,onPointerDownOutside:H,onFocusOutside:B,onInteractOutside:U,onDismiss:_,children:G(KY,{asChild:!0,...N,dir:M.dir,orientation:"vertical",loop:Z,currentTabStopId:I,onCurrentTabStopIdChange:A,onEntryFocus:R5(K,(r)=>{if(!M.isUsingKeyboardRef.current)r.preventDefault()}),preventScrollOnEntryFocus:!0,children:G(F7,{role:"menu","aria-orientation":"vertical","data-state":dO(V.open),"data-radix-menu-content":"",dir:M.dir,...D,...F,ref:k,style:{outline:"none",...F.style},onKeyDown:R5(F.onKeyDown,(r)=>{let Y0=r.target.closest("[data-radix-menu-content]")===r.currentTarget,e=r.ctrlKey||r.altKey||r.metaKey,H0=r.key.length===1;if(Y0){if(r.key==="Tab")r.preventDefault();if(!e&&H0)t(r.key)}let K0=b.current;if(r.target!==K0)return;if(!cu.includes(r.key))return;r.preventDefault();let m=O().filter((c)=>!c.disabled).map((c)=>c.ref.current);if(NO.includes(r.key))m.reverse();Gm(m)}),onBlur:R5($.onBlur,(r)=>{if(!r.currentTarget.contains(r.target))window.clearTimeout(w.current),C.current=""}),onPointerMove:R5($.onPointerMove,GZ((r)=>{let $0=r.target,Y0=P.current!==r.clientX;if(r.currentTarget.contains($0)&&Y0){let e=r.clientX>P.current?"right":"left";j.current=e,P.current=r.clientX}}))})})})})})})});TO.displayName=o6;var $m="MenuGroup",N3=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,...Z}=$;return G(XJ.div,{role:"group",...Z,ref:J})});N3.displayName=$m;var Jm="MenuLabel",bO=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,...Z}=$;return G(XJ.div,{...Z,ref:J})});bO.displayName=Jm;var WY="MenuItem",DO="menu.itemSelect",BY=q1.forwardRef(($,J)=>{let{disabled:Q=!1,onSelect:Z,...q}=$,X=q1.useRef(null),Y=BZ(WY,$.__scopeMenu),z=M3(WY,$.__scopeMenu),K=A7(J,X),W=q1.useRef(!1),H=()=>{let B=X.current;if(!Q&&B){let U=new CustomEvent(DO,{bubbles:!0,cancelable:!0});if(B.addEventListener(DO,(_)=>Z?.(_),{once:!0}),XO(B,U),U.defaultPrevented)W.current=!1;else Y.onClose()}};return G(jO,{...q,ref:K,disabled:Q,onClick:R5($.onClick,H),onPointerDown:(B)=>{$.onPointerDown?.(B),W.current=!0},onPointerUp:R5($.onPointerUp,(B)=>{if(!W.current)B.currentTarget?.click()}),onKeyDown:R5($.onKeyDown,(B)=>{let U=z.searchRef.current!=="";if(Q||U&&B.key===" ")return;if(_3.includes(B.key))B.currentTarget.click(),B.preventDefault()})})});BY.displayName=WY;var jO=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,disabled:Z=!1,textValue:q,...X}=$,Y=M3(WY,Q),z=OO(Q),K=q1.useRef(null),W=A7(J,K),[H,B]=q1.useState(!1),[U,_]=q1.useState("");return q1.useEffect(()=>{let L=K.current;if(L)_((L.textContent??"").trim())},[X.children]),G(KZ.ItemSlot,{scope:Q,disabled:Z,textValue:q??U,children:G(GY,{asChild:!0,...z,focusable:!Z,children:G(XJ.div,{role:"menuitem","data-highlighted":H?"":void 0,"aria-disabled":Z||void 0,"data-disabled":Z?"":void 0,...X,ref:W,onPointerMove:R5($.onPointerMove,GZ((L)=>{if(Z)Y.onItemLeave(L);else if(Y.onItemEnter(L),!L.defaultPrevented)L.currentTarget.focus({preventScroll:!0})})),onPointerLeave:R5($.onPointerLeave,GZ((L)=>Y.onItemLeave(L))),onFocus:R5($.onFocus,()=>B(!0)),onBlur:R5($.onBlur,()=>B(!1))})})})}),Qm="MenuCheckboxItem",EO=q1.forwardRef(($,J)=>{let{checked:Q=!1,onCheckedChange:Z,...q}=$;return G(SO,{scope:$.__scopeMenu,checked:Q,children:G(BY,{role:"menuitemcheckbox","aria-checked":HY(Q)?"mixed":Q,...q,ref:J,"data-state":w3(Q),onSelect:R5(q.onSelect,()=>Z?.(HY(Q)?!0:!Q),{checkForDefaultPrevented:!1})})})});EO.displayName=Qm;var yO="MenuRadioGroup",[Zm,qm]=b2(yO,{value:void 0,onValueChange:()=>{}}),PO=q1.forwardRef(($,J)=>{let{value:Q,onValueChange:Z,...q}=$,X=d5(Z);return G(Zm,{scope:$.__scopeMenu,value:Q,onValueChange:X,children:G(N3,{...q,ref:J})})});PO.displayName=yO;var RO="MenuRadioItem",CO=q1.forwardRef(($,J)=>{let{value:Q,...Z}=$,q=qm(RO,$.__scopeMenu),X=Q===q.value;return G(SO,{scope:$.__scopeMenu,checked:X,children:G(BY,{role:"menuitemradio","aria-checked":X,...Z,ref:J,"data-state":w3(X),onSelect:R5(Z.onSelect,()=>q.onValueChange?.(Q),{checkForDefaultPrevented:!1})})})});CO.displayName=RO;var O3="MenuItemIndicator",[SO,Xm]=b2(O3,{checked:!1}),hO=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,forceMount:Z,...q}=$,X=Xm(O3,Q);return G(qJ,{present:Z||HY(X.checked)||X.checked===!0,children:G(XJ.span,{...q,ref:J,"data-state":w3(X.checked)})})});hO.displayName=O3;var Ym="MenuSeparator",xO=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,...Z}=$;return G(XJ.div,{role:"separator","aria-orientation":"horizontal",...Z,ref:J})});xO.displayName=Ym;var zm="MenuArrow",fO=q1.forwardRef(($,J)=>{let{__scopeMenu:Q,...Z}=$,q=HZ(Q);return G(V7,{...q,...Z,ref:J})});fO.displayName=zm;var A3="MenuSub",[Km,vO]=b2(A3),gO=($)=>{let{__scopeMenu:J,children:Q,open:Z=!1,onOpenChange:q}=$,X=w7(A3,J),Y=HZ(J),[z,K]=q1.useState(null),[W,H]=q1.useState(null),B=d5(q);return q1.useEffect(()=>{if(X.open===!1)B(!1);return()=>B(!1)},[X.open,B]),G(I4,{...Y,children:G(AO,{scope:J,open:Z,onOpenChange:B,content:W,onContentChange:H,children:G(Km,{scope:J,contentId:t5(),triggerId:t5(),trigger:z,onTriggerChange:K,children:Q})})})};gO.displayName=A3;var zZ="MenuSubTrigger",uO=q1.forwardRef(($,J)=>{let Q=w7(zZ,$.__scopeMenu),Z=BZ(zZ,$.__scopeMenu),q=vO(zZ,$.__scopeMenu),X=M3(zZ,$.__scopeMenu),Y=q1.useRef(null),{pointerGraceTimerRef:z,onPointerGraceIntentChange:K}=X,W={__scopeMenu:$.__scopeMenu},H=q1.useCallback(()=>{if(Y.current)window.clearTimeout(Y.current);Y.current=null},[]);return q1.useEffect(()=>H,[H]),q1.useEffect(()=>{let B=z.current;return()=>{window.clearTimeout(B),K(null)}},[z,K]),G(F3,{asChild:!0,...W,children:G(jO,{id:q.triggerId,"aria-haspopup":"menu","aria-expanded":Q.open,"aria-controls":q.contentId,"data-state":dO(Q.open),...$,ref:XZ(J,q.onTriggerChange),onClick:(B)=>{if($.onClick?.(B),$.disabled||B.defaultPrevented)return;if(B.currentTarget.focus(),!Q.open)Q.onOpenChange(!0)},onPointerMove:R5($.onPointerMove,GZ((B)=>{if(X.onItemEnter(B),B.defaultPrevented)return;if(!$.disabled&&!Q.open&&!Y.current)X.onPointerGraceIntentChange(null),Y.current=window.setTimeout(()=>{Q.onOpenChange(!0),H()},100)})),onPointerLeave:R5($.onPointerLeave,GZ((B)=>{H();let U=Q.content?.getBoundingClientRect();if(U){let _=Q.content?.dataset.side,L=_==="right",F=L?-5:5,V=U[L?"left":"right"],M=U[L?"right":"left"];X.onPointerGraceIntentChange({area:[{x:B.clientX+F,y:B.clientY},{x:V,y:U.top},{x:M,y:U.top},{x:M,y:U.bottom},{x:V,y:U.bottom}],side:_}),window.clearTimeout(z.current),z.current=window.setTimeout(()=>X.onPointerGraceIntentChange(null),300)}else{if(X.onTriggerLeave(B),B.defaultPrevented)return;X.onPointerGraceIntentChange(null)}})),onKeyDown:R5($.onKeyDown,(B)=>{let U=X.searchRef.current!=="";if($.disabled||U&&B.key===" ")return;if(du[Z.dir].includes(B.key))Q.onOpenChange(!0),Q.content?.focus(),B.preventDefault()})})})});uO.displayName=zZ;var mO="MenuSubContent",cO=q1.forwardRef(($,J)=>{let Q=kO(o6,$.__scopeMenu),{forceMount:Z=Q.forceMount,...q}=$,X=w7(o6,$.__scopeMenu),Y=BZ(o6,$.__scopeMenu),z=vO(mO,$.__scopeMenu),K=q1.useRef(null),W=A7(J,K);return G(KZ.Provider,{scope:$.__scopeMenu,children:G(qJ,{present:Z||X.open,children:G(KZ.Slot,{scope:$.__scopeMenu,children:G(D3,{id:z.contentId,"aria-labelledby":z.triggerId,...q,ref:W,align:"start",side:Y.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:(H)=>{if(Y.isUsingKeyboardRef.current)K.current?.focus();H.preventDefault()},onCloseAutoFocus:(H)=>H.preventDefault(),onFocusOutside:R5($.onFocusOutside,(H)=>{if(H.target!==z.trigger)X.onOpenChange(!1)}),onEscapeKeyDown:R5($.onEscapeKeyDown,(H)=>{Y.onClose(),H.preventDefault()}),onKeyDown:R5($.onKeyDown,(H)=>{let B=H.currentTarget.contains(H.target),U=pu[Y.dir].includes(H.key);if(B&&U)X.onOpenChange(!1),z.trigger?.focus(),H.preventDefault()})})})})})});cO.displayName=mO;function dO($){return $?"open":"closed"}function HY($){return $==="indeterminate"}function w3($){return HY($)?"indeterminate":$?"checked":"unchecked"}function Gm($){let J=document.activeElement;for(let Q of $){if(Q===J)return;if(Q.focus(),document.activeElement!==J)return}}function Wm($,J){return $.map((Q,Z)=>$[(J+Z)%$.length])}function Hm($,J,Q){let q=J.length>1&&Array.from(J).every((W)=>W===J[0])?J[0]:J,X=Q?$.indexOf(Q):-1,Y=Wm($,Math.max(X,0));if(q.length===1)Y=Y.filter((W)=>W!==Q);let K=Y.find((W)=>W.toLowerCase().startsWith(q.toLowerCase()));return K!==Q?K:void 0}function Bm($,J){let{x:Q,y:Z}=$,q=!1;for(let X=0,Y=J.length-1;X<J.length;Y=X++){let z=J[X],K=J[Y],W=z.x,H=z.y,B=K.x,U=K.y;if(H>Z!==U>Z&&Q<(B-W)*(Z-H)/(U-H)+W)q=!q}return q}function Um($,J){if(!J)return!1;let Q={x:$.clientX,y:$.clientY};return Bm(Q,J)}function GZ($){return(J)=>J.pointerType==="mouse"?$(J):void 0}var pO=wO,lO=F3,iO=IO,rO=TO,sO=N3,oO=bO,nO=BY,aO=EO,tO=PO,eO=CO,$A=hO,JA=xO,QA=fO,ZA=gO,qA=uO,XA=cO;var n6=R(v(),1);var UY=R(v(),1);var Lm=n6[" useInsertionEffect ".trim().toString()]||_1;function YA({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=Fm({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=n6.useRef($!==void 0);n6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=n6.useCallback((H)=>{if(z){let B=Vm(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function Fm({defaultProp:$,onChange:J}){let[Q,Z]=n6.useState($),q=n6.useRef(Q),X=n6.useRef(J);return Lm(()=>{X.current=J},[J]),n6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function Vm($){return typeof $==="function"}var h40=Symbol("RADIX:SYNC_STATE");var k3="ContextMenu",[Mm,p40]=rN(k3,[L3]),g8=L3(),[Dm,zA]=Mm(k3),KA=($)=>{let{__scopeContextMenu:J,children:Q,onOpenChange:Z,dir:q,modal:X=!0}=$,[Y,z]=B5.useState(!1),K=g8(J),W=d5(Z),H=B5.useCallback((B)=>{z(B),W(B)},[W]);return G(Dm,{scope:J,open:Y,onOpenChange:H,modal:X,children:G(pO,{...K,dir:q,open:Y,onOpenChange:H,modal:X,children:Q})})};KA.displayName=k3;var GA="ContextMenuTrigger",WA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,disabled:Z=!1,...q}=$,X=zA(GA,Q),Y=g8(Q),z=B5.useRef({x:0,y:0}),K=B5.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...z.current})}),W=B5.useRef(0),H=B5.useCallback(()=>window.clearTimeout(W.current),[]),B=(U)=>{z.current={x:U.clientX,y:U.clientY},X.onOpenChange(!0)};return B5.useEffect(()=>H,[H]),B5.useEffect(()=>void(Z&&H()),[Z,H]),T(G1,{children:[G(lO,{...Y,virtualRef:K}),G(tN.span,{"data-state":X.open?"open":"closed","data-disabled":Z?"":void 0,...q,ref:J,style:{WebkitTouchCallout:"none",...$.style},onContextMenu:Z?$.onContextMenu:ZJ($.onContextMenu,(U)=>{H(),B(U),U.preventDefault()}),onPointerDown:Z?$.onPointerDown:ZJ($.onPointerDown,_Y((U)=>{H(),W.current=window.setTimeout(()=>B(U),700)})),onPointerMove:Z?$.onPointerMove:ZJ($.onPointerMove,_Y(H)),onPointerCancel:Z?$.onPointerCancel:ZJ($.onPointerCancel,_Y(H)),onPointerUp:Z?$.onPointerUp:ZJ($.onPointerUp,_Y(H))})]})});WA.displayName=GA;var Nm="ContextMenuPortal",HA=($)=>{let{__scopeContextMenu:J,...Q}=$,Z=g8(J);return G(iO,{...Z,...Q})};HA.displayName=Nm;var BA="ContextMenuContent",UA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=zA(BA,Q),X=g8(Q),Y=B5.useRef(!1);return G(rO,{...X,...Z,ref:J,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:(z)=>{if($.onCloseAutoFocus?.(z),!z.defaultPrevented&&Y.current)z.preventDefault();Y.current=!1},onInteractOutside:(z)=>{if($.onInteractOutside?.(z),!z.defaultPrevented&&!q.modal)Y.current=!0},style:{...$.style,...{"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}})});UA.displayName=BA;var Om="ContextMenuGroup",Am=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(sO,{...q,...Z,ref:J})});Am.displayName=Om;var wm="ContextMenuLabel",_A=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(oO,{...q,...Z,ref:J})});_A.displayName=wm;var km="ContextMenuItem",LA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(nO,{...q,...Z,ref:J})});LA.displayName=km;var Im="ContextMenuCheckboxItem",FA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(aO,{...q,...Z,ref:J})});FA.displayName=Im;var Tm="ContextMenuRadioGroup",bm=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(tO,{...q,...Z,ref:J})});bm.displayName=Tm;var jm="ContextMenuRadioItem",VA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(eO,{...q,...Z,ref:J})});VA.displayName=jm;var Em="ContextMenuItemIndicator",MA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G($A,{...q,...Z,ref:J})});MA.displayName=Em;var ym="ContextMenuSeparator",DA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(JA,{...q,...Z,ref:J})});DA.displayName=ym;var Pm="ContextMenuArrow",Rm=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(QA,{...q,...Z,ref:J})});Rm.displayName=Pm;var NA="ContextMenuSub",OA=($)=>{let{__scopeContextMenu:J,children:Q,onOpenChange:Z,open:q,defaultOpen:X}=$,Y=g8(J),[z,K]=YA({prop:q,defaultProp:X??!1,onChange:Z,caller:NA});return G(ZA,{...Y,open:z,onOpenChange:K,children:Q})};OA.displayName=NA;var Cm="ContextMenuSubTrigger",AA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(qA,{...q,...Z,ref:J})});AA.displayName=Cm;var Sm="ContextMenuSubContent",wA=B5.forwardRef(($,J)=>{let{__scopeContextMenu:Q,...Z}=$,q=g8(Q);return G(XA,{...q,...Z,ref:J,style:{...$.style,...{"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}})});wA.displayName=Sm;function _Y($){return(J)=>J.pointerType!=="mouse"?$(J):void 0}var kA=KA,IA=WA,TA=HA,I3=UA;var T3=_A,b3=LA,j3=FA;var E3=VA,y3=MA,P3=DA;var bA=OA,R3=AA,C3=wA;var a6=kA,t6=IA;var EA=bA;var S3=h4.forwardRef(({className:$,inset:J,children:Q,...Z},q)=>T(R3,{ref:q,className:b0("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm text-popover-foreground outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",J&&"pl-8",$),...Z,children:[Q,G(LY,{className:"ml-auto h-4 w-4"})]}));S3.displayName=R3.displayName;var h3=h4.forwardRef(({className:$,...J},Q)=>G(C3,{ref:Q,className:b0("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",$),...J}));h3.displayName=C3.displayName;var y6=h4.forwardRef(({className:$,...J},Q)=>G(TA,{children:T("div",{className:`${D8}`,children:[G("div",{"aria-hidden":"true","data-easy-media-context-menu-backdrop":"",className:"fixed inset-0 z-[9997]"}),G(I3,{ref:Q,className:b0("z-[9999] max-h-[--radix-context-menu-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",$),...J})]})}));y6.displayName=I3.displayName;var Q5=h4.forwardRef(({className:$,inset:J,...Q},Z)=>G(b3,{ref:Z,className:b0("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",J&&"pl-8",$),...Q}));Q5.displayName=b3.displayName;var xm=h4.forwardRef(({className:$,children:J,checked:Q,...Z},q)=>T(j3,{ref:q,className:b0("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",$),checked:Q,...Z,children:[G("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:G(y3,{children:G(j9,{className:"h-4 w-4"})})}),J]}));xm.displayName=j3.displayName;var fm=h4.forwardRef(({className:$,children:J,...Q},Z)=>T(E3,{ref:Z,className:b0("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",$),...Q,children:[G("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:G(y3,{children:G(jA,{className:"h-4 w-4 fill-current"})})}),J]}));fm.displayName=E3.displayName;var vm=h4.forwardRef(({className:$,inset:J,...Q},Z)=>G(T3,{ref:Z,className:b0("px-2 py-1.5 text-sm font-semibold text-foreground",J&&"pl-8",$),...Q}));vm.displayName=T3.displayName;var x3=h4.forwardRef(({className:$,...J},Q)=>G(P3,{ref:Q,className:b0("-mx-1 my-1 h-px bg-border",$),...J}));x3.displayName=P3.displayName;var gm=({className:$,...J})=>{return G("span",{className:b0("ml-auto text-xs tracking-widest text-muted-foreground",$),...J})};gm.displayName="ContextMenuShortcut";var aA=R(v(),1);var O5=R(v(),1);var t40=!!(typeof window<"u"&&window.document&&window.document.createElement);function zJ($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var PA=R(v(),1);function yA($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function f3(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=yA(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else yA($[q],null)}}}}function UZ(...$){return PA.useCallback(f3(...$),$)}var x4=R(v(),1);function RA($,J=[]){let Q=[];function Z(X,Y){let z=x4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=x4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=x4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return x4.createContext(Y)});return function(z){let K=z?.[$]||X;return x4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,um(q,...J)]}function um(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return x4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var U6=R(v(),1);var CA=R(v(),1);function mm($,J){return CA.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}var VY=($)=>{let{present:J,children:Q}=$,Z=cm(J),q=typeof Q==="function"?Q({present:Z.isPresent}):U6.Children.only(Q),X=UZ(Z.ref,dm(q));return typeof Q==="function"||Z.isPresent?U6.cloneElement(q,{ref:X}):null};VY.displayName="Presence";function cm($){let[J,Q]=U6.useState(),Z=U6.useRef(null),q=U6.useRef($),X=U6.useRef("none"),Y=$?"mounted":"unmounted",[z,K]=mm(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return U6.useEffect(()=>{let W=FY(Z.current);X.current=z==="mounted"?W:"none"},[z]),_1(()=>{let W=Z.current,H=q.current;if(H!==$){let U=X.current,_=FY(W);if($)K("MOUNT");else if(_==="none"||W?.display==="none")K("UNMOUNT");else if(H&&U!==_)K("ANIMATION_OUT");else K("UNMOUNT");q.current=$}},[$,K]),_1(()=>{if(J){let W,H=J.ownerDocument.defaultView??window,B=(_)=>{let F=FY(Z.current).includes(CSS.escape(_.animationName));if(_.target===J&&F){if(K("ANIMATION_END"),!q.current){let V=J.style.animationFillMode;J.style.animationFillMode="forwards",W=H.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=V})}}},U=(_)=>{if(_.target===J)X.current=FY(Z.current)};return J.addEventListener("animationstart",U),J.addEventListener("animationcancel",B),J.addEventListener("animationend",B),()=>{H.clearTimeout(W),J.removeEventListener("animationstart",U),J.removeEventListener("animationcancel",B),J.removeEventListener("animationend",B)}}else K("ANIMATION_END")},[J,K]),{isPresent:["mounted","unmountSuspended"].includes(z),ref:U6.useCallback((W)=>{Z.current=W?getComputedStyle(W):null,Q(W)},[])}}function FY($){return $?.animationName||"none"}function dm($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var SA=R(v(),1),om=R(J5(),1);var G8=R(v(),1);function MY($){let J=pm($),Q=G8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=G8.Children.toArray(X),K=z.find(im);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(G8.Children.count(W)>1)return G8.Children.only(null);return G8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:G8.isValidElement(W)?G8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function pm($){let J=G8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(G8.isValidElement(q)){let Y=sm(q),z=rm(X,q.props);if(q.type!==G8.Fragment)z.ref=Z?f3(Z,Y):Y;return G8.cloneElement(q,z)}return G8.Children.count(q)>1?G8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var lm=Symbol("radix.slottable");function im($){return G8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===lm}function rm($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function sm($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var nm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v3=nm.reduce(($,J)=>{let Q=MY(`Primitive.${J}`),Z=SA.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var e6=R(v(),1);var DY=R(v(),1);var am=e6[" useInsertionEffect ".trim().toString()]||_1;function hA({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=tm({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=e6.useRef($!==void 0);e6.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=e6.useCallback((H)=>{if(z){let B=em(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function tm({defaultProp:$,onChange:J}){let[Q,Z]=e6.useState($),q=e6.useRef(Q),X=e6.useRef(J);return am(()=>{X.current=J},[J]),e6.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function em($){return typeof $==="function"}var U70=Symbol("RADIX:SYNC_STATE");var NY="Popover",[xA,P70]=RA(NY,[p6]),_Z=p6(),[$c,k7]=xA(NY),fA=($)=>{let{__scopePopover:J,children:Q,open:Z,defaultOpen:q,onOpenChange:X,modal:Y=!1}=$,z=_Z(J),K=O5.useRef(null),[W,H]=O5.useState(!1),[B,U]=hA({prop:Z,defaultProp:q??!1,onChange:X,caller:NY});return G(I4,{...z,children:G($c,{scope:J,contentId:t5(),triggerRef:K,open:B,onOpenChange:U,onOpenToggle:O5.useCallback(()=>U((_)=>!_),[U]),hasCustomAnchor:W,onCustomAnchorAdd:O5.useCallback(()=>H(!0),[]),onCustomAnchorRemove:O5.useCallback(()=>H(!1),[]),modal:Y,children:Q})})};fA.displayName=NY;var vA="PopoverAnchor",gA=O5.forwardRef(($,J)=>{let{__scopePopover:Q,...Z}=$,q=k7(vA,Q),X=_Z(Q),{onCustomAnchorAdd:Y,onCustomAnchorRemove:z}=q;return O5.useEffect(()=>{return Y(),()=>z()},[Y,z]),G(T4,{...X,...Z,ref:J})});gA.displayName=vA;var uA="PopoverTrigger",mA=O5.forwardRef(($,J)=>{let{__scopePopover:Q,...Z}=$,q=k7(uA,Q),X=_Z(Q),Y=UZ(J,q.triggerRef),z=G(v3.button,{type:"button","aria-haspopup":"dialog","aria-expanded":q.open,"aria-controls":q.contentId,"data-state":iA(q.open),...Z,ref:Y,onClick:zJ($.onClick,q.onOpenToggle)});return q.hasCustomAnchor?z:G(T4,{asChild:!0,...X,children:z})});mA.displayName=uA;var g3="PopoverPortal",[Jc,Qc]=xA(g3,{forceMount:void 0}),cA=($)=>{let{__scopePopover:J,forceMount:Q,children:Z,container:q}=$,X=k7(g3,J);return G(Jc,{scope:J,forceMount:Q,children:G(VY,{present:Q||X.open,children:G(T9,{asChild:!0,container:q,children:Z})})})};cA.displayName=g3;var KJ="PopoverContent",dA=O5.forwardRef(($,J)=>{let Q=Qc(KJ,$.__scopePopover),{forceMount:Z=Q.forceMount,...q}=$,X=k7(KJ,$.__scopePopover);return G(VY,{present:Z||X.open,children:X.modal?G(qc,{...q,ref:J}):G(Xc,{...q,ref:J})})});dA.displayName=KJ;var Zc=MY("PopoverContent.RemoveScroll"),qc=O5.forwardRef(($,J)=>{let Q=k7(KJ,$.__scopePopover),Z=O5.useRef(null),q=UZ(J,Z),X=O5.useRef(!1);return O5.useEffect(()=>{let Y=Z.current;if(Y)return M7(Y)},[]),G(b4,{as:Zc,allowPinchZoom:!0,children:G(pA,{...$,ref:q,trapFocus:Q.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zJ($.onCloseAutoFocus,(Y)=>{if(Y.preventDefault(),!X.current)Q.triggerRef.current?.focus()}),onPointerDownOutside:zJ($.onPointerDownOutside,(Y)=>{let z=Y.detail.originalEvent,K=z.button===0&&z.ctrlKey===!0,W=z.button===2||K;X.current=W},{checkForDefaultPrevented:!1}),onFocusOutside:zJ($.onFocusOutside,(Y)=>Y.preventDefault(),{checkForDefaultPrevented:!1})})})}),Xc=O5.forwardRef(($,J)=>{let Q=k7(KJ,$.__scopePopover),Z=O5.useRef(!1),q=O5.useRef(!1);return G(pA,{...$,ref:J,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:(X)=>{if($.onCloseAutoFocus?.(X),!X.defaultPrevented){if(!Z.current)Q.triggerRef.current?.focus();X.preventDefault()}Z.current=!1,q.current=!1},onInteractOutside:(X)=>{if($.onInteractOutside?.(X),!X.defaultPrevented){if(Z.current=!0,X.detail.originalEvent.type==="pointerdown")q.current=!0}let Y=X.target;if(Q.triggerRef.current?.contains(Y))X.preventDefault();if(X.detail.originalEvent.type==="focusin"&&q.current)X.preventDefault()}})}),pA=O5.forwardRef(($,J)=>{let{__scopePopover:Q,trapFocus:Z,onOpenAutoFocus:q,onCloseAutoFocus:X,disableOutsidePointerEvents:Y,onEscapeKeyDown:z,onPointerDownOutside:K,onFocusOutside:W,onInteractOutside:H,...B}=$,U=k7(KJ,Q),_=_Z(Q);return B7(),G(w4,{asChild:!0,loop:!0,trapped:Z,onMountAutoFocus:q,onUnmountAutoFocus:X,children:G(w9,{asChild:!0,disableOutsidePointerEvents:Y,onInteractOutside:H,onEscapeKeyDown:z,onPointerDownOutside:K,onFocusOutside:W,onDismiss:()=>U.onOpenChange(!1),children:G(F7,{"data-state":iA(U.open),role:"dialog",id:U.contentId,..._,...B,ref:J,style:{...B.style,...{"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}})})})}),lA="PopoverClose",Yc=O5.forwardRef(($,J)=>{let{__scopePopover:Q,...Z}=$,q=k7(lA,Q);return G(v3.button,{type:"button",...Z,ref:J,onClick:zJ($.onClick,()=>q.onOpenChange(!1))})});Yc.displayName=lA;var zc="PopoverArrow",Kc=O5.forwardRef(($,J)=>{let{__scopePopover:Q,...Z}=$,q=_Z(Q);return G(V7,{...q,...Z,ref:J})});Kc.displayName=zc;function iA($){return $?"open":"closed"}var rA=fA,sA=gA,oA=mA,nA=cA,u3=dA;var t1=rA,b5=oA,_6=sA,o1=aA.forwardRef(({className:$,align:J="center",sideOffset:Q=4,...Z},q)=>G(nA,{children:G("div",{className:`${D8}`,children:G(u3,{ref:q,align:J,sideOffset:Q,className:b0("z-[9999] w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",$),...Z})})}));o1.displayName=u3.displayName;var n1=R(v(),1);var tA=R(v(),1);var $6=tA.forwardRef(({className:$,type:J,...Q},Z)=>{return G("input",{type:J,className:b0("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",$),ref:Z,...Q})});$6.displayName="Input";var Sw=R(v(),1);var r5=R(v(),1);var eA=R(v(),1),Wc=Object.defineProperty,c3=($,J)=>Wc($,"name",{value:J,configurable:!0});function m3($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}c3(m3,"setRef");function $w(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=m3(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else m3($[q],null)}}}}c3($w,"composeRefs");function GJ(...$){return eA.useCallback($w(...$),$)}c3(GJ,"useComposedRefs");var J9=R(v(),1);var Hc=Object.defineProperty,$9=($,J)=>Hc($,"name",{value:J,configurable:!0});function Bc($,J){let Q=J9.createContext(J);Q.displayName=$+"Context";let Z=$9((X)=>{let{children:Y,...z}=X,K=J9.useMemo(()=>z,Object.values(z));return G(Q.Provider,{value:K,children:Y})},"Provider");Z.displayName=$+"Provider";function q(X,Y={}){let{optional:z=!1}=Y,K=J9.useContext(Q);if(K)return K;if(J!==void 0)return J;if(z)return;throw Error(`\`${X}\` must be used within \`${$}\``)}return $9(q,"useContext"),[Z,q]}$9(Bc,"createContext");function d3($,J=[]){let Q=[];function Z(X,Y){let z=J9.createContext(Y);z.displayName=X+"Context";let K=Q.length;Q=[...Q,Y];let W=$9((B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=J9.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})},"Provider");W.displayName=X+"Provider";function H(B,U,_={}){let{optional:L=!1}=_,F=U?.[$]?.[K]||z,V=J9.useContext(F);if(V)return V;if(Y!==void 0)return Y;if(L)return;throw Error(`\`${B}\` must be used within \`${X}\``)}return $9(H,"useContext"),[W,H]}$9(Z,"createContext");let q=$9(()=>{let X=Q.map((Y)=>{return J9.createContext(Y)});return $9(function(z){let K=z?.[$]||X;return J9.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])},"useScope")},"createScope");return q.scopeName=$,[Z,Jw(q,...J)]}$9(d3,"createContextScope");function Jw(...$){let J=$[0];if($.length===1)return J;let Q=$9(()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return $9(function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return J9.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])},"useComposedScopes")},"createScope");return Q.scopeName=J.scopeName,Q}$9(Jw,"composeContextScopes");var Uc=Object.defineProperty,WJ=($,J)=>Uc($,"name",{value:J,configurable:!0}),Qw=!!(typeof window<"u"&&window.document&&window.document.createElement);function LZ($,J,{checkForDefaultPrevented:Q=!0}={}){return WJ(function(q){if($?.(q),Q===!1||!q||!q.defaultPrevented)return J?.(q)},"handleEvent")}WJ(LZ,"composeEventHandlers");function _c($){if(!Qw)throw Error("Cannot access window outside of the DOM");return $?.ownerDocument?.defaultView??window}WJ(_c,"getOwnerWindow");function p3($){if(!Qw)throw Error("Cannot access document outside of the DOM");return $?.ownerDocument??document}WJ(p3,"getOwnerDocument");function Zw($,J=!1){let{activeElement:Q}=p3($);if(!Q?.nodeName)return null;if(qw(Q)&&Q.contentDocument)return Zw(Q.contentDocument.body,J);if(J){let Z=Q.getAttribute("aria-activedescendant");if(Z){let q=p3(Q).getElementById(Z);if(q)return q}}return Q}WJ(Zw,"getActiveElement");function qw($){return $.tagName==="IFRAME"}WJ(qw,"isFrame");var Q9=R(v(),1);var OY=!1;var Xw=R(v(),1),Yw=globalThis?.document?Xw.useLayoutEffect:()=>{};var E9=R(v(),1);var zw=R(v(),1),Kw=globalThis?.document?zw.useLayoutEffect:()=>{};var HJ=R(v(),1),Lc=Object.defineProperty,Fc=($,J)=>Lc($,"name",{value:J,configurable:!0}),Gw=HJ[" useEffectEvent ".trim().toString()],Ww=HJ[" useInsertionEffect ".trim().toString()];function l3($){if(typeof Gw==="function")return Gw($);let J=HJ.useRef(()=>{throw Error("Cannot call an event handler while rendering.")});if(typeof Ww==="function")Ww(()=>{J.current=$});else Kw(()=>{J.current=$});return HJ.useMemo(()=>(...Q)=>J.current?.(...Q),[])}Fc(l3,"useEffectEvent");var Vc=Object.defineProperty,FZ=($,J)=>Vc($,"name",{value:J,configurable:!0}),Mc=Q9[" useInsertionEffect ".trim().toString()]||Yw;function i3({prop:$,defaultProp:J,onChange:Q=FZ(()=>{},"onChange"),caller:Z}){let[q,X,Y]=Bw({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;if(OY){let H=Q9.useRef($!==void 0);Q9.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=Q9.useCallback((H)=>{if(z){let B=Uw(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}FZ(i3,"useControllableState");function Bw({defaultProp:$,onChange:J}){let[Q,Z]=Q9.useState($),q=Q9.useRef(Q),X=Q9.useRef(J);return Mc(()=>{X.current=J},[J]),Q9.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}FZ(Bw,"useUncontrolledState");function Uw($){return typeof $==="function"}FZ(Uw,"isFunction");var Hw=Symbol("RADIX:SYNC_STATE");function Dc($,J,Q,Z){let{prop:q,defaultProp:X,onChange:Y,caller:z}=J,K=q!==void 0,W=l3(Y);if(OY){let V=E9.useRef(q!==void 0);E9.useEffect(()=>{let M=V.current;if(M!==K)console.warn(`${z} is changing from ${M?"controlled":"uncontrolled"} to ${K?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);V.current=K},[K,z])}let H=[{...Q,state:X}];if(Z)H.push(Z);let[B,U]=E9.useReducer((V,M)=>{if(M.type===Hw)return{...V,state:M.state};let D=$(V,M);if(K&&!Object.is(D.state,V.state))W(D.state);return D},...H),_=B.state,L=E9.useRef(_);E9.useEffect(()=>{if(L.current!==_){if(L.current=_,!K)W(_)}},[_,L,K]);let F=E9.useMemo(()=>{if(q!==void 0)return{...B,state:q};return B},[B,q]);return E9.useEffect(()=>{if(K&&!Object.is(q,B.state))U({type:Hw,state:q})},[q,B.state,K]),[F,U]}FZ(Dc,"useControllableStateReducer");var Fw=R(v(),1);var _w=R(v(),1),Lw=globalThis?.document?_w.useLayoutEffect:()=>{};var Nc=Object.defineProperty,Oc=($,J)=>Nc($,"name",{value:J,configurable:!0});function r3($){let[J,Q]=Fw.useState(void 0);return Lw(()=>{if($){Q({width:$.offsetWidth,height:$.offsetHeight});let Z=new ResizeObserver((q)=>{if(!Array.isArray(q))return;if(!q.length)return;let X=q[0],Y,z;if("borderBoxSize"in X){let K=X.borderBoxSize,W=Array.isArray(K)?K[0]:K;Y=W.inlineSize,z=W.blockSize}else Y=$.offsetWidth,z=$.offsetHeight;Q({width:Y,height:z})});return Z.observe($,{box:"border-box"}),()=>Z.unobserve($)}else Q(void 0)},[$]),J}Oc(r3,"useSize");var C8=R(v(),1);var Vw=R(v(),1),s3=globalThis?.document?Vw.useLayoutEffect:()=>{};var Mw=R(v(),1),Ac=Object.defineProperty,f4=($,J)=>Ac($,"name",{value:J,configurable:!0});function Dw($,J){return Mw.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}f4(Dw,"useStateMachine");var Nw=f4(($)=>{let{present:J,children:Q}=$,Z=Ow(J),q=typeof Q==="function"?Q({present:Z.isPresent}):C8.Children.only(Q),X=Aw(Z.ref,ww(q));return typeof Q==="function"||Z.isPresent?C8.cloneElement(q,{ref:X}):null},"Presence");function Ow($){let[J,Q]=C8.useState(),Z=C8.useRef(null),q=C8.useRef($),X=C8.useRef("none"),Y=C8.useRef(void 0),z=$?"mounted":"unmounted",[K,W]=Dw(z,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C8.useEffect(()=>{if(K==="mounted")X.current=Y.current??BJ(Z.current),Y.current=void 0;else X.current="none"},[K]),s3(()=>{let H=Z.current,B=q.current;if(B!==$){let _=X.current,L=BJ(H);if($)Y.current=L,W("MOUNT");else if(L==="none"||H?.display==="none")W("UNMOUNT");else if(B&&_!==L)W("ANIMATION_OUT");else W("UNMOUNT");q.current=$}},[$,W]),s3(()=>{if(J){let H,B=J.ownerDocument.defaultView??window,U=f4((L)=>{let V=BJ(Z.current).includes(CSS.escape(L.animationName));if(L.target===J&&V){if(W("ANIMATION_END"),!q.current){let M=J.style.animationFillMode;J.style.animationFillMode="forwards",H=B.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=M})}}},"handleAnimationEnd"),_=f4((L)=>{if(L.target===J)X.current=BJ(Z.current)},"handleAnimationStart");return J.addEventListener("animationstart",_),J.addEventListener("animationcancel",U),J.addEventListener("animationend",U),()=>{B.clearTimeout(H),J.removeEventListener("animationstart",_),J.removeEventListener("animationcancel",U),J.removeEventListener("animationend",U)}}else W("ANIMATION_END")},[J,W]),{isPresent:["mounted","unmountSuspended"].includes(K),ref:C8.useCallback((H)=>{if(H){let B=getComputedStyle(H);Z.current=B,Y.current=BJ(B)}else Z.current=null;Q(H)},[])}}f4(Ow,"usePresence");function o3($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}f4(o3,"setRef");function Aw(...$){let J=C8.useRef($);return J.current=$,C8.useCallback((Q)=>{let Z=J.current,q=!1,X=Z.map((Y)=>{let z=o3(Y,Q);if(!q&&typeof z==="function")q=!0;return z});if(q)return()=>{for(let Y=0;Y<X.length;Y++){let z=X[Y];if(typeof z==="function")z();else o3(Z[Y],null)}}},[])}f4(Aw,"useStableComposedRefs");function BJ($){return $?.animationName||"none"}f4(BJ,"getAnimationName");function ww($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}f4(ww,"getElementRef");var Ew=R(v(),1),yw=R(J5(),1);var S8=R(v(),1);var wc=Object.defineProperty,y9=($,J)=>wc($,"name",{value:J,configurable:!0});function a3($){let J=S8.forwardRef((Q,Z)=>{let{children:q,...X}=Q,Y=null,z=!1,K=[];if(n3(q)&&typeof AY==="function")q=AY(q._payload);if(S8.Children.forEach(q,(U)=>{if(bw(U)){z=!0;let _=U,L="child"in _.props?_.props.child:_.props.children;if(n3(L)&&typeof AY==="function")L=AY(L._payload);Y=Ic(_,L),K.push(Y?.props?.children)}else K.push(U)}),Y)Y=S8.cloneElement(Y,void 0,K);else if(!z&&S8.Children.count(q)===1&&S8.isValidElement(q))Y=q;let W=Y?Tw(Y):void 0,H=GJ(Z,W);if(!Y){if(q||q===0)throw Error(z?jc($):bc($));return q}let B=Iw(X,Y.props??{});if(Y.type!==S8.Fragment)B.ref=Z?H:W;return S8.cloneElement(Y,B)});return J.displayName=`${$}.Slot`,J}y9(a3,"createSlot");var kw=Symbol.for("radix.slottable");function kc($){let J=y9((Q)=>("child"in Q)?Q.children(Q.child):Q.children,"Slottable");return J.displayName=`${$}.Slottable`,J.__radixId=kw,J}y9(kc,"createSlottable");var Ic=y9(($,J)=>{if("child"in $.props){let Q=$.props.child;if(!S8.isValidElement(Q))return null;return S8.cloneElement(Q,void 0,$.props.children(Q.props.children))}return S8.isValidElement(J)?J:null},"getSlottableElementFromSlottable");function Iw($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}y9(Iw,"mergeProps");function Tw($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}y9(Tw,"getElementRef");function bw($){return S8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===kw}y9(bw,"isSlottable");var Tc=Symbol.for("react.lazy");function n3($){return $!=null&&typeof $==="object"&&"$$typeof"in $&&$.$$typeof===Tc&&"_payload"in $&&jw($._payload)}y9(n3,"isLazyComponent");function jw($){return typeof $==="object"&&$!==null&&"then"in $}y9(jw,"isPromiseLike");var bc=y9(($)=>{return`${$} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`},"createSlotError"),jc=y9(($)=>{return`${$} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`},"createSlottableError"),AY=S8[" use ".trim().toString()];var Ec=Object.defineProperty,yc=($,J)=>Ec($,"name",{value:J,configurable:!0}),Pc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wY=Pc.reduce(($,J)=>{let Q=a3(`Primitive.${J}`),Z=Ew.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});function Rc($,J){if($)yw.flushSync(()=>$.dispatchEvent(J))}yc(Rc,"dispatchDiscreteCustomEvent");var Cc=Object.defineProperty,g4=($,J)=>Cc($,"name",{value:J,configurable:!0}),t3="Checkbox",[Sc,M20]=d3(t3),[hc,e3]=Sc(t3);function Pw($){let{__scopeCheckbox:J,checked:Q,children:Z,defaultChecked:q,disabled:X,form:Y,name:z,onCheckedChange:K,required:W,value:H="on",internal_do_not_use_render:B}=$,[U,_]=i3({prop:Q,defaultProp:q??!1,onChange:K,caller:t3}),[L,F]=r5.useState(null),[V,M]=r5.useState(null),D=r5.useRef(!1),[N,O]=r5.useReducer((b)=>b+1,0),I=L?!!Y||!!L.closest("form"):!0,A={checked:U,disabled:X,setChecked:_,control:L,setControl:F,name:z,form:Y,value:H,hasConsumerStoppedPropagationRef:D,userInteractionCount:N,onUserInteraction:O,required:W,defaultChecked:v4(q)?!1:q,isFormControl:I,bubbleInput:V,setBubbleInput:M};return G(hc,{scope:J,...A,children:Cw(B)?B(A):Z})}g4(Pw,"CheckboxProvider");var xc="CheckboxTrigger",fc=r5.forwardRef(g4(function({__scopeCheckbox:J,onKeyDown:Q,onClick:Z,...q},X){let{control:Y,value:z,disabled:K,checked:W,required:H,setControl:B,setChecked:U,hasConsumerStoppedPropagationRef:_,onUserInteraction:L,isFormControl:F,bubbleInput:V}=e3(xc,J),M=GJ(X,B),D=r5.useRef(W);return r5.useEffect(()=>{let N=Y?.form;if(N){let O=g4(()=>U(D.current),"reset");return N.addEventListener("reset",O),()=>N.removeEventListener("reset",O)}},[Y,U]),G(wY.button,{type:"button",role:"checkbox","aria-checked":v4(W)?"mixed":W,"aria-required":H,"data-state":JB(W),"data-disabled":K?"":void 0,disabled:K,value:z,...q,ref:M,onKeyDown:LZ(Q,(N)=>{if(N.key==="Enter")N.preventDefault()}),onClick:LZ(Z,(N)=>{if(L(),U((O)=>v4(O)?!0:!O),V&&F){if(_.current=N.isPropagationStopped(),!_.current)N.stopPropagation()}})})},"CheckboxTrigger")),$B=r5.forwardRef(g4(function(J,Q){let{__scopeCheckbox:Z,name:q,checked:X,defaultChecked:Y,required:z,disabled:K,value:W,onCheckedChange:H,form:B,...U}=J;return G(Pw,{__scopeCheckbox:Z,checked:X,defaultChecked:Y,disabled:K,required:z,onCheckedChange:H,name:q,form:B,value:W,internal_do_not_use_render:({isFormControl:_})=>T(G1,{children:[G(fc,{...U,ref:Q,__scopeCheckbox:Z}),_&&G(uc,{__scopeCheckbox:Z})]})})},"Checkbox")),vc="CheckboxIndicator",Rw=r5.forwardRef(g4(function(J,Q){let{__scopeCheckbox:Z,forceMount:q,...X}=J,Y=e3(vc,Z);return G(Nw,{present:q||v4(Y.checked)||Y.checked===!0,children:G(wY.span,{"data-state":JB(Y.checked),"data-disabled":Y.disabled?"":void 0,...X,ref:Q,style:{pointerEvents:"none",...J.style}})})},"CheckboxIndicator")),gc="CheckboxBubbleInput",uc=r5.forwardRef(g4(function({__scopeCheckbox:J,onClick:Q,...Z},q){let{control:X,hasConsumerStoppedPropagationRef:Y,userInteractionCount:z,checked:K,defaultChecked:W,required:H,disabled:B,name:U,value:_,form:L,bubbleInput:F,setBubbleInput:V}=e3(gc,J),M=GJ(q,V),D=r3(X),N=r5.useRef(!1),O=r5.useRef(K),I=r5.useRef(z);r5.useEffect(()=>{let b=F;if(!b)return;let k=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(k,"checked").set,y=z!==I.current;I.current=z;let f=O.current!==K;O.current=K;let j=!(y&&Y.current);if(f&&C){N.current=!y;let P=new Event("click",{bubbles:j});b.indeterminate=v4(K),C.call(b,v4(K)?!1:K),b.dispatchEvent(P),N.current=!1}},[F,K,Y,z]);let A=r5.useRef(v4(K)?!1:K);return G(wY.input,{type:"checkbox","aria-hidden":!0,defaultChecked:W??A.current,required:H,disabled:B,name:U,value:_,form:L,...Z,tabIndex:-1,ref:M,onClick:LZ(Q,(b)=>{if(N.current)b.stopPropagation()}),style:{...Z.style,...D,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function Cw($){return typeof $==="function"}g4(Cw,"isFunction");function v4($){return $==="indeterminate"}g4(v4,"isIndeterminate");function JB($){return v4($)?"indeterminate":$?"checked":"unchecked"}g4(JB,"getState");var UJ=Sw.forwardRef(({className:$,...J},Q)=>G($B,{ref:Q,className:b0("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",$),...J,children:G(Rw,{className:b0("grid place-content-center text-current"),children:G(j9,{className:"h-4 w-4"})})}));UJ.displayName=$B.displayName;var jY=R(v(),1);var m4=R(v(),1);var w20=!!(typeof window<"u"&&window.document&&window.document.createElement);function kY($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var u4=R(v(),1);function hw($,J=[]){let Q=[];function Z(X,Y){let z=u4.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=u4.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=u4.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return u4.createContext(Y)});return function(z){let K=z?.[$]||X;return u4.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,cc(q,...J)]}function cc(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return u4.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var L6=R(v(),1);var fw=R(v(),1);function xw($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function dc(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=xw(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else xw($[q],null)}}}}function vw(...$){return fw.useCallback(dc(...$),$)}var gw=R(v(),1);function pc($,J){return gw.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}var QB=($)=>{let{present:J,children:Q}=$,Z=lc(J),q=typeof Q==="function"?Q({present:Z.isPresent}):L6.Children.only(Q),X=vw(Z.ref,ic(q));return typeof Q==="function"||Z.isPresent?L6.cloneElement(q,{ref:X}):null};QB.displayName="Presence";function lc($){let[J,Q]=L6.useState(),Z=L6.useRef(null),q=L6.useRef($),X=L6.useRef("none"),Y=$?"mounted":"unmounted",[z,K]=pc(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return L6.useEffect(()=>{let W=IY(Z.current);X.current=z==="mounted"?W:"none"},[z]),_1(()=>{let W=Z.current,H=q.current;if(H!==$){let U=X.current,_=IY(W);if($)K("MOUNT");else if(_==="none"||W?.display==="none")K("UNMOUNT");else if(H&&U!==_)K("ANIMATION_OUT");else K("UNMOUNT");q.current=$}},[$,K]),_1(()=>{if(J){let W,H=J.ownerDocument.defaultView??window,B=(_)=>{let F=IY(Z.current).includes(CSS.escape(_.animationName));if(_.target===J&&F){if(K("ANIMATION_END"),!q.current){let V=J.style.animationFillMode;J.style.animationFillMode="forwards",W=H.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=V})}}},U=(_)=>{if(_.target===J)X.current=IY(Z.current)};return J.addEventListener("animationstart",U),J.addEventListener("animationcancel",B),J.addEventListener("animationend",B),()=>{H.clearTimeout(W),J.removeEventListener("animationstart",U),J.removeEventListener("animationcancel",B),J.removeEventListener("animationend",B)}}else K("ANIMATION_END")},[J,K]),{isPresent:["mounted","unmountSuspended"].includes(z),ref:L6.useCallback((W)=>{Z.current=W?getComputedStyle(W):null,Q(W)},[])}}function IY($){return $?.animationName||"none"}function ic($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var dw=R(v(),1),ec=R(J5(),1);var W8=R(v(),1);var rc=R(v(),1);function uw($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function mw(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=uw(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else uw($[q],null)}}}}function cw($){let J=sc($),Q=W8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=W8.Children.toArray(X),K=z.find(nc);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(W8.Children.count(W)>1)return W8.Children.only(null);return W8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:W8.isValidElement(W)?W8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function sc($){let J=W8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(W8.isValidElement(q)){let Y=tc(q),z=ac(X,q.props);if(q.type!==W8.Fragment)z.ref=Z?mw(Z,Y):Y;return W8.cloneElement(q,z)}return W8.Children.count(q)>1?W8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var oc=Symbol("radix.slottable");function nc($){return W8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===oc}function ac($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function tc($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var $d=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],VZ=$d.reduce(($,J)=>{let Q=cw(`Primitive.${J}`),Z=dw.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var Z9=R(v(),1);var TY=R(v(),1);var Jd=Z9[" useInsertionEffect ".trim().toString()]||_1;function pw({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=Qd({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=Z9.useRef($!==void 0);Z9.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=Z9.useCallback((H)=>{if(z){let B=Zd(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function Qd({defaultProp:$,onChange:J}){let[Q,Z]=Z9.useState($),q=Z9.useRef(Q),X=Z9.useRef(J);return Jd(()=>{X.current=J},[J]),Z9.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function Zd($){return typeof $==="function"}var g20=Symbol("RADIX:SYNC_STATE");var bY="Tabs",[qd,n20]=hw(bY,[YJ]),lw=YJ(),[Xd,ZB]=qd(bY),iw=m4.forwardRef(($,J)=>{let{__scopeTabs:Q,value:Z,onValueChange:q,defaultValue:X,orientation:Y="horizontal",dir:z,activationMode:K="automatic",...W}=$,H=l9(z),[B,U]=pw({prop:Z,onChange:q,defaultProp:X??"",caller:bY});return G(Xd,{scope:Q,baseId:t5(),value:B,onValueChange:U,orientation:Y,dir:H,activationMode:K,children:G(VZ.div,{dir:H,"data-orientation":Y,...W,ref:J})})});iw.displayName=bY;var rw="TabsList",sw=m4.forwardRef(($,J)=>{let{__scopeTabs:Q,loop:Z=!0,...q}=$,X=ZB(rw,Q),Y=lw(Q);return G(KY,{asChild:!0,...Y,orientation:X.orientation,dir:X.dir,loop:Z,children:G(VZ.div,{role:"tablist","aria-orientation":X.orientation,...q,ref:J})})});sw.displayName=rw;var ow="TabsTrigger",nw=m4.forwardRef(($,J)=>{let{__scopeTabs:Q,value:Z,disabled:q=!1,...X}=$,Y=ZB(ow,Q),z=lw(Q),K=ew(Y.baseId,Z),W=$k(Y.baseId,Z),H=Z===Y.value;return G(GY,{asChild:!0,...z,focusable:!q,active:H,children:G(VZ.button,{type:"button",role:"tab","aria-selected":H,"aria-controls":W,"data-state":H?"active":"inactive","data-disabled":q?"":void 0,disabled:q,id:K,...X,ref:J,onMouseDown:kY($.onMouseDown,(B)=>{if(!q&&B.button===0&&B.ctrlKey===!1)Y.onValueChange(Z);else B.preventDefault()}),onKeyDown:kY($.onKeyDown,(B)=>{if([" ","Enter"].includes(B.key))Y.onValueChange(Z)}),onFocus:kY($.onFocus,()=>{let B=Y.activationMode!=="manual";if(!H&&!q&&B)Y.onValueChange(Z)})})})});nw.displayName=ow;var aw="TabsContent",tw=m4.forwardRef(($,J)=>{let{__scopeTabs:Q,value:Z,forceMount:q,children:X,...Y}=$,z=ZB(aw,Q),K=ew(z.baseId,Z),W=$k(z.baseId,Z),H=Z===z.value,B=m4.useRef(H);return m4.useEffect(()=>{let U=requestAnimationFrame(()=>B.current=!1);return()=>cancelAnimationFrame(U)},[]),G(QB,{present:q||H,children:({present:U})=>G(VZ.div,{"data-state":H?"active":"inactive","data-orientation":z.orientation,role:"tabpanel","aria-labelledby":K,hidden:!U,id:W,tabIndex:0,...Y,ref:J,style:{...$.style,animationDuration:B.current?"0s":void 0},children:U&&X})})});tw.displayName=aw;function ew($,J){return`${$}-trigger-${J}`}function $k($,J){return`${$}-content-${J}`}var Jk=iw,qB=sw,XB=nw,YB=tw;var c4=Jk,o9=jY.forwardRef(({className:$,...J},Q)=>G(qB,{ref:Q,className:b0("inline-flex h-9 items-center justify-center rounded-lg border bg-muted p-1 text-muted-foreground",$),...J}));o9.displayName=qB.displayName;var H8=jY.forwardRef(({className:$,...J},Q)=>G(XB,{ref:Q,className:b0("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",$),...J}));H8.displayName=XB.displayName;var P9=jY.forwardRef(({className:$,...J},Q)=>G(YB,{ref:Q,className:b0("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",$),...J}));P9.displayName=YB.displayName;function j2({className:$,...J}){return G("div",{className:b0("animate-pulse rounded-md bg-primary/10",$),...J})}var zd=globalThis.comfyAPI.app.app;var Qk=($,J,Q=3000)=>{try{zd.extensionManager.toast.add({severity:"error",summary:$,detail:J,life:Q})}catch{globalThis.alert($)}};async function MZ($,J=""){let Q=new FormData;if(Q.append("image",$),Q.append("type","input"),Q.append("overwrite","false"),J)Q.append("subfolder",J);let Z=await fetch("/upload/image",{method:"POST",body:Q});if(!Z.ok)throw Error(`Upload failed: ${Z.status}`);let q=await Z.json();return q.subfolder?`${q.subfolder}/${q.name}`:q.name}var EY=R(v(),1),Kd=180,Gd={threshold:0};function zB($,{delayMs:J=Kd,observerInit:Q=Gd}={}){let[Z,q]=EY.useState(!1);return EY.useEffect(()=>{if(Z)return;let X=$.current;if(!X)return;if(typeof IntersectionObserver>"u"){q(!0);return}let Y,z=new IntersectionObserver(([K])=>{if(K.isIntersecting){Y??=setTimeout(()=>{q(!0),z.disconnect()},J);return}if(Y)clearTimeout(Y),Y=void 0},Q);return z.observe(X),()=>{if(Y)clearTimeout(Y);z.disconnect()}},[J,Z,Q,$]),Z}var yY=new Map,_J=new Map,KB=new Set,Zk=0,LJ={inputs:0,outputs:0,local:0};function Wd($){return JSON.stringify($)}function qk($){let J=$&&typeof $==="object"?$:{};return(Array.isArray(J.items)?J.items:Array.isArray(J.files)?J.files:[]).reduce((Z,q)=>{if(!q||typeof q!=="object")return Z;let X=q;return Z.push(X.type==="dir"?X:{...X,type:"file"}),Z},[])}function Hd($){let J=new URLSearchParams({source:$.source,type:$.mediaType});if($.source==="local")J.set("path",$.localPath);if($.subfolder)J.set("subfolder",$.subfolder);return`/easy-media/media/list?${J}`}function Xk($){let J=Wd($),Q=yY.get(J);if(Q)return Promise.resolve(Q.items);let Z=_J.get(J);if(Z)return Z.promise;let q=LJ[$.source],X=fetch(Hd($)).then((Y)=>{if(!Y.ok)throw Error(`${Y.status}`);return Y.json()}).then((Y)=>{let z=qk(Y);if(q===LJ[$.source])yY.set(J,{request:$,items:z});return z}).finally(()=>{if(_J.get(J)?.promise===X)_J.delete(J)});return _J.set(J,{request:$,promise:X}),X}async function PY($){let J=new URLSearchParams({source:$.source,type:$.mediaType,hours:String($.hours)});if($.limit)J.set("limit",String($.limit));let Q=await fetch(`/easy-media/media/recent?${J}`);if(!Q.ok)throw Error(`${Q.status}`);let Z=await Q.json();return qk(Z)}async function Yk($,J=48,Q=50){let[Z,q]=await Promise.all([PY({source:"outputs",mediaType:$,hours:J,limit:Q}),PY({source:"temp",mediaType:$,hours:J,limit:Q})]),X=Z.filter((z)=>z.type==="file"&&typeof z.path==="string").map((z)=>({...z,source_type:"output"})),Y=q.filter((z)=>z.type==="file"&&typeof z.path==="string").map((z)=>({...z,source_type:"temp"}));return[...X,...Y].sort((z,K)=>K.mtime-z.mtime)}function C5($){if($)LJ[$]+=1;else LJ.inputs+=1,LJ.outputs+=1,LJ.local+=1;for(let[J,Q]of yY)if(!$||Q.request.source===$)yY.delete(J);for(let[J,Q]of _J)if(!$||Q.request.source===$)_J.delete(J);Zk+=1,KB.forEach((J)=>J())}function zk($){return KB.add($),()=>KB.delete($)}function GB(){return Zk}var Kk=new Map,DZ="|MULTIPLE|",Gk=2000;function Bd($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}function Vk($,J){if(J==="audio")return FJ;if(J==="image")return MJ;if(J==="video")return VJ;let Q=$.split(".").pop()?.toLowerCase()??"";if(["mp3","wav","flac","ogg","m4a","aac","opus","wma"].includes(Q))return FJ;if(["png","jpg","jpeg","webp","gif","bmp","tiff","tif"].includes(Q))return MJ;if(["mp4","webm","mov","mkv","avi","m4v"].includes(Q))return VJ;return Bk}function UB($,J){if(J==="image")return!0;let Q=$.split(".").pop()?.toLowerCase()??"";return["png","jpg","jpeg","webp","gif","bmp","tiff","tif"].includes(Q)}function Mk($,J){if(J==="audio")return!0;let Q=$.split(".").pop()?.toLowerCase()??"";return["mp3","wav","flac","ogg","m4a","aac","opus","wma"].includes(Q)}function Dk($,J){if(J==="video")return!0;let Q=$.split(".").pop()?.toLowerCase()??"";return["mp4","webm","mov","mkv","avi","m4v"].includes(Q)}function BB($){if(!$)return new Set;return new Set($.split(DZ).filter((J)=>J.length>0))}function Ud($){let J=$.split(DZ)[0]??"";if(!J||J.startsWith("http")||J.startsWith("__slot__:"))return"";return J.replaceAll("\\","/").split("/").slice(0,-1).join("/")}function _d($){return $.replaceAll("\\","/").split("/").filter(Boolean)}function Wk($,J){if(UB($.name,J)&&$.width&&$.height)return`${$.width}×${$.height}`;return Bd($.size)}function Ld($,J){return[...$].sort((Q,Z)=>{if(J==="date")return Z.mtime-Q.mtime;return Q.name.localeCompare(Z.name)})}function Fd($){return[...$].sort((J,Q)=>J.name.localeCompare(Q.name))}function Vd($){if($==="name")return"mediaSelector.sortName";if($==="date")return"mediaSelector.sortDate";return"mediaSelector.sortFolders"}function Nk({src:$,alt:J,className:Q}){let Z=n1.useRef(null),q=zB(Z);return G("img",{ref:Z,src:q?$:void 0,alt:J,className:Q,onError:(X)=>{X.target.style.display="none"}})}function Ok({src:$,className:J}){let Q=n1.useRef(null),Z=zB(Q);return G("video",{ref:Q,src:Z?$:void 0,className:J,muted:!0,playsInline:!0,preload:"metadata",onLoadedMetadata:(q)=>{let X=q.currentTarget;if(Number.isFinite(X.duration)&&X.duration>0.1)X.currentTime=0.1},onError:(q)=>{q.currentTarget.style.display="none"}})}function Md({file:$,mediaType:J,isSelected:Q}){let Z=Vk($.name,J),q=UB($.name,J)&&!!$.url,X=!q&&Dk($.name,J)&&!!$.url,Y=!q&&!X&&Mk($.name,J);return T("div",{className:b0("relative w-full aspect-square rounded overflow-hidden flex items-center justify-center bg-muted",Q&&"ring-2 ring-primary"),children:[q?G(Nk,{src:$.url,alt:$.name,className:"w-full h-full object-cover"}):X?G(Ok,{src:$.url,className:"w-full h-full object-cover"}):G(Z,{className:`w-6 h-6 ${Y?"text-highlight":"text-muted-foreground"}`}),Q&&G("div",{className:"absolute top-1 right-1",children:G(CY,{className:"w-3.5 h-3.5 text-primary fill-primary-foreground"})})]})}function Dd(){return G("div",{className:"grid grid-cols-4 gap-2 p-2",children:Array.from({length:8},($,J)=>`sk-grid-${J}`).map(($)=>T("div",{className:"space-y-1",children:[G(j2,{className:"w-full aspect-square rounded"}),G(j2,{className:"h-3 w-3/4"}),G(j2,{className:"h-2.5 w-1/2"})]},$))})}function Nd(){return G("div",{className:"flex flex-col gap-1 p-2",children:Array.from({length:6},($,J)=>`sk-list-${J}`).map(($)=>T("div",{className:"flex items-center gap-2 h-8",children:[G(j2,{className:"w-6 h-6 rounded shrink-0"}),G(j2,{className:"h-3 flex-1"}),G(j2,{className:"h-3 w-14 shrink-0"})]},$))})}function Od({subfolder:$,onNavigate:J}){if(!$)return null;let Q=_d($);return T("div",{className:"flex items-center gap-0.5 px-2 py-0.5 border-b border-border text-[11px] text-muted-foreground flex-wrap",children:[G("button",{type:"button",className:"hover:text-foreground transition-colors",onClick:()=>J(""),children:"…"}),Q.map((Z,q)=>{let X=Q.slice(0,q+1).join("/");return T("span",{className:"flex items-center gap-0.5",children:[G(LY,{className:"w-3 h-3 shrink-0"}),G("button",{type:"button",className:"hover:text-foreground transition-colors truncate max-w-20",onClick:()=>J(X),children:Z})]},X)})]})}function RY({source:$,mediaType:J,localPath:Q,viewMode:Z,sortBy:q,searchQuery:X,value:Y,historySource:z="outputs",onChange:K,onSourceChange:W,initialSubfolder:H,onNavigateSubfolder:B,onAddLocalFile:U,multipleSelection:_,selectionLimit:L,onToggleSelection:F,onVisibleFilesChange:V}){let M=Z1(),[D,N]=n1.useState([]),[O,I]=n1.useState(H??""),[A,b]=n1.useState(!0),[k,w]=n1.useState(null),C=n1.useSyncExternalStore(zk,GB,GB),y=BB(Y),f=$==="history"?"history":`${$}|${Q}`,j=n1.useRef(f);n1.useEffect(()=>{let S=j.current;if(j.current=f,S!==f)I(""),N([])},[f]),n1.useEffect(()=>{if($==="local"&&!Q){b(!1);return}b(!0),w(null);let S=!1;return($==="history"?z==="combined"?Yk(J,48,50):PY({source:"outputs",mediaType:J,hours:48,limit:50}):Xk({source:$,mediaType:J,localPath:Q,subfolder:O})).then((G0)=>{if(!S)N(G0)}).catch((G0)=>{if(!S)w(G0 instanceof Error?G0.message:JSON.stringify(G0))}).finally(()=>{if(!S)b(!1)}),()=>{S=!0}},[$,z,J,Q,O,C]);let P=Fd(D.filter((S)=>S.type==="dir")),x=Ld(D.filter((S)=>S.type==="file").filter((S)=>S.name.toLowerCase().includes(X.toLowerCase())),q),p=P.filter((S)=>X?S.name.toLowerCase().includes(X.toLowerCase()):!0);if(n1.useEffect(()=>{V(x)},[x,V]),A)return Z==="grid"?G(Dd,{}):G(Nd,{});if(k)return G("div",{className:"flex items-center justify-center h-24 text-destructive text-xs",children:M("mediaSelector.error",{msg:k})});let t=p.length===0&&x.length===0,h=x.filter((S)=>y.has(S.path)),$0=(q==="folders"?[...p,...x]:[...x,...p]).filter((S)=>S.type==="dir"||!y.has(S.path));function Y0(S){if(S===O)return;N([]),b(!0),V([]),I(S),B?.(S)}function e(S){if($==="history")return S.source_type==="temp"?"temp":"output";return $==="outputs"?"output":$==="local"?"local":"input"}function H0(S){let s=e(S);K(S.path,s==="temp"?"output":s),W?.({filePath:S.path,sourceType:s})}function K0(S,s){let G0=e(S),l=_&&!s&&y.size>=L;return T("div",{role:"button",tabIndex:l?-1:0,"aria-disabled":l,className:b0("relative flex flex-col gap-1 text-left hover:opacity-80 transition-opacity",l&&"cursor-not-allowed opacity-50"),onClick:()=>_?F(S.path,G0==="temp"?"output":G0):H0(S),onKeyDown:(Q0)=>{if(Q0.target!==Q0.currentTarget)return;if(Q0.key!=="Enter"&&Q0.key!==" ")return;if(Q0.preventDefault(),_)F(S.path,G0==="temp"?"output":G0);else H0(S)},children:[G(Md,{file:S,mediaType:J,isSelected:s&&!_}),_&&G(UJ,{checked:s,disabled:l,"aria-label":M("mediaSelector.selectFile",{name:S.name}),className:"absolute right-1 top-1 z-10 bg-background/80",onClick:(Q0)=>Q0.stopPropagation(),onCheckedChange:()=>F(S.path,G0==="temp"?"output":G0)}),G("span",{className:"text-[10px] truncate leading-tight max-w-full",title:S.name,children:S.name}),G("span",{className:"text-[10px] text-muted-foreground truncate leading-tight max-w-full",children:Wk(S,J)})]},S.path)}function E(S,s){let G0=Vk(S.name,J),l=UB(S.name,J)&&!!S.url,Q0=!l&&Dk(S.name,J)&&!!S.url,J0=!l&&!Q0&&Mk(S.name,J),B0=e(S),W0=_&&!s&&y.size>=L;return T("div",{role:"button",tabIndex:W0?-1:0,"aria-disabled":W0,className:b0("flex items-center gap-2 px-2 py-1 text-left hover:bg-accent transition-colors",s&&"bg-accent",W0&&"cursor-not-allowed opacity-50"),onClick:()=>_?F(S.path,B0==="temp"?"output":B0):H0(S),onKeyDown:(L0)=>{if(L0.target!==L0.currentTarget)return;if(L0.key!=="Enter"&&L0.key!==" ")return;if(L0.preventDefault(),_)F(S.path,B0==="temp"?"output":B0);else H0(S)},children:[_&&G(UJ,{checked:s,disabled:W0,"aria-label":M("mediaSelector.selectFile",{name:S.name}),onClick:(L0)=>L0.stopPropagation(),onCheckedChange:()=>F(S.path,B0==="temp"?"output":B0)}),l&&G("div",{className:"w-4 h-4 rounded overflow-hidden shrink-0 bg-muted",children:G(Nk,{src:S.url,alt:S.name,className:"w-full h-full object-cover"})}),Q0&&G("div",{className:"w-4 h-4 rounded overflow-hidden shrink-0 bg-muted",children:G(Ok,{src:S.url,className:"w-full h-full object-cover"})}),J0&&G("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-[#34d399] shrink-0",children:G(G0,{className:"w-3 h-3 text-white"})}),!l&&!Q0&&!J0&&G(G0,{className:"w-4 h-4 text-muted-foreground shrink-0"}),G("span",{className:"flex-1 text-xs truncate min-w-0",title:S.name,children:S.name}),G("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Wk(S,J)}),s&&!_&&G(CY,{className:"w-3.5 h-3.5 text-primary shrink-0"})]},S.path)}function m(S){return T("button",{type:"button",className:"flex flex-col gap-1 text-left hover:opacity-80 transition-opacity",onClick:()=>Y0(S.path),children:[G("div",{className:"relative w-full aspect-square rounded overflow-hidden bg-muted flex items-center justify-center",children:G(WB,{className:"w-6 h-6 text-warning"})}),G("span",{className:"text-[10px] truncate leading-tight max-w-full",title:S.name,children:S.name})]},S.path)}function c(S){return T("button",{type:"button",className:"flex items-center gap-2 px-2 py-1 text-left hover:bg-accent transition-colors",onClick:()=>Y0(S.path),children:[G("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-muted shrink-0",children:G(WB,{className:"w-3 h-3 text-warning"})}),G("span",{className:"flex-1 text-xs truncate min-w-0",title:S.name,children:S.name})]},S.path)}function i(S){return S.type==="dir"?m(S):K0(S,y.has(S.path))}function u(S){return S.type==="dir"?c(S):E(S,y.has(S.path))}function d(){return T("div",{className:"grid grid-cols-4 gap-2 p-2 overflow-y-auto flex-1",children:[U&&T("button",{type:"button",className:"flex flex-col gap-1 text-left hover:opacity-80 transition-opacity",onClick:U,children:[G("div",{className:"relative w-full aspect-square rounded overflow-hidden bg-muted flex items-center justify-center border-2 border-dashed border-muted-foreground/50",children:G(K5,{className:"w-6 h-6 text-muted-foreground"})}),G("span",{className:"text-[10px] truncate leading-tight max-w-full text-muted-foreground",children:M("mediaSelector.addLocal")})]},"__add_local__"),h.map((S)=>K0(S,!0)),$0.map(i)]})}function o(){return T("div",{className:"flex flex-col overflow-y-auto flex-1",children:[U&&T("button",{type:"button",className:"flex items-center gap-2 px-2 py-1 text-left hover:bg-accent transition-colors text-muted-foreground",onClick:U,children:[G("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-muted shrink-0",children:G(K5,{className:"w-3 h-3"})}),G("span",{className:"flex-1 text-xs truncate min-w-0",children:M("mediaSelector.addLocal")})]},"__add_local__"),h.map((S)=>E(S,!0)),$0.map(u)]})}return T("div",{className:"flex flex-col flex-1 overflow-hidden",children:[$!=="history"?G(Od,{subfolder:O,onNavigate:Y0}):null,t&&G("div",{className:"flex items-center justify-center h-24 text-muted-foreground text-xs",children:M("mediaSelector.empty")}),!t&&Z==="grid"&&d(),!t&&Z!=="grid"&&o()]})}function M5({value:$,onChange:J,onSourceChange:Q,mediaType:Z="all",defaultTab:q="inputs",slotItems:X=[],historySource:Y="outputs",historyOnly:z=!1,allowMultipleSelection:K=!1,maxSelectionCount:W=9}){let H=Z1(),B=Z==="image"||Z==="audio"||Z==="video",U=Kk.get(Z),_=$&&["inputs","outputs","local"].includes(q)?{...U?.subfolders,[q]:Ud($)}:U?.subfolders??{},[L,F]=n1.useState(z?"history":$?q:U?.activeTab??q),[V,M]=n1.useState(_),[D,N]=n1.useState("grid"),[O,I]=n1.useState("name"),[A,b]=n1.useState(""),[k,w]=n1.useState(""),[C,y]=n1.useState(L==="url"?$:""),[f,j]=n1.useState(!1),[P,x]=n1.useState(!1),[p,t]=n1.useState(()=>new Set),[h,r]=n1.useState([]),[$0,Y0]=n1.useState(!1),e=n1.useRef(null),H0=n1.useRef(null),K0=Number.isFinite(W)?Math.max(1,Math.floor(W)):9,E=Z==="image"&&K,m=P?[...p].join(DZ):$,c=BB(m),i=n1.useRef(q);n1.useEffect(()=>{if(z)return;if(i.current===q)return;i.current=q,F(q),b("")},[q,z]),n1.useEffect(()=>()=>{if(H0.current!==null)clearTimeout(H0.current)},[]);function u(g,a=V){Kk.set(Z,{activeTab:g,subfolders:a})}function d(g){if(F(g),b(""),r([]),P)t(new Set),x(!1);u(g)}function o(g,a){let I0={...V,[g]:a};M(I0),u(L,I0),b("")}function S(){I((g)=>{if(g==="name")return"date";if(g==="date")return"folders";return"name"})}function s(){let g=Date.now();if(e.current!==null&&g-e.current<Gk)return;if(e.current=g,Y0(!0),C5(L==="outputs"||L==="history"?"outputs":L==="local"?"local":"inputs"),H0.current!==null)clearTimeout(H0.current);H0.current=setTimeout(()=>{H0.current=null,Y0(!1)},Gk)}function G0(g,a){J(g,a==="temp"?"output":a),Q?.({filePath:g,sourceType:a})}function l(g){r((a)=>{let I0=a.map((F0)=>F0.path).join(`
|
||
`),A0=g.map((F0)=>F0.path).join(`
|
||
`);return I0===A0?a:g})}function Q0(){t(new Set([...BB($)].slice(0,K0))),x(!0)}function J0(){t(new Set),x(!1)}function B0(g){t((a)=>{let I0=new Set(a);if(I0.has(g))I0.delete(g);else if(I0.size<K0)I0.add(g);return I0})}function W0(){t((g)=>{let a=new Set(g);for(let I0 of h){if(a.size>=K0)break;a.add(I0.path)}return a})}function L0(){if(p.size===0)return;let g=L==="outputs"||L==="history"?"output":L==="local"?"local":"input";G0([...p].join(DZ),g),x(!1)}async function _0(){if(f)return;j(!0);try{let g=new globalThis.Image;await new Promise((a,I0)=>{g.onload=a,g.onerror=()=>I0(Error("Image load failed")),g.src=C}),J(C)}catch{await D0()}finally{j(!1)}}async function D0(){try{let g=await fetch("/easy-media/download-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:C})});if(!g.ok){Qk(H("mediaSelector.urlErrorTitle"),H("mediaSelector.urlErrorNotFound"));return}let a=await g.json();if(a.source_type==="url")J(a.url);else C5("inputs"),J(a.file_name)}catch{J(C)}}function c0(){let g=document.createElement("input");g.type="file";let a=Z==="image"?"image/*":Z==="audio"?"audio/*":Z==="video"?"video/*":"*/*";g.accept=a,g.multiple=!0,g.onchange=async()=>{if(!g.files||g.files.length===0)return;if(g.files.length===1){let A0=g.files[0];try{let F0=await MZ(A0,V.inputs??"");C5("inputs"),J(F0)}catch(F0){console.error("[MediaSelector] upload failed:",F0)}return}let I0=[];for(let A0 of g.files)try{let F0=await MZ(A0,V.inputs??"");I0.push(F0)}catch(F0){console.error("[MediaSelector] upload failed:",F0)}if(I0.length>0)C5("inputs"),J(I0.join(DZ))},g.click()}return G("div",{"data-media-selector":"",className:"flex flex-col w-80 h-80 text-xs select-none",children:T(c4,{value:L,onValueChange:(g)=>d(g),className:"flex flex-col flex-1 overflow-hidden",children:[G(o9,{className:"w-full rounded-none rounded-t-md h-7 p-0.5 gap-0.5 shrink-0",children:z?G(H8,{value:"history",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabHistory")}):T(G1,{children:[G(H8,{value:"inputs",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabInputs")}),G(H8,{value:"outputs",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabOutputs")}),G(H8,{value:"history",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabHistory")}),G(H8,{value:"url",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabUrl")}),B&&G(H8,{value:"slot",className:"flex-1 h-full text-[11px] px-1",children:H("mediaSelector.tabSlot")})]})}),L!=="url"&&L!=="slot"&&T("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border shrink-0",children:[T("div",{className:"relative flex-1",children:[G(Fk,{className:"absolute left-1.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"}),G($6,{className:"h-6 pl-6 text-[11px]",placeholder:H("mediaSelector.searchPlaceholder"),value:A,onChange:(g)=>b(g.target.value)})]}),E&&!P&&T(k0,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-1.5 text-[11px]",title:H("mediaSelector.filter"),onClick:Q0,children:[G(HB,{className:"w-3 h-3"}),H("mediaSelector.filter")]}),P?T(G1,{children:[G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",title:H("mediaSelector.cancelFilter"),onClick:J0,children:G(HB,{className:"w-3 h-3"})}),G(k0,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px]",disabled:h.length===0||p.size>=K0,onClick:W0,children:H("mediaSelector.selectAll")}),G(k0,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px]",disabled:p.size===0,onClick:L0,children:H("mediaSelector.confirm")})]}):null,G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",title:H("mediaSelector.sort",{by:H(Vd(O))}),onClick:S,children:G(Hk,{className:"w-3 h-3"})}),!P&&G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",title:H(D==="grid"?"mediaSelector.viewList":"mediaSelector.viewGrid"),onClick:()=>N((g)=>g==="grid"?"list":"grid"),children:D==="grid"?G(_k,{className:"w-3 h-3"}):G(Uk,{className:"w-3 h-3"})}),G(k0,{variant:"ghost",size:"icon",className:"h-6 w-6",title:H("mediaSelector.refresh"),"aria-label":H("mediaSelector.refresh"),disabled:$0,onClick:s,children:G(SY,{className:"w-3 h-3"})})]}),G(P9,{value:"inputs",className:"mt-0 flex-1 overflow-hidden flex flex-col",children:G(RY,{source:"inputs",mediaType:Z,localPath:"",viewMode:D,sortBy:O,searchQuery:A,value:m,onChange:(g)=>G0(g,"input"),initialSubfolder:V.inputs,onNavigateSubfolder:(g)=>o("inputs",g),onAddLocalFile:c0,multipleSelection:P,selectionLimit:K0,onToggleSelection:B0,onVisibleFilesChange:l})}),G(P9,{value:"outputs",className:"mt-0 flex-1 overflow-hidden flex flex-col",children:G(RY,{source:"outputs",mediaType:Z,localPath:"",viewMode:D,sortBy:O,searchQuery:A,value:m,onChange:(g)=>G0(g,"output"),initialSubfolder:V.outputs,onNavigateSubfolder:(g)=>o("outputs",g),multipleSelection:P,selectionLimit:K0,onToggleSelection:B0,onVisibleFilesChange:l})}),G(P9,{value:"history",className:"mt-0 flex-1 overflow-hidden flex flex-col",children:G(RY,{source:"history",mediaType:Z,localPath:"",viewMode:D,sortBy:O,searchQuery:A,value:m,historySource:Y,onChange:(g,a)=>G0(g,a),onSourceChange:Q,initialSubfolder:"",multipleSelection:P,selectionLimit:K0,onToggleSelection:B0,onVisibleFilesChange:l})}),T(P9,{value:"local",className:"mt-0 flex-1 overflow-hidden flex flex-col",children:[G("div",{className:"flex gap-1 px-2 pt-1 pb-1 border-b border-border",children:G($6,{className:"h-6 text-[11px] flex-1",placeholder:H("mediaSelector.localPathPlaceholder"),value:k,onChange:(g)=>w(g.target.value)})}),G(RY,{source:"local",mediaType:Z,localPath:k,viewMode:D,sortBy:O,searchQuery:A,value:m,onChange:(g)=>G0(g,"local"),initialSubfolder:V.local,onNavigateSubfolder:(g)=>o("local",g),multipleSelection:P,selectionLimit:K0,onToggleSelection:B0,onVisibleFilesChange:l})]}),G(P9,{value:"url",className:"mt-0 flex-1 p-2",children:T("div",{className:"space-y-2",children:[G("p",{className:"text-muted-foreground text-[11px]",children:H("mediaSelector.urlHint")}),G($6,{className:"h-7 text-[11px]",placeholder:"https://...",value:C,onChange:(g)=>y(g.target.value),onKeyDown:(g)=>{if(g.key==="Enter")_0()}}),G(k0,{size:"sm",className:"h-6 text-[11px] w-full",disabled:!C.startsWith("http")||f,onClick:_0,children:f?H("mediaSelector.urlChecking"):H("mediaSelector.urlConfirm")})]})}),B&&G(P9,{value:"slot",className:"mt-0 flex-1 overflow-hidden flex flex-col",children:X.length===0?G("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-[11px]",children:H("mediaSelector.slotEmpty")}):G("div",{className:"flex flex-col overflow-y-auto flex-1",children:X.map((g,a)=>({item:g,index:a})).sort((g,a)=>Number(c.has(a.item.value))-Number(c.has(g.item.value))).map(({item:g,index:a})=>{let I0=c.has(g.value),A0=g.value.startsWith("__slot__:image"),F0=g.value.startsWith("__slot__:audio"),u0=g.value.startsWith("__slot__:video"),P0=A0?H("mediaSelector.slotImage",{n:a+1}):F0?H("mediaSelector.slotAudio",{n:a+1}):u0?H("mediaSelector.slotVideo",{n:a+1}):g.label;return T("button",{type:"button",className:b0("flex items-center gap-2 px-2 py-1 text-left hover:bg-accent transition-colors",I0&&"bg-accent"),onClick:()=>J(g.value),children:[g.img?G("img",{src:g.img,alt:P0,className:"w-8 h-8 object-cover rounded shrink-0 bg-muted"}):F0?G("div",{className:"w-8 h-8 rounded flex items-center justify-center bg-[#34d399] shrink-0",children:G(FJ,{className:"w-4 h-4 text-white"})}):u0?G("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded bg-muted",children:G(VJ,{className:"h-4 w-4 text-muted-foreground"})}):G(Lk,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),G("span",{className:"flex-1 text-xs truncate min-w-0",children:P0}),F0&&g.audio_name&&G("span",{className:"text-[10px] text-muted-foreground truncate max-w-24",title:g.audio_name,children:g.audio_name}),I0&&G(CY,{className:"w-3.5 h-3.5 text-primary shrink-0"})]},g.value)})})})]})})}function _B($){if($.url)return $.url;if($.local_path)return $.local_path;if($.file_path){if(/^https?:\/\//i.test($.file_path))return $.file_path;let J=Math.max($.file_path.lastIndexOf("/"),$.file_path.lastIndexOf("\\")),Q=J>=0?$.file_path.slice(J+1):$.file_path,Z=J>=0?$.file_path.slice(0,J):"",q=$.source_type==="output"||$.source_type==="local"?$.source_type:"input";return`/view?filename=${encodeURIComponent(Q)}&type=${q}&subfolder=${encodeURIComponent(Z)}`}return null}function Ak($,J="input"){return{source_type:J,file_path:$,file_name:$.split("/").pop()??$}}function wk($){return{source_type:"url",url:$,file_name:$.split("/").pop()??$}}function kk($){let J=$.map((Q)=>_B(Q)).filter((Q)=>Q!==null);if(J.length===0)return{};return{backgroundImage:J.map((Q)=>`url("${Q.replaceAll('"',"%22")}")`).join(", "),backgroundRepeat:"repeat",backgroundSize:J.map(()=>"auto 100%").join(", "),backgroundPosition:"0 0"}}function LB({position:$,onClick:J,disabled:Q}){let Z=Z1();return G("button",{type:"button","aria-label":$==="left"?Z("insertButton.insertBefore"):Z("insertButton.insertAfter"),className:"flex items-center opacity-80 hover:opacity-100 transition-opacity cursor-pointer select-none disabled:opacity-20",onClick:(q)=>{q.stopPropagation(),J()},disabled:Q,style:{padding:0,border:"none",background:"none"},children:G("span",{className:"inline-flex items-center justify-center rounded-full bg-foreground shrink-0",style:{width:10,height:10},children:G(K5,{className:"w-2 h-2 text-background"})})})}var n9=R(v(),1);var Ad=8,wd=12;function kd($,J,Q,Z){let q=Z/Math.max(Q-1,1),X=$*q,Y=Math.min((J+1)*q,Z);return{left:X,width:Math.max(Y-X,2)}}function Id($,J=0.3){if(!$.startsWith("#")||$.length<7)return"var(--border)";let Q=Number.parseInt($.slice(1,3),16),Z=Number.parseInt($.slice(3,5),16),q=Number.parseInt($.slice(5,7),16),X=Math.round(Q+(255-Q)*J),Y=Math.round(Z+(255-Z)*J),z=Math.round(q+(255-q)*J);return`#${X.toString(16).padStart(2,"0")}${Y.toString(16).padStart(2,"0")}${z.toString(16).padStart(2,"0")}`}var hY=n9.default.forwardRef(function({segment:J,totalFrames:Q,areaWidth:Z,interactive:q=!0,hideLeftHandle:X=!1,disableLeftResize:Y=!1,minStart:z=0,selected:K=!1,onClick:W,onDoubleClick:H,onSelect:B,onContextMenu:U,onDragEnd:_,onResizeEnd:L,children:F,backgroundSlot:V,className:M,bgStyle:D,frameRate:N,displayFormat:O},I){let A=Z1(),[b,k]=n9.useState(!1),w=n9.useRef(null);function C(){if(k(!0),w.current)clearTimeout(w.current)}function y(){if(w.current)clearTimeout(w.current);w.current=setTimeout(()=>k(!1),1500)}let{left:f,width:j}=kd(J.start_frame,J.end_frame,Q,Z),P=n9.useRef(null),x=n9.useRef(!1),[p,t]=n9.useState(!1),[h,r]=n9.useState(null);function $0(){return K?wd:Ad}function Y0(E){if(!q)return;let m=E.currentTarget.getBoundingClientRect(),c=E.clientX-m.left,i=$0(),u=c<=i&&!Y,d=c>=m.width-i;if(u||d)r("ew-resize");else r("grab")}function e(){r(null)}function H0(E){if(!q)return;E.preventDefault(),x.current=!1;let m=Z/Math.max(Q-1,1),c=E.clientX,i=J.start_frame,u=E.currentTarget.getBoundingClientRect(),d=E.clientX-u.left,o=$0(),S=d<=o&&!Y,s=d>=u.width-o,G0="move";if(S)G0="start";else if(s)G0="end";if(C(),G0!=="move")t(!0);function l(J0){let B0=Math.round((J0.clientX-c)/m);if(B0!==0)x.current=!0;if(G0==="start"&&L)L(J.id,"start",B0,z);else if(G0==="end"&&L)L(J.id,"end",B0);else if(G0==="move"&&_)_(J.id,B0,i)}function Q0(){if(P.current=null,G0!=="move")t(!1);y(),globalThis.removeEventListener("mousemove",l),globalThis.removeEventListener("mouseup",Q0)}globalThis.addEventListener("mousemove",l),globalThis.addEventListener("mouseup",Q0)}function K0(E){return(m)=>{if(!q||!L)return;m.preventDefault(),m.stopPropagation();let c=m.clientX,i=Z/Math.max(Q-1,1);t(!0),C();function u(o){let S=Math.round((o.clientX-c)/i);L?.(J.id,E,S,E==="start"?z:void 0)}function d(){t(!1),y(),globalThis.removeEventListener("mousemove",u),globalThis.removeEventListener("mouseup",d)}globalThis.addEventListener("mousemove",u),globalThis.addEventListener("mouseup",d)}}return T("div",{ref:I,role:"button",tabIndex:0,"data-segment-block":"",className:b0("absolute top-0 h-full flex items-center overflow-hidden rounded select-none active:opacity-70",M),style:{left:f,width:j,backgroundColor:J.color,border:p?"1px solid #eab308":K?"1px solid var(--foreground)":`1px solid ${Id(J.color)}`,cursor:h??(q?"grab":"default"),...D},onMouseDown:H0,onMouseMove:Y0,onMouseLeave:e,onClick:(E)=>{if(x.current)return;E.stopPropagation(),C(),y(),B?.(J),W?.(J)},onDoubleClick:()=>H?.(J),onContextMenu:(E)=>U?.(E,J),onKeyDown:(E)=>{if(E.key==="Enter")B?.(J),W?.(J)},children:[V&&G("div",{className:"absolute inset-0 pointer-events-none overflow-hidden rounded z-1",children:V}),b&&N!==void 0&&O!==void 0&&G("div",{className:"absolute top-0.5 left-1 z-20 pointer-events-none",children:G("span",{className:"text-[9px] bg-black/70 text-white px-1 py-px rounded leading-none",children:O==="seconds"?`${(J.start_frame/N).toFixed(1)}s`:`${J.start_frame}f`})}),q&&L&&!X&&G("button",{type:"button","aria-label":A("segmentBlock.resizeStart"),className:"absolute left-0 top-0 h-full w-0.5 cursor-ew-resize z-20",style:{background:p?"#eab308":K?"var(--foreground)":"transparent"},onMouseDown:(E)=>{if(Y)return;K0("start")(E)}}),G("div",{className:"flex-1 overflow-hidden min-w-0 px-1.5 text-xs text-foreground font-medium pointer-events-none",children:F}),q&&L&&G("button",{type:"button","aria-label":A("segmentBlock.resizeEnd"),className:"absolute right-0 top-0 h-full w-0.5 cursor-ew-resize z-20",style:{background:p?"#eab308":K?"var(--foreground)":"transparent"},onMouseDown:(E)=>{E.stopPropagation(),K0("end")(E)}})]})});var Ik=80;function xY({children:$,height:J,grow:Q}){let Z=J??40;return G("div",{className:"flex border-b border-border",style:Q!==void 0?{flexGrow:Q,minHeight:0}:{height:Z,minHeight:Z},children:G("div",{className:"relative flex-1 min-w-0 overflow-x-clip overflow-y-visible",children:$})})}function NZ($){return $*2+1}function Td($,J){if($.length===0)return $;let Q=Math.floor(J/$.length),Z=J%$.length;return $.map((q,X)=>{let Y=X<Z,z=Q+(Y?1:0),K=X*Q+Math.min(X,Z),W=X<$.length-1?K+z-1:J-1;return{...q,start_frame:K,end_frame:W}})}async function bd($){let J=new FormData;J.append("image",$),J.append("type","input"),J.append("overwrite","false");let Q=await fetch("/upload/image",{method:"POST",body:J});if(!Q.ok)throw Error(`Upload failed: ${Q.status}`);let Z=await Q.json();return`${Z.subfolder?`${Z.subfolder}/`:""}${Z.name}`}function jd($,J,Q){if($.length===0)return null;if(J<$[0].start_frame)return{start:0,end:$[0].start_frame-1};for(let q=0;q<$.length-1;q++){let X=$[q].end_frame+1,Y=$[q+1].start_frame-1;if(J>=X&&J<=Y)return{start:X,end:Y}}let Z=$[$.length-1];if(J>Z.end_frame&&Z.end_frame<Q-1)return{start:Z.end_frame+1,end:Q-1};return null}function Ed({images:$}){let J=$.map((Z)=>_B(Z)).filter((Z)=>Z!==null);if(J.length===0)return null;let Q=Array.from({length:24},(Z,q)=>J.map((X,Y)=>({src:X,key:`${q}-${Y}`}))).flat();return G("div",{className:"absolute inset-0 bg-black overflow-hidden",children:G("div",{className:"flex h-full w-max",children:Q.map(({src:Z,key:q})=>G("img",{src:Z,alt:"",className:"h-full w-auto max-w-none shrink-0 object-contain",draggable:!1,onError:(X)=>{X.currentTarget.style.display="none"}},q))})})}function yd({seg:$,index:J}){let Q=Z1(),Z=$.content,q=Z.images.length>0,X=Z.text.trim().length>0;if(!q)return G("div",{className:"flex items-center justify-center w-full h-full px-1",children:X?G("span",{className:"text-[9px] text-foreground leading-tight line-clamp-3 text-center",children:Z.text}):T("div",{className:"flex flex-col gap-1",children:[G("span",{className:"text-[9px] text-foreground leading-tight truncate text-center",children:Q("maintainTrack.segmentLabel",{n:J+1})}),G("span",{className:"text-[8px] text-muted-foreground leading-tight truncate text-center",children:Q("maintainTrack.segmentPlaceholder")})]})});return G(G1,{children:X&&G("div",{className:"absolute bottom-0 left-0 right-0 px-1 pb-0.5 pointer-events-none z-10 bg-black",children:G("span",{className:"block text-[9px] leading-tight truncate text-white drop-shadow",children:Z.text})})})}function Tk({track:$,totalFrames:J,frameRate:Q,displayFormat:Z,areaWidth:q,canvasScale:X=1,selectedId:Y,onSelectedIdChange:z,onTrackChange:K,onSegmentsChange:W,onExtendTimeline:H,grow:B}){let U=Z1(),_=d4.useRef(null),[L,F]=d4.useState(null),[V,M]=d4.useState(null),[D,N]=d4.useState(!1),[O,I]=d4.useState({x:0,y:0}),[A,b]=d4.useState(""),k=d4.useRef(null),w=$.segments;function C(E){let m=_.current?.getBoundingClientRect();if(!m)return;let c=E.clientX-m.left;if(w.length===0)return;if(!e(c))z(null)}function y(E){let m=_.current?.getBoundingClientRect();if(!m||$.locked)return;let c=E.clientX-m.left,i=q/Math.max(J-1,1),u=Math.round(c/i);if(w.length===0){W([{id:f1(),start_frame:0,end_frame:J-1,content:{text:"",images:[],type:"flf"},color:$.color}]);return}if(w.find((s)=>u>=s.start_frame&&u<=s.end_frame))return;let o=[...w].sort((s,G0)=>s.start_frame-G0.start_frame),S=jd(o,u,J);if(!S)return;W([...w,{id:f1(),start_frame:S.start,end_frame:S.end,content:{text:"",images:[],type:"flf"},color:$.color}])}function f(E,m,c){let i=w.find((J0)=>J0.id===E);if(!i)return;let u=i.end_frame-i.start_frame,d=Math.max(0,c+m),o=Math.min(J-1,d+u),S=o-u,G0=[...w.map((J0)=>J0.id===E?{...J0,start_frame:S,end_frame:o}:J0)].sort((J0,B0)=>J0.start_frame+J0.end_frame-(B0.start_frame+B0.end_frame)),l=[...w].sort((J0,B0)=>J0.start_frame-B0.start_frame).map((J0)=>({start_frame:J0.start_frame,end_frame:J0.end_frame})),Q0=G0.map((J0,B0)=>({...J0,start_frame:l[B0].start_frame,end_frame:l[B0].end_frame}));W(Q0)}function j(E,m,c){if($.locked)return;let i=w.findIndex((o)=>o.id===E);if(i===-1)return;let u=w[i],d=[...w];if(m==="end")P(d,i,u,c);else x(d,i,u,c);W(d)}function P(E,m,c,i){let u=E[m+1],d=c.start_frame+1,o=Math.max(d,Math.min(c.end_frame+i,J-1));if(E[m]=p(c,c.start_frame,o),u){let S=o+1;if(u.start_frame!==S){let s=S-u.start_frame;E[m+1]={...u,start_frame:S,end_frame:u.end_frame+s};for(let G0=m+2;G0<E.length;G0++)E[G0]={...E[G0],start_frame:E[G0].start_frame+s,end_frame:E[G0].end_frame+s}}}}function x(E,m,c,i){let u=E[m-1],d=c.end_frame-1,o=u?u.start_frame+1:0,S=Math.max(o,Math.min(d,c.start_frame+i));if(E[m]=p(c,S,c.end_frame),u)E[m-1]=p(u,u.start_frame,S-1);for(let s=m+1;s<E.length;s++){let G0=E[s-1].end_frame+1;if(E[s].start_frame!==G0){let l=G0-E[s].start_frame;E[s]={...E[s],start_frame:G0,end_frame:E[s].end_frame+l}}}}function p(E,m,c){let i=E.end_frame-E.start_frame+1,u=c-m+1;if(i===u)return{...E,start_frame:m,end_frame:c};return{...E,start_frame:m,end_frame:c,content:{...E.content,images:OZ(E.content.images,i,u)}}}function t(){let E=[...w].sort((c,i)=>c.start_frame-i.start_frame);if(E.length===0||E[0].start_frame>0)return{start:0,end:E.length>0?E[0].start_frame-1:J-1};for(let c=0;c<E.length-1;c++){let i=E[c].end_frame+1,u=E[c+1].start_frame-1;if(i<=u)return{start:i,end:u}}let m=E.at(-1).end_frame+1;if(m<=J-1)return{start:m,end:J-1};return null}function h(E){let m=w.findIndex((Q0)=>Q0.id===Y);if(m===-1)return;let c=w[m],i=NZ(Q),u=E==="left"?c.start_frame:c.end_frame+1,d=E==="left"?m:m+1,o={id:f1(),start_frame:u,end_frame:u+i-1,content:{text:"",images:[],type:"flf"},color:$.color},S=w.map((Q0,J0)=>{if(J0<d)return Q0;return{...Q0,start_frame:Q0.start_frame+i,end_frame:Q0.end_frame+i}}),s=[...S.slice(0,d),o,...S.slice(d)],l=s.at(-1).end_frame+1;if(l>J&&H)H(s,l);else W(s);z(o.id)}function r(E){if($.locked)return;let m=[...w].sort((Q0,J0)=>Q0.start_frame-J0.start_frame),c=m.findIndex((Q0)=>Q0.id===E);if(c===-1)return;let i=m[c],u=i.end_frame-i.start_frame+1,d=i.end_frame+1,o={...structuredClone(i),id:f1(),start_frame:d,end_frame:d+u-1,color:$.color},S=[],s=o.end_frame+1;for(let Q0 of m.slice(c+1)){let J0=Q0.end_frame-Q0.start_frame+1;S.push({...Q0,start_frame:s,end_frame:s+J0-1}),s+=J0}let G0=[...m.slice(0,c+1),o,...S],l=J+u;if(H)H(G0,l);else W(G0);z(o.id)}function $0(){if(w.length===0){W([{id:f1(),start_frame:0,end_frame:J-1,content:{text:"",images:[],type:"flf"},color:$.color}]);return}let E=t();if(E){W([...w,{id:f1(),start_frame:E.start,end_frame:E.end,content:{text:"",images:[],type:"flf"},color:$.color}].sort((o,S)=>o.start_frame-S.start_frame));return}let m=w.at(-1),c=NZ(Q),i=m.end_frame+1,u=i+c-1,d={id:f1(),start_frame:i,end_frame:u,content:{text:"",images:[],type:"flf"},color:$.color};if(W([...w,d]),H)H([...w,d],u+1)}function Y0(E){let m=w.findIndex((d)=>d.id===E);if(m===-1)return;if(w.length===1){if(W([]),Y===E)z(null);return}let c=w[m],i=c.end_frame-c.start_frame+1,u=w.map((d,o)=>{if(o===m)return null;let S={...d};if(o>m)S.start_frame=d.start_frame-i,S.end_frame=d.end_frame-i;return S}).filter((d)=>d!==null);if(m>0)u[m-1]={...u[m-1],end_frame:c.start_frame-1};if(W(u),Y===E)z(null)}function e(E){let m=q/Math.max(J-1,1),c=Math.round(E/m);return w.find((i)=>c>=i.start_frame&&c<=i.end_frame)??null}function H0(E){if(E.dataTransfer.types.includes("Files")){E.preventDefault();let m=E.currentTarget.getBoundingClientRect(),c=(E.clientX-m.left)/X;M(Math.round(c/q*(J-1)))}}async function K0(E){E.preventDefault();let m=new Set([".png",".jpg",".jpeg",".webp",".gif",".bmp",".tiff",".tif"]),c=Array.from(E.dataTransfer.files).filter((Q0)=>{if(Q0.type.startsWith("image/"))return!0;let J0=`.${Q0.name.split(".").pop()?.toLowerCase()??""}`;return m.has(J0)});if(c.length===0){M(null);return}let i=[];for(let Q0 of c)try{let J0=await bd(Q0);i.push(J0)}catch(J0){console.error("[MaintainTrack] upload failed:",J0)}if(i.length===0){M(null);return}if(C5("inputs"),w.length===0){let Q0=Math.floor(J/i.length),J0=J%i.length,B0=[],W0=0;for(let L0=0;L0<i.length;L0++){let _0=Q0+(L0<J0?1:0),D0=[{source_type:"input",file_path:i[L0],file_name:i[L0].split("/").pop()??i[L0]}];B0.push({id:f1(),start_frame:W0,end_frame:W0+_0-1,content:{text:"",images:D0,type:"flf"},color:$.color}),W0+=_0}W(B0),M(null);return}let u=t(),d=NZ(Q);if(u){let Q0=[],J0=u.start;for(let L0 of i){if(J0>J-1)break;let _0=Math.min(d,J-J0);Q0.push({id:f1(),start_frame:J0,end_frame:J0+_0-1,content:{text:"",images:[{source_type:"input",file_path:L0,file_name:L0.split("/").pop()??L0}],type:"flf"},color:$.color}),J0+=d}let B0=[...w,...Q0].sort((L0,_0)=>L0.start_frame-_0.start_frame);W(B0);let W0=Q0[Q0.length-1];if(W0&&H)H(B0,W0.end_frame+1);M(null);return}let o=w[w.length-1],S=[],s=o.end_frame+1;for(let Q0 of i)S.push({id:f1(),start_frame:s,end_frame:s+d-1,content:{text:"",images:[{source_type:"input",file_path:Q0,file_name:Q0.split("/").pop()??Q0}],type:"flf"},color:$.color}),s+=d;let G0=[...w,...S];W(G0);let l=S[S.length-1];if(H)H(G0,l.end_frame+1);M(null)}return T(xY,{track:$,onTrackChange:K,height:B===void 0?Ik:void 0,grow:B,children:[T(a6,{children:[G(t6,{className:"relative block w-full h-full",asChild:!0,children:T("section",{ref:_,"aria-label":U("maintainTrack.dropZone"),className:"relative w-full h-full",onDragOver:H0,onDragLeave:()=>M(null),onDrop:K0,onClick:C,onDoubleClick:y,children:[w.map((E,m)=>G(hY,{segment:E,totalFrames:J,areaWidth:q,interactive:!$.locked,hideLeftHandle:!1,disableLeftResize:m===0,selected:Y===E.id,onSelect:(c)=>z(Y===c.id?null:c.id),onDragEnd:f,onResizeEnd:j,frameRate:Q,displayFormat:Z,onContextMenu:(c,i)=>{F(i.id),z(i.id)},onDoubleClick:(c)=>{k.current=c.id,setTimeout(()=>{k.current=null},100)},backgroundSlot:E.content.images.length>0?G(Ed,{images:E.content.images}):void 0,children:G(yd,{seg:E,index:m})},E.id)),Y&&!$.locked&&(()=>{let E=w.findIndex((u)=>u.id===Y);if(E===-1)return null;let m=w[E],c=m.start_frame/Math.max(J-1,1)*q,i=(m.end_frame+1)/Math.max(J-1,1)*q;return T(G1,{children:[G("div",{className:"absolute pointer-events-auto",style:{left:E==0?c+10:c,top:-16,transform:"translate(-50%, 0)",zIndex:25},children:G(LB,{position:"left",onClick:()=>h("left")})}),G("div",{className:"absolute pointer-events-auto",style:{left:E>=w.length-1||w.length==1?i-10:i,top:-16,transform:"translate(-50%, 0)",zIndex:25},children:G(LB,{position:"right",onClick:()=>h("right")})})]})})(),w.length===0?T(a6,{children:[G(t6,{asChild:!0,children:T("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground select-none opacity-40",children:[T("div",{className:"flex items-center gap-1",children:[G(K5,{className:"w-3 h-3"}),G("span",{className:"text-[11px]",children:U("maintainTrack.placeholder")})]}),G("span",{className:"text-[10px]",children:U("maintainTrack.placeholderHint")})]})}),T(y6,{children:[G(Q5,{onClick:$0,children:U("maintainTrack.contextAdd")}),G(Q5,{onClick:()=>{I({x:0,y:60}),b(""),N(!0)},children:U("maintainTrack.addMedia")})]})]}):G("div",{className:"hidden"}),V!==null&&G("div",{className:"absolute top-0 w-0.5 h-full bg-foreground/60 pointer-events-none",style:{left:V/Math.max(J-1,1)*q}})]})}),T(y6,{onCloseAutoFocus:()=>F(null),children:[G(Q5,{onClick:()=>W(Td(w,J)),children:U("maintainTrack.contextDistribute")}),G(Q5,{onClick:$0,children:U("maintainTrack.contextAdd")}),L&&T(G1,{children:[G(Q5,{onClick:()=>{r(L),F(null)},children:U("maintainTrack.contextClone")}),G(Q5,{onClick:()=>{Y0(L),F(null)},children:U("maintainTrack.contextDelete")})]})]})]}),T(t1,{open:D,onOpenChange:N,children:[G(_6,{asChild:!0,children:G("span",{className:"absolute w-0 h-0 pointer-events-none",style:{left:O.x,top:O.y}})}),G(o1,{"data-add-popover":"",className:"p-0 w-auto",side:"bottom",align:"start",onOpenAutoFocus:(E)=>E.preventDefault(),children:G(M5,{value:A,onChange:(E,m)=>{if(!E){N(!1);return}let i=E.includes("|MULTIPLE|")?E.split("|MULTIPLE|"):[E],u=m??"input";if(w.length===0){let l=[],Q0=0;for(let J0=0;J0<i.length;J0++){let B0=i[J0],W0=B0.split("/").pop()??B0,L0=B0.startsWith("http"),_0=J-Q0,D0=i.length-J0,c0=Math.floor(_0/D0),g=_0%D0,a=c0+(J0<g?1:0),I0={id:f1(),start_frame:Q0,end_frame:Math.min(Q0+a-1,J-1),content:{text:"",images:[{source_type:L0?"url":u,file_path:L0?void 0:B0,url:L0?B0:void 0,file_name:W0}],type:"flf"},color:$.color};l.push(I0),Q0=I0.end_frame+1}W(l),N(!1);return}let d=t();if(d){let l=NZ(Q),Q0=[],J0=d.start;for(let B0=0;B0<i.length;B0++){if(J0>J-1)break;let W0=i[B0],L0=W0.split("/").pop()??W0,_0=W0.startsWith("http"),D0=Math.min(l,J-J0);Q0.push({id:f1(),start_frame:J0,end_frame:J0+D0-1,content:{text:"",images:[{source_type:_0?"url":u,file_path:_0?void 0:W0,url:_0?W0:void 0,file_name:L0}],type:"flf"},color:$.color}),J0+=l}W([...w,...Q0].sort((B0,W0)=>B0.start_frame-W0.start_frame)),N(!1);return}let o=w[w.length-1],S=NZ(Q),s=[],G0=o.end_frame+1;for(let l=0;l<i.length;l++){let Q0=i[l],J0=Q0.split("/").pop()??Q0,B0=Q0.startsWith("http");s.push({id:f1(),start_frame:G0,end_frame:G0+S-1,content:{text:"",images:[{source_type:B0?"url":u,file_path:B0?void 0:Q0,url:B0?Q0:void 0,file_name:J0}],type:"flf"},color:$.color}),G0+=S}if(W([...w,...s]),H){let l=s[s.length-1];if(l)H([...w,...s],l.end_frame+1)}N(!1)},mediaType:"image",defaultTab:"inputs"})})]})]})}var w8=R(v(),1),$I=R(J5(),1);var wZ=R(v(),1);var L5=R(v(),1);var i$0=!!(typeof window<"u"&&window.document&&window.document.createElement);function DJ($,J,{checkForDefaultPrevented:Q=!0}={}){return function(q){if($?.(q),Q===!1||!q.defaultPrevented)return J?.(q)}}var jk=R(v(),1);function bk($,J){if(typeof $==="function")return $(J);else if($!==null&&$!==void 0)$.current=J}function FB(...$){return(J)=>{let Q=!1,Z=$.map((q)=>{let X=bk(q,J);if(!Q&&typeof X=="function")Q=!0;return X});if(Q)return()=>{for(let q=0;q<Z.length;q++){let X=Z[q];if(typeof X=="function")X();else bk($[q],null)}}}}function NJ(...$){return jk.useCallback(FB(...$),$)}var q9=R(v(),1);function Ek($,J){let Q=q9.createContext(J),Z=(X)=>{let{children:Y,...z}=X,K=q9.useMemo(()=>z,Object.values(z));return G(Q.Provider,{value:K,children:Y})};Z.displayName=$+"Provider";function q(X){let Y=q9.useContext(Q);if(Y)return Y;if(J!==void 0)return J;throw Error(`\`${X}\` must be used within \`${$}\``)}return[Z,q]}function yk($,J=[]){let Q=[];function Z(X,Y){let z=q9.createContext(Y),K=Q.length;Q=[...Q,Y];let W=(B)=>{let{scope:U,children:_,...L}=B,F=U?.[$]?.[K]||z,V=q9.useMemo(()=>L,Object.values(L));return G(F.Provider,{value:V,children:_})};W.displayName=X+"Provider";function H(B,U){let _=U?.[$]?.[K]||z,L=q9.useContext(_);if(L)return L;if(Y!==void 0)return Y;throw Error(`\`${B}\` must be used within \`${X}\``)}return[W,H]}let q=()=>{let X=Q.map((Y)=>{return q9.createContext(Y)});return function(z){let K=z?.[$]||X;return q9.useMemo(()=>({[`__scope${$}`]:{...z,[$]:K}}),[z,K])}};return q.scopeName=$,[Z,Pd(q,...J)]}function Pd(...$){let J=$[0];if($.length===1)return J;let Q=()=>{let Z=$.map((q)=>({useScope:q(),scopeName:q.scopeName}));return function(X){let Y=Z.reduce((z,{useScope:K,scopeName:W})=>{let B=K(X)[`__scope${W}`];return{...z,...B}},{});return q9.useMemo(()=>({[`__scope${J.scopeName}`]:Y}),[Y])}};return Q.scopeName=J.scopeName,Q}var X9=R(v(),1);var fY=R(v(),1);var Rd=X9[" useInsertionEffect ".trim().toString()]||_1;function Pk({prop:$,defaultProp:J,onChange:Q=()=>{},caller:Z}){let[q,X,Y]=Cd({defaultProp:J,onChange:Q}),z=$!==void 0,K=z?$:q;{let H=X9.useRef($!==void 0);X9.useEffect(()=>{let B=H.current;if(B!==z)console.warn(`${Z} is changing from ${B?"controlled":"uncontrolled"} to ${z?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);H.current=z},[z,Z])}let W=X9.useCallback((H)=>{if(z){let B=Sd(H)?H($):H;if(B!==$)Y.current?.(B)}else X(H)},[z,$,X,Y]);return[K,W]}function Cd({defaultProp:$,onChange:J}){let[Q,Z]=X9.useState($),q=X9.useRef(Q),X=X9.useRef(J);return Rd(()=>{X.current=J},[J]),X9.useEffect(()=>{if(q.current!==Q)X.current?.(Q),q.current=Q},[Q,q]),[Q,Z,X]}function Sd($){return typeof $==="function"}var t$0=Symbol("RADIX:SYNC_STATE");var F6=R(v(),1);var Rk=R(v(),1);function hd($,J){return Rk.useReducer((Q,Z)=>{return J[Q][Z]??Q},$)}var AZ=($)=>{let{present:J,children:Q}=$,Z=xd(J),q=typeof Q==="function"?Q({present:Z.isPresent}):F6.Children.only(Q),X=NJ(Z.ref,fd(q));return typeof Q==="function"||Z.isPresent?F6.cloneElement(q,{ref:X}):null};AZ.displayName="Presence";function xd($){let[J,Q]=F6.useState(),Z=F6.useRef(null),q=F6.useRef($),X=F6.useRef("none"),Y=$?"mounted":"unmounted",[z,K]=hd(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return F6.useEffect(()=>{let W=vY(Z.current);X.current=z==="mounted"?W:"none"},[z]),_1(()=>{let W=Z.current,H=q.current;if(H!==$){let U=X.current,_=vY(W);if($)K("MOUNT");else if(_==="none"||W?.display==="none")K("UNMOUNT");else if(H&&U!==_)K("ANIMATION_OUT");else K("UNMOUNT");q.current=$}},[$,K]),_1(()=>{if(J){let W,H=J.ownerDocument.defaultView??window,B=(_)=>{let F=vY(Z.current).includes(CSS.escape(_.animationName));if(_.target===J&&F){if(K("ANIMATION_END"),!q.current){let V=J.style.animationFillMode;J.style.animationFillMode="forwards",W=H.setTimeout(()=>{if(J.style.animationFillMode==="forwards")J.style.animationFillMode=V})}}},U=(_)=>{if(_.target===J)X.current=vY(Z.current)};return J.addEventListener("animationstart",U),J.addEventListener("animationcancel",B),J.addEventListener("animationend",B),()=>{H.clearTimeout(W),J.removeEventListener("animationstart",U),J.removeEventListener("animationcancel",B),J.removeEventListener("animationend",B)}}else K("ANIMATION_END")},[J,K]),{isPresent:["mounted","unmountSuspended"].includes(z),ref:F6.useCallback((W)=>{Z.current=W?getComputedStyle(W):null,Q(W)},[])}}function vY($){return $?.animationName||"none"}function fd($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var Ck=R(v(),1),dd=R(J5(),1);var B8=R(v(),1);function gY($){let J=vd($),Q=B8.forwardRef((Z,q)=>{let{children:X,...Y}=Z,z=B8.Children.toArray(X),K=z.find(ud);if(K){let W=K.props.children,H=z.map((B)=>{if(B===K){if(B8.Children.count(W)>1)return B8.Children.only(null);return B8.isValidElement(W)?W.props.children:null}else return B});return G(J,{...Y,ref:q,children:B8.isValidElement(W)?B8.cloneElement(W,void 0,H):null})}return G(J,{...Y,ref:q,children:X})});return Q.displayName=`${$}.Slot`,Q}function vd($){let J=B8.forwardRef((Q,Z)=>{let{children:q,...X}=Q;if(B8.isValidElement(q)){let Y=cd(q),z=md(X,q.props);if(q.type!==B8.Fragment)z.ref=Z?FB(Z,Y):Y;return B8.cloneElement(q,z)}return B8.Children.count(q)>1?B8.Children.only(null):null});return J.displayName=`${$}.SlotClone`,J}var gd=Symbol("radix.slottable");function ud($){return B8.isValidElement($)&&typeof $.type==="function"&&"__radixId"in $.type&&$.type.__radixId===gd}function md($,J){let Q={...J};for(let Z in J){let q=$[Z],X=J[Z];if(/^on[A-Z]/.test(Z)){if(q&&X)Q[Z]=(...z)=>{let K=X(...z);return q(...z),K};else if(q)Q[Z]=q}else if(Z==="style")Q[Z]={...q,...X};else if(Z==="className")Q[Z]=[q,X].filter(Boolean).join(" ")}return{...$,...Q}}function cd($){let J=Object.getOwnPropertyDescriptor($.props,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning;if(Q)return $.ref;if(J=Object.getOwnPropertyDescriptor($,"ref")?.get,Q=J&&"isReactWarning"in J&&J.isReactWarning,Q)return $.props.ref;return $.props.ref||$.ref}var pd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],OJ=pd.reduce(($,J)=>{let Q=gY(`Primitive.${J}`),Z=Ck.forwardRef((q,X)=>{let{asChild:Y,...z}=q,K=Y?Q:J;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return G(K,{...z,ref:X})});return Z.displayName=`Primitive.${J}`,{...$,[J]:Z}},{});var mY="Dialog",[Sk,kJ0]=yk(mY),[ld,R9]=Sk(mY),hk=($)=>{let{__scopeDialog:J,children:Q,open:Z,defaultOpen:q,onOpenChange:X,modal:Y=!0}=$,z=L5.useRef(null),K=L5.useRef(null),[W,H]=Pk({prop:Z,defaultProp:q??!1,onChange:X,caller:mY});return G(ld,{scope:J,triggerRef:z,contentRef:K,contentId:t5(),titleId:t5(),descriptionId:t5(),open:W,onOpenChange:H,onOpenToggle:L5.useCallback(()=>H((B)=>!B),[H]),modal:Y,children:Q})};hk.displayName=mY;var xk="DialogTrigger",id=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,...Z}=$,q=R9(xk,Q),X=NJ(J,q.triggerRef);return G(OJ.button,{type:"button","aria-haspopup":"dialog","aria-expanded":q.open,"aria-controls":q.contentId,"data-state":DB(q.open),...Z,ref:X,onClick:DJ($.onClick,q.onOpenToggle)})});id.displayName=xk;var VB="DialogPortal",[rd,fk]=Sk(VB,{forceMount:void 0}),vk=($)=>{let{__scopeDialog:J,forceMount:Q,children:Z,container:q}=$,X=R9(VB,J);return G(rd,{scope:J,forceMount:Q,children:L5.Children.map(Z,(Y)=>G(AZ,{present:Q||X.open,children:G(T9,{asChild:!0,container:q,children:Y})}))})};vk.displayName=VB;var uY="DialogOverlay",gk=L5.forwardRef(($,J)=>{let Q=fk(uY,$.__scopeDialog),{forceMount:Z=Q.forceMount,...q}=$,X=R9(uY,$.__scopeDialog);return X.modal?G(AZ,{present:Z||X.open,children:G(od,{...q,ref:J})}):null});gk.displayName=uY;var sd=gY("DialogOverlay.RemoveScroll"),od=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,...Z}=$,q=R9(uY,Q);return G(b4,{as:sd,allowPinchZoom:!0,shards:[q.contentRef],children:G(OJ.div,{"data-state":DB(q.open),...Z,ref:J,style:{pointerEvents:"auto",...Z.style}})})}),E2="DialogContent",uk=L5.forwardRef(($,J)=>{let Q=fk(E2,$.__scopeDialog),{forceMount:Z=Q.forceMount,...q}=$,X=R9(E2,$.__scopeDialog);return G(AZ,{present:Z||X.open,children:X.modal?G(nd,{...q,ref:J}):G(ad,{...q,ref:J})})});uk.displayName=E2;var nd=L5.forwardRef(($,J)=>{let Q=R9(E2,$.__scopeDialog),Z=L5.useRef(null),q=NJ(J,Q.contentRef,Z);return L5.useEffect(()=>{let X=Z.current;if(X)return M7(X)},[]),G(mk,{...$,ref:q,trapFocus:Q.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:DJ($.onCloseAutoFocus,(X)=>{X.preventDefault(),Q.triggerRef.current?.focus()}),onPointerDownOutside:DJ($.onPointerDownOutside,(X)=>{let Y=X.detail.originalEvent,z=Y.button===0&&Y.ctrlKey===!0;if(Y.button===2||z)X.preventDefault()}),onFocusOutside:DJ($.onFocusOutside,(X)=>X.preventDefault())})}),ad=L5.forwardRef(($,J)=>{let Q=R9(E2,$.__scopeDialog),Z=L5.useRef(!1),q=L5.useRef(!1);return G(mk,{...$,ref:J,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:(X)=>{if($.onCloseAutoFocus?.(X),!X.defaultPrevented){if(!Z.current)Q.triggerRef.current?.focus();X.preventDefault()}Z.current=!1,q.current=!1},onInteractOutside:(X)=>{if($.onInteractOutside?.(X),!X.defaultPrevented){if(Z.current=!0,X.detail.originalEvent.type==="pointerdown")q.current=!0}let Y=X.target;if(Q.triggerRef.current?.contains(Y))X.preventDefault();if(X.detail.originalEvent.type==="focusin"&&q.current)X.preventDefault()}})}),mk=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,trapFocus:Z,onOpenAutoFocus:q,onCloseAutoFocus:X,...Y}=$,z=R9(E2,Q),K=L5.useRef(null),W=NJ(J,K);return B7(),T(G1,{children:[G(w4,{asChild:!0,loop:!0,trapped:Z,onMountAutoFocus:q,onUnmountAutoFocus:X,children:G(w9,{role:"dialog",id:z.contentId,"aria-describedby":z.descriptionId,"aria-labelledby":z.titleId,"data-state":DB(z.open),...Y,ref:W,onDismiss:()=>z.onOpenChange(!1)})}),T(G1,{children:[G(td,{titleId:z.titleId}),G($p,{contentRef:K,descriptionId:z.descriptionId})]})]})}),MB="DialogTitle",ck=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,...Z}=$,q=R9(MB,Q);return G(OJ.h2,{id:q.titleId,...Z,ref:J})});ck.displayName=MB;var dk="DialogDescription",pk=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,...Z}=$,q=R9(dk,Q);return G(OJ.p,{id:q.descriptionId,...Z,ref:J})});pk.displayName=dk;var lk="DialogClose",ik=L5.forwardRef(($,J)=>{let{__scopeDialog:Q,...Z}=$,q=R9(lk,Q);return G(OJ.button,{type:"button",...Z,ref:J,onClick:DJ($.onClick,()=>q.onOpenChange(!1))})});ik.displayName=lk;function DB($){return $?"open":"closed"}var rk="DialogTitleWarning",[IJ0,sk]=Ek(rk,{contentName:E2,titleName:MB,docsSlug:"dialog"}),td=({titleId:$})=>{let J=sk(rk),Q=`\`${J.contentName}\` requires a \`${J.titleName}\` for the component to be accessible for screen reader users.
|
||
|
||
If you want to hide the \`${J.titleName}\`, you can wrap it with our VisuallyHidden component.
|
||
|
||
For more information, see https://radix-ui.com/primitives/docs/components/${J.docsSlug}`;return L5.useEffect(()=>{if($){if(!document.getElementById($))console.error(Q)}},[Q,$]),null},ed="DialogDescriptionWarning",$p=({contentRef:$,descriptionId:J})=>{let Z=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sk(ed).contentName}}.`;return L5.useEffect(()=>{let q=$.current?.getAttribute("aria-describedby");if(J&&q){if(!document.getElementById(J))console.warn(Z)}},[Z,$,J]),null},ok=hk;var nk=vk,NB=gk,OB=uk,AB=ck,wB=pk,ak=ik;var AJ=ok;var Qp=nk;var tk=wZ.forwardRef(({className:$,...J},Q)=>G(NB,{ref:Q,className:b0("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",$),...J}));tk.displayName=NB.displayName;var y2=wZ.forwardRef(({className:$,children:J,...Q},Z)=>G(Qp,{children:T("div",{className:`${D8}`,children:[G(tk,{}),T(OB,{ref:Z,className:b0("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",$),...Q,children:[J,T(ak,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[G(a9,{className:"h-4 w-4"}),G("span",{className:"sr-only",children:"Close"})]})]})]})}));y2.displayName=OB.displayName;var kZ=({className:$,...J})=>G("div",{className:b0("flex flex-col space-y-1.5 text-center sm:text-left",$),...J});kZ.displayName="DialogHeader";var IZ=({className:$,...J})=>G("div",{className:b0("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",$),...J});IZ.displayName="DialogFooter";var P2=wZ.forwardRef(({className:$,...J},Q)=>G(AB,{ref:Q,className:b0("text-lg font-semibold leading-none tracking-tight",$),...J}));P2.displayName=AB.displayName;var TZ=wZ.forwardRef(({className:$,...J},Q)=>G(wB,{ref:Q,className:b0("text-sm text-muted-foreground",$),...J}));TZ.displayName=wB.displayName;var Y9=R(v(),1);var cY=new Map;function Zp($,J){if(!$)return getComputedStyle(J).getPropertyValue("--multitrack-waveform").trim()||"#1D7456";if($.startsWith("var(")){let Q=$.match(/^var\((--[^)]+)\)$/);if(Q)return getComputedStyle(J).getPropertyValue(Q[1]).trim()||"#1D7456"}return $}function qp($,J,Q,Z,q){let X=window.devicePixelRatio||1,Y=$.getBoundingClientRect();if(Y.width===0||Y.height===0)return;$.width=Math.round(Y.width*X),$.height=Math.round(Y.height*X);let z=$.getContext("2d");if(!z)return;z.scale(X,X);let{width:K,height:W}=Y,H=W/2,B=Math.floor(Q*J.length),U=Math.ceil(Z*J.length),L=Math.max(U-B,1)/K;z.clearRect(0,0,K,W),z.fillStyle=Zp(q,$);for(let F=0;F<K;F++){let V=Math.min(B+Math.floor(F*L),U-1),M=J[V]*H*0.9;z.fillRect(F,H-M,1,Math.max(M*2,1))}}async function Xp($){let J=cY.get($);if(J)return J;let Q=(async()=>{let Z=await fetch($);if(!Z.ok)throw Error(`Unable to fetch waveform media: ${$}`);let q=await Z.arrayBuffer(),X=new AudioContext;try{let z=(await X.decodeAudioData(q)).getChannelData(0),K=2000,W=Math.ceil(z.length/2000),H=new Float32Array(2000);for(let B=0;B<2000;B++){let U=0,_=B*W;for(let L=_;L<_+W&&L<z.length;L++){let F=Math.abs(z[L]);if(F>U)U=F}H[B]=U}return cY.set($,H),H}finally{await X.close()}})();cY.set($,Q);try{return await Q}catch(Z){throw cY.delete($),Z}}function dY({content:$,startRatio:J=0,endRatio:Q=1,className:Z,color:q}){let X=Y9.useRef(null),Y=Y9.useRef(null),z=Z5($),K=Y9.useRef(J),W=Y9.useRef(Q),H=Y9.useRef(q);K.current=J,W.current=Q,H.current=q;let B=Y9.useCallback(()=>{let U=X.current;if(!U||!Y.current)return;qp(U,Y.current,K.current,W.current,H.current)},[]);return Y9.useEffect(()=>{if(!z){Y.current=null;return}let U=z,_=!1;async function L(){try{let F=await Xp(U);if(_)return;Y.current=F,B()}catch(F){if(!_)console.warn("[AudioWaveform] failed to decode waveform:",F)}}return L(),()=>{_=!0}},[z,B]),Y9.useEffect(()=>{B()},[J,Q,B]),Y9.useEffect(()=>{let U=X.current;if(!U)return;let _=new ResizeObserver(B);return _.observe(U),()=>_.disconnect()},[B]),G("canvas",{ref:X,className:Z,style:{display:"block",width:"100%",height:"100%"}})}function ek($){if($==="input")return"inputs";if($==="output")return"outputs";if($==="url")return"url";if($==="local")return"local";return"inputs"}function pY($,J,Q){return $/Math.max(J-1,1)*Q}function JI({track:$,totalFrames:J,frameRate:Q,displayFormat:Z,areaWidth:q,selectedId:X,onSelectedIdChange:Y,onTrackChange:z,onSegmentsChange:K,node:W,app:H,grow:B}){let U=Z1(),_=w8.useRef(null),[L,F]=w8.useState(null),[V,M]=w8.useState(null),[D,N]=w8.useState(!1),[O,I]=w8.useState("inputs"),[A,b]=w8.useState({x:0,y:0}),[k,w]=w8.useState(null),[C,y]=w8.useState(""),[f,j]=w8.useState(null),[P,x]=w8.useState(!1),p=w8.useRef([]),t=w8.useMemo(()=>K9(W,H,"audio"),[W,H,D]);w8.useEffect(()=>{return()=>{p.current.forEach((l)=>{l.removeEventListener("loadedmetadata",()=>{}),l.removeEventListener("error",()=>{}),l.src=""}),p.current=[]}},[]),w8.useEffect(()=>{let l=_.current?.closest(".comfyui-react-widget");if(!l)return;let Q0=`${D8}-overlay-active`;return l.classList.toggle(Q0,D||P),()=>l.classList.remove(Q0)},[D,P]);let h=$.segments,r=h.reduce((l,Q0)=>Math.max(l,Q0.end_frame),-1),$0=r<J-1;function Y0(l,Q0,J0,B0,W0){b({x:l,y:Q0}),I(J0),w(B0),y(W0),N(!0)}function e(l,Q0,J0,B0){let W0=_.current?.getBoundingClientRect(),L0=_.current,_0=W0&&L0?W0.width/L0.offsetWidth:1;Y0((l.clientX-(W0?.left??0))/_0,(l.clientY-(W0?.top??0))/_0,Q0,J0,B0)}function H0(l,Q0="input"){y(l);let B0=l.includes("|MULTIPLE|")?l.split("|MULTIPLE|"):[l];if(k){let _0=B0[0],D0=_0.split("/").pop()??_0,g=_0.startsWith("http")?{source_type:"url",url:_0,file_name:D0}:Q0==="local"?{source_type:"local",local_path:_0,file_name:D0}:{source_type:Q0,file_path:_0,file_name:D0};K(h.map((a)=>a.id===k?{...a,content:g}:a)),N(!1);return}async function W0(_0,D0,c0,g){let a=_0.split("/").pop()??_0,A0=_0.startsWith("http")?{source_type:"url",url:_0,file_name:a}:g==="local"?{source_type:"local",local_path:_0,file_name:a}:{source_type:g,file_path:_0,file_name:a},F0=lY(A0)??_0,u0=await new Promise((Y1)=>{let z1=new Audio(F0);p.current.push(z1),z1.preload="metadata",z1.addEventListener("loadedmetadata",()=>Y1(z1.duration)),z1.addEventListener("error",()=>Y1(5))}),P0=Math.ceil(u0*Q),n0=Math.min(J-1,D0+P0-1);if(D0>=J)return{newSeg:null,nextCursor:D0,updatedSegments:c0};let R0={id:f1(),start_frame:D0,end_frame:n0,origin_start_frame:D0,origin_end_frame:D0+P0-1,content:A0,color:$.color,markers:[]};return{newSeg:R0,nextCursor:n0+1,updatedSegments:[...c0,R0]}}async function L0(){let _0=r>=0?r+1:0,D0=[...h];for(let c0 of B0){if(_0>=J)break;if(c0.startsWith("__slot__:")){let g=c0.slice(9),I0=t.find((R0)=>R0.value===c0)?.audio_name,A0=I0?z9(I0,"input"):void 0,F0=await new Promise((R0)=>{if(A0){let Y1=new Audio(A0);p.current.push(Y1),Y1.preload="metadata",Y1.addEventListener("loadedmetadata",()=>R0(Y1.duration)),Y1.addEventListener("error",()=>R0(5))}else R0(5)}),u0=Math.ceil(F0*Q),P0=Math.min(J-1,_0+u0-1),n0={id:f1(),start_frame:_0,end_frame:P0,origin_start_frame:_0,origin_end_frame:_0+u0-1,content:{source_type:"slot",slot_name:g,file_name:g,url:A0},color:$.color,markers:[]};D0=[...D0,n0],_0=P0+1}else{let g=await W0(c0,_0,D0,Q0);if(g.newSeg)_0=g.nextCursor,D0=g.updatedSegments}}if(K([...D0].sort((c0,g)=>c0.start_frame-g.start_frame)),D0.length>h.length)w(D0[D0.length-1].id);N(!1)}L0()}function K0(l){if(K(h.filter((Q0)=>Q0.id!==l)),N(!1),X===l)Y(null)}function E(l){return h.find((Q0)=>l>=Q0.start_frame&&l<=Q0.end_frame)??null}function m(l){let Q0=_.current?.getBoundingClientRect();if(!Q0)return;let J0=q/Math.max(J-1,1),B0=Math.round((l.clientX-Q0.left)/J0);if(!E(B0))Y(null)}function c(l){l.preventDefault();let Q0=l.currentTarget.getBoundingClientRect(),J0=l.clientX-Q0.left,B0=Math.round(J0/q*(J-1));F(B0)}async function i(l){l.preventDefault();let Q0=new Set([".mp3",".wav",".flac",".ogg",".m4a",".aac",".opus",".wma"]),J0=Array.from(l.dataTransfer.files).filter((_0)=>{if(_0.type.startsWith("audio/"))return!0;let D0=`.${_0.name.split(".").pop()?.toLowerCase()??""}`;return Q0.has(D0)});if(J0.length===0){F(null);return}if(!$0)return;let B0=[...h],W0=L??(r>=0?r+1:0),L0=!1;for(let _0 of J0){if(W0>=J)break;try{let D0=new FormData;D0.append("file",_0);let c0=await fetch("/easy-media/upload",{method:"POST",body:D0});if(!c0.ok)continue;let{file_name:g}=await c0.json();L0=!0;let a=z9(g,"input"),I0=await new Promise((P0)=>{let n0=new Audio(a);n0.preload="metadata",p.current.push(n0),n0.addEventListener("loadedmetadata",()=>P0(n0.duration)),n0.addEventListener("error",()=>P0(5))}),A0=Math.ceil(I0*Q),F0=Math.min(J-1,W0+A0-1),u0={id:f1(),start_frame:W0,end_frame:F0,origin_start_frame:W0,origin_end_frame:W0+A0-1,content:{source_type:"input",file_path:g,file_name:g},color:$.color,markers:[]};B0.push(u0),W0=u0.end_frame+1}catch{}}if(L0)C5("inputs");K(B0.toSorted((_0,D0)=>_0.start_frame-D0.start_frame)),F(null)}function u(l,Q0,J0,B0=0){if($.locked)return;let W0=h.find((a)=>a.id===l);if(!W0)return;let L0=W0.origin_start_frame??W0.start_frame,_0=W0.origin_end_frame??W0.end_frame,D0=h.filter((a)=>a.id!==l).toSorted((a,I0)=>a.start_frame-I0.start_frame),c0=W0.start_frame,g=W0.end_frame;if(Q0==="start"){c0=Math.max(B0,Math.max(L0,W0.start_frame+J0));let a=D0.findLast((I0)=>I0.end_frame<W0.end_frame);if(a)c0=Math.max(c0,a.end_frame+1);c0=Math.min(c0,W0.end_frame-1)}else{g=Math.min(_0,W0.end_frame+J0),g=Math.min(g,J-1);let a=D0.find((I0)=>I0.start_frame>W0.start_frame);if(a)g=Math.min(g,a.start_frame-1);g=Math.max(g,W0.start_frame+1)}K(h.map((a)=>a.id===l?{...a,start_frame:c0,end_frame:g}:a))}function d(l,Q0,J0){if($.locked)return;let B0=h.find((a)=>a.id===l);if(!B0)return;let W0=B0.end_frame-B0.start_frame,L0=Math.max(0,J0+Q0),_0=Math.min(J-1,L0+W0),D0=_0-W0,c0=Math.max(0,D0)-B0.start_frame,g=h.map((a)=>{if(a.id!==l)return a;return{...a,start_frame:Math.max(0,D0),end_frame:Math.min(J-1,_0),origin_start_frame:(a.origin_start_frame??a.start_frame)+c0,origin_end_frame:(a.origin_end_frame??a.end_frame)+c0}}).toSorted((a,I0)=>a.start_frame-I0.start_frame);K(g)}function o(l,Q0){let J0=h.map((B0)=>{if(B0.id!==l)return B0;let W0=[...B0.markers??[],{id:f1(),frame:Q0,label:""}];return{...B0,markers:W0}});K(J0)}function S(l,Q0){let J0=h.map((B0)=>{if(B0.id!==l)return B0;return{...B0,markers:(B0.markers??[]).filter((W0)=>W0.id!==Q0)}});K(J0)}function s(l,Q0,J0){let B0=h.map((W0)=>{if(W0.id!==l)return W0;return{...W0,markers:(W0.markers??[]).map((L0)=>L0.id===Q0?{...L0,label:J0}:L0)}});K(B0),M(null)}let G0=[G("button",{type:"button",title:U("audioTrack.addMarker"),className:"w-full h-full flex items-center justify-center hover:bg-accent",onClick:()=>{if(!h.length)return;let l=h[0],Q0=Math.floor((l.start_frame+l.end_frame)/2);o(l.id,Q0)}},"marker"),void 0,void 0];return T(xY,{track:$,onTrackChange:z,toolSlots:G0,grow:B,children:[T(t1,{open:D,onOpenChange:N,children:[T(a6,{children:[G(t6,{className:"relative block w-full h-full",asChild:!0,children:T("section",{ref:_,"aria-label":U("audioTrack.dropZone"),className:"relative w-full h-full cursor-default",onDragOver:c,onDragLeave:()=>F(null),onDrop:i,onClick:m,onContextMenu:()=>x(!0),onDoubleClick:(l)=>{if(l.target.closest("[data-segment-block]"))return;if(!$0)return;e(l,"inputs",null,"")},children:[G(_6,{asChild:!0,children:G("span",{className:"absolute w-0 h-0 pointer-events-none",style:{left:A.x,top:A.y}})}),h.length===0?T("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground pointer-events-none select-none opacity-40",children:[T("div",{className:"flex items-center gap-1",children:[G(wJ,{className:"w-3 h-3"}),G("span",{className:"text-[11px]",children:U("audioTrack.placeholder")})]}),G("span",{className:"text-[10px]",children:U("audioTrack.placeholderHint")})]}):G(G1,{children:h.map((l)=>T(hY,{segment:l,totalFrames:J,areaWidth:q,interactive:!$.locked,minStart:0,selected:X===l.id,onSelect:(Q0)=>{Y(X===Q0.id?null:Q0.id)},onDoubleClick:()=>{Y0(pY(l.start_frame,J,q),8,ek(l.content.source_type),l.id,l.content.file_path??l.content.local_path??l.content.url??"")},onDragEnd:d,onResizeEnd:u,frameRate:Q,displayFormat:Z,backgroundSlot:G(dY,{content:l.content,startRatio:l.origin_end_frame!==void 0&&l.origin_start_frame!==void 0?(l.start_frame-l.origin_start_frame)/(l.origin_end_frame-l.origin_start_frame):0,endRatio:l.origin_end_frame!==void 0&&l.origin_start_frame!==void 0?(l.end_frame-l.origin_start_frame)/(l.origin_end_frame-l.origin_start_frame):1,color:"#2E6E53"}),onContextMenu:(Q0,J0)=>{Y(J0.id),j(J0.id)},children:[G("span",{className:"absolute top-0.5 truncate text-[8px]",children:l.content.file_name}),(l.markers??[]).map((Q0)=>G(a1,{delayDuration:200,children:T(H1,{children:[G(B1,{asChild:!0,children:G("button",{type:"button","aria-label":Q0.label?U("audioTrack.markerAriaLabel",{label:Q0.label}):U("audioTrack.markerAtFrame",{frame:Q0.frame}),className:"absolute top-0 w-0.5 h-full bg-yellow-300/80 cursor-pointer hover:bg-yellow-200 z-20",style:{left:pY(Q0.frame,J,q)},onClick:(J0)=>{J0.stopPropagation(),M({segId:l.id,markerId:Q0.id,label:Q0.label??""})}})}),G(W1,{side:"top",children:G("p",{children:Q0.label||U("audioTrack.frameLabel",{n:Q0.frame})})})]})},Q0.id))]},l.id))}),L!==null&&G("div",{className:"absolute top-0 w-0.5 h-full bg-foreground/60 pointer-events-none",style:{left:pY(L,J,q)}})]})}),T(y6,{onCloseAutoFocus:()=>{j(null),x(!1)},children:[G(Q5,{disabled:!$0,onClick:()=>setTimeout(()=>Y0(8,8,"inputs",null,""),0),children:U("audioTrack.contextAdd")}),f&&(()=>{let l=h.find((Q0)=>Q0.id===f);return T(G1,{children:[G(Q5,{onClick:()=>{if(!l)return;setTimeout(()=>Y0(pY(l.start_frame,J,q),8,ek(l.content.source_type),l.id,l.content.file_path??l.content.local_path??l.content.url??""),0),j(null)},children:U("audioTrack.contextEdit")}),G(Q5,{onClick:()=>{K0(f),j(null)},children:U("audioTrack.contextDelete")})]})})()]})]}),G(o1,{"data-audio-popover":"",className:"p-0 w-auto",side:"bottom",align:"start",onOpenAutoFocus:(l)=>l.preventDefault(),children:G(M5,{value:C,onChange:H0,mediaType:"audio",defaultTab:O,slotItems:t})})]}),G(AJ,{open:!!V,onOpenChange:(l)=>{if(!l)M(null)},children:T(y2,{className:"max-w-xs p-4 space-y-2",children:[G(P2,{className:"text-xs text-muted-foreground font-normal",children:U("audioTrack.markerLabelInput")}),V!=null&&(()=>{let l=V;return T(G1,{children:[G($6,{autoFocus:!0,className:"h-7 text-xs",value:l.label,onChange:(Q0)=>M({...l,label:Q0.target.value}),onKeyDown:(Q0)=>{if(Q0.key==="Enter")s(l.segId,l.markerId,l.label);if(Q0.key==="Escape")M(null)}}),T("div",{className:"flex gap-2 justify-end",children:[G(k0,{size:"sm",variant:"ghost",className:"h-6 text-xs",onClick:()=>M(null),children:U("common.cancel")}),G(k0,{size:"sm",variant:"destructive",className:"h-6 text-xs",onClick:()=>{S(l.segId,l.markerId),M(null)},children:U("common.delete")}),G(k0,{size:"sm",className:"h-6 text-xs",onClick:()=>s(l.segId,l.markerId,l.label),children:U("common.save")})]})]})})()]})}),(D||P)&&$I.createPortal(G("div",{"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:9997},onPointerDown:()=>{N(!1),x(!1)}}),document.body)]})}var v1=R(v(),1);var QI=R(v(),1);var p4=QI.forwardRef(({className:$,...J},Q)=>{return G("textarea",{className:b0("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 resize-none",$),ref:Q,...J})});p4.displayName="Textarea";function Yp($){return String($).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function zp($){return $.split(/[||]/).map(Yp).join('<span style="color:var(--highlight)" data-pipe="1">|</span>')}var ZI={fontFamily:"inherit",fontSize:"10px",lineHeight:"1.4",letterSpacing:0,whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word"};function Kp($,J,Q,Z){if($.length===0)return[];if($.length===J.length)return J.map((z,K)=>({...z,content:{...z.content,text:$[K]}}));let q=Math.max(1,$.length),X=Math.floor(Q/q),Y=Q%q;return $.map((z,K)=>({id:J[K]?.id??f1(),start_frame:K*X+Math.min(K,Y),end_frame:K<q-1?K*X+Math.min(K,Y)+X+(K<Y?1:0)-1:Q-1,content:{text:z,images:J[K]?.content.images??[],type:J[K]?.content.type??"flf"},color:J[K]?.color??Z,markers:J[K]?.markers}))}function Gp({allSegments:$,totalFrames:J,trackColor:Q,onAllSegmentsChange:Z}){let q=Z1(),X=v1.useRef(null),Y=v1.useRef(null),z=v1.useRef(!1),K=v1.useRef($);K.current=$;let W=$.map((F)=>F.content.text).join("|"),[H,B]=v1.useState(()=>W);v1.useEffect(()=>{if(z.current)return;B((F)=>F===W?F:W)},[W]);function U(){if(X.current&&Y.current)Y.current.scrollTop=X.current.scrollTop}let _=v1.useCallback((F)=>{let V=F===""?[]:F.split(/[||]/);Z(Kp(V,K.current,J,Q))},[J,Q,Z]),L=v1.useCallback((F)=>{let V=F.target.value;if(B(V),z.current)return;_(V)},[_]);return T("div",{className:"flex flex-col gap-1",children:[T("div",{className:"relative w-full h-30 overflow-hidden",children:[G("div",{ref:Y,"aria-hidden":"true",className:"absolute inset-0 overflow-y-auto pointer-events-none",style:{...ZI,padding:0},dangerouslySetInnerHTML:{__html:zp(H)}}),G(p4,{ref:X,value:H,onChange:L,onScroll:U,spellCheck:!1,onCompositionStart:()=>{z.current=!0},onCompositionEnd:()=>{z.current=!1;let F=X.current?.value??"";B(F),_(F)},className:"absolute inset-0 w-full h-full resize-none border-0 shadow-none focus-visible:ring-0 p-0 bg-transparent outline-none",style:{...ZI,color:"transparent",caretColor:"var(--foreground)"}})]}),G("p",{className:"text-[9px] text-muted-foreground",children:q("maintainTrack.combinedHint")})]})}function qI($,J){return $.map((Q,Z)=>{let q=Math.max(1,Math.floor(J/Math.max($.length,1)));return{id:String(Z),item:Q,start_frame:Q.start_frame??Z*q,end_frame:Q.end_frame??Math.min(J-1,Z*q+q-1)}})}function Wp($,J,Q,Z){let q=Z/Math.max(Q-1,1),X=$*q,Y=Math.min((J+1)*q,Z);return{left:X,width:Math.max(Y-X,20)}}async function Hp($){let J=new FormData;J.append("image",$),J.append("type","input"),J.append("overwrite","false");let Q=await fetch("/upload/image",{method:"POST",body:J});if(!Q.ok)throw Error(`Upload failed: ${Q.status}`);let Z=await Q.json();return`${Z.subfolder?`${Z.subfolder}/`:""}${Z.name}`}function Bp($,J,Q){return Q==="seconds"?`${($/J).toFixed(1)}s`:`${$}f`}function Up($,J=0.3){if(!$.startsWith("#")||$.length<7)return"var(--border)";let Q=Number.parseInt($.slice(1,3),16),Z=Number.parseInt($.slice(3,5),16),q=Number.parseInt($.slice(5,7),16),X=Math.round(Q+(255-Q)*J),Y=Math.round(Z+(255-Z)*J),z=Math.round(q+(255-q)*J);return`#${X.toString(16).padStart(2,"0")}${Y.toString(16).padStart(2,"0")}${z.toString(16).padStart(2,"0")}`}var _p=v1.default.forwardRef(function({block:J,span:Q,areaWidth:Z,frameRate:q,displayFormat:X,trackColor:Y,selected:z=!1,onSelect:K,onMoveEnd:W,onResizeEnd:H,onEdit:B,onRemove:U,onContextMenu:_},L){let F=Z1(),[V,M]=v1.useState(J.start_frame),[D,N]=v1.useState(J.end_frame),[O,I]=v1.useState(!1),[A,b]=v1.useState(!1),k=v1.useRef(J.start_frame),w=v1.useRef(J.end_frame),C=v1.useRef(!1),y=v1.useRef(!1),f=v1.useRef(null);v1.useEffect(()=>{if(!C.current)k.current=J.start_frame,w.current=J.end_frame,M(J.start_frame),N(J.end_frame)},[J.start_frame,J.end_frame]);let{left:j,width:P}=Wp(V,D,Q,Z);function x(){if(I(!0),f.current)clearTimeout(f.current)}function p(){if(C.current=!1,f.current)clearTimeout(f.current);f.current=setTimeout(()=>I(!1),2000)}function t(e){if(e.button!==0)return;e.preventDefault(),C.current=!0,y.current=!1,x();let H0=e.clientX,K0=J.start_frame,m=J.end_frame-K0,c=Z/Math.max(Q-1,1);function i(d){let o=Math.round((d.clientX-H0)/c);if(o!==0)y.current=!0;let S=Math.max(0,Math.min(Q-1-m,K0+o)),s=S+m;k.current=S,w.current=s,M(S),N(s)}function u(){p(),W(J.id,k.current,w.current),globalThis.removeEventListener("mousemove",i),globalThis.removeEventListener("mouseup",u)}globalThis.addEventListener("mousemove",i),globalThis.addEventListener("mouseup",u)}function h(e){return(H0)=>{if(H0.button!==0)return;H0.preventDefault(),H0.stopPropagation(),C.current=!0,b(!0),x();let K0=H0.clientX,E=J.start_frame,m=J.end_frame,c=Z/Math.max(Q-1,1);function i(d){let o=Math.round((d.clientX-K0)/c);if(e==="start"){let S=Math.max(0,Math.min(m-1,E+o));k.current=S,M(S)}else{let S=Math.max(E+1,Math.min(Q-1,m+o));w.current=S,N(S)}}function u(){b(!1),p(),H(J.id,k.current,w.current),globalThis.removeEventListener("mousemove",i),globalThis.removeEventListener("mouseup",u)}globalThis.addEventListener("mousemove",i),globalThis.addEventListener("mouseup",u)}}let r=[J.item],$0=A?"#eab308":z?"var(--foreground)":Up(Y),Y0=A?"#eab308":z?"var(--foreground)":"transparent";return T("div",{ref:L,role:"button",tabIndex:0,className:"absolute top-0 h-full select-none group",style:{left:j,width:P,backgroundColor:Y,opacity:0.9,border:`1px solid ${$0}`,borderRadius:3,overflow:"hidden",cursor:"grab"},onMouseDown:t,onClick:(e)=>{if(y.current)return;e.stopPropagation(),K?.(J.id)},onDoubleClick:()=>{K?.(J.id),B()},onContextMenu:_,onKeyDown:(e)=>{if(e.key==="Enter")K?.(J.id),B()},children:[r.length>0&&G("div",{className:"absolute inset-0 bg-black overflow-hidden",style:kk(r)}),G("button",{type:"button","aria-label":"Resize start",className:"absolute left-0 top-0 h-full w-0.5 cursor-ew-resize z-10 border-0 p-0",style:{background:Y0},onMouseDown:h("start")}),G("button",{type:"button","aria-label":"Resize end",className:"absolute right-0 top-0 h-full w-0.5 cursor-ew-resize z-10 border-0 p-0",style:{background:Y0},onMouseDown:h("end")}),G("button",{type:"button",className:"absolute top-0.5 right-0.5 w-3 h-3 z-20 rounded-sm bg-destructive text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:(e)=>{e.stopPropagation(),U()},title:F("common.delete"),children:"×"}),G("div",{className:"absolute bottom-0 left-0 right-0 text-center text-[8px] bg-black/60 text-white truncate px-1 pointer-events-none",children:J.item.file_name}),O&&G("div",{className:"absolute top-0.5 left-1 z-20 pointer-events-none",children:G("span",{className:"text-[9px] bg-black/80 text-white px-1 py-px rounded leading-none",children:Bp(V,q,X)})})]})});function XI({segment:$,allSegments:J,totalFrames:Q,frameRate:Z,displayFormat:q,areaWidth:X,trackColor:Y,canvasScale:z,onContentChange:K,onAllSegmentsChange:W,node:H,app:B}){let U=Z1(),_=$.end_frame-$.start_frame+1,[L,F]=v1.useState("individual"),[V,M]=v1.useState(()=>qI($.content.images,_)),D=$.content.images.map((E)=>[E.source_type,E.file_path,E.local_path,E.url,E.slot_name,E.start_frame,E.end_frame].join(":")).join("|");v1.useEffect(()=>{M(qI($.content.images,_))},[$.id,D,$.content.images,_]);let[N,O]=v1.useState(!1),[I,A]=v1.useState(null),[b,k]=v1.useState(null),[w,C]=v1.useState(""),[y,f]=v1.useState("inputs"),[j,P]=v1.useState({x:8,y:8}),x=v1.useRef(null),p=v1.useRef(!1),t=v1.useMemo(()=>K9(H,B,"image"),[H,B,N]);function h(E,m,c,i){if(E){let u=x.current?.getBoundingClientRect();P({x:E.clientX-(u?.left??0),y:E.clientY-(u?.top??0)})}p.current=!0,A(m),C(c),f(i),O(!0)}function r(E,m){let c=E.startsWith("__slot__:"),i=!c&&/^https?:\/\//i.test(E),u=c?E.slice(9):void 0,o=t.find((s)=>s.value===E)?.img,S;if(c)S={source_type:"slot",slot_name:u,file_name:u??E,url:o};else if(i)S=wk(E);else S=Ak(E,m);if(I===null){let s=V.reduce((L0,_0)=>Math.max(L0,_0.end_frame),-1),G0=s>=0?s+1:0,l=V;if(G0>=_&&V.length>0){let L0=V.at(-1),_0=Math.floor((L0.start_frame+L0.end_frame)/2);l=V.map((D0,c0)=>c0===V.length-1?{...D0,end_frame:_0}:D0),G0=_0+1}let Q0=l.length===0?Math.max(1,Math.floor(_/2)):Math.max(1,Math.floor(_/(l.length+1))),J0=Math.min(_-1,G0+Q0-1),B0={id:String(l.length),item:{...S,start_frame:G0,end_frame:J0},start_frame:G0,end_frame:J0},W0=[...l,B0];M(W0),K({images:W0.map((L0)=>({...L0.item,start_frame:L0.start_frame,end_frame:L0.end_frame}))})}else{let s=V.map((G0)=>G0.id===I?{...G0,item:{...S,start_frame:G0.start_frame,end_frame:G0.end_frame}}:G0);M(s),K({images:s.map((G0)=>({...G0.item,start_frame:G0.start_frame,end_frame:G0.end_frame}))})}O(!1)}function $0(E,m,c){let i=V.map((u)=>u.id===E?{...u,start_frame:m,end_frame:c}:u);M(i),K({images:i.map((u)=>({...u.item,start_frame:u.start_frame,end_frame:u.end_frame}))})}function Y0(E){let m=V.filter((c)=>c.id!==E);M(m),K({images:m.map((c)=>({...c.item,start_frame:c.start_frame,end_frame:c.end_frame}))})}function e(){if(V.length===0)return;let E=Math.floor(_/V.length),m=_%V.length,c=V.map((i,u)=>{let d=u<m?1:0,o=u*E+Math.min(u,m),S=u===V.length-1?_-1:o+E+d-1;return{...i,start_frame:o,end_frame:S}});M(c),K({images:c.map((i)=>({...i.item,start_frame:i.start_frame,end_frame:i.end_frame}))})}function H0(E){if(!E.dataTransfer.types.includes("Files"))return;E.preventDefault(),E.dataTransfer.dropEffect="copy"}async function K0(E){if(!E.dataTransfer.types.includes("Files"))return;E.preventDefault();let m=new Set([".png",".jpg",".jpeg",".webp",".gif",".bmp",".tiff",".tif"]),c=Array.from(E.dataTransfer.files).filter((J0)=>{if(J0.type.startsWith("image/"))return!0;let B0=`.${J0.name.split(".").pop()?.toLowerCase()??""}`;return m.has(B0)});if(c.length===0)return;let i=E.currentTarget.getBoundingClientRect(),d=((Number.isFinite(E.clientX)?E.clientX:i.left+X/2)-i.left)/z,o=Math.max(0,Math.min(_-1,Math.round(d/X*(_-1)))),S=Math.max(1,Math.floor(_/Math.max(V.length+c.length,1))),s=[];for(let J0 of c)try{s.push(await Hp(J0))}catch(B0){console.error("[EditPanel] upload failed:",B0)}if(s.length===0)return;C5("inputs");let G0=o,l=[];for(let J0 of s){if(G0>_-1)break;let B0=Math.min(_-1,G0+S-1),W0={source_type:"input",file_path:J0,file_name:J0.split("/").pop()??J0,start_frame:G0,end_frame:B0};l.push({id:String(V.length+l.length),item:W0,start_frame:G0,end_frame:B0}),G0=B0+1}if(l.length===0)return;let Q0=[...V,...l];M(Q0),K({images:Q0.map((J0)=>({...J0.item,start_frame:J0.start_frame,end_frame:J0.end_frame}))})}return T("div",{"data-edit-panel":"",className:"bg-card border border-border rounded shadow-lg overflow-hidden",style:{width:X},children:[L==="combined"?G("div",{className:"p-2 border-border",children:G(Gp,{allSegments:J,totalFrames:Q,trackColor:Y,onAllSegmentsChange:W},`combined-${$.id}-${L}`)}):T(G1,{children:[G("div",{className:"p-2 border-b border-border",children:G(p4,{className:"w-full h-16 resize-none text-[10px] border-0 shadow-none focus-visible:ring-0 p-0 bg-transparent",placeholder:U("maintainTrack.promptPlaceholder"),value:$.content.text,onChange:(E)=>K({text:E.target.value})})}),G(qY,{totalFrames:_,frameRate:Z,displayFormat:q,width:X,canvasScale:z,showLabel:!1}),T("div",{ref:x,className:"relative w-full select-none bg-muted/30",style:{height:48},onDragOver:H0,onDrop:K0,children:[V.length===0?T(a6,{children:[G(t6,{asChild:!0,children:T("button",{type:"button",className:"absolute inset-0 flex items-center justify-center gap-1 text-[10px] text-muted-foreground hover:text-foreground cursor-pointer",onClick:(E)=>h(E,null,"","inputs"),children:[G(K5,{className:"w-2.5 h-2.5"}),G("span",{children:U("maintainTrack.addImage")})]})}),G(y6,{children:G(Q5,{onClick:()=>h(null,null,"","inputs"),children:U("imageTrack.contextAdd")})})]}):T(G1,{children:[V.map((E)=>{return T(a6,{children:[G(t6,{asChild:!0,children:G(_p,{block:E,span:_,areaWidth:X,frameRate:Z,displayFormat:q,trackColor:Y,selected:b===E.id,onSelect:k,onMoveEnd:$0,onResizeEnd:$0,onEdit:()=>h(null,E.id,E.item.file_path??E.item.url??"",E.item.source_type==="url"?"url":"inputs"),onRemove:()=>Y0(E.id)})}),T(y6,{children:[G(Q5,{onClick:()=>{k(E.id),h(null,E.id,E.item.file_path??E.item.url??"",E.item.source_type==="url"?"url":"inputs")},children:U("imageTrack.contextReselect")}),G(Q5,{onClick:()=>h(null,null,"","inputs"),children:U("imageTrack.contextAdd")}),G(Q5,{disabled:V.length<1,onClick:e,children:U("imageTrack.contextDistribute")}),G(x3,{}),G(Q5,{className:"text-destructive focus:text-destructive",onClick:()=>Y0(E.id),children:U("imageTrack.contextDelete")})]})]},E.id)}),G("button",{type:"button",className:"absolute right-1 top-1/2 w-5 h-5 flex items-center justify-center rounded border border-dashed border-border bg-card transition-colors text-muted-foreground z-30 cursor-pointer",onClick:(E)=>{E.stopPropagation(),h(E,null,"","inputs")},title:U("maintainTrack.addImage"),children:G(K5,{className:"w-3 h-3"})})]}),T(t1,{open:N,onOpenChange:(E)=>{if(!E)O(!1)},children:[G(_6,{asChild:!0,children:G("span",{className:"absolute w-0 h-0 pointer-events-none",style:{left:j.x,top:j.y}})}),G(o1,{className:"p-0 w-auto",side:"bottom",align:"start",onOpenAutoFocus:(E)=>E.preventDefault(),onInteractOutside:(E)=>{if(p.current)p.current=!1,E.preventDefault()},children:G(M5,{value:w,onChange:r,mediaType:"image",defaultTab:y,slotItems:t})})]})]})]}),T("div",{className:"flex items-center space-between gap-2 p-2 border-t",children:[G(c4,{value:L,onValueChange:(E)=>F(E),children:T(o9,{className:"h-6",children:[G(H8,{value:"individual",className:"text-[10px] h-5 px-2",children:U("maintainTrack.tabIndividual")}),G(H8,{value:"combined",className:"text-[10px] h-5 px-2",children:U("maintainTrack.tabCombined")})]})}),L==="combined"?G(G1,{}):G("div",{className:"flex items-center gap-2 ml-auto",children:T(y8,{value:$.content.type,onValueChange:(E)=>K({type:E}),children:[G(P8,{className:"h-6 w-28 text-[10px]",children:G(W6,{})}),T(R8,{children:[G(i5,{value:"flf",children:U("maintainTrack.flf")}),G(i5,{value:"fmlf",children:U("maintainTrack.fmlf")}),G(i5,{value:"ref",children:U("maintainTrack.ref")})]})]})})]})]})}var iY=R(v(),1);function t9($){let[J,Q]=iY.useState(()=>$?.canvas?.ds?.scale??1);return iY.useEffect(()=>{if(!$?.canvas)return;let Z=$.canvas,q=Z.onDrawForeground?.bind(Z);return Z.onDrawForeground=(...X)=>{q?.(...X);let Y=Z.ds?.scale??1;Q((z)=>z!==Y?Y:z)},()=>{Z.onDrawForeground=q}},[$]),J}var rY=R(v(),1);function kJ($){let[J,Q]=rY.useState(0);return rY.useLayoutEffect(()=>{let Z=$.current;if(!Z)return;let q=new ResizeObserver(()=>Q(Z.clientWidth));return q.observe(Z),Q(Z.clientWidth),()=>q.disconnect()},[$]),J}var YI=R(v(),1);function zI($){let J=YI.useRef($);return J.current=$,J}function Lp($){if($&&typeof $==="object"&&!Array.isArray($)){let J=$;if(Array.isArray(J.tracks)&&typeof J.total_length==="number"&&typeof J.frame_rate==="number")return $}return KI()}function Fp($){return lY($.content)}var sY={current:-1};function Vp($,J,Q,Z,q){if(!(Q>=J.start_frame&&Q<=J.end_frame)){if(!$.paused)$.pause();return}if(Q!==sY.current){let Y=J.origin_start_frame??J.start_frame,K=(Q-Y)/Z;if(Math.abs($.currentTime-K)>0.1)$.currentTime=K;sY.current=Q}if(q){if($.paused&&$.readyState>=2)$.play().catch(()=>{})}else if(!$.paused)$.pause()}function Mp({value:$,onChange:J,app:Q,node:Z}){let q=Lp($),[X,Y]=U8.useState("frames"),[z,K]=U8.useState(null),W=U8.useRef(null),H=U8.useRef(null),B=kJ(H),[U,_]=U8.useState(!1),[L,F]=U8.useState(0),[V,M]=U8.useState(!1),D=U8.useRef(null),[N,O]=U8.useState(1),I=Q?.ui?.settings?.settingsValues?.["Comfy.VueNodes.Enabled"],A=Q?.ui?.settings?.settingsValues?.["Comfy.Locale"],b=t9(Q),k=U8.useRef({rafId:null,lastTimestamp:null,frame:0,audioEls:new Map}),w=Math.max(B,1)*N;function C(d){let o=H.current;if(!o||o.scrollWidth<=o.clientWidth)return;d.preventDefault(),d.stopPropagation();let S=d.deltaMode===1?16:d.deltaMode===2?o.clientWidth:1,s=Math.abs(d.deltaX)>Math.abs(d.deltaY)?d.deltaX:d.deltaY;o.scrollLeft=Math.max(0,Math.min(o.scrollWidth-o.clientWidth,o.scrollLeft+s*S))}let y=zI(q);U8.useEffect(()=>{k.current.frame=L},[L]);function f(){let{tracks:d}=y.current,o=k.current,S=d.filter((s)=>s.type==="audio").flatMap((s)=>s.segments);for(let s of S)if(!o.audioEls.has(s.id)){let G0=Fp(s);if(!G0)continue;let l=new Audio(G0);l.preload="auto",l.playbackRate=1,o.audioEls.set(s.id,l)}else{let G0=o.audioEls.get(s.id);if(G0.playbackRate===1)continue;G0.playbackRate=1}for(let[s,G0]of o.audioEls.entries())if(!S.some((l)=>l.id===s))G0.pause(),o.audioEls.delete(s)}function j(d,o){let{frame_rate:S,tracks:s}=y.current,G0=s.filter((l)=>l.type==="audio").flatMap((l)=>l.segments);for(let[l,Q0]of k.current.audioEls.entries()){let J0=G0.find((B0)=>B0.id===l);if(J0)Vp(Q0,J0,d,S,o);else if(!Q0.paused)Q0.pause()}}U8.useEffect(()=>{f()},[q.tracks]),U8.useEffect(()=>{let d=k.current;if(!U){if(d.rafId!==null)cancelAnimationFrame(d.rafId),d.rafId=null,sY.current=-1;j(d.frame,!1);return}f();let o={current:0},S={current:0};function s(G0){let l=(G0-o.current)/1000,{frame_rate:Q0,total_length:J0}=y.current,B0=S.current+l*Q0,W0=Math.min(J0-1,B0);if(d.frame=W0,F(Math.round(W0)),j(W0,!0),W0>=J0-1){if(_(!1),M(!0),D.current)clearTimeout(D.current);D.current=setTimeout(()=>M(!1),1500);return}d.rafId=requestAnimationFrame(s)}return o.current=performance.now(),S.current=d.frame,d.rafId=requestAnimationFrame(s),()=>{if(d.rafId!==null)cancelAnimationFrame(d.rafId)}},[U]),U8.useEffect(()=>{return()=>{for(let d of k.current.audioEls.values())d.pause()}},[]),U8.useEffect(()=>{if(!U||!H.current)return;let d=H.current,o=L/Math.max(q.total_length-1,1)*w,{scrollLeft:S,clientWidth:s}=d,G0=s*0.15;if(o<S+G0)d.scrollLeft=Math.max(0,o-G0);else if(o>S+s-G0)d.scrollLeft=o-s+G0},[L,U,w,q.total_length]);function P(d){J({...q,...d})}function x(d,o){P({tracks:q.tracks.map((S)=>S.id===d?{...S,...o}:S)})}function p(d,o){P({tracks:q.tracks.map((S)=>S.id===d?{...S,segments:o}:S)})}function t(d){if(I)d.stopPropagation()}function h(){if(!U&&L>=q.total_length-1)F(0),k.current.frame=0;let d=U;if(_((o)=>!o),d){if(M(!0),D.current)clearTimeout(D.current);D.current=setTimeout(()=>M(!1),1500)}else M(!1)}function r(d){if(F(d),k.current.frame=d,sY.current=d,j(d,U),M(!0),!U){if(D.current)clearTimeout(D.current);D.current=setTimeout(()=>M(!1),1500)}}function $0(){if(!z)return;let d=q.tracks.map((o)=>{if(o.type!=="maintain")return{...o,segments:o.segments.filter((J0)=>J0.id!==z)};let S=o.segments,s=S.findIndex((J0)=>J0.id===z);if(s===-1)return o;if(S.length===1)return{...o,segments:[]};let G0=S[s],l=G0.end_frame-G0.start_frame+1,Q0=S.map((J0,B0)=>{if(B0===s)return null;let W0={...J0};if(B0>s)W0.start_frame=J0.start_frame-l,W0.end_frame=J0.end_frame-l;return W0}).filter((J0)=>J0!==null);if(s>0)Q0[s-1]={...Q0[s-1],end_frame:G0.start_frame-1};return{...o,segments:Q0}});P({tracks:d}),K(null)}let Y0=q.tracks.find((d)=>d.type==="maintain"),e=Y0&&z?Y0.segments.find((d)=>d.id===z)??null:null;U8.useEffect(()=>{let d=W.current?.closest(".comfyui-react-widget");if(!d)return;let o=`${D8}-timeline-editor-open`;return d.classList.toggle(o,e!==null),()=>d.classList.remove(o)},[e]);function H0(d){if(!Y0||!z)return;p(Y0.id,Y0.segments.map((o)=>o.id===z?{...o,content:{...o.content,...d}}:o))}function K0(d,o){if(!Y0)return;let S=Y0.segments,s=S.findIndex((_0)=>_0.id===d);if(s===-1)return;let G0=S[s],l=G0.end_frame-G0.start_frame+1;if(o===l)return;let Q0=o-l,J0=G0.end_frame+Q0,B0=S.map((_0,D0)=>{if(D0<s)return _0;if(D0===s)return{..._0,end_frame:J0,content:{..._0.content,images:OZ(_0.content.images,l,o)}};return{..._0,start_frame:_0.start_frame+Q0,end_frame:_0.end_frame+Q0}}),W0=B0.reduce((_0,D0)=>Math.max(_0,D0.end_frame),0),L0=Math.max(q.total_length,W0+1);P({tracks:q.tracks.map((_0)=>_0.type==="maintain"?{..._0,segments:B0}:_0),total_length:L0})}function E(d){let o=d.target;if(o.closest("[data-edit-panel]")||o.closest("[data-segment-block]")||o.closest("[data-add-popover]")||o.closest("[data-media-selector]")||o.closest("[data-audio-popover]")||o.closest("[data-time-toolbar]")||o.closest("[data-radix-popper-content-wrapper]")||o.closest("[data-radix-context-menu-content]"))return;K(null)}let i=Math.min(1.5,Math.max(0.8,1/b)),u=B/i;return G(P6.Provider,{value:A,children:G(a1,{children:T("div",{ref:W,className:`relative flex flex-col h-full w-full text-foreground font-sans text-xs select-none${I?" nodeNew":""}`,onContextMenu:t,onClick:E,children:[T("div",{className:"flex flex-col flex-1 min-h-0 rounded overflow-hidden",children:[G(iN,{totalLength:q.total_length,frameRate:q.frame_rate,displayFormat:X,onTotalLengthChange:(d)=>{let o=q.total_length;if(d<o&&Y0){let s=Y0.segments.map((l)=>{if(l.end_frame>=d){let Q0=l.end_frame-l.start_frame+1,J0=d-l.start_frame;return{...l,end_frame:d-1,content:{...l.content,images:OZ(l.content.images,Q0,J0)}}}return l}),G0=5;for(let l=s.length-1;l>=0;l--){let Q0=s[l],J0=Q0.end_frame-Q0.start_frame+1;if(J0<G0){let B0=J0;if(s=s.map((W0,L0)=>{if(L0===l)return null;let _0={...W0};if(L0>l)_0.start_frame=Math.max(0,W0.start_frame-B0),_0.end_frame=Math.max(0,W0.end_frame-B0);return _0}).filter((W0)=>W0!==null),l>0)s[l-1]={...s[l-1],end_frame:Q0.start_frame-1}}}P({tracks:q.tracks.map((l)=>l.type==="maintain"?{...l,segments:s}:l),total_length:d})}else P({total_length:d})},onFrameRateChange:(d)=>P({frame_rate:d}),onDisplayFormatChange:Y,isPlaying:U,onPlayPause:h,hasSelection:z!==null,canDelete:z!==null&&(q.tracks.some((d)=>d.type!=="maintain"&&d.segments.some((o)=>o.id===z))||(Y0?.segments.length??0)>0),onDeleteSelected:$0,zoom:N,onZoomChange:O,selectedSegment:e,onSelectedSegmentDurationChange:K0}),G("div",{ref:H,className:"flex-1 min-h-0 overflow-x-hidden overflow-y-auto",children:T("div",{className:"h-full flex flex-col",style:{width:w,minWidth:"100%"},children:[G("div",{className:"border-t shrink-0",children:G(qY,{totalFrames:q.total_length,frameRate:q.frame_rate,displayFormat:X,width:w,canvasScale:b,playheadFrame:L,showLabel:V||U,onSeek:r,onWheel:C})}),T("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[L!==void 0&&w>0&&G("div",{className:"absolute top-0 h-full w-px bg-red-400 pointer-events-none z-30",style:{left:L/Math.max(q.total_length-1,1)*w}}),q.tracks.map((d)=>{if(d.type==="maintain")return G(Tk,{track:d,totalFrames:q.total_length,frameRate:q.frame_rate,displayFormat:X,areaWidth:w,canvasScale:b,selectedId:z,onSelectedIdChange:K,onTrackChange:(o)=>x(d.id,o),onSegmentsChange:(o)=>p(d.id,o),onExtendTimeline:(o,S)=>{P({tracks:q.tracks.map((s)=>s.type==="maintain"?{...s,segments:o}:s),total_length:S})},grow:2},d.id);if(d.type==="audio")return G(JI,{track:d,totalFrames:q.total_length,frameRate:q.frame_rate,displayFormat:X,areaWidth:w,selectedId:z,onSelectedIdChange:K,onTrackChange:(o)=>x(d.id,o),onSegmentsChange:(o)=>p(d.id,o),node:Z,app:Q,grow:1},d.id);return null})]})]})})]}),e&&Y0&&G("div",{className:"absolute left-0 z-50",style:{top:"100%",transformOrigin:"top left",transform:`scale(${i})`,width:u},children:G(XI,{segment:e,allSegments:Y0.segments,totalFrames:q.total_length,frameRate:q.frame_rate,displayFormat:X,areaWidth:u,canvasScale:b*i,trackColor:Y0.color,onContentChange:H0,onAllSegmentsChange:(d)=>{if(p(Y0.id,d),z&&!d.some((o)=>o.id===z))K(null)},node:Z,app:Q})})]})})})}var i1=R(v(),1);var V6=R(v(),1),kB=50;function l4($){return JSON.stringify($)}function GI($,J){let[Q,Z]=V6.useState({past:[],future:[]}),q=V6.useRef($),X=V6.useRef(l4($)),Y=V6.useRef(l4($)),z=V6.useRef(new Set),K=V6.useRef(new Set),W=l4($);V6.useLayoutEffect(()=>{let _=z.current;if(_.size>0){if(_.has(W)){if(_.delete(W),_.size===0)K.current.clear();Y.current=W,X.current=W,q.current=$;return}if(W===Y.current||K.current.has(W))return;_.clear(),K.current.clear(),X.current=W,Y.current=W,q.current=$,Z({past:[],future:[]});return}if(q.current=$,W!==X.current){X.current=W,Y.current=W,Z({past:[],future:[]});return}Y.current=W},[$,W]);let H=V6.useCallback((_)=>{let L=q.current,F=l4(L),V=l4(_);if(V===F)return;X.current=V,z.current.add(V),K.current.add(F),q.current=_,Z((M)=>({past:[...M.past,L].slice(-kB),future:[]})),J(_)},[J]),B=V6.useCallback(()=>{Z((_)=>{let L=_.past.at(-1);if(!L)return _;let F=q.current,V=l4(F),M=l4(L);return X.current=M,z.current.add(M),K.current.add(V),q.current=L,J(L),{past:_.past.slice(0,-1),future:[F,..._.future].slice(0,kB)}})},[J]),U=V6.useCallback(()=>{Z((_)=>{let L=_.future[0];if(!L)return _;let F=q.current,V=l4(F),M=l4(L);return X.current=M,z.current.add(M),K.current.add(V),q.current=L,J(L),{past:[..._.past,F].slice(-kB),future:_.future.slice(1)}})},[J]);return{canUndo:Q.past.length>0,canRedo:Q.future.length>0,commitChange:H,undo:B,redo:U}}var nY=R(v(),1);var Dp=250;function IB($){try{return JSON.stringify($)}catch(J){return console.error("[useMultiTrackResolutionInput] failed to serialize resolution input:",J),String(Date.now())}}function aY($){let[J,Q]=nY.useState(()=>oY($));return nY.useEffect(()=>{let Z=oY($),q=IB(Z);Q((Y)=>IB(Y)===q?Y:Z);let X=window.setInterval(()=>{Z=oY($);let Y=IB(Z);if(Y===q)return;q=Y,Q(Z)},Dp);return()=>window.clearInterval(X)},[$]),J}var TB="easy-media-model-missing";class R2 extends Error{model;constructor($,J){super($);this.name="MissingModelError",this.model=J}}function Np($){if(!$||typeof $!=="object")return!1;let J=$;return typeof J.name==="string"&&typeof J.display_name==="string"&&typeof J.filename==="string"&&typeof J.directory==="string"&&typeof J.path==="string"&&typeof J.url==="string"&&(J.urls===void 0||Array.isArray(J.urls)&&J.urls.every((Q)=>typeof Q==="string"))}function tY($){return Np($)?$:null}function IJ($){if(!$||typeof $!=="object")return;let J=$,Q=tY(J.model_missing);if(!Q)return;let Z=typeof J.error==="string"?J.error:`${Q.display_name} model is not installed.`;throw new R2(Z,Q)}async function WI($){let J=await fetch("/easy-media/models/download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model_name:$})}),Q;try{Q=await J.json()}catch(q){throw Error(`Model download returned invalid JSON: ${String(q)}`)}if(!J.ok){let q=Q&&typeof Q==="object"&&"error"in Q?String(Q.error):`Model download failed (${J.status})`;throw Error(q)}if(!Q||typeof Q!=="object")throw Error("Invalid model download response");let Z=tY(Q.model);if(!Z)throw Error("Invalid model download response");return Z}function Op($){if(!$||typeof $!=="object")throw Error("Invalid smart split response");let J=$;if(typeof J.error==="string")throw Error(J.error);if(!Array.isArray(J.ranges))throw Error("Invalid smart split response");return{ranges:J.ranges.map((Z)=>{if(!Array.isArray(Z)||Z.length!==2||!Z.every(Number.isFinite))throw Error("Invalid shot range in smart split response");return[Number(Z[0]),Number(Z[1])]})}}async function bB($,J){let Q=await fetch("/easy-media/video/smart-split",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_type:$.content.source_type??"input",file_path:$.content.file_path,local_path:$.content.local_path,url:$.content.url,fps:J})}),Z;try{Z=await Q.json()}catch(q){throw Error(`Smart split returned invalid JSON: ${String(q)}`)}if(!Q.ok){IJ(Z);let q=Z&&typeof Z==="object"&&"error"in Z?String(Z.error):`Smart split failed (${Q.status})`;throw Error(q)}return Op(Z)}function eY($,J,Q){let Z=[$.start_frame,...J,$.end_frame];return Z.slice(0,-1).map((q,X)=>({...$,id:X===0?$.id:f1(),start_frame:q,end_frame:Z[X+1],...Q===void 0?{}:{origin_start_frame:Q},content:{...$.content,images:$.content.images?.map((Y)=>({...Y}))}}))}function jB($,J){return $.tracks.find((Q)=>Q.type==="video"&&Q.segments.some((Z)=>Z.id===J))?.segments.find((Q)=>Q.id===J)}function HI($,J){let Q=$.origin_start_frame??$.start_frame;return[...new Set(J.ranges.map((Z)=>Z[1]+Q).filter((Z)=>Z>$.start_frame&&Z<$.end_frame))].sort((Z,q)=>Z-q)}function BI($,J){let Q=jB($,J);if(!Q)return!1;return $.tracks.some((Z)=>Z.type==="task"&&Z.segments.some((q)=>q.start_frame===Q.start_frame&&q.end_frame===Q.end_frame))}function UI($,J,Q){let Z=jB($,J);if(!Z)return $;let q=Z.end_frame-Z.start_frame,X=Z.origin_start_frame??Z.start_frame,Y=HI(Z,Q);if(q<=1||Y.length===0)return $;let z=$.tracks.map((K)=>({...K,segments:K.segments.flatMap((W)=>{let H=W.id===J,B=K.type==="task"&&W.start_frame===Z.start_frame&&W.end_frame===Z.end_frame;if(H)return eY(W,Y,X);return B?eY(W,Y):[W]}).sort((W,H)=>W.start_frame-H.start_frame)}));return{...$,tracks:z}}function _I($,J,Q){let Z=jB($,J);if(!Z)return $;let q=HI(Z,Q);if(q.length===0)return $;return{...$,tracks:$.tracks.map((X)=>({...X,segments:X.segments.flatMap((Y)=>X.type==="task"&&Y.start_frame===Z.start_frame&&Y.end_frame===Z.end_frame?eY(Y,q):[Y]).sort((Y,z)=>Y.start_frame-z.start_frame)}))}}function EB($,J,Q){let Z=$.tracks.flatMap((z)=>z.segments).find((z)=>z.id===J),q=Math.round(Q);if(!Z||q<=Z.start_frame||q>=Z.end_frame)return $;let Y=Z.content.media_type==="video"||Z.content.media_type==="audio"?Z.origin_start_frame??Z.start_frame:void 0;return{...$,tracks:$.tracks.map((z)=>({...z,segments:z.segments.flatMap((K)=>K.id===J?eY(K,[q],Y):[K]).sort((K,W)=>K.start_frame-W.start_frame)}))}}var C2="#9D4937",h2={font_size:12,color:"#ffffff",outline_color:"#000000",background_color:"rgba(0, 0, 0, 0)",background_opacity:0.7,x:0.125,y:0.8,width:0.75};function Ap($){if(!$||typeof $!=="object")throw Error("Invalid subtitle segment");let J=$,Q=Number(J.start),Z=Number(J.end);if(!Number.isFinite(Q)||!Number.isFinite(Z)||Z<=Q)throw Error("Invalid subtitle timestamp");if(typeof J.text!=="string")throw Error("Invalid subtitle text");return{start:Q,end:Z,text:J.text}}function wp($){if(!$||typeof $!=="object")throw Error("Invalid subtitle recognition response");let J=$;if(typeof J.error==="string")throw Error(J.error);if(!Array.isArray(J.segments))throw Error("Invalid subtitle recognition response");return{segments:J.segments.map(Ap)}}function kp($,J){return $.tracks.find((Q)=>(Q.type==="video"||Q.type==="audio")&&Q.segments.some((Z)=>Z.id===J))?.segments.find((Q)=>Q.id===J)}function Ip($){return{id:f1(),name:`Subtitle ${$+1}`,type:"subtitle",color:C2,muted:!1,solo:!1,volume_db:S2,locked:!1,segments:[]}}async function LI($,J,Q="qwen3-asr"){let Z=await fetch("/easy-media/subtitles/recognize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({media_type:$.content.media_type,source_type:$.content.source_type??"input",file_path:$.content.file_path,local_path:$.content.local_path,url:$.content.url,fps:J,start_frame:$.start_frame,end_frame:$.end_frame,origin_start_frame:$.origin_start_frame,method:Q})}),q;try{q=await Z.json()}catch(X){throw Error(`Subtitle recognition returned invalid JSON: ${String(X)}`)}if(!Z.ok){IJ(q);let X=q&&typeof q==="object"&&"error"in q?String(q.error):`Subtitle recognition failed (${Z.status})`;throw Error(X)}return wp(q)}function FI($,J,Q){let Z=kp($,J);if(!Z||Q.segments.length===0)return $;let q=Q.segments.flatMap((K)=>{let W=Math.max(Z.start_frame,Z.start_frame+C9(K.start,$.frame_rate)),H=Math.min(Z.end_frame,Z.start_frame+C9(K.end,$.frame_rate));if(H<=W)return[];return[{id:f1(),start_frame:W,end_frame:H,color:C2,content:{media_type:"subtitle",text:K.text,subtitle_style:{...h2}}}]});if(q.length===0)return $;let X=!1,Y=$.tracks.map((K)=>{if(K.type!=="subtitle")return K;if(X)return K;return X=!0,{...K,color:K.color||C2,segments:[...K.segments,...q].sort((W,H)=>W.start_frame-H.start_frame)}}),z=X?Y:[...$.tracks,{...Ip($.tracks.filter((K)=>K.type==="subtitle").length),segments:q}];return{...$,tracks:z,total_length:_8(z,$.frame_rate)}}var jZ={model:"VoxCPM2",prompt:"",cfg:2,steps:10,referenceAudio:"",referenceAudioSourceType:"input"};async function Tp($){if(!$.referenceAudio)return{path:void 0,sourceType:void 0};if(!/^https?:\/\//i.test($.referenceAudio))return{path:$.referenceAudio,sourceType:$.referenceAudioSourceType??"input"};let J=await fetch("/easy-media/download-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:$.referenceAudio})}),Q;try{Q=await J.json()}catch(q){throw Error(`Reference audio download returned invalid JSON: ${String(q)}`)}let Z=Q&&typeof Q==="object"&&"file_name"in Q?Q.file_name:void 0;if(!J.ok||typeof Z!=="string"||!Z){let q=Q&&typeof Q==="object"&&"error"in Q?String(Q.error):`Reference audio download failed (${J.status})`;throw Error(q)}return{path:Z,sourceType:"input"}}function bp($){if(!$||typeof $!=="object")throw Error("Invalid subtitle speech response");let J=$;if(typeof J.error==="string")throw Error(J.error);if(typeof J.file_path!=="string"||J.source_type!=="output")throw Error("Invalid subtitle speech response");return{filePath:J.file_path,sourceType:"output",absolutePath:typeof J.absolute_path==="string"?J.absolute_path:"",message:typeof J.message==="string"?J.message:"",duration:typeof J.duration==="number"&&Number.isFinite(J.duration)?J.duration:void 0}}async function VI($){let J=await Tp($),Q=await fetch("/easy-media/subtitles/speech",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:$.text,model:$.model,prompt:$.prompt,cfg:$.cfg,steps:$.steps,reference_audio_path:J.path,reference_audio_source_type:J.sourceType})}),Z;try{Z=await Q.json()}catch(q){throw Error(`Subtitle speech returned invalid JSON: ${String(q)}`)}if(!Q.ok){IJ(Z);let q=Z&&typeof Z==="object"&&"error"in Z?String(Z.error):`Subtitle speech failed (${Q.status})`;throw Error(q)}return bp(Z)}function jp($,J,Q,Z){return Math.max($,Q)<Math.min(J,Z)}function Ep($,J){return{id:f1(),name:`Audio ${$}`,type:"audio",color:bZ.audio,muted:!1,solo:!1,volume_db:S2,locked:!1,segments:[J]}}function MI($,J){if(J.endFrame<=J.startFrame)return $;let Q=J.endFrame-J.startFrame,Z=J.duration??Q/$.frame_rate,q=J.duration&&Number.isFinite(J.duration)?Math.max(1,C9(J.duration,$.frame_rate)):Q,X=J.startFrame+q,Y={id:f1(),start_frame:J.startFrame,end_frame:X,color:bZ.audio,content:{media_type:"audio",source_type:"output",file_path:J.filePath,file_name:J.filePath.split(/[\\/]/).pop()??J.filePath,duration:Z,muted:!1,volume_db:S2}},z=!1,K=$.tracks.map((H)=>{if(H.type!=="audio"||z)return H;if(H.segments.some((U)=>jp(J.startFrame,X,U.start_frame,U.end_frame)))return H;return z=!0,{...H,segments:[...H.segments,Y].sort((U,_)=>U.start_frame-_.start_frame)}}),W=z?K:[...K,Ep($.tracks.filter((H)=>H.type==="audio").length,Y)];return{...$,tracks:W,total_length:_8(W,$.frame_rate)}}var yp=/^(\d+):([0-5]\d):([0-5]\d)[,.](\d{3})\s*-->\s*(\d+):([0-5]\d):([0-5]\d)[,.](\d{3})(?:\s+.*)?$/;function DI($){let[J,Q,Z,q]=$.map(Number);return J*3600+Q*60+Z+q/1000}function Pp($){let J=$.replace(/^\uFEFF/,"").replaceAll(`\r
|
||
`,`
|
||
`).replaceAll("\r",`
|
||
`).split(`
|
||
`),Q=[];for(let Z=0;Z<J.length;Z+=1){let q=J[Z]?.trim().match(yp);if(!q)continue;let X=DI(q.slice(1,5)),Y=DI(q.slice(5,9)),z=[];Z+=1;while(Z<J.length&&J[Z]?.trim()!=="")z.push(J[Z]??""),Z+=1;let K=z.join(`
|
||
`).trim();if(K&&Y>X)Q.push({startSeconds:X,endSeconds:Y,text:K})}return Q}function NI($,J){let Q=Pp($).sort((q,X)=>q.startSeconds-X.startSeconds||q.endSeconds-X.endSeconds);if(Q.length===0)throw Error("No valid SRT subtitle cues found");let Z=Q[0].startSeconds;return Q.map((q,X)=>{let Y=J.startFrame+Math.round((q.startSeconds-Z)*J.frameRate),z=Math.max(Y+1,J.startFrame+Math.round((q.endSeconds-Z)*J.frameRate));return{id:J.createId(X),start_frame:Y,end_frame:z,color:J.color,content:{media_type:"subtitle",text:q.text,subtitle_style:{...J.subtitleStyle}}}})}function yB($,J){if(!J)return!1;try{return new URL($,J).origin===new URL(J).origin}catch(Q){return console.error("[audio-utils] failed to resolve media origin:",Q),!1}}function OI($,J,Q=globalThis.location?.href){let q=10**((Number.isFinite($)?$:0)/20);return yB(J,Q)?q:Math.min(1,q)}function PB($){return new Promise((J,Q)=>{let Z=new Audio,q=()=>{Z.removeEventListener("loadedmetadata",X),Z.removeEventListener("error",Y),Z.src=""},X=()=>{let z=Z.duration;if(q(),!Number.isFinite(z)||z<=0){Q(Error(`Invalid audio duration for ${$}`));return}J({duration:z})},Y=()=>{q(),Q(Error(`Unable to load audio metadata for ${$}`))};Z.addEventListener("loadedmetadata",X),Z.addEventListener("error",Y),Z.preload="metadata",Z.src=$})}function EZ($){return new Promise((J,Q)=>{let Z=document.createElement("video");Z.preload="metadata",Z.muted=!0,Z.onloadedmetadata=()=>{J({duration:Number.isFinite(Z.duration)?Z.duration:0,width:Z.videoWidth,height:Z.videoHeight})},Z.onerror=()=>Q(Error(`Unable to load video metadata: ${$}`)),Z.src=$})}function AI($,J=0.1){return new Promise((Q,Z)=>{let q=document.createElement("video");q.preload="auto",q.muted=!0,q.playsInline=!0;function X(){try{let{videoWidth:Y,videoHeight:z}=q;if(Y<=0||z<=0){Z(Error(`Unable to capture video frame: ${$}`));return}let K=document.createElement("canvas");K.width=Y,K.height=z;let W=K.getContext("2d");if(!W){Z(Error("Unable to create canvas context for video frame"));return}W.drawImage(q,0,0,Y,z),K.toBlob((H)=>{if(!H){Z(Error(`Unable to encode video frame: ${$}`));return}Q(URL.createObjectURL(H))},"image/jpeg",0.8)}catch(Y){Z(Y instanceof Error?Y:Error(`Unable to capture video frame: ${$}`))}}q.onloadeddata=()=>{let Y=Number.isFinite(q.duration)?Math.max(0,Math.min(J,Math.max(0,q.duration-0.001))):Math.max(0,J);if(Y>0){q.currentTime=Y;return}X()},q.onseeked=X,q.onerror=()=>Z(Error(`Unable to load video frame: ${$}`)),q.src=$})}var $z=R(v(),1);var wI=yZ("SplitCenterIcon",[["path",{d:"M5 4h4v16H5",key:"left-bracket"}],["path",{d:"M19 4h-4v16h4",key:"right-bracket"}]]),kI=yZ("SplitLeftDotsIcon",[["path",{d:"M20 4h-4v16h4",key:"bracket"}],["path",{d:"M6 4h.01",key:"d1"}],["path",{d:"M6 20h.01",key:"d3"}],["path",{d:"M11 4h.01",key:"d4"}],["path",{d:"M11 8h.01",key:"d5"}],["path",{d:"M11 12h.01",key:"d6"}],["path",{d:"M11 16h.01",key:"d7"}],["path",{d:"M11 20h.01",key:"d8"}]]),II=yZ("SplitRightDotsIcon",[["path",{d:"M4 4h4v16H4",key:"bracket"}],["path",{d:"M13 4h.01",key:"d1"}],["path",{d:"M13 8h.01",key:"d2"}],["path",{d:"M13 12h.01",key:"d3"}],["path",{d:"M13 16h.01",key:"d4"}],["path",{d:"M13 20h.01",key:"d5"}],["path",{d:"M18 4h.01",key:"d6"}],["path",{d:"M18 20h.01",key:"d8"}]]),TJ=yZ("TaskMarkerIcon",[["path",{d:"M7.5 4.75h9a1 1 0 0 1 1 1v8.5L12 20l-5.5-5.75V5.75a1 1 0 0 1 1-1Z",key:"task-marker"}]]);function TI({marker:$,markerNumber:J,frameRate:Q,left:Z,selected:q,dragging:X,onSelect:Y,onDragStart:z,onDelete:K}){let W=Z1(),H=W("multitrack.taskMarkerLabel",{n:J.toString().padStart(2,"0")}),B=M6($.frame,{frameRate:Q,showFrames:!0,showHours:!1});return T(a6,{children:[T(H1,{children:[G(B1,{asChild:!0,children:G(t6,{asChild:!0,children:T(k0,{type:"button",variant:"ghost",size:"icon",className:`absolute top-0 z-30 h-6 w-5 -translate-x-1/2 rounded-none p-0 hover:bg-transparent ${X?"cursor-grabbing":"cursor-grab"} ${q?"opacity-100":"opacity-90"}`,style:{left:Z,color:"var(--highlight)"},"aria-label":W("multitrack.taskMarkerAtFrame",{frame:$.frame}),"aria-pressed":q,onMouseDown:(U)=>{U.preventDefault(),U.stopPropagation(),Y($.id),z($.id,U.clientX)},onContextMenu:(U)=>{U.stopPropagation(),Y($.id)},onClick:(U)=>{U.stopPropagation()},children:[G("span",{className:"absolute left-1/2 top-0 h-2 w-px -translate-x-1/2 bg-border"}),G(TJ,{className:"absolute left-1/2 top-1 h-4 w-4 -translate-x-1/2 fill-current stroke-current"})]})})}),T(W1,{side:"bottom",sideOffset:3,className:"min-w-24 rounded-md border border-border bg-popover px-2 py-1.5 text-popover-foreground shadow-md",children:[G("div",{className:"text-[10px] font-medium leading-4",children:H}),G("div",{className:"text-[11px] leading-4 tabular-nums",children:B})]})]}),G(y6,{children:T(Q5,{onClick:()=>K($.id),children:[G(N5,{className:"mr-2 h-3.5 w-3.5"}),W("multitrack.deleteTaskMarker")]})})]})}var q5=28,x2=48,RB=56,CB=[1,2,5,10,15,30,60,120,300];function Rp($,J,Q){let Z=Math.max(1,J),q=Math.max($,1),X=Q/q,Y=X>=6,z=[],K=Number.NEGATIVE_INFINITY;function W(L){return(L-K)*X>=RB}function H(L,F,V){if(F)K=L;z.push({time:L,label:F,major:V})}if(Y){let L=Math.max(1,Math.ceil(RB/Math.max(X,1))),F=Math.max(1,Math.round(Z/8)),V=Math.max(1,Math.ceil(L/F)*F);for(let M=0;M<=$;M+=1){let D=M%V===0,N=M===$&&W(M),O=D||N;H(M,O?M6(M,{frameRate:Z,showFrames:!0}):void 0,O)}return z}let B=RB/Math.max(X*Z,1),U=CB.find((L)=>L>=B)??CB[CB.length-1],_=Math.max(1,Math.round(U*Z));for(let L=0;L<=$;L+=_)H(L,M6(L,{frameRate:Z,showFrames:!0}),!0);if(z.at(-1)?.time!==$&&W($))H($,M6($,{frameRate:Z,showFrames:!0}),!0);return z}function Jz({totalLength:$,frameRate:J,width:Q,canvasScale:Z,currentTime:q,taskMarkers:X,selectedTaskMarkerId:Y,onSeek:z,onSelectTaskMarker:K,onMoveTaskMarker:W,onDeleteTaskMarker:H}){let B=$z.useRef(null),[U,_]=$z.useState(null),L=Math.max(1,Q-q5),F=Math.max(1,L-x2),V=Rp($,J,F),M=Math.max($,1),D=q5+q/M*F,N=q5+F;function O(k){let w=k/Math.max(Q,1);return Number.isFinite(w)&&w>0.01?w:Math.max(Z,0.01)}function I(k,w,C){let f=Math.max(0,(k-w)/C-q5)/F;return Math.max(0,Math.min($,Math.round(f*$)))}function A(k){k.preventDefault();let w=k.currentTarget.getBoundingClientRect(),C=O(w.width);z(I(k.clientX,w.left,C));function y(j){z(I(j.clientX,w.left,C))}function f(){globalThis.removeEventListener("mousemove",y),globalThis.removeEventListener("mouseup",f)}globalThis.addEventListener("mousemove",y),globalThis.addEventListener("mouseup",f)}function b(k,w){let C=X.find((r)=>r.id===k);if(!C)return;let y=B.current?.getBoundingClientRect(),f=y?.left??0,j=O(y?.width??0),P=C.frame,x=P;function p(r){let $0=Math.max(1,I(r,f,j));if(X.some((e)=>e.id!==k&&e.frame===$0))return;x=$0,_({markerId:k,frame:$0})}function t(r){p(r.clientX)}function h(r){if(p(r.clientX),globalThis.removeEventListener("mousemove",t),globalThis.removeEventListener("mouseup",h),_(null),x!==P)W(k,x)}p(w),globalThis.addEventListener("mousemove",t),globalThis.addEventListener("mouseup",h)}return T("div",{ref:B,className:`relative h-6 shrink-0 select-none border-b border-border ${U?"cursor-grabbing":"cursor-col-resize"}`,style:{width:Q},onMouseDown:A,children:[G("div",{className:"absolute left-0 top-0 h-full border-r border-border",style:{width:q5}}),G("div",{className:"pointer-events-none absolute top-0 h-full bg-black/30",style:{left:N,width:x2}}),V.map((k)=>T("div",{className:"absolute bottom-0 flex h-full flex-col justify-end",style:{left:q5+k.time/M*F},children:[G("div",{className:k.major?"h-3 w-px bg-border":"h-1.5 w-px bg-border"}),k.label&&G("span",{className:"absolute left-1 top-1 text-[8px] text-muted-foreground",children:k.label})]},`${k.time}-${k.major?"major":"minor"}`)),X.map((k,w)=>{let C=U?.markerId===k.id,y=C?{...k,frame:U.frame}:k;return G(TI,{marker:y,markerNumber:w+1,frameRate:J,left:q5+y.frame/M*F,selected:y.id===Y,dragging:C,onSelect:K,onDragStart:b,onDelete:H},y.id)}),G("div",{className:"absolute top-0 h-full w-px bg-destructive",style:{left:D}})]})}var S9="h-6 w-6 shrink-0 [&_svg]:size-3.5",D6="size-3.5";function yI({currentTime:$,totalLength:J,frameRate:Q,isPlaying:Z,zoom:q,snapEnabled:X,taskOverview:Y,timelineCollapsed:z,onPlayPause:K,onZoomChange:W,onSnapEnabledChange:H,canAddTaskMarker:B,onAddTaskMarker:U,onTaskOverviewChange:_,onToggleTimeline:L,canDelete:F,onDeleteSelected:V,onCutAtCurrentTime:M,canTrimCenter:D,canTrimLeft:N,canTrimRight:O,onTrimLeftAtCurrentTime:I,onTrimRightAtCurrentTime:A,canUndo:b,canRedo:k,onUndo:w,onRedo:C}){let y=Z1();function f(j,P){return T(H1,{children:[G(B1,{asChild:!0,children:G("span",{className:"inline-flex shrink-0",children:P})}),G(W1,{children:j})]})}return T("div",{className:"grid h-9 min-h-9 shrink-0 grid-cols-[1fr_auto_1fr] items-center overflow-hidden border-b border-border text-[10px] leading-none",children:[T("div",{className:"flex items-center",children:[f(y("multitrack.undo"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!b,"aria-label":y("multitrack.undo"),onClick:(j)=>{j.stopPropagation(),w()},children:G(EI,{className:D6})})),f(y("multitrack.redo"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!k,"aria-label":y("multitrack.redo"),onClick:(j)=>{j.stopPropagation(),C()},children:G(jI,{className:D6})})),f(y("multitrack.cutMode"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!D,"aria-label":y("multitrack.cutMode"),onClick:(j)=>{j.stopPropagation(),M()},children:G(wI,{className:D6})})),f(y("multitrack.trimLeftAtPlayhead"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!N,"aria-label":y("multitrack.trimLeftAtPlayhead"),onClick:(j)=>{j.stopPropagation(),I()},children:G(kI,{className:D6})})),f(y("multitrack.trimRightAtPlayhead"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!O,"aria-label":y("multitrack.trimRightAtPlayhead"),onClick:(j)=>{j.stopPropagation(),A()},children:G(II,{className:D6})})),f(y("multitrack.deleteSelectedSegment"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!F,"aria-label":y("multitrack.deleteSelectedSegment"),onClick:(j)=>{j.stopPropagation(),V()},children:G(N5,{className:D6})})),f(y("multitrack.addTaskMarker"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,disabled:!B,"aria-label":y("multitrack.addTaskMarker"),onClick:(j)=>{j.stopPropagation(),U()},children:G(TJ,{className:D6})}))]}),T("div",{className:"flex items-center gap-2 text-muted-foreground",children:[G("span",{className:"w-16 text-right tabular-nums text-gradient",children:M6($,{frameRate:Q,showFrames:!0})}),f(Z?y("multitrack.pause"):y("multitrack.play"),G(k0,{type:"button",variant:"secondary",size:"icon",className:`${S9} text-foreground rounded-full cursor-pointer`,"aria-label":Z?y("multitrack.pause"):y("multitrack.play"),onClick:K,children:Z?T("svg",{className:D6,viewBox:"0 0 24 24",fill:"none",children:[G("defs",{children:T("linearGradient",{id:"icon-gradient-pause",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[G("stop",{offset:"0%",stopColor:"var(--primary)"}),G("stop",{offset:"100%",stopColor:"var(--highlight)"})]})}),G("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1",fill:"url(#icon-gradient-pause)"}),G("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1",fill:"url(#icon-gradient-pause)"})]}):T("svg",{className:D6,viewBox:"0 0 24 24",fill:"none",children:[G("defs",{children:T("linearGradient",{id:"icon-gradient-play",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[G("stop",{offset:"0%",stopColor:"var(--primary)"}),G("stop",{offset:"100%",stopColor:"var(--highlight)"})]})}),G("path",{d:"M8 5.5v13l11-6.5L8 5.5z",fill:"url(#icon-gradient-play)"})]})})),G("span",{className:"w-16 tabular-nums",children:M6(J,{frameRate:Q,showFrames:!0})})]}),T("div",{className:"ml-auto flex h-6 max-h-6 min-h-6 items-center gap-0.5 overflow-hidden",children:[f(y("multitrack.taskOverview"),G(k0,{type:"button",variant:Y?"outline":"ghost",size:"icon",className:`${S9} cursor-pointer ${Y?"text-highlight":"text-muted-foreground"}`,"aria-label":y("multitrack.taskOverview"),"aria-pressed":Y,onClick:(j)=>{j.stopPropagation(),_(!Y)},children:G(Qz,{className:D6})})),f(y("multitrack.timelineSnap"),G(k0,{type:"button",variant:X?"outline":"ghost",size:"icon",className:`${S9} cursor-pointer ${X?"text-highlight":"text-muted-foreground"}`,"aria-label":y("multitrack.timelineSnap"),"aria-pressed":X,onClick:(j)=>{j.stopPropagation(),H(!X)},children:G(bI,{className:D6})})),f(z?y("multitrack.showTimeline"):y("multitrack.hideTimeline"),G(k0,{type:"button",variant:"ghost",size:"icon",className:`${S9} text-muted-foreground cursor-pointer`,"aria-label":z?y("multitrack.showTimeline"):y("multitrack.hideTimeline"),onClick:(j)=>{j.stopPropagation(),L()},children:z?G(Zz,{className:D6}):G(qz,{className:D6})})),f(y("multitrack.timelineZoom"),G("span",{className:"inline-flex shrink-0","aria-label":y("multitrack.timelineZoom"),children:G(JJ,{className:`${D6} text-muted-foreground`})})),G("div",{className:"relative h-3 max-h-3 min-h-3 w-12 overflow-visible",children:G(O8,{min:1,max:6,step:0.25,value:[q],onValueChange:([j])=>W(j),className:"absolute inset-0 h-3 max-h-3 min-h-3 w-12 [&_[role=slider]]:h-2.5 [&_[role=slider]]:w-2.5 [&_[data-orientation=horizontal]]:h-1","aria-label":y("multitrack.timelineZoom")})})]})]})}var I5=R(v(),1);var Cp=PI("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-1 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function bJ({className:$,variant:J,...Q}){return G("div",{className:b0(Cp({variant:J}),$),...Q})}var I7=R(v(),1),SB=1,Sp=6,RI=1.15,CI={x:50,y:50};function Xz($,J){let Q=I7.useRef(null),[Z,q]=I7.useState(SB),[X,Y]=I7.useState(CI);I7.useEffect(()=>{q(SB),Y(CI)},[$]),I7.useEffect(()=>{if(!$)return;let K=(W)=>{if(W.key==="Escape")J()};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[$,J]);function z(K){K.preventDefault(),K.stopPropagation();let W=Q.current?.getBoundingClientRect();if(W&&W.width>0&&W.height>0)Y({x:Math.max(0,Math.min(100,(K.clientX-W.left)/W.width*100)),y:Math.max(0,Math.min(100,(K.clientY-W.top)/W.height*100))});let H=K.deltaY<0?RI:1/RI;q((B)=>Math.max(SB,Math.min(Sp,B*H)))}return{imageRef:Q,zoom:Z,origin:X,onWheel:z}}var zz=R(v(),1);function hp($){let J=e9.findIndex((Z)=>Z===$);if(J>=0)return J;let Q=e9.findIndex((Z)=>Z===f2);if(!Number.isFinite($)||$<=0)return Math.max(0,Q);return e9.reduce((Z,q,X)=>{let Y=e9[Z]??f2;return Math.abs(q-$)<Math.abs(Y-$)?X:Z},Math.max(0,Q))}function hI({globalMuted:$,globalVolumeDb:J,frameRate:Q,selectedMediaVolumeDb:Z,selectedMediaMuted:q,selectedMediaDuration:X,rightInset:Y=12,onGlobalSettingsChange:z,onSelectedSegmentContentChange:K,onSelectedSegmentDurationChange:W}){let H=Z1(),B=Z!==null,U=H(B?"multitrack.audio":"multitrack.globalAudio"),_=B?Z:J,L=B?q:$,F=X===null?"":jJ(X,Q),[V,M]=zz.useState(F);zz.useEffect(()=>{M(F)},[F]);function D(b){let k=fB(b);if(B){K({volume_db:k});return}z({volume_db:k})}function N(){if(B){K({muted:!L});return}z({muted:!$})}function O(b){let k=Math.max(0,Math.min(e9.length-1,Math.round(b))),w=e9[k]??f2;if(w!==Q)z({frame_rate:w})}function I(){let b=Yz(V,Q);if(b===null){M(F);return}if(M(jJ(b,Q)),b!==X)W(b)}let A=hp(Q);return T("div",{className:"absolute top-1/2 z-20 flex -translate-y-1/2 flex-col overflow-hidden rounded-lg border border-border bg-popover/90 text-popover-foreground shadow-lg backdrop-blur",style:{right:Y},children:[T(t1,{children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"ghost",className:"flex h-12 w-10 flex-col gap-1 rounded-none px-1 py-1 cursor-pointer","aria-label":H("multitrack.audioSettings"),children:[L?G(EJ,{className:"h-4 w-4"}):G($4,{className:"h-4 w-4"}),G("span",{className:"text-[8px]",children:U})]})}),T(o1,{className:"w-56 space-y-3",align:"end",side:"left",children:[T("div",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[G("span",{className:"text-sm font-medium",children:U}),G(k0,{type:"button",variant:"secondary",size:"sm",className:"cursor-pointer","aria-label":L?H("multitrack.unmutePreviewAudio"):H("multitrack.mutePreviewAudio"),onClick:N,children:L?H("multitrack.unmute"):H("multitrack.mute")})]}),T("div",{className:"grid gap-2 text-xs text-muted-foreground",children:[T("span",{className:"flex items-center justify-between",children:[G("span",{children:H("multitrack.volume")}),T("span",{className:"tabular-nums text-foreground",children:[_.toFixed(1)," dB"]})]}),G(e8,{"aria-label":H("multitrack.volume"),min:hB,max:xB,step:0.1,className:"cursor-pointer",value:_,onChange:D})]}),G(O8,{"aria-label":H("multitrack.volume"),className:"cursor-pointer",value:[fB(_)],min:hB,max:xB,step:0.1,onValueChange:(b)=>D(b[0]??0)})]})]}),G("div",{className:"mx-3 h-px bg-border"}),T(t1,{children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"ghost",className:"flex h-12 w-10 flex-col gap-1 rounded-none px-1 py-1 cursor-pointer","aria-label":H("multitrack.fpsSettings"),children:[G(SI,{className:"h-4 w-4"}),G("span",{className:"text-[8px]",children:H("multitrack.frameRate")})]})}),G(o1,{className:"w-72 space-y-4",align:"end",side:"left",children:T("div",{className:"grid gap-3 text-xs text-muted-foreground",children:[T("div",{className:"flex items-center justify-between",children:[G("span",{children:H("multitrack.frameRate")}),T("span",{className:"tabular-nums text-foreground",children:[e9[A]??f2," ",H("multitrack.fps")]})]}),G(O8,{"aria-label":H("multitrack.frameRate"),value:[A],min:0,max:e9.length-1,step:1,ticks:e9.map((b,k)=>({value:k,label:String(b)})),onValueChange:(b)=>O(b[0]??A)}),X!==null&&T("label",{className:"grid gap-2 pt-2",children:[H("multitrack.duration"),G($6,{"aria-label":H("multitrack.duration"),type:"text",inputMode:"numeric",placeholder:"00:00:00",className:"tabular-nums",value:V,onChange:(b)=>M(b.currentTarget.value),onBlur:I,onKeyDown:(b)=>{if(b.key!=="Enter")return;b.preventDefault(),I()}})]})]})})]})]})}var G9=R(v(),1);function xp({source:$,isPlaying:J,playbackNonce:Q=0}){let Z=G9.useRef(null),q=G9.useRef(null),X=G9.useRef(null),Y=G9.useMemo(()=>Z5({source_type:$.segment.content.source_type??"input",file_path:$.segment.content.file_path,local_path:$.segment.content.local_path,url:$.segment.content.url,slot_name:$.segment.content.slot_name}),[$.segment.content]),z=globalThis.location?.href,K=Y?OI($.volumeDb,Y,z):0,W=Y?yB(Y,z):!1;return G9.useEffect(()=>()=>{let H=Z.current;if(!H)return;H.pause(),H.src=""},[]),G9.useEffect(()=>{let H=Z.current,B=globalThis.AudioContext;if(!H||!Y||!B)return;if(!W)return;try{let U=new B,_=U.createGain();return U.createMediaElementSource(H).connect(_).connect(U.destination),q.current=U,X.current=_,H.volume=1,()=>{_.disconnect(),X.current=null,q.current=null,U.close().catch((L)=>{console.error("[PreviewAudioPlayback] failed to close audio context:",L)})}}catch(U){console.error("[PreviewAudioPlayback] failed to create audio gain graph:",U)}},[W,Y]),G9.useEffect(()=>{let H=Z.current;if(!H)return;if(X.current){X.current.gain.value=K;return}H.volume=Math.max(0,Math.min(1,K))},[K]),G9.useEffect(()=>{let H=Z.current;if(!H||J||Math.abs(H.currentTime-$.localTime)<=0.001)return;try{H.currentTime=$.localTime}catch(B){console.error("[PreviewAudioPlayback] failed to seek audio:",B)}},[J,$.localTime]),G9.useEffect(()=>{let H=Z.current;if(!H)return;if(!J){H.pause();return}q.current?.resume().catch((U)=>{console.error("[PreviewAudioPlayback] failed to resume audio context:",U)});try{H.currentTime=$.localTime}catch(U){console.error("[PreviewAudioPlayback] failed to seek audio before playback:",U)}H.play()?.catch((U)=>{console.error("[PreviewAudioPlayback] failed to play audio:",U)})},[J,$.segment.id,Y,Q]),Y?G("audio",{ref:Z,"data-testid":`preview-audio-${$.segment.id}`,src:Y,preload:"auto",className:"hidden"}):null}function xI({sources:$,isPlaying:J,playbackNonce:Q=0}){return $.map((Z)=>G(xp,{source:Z,isPlaying:J,playbackNonce:Q},`${Z.trackId}:${Z.segment.id}`))}var fp={version:1,projection:"equirectangular",yaw:0,pitch:0,hfov:90,aspect_ratio:1};function vI($,J,Q){return Math.min(Q,Math.max(J,$))}function Kz($){return typeof $==="number"&&Number.isFinite($)}function fI($){return(($+180)%360+360)%360-180}function vp($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let J=$;return J.version===1&&J.projection==="equirectangular"&&Kz(J.yaw)&&Kz(J.pitch)&&Kz(J.hfov)&&Kz(J.aspect_ratio)&&J.aspect_ratio>0}function gI($){if(!vp($))return{...fp};return{version:1,projection:"equirectangular",yaw:fI($.yaw),pitch:fI($.pitch),hfov:vI($.hfov,30,120),aspect_ratio:$.aspect_ratio}}function uI($,J){if(!Number.isFinite(J)||J<=0)throw RangeError("Panorama aspect ratio must be a positive finite number");let Q=vI($,30,120)*Math.PI/180;return 2*Math.atan(Math.tan(Q/2)/J)*180/Math.PI}function Gz({alt:$,className:J,imageId:Q,imageUrl:Z,view:q}){let X=gI(q),Y=uI(X.hfov,1.7777777777777777),z=360/X.hfov*100,K=50-X.yaw/X.hfov*100,W=50+X.pitch/Y*100;return G("div",{"data-testid":`panorama-image-preview-${Q}`,className:b0("relative aspect-video w-full overflow-hidden bg-black",J),children:[-1,0,1].map((H)=>G("img",{src:Z,alt:H===0?$:"","aria-hidden":H===0?void 0:!0,className:"pointer-events-none absolute top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 select-none",style:{left:`${K+H*z}%`,top:`${W}%`,width:`${z}%`},draggable:!1},H))})}var c1=R(v(),1);var R1=R(v(),1);function gp($,J){let Q=getComputedStyle($),Z=parseFloat(Q.fontSize);return J*Z}function up($,J){let Q=getComputedStyle($.ownerDocument.documentElement),Z=parseFloat(Q.fontSize);return J*Z}function mp($){return $/100*window.innerHeight}function cp($){return $/100*window.innerWidth}function dp($){switch(typeof $){case"number":return[$,"px"];case"string":{let J=parseFloat($);return $.endsWith("%")?[J,"%"]:$.endsWith("px")?[J,"px"]:$.endsWith("rem")?[J,"rem"]:$.endsWith("em")?[J,"em"]:$.endsWith("vh")?[J,"vh"]:$.endsWith("vw")?[J,"vw"]:[J,"%"]}}}function PZ({groupSize:$,panelElement:J,styleProp:Q}){let Z,[q,X]=dp(Q);switch(X){case"%":{Z=q/100*$;break}case"px":{Z=q;break}case"rem":{Z=up(J,q);break}case"em":{Z=gp(J,q);break}case"vh":{Z=mp(q);break}case"vw":{Z=cp(q);break}}return Z}function J6($){return parseFloat($.toFixed(3))}function SJ({group:$}){let{orientation:J,panels:Q}=$;return Q.reduce((Z,q)=>(Z+=J==="horizontal"?q.element.offsetWidth:q.element.offsetHeight,Z),0)}function gB($){let{panels:J}=$,Q=SJ({group:$});return Q===0?J.map((Z)=>({groupResizeBehavior:Z.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:Z.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:Z.panelConstraints.disabled,minSize:0,maxSize:100,panelId:Z.id})):J.map((Z)=>{let{element:q,panelConstraints:X}=Z,Y=0;if(X.collapsedSize!==void 0){let H=PZ({groupSize:Q,panelElement:q,styleProp:X.collapsedSize});Y=J6(H/Q*100)}let z;if(X.defaultSize!==void 0){let H=PZ({groupSize:Q,panelElement:q,styleProp:X.defaultSize});z=J6(H/Q*100)}let K=0;if(X.minSize!==void 0){let H=PZ({groupSize:Q,panelElement:q,styleProp:X.minSize});K=J6(H/Q*100)}let W=100;if(X.maxSize!==void 0){let H=PZ({groupSize:Q,panelElement:q,styleProp:X.maxSize});W=J6(H/Q*100)}return{groupResizeBehavior:X.groupResizeBehavior,collapsedSize:Y,collapsible:X.collapsible===!0,defaultSize:z,disabled:X.disabled,minSize:K,maxSize:W,panelId:Z.id}})}function G5($,J="Assertion error"){if(!$)throw Error(J)}function uB($,J){return Array.from(J).sort($==="horizontal"?pp:lp)}function pp($,J){let Q=$.element.offsetLeft-J.element.offsetLeft;return Q!==0?Q:$.element.offsetWidth-J.element.offsetWidth}function lp($,J){let Q=$.element.offsetTop-J.element.offsetTop;return Q!==0?Q:$.element.offsetHeight-J.element.offsetHeight}function ZT($){return $!==null&&typeof $=="object"&&"nodeType"in $&&$.nodeType===Node.ELEMENT_NODE}function qT($,J){return{x:$.x>=J.left&&$.x<=J.right?0:Math.min(Math.abs($.x-J.left),Math.abs($.x-J.right)),y:$.y>=J.top&&$.y<=J.bottom?0:Math.min(Math.abs($.y-J.top),Math.abs($.y-J.bottom))}}function ip({orientation:$,rects:J,targetRect:Q}){let Z={x:Q.x+Q.width/2,y:Q.y+Q.height/2},q,X=Number.MAX_VALUE;for(let Y of J){let{x:z,y:K}=qT(Z,Y),W=$==="horizontal"?z:K;W<X&&(X=W,q=Y)}return G5(q,"No rect found"),q}var Wz;function rp(){return Wz===void 0&&(typeof matchMedia=="function"?Wz=!!matchMedia("(pointer:coarse)").matches:Wz=!1),Wz}function XT($){let{element:J,orientation:Q,panels:Z,separators:q}=$,X=uB(Q,Array.from(J.children).filter(ZT).map((L)=>({element:L}))).map(({element:L})=>L),Y=[],z=!1,K=!1,W=-1,H=-1,B=0,U,_=[];{let L=-1;for(let F of X)F.hasAttribute("data-panel")&&(L++,F.hasAttribute("data-disabled")||(B++,W===-1&&(W=L),H=L))}if(B>1){let L=-1;for(let F of X)if(F.hasAttribute("data-panel")){L++;let V=Z.find((M)=>M.element===F);if(V){if(U){let M=U.element.getBoundingClientRect(),D=F.getBoundingClientRect(),N;if(K){let O=Q==="horizontal"?new DOMRect(M.right,M.top,0,M.height):new DOMRect(M.left,M.bottom,M.width,0),I=Q==="horizontal"?new DOMRect(D.left,D.top,0,D.height):new DOMRect(D.left,D.top,D.width,0);switch(_.length){case 0:{N=[O,I];break}case 1:{let A=_[0],b=ip({orientation:Q,rects:[M,D],targetRect:A.element.getBoundingClientRect()});N=[A,b===M?I:O];break}default:{N=_;break}}}else _.length?N=_:N=[Q==="horizontal"?new DOMRect(M.right,D.top,D.left-M.right,D.height):new DOMRect(D.left,M.bottom,D.width,D.top-M.bottom)];for(let O of N){let I="width"in O?O:O.element.getBoundingClientRect(),A=rp()?$.resizeTargetMinimumSize.coarse:$.resizeTargetMinimumSize.fine;if(I.width<A){let k=A-I.width;I=new DOMRect(I.x-k/2,I.y,I.width+k,I.height)}if(I.height<A){let k=A-I.height;I=new DOMRect(I.x,I.y-k/2,I.width,I.height+k)}let b=L<=W||L>H;!z&&!b&&Y.push({group:$,groupSize:SJ({group:$}),panels:[U,V],separator:"width"in O?void 0:O,rect:I}),z=!1}}K=!1,U=V,_=[]}}else if(F.hasAttribute("data-separator")){F.ariaDisabled!==null&&(z=!0);let V=q.find((M)=>M.element===F);V?_.push(V):(U=void 0,_=[])}else K=!0}return Y}class mB{#$={};addListener($,J){let Q=this.#$[$];return Q===void 0?this.#$[$]=[J]:Q.includes(J)||Q.push(J),()=>{this.removeListener($,J)}}emit($,J){let Q=this.#$[$];if(Q!==void 0)if(Q.length===1)Q[0].call(null,J);else{let Z=!1,q=null,X=Array.from(Q);for(let Y=0;Y<X.length;Y++){let z=X[Y];try{z.call(null,J)}catch(K){q===null&&(Z=!0,q=K)}}if(Z)throw q}}removeAllListeners(){this.#$={}}removeListener($,J){let Q=this.#$[$];if(Q!==void 0){let Z=Q.indexOf(J);Z>=0&&Q.splice(Z,1)}}}var Q4=new Map,YT=new mB;function sp($){Q4=new Map(Q4),Q4.delete($)}function mI($,J){for(let[Q]of Q4)if(Q.id===$)return Q}function T7($,J){for(let[Q,Z]of Q4)if(Q.id===$)return Z;if(J)throw Error(`Could not find data for Group with id ${$}`)}function c2(){return Q4}function cB($,J){return YT.addListener("groupChange",(Q)=>{Q.group.id===$&&J(Q)})}function i4($,J){let Q=Q4.get($);Q4=new Map(Q4),Q4.set($,J),YT.emit("groupChange",{group:$,prev:Q,next:J})}function op($,J,Q){let Z,q={x:1/0,y:1/0};for(let X of J){let Y=qT(Q,X.rect);switch($){case"horizontal":{Y.x<=q.x&&(Z=X,q=Y);break}case"vertical":{Y.y<=q.y&&(Z=X,q=Y);break}}}return Z?{distance:q,hitRegion:Z}:void 0}function np($){return $!==null&&typeof $=="object"&&"nodeType"in $&&$.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ap($,J){if($===J)throw Error("Cannot compare node with itself");let Q={a:pI($),b:pI(J)},Z;for(;Q.a.at(-1)===Q.b.at(-1);)Z=Q.a.pop(),Q.b.pop();G5(Z,"Stacking order can only be calculated for elements with a common ancestor");let q={a:dI(cI(Q.a)),b:dI(cI(Q.b))};if(q.a===q.b){let X=Z.childNodes,Y={a:Q.a.at(-1),b:Q.b.at(-1)},z=X.length;for(;z--;){let K=X[z];if(K===Y.a)return 1;if(K===Y.b)return-1}}return Math.sign(q.a-q.b)}var tp=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ep($){let J=getComputedStyle(zT($)??$).display;return J==="flex"||J==="inline-flex"}function $l($){let J=getComputedStyle($);return!!(J.position==="fixed"||J.zIndex!=="auto"&&(J.position!=="static"||ep($))||+J.opacity<1||("transform"in J)&&J.transform!=="none"||("webkitTransform"in J)&&J.webkitTransform!=="none"||("mixBlendMode"in J)&&J.mixBlendMode!=="normal"||("filter"in J)&&J.filter!=="none"||("webkitFilter"in J)&&J.webkitFilter!=="none"||("isolation"in J)&&J.isolation==="isolate"||tp.test(J.willChange)||J.webkitOverflowScrolling==="touch")}function cI($){let J=$.length;for(;J--;){let Q=$[J];if(G5(Q,"Missing node"),$l(Q))return Q}return null}function dI($){return $&&Number(getComputedStyle($).zIndex)||0}function pI($){let J=[];for(;$;)J.push($),$=zT($);return J}function zT($){let{parentNode:J}=$;return np(J)?J.host:J}function Jl($,J){return $.x<J.x+J.width&&$.x+$.width>J.x&&$.y<J.y+J.height&&$.y+$.height>J.y}function Ql({groupElement:$,hitRegion:J,pointerEventTarget:Q}){if(!ZT(Q)||Q.contains($)||$.contains(Q))return!0;if(ap(Q,$)>0){let Z=Q;for(;Z;){if(Z.contains($))return!0;if(Jl(Z.getBoundingClientRect(),J))return!1;Z=Z.parentElement}}return!0}function dB($,J){let Q=[];return J.forEach((Z,q)=>{if(q.disabled)return;let X=XT(q),Y=op(q.orientation,X,{x:$.clientX,y:$.clientY});Y&&Y.distance.x<=0&&Y.distance.y<=0&&Ql({groupElement:q.element,hitRegion:Y.hitRegion.rect,pointerEventTarget:$.target})&&Q.push(Y.hitRegion)}),Q}function Zl($,J){if($.length!==J.length)return!1;for(let Q=0;Q<$.length;Q++)if($[Q]!=J[Q])return!1;return!0}function u8($,J,Q=0){return Math.abs(J6($)-J6(J))<=Q}function J4($,J){return u8($,J)?0:$>J?1:-1}function PJ({overrideDisabledPanels:$,panelConstraints:J,prevSize:Q,size:Z}){let{collapsedSize:q=0,collapsible:X,disabled:Y,maxSize:z=100,minSize:K=0}=J;if(Y&&!$)return Q;if(J4(Z,K)<0)if(X){let W=(q+K)/2;J4(Z,W)<0?Z=q:Z=K}else Z=K;return Z=Math.min(z,Z),Z=J6(Z),Z}function CZ({delta:$,initialLayout:J,panelConstraints:Q,pivotIndices:Z,prevLayout:q,trigger:X}){if(u8($,0))return J;let Y=X==="imperative-api",z=Object.values(J),K=Object.values(q),W=[...z],[H,B]=Z;G5(H!=null,"Invalid first pivot index"),G5(B!=null,"Invalid second pivot index");let U=0;switch(X){case"keyboard":{{let F=$<0?B:H,V=Q[F];G5(V,`Panel constraints not found for index ${F}`);let{collapsedSize:M=0,collapsible:D,minSize:N=0}=V;if(D){let O=z[F];if(G5(O!=null,`Previous layout not found for panel index ${F}`),u8(O,M)){let I=N-O;J4(I,Math.abs($))>0&&($=$<0?0-I:I)}}}{let F=$<0?H:B,V=Q[F];G5(V,`No panel constraints found for index ${F}`);let{collapsedSize:M=0,collapsible:D,minSize:N=0}=V;if(D){let O=z[F];if(G5(O!=null,`Previous layout not found for panel index ${F}`),u8(O,N)){let I=O-M;J4(I,Math.abs($))>0&&($=$<0?0-I:I)}}}break}default:{let F=$<0?B:H,V=Q[F];G5(V,`Panel constraints not found for index ${F}`);let M=z[F],{collapsible:D,collapsedSize:N,minSize:O}=V;if(D&&J4(M,O)<0)if($>0){let I=O-N,A=I/2,b=M+$;J4(b,O)<0&&($=J4($,A)<=0?0:I)}else{let I=O-N,A=100-I/2,b=M-$;J4(b,O)<0&&($=J4(100+$,A)>0?0:-I)}break}}{let F=$<0?1:-1,V=$<0?B:H,M=0;for(;;){let N=z[V];G5(N!=null,`Previous layout not found for panel index ${V}`);let O=PJ({overrideDisabledPanels:Y,panelConstraints:Q[V],prevSize:N,size:100})-N;if(M+=O,V+=F,V<0||V>=Q.length)break}let D=Math.min(Math.abs($),Math.abs(M));$=$<0?0-D:D}{let F=$<0?H:B;for(;F>=0&&F<Q.length;){let V=Math.abs($)-Math.abs(U),M=z[F];G5(M!=null,`Previous layout not found for panel index ${F}`);let D=M-V,N=PJ({overrideDisabledPanels:Y,panelConstraints:Q[F],prevSize:M,size:D});if(!u8(M,N)&&(U+=M-N,W[F]=N,U.toFixed(3).localeCompare(Math.abs($).toFixed(3),void 0,{numeric:!0})>=0))break;$<0?F--:F++}}if(Zl(K,W))return q;{let F=$<0?B:H,V=z[F];G5(V!=null,`Previous layout not found for panel index ${F}`);let M=V+U,D=PJ({overrideDisabledPanels:Y,panelConstraints:Q[F],prevSize:V,size:M});if(W[F]=D,!u8(D,M)){let N=M-D,O=$<0?B:H;for(;O>=0&&O<Q.length;){let I=W[O];G5(I!=null,`Previous layout not found for panel index ${O}`);let A=I+N,b=PJ({overrideDisabledPanels:Y,panelConstraints:Q[O],prevSize:I,size:A});if(u8(I,b)||(N-=b-I,W[O]=b),u8(N,0))break;$>0?O--:O++}}}let _=Object.values(W).reduce((F,V)=>V+F,0);if(!u8(_,100,0.1))return q;let L=Object.keys(q);return W.reduce((F,V,M)=>(F[L[M]]=V,F),{})}function g2($,J){if(Object.keys($).length!==Object.keys(J).length)return!1;for(let Q in $)if(J[Q]===void 0||J4($[Q],J[Q])!==0)return!1;return!0}function u2({layout:$,panelConstraints:J}){let Q=Object.values($),Z=[...Q],q=Z.reduce((z,K)=>z+K,0);if(Z.length!==J.length)throw Error(`Invalid ${J.length} panel layout: ${Z.map((z)=>`${z}%`).join(", ")}`);if(!u8(q,100)&&Z.length>0)for(let z=0;z<J.length;z++){let K=Z[z];G5(K!=null,`No layout data found for index ${z}`);let W=100/q*K;Z[z]=W}let X=0;for(let z=0;z<J.length;z++){let K=Q[z];G5(K!=null,`No layout data found for index ${z}`);let W=Z[z];G5(W!=null,`No layout data found for index ${z}`);let H=PJ({overrideDisabledPanels:!0,panelConstraints:J[z],prevSize:K,size:W});W!=H&&(X+=W-H,Z[z]=H)}if(!u8(X,0))for(let z=0;z<J.length;z++){let K=Z[z];G5(K!=null,`No layout data found for index ${z}`);let W=K+X,H=PJ({overrideDisabledPanels:!0,panelConstraints:J[z],prevSize:K,size:W});if(K!==H&&(X-=H-K,Z[z]=H,u8(X,0)))break}let Y=Object.keys($);return Z.reduce((z,K,W)=>(z[Y[W]]=K,z),{})}function KT({groupId:$,panelId:J}){let Q=()=>{let K=c2();for(let[W,{defaultLayoutDeferred:H,derivedPanelConstraints:B,layout:U,groupSize:_,separatorToPanels:L}]of K)if(W.id===$)return{defaultLayoutDeferred:H,derivedPanelConstraints:B,group:W,groupSize:_,layout:U,separatorToPanels:L};throw Error(`Group ${$} not found`)},Z=()=>{let K=Q().derivedPanelConstraints.find((W)=>W.panelId===J);if(K!==void 0)return K;throw Error(`Panel constraints not found for Panel ${J}`)},q=()=>{let K=Q().group.panels.find((W)=>W.id===J);if(K!==void 0)return K;throw Error(`Layout not found for Panel ${J}`)},X=()=>{let K=Q().layout[J];if(K!==void 0)return K;throw Error(`Layout not found for Panel ${J}`)},Y=({nextSize:K,panels:W,prevLayout:H,derivedPanelConstraints:B})=>{let U=X(),_=W.findIndex((V)=>V.id===J),L=_===0,F=_===W.length-1;if(F&&K<U&&(L||W.slice(0,_).every((V,M)=>{let D=B[M];return D?.collapsible&&u8(D.collapsedSize,H[D.panelId])}))){let V=W.slice(0,_).reduce((M,D)=>M+H[D.id],0);return{...H,[J]:J6(100-V)}}return CZ({delta:F?U-K:K-U,initialLayout:H,panelConstraints:B,pivotIndices:F?[_-1,_]:[_,_+1],prevLayout:H,trigger:"imperative-api"})},z=(K)=>{let W=X();if(K===W)return;let{defaultLayoutDeferred:H,derivedPanelConstraints:B,group:U,groupSize:_,layout:L,separatorToPanels:F}=Q(),V=Y({nextSize:K,panels:U.panels,prevLayout:L,derivedPanelConstraints:B}),M=u2({layout:V,panelConstraints:B});g2(L,M)||i4(U,{defaultLayoutDeferred:H,derivedPanelConstraints:B,groupSize:_,layout:M,separatorToPanels:F})};return{collapse:()=>{let{collapsible:K,collapsedSize:W}=Z(),{mutableValues:H}=q(),B=X();K&&B!==W&&(H.expandToSize=B,z(W))},expand:()=>{let{collapsible:K,collapsedSize:W,minSize:H}=Z(),{mutableValues:B}=q(),U=X();if(K&&U===W){let _=B.expandToSize??H;_===0&&(_=1),z(_)}},getSize:()=>{let{group:K}=Q(),W=X(),{element:H}=q(),B=K.orientation==="horizontal"?H.offsetWidth:H.offsetHeight;return{asPercentage:W,inPixels:B}},isCollapsed:()=>{let{collapsible:K,collapsedSize:W}=Z(),H=X();return K&&u8(W,H)},resize:(K)=>{let{group:W}=Q(),{element:H}=q(),B=SJ({group:W}),U=PZ({groupSize:B,panelElement:H,styleProp:K}),_=J6(U/B*100);z(_)}}}function lI($){if($.defaultPrevented)return;let J=c2();dB($,J).forEach((Q)=>{if(Q.separator&&!Q.separator.disableDoubleClick){let Z=Q.panels.find((q)=>q.panelConstraints.defaultSize!==void 0);if(Z){let q=Z.panelConstraints.defaultSize,X=KT({groupId:Q.group.id,panelId:Z.id});X&&q!==void 0&&(X.resize(q),$.preventDefault())}}})}function Bz($){let J=c2();for(let[Q]of J)if(Q.separators.some((Z)=>Z.element===$))return Q;throw Error("Could not find parent Group for separator element")}function GT({groupId:$}){let J=()=>{let Q=c2();for(let[Z,q]of Q)if(Z.id===$)return{group:Z,...q};throw Error(`Could not find Group with id "${$}"`)};return{getLayout(){let{defaultLayoutDeferred:Q,layout:Z}=J();return Q?{}:Z},setLayout(Q){let{defaultLayoutDeferred:Z,derivedPanelConstraints:q,group:X,groupSize:Y,layout:z,separatorToPanels:K}=J(),W=u2({layout:Q,panelConstraints:q});return Z?z:(g2(z,W)||i4(X,{defaultLayoutDeferred:Z,derivedPanelConstraints:q,groupSize:Y,layout:W,separatorToPanels:K}),W)}}}function v2($,J){let Q=Bz($),Z=T7(Q.id,!0),q=Q.separators.find((H)=>H.element===$);G5(q,"Matching separator not found");let X=Z.separatorToPanels.get(q);G5(X,"Matching panels not found");let Y=X.map((H)=>Q.panels.indexOf(H)),z=GT({groupId:Q.id}).getLayout(),K=CZ({delta:J,initialLayout:z,panelConstraints:Z.derivedPanelConstraints,pivotIndices:Y,prevLayout:z,trigger:"keyboard"}),W=u2({layout:K,panelConstraints:Z.derivedPanelConstraints});g2(z,W)||i4(Q,{defaultLayoutDeferred:Z.defaultLayoutDeferred,derivedPanelConstraints:Z.derivedPanelConstraints,groupSize:Z.groupSize,layout:W,separatorToPanels:Z.separatorToPanels})}function iI($){if($.defaultPrevented)return;let J=$.currentTarget,Q=Bz(J);if(!Q.disabled)switch($.key){case"ArrowDown":{$.preventDefault(),Q.orientation==="vertical"&&v2(J,5);break}case"ArrowLeft":{$.preventDefault(),Q.orientation==="horizontal"&&v2(J,-5);break}case"ArrowRight":{$.preventDefault(),Q.orientation==="horizontal"&&v2(J,5);break}case"ArrowUp":{$.preventDefault(),Q.orientation==="vertical"&&v2(J,-5);break}case"End":{$.preventDefault(),v2(J,100);break}case"Enter":{$.preventDefault();let Z=Bz(J),q=T7(Z.id,!0),{derivedPanelConstraints:X,layout:Y,separatorToPanels:z}=q,K=Z.separators.find((U)=>U.element===J);G5(K,"Matching separator not found");let W=z.get(K);G5(W,"Matching panels not found");let H=W[0],B=X.find((U)=>U.panelId===H.id);if(G5(B,"Panel metadata not found"),B.collapsible){let U=Y[H.id],_=B.collapsedSize===U?Z.mutableState.expandedPanelSizes[H.id]??B.minSize:B.collapsedSize;v2(J,_-U)}break}case"F6":{$.preventDefault();let Z=Bz(J).separators.map((Y)=>Y.element),q=Array.from(Z).findIndex((Y)=>Y===$.currentTarget);G5(q!==null,"Index not found");let X=$.shiftKey?q>0?q-1:Z.length-1:q+1<Z.length?q+1:0;Z[X].focus({preventScroll:!0});break}case"Home":{$.preventDefault(),v2(J,-100);break}}}var RJ={cursorFlags:0,state:"inactive"},pB=new mB;function m2(){return RJ}function ql($){return pB.addListener("change",$)}function Xl($){let J=RJ,Q={...RJ};Q.cursorFlags=$,RJ=Q,pB.emit("change",{prev:J,next:Q})}function CJ($){let J=RJ;RJ=$,pB.emit("change",{prev:J,next:$})}function rI($){if($.defaultPrevented)return;if($.pointerType==="mouse"&&$.button>0)return;let J=c2(),Q=dB($,J),Z=new Map,q=!1;Q.forEach((X)=>{X.separator&&(q||(q=!0,X.separator.element.focus({focusVisible:!1,preventScroll:!0})));let Y=J.get(X.group);Y&&Z.set(X.group,Y.layout)}),CJ({cursorFlags:0,hitRegions:Q,initialLayoutMap:Z,pointerDownAtPoint:{x:$.clientX,y:$.clientY},state:"active"}),Q.length&&$.preventDefault()}var Yl=($)=>$,vB=()=>{},WT=1,HT=2,BT=4,UT=8,sI=3,oI=12,Hz;function nI(){return Hz===void 0&&(Hz=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Hz=!0)),Hz}function zl({cursorFlags:$,groups:J,state:Q}){let Z=0,q=0;switch(Q){case"active":case"hover":J.forEach((X)=>{if(!X.mutableState.disableCursor)switch(X.orientation){case"horizontal":{Z++;break}case"vertical":{q++;break}}})}if(!(Z===0&&q===0)){switch(Q){case"active":{if($&&nI()){let X=($&WT)!==0,Y=($&HT)!==0,z=($&BT)!==0,K=($&UT)!==0;if(X)return z?"se-resize":K?"ne-resize":"e-resize";if(Y)return z?"sw-resize":K?"nw-resize":"w-resize";if(z)return"s-resize";if(K)return"n-resize"}break}}return nI()?Z>0&&q>0?"move":Z>0?"ew-resize":"ns-resize":Z>0&&q>0?"grab":Z>0?"col-resize":"row-resize"}}var aI=new WeakMap;function lB($){if($.defaultView===null||$.defaultView===void 0)return;let{prevStyle:J,styleSheet:Q}=aI.get($)??{};Q===void 0&&(Q=new $.defaultView.CSSStyleSheet,$.adoptedStyleSheets&&(Object.isExtensible($.adoptedStyleSheets)?$.adoptedStyleSheets.push(Q):$.adoptedStyleSheets=[...$.adoptedStyleSheets,Q]));let Z=m2();switch(Z.state){case"active":case"hover":{let q=zl({cursorFlags:Z.cursorFlags,groups:Z.hitRegions.map((Y)=>Y.group),state:Z.state}),X=`*, *:hover {cursor: ${q} !important; }`;if(J===X)return;J=X,q?Q.cssRules.length===0?Q.insertRule(X):Q.replaceSync(X):Q.cssRules.length===1&&Q.deleteRule(0);break}case"inactive":{J=void 0,Q.cssRules.length===1&&Q.deleteRule(0);break}}aI.set($,{prevStyle:J,styleSheet:Q})}function _T({document:$,event:J,hitRegions:Q,initialLayoutMap:Z,mountedGroups:q,pointerDownAtPoint:X,prevCursorFlags:Y}){let z=0;Q.forEach((W)=>{let{group:H,groupSize:B}=W,{orientation:U,panels:_}=H,{disableCursor:L}=H.mutableState,F=0;X?U==="horizontal"?F=(J.clientX-X.x)/B*100:F=(J.clientY-X.y)/B*100:U==="horizontal"?F=J.clientX<0?-100:100:F=J.clientY<0?-100:100;let V=Z.get(H),M=q.get(H);if(!V||!M)return;let{defaultLayoutDeferred:D,derivedPanelConstraints:N,groupSize:O,layout:I,separatorToPanels:A}=M;if(N&&I&&A){let b=CZ({delta:F,initialLayout:V,panelConstraints:N,pivotIndices:W.panels.map((k)=>_.indexOf(k)),prevLayout:I,trigger:"mouse-or-touch"});if(g2(b,I)){if(F!==0&&!L)switch(U){case"horizontal":{z|=F<0?WT:HT;break}case"vertical":{z|=F<0?BT:UT;break}}}else i4(W.group,{defaultLayoutDeferred:D,derivedPanelConstraints:N,groupSize:O,layout:b,separatorToPanels:A})}});let K=0;J.movementX===0?K|=Y&sI:K|=z&sI,J.movementY===0?K|=Y&oI:K|=z&oI,Xl(K),lB($)}function tI($){let J=c2(),Q=m2();switch(Q.state){case"active":_T({document:$.currentTarget,event:$,hitRegions:Q.hitRegions,initialLayoutMap:Q.initialLayoutMap,mountedGroups:J,prevCursorFlags:Q.cursorFlags})}}function eI($){if($.defaultPrevented)return;let J=m2(),Q=c2();switch(J.state){case"active":{if($.buttons===0){CJ({cursorFlags:0,state:"inactive"}),J.hitRegions.forEach((Z)=>{let q=T7(Z.group.id,!0);i4(Z.group,q)});return}for(let Z of J.hitRegions)if(Z.separator){let{element:q}=Z.separator;q.hasPointerCapture?.($.pointerId)||q.setPointerCapture?.($.pointerId)}_T({document:$.currentTarget,event:$,hitRegions:J.hitRegions,initialLayoutMap:J.initialLayoutMap,mountedGroups:Q,pointerDownAtPoint:J.pointerDownAtPoint,prevCursorFlags:J.cursorFlags});break}default:{let Z=dB($,Q);Z.length===0?J.state!=="inactive"&&CJ({cursorFlags:0,state:"inactive"}):CJ({cursorFlags:0,hitRegions:Z,state:"hover"}),lB($.currentTarget);break}}}function $T($){if($.relatedTarget instanceof HTMLIFrameElement)switch(m2().state){case"hover":CJ({cursorFlags:0,state:"inactive"})}}function JT($){if($.defaultPrevented)return;if($.pointerType==="mouse"&&$.button>0)return;let J=m2();switch(J.state){case"active":CJ({cursorFlags:0,state:"inactive"}),J.hitRegions.length>0&&(lB($.currentTarget),J.hitRegions.forEach((Q)=>{let Z=T7(Q.group.id,!0);i4(Q.group,Z)}),$.preventDefault())}}function QT($){let J=0,Q=0,Z={};for(let X of $)if(X.defaultSize!==void 0){J++;let Y=J6(X.defaultSize);Q+=Y,Z[X.panelId]=Y}else Z[X.panelId]=void 0;let q=$.length-J;if(q!==0){let X=J6((100-Q)/q);for(let Y of $)Y.defaultSize===void 0&&(Z[Y.panelId]=X)}return Z}function Kl($,J,Q){if(!Q[0])return;let Z=$.panels.find((K)=>K.element===J);if(!Z||!Z.onResize)return;let q=SJ({group:$}),X=$.orientation==="horizontal"?Z.element.offsetWidth:Z.element.offsetHeight,Y=Z.mutableValues.prevSize,z={asPercentage:J6(X/q*100),inPixels:X};Z.mutableValues.prevSize=z,Z.onResize(z,Z.id,Y)}function Gl($,J){if(Object.keys($).length!==Object.keys(J).length)return!1;for(let Q in $)if($[Q]!==J[Q])return!1;return!0}function Wl({group:$,nextGroupSize:J,prevGroupSize:Q,prevLayout:Z}){if(Q<=0||J<=0||Q===J)return Z;let q=0,X=0,Y=!1,z=new Map,K=[];for(let B of $.panels){let U=Z[B.id]??0;switch(B.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{Y=!0;let _=U/100*Q,L=J6(_/J*100);z.set(B.id,L),q+=L;break}case"preserve-relative-size":default:{K.push(B.id),X+=U;break}}}if(!Y||K.length===0)return Z;let W=100-q,H={...Z};if(z.forEach((B,U)=>{H[U]=B}),X>0)for(let B of K){let U=Z[B]??0;H[B]=J6(U/X*W)}else{let B=J6(W/K.length);for(let U of K)H[U]=B}return H}function Hl($,J){let Q=$.map((q)=>q.id),Z=Object.keys(J);if(Q.length!==Z.length)return!1;for(let q of Q)if(!Z.includes(q))return!1;return!0}var yJ=new Map;function Bl($){let J=!0;G5($.element.ownerDocument.defaultView,"Cannot register an unmounted Group");let Q=$.element.ownerDocument.defaultView.ResizeObserver,Z=new Set,q=new Set,X=new Q((L)=>{for(let F of L){let{borderBoxSize:V,target:M}=F;if(M===$.element){if(J){let D=SJ({group:$});if(D===0)return;let N=T7($.id);if(!N)return;let O=gB($),I=N.defaultLayoutDeferred?QT(O):N.layout,A=Wl({group:$,nextGroupSize:D,prevGroupSize:N.groupSize,prevLayout:I}),b=u2({layout:A,panelConstraints:O});if(!N.defaultLayoutDeferred&&g2(N.layout,b)&&Gl(N.derivedPanelConstraints,O)&&N.groupSize===D)return;i4($,{defaultLayoutDeferred:!1,derivedPanelConstraints:O,groupSize:D,layout:b,separatorToPanels:N.separatorToPanels})}}else Kl($,M,V)}});X.observe($.element),$.panels.forEach((L)=>{G5(!Z.has(L.id),`Panel ids must be unique; id "${L.id}" was used more than once`),Z.add(L.id),L.onResize&&X.observe(L.element)});let Y=SJ({group:$}),z=gB($),K=$.panels.map(({id:L})=>L).join(","),W=$.mutableState.defaultLayout;W&&(Hl($.panels,W)||(W=void 0));let H=$.mutableState.layouts[K]??W??QT(z),B=u2({layout:H,panelConstraints:z}),U=$.element.ownerDocument;yJ.set(U,(yJ.get(U)??0)+1);let _=new Map;return XT($).forEach((L)=>{L.separator&&_.set(L.separator,L.panels)}),i4($,{defaultLayoutDeferred:Y===0,derivedPanelConstraints:z,groupSize:Y,layout:B,separatorToPanels:_}),$.separators.forEach((L)=>{G5(!q.has(L.id),`Separator ids must be unique; id "${L.id}" was used more than once`),q.add(L.id),L.element.addEventListener("keydown",iI)}),yJ.get(U)===1&&(U.addEventListener("dblclick",lI,!0),U.addEventListener("pointerdown",rI,!0),U.addEventListener("pointerleave",tI),U.addEventListener("pointermove",eI),U.addEventListener("pointerout",$T),U.addEventListener("pointerup",JT,!0)),function(){J=!1,yJ.set(U,Math.max(0,(yJ.get(U)??0)-1)),sp($),$.separators.forEach((L)=>{L.element.removeEventListener("keydown",iI)}),yJ.get(U)||(U.removeEventListener("dblclick",lI,!0),U.removeEventListener("pointerdown",rI,!0),U.removeEventListener("pointerleave",tI),U.removeEventListener("pointermove",eI),U.removeEventListener("pointerout",$T),U.removeEventListener("pointerup",JT,!0)),X.disconnect()}}function Ul(){let[$,J]=R1.useState({}),Q=R1.useCallback(()=>J({}),[]);return[$,Q]}function iB($){let J=R1.useId();return`${$??J}`}var d2=typeof window<"u"?R1.useLayoutEffect:R1.useEffect;function RZ($){let J=R1.useRef($);return d2(()=>{J.current=$},[$]),R1.useCallback((...Q)=>J.current?.(...Q),[J])}function rB(...$){return RZ((J)=>{$.forEach((Q)=>{if(Q)switch(typeof Q){case"function":{Q(J);break}case"object":{Q.current=J;break}}})})}function sB($){let J=R1.useRef({...$});return d2(()=>{for(let Q in $)J.current[Q]=$[Q]},[$]),J.current}var LT=R1.createContext(null);function _l($,J){let Q=R1.useRef({getLayout:()=>({}),setLayout:Yl});R1.useImperativeHandle(J,()=>Q.current,[]),d2(()=>{Object.assign(Q.current,GT({groupId:$}))})}function oB({children:$,className:J,defaultLayout:Q,disableCursor:Z,disabled:q,elementRef:X,groupRef:Y,id:z,onLayoutChange:K,onLayoutChanged:W,orientation:H="horizontal",resizeTargetMinimumSize:B={coarse:20,fine:10},style:U,..._}){let L=R1.useRef({onLayoutChange:{},onLayoutChanged:{}}),F=RZ((y)=>{g2(L.current.onLayoutChange,y)||(L.current.onLayoutChange=y,K?.(y))}),V=RZ((y)=>{g2(L.current.onLayoutChanged,y)||(L.current.onLayoutChanged=y,W?.(y))}),M=iB(z),D=R1.useRef(null),[N,O]=Ul(),I=R1.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:B,separators:[]}),A=rB(D,X);_l(M,Y);let b=RZ((y,f)=>{let j=m2(),P=mI(y),x=T7(y);if(x){let p=!1;switch(j.state){case"active":{p=j.hitRegions.some((t)=>t.group===P);break}}return{flexGrow:x.layout[f]??1,pointerEvents:p?"none":void 0}}if(Q?.[f])return{flexGrow:Q?.[f]}}),k=sB({defaultLayout:Q,disableCursor:Z}),w=R1.useMemo(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:b,id:M,orientation:H,registerPanel:(y)=>{let f=I.current;return f.panels=uB(H,[...f.panels,y]),O(),()=>{f.panels=f.panels.filter((j)=>j!==y),O()}},registerSeparator:(y)=>{let f=I.current;return f.separators=uB(H,[...f.separators,y]),O(),()=>{f.separators=f.separators.filter((j)=>j!==y),O()}},updatePanelProps:(y,{disabled:f})=>{let j=I.current.panels.find((p)=>p.id===y);j&&(j.panelConstraints.disabled=f);let P=mI(M),x=T7(M);P&&x&&i4(P,{...x,derivedPanelConstraints:gB(P)})},updateSeparatorProps:(y,{disabled:f,disableDoubleClick:j})=>{let P=I.current.separators.find((x)=>x.id===y);P&&(P.disabled=f,P.disableDoubleClick=j)}}),[b,M,O,H,k]),C=R1.useRef(null);return d2(()=>{let y=D.current;if(y===null)return;let f=I.current,j;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===f.panels.length){j={};for(let $0 of f.panels){let Y0=k.defaultLayout[$0.id];Y0!==void 0&&(j[$0.id]=Y0)}}let P={disabled:!!q,element:y,id:M,mutableState:{defaultLayout:j,disableCursor:!!k.disableCursor,expandedPanelSizes:I.current.lastExpandedPanelSizes,layouts:I.current.layouts},orientation:H,panels:f.panels,resizeTargetMinimumSize:f.resizeTargetMinimumSize,separators:f.separators};C.current=P;let x=Bl(P),{defaultLayoutDeferred:p,derivedPanelConstraints:t,layout:h}=T7(P.id,!0);!p&&t.length>0&&(F(h),V(h));let r=cB(M,($0)=>{let{defaultLayoutDeferred:Y0,derivedPanelConstraints:e,layout:H0}=$0.next;if(Y0||e.length===0)return;let K0=P.panels.map(({id:m})=>m).join(",");P.mutableState.layouts[K0]=H0,e.forEach((m)=>{if(m.collapsible){let{layout:c}=$0.prev??{};if(c){let i=u8(m.collapsedSize,H0[m.panelId]),u=u8(m.collapsedSize,c[m.panelId]);i&&!u&&(P.mutableState.expandedPanelSizes[m.panelId]=c[m.panelId])}}});let E=m2().state!=="active";F(H0),E&&V(H0)});return()=>{C.current=null,x(),r()}},[q,M,V,F,H,N,k]),R1.useEffect(()=>{let y=C.current;y&&(y.mutableState.defaultLayout=Q,y.mutableState.disableCursor=!!Z)}),G(LT.Provider,{value:w,children:G("div",{..._,className:J,"data-group":!0,"data-testid":M,id:M,ref:A,style:{height:"100%",width:"100%",overflow:"hidden",...U,display:"flex",flexDirection:H==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:H==="horizontal"?"pan-y":"pan-x"},children:$})})}oB.displayName="Group";function nB(){let $=R1.useContext(LT);return G5($,"Group Context not found; did you render a Panel or Separator outside of a Group?"),$}function Ll($,J){let{id:Q}=nB(),Z=R1.useRef({collapse:vB,expand:vB,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:vB});R1.useImperativeHandle(J,()=>Z.current,[]),d2(()=>{Object.assign(Z.current,KT({groupId:Q,panelId:$}))})}function aB({children:$,className:J,collapsedSize:Q="0%",collapsible:Z=!1,defaultSize:q,disabled:X,elementRef:Y,groupResizeBehavior:z="preserve-relative-size",id:K,maxSize:W="100%",minSize:H="0%",onResize:B,panelRef:U,style:_,...L}){let F=!!K,V=iB(K),M=sB({disabled:X}),D=R1.useRef(null),N=rB(D,Y),{getPanelStyles:O,id:I,orientation:A,registerPanel:b,updatePanelProps:k}=nB(),w=B!==null,C=RZ((P,x,p)=>{B?.(P,K,p)});d2(()=>{let P=D.current;if(P!==null){let x={element:P,id:V,idIsStable:F,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:w?C:void 0,panelConstraints:{groupResizeBehavior:z,collapsedSize:Q,collapsible:Z,defaultSize:q,disabled:M.disabled,maxSize:W,minSize:H}};return b(x)}},[z,Q,Z,q,w,V,F,W,H,C,b,M]),R1.useEffect(()=>{k(V,{disabled:X})},[X,V,k]),Ll(V,U);let y=()=>{let P=O(I,V);if(P)return JSON.stringify(P)},f=R1.useSyncExternalStore((P)=>cB(I,P),y,y),j;return f?j=JSON.parse(f):q!==void 0?j={flexGrow:void 0,flexShrink:void 0,flexBasis:q}:j={flexGrow:1},G("div",{...L,"data-disabled":X||void 0,"data-panel":!0,"data-testid":V,id:V,ref:N,style:{...Fl,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...j},children:G("div",{className:J,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:A==="horizontal"?"pan-y":"pan-x"},children:$})})}aB.displayName="Panel";var Fl={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Vl({layout:$,panelConstraints:J,panelId:Q,panelIndex:Z}){let q,X,Y=$[Q],z=J.find((K)=>K.panelId===Q);if(z){let K=z.maxSize,W=z.collapsible?z.collapsedSize:z.minSize,H=[Z,Z+1];X=u2({layout:CZ({delta:W-Y,initialLayout:$,panelConstraints:J,pivotIndices:H,prevLayout:$}),panelConstraints:J})[Q],q=u2({layout:CZ({delta:K-Y,initialLayout:$,panelConstraints:J,pivotIndices:H,prevLayout:$}),panelConstraints:J})[Q]}return{valueControls:Q,valueMax:q,valueMin:X,valueNow:Y}}function tB({children:$,className:J,disabled:Q,disableDoubleClick:Z,elementRef:q,id:X,style:Y,...z}){let K=iB(X),W=sB({disabled:Q,disableDoubleClick:Z}),[H,B]=R1.useState({}),[U,_]=R1.useState("inactive"),[L,F]=R1.useState(!1),V=R1.useRef(null),M=rB(V,q),{disableCursor:D,id:N,orientation:O,registerSeparator:I,updateSeparatorProps:A}=nB(),b=O==="horizontal"?"vertical":"horizontal";d2(()=>{let C=V.current;if(C!==null){let y={disabled:W.disabled,disableDoubleClick:W.disableDoubleClick,element:C,id:K},f=I(y),j=ql((x)=>{_(x.next.state!=="inactive"&&x.next.hitRegions.some((p)=>p.separator===y)?x.next.state:"inactive")}),P=cB(N,(x)=>{let{derivedPanelConstraints:p,layout:t,separatorToPanels:h}=x.next,r=h.get(y);if(r){let $0=r[0],Y0=r.indexOf($0);B(Vl({layout:t,panelConstraints:p,panelId:$0.id,panelIndex:Y0}))}});return()=>{j(),P(),f()}}},[N,K,I,W]),R1.useEffect(()=>{A(K,{disabled:Q,disableDoubleClick:Z})},[Q,Z,K,A]);let k;Q&&!D&&(k="not-allowed");let w;if(Q)w="disabled";else switch(U){case"active":{w="active";break}default:L?w="focus":w=U}return G("div",{...z,"aria-controls":H.valueControls,"aria-disabled":Q||void 0,"aria-orientation":b,"aria-valuemax":H.valueMax,"aria-valuemin":H.valueMin,"aria-valuenow":H.valueNow,children:$,className:J,"data-separator":w,"data-testid":K,id:K,onBlur:()=>F(!1),onFocus:()=>F(!0),ref:M,role:"separator",style:{flexBasis:"auto",cursor:k,...Y,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:Q?void 0:0})}tB.displayName="Separator";function VT({className:$,...J}){return G(oB,{"data-slot":"resizable-panel-group",className:b0("flex h-full w-full aria-[orientation=vertical]:flex-col",$),...J})}function eB($){return G(aB,{"data-slot":"resizable-panel",...$})}function MT({withHandle:$,className:J,onPointerDown:Q,...Z}){return G(tB,{"data-slot":"resizable-handle",className:b0("relative flex w-px touch-none items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-2 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 aria-[orientation=vertical]:cursor-col-resize aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:cursor-row-resize aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-2 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",J),onPointerDown:(q)=>{q.stopPropagation(),Q?.(q)},...Z,children:$?G("div",{className:"z-10 flex h-7 w-3 items-center justify-center rounded-sm border border-border bg-background shadow-sm",children:G(FT,{className:"size-2.5 text-muted-foreground"})}):null})}var Dl={backgroundColor:"var(--multitrack-video-bg)",backgroundColorStrong:"var(--multitrack-video-bg-strong)",borderColor:"var(--multitrack-video-border)",textColor:"var(--multitrack-video-text)",textClassName:"text-[10px]",titleBackgroundColor:null,waveformColor:"var(--multitrack-video-waveform)",showThumbnail:!0,showWaveform:!0,waveformSource:"decoded-media"},Nl={backgroundColor:"var(--multitrack-audio-bg)",backgroundColorStrong:"var(--multitrack-audio-bg-strong)",borderColor:"var(--multitrack-audio-border)",textColor:"var(--multitrack-audio-text)",textClassName:"text-[10px]",titleBackgroundColor:"var(--multitrack-audio-title-bg)",waveformColor:"var(--multitrack-audio-waveform)",showThumbnail:!1,showWaveform:!0,waveformSource:"decoded-media"},Ol={backgroundColor:"var(--multitrack-task-bg)",backgroundColorStrong:"var(--multitrack-task-bg-strong)",borderColor:"var(--multitrack-task-border)",textColor:"var(--multitrack-task-text)",textClassName:"text-[8px]",titleBackgroundColor:null,waveformColor:null,showThumbnail:!1,showWaveform:!1,waveformSource:null},Al={backgroundColor:"var(--multitrack-subtitle-bg)",backgroundColorStrong:"var(--multitrack-subtitle-bg-strong)",borderColor:"var(--multitrack-subtitle-border)",textColor:"var(--multitrack-subtitle-text)",textClassName:"text-[8px]",titleBackgroundColor:null,waveformColor:null,showThumbnail:!1,showWaveform:!1,waveformSource:null};function Z4($){if($==="video")return Dl;if($==="audio")return Nl;if($==="subtitle")return Al;return Ol}var R6=R(v(),1),AT=R(J5(),1);var wl=new Set(["arabic","chinese","english","french","german","hindi","indonesian","italian","japanese","korean","malay","portuguese","russian","spanish","thai","turkish","vietnamese"]),hJ=/<[^<>\n]*>|@(?:图片|音频|视频|Picture|Image|Audio|Video)\s*\d+|\{[^{}\n]*\}|\[[^\[\]\n]*\]|\(S\d+(?:\s*,\s*S?\d+)*\)|(?:subject_definitions|summary|retention_analysis|detailed_description|overall_soundscape|non_diegetic_music)\s*:\s*|(?:主体定义|摘要|留存分析|详细描述|整体声景|非叙事性音乐)\s*[::]\s*|[||]/gi,ZU="prompt-reference-chip inline-flex h-[1.6em] max-w-full items-center gap-1 rounded-md border px-1.5 py-0.5 mx-1 align-middle font-semibold leading-none shadow-sm",wT="font-semibold text-muted-foreground";function kT($){if(/^<Subject\s+\d+>$/i.test($))return!0;if(/^<\/?d>$/i.test($)||/^<(?:scenetrans|cutoff)>$/i.test($))return!0;if(/^\[Shot\s+\d+\]$/i.test($)||/^\(S\d+(?:\s*,\s*S?\d+)*\)$/i.test($))return!0;return IT($)}function IT($){let J=$.match(/^\[([A-Za-z]+)\]$/)?.[1].toLowerCase();return J!==void 0&&wl.has(J)}function DT($){return/^\[Shot\s+\d+\]$/i.test($)}function TT($){return/^(?:(?:subject_definitions|summary|retention_analysis|detailed_description|overall_soundscape|non_diegetic_music)\s*:|(?:主体定义|摘要|留存分析|详细描述|整体声景|非叙事性音乐)\s*[::])\s*$/i.test($)}function kl($,J){if(J?.color)return J.color;if($.type==="audio")return"var(--multitrack-audio-waveform)";if($.type==="video")return"var(--multitrack-video-waveform)";return"var(--multitrack-task-bg)"}function bT($,J){$.style.color=J,$.style.borderColor=J,$.style.backgroundColor=`color-mix(in srgb, ${J} 10%, transparent)`}function Il($,J){let Q=J.type==="image"?"Picture":J.type==="audio"?"Audio":"Video";if(/^<(?:Picture|Image|Audio|Video)\s+\d+>$/i.test($))return`<${Q} ${J.index}>`;if(/^@(?:Picture|Image|Audio|Video)\s*\d+$/i.test($))return`@${Q} ${J.index}`;return J.token}function xJ($){let J=$.match(/^@?(图片|音频|视频|Picture|Image|Audio|Video)\s*(\d+)>?$/i)??$.match(/^<(Picture|Audio|Video)\s+(\d+)>$/i);if(!J)return null;let Q=J[1].toLowerCase();return{type:Q==="图片"||Q==="picture"||Q==="image"?"image":Q==="音频"||Q==="audio"?"audio":"video",index:Number(J[2])}}function Fz($){let J="",Q=(q)=>{J+=q.replaceAll("","")},Z=(q)=>{if(q.nodeType===Node.TEXT_NODE){Q(q.textContent??"");return}if(!(q instanceof HTMLElement))return;let X=q.dataset.promptReferenceToken??q.dataset.promptSemanticToken;if(X!==void 0){Q(X);return}if(q.dataset.promptEmphasisText!==void 0){Q(q.textContent??"");return}if(q.tagName==="BR"){Q(`
|
||
`);return}if((q.tagName==="DIV"||q.tagName==="P")&&J&&!J.endsWith(`
|
||
`))Q(`
|
||
`);q.childNodes.forEach(Z)};return $.childNodes.forEach(Z),J}function SZ($){return Fz($)}function Tl($){return/^\n*$/.test($)?"":$}function $U($){let J=window.getSelection();if(!J?.rangeCount)return SZ($).length;let Q=J.getRangeAt(0);if(!$.contains(Q.endContainer))return SZ($).length;let Z=Q.cloneRange();return Z.selectNodeContents($),Z.setEnd(Q.endContainer,Q.endOffset),Fz(Z.cloneContents()).length}function bl($,J,Q,Z){let q=[];hJ.lastIndex=0;for(let X of $.matchAll(hJ)){let Y=X[0],z=xJ(Y);if(z&&!J)q.push(`reference:${z.type}:${z.index}`);else if(Q&&kT(Y))q.push(`semantic:${Y.toLowerCase()}`);else if(Q&&TT(Y))q.push(`emphasis:${Y.toLowerCase()}`);else if(J&&(Y.startsWith("{")||Y.startsWith("<")))q.push("system");else if(Z&&(Y==="|"||Y==="|"))q.push("pipe")}return q.join("|")}function jl($){return Array.from($.querySelectorAll("[data-prompt-reference-token], [data-prompt-semantic-token], [data-prompt-emphasis-text], [data-system-prompt-variable], [data-pipe]")).map((J)=>{let Q=J.dataset.promptReferenceToken;if(Q!==void 0){let Z=xJ(Q);return Z?`reference:${Z.type}:${Z.index}`:"reference:unknown"}if(J.dataset.systemPromptVariable!==void 0)return"system";if(J.dataset.promptSemanticToken!==void 0)return`semantic:${J.dataset.promptSemanticToken.toLowerCase()}`;if(J.dataset.promptEmphasisText!==void 0)return`emphasis:${J.dataset.promptEmphasisText.toLowerCase()}`;return"pipe"}).join("|")}function Uz($,J){let Q=window.getSelection();if(!Q)return;let Z=Math.max(0,J);for(let X of $.childNodes){let Y=X instanceof HTMLElement?X:null,z=Y?.dataset.promptReferenceToken??Y?.dataset.promptSemanticToken??Y?.dataset.promptEmphasisText,K=z!==void 0?z.length:Y?.tagName==="BR"?1:X.textContent?.replaceAll("","").length??0;if(Z<=K){let W=document.createRange();if(z!==void 0)Z===0?W.setStartBefore(X):W.setStartAfter(X);else if(Y?.tagName==="BR")Z===0?W.setStartBefore(X):W.setStartAfter(X);else if(X.nodeType===Node.TEXT_NODE)W.setStart(X,Math.min(Z,X.textContent?.length??0));else{let H=document.createTreeWalker(X,NodeFilter.SHOW_TEXT).nextNode();if(H)W.setStart(H,Math.min(Z,H.textContent?.length??0));else W.setStartAfter(X)}W.collapse(!0),Q.removeAllRanges(),Q.addRange(W);return}Z-=K}let q=document.createRange();q.selectNodeContents($),q.collapse(!1),Q.removeAllRanges(),Q.addRange(q)}function El($,J,Q){hJ.lastIndex=0;for(let Z of $.matchAll(hJ)){if(!xJ(Z[0]))continue;let q=Z.index??0,X=q+Z[0].length;if(Q==="Backspace"&&J>q&&J<=X)return{start:q,end:X};if(Q==="Delete"&&J>=q&&J<X)return{start:q,end:X}}return null}function Lz($,J){J.split(`
|
||
`).forEach((Q,Z)=>{if(Z>0)$.append(document.createElement("br"));if(Q)$.append(document.createTextNode(Q))})}function JU($,J){J.split(`
|
||
`).forEach((Q,Z)=>{if(Z>0)$.append(document.createElement("br"));if(!Q)return;let q=document.createElement("span");q.dataset.promptDialogueContent="true",q.className=wT,q.textContent=Q,$.append(q)})}function NT($,J){let Q=window.getSelection();if(!Q?.rangeCount)return!1;let Z=Q.getRangeAt(0);if(!$.contains(Z.commonAncestorContainer))return!1;Z.deleteContents();let q=document.createDocumentFragment();Lz(q,J);let X=document.createTextNode("");q.append(X),Z.insertNode(q);let Y=document.createRange();return Y.setStart(X,X.textContent?.length??0),Y.collapse(!0),Q.removeAllRanges(),Q.addRange(Y),!0}function yl($){let J=window.getSelection();if(!J?.rangeCount||J.isCollapsed)return null;let Q=J.getRangeAt(0);if(!$.contains(Q.commonAncestorContainer))return null;return Fz(Q.cloneContents())}function Pl($,J,Q){let Z=xJ(J),q=document.createElement("span");if(q.contentEditable="false",q.dataset.promptReferenceToken=J,q.dataset.promptReferenceType=Z?.type??"",q.className=`${ZU} cursor-pointer`,bT(q,Z?kl(Z,Q):"var(--muted-foreground)"),Q?.type==="image"&&Q.thumbnailUrl){let Y=document.createElement("img");Y.src=Q.thumbnailUrl,Y.alt="",Y.draggable=!1,Y.className="h-4 w-4 shrink-0 rounded-sm object-cover align-middle",q.append(Y)}else{let Y=document.createElement("span");Y.className="prompt-reference-icon inline-flex h-4 w-4 shrink-0 items-center justify-center",Y.dataset.referenceIcon=Q?.type??Z?.type??"image";let z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("viewBox","0 0 24 24"),z.setAttribute("fill","none"),z.setAttribute("stroke","currentColor"),z.setAttribute("stroke-width","2"),z.setAttribute("stroke-linecap","round"),z.setAttribute("stroke-linejoin","round"),z.setAttribute("aria-hidden","true"),z.classList.add("lucide","h-4","w-4");let K=Q?.type??Z?.type??"image";(K==="audio"?["M2 10v3","M6 6v11","M10 3v18","M14 8v7","M18 5v13","M22 10v3"]:K==="video"?["m16 13 5.223-3.482a.5.5 0 0 1 .777.416v8.132a.5.5 0 0 1-.777.416L16 15","M2 6h14v12H2z","m2 6 3-4","m7 6 3-4","m12 6 3-4"]:["M14.5 4h-9A2.5 2.5 0 0 0 3 6.5v11A2.5 2.5 0 0 0 5.5 20h13a2.5 2.5 0 0 0 2.5-2.5v-8","m3 16 5-5c.928-.893 2.072-.893 3 0l4 4","m14 14 1-1c.928-.893 2.072-.893 3 0l3 3","M14 7h.01"]).forEach((H)=>{let B=document.createElementNS("http://www.w3.org/2000/svg","path");B.setAttribute("d",H),z.append(B)}),Y.append(z),q.append(Y)}let X=document.createElement("span");X.className="inline-flex h-full items-center leading-none",X.textContent=J,q.append(X),q.title=Q?.detail??J,$.append(q)}function OT($,J){let Q=document.createElement("span");Q.className="inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",Q.dataset.semanticIcon=J;let Z=document.createElementNS("http://www.w3.org/2000/svg","svg");Z.setAttribute("viewBox","0 0 24 24"),Z.setAttribute("fill","none"),Z.setAttribute("stroke","currentColor"),Z.setAttribute("stroke-width","2"),Z.setAttribute("stroke-linecap","round"),Z.setAttribute("stroke-linejoin","round"),Z.setAttribute("aria-hidden","true"),Z.classList.add("lucide","h-3.5","w-3.5"),(J==="subject"?["M18 21a8 8 0 0 0-16 0","M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8","M19 8v6","M22 11h-6"]:["M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"]).forEach((X)=>{let Y=document.createElementNS("http://www.w3.org/2000/svg","path");Y.setAttribute("d",X),Z.append(Y)}),Q.append(Z),$.append(Q)}function Rl($,J){let Q=document.createElement("span");Q.contentEditable="false",Q.dataset.promptSemanticToken=J,Q.className=ZU;let Z=/^<Subject\s+\d+>$/i.test(J),q=/^<\/?d>$/i.test(J),X=DT(J)||IT(J),Y=Z||DT(J)?"var(--highlight)":q?"var(--prompt-dialogue)":"var(--prompt-semantic)";if(X)Q.classList.add("border-border","bg-background","text-foreground");else bT(Q,Y);if(Z)OT(Q,"subject");if(q)OT(Q,"dialogue");let z=document.createElement("span");z.className="inline-flex h-full items-center leading-none",z.textContent=J,Q.append(z),$.append(Q)}function Cl($,J){let Q=document.createElement("span");Q.dataset.promptEmphasisText=J,Q.className=wT,Q.textContent=J,$.append(Q)}function _z($,J,Q,Z,q,X){$.textContent="";let Y=0,z=!1;hJ.lastIndex=0;for(let W of J.matchAll(hJ)){let H=W.index??0,B=J.slice(Y,H);if(z)JU($,B);else Lz($,B);let U=W[0],_=/^<d>$/i.test(U);if(/^<\/d>$/i.test(U))z=!1;let F=xJ(U);if(F&&!Z){let V=Q.find((M)=>M.type===F.type&&M.index===F.index);Pl($,U,V)}else if(q&&kT(U))Rl($,U);else if(q&&TT(U))Cl($,U);else if(Z&&(U.startsWith("{")||U.startsWith("<"))){let V=document.createElement("span");V.dataset.systemPromptVariable="true",V.className="text-highlight",V.textContent=U,$.append(V)}else if(X&&(U==="|"||U==="|")){let V=document.createElement("span");V.dataset.pipe="true",V.className="text-highlight",V.textContent="|",$.append(V)}else if(z)JU($,U);else Lz($,U);if(q&&_)z=!0;Y=H+U.length}let K=J.slice(Y);if(z)JU($,K);else Lz($,K)}function Sl({type:$}){if($==="audio")return G(QU,{className:"h-4 w-4"});if($==="video")return G(q4,{className:"h-4 w-4"});return G(MJ,{className:"h-4 w-4"})}function Vz({value:$,onChange:J,ariaLabel:Q,placeholder:Z,resources:q=[],mentionsEnabled:X=!1,interactivePlaceholder:Y=!1,highlightSystemVariables:z=!1,highlightPromptSemantics:K=!1,highlightPipes:W=!1,className:H,testId:B}){let U=Z1(),_=R6.useRef(null),L=R6.useRef(null),F=R6.useRef(!1),V=R6.useRef(""),[M,D]=R6.useState(null),[N,O]=R6.useState($.length===0),I=R6.useMemo(()=>{if(!M)return q;let j=M.query.toLocaleLowerCase();return q.filter((P)=>!j||`${P.label} ${P.detail}`.toLocaleLowerCase().includes(j))},[M,q]),A=R6.useMemo(()=>JSON.stringify({value:$,highlightSystemVariables:z,highlightPromptSemantics:K,highlightPipes:W,resources:q.map((j)=>[j.id,j.index,j.label,j.detail,j.token,j.color,j.thumbnailUrl])}),[W,K,z,q,$]);R6.useEffect(()=>{O($.length===0);let j=L.current;if(!j||V.current===A)return;let P=document.activeElement===j,x=P?$U(j):0;if(_z(j,$,q,z,K,W),P)Uz(j,Math.min(x,$.length));V.current=A},[W,K,z,A,q,$]);function b(j,P){if(!X){D(null);return}let p=j.slice(0,P).match(/@([^\s@|<>]*)$/);if(!p){D(null);return}if(xJ(p[0])){D(null);return}let t=_.current,h=window.getSelection(),$0=(h?.rangeCount?h.getRangeAt(0):null)?.getBoundingClientRect?.(),Y0=t?.getBoundingClientRect(),e=$0?.left??Y0?.left??0,H0=$0?.top??Y0?.top??0,K0=$0?.bottom??Y0?.bottom??0,E=Math.min(Math.max(8,e),Math.max(8,window.innerWidth-264)),m=K0+214<=window.innerHeight?K0+6:Math.max(8,H0-214),c=P-p[0].length;D((i)=>({start:c,end:P,query:p[1],left:E,top:m,activeIndex:i?.start===c?i.activeIndex:0}))}function k(j){if(!X||!N)return;let P=j.getBoundingClientRect(),x=Math.min(Math.max(8,P.left),Math.max(8,window.innerWidth-264)),p=P.bottom+214<=window.innerHeight?P.bottom+6:Math.max(8,P.top-214);D({start:0,end:0,query:"",left:x,top:p,activeIndex:0})}function w(j){let P=L.current,x=j.dataset.promptReferenceToken;if(!X||!P||x===void 0)return;let p=document.createRange();p.selectNodeContents(P),p.setEndBefore(j);let t=Fz(p.cloneContents()).length,h=j.getBoundingClientRect(),r=Math.min(Math.max(8,h.left),Math.max(8,window.innerWidth-264)),$0=h.bottom+214<=window.innerHeight?h.bottom+6:Math.max(8,h.top-214);D({start:t,end:t+x.length,query:"",left:r,top:$0,activeIndex:0})}function C(){let j=L.current;if(!j)return;let P=Tl(SZ(j)),x=P.length===0?0:$U(j);if(P.length===0||jl(j)!==bl(P,z,K,W)){let{scrollTop:t,scrollLeft:h}=j;_z(j,P,q,z,K,W),Uz(j,x),j.scrollTop=t,j.scrollLeft=h}O(P.length===0),V.current=JSON.stringify({value:P,highlightSystemVariables:z,highlightPromptSemantics:K,highlightPipes:W,resources:q.map((t)=>[t.id,t.index,t.label,t.detail,t.token,t.color,t.thumbnailUrl])}),J(P),b(P,x)}function y(j){let P=L.current;if(!P||!M)return;let x=SZ(P),p=x.slice(M.start,M.end),t=Il(p,j),h=`${x.slice(0,M.start)}${t}${x.slice(M.end)}`;_z(P,h,q,z,K,W),O(!1),Uz(P,M.start+t.length),V.current="",J(h),D(null),P.focus()}function f(j){let P=L.current;if(!P)return!1;let x=SZ(P),p=El(x,$U(P),j);if(!p)return!1;let t=`${x.slice(0,p.start)}${x.slice(p.end)}`;return _z(P,t,q,z,K,W),O(t.length===0),Uz(P,p.start),V.current="",D(null),J(t),!0}return T("div",{ref:_,className:"relative h-full min-h-0 max-h-full overflow-hidden [contain:size_layout_paint]",children:[G("div",{ref:L,role:"textbox","aria-label":Q,"aria-multiline":"true","data-testid":B,"data-placeholder":Z,contentEditable:!0,suppressContentEditableWarning:!0,className:b0("prompt-content-editor h-full min-h-0 max-h-full overflow-auto whitespace-pre-wrap wrap-break-word rounded-md px-3 py-2 text-[10px] leading-normal text-foreground caret-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring",!Y&&"empty:before:pointer-events-none empty:before:text-muted-foreground empty:before:content-[attr(data-placeholder)]",H),onInput:()=>{if(!F.current)C()},onCompositionStart:()=>{F.current=!0},onCompositionEnd:()=>{F.current=!1,C()},onPaste:(j)=>{j.preventDefault(),j.stopPropagation(),j.nativeEvent.stopImmediatePropagation?.();let P=L.current,x=j.clipboardData.getData("text/plain");if(P&&NT(P,x))C()},onCopy:(j)=>{j.stopPropagation();let P=L.current,x=P?yl(P):null;if(x===null)return;j.preventDefault(),j.clipboardData.setData("text/plain",x)},onKeyDown:(j)=>{if((j.key==="Backspace"||j.key==="Delete")&&f(j.key)){j.preventDefault();return}if(M){if(j.key==="Escape")j.preventDefault(),D(null);else if(j.key==="ArrowDown"||j.key==="ArrowUp")j.preventDefault(),D((P)=>P&&I.length>0?{...P,activeIndex:(P.activeIndex+(j.key==="ArrowDown"?1:-1)+I.length)%I.length}:P);else if(j.key==="Enter"&&I.length>0){j.preventDefault(),y(I[Math.min(M.activeIndex,I.length-1)]);return}}if(j.key==="Enter"&&!F.current&&!j.nativeEvent.isComposing){j.preventDefault();let P=L.current;if(P&&NT(P,`
|
||
`))C();return}if((j.ctrlKey||j.metaKey)&&["a","c","v","x"].includes(j.key.toLowerCase()))j.stopPropagation()},onClick:(j)=>{let x=(j.target instanceof Element?j.target:null)?.closest("[data-prompt-reference-token]");if(x&&L.current?.contains(x))w(x);else D(null)},onBlur:(j)=>{if(_.current?.contains(j.relatedTarget))return;D(null)}}),Y&&N&&(()=>{let j=Z.indexOf("@"),P=j>=0?Z.slice(0,j):Z,x=j>=0?Z.slice(j+1):"";return T("div",{className:"pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap wrap-break-word px-3 py-2 text-[10px] leading-normal text-muted-foreground",children:[P,j>=0&&G(k0,{type:"button",variant:"ghost","aria-label":U("multitrack.openReferenceResources"),className:b0(ZU,"pointer-events-auto min-w-0 border-border bg-background text-highlight text-[10px]"),onPointerDown:(p)=>p.preventDefault(),onClick:(p)=>k(p.currentTarget),children:"@"}),x]})})(),M&&AT.createPortal(G("div",{className:D8,children:T("div",{role:"listbox","aria-label":U("multitrack.referenceResources"),className:b0("fixed z-50 flex w-64 flex-col overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",I.length===0?"h-64":"max-h-52"),style:{left:M.left,top:M.top},children:[G("div",{className:"shrink-0 px-2 py-1.5 text-[10px] font-semibold text-muted-foreground",children:U("multitrack.referenceResources")}),I.length===0?T("div",{"data-testid":"reference-resources-empty",className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 px-5 pb-7 text-center text-muted-foreground",children:[T("div",{"aria-hidden":"true",className:"relative h-14 w-20 opacity-60",children:[G("span",{className:"absolute left-8 -top-2 flex h-10 w-10 -rotate-12 items-center justify-center rounded-md border border-border bg-muted shadow-sm",children:G(MJ,{className:"h-5 w-5"})}),G("span",{className:"absolute -left-2 top-1 flex h-10 w-10 rotate-3 items-center justify-center rounded-md border border-border bg-muted shadow-sm",children:G(QU,{className:"h-5 w-5"})}),G("span",{className:"absolute left-6 top-4 flex h-10 w-10 rotate-6 items-center justify-center rounded-md border border-border bg-muted shadow-sm",children:G(q4,{className:"h-5 w-5"})})]}),G("span",{className:" text-[10px] leading-relaxed",children:U("multitrack.referenceResourcesEmpty")})]}):I.map((j,P)=>T(k0,{type:"button",variant:"ghost",role:"option","aria-selected":P===M.activeIndex,className:b0("h-auto w-full justify-start gap-2 px-2 py-1.5 text-left",P===M.activeIndex&&"bg-accent text-accent-foreground"),onPointerDown:(x)=>x.preventDefault(),onPointerMove:()=>D((x)=>x?{...x,activeIndex:P}:x),onClick:()=>y(j),children:[j.type==="image"&&j.thumbnailUrl?G("img",{src:j.thumbnailUrl,alt:"",className:"h-8 w-8 shrink-0 rounded-sm object-cover"}):G("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm bg-muted",children:G(Sl,{type:j.type})}),T("span",{className:"min-w-0",children:[G("span",{className:"block truncate text-[11px] font-semibold",style:{color:j.color},children:j.label}),G("span",{className:"block truncate text-[9px] text-muted-foreground",children:j.detail})]})]},j.id))]})}),document.body)]})}var jT=180,hl="55%",ET=280,xl=16,qU="task-images-resizable-panel",yT="task-prompt-resizable-panel",Dz,Mz=null;function PT($){return Oz($.content.images)}function fl($,J,Q){let Z=$.findIndex((z)=>z.id===J),q=$.findIndex((z)=>z.id===Q);if(Z<0||q<0||Z===q)return $;let X=[...$],[Y]=X.splice(Z,1);return X.splice(q,0,Y),X}function hZ($){return $.file_name??$.file_path??$.local_path??$.url??$.slot_name??$.id}function vl($){if(!$)return"";if($.slot_name)return`__slot__:${$.slot_name}`;return $.file_path??$.local_path??$.url??""}function gl($){if($?.source_type==="output")return"outputs";if($?.source_type==="local")return"local";if($?.source_type==="url")return"url";if($?.source_type==="slot")return"slot";return"inputs"}function ul($,J){if(J)return J;if($.startsWith("__slot__:"))return"slot";if($.startsWith("http://")||$.startsWith("https://"))return"url";return"input"}function vT($,J){return J.some((Q)=>Q.content.media_type==="video"&&Q.start_frame<$.end_frame&&Q.end_frame>$.start_frame)}function RT($,J,Q,Z){let q=gZ($.content.images),X=XU($.content.task_mode??"default",q.length,vT($,Q)),Y=$.content.task_mode??"default",z=X==="fl2v"||X==="fmlf2v"?"i2v":X;return J.find((W)=>W.format===Z&&(W.modes?.includes(Y)||W.task_type===X))?.system_prompt??J.find((W)=>W.task_type===z&&W.format===void 0)?.system_prompt??""}async function ml(){if(Dz)return Dz;if(!Mz)Mz=(async()=>{let $=await fetch("/easy-media/prompt/system-prompts");if(!$.ok)throw Error(`Failed to load system prompt options: ${$.status}`);let J=await $.json(),Q=Array.isArray(J.items)?J.items:[];return Dz=Q,Q})().catch(($)=>{throw Mz=null,$});return Mz}function gT({segment:$,node:J,app:Q,trackSegments:Z,selectedSegments:q,videoSegments:X=[],mediaTracks:Y=[],frameRate:z=f2,totalFrames:K,imageIndexOffset:W=0,format:H,onContentChange:B,onTrackSegmentsContentChange:U,onTrackSegmentsChange:_,onDurationChange:L,onOpenImagePreview:F}){let V=xT(H),M=r4(H),D=Z1(),N=c1.useRef(null),[O,I]=c1.useState("user"),[A,b]=c1.useState("individual"),[k,w]=c1.useState(!1),[C,y]=c1.useState(null),[f,j]=c1.useState(!1),[P,x]=c1.useState(!1),[p,t]=c1.useState(Dz??null),[h,r]=c1.useState(!1),[$0,Y0]=c1.useState(!1),e=p2(mJ($),z),H0=jJ(e,z),[K0,E]=c1.useState(H0),m=PT($),c=c1.useMemo(()=>K9(J,Q,"image"),[J,Q,k]),i=m.find((Z0)=>Z0.id===C),u=$.content.task_mode??"default",d=$.content.continuity_mode??xZ,o=$.content.ref_image_size??Tz,S=c1.useMemo(()=>Z&&Z.length>0?Z:[$],[$,Z]),s=S.map((Z0)=>fZ(Z0.content)).join("|"),[G0,l]=c1.useState(s),Q0=Math.max(0,S.findIndex((Z0)=>Z0.id===$.id)),J0=S.reduce((Z0,f0)=>f0.start_frame<Z0.start_frame?f0:Z0).id,B0=q?.some((Z0)=>Z0.id!==J0)===!0,W0=$.content.user_prompt_variant==="b"?"b":"a",L0=A==="combined"?G0:fZ($.content),_0=M,D0=_0?D("multitrack.minimaxPromptPlaceholder"):D("multitrack.promptPlaceholder"),c0=vT($,X),g=RT($,p??[],X,V),a=A==="combined"?S.map((Z0)=>Z0.content.system_prompt??RT(Z0,p??[],X,V)).join("|"):$.content.system_prompt||g,I0=c1.useMemo(()=>{let Z0=gZ(m).map((O1,A1)=>({id:`image:${O1.id}`,type:"image",index:A1+1,label:D("multitrack.referencePicture",{n:A1+1}),detail:hZ(O1),token:`@${D("multitrack.referencePicture",{n:A1+1})}`,color:Z4("task").backgroundColor,thumbnailUrl:Z5({source_type:O1.source_type??"input",file_path:O1.file_path,local_path:O1.local_path,url:O1.url,slot_name:O1.slot_name})??void 0})),f0=Y.filter((O1)=>O1.type==="video"&&O1.segments.some((A1)=>A1.content.media_type==="video")),i0=Y.filter((O1)=>O1.type==="audio"&&O1.segments.some((A1)=>A1.content.media_type==="audio")),M1=f0.map((O1,A1)=>{let T6=A1+1,u6=D("multitrack.referenceAudioItem",{n:T6});return{id:`video-audio:${O1.id}`,type:"audio",index:T6,label:u6,detail:O1.name,token:`@${u6}`,color:Z4("video").waveformColor??Z4("video").backgroundColor}}),N1=i0.map((O1,A1)=>{let T6=f0.length+A1+1,u6=D("multitrack.referenceAudioItem",{n:T6});return{id:`audio:${O1.id}`,type:"audio",index:T6,label:u6,detail:O1.name,token:`@${u6}`,color:Z4("audio").waveformColor??Z4("audio").backgroundColor}}),_5=f0.map((O1,A1)=>{let T6=A1+1,u6=D("multitrack.referenceVideoItem",{n:T6});return{id:`video:${O1.id}`,type:"video",index:T6,label:u6,detail:O1.name,token:`@${u6}`,color:Z4("video").waveformColor??Z4("video").backgroundColor}});return[...Z0,...M1,...N1,..._5]},[m,Y,D]);c1.useEffect(()=>{E(H0)},[H0]),c1.useEffect(()=>{Y0(!1)},[$.id]),c1.useEffect(()=>{l((Z0)=>Z0===s?Z0:s)},[s]);function A0(){let Z0=Yz(K0,z);if(Z0===null){E(H0),Y0(!1);return}if(E(jJ(Z0,z)),Y0(!1),Z0!==e)L?.(Z0)}c1.useEffect(()=>{if(O!=="system")return;if(p!==null)return;let Z0=!1;return r(!0),ml().then((f0)=>{if(!Z0)t(f0)}).catch((f0)=>{if(console.error("[TaskSegmentEditor] failed to load system prompt options:",f0),!Z0)t([])}).finally(()=>{if(!Z0)r(!1)}),()=>{Z0=!0}},[O,p]);function F0(Z0){if(Array.from(Z0.files).some((i0)=>i0.type.startsWith("image/")))return!0;return Array.from(Z0.items??[]).some((i0)=>i0.kind==="file"&&i0.type.startsWith("image/"))}function u0(Z0){if(!Z0.dataTransfer||!F0(Z0.dataTransfer))return;Z0.preventDefault(),j(!0)}function P0(Z0){if(!Z0.dataTransfer||!F0(Z0.dataTransfer))return;Z0.preventDefault(),j(!0)}function n0(Z0){let f0=Z0.relatedTarget;if(f0 instanceof Node&&Z0.currentTarget.contains(f0))return;j(!1)}async function R0(Z0){if(Z0.preventDefault(),j(!1),!Z0.dataTransfer)return;let f0=X4-m.length;if(f0<=0)return;let i0=Array.from(Z0.dataTransfer.files).filter((_5)=>_5.type.startsWith("image/")).slice(0,f0);if(i0.length===0)return;let N1=(await Promise.allSettled(i0.map((_5)=>y7(_5)))).flatMap((_5)=>{if(_5.status==="fulfilled")return[_5.value];return console.error("[TaskSegmentEditor] failed to upload task image:",_5.reason),[]});if(N1.length>0)C5("inputs"),B({images:[...m,...N1]})}function Y1(Z0,f0){let i0=C?1:X4-m.length;if(i0<=0)return;let M1=uJ(Z0).slice(0,i0),N1=ul(Z0,f0),_5=M1.map((O1)=>gJ(O1,N1));if(_5.length===0)return;if(C){let O1={..._5[0],id:C};if(i?.shared_reference===!0&&U){let A1=b7(i),T6=new Map(j7(S,i,!1).map((Y6)=>[Y6.segmentId,Y6.images])),u6=S.map((Y6)=>({...Y6,content:{...Y6.content,images:Y6.id===$.id?[O1,...(T6.get(Y6.id)??[]).filter((rW)=>b7(rW)!==A1)]:T6.get(Y6.id)??PT(Y6)}}));U(j7(u6,O1,!0).map((Y6)=>({segmentId:Y6.segmentId,patch:{images:Y6.images}}))),y(null),w(!1);return}B({images:m.map((A1)=>A1.id===C?O1:A1)})}else B({images:[...m,..._5]});y(null),w(!1)}function z1(Z0){let f0=Z0===""?[""]:Z0.split(/[||]/);if(_){let i0=S.reduce((M1,N1)=>Math.max(M1,N1.end_frame),0);_(fT(f0,S,K??i0,$.color));return}U?.(S.map((i0,M1)=>({segmentId:i0.id,patch:vZ(i0.content,f0[M1]??"")})))}function a0(Z0){if(A==="combined"){l(Z0),z1(Z0);return}B(vZ($.content,Z0))}function C1(Z0){if(A==="combined"){let f0=Z0.split("|");U?.(S.map((i0,M1)=>({segmentId:i0.id,patch:{system_prompt:f0[M1]??""}})));return}B({system_prompt:Z0})}function g1(){let Z0={user_prompt:L0,user_prompt_b:L0};if(U)U(S.map((f0)=>({segmentId:f0.id,patch:Z0})));else B(Z0);x(!1)}function b1(Z0){if(!q||q.length<=1||!U){B(Z0);return}U(q.map((f0)=>({segmentId:f0.id,patch:Z0.continuity_mode!==void 0&&f0.id===J0?{...Z0,continuity_mode:xZ}:Z0})))}function n(Z0){let f0=m.find((i0)=>i0.id===Z0);if(f0?.shared_reference===!0&&U){let i0=b7(f0),M1=j7(S,f0,!1).map((N1)=>({segmentId:N1.segmentId,patch:{images:N1.segmentId===$.id?N1.images.filter((_5)=>b7(_5)!==i0):N1.images}}));U(M1);return}B({images:m.filter((i0)=>i0.id!==Z0)})}function N0(Z0,f0){if(f0&&!fJ(S,Z0))return;let i0=j7(S,Z0,f0);if(U){U(i0.map((N1)=>({segmentId:N1.segmentId,patch:{images:N1.images}})));return}let M1=i0.find((N1)=>N1.segmentId===$.id);if(M1)B({images:M1.images})}function w0(Z0,f0){B({images:m.map((i0)=>i0.id===Z0?{...i0,muted:f0}:i0)})}let v0=m.length>0&&m.length<4?"grid-cols-2":"grid-cols-3",r0=f?"border-primary bg-accent/20":"border-border bg-muted/20",K1=c1.useRef(null),x1=c1.useRef(null),s1=c1.useRef(null),z0=c1.useRef(null),C0=c1.useRef(null),h0=c1.useRef(null),[l0,j0]=c1.useState(!0),[V1,r1]=c1.useState("40%"),[w1,e1]=c1.useState(120);c1.useLayoutEffect(()=>{let Z0=x1.current;if(!Z0)return;let f0=globalThis.getComputedStyle(Z0),i0=Z0.clientWidth-Number.parseFloat(f0.paddingLeft)-Number.parseFloat(f0.paddingRight),M1=Z0.clientHeight-Number.parseFloat(f0.paddingTop)-Number.parseFloat(f0.paddingBottom);if(i0<=0||M1<=0)return;let N1=Math.min(i0*0.55,i0-ET-xl);r1(Math.max(jT,Math.min(M1,N1)))},[]),c1.useLayoutEffect(()=>{let Z0=z0.current??s1.current;if(!Z0)return;let f0=()=>{let M1=Z0.clientWidth;if(M1<=0)return;e1((N1)=>Math.abs(N1-M1)>1?M1:N1)};f0();let i0=new ResizeObserver(f0);return i0.observe(Z0),()=>i0.disconnect()},[m.length]);let D5=Math.round(Math.max(14,Math.min(w1*0.07,28))),X0=Math.round(Math.max(14,Math.min(w1*0.08,32))),O0=Math.round(Math.max(10,Math.min(w1*0.05,20))),x0=Math.round(Math.max(10,Math.min(w1*0.06,18)));c1.useEffect(()=>{let Z0=K1.current;if(!Z0)return;let f0=new ResizeObserver((i0)=>{let M1=i0[0]?.contentRect.width??Z0.clientWidth;j0(M1>=600)});return f0.observe(Z0),j0(Z0.clientWidth>=600),()=>f0.disconnect()},[]);function J1(Z0){if(Z0.button!==0)return;Z0.preventDefault(),Z0.stopPropagation();let f0=C0.current?.getLayout(),i0=Z0.currentTarget.parentElement?.getBoundingClientRect().width??0,M1=f0?.[qU];if(i0<=0||M1===void 0)return;h0.current={pointerId:Z0.pointerId,startClientX:Z0.clientX,startImageSize:M1,groupWidth:i0},Z0.currentTarget.setPointerCapture?.(Z0.pointerId)}function u1(Z0){let f0=h0.current;if(!f0||f0.pointerId!==Z0.pointerId)return;Z0.preventDefault(),Z0.stopPropagation();let i0=f0.startImageSize+(Z0.clientX-f0.startClientX)/f0.groupWidth*100;C0.current?.setLayout({[qU]:i0,[yT]:100-i0})}function S1(Z0){if(h0.current?.pointerId!==Z0.pointerId)return;if(Z0.preventDefault(),Z0.stopPropagation(),h0.current=null,Z0.currentTarget.hasPointerCapture?.(Z0.pointerId))Z0.currentTarget.releasePointerCapture?.(Z0.pointerId)}return T("div",{ref:K1,"data-capture-wheel":"true",className:"task-segment-editor flex h-full min-h-24 w-full flex-col overflow-hidden rounded-sm bg-background text-foreground",children:[G("div",{ref:x1,className:"flex min-h-0 flex-1 p-4",children:T(VT,{groupRef:C0,orientation:"horizontal",className:"min-h-0 min-w-0",children:[A==="individual"&&G(eB,{id:qU,defaultSize:V1,minSize:jT,maxSize:hl,children:G("div",{ref:z0,"data-testid":"task-image-drop-zone","aria-label":D("multitrack.taskImageDropZone"),className:b0("task-image-drop-zone flex h-full min-h-0 w-full items-center justify-center rounded-md border border-dashed transition-colors",f?"border-primary bg-accent/20":"border-border bg-muted/30"),onDragEnter:u0,onDragOver:P0,onDragLeave:n0,onDrop:R0,children:T(t1,{open:k,onOpenChange:(Z0)=>{if(w(Z0),!Z0)y(null)},children:[m.length===0?G(b5,{asChild:!0,children:T("div",{role:"button",tabIndex:0,className:b0("task-image-picker-empty flex aspect-square h-full max-h-full min-h-24 min-w-24 max-w-full cursor-pointer flex-col items-center justify-center gap-1 rounded-md px-4 py-2 text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",r0),"aria-label":D("multitrack.taskImageDropZone"),onClick:()=>y(null),onKeyDown:(Z0)=>{if(Z0.key!=="Enter"&&Z0.key!==" ")return;Z0.preventDefault(),w(!0)},children:[G(Nz,{}),G("span",{className:"text-[10px] font-semibold mt-1",children:D("multitrack.selectImage")}),G("span",{className:"max-w-full whitespace-normal text-center text-[9px] text-muted-foreground",children:D("multitrack.imageDropHint")})]})}):G(_6,{asChild:!0,children:T("div",{ref:s1,"data-testid":"task-image-grid",className:b0("task-image-grid relative grid h-full w-full auto-rows-max content-start gap-2 overflow-y-auto rounded-md p-3 transition-colors",v0,r0),children:[m.map((Z0,f0)=>{let i0=Z5({source_type:Z0.source_type??"input",file_path:Z0.file_path,local_path:Z0.local_path,url:Z0.url,slot_name:Z0.slot_name}),M1=Z0.shared_reference===!0||fJ(S,Z0),N1=Z0.shared_reference?D5:X0,_5={width:`${O0}px`,height:`${O0}px`},O1=hT(m,Z0.id,W);return T("div",{draggable:!0,"data-testid":`task-image-${Z0.id}`,className:`task-image-grid-item group/task-image relative flex aspect-square w-full self-start cursor-pointer items-center justify-center overflow-hidden rounded-md border bg-black ${Z0.shared_reference?Z0.muted===!0?"border-highlight opacity-50":"border-highlight":"border-border"}`,role:"button",tabIndex:0,"aria-label":D("multitrack.reselectImage",{name:hZ(Z0)}),onClick:()=>{y(Z0.id),w(!0)},onKeyDown:(A1)=>{if(A1.target!==A1.currentTarget)return;if(A1.key!=="Enter"&&A1.key!==" ")return;A1.preventDefault(),y(Z0.id),w(!0)},onDragStart:()=>{N.current=Z0.id},onDragOver:(A1)=>A1.preventDefault(),onDrop:()=>{let A1=N.current;if(N.current=null,!A1)return;B({images:fl(m,A1,Z0.id)})},children:[i0&&Z0.panorama_view?G(Gz,{imageId:Z0.id,imageUrl:i0,alt:hZ(Z0),view:Z0.panorama_view,className:b0("absolute inset-0 m-auto transition-opacity",Z0.muted===!0&&"opacity-40")}):i0?G("img",{src:i0,alt:hZ(Z0),className:b0("absolute inset-0 h-full w-full object-contain transition-opacity",Z0.muted===!0&&"opacity-40"),draggable:!1}):G("div",{className:"flex h-full w-full items-center justify-center px-2 text-center text-[8px] text-muted-foreground",children:Z0.source_type==="slot"?D("mediaSelector.slotImage",{n:Az(Z0,f0)}):hZ(Z0)}),G("div",{"data-testid":`task-image-overlay-${Z0.id}`,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-[5] bg-black/30 opacity-0 transition-opacity group-hover/task-image:opacity-100 group-focus-within/task-image:opacity-100"}),T("div",{"data-testid":`task-image-actions-${Z0.id}`,className:"absolute right-0.5 top-1 z-10 flex gap-1 opacity-0 transition-opacity group-hover/task-image:opacity-100 group-focus-within/task-image:opacity-100",children:[G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:Z0.shared_reference===!0?"secondary":"ghost","data-testid":`task-image-shared-${Z0.id}`,className:`h-auto w-auto cursor-pointer bg-background/70 hover:bg-background/90 ${Z0.shared_reference===!0?"text-highlight":"text-muted-foreground"}`,style:{width:N1,height:N1},"aria-label":Z0.shared_reference===!0?D("multitrack.disableSharedReference"):D("multitrack.enableSharedReference"),"aria-pressed":Z0.shared_reference===!0,disabled:!M1,onClick:(A1)=>{A1.stopPropagation(),N0(Z0,Z0.shared_reference!==!0)},children:G(vJ,{style:_5})})}),G(W1,{side:"bottom",className:"max-w-64",children:M1?D("multitrack.sharedImageReferenceTooltip"):D("multitrack.sharedImageLimitTooltip")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:Z0.muted===!0?"secondary":"ghost","data-testid":`task-image-muted-${Z0.id}`,className:`h-auto w-auto cursor-pointer bg-background/70 font-bold hover:bg-background/90 ${Z0.muted===!0?"text-destructive hover:text-destructive":"text-muted-foreground"}`,style:{width:N1,height:N1,fontSize:x0},"aria-label":Z0.muted===!0?D("multitrack.includeImage"):D("multitrack.bypassImage"),"aria-pressed":Z0.muted===!0,onClick:(A1)=>{A1.stopPropagation(),w0(Z0.id,Z0.muted!==!0)},children:"M"})}),G(W1,{side:"bottom",children:Z0.muted===!0?D("multitrack.includeImageTooltip"):D("multitrack.bypassImageTooltip")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:"h-auto w-auto cursor-pointer bg-background/70 text-muted-foreground font-bold hover:bg-background/90",style:{width:N1,height:N1},"aria-label":D("multitrack.previewImage"),disabled:!i0,onClick:(A1)=>{A1.stopPropagation(),F?.(Z0.id)},children:G(E7,{style:_5})})}),G(W1,{side:"bottom",children:D("multitrack.previewImage")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:"h-auto w-auto cursor-pointer bg-background/70 text-destructive hover:bg-background/90 hover:text-destructive",style:{width:N1,height:N1},"aria-label":D("multitrack.deleteImage"),onClick:(A1)=>{A1.stopPropagation(),n(Z0.id)},children:G(N5,{style:_5})})}),G(W1,{side:"bottom",children:D("multitrack.deleteImage")})]})})]}),O1!==null?G("span",{"data-testid":`task-image-index-${Z0.id}`,className:"absolute bottom-0 left-0 z-10 min-w-5 rounded-sm bg-black/50 px-1.5 py-0.5 text-center text-[9px] font-semibold leading-none text-white",children:O1}):null]},Z0.id)}),m.length<X4&&G(k0,{type:"button",variant:"outline",className:"task-image-grid-add aspect-square h-auto w-full self-start border-dashed text-muted-foreground","aria-label":D("multitrack.selectImage"),onClick:()=>{y(null),w(!0)},children:G(K5,{className:"h-7 w-7"})})]})}),G(o1,{className:"w-auto p-0",align:"end",children:G(M5,{value:vl(i),mediaType:"image",defaultTab:gl(i),allowMultipleSelection:!C,maxSelectionCount:C?1:X4-m.length,slotItems:c,onChange:Y1},C??"add-images")})]})})}),A==="individual"?G(MT,{withHandle:!0,"aria-label":D("multitrack.resizeTaskEditorPanels"),className:"mx-2 bg-transparent",onPointerDown:J1,onPointerMove:u1,onPointerUp:S1,onPointerCancel:S1,onLostPointerCapture:()=>{h0.current=null}}):null,G(eB,{id:yT,minSize:A==="individual"?ET:"100%",children:T("div",{"data-testid":"task-prompt-panel",className:"flex h-full min-h-0 min-w-0 flex-col overflow-hidden rounded-md border border-border bg-muted/30 shadow-sm",children:[A==="individual"&&T("div",{className:"flex h-11 shrink-0 items-center px-2 justify-between",children:[T("div",{className:"flex h-7 items-center rounded-md bg-card p-1",children:[G(k0,{type:"button",variant:"ghost",className:b0("h-full rounded-sm px-3 py-1 text-[10px] shadow-none cursor-pointer",O==="user"?"bg-background text-primary hover:bg-background/90 hover:text-primary":"text-muted-foreground"),onClick:()=>I("user"),children:D("multitrack.userPrompt")}),G(k0,{type:"button",variant:"ghost",className:b0("h-full rounded-sm px-3 py-1 text-[10px] shadow-none cursor-pointer",O==="system"?"bg-background text-primary hover:bg-background/90 hover:text-primary":"text-muted-foreground"),onClick:()=>I("system"),children:D("multitrack.systemPrompt")})]}),O==="user"?T("div",{className:"flex items-center gap-1",children:[G(k0,{type:"button",variant:"ghost",className:"h-7 px-2 text-[10px] text-highlight hover:bg-highlight/10 hover:text-highlight cursor-pointer hover:opacity-70",onClick:()=>x(!0),children:D("multitrack.applyPromptToAll")}),G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G("div",{"aria-label":D("multitrack.userPromptVariantTooltip"),children:G(c4,{value:W0,onValueChange:(Z0)=>B({user_prompt_variant:Z0}),children:T(o9,{className:"h-7 bg-card p-1",children:[G(H8,{value:"a",className:"h-full min-w-7 px-2 text-[10px]",children:"A"}),G(H8,{value:"b",className:"h-full min-w-7 px-2 text-[10px]",children:"B"})]})})})}),G(W1,{side:"bottom",className:"max-w-72",children:D("multitrack.userPromptVariantTooltip")})]})})]}):Boolean($.content.system_prompt)&&T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 text-muted-foreground [&_svg]:!size-3","aria-label":D("multitrack.resetSystemPrompt"),onClick:()=>B({system_prompt:""}),children:G(ST,{})})}),G(W1,{side:"bottom",children:D("multitrack.resetSystemPrompt")})]})]}),A==="combined"?T("div",{className:"flex min-h-0 flex-1 flex-col gap-1 p-2",children:[G("div",{className:"relative h-full min-h-0 flex-1 overflow-hidden rounded-md bg-card",children:G(Vz,{ariaLabel:D("multitrack.prompt"),placeholder:D0,interactivePlaceholder:_0,testId:"combined-prompt-highlight",className:"border-none bg-card shadow-none",value:L0,resources:I0,mentionsEnabled:!0,highlightPromptSemantics:!0,highlightPipes:!0,onChange:a0})}),G("p",{className:"shrink-0 text-[9px] text-muted-foreground mt-1",children:D("maintainTrack.combinedHint")})]}):O==="user"?G("div",{className:"relative h-full min-h-0 flex-1 overflow-hidden pb-2 px-2",children:G(Vz,{placeholder:D0,interactivePlaceholder:_0,ariaLabel:D("multitrack.prompt"),className:"border-none bg-card shadow-none",value:L0,resources:I0,mentionsEnabled:!0,highlightPromptSemantics:!0,onChange:a0})}):G("div",{className:"relative h-full min-h-0 flex-1 overflow-hidden pb-2 px-2",children:G("div",{className:"relative h-full min-h-0 overflow-hidden rounded-md bg-card",children:G(Vz,{ariaLabel:D("multitrack.systemPrompt"),placeholder:h?D("multitrack.loadingSystemPrompt"):D("multitrack.systemPromptPlaceholder"),className:"border-none bg-card shadow-none",value:a,resources:I0,highlightSystemVariables:!0,onChange:C1})})})]})})]},A)}),T("div",{className:"relative flex shrink-0 items-center justify-between border-t border-dashed border-border p-2",children:[G(c4,{value:A,onValueChange:(Z0)=>b(Z0),className:l0?void 0:"hidden",children:T(o9,{className:"h-8 bg-card",children:[G(H8,{value:"individual",className:"text-[10px]",children:D("multitrack.individualEdit")}),G(H8,{value:"combined",className:"text-[10px]",children:D("multitrack.combinedEdit")})]})}),G("div",{className:b0(l0?"absolute left-1/2 -translate-x-1/2":"flex items-center",$0&&"w-28"),children:$0?G($6,{autoFocus:!0,"aria-label":D("multitrack.duration"),type:"text",inputMode:"numeric",placeholder:"00:00:00",className:"tabular-nums",value:K0,onChange:(Z0)=>E(Z0.currentTarget.value),onBlur:A0,onKeyDown:(Z0)=>{if(Z0.key!=="Enter")return;Z0.preventDefault(),A0()}}):T("div",{className:"flex items-center gap-1 text-muted-foreground",children:[T("div",{className:"flex flex-col items-center",children:[G("span",{className:"text-[10px] text-primary",children:D("multitrack.taskNumber",{n:Q0+1})}),G("span",{className:"text-[10px] mt-0.5 tabular-nums",children:H0})]}),L&&G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer","aria-label":D("multitrack.editTaskDuration"),onClick:()=>Y0(!0),children:G(CT,{className:"h-3 w-3"})})]})}),T("div",{className:"flex items-center gap-2",children:[M&&(Q0>0||B0)&&T(y8,{value:d,onValueChange:(Z0)=>b1({continuity_mode:Z0}),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"aria-label":D("multitrack.continuityMode"),className:"h-8 w-28 bg-card text-[10px]",children:G(W6,{})})}),G(W1,{side:"bottom",className:"max-w-72",children:D("multitrack.continuityModeTooltip")})]})}),G(R8,{children:kz.map((Z0)=>G(i5,{value:Z0,children:G("span",{className:"text-[10px]",children:D(`multitrackContinuityModes.${Z0}`)})},Z0))})]}),M&&["ref","edit"].includes(u)&&T(y8,{value:o,onValueChange:(Z0)=>b1({ref_image_size:Z0}),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"aria-label":D("multitrack.refImageSize"),className:"h-8 w-20 bg-card text-[10px]",children:G(W6,{})})}),G(W1,{side:"bottom",className:"max-w-72",children:D("multitrack.refImageSizeTooltip")})]})}),G(R8,{children:Iz.map((Z0)=>G(i5,{value:Z0,children:G("span",{className:"text-[10px]",children:D(`multitrackRefImageSizes.${Z0}`)})},Z0))})]}),T(y8,{value:u,onValueChange:(Z0)=>b1({task_mode:Z0}),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"aria-label":D("multitrack.taskMode"),className:"h-8 w-24 bg-card text-[10px]",children:G(W6,{})})}),G(W1,{side:"bottom",className:"max-w-72",children:D("multitrack.taskModeTooltip")})]})}),G(R8,{children:wz.map((Z0)=>G(i5,{value:Z0,children:G("span",{className:"text-[10px]",children:D(`multitrackTaskModes.${XU(Z0,m.length,c0)}`)})},Z0))})]})]})]}),G(AJ,{open:P,onOpenChange:x,children:T(y2,{className:"max-w-md",children:[T(kZ,{children:[G(P2,{children:D("multitrack.applyPromptToAllTitle")}),G(TZ,{children:D("multitrack.applyPromptToAllDescription")})]}),T(IZ,{children:[G(k0,{type:"button",variant:"outline",onClick:()=>x(!1),children:D("common.cancel")}),G(k0,{type:"button",onClick:g1,children:D("multitrack.applyPromptToAllConfirm")})]})]})})]})}var m8=R(v(),1);function cl($){if($==="stretch")return"fill";if($==="crop")return"cover";return"contain"}function uT($,J){if(!Number.isFinite(J)||Math.abs($.currentTime-J)<=0.001)return;try{$.currentTime=J}catch(Q){console.error("[VideoPreview] failed to seek preview video:",Q)}}function cT({activeVideo:$,resolution:J,isPlaying:Q,playbackNonce:Z=0,muted:q,volume:X,frameRate:Y,className:z,children:K}){let W=Z1(),H=m8.useRef(null),[B,U]=m8.useState(null),[_,L]=m8.useState(null),[F,V]=m8.useState(null),[M,D]=m8.useState(null),N=m8.useMemo(()=>{if(!$)return null;return Z5({source_type:$.segment.content.source_type??"input",file_path:$.segment.content.file_path,local_path:$.segment.content.local_path,url:$.segment.content.url,slot_name:$.segment.content.slot_name})},[$]),O=Math.max(0,Math.min(X,1)),I=cl(J.resizeMethod),A=$?.segment.id??null,b=$?.segment.content.source_type==="url",k=$?.localTime??0,w=Math.round(k*Y),C=$&&N?`${N}:${Y}:${w}`:null,y=F?.url===N,f=y&&F.fps!==null&&Math.abs(F.fps-Y)<=0.01;m8.useEffect(()=>{if(!$||!N||b)return;let P=new AbortController,x=$.segment.content,p=N;async function t(){try{let h=await fetch("/easy-media/video/source-fps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_type:x.source_type??"input",file_path:x.file_path,local_path:x.local_path,url:x.url}),signal:P.signal});if(!h.ok)throw Error(`Video frame rate request failed (${h.status})`);let r=await h.json(),$0=r&&typeof r==="object"&&"fps"in r?r.fps:null;if(typeof $0!=="number"||!Number.isFinite($0)||$0<=0)throw Error("Video frame rate response is invalid");if(!P.signal.aborted)V({url:p,fps:$0})}catch(h){if(!P.signal.aborted)console.error("[VideoPreview] failed to probe source frame rate:",h),V({url:p,fps:null})}}return t(),()=>P.abort()},[N,b]),m8.useEffect(()=>{if(Q||b||f||!y||!$||!N||C===null){U(null),L(null);return}let P=C,x=new AbortController,p=null,t=$.segment.content;async function h(){try{let $0=await fetch("/easy-media/video/preview-frame",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_type:t.source_type??"input",file_path:t.file_path,local_path:t.local_path,url:t.url,frame:w,fps:Y}),signal:x.signal});if(!$0.ok)throw Error(`Preview frame request failed (${$0.status})`);if(p=URL.createObjectURL(await $0.blob()),!x.signal.aborted)L(null),U({key:P,url:p})}catch($0){if(!x.signal.aborted)console.error("[VideoPreview] failed to load timeline frame:",$0),L(P)}}let r=setTimeout(()=>{h()},60);return()=>{if(clearTimeout(r),x.abort(),p)URL.revokeObjectURL(p)}},[$?.segment.id,Y,Q,b,w,y,C,f,N]),m8.useEffect(()=>{let P=H.current;if(!P)return;P.muted=q,P.volume=O},[q,O]),m8.useEffect(()=>{let P=H.current;if(!P||!$||Q)return;uT(P,$.localTime)},[$,k,Q]),m8.useEffect(()=>{let P=H.current;if(f&&!Q&&P&&P.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&!P.seeking&&Math.abs(P.currentTime-k)<1/Y)D(C)},[k,Y,Q,C,f]);function j(){let P=H.current;if(f&&!Q&&P&&!P.seeking&&Math.abs(P.currentTime-k)<1/Y)D(C)}return m8.useEffect(()=>{let P=H.current;if(!P||!$)return;if(Q){uT(P,$.localTime);let x=P.play();if(x)x.catch((p)=>{console.error("[VideoPreview] failed to play preview video:",p)});return}P.pause()},[Q,N,A,Z]),T("div",{"data-testid":"multitrack-video-stage",className:b0("relative flex h-full min-w-0 max-h-full max-w-full items-center justify-center overflow-hidden bg-black",z),style:{aspectRatio:`${J.width} / ${J.height}`},children:[N?G("video",{ref:H,"data-testid":"multitrack-video-preview",className:"absolute inset-0 h-full min-h-0 w-full min-w-0 max-h-full max-w-full",src:N,muted:q,playsInline:!0,preload:"auto",onSeeked:j,onLoadedData:j,style:{objectFit:I,visibility:Q||b||_===C||f&&M===C?"visible":"hidden"}}):$?.segment.content.source_type==="slot"?G("div",{"data-testid":"multitrack-video-slot-placeholder",className:"flex h-full w-full items-center justify-center bg-muted/30 px-3 text-center text-xs font-medium text-muted-foreground",children:W("mediaSelector.slotVideo",{n:mT($.segment.content.slot_name)})}):G("div",{"data-testid":"multitrack-black-frame",className:"h-full w-full bg-black"}),!Q&&B?.key===C&&G("img",{src:B.url,alt:"","data-testid":"multitrack-timeline-frame",className:"absolute inset-0 h-full w-full",style:{objectFit:I}}),K]})}var d9=R(v(),1);var s0=R(v(),1);function l2($,J){if($.indexOf(J)===-1)$.push(J)}function P7($,J){let Q=$.indexOf(J);if(Q>-1)$.splice(Q,1)}var L8=($,J,Q)=>{if(Q>J)return J;if(Q<$)return $;return Q};function YU($,J){return J?`${$}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${J}`:$}var Y4=()=>{},N6=()=>{};if(typeof process<"u"&&process.env?.NODE_ENV!=="production")Y4=($,J,Q)=>{if(!$&&typeof console<"u")console.warn(YU(J,Q))},N6=($,J,Q)=>{if(!$)throw Error(YU(J,Q))};var Q6={};var uZ=($)=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test($);var mZ=($)=>typeof $==="object"&&$!==null;var cZ=($)=>/^0[^.\s]+$/u.test($);function dZ($){let J;return()=>{if(J===void 0)J=$();return J}}var j5=($)=>$;var h9=(...$)=>$.reduce((J,Q)=>(Z)=>Q(J(Z)));var z4=($,J,Q)=>{let Z=J-$;return Z?(Q-$)/Z:1};class R7{constructor(){this.subscriptions=[]}add($){return l2(this.subscriptions,$),()=>P7(this.subscriptions,$)}notify($,J,Q){let Z=this.subscriptions.length;if(!Z)return;if(Z===1)this.subscriptions[0]($,J,Q);else for(let q=0;q<Z;q++){let X=this.subscriptions[q];X&&X($,J,Q)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}var v5=($)=>$*1000,k8=($)=>$/1000;var pZ=($,J)=>J?$*(1000/J):0;var dT=($,J,Q)=>(((1-3*Q+3*J)*$+(3*Q-6*J))*$+3*J)*$,dl=0.0000001,pl=12;function ll($,J,Q,Z,q){let X,Y,z=0;do if(Y=J+(Q-J)/2,X=dT(Y,Z,q)-$,X>0)Q=Y;else J=Y;while(Math.abs(X)>dl&&++z<pl);return Y}function C7($,J,Q,Z){if($===J&&Q===Z)return j5;let q=(X)=>ll(X,0,1,$,Q);return(X)=>X===0||X===1?X:dT(q(X),J,Z)}var bz=($)=>(J)=>J<=0.5?$(2*J)/2:(2-$(2*(1-J)))/2;var jz=($)=>(J)=>1-$(1-J);var Ez=C7(0.33,1.53,0.69,0.99),cJ=jz(Ez),lZ=bz(cJ);var iZ=($)=>$>=1?1:($*=2)<1?0.5*cJ($):0.5*(2-Math.pow(2,-10*($-1)));var rZ=($)=>1-Math.sin(Math.acos($)),sZ=jz(rZ),oZ=bz(rZ);var zU=C7(0.42,0,1,1),KU=C7(0,0,0.58,1),nZ=C7(0.42,0,0.58,1);var GU=($)=>{return Array.isArray($)&&typeof $[0]!=="number"};var aZ=($)=>Array.isArray($)&&typeof $[0]==="number";var pT={linear:j5,easeIn:zU,easeInOut:nZ,easeOut:KU,circIn:rZ,circInOut:oZ,circOut:sZ,backIn:cJ,backInOut:lZ,backOut:Ez,anticipate:iZ},il=($)=>{return typeof $==="string"},yz=($)=>{if(aZ($)){N6($.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");let[J,Q,Z,q]=$;return C7(J,Q,Z,q)}else if(il($))return N6(pT[$]!==void 0,`Invalid easing type '${$}'`,"invalid-easing-type"),pT[$];return $};var tZ=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function lT($){let J=new Set,Q=new Set,Z=!1,q=!1,X=new WeakSet,Y={delta:0,timestamp:0,isProcessing:!1};function z(W){if(X.has(W))K.schedule(W),$();W(Y)}let K={schedule:(W,H=!1,B=!1)=>{let _=B&&Z?J:Q;if(H)X.add(W);return _.add(W),W},cancel:(W)=>{Q.delete(W),X.delete(W)},process:(W)=>{if(Y=W,Z){q=!0;return}Z=!0;let H=J;if(J=Q,Q=H,J.forEach(z),J.clear(),Z=!1,q)q=!1,K.process(W)}};return K}var rl=40;function Pz($,J){let Q=!1,Z=!0,q={delta:0,timestamp:0,isProcessing:!1},X=()=>Q=!0,Y=tZ.reduce((N,O)=>{return N[O]=lT(X),N},{}),{setup:z,read:K,resolveKeyframes:W,preUpdate:H,update:B,preRender:U,render:_,postRender:L}=Y,F=()=>{let N=Q6.useManualTiming,O=N?q.timestamp:performance.now();if(Q=!1,!N)q.delta=Z?16.666666666666668:Math.max(Math.min(O-q.timestamp,rl),1);if(q.timestamp=O,q.isProcessing=!0,z.process(q),K.process(q),W.process(q),H.process(q),B.process(q),U.process(q),_.process(q),L.process(q),q.isProcessing=!1,Q&&J)Z=!1,$(F)},V=()=>{if(Q=!0,Z=!0,!q.isProcessing)$(F)};return{schedule:tZ.reduce((N,O)=>{let I=Y[O];return N[O]=(A,b=!1,k=!1)=>{if(!Q)V();return I.schedule(A,b,k)},N},{}),cancel:(N)=>{for(let O=0;O<tZ.length;O++)Y[tZ[O]].cancel(N)},state:q,steps:Y}}var{schedule:I1,cancel:O6,state:S5,steps:eZ}=Pz(typeof requestAnimationFrame<"u"?requestAnimationFrame:j5,!0);var Rz;function sl(){Rz=void 0}var E5={now:()=>{if(Rz===void 0)E5.set(S5.isProcessing||Q6.useManualTiming?S5.timestamp:performance.now());return Rz},set:($)=>{Rz=$,queueMicrotask(sl)}};var iT=($)=>(J)=>typeof J==="string"&&J.startsWith($),Cz=iT("--"),ol=iT("var(--"),dJ=($)=>{if(!ol($))return!1;return nl.test($.split("/*")[0].trim())},nl=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function WU($){if(typeof $!=="string")return!1;return $.split("/*")[0].includes("var(--")}var K4={test:($)=>typeof $==="number",parse:parseFloat,transform:($)=>$},s4={...K4,transform:($)=>L8(0,1,$)},$q={...K4,default:1};var S7=($)=>Math.round($*1e5)/1e5;var pJ=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function rT($){return $==null}var sT=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;var lJ=($,J)=>(Q)=>{return Boolean(typeof Q==="string"&&sT.test(Q)&&Q.startsWith($)||J&&!rT(Q)&&Object.prototype.hasOwnProperty.call(Q,J))},Sz=($,J,Q)=>(Z)=>{if(typeof Z!=="string")return Z;let[q,X,Y,z]=Z.match(pJ);return{[$]:parseFloat(q),[J]:parseFloat(X),[Q]:parseFloat(Y),alpha:z!==void 0?parseFloat(z):1}};var al=($)=>L8(0,255,$),HU={...K4,transform:($)=>Math.round(al($))},G4={test:lJ("rgb","red"),parse:Sz("red","green","blue"),transform:({red:$,green:J,blue:Q,alpha:Z=1})=>"rgba("+HU.transform($)+", "+HU.transform(J)+", "+HU.transform(Q)+", "+S7(s4.transform(Z))+")"};function tl($){let J="",Q="",Z="",q="";if($.length>5)J=$.substring(1,3),Q=$.substring(3,5),Z=$.substring(5,7),q=$.substring(7,9);else J=$.substring(1,2),Q=$.substring(2,3),Z=$.substring(3,4),q=$.substring(4,5),J+=J,Q+=Q,Z+=Z,q+=q;return{red:parseInt(J,16),green:parseInt(Q,16),blue:parseInt(Z,16),alpha:q?parseInt(q,16)/255:1}}var Jq={test:lJ("#"),parse:tl,transform:G4.transform};var Qq=($)=>({test:(J)=>typeof J==="string"&&J.endsWith($)&&J.split(" ").length===1,parse:parseFloat,transform:(J)=>`${J}${$}`}),W9=Qq("deg"),c8=Qq("%"),d0=Qq("px"),BU=Qq("vh"),UU=Qq("vw"),hz=(()=>({...c8,parse:($)=>c8.parse($)/100,transform:($)=>c8.transform($*100)}))();var h7={test:lJ("hsl","hue"),parse:Sz("hue","saturation","lightness"),transform:({hue:$,saturation:J,lightness:Q,alpha:Z=1})=>{return"hsla("+Math.round($)+", "+c8.transform(S7(J))+", "+c8.transform(S7(Q))+", "+S7(s4.transform(Z))+")"}};var A5={test:($)=>G4.test($)||Jq.test($)||h7.test($),parse:($)=>{if(G4.test($))return G4.parse($);else if(h7.test($))return h7.parse($);else return Jq.parse($)},transform:($)=>{return typeof $==="string"?$:$.hasOwnProperty("red")?G4.transform($):h7.transform($)},getAnimatableNone:($)=>{let J=A5.parse($);return J.alpha=0,A5.transform(J)}};var oT=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function el($){return isNaN($)&&typeof $==="string"&&($.match(pJ)?.length||0)+($.match(oT)?.length||0)>0}var aT="number",tT="color",$i="var",Ji="var(",nT="${}",Qi=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function x7($){let J=$.toString(),Q=[],Z={color:[],number:[],var:[]},q=[],X=0,z=J.replace(Qi,(K)=>{if(A5.test(K))Z.color.push(X),q.push(tT),Q.push(A5.parse(K));else if(K.startsWith(Ji))Z.var.push(X),q.push($i),Q.push(K);else Z.number.push(X),q.push(aT),Q.push(parseFloat(K));return++X,nT}).split(nT);return{values:Q,split:z,indexes:Z,types:q}}function Zi($){return x7($).values}function eT({split:$,types:J}){let Q=$.length;return(Z)=>{let q="";for(let X=0;X<Q;X++)if(q+=$[X],Z[X]!==void 0){let Y=J[X];if(Y===aT)q+=S7(Z[X]);else if(Y===tT)q+=A5.transform(Z[X]);else q+=Z[X]}return q}}function qi($){return eT(x7($))}var Xi=($)=>typeof $==="number"?0:A5.test($)?A5.getAnimatableNone($):$,Yi=($,J)=>{if(typeof $==="number")return J?.trim().endsWith("/")?$:0;return Xi($)};function zi($){let J=x7($);return eT(J)(J.values.map((Z,q)=>Yi(Z,J.split[q])))}var F8={test:el,parse:Zi,createTransformer:qi,getAnimatableNone:zi};function _U($,J,Q){if(Q<0)Q+=1;if(Q>1)Q-=1;if(Q<0.16666666666666666)return $+(J-$)*6*Q;if(Q<0.5)return J;if(Q<0.6666666666666666)return $+(J-$)*(0.6666666666666666-Q)*6;return $}function $b({hue:$,saturation:J,lightness:Q,alpha:Z}){$/=360,J/=100,Q/=100;let q=0,X=0,Y=0;if(!J)q=X=Y=Q;else{let z=Q<0.5?Q*(1+J):Q+J-Q*J,K=2*Q-z;q=_U(K,z,$+0.3333333333333333),X=_U(K,z,$),Y=_U(K,z,$-0.3333333333333333)}return{red:Math.round(q*255),green:Math.round(X*255),blue:Math.round(Y*255),alpha:Z}}function iJ($,J){return(Q)=>Q>0?J:$}var j1=($,J,Q)=>{return $+(J-$)*Q};var LU=($,J,Q)=>{let Z=$*$,q=Q*(J*J-Z)+Z;return q<0?0:Math.sqrt(q)},Ki=[Jq,G4,h7],Gi=($)=>Ki.find((J)=>J.test($));function Jb($){let J=Gi($);if(Y4(Boolean(J),`'${$}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!Boolean(J))return!1;let Q=J.parse($);if(J===h7)Q=$b(Q);return Q}var FU=($,J)=>{let Q=Jb($),Z=Jb(J);if(!Q||!Z)return iJ($,J);let q={...Q};return(X)=>{return q.red=LU(Q.red,Z.red,X),q.green=LU(Q.green,Z.green,X),q.blue=LU(Q.blue,Z.blue,X),q.alpha=j1(Q.alpha,Z.alpha,X),G4.transform(q)}};var xz=new Set(["none","hidden"]);function Qb($,J){if(xz.has($))return(Q)=>Q<=0?$:J;else return(Q)=>Q>=1?J:$}function Wi($,J){return(Q)=>j1($,J,Q)}function fz($){if(typeof $==="number")return Wi;else if(typeof $==="string")return dJ($)?iJ:A5.test($)?FU:Ui;else if(Array.isArray($))return Zb;else if(typeof $==="object")return A5.test($)?FU:Hi;return iJ}function Zb($,J){let Q=[...$],Z=Q.length,q=$.map((X,Y)=>fz(X)(X,J[Y]));return(X)=>{for(let Y=0;Y<Z;Y++)Q[Y]=q[Y](X);return Q}}function Hi($,J){let Q={...$,...J},Z={};for(let q in Q)if($[q]!==void 0&&J[q]!==void 0)Z[q]=fz($[q])($[q],J[q]);return(q)=>{for(let X in Z)Q[X]=Z[X](q);return Q}}function Bi($,J){let Q=[],Z={color:0,var:0,number:0};for(let q=0;q<J.values.length;q++){let X=J.types[q],Y=$.indexes[X][Z[X]],z=$.values[Y]??0;Q[q]=z,Z[X]++}return Q}var Ui=($,J)=>{let Q=F8.createTransformer(J),Z=x7($),q=x7(J);if(Z.indexes.var.length===q.indexes.var.length&&Z.indexes.color.length===q.indexes.color.length&&Z.indexes.number.length>=q.indexes.number.length){if(xz.has($)&&!q.values.length||xz.has(J)&&!Z.values.length)return Qb($,J);return h9(Zb(Bi(Z,q),q.values),Q)}else return Y4(!0,`Complex values '${$}' and '${J}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),iJ($,J)};function vz($,J,Q){if(typeof $==="number"&&typeof J==="number"&&typeof Q==="number")return j1($,J,Q);return fz($)($,J)}var qb=($)=>{let J=({timestamp:Q})=>$(Q);return{start:(Q=!0)=>I1.update(J,Q),stop:()=>O6(J),now:()=>S5.isProcessing?S5.timestamp:E5.now()}};var gz=($,J,Q=10)=>{let Z="",q=Math.max(Math.round(J/Q),2);for(let X=0;X<q;X++)Z+=Math.round($(X/(q-1))*1e4)/1e4+", ";return`linear(${Z.substring(0,Z.length-2)})`};var uz=20000;function rJ($){let J=0,Q=50,Z=$.next(J);while(!Z.done&&J<20000)J+=Q,Z=$.next(J);return J>=20000?1/0:J}function Xb($,J=100,Q){let Z=Q({...$,keyframes:[0,J]}),q=Math.min(rJ(Z),uz);return{type:"keyframes",ease:(X)=>{return Z.next(q*X).value/J},duration:k8(q)}}var y5={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:0.3,visualDuration:0.3,restSpeed:{granular:0.01,default:2},restDelta:{granular:0.005,default:0.5},minDuration:0.01,maxDuration:10,minDamping:0.05,maxDamping:1};function MU($,J){return $*Math.sqrt(1-J*J)}var _i=12;function Li($,J,Q){let Z=Q;for(let q=1;q<_i;q++)Z=Z-$(Z)/J(Z);return Z}var VU=0.001;function Fi({duration:$=y5.duration,bounce:J=y5.bounce,velocity:Q=y5.velocity,mass:Z=y5.mass}){let q,X;Y4($<=v5(y5.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let Y=1-J;if(Y=L8(y5.minDamping,y5.maxDamping,Y),$=L8(y5.minDuration,y5.maxDuration,k8($)),Y<1)q=(W)=>{let H=W*Y,B=H*$,U=H-Q,_=MU(W,Y),L=Math.exp(-B);return VU-U/_*L},X=(W)=>{let B=W*Y*$,U=B*Q+Q,_=Math.pow(Y,2)*Math.pow(W,2)*$,L=Math.exp(-B),F=MU(Math.pow(W,2),Y);return(-q(W)+VU>0?-1:1)*((U-_)*L)/F};else q=(W)=>{let H=Math.exp(-W*$),B=(W-Q)*$+1;return-VU+H*B},X=(W)=>{let H=Math.exp(-W*$),B=(Q-W)*($*$);return H*B};let z=5/$,K=Li(q,X,z);if($=v5($),isNaN(K))return{stiffness:y5.stiffness,damping:y5.damping,duration:$};else{let W=Math.pow(K,2)*Z;return{stiffness:W,damping:Y*2*Math.sqrt(Z*W),duration:$}}}var Vi=["duration","bounce"],Mi=["stiffness","damping","mass"];function Yb($,J){return J.some((Q)=>$[Q]!==void 0)}function Di($){let J={velocity:y5.velocity,stiffness:y5.stiffness,damping:y5.damping,mass:y5.mass,isResolvedFromDuration:!1,...$};if(!Yb($,Mi)&&Yb($,Vi))if(J.velocity=0,$.visualDuration){let Q=$.visualDuration,Z=2*Math.PI/(Q*1.2),q=Z*Z,X=2*L8(0.05,1,1-($.bounce||0))*Math.sqrt(q);J={...J,mass:y5.mass,stiffness:q,damping:X}}else{let Q=Fi({...$,velocity:0});J={...J,...Q,mass:y5.mass},J.isResolvedFromDuration=!0}return J}function sJ($=y5.visualDuration,J=y5.bounce){let Q=typeof $!=="object"?{visualDuration:$,keyframes:[0,1],bounce:J}:$,{restSpeed:Z,restDelta:q}=Q,X=Q.keyframes[0],Y=Q.keyframes[Q.keyframes.length-1],z={done:!1,value:X},{stiffness:K,damping:W,mass:H,duration:B,velocity:U,isResolvedFromDuration:_}=Di({...Q,velocity:-k8(Q.velocity||0)}),L=U||0,F=W/(2*Math.sqrt(K*H)),V=Y-X,M=k8(Math.sqrt(K/H)),D=Math.abs(V)<5;Z||(Z=D?y5.restSpeed.granular:y5.restSpeed.default),q||(q=D?y5.restDelta.granular:y5.restDelta.default);let N,O,I,A,b,k;if(F<1)I=MU(M,F),A=(L+F*M*V)/I,N=(C)=>{let y=Math.exp(-F*M*C);return Y-y*(A*Math.sin(I*C)+V*Math.cos(I*C))},b=F*M*A+V*I,k=F*M*V-A*I,O=(C)=>{return Math.exp(-F*M*C)*(b*Math.sin(I*C)+k*Math.cos(I*C))};else if(F===1){N=(y)=>Y-Math.exp(-M*y)*(V+(L+M*V)*y);let C=L+M*V;O=(y)=>Math.exp(-M*y)*(M*C*y-L)}else{let C=M*Math.sqrt(F*F-1);N=(P)=>{let x=Math.exp(-F*M*P),p=Math.min(C*P,300);return Y-x*((L+F*M*V)*Math.sinh(p)+C*V*Math.cosh(p))/C};let y=(L+F*M*V)/C,f=F*M*y-V*C,j=F*M*V-y*C;O=(P)=>{let x=Math.exp(-F*M*P),p=Math.min(C*P,300);return x*(f*Math.sinh(p)+j*Math.cosh(p))}}let w={calculatedDuration:_?B||null:null,velocity:(C)=>v5(O(C)),next:(C)=>{if(!_&&F<1){let f=Math.exp(-F*M*C),j=Math.sin(I*C),P=Math.cos(I*C),x=Y-f*(A*j+V*P),p=v5(f*(b*j+k*P));return z.done=Math.abs(p)<=Z&&Math.abs(Y-x)<=q,z.value=z.done?Y:x,z}let y=N(C);if(!_){let f=v5(O(C));z.done=Math.abs(f)<=Z&&Math.abs(Y-y)<=q}else z.done=C>=B;return z.value=z.done?Y:y,z},toString:()=>{let C=Math.min(rJ(w),uz),y=gz((f)=>w.next(C*f).value,C,30);return C+"ms "+y},toTransition:()=>{}};return w}sJ.applyToOptions=($)=>{let J=Xb($,100,sJ);return $.ease=J.ease,$.duration=v5(J.duration),$.type="keyframes",$};var Ni=5;function mz($,J,Q){let Z=Math.max(J-Ni,0);return pZ(Q-$(Z),J-Z)}function Zq({keyframes:$,velocity:J=0,power:Q=0.8,timeConstant:Z=325,bounceDamping:q=10,bounceStiffness:X=500,modifyTarget:Y,min:z,max:K,restDelta:W=0.5,restSpeed:H}){let B=$[0],U={done:!1,value:B},_=(k)=>z!==void 0&&k<z||K!==void 0&&k>K,L=(k)=>{if(z===void 0)return K;if(K===void 0)return z;return Math.abs(z-k)<Math.abs(K-k)?z:K},F=Q*J,V=B+F,M=Y===void 0?V:Y(V);if(M!==V)F=M-B;let D=(k)=>-F*Math.exp(-k/Z),N=(k)=>M+D(k),O=(k)=>{let w=D(k),C=N(k);U.done=Math.abs(w)<=W,U.value=U.done?M:C},I,A,b=(k)=>{if(!_(U.value))return;I=k,A=sJ({keyframes:[U.value,L(U.value)],velocity:mz(N,k,U.value),damping:q,stiffness:X,restDelta:W,restSpeed:H})};return b(0),{calculatedDuration:null,next:(k)=>{let w=!1;if(!A&&I===void 0)w=!0,O(k),b(k);if(I!==void 0&&k>=I)return A.next(k-I);else return!w&&O(k),U}}}function Oi($,J,Q){let Z=[],q=Q||Q6.mix||vz,X=$.length-1;for(let Y=0;Y<X;Y++){let z=q($[Y],$[Y+1]);if(J){let K=Array.isArray(J)?J[Y]||j5:J;z=h9(K,z)}Z.push(z)}return Z}function zb($,J,{clamp:Q=!0,ease:Z,mixer:q}={}){let X=$.length;if(N6(X===J.length,"Both input and output ranges must be the same length","range-length"),X===1)return()=>J[0];if(X===2&&J[0]===J[1])return()=>J[1];let Y=$[0]===$[1];if($[0]>$[X-1])$=[...$].reverse(),J=[...J].reverse();let z=Oi(J,Z,q),K=z.length,W=(H)=>{if(Y&&H<$[0])return J[0];let B=0;if(K>1){for(;B<$.length-2;B++)if(H<$[B+1])break}let U=z4($[B],$[B+1],H);return z[B](U)};return Q?(H)=>W(L8($[0],$[X-1],H)):W}function Kb($,J){let Q=$[$.length-1];for(let Z=1;Z<=J;Z++){let q=z4(0,J,Z);$.push(j1(Q,1,q))}}function Gb($){let J=[0];return Kb(J,$.length-1),J}function Wb($,J){return $.map((Q)=>Q*J)}function Ai($,J){return $.map(()=>J||nZ).splice(0,$.length-1)}function i2({duration:$=300,keyframes:J,times:Q,ease:Z="easeInOut"}){let q=GU(Z)?Z.map(yz):yz(Z),X={done:!1,value:J[0]},Y=Wb(Q&&Q.length===J.length?Q:Gb(J),$),z=zb(Y,J,{ease:Array.isArray(q)?q:Ai(J,q)});return{calculatedDuration:$,next:(K)=>{return X.value=z(K),X.done=K>=$,X}}}var wi=($)=>$!==null;function f7($,{repeat:J,repeatType:Q="loop"},Z,q=1){let X=$.filter(wi),z=q<0||J&&Q!=="loop"&&J%2===1?0:X.length-1;return!z||Z===void 0?X[z]:Z}var ki={decay:Zq,inertia:Zq,tween:i2,keyframes:i2,spring:sJ};function cz($){if(typeof $.type==="string")$.type=ki[$.type]}class r2{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(($)=>{this.resolve=$})}notifyFinished(){this.resolve()}then($,J){return this.finished.then($,J)}}var Ii=($)=>$/100;class v7 extends r2{constructor($){super();if(this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:J}=this.options;if(J&&J.updatedAt!==E5.now())this.tick(E5.now());if(this.isStopped=!0,this.state==="idle")return;this.teardown(),this.options.onStop?.()},this.options=$,this.initAnimation(),this.play(),$.autoplay===!1)this.pause()}initAnimation(){let{options:$}=this;cz($);let{type:J=i2,repeat:Q=0,repeatDelay:Z=0,repeatType:q,velocity:X=0}=$,{keyframes:Y}=$,z=J||i2;if(z!==i2&&typeof Y[0]!=="number")this.mixKeyframes=h9(Ii,vz(Y[0],Y[1])),Y=[0,100];let K=z({...$,keyframes:Y});if(q==="mirror")this.mirroredGenerator=z({...$,keyframes:[...Y].reverse(),velocity:-X});if(K.calculatedDuration===null)K.calculatedDuration=rJ(K);let{calculatedDuration:W}=K;this.calculatedDuration=W,this.resolvedDuration=W+Z,this.totalDuration=this.resolvedDuration*(Q+1)-Z,this.generator=K}updateTime($){let J=Math.round($-this.startTime)*this.playbackSpeed;if(this.holdTime!==null)this.currentTime=this.holdTime;else this.currentTime=J}tick($,J=!1){let{generator:Q,totalDuration:Z,mixKeyframes:q,mirroredGenerator:X,resolvedDuration:Y,calculatedDuration:z}=this;if(this.startTime===null)return Q.next(0);let{delay:K=0,keyframes:W,repeat:H,repeatType:B,repeatDelay:U,type:_,onUpdate:L,finalKeyframe:F}=this.options;if(this.speed>0)this.startTime=Math.min(this.startTime,$);else if(this.speed<0)this.startTime=Math.min($-Z/this.speed,this.startTime);if(J)this.currentTime=$;else this.updateTime($);let V=this.currentTime-K*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?V<0:V>Z;if(this.currentTime=Math.max(V,0),this.state==="finished"&&this.holdTime===null)this.currentTime=Z;let D=this.currentTime,N=Q;if(H){let b=Math.min(this.currentTime,Z)/Y,k=Math.floor(b),w=b%1;if(!w&&b>=1)w=1;if(w===1&&k--,k=Math.min(k,H+1),Boolean(k%2)){if(B==="reverse"){if(w=1-w,U)w-=U/Y}else if(B==="mirror")N=X}D=L8(0,1,w)*Y}let O;if(M)this.delayState.value=W[0],O=this.delayState;else O=N.next(D);if(q&&!M)O.value=q(O.value);let{done:I}=O;if(!M&&z!==null)I=this.playbackSpeed>=0?this.currentTime>=Z:this.currentTime<=0;let A=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);if(A&&_!==Zq)O.value=f7(W,this.options,F,this.speed);if(L)L(O.value);if(A)this.finish();return O}then($,J){return this.finished.then($,J)}get duration(){return k8(this.calculatedDuration)}get iterationDuration(){let{delay:$=0}=this.options||{};return this.duration+k8($)}get time(){return k8(this.currentTime)}set time($){if($=v5($),this.currentTime=$,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0)this.holdTime=$;else if(this.driver)this.startTime=this.driver.now()-$/this.playbackSpeed;if(this.driver)this.driver.start(!1);else this.startTime=0,this.state="paused",this.holdTime=$,this.tick($)}getGeneratorVelocity(){let $=this.currentTime;if($<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity($);let J=this.generator.next($).value;return mz((Q)=>this.generator.next(Q).value,$,J)}get speed(){return this.playbackSpeed}set speed($){let J=this.playbackSpeed!==$;if(J&&this.driver)this.updateTime(E5.now());if(this.playbackSpeed=$,J&&this.driver)this.time=k8(this.currentTime)}play(){if(this.isStopped)return;let{driver:$=qb,startTime:J}=this.options;if(!this.driver)this.driver=$((Z)=>this.tick(Z));this.options.onPlay?.();let Q=this.driver.now();if(this.state==="finished")this.updateFinished(),this.startTime=Q;else if(this.holdTime!==null)this.startTime=Q-this.holdTime;else if(!this.startTime)this.startTime=J??Q;if(this.state==="finished"&&this.speed<0)this.startTime+=this.calculatedDuration;this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(E5.now()),this.holdTime=this.currentTime}complete(){if(this.state!=="running")this.play();this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){if(!this.driver)return;this.driver.stop(),this.driver=void 0}sample($){return this.startTime=0,this.tick($,!0)}attachTimeline($){if(this.options.allowFlatten)this.options.type="keyframes",this.options.ease="linear",this.initAnimation();return this.driver?.stop(),$.observe(this)}}function Hb($){for(let J=1;J<$.length;J++)$[J]??($[J]=$[J-1])}var s2=($)=>$*180/Math.PI,DU=($)=>{let J=s2(Math.atan2($[1],$[0]));return NU(J)},Ti={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:($)=>(Math.abs($[0])+Math.abs($[3]))/2,rotate:DU,rotateZ:DU,skewX:($)=>s2(Math.atan($[1])),skewY:($)=>s2(Math.atan($[2])),skew:($)=>(Math.abs($[1])+Math.abs($[2]))/2},NU=($)=>{if($=$%360,$<0)$+=360;return $},Bb=DU,Ub=($)=>Math.sqrt($[0]*$[0]+$[1]*$[1]),_b=($)=>Math.sqrt($[4]*$[4]+$[5]*$[5]),bi={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ub,scaleY:_b,scale:($)=>(Ub($)+_b($))/2,rotateX:($)=>NU(s2(Math.atan2($[6],$[5]))),rotateY:($)=>NU(s2(Math.atan2(-$[2],$[0]))),rotateZ:Bb,rotate:Bb,skewX:($)=>s2(Math.atan($[4])),skewY:($)=>s2(Math.atan($[1])),skew:($)=>(Math.abs($[1])+Math.abs($[4]))/2};function dz($){return $.includes("scale")?1:0}function pz($,J){if(!$||$==="none")return dz(J);let Q=$.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),Z,q;if(Q)Z=bi,q=Q;else{let z=$.match(/^matrix\(([-\d.e\s,]+)\)$/u);Z=Ti,q=z}if(!q)return dz(J);let X=Z[J],Y=q[1].split(",").map(ji);return typeof X==="function"?X(Y):Y[X]}var Lb=($,J)=>{let{transform:Q="none"}=getComputedStyle($);return pz(Q,J)};function ji($){return parseFloat($.trim())}var W4=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],H9=(()=>new Set([...W4,"pathRotation"]))();var OU=($)=>$===K4||$===d0,Ei=new Set(["x","y","z"]),yi=W4.filter(($)=>!Ei.has($));function Fb($){let J=[];return yi.forEach((Q)=>{let Z=$.getValue(Q);if(Z!==void 0)J.push([Q,Z.get()]),Z.set(Q.startsWith("scale")?1:0)}),J}var o4={width:({x:$},{paddingLeft:J="0",paddingRight:Q="0",boxSizing:Z})=>{let q=$.max-$.min;return Z==="border-box"?q:q-parseFloat(J)-parseFloat(Q)},height:({y:$},{paddingTop:J="0",paddingBottom:Q="0",boxSizing:Z})=>{let q=$.max-$.min;return Z==="border-box"?q:q-parseFloat(J)-parseFloat(Q)},top:($,{top:J})=>parseFloat(J),left:($,{left:J})=>parseFloat(J),bottom:({y:$},{top:J})=>parseFloat(J)+($.max-$.min),right:({x:$},{left:J})=>parseFloat(J)+($.max-$.min),x:($,{transform:J})=>pz(J,"x"),y:($,{transform:J})=>pz(J,"y")};o4.translateX=o4.x;o4.translateY=o4.y;var o2=new Set,AU=!1,wU=!1,kU=!1;function Vb(){if(wU){let $=Array.from(o2).filter((Z)=>Z.needsMeasurement),J=new Set($.map((Z)=>Z.element)),Q=new Map;J.forEach((Z)=>{let q=Fb(Z);if(!q.length)return;Q.set(Z,q),Z.render()}),$.forEach((Z)=>Z.measureInitialState()),J.forEach((Z)=>{Z.render();let q=Q.get(Z);if(q)q.forEach(([X,Y])=>{Z.getValue(X)?.set(Y)})}),$.forEach((Z)=>Z.measureEndState()),$.forEach((Z)=>{if(Z.suspendedScrollY!==void 0)window.scrollTo(0,Z.suspendedScrollY)})}wU=!1,AU=!1,o2.forEach(($)=>$.complete(kU)),o2.clear()}function Mb(){o2.forEach(($)=>{if($.readKeyframes(),$.needsMeasurement)wU=!0})}function Db(){kU=!0,Mb(),Vb(),kU=!1}class n2{constructor($,J,Q,Z,q,X=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...$],this.onComplete=J,this.name=Q,this.motionValue=Z,this.element=q,this.isAsync=X}scheduleResolve(){if(this.state="scheduled",this.isAsync){if(o2.add(this),!AU)AU=!0,I1.read(Mb),I1.resolveKeyframes(Vb)}else this.readKeyframes(),this.complete()}readKeyframes(){let{unresolvedKeyframes:$,name:J,element:Q,motionValue:Z}=this;if($[0]===null){let q=Z?.get(),X=$[$.length-1];if(q!==void 0)$[0]=q;else if(Q&&J){let Y=Q.readValue(J,X);if(Y!==void 0&&Y!==null)$[0]=Y}if($[0]===void 0)$[0]=X;if(Z&&q===void 0)Z.set($[0])}Hb($)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete($=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,$),o2.delete(this)}cancel(){if(this.state==="scheduled")o2.delete(this),this.state="pending"}resume(){if(this.state==="pending")this.scheduleResolve()}}var Nb=($)=>$.startsWith("--");function lz($,J,Q){Nb(J)?$.style.setProperty(J,Q):$.style[J]=Q}var Ob={};function iz($,J){let Q=dZ($);return()=>Ob[J]??Q()}var Ab=iz(()=>window.ScrollTimeline!==void 0,"scrollTimeline");var rz=iz(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch($){return!1}return!0},"linearEasing");var a2=([$,J,Q,Z])=>`cubic-bezier(${$}, ${J}, ${Q}, ${Z})`;var IU={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:a2([0,0.65,0.55,1]),circOut:a2([0.55,0,1,0.45]),backIn:a2([0.31,0.01,0.66,-0.59]),backOut:a2([0.33,1.53,0.69,0.99])};function TU($,J){if(!$)return;else if(typeof $==="function")return rz()?gz($,J):"ease-out";else if(aZ($))return a2($);else if(Array.isArray($))return $.map((Q)=>TU(Q,J)||IU.easeOut);else return IU[$]}function wb($,J,Q,{delay:Z=0,duration:q=300,repeat:X=0,repeatType:Y="loop",ease:z="easeOut",times:K}={},W=void 0){let H={[J]:Q};if(K)H.offset=K;let B=TU(z,q);if(Array.isArray(B))H.easing=B;let U={delay:Z,duration:q,easing:!Array.isArray(B)?B:"linear",fill:"both",iterations:X+1,direction:Y==="reverse"?"alternate":"normal"};if(W)U.pseudoElement=W;return $.animate(H,U)}function sz($){return typeof $==="function"&&"applyToOptions"in $}function kb({type:$,...J}){if(sz($)&&rz())return $.applyToOptions(J);else J.duration??(J.duration=300),J.ease??(J.ease="easeOut");return J}class qq extends r2{constructor($){super();if(this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!$)return;let{element:J,name:Q,keyframes:Z,pseudoElement:q,allowFlatten:X=!1,finalKeyframe:Y,onComplete:z}=$;this.isPseudoElement=Boolean(q),this.allowFlatten=X,this.options=$,N6(typeof $.type!=="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");let K=kb($);if(this.animation=wb(J,Q,Z,K,q),K.autoplay===!1)this.animation.pause();this.animation.onfinish=()=>{if(this.finishedTime=this.time,!q){let W=f7(Z,this.options,Y,this.speed);if(this.updateMotionValue)this.updateMotionValue(W);lz(J,Q,W),this.animation.cancel()}z?.(),this.notifyFinished()}}play(){if(this.isStopped)return;if(this.manualStartTime=null,this.animation.play(),this.state==="finished")this.updateFinished()}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch($){}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:$}=this;if($==="idle"||$==="finished")return;if(this.updateMotionValue)this.updateMotionValue();else this.commitStyles();if(!this.isPseudoElement)this.cancel()}commitStyles(){let $=this.options?.element;if(!this.isPseudoElement&&$?.isConnected)this.animation.commitStyles?.()}get duration(){let $=this.animation.effect?.getComputedTiming?.().duration||0;return k8(Number($))}get iterationDuration(){let{delay:$=0}=this.options||{};return this.duration+k8($)}get time(){return k8(Number(this.animation.currentTime)||0)}set time($){let J=this.finishedTime!==null;if(this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=v5($),J)this.animation.pause()}get speed(){return this.animation.playbackRate}set speed($){if($<0)this.finishedTime=null;this.animation.playbackRate=$}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime($){this.manualStartTime=this.animation.startTime=$}attachTimeline({timeline:$,rangeStart:J,rangeEnd:Q,observe:Z}){if(this.allowFlatten)this.animation.effect?.updateTiming({easing:"linear"});if(this.animation.onfinish=null,$&&Ab()){if(this.animation.timeline=$,J)this.animation.rangeStart=J;if(Q)this.animation.rangeEnd=Q;return j5}else return Z(this)}}var Ib={anticipate:iZ,backInOut:lZ,circInOut:oZ};function Pi($){return $ in Ib}function Tb($){if(typeof $.ease==="string"&&Pi($.ease))$.ease=Ib[$.ease]}var bU=10;class jU extends qq{constructor($){Tb($),cz($);super($);if($.startTime!==void 0&&$.autoplay!==!1)this.startTime=$.startTime;this.options=$}updateMotionValue($){let{motionValue:J,onUpdate:Q,onComplete:Z,element:q,...X}=this.options;if(!J)return;if($!==void 0){J.set($);return}let Y=new v7({...X,autoplay:!1}),z=Math.max(bU,E5.now()-this.startTime),K=L8(0,bU,z-bU),W=Y.sample(z).value,{name:H}=this.options;if(q&&H)lz(q,H,W);J.setWithVelocity(Y.sample(Math.max(0,z-K)).value,W,K),Y.stop()}}var EU=($,J)=>{if(J==="zIndex")return!1;if(typeof $==="number"||Array.isArray($))return!0;if(typeof $==="string"&&(F8.test($)||$==="0")&&!$.startsWith("url("))return!0;return!1};function Ri($){let J=$[0];if($.length===1)return!0;for(let Q=0;Q<$.length;Q++)if($[Q]!==J)return!0}function bb($,J,Q,Z){let q=$[0];if(q===null)return!1;if(J==="display"||J==="visibility")return!0;let X=$[$.length-1],Y=EU(q,J),z=EU(X,J);if(Y4(Y===z,`You are trying to animate ${J} from "${q}" to "${X}". "${Y?X:q}" is not an animatable value.`,"value-not-animatable"),!Y||!z)return!1;return Ri($)||(Q==="spring"||sz(Q))&&Z}function Xq($){$.duration=0,$.type="keyframes"}var oz=new Set(["opacity","clipPath","filter","transform"]);var Ci=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function jb($){for(let J=0;J<$.length;J++)if(typeof $[J]==="string"&&Ci.test($[J]))return!0;return!1}var Si=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),hi=dZ(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Eb($){let{motionValue:J,name:Q,repeatDelay:Z,repeatType:q,damping:X,type:Y,keyframes:z}=$;if(!(J?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:W,transformTemplate:H}=J.owner.getProps();return hi()&&Q&&(oz.has(Q)||Si.has(Q)&&jb(z))&&(Q!=="transform"||!H)&&!W&&!Z&&q!=="mirror"&&X!==0&&Y!=="inertia"}var xi=40;class yU extends r2{constructor({autoplay:$=!0,delay:J=0,type:Q="keyframes",repeat:Z=0,repeatDelay:q=0,repeatType:X="loop",keyframes:Y,name:z,motionValue:K,element:W,...H}){super();this.stop=()=>{if(this._animation)this._animation.stop(),this.stopTimeline?.();this.keyframeResolver?.cancel()},this.createdAt=E5.now();let B={autoplay:$,delay:J,type:Q,repeat:Z,repeatDelay:q,repeatType:X,name:z,motionValue:K,element:W,...H},U=W?.KeyframeResolver||n2;this.keyframeResolver=new U(Y,(_,L,F)=>this.onKeyframesResolved(_,L,B,!F),z,K,W),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved($,J,Q,Z){this.keyframeResolver=void 0;let{name:q,type:X,velocity:Y,delay:z,isHandoff:K,onUpdate:W}=Q;this.resolvedAt=E5.now();let H=!0;if(!bb($,q,X,Y)){if(H=!1,Q6.instantAnimations||!z)W?.(f7($,Q,J));$[0]=$[$.length-1],Xq(Q),Q.repeat=0}let U={startTime:Z?!this.resolvedAt?this.createdAt:this.resolvedAt-this.createdAt>xi?this.resolvedAt:this.createdAt:void 0,finalKeyframe:J,...Q,keyframes:$},_=H&&!K&&Eb(U),L=U.motionValue?.owner?.current,F;if(_)try{F=new jU({...U,element:L})}catch{F=new v7(U)}else F=new v7(U);if(F.finished.then(()=>{this.notifyFinished()}).catch(j5),this.pendingTimeline)this.stopTimeline=F.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0;this._animation=F}get finished(){if(!this._animation)return this._finished;else return this.animation.finished}then($,J){return this.finished.finally($).then(()=>{})}get animation(){if(!this._animation)this.keyframeResolver?.resume(),Db();return this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time($){this.animation.time=$}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed($){this.animation.speed=$}get startTime(){return this.animation.startTime}attachTimeline($){if(this._animation)this.stopTimeline=this.animation.attachTimeline($);else this.pendingTimeline=$;return()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){if(this._animation)this.animation.cancel();this.keyframeResolver?.cancel()}}function nz($,J,Q,Z=0,q=1){let X=Array.from($).sort((W,H)=>W.sortNodePosition(H)).indexOf(J),Y=$.size,z=(Y-1)*Z;return typeof Q==="function"?Q(X,Y):q===1?X*Z:z-X*Z}var yb=30,vi=($)=>{return!isNaN(parseFloat($))},Pb={current:void 0};class Rb{constructor($,J={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(Q)=>{let Z=E5.now();if(this.updatedAt!==Z)this.setPrevFrameValue();if(this.prev=this.current,this.setCurrent(Q),this.current!==this.prev){if(this.events.change?.notify(this.current),this.dependents)for(let q of this.dependents)q.dirty()}},this.hasAnimated=!1,this.setCurrent($),this.owner=J.owner}setCurrent($){if(this.current=$,this.updatedAt=E5.now(),this.canTrackVelocity===null&&$!==void 0)this.canTrackVelocity=vi(this.current)}setPrevFrameValue($=this.current){this.prevFrameValue=$,this.prevUpdatedAt=this.updatedAt}onChange($){return this.on("change",$)}on($,J){if(!this.events[$])this.events[$]=new R7;let Q=this.events[$].add(J);if($==="change")return()=>{Q(),I1.read(()=>{if(!this.events.change.getSize())this.stop()})};return Q}clearListeners(){for(let $ in this.events)this.events[$].clear()}attach($,J){this.passiveEffect=$,this.stopPassiveEffect=J}set($){if(!this.passiveEffect)this.updateAndNotify($);else this.passiveEffect($,this.updateAndNotify)}setWithVelocity($,J,Q){this.set(J),this.prev=void 0,this.prevFrameValue=$,this.prevUpdatedAt=this.updatedAt-Q}jump($,J=!0){if(this.updateAndNotify($),this.prev=$,this.prevUpdatedAt=this.prevFrameValue=void 0,J&&this.stop(),this.stopPassiveEffect)this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent($){if(!this.dependents)this.dependents=new Set;this.dependents.add($)}removeDependent($){if(this.dependents)this.dependents.delete($)}get(){if(Pb.current)Pb.current.push(this);return this.current}getPrevious(){return this.prev}getVelocity(){let $=E5.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||$-this.updatedAt>yb)return 0;let J=Math.min(this.updatedAt-this.prevUpdatedAt,yb);return pZ(parseFloat(this.current)-parseFloat(this.prevFrameValue),J)}start($){return this.stop(),new Promise((J)=>{if(this.hasAnimated=!0,this.animation=$(J),this.events.animationStart)this.events.animationStart.notify()}).then(()=>{if(this.events.animationComplete)this.events.animationComplete.notify();this.clearAnimation()})}stop(){if(this.animation){if(this.animation.stop(),this.events.animationCancel)this.events.animationCancel.notify()}this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){if(this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect)this.stopPassiveEffect()}}function x9($,J){return new Rb($,J)}function az($,J){if($?.inherit&&J){let{inherit:Q,...Z}=$;return{...J,...Z}}return $}function oJ($,J){let Q=$?.[J]??$?.default??$;if(Q!==$)return az(Q,$);return Q}var gi={type:"spring",stiffness:500,damping:25,restSpeed:10},ui=($)=>({type:"spring",stiffness:550,damping:$===0?2*Math.sqrt(550):30,restSpeed:10}),mi={type:"keyframes",duration:0.8},ci={type:"keyframes",ease:[0.25,0.1,0.35,1],duration:0.3},Cb=($,{keyframes:J})=>{if(J.length>2)return mi;else if(H9.has($))return $.startsWith("scale")?ui(J[1]):gi;return ci};var di=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function Sb($){for(let J in $)if(!di.has(J))return!0;return!1}var t2=($,J,Q,Z={},q,X)=>(Y)=>{let z=oJ(Z,$)||{},K=z.delay||Z.delay||0,{elapsed:W=0}=Z;W=W-v5(K);let H={keyframes:Array.isArray(Q)?Q:[null,Q],ease:"easeOut",velocity:J.getVelocity(),...z,delay:-W,onUpdate:(U)=>{J.set(U),z.onUpdate&&z.onUpdate(U)},onComplete:()=>{Y(),z.onComplete&&z.onComplete()},name:$,motionValue:J,element:X?void 0:q};if(!Sb(z))Object.assign(H,Cb($,H));if(H.duration&&(H.duration=v5(H.duration)),H.repeatDelay&&(H.repeatDelay=v5(H.repeatDelay)),H.from!==void 0)H.keyframes[0]=H.from;let B=!1;if(H.type===!1||H.duration===0&&!H.repeatDelay){if(Xq(H),H.delay===0)B=!0}if(Q6.instantAnimations||Q6.skipAnimations||q?.shouldSkipAnimations||z.skipAnimations)B=!0,Xq(H),H.delay=0;if(H.allowFlatten=!z.type&&!z.ease,B&&!X&&J.get()!==void 0){let U=f7(H.keyframes,z);if(U!==void 0){I1.update(()=>{H.onUpdate(U),H.onComplete()});return}}return z.isSync?new v7(H):new yU(H)};var pi=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function li($){let J=pi.exec($);if(!J)return[,];let[,Q,Z,q]=J;return[`--${Q??Z}`,q]}var ii=4;function PU($,J,Q=1){N6(Q<=ii,`Max CSS variable fallback depth detected in property "${$}". This may indicate a circular fallback dependency.`,"max-css-var-depth");let[Z,q]=li($);if(!Z)return;let X=window.getComputedStyle(J).getPropertyValue(Z);if(X){let Y=X.trim();return uZ(Y)?parseFloat(Y):Y}return dJ(q)?PU(q,J,Q+1):q}function hb($){let J=[{},{}];return $?.values.forEach((Q,Z)=>{J[0][Z]=Q.get(),J[1][Z]=Q.getVelocity()}),J}function e2($,J,Q,Z){if(typeof J==="function"){let[q,X]=hb(Z);J=J(Q!==void 0?Q:$.custom,q,X)}if(typeof J==="string")J=$.variants&&$.variants[J];if(typeof J==="function"){let[q,X]=hb(Z);J=J(Q!==void 0?Q:$.custom,q,X)}return J}function C6($,J,Q){let Z=$.getProps();return e2(Z,J,Q!==void 0?Q:Z.custom,$)}var tz=new Set(["width","height","top","left","right","bottom",...W4]);var Yq=($)=>{return Array.isArray($)};function ri($,J,Q){if($.hasValue(J))$.getValue(J).set(Q);else $.addValue(J,x9(Q))}function si($){return Yq($)?$[$.length-1]||0:$}function xb($,J){let Q=C6($,J),{transitionEnd:Z={},transition:q={},...X}=Q||{};X={...X,...Z};for(let Y in X){let z=si(X[Y]);ri($,Y,z)}}var X5=($)=>Boolean($&&$.getVelocity);function fb($){return Boolean(X5($)&&$.add)}function nJ($,J){let Q=$.getValue("willChange");if(fb(Q))return Q.add(J);else if(!Q&&Q6.WillChange){let Z=new Q6.WillChange("auto");$.addValue("willChange",Z),Z.add(J)}}function aJ($){return $.replace(/([A-Z])/g,(J)=>`-${J.toLowerCase()}`)}var vb="framerAppearId",zq="data-"+aJ(vb);function ez($){return $.props[zq]}function oi({protectedKeys:$,needsAnimating:J},Q){let Z=$.hasOwnProperty(Q)&&J[Q]!==!0;return J[Q]=!1,Z}function $K($,J,{delay:Q=0,transitionOverride:Z,type:q}={}){let{transition:X,transitionEnd:Y,...z}=J,K=$.getDefaultTransition();X=X?az(X,K):K;let W=X?.reduceMotion,H=X?.skipAnimations;if(Z)X=Z;let B=[],U=q&&$.animationState&&$.animationState.getState()[q],_=X?.path;if(_)_.animateVisualElement($,z,X,Q,B);for(let L in z){let F=$.getValue(L,$.latestValues[L]??null),V=z[L];if(V===void 0||U&&oi(U,L))continue;let M={delay:Q,...oJ(X||{},L)};if(H)M.skipAnimations=!0;let D=F.get();if(D!==void 0&&!F.isAnimating()&&!Array.isArray(V)&&V===D&&!M.velocity){I1.update(()=>F.set(V));continue}let N=!1;if(window.MotionHandoffAnimation){let A=ez($);if(A){let b=window.MotionHandoffAnimation(A,L,I1);if(b!==null)M.startTime=b,N=!0}}nJ($,L);let O=W??$.shouldReduceMotion;F.start(t2(L,F,V,O&&tz.has(L)?{type:!1}:M,$,N));let I=F.animation;if(I)B.push(I)}if(Y){let L=()=>I1.update(()=>{Y&&xb($,Y)});if(B.length)Promise.all(B).then(L);else L()}return B}function JK($,J,Q={}){let Z=C6($,J,Q.type==="exit"?$.presenceContext?.custom:void 0),{transition:q=$.getDefaultTransition()||{}}=Z||{};if(Q.transitionOverride)q=Q.transitionOverride;let X=Z?()=>Promise.all($K($,Z,Q)):()=>Promise.resolve(),Y=$.variantChildren&&$.variantChildren.size?(K=0)=>{let{delayChildren:W=0,staggerChildren:H,staggerDirection:B}=q;return ni($,J,K,W,H,B,Q)}:()=>Promise.resolve(),{when:z}=q;if(z){let[K,W]=z==="beforeChildren"?[X,Y]:[Y,X];return K().then(()=>W())}else return Promise.all([X(),Y(Q.delay)])}function ni($,J,Q=0,Z=0,q=0,X=1,Y){let z=[];for(let K of $.variantChildren)K.notify("AnimationStart",J),z.push(JK(K,J,{...Y,delay:Q+(typeof Z==="function"?0:Z)+nz($.variantChildren,K,Z,q,X)}).then(()=>K.notify("AnimationComplete",J)));return Promise.all(z)}function gb($,J,Q={}){$.notify("AnimationStart",J);let Z;if(Array.isArray(J)){let q=J.map((X)=>JK($,X,Q));Z=Promise.all(q)}else if(typeof J==="string")Z=JK($,J,Q);else{let q=typeof J==="function"?C6($,J,Q.custom):J;Z=Promise.all($K($,q,Q))}return Z.then(()=>{$.notify("AnimationComplete",J)})}var ub={test:($)=>$==="auto",parse:($)=>$};var QK=($)=>(J)=>J.test($);var RU=[K4,d0,c8,W9,UU,BU,ub],CU=($)=>RU.find(QK($));function mb($){if(typeof $==="number")return $===0;else if($!==null)return $==="none"||$==="0"||cZ($);else return!0}var ai=new Set(["brightness","contrast","saturate","opacity"]);function ti($){let[J,Q]=$.slice(0,-1).split("(");if(J==="drop-shadow")return $;let[Z]=Q.match(pJ)||[];if(!Z)return $;let q=Q.replace(Z,""),X=ai.has(J)?1:0;if(Z!==Q)X*=100;return J+"("+X+q+")"}var ei=/\b([a-z-]*)\(.*?\)/gu,Kq={...F8,getAnimatableNone:($)=>{let J=$.match(ei);return J?J.map(ti).join(" "):$}};var Gq={...F8,getAnimatableNone:($)=>{let J=F8.parse($);return F8.createTransformer($)(J.map((Z)=>typeof Z==="number"?0:typeof Z==="object"?{...Z,alpha:1}:Z))}};var SU={...K4,transform:Math.round};var cb={rotate:W9,pathRotation:W9,rotateX:W9,rotateY:W9,rotateZ:W9,scale:$q,scaleX:$q,scaleY:$q,scaleZ:$q,skew:W9,skewX:W9,skewY:W9,distance:d0,translateX:d0,translateY:d0,translateZ:d0,x:d0,y:d0,z:d0,perspective:d0,transformPerspective:d0,opacity:s4,originX:hz,originY:hz,originZ:d0};var $$={borderWidth:d0,borderTopWidth:d0,borderRightWidth:d0,borderBottomWidth:d0,borderLeftWidth:d0,borderRadius:d0,borderTopLeftRadius:d0,borderTopRightRadius:d0,borderBottomRightRadius:d0,borderBottomLeftRadius:d0,width:d0,maxWidth:d0,height:d0,maxHeight:d0,top:d0,right:d0,bottom:d0,left:d0,inset:d0,insetBlock:d0,insetBlockStart:d0,insetBlockEnd:d0,insetInline:d0,insetInlineStart:d0,insetInlineEnd:d0,padding:d0,paddingTop:d0,paddingRight:d0,paddingBottom:d0,paddingLeft:d0,paddingBlock:d0,paddingBlockStart:d0,paddingBlockEnd:d0,paddingInline:d0,paddingInlineStart:d0,paddingInlineEnd:d0,margin:d0,marginTop:d0,marginRight:d0,marginBottom:d0,marginLeft:d0,marginBlock:d0,marginBlockStart:d0,marginBlockEnd:d0,marginInline:d0,marginInlineStart:d0,marginInlineEnd:d0,fontSize:d0,backgroundPositionX:d0,backgroundPositionY:d0,...cb,zIndex:SU,fillOpacity:s4,strokeOpacity:s4,numOctaves:SU};var $r={...$$,color:A5,backgroundColor:A5,outlineColor:A5,fill:A5,stroke:A5,borderColor:A5,borderTopColor:A5,borderRightColor:A5,borderBottomColor:A5,borderLeftColor:A5,filter:Kq,WebkitFilter:Kq,mask:Gq,WebkitMask:Gq},ZK=($)=>$r[$];var Jr=new Set([Kq,Gq]);function qK($,J){let Q=ZK($);if(!Jr.has(Q))Q=F8;return Q.getAnimatableNone?Q.getAnimatableNone(J):void 0}var Qr=new Set(["auto","none","0"]);function db($,J,Q){let Z=0,q=void 0;while(Z<$.length&&!q){let X=$[Z];if(typeof X==="string"&&!Qr.has(X)&&x7(X).values.length)q=$[Z];Z++}if(q&&Q)for(let X of J)$[X]=qK(Q,q)}class hU extends n2{constructor($,J,Q,Z,q){super($,J,Q,Z,q,!0)}readKeyframes(){let{unresolvedKeyframes:$,element:J,name:Q}=this;if(!J||!J.current)return;super.readKeyframes();for(let W=0;W<$.length;W++){let H=$[W];if(typeof H==="string"){if(H=H.trim(),dJ(H)){let B=PU(H,J.current);if(B!==void 0)$[W]=B;if(W===$.length-1)this.finalKeyframe=H}}}if(this.resolveNoneKeyframes(),!tz.has(Q)||$.length!==2)return;let[Z,q]=$,X=CU(Z),Y=CU(q),z=WU(Z),K=WU(q);if(z!==K&&o4[Q]){this.needsMeasurement=!0;return}if(X===Y)return;if(OU(X)&&OU(Y))for(let W=0;W<$.length;W++){let H=$[W];if(typeof H==="string")$[W]=parseFloat(H)}else if(o4[Q])this.needsMeasurement=!0}resolveNoneKeyframes(){let{unresolvedKeyframes:$,name:J}=this,Q=[];for(let Z=0;Z<$.length;Z++)if($[Z]===null||mb($[Z]))Q.push(Z);if(Q.length)db($,Q,J)}measureInitialState(){let{element:$,unresolvedKeyframes:J,name:Q}=this;if(!$||!$.current)return;if(Q==="height")this.suspendedScrollY=window.pageYOffset;this.measuredOrigin=o4[Q]($.measureViewportBox(),window.getComputedStyle($.current)),J[0]=this.measuredOrigin;let Z=J[J.length-1];if(Z!==void 0)$.getValue(Q,Z).jump(Z,!1)}measureEndState(){let{element:$,name:J,unresolvedKeyframes:Q}=this;if(!$||!$.current)return;let Z=$.getValue(J);Z&&Z.jump(this.measuredOrigin,!1);let q=Q.length-1,X=Q[q];if(Q[q]=o4[J]($.measureViewportBox(),window.getComputedStyle($.current)),X!==null&&this.finalKeyframe===void 0)this.finalKeyframe=X;if(this.removedTransforms?.length)this.removedTransforms.forEach(([Y,z])=>{$.getValue(Y).set(z)});this.resolveNoneKeyframes()}}var Wq=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function XK($,J,Q){if($==null)return[];if($ instanceof EventTarget)return[$];else if(typeof $==="string"){let Z=document;if(J)Z=J.current;let q=Q?.[$]??Z.querySelectorAll($);return q?Array.from(q):[]}return Array.from($).filter((Z)=>Z!=null)}var Hq=($,J)=>{return J&&typeof $==="number"?J.transform($):$};function pb($){return mZ($)&&"offsetHeight"in $&&!("ownerSVGElement"in $)}var{schedule:J$,cancel:Zr}=Pz(queueMicrotask,!1);var B9={x:!1,y:!1};function YK(){return B9.x||B9.y}function xU($){if($==="x"||$==="y")if(B9[$])return null;else return B9[$]=!0,()=>{B9[$]=!1};else if(B9.x||B9.y)return null;else return B9.x=B9.y=!0,()=>{B9.x=B9.y=!1}}function zK($,J){let Q=XK($),Z=new AbortController,q={passive:!0,...J,signal:Z.signal};return[Q,q,()=>Z.abort()]}function qr($){return!($.pointerType==="touch"||YK())}function fU($,J,Q={}){let[Z,q,X]=zK($,Q);return Z.forEach((Y)=>{let z=!1,K=!1,W,H=()=>{Y.removeEventListener("pointerleave",L)},B=(V)=>{if(W)W(V),W=void 0;H()},U=(V)=>{if(z=!1,window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",U),K)K=!1,B(V)},_=()=>{z=!0,window.addEventListener("pointerup",U,q),window.addEventListener("pointercancel",U,q)},L=(V)=>{if(V.pointerType==="touch")return;if(z){K=!0;return}B(V)},F=(V)=>{if(!qr(V))return;K=!1;let M=J(Y,V);if(typeof M!=="function")return;W=M,Y.addEventListener("pointerleave",L,q)};Y.addEventListener("pointerenter",F,q),Y.addEventListener("pointerdown",_,q)}),X}var vU=($,J)=>{if(!J)return!1;else if($===J)return!0;else return vU($,J.parentElement)};var Q$=($)=>{if($.pointerType==="mouse")return typeof $.button!=="number"||$.button<=0;else return $.isPrimary!==!1};var Xr=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function gU($){return Xr.has($.tagName)||$.isContentEditable===!0}var Yr=new Set(["INPUT","SELECT","TEXTAREA"]);function uU($){return Yr.has($.tagName)||$.isContentEditable===!0}var tJ=new WeakSet;function lb($){return(J)=>{if(J.key!=="Enter")return;$(J)}}function mU($,J){$.dispatchEvent(new PointerEvent("pointer"+J,{isPrimary:!0,bubbles:!0}))}var ib=($,J)=>{let Q=$.currentTarget;if(!Q)return;let Z=lb(()=>{if(tJ.has(Q))return;mU(Q,"down");let q=lb(()=>{mU(Q,"up")}),X=()=>mU(Q,"cancel");Q.addEventListener("keyup",q,J),Q.addEventListener("blur",X,J)});Q.addEventListener("keydown",Z,J),Q.addEventListener("blur",()=>Q.removeEventListener("keydown",Z),J)};function rb($){return Q$($)&&!YK()}var sb=new WeakSet;function cU($,J,Q={}){let[Z,q,X]=zK($,Q),Y=(z)=>{let K=z.currentTarget;if(!rb(z))return;if(sb.has(z))return;if(tJ.add(K),Q.stopPropagation)sb.add(z);let W=J(K,z),H={...q,capture:!0},B=(L,F)=>{if(window.removeEventListener("pointerup",U,H),window.removeEventListener("pointercancel",_,H),tJ.has(K))tJ.delete(K);if(!rb(L))return;if(typeof W==="function")W(L,{success:F})},U=(L)=>{B(L,K===window||K===document||Q.useGlobalTarget||vU(K,L.target))},_=(L)=>{B(L,!1)};window.addEventListener("pointerup",U,H),window.addEventListener("pointercancel",_,H)};return Z.forEach((z)=>{if((Q.useGlobalTarget?window:z).addEventListener("pointerdown",Y,q),pb(z)){if(z.addEventListener("focus",(W)=>ib(W,q)),!gU(z)&&!z.hasAttribute("tabindex"))z.tabIndex=0}}),X}function eJ($){return mZ($)&&"ownerSVGElement"in $}var KK=new WeakMap,GK,ob=($,J,Q)=>(Z,q)=>{if(q&&q[0])return q[0][$+"Size"];else if(eJ(Z)&&"getBBox"in Z)return Z.getBBox()[J];else return Z[Q]},zr=ob("inline","width","offsetWidth"),Kr=ob("block","height","offsetHeight");function Gr({target:$,borderBoxSize:J}){KK.get($)?.forEach((Q)=>{Q($,{get width(){return zr($,J)},get height(){return Kr($,J)}})})}function Wr($){$.forEach(Gr)}function Hr(){if(typeof ResizeObserver>"u")return;GK=new ResizeObserver(Wr)}function nb($,J){if(!GK)Hr();let Q=XK($);return Q.forEach((Z)=>{let q=KK.get(Z);if(!q)q=new Set,KK.set(Z,q);q.add(J),GK?.observe(Z)}),()=>{Q.forEach((Z)=>{let q=KK.get(Z);if(q?.delete(J),!q?.size)GK?.unobserve(Z)})}}var WK=new Set,$Q;function Br(){$Q=()=>{let $={get width(){return window.innerWidth},get height(){return window.innerHeight}};WK.forEach((J)=>J($))},window.addEventListener("resize",$Q)}function ab($){if(WK.add($),!$Q)Br();return()=>{if(WK.delete($),!WK.size&&typeof $Q==="function")window.removeEventListener("resize",$Q),$Q=void 0}}function HK($,J){return typeof $==="function"?ab($):nb($,J)}var Z$={value:null,addProjectionMetrics:null};function tb($){return eJ($)&&$.tagName==="svg"}var Ur=[...RU,A5,F8],eb=($)=>Ur.find(QK($));var dU=()=>({translate:0,scale:1,origin:0,originPoint:0}),g7=()=>({x:dU(),y:dU()}),pU=()=>({min:0,max:0}),w5=()=>({x:pU(),y:pU()});var $j=new WeakMap;function n4($){return $!==null&&typeof $==="object"&&typeof $.start==="function"}function H4($){return typeof $==="string"||Array.isArray($)}var BK=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Bq=["initial",...BK];function u7($){return n4($.animate)||Bq.some((J)=>H4($[J]))}function Uq($){return Boolean(u7($)||$.variants)}function Jj($,J,Q){for(let Z in J){let q=J[Z],X=Q[Z];if(X5(q))$.addValue(Z,q);else if(X5(X))$.addValue(Z,x9(q,{owner:$}));else if(X!==q)if($.hasValue(Z)){let Y=$.getValue(Z);if(Y.liveStyle===!0)Y.jump(q);else if(!Y.hasAnimated)Y.set(q)}else{let Y=$.getStaticValue(Z);$.addValue(Z,x9(Y!==void 0?Y:q,{owner:$}))}}for(let Z in Q)if(J[Z]===void 0)$.removeValue(Z);return J}var _q={current:null},UK={current:!1};var _r=typeof window<"u";function Qj(){if(UK.current=!0,!_r)return;if(window.matchMedia){let $=window.matchMedia("(prefers-reduced-motion)"),J=()=>_q.current=$.matches;$.addEventListener("change",J),J()}else _q.current=!1}var Zj=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],_K={};function Lq($){_K=$}function lU(){return _K}class LK{scrapeMotionValuesFromProps($,J,Q){return{}}constructor({parent:$,props:J,presenceContext:Q,reducedMotionConfig:Z,skipAnimations:q,blockInitialAnimation:X,visualState:Y},z={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=n2,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{if(!this.current)return;this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection)},this.renderScheduledAt=0,this.scheduleRender=()=>{let U=E5.now();if(this.renderScheduledAt<U)this.renderScheduledAt=U,I1.render(this.render,!1,!0)};let{latestValues:K,renderState:W}=Y;if(this.latestValues=K,this.baseTarget={...K},this.initialValues=J.initial?{...K}:{},this.renderState=W,this.parent=$,this.props=J,this.presenceContext=Q,this.depth=$?$.depth+1:0,this.reducedMotionConfig=Z,this.skipAnimationsConfig=q,this.options=z,this.blockInitialAnimation=Boolean(X),this.isControllingVariants=u7(J),this.isVariantNode=Uq(J),this.isVariantNode)this.variantChildren=new Set;this.manuallyAnimateOnMount=Boolean($&&$.current);let{willChange:H,...B}=this.scrapeMotionValuesFromProps(J,{},this);for(let U in B){let _=B[U];if(K[U]!==void 0&&X5(_))_.set(K[U])}}mount($){if(this.hasBeenMounted)for(let J in this.initialValues)this.values.get(J)?.jump(this.initialValues[J]),this.latestValues[J]=this.initialValues[J];if(this.current=$,$j.set($,this),this.projection&&!this.projection.instance)this.projection.mount($);if(this.parent&&this.isVariantNode&&!this.isControllingVariants)this.removeFromVariantTree=this.parent.addVariantChild(this);if(this.values.forEach((J,Q)=>this.bindToMotionValue(Q,J)),this.reducedMotionConfig==="never")this.shouldReduceMotion=!1;else if(this.reducedMotionConfig==="always")this.shouldReduceMotion=!0;else{if(!UK.current)Qj();this.shouldReduceMotion=_q.current}this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),O6(this.notifyUpdate),O6(this.render),this.valueSubscriptions.forEach(($)=>$()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let $ in this.events)this.events[$].clear();for(let $ in this.features){let J=this.features[$];if(J)J.unmount(),J.isMounted=!1}this.current=null}addChild($){this.children.add($),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add($)}removeChild($){this.children.delete($),this.enteringChildren&&this.enteringChildren.delete($)}bindToMotionValue($,J){if(this.valueSubscriptions.has($))this.valueSubscriptions.get($)();if(J.accelerate&&oz.has($)&&this.current instanceof HTMLElement){let{factory:X,keyframes:Y,times:z,ease:K,duration:W}=J.accelerate,H=new qq({element:this.current,name:$,keyframes:Y,times:z,ease:K,duration:v5(W)}),B=X(H);this.valueSubscriptions.set($,()=>{B(),H.cancel()});return}let Q=H9.has($);if(Q&&this.onBindTransform)this.onBindTransform();let Z=J.on("change",(X)=>{if(this.latestValues[$]=X,this.props.onUpdate&&I1.preRender(this.notifyUpdate),Q&&this.projection)this.projection.isTransformDirty=!0;this.scheduleRender()}),q;if(typeof window<"u"&&window.MotionCheckAppearSync)q=window.MotionCheckAppearSync(this,$,J);this.valueSubscriptions.set($,()=>{if(Z(),q)q()})}sortNodePosition($){if(!this.current||!this.sortInstanceNodePosition||this.type!==$.type)return 0;return this.sortInstanceNodePosition(this.current,$.current)}updateFeatures(){let $="animation";for($ in _K){let J=_K[$];if(!J)continue;let{isEnabled:Q,Feature:Z}=J;if(!this.features[$]&&Z&&Q(this.props))this.features[$]=new Z(this);if(this.features[$]){let q=this.features[$];if(q.isMounted)q.update();else q.mount(),q.isMounted=!0}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):w5()}getStaticValue($){return this.latestValues[$]}setStaticValue($,J){this.latestValues[$]=J}update($,J){if($.transformTemplate||this.props.transformTemplate)this.scheduleRender();this.prevProps=this.props,this.props=$,this.prevPresenceContext=this.presenceContext,this.presenceContext=J;for(let Q=0;Q<Zj.length;Q++){let Z=Zj[Q];if(this.propEventSubscriptions[Z])this.propEventSubscriptions[Z](),delete this.propEventSubscriptions[Z];let q="on"+Z,X=$[q];if(X)this.propEventSubscriptions[Z]=this.on(Z,X)}if(this.prevMotionValues=Jj(this,this.scrapeMotionValuesFromProps($,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue)this.handleChildMotionValue()}getProps(){return this.props}getVariant($){return this.props.variants?this.props.variants[$]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild($){let J=this.getClosestVariantNode();if(J)return J.variantChildren&&J.variantChildren.add($),()=>J.variantChildren.delete($)}addValue($,J){let Q=this.values.get($);if(J!==Q){if(Q)this.removeValue($);this.bindToMotionValue($,J),this.values.set($,J),this.latestValues[$]=J.get()}}removeValue($){this.values.delete($);let J=this.valueSubscriptions.get($);if(J)J(),this.valueSubscriptions.delete($);delete this.latestValues[$],this.removeValueFromRenderState($,this.renderState)}hasValue($){return this.values.has($)}getValue($,J){if(this.props.values&&this.props.values[$])return this.props.values[$];let Q=this.values.get($);if(Q===void 0&&J!==void 0)Q=x9(J===null?void 0:J,{owner:this}),this.addValue($,Q);return Q}readValue($,J){let Q=this.latestValues[$]!==void 0||!this.current?this.latestValues[$]:this.getBaseTargetFromProps(this.props,$)??this.readValueFromInstance(this.current,$,this.options);if(Q!==void 0&&Q!==null){if(typeof Q==="string"&&(uZ(Q)||cZ(Q)))Q=parseFloat(Q);else if(!eb(Q)&&F8.test(J))Q=qK($,J);this.setBaseTarget($,X5(Q)?Q.get():Q)}return X5(Q)?Q.get():Q}setBaseTarget($,J){this.baseTarget[$]=J}getBaseTarget($){let{initial:J}=this.props,Q;if(typeof J==="string"||typeof J==="object"){let q=e2(this.props,J,this.presenceContext?.custom);if(q)Q=q[$]}if(J&&Q!==void 0)return Q;let Z=this.getBaseTargetFromProps(this.props,$);if(Z!==void 0&&!X5(Z))return Z;return this.initialValues[$]!==void 0&&Q===void 0?void 0:this.baseTarget[$]}on($,J){if(!this.events[$])this.events[$]=new R7;return this.events[$].add(J)}notify($,...J){if(this.events[$])this.events[$].notify(...J)}scheduleRenderMicrotask(){J$.render(this.render)}}class Fq extends LK{constructor(){super(...arguments);this.KeyframeResolver=hU}sortInstanceNodePosition($,J){return $.compareDocumentPosition(J)&2?1:-1}getBaseTargetFromProps($,J){let Q=$.style;return Q?Q[J]:void 0}removeValueFromRenderState($,{vars:J,style:Q}){delete J[$],delete Q[$]}handleChildMotionValue(){if(this.childSubscription)this.childSubscription(),delete this.childSubscription;let{children:$}=this.props;if(X5($))this.childSubscription=$.on("change",(J)=>{if(this.current)this.current.textContent=`${J}`})}}class I8{constructor($){this.isMounted=!1,this.node=$}update(){}}function Vq({top:$,left:J,right:Q,bottom:Z}){return{x:{min:J,max:Q},y:{min:$,max:Z}}}function iU({x:$,y:J}){return{top:J.min,right:$.max,bottom:J.max,left:$.min}}function rU($,J){if(!J)return $;let Q=J({x:$.left,y:$.top}),Z=J({x:$.right,y:$.bottom});return{top:Q.y,left:Q.x,bottom:Z.y,right:Z.x}}function sU($){return $===void 0||$===1}function FK({scale:$,scaleX:J,scaleY:Q}){return!sU($)||!sU(J)||!sU(Q)}function a4($){return FK($)||oU($)||$.z||$.rotate||$.rotateX||$.rotateY||$.skewX||$.skewY}function oU($){return qj($.x)||qj($.y)}function qj($){return $&&$!=="0%"}function Mq($,J,Q){let Z=$-Q,q=J*Z;return Q+q}function Xj($,J,Q,Z,q){if(q!==void 0)$=Mq($,q,Z);return Mq($,Q,Z)+J}function nU($,J=0,Q=1,Z,q){$.min=Xj($.min,J,Q,Z,q),$.max=Xj($.max,J,Q,Z,q)}function aU($,{x:J,y:Q}){nU($.x,J.translate,J.scale,J.originPoint),nU($.y,Q.translate,Q.scale,Q.originPoint)}var Yj=0.999999999999,zj=1.0000000000001;function Wj($,J,Q,Z=!1){let q=Q.length;if(!q)return;J.x=J.y=1;let X,Y;for(let z=0;z<q;z++){X=Q[z],Y=X.projectionDelta;let{visualElement:K}=X.options;if(K&&K.props.style&&K.props.style.display==="contents")continue;if(Z&&X.options.layoutScroll&&X.scroll&&X!==X.root)U9($.x,-X.scroll.offset.x),U9($.y,-X.scroll.offset.y);if(Y)J.x*=Y.x.scale,J.y*=Y.y.scale,aU($,Y);if(Z&&a4(X.latestValues))Dq($,X.latestValues,X.layout?.layoutBox)}if(J.x<zj&&J.x>Yj)J.x=1;if(J.y<zj&&J.y>Yj)J.y=1}function U9($,J){$.min+=J,$.max+=J}function Kj($,J,Q,Z,q=0.5){let X=j1($.min,$.max,q);nU($,J,Q,X,Z)}function Gj($,J){if(typeof $==="string")return parseFloat($)/100*(J.max-J.min);return $}function Dq($,J,Q){let Z=Q??$;Kj($.x,Gj(J.x,Z.x),J.scaleX,J.scale,J.originX),Kj($.y,Gj(J.y,Z.y),J.scaleY,J.scale,J.originY)}function VK($,J){return Vq(rU($.getBoundingClientRect(),J))}function tU($,J,Q){let Z=VK($,Q),{scroll:q}=J;if(q)U9(Z.x,q.offset.x),U9(Z.y,q.offset.y);return Z}var Lr={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Fr=W4.length;function Hj($,J,Q){let Z="",q=!0;for(let Y=0;Y<Fr;Y++){let z=W4[Y],K=$[z];if(K===void 0)continue;let W=!0;if(typeof K==="number")W=K===(z.startsWith("scale")?1:0);else{let H=parseFloat(K);W=z.startsWith("scale")?H===1:H===0}if(!W||Q){let H=Hq(K,$$[z]);if(!W){q=!1;let B=Lr[z]||z;Z+=`${B}(${H}) `}if(Q)J[z]=H}}let X=$.pathRotation;if(X)q=!1,Z+=`rotate(${Hq(X,$$.pathRotation)}) `;if(Z=Z.trim(),Q)Z=Q(J,q?"":Z);else if(q)Z="none";return Z}function q$($,J,Q){let{style:Z,vars:q,transformOrigin:X}=$,Y=!1,z=!1;for(let K in J){let W=J[K];if(H9.has(K)){Y=!0;continue}else if(Cz(K)){q[K]=W;continue}else{let H=Hq(W,$$[K]);if(K.startsWith("origin"))z=!0,X[K]=H;else Z[K]=H}}if(!J.transform){if(Y||Q)Z.transform=Hj(J,$.transform,Q);else if(Z.transform)Z.transform="none"}if(z){let{originX:K="50%",originY:W="50%",originZ:H=0}=X;Z.transformOrigin=`${K} ${W} ${H}`}}function MK($,{style:J,vars:Q},Z,q){let X=$.style,Y;for(Y in J)X[Y]=J[Y];q?.applyProjectionStyles(X,Z);for(Y in Q)X.setProperty(Y,Q[Y])}function Bj($,J){if(J.max===J.min)return 0;return $/(J.max-J.min)*100}var JQ={correct:($,J)=>{if(!J.target)return $;if(typeof $==="string")if(d0.test($))$=parseFloat($);else return $;let Q=Bj($,J.target.x),Z=Bj($,J.target.y);return`${Q}% ${Z}%`}};var Uj={correct:($,{treeScale:J,projectionDelta:Q})=>{let Z=$,q=F8.parse($);if(q.length>5)return Z;let X=F8.createTransformer($),Y=typeof q[0]!=="number"?1:0,z=Q.x.scale*J.x,K=Q.y.scale*J.y;q[0+Y]/=z,q[1+Y]/=K;let W=j1(z,K,0.5);if(typeof q[2+Y]==="number")q[2+Y]/=W;if(typeof q[3+Y]==="number")q[3+Y]/=W;return X(q)}};var Nq={borderRadius:{...JQ,applyTo:[...Wq]},borderTopLeftRadius:JQ,borderTopRightRadius:JQ,borderBottomLeftRadius:JQ,borderBottomRightRadius:JQ,boxShadow:Uj};function Oq($,{layout:J,layoutId:Q}){return H9.has($)||$.startsWith("origin")||(J||Q!==void 0)&&(!!Nq[$]||$==="opacity")}function X$($,J,Q){let Z=$.style,q=J?.style,X={};if(!Z)return X;for(let Y in Z)if(X5(Z[Y])||q&&X5(q[Y])||Oq(Y,$)||Q?.getValue(Y)?.liveStyle!==void 0)X[Y]=Z[Y];return X}function Vr($){return window.getComputedStyle($)}class DK extends Fq{constructor(){super(...arguments);this.type="html",this.renderInstance=MK}readValueFromInstance($,J){if(H9.has(J))return this.projection?.isProjecting?dz(J):Lb($,J);else{let Q=Vr($),Z=(Cz(J)?Q.getPropertyValue(J):Q[J])||0;return typeof Z==="string"?Z.trim():Z}}measureInstanceViewportBox($,{transformPagePoint:J}){return VK($,J)}build($,J,Q){q$($,J,Q.transformTemplate)}scrapeMotionValuesFromProps($,J,Q){return X$($,J,Q)}}var Mr={offset:"stroke-dashoffset",array:"stroke-dasharray"},Dr={offset:"strokeDashoffset",array:"strokeDasharray"};function _j($,J,Q=1,Z=0,q=!0){$.pathLength=1;let X=q?Mr:Dr;$[X.offset]=`${-Z}`,$[X.array]=`${J} ${Q}`}var Nr=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Aq($,{attrX:J,attrY:Q,attrScale:Z,pathLength:q,pathSpacing:X=1,pathOffset:Y=0,...z},K,W,H){if(q$($,z,W),K){if($.style.viewBox)$.attrs.viewBox=$.style.viewBox;return}$.attrs=$.style,$.style={};let{attrs:B,style:U}=$;if(B.transform)U.transform=B.transform,delete B.transform;if(U.transform||B.transformOrigin)U.transformOrigin=B.transformOrigin??"50% 50%",delete B.transformOrigin;if(U.transform)U.transformBox=H?.transformBox??"fill-box",delete B.transformBox;for(let _ of Nr)if(B[_]!==void 0)U[_]=B[_],delete B[_];if(J!==void 0)B.x=J;if(Q!==void 0)B.y=Q;if(Z!==void 0)B.scale=Z;if(q!==void 0)_j(B,q,X,Y,!1)}var NK=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);var wq=($)=>typeof $==="string"&&$.toLowerCase()==="svg";function Lj($,J,Q,Z){MK($,J,void 0,Z);for(let q in J.attrs)$.setAttribute(!NK.has(q)?aJ(q):q,J.attrs[q])}function kq($,J,Q){let Z=X$($,J,Q);for(let q in $)if(X5($[q])||X5(J[q])){let X=W4.indexOf(q)!==-1?"attr"+q.charAt(0).toUpperCase()+q.substring(1):q;Z[X]=$[q]}return Z}class OK extends Fq{constructor(){super(...arguments);this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=w5}getBaseTargetFromProps($,J){return $[J]}readValueFromInstance($,J){if(H9.has(J)){let Q=ZK(J);return Q?Q.default||0:0}return J=!NK.has(J)?aJ(J):J,$.getAttribute(J)}scrapeMotionValuesFromProps($,J,Q){return kq($,J,Q)}build($,J,Q){Aq($,J,this.isSVGTag,Q.transformTemplate,Q.style)}renderInstance($,J,Q,Z){Lj($,J,Q,Z)}mount($){this.isSVGTag=wq($.tagName),super.mount($)}}var Or=Bq.length;function eU($){if(!$)return;if(!$.isControllingVariants){let Q=$.parent?eU($.parent)||{}:{};if($.props.initial!==void 0)Q.initial=$.props.initial;return Q}let J={};for(let Q=0;Q<Or;Q++){let Z=Bq[Q],q=$.props[Z];if(H4(q)||q===!1)J[Z]=q}return J}function $_($,J){if(!Array.isArray(J))return!1;let Q=J.length;if(Q!==$.length)return!1;for(let Z=0;Z<Q;Z++)if(J[Z]!==$[Z])return!1;return!0}var Ar=[...BK].reverse(),wr=BK.length;function kr($){return(J)=>{return Promise.all(J.map(({animation:Q,options:Z})=>gb($,Q,Z)))}}function J_($){let J=kr($),Q=Fj(),Z=!0,q=!1,X=(W)=>(H,B)=>{let U=C6($,B,W==="exit"?$.presenceContext?.custom:void 0);if(U){let{transition:_,transitionEnd:L,...F}=U;H={...H,...F,...L}}return H};function Y(W){J=W($)}function z(W){let{props:H}=$,B=eU($.parent)||{},U=[],_=new Set,L={},F=1/0;for(let M=0;M<wr;M++){let D=Ar[M],N=Q[D],O=H[D]!==void 0?H[D]:B[D],I=H4(O),A=D===W?N.isActive:null;if(A===!1)F=M;let b=O===B[D]&&O!==H[D]&&I;if(b&&(Z||q)&&$.manuallyAnimateOnMount)b=!1;if(N.protectedKeys={...L},!N.isActive&&A===null||!O&&!N.prevProp||n4(O)||typeof O==="boolean")continue;if(D==="exit"&&N.isActive&&A!==!0){if(N.prevResolvedValues)L={...L,...N.prevResolvedValues};continue}let k=Vj(N.prevProp,O),w=k||D===W&&N.isActive&&!b&&I||M>F&&I,C=!1,y=Array.isArray(O)?O:[O],f=y.reduce(X(D),{});if(A===!1)f={};let{prevResolvedValues:j={}}=N,P={...j,...f},x=(h)=>{if(w=!0,_.has(h))C=!0,_.delete(h);N.needsAnimating[h]=!0;let r=$.getValue(h);if(r)r.liveStyle=!1};for(let h in P){let r=f[h],$0=j[h];if(L.hasOwnProperty(h))continue;let Y0=!1;if(Yq(r)&&Yq($0))Y0=!$_(r,$0)||k;else Y0=r!==$0;if(Y0)if(r!==void 0&&r!==null)x(h);else _.add(h);else if(r!==void 0&&_.has(h))x(h);else N.protectedKeys[h]=!0}if(N.prevProp=O,N.prevResolvedValues=f,N.isActive)L={...L,...f};if((Z||q)&&$.blockInitialAnimation)w=!1;let p=b&&k;if(w&&(!p||C))U.push(...y.map((h)=>{let r={type:D};if(typeof h==="string"&&(Z||q)&&!p&&$.manuallyAnimateOnMount&&$.parent){let{parent:$0}=$,Y0=C6($0,h);if($0.enteringChildren&&Y0){let{delayChildren:e}=Y0.transition||{};r.delay=nz($0.enteringChildren,$,e)}}return{animation:h,options:r}}))}if(_.size){let M={};if(typeof H.initial!=="boolean"){let D=C6($,Array.isArray(H.initial)?H.initial[0]:H.initial);if(D&&D.transition)M.transition=D.transition}_.forEach((D)=>{let N=$.getBaseTarget(D),O=$.getValue(D);if(O)O.liveStyle=!0;M[D]=N??null}),U.push({animation:M})}let V=Boolean(U.length);if(Z&&(H.initial===!1||H.initial===H.animate)&&!$.manuallyAnimateOnMount)V=!1;return Z=!1,q=!1,V?J(U):Promise.resolve()}function K(W,H){if(Q[W].isActive===H)return Promise.resolve();$.variantChildren?.forEach((U)=>U.animationState?.setActive(W,H)),Q[W].isActive=H;let B=z(W);for(let U in Q)Q[U].protectedKeys={};return B}return{animateChanges:z,setActive:K,setAnimateFunction:Y,getState:()=>Q,reset:()=>{Q=Fj(),q=!0}}}function Vj($,J){if(typeof J==="string")return J!==$;else if(Array.isArray(J))return!$_(J,$);return!1}function Y$($=!1){return{isActive:$,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Fj(){return{animate:Y$(!0),whileInView:Y$(),whileHover:Y$(),whileTap:Y$(),whileDrag:Y$(),whileFocus:Y$(),exit:Y$()}}function AK($,J){$.min=J.min,$.max=J.max}function _9($,J){AK($.x,J.x),AK($.y,J.y)}function Q_($,J){$.translate=J.translate,$.scale=J.scale,$.originPoint=J.originPoint,$.origin=J.origin}var Mj=0.0001,Ir=1-Mj,Tr=1+Mj,Dj=0.01,br=0-Dj,jr=0+Dj;function s5($){return $.max-$.min}function Y_($,J,Q){return Math.abs($-J)<=Q}function Z_($,J,Q,Z=0.5){if($.origin=Z,$.originPoint=j1(J.min,J.max,$.origin),$.scale=s5(Q)/s5(J),$.translate=j1(Q.min,Q.max,$.origin)-$.originPoint,$.scale>=Ir&&$.scale<=Tr||isNaN($.scale))$.scale=1;if($.translate>=br&&$.translate<=jr||isNaN($.translate))$.translate=0}function z$($,J,Q,Z){Z_($.x,J.x,Q.x,Z?Z.originX:void 0),Z_($.y,J.y,Q.y,Z?Z.originY:void 0)}function q_($,J,Q,Z=0){let q=Z?j1(Q.min,Q.max,Z):Q.min;$.min=q+J.min,$.max=$.min+s5(J)}function z_($,J,Q,Z){q_($.x,J.x,Q.x,Z?.x),q_($.y,J.y,Q.y,Z?.y)}function X_($,J,Q,Z=0){let q=Z?j1(Q.min,Q.max,Z):Q.min;$.min=J.min-q,$.max=$.min+s5(J)}function QQ($,J,Q,Z){X_($.x,J.x,Q.x,Z?.x),X_($.y,J.y,Q.y,Z?.y)}function Nj($,J,Q,Z,q){if($-=J,$=Mq($,1/Q,Z),q!==void 0)$=Mq($,1/q,Z);return $}function Er($,J=0,Q=1,Z=0.5,q,X=$,Y=$){if(c8.test(J))J=parseFloat(J),J=j1(Y.min,Y.max,J/100)-Y.min;if(typeof J!=="number")return;let z=j1(X.min,X.max,Z);if($===X)z-=J;$.min=Nj($.min,J,Q,z,q),$.max=Nj($.max,J,Q,z,q)}function Oj($,J,[Q,Z,q],X,Y){Er($,J[Q],J[Z],J[q],J.scale,X,Y)}var yr=["x","scaleX","originX"],Pr=["y","scaleY","originY"];function K_($,J,Q,Z){Oj($.x,J,yr,Q?Q.x:void 0,Z?Z.x:void 0),Oj($.y,J,Pr,Q?Q.y:void 0,Z?Z.y:void 0)}function Aj($){return $.translate===0&&$.scale===1}function G_($){return Aj($.x)&&Aj($.y)}function wj($,J){return $.min===J.min&&$.max===J.max}function Ij($,J){return wj($.x,J.x)&&wj($.y,J.y)}function kj($,J){return Math.round($.min)===Math.round(J.min)&&Math.round($.max)===Math.round(J.max)}function W_($,J){return kj($.x,J.x)&&kj($.y,J.y)}function H_($){return s5($.x)/s5($.y)}function B_($,J){return $.translate===J.translate&&$.scale===J.scale&&$.originPoint===J.originPoint}function S6($){return[$("x"),$("y")]}function Tj($,J,Q){let Z="",q=$.x.translate/J.x,X=$.y.translate/J.y,Y=Q?.z||0;if(q||X||Y)Z=`translate3d(${q}px, ${X}px, ${Y}px) `;if(J.x!==1||J.y!==1)Z+=`scale(${1/J.x}, ${1/J.y}) `;if(Q){let{transformPerspective:W,rotate:H,pathRotation:B,rotateX:U,rotateY:_,skewX:L,skewY:F}=Q;if(W)Z=`perspective(${W}px) ${Z}`;if(H)Z+=`rotate(${H}deg) `;if(B)Z+=`rotate(${B}deg) `;if(U)Z+=`rotateX(${U}deg) `;if(_)Z+=`rotateY(${_}deg) `;if(L)Z+=`skewX(${L}deg) `;if(F)Z+=`skewY(${F}deg) `}let z=$.x.scale*J.x,K=$.y.scale*J.y;if(z!==1||K!==1)Z+=`scale(${z}, ${K})`;return Z||"none"}var Rr=Wq.length,bj=($)=>typeof $==="string"?parseFloat($):$,jj=($)=>typeof $==="number"||d0.test($);function yj($,J,Q,Z,q,X){if(q)$.opacity=j1(0,Q.opacity??1,Cr(Z)),$.opacityExit=j1(J.opacity??1,0,Sr(Z));else if(X)$.opacity=j1(J.opacity??1,Q.opacity??1,Z);for(let Y=0;Y<Rr;Y++){let z=Wq[Y],K=Ej(J,z),W=Ej(Q,z);if(K===void 0&&W===void 0)continue;if(K||(K=0),W||(W=0),K===0||W===0||jj(K)===jj(W)){if($[z]=Math.max(j1(bj(K),bj(W),Z),0),c8.test(W)||c8.test(K))$[z]+="%"}else $[z]=W}if(J.rotate||Q.rotate)$.rotate=j1(J.rotate||0,Q.rotate||0,Z)}function Ej($,J){return $[J]!==void 0?$[J]:$.borderRadius}var Cr=Pj(0,0.5,sZ),Sr=Pj(0.5,0.95,j5);function Pj($,J,Q){return(Z)=>{if(Z<$)return 0;if(Z>J)return 1;return Q(z4($,J,Z))}}function Rj($,J,Q){let Z=X5($)?$:x9($);return Z.start(t2("",Z,J,Q)),Z.animation}function B4($,J,Q,Z={passive:!0}){return $.addEventListener(J,Q,Z),()=>$.removeEventListener(J,Q,Z)}var Cj=($,J)=>$.depth-J.depth;class U_{constructor(){this.children=[],this.isDirty=!1}add($){l2(this.children,$),this.isDirty=!0}remove($){P7(this.children,$),this.isDirty=!0}forEach($){this.isDirty&&this.children.sort(Cj),this.isDirty=!1,this.children.forEach($)}}function Sj($,J){let Q=E5.now(),Z=({timestamp:q})=>{let X=q-Q;if(X>=J)O6(Z),$(X-J)};return I1.setup(Z,!0),()=>O6(Z)}function K$($){return X5($)?$.get():$}class __{constructor(){this.members=[]}add($){l2(this.members,$);for(let J=this.members.length-1;J>=0;J--){let Q=this.members[J];if(Q===$||Q===this.lead||Q===this.prevLead)continue;let Z=Q.instance;if((!Z||Z.isConnected===!1)&&!Q.snapshot)P7(this.members,Q),Q.unmount()}$.scheduleRender()}remove($){if(P7(this.members,$),$===this.prevLead)this.prevLead=void 0;if($===this.lead){let J=this.members[this.members.length-1];if(J)this.promote(J)}}relegate($){for(let J=this.members.indexOf($)-1;J>=0;J--){let Q=this.members[J];if(Q.isPresent!==!1&&Q.instance?.isConnected!==!1)return this.promote(Q),!0}return!1}promote($,J){let Q=this.lead;if($===Q)return;if(this.prevLead=Q,this.lead=$,$.show(),Q){Q.updateSnapshot(),$.scheduleRender();let{layoutDependency:Z}=Q.options,{layoutDependency:q}=$.options;if(Z===void 0||Z!==q){if($.resumeFrom=Q,J)Q.preserveOpacity=!0;if(Q.snapshot)$.snapshot=Q.snapshot,$.snapshot.latestValues=Q.animationValues||Q.latestValues;if($.root?.isUpdating)$.isLayoutDirty=!0}if($.options.crossfade===!1)Q.hide()}}exitAnimationComplete(){this.members.forEach(($)=>{$.options.onExitComplete?.(),$.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(($)=>$.instance&&$.scheduleRender(!1))}removeLeadSnapshot(){if(this.lead?.snapshot)this.lead.snapshot=void 0}}var G$={hasAnimatedSinceResize:!0,hasEverUpdated:!1};var W$={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},L_=["","X","Y","Z"],hr=1000,xr=0;function F_($,J,Q,Z){let{latestValues:q}=J;if(q[$]){if(Q[$]=q[$],J.setStaticValue($,0),Z)Z[$]=0}}function dj($){if($.hasCheckedOptimisedAppear=!0,$.root===$)return;let{visualElement:J}=$.options;if(!J)return;let Q=ez(J);if(window.MotionHasOptimisedAnimation(Q,"transform")){let{layout:q,layoutId:X}=$.options;window.MotionCancelOptimisedAnimation(Q,"transform",I1,!(q||X))}let{parent:Z}=$;if(Z&&!Z.hasCheckedOptimisedAppear)dj(Z)}function wK({attachResizeListener:$,defaultParent:J,measureScroll:Q,checkIsScrollRoot:Z,resetTransform:q}){return class{constructor(Y={},z=J?.()){this.id=xr++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{if(this.isUpdating)this.isUpdating=!1,this.clearAllSnapshots()},this.updateProjection=()=>{if(this.projectionUpdateScheduled=!1,Z$.value)W$.nodes=W$.calculatedTargetDeltas=W$.calculatedProjections=0;if(this.nodes.forEach(gr),this.nodes.forEach(lr),this.nodes.forEach(ir),this.nodes.forEach(ur),Z$.addProjectionMetrics)Z$.addProjectionMetrics(W$)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=Y,this.root=z?z.root||z:this,this.path=z?[...z.path,z]:[],this.parent=z,this.depth=z?z.depth+1:0;for(let K=0;K<this.path.length;K++)this.path[K].shouldResetTransform=!0;if(this.root===this)this.nodes=new U_}addEventListener(Y,z){if(!this.eventHandlers.has(Y))this.eventHandlers.set(Y,new R7);return this.eventHandlers.get(Y).add(z)}notifyListeners(Y,...z){let K=this.eventHandlers.get(Y);K&&K.notify(...z)}hasListeners(Y){return this.eventHandlers.has(Y)}mount(Y){if(this.instance)return;this.isSVG=eJ(Y)&&!tb(Y),this.instance=Y;let{layoutId:z,layout:K,visualElement:W}=this.options;if(W&&!W.current)W.mount(Y);if(this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(K||z))this.isLayoutDirty=!0;if($){let H,B=0,U=()=>this.root.updateBlockedByResize=!1;I1.read(()=>{B=window.innerWidth}),$(Y,()=>{let _=window.innerWidth;if(_===B)return;if(B=_,this.root.updateBlockedByResize=!0,H&&H(),H=Sj(U,250),G$.hasAnimatedSinceResize)G$.hasAnimatedSinceResize=!1,this.nodes.forEach(fj)})}if(z)this.root.registerSharedNode(z,this);if(this.options.animate!==!1&&W&&(z||K))this.addEventListener("didUpdate",({delta:H,hasLayoutChanged:B,hasRelativeLayoutChanged:U,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let L=this.options.transition||W.getDefaultTransition()||ar,{onLayoutAnimationStart:F,onLayoutAnimationComplete:V}=W.getProps(),M=!this.targetLayout||!W_(this.targetLayout,_),D=!B&&U;if(this.options.layoutRoot||this.resumeFrom||D||B&&(M||!this.currentAnimation)){if(this.resumeFrom)this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0;let N={...oJ(L,"layout"),onPlay:F,onComplete:V};if(W.shouldReduceMotion||this.options.layoutRoot)N.delay=0,N.type=!1;this.startAnimation(N),this.setAnimationOrigin(H,D,N.path)}else{if(!B)fj(this);if(this.isLead()&&this.options.onExitComplete)this.options.onExitComplete()}this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let Y=this.getStack();Y&&Y.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),O6(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){if(this.isUpdateBlocked())return;this.isUpdating=!0,this.nodes&&this.nodes.forEach(rr),this.animationId++}getTransformTemplate(){let{visualElement:Y}=this.options;return Y&&Y.getProps().transformTemplate}willUpdate(Y=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear)dj(this);if(!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let H=0;H<this.path.length;H++){let B=this.path[H];if(B.shouldResetTransform=!0,typeof B.latestValues.x==="string"||typeof B.latestValues.y==="string")B.isLayoutDirty=!0;if(B.updateScroll("snapshot"),B.options.layoutRoot)B.willUpdate(!1)}let{layoutId:z,layout:K}=this.options;if(z===void 0&&!K)return;let W=this.getTransformTemplate();this.prevTransformTemplateValue=W?W(this.latestValues,""):void 0,this.updateSnapshot(),Y&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let K=this.updateBlockedByResize;if(this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),K)this.nodes.forEach(cr);this.nodes.forEach(hj);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(xj);return}if(this.animationCommitId=this.animationId,!this.isUpdating)this.nodes.forEach(xj);else this.isUpdating=!1,this.nodes.forEach(dr),this.nodes.forEach(pr),this.nodes.forEach(fr),this.nodes.forEach(vr);this.clearAllSnapshots();let z=E5.now();S5.delta=L8(0,16.666666666666668,z-S5.timestamp),S5.timestamp=z,S5.isProcessing=!0,eZ.update.process(S5),eZ.preRender.process(S5),eZ.render.process(S5),S5.isProcessing=!1}didUpdate(){if(!this.updateScheduled)this.updateScheduled=!0,J$.read(this.scheduleUpdate)}clearAllSnapshots(){this.nodes.forEach(mr),this.sharedNodes.forEach(sr)}scheduleUpdateProjection(){if(!this.projectionUpdateScheduled)this.projectionUpdateScheduled=!0,I1.preRender(this.updateProjection,!1,!0)}scheduleCheckAfterUnmount(){I1.postRender(()=>{if(this.isLayoutDirty)this.root.didUpdate();else this.root.checkUpdateFailed()})}updateSnapshot(){if(this.snapshot||!this.instance)return;if(this.snapshot=this.measure(),this.snapshot&&!s5(this.snapshot.measuredBox.x)&&!s5(this.snapshot.measuredBox.y))this.snapshot=void 0}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty)return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let K=0;K<this.path.length;K++)this.path[K].updateScroll();let Y=this.layout;if(this.layout=this.measure(!1),this.layoutVersion++,!this.layoutCorrected)this.layoutCorrected=w5();this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:z}=this.options;z&&z.notify("LayoutMeasure",this.layout.layoutBox,Y?Y.layoutBox:void 0)}updateScroll(Y="measure"){let z=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===Y)z=!1;if(z&&this.instance){let K=Z(this.instance);this.scroll={animationId:this.root.animationId,phase:Y,isRoot:K,offset:Q(this.instance),wasRoot:this.scroll?this.scroll.isRoot:K}}}resetTransform(){if(!q)return;let Y=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,z=this.projectionDelta&&!G_(this.projectionDelta),K=this.getTransformTemplate(),W=K?K(this.latestValues,""):void 0,H=W!==this.prevTransformTemplateValue;if(Y&&this.instance&&(z||a4(this.latestValues)||H))q(this.instance,W),this.shouldResetTransform=!1,this.scheduleRender()}measure(Y=!0){let z=this.measurePageBox(),K=this.removeElementScroll(z);if(Y)K=this.removeTransform(K);return tr(K),{animationId:this.root.animationId,measuredBox:z,layoutBox:K,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:Y}=this.options;if(!Y)return w5();let z=Y.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(er))){let{scroll:W}=this.root;if(W)U9(z.x,W.offset.x),U9(z.y,W.offset.y)}return z}removeElementScroll(Y){let z=w5();if(_9(z,Y),this.scroll?.wasRoot)return z;for(let K=0;K<this.path.length;K++){let W=this.path[K],{scroll:H,options:B}=W;if(W!==this.root&&H&&B.layoutScroll){if(H.wasRoot)_9(z,Y);U9(z.x,H.offset.x),U9(z.y,H.offset.y)}}return z}applyTransform(Y,z=!1,K){let W=K||w5();_9(W,Y);for(let H=0;H<this.path.length;H++){let B=this.path[H];if(!z&&B.options.layoutScroll&&B.scroll&&B!==B.root)U9(W.x,-B.scroll.offset.x),U9(W.y,-B.scroll.offset.y);if(!a4(B.latestValues))continue;Dq(W,B.latestValues,B.layout?.layoutBox)}if(a4(this.latestValues))Dq(W,this.latestValues,this.layout?.layoutBox);return W}removeTransform(Y){let z=w5();_9(z,Y);for(let K=0;K<this.path.length;K++){let W=this.path[K];if(!a4(W.latestValues))continue;let H;if(W.instance)FK(W.latestValues)&&W.updateSnapshot(),H=w5(),_9(H,W.measurePageBox());K_(z,W.latestValues,W.snapshot?.layoutBox,H)}if(a4(this.latestValues))K_(z,this.latestValues);return z}setTargetDelta(Y){this.targetDelta=Y,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(Y){this.options={...this.options,...Y,crossfade:Y.crossfade!==void 0?Y.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){if(!this.relativeParent)return;if(this.relativeParent.resolvedRelativeTargetAt!==S5.timestamp)this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(Y=!1){let z=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=z.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=z.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=z.isSharedProjectionDirty);let K=Boolean(this.resumingFrom)||this!==z;if(!(Y||K&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:H,layoutId:B}=this.options;if(!this.layout||!(H||B))return;this.resolvedRelativeTargetAt=S5.timestamp;let U=this.getClosestProjectingParent();if(U&&this.linkedParentVersion!==U.layoutVersion&&!U.options.layoutRoot)this.removeRelativeTarget();if(!this.targetDelta&&!this.relativeTarget)if(this.options.layoutAnchor!==!1&&U&&U.layout)this.createRelativeTarget(U,this.layout.layoutBox,U.layout.layoutBox);else this.removeRelativeTarget();if(!this.relativeTarget&&!this.targetDelta)return;if(!this.target)this.target=w5(),this.targetWithTransforms=w5();if(this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target)this.forceRelativeParentToResolveTarget(),z_(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0);else if(this.targetDelta){if(Boolean(this.resumingFrom))this.applyTransform(this.layout.layoutBox,!1,this.target);else _9(this.target,this.layout.layoutBox);aU(this.target,this.targetDelta)}else _9(this.target,this.layout.layoutBox);if(this.attemptToResolveRelativeTarget)if(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&U&&Boolean(U.resumingFrom)===Boolean(this.resumingFrom)&&!U.options.layoutScroll&&U.target&&this.animationProgress!==1)this.createRelativeTarget(U,this.target,U.target);else this.relativeParent=this.relativeTarget=void 0;if(Z$.value)W$.calculatedTargetDeltas++}getClosestProjectingParent(){if(!this.parent||FK(this.parent.latestValues)||oU(this.parent.latestValues))return;if(this.parent.isProjecting())return this.parent;else return this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(Y,z,K){this.relativeParent=Y,this.linkedParentVersion=Y.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=w5(),this.relativeTargetOrigin=w5(),QQ(this.relativeTargetOrigin,z,K,this.options.layoutAnchor||void 0),_9(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let Y=this.getLead(),z=Boolean(this.resumingFrom)||this!==Y,K=!0;if(this.isProjectionDirty||this.parent?.isProjectionDirty)K=!1;if(z&&(this.isSharedProjectionDirty||this.isTransformDirty))K=!1;if(this.resolvedRelativeTargetAt===S5.timestamp)K=!1;if(K)return;let{layout:W,layoutId:H}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),!this.isTreeAnimating)this.targetDelta=this.relativeTarget=void 0;if(!this.layout||!(W||H))return;_9(this.layoutCorrected,this.layout.layoutBox);let B=this.treeScale.x,U=this.treeScale.y;if(Wj(this.layoutCorrected,this.treeScale,this.path,z),Y.layout&&!Y.target&&(this.treeScale.x!==1||this.treeScale.y!==1))Y.target=Y.layout.layoutBox,Y.targetWithTransforms=w5();let{target:_}=Y;if(!_){if(this.prevProjectionDelta)this.createProjectionDeltas(),this.scheduleRender();return}if(!this.projectionDelta||!this.prevProjectionDelta)this.createProjectionDeltas();else Q_(this.prevProjectionDelta.x,this.projectionDelta.x),Q_(this.prevProjectionDelta.y,this.projectionDelta.y);if(z$(this.projectionDelta,this.layoutCorrected,_,this.latestValues),this.treeScale.x!==B||this.treeScale.y!==U||!B_(this.projectionDelta.x,this.prevProjectionDelta.x)||!B_(this.projectionDelta.y,this.prevProjectionDelta.y))this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",_);if(Z$.value)W$.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(Y=!0){if(this.options.visualElement?.scheduleRender(),Y){let z=this.getStack();z&&z.scheduleRender()}if(this.resumingFrom&&!this.resumingFrom.instance)this.resumingFrom=void 0}createProjectionDeltas(){this.prevProjectionDelta=g7(),this.projectionDelta=g7(),this.projectionDeltaWithTransform=g7()}setAnimationOrigin(Y,z=!1,K){let W=this.snapshot,H=W?W.latestValues:{},B={...this.latestValues},U=g7();if(!this.relativeParent||!this.relativeParent.options.layoutRoot)this.relativeTarget=this.relativeTargetOrigin=void 0;this.attemptToResolveRelativeTarget=!z;let _=w5(),L=W?W.source:void 0,F=this.layout?this.layout.source:void 0,V=L!==F,M=this.getStack(),D=!M||M.members.length<=1,N=Boolean(V&&!D&&this.options.crossfade===!0&&!this.path.some(nr));this.animationProgress=0;let O,I=K?.interpolateProjection(Y);this.mixTargetDelta=(A)=>{let b=A/1000,k=I?.(b);if(k)U.x.translate=k.x,U.x.scale=j1(Y.x.scale,1,b),U.x.origin=Y.x.origin,U.x.originPoint=Y.x.originPoint,U.y.translate=k.y,U.y.scale=j1(Y.y.scale,1,b),U.y.origin=Y.y.origin,U.y.originPoint=Y.y.originPoint;else vj(U.x,Y.x,b),vj(U.y,Y.y,b);if(this.setTargetDelta(U),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){if(QQ(_,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),or(this.relativeTarget,this.relativeTargetOrigin,_,b),O&&Ij(this.relativeTarget,O))this.isProjectionDirty=!1;if(!O)O=w5();_9(O,this.relativeTarget)}if(V)this.animationValues=B,yj(B,H,this.latestValues,b,N,D);if(k&&k.rotate!==void 0){if(!this.animationValues)this.animationValues=B;this.animationValues.pathRotation=k.rotate}this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=b},this.mixTargetDelta(this.options.layoutRoot?1000:0)}startAnimation(Y){if(this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation)O6(this.pendingAnimation),this.pendingAnimation=void 0;this.pendingAnimation=I1.update(()=>{if(G$.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=x9(0)),this.motionValue.jump(0,!1),this.currentAnimation=Rj(this.motionValue,[0,1000],{...Y,velocity:0,isSync:!0,onUpdate:(z)=>{this.mixTargetDelta(z),Y.onUpdate&&Y.onUpdate(z)},onComplete:()=>{Y.onComplete&&Y.onComplete(),this.completeAnimation()}}),this.resumingFrom)this.resumingFrom.currentAnimation=this.currentAnimation;this.pendingAnimation=void 0})}completeAnimation(){if(this.resumingFrom)this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0;let Y=this.getStack();Y&&Y.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){if(this.currentAnimation)this.mixTargetDelta&&this.mixTargetDelta(hr),this.currentAnimation.stop();this.completeAnimation()}applyTransformsToTarget(){let Y=this.getLead(),{targetWithTransforms:z,target:K,layout:W,latestValues:H}=Y;if(!z||!K||!W)return;if(this!==Y&&this.layout&&W&&pj(this.options.animationType,this.layout.layoutBox,W.layoutBox)){K=this.target||w5();let B=s5(this.layout.layoutBox.x);K.x.min=Y.target.x.min,K.x.max=K.x.min+B;let U=s5(this.layout.layoutBox.y);K.y.min=Y.target.y.min,K.y.max=K.y.min+U}_9(z,K),Dq(z,H),z$(this.projectionDeltaWithTransform,this.layoutCorrected,z,H)}registerSharedNode(Y,z){if(!this.sharedNodes.has(Y))this.sharedNodes.set(Y,new __);this.sharedNodes.get(Y).add(z);let W=z.options.initialPromotionConfig;z.promote({transition:W?W.transition:void 0,preserveFollowOpacity:W&&W.shouldPreserveFollowOpacity?W.shouldPreserveFollowOpacity(z):void 0})}isLead(){let Y=this.getStack();return Y?Y.lead===this:!0}getLead(){let{layoutId:Y}=this.options;return Y?this.getStack()?.lead||this:this}getPrevLead(){let{layoutId:Y}=this.options;return Y?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:Y}=this.options;if(Y)return this.root.sharedNodes.get(Y)}promote({needsReset:Y,transition:z,preserveFollowOpacity:K}={}){let W=this.getStack();if(W)W.promote(this,K);if(Y)this.projectionDelta=void 0,this.needsReset=!0;if(z)this.setOptions({transition:z})}relegate(){let Y=this.getStack();if(Y)return Y.relegate(this);else return!1}resetSkewAndRotation(){let{visualElement:Y}=this.options;if(!Y)return;let z=!1,{latestValues:K}=Y;if(K.z||K.rotate||K.rotateX||K.rotateY||K.rotateZ||K.skewX||K.skewY)z=!0;if(!z)return;let W={};if(K.z)F_("z",Y,W,this.animationValues);for(let H=0;H<L_.length;H++)F_(`rotate${L_[H]}`,Y,W,this.animationValues),F_(`skew${L_[H]}`,Y,W,this.animationValues);Y.render();for(let H in W)if(Y.setStaticValue(H,W[H]),this.animationValues)this.animationValues[H]=W[H];Y.scheduleRender()}applyProjectionStyles(Y,z){if(!this.instance||this.isSVG)return;if(!this.isVisible){Y.visibility="hidden";return}let K=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,Y.visibility="",Y.opacity="",Y.pointerEvents=K$(z?.pointerEvents)||"",Y.transform=K?K(this.latestValues,""):"none";return}let W=this.getLead();if(!this.projectionDelta||!this.layout||!W.target){if(this.options.layoutId)Y.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,Y.pointerEvents=K$(z?.pointerEvents)||"";if(this.hasProjected&&!a4(this.latestValues))Y.transform=K?K({},""):"none",this.hasProjected=!1;return}Y.visibility="";let H=W.animationValues||W.latestValues;this.applyTransformsToTarget();let B=Tj(this.projectionDeltaWithTransform,this.treeScale,H);if(K)B=K(H,B);Y.transform=B;let{x:U,y:_}=this.projectionDelta;if(Y.transformOrigin=`${U.origin*100}% ${_.origin*100}% 0`,W.animationValues)Y.opacity=W===this?H.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:H.opacityExit;else Y.opacity=W===this?H.opacity!==void 0?H.opacity:"":H.opacityExit!==void 0?H.opacityExit:0;for(let L in Nq){if(H[L]===void 0)continue;let{correct:F,applyTo:V,isCSSVariable:M}=Nq[L],D=B==="none"?H[L]:F(H[L],W);if(V){let N=V.length;for(let O=0;O<N;O++)Y[V[O]]=D}else if(M)this.options.visualElement.renderState.vars[L]=D;else Y[L]=D}if(this.options.layoutId)Y.pointerEvents=W===this?K$(z?.pointerEvents)||"":"none"}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach((Y)=>Y.currentAnimation?.stop()),this.root.nodes.forEach(hj),this.root.sharedNodes.clear()}}}function fr($){$.updateLayout()}function vr($){let J=$.resumeFrom?.snapshot||$.snapshot;if($.isLead()&&$.layout&&J&&$.hasListeners("didUpdate")){let{layoutBox:Q,measuredBox:Z}=$.layout,{animationType:q}=$.options,X=J.source!==$.layout.source;if(q==="size")S6((H)=>{let B=X?J.measuredBox[H]:J.layoutBox[H],U=s5(B);B.min=Q[H].min,B.max=B.min+U});else if(q==="x"||q==="y"){let H=q==="x"?"y":"x";AK(X?J.measuredBox[H]:J.layoutBox[H],Q[H])}else if(pj(q,J.layoutBox,Q))S6((H)=>{let B=X?J.measuredBox[H]:J.layoutBox[H],U=s5(Q[H]);if(B.max=B.min+U,$.relativeTarget&&!$.currentAnimation)$.isProjectionDirty=!0,$.relativeTarget[H].max=$.relativeTarget[H].min+U});let Y=g7();z$(Y,Q,J.layoutBox);let z=g7();if(X)z$(z,$.applyTransform(Z,!0),J.measuredBox);else z$(z,Q,J.layoutBox);let K=!G_(Y),W=!1;if(!$.resumeFrom){let H=$.getClosestProjectingParent();if(H&&!H.resumeFrom){let{snapshot:B,layout:U}=H;if(B&&U){let _=$.options.layoutAnchor||void 0,L=w5();QQ(L,J.layoutBox,B.layoutBox,_);let F=w5();if(QQ(F,Q,U.layoutBox,_),!W_(L,F))W=!0;if(H.options.layoutRoot)$.relativeTarget=F,$.relativeTargetOrigin=L,$.relativeParent=H}}}$.notifyListeners("didUpdate",{layout:Q,snapshot:J,delta:z,layoutDelta:Y,hasLayoutChanged:K,hasRelativeLayoutChanged:W})}else if($.isLead()){let{onExitComplete:Q}=$.options;Q&&Q()}$.options.transition=void 0}function gr($){if(Z$.value)W$.nodes++;if(!$.parent)return;if(!$.isProjecting())$.isProjectionDirty=$.parent.isProjectionDirty;$.isSharedProjectionDirty||($.isSharedProjectionDirty=Boolean($.isProjectionDirty||$.parent.isProjectionDirty||$.parent.isSharedProjectionDirty)),$.isTransformDirty||($.isTransformDirty=$.parent.isTransformDirty)}function ur($){$.isProjectionDirty=$.isSharedProjectionDirty=$.isTransformDirty=!1}function mr($){$.clearSnapshot()}function hj($){$.clearMeasurements()}function cr($){$.isLayoutDirty=!0,$.updateLayout()}function xj($){$.isLayoutDirty=!1}function dr($){if($.isAnimationBlocked&&$.layout&&!$.isLayoutDirty)$.snapshot=$.layout,$.isLayoutDirty=!0}function pr($){let{visualElement:J}=$.options;if(J&&J.getProps().onBeforeLayoutMeasure)J.notify("BeforeLayoutMeasure");$.resetTransform()}function fj($){$.finishAnimation(),$.targetDelta=$.relativeTarget=$.target=void 0,$.isProjectionDirty=!0}function lr($){$.resolveTargetDelta()}function ir($){$.calcProjection()}function rr($){$.resetSkewAndRotation()}function sr($){$.removeLeadSnapshot()}function vj($,J,Q){$.translate=j1(J.translate,0,Q),$.scale=j1(J.scale,1,Q),$.origin=J.origin,$.originPoint=J.originPoint}function gj($,J,Q,Z){$.min=j1(J.min,Q.min,Z),$.max=j1(J.max,Q.max,Z)}function or($,J,Q,Z){gj($.x,J.x,Q.x,Z),gj($.y,J.y,Q.y,Z)}function nr($){return $.animationValues&&$.animationValues.opacityExit!==void 0}var ar={duration:0.45,ease:[0.4,0,0.1,1]},uj=($)=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes($),mj=uj("applewebkit/")&&!uj("chrome/")?Math.round:j5;function cj($){$.min=mj($.min),$.max=mj($.max)}function tr($){cj($.x),cj($.y)}function pj($,J,Q){return $==="position"||$==="preserve-aspect"&&!Y_(H_(J),H_(Q),0.2)}function er($){return $!==$.root&&$.scroll?.wasRoot}var lj=wK({attachResizeListener:($,J)=>B4($,"resize",J),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0});var kK={current:void 0},Iq=wK({measureScroll:($)=>({x:$.scrollLeft,y:$.scrollTop}),defaultParent:()=>{if(!kK.current){let $=new lj({});$.mount(window),$.setOptions({layoutScroll:!0}),kK.current=$}return kK.current},resetTransform:($,J)=>{$.style.transform=J!==void 0?J:"none"},checkIsScrollRoot:($)=>Boolean(window.getComputedStyle($).position==="fixed")});var rj=R(v(),1);var ij=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ZQ($){if(typeof $!=="string"||$.includes("-"))return!1;else if(ij.indexOf($)>-1||/[A-Z]/u.test($))return!0;return!1}var sj=($,J)=>{return J.isSVG??ZQ($)?new OK(J):new DK(J,{allowProjection:$!==rj.Fragment})};var zQ=R(v(),1);var oj=R(v(),1),IK=oj.createContext({});var nj=R(v(),1),TK=nj.createContext({strict:!1});var aj=R(v(),1),bK=aj.createContext({transformPagePoint:($)=>$,isStatic:!1,reducedMotion:"never"});var tj=R(v(),1),m7=tj.createContext({});var jK=R(v(),1);function ej($,J){if(u7($)){let{initial:Q,animate:Z}=$;return{initial:Q===!1||H4(Q)?Q:void 0,animate:H4(Z)?Z:void 0}}return $.inherit!==!1?J:{}}function JE($){let{initial:J,animate:Q}=ej($,jK.useContext(m7));return jK.useMemo(()=>({initial:J,animate:Q}),[$E(J),$E(Q)])}function $E($){return Array.isArray($)?$.join(" "):$}var XQ=R(v(),1);var QE=R(v(),1);var qQ=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function V_($,J,Q){for(let Z in J)if(!X5(J[Z])&&!Oq(Z,Q))$[Z]=J[Z]}function $s({transformTemplate:$},J){return QE.useMemo(()=>{let Q=qQ();return q$(Q,J,$),Object.assign({},Q.vars,Q.style)},[J])}function Js($,J){let Q=$.style||{},Z={};return V_(Z,Q,$),Object.assign(Z,$s($,J)),Z}function ZE($,J){let Q={},Z=Js($,J);if($.drag&&$.dragListener!==!1)Q.draggable=!1,Z.userSelect=Z.WebkitUserSelect=Z.WebkitTouchCallout="none",Z.touchAction=$.drag===!0?"none":`pan-${$.drag==="x"?"y":"x"}`;if($.tabIndex===void 0&&($.onTap||$.onTapStart||$.whileTap))Q.tabIndex=0;return Q.style=Z,Q}var qE=R(v(),1);var EK=()=>({...qQ(),attrs:{}});function XE($,J,Q,Z){let q=qE.useMemo(()=>{let X=EK();return Aq(X,J,wq(Z),$.transformTemplate,$.style),{...X.attrs,style:{...X.style}}},[J]);if($.style){let X={};V_(X,$.style,$),q.style={...X,...q.style}}return q}var Qs=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Tq($){return $.startsWith("while")||$.startsWith("drag")&&$!=="draggable"||$.startsWith("layout")||$.startsWith("onTap")||$.startsWith("onPan")||$.startsWith("onLayout")||Qs.has($)}var zE=($)=>!Tq($);function Zs($){if(typeof $!=="function")return;zE=(J)=>J.startsWith("on")?!Tq(J):$(J)}try{let $="@emotion/is-prop-valid";Zs(YE($).default)}catch{}function KE($,J,Q){let Z={};for(let q in $){if(q==="values"&&typeof $.values==="object")continue;if(X5($[q]))continue;if(zE(q)||Q===!0&&Tq(q)||!J&&!Tq(q)||$.draggable&&q.startsWith("onDrag"))Z[q]=$[q]}return Z}function GE($,J,Q,{latestValues:Z},q,X=!1,Y){let K=(Y??ZQ($)?XE:ZE)(J,Z,q,$),W=KE(J,typeof $==="string",X),H=$!==XQ.Fragment?{...W,...K,ref:Q}:{},{children:B}=J,U=XQ.useMemo(()=>X5(B)?B.get():B,[B]);return XQ.createElement($,{...H,children:U})}var M_=R(v(),1);var WE=R(v(),1),YQ=WE.createContext(null);var HE=R(v(),1);function BE($){let J=HE.useRef(null);if(J.current===null)J.current=$();return J.current}function qs({scrapeMotionValuesFromProps:$,createRenderState:J},Q,Z,q){return{latestValues:Xs(Q,Z,q,$),renderState:J()}}function Xs($,J,Q,Z){let q={},X=Z($,{});for(let U in X)q[U]=K$(X[U]);let{initial:Y,animate:z}=$,K=u7($),W=Uq($);if(J&&W&&!K&&$.inherit!==!1){if(Y===void 0)Y=J.initial;if(z===void 0)z=J.animate}let H=Q?Q.initial===!1:!1;H=H||Y===!1;let B=H?z:Y;if(B&&typeof B!=="boolean"&&!n4(B)){let U=Array.isArray(B)?B:[B];for(let _=0;_<U.length;_++){let L=e2($,U[_]);if(L){let{transitionEnd:F,transition:V,...M}=L;for(let D in M){let N=M[D];if(Array.isArray(N)){let O=H?N.length-1:0;N=N[O]}if(N!==null)q[D]=N}for(let D in F)q[D]=F[D]}}}return q}var yK=($)=>(J,Q)=>{let Z=M_.useContext(m7),q=M_.useContext(YQ),X=()=>qs($,J,Z,q);return Q?X():BE(X)};var UE=yK({scrapeMotionValuesFromProps:X$,createRenderState:qQ});var _E=yK({scrapeMotionValuesFromProps:kq,createRenderState:EK});var LE={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},FE=!1;function Ys(){if(FE)return;let $={};for(let J in LE)$[J]={isEnabled:(Q)=>LE[J].some((Z)=>!!Q[Z])};Lq($),FE=!0}function PK(){return Ys(),lU()}function VE($){let J=PK();for(let Q in $)J[Q]={...J[Q],...$[Q]};Lq(J)}var ME=Symbol.for("motionComponentSymbol");var H$=R(v(),1);function DE($,J,Q){let Z=H$.useRef(Q);H$.useInsertionEffect(()=>{Z.current=Q});let q=H$.useRef(null);return H$.useCallback((X)=>{if(X)$.onMount?.(X);if(J)X?J.mount(X):J.unmount();let Y=Z.current;if(typeof Y==="function")if(X){let z=Y(X);if(typeof z==="function")q.current=z}else if(q.current)q.current(),q.current=null;else Y(X);else if(Y)Y.current=X},[J])}var Z6=R(v(),1);var NE=R(v(),1),RK=NE.createContext({});function c7($){return $&&typeof $==="object"&&Object.prototype.hasOwnProperty.call($,"current")}var CK=R(v(),1);var OE=typeof window<"u";var AE=OE?CK.useLayoutEffect:CK.useEffect;function wE($,J,Q,Z,q,X){let{visualElement:Y}=Z6.useContext(m7),z=Z6.useContext(TK),K=Z6.useContext(YQ),W=Z6.useContext(bK),H=W.reducedMotion,B=W.skipAnimations,U=Z6.useRef(null),_=Z6.useRef(!1);if(Z=Z||z.renderer,!U.current&&Z){if(U.current=Z($,{visualState:J,parent:Y,props:Q,presenceContext:K,blockInitialAnimation:K?K.initial===!1:!1,reducedMotionConfig:H,skipAnimations:B,isSVG:X}),_.current&&U.current)U.current.manuallyAnimateOnMount=!0}let L=U.current,F=Z6.useContext(RK);if(L&&!L.projection&&q&&(L.type==="html"||L.type==="svg"))zs(U.current,Q,q,F);let V=Z6.useRef(!1);Z6.useInsertionEffect(()=>{if(L&&V.current)L.update(Q,K)});let M=Q[zq],D=Z6.useRef(Boolean(M)&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(M)&&window.MotionHasOptimisedAnimation?.(M));return AE(()=>{if(_.current=!0,!L)return;if(V.current=!0,window.MotionIsMounted=!0,L.updateFeatures(),L.scheduleRenderMicrotask(),D.current&&L.animationState)L.animationState.animateChanges()}),Z6.useEffect(()=>{if(!L)return;if(!D.current&&L.animationState)L.animationState.animateChanges();if(D.current)queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(M)}),D.current=!1;L.enteringChildren=void 0}),L}function zs($,J,Q,Z){let{layoutId:q,layout:X,drag:Y,dragConstraints:z,layoutScroll:K,layoutRoot:W,layoutAnchor:H,layoutCrossfade:B}=J;$.projection=new Q($.latestValues,J["data-framer-portal-id"]?void 0:kE($.parent)),$.projection.setOptions({layoutId:q,layout:X,alwaysMeasureLayout:Boolean(Y)||z&&c7(z),visualElement:$,animationType:typeof X==="string"?X:"both",initialPromotionConfig:Z,crossfade:B,layoutScroll:K,layoutRoot:W,layoutAnchor:H})}function kE($){if(!$)return;return $.options.allowProjection!==!1?$.projection:kE($.parent)}function SK($,{forwardMotionProps:J=!1,type:Q}={},Z,q){Z&&VE(Z);let X=Q?Q==="svg":ZQ($),Y=X?_E:UE;function z(W,H){let B,U={...zQ.useContext(bK),...W,layoutId:Ks(W)},{isStatic:_}=U,L=JE(W),F=Y(W,_);if(!_&&typeof window<"u"){Gs(U,Z);let V=Ws(U);B=V.MeasureLayout,L.visualElement=wE($,F,U,q,V.ProjectionNode,X)}return T(m7.Provider,{value:L,children:[B&&L.visualElement?G(B,{visualElement:L.visualElement,...U}):null,GE($,W,DE(F,L.visualElement,H),F,_,J,X)]})}z.displayName=`motion.${typeof $==="string"?$:`create(${$.displayName??$.name??""})`}`;let K=zQ.forwardRef(z);return K[ME]=$,K}function Ks({layoutId:$}){let J=zQ.useContext(IK).id;return J&&$!==void 0?J+"-"+$:$}function Gs($,J){let Q=zQ.useContext(TK).strict}function Ws($){let J=PK(),{drag:Q,layout:Z}=J;if(!Q&&!Z)return{};let q={...Q,...Z};return{MeasureLayout:Q?.isEnabled($)||Z?.isEnabled($)?q.MeasureLayout:void 0,ProjectionNode:q.ProjectionNode}}function IE($,J){if(typeof Proxy>"u")return SK;let Q=new Map,Z=(X,Y)=>{return SK(X,Y,$,J)};return new Proxy((X,Y)=>{return Z(X,Y)},{get:(X,Y)=>{if(Y==="create")return Z;if(!Q.has(Y))Q.set(Y,SK(Y,void 0,$,J));return Q.get(Y)}})}class D_ extends I8{constructor($){super($);$.animationState||($.animationState=J_($))}updateAnimationControlsSubscription(){let{animate:$}=this.node.getProps();if(n4($))this.unmountControls=$.subscribe(this.node)}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:$}=this.node.getProps(),{animate:J}=this.node.prevProps||{};if($!==J)this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}var Hs=0;class N_ extends I8{constructor(){super(...arguments);this.id=Hs++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:$,onExitComplete:J}=this.node.presenceContext,{isPresent:Q}=this.node.prevPresenceContext||{};if(!this.node.animationState||$===Q)return;if($&&Q===!1){if(this.isExitComplete){let{initial:q,custom:X}=this.node.getProps();if(typeof q==="string"||typeof q==="object"&&q!==null&&!Array.isArray(q)){let Y=C6(this.node,q,X);if(Y){let{transition:z,transitionEnd:K,...W}=Y;for(let H in W)this.node.getValue(H)?.jump(W[H])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}let Z=this.node.animationState.setActive("exit",!$);if(J&&!$)Z.then(()=>{this.isExitComplete=!0,J(this.id)})}mount(){let{register:$,onExitComplete:J}=this.node.presenceContext||{};if(J)J(this.id);if($)this.unmount=$(this.id)}unmount(){}}var TE={animation:{Feature:D_},exit:{Feature:N_}};function t4($){return{point:{x:$.pageX,y:$.pageY}}}var bE=($)=>(J)=>Q$(J)&&$(J,t4(J));function d7($,J,Q,Z){return B4($,J,bE(Q),Z)}var hK=({current:$})=>{return $?$.ownerDocument.defaultView:null};var jE=($,J)=>Math.abs($-J);function EE($,J){let Q=jE($.x,J.x),Z=jE($.y,J.y);return Math.sqrt(Q**2+Z**2)}var yE=new Set(["auto","scroll"]);class bq{constructor($,J,{transformPagePoint:Q,contextWindow:Z=window,dragSnapToOrigin:q=!1,distanceThreshold:X=3,element:Y}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=(_)=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;if(this.lastRawMoveEventInfo)this.lastMoveEventInfo=xK(this.lastRawMoveEventInfo,this.transformPagePoint);let _=O_(this.lastMoveEventInfo,this.history),L=this.startEvent!==null,F=EE(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!L&&!F)return;let{point:V}=_,{timestamp:M}=S5;this.history.push({...V,timestamp:M});let{onStart:D,onMove:N}=this.handlers;if(!L)D&&D(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent;N&&N(this.lastMoveEvent,_)},this.handlePointerMove=(_,L)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=L,this.lastMoveEventInfo=xK(L,this.transformPagePoint),I1.update(this.updatePoint,!0)},this.handlePointerUp=(_,L)=>{this.end();let{onEnd:F,onSessionEnd:V,resumeAnimation:M}=this.handlers;if(this.dragSnapToOrigin||!this.startEvent)M&&M();if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let D=O_(_.type==="pointercancel"?this.lastMoveEventInfo:xK(L,this.transformPagePoint),this.history);if(this.startEvent&&F)F(_,D);V&&V(_,D)},!Q$($))return;this.dragSnapToOrigin=q,this.handlers=J,this.transformPagePoint=Q,this.distanceThreshold=X,this.contextWindow=Z||window;let z=t4($),K=xK(z,this.transformPagePoint),{point:W}=K,{timestamp:H}=S5;this.history=[{...W,timestamp:H}];let{onSessionStart:B}=J;B&&B($,O_(K,this.history));let U={passive:!0,capture:!0};if(this.removeListeners=h9(d7(this.contextWindow,"pointermove",this.handlePointerMove,U),d7(this.contextWindow,"pointerup",this.handlePointerUp,U),d7(this.contextWindow,"pointercancel",this.handlePointerUp,U)),Y)this.startScrollTracking(Y)}startScrollTracking($){let J=$.parentElement;while(J){let Q=getComputedStyle(J);if(yE.has(Q.overflowX)||yE.has(Q.overflowY))this.scrollPositions.set(J,{x:J.scrollLeft,y:J.scrollTop});J=J.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll($){let J=this.scrollPositions.get($);if(!J)return;let Q=$===window,Z=Q?{x:window.scrollX,y:window.scrollY}:{x:$.scrollLeft,y:$.scrollTop},q={x:Z.x-J.x,y:Z.y-J.y};if(q.x===0&&q.y===0)return;if(Q){if(this.lastMoveEventInfo)this.lastMoveEventInfo.point.x+=q.x,this.lastMoveEventInfo.point.y+=q.y}else if(this.history.length>0)this.history[0].x-=q.x,this.history[0].y-=q.y;this.scrollPositions.set($,Z),I1.update(this.updatePoint,!0)}updateHandlers($){this.handlers=$}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),O6(this.updatePoint)}}function xK($,J){return J?{point:J($.point)}:$}function PE($,J){return{x:$.x-J.x,y:$.y-J.y}}function O_({point:$},J){return{point:$,delta:PE($,RE(J)),offset:PE($,Bs(J)),velocity:Us(J,0.1)}}function Bs($){return $[0]}function RE($){return $[$.length-1]}function Us($,J){if($.length<2)return{x:0,y:0};let Q=$.length-1,Z=null,q=RE($);while(Q>=0){if(Z=$[Q],q.timestamp-Z.timestamp>v5(J))break;Q--}if(!Z)return{x:0,y:0};if(Z===$[0]&&$.length>2&&q.timestamp-Z.timestamp>v5(J)*2)Z=$[1];let X=k8(q.timestamp-Z.timestamp);if(X===0)return{x:0,y:0};let Y={x:(q.x-Z.x)/X,y:(q.y-Z.y)/X};if(Y.x===1/0)Y.x=0;if(Y.y===1/0)Y.y=0;return Y}function fE($,{min:J,max:Q},Z){if(J!==void 0&&$<J)$=Z?j1(J,$,Z.min):Math.max($,J);else if(Q!==void 0&&$>Q)$=Z?j1(Q,$,Z.max):Math.min($,Q);return $}function CE($,J,Q){return{min:J!==void 0?$.min+J:void 0,max:Q!==void 0?$.max+Q-($.max-$.min):void 0}}function vE($,{top:J,left:Q,bottom:Z,right:q}){return{x:CE($.x,Q,q),y:CE($.y,J,Z)}}function SE($,J){let Q=J.min-$.min,Z=J.max-$.max;if(J.max-J.min<$.max-$.min)[Q,Z]=[Z,Q];return{min:Q,max:Z}}function gE($,J){return{x:SE($.x,J.x),y:SE($.y,J.y)}}function uE($,J){let Q=0.5,Z=s5($),q=s5(J);if(q>Z)Q=z4(J.min,J.max-Z,$.min);else if(Z>q)Q=z4($.min,$.max-q,J.min);return L8(0,1,Q)}function mE($,J){let Q={};if(J.min!==void 0)Q.min=J.min-$.min;if(J.max!==void 0)Q.max=J.max-$.min;return Q}var fK=0.35;function cE($=fK){if($===!1)$=0;else if($===!0)$=fK;return{x:hE($,"left","right"),y:hE($,"top","bottom")}}function hE($,J,Q){return{min:xE($,J),max:xE($,Q)}}function xE($,J){return typeof $==="number"?$:$[J]||0}var _s=new WeakMap;class A_{constructor($){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=w5(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=$}start($,{snapToCursor:J=!1,distanceThreshold:Q}={}){let{presenceContext:Z}=this.visualElement;if(Z&&Z.isPresent===!1)return;let q=(H)=>{if(J)this.snapToCursor(t4(H).point);this.stopAnimation()},X=(H,B)=>{let{drag:U,dragPropagation:_,onDragStart:L}=this.getProps();if(U&&!_){if(this.openDragLock)this.openDragLock();if(this.openDragLock=xU(U),!this.openDragLock)return}if(this.latestPointerEvent=H,this.latestPanInfo=B,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection)this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0;if(S6((V)=>{let M=this.getAxisMotionValue(V).get()||0;if(c8.test(M)){let{projection:D}=this.visualElement;if(D&&D.layout){let N=D.layout.layoutBox[V];if(N)M=s5(N)*(parseFloat(M)/100)}}this.originPoint[V]=M}),L)I1.update(()=>L(H,B),!1,!0);nJ(this.visualElement,"transform");let{animationState:F}=this.visualElement;F&&F.setActive("whileDrag",!0)},Y=(H,B)=>{this.latestPointerEvent=H,this.latestPanInfo=B;let{dragPropagation:U,dragDirectionLock:_,onDirectionLock:L,onDrag:F}=this.getProps();if(!U&&!this.openDragLock)return;let{offset:V}=B;if(_&&this.currentDirection===null){if(this.currentDirection=Fs(V),this.currentDirection!==null)L&&L(this.currentDirection);return}if(this.updateAxis("x",B.point,V),this.updateAxis("y",B.point,V),this.visualElement.render(),F)I1.update(()=>F(H,B),!1,!0)},z=(H,B)=>{this.latestPointerEvent=H,this.latestPanInfo=B,this.stop(H,B),this.latestPointerEvent=null,this.latestPanInfo=null},K=()=>{let{dragSnapToOrigin:H}=this.getProps();if(H||this.constraints)this.startAnimation({x:0,y:0})},{dragSnapToOrigin:W}=this.getProps();this.panSession=new bq($,{onSessionStart:q,onStart:X,onMove:Y,onSessionEnd:z,resumeAnimation:K},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:W,distanceThreshold:Q,contextWindow:hK(this.visualElement),element:this.visualElement.current})}stop($,J){let Q=$||this.latestPointerEvent,Z=J||this.latestPanInfo,q=this.isDragging;if(this.cancel(),!q||!Z||!Q)return;let{velocity:X}=Z;this.startAnimation(X);let{onDragEnd:Y}=this.getProps();if(Y)I1.postRender(()=>Y(Q,Z))}cancel(){this.isDragging=!1;let{projection:$,animationState:J}=this.visualElement;if($)$.isAnimationBlocked=!1;this.endPanSession();let{dragPropagation:Q}=this.getProps();if(!Q&&this.openDragLock)this.openDragLock(),this.openDragLock=null;J&&J.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis($,J,Q){let{drag:Z}=this.getProps();if(!Q||!vK($,Z,this.currentDirection))return;let q=this.getAxisMotionValue($),X=this.originPoint[$]+Q[$];if(this.constraints&&this.constraints[$])X=fE(X,this.constraints[$],this.elastic[$]);q.set(X)}resolveConstraints(){let{dragConstraints:$,dragElastic:J}=this.getProps(),Q=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,Z=this.constraints;if($&&c7($)){if(!this.constraints)this.constraints=this.resolveRefConstraints()}else if($&&Q)this.constraints=vE(Q.layoutBox,$);else this.constraints=!1;if(this.elastic=cE(J),Z!==this.constraints&&!c7($)&&Q&&this.constraints&&!this.hasMutatedConstraints)S6((q)=>{if(this.constraints!==!1&&this.getAxisMotionValue(q))this.constraints[q]=mE(Q.layoutBox[q],this.constraints[q])})}resolveRefConstraints(){let{dragConstraints:$,onMeasureDragConstraints:J}=this.getProps();if(!$||!c7($))return!1;let Q=$.current;N6(Q!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");let{projection:Z}=this.visualElement;if(!Z||!Z.layout)return!1;if(Z.root)Z.root.scroll=void 0,Z.root.updateScroll();let q=tU(Q,Z.root,this.visualElement.getTransformPagePoint()),X=gE(Z.layout.layoutBox,q);if(J){let Y=J(iU(X));if(this.hasMutatedConstraints=!!Y,Y)X=Vq(Y)}return X}startAnimation($){let{drag:J,dragMomentum:Q,dragElastic:Z,dragTransition:q,dragSnapToOrigin:X,onDragTransitionEnd:Y}=this.getProps(),z=this.constraints||{},K=S6((W)=>{if(!vK(W,J,this.currentDirection))return;let H=z&&z[W]||{};if(X===!0||X===W)H={min:0,max:0};let B=Z?200:1e6,U=Z?40:1e7,_={type:"inertia",velocity:Q?$[W]:0,bounceStiffness:B,bounceDamping:U,timeConstant:750,restDelta:1,restSpeed:10,...q,...H};return this.startAxisValueAnimation(W,_)});return Promise.all(K).then(Y)}startAxisValueAnimation($,J){let Q=this.getAxisMotionValue($);return nJ(this.visualElement,$),Q.start(t2($,Q,0,J,this.visualElement,!1))}stopAnimation(){S6(($)=>this.getAxisMotionValue($).stop())}getAxisMotionValue($){let J=`_drag${$.toUpperCase()}`,Z=this.visualElement.getProps()[J];return Z?Z:this.visualElement.getValue($,this.visualElement.latestValues[$]??0)}snapToCursor($){S6((J)=>{let{drag:Q}=this.getProps();if(!vK(J,Q,this.currentDirection))return;let{projection:Z}=this.visualElement,q=this.getAxisMotionValue(J);if(Z&&Z.layout){let{min:X,max:Y}=Z.layout.layoutBox[J],z=q.get()||0;q.set($[J]-j1(X,Y,0.5)+z)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:$,dragConstraints:J}=this.getProps(),{projection:Q}=this.visualElement;if(!c7(J)||!Q||!this.constraints)return;this.stopAnimation();let Z={x:0,y:0};S6((X)=>{let Y=this.getAxisMotionValue(X);if(Y&&this.constraints!==!1){let z=Y.get();Z[X]=uE({min:z,max:z},this.constraints[X])}});let{transformTemplate:q}=this.visualElement.getProps();this.visualElement.current.style.transform=q?q({},""):"none",Q.root&&Q.root.updateScroll(),Q.updateLayout(),this.constraints=!1,this.resolveConstraints(),S6((X)=>{if(!vK(X,$,null))return;let Y=this.getAxisMotionValue(X),{min:z,max:K}=this.constraints[X];Y.set(j1(z,K,Z[X]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;_s.set(this.visualElement,this);let $=this.visualElement.current,J=d7($,"pointerdown",(K)=>{let{drag:W,dragListener:H=!0}=this.getProps(),B=K.target,U=B!==$&&uU(B);if(W&&H&&!U)this.start(K)}),Q,Z=()=>{let{dragConstraints:K}=this.getProps();if(c7(K)&&K.current){if(this.constraints=this.resolveRefConstraints(),!Q)Q=Ls($,K.current,()=>this.scalePositionWithinConstraints())}},{projection:q}=this.visualElement,X=q.addEventListener("measure",Z);if(q&&!q.layout)q.root&&q.root.updateScroll(),q.updateLayout();I1.read(Z);let Y=B4(window,"resize",()=>this.scalePositionWithinConstraints()),z=q.addEventListener("didUpdate",({delta:K,hasLayoutChanged:W})=>{if(this.isDragging&&W)S6((H)=>{let B=this.getAxisMotionValue(H);if(!B)return;this.originPoint[H]+=K[H].translate,B.set(B.get()+K[H].translate)}),this.visualElement.render()});return()=>{Y(),J(),X(),z&&z(),Q&&Q()}}getProps(){let $=this.visualElement.getProps(),{drag:J=!1,dragDirectionLock:Q=!1,dragPropagation:Z=!1,dragConstraints:q=!1,dragElastic:X=fK,dragMomentum:Y=!0}=$;return{...$,drag:J,dragDirectionLock:Q,dragPropagation:Z,dragConstraints:q,dragElastic:X,dragMomentum:Y}}}function dE($){let J=!0;return()=>{if(J){J=!1;return}$()}}function Ls($,J,Q){let Z=HK($,dE(Q)),q=HK(J,dE(Q));return()=>{Z(),q()}}function vK($,J,Q){return(J===!0||J===$)&&(Q===null||Q===$)}function Fs($,J=10){let Q=null;if(Math.abs($.y)>J)Q="y";else if(Math.abs($.x)>J)Q="x";return Q}class w_ extends I8{constructor($){super($);this.removeGroupControls=j5,this.removeListeners=j5,this.controls=new A_($)}mount(){let{dragControls:$}=this.node.getProps();if($)this.removeGroupControls=$.subscribe(this.controls);this.removeListeners=this.controls.addListeners()||j5}update(){let{dragControls:$}=this.node.getProps(),{dragControls:J}=this.node.prevProps||{};if($!==J){if(this.removeGroupControls(),$)this.removeGroupControls=$.subscribe(this.controls)}}unmount(){if(this.removeGroupControls(),this.removeListeners(),!this.controls.isDragging)this.controls.endPanSession()}}var k_=($)=>(J,Q)=>{if($)I1.update(()=>$(J,Q),!1,!0)};class I_ extends I8{constructor(){super(...arguments);this.removePointerDownListener=j5}onPointerDown($){this.session=new bq($,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:hK(this.node)})}createPanHandlers(){let{onPanSessionStart:$,onPanStart:J,onPan:Q,onPanEnd:Z}=this.node.getProps();return{onSessionStart:k_($),onStart:k_(J),onMove:k_(Q),onEnd:(q,X)=>{if(delete this.session,Z)I1.postRender(()=>Z(q,X))}}}mount(){this.removePointerDownListener=d7(this.node.current,"pointerdown",($)=>this.onPointerDown($))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}var jq=R(v(),1);var p7=R(v(),1);function pE($=!0){let J=p7.useContext(YQ);if(J===null)return[!0,null];let{isPresent:Q,onExitComplete:Z,register:q}=J,X=p7.useId();p7.useEffect(()=>{if($)return q(X)},[$]);let Y=p7.useCallback(()=>$&&Z&&Z(X),[X,Z,$]);return!Q&&Z?[!1,Y]:[!0]}var T_=!1;class lE extends jq.Component{componentDidMount(){let{visualElement:$,layoutGroup:J,switchLayoutGroup:Q,layoutId:Z}=this.props,{projection:q}=$;if(q){if(J.group)J.group.add(q);if(Q&&Q.register&&Z)Q.register(q);if(T_)q.root.didUpdate();q.addEventListener("animationComplete",()=>{this.safeToRemove()}),q.setOptions({...q.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})}G$.hasEverUpdated=!0}getSnapshotBeforeUpdate($){let{layoutDependency:J,visualElement:Q,drag:Z,isPresent:q}=this.props,{projection:X}=Q;if(!X)return null;if(X.isPresent=q,$.layoutDependency!==J)X.setOptions({...X.options,layoutDependency:J});if(T_=!0,Z||$.layoutDependency!==J||J===void 0||$.isPresent!==q)X.willUpdate();else this.safeToRemove();if($.isPresent!==q){if(q)X.promote();else if(!X.relegate())I1.postRender(()=>{let Y=X.getStack();if(!Y||!Y.members.length)this.safeToRemove()})}return null}componentDidUpdate(){let{visualElement:$,layoutAnchor:J}=this.props,{projection:Q}=$;if(Q)Q.options.layoutAnchor=J,Q.root.didUpdate(),J$.postRender(()=>{if(!Q.currentAnimation&&Q.isLead())this.safeToRemove()})}componentWillUnmount(){let{visualElement:$,layoutGroup:J,switchLayoutGroup:Q}=this.props,{projection:Z}=$;if(T_=!0,Z){if(Z.scheduleCheckAfterUnmount(),J&&J.group)J.group.remove(Z);if(Q&&Q.deregister)Q.deregister(Z)}}safeToRemove(){let{safeToRemove:$}=this.props;$&&$()}render(){return null}}function gK($){let[J,Q]=pE(),Z=jq.useContext(IK);return G(lE,{...$,layoutGroup:Z,switchLayoutGroup:jq.useContext(RK),isPresent:J,safeToRemove:Q})}var iE={pan:{Feature:I_},drag:{Feature:w_,ProjectionNode:Iq,MeasureLayout:gK}};function rE($,J,Q){let{props:Z}=$;if($.animationState&&Z.whileHover)$.animationState.setActive("whileHover",Q==="Start");let q="onHover"+Q,X=Z[q];if(X)I1.postRender(()=>X(J,t4(J)))}class b_ extends I8{mount(){let{current:$}=this.node;if(!$)return;this.unmount=fU($,(J,Q)=>{return rE(this.node,Q,"Start"),(Z)=>rE(this.node,Z,"End")})}unmount(){}}class j_ extends I8{constructor(){super(...arguments);this.isActive=!1}onFocus(){let $=!1;try{$=this.node.current.matches(":focus-visible")}catch(J){$=!0}if(!$||!this.node.animationState)return;this.node.animationState.setActive("whileFocus",!0),this.isActive=!0}onBlur(){if(!this.isActive||!this.node.animationState)return;this.node.animationState.setActive("whileFocus",!1),this.isActive=!1}mount(){this.unmount=h9(B4(this.node.current,"focus",()=>this.onFocus()),B4(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function sE($,J,Q){let{props:Z}=$;if($.current instanceof HTMLButtonElement&&$.current.disabled)return;if($.animationState&&Z.whileTap)$.animationState.setActive("whileTap",Q==="Start");let q="onTap"+(Q==="End"?"":Q),X=Z[q];if(X)I1.postRender(()=>X(J,t4(J)))}class E_ extends I8{mount(){let{current:$}=this.node;if(!$)return;let{globalTapTarget:J,propagate:Q}=this.node.props;this.unmount=cU($,(Z,q)=>{return sE(this.node,q,"Start"),(X,{success:Y})=>sE(this.node,X,Y?"End":"Cancel")},{useGlobalTarget:J,stopPropagation:Q?.tap===!1})}unmount(){}}var P_=new WeakMap,y_=new WeakMap,Vs=($)=>{let J=P_.get($.target);J&&J($)},Ms=($)=>{$.forEach(Vs)};function Ds({root:$,...J}){let Q=$||document;if(!y_.has(Q))y_.set(Q,{});let Z=y_.get(Q),q=JSON.stringify(J);if(!Z[q])Z[q]=new IntersectionObserver(Ms,{root:$,...J});return Z[q]}function oE($,J,Q){let Z=Ds(J);return P_.set($,Q),Z.observe($),()=>{P_.delete($),Z.unobserve($)}}var Ns={some:0,all:1};class R_ extends I8{constructor(){super(...arguments);this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:$={}}=this.node.getProps(),{root:J,margin:Q,amount:Z="some",once:q}=$,X={root:J?J.current:void 0,rootMargin:Q,threshold:typeof Z==="number"?Z:Ns[Z]},Y=(z)=>{let{isIntersecting:K}=z;if(this.isInView===K)return;if(this.isInView=K,q&&!K&&this.hasEnteredView)return;else if(K)this.hasEnteredView=!0;if(this.node.animationState)this.node.animationState.setActive("whileInView",K);let{onViewportEnter:W,onViewportLeave:H}=this.node.getProps(),B=K?W:H;B&&B(z)};this.stopObserver=oE(this.node.current,X,Y)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;let{props:$,prevProps:J}=this.node;if(["amount","margin","root"].some(Os($,J)))this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function Os({viewport:$={}},{viewport:J={}}={}){return(Q)=>$[Q]!==J[Q]}var nE={inView:{Feature:R_},tap:{Feature:E_},focus:{Feature:j_},hover:{Feature:b_}};var aE={layout:{ProjectionNode:Iq,MeasureLayout:gK}};var tE={...TE,...nE,...iE,...aE};var Eq=IE(tE,sj);var Z2={};e4(Z2,{createHandle:()=>AR,Viewport:()=>OR,Trigger:()=>hP,Title:()=>KR,Root:()=>bP,Positioner:()=>aP,Portal:()=>vP,Popup:()=>QR,Handle:()=>pG,Description:()=>WR,Close:()=>BR,Backdrop:()=>YR,Arrow:()=>qR});var q7=R(v(),1);function d1(){}var B$=Object.freeze([]),T1=Object.freeze({});var p8=R(v(),1);function U1($,J,Q,Z){return $.addEventListener(J,Q,Z),()=>{$.removeEventListener(J,Q,Z)}}function T8(...$){return()=>{for(let J=0;J<$.length;J+=1){let Q=$[J];if(Q)Q()}}}var $y=R(v(),1),eE={};function W5($,J){let Q=$y.useRef(eE);if(Q.current===eE)Q.current=$(J);return Q}function L9($,J,Q,Z){let q=W5(Qy).current;if(As(q,$,J,Q,Z))Zy(q,[$,J,Q,Z]);return q.callback}function Jy($){let J=W5(Qy).current;if(ws(J,$))Zy(J,$);return J.callback}function Qy(){return{callback:null,cleanup:null,refs:[]}}function As($,J,Q,Z,q){return $.refs[0]!==J||$.refs[1]!==Q||$.refs[2]!==Z||$.refs[3]!==q}function ws($,J){return $.refs.length!==J.length||$.refs.some((Q,Z)=>Q!==J[Z])}function Zy($,J){if($.refs=J,J.every((Q)=>Q==null)){$.callback=null;return}$.callback=(Q)=>{if($.cleanup)$.cleanup(),$.cleanup=null;if(Q!=null){let Z=Array(J.length).fill(null);for(let q=0;q<J.length;q+=1){let X=J[q];if(X==null)continue;switch(typeof X){case"function":{let Y=X(Q);if(typeof Y==="function")Z[q]=Y;break}case"object":{X.current=Q;break}default:}}$.cleanup=()=>{for(let q=0;q<J.length;q+=1){let X=J[q];if(X==null)continue;switch(typeof X){case"function":{let Y=Z[q];if(typeof Y==="function")Y();else X(null);break}case"object":{X.current=null;break}default:}}}}}}var qy=R(v(),1),ks=()=>{},y0=typeof document<"u"?qy.useLayoutEffect:ks;function F5($){let J=W5(Is,$).current;return J.next=$,y0(J.effect),J}function Is($){let J={current:$,next:$,effect:()=>{J.current=J.next}};return J}var Ts=R(v(),1),yq={...Ts};var C_=yq.useInsertionEffect,bs=C_&&C_!==yq.useLayoutEffect?C_:($)=>$();function g0($){let J=W5(js).current;return J.next=$,bs(J.effect),J.trampoline}function js(){let $={next:void 0,callback:Es,trampoline:(...J)=>$.callback?.(...J),effect:()=>{$.callback=$.next}};return $}function Es(){}var Xy=R(v(),1),ys=[];function l7($){Xy.useEffect($,ys)}var Pq=0;class b8{static create(){return new b8}currentId=Pq;start($,J){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Pq,J()},$)}isStarted(){return this.currentId!==Pq}clear=()=>{if(this.currentId!==Pq)clearTimeout(this.currentId),this.currentId=Pq};disposeEffect=()=>{return this.clear}}function U5(){let $=W5(b8.create).current;return l7($.disposeEffect),$}var p1={};e4(p1,{screenReader:()=>g_,os:()=>x_,env:()=>u_,engine:()=>v_});var x_={};e4(x_,{windows:()=>Ss,mac:()=>Gy,linux:()=>hs,ios:()=>S_,apple:()=>h_,android:()=>Ky});function Ps(){if(typeof navigator>"u")return{userAgent:"",platform:"",maxTouchPoints:0};return{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Rs,platform:Cs,maxTouchPoints:Yy}=Ps(),U$=Rs.toLowerCase(),_$=Cs.toLowerCase();var S_=/^i(os$|p)/.test(_$)||_$==="macintel"&&Yy>1,zy="android",Ky=_$===zy||U$.includes(zy),Gy=!S_&&_$.startsWith("mac"),Ss=_$.startsWith("win"),hs=!Ky&&/^(linux|chrome os)/.test(_$),h_=Gy||S_;var v_={};e4(v_,{webkit:()=>f_,gecko:()=>xs,blink:()=>fs});var f_=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none"),xs=!f_&&U$.includes("firefox"),fs=!f_&&U$.includes("chrom");var g_={};e4(g_,{voiceOver:()=>vs});var vs=h_;var u_={};e4(u_,{jsdom:()=>gs});var gs=/jsdom|happydom/.test(U$);var uK=null,yA0=globalThis.requestAnimationFrame;class Wy{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=($)=>{this.isScheduled=!1;let J=this.callbacks,Q=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,Q>0)for(let Z=0;Z<J.length;Z+=1)J[Z]?.($)};request($){let J=this.nextId;this.nextId+=1,this.callbacks.push($),this.callbacksCount+=1;let Q=!1;if(!this.isScheduled||Q)requestAnimationFrame(this.tick),this.isScheduled=!0;return J}cancel($){let J=$-this.startId;if(J<0||J>=this.callbacks.length)return;this.callbacks[J]=null,this.callbacksCount-=1}}var mK=new Wy;class F9{static create(){return new F9}static request($){return mK.request($)}static cancel($){return mK.cancel($)}currentId=uK;request($){this.cancel(),this.currentId=mK.request(()=>{this.currentId=uK,$()})}cancel=()=>{if(this.currentId!==uK)mK.cancel(this.currentId),this.currentId=uK};disposeEffect=()=>{return this.cancel}}function h6(){let $=W5(F9.create).current;return l7($.disposeEffect),$}function X1($){return $?.ownerDocument||document}var dK=R(v(),1);var Hy={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},cK={...Hy,position:"fixed",top:0,left:0},By={...Hy,position:"absolute"};var V9=dK.forwardRef(function(J,Q){let[Z,q]=dK.useState();return y0(()=>{if(p1.screenReader.voiceOver&&p1.engine.webkit)q("button")},[]),G("span",{...J,ref:Q,style:cK,"aria-hidden":Z?void 0:!0,...{tabIndex:0,role:Z},"data-base-ui-focus-guard":""})});var Rq="data-base-ui-focusable";var m_="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Cq="ArrowLeft",Sq="ArrowRight",c_="ArrowUp",pK="ArrowDown";function g5($){let J=$.activeElement;while(J?.shadowRoot?.activeElement!=null)J=J.shadowRoot.activeElement;return J}function e0($,J){if(!$||!J)return!1;let Q=J.getRootNode?.();if($.contains(J))return!0;if(Q&&r9(Q)){let Z=J;while(Z){if($===Z)return!0;Z=Z.parentNode||Z.host}}return!1}function k5($){if("composedPath"in $)return $.composedPath()[0];return $.target}function i7($,J){if(!L1($))return!1;let Q=$;if(J.hasElement(Q))return!Q.hasAttribute("data-trigger-disabled");for(let[,Z]of J.entries())if(e0(Z,Q))return!Z.hasAttribute("data-trigger-disabled");return!1}function lK($,J){if(J==null)return!1;if("composedPath"in $)return $.composedPath().includes(J);let Q=$;return Q.target!=null&&J.contains(Q.target)}function Uy($){return $.matches("html,body")}function L$($){return P1($)&&$.matches(m_)}function d_($){return $?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${m_}`)!=null}function hq($){if(!$)return!1;return $.getAttribute("role")==="combobox"&&L$($)}function _y($){if(!$||p1.env.jsdom)return!0;try{return $.matches(":focus-visible")}catch(J){return!0}}function xq($){if(!$)return null;return $.hasAttribute(Rq)?$:$.querySelector(`[${Rq}]`)||$}function q6($){$.preventDefault(),$.stopPropagation()}function Ly($){return"nativeEvent"in $}function iK($){if($.pointerType===""&&$.isTrusted)return!0;if(p1.os.android&&$.pointerType)return $.type==="click"&&$.buttons===1;return $.detail===0&&!$.pointerType}function rK($){if(p1.env.jsdom)return!1;return!p1.os.android&&$.width===0&&$.height===0||p1.os.android&&$.width===1&&$.height===1&&$.pressure===0&&$.detail===0&&$.pointerType==="mouse"||$.width<1&&$.height<1&&$.pressure===0&&$.detail===0&&$.pointerType==="touch"}function r7($,J){let Q=["mouse","pen"];if(!J)Q.push("",void 0);return Q.includes($)}function Fy($){let J=$.type;return J==="click"||J==="mousedown"||J==="keydown"||J==="keyup"}function p_($,J){return J<0||J>=$.length}function sK($,J){return F$($.current,{disabledIndices:J})}function l_($,J){return F$($.current,{decrement:!0,startingIndex:$.current.length,disabledIndices:J})}function F$($,{startingIndex:J=-1,decrement:Q=!1,disabledIndices:Z,amount:q=1}={}){let X=J;do X+=Q?-q:q;while(X>=0&&X<=$.length-1&&i_($,X,Z));return X}function i_($,J,Q){if(typeof Q==="function"?Q(J):Q?.includes(J)??!1)return!0;let q=$[J];if(!q)return!1;if(!V$(q))return!0;return!Q&&(q.hasAttribute("disabled")||q.getAttribute("aria-disabled")==="true")}function us($){return $.visibility==="hidden"||$.visibility==="collapse"}function V$($,J=$?p5($):null){if(!$||!$.isConnected||!J||us(J))return!1;if(typeof $.checkVisibility==="function")return $.checkVisibility();return J.display!=="none"&&J.display!=="contents"}var ms='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function cs($){let J=$.assignedSlot;if(J)return J;if($.parentElement)return $.parentElement;let Q=$.getRootNode();return r9(Q)?Q.host:null}function s_($){for(let J of Array.from($.children))if(f5(J)==="summary")return J;return null}function ds($,J){let Q=s_(J);return!!Q&&($===Q||e0(Q,$))}function Vy($){let J=$?f5($):"";return $!=null&&$.matches(ms)&&(J!=="summary"||$.parentElement!=null&&f5($.parentElement)==="details"&&s_($.parentElement)===$)&&(J!=="details"||s_($)==null)&&(J!=="input"||$.type!=="hidden")}function My($){if(!Vy($)||!$.isConnected||$.matches(":disabled"))return!1;for(let J=$;J;J=cs(J)){let Q=J!==$,Z=f5(J)==="slot";if(J.hasAttribute("inert"))return!1;if(Q&&f5(J)==="details"&&!J.open&&!ds($,J)||J.hasAttribute("hidden")||!Z&&!ps(J,Q))return!1}return!0}function ps($,J){let Q=p5($);if(!J)return V$($,Q);return Q.display!=="none"}function Dy($){let J=$.tabIndex;if(J<0){let Q=f5($);if(Q==="details"||Q==="audio"||Q==="video"||P1($)&&$.isContentEditable)return 0}return J}function r_($){if(f5($)!=="input")return null;let J=$;return J.type==="radio"&&J.name!==""?J:null}function ls($,J){let Q=r_($);if(!Q)return!0;let Z=J.find((q)=>{let X=r_(q);return X?.name===Q.name&&X.form===Q.form&&X.checked});if(Z)return Z===Q;return J.find((q)=>{let X=r_(q);return X?.name===Q.name&&X.form===Q.form})===Q}function Ny($){if(P1($)&&f5($)==="slot"){let J=$.assignedElements({flatten:!0});if(J.length>0)return J}if(P1($)&&$.shadowRoot)return Array.from($.shadowRoot.children);return Array.from($.children)}function Oy($,J){Ny($).forEach((Q)=>{if(Vy(Q))J.push(Q);Oy(Q,J)})}function Ay($,J,Q){Ny($).forEach((Z)=>{if(P1(Z)&&Z.matches(J))Q.push(Z);Ay(Z,J,Q)})}function oK($){return My($)&&Dy($)>=0}function o_($){let J=[];return Oy($,J),J.filter(My)}function KQ($){let J=o_($);return J.filter((Q)=>Dy(Q)>=0&&ls(Q,J))}function wy($,J){let Q=KQ($),Z=Q.length;if(Z===0)return;let q=g5(X1($)),X=Q.indexOf(q),Y=X===-1?J===1?0:Z-1:X+J;return Q[Y]}function GQ($){return wy(X1($).body,1)||$}function nK($){return wy(X1($).body,-1)||$}function ky($,J){if(!$)return null;let Q=KQ(X1($).body),Z=Q.length;if(Z===0)return null;let q=Q.indexOf($);if(q===-1)return null;let X=(q+J+Z)%Z;return Q[X]}function Iy($){return ky($,1)}function Ty($){return ky($,-1)}function $7($,J){let Q=J||$.currentTarget,Z=$.relatedTarget;return!Z||!e0(Q,Z)}function by($){KQ($).forEach((Q)=>{Q.dataset.tabindex=Q.getAttribute("tabindex")||"",Q.setAttribute("tabindex","-1")})}function n_($){let J=[];Ay($,"[data-tabindex]",J),J.forEach((Q)=>{let Z=Q.dataset.tabindex;if(delete Q.dataset.tabindex,Z)Q.setAttribute("tabindex",Z);else Q.removeAttribute("tabindex")})}function M9($,J,Q=!0){return $.filter((q)=>q.parentId===J).flatMap((q)=>[...!Q||q.context?.open?[q]:[],...M9($,q.id,Q)])}function a_($,J){let Q=[],Z=$.find((q)=>q.id===J)?.parentId;while(Z){let q=$.find((X)=>X.id===Z);if(Z=q?.parentId,q)Q=Q.concat(q)}return Q}var T0={};e4(T0,{windowResize:()=>To,wheel:()=>Vo,triggerPress:()=>rs,triggerHover:()=>ss,triggerFocus:()=>os,trackPress:()=>Qo,swipe:()=>Io,siblingOpen:()=>No,scrub:()=>Mo,pointer:()=>Lo,outsidePress:()=>ns,none:()=>is,missing:()=>Ao,listNavigation:()=>Uo,linkPress:()=>es,keyboard:()=>_o,itemPress:()=>as,inputPress:()=>Go,inputPaste:()=>Ko,inputClear:()=>Yo,inputChange:()=>Xo,inputBlur:()=>zo,initial:()=>wo,incrementPress:()=>Zo,imperativeAction:()=>ko,focusOut:()=>Wo,escapeKey:()=>Ho,drag:()=>Fo,disabled:()=>Oo,decrementPress:()=>qo,closeWatcher:()=>Bo,closePress:()=>ts,clearPress:()=>$o,chipRemovePress:()=>Jo,cancelOpen:()=>Do});var is="none",rs="trigger-press",ss="trigger-hover",os="trigger-focus",ns="outside-press",as="item-press",ts="close-press",es="link-press",$o="clear-press",Jo="chip-remove-press",Qo="track-press",Zo="increment-press",qo="decrement-press",Xo="input-change",Yo="input-clear",zo="input-blur",Ko="input-paste",Go="input-press",Wo="focus-out",Ho="escape-key",Bo="close-watcher",Uo="list-navigation",_o="keyboard",Lo="pointer",Fo="drag",Vo="wheel",Mo="scrub",Do="cancel-open",No="sibling-open",Oo="disabled",Ao="missing",wo="initial",ko="imperative-action",Io="swipe",To="window-resize";function p0($,J,Q,Z){let q=!1,X=!1,Y=Z??T1;return{reason:$,event:J??new Event("base-ui"),cancel(){q=!0},allowPropagation(){X=!0},get isCanceled(){return q},get isPropagationAllowed(){return X},trigger:Q,...Y}}function f9($,J,Q){let Z=Q??T1;return{reason:$,event:J??new Event("base-ui"),...Z}}function J7($){return`data-base-ui-${$}`}var aK=0;function WQ($,J={}){let{preventScroll:Q=!1,sync:Z=!1,shouldFocus:q}=J;cancelAnimationFrame(aK);function X(){if(q&&!q())return;$?.focus({preventScroll:Q})}if(Z)return X(),d1;let Y=requestAnimationFrame(X);return aK=Y,()=>{if(aK===Y)cancelAnimationFrame(Y),aK=0}}var t_={inert:new WeakMap,"aria-hidden":new WeakMap},jy="data-base-ui-inert",$L={inert:new WeakSet,"aria-hidden":new WeakSet},fq=new WeakMap,e_=0;function bo($){return $L[$]}function Ry($){if(!$)return null;return r9($)?$.host:Ry($.parentNode)}var Ey=($,J)=>J.map((Q)=>{if($.contains(Q))return Q;let Z=Ry(Q);if($.contains(Z))return Z;return null}).filter((Q)=>Q!=null),yy=($)=>{let J=new Set;return $.forEach((Q)=>{let Z=Q;while(Z&&!J.has(Z))J.add(Z),Z=Z.parentNode}),J},Py=($,J,Q)=>{let Z=[],q=(X)=>{if(!X||Q.has(X))return;Array.from(X.children).forEach((Y)=>{if(f5(Y)==="script")return;if(J.has(Y))q(Y);else Z.push(Y)})};return q($),Z};function jo($,J,Q,Z,{mark:q=!0}){let X=null;if(Z)X="inert";else if(Q)X="aria-hidden";let Y=null,z=null,K=Ey(J,$),W=q?Py(J,yy(K),new Set(K)):[],H=[],B=[];if(X){let U=t_[X],_=bo(X);z=_,Y=U;let L=Ey(J,Array.from(J.querySelectorAll("[aria-live]"))),F=K.concat(L);Py(J,yy(F),new Set(F)).forEach((M)=>{let D=M.getAttribute(X),N=D!==null&&D!=="false",O=(U.get(M)||0)+1;if(U.set(M,O),H.push(M),O===1&&N)_.add(M);if(!N)M.setAttribute(X,X==="inert"?"":"true")})}if(q)W.forEach((U)=>{let _=(fq.get(U)||0)+1;if(fq.set(U,_),B.push(U),_===1)U.setAttribute(jy,"")});return e_+=1,()=>{if(Y)H.forEach((U)=>{let L=(Y.get(U)||0)-1;if(Y.set(U,L),!L){if(!z?.has(U)&&X)U.removeAttribute(X);z?.delete(U)}});if(q)B.forEach((U)=>{let _=(fq.get(U)||0)-1;if(fq.set(U,_),!_)U.removeAttribute(jy)});if(e_-=1,!e_)t_.inert=new WeakMap,t_["aria-hidden"]=new WeakMap,$L.inert=new WeakSet,$L["aria-hidden"]=new WeakSet,fq=new WeakMap}}function JL($,J={}){let{ariaHidden:Q=!1,inert:Z=!1,mark:q=!0}=J,X=X1($[0]).body;return jo($,X,Q,Z,{mark:q})}var P5=R(v(),1),zL=R(J5(),1);var tK=R(v(),1);var Cy=0;function Eo($,J="mui"){let[Q,Z]=tK.useState($),q=$||Q;return tK.useEffect(()=>{if(Q==null)Cy+=1,Z(`${J}-${Cy}`)},[Q,J]),q}var Sy=yq.useId;function x6($,J){if(Sy!==void 0){let Q=Sy();return $??(J?`${J}-${Q}`:Q)}return Eo($,J)}function yo($,J){return function(Z,...q){let X=new URL($);return X.searchParams.set("code",Z.toString()),q.forEach((Y)=>X.searchParams.append("args[]",Y)),`${J} error #${Z}; visit ${X} for the full message.`}}var Po=yo("https://base-ui.com/production-error","Base UI"),F1=Po;var s7=R(v(),1);var xy=R(v(),1);var hy=R(v(),1),Ro=parseInt(hy.version,10);function HQ($){return Ro>=$}function QL($){if(!xy.isValidElement($))return null;let J=$,Q=J.props;return(HQ(19)?Q?.ref:J.ref)??null}function vq($,J){if($&&!J)return $;if(!$&&J)return J;if($||J)return{...$,...J};return}function fy($,J){let Q={};for(let Z in $){let q=$[Z];if(J?.hasOwnProperty(Z)){let X=J[Z](q);if(X!=null)Object.assign(Q,X);continue}if(q===!0)Q[`data-${Z.toLowerCase()}`]="";else if(q)Q[`data-${Z.toLowerCase()}`]=q.toString()}return Q}function vy($,J){return typeof $==="function"?$(J):$}function gy($,J){return typeof $==="function"?$(J):$}var ZL={};function h8($,J,Q,Z,q){if(!Q&&!Z&&!q&&!$)return eK(J);let X=eK($);if(J)X=gq(X,J);if(Q)X=gq(X,Q);if(Z)X=gq(X,Z);if(q)X=gq(X,q);return X}function uy($){if($.length===0)return ZL;if($.length===1)return eK($[0]);let J=eK($[0]);for(let Q=1;Q<$.length;Q+=1)J=gq(J,$[Q]);return J}function eK($){if(qL($))return{...cy($,ZL)};return Co($)}function gq($,J){if(qL(J))return cy(J,$);return So($,J)}function Co($){let J={...$};for(let Q in J){let Z=J[Q];if(my(Q,Z))J[Q]=dy(Z)}return J}function So($,J){if(!J)return $;for(let Q in J){let Z=J[Q];switch(Q){case"style":{$[Q]=vq($.style,Z);break}case"className":{$[Q]=XL($.className,Z);break}default:if(my(Q,Z))$[Q]=ho($[Q],Z);else $[Q]=Z}}return $}function my($,J){let Q=$.charCodeAt(0),Z=$.charCodeAt(1),q=$.charCodeAt(2);return Q===111&&Z===110&&q>=65&&q<=90&&(typeof J==="function"||typeof J>"u")}function qL($){return typeof $==="function"}function cy($,J){if(qL($))return $(J);return $??ZL}function ho($,J){if(!J)return $;if(!$)return dy(J);return(...Q)=>{let Z=Q[0];if(py(Z)){let X=Z;uq(X);let Y=J(...Q);if(!X.baseUIHandlerPrevented)$?.(...Q);return Y}let q=J(...Q);return $?.(...Q),q}}function dy($){if(!$)return $;return(...J)=>{let Q=J[0];if(py(Q))uq(Q);return $(...J)}}function uq($){return $.preventBaseUIHandler=()=>{$.baseUIHandlerPrevented=!0},$}function XL($,J){if(J){if($)return J+" "+$;return J}return $}function py($){return $!=null&&typeof $==="object"&&"nativeEvent"in $}var YL=R(v(),1);function o0($,J,Q={}){let Z=J.render,q=xo(J,Q);if(Q.enabled===!1)return null;let X=Q.state??T1;return go($,Z,q,X)}function xo($,J={}){let{className:Q,style:Z,render:q}=$,{state:X=T1,ref:Y,props:z,stateAttributesMapping:K,enabled:W=!0}=J,H=W?vy(Q,X):void 0,B=W?gy(Z,X):void 0,U=W?fy(X,K):T1,_=W&&z?fo(z):void 0,L=W?vq(U,_)??{}:T1;if(typeof document<"u")if(!W)L9(null,null);else if(Array.isArray(Y))L.ref=Jy([L.ref,QL(q),...Y]);else L.ref=L9(L.ref,QL(q),Y);if(!W)return T1;if(H!==void 0)L.className=XL(L.className,H);if(B!==void 0)L.style=vq(L.style,B);return L}function fo($){if(Array.isArray($))return uy($);return h8(void 0,$)}var vo=Symbol.for("react.lazy");function go($,J,Q,Z){if(J){if(typeof J==="function")return J(Q,Z);let q=h8(Q,J.props);q.ref=Q.ref;let X=J;if(X?.$$typeof===vo)X=s7.Children.toArray(J)[0];return s7.cloneElement(X,q)}if($){if(typeof $==="string")return uo($,Q)}throw Error(F1(8))}function uo($,J){if($==="button")return YL.createElement("button",{type:"button",...J,key:J.key});if($==="img")return YL.createElement("img",{alt:"",...J,key:J.key});return s7.createElement($,J)}var ly=500,$G=500,iy={style:{transition:"none"}},JG="data-base-ui-click-trigger";var ry={fallbackAxisSide:"none"},QG={fallbackAxisSide:"end"},sy={clipPath:"inset(50%)",position:"fixed",top:0,left:0};var oy=P5.createContext(null),KL=()=>P5.useContext(oy),mo=J7("portal");function ny($={}){let{ref:J,container:Q,componentProps:Z=T1,elementProps:q}=$,X=x6(),z=KL()?.portalNode,[K,W]=P5.useState(null),[H,B]=P5.useState(null),U=g0((V)=>{if(V!==null)B(V)}),_=P5.useRef(null);y0(()=>{if(Q===null){if(_.current)_.current=null,B(null),W(null);return}if(X==null)return;let V=(Q&&(NX(Q)?Q:Q.current))??z??document.body;if(V==null){if(_.current)_.current=null,B(null),W(null);return}if(_.current!==V)_.current=V,B(null),W(V)},[Q,z,X]);let L=o0("div",Z,{ref:[J,U],props:[{id:X,[mo]:""},q]});return{portalNode:H,portalSubtree:K&&L?zL.createPortal(L,K):null}}var mq=P5.forwardRef(function(J,Q){let{render:Z,className:q,style:X,children:Y,container:z,renderGuards:K,...W}=J,{portalNode:H,portalSubtree:B}=ny({container:z,ref:Q,componentProps:J,elementProps:W}),U=P5.useRef(null),_=P5.useRef(null),L=P5.useRef(null),F=P5.useRef(null),[V,M]=P5.useState(null),D=P5.useRef(!1),N=V?.modal,O=V?.open,I=typeof K==="boolean"?K:!!V&&!V.modal&&V.open&&!!H;P5.useEffect(()=>{if(!H||N)return;function b(k){if(H&&k.relatedTarget&&$7(k))if(k.type==="focusin"){if(D.current)n_(H),D.current=!1}else by(H),D.current=!0}return T8(U1(H,"focusin",b,!0),U1(H,"focusout",b,!0))},[H,N]),y0(()=>{if(!H||O!==!0||!D.current)return;n_(H),D.current=!1},[O,H]);let A=P5.useMemo(()=>({beforeOutsideRef:U,afterOutsideRef:_,beforeInsideRef:L,afterInsideRef:F,portalNode:H,setFocusManagerState:M}),[H]);return T(P5.Fragment,{children:[B,T(oy.Provider,{value:A,children:[I&&H&&G(V9,{"data-type":"outside",ref:U,onFocus:(b)=>{if($7(b,H))L.current?.focus();else{let k=V?V.domReference:null;nK(k)?.focus()}}}),I&&H&&G("span",{"aria-owns":H.id,style:sy}),H&&zL.createPortal(Y,H),I&&H&&G(V9,{"data-type":"outside",ref:_,onFocus:(b)=>{if($7(b,H))F.current?.focus();else{let k=V?V.domReference:null;if(GQ(k)?.focus(),V?.closeOnFocusOut)V?.onOpenChange(!1,p0(T0.focusOut,b.nativeEvent))}}})]})]})});var o7=R(v(),1);function ZG(){let $=new Map;return{emit(J,Q){$.get(J)?.forEach((Z)=>Z(Q))},on(J,Q){if(!$.has(J))$.set(J,new Set);$.get(J).add(Q)},off(J,Q){$.get(J)?.delete(Q)}}}class M${nodesRef={current:[]};events=ZG();addNode($){this.nodesRef.current.push($)}removeNode($){let J=this.nodesRef.current.findIndex((Q)=>Q===$);if(J!==-1)this.nodesRef.current.splice(J,1)}}var ay=o7.createContext(null),ty=o7.createContext(null),x8=()=>o7.useContext(ay)?.id||null,d8=($)=>{let J=o7.useContext(ty);return $??J};function D$($){let J=x6(),Q=d8($),Z=x8();return y0(()=>{if(!J)return;let q={id:J,parentId:Z};return Q?.addNode(q),()=>{Q?.removeNode(q)}},[Q,J,Z]),J}function cq($){let{children:J,id:Q}=$,Z=x8();return G(ay.Provider,{value:o7.useMemo(()=>({id:Q,parentId:Z}),[Q,Z]),children:J})}function dq($){let{children:J,externalTree:Q}=$,Z=W5(()=>Q??new M$).current;return G(ty.Provider,{value:Z,children:J})}function v9($){if($==null)return $;return"current"in $?$.current:$}function co($,J){let Q=h1(k5($));if($ instanceof Q.KeyboardEvent)return"keyboard";if($ instanceof Q.FocusEvent)return J||"keyboard";if("pointerType"in $)return $.pointerType||"keyboard";if("touches"in $)return"touch";if($ instanceof Q.MouseEvent)return J||($.detail===0?"keyboard":"mouse");return""}var ey=20,n7=[];function GL(){n7=n7.filter(($)=>{return $.deref()?.isConnected})}function $P($){if(GL(),$&&f5($)!=="body"){if(n7.push(new WeakRef($)),n7.length>ey)n7=n7.slice(-ey)}}function JP(){return GL(),n7[n7.length-1]?.deref()}function po($){if(!$)return null;if(oK($))return $;return KQ($)[0]||$}function QP($){if($.hasAttribute("tabindex")&&!$.hasAttribute("data-tabindex"))return;if(!$.getAttribute("role")?.includes("dialog"))return;let Q=o_($).filter((q)=>{let X=q.getAttribute("data-tabindex")||"";return oK(q)||q.hasAttribute("data-tabindex")&&!X.startsWith("-")}),Z=$.getAttribute("tabindex");if(Q.length===0){if(Z!=="0")$.setAttribute("tabindex","0"),$.setAttribute("data-tabindex","0")}else if(Z!=="-1"||$.hasAttribute("data-tabindex")&&$.getAttribute("data-tabindex")!=="-1")$.setAttribute("tabindex","-1"),$.setAttribute("data-tabindex","-1")}function pq($){let{context:J,children:Q,disabled:Z=!1,initialFocus:q=!0,returnFocus:X=!0,restoreFocus:Y=!1,modal:z=!0,closeOnFocusOut:K=!0,openInteractionType:W="",nextFocusableElement:H,previousFocusableElement:B,beforeContentFocusGuardRef:U,externalTree:_,getInsideElements:L}=$,F="rootStore"in J?J.rootStore:J,V=F.useState("open"),M=F.useState("domReferenceElement"),D=F.useState("floatingElement"),{events:N,dataRef:O}=F.context,I=g0(()=>O.current.floatingContext?.nodeId),A=q===!1,b=hq(M)&&A,k=F5(q),w=F5(X),C=F5(W),y=F5(V),f=d8(_),j=KL(),P=p8.useRef(!1),x=p8.useRef(!1),p=p8.useRef(!1),t=p8.useRef(null),h=p8.useRef(""),r=p8.useRef(""),$0=p8.useRef(null),Y0=p8.useRef(null),e=L9($0,U,j?.beforeInsideRef),H0=L9(Y0,j?.afterInsideRef),K0=U5(),E=U5(),m=h6(),c=j!=null,i=xq(D),u=g0((S=i)=>{return S?KQ(S):[]}),d=g0(()=>L?.().filter((S)=>S!=null)??[]);p8.useEffect(()=>{if(Z||!z)return;function S(G0){if(G0.key==="Tab"){if(e0(i,g5(X1(i)))&&u().length===0&&!b)q6(G0)}}let s=X1(i);return U1(s,"keydown",S)},[Z,i,z,b,u]),p8.useEffect(()=>{if(Z||!V)return;let S=X1(i);function s(){p.current=!1}function G0(Q0){let J0=k5(Q0),B0=d(),W0=e0(D,J0)||e0(M,J0)||e0(j?.portalNode,J0)||B0.some((L0)=>L0===J0||e0(L0,J0));if(p.current=!W0,r.current=Q0.pointerType||"keyboard",J0?.closest(`[${JG}]`))x.current=!0,E.start(0,()=>{x.current=!1})}function l(){r.current="keyboard"}return T8(U1(S,"pointerdown",G0,!0),U1(S,"pointerup",s,!0),U1(S,"pointercancel",s,!0),U1(S,"keydown",l,!0),s)},[Z,D,M,i,V,j,E,d]),p8.useEffect(()=>{if(Z||!K)return;let S=X1(i);function s(){x.current=!0,E.start(0,()=>{x.current=!1})}function G0(B0){let W0=k5(B0);if(oK(W0))t.current=W0}function l(B0){let{relatedTarget:W0,currentTarget:L0}=B0,_0=k5(B0);if(z&&W0==null&&_0!=null&&e0(D,_0))$P(_0);queueMicrotask(()=>{let D0=I(),c0=F.context.triggerElements,g=d(),a=W0?.hasAttribute(J7("focus-guard"))&&[$0.current,Y0.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,v9(B),v9(H)].includes(W0),I0=!(e0(M,W0)||e0(D,W0)||e0(W0,D)||e0(j?.portalNode,W0)||g.some((A0)=>A0===W0||e0(A0,W0))||W0!=null&&c0.hasElement(W0)||c0.hasMatchingElement((A0)=>e0(A0,W0))||a||f&&(M9(f.nodesRef.current,D0).find((A0)=>e0(A0.context?.elements.floating,W0)||e0(A0.context?.elements.domReference,W0))||a_(f.nodesRef.current,D0).find((A0)=>[A0.context?.elements.floating,xq(A0.context?.elements.floating)].includes(W0)||A0.context?.elements.domReference===W0)));if(L0===M&&i)QP(i);if(Y&&L0!==M&&!V$(_0)&&g5(S)===S.body){if(P1(i)){if(i.focus(),Y==="popup"){m.request(()=>{i.focus()});return}}let A0=u(),F0=t.current,u0=(F0&&A0.includes(F0)?F0:null)||A0[A0.length-1]||i;if(P1(u0))u0.focus()}if(O.current.insideReactTree){O.current.insideReactTree=!1;return}if((b?!0:!z)&&W0&&I0&&!x.current&&(b||W0!==JP()))P.current=!0,F.setOpen(!1,p0(T0.focusOut,B0))})}function Q0(){if(p.current)return;O.current.insideReactTree=!0,K0.start(0,()=>{O.current.insideReactTree=!1})}let J0=P1(M)?M:null;if(!D&&!J0)return;return T8(J0&&U1(J0,"focusout",l),J0&&U1(J0,"pointerdown",s),D&&U1(D,"focusin",G0),D&&U1(D,"focusout",l),D&&j&&U1(D,"focusout",Q0,!0))},[Z,M,D,i,z,f,j,F,K,Y,u,b,I,O,K0,E,m,H,B,d]),p8.useEffect(()=>{if(Z||!D||!V)return;let S=Array.from(j?.portalNode?.querySelectorAll(`[${J7("portal")}]`)||[]),G0=(f?a_(f.nodesRef.current,I()):[]).find((L0)=>hq(L0.context?.elements.domReference||null))?.context?.elements.domReference,Q0=[...[D,...S,$0.current,Y0.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,...d()],G0,v9(B),v9(H),b?M:null].filter((L0)=>L0!=null),J0=JL(Q0,{ariaHidden:z||b,mark:!1}),B0=[D,...S].filter((L0)=>L0!=null),W0=JL(B0);return()=>{W0(),J0()}},[V,Z,M,D,z,j,b,f,I,H,B,d]),y0(()=>{if(!V||Z||!P1(i))return;let S=X1(i),s=g5(S);queueMicrotask(()=>{let G0=k.current,l=typeof G0==="function"?G0(C.current||""):G0;if(l===void 0||l===!1)return;if(e0(i,s))return;let J0=null,B0=()=>{if(J0==null)J0=u(i);return J0[0]||i},W0;if(l===!0||l===null)W0=B0();else W0=v9(l);W0=W0||B0();let L0=e0(i,g5(S));WQ(W0,{preventScroll:W0===i,shouldFocus(){if(!y.current)return!1;if(L0)return!0;let _0=g5(S);return!(_0!==W0&&e0(i,_0))}})})},[Z,V,i,u,k,C,y]),y0(()=>{if(Z||!i)return;let S=X1(i),s=g5(S),G0=C.current==null;$P(s);function l(J0){if(!J0.open)h.current=co(J0.nativeEvent,r.current);if(J0.reason===T0.triggerHover&&J0.nativeEvent.type==="mouseleave")P.current=!0;if(J0.reason!==T0.outsidePress)return;if(J0.nested)P.current=!1;else if(iK(J0.nativeEvent)||rK(J0.nativeEvent))P.current=!1;else{let B0=!1;if(X1(i).createElement("div").focus({get preventScroll(){return B0=!0,!1}}),B0)P.current=!1;else P.current=!0}}N.on("openchange",l);function Q0(){let J0=w.current,B0=typeof J0==="function"?J0(h.current):J0;if(B0===void 0||B0===!1)return null;if(B0===null)B0=!0;let W0=M?.isConnected?M:null,L0=s?.isConnected&&f5(s)!=="body"?s:null,_0=G0?L0||W0:W0||L0;if(!_0)_0=JP()||null;if(typeof B0==="boolean")return _0;return v9(B0)||_0||null}return()=>{N.off("openchange",l);let J0=g5(S),B0=d(),W0=e0(D,J0)||B0.some((D0)=>D0===J0||e0(D0,J0))||f&&M9(f.nodesRef.current,I(),!1).some((D0)=>e0(D0.context?.elements.floating,J0)),L0=w.current,_0=Q0();queueMicrotask(()=>{let D0=po(_0),c0=typeof L0!=="boolean";if(L0&&!P.current&&P1(D0)&&(!c0&&D0!==J0&&J0!==S.body?W0:!0))D0.focus({preventScroll:!0});P.current=!1})}},[Z,D,i,w,C,N,f,M,I,d]),y0(()=>{if(!p1.engine.webkit||V||!D)return;let S=g5(X1(D));if(!P1(S)||!L$(S))return;if(e0(D,S))S.blur()},[V,D]),y0(()=>{if(Z||!j)return;return j.setFocusManagerState({modal:z,closeOnFocusOut:K,open:V,onOpenChange:F.setOpen,domReference:M}),()=>{j.setFocusManagerState(null)}},[Z,j,z,V,F,K,M]),y0(()=>{if(Z||!i)return;return QP(i),()=>{queueMicrotask(GL)}},[Z,i]);let o=!Z&&(z?!b:!0)&&(c||z);return T(p8.Fragment,{children:[o&&G(V9,{"data-type":"inside",ref:e,onFocus:(S)=>{if(z){let s=u();WQ(s[s.length-1])}else if(j?.portalNode)if(P.current=!1,$7(S,j.portalNode))GQ(M)?.focus();else v9(B??j.beforeOutsideRef)?.focus()}}),Q,o&&G(V9,{"data-type":"inside",ref:H0,onFocus:(S)=>{if(z)WQ(u()[0]);else if(j?.portalNode){if(K)P.current=!0;if($7(S,j.portalNode))nK(M)?.focus();else v9(H??j.afterOutsideRef)?.focus()}}})]})}var lq=R(v(),1);function N$($,J={}){let{enabled:Q=!0,event:Z="click",toggle:q=!0,ignoreMouse:X=!1,stickIfOpen:Y=!0,touchOpenDelay:z=0,reason:K=T0.triggerPress}=J,W="rootStore"in $?$.rootStore:$,H=W.context.dataRef,B=lq.useRef(void 0),U=h6(),_=U5(),L=lq.useMemo(()=>{function F(M,D,N,O){let I=p0(K,D,N);if(M&&O==="touch"&&z>0)_.start(z,()=>{W.setOpen(!0,I)});else W.setOpen(M,I)}function V(M,D,N){let O=H.current.openEvent,I=W.select("domReferenceElement")!==D;if(M&&I)return!0;if(!M)return!0;if(!q)return!0;if(O&&Y)return!N(O.type);return!1}return{onPointerDown(M){B.current=M.pointerType},onMouseDown(M){let D=B.current,N=M.nativeEvent,O=W.select("open");if(M.button!==0||Z==="click"||r7(D,!0)&&X)return;let I=V(O,M.currentTarget,(k)=>k==="click"||k==="mousedown"),A=k5(N);if(L$(A)){F(I,N,A,D);return}let b=M.currentTarget;U.request(()=>{F(I,N,b,D)})},onClick(M){if(Z==="mousedown-only")return;let D=B.current;if(Z==="mousedown"&&D){B.current=void 0;return}if(r7(D,!0)&&X)return;let N=W.select("open"),O=V(N,M.currentTarget,(I)=>I==="click"||I==="mousedown"||I==="keydown"||I==="keyup");F(O,M.nativeEvent,M.currentTarget,D)},onKeyDown(){B.current=void 0}}},[H,Z,X,K,W,Y,q,U,_,z]);return lq.useMemo(()=>Q?{reference:L}:T1,[Q,L])}var A6=R(v(),1);function lo(){return!1}function io($){return{escapeKey:typeof $==="boolean"?$:$?.escapeKey??!1,outsidePress:typeof $==="boolean"?$:$?.outsidePress??!0}}function iq($,J={}){let{enabled:Q=!0,escapeKey:Z=!0,outsidePress:q=!0,outsidePressEvent:X="sloppy",referencePress:Y=lo,bubbles:z,externalTree:K}=J,W="rootStore"in $?$.rootStore:$,H=W.useState("open"),B=W.useState("floatingElement"),{dataRef:U}=W.context,_=d8(K),L=g0(typeof q==="function"?q:()=>!1),F=typeof q==="function"?L:q,V=F!==!1,M=g0(()=>X),{escapeKey:D,outsidePress:N}=io(z),O=A6.useRef(!1),I=A6.useRef(!1),A=A6.useRef(!1),b=A6.useRef(!1),k=A6.useRef(""),w=A6.useRef(null),C=U5(),y=U5(),f=g0(()=>{y.clear(),U.current.insideReactTree=!1}),j=g0((e)=>{let H0=U.current.floatingContext?.nodeId;return(_?M9(_.nodesRef.current,H0):[]).some((E)=>E.context?.open&&!E.context.dataRef.current[e])}),P=g0((e)=>{return lK(e,W.select("floatingElement"))||lK(e,W.select("domReferenceElement"))}),x=g0((e)=>{if(!Y())return;W.setOpen(!1,p0(T0.triggerPress,e.nativeEvent))}),p=g0((e)=>{if(!H||!Q||!Z||e.key!=="Escape")return;if(b.current)return;if(!D&&j("__escapeKeyBubbles"))return;let H0=Ly(e)?e.nativeEvent:e,K0=p0(T0.escapeKey,H0);if(W.setOpen(!1,K0),!K0.isCanceled)e.preventDefault();if(!D&&!K0.isPropagationAllowed)e.stopPropagation()}),t=g0(()=>{U.current.insideReactTree=!0,y.start(0,f)}),h=g0((e)=>{if(!H||!Q||e.button!==0)return;let H0=k5(e.nativeEvent);if(!e0(W.select("floatingElement"),H0))return;if(!O.current)O.current=!0,I.current=!1}),r=g0((e)=>{if(!H||!Q)return;if(!(e.defaultPrevented||e.nativeEvent.defaultPrevented))return;if(O.current)I.current=!0});A6.useEffect(()=>{if(!H||!Q)return;U.current.__escapeKeyBubbles=D,U.current.__outsidePressBubbles=N;let e=new b8,H0=new b8;function K0(){e.clear(),b.current=!0}function E(){e.start(p1.engine.webkit?5:0,()=>{b.current=!1})}function m(){A.current=!0,H0.start(0,()=>{A.current=!1})}function c(){O.current=!1,I.current=!1}function i(){let g=k.current,a=g==="pen"||!g?"mouse":g,I0=M(),A0=typeof I0==="function"?I0():I0;if(typeof A0==="string")return A0;return A0[a]}function u(g){let a=i();return a==="intentional"&&g.type!=="click"||a==="sloppy"&&g.type==="click"}function d(g){let a=U.current.floatingContext?.nodeId,I0=_&&M9(_.nodesRef.current,a).some((A0)=>lK(g,A0.context?.elements.floating));return P(g)||I0}function o(g){if(u(g)){if(g.type!=="click"&&!P(g))H0.clear(),A.current=!1;f();return}if(U.current.insideReactTree){f();return}let a=k5(g),I0=`[${J7("inert")}]`,A0=L1(a)?a.getRootNode():null,F0=Array.from((r9(A0)?A0:X1(W.select("floatingElement"))).querySelectorAll(I0)),u0=W.context.triggerElements;if(a&&(u0.hasElement(a)||u0.hasMatchingElement((n0)=>e0(n0,a))))return;let P0=L1(a)?a:null;while(P0&&!E6(P0)){let n0=j6(P0);if(E6(n0)||!L1(n0))break;P0=n0}if(F0.length&&L1(a)&&!Uy(a)&&!e0(a,W.select("floatingElement"))&&F0.every((n0)=>!e0(P0,n0)))return;if(P1(a)&&!("touches"in g)){let n0=E6(a),R0=p5(a),Y1=/auto|scroll/,z1=n0||Y1.test(R0.overflowX),a0=n0||Y1.test(R0.overflowY),C1=z1&&a.clientWidth>0&&a.scrollWidth>a.clientWidth,g1=a0&&a.clientHeight>0&&a.scrollHeight>a.clientHeight,b1=R0.direction==="rtl",n=g1&&(b1?g.offsetX<=a.offsetWidth-a.clientWidth:g.offsetX>a.clientWidth),N0=C1&&g.offsetY>a.clientHeight;if(n||N0)return}if(d(g))return;if(i()==="intentional"&&A.current){H0.clear(),A.current=!1;return}if(typeof F==="function"&&!F(g))return;if(j("__outsidePressBubbles"))return;W.setOpen(!1,p0(T0.outsidePress,g)),f()}function S(g){if(i()!=="sloppy"||g.pointerType==="touch"||!W.select("open")||!Q||P(g))return;o(g)}function s(g){if(i()!=="sloppy"||!W.select("open")||!Q||P(g))return;let a=g.touches[0];if(a)w.current={startTime:Date.now(),startX:a.clientX,startY:a.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},C.start(1000,()=>{if(w.current)w.current.dismissOnTouchEnd=!1,w.current.dismissOnMouseDown=!1})}function G0(g,a){let I0=k5(g);if(!I0)return;let A0=U1(I0,g.type,()=>{a(g),A0()})}function l(g){k.current="touch",G0(g,s)}function Q0(g){if(C.clear(),g.type==="pointerdown")k.current=g.pointerType;if(g.type==="mousedown"&&w.current&&!w.current.dismissOnMouseDown)return;G0(g,(a)=>{if(a.type==="pointerdown")S(a);else o(a)})}function J0(g){if(!O.current)return;let a=I.current;if(c(),i()!=="intentional")return;if(g.type==="pointercancel"){if(a)m();return}if(d(g))return;if(a){m();return}if(typeof F==="function"&&!F(g))return;H0.clear(),A.current=!0,f()}function B0(g){if(i()!=="sloppy"||!w.current||P(g))return;let a=g.touches[0];if(!a)return;let I0=Math.abs(a.clientX-w.current.startX),A0=Math.abs(a.clientY-w.current.startY),F0=Math.sqrt(I0*I0+A0*A0);if(F0>5)w.current.dismissOnTouchEnd=!0;if(F0>10)o(g),C.clear(),w.current=null}function W0(g){G0(g,B0)}function L0(g){if(i()!=="sloppy"||!w.current||P(g))return;if(w.current.dismissOnTouchEnd)o(g);C.clear(),w.current=null}function _0(g){G0(g,L0)}let D0=X1(B),c0=T8(Z&&T8(U1(D0,"keydown",p),U1(D0,"compositionstart",K0),U1(D0,"compositionend",E)),V&&T8(U1(D0,"click",Q0,!0),U1(D0,"pointerdown",Q0,!0),U1(D0,"pointerup",J0,!0),U1(D0,"pointercancel",J0,!0),U1(D0,"mousedown",Q0,!0),U1(D0,"mouseup",J0,!0),U1(D0,"touchstart",l,!0),U1(D0,"touchmove",W0,!0),U1(D0,"touchend",_0,!0)));return()=>{c0(),e.clear(),H0.clear(),c(),A.current=!1}},[U,B,Z,V,F,H,Q,D,N,p,f,M,j,P,_,W,C]),A6.useEffect(f,[F,f]);let $0=A6.useMemo(()=>({onKeyDown:p,onPointerDown:x,onClick:x}),[p,x]),Y0=A6.useMemo(()=>({onKeyDown:p,onPointerDown:r,onMouseDown:r,onClickCapture:t,onMouseDownCapture(e){t(),h(e)},onPointerDownCapture(e){t(),h(e)},onMouseUpCapture:t,onTouchEndCapture:t,onTouchMoveCapture:t}),[p,t,h,r]);return A6.useMemo(()=>Q?{reference:$0,floating:Y0,trigger:$0}:{},[Q,$0,Y0])}var l8=R(v(),1);var UQ=R(v(),1),An=R(J5(),1);var ZP=R(v(),1);function qP($){let J=ZP.useRef(!0);if(J.current)J.current=!1,$()}var HP=R(v(),1);var $1=($,J,Q,Z,q,X,...Y)=>{if(Y.length>0)throw Error(F1(1));let z;if($&&J&&Q&&Z&&q&&X)z=(K,W,H,B)=>{let U=$(K,W,H,B),_=J(K,W,H,B),L=Q(K,W,H,B),F=Z(K,W,H,B),V=q(K,W,H,B);return X(U,_,L,F,V,W,H,B)};else if($&&J&&Q&&Z&&q)z=(K,W,H,B)=>{let U=$(K,W,H,B),_=J(K,W,H,B),L=Q(K,W,H,B),F=Z(K,W,H,B);return q(U,_,L,F,W,H,B)};else if($&&J&&Q&&Z)z=(K,W,H,B)=>{let U=$(K,W,H,B),_=J(K,W,H,B),L=Q(K,W,H,B);return Z(U,_,L,W,H,B)};else if($&&J&&Q)z=(K,W,H,B)=>{let U=$(K,W,H,B),_=J(K,W,H,B);return Q(U,_,W,H,B)};else if($&&J)z=(K,W,H,B)=>{let U=$(K,W,H,B);return J(U,W,H,B)};else if($)z=$;else throw Error("Missing arguments");return z};var GP=R(v(),1),FL=R(HL(),1);var a7=R(v(),1),Xn=HL();function Yn($,J){return $===J&&($!==0||1/$===1/J)||$!==$&&J!==J}var zn=typeof Object.is==="function"?Object.is:Yn,Kn=Xn.useSyncExternalStore,Gn=a7.useRef,Wn=a7.useEffect,Hn=a7.useMemo,Bn=a7.useDebugValue;var BL=function($,J,Q,Z,q){var X=Gn(null);if(X.current===null){var Y={hasValue:!1,value:null};X.current=Y}else Y=X.current;X=Hn(function(){function K(_){if(!W){if(W=!0,H=_,_=Z(_),q!==void 0&&Y.hasValue){var L=Y.value;if(q(L,_))return B=L}return B=_}if(L=B,zn(H,_))return L;var F=Z(_);if(q!==void 0&&q(L,F))return H=_,L;return H=_,B=F}var W=!1,H,B,U=Q===void 0?null:Q;return[function(){return K(J())},U===null?void 0:function(){return K(U())}]},[J,Q,Z,q]);var z=Kn($,X[0],X[1]);return Wn(function(){Y.hasValue=!0,Y.value=z},[z]),Bn(z),z};var XP=R(v(),1);var UL=[],_L=void 0;function YP(){return _L}function zP($){UL.push($)}function LL($){let J=(Q,Z)=>{let q=W5(Un).current,X;try{_L=q;for(let Y of UL)Y.before(q);X=$(Q,Z);for(let Y of UL)Y.after(q);q.didInitialize=!0}finally{_L=void 0}return X};return J.displayName=$.displayName||$.name,J}function KP($){return XP.forwardRef(LL($))}function Un(){return{didInitialize:!1}}var _n=HQ(19),Ln=_n?Vn:Mn;function qG($,J,Q,Z,q){return Ln($,J,Q,Z,q)}function Fn($,J,Q,Z,q){let X=GP.useCallback(()=>J($.getSnapshot(),Q,Z,q),[$,J,Q,Z,q]);return FL.useSyncExternalStore($.subscribe,X,X)}zP({before($){if($.syncIndex=0,!$.didInitialize)$.syncTick=1,$.syncHooks=[],$.didChangeStore=!0,$.getSnapshot=()=>{let J=!1;for(let Q=0;Q<$.syncHooks.length;Q+=1){let Z=$.syncHooks[Q],q=Z.selector(Z.store.state,Z.a1,Z.a2,Z.a3);if(!Object.is(Z.value,q))J=!0,Z.value=q}if(J)$.syncTick+=1;return $.syncTick}},after($){if($.syncHooks.length>0){if($.didChangeStore)$.didChangeStore=!1,$.subscribe=(J)=>{let Q=new Set;for(let q of $.syncHooks)Q.add(q.store);let Z=[];for(let q of Q)Z.push(q.subscribe(J));return()=>{for(let q of Z)q()}};FL.useSyncExternalStore($.subscribe,$.getSnapshot,$.getSnapshot)}}});function Vn($,J,Q,Z,q){let X=YP();if(!X)return Fn($,J,Q,Z,q);let Y=X.syncIndex;X.syncIndex+=1;let z;if(!X.didInitialize)z={store:$,selector:J,a1:Q,a2:Z,a3:q,value:J($.getSnapshot(),Q,Z,q)},X.syncHooks.push(z);else if(z=X.syncHooks[Y],z.store!==$||z.selector!==J||!Object.is(z.a1,Q)||!Object.is(z.a2,Z)||!Object.is(z.a3,q)){if(z.store!==$)X.didChangeStore=!0;z.store=$,z.selector=J,z.a1=Q,z.a2=Z,z.a3=q,z.value=J($.getSnapshot(),Q,Z,q)}return z.value}function Mn($,J,Q,Z,q){return BL($.subscribe,$.getSnapshot,$.getSnapshot,(X)=>J(X,Q,Z,q))}class VL{constructor($){this.state=$,this.listeners=new Set,this.updateTick=0}subscribe=($)=>{return this.listeners.add($),()=>{this.listeners.delete($)}};getSnapshot=()=>{return this.state};setState($){if(this.state===$)return;this.state=$,this.updateTick+=1;let J=this.updateTick;for(let Q of this.listeners){if(J!==this.updateTick)return;Q($)}}update($){for(let J in $)if(!Object.is(this.state[J],$[J])){this.setState({...this.state,...$});return}}set($,J){if(!Object.is(this.state[$],J))this.setState({...this.state,[$]:J})}notifyAll(){let $={...this.state};this.setState($)}use($,J,Q,Z){return qG(this,$,J,Q,Z)}}var O$=R(v(),1);class A$ extends VL{constructor($,J={},Q){super($);this.context=J,this.selectors=Q}useSyncedValue($,J){O$.useDebugValue($);let Q=this;y0(()=>{if(Q.state[$]!==J)Q.set($,J)},[Q,$,J])}useSyncedValueWithCleanup($,J){let Q=this;y0(()=>{if(Q.state[$]!==J)Q.set($,J);return()=>{Q.set($,void 0)}},[Q,$,J])}useSyncedValues($){let J=this,Q=Object.values($);y0(()=>{J.update($)},[J,...Q])}useControlledProp($,J){O$.useDebugValue($);let Q=this,Z=J!==void 0;y0(()=>{if(Z&&!Object.is(Q.state[$],J))Q.setState({...Q.state,[$]:J})},[Q,$,J,Z])}select($,J,Q,Z){let q=this.selectors[$];return q(this.state,J,Q,Z)}useState($,J,Q,Z){return O$.useDebugValue($),qG(this,this.selectors[$],J,Q,Z)}useContextCallback($,J){O$.useDebugValue($);let Q=g0(J??d1);this.context[$]=Q}useStateSetter($){let J=O$.useRef(void 0);if(J.current===void 0)J.current=(Q)=>{this.set($,Q)};return J.current}observe($,J){let Q;if(typeof $==="function")Q=$;else Q=this.selectors[$];let Z=Q(this.state);return J(Z,Z,this),this.subscribe((q)=>{let X=Q(q);if(!Object.is(Z,X)){let Y=Z;Z=X,J(X,Y,this)}})}}var XG=R(v(),1);function WP(){let[,$]=XG.useState({});return XG.useCallback(()=>{$({})},[])}var Dn={open:$1(($)=>$.open),transitionStatus:$1(($)=>$.transitionStatus),domReferenceElement:$1(($)=>$.domReferenceElement),referenceElement:$1(($)=>$.positionReference??$.referenceElement),floatingElement:$1(($)=>$.floatingElement),floatingId:$1(($)=>$.floatingId)};class Q7 extends A${constructor($){let{syncOnly:J,nested:Q,onOpenChange:Z,triggerElements:q,...X}=$;super({...X,positionReference:X.referenceElement,domReferenceElement:X.referenceElement},{onOpenChange:Z,dataRef:{current:{}},events:ZG(),nested:Q,triggerElements:q},Dn);this.syncOnly=J}syncOpenEvent=($,J)=>{if(!$||!this.state.open||J!=null&&Fy(J))this.context.dataRef.current.openEvent=$?J:void 0};dispatchOpenChange=($,J)=>{this.syncOpenEvent($,J.event);let Q={open:$,reason:J.reason,nativeEvent:J.event,nested:this.context.nested,triggerElement:J.trigger};this.context.events.emit("openchange",Q)};setOpen=($,J)=>{if(this.syncOnly){this.context.onOpenChange?.($,J);return}this.dispatchOpenChange($,J),this.context.onOpenChange?.($,J)}}function rq($){let{popupStore:J,treatPopupAsFloatingElement:Q=!1,floatingRootContext:Z,floatingId:q,nested:X,onOpenChange:Y}=$,z=J.useState("open"),K=J.useState("activeTriggerElement"),W=J.useState(Q?"popupElement":"positionerElement"),H=J.context.triggerElements,B=Y,U=HP.useRef(null);if(Z===void 0&&U.current===null)U.current=new Q7({open:z,transitionStatus:void 0,referenceElement:K,floatingElement:W,triggerElements:H,onOpenChange:B,floatingId:q,syncOnly:!0,nested:X});let _=Z??U.current;return J.useSyncedValue("floatingId",q),y0(()=>{let L={open:z,floatingId:q,referenceElement:K,floatingElement:W};if(L1(K))L.domReferenceElement=K;if(_.state.positionReference===_.state.referenceElement)L.positionReference=K;_.update(L)},[z,q,K,W,_]),_.context.onOpenChange=B,_.context.nested=X,_}var ML=R(v(),1);function BQ($,J=!1,Q=!1){let[Z,q]=ML.useState($&&J?"idle":void 0),[X,Y]=ML.useState($);if($&&!X)Y(!0),q("starting");if(!$&&X&&Z!=="ending"&&!Q)q("ending");if(!$&&!X&&Z==="ending")q(void 0);return y0(()=>{if(!$&&X&&Z!=="ending"&&Q){let z=F9.request(()=>{q("ending")});return()=>{F9.cancel(z)}}return},[$,X,Z,Q]),y0(()=>{if(!$||J)return;let z=F9.request(()=>{q(void 0)});return()=>{F9.cancel(z)}},[J,$]),y0(()=>{if(!$||!J)return;if($&&X&&Z!=="idle")q("starting");let z=F9.request(()=>{q("idle")});return()=>{F9.cancel(z)}},[J,$,X,Z]),{mounted:X,setMounted:Y,transitionStatus:Z}}var UP=R(v(),1);var BP=R(J5(),1);var w$=function($){return $.startingStyle="data-starting-style",$.endingStyle="data-ending-style",$}({}),Nn={[w$.startingStyle]:""},On={[w$.endingStyle]:""},U4={transitionStatus($){if($==="starting")return Nn;if($==="ending")return On;return null}};function _4($,J=!1,Q=!0){let Z=h6();return g0((q,X=null)=>{Z.cancel();let Y=v9($);if(Y==null)return;let z=Y,K=()=>{BP.flushSync(q)};if(typeof z.getAnimations!=="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){q();return}function W(){Promise.all(z.getAnimations().map((H)=>H.finished)).then(()=>{if(!X?.aborted)K()}).catch(()=>{if(Q){if(!X?.aborted)K();return}let H=z.getAnimations();if(!X?.aborted&&H.length>0&&H.some((B)=>B.pending||B.playState!=="finished"))W()})}if(J){let H=w$.startingStyle;if(!z.hasAttribute(H)){Z.request(W);return}let B=new MutationObserver(()=>{if(!z.hasAttribute(H))B.disconnect(),W()});B.observe(z,{attributes:!0,attributeFilter:[H]}),X?.addEventListener("abort",()=>B.disconnect(),{once:!0});return}Z.request(W)})}function L4($){let{enabled:J=!0,open:Q,ref:Z,onComplete:q}=$,X=g0(q),Y=_4(Z,Q,!1);UP.useEffect(()=>{if(!J)return;let z=new AbortController;return Y(X,z.signal),()=>{z.abort()}},[J,Q,X,Y])}var _Q={tabIndex:-1,[Rq]:""};function _P($){return(J)=>J==="touch"?$.current:!0}function LP($,J,Q=!1){let Z=x6(),q=x8()!=null,X=UQ.useRef(null);if($===void 0&&X.current===null)X.current=J(Z,q);let Y=$??X.current;return rq({popupStore:Y,treatPopupAsFloatingElement:Q,floatingRootContext:Y.state.floatingRootContext,floatingId:Z,nested:q,onOpenChange:Y.setOpen}),{store:Y,internalStore:X.current}}function DL($,J){let Q=UQ.useRef(null),Z=UQ.useRef(null);return UQ.useCallback((q)=>{if($===void 0)return;let X=!1;if(Q.current!==null){let Y=Q.current,z=Z.current,K=J.context.triggerElements.getById(Y);if(z&&K===z)J.context.triggerElements.delete(Y),X=!0;Q.current=null,Z.current=null}if(q!==null)Q.current=$,Z.current=q,J.context.triggerElements.add($,q),X=!0;if(X){let Y=J.context.triggerElements.size;if(J.select("open")&&J.state.triggerCount!==Y)J.set("triggerCount",Y)}},[J,$])}function YG($,J,Q,Z=!1){if(J)$.preventUnmountingOnClose=!1;else if(Z)$.preventUnmountingOnClose=!0;let q=Q?.id??null;if(q||J)$.activeTriggerId=q,$.activeTriggerElement=Q??null}function zG($){let J=!1;return $.preventUnmountOnClose=()=>{J=!0},()=>J}function KG($,J,Q,Z){qP(()=>{if(J===void 0&&$.state.open===!1&&Q)$.state={...$.state,open:!0,activeTriggerId:Z,preventUnmountingOnClose:!1}})}function GG($,J,Q,Z){let q=Q.useState("isMountedByTrigger",$),X=DL($,Q),Y=g0((z)=>{if(X(z),!z)return;let K=Q.select("open"),W=Q.select("activeTriggerId");if(W===$){Q.update({activeTriggerElement:z,...K?Z:null});return}if(W==null&&K)Q.update({activeTriggerId:$,activeTriggerElement:z,...Z})});return y0(()=>{if(q)Q.update({activeTriggerElement:J.current,...Z})},[q,Q,J,...Object.values(Z)]),{registerTrigger:Y,isMountedByThisTrigger:q}}function WG($,J={}){let{closeOnActiveTriggerUnmount:Q=!1}=J,Z=$.useState("open"),q=$.useState("triggerCount");y0(()=>{if(!Z){if($.state.triggerCount!==0)$.set("triggerCount",0);return}let X=$.context.triggerElements.size,Y={};if($.state.triggerCount!==X)Y.triggerCount=X;let z=$.select("activeTriggerId"),K=null;if(z){let W=$.context.triggerElements.getById(z);if(!W)K=z;else if(W!==$.state.activeTriggerElement)Y.activeTriggerElement=W}if(!K&&!z&&X===1){let W=$.context.triggerElements.entries().next();if(!W.done){let[H,B]=W.value;Y.activeTriggerId=H,Y.activeTriggerElement=B}}if(Y.triggerCount!==void 0||Y.activeTriggerId!==void 0||Y.activeTriggerElement!==void 0)$.update(Y);if(K){if(Q)queueMicrotask(()=>{if($.select("open")&&$.select("activeTriggerId")===K&&!$.context.triggerElements.getById(K)){let W=p0(T0.none);if($.setOpen(!1,W),!W.isCanceled)$.update({activeTriggerId:null,activeTriggerElement:null})}})}},[Z,$,q,Q])}function HG($,J,Q){let{mounted:Z,setMounted:q,transitionStatus:X}=BQ($),Y=J.useState("preventUnmountingOnClose"),z=$?!1:Y;J.useSyncedValues({mounted:Z,transitionStatus:X,preventUnmountingOnClose:z});let K=g0(()=>{q(!1),J.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),Q?.(),J.context.onOpenChangeComplete?.(!1)});return L4({enabled:Z&&!$&&!z,open:$,ref:J.context.popupRef,onComplete(){if(!$)K()}}),{forceUnmount:K,transitionStatus:X}}function BG($,J){$.useSyncedValues(J),y0(()=>()=>{$.update({activeTriggerProps:T1,inactiveTriggerProps:T1,popupProps:T1})},[$])}function FP($,J){y0(()=>{if(!J&&$.state.openMethod!==null)$.set("openMethod",null)},[J,$]),y0(()=>()=>{if($.state.openMethod!==null)$.set("openMethod",null)},[$])}class Z7{constructor(){this.elementsSet=new Set,this.idMap=new Map}add($,J){let Q=this.idMap.get($);if(Q===J)return;if(Q!==void 0)this.elementsSet.delete(Q);this.elementsSet.add(J),this.idMap.set($,J)}delete($){let J=this.idMap.get($);if(J)this.elementsSet.delete(J),this.idMap.delete($)}hasElement($){return this.elementsSet.has($)}hasMatchingElement($){for(let J of this.elementsSet)if($(J))return!0;return!1}getById($){return this.idMap.get($)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function VP(){return new Q7({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Z7,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function UG(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:VP(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:T1,inactiveTriggerProps:T1,popupProps:T1}}function DP($,J,Q=!1){return new Q7({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:$,floatingId:J,syncOnly:!0,nested:Q,onOpenChange:void 0})}var sq=$1(($)=>$.triggerIdProp??$.activeTriggerId),NL=$1(($)=>$.openProp??$.open),MP=$1(($)=>{return($.popupElement?.id??$.floatingId)||void 0});function NP($,J){return J!==void 0&&NL($)&&sq($)===J}function wn($,J){if(NP($,J))return!0;return J!==void 0&&NL($)&&sq($)==null&&$.triggerCount===1}var _G={open:NL,mounted:$1(($)=>$.mounted),transitionStatus:$1(($)=>$.transitionStatus),floatingRootContext:$1(($)=>$.floatingRootContext),triggerCount:$1(($)=>$.triggerCount),preventUnmountingOnClose:$1(($)=>$.preventUnmountingOnClose),payload:$1(($)=>$.payload),activeTriggerId:sq,activeTriggerElement:$1(($)=>$.mounted?$.activeTriggerElement:null),popupId:MP,isTriggerActive:$1(($,J)=>J!==void 0&&sq($)===J),isOpenedByTrigger:$1(($,J)=>NP($,J)),isMountedByTrigger:$1(($,J)=>J!==void 0&&sq($)===J&&$.mounted),triggerProps:$1(($,J)=>J?$.activeTriggerProps:$.inactiveTriggerProps),triggerPopupId:$1(($,J)=>wn($,J)?MP($):void 0),popupProps:$1(($)=>$.popupProps),popupElement:$1(($)=>$.popupElement),positionerElement:$1(($)=>$.positionerElement)};function OP($){let{open:J=!1,onOpenChange:Q,elements:Z={}}=$,q=x6(),X=x8()!=null,Y=W5(()=>new Q7({open:J,transitionStatus:void 0,onOpenChange:Q,referenceElement:Z.reference??null,floatingElement:Z.floating??null,triggerElements:new Z7,floatingId:q,syncOnly:!1,nested:X})).current;return y0(()=>{let z={open:J,floatingId:q};if(Z.reference!==void 0)z.referenceElement=Z.reference,z.domReferenceElement=L1(Z.reference)?Z.reference:null;if(Z.floating!==void 0)z.floatingElement=Z.floating;Y.update(z)},[J,q,Z.reference,Z.floating,Y]),Y.context.onOpenChange=Q,Y.context.nested=X,Y}function OL($={}){let{nodeId:J,externalTree:Q}=$,Z=OP($),q=$.rootContext||Z,X=q.useState("referenceElement"),Y=q.useState("floatingElement"),z=q.useState("domReferenceElement"),K=q.useState("open"),W=q.useState("floatingId"),[H,B]=l8.useState(null),[U,_]=l8.useState(void 0),[L,F]=l8.useState(void 0),V=l8.useRef(null),M=d8(Q),D=l8.useMemo(()=>({reference:X,floating:Y,domReference:z}),[X,Y,z]),N=jX({...$,elements:{...D,...H&&{reference:H}}}),O=L1(U)?U:null,I=L===void 0?q.state.floatingElement:L;q.useSyncedValue("referenceElement",U??null),q.useSyncedValue("domReferenceElement",U===void 0?z:O),q.useSyncedValue("floatingElement",I);let A=l8.useCallback((f)=>{let j=L1(f)?{getBoundingClientRect:()=>f.getBoundingClientRect(),getClientRects:()=>f.getClientRects(),contextElement:f}:f;B(j),N.refs.setReference(j)},[N.refs]),b=l8.useCallback((f)=>{if(L1(f)||f===null)V.current=f,_(f);if(L1(N.refs.reference.current)||N.refs.reference.current===null||f!==null&&!L1(f))N.refs.setReference(f)},[N.refs,_]),k=l8.useCallback((f)=>{F(f),N.refs.setFloating(f)},[N.refs]),w=l8.useMemo(()=>({...N.refs,setReference:b,setFloating:k,setPositionReference:A,domReference:V}),[N.refs,b,k,A]),C=l8.useMemo(()=>({...N.elements,domReference:z}),[N.elements,z]),y=l8.useMemo(()=>({...N,dataRef:q.context.dataRef,open:K,onOpenChange:q.setOpen,events:q.context.events,floatingId:W,refs:w,elements:C,nodeId:J,rootStore:q}),[N,w,C,J,q,K,W]);return y0(()=>{if(z)V.current=z},[z]),y0(()=>{q.context.dataRef.current.floatingContext=y;let f=M?.nodesRef.current.find((j)=>j.id===J);if(f)f.context=y}),l8.useMemo(()=>({...N,context:y,refs:w,elements:C,rootStore:q}),[N,w,C,y,q])}var F4=R(v(),1);var AL=p1.os.mac&&p1.engine.webkit;function wL($,J={}){let{enabled:Q=!0,delay:Z}=J,q="rootStore"in $?$.rootStore:$,{events:X,dataRef:Y}=q.context,z=F4.useRef(!1),K=F4.useRef(null),W=F4.useRef(!0),H=U5();F4.useEffect(()=>{let U=q.select("domReferenceElement");if(!Q)return;let _=h1(U);function L(){let M=q.select("domReferenceElement");if(!q.select("open")&&P1(M)&&M===g5(X1(M)))z.current=!0}function F(){W.current=!0}function V(){W.current=!1}return T8(U1(_,"blur",L),AL&&U1(_,"keydown",F,!0),AL&&U1(_,"pointerdown",V,!0))},[q,Q]),F4.useEffect(()=>{if(!Q)return;function U(_){if(_.reason===T0.triggerPress||_.reason===T0.escapeKey){let L=q.select("domReferenceElement");if(L1(L))K.current=L,z.current=!0}}return X.on("openchange",U),()=>{X.off("openchange",U)}},[X,Q,q]);let B=F4.useMemo(()=>{function U(){z.current=!1,K.current=null}return{onMouseLeave(){U()},onFocus(_){let L=_.currentTarget;if(z.current){if(K.current===L)return;U()}let F=k5(_.nativeEvent);if(L1(F)){if(AL&&!_.relatedTarget){if(!W.current&&!L$(F))return}else if(!_y(F))return}let V=i7(_.relatedTarget,q.context.triggerElements),{nativeEvent:M,currentTarget:D}=_,N=typeof Z==="function"?Z():Z;if(q.select("open")&&V||N===0||N===void 0){q.setOpen(!0,p0(T0.triggerFocus,M,D));return}H.start(N,()=>{if(z.current)return;q.setOpen(!0,p0(T0.triggerFocus,M,D))})},onBlur(_){U();let{relatedTarget:L,nativeEvent:F}=_,V=L1(L)&&L.hasAttribute(J7("focus-guard"))&&L.getAttribute("data-type")==="outside";H.start(0,()=>{let M=q.select("domReferenceElement"),D=g5(X1(M));if(!L&&D===M)return;if(e0(Y.current.floatingContext?.refs.floating.current,D)||e0(M,D)||V)return;if(i7(L??D,q.context.triggerElements))return;q.setOpen(!1,p0(T0.triggerFocus,F))})}}},[Y,Z,q,H]);return F4.useMemo(()=>Q?{reference:B,trigger:B}:{},[Q,B])}var TL=R(v(),1);class kL{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new b8,this.restTimeout=new b8,this.handleCloseOptions=void 0}static create(){return new kL}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>{return this.dispose}}var LG=new WeakMap;function LQ($){if(!$.performedPointerEventsMutation)return;let J=$.pointerEventsScopeElement;if(J&&LG.get(J)===$)$.pointerEventsScopeElement?.style.removeProperty("pointer-events"),$.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),$.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),LG.delete(J);$.performedPointerEventsMutation=!1,$.pointerEventsScopeElement=null,$.pointerEventsReferenceElement=null,$.pointerEventsFloatingElement=null}function FG($,J){let{scopeElement:Q,referenceElement:Z,floatingElement:q}=J,X=LG.get(Q);if(X&&X!==$)LQ(X);LQ($),$.performedPointerEventsMutation=!0,$.pointerEventsScopeElement=Q,$.pointerEventsReferenceElement=Z,$.pointerEventsFloatingElement=q,LG.set(Q,$),Q.style.pointerEvents="none",Z.style.pointerEvents="auto",q.style.pointerEvents="auto"}function VG($){let J=$.context.dataRef.current,Q=W5(()=>J.hoverInteractionState??kL.create()).current;if(!J.hoverInteractionState)J.hoverInteractionState=Q;return l7(J.hoverInteractionState.disposeEffect),J.hoverInteractionState}function kn($,J){if(J!=null&&!r7(J))return 0;if(typeof $==="function")return $();return $}function oq($,J,Q){let Z=kn($,Q);if(typeof Z==="number")return Z;return Z?.[J]}function IL($){if(typeof $==="function")return $();return $}function MG($,J){return J||$==="click"||$==="mousedown"}function AP($){return $?.includes("mouse")&&$!=="mousedown"}function nq($,J={}){let{enabled:Q=!0,closeDelay:Z=0,nodeId:q}=J,X="rootStore"in $?$.rootStore:$,Y=X.useState("open"),z=X.useState("floatingElement"),K=X.useState("domReferenceElement"),{dataRef:W}=X.context,H=d8(),B=x8(),U=VG(X),_=U5(),L=g0(()=>{return MG(W.current.openEvent?.type,U.interactedInside)}),F=g0(()=>{return AP(W.current.openEvent?.type)}),V=g0(()=>{LQ(U)});y0(()=>{if(!Y)U.pointerType=void 0,U.restTimeoutPending=!1,U.interactedInside=!1,V()},[Y,U,V]),TL.useEffect(()=>{return V},[V]),y0(()=>{if(!Q)return;if(Y&&U.handleCloseOptions?.blockPointerEvents&&F()&&L1(K)&&z){let M=K,D=z,N=X1(z),O=H?.nodesRef.current.find((k)=>k.id===B)?.context?.elements.floating;if(O)O.style.pointerEvents="";let I=U.pointerEventsScopeElement!==D?U.pointerEventsScopeElement:null,A=O!==D?O:null,b=U.handleCloseOptions?.getScope?.()??I??A??M.closest("[data-rootownerid]")??N.body;return FG(U,{scopeElement:b,referenceElement:M,floatingElement:D}),()=>{V()}}return},[Q,Y,K,z,U,F,H,B,V]),TL.useEffect(()=>{if(!Q)return;function M(){return!!(H&&B&&M9(H.nodesRef.current,B).length>0)}function D(k){let w=oq(Z,"close",U.pointerType),C=()=>{X.setOpen(!1,p0(T0.triggerHover,k)),H?.events.emit("floating.closed",k)};if(w)U.openChangeTimeout.start(w,C);else U.openChangeTimeout.clear(),C()}function N(k){let w=k5(k);if(!d_(w)){U.interactedInside=!1;return}U.interactedInside=w?.closest("[aria-haspopup]")!=null}function O(){U.openChangeTimeout.clear(),_.clear(),H?.events.off("floating.closed",A),V()}function I(k){if(M()&&H){H.events.on("floating.closed",A);return}if(i7(k.relatedTarget,X.context.triggerElements))return;let w=W.current.floatingContext?.nodeId??q,C=k.relatedTarget;if(H&&w&&L1(C)&&M9(H.nodesRef.current,w,!1).some((f)=>e0(f.context?.elements.floating,C)))return;if(U.handler){U.handler(k);return}if(V(),F()&&!L())D(k)}function A(k){if(!H||!B||M())return;_.start(0,()=>{H.events.off("floating.closed",A),X.setOpen(!1,p0(T0.triggerHover,k)),H.events.emit("floating.closed",k)})}let b=z;return T8(b&&U1(b,"mouseenter",O),b&&U1(b,"mouseleave",I),b&&U1(b,"pointerdown",N,!0),()=>{H?.events.off("floating.closed",A)})},[Q,z,X,W,Z,q,F,L,V,U,H,B,_])}var t7=R(v(),1),wP=R(J5(),1);var In={current:null};function k$($,J={}){let{enabled:Q=!0,delay:Z=0,handleClose:q=null,mouseOnly:X=!1,restMs:Y=0,move:z=!0,triggerElementRef:K=In,externalTree:W,isActiveTrigger:H=!0,getHandleCloseContext:B,isClosing:U,shouldOpen:_}=J,L="rootStore"in $?$.rootStore:$,{dataRef:F,events:V}=L.context,M=d8(W),D=VG(L),N=t7.useRef(!1),O=F5(q),I=F5(Z),A=F5(Y),b=F5(Q),k=F5(_),w=F5(U),C=g0(()=>{return MG(F.current.openEvent?.type,D.interactedInside)}),y=g0(()=>{return k.current?.()!==!1}),f=g0((x,p,t)=>{let h=L.context.triggerElements;if(h.hasElement(p))return!x||!e0(x,p);if(!L1(t))return!1;let r=t;return h.hasMatchingElement(($0)=>e0($0,r))&&(!x||!e0(x,r))}),j=g0(()=>{if(!D.handler)return;X1(L.select("domReferenceElement")).removeEventListener("mousemove",D.handler),D.handler=void 0}),P=g0(()=>{LQ(D)});if(H)D.handleCloseOptions=O.current?.__options;return t7.useEffect(()=>j,[j]),t7.useEffect(()=>{if(!Q)return;function x(p){if(!p.open)N.current=p.reason===T0.triggerHover,j(),D.openChangeTimeout.clear(),D.restTimeout.clear(),D.blockMouseMove=!0,D.restTimeoutPending=!1;else N.current=!1}return V.on("openchange",x),()=>{V.off("openchange",x)}},[Q,V,D,j]),t7.useEffect(()=>{if(!Q)return;function x(r,$0=!0){let Y0=oq(I.current,"close",D.pointerType);if(Y0)D.openChangeTimeout.start(Y0,()=>{L.setOpen(!1,p0(T0.triggerHover,r)),M?.events.emit("floating.closed",r)});else if($0)D.openChangeTimeout.clear(),L.setOpen(!1,p0(T0.triggerHover,r)),M?.events.emit("floating.closed",r)}let p=K.current??(H?L.select("domReferenceElement"):null);if(!L1(p))return;function t(r){if(D.openChangeTimeout.clear(),D.blockMouseMove=!1,X&&!r7(D.pointerType))return;let $0=IL(A.current),Y0=oq(I.current,"open",D.pointerType),e=k5(r),H0=r.currentTarget??null,K0=L.select("domReferenceElement"),E=H0;if(L1(e)&&!L.context.triggerElements.hasElement(e)){for(let G0 of L.context.triggerElements.elements())if(e0(G0,e)){E=G0;break}}if(L1(H0)&&L1(K0)&&!L.context.triggerElements.hasElement(H0)&&e0(H0,K0))E=K0;let m=E==null?!1:f(K0,E,e),c=L.select("open"),i=w.current?.()??L.select("transitionStatus")==="ending",u=!c&&i&&N.current,d=!m&&L1(E)&&L1(K0)&&e0(K0,E)&&u,o=$0>0&&!Y0,S=m&&(c||u)||d,s=!c||m;if(S){if(y())L.setOpen(!0,p0(T0.triggerHover,r,E));return}if(o)return;if(Y0)D.openChangeTimeout.start(Y0,()=>{if(s&&y())L.setOpen(!0,p0(T0.triggerHover,r,E))});else if(s){if(y())L.setOpen(!0,p0(T0.triggerHover,r,E))}}function h(r){if(C()){P();return}j();let $0=L.select("domReferenceElement"),Y0=X1($0);D.restTimeout.clear(),D.restTimeoutPending=!1;let e=F.current.floatingContext??B?.();if(i7(r.relatedTarget,L.context.triggerElements))return;if(O.current&&e){if(!L.select("open"))D.openChangeTimeout.clear();let K0=K.current;D.handler=O.current({...e,tree:M,x:r.clientX,y:r.clientY,onClose(){if(P(),j(),b.current&&!C()&&K0===L.select("domReferenceElement"))x(r,!0)}}),Y0.addEventListener("mousemove",D.handler),D.handler(r);return}if(D.pointerType==="touch"?!e0(L.select("floatingElement"),r.relatedTarget):!0)x(r)}if(z)return T8(U1(p,"mousemove",t,{once:!0}),U1(p,"mouseenter",t),U1(p,"mouseleave",h));return T8(U1(p,"mouseenter",t),U1(p,"mouseleave",h))},[j,P,F,I,L,Q,O,D,H,f,C,X,z,A,K,M,b,B,w,y]),t7.useMemo(()=>{if(!Q)return;function x(p){D.pointerType=p.pointerType}return{onPointerDown:x,onPointerEnter:x,onMouseMove(p){let{nativeEvent:t}=p,h=p.currentTarget,r=L.select("domReferenceElement"),$0=L.select("open"),Y0=f(r,h,p.target);if(X&&!r7(D.pointerType))return;if($0&&Y0&&D.handleCloseOptions?.blockPointerEvents){let K0=L.select("floatingElement");if(K0){let E=D.handleCloseOptions?.getScope?.()??h.ownerDocument.body;FG(D,{scopeElement:E,referenceElement:h,floatingElement:K0})}}let e=IL(A.current);if($0&&!Y0||e===0)return;if(!Y0&&D.restTimeoutPending&&p.movementX**2+p.movementY**2<2)return;D.restTimeout.clear();function H0(){if(D.restTimeoutPending=!1,C())return;let K0=L.select("open");if(!D.blockMouseMove&&(!K0||Y0)&&y())L.setOpen(!0,p0(T0.triggerHover,t,h))}if(D.pointerType==="touch")wP.flushSync(()=>{H0()});else if(Y0&&$0)H0();else D.restTimeoutPending=!0,D.restTimeout.start(e,H0)}}},[Q,D,C,f,X,L,A,y])}var f8=R(v(),1);var Tn="Escape";function NG($,J,Q){switch($){case"vertical":return J;case"horizontal":return Q;default:return J||Q}}function DG($,J){return NG(J,$===c_||$===pK,$===Cq||$===Sq)}function bL($,J,Q){return NG(J,$===pK,Q?$===Cq:$===Sq)||$==="Enter"||$===" "||$===""}function bn($,J,Q){return NG(J,Q?$===Cq:$===Sq,$===pK)}function jn($,J,Q,Z){let q=Q?$===Sq:$===Cq,X=$===c_;if(J==="both"||J==="horizontal"&&Z)return $===Tn;return NG(J,q,X)}function jL($,J){let{listRef:Q,activeIndex:Z,onNavigate:q=()=>{},enabled:X=!0,selectedIndex:Y=null,allowEscape:z=!1,loopFocus:K=!1,nested:W=!1,rtl:H=!1,virtual:B=!1,focusItemOnOpen:U="auto",focusItemOnHover:_=!0,openOnArrowKeyDown:L=!0,disabledIndices:F=void 0,orientation:V="vertical",parentOrientation:M,id:D,resetOnPointerLeave:N=!0,externalTree:O,grid:I}=J,A=I!=null,b="rootStore"in $?$.rootStore:$,k=b.useState("open"),w=b.useState("floatingElement"),C=b.useState("domReferenceElement"),y=b.context.dataRef,f=xq(w),j=hq(C),P=F5(f),x=x8(),p=d8(O),t=f8.useRef(U),h=f8.useRef(Y??-1),r=f8.useRef(null),$0=f8.useRef(!0),Y0=g0((g)=>{q(h.current===-1?null:h.current,g)}),e=f8.useRef(!!w),H0=f8.useRef(k),K0=f8.useRef(!1),E=f8.useRef(!1),m=f8.useRef(null),c=F5(F),i=F5(k),u=F5(Y),d=F5(N),o=h6(),S=h6(),s=g0(()=>{function g(F0){if(B)p?.events.emit("virtualfocus",F0);else m.current=WQ(F0,{sync:K0.current,preventScroll:!0})}let a=Q.current[h.current],I0=E.current;if(a)g(a);(K0.current?(F0)=>F0():(F0)=>o.request(F0))(()=>{let F0=Q.current[h.current]||a;if(!F0)return;if(!a)g(F0);if(W0&&(I0||!$0.current))F0.scrollIntoView?.({block:"nearest",inline:"nearest"})})});y0(()=>{y.current.orientation=V},[y,V]),y0(()=>{if(!X)return;if(k&&w){if(h.current=Y??-1,t.current&&Y!=null)E.current=!0,Y0()}else if(e.current)h.current=-1,Y0()},[X,k,w,Y,Y0]),y0(()=>{if(!X)return;if(!k){K0.current=!1;return}if(!w)return;if(Z==null){if(K0.current=!1,u.current!=null)return;if(e.current)h.current=-1,s();if((!H0.current||!e.current)&&t.current&&(r.current!=null||t.current===!0&&r.current==null)){let g=0,a=()=>{if(Q.current[0]==null){if(g<2)(g?(A0)=>S.request(A0):queueMicrotask)(a);g+=1}else h.current=r.current==null||bL(r.current,V,H)||W?sK(Q):l_(Q),r.current=null,Y0()};a()}}else if(!p_(Q.current,Z))h.current=Z,s(),E.current=!1},[X,k,w,Z,u,W,Q,V,H,Y0,s,S]),y0(()=>{if(!X||w||!p||B||!e.current)return;let g=p.nodesRef.current,a=g.find((F0)=>F0.id===x)?.context?.elements.floating,I0=g5(X1(C??a??null)),A0=g.some((F0)=>F0.context&&e0(F0.context.elements.floating,I0));if(a&&!A0&&$0.current)a.focus({preventScroll:!0})},[X,w,C,p,x,B]),y0(()=>{H0.current=k,e.current=!!w}),y0(()=>{if(!k)r.current=null,t.current=U},[k,U]);let G0=Z!=null,l=g0((g)=>{if(!i.current)return;let a=Q.current.indexOf(g.currentTarget);if(a!==-1&&(h.current!==a||Z!==a))h.current=a,Y0(g)}),Q0=g0(()=>{return M??p?.nodesRef.current.find((g)=>g.id===x)?.context?.dataRef?.current.orientation}),J0=g0(()=>{return sK(Q,c.current)}),B0=g0((g)=>{if($0.current=!1,K0.current=!0,g.which===229)return;if(!i.current&&g.currentTarget===P.current)return;if(W&&jn(g.key,V,H,A)){if(!DG(g.key,Q0()))q6(g);if(b.setOpen(!1,p0(T0.listNavigation,g.nativeEvent)),P1(C))if(B)p?.events.emit("virtualfocus",C);else C.focus();return}let a=h.current,I0=sK(Q,F),A0=l_(Q,F);if(!j){if(g.key==="Home")q6(g),h.current=I0,Y0(g);if(g.key==="End")q6(g),h.current=A0,Y0(g)}if(I!=null){let F0=I(g,h.current,Q,V,K,H,F,I0,A0);if(F0!=null)h.current=F0,Y0(g);if(V==="both")return}if(DG(g.key,V)){if(q6(g),k&&!B&&g5(g.currentTarget.ownerDocument)===g.currentTarget){h.current=bL(g.key,V,H)?I0:A0,Y0(g);return}if(bL(g.key,V,H))if(K)if(a>=A0)if(z&&a!==Q.current.length)h.current=-1;else K0.current=!1,h.current=I0;else h.current=F$(Q.current,{startingIndex:a,disabledIndices:F});else h.current=Math.min(A0,F$(Q.current,{startingIndex:a,disabledIndices:F}));else if(K)if(a<=I0)if(z&&a!==-1)h.current=Q.current.length;else K0.current=!1,h.current=A0;else h.current=F$(Q.current,{startingIndex:a,decrement:!0,disabledIndices:F});else h.current=Math.max(I0,F$(Q.current,{startingIndex:a,decrement:!0,disabledIndices:F}));if(p_(Q.current,h.current))h.current=-1;Y0(g)}}),W0=f8.useMemo(()=>{return{onFocus(a){K0.current=!0,l(a)},onClick:({currentTarget:a})=>a.focus({preventScroll:!0}),onMouseMove(a){if(K0.current=!0,E.current=!1,_)l(a)},onPointerLeave(a){if(!i.current||!$0.current||a.pointerType==="touch")return;K0.current=!0;let I0=a.relatedTarget;if(!_||Q.current.includes(I0))return;if(!d.current)return;if(m.current?.(),m.current=null,h.current=-1,Y0(a),!B){let A0=P.current,F0=g5(X1(A0));if(A0&&e0(A0,F0))A0.focus({preventScroll:!0})}}}},[l,i,P,_,Q,Y0,d,B]),L0=f8.useMemo(()=>{return B&&k&&G0&&{"aria-activedescendant":`${D}-${Z}`}},[B,k,G0,D,Z]),_0=f8.useMemo(()=>{return{"aria-orientation":V==="both"?void 0:V,...!j?L0:{},onKeyDown(g){if(g.key==="Tab"&&g.shiftKey&&k&&!B){let a=k5(g.nativeEvent);if(a&&!e0(P.current,a))return;if(q6(g),b.setOpen(!1,p0(T0.focusOut,g.nativeEvent)),P1(C))C.focus();return}B0(g)},onPointerMove(){$0.current=!0}}},[L0,B0,P,V,j,b,k,B,C]),D0=f8.useMemo(()=>{function g(A0){b.setOpen(!0,p0(T0.listNavigation,A0.nativeEvent,A0.currentTarget))}function a(A0){if(U==="auto"&&iK(A0.nativeEvent))t.current=!B}function I0(A0){if(t.current=U,U==="auto"&&rK(A0.nativeEvent))t.current=!0}return{onKeyDown(A0){let F0=b.select("open");$0.current=!1;let u0=A0.key.startsWith("Arrow"),P0=bn(A0.key,Q0(),H),n0=DG(A0.key,V),R0=(W?P0:n0)||A0.key==="Enter"||A0.key.trim()==="";if(B&&F0)return B0(A0);if(!F0&&!L&&u0)return;if(R0){let Y1=DG(A0.key,Q0());r.current=W&&Y1?null:A0.key}if(W){if(P0)if(q6(A0),F0)h.current=J0(),Y0(A0);else g(A0);return}if(n0){if(u.current!=null)h.current=u.current;if(q6(A0),!F0&&L)g(A0);else B0(A0);if(F0)Y0(A0)}return},onFocus(A0){if(b.select("open")&&!B)h.current=-1,Y0(A0)},onPointerDown:I0,onPointerEnter:I0,onMouseDown:a,onClick:a}},[B0,U,J0,W,Y0,b,L,V,Q0,H,u,B]),c0=f8.useMemo(()=>{return{...L0,...D0}},[L0,D0]);return f8.useMemo(()=>X?{reference:c0,floating:_0,item:W0,trigger:D0}:{},[X,c0,_0,D0,W0])}var I$=R(v(),1);function EL($,J){let{listRef:Q,elementsRef:Z,activeIndex:q,onMatch:X,disabledIndices:Y,onTyping:z,enabled:K=!0,resetMs:W=750,selectedIndex:H=null}=J,B="rootStore"in $?$.rootStore:$,U=B.useState("open"),_=U5(),L=I$.useRef(""),F=I$.useRef(H??q??-1),V=I$.useRef(null),M=g0((O)=>{function I(P){let x=Z?.current[P];return!x||V$(x)}function A(P){if(!I(P))return!1;return Y==null||!i_(B$,P,Y)}function b(P,x,p=0){if(P.length===0)return-1;let t=(p%P.length+P.length)%P.length,h=x.toLowerCase();for(let r=0;r<P.length;r+=1){let $0=(t+r)%P.length;if(!P[$0]?.toLowerCase().startsWith(h)||!A($0))continue;return $0}return-1}let k=Q.current;if(L.current.length>0&&O.key===" ")q6(O),z?.(!0);if(L.current.length>0&&L.current[0]!==" "){if(b(k,L.current)===-1&&O.key!==" ")z?.(!1)}if(k==null||O.key.length!==1||O.ctrlKey||O.metaKey||O.altKey)return;if(U&&O.key!==" ")q6(O),z?.(!0);let w=L.current==="";if(w)F.current=H??q??-1;if(k.every((P,x)=>P&&A(x)?P[0]?.toLowerCase()!==P[1]?.toLowerCase():!0)&&L.current===O.key)L.current="",F.current=V.current;L.current+=O.key,_.start(W,()=>{L.current="",F.current=V.current,z?.(!1)});let f=((w?H??q??-1:F.current)??0)+1,j=b(k,L.current,f);if(j!==-1)X?.(j),V.current=j;else if(O.key!==" ")L.current="",z?.(!1)}),D=g0((O)=>{let I=O.relatedTarget,A=B.select("domReferenceElement"),b=B.select("floatingElement");if(e0(A,I)||e0(b,I))return;_.clear(),L.current="",F.current=V.current,z?.(!1)});y0(()=>{if(!U&&H!==null)return;if(_.clear(),V.current=null,L.current!=="")L.current=""},[U,H,_]),y0(()=>{if(U&&L.current==="")F.current=H??q??-1},[U,H,q]);let N=I$.useMemo(()=>({onKeyDown:M,onBlur:D}),[M,D]);return I$.useMemo(()=>K?{reference:N,floating:N}:{},[K,N])}var kP=0.1,En=kP*kP,H5=0.5;function OG($,J,Q,Z,q,X){return Z>=J!==X>=J&&$<=(q-Q)*(J-Z)/(X-Z)+Q}function AG($,J,Q,Z,q,X,Y,z,K,W){let H=!1;if(OG($,J,Q,Z,q,X))H=!H;if(OG($,J,q,X,Y,z))H=!H;if(OG($,J,Y,z,K,W))H=!H;if(OG($,J,K,W,Q,Z))H=!H;return H}function yn($,J,Q){return $>=Q.x&&$<=Q.x+Q.width&&J>=Q.y&&J<=Q.y+Q.height}function wG($,J,Q,Z,q,X){let Y=Math.min(Q,q),z=Math.max(Q,q),K=Math.min(Z,X),W=Math.max(Z,X);return $>=Y&&$<=z&&J>=K&&J<=W}function T$($={}){let{blockPointerEvents:J=!1}=$,Q=new b8,Z=({x:q,y:X,placement:Y,elements:z,onClose:K,nodeId:W,tree:H})=>{let B=Y?.split("-")[0],U=!1,_=null,L=null,F=typeof performance<"u"?performance.now():0;function V(D,N){let O=performance.now(),I=O-F;if(_===null||L===null||I===0)return _=D,L=N,F=O,!1;let A=D-_,b=N-L,k=A*A+b*b,w=I*I*En;return _=D,L=N,F=O,k<w}function M(){Q.clear(),K()}return function(N){Q.clear();let{domReference:O,floating:I}=z;if(!O||!I||B==null||q==null||X==null)return;let{clientX:A,clientY:b}=N,k=k5(N),w=N.type==="mouseleave",C=e0(I,k),y=e0(O,k);if(C){if(U=!0,!w)return}if(y){if(U=!1,!w){U=!0;return}}if(w&&L1(N.relatedTarget)&&e0(I,N.relatedTarget))return;function f(){return Boolean(H&&M9(H.nodesRef.current,W).length>0)}function j(){if(!f())M()}if(f())return;let P=O.getBoundingClientRect(),x=I.getBoundingClientRect(),p=q>x.right-x.width/2,t=X>x.bottom-x.height/2,h=x.width>P.width,r=x.height>P.height,$0=(h?P:x).left,Y0=(h?P:x).right,e=(r?P:x).top,H0=(r?P:x).bottom;if(B==="top"&&X>=P.bottom-1||B==="bottom"&&X<=P.top+1||B==="left"&&q>=P.right-1||B==="right"&&q<=P.left+1){j();return}let K0=!1;switch(B){case"top":K0=wG(A,b,$0,P.top+1,Y0,x.bottom-1);break;case"bottom":K0=wG(A,b,$0,x.top+1,Y0,P.bottom-1);break;case"left":K0=wG(A,b,x.right-1,H0,P.left+1,e);break;case"right":K0=wG(A,b,P.right-1,H0,x.left+1,e);break;default:}if(K0)return;if(U&&!yn(A,b,P)){j();return}if(!w&&V(A,b)){j();return}let E=!1;switch(B){case"top":{let m=h?H5/2:H5*4,c=h?q+m:p?q+m:q-m,i=h?q-m:p?q+m:q-m,u=X+H5+1,d=p?x.bottom-H5:h?x.bottom-H5:x.top,o=p?h?x.bottom-H5:x.top:x.bottom-H5;E=AG(A,b,c,u,i,u,x.left,d,x.right,o);break}case"bottom":{let m=h?H5/2:H5*4,c=h?q+m:p?q+m:q-m,i=h?q-m:p?q+m:q-m,u=X-H5,d=p?x.top+H5:h?x.top+H5:x.bottom,o=p?h?x.top+H5:x.bottom:x.top+H5;E=AG(A,b,c,u,i,u,x.left,d,x.right,o);break}case"left":{let m=r?H5/2:H5*4,c=r?X+m:t?X+m:X-m,i=r?X-m:t?X+m:X-m,u=q+H5+1,d=t?x.right-H5:r?x.right-H5:x.left,o=t?r?x.right-H5:x.left:x.right-H5;E=AG(A,b,d,x.top,o,x.bottom,u,c,u,i);break}case"right":{let m=r?H5/2:H5*4,c=r?X+m:t?X+m:X-m,i=r?X-m:t?X+m:X-m,u=q-H5,d=t?x.left+H5:r?x.left+H5:x.right,o=t?r?x.left+H5:x.right:x.left+H5;E=AG(A,b,u,c,u,i,d,x.top,o,x.bottom);break}default:}if(!E)j();else if(!U)Q.start(40,j);return}};return Z.__options={...$,blockPointerEvents:J},Z}var kG=R(v(),1),yL=kG.createContext(void 0);function h5($){let J=kG.useContext(yL);if(J===void 0&&!$)throw Error(F1(47));return J}var e7=R(v(),1),IP=R(J5(),1);function Pn(){return{...UG(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}var Rn={..._G,disabled:$1(($)=>$.disabled),instantType:$1(($)=>$.instantType),openMethod:$1(($)=>$.openMethod),openChangeReason:$1(($)=>$.openChangeReason),modal:$1(($)=>$.modal),focusManagerModal:$1(($)=>$.focusManagerModal),stickIfOpen:$1(($)=>$.stickIfOpen),titleElementId:$1(($)=>$.titleElementId),descriptionElementId:$1(($)=>$.descriptionElementId),openOnHover:$1(($)=>$.openOnHover),closeDelay:$1(($)=>$.closeDelay),hasViewport:$1(($)=>$.hasViewport)};class FQ extends A${constructor($,J,Q=!1){let Z={...Pn(),...$},q=new Z7;if(Z.open&&$?.mounted===void 0)Z.mounted=!0;Z.floatingRootContext=DP(q,J,Q);super(Z,{popupRef:e7.createRef(),backdropRef:e7.createRef(),internalBackdropRef:e7.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:e7.createRef(),beforeContentFocusGuardRef:e7.createRef(),stickIfOpenTimeout:new b8,triggerElements:q},Rn)}setOpen=($,J)=>{let Q=J.reason===T0.triggerHover,Z=J.reason===T0.triggerPress&&J.event.detail===0,q=!$&&(J.reason===T0.escapeKey||J.reason==null),X=zG(J),Y=this.select("activeTriggerId");if(!$&&J.reason===T0.closePress&&J.trigger==null&&Y!=null)J.trigger=this.context.triggerElements.getById(Y)??this.select("activeTriggerElement")??void 0;if(this.context.onOpenChange?.($,J),J.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange($,J);let z=()=>{let K={open:$,openChangeReason:J.reason};YG(K,$,J.trigger,X()),this.update(K)};if(Q)this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($G,()=>{this.set("stickIfOpen",!1)}),IP.flushSync(z);else z();if(Z||q)this.set("instantType",Z?"click":"dismiss");else if(J.reason===T0.focusOut)this.set("instantType","focus");else this.set("instantType",void 0)};static useStore($,J){let{store:Q,internalStore:Z}=LP($,(q,X)=>new FQ(J,q,X));return e7.useEffect(()=>Z?.disposeEffect(),[Z]),Q}disposeEffect=()=>{return this.context.stickIfOpenTimeout.disposeEffect()}}function TP({props:$}){let{children:J,open:Q,defaultOpen:Z=!1,onOpenChange:q,onOpenChangeComplete:X,modal:Y=!1,handle:z,triggerId:K,defaultTriggerId:W=null}=$,H=FQ.useStore(z?.store,{modal:Y,open:Z,openProp:Q,activeTriggerId:W,triggerIdProp:K});KG(H,Q,Z,W),H.useControlledProp("openProp",Q),H.useControlledProp("triggerIdProp",K);let B=H.useState("open"),U=H.useState("mounted"),_=H.useState("payload"),L=x8()!=null;H.useContextCallback("onOpenChange",q),H.useContextCallback("onOpenChangeComplete",X),FP(H,B),WG(H);let{forceUnmount:F}=HG(B,H,()=>{H.update({stickIfOpen:!0,openChangeReason:null})});H.useSyncedValues({modal:Y,nested:L}),q7.useEffect(()=>{if(!B)H.context.stickIfOpenTimeout.clear()},[H,B]);let V=q7.useCallback(()=>{H.setOpen(!1,p0(T0.imperativeAction))},[H]);q7.useImperativeHandle($.actionsRef,()=>({unmount:F,close:V}),[F,V]);let M=B||U,D=q7.useMemo(()=>({store:H}),[H]);return T(yL.Provider,{value:D,children:[M&&G(Cn,{store:H,modal:Y}),typeof J==="function"?J({payload:_}):J]})}function bP($){if(h5(!0))return G(TP,{props:$});return G(dq,{children:G(TP,{props:$})})}function Cn({store:$,modal:J}){let Q=$.useState("floatingRootContext"),Z=iq(Q,{outsidePressEvent:{mouse:J==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),q=Z.reference??T1,X=Z.trigger??T1,Y=q7.useMemo(()=>h8(_Q,Z.floating),[Z.floating]);return BG($,{activeTriggerProps:q,inactiveTriggerProps:X,popupProps:Y}),null}var $2=R(v(),1);var MQ=R(v(),1);var IG=R(v(),1),Sn=IG.createContext(void 0);function VQ($=!1){let J=IG.useContext(Sn);if(J===void 0&&!$)throw Error(F1(16));return J}var jP=R(v(),1);function EP($){let{focusableWhenDisabled:J,disabled:Q,composite:Z=!1,tabIndex:q=0,isNativeButton:X}=$,Y=Z&&J!==!1,z=Z&&J===!1;return{props:jP.useMemo(()=>{let W={onKeyDown(H){if(Q&&J&&H.key!=="Tab")H.preventDefault()}};if(!Z){if(W.tabIndex=q,!X&&Q)W.tabIndex=J?q:-1}if(X&&(J||Y)||!X&&Q)W["aria-disabled"]=Q;if(X&&(!J||z))W.disabled=Q;return W},[Z,Q,J,Y,z,X,q])}}function f6($={}){let{disabled:J=!1,focusableWhenDisabled:Q,tabIndex:Z=0,native:q=!0,composite:X}=$,Y=MQ.useRef(null),z=VQ(!0),K=X??z!==void 0,{props:W}=EP({focusableWhenDisabled:Q,disabled:J,composite:K,tabIndex:Z,isNativeButton:q}),H=MQ.useCallback(()=>{let _=Y.current;if(!PL(_))return;if(K&&J&&W.disabled===void 0&&_.disabled)_.disabled=!1},[J,W.disabled,K]);y0(H,[H]);let B=MQ.useCallback((_={})=>{let{onClick:L,onMouseDown:F,onKeyUp:V,onKeyDown:M,onPointerDown:D,...N}=_;return h8({onClick(O){if(J){O.preventDefault();return}L?.(O)},onMouseDown(O){if(!J)F?.(O)},onKeyDown(O){if(J)return;if(uq(O),M?.(O),O.baseUIHandlerPrevented)return;let I=O.target===O.currentTarget,A=O.currentTarget,b=PL(A),k=!q&&hn(A),w=I&&(q?b:!k),C=O.key==="Enter",y=O.key===" ",f=A.getAttribute("role"),j=f?.startsWith("menuitem")||f==="option"||f==="gridcell";if(I&&K&&y){if(O.defaultPrevented&&j)return;if(O.preventDefault(),k||q&&b)A.click(),O.preventBaseUIHandler();else if(w)L?.(O),O.preventBaseUIHandler();return}if(w){if(!q&&(y||C))O.preventDefault();if(!q&&C)L?.(O)}},onKeyUp(O){if(J)return;if(uq(O),V?.(O),O.target===O.currentTarget&&q&&K&&PL(O.currentTarget)&&O.key===" "){O.preventDefault();return}if(O.baseUIHandlerPrevented)return;if(O.target===O.currentTarget&&!q&&!K&&O.key===" ")L?.(O)},onPointerDown(O){if(J){O.preventDefault();return}D?.(O)}},q?{type:"button"}:{role:"button"},W,N)},[J,W,K,q]),U=g0((_)=>{Y.current=_,H()});return{getButtonProps:B,buttonRef:U}}function PL($){return P1($)&&$.tagName==="BUTTON"}function hn($){return Boolean($?.tagName==="A"&&$?.href)}var CL=function($){return $.open="data-open",$.closed="data-closed",$[$.startingStyle=w$.startingStyle]="startingStyle",$[$.endingStyle=w$.endingStyle]="endingStyle",$.anchorHidden="data-anchor-hidden",$.side="data-side",$.align="data-align",$}({}),RL=function($){return $.popupOpen="data-popup-open",$.pressed="data-pressed",$}({}),xn={[RL.popupOpen]:""},fn={[RL.popupOpen]:"",[RL.pressed]:""},vn={[CL.open]:""},gn={[CL.closed]:""},un={[CL.anchorHidden]:""},TG={open($){if($)return xn;return null}},aq={open($){if($)return fn;return null}},w6={open($){if($)return vn;return gn},anchorHidden($){if($)return un;return null}};var yP=300;function x5($){return x6($,"base-ui")}var PP=R(v(),1),SL=R(J5(),1);function bG($,J){let Q=PP.useRef(null);function Z(X){SL.flushSync(()=>{$.setOpen(!1,p0(T0.focusOut,X.nativeEvent,X.currentTarget))}),Ty(Q.current)?.focus()}function q(X){let Y=$.select("positionerElement");if(Y&&$7(X,Y))$.context.beforeContentFocusGuardRef.current?.focus();else{SL.flushSync(()=>{$.setOpen(!1,p0(T0.focusOut,X.nativeEvent,X.currentTarget))});let z=Iy($.context.triggerFocusTargetRef.current||J.current);while(z!==null&&e0(Y,z)){let K=z;if(z=GQ(z),z===K)break}z?.focus()}}return{preFocusGuardRef:Q,handlePreFocusGuardFocus:Z,handleFocusTargetFocus:q}}var eq=R(v(),1);var tq=R(v(),1);function RP($){let J=tq.useRef(""),Q=tq.useCallback((q)=>{if(q.defaultPrevented)return;J.current=q.pointerType,$(q,q.pointerType)},[$]);return{onClick:tq.useCallback((q)=>{if(q.detail===0){$(q,"keyboard");return}if("pointerType"in q)$(q,q.pointerType);else $(q,J.current);J.current=""},[$]),onPointerDown:Q}}var CP=R(v(),1);function jG($,J){let Q=CP.useRef($),Z=g0(J);y0(()=>{if(Q.current===$)return;Z(Q.current)},[$,Z]),y0(()=>{Q.current=$},[$])}function hL($,J){let Q=g0((X,Y)=>{if(!(typeof $==="function"?$():$))J(Y||(p1.os.ios?"touch":""))}),{onClick:Z,onPointerDown:q}=RP(Q);return eq.useMemo(()=>({onClick:Z,onPointerDown:q}),[Z,q])}function SP($){let[J,Q]=eq.useState(null),Z=hL($,Q);return jG($,(q)=>{if(q&&!$)Q(null)}),eq.useMemo(()=>({openMethod:J,triggerProps:Z}),[J,Z])}var hP=$2.forwardRef(function(J,Q){let{render:Z,className:q,style:X,disabled:Y=!1,nativeButton:z=!0,handle:K,payload:W,openOnHover:H=!1,delay:B=yP,closeDelay:U=0,id:_,...L}=J,F=h5(!0),V=K?.store??F?.store;if(!V)throw Error(F1(74));let M=x5(_),D=V.useState("isTriggerActive",M),N=V.useState("floatingRootContext"),O=V.useState("isOpenedByTrigger",M),I=V.useState("triggerPopupId",M),A=$2.useRef(null),{registerTrigger:b,isMountedByThisTrigger:k}=GG(M,A,V,{payload:W,disabled:Y,openOnHover:H,closeDelay:U}),w=V.useState("openChangeReason"),C=V.useState("stickIfOpen"),y=V.useState("openMethod"),f=V.useState("focusManagerModal"),j=k$(N,{enabled:!Y&&N!=null&&H&&(y!=="touch"||w!==T0.triggerPress),mouseOnly:!0,move:!1,handleClose:T$(),restMs:B,delay:{close:U},triggerElementRef:A,isActiveTrigger:D,isClosing:()=>V.select("transitionStatus")==="ending"}),P=N$(N,{enabled:N!=null,stickIfOpen:C}),x=hL(()=>V.select("open"),(E)=>{V.set("openMethod",E)}),p=V.useState("triggerProps",k),{getButtonProps:t,buttonRef:h}=f6({disabled:Y,native:z}),r={open(E){if(E&&w===T0.triggerPress)return aq.open(E);return TG.open(E)}},{preFocusGuardRef:$0,handlePreFocusGuardFocus:Y0,handleFocusTargetFocus:e}=bG(V,A),K0=o0("button",J,{state:{disabled:Y,open:O},ref:[h,Q,b,A],props:[P.reference,j,p,x,{[JG]:"",id:M,"aria-haspopup":"dialog","aria-expanded":O,"aria-controls":I},L,t],stateAttributesMapping:r});if(k&&!f)return T($2.Fragment,{children:[G(V9,{ref:$0,onFocus:Y0}),G($2.Fragment,{children:K0},M),G(V9,{ref:V.context.triggerFocusTargetRef,onFocus:e})]});return G($2.Fragment,{children:K0},M)});var fP=R(v(),1);var EG=R(v(),1),xL=EG.createContext(void 0);function xP(){let $=EG.useContext(xL);if($===void 0)throw Error(F1(45));return $}var vP=fP.forwardRef(function(J,Q){let{keepMounted:Z=!1,...q}=J,{store:X}=h5();if(!(X.useState("mounted")||Z))return null;return G(xL.Provider,{value:Z,children:G(mq,{ref:Q,...q})})});var AQ=R(v(),1);function DQ($){if(HQ(19))return $;return $?"true":void 0}var yG=R(v(),1),fL=yG.createContext(void 0);function NQ(){let $=yG.useContext(fL);if(!$)throw Error(F1(46));return $}var v6=R(v(),1);var PG=R(v(),1),mn=PG.createContext(void 0);function J2(){return PG.useContext(mn)?.direction??"ltr"}var cn=($)=>({name:"arrow",options:$,async fn(J){let{x:Q,y:Z,placement:q,rects:X,platform:Y,elements:z,middlewareData:K}=J,{element:W,padding:H=0,offsetParent:B="real"}=c6($,J)||{};if(W==null)return{};let U=cQ(H),_={x:Q,y:Z},L=p$(q),F=d$(L),V=await Y.getDimensions(W),M=L==="y",D=M?"top":"left",N=M?"bottom":"right",O=M?"clientHeight":"clientWidth",I=X.reference[F]+X.reference[L]-_[L]-X.floating[F],A=_[L]-X.reference[L],b=B==="real"?await Y.getOffsetParent?.(W):z.floating,k=z.floating[O]||X.floating[F];if(!k||!await Y.isElement?.(b))k=z.floating[O]||X.floating[F];let w=I/2-A/2,C=k/2-V[F]/2-1,y=Math.min(U[D],C),f=Math.min(U[N],C),j=y,P=k-V[F]-f,x=k/2-V[F]/2+w,p=c$(j,x,P),t=!K.arrow&&d6(q)!=null&&x!==p&&X.reference[F]/2-(x<j?y:f)-V[F]/2<0,h=t?x<j?x-j:x-P:0;return{[L]:_[L]+h,data:{[L]:p,centerOffset:x-p-h,...t&&{alignmentOffset:h}},reset:t}}}),gP=($,J)=>({...cn($),options:[$,J]});var dn=nQ().fn,uP={name:"hide",async fn($){let{width:J,height:Q,x:Z,y:q}=$.rects.reference,X=J===0&&Q===0&&Z===0&&q===0;return{data:{referenceHidden:(await dn($)).data?.referenceHidden||X}}}};var $X={sideX:"left",sideY:"top"},RG={name:"adaptiveOrigin",async fn($){let{x:J,y:Q,rects:{floating:Z},elements:{floating:q},platform:X,strategy:Y,placement:z}=$,K=h1(q),W=K.getComputedStyle(q);if(!(W.transitionDuration!=="0s"&&W.transitionDuration!==""))return{x:J,y:Q,data:$X};let B=await X.getOffsetParent?.(q),U={width:0,height:0};if(Y==="fixed"&&K?.visualViewport)U={width:K.visualViewport.width,height:K.visualViewport.height};else if(B===K){let D=X1(q);U={width:D.documentElement.clientWidth,height:D.documentElement.clientHeight}}else if(await X.isElement?.(B))U=await X.getDimensions(B);let _=E8(z),L=J,F=Q;if(_==="left")L=U.width-(J+Z.width);if(_==="top")F=U.height-(Q+Z.height);let V=_==="left"?"right":$X.sideX,M=_==="top"?"bottom":$X.sideY;return{x:L,y:F,data:{sideX:V,sideY:M}}}};function dP($,J,Q){let Z=$==="inline-start"||$==="inline-end";return{top:"top",right:Z?Q?"inline-start":"inline-end":"right",bottom:"bottom",left:Z?Q?"inline-end":"inline-start":"left"}[J]}function mP($,J,Q){let{rects:Z,placement:q}=$;return{side:dP(J,E8(q),Q),align:d6(q)||"center",anchor:{width:Z.reference.width,height:Z.reference.height},positioner:{width:Z.floating.width,height:Z.floating.height}}}function CG($){let{anchor:J,positionMethod:Q="absolute",side:Z="bottom",sideOffset:q=0,align:X="center",alignOffset:Y=0,collisionBoundary:z,collisionPadding:K=5,sticky:W=!1,arrowPadding:H=5,disableAnchorTracking:B=!1,inline:U,keepMounted:_=!1,floatingRootContext:L,mounted:F,collisionAvoidance:V,shiftCrossAxis:M=!1,nodeId:D,adaptiveOrigin:N,lazyFlip:O=!1,externalTree:I}=$,[A,b]=v6.useState(null);if(!F&&A!==null)b(null);let k=V.side||"flip",w=V.align||"flip",C=V.fallbackAxisSide||"end",y=typeof J==="function"?J:void 0,f=g0(y),j=y?f:J,P=F5(J),x=F5(F),t=J2()==="rtl",h=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":t?"left":"right","inline-start":t?"right":"left"}[Z],r=X==="center"?h:`${h}-${X}`,$0=K,Y0=1,e=Z==="bottom"?Y0:0,H0=Z==="top"?Y0:0,K0=Z==="right"?Y0:0,E=Z==="left"?Y0:0;if(typeof $0==="number")$0={top:$0+e,right:$0+E,bottom:$0+H0,left:$0+K0};else if($0)$0={top:($0.top||0)+e,right:($0.right||0)+E,bottom:($0.bottom||0)+H0,left:($0.left||0)+K0};let m={boundary:z==="clipping-ancestors"?"clippingAncestors":z,padding:$0},c=v6.useRef(null),i=F5(q),u=F5(Y),d=typeof q!=="function"?q:0,o=typeof Y!=="function"?Y:0,S=[];if(U)S.push(U);S.push(lQ((n)=>{let N0=mP(n,Z,t),w0=typeof i.current==="function"?i.current(N0):i.current,v0=typeof u.current==="function"?u.current(N0):u.current;return{mainAxis:w0,crossAxis:v0,alignmentAxis:v0}},[d,o,t,Z]));let s=w==="none"&&k!=="shift",G0=!s&&(W||M||k==="shift"),l=k==="none"?null:sQ({...m,padding:{top:$0.top+Y0,right:$0.right+Y0,bottom:$0.bottom+Y0,left:$0.left+Y0},mainAxis:!M&&k==="flip",crossAxis:w==="flip"?"alignment":!1,fallbackAxisSideDirection:C}),Q0=s?null:iQ((n)=>{let N0=X1(n.elements.floating).documentElement;return{...m,rootBoundary:M?{x:0,y:0,width:N0.clientWidth,height:N0.clientHeight}:void 0,mainAxis:w!=="none",crossAxis:G0,limiter:W||M?void 0:rQ((w0)=>{if(!c.current)return{};let{width:v0,height:r0}=c.current.getBoundingClientRect(),K1=z6(E8(w0.placement)),x1=K1==="y"?v0:r0,s1=K1==="y"?$0.left+$0.right:$0.top+$0.bottom;return{offset:x1/2+s1/2}})}},[m,W,M,$0,w]);if(k==="shift"||w==="shift"||X==="center")S.push(Q0,l);else S.push(l,Q0);S.push(oQ({...m,apply({elements:{floating:n},availableWidth:N0,availableHeight:w0,rects:v0}){if(!x.current)return;let r0=n.style;r0.setProperty("--available-width",`${N0}px`),r0.setProperty("--available-height",`${w0}px`);let K1=h1(n).devicePixelRatio||1,{x:x1,y:s1,width:z0,height:C0}=v0.reference,h0=(Math.round((x1+z0)*K1)-Math.round(x1*K1))/K1,l0=(Math.round((s1+C0)*K1)-Math.round(s1*K1))/K1;r0.setProperty("--anchor-width",`${h0}px`),r0.setProperty("--anchor-height",`${l0}px`)}}),gP((n)=>({element:c.current||X1(n.elements.floating).createElement("div"),padding:H,offsetParent:"floating"}),[H]),{name:"transformOrigin",fn(n){let{elements:N0,middlewareData:w0,placement:v0,rects:r0,y:K1}=n,x1=E8(v0),s1=z6(x1),z0=c.current,C0=w0.arrow?.x||0,h0=w0.arrow?.y||0,l0=z0?.clientWidth||0,j0=z0?.clientHeight||0,V1=C0+l0/2,r1=h0+j0/2,w1=Math.abs(w0.shift?.y||0),e1=r0.reference.height/2,D5=typeof q==="function"?q(mP(n,Z,t)):q,X0=w1>D5,O0={top:`${V1}px calc(100% + ${D5}px)`,bottom:`${V1}px ${-D5}px`,left:`calc(100% + ${D5}px) ${r1}px`,right:`${-D5}px ${r1}px`}[x1],x0=`${V1}px ${r0.reference.y+e1-K1}px`;return N0.floating.style.setProperty("--transform-origin",G0&&s1==="y"&&X0?x0:O0),{}}},uP,N),y0(()=>{if(!F&&L)L.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[F,L]);let J0=v6.useMemo(()=>({elementResize:!B&&typeof ResizeObserver<"u",layoutShift:!B&&typeof IntersectionObserver<"u"}),[B]),{refs:B0,elements:W0,x:L0,y:_0,middlewareData:D0,update:c0,placement:g,context:a,isPositioned:I0,floatingStyles:A0}=OL({rootContext:L,open:_?F:void 0,placement:r,middleware:S,strategy:Q,whileElementsMounted:_?void 0:(...n)=>V2(...n,J0),nodeId:D,externalTree:I}),{sideX:F0,sideY:u0}=D0.adaptiveOrigin||$X,P0=I0?Q:"fixed",n0=v6.useMemo(()=>{let n=N?{position:P0,[F0]:L0,[u0]:_0}:{position:P0,...A0};if(!I0)n.opacity=0;return n},[N,P0,F0,L0,u0,_0,A0,I0]),R0=v6.useRef(null);y0(()=>{if(!F)return;let n=P.current,N0=typeof n==="function"?n():n,v0=(cP(N0)?N0.current:N0)||null||null;if(v0!==R0.current)B0.setPositionReference(v0),R0.current=v0},[F,B0,j,P]),v6.useEffect(()=>{if(!F)return;let n=P.current;if(typeof n==="function")return;if(cP(n)&&n.current!==R0.current)B0.setPositionReference(n.current),R0.current=n.current},[F,B0,j,P]),v6.useEffect(()=>{if(_&&F&&W0.reference&&W0.floating)return V2(W0.reference,W0.floating,c0,J0);return},[_,F,W0,c0,J0]);let Y1=E8(g),z1=dP(Z,Y1,t),a0=d6(g)||"center",C1=Boolean(D0.hide?.referenceHidden);y0(()=>{if(O&&F&&I0)b(Y1)},[O,F,I0,Y1]);let g1=v6.useMemo(()=>({position:"absolute",top:D0.arrow?.y,left:D0.arrow?.x}),[D0.arrow]),b1=D0.arrow?.centerOffset!==0;return v6.useMemo(()=>({positionerStyles:n0,arrowStyles:g1,arrowRef:c,arrowUncentered:b1,side:z1,align:a0,physicalSide:Y1,anchorHidden:C1,refs:B0,context:a,isPositioned:I0,update:c0}),[n0,g1,c,b1,z1,a0,Y1,C1,B0,a,I0,c0])}function cP($){return $!=null&&"current"in $}var pP=R(v(),1);var SG=pP.forwardRef(function(J,Q){let{cutout:Z,...q}=J,X;if(Z){let Y=Z.getBoundingClientRect();X=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${Y.left}px ${Y.top}px,${Y.left}px ${Y.bottom}px,${Y.right}px ${Y.bottom}px,${Y.right}px ${Y.top}px,${Y.left}px ${Y.top}px)`}return G("div",{ref:Q,role:"presentation","data-base-ui-inert":"",...q,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:X}})});function OQ($){return $==="starting"?iy:T1}function hG($,J,{styles:Q,transitionStatus:Z,props:q,refs:X,hidden:Y,inert:z=!1}){let K={...Q};if(z)K.pointerEvents="none";return o0("div",$,{state:J,ref:X,props:[{role:"presentation",hidden:Y,style:K},OQ(Z),q],stateAttributesMapping:w6})}var nP=R(v(),1);var lP={},iP={},rP="";function pn($){if(typeof document>"u")return!1;let J=X1($);return h1(J).innerWidth-J.documentElement.clientWidth>0}function ln($){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;let Q=X1($),Z=Q.documentElement,q=Q.body,X=s9(Z)?Z:q,Y=X.style.overflowY,z=Z.style.scrollbarGutter;Z.style.scrollbarGutter="stable",X.style.overflowY="scroll";let K=X.offsetWidth;X.style.overflowY="hidden";let W=X.offsetWidth;return X.style.overflowY=Y,Z.style.scrollbarGutter=z,K===W}function rn($){let J=X1($),Q=J.documentElement,Z=J.body,q=s9(Q)?Q:Z,X={overflowY:q.style.overflowY,overflowX:q.style.overflowX};return Object.assign(q.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(q.style,X)}}function sn($){let J=X1($),Q=J.documentElement,Z=J.body,q=h1(Q),X=0,Y=0,z=!1,K=F9.create();if(p1.engine.webkit&&(q.visualViewport?.scale??1)!==1)return()=>{};function W(){let _=q.getComputedStyle(Q),L=q.getComputedStyle(Z),M=(_.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";X=Q.scrollTop,Y=Q.scrollLeft,lP={scrollbarGutter:Q.style.scrollbarGutter,overflowY:Q.style.overflowY,overflowX:Q.style.overflowX},rP=Q.style.scrollBehavior,iP={position:Z.style.position,height:Z.style.height,width:Z.style.width,boxSizing:Z.style.boxSizing,overflowY:Z.style.overflowY,overflowX:Z.style.overflowX,scrollBehavior:Z.style.scrollBehavior};let D=Q.scrollHeight>Q.clientHeight,N=Q.scrollWidth>Q.clientWidth,O=_.overflowY==="scroll"||L.overflowY==="scroll",I=_.overflowX==="scroll"||L.overflowX==="scroll",A=Math.max(0,q.innerWidth-Z.clientWidth),b=Math.max(0,q.innerHeight-Z.clientHeight),k=parseFloat(L.marginTop)+parseFloat(L.marginBottom),w=parseFloat(L.marginLeft)+parseFloat(L.marginRight),C=s9(Q)?Q:Z;if(z=ln($),z){Q.style.scrollbarGutter=M,C.style.overflowY="hidden",C.style.overflowX="hidden";return}if(Object.assign(Q.style,{scrollbarGutter:M,overflowY:"hidden",overflowX:"hidden"}),D||O)Q.style.overflowY="scroll";if(N||I)Q.style.overflowX="scroll";Object.assign(Z.style,{position:"relative",height:k||b?`calc(100dvh - ${k+b}px)`:"100dvh",width:w||A?`calc(100vw - ${w+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),Z.scrollTop=X,Z.scrollLeft=Y,Q.setAttribute("data-base-ui-scroll-locked",""),Q.style.scrollBehavior="unset"}function H(){if(Object.assign(Q.style,lP),Object.assign(Z.style,iP),!z)Q.scrollTop=X,Q.scrollLeft=Y,Q.removeAttribute("data-base-ui-scroll-locked"),Q.style.scrollBehavior=rP}function B(){H(),K.request(W)}W();let U=U1(q,"resize",B);return()=>{if(K.cancel(),H(),typeof q.removeEventListener==="function")U()}}class sP{lockCount=0;restore=null;timeoutLock=b8.create();timeoutUnlock=b8.create();acquire($){if(this.lockCount+=1,this.lockCount===1&&this.restore===null)this.timeoutLock.start(0,()=>this.lock($));return this.release}release=()=>{if(this.lockCount-=1,this.lockCount===0&&this.restore)this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{if(this.lockCount===0&&this.restore)this.restore?.(),this.restore=null};lock($){if(this.lockCount===0||this.restore!==null)return;let Q=X1($).documentElement,Z=h1(Q).getComputedStyle(Q).overflowY;if(Z==="hidden"||Z==="clip"){this.restore=d1;return}let q=p1.os.ios||!pn($);this.restore=q?rn($):sn($)}}var on=new sP;function oP($=!0,J=null){y0(()=>{if(!$)return;return on.acquire(J)},[$,J])}var nn=20;function xG($,J,Q,Z){let[q,X]=nP.useState(!1);y0(()=>{if(!$||!J||Q==null){X(!1);return}let Y=X1(Q).documentElement.clientWidth,z=Q.offsetWidth;X(Y>0&&z>0&&z>=Y-nn)},[$,J,Q]),oP($&&(!J||q),Z)}var aP=AQ.forwardRef(function(J,Q){let{render:Z,className:q,style:X,anchor:Y,positionMethod:z="absolute",side:K="bottom",align:W="center",sideOffset:H=0,alignOffset:B=0,collisionBoundary:U="clipping-ancestors",collisionPadding:_=5,arrowPadding:L=5,sticky:F=!1,disableAnchorTracking:V=!1,collisionAvoidance:M=QG,...D}=J,{store:N}=h5(),O=xP(),I=D$(),A=N.useState("floatingRootContext"),b=N.useState("mounted"),k=N.useState("open"),w=N.useState("openChangeReason"),C=N.useState("activeTriggerElement"),y=N.useState("modal"),f=N.useState("openMethod"),j=N.useState("positionerElement"),P=N.useState("instantType"),x=N.useState("transitionStatus"),p=N.useState("hasViewport"),t=AQ.useRef(null),h=_4(j,!1,!1),r=CG({anchor:Y,floatingRootContext:A,positionMethod:z,mounted:b,side:K,sideOffset:H,align:W,alignOffset:B,arrowPadding:L,collisionBoundary:U,collisionPadding:_,sticky:F,disableAnchorTracking:V,keepMounted:O,nodeId:I,collisionAvoidance:M,adaptiveOrigin:p?RG:void 0}),$0=A.useState("domReferenceElement");y0(()=>{let K0=$0,E=t.current;if(K0)t.current=K0;if(E&&K0&&K0!==E){N.set("instantType",void 0);let m=new AbortController;return h(()=>{N.set("instantType","trigger-change")},m.signal),()=>{m.abort()}}return},[$0,h,N]),xG(k&&y===!0&&w!==T0.triggerHover,f==="touch",j,C);let Y0=AQ.useCallback((K0)=>{N.set("positionerElement",K0)},[N]),e={open:k,side:r.side,align:r.align,anchorHidden:r.anchorHidden,instant:P},H0=hG(J,e,{styles:r.positionerStyles,transitionStatus:x,props:D,refs:[Q,Y0],hidden:!b,inert:!k});return T(fL.Provider,{value:r,children:[b&&y===!0&&w!==T0.triggerHover&&G(SG,{ref:N.context.internalBackdropRef,inert:DQ(!k),cutout:C}),G(cq,{id:I,children:H0})]})});var uG=R(v(),1);var an="ArrowUp",tn="ArrowDown",en="ArrowLeft",$a="ArrowRight",Ja="Home",Qa="End";var Za=new Set([en,$a]);var qa=new Set([an,tn]);var Xa=new Set([...Za,...qa]),fG=new Set([...Xa,Ja,Qa]);var vG=R(v(),1),Ya=vG.createContext(void 0);function gG($){let J=vG.useContext(Ya);if(J===void 0&&!$)throw Error(F1(69));return J}var Q2=R(v(),1);var tP=Q2.createContext(void 0);function eP(){let[$,J]=Q2.useState(0),Q=g0(()=>{return J((q)=>q+1),()=>{J((q)=>Math.max(0,q-1))}});return{context:Q2.useMemo(()=>({register:Q}),[Q]),hasClosePart:$>0}}function $R($){let{value:J,children:Q}=$;return G(tP.Provider,{value:J,children:Q})}function JR(){let $=Q2.useContext(tP);y0(()=>{return $?.register()},[$])}var za={...w6,...U4},QR=uG.forwardRef(function(J,Q){let{render:Z,className:q,style:X,initialFocus:Y,finalFocus:z,...K}=J,{store:W}=h5(),H=NQ(),B=gG(!0)!=null,{context:U,hasClosePart:_}=eP(),L=W.useState("open"),F=W.useState("openMethod"),V=W.useState("instantType"),M=W.useState("transitionStatus"),D=W.useState("popupProps"),N=W.useState("titleElementId"),O=W.useState("descriptionElementId"),I=W.useState("modal"),A=W.useState("mounted"),b=W.useState("openChangeReason"),k=W.useState("activeTriggerElement"),w=W.useState("floatingRootContext"),C=w.useState("floatingId"),y=W.useState("disabled"),f=W.useState("openOnHover"),j=W.useState("closeDelay"),P=K.id??C;L4({open:L,ref:W.context.popupRef,onComplete(){if(L)W.context.onOpenChangeComplete?.(!0)}}),nq(w,{enabled:f&&!y,closeDelay:j});let x=Y===void 0?_P(W.context.popupRef):Y,p=I!==!1&&_;W.useSyncedValue("focusManagerModal",p);let t=uG.useCallback(($0)=>{W.set("popupElement",$0)},[W]),h={open:L,side:H.side,align:H.align,instant:V,transitionStatus:M},r=o0("div",J,{state:h,ref:[Q,W.context.popupRef,t],props:[D,{id:P,role:"dialog",..._Q,"aria-labelledby":N,"aria-describedby":O,onKeyDown($0){if(B&&fG.has($0.key))$0.stopPropagation()}},OQ(M),K],stateAttributesMapping:za});return G(pq,{context:w,openInteractionType:F,modal:p,disabled:!A||b===T0.triggerHover,initialFocus:x,returnFocus:z,restoreFocus:"popup",previousFocusableElement:P1(k)?k:void 0,nextFocusableElement:W.context.triggerFocusTargetRef,beforeContentFocusGuardRef:W.context.beforeContentFocusGuardRef,children:G($R,{value:U,children:r})})});var ZR=R(v(),1);var qR=ZR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=h5(),K=z.useState("open"),{arrowRef:W,side:H,align:B,arrowUncentered:U,arrowStyles:_}=NQ();return o0("div",J,{state:{open:K,side:H,align:B,uncentered:U},ref:[Q,W],props:[{style:_,"aria-hidden":!0},Y],stateAttributesMapping:w6})});var XR=R(v(),1);var Ka={...w6,...U4},YR=XR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=h5(),K=z.useState("open"),W=z.useState("mounted"),H=z.useState("transitionStatus"),B=z.useState("openChangeReason");return o0("div",J,{state:{open:K,transitionStatus:H},ref:[z.context.backdropRef,Q],props:[{role:"presentation",hidden:!W,style:{pointerEvents:B===T0.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},Y],stateAttributesMapping:Ka})});var zR=R(v(),1);var KR=zR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=h5(),K=x5(Y.id);return z.useSyncedValueWithCleanup("titleElementId",K),o0("h2",J,{ref:Q,props:[{id:K},Y]})});var GR=R(v(),1);var WR=GR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=h5(),K=x5(Y.id);return z.useSyncedValueWithCleanup("descriptionElementId",K),o0("p",J,{ref:Q,props:[{id:K},Y]})});var HR=R(v(),1);var BR=HR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,disabled:Y=!1,nativeButton:z=!0,...K}=J,{buttonRef:W,getButtonProps:H}=f6({disabled:Y,focusableWhenDisabled:!1,native:z}),{store:B}=h5();return JR(),o0("button",J,{ref:[Q,W],props:[{onClick(_){B.setOpen(!1,p0(T0.closePress,_.nativeEvent))}},K,H]})});var NR=R(v(),1);var UR=function($){return $.popupWidth="--popup-width",$.popupHeight="--popup-height",$}({});var i8=R(v(),1),DR=R(J5(),1);var _R=R(v(),1);function LR($){let[J,Q]=_R.useState({current:$,previous:null});if($!==J.current)Q({current:$,previous:J.current});return J.previous}var wQ=R(v(),1);function vL($){let J=p5($),Q=parseFloat(J.width)||0,Z=parseFloat(J.height)||0,q=P1($),X=q?$.offsetWidth:Q,Y=q?$.offsetHeight:Z;if(_7(Q)!==X||_7(Z)!==Y)Q=X,Z=Y;return{width:Q,height:Z}}function VR($){let{popupElement:J,positionerElement:Q,content:Z,mounted:q,onMeasureLayout:X,onMeasureLayoutComplete:Y,side:z,direction:K}=$,W=_4(J,!0,!1),H=h6(),B=wQ.useRef(null),U=wQ.useRef(!0),_=wQ.useRef(d1),L=g0(X),F=g0(Y),V=wQ.useMemo(()=>{let M=z==="top",D=z==="left";if(K==="rtl")M=M||z==="inline-end",D=D||z==="inline-end";else M=M||z==="inline-start",D=D||z==="inline-start";return M?{position:"absolute",[z==="top"?"bottom":"top"]:"0",[D?"right":"left"]:"0"}:T1},[z,K]);y0(()=>{if(!q){_.current=d1,U.current=!0,B.current=null;return}if(!J||!Q)return;_.current=FR(J,V),gL(J,"auto");let M=cG(J,"position","static"),D=cG(J,"transform","none"),N=cG(J,"scale","1"),O=FR(Q,{"--available-width":"max-content","--available-height":"max-content"});function I(){M(),D(),O()}function A(){I(),N()}if(L?.(),U.current||B.current===null){mG(Q,"max-content");let C=vL(J);return B.current=C,mG(Q,C),A(),F?.(null,C),U.current=!1,()=>{_.current(),_.current=d1}}mG(Q,"max-content");let b=B.current,k=vL(J);B.current=k,gL(J,b),A(),F?.(b,k),mG(Q,k);let w=new AbortController;return H.request(()=>{gL(J,k),W(()=>{J.style.setProperty("--popup-width","auto"),J.style.setProperty("--popup-height","auto")},w.signal)}),()=>{w.abort(),H.cancel(),_.current(),_.current=d1}},[Z,J,Q,W,H,q,L,F,V])}function cG($,J,Q){let Z=$.style.getPropertyValue(J);return $.style.setProperty(J,Q),()=>{$.style.setProperty(J,Z)}}function FR($,J){let Q=[];for(let[Z,q]of Object.entries(J))Q.push(cG($,Z,q));return Q.length?()=>{Q.forEach((Z)=>Z())}:d1}function gL($,J){let Q=J==="auto"?"auto":`${J.width}px`,Z=J==="auto"?"auto":`${J.height}px`;$.style.setProperty("--popup-width",Q),$.style.setProperty("--popup-height",Z)}function mG($,J){let Q=J==="max-content"?"max-content":`${J.width}px`,Z=J==="max-content"?"max-content":`${J.height}px`;$.style.setProperty("--positioner-width",Q),$.style.setProperty("--positioner-height",Z)}function dG($){let{store:J,side:Q,cssVars:Z,children:q}=$,X=J2(),Y=J.useState("activeTriggerElement"),z=J.useState("activeTriggerId"),K=J.useState("open"),W=J.useState("payload"),H=J.useState("mounted"),B=J.useState("popupElement"),U=J.useState("positionerElement"),_=LR(K?Y:null),L=Ha(z,W),F=i8.useRef(null),[V,M]=i8.useState(null),[D,N]=i8.useState(null),O=i8.useRef(null),I=i8.useRef(null),A=_4(O,!0,!1),b=h6(),[k,w]=i8.useState(null),[C,y]=i8.useState(!1);y0(()=>{return J.set("hasViewport",!0),()=>{J.set("hasViewport",!1)}},[J]);let f=g0(()=>{O.current?.style.setProperty("animation","none"),O.current?.style.setProperty("transition","none"),I.current?.style.setProperty("display","none")}),j=g0((h)=>{if(O.current?.style.removeProperty("animation"),O.current?.style.removeProperty("transition"),I.current?.style.removeProperty("display"),h)w(h)}),P=i8.useRef(null);y0(()=>{if(!K||!H)P.current=null},[K,H]),y0(()=>{if(Y&&_&&Y!==_&&P.current!==Y&&F.current){M(F.current),y(!0);let h=Wa(_,Y);N(h),b.request(()=>{DR.flushSync(()=>{y(!1)}),A(()=>{M(null),w(null),F.current=null})}),P.current=Y}},[Y,_,V,A,b]),y0(()=>{let h=O.current;if(!h)return;let r=X1(h).createElement("div");for(let $0 of Array.from(h.childNodes))r.appendChild($0.cloneNode(!0));F.current=r});let x=V!=null,p;if(!x)p=G("div",{"data-current":!0,ref:O,children:q},L);else p=T(i8.Fragment,{children:[G("div",{"data-previous":!0,inert:DQ(!0),ref:I,style:{...k?{[Z.popupWidth]:`${k.width}px`,[Z.popupHeight]:`${k.height}px`}:null,position:"absolute"},"data-ending-style":C?void 0:""},"previous"),G("div",{"data-current":!0,ref:O,"data-starting-style":C?"":void 0,children:q},L)]});y0(()=>{let h=I.current;if(!h||!V)return;h.replaceChildren(...Array.from(V.childNodes))},[V]),VR({popupElement:B,positionerElement:U,mounted:H,content:W,onMeasureLayout:f,onMeasureLayoutComplete:j,side:Q,direction:X});let t={activationDirection:Ga(D),transitioning:x};return{children:p,state:t}}function Ga($){if(!$)return;return`${MR($.horizontal,5,"right","left")} ${MR($.vertical,5,"down","up")}`}function MR($,J,Q,Z){if($>J)return Q;if($<-J)return Z;return""}function Wa($,J){let Q=$.getBoundingClientRect(),Z=J.getBoundingClientRect(),q={x:Q.left+Q.width/2,y:Q.top+Q.height/2},X={x:Z.left+Z.width/2,y:Z.top+Z.height/2};return{horizontal:X.x-q.x,vertical:X.y-q.y}}function Ha($,J){let[Q,Z]=i8.useState(0),q=i8.useRef($),X=i8.useRef(J),Y=i8.useRef(!1);return y0(()=>{let z=q.current,K=X.current,W=$!==z,H=J!==K;if(W)Z((B)=>B+1),Y.current=!H;else if(Y.current&&H)Z((B)=>B+1),Y.current=!1;q.current=$,X.current=J},[$,J]),`${$??"current"}-${Q}`}var Ba={activationDirection:($)=>$?{"data-activation-direction":$}:null},OR=NR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,children:Y,...z}=J,{store:K}=h5(),{side:W}=NQ(),H=K.useState("instantType"),{children:B,state:U}=dG({store:K,side:W,cssVars:UR,children:Y}),_={activationDirection:U.activationDirection,transitioning:U.transitioning,instant:H};return o0("div",J,{state:_,ref:Q,props:[z,{children:B}],stateAttributesMapping:Ba})});class pG{constructor(){this.store=new FQ}open($){let J=$?this.store.context.triggerElements.getById($)??void 0:void 0;if($&&!J)throw Error(F1(80,$));this.store.setOpen(!0,p0(T0.imperativeAction,void 0,J))}close(){this.store.setOpen(!1,p0(T0.imperativeAction,void 0,void 0))}get isOpen(){return this.store.select("open")}}function AR(){return new pG}var D4={};e4(D4,{createHandle:()=>WC,Viewport:()=>YC,Trigger:()=>ZC,SubmenuTrigger:()=>GC,SubmenuRoot:()=>aR,Separator:()=>KC,Root:()=>HW,RadioItemIndicator:()=>oR,RadioItem:()=>sR,RadioGroup:()=>iR,Positioner:()=>pR,Portal:()=>cR,Popup:()=>gR,LinkItem:()=>vR,Item:()=>fR,Handle:()=>_W,GroupLabel:()=>hR,Group:()=>CR,CheckboxItemIndicator:()=>PR,CheckboxItem:()=>yR,Backdrop:()=>TR,Arrow:()=>kR});var wR=R(v(),1);var lG=R(v(),1),uL=lG.createContext(void 0);function r8($){let J=lG.useContext(uL);if(J===void 0&&!$)throw Error(F1(33));return J}var iG=R(v(),1),mL=iG.createContext(void 0);function Y5($){let J=iG.useContext(mL);if(J===void 0&&!$)throw Error(F1(36));return J}var kR=wR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=Y5(),{arrowRef:K,side:W,align:H,arrowUncentered:B,arrowStyles:U}=r8(),L={open:z.useState("open"),side:W,align:H,uncentered:B};return o0("div",J,{ref:[K,Q],stateAttributesMapping:w6,state:L,props:{style:U,"aria-hidden":!0,...Y}})});var IR=R(v(),1);var rG=R(v(),1),Ua=rG.createContext(void 0);function V4($=!0){let J=rG.useContext(Ua);if(J===void 0&&!$)throw Error(F1(25));return J}var _a={...w6,...U4},TR=IR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{store:z}=Y5(),K=z.useState("open"),W=z.useState("mounted"),H=z.useState("transitionStatus"),B=z.useState("lastOpenChangeReason"),U=V4(),_={open:K,transitionStatus:H};return o0("div",J,{ref:U?.backdropRef?[Q,U.backdropRef]:Q,state:_,stateAttributesMapping:_a,props:[{role:"presentation",hidden:!W,style:{pointerEvents:B===T0.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},Y]})});var aG=R(v(),1);var b$=R(v(),1);function kQ({controlled:$,default:J,name:Q,state:Z="value"}){let{current:q}=b$.useRef($!==void 0),[X,Y]=b$.useState(J),z=q?$:X,K=b$.useCallback((W)=>{if(!q)Y(W)},[]);return[z,K]}var sG=R(v(),1),cL=sG.createContext(void 0);function bR(){let $=sG.useContext(cL);if($===void 0)throw Error(F1(30));return $}var IQ=R(v(),1);var jR=R(v(),1);function oG($){let{closeOnClick:J,highlighted:Q,id:Z,nodeId:q,store:X,typingRef:Y,itemRef:z,itemMetadata:K}=$,{events:W}=X.useState("floatingTreeRoot"),H=X.useState("open"),B=V4(!0),U=B!==void 0;return jR.useMemo(()=>({id:Z,role:"menuitem",tabIndex:H&&Q?0:-1,onKeyDown(_){if(_.key===" "&&Y?.current)_.preventDefault()},onMouseMove(_){if(!q)return;W.emit("itemhover",{nodeId:q,target:_.currentTarget})},onClick(_){if(J)W.emit("close",{domEvent:_,reason:T0.itemPress})},onMouseUp(_){if(B){let L=B.initialCursorPointRef.current;if(B.initialCursorPointRef.current=null,U&&L&&Math.abs(_.clientX-L.x)<=1&&Math.abs(_.clientY-L.y)<=1)return;if(U&&!p1.os.mac&&_.button===2)return}if(z.current&&X.context.allowMouseUpTriggerRef.current&&(!U||_.button===2)){if(!K||K.type==="regular-item")z.current.click()}}}),[J,Q,Z,W,q,H,X,Y,z,B,U,K])}var TQ={type:"regular-item"};function q2($){let{closeOnClick:J,disabled:Q=!1,highlighted:Z,id:q,store:X,typingRef:Y=X.context.typingRef,nativeButton:z,itemMetadata:K,nodeId:W}=$,H=X.useState("disabled"),B=Q||H,U=IQ.useRef(null),{getButtonProps:_,buttonRef:L}=f6({disabled:B,focusableWhenDisabled:!0,native:z,composite:!0}),F=oG({closeOnClick:J,highlighted:Z,id:q,nodeId:W,store:X,typingRef:Y,itemRef:U,itemMetadata:K}),V=IQ.useCallback((D)=>{return h8(F,{onMouseEnter(){if(K.type!=="submenu-trigger")return;K.setActive()}},D,_)},[F,_,K]),M=L9(U,L);return IQ.useMemo(()=>({getItemProps:V,itemRef:M}),[V,M])}var j$=R(v(),1);var nG=R(v(),1),dL=nG.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>{return()=>{}},elementsRef:{current:[]},nextIndexRef:{current:0}});function ER(){return nG.useContext(dL)}var La=function($){return $[$.None=0]="None",$[$.GuessFromOrder=1]="GuessFromOrder",$}({});function D9($={}){let{label:J,metadata:Q,textRef:Z,indexGuessBehavior:q,index:X}=$,{register:Y,unregister:z,subscribeMapChange:K,elementsRef:W,labelsRef:H,nextIndexRef:B}=ER(),U=j$.useRef(-1),[_,L]=j$.useState(X??(q===La.GuessFromOrder?()=>{if(U.current===-1){let M=B.current;B.current+=1,U.current=M}return U.current}:-1)),F=j$.useRef(null),V=j$.useCallback((M)=>{if(F.current=M,_!==-1&&M!==null){if(W.current[_]=M,H){let D=J!==void 0;H.current[_]=D?J:Z?.current?.textContent??M.textContent}}},[_,W,H,J,Z]);return y0(()=>{if(X!=null)return;let M=F.current;if(M)return Y(M,Q),()=>{z(M)};return},[X,Y,z,Q]),y0(()=>{if(X!=null)return;return K((M)=>{let D=F.current?M.get(F.current)?.index:null;if(D!=null)L(D)})},[X,K,L]),{ref:V,index:_}}var pL=function($){return $.checked="data-checked",$.unchecked="data-unchecked",$.disabled="data-disabled",$.highlighted="data-highlighted",$}({});var X2={checked($){if($)return{[pL.checked]:""};return{[pL.unchecked]:""}},...U4};var yR=aG.forwardRef(function(J,Q){let{render:Z,className:q,id:X,label:Y,nativeButton:z=!1,disabled:K=!1,closeOnClick:W=!1,checked:H,defaultChecked:B,onCheckedChange:U,style:_,...L}=J,F=D9({label:Y}),V=r8(!0),M=x5(X),{store:D}=Y5(),N=D.useState("isActive",F.index),O=D.useState("itemProps"),[I,A]=kQ({controlled:H,default:B??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:b,itemRef:k}=q2({closeOnClick:W,disabled:K,highlighted:N,id:M,store:D,nativeButton:z,nodeId:V?.context.nodeId,itemMetadata:TQ}),w=aG.useMemo(()=>({disabled:K,highlighted:N,checked:I}),[K,N,I]);function C(f){let j=p0(T0.itemPress,f.nativeEvent,void 0,{preventUnmountOnClose(){}});if(U?.(!I,j),j.isCanceled)return;A((P)=>!P)}let y=o0("div",J,{state:w,stateAttributesMapping:X2,props:[O,{role:"menuitemcheckbox","aria-checked":I,onClick:C},L,b],ref:[k,Q,F.ref]});return G(cL.Provider,{value:w,children:y})});var tG=R(v(),1);var PR=tG.forwardRef(function(J,Q){let{render:Z,className:q,style:X,keepMounted:Y=!1,...z}=J,K=bR(),W=tG.useRef(null),{transitionStatus:H,setMounted:B}=BQ(K.checked);L4({open:K.checked,ref:W,onComplete(){if(!K.checked)B(!1)}});let U={checked:K.checked,disabled:K.disabled,highlighted:K.highlighted,transitionStatus:H};return o0("span",J,{state:U,ref:[Q,W],stateAttributesMapping:X2,props:{"aria-hidden":!0,...z},enabled:Y||K.checked})});var $W=R(v(),1);var eG=R(v(),1),JX=eG.createContext(void 0);function RR(){let $=eG.useContext(JX);if($===void 0)throw Error(F1(31));return $}var CR=$W.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,[z,K]=$W.useState(void 0),W=o0("div",J,{ref:Q,props:{role:"group","aria-labelledby":z,...Y}});return G(JX.Provider,{value:K,children:W})});var SR=R(v(),1);var hR=SR.forwardRef(function(J,Q){let{render:Z,className:q,style:X,id:Y,...z}=J,K=x5(Y),W=RR();return y0(()=>{return W(K),()=>{W(void 0)}},[W,K]),o0("div",J,{ref:Q,props:{id:K,role:"presentation",...z}})});var xR=R(v(),1);var fR=xR.forwardRef(function(J,Q){let{render:Z,className:q,id:X,label:Y,nativeButton:z=!1,disabled:K=!1,closeOnClick:W=!0,style:H,...B}=J,U=D9({label:Y}),_=r8(!0),L=x5(X),{store:F}=Y5(),V=F.useState("isActive",U.index),M=F.useState("itemProps"),{getItemProps:D,itemRef:N}=q2({closeOnClick:W,disabled:K,highlighted:V,id:L,store:F,nativeButton:z,nodeId:_?.context.nodeId,itemMetadata:TQ});return o0("div",J,{state:{disabled:K,highlighted:V},props:[M,B,D],ref:[N,Q,U.ref]})});var JW=R(v(),1);var vR=JW.forwardRef(function(J,Q){let{render:Z,className:q,id:X,label:Y,closeOnClick:z=!1,style:K,...W}=J,H=JW.useRef(null),B=D9({label:Y}),_=r8(!0)?.context.nodeId,L=x5(X),{store:F}=Y5(),V=F.useState("isActive",B.index),M=F.useState("itemProps"),D=F.context.typingRef,{getButtonProps:N,buttonRef:O}=f6({native:!1,composite:!0}),I=oG({closeOnClick:z,highlighted:V,id:L,nodeId:_,store:F,typingRef:D,itemRef:H});function A(k){return h8(I,k,N)}return o0("a",J,{state:{highlighted:V},props:[M,W,A],ref:[H,O,Q,B.ref]})});var bQ=R(v(),1);var Fa={...w6,...U4},gR=bQ.forwardRef(function(J,Q){let{render:Z,className:q,style:X,finalFocus:Y,...z}=J,{store:K}=Y5(),{side:W,align:H}=r8(),B=gG(!0)!=null,U=K.useState("open"),_=K.useState("transitionStatus"),L=K.useState("popupProps"),F=K.useState("mounted"),V=K.useState("instantType"),M=K.useState("activeTriggerElement"),D=K.useState("parent"),N=K.useState("lastOpenChangeReason"),O=K.useState("rootId"),I=K.useState("floatingRootContext"),A=K.useState("floatingTreeRoot"),b=K.useState("closeDelay"),k=K.useState("activeTriggerElement"),w=K.useState("hoverEnabled"),C=K.useState("disabled"),y=K.useState("openMethod"),f=D.type==="context-menu";L4({open:U,ref:K.context.popupRef,onComplete(){if(U)K.context.onOpenChangeComplete?.(!0)}}),bQ.useEffect(()=>{function t(h){K.setOpen(!1,p0(h.reason,h.domEvent))}return A.events.on("close",t),()=>{A.events.off("close",t)}},[A.events,K]),nq(I,{enabled:w&&!C&&!f&&D.type!=="menubar",closeDelay:b});let j=bQ.useCallback((t)=>{K.set("popupElement",t)},[K]),P={transitionStatus:_,side:W,align:H,open:U,nested:D.type==="menu",instant:V},x=o0("div",J,{state:P,ref:[Q,K.context.popupRef,j],stateAttributesMapping:Fa,props:[L,{onKeyDown(t){if(B&&fG.has(t.key))t.stopPropagation()}},OQ(_),z,{"data-rootownerid":O}]}),p=D.type===void 0||f;if(M||D.type==="menubar"&&N!==T0.outsidePress)p=!0;return G(pq,{context:I,openInteractionType:y,modal:f,disabled:!F,returnFocus:Y===void 0?p:Y,initialFocus:D.type!=="menu",restoreFocus:!0,externalTree:D.type!=="menubar"?A:void 0,previousFocusableElement:k,nextFocusableElement:D.type===void 0?K.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:D.type===void 0?K.context.beforeContentFocusGuardRef:void 0,children:x})});var mR=R(v(),1);var QW=R(v(),1),lL=QW.createContext(void 0);function uR(){let $=QW.useContext(lL);if($===void 0)throw Error(F1(32));return $}var cR=mR.forwardRef(function(J,Q){let{keepMounted:Z=!1,...q}=J,{store:X}=Y5();if(!(X.useState("mounted")||Z))return null;return G(lL.Provider,{value:Z,children:G(mq,{ref:Q,...q})})});var M4=R(v(),1);var Y2=R(v(),1);function dR($){let{children:J,elementsRef:Q,labelsRef:Z,onMapChange:q}=$,X=g0(q),Y=Y2.useRef(0),z=W5(Ma).current,K=W5(Va).current,[W,H]=Y2.useState(0),B=Y2.useRef(W),U=g0((M,D)=>{K.set(M,D??null),B.current+=1,H(B.current)}),_=g0((M)=>{K.delete(M),B.current+=1,H(B.current)}),L=Y2.useMemo(()=>{Na(W);let M=new Map;return Array.from(K.keys()).filter((N)=>N.isConnected).sort(Da).forEach((N,O)=>{let I=K.get(N)??{};M.set(N,{...I,index:O})}),M},[K,W]);y0(()=>{if(typeof MutationObserver!=="function"||L.size===0)return;let M=new MutationObserver((D)=>{let N=new Set,O=(I)=>N.has(I)?N.delete(I):N.add(I);if(D.forEach((I)=>{I.removedNodes.forEach(O),I.addedNodes.forEach(O)}),N.size===0)B.current+=1,H(B.current)});return L.forEach((D,N)=>{if(N.parentElement)M.observe(N.parentElement,{childList:!0})}),()=>{M.disconnect()}},[L]),y0(()=>{if(B.current===W){if(Q.current.length!==L.size)Q.current.length=L.size;if(Z&&Z.current.length!==L.size)Z.current.length=L.size;Y.current=L.size}X(L)},[X,L,Q,Z,W]),y0(()=>{return()=>{Q.current=[]}},[Q]),y0(()=>{return()=>{if(Z)Z.current=[]}},[Z]);let F=g0((M)=>{return z.add(M),()=>{z.delete(M)}});y0(()=>{z.forEach((M)=>M(L))},[z,L]);let V=Y2.useMemo(()=>({register:U,unregister:_,subscribeMapChange:F,elementsRef:Q,labelsRef:Z,nextIndexRef:Y}),[U,_,F,Q,Z,Y]);return G(dL.Provider,{value:V,children:J})}function Va(){return new Map}function Ma(){return new Set}function Da($,J){let Q=$.compareDocumentPosition(J);if(Q&Node.DOCUMENT_POSITION_FOLLOWING||Q&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(Q&Node.DOCUMENT_POSITION_PRECEDING||Q&Node.DOCUMENT_POSITION_CONTAINS)return 1;return 0}function Na($){}var pR=M4.forwardRef(function(J,Q){let{anchor:Z,positionMethod:q="absolute",className:X,render:Y,side:z,align:K,sideOffset:W=0,alignOffset:H=0,collisionBoundary:B="clipping-ancestors",collisionPadding:U=5,arrowPadding:_=5,sticky:L=!1,disableAnchorTracking:F=!1,collisionAvoidance:V=ry,style:M,...D}=J,{store:N}=Y5(),O=uR(),I=V4(!0),A=N.useState("parent"),b=N.useState("floatingRootContext"),k=N.useState("floatingTreeRoot"),w=N.useState("mounted"),C=N.useState("open"),y=N.useState("modal"),f=N.useState("openMethod"),j=N.useState("activeTriggerElement"),P=N.useState("transitionStatus"),x=N.useState("positionerElement"),p=N.useState("instantType"),t=N.useState("hasViewport"),h=N.useState("lastOpenChangeReason"),r=N.useState("floatingNodeId"),$0=N.useState("floatingParentNodeId"),Y0=b.useState("domReferenceElement"),e=M4.useRef(null),H0=_4(x,!1,!1),K0=Z,E=W,m=H,c=K,i=V;if(A.type==="context-menu"){if(K0=Z??A.context?.anchor,c=c??"start",!z&&c!=="center")m=J.alignOffset??2,E=J.sideOffset??-5}let u=z,d=c;if(A.type==="menu")u=u??"inline-end",d=d??"start",i=J.collisionAvoidance??QG;else if(A.type==="menubar")u=u??(A.context.orientation==="vertical"?"inline-end":"bottom"),d=d??"start";let o=A.type==="context-menu",S=CG({anchor:K0,floatingRootContext:b,positionMethod:I?"fixed":q,mounted:w,side:u,sideOffset:E,align:d,alignOffset:m,arrowPadding:o?0:_,collisionBoundary:B,collisionPadding:U,sticky:L,nodeId:r,keepMounted:O,disableAnchorTracking:F,collisionAvoidance:i,shiftCrossAxis:o&&!(("side"in i)&&i.side==="flip"),externalTree:k,adaptiveOrigin:t?RG:void 0});M4.useEffect(()=>{function L0(_0){if(_0.open){if(_0.parentNodeId===r)N.set("hoverEnabled",!1);if(_0.nodeId!==r&&_0.parentNodeId===N.select("floatingParentNodeId"))N.setOpen(!1,p0(T0.siblingOpen))}}return k.events.on("menuopenchange",L0),()=>{k.events.off("menuopenchange",L0)}},[N,k.events,r]),M4.useEffect(()=>{if(N.select("floatingParentNodeId")==null)return;function L0(_0){if(_0.open||_0.nodeId!==N.select("floatingParentNodeId"))return;let D0=_0.reason??T0.siblingOpen;N.setOpen(!1,p0(D0))}return k.events.on("menuopenchange",L0),()=>{k.events.off("menuopenchange",L0)}},[k.events,N]);let s=U5();M4.useEffect(()=>{if(!C)s.clear()},[C,s]),M4.useEffect(()=>{function L0(_0){if(!C||_0.nodeId!==N.select("floatingParentNodeId"))return;if(_0.target&&j&&j!==_0.target){let D0=N.select("closeDelay");if(D0>0){if(!s.isStarted())s.start(D0,()=>{N.setOpen(!1,p0(T0.siblingOpen))})}else N.setOpen(!1,p0(T0.siblingOpen))}else s.clear()}return k.events.on("itemhover",L0),()=>{k.events.off("itemhover",L0)}},[k.events,C,j,N,s]),M4.useEffect(()=>{let L0={open:C,nodeId:r,parentNodeId:$0,reason:N.select("lastOpenChangeReason")};k.events.emit("menuopenchange",L0)},[k.events,C,N,r,$0]),y0(()=>{let L0=Y0,_0=e.current;if(L0)e.current=L0;if(_0&&L0&&L0!==_0){N.set("instantType",void 0);let D0=new AbortController;return H0(()=>{N.set("instantType","trigger-change")},D0.signal),()=>{D0.abort()}}return},[Y0,H0,N]);let G0={open:C,side:S.side,align:S.align,anchorHidden:S.anchorHidden,nested:A.type==="menu",instant:p},l=A.type==="menubar"&&A.context.modal,Q0=y&&h!==T0.triggerHover;xG(C&&(l||Q0),f==="touch",x,j);let J0=hG(J,G0,{styles:S.positionerStyles,transitionStatus:P,props:D,refs:[Q,N.useStateSetter("positionerElement")],hidden:!w,inert:!C}),B0=w&&A.type!=="menu"&&(A.type!=="menubar"&&y&&h!==T0.triggerHover||A.type==="menubar"&&A.context.modal),W0=null;if(A.type==="menubar")W0=A.context.contentElement;else if(A.type===void 0)W0=j;return T(uL.Provider,{value:S,children:[B0&&G(SG,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:DQ(!C),cutout:W0}),G(cq,{id:r,children:G(dR,{elementsRef:N.context.itemDomElements,labelsRef:N.context.itemLabels,children:J0})})]})});var z2=R(v(),1);var ZW=R(v(),1),iL=ZW.createContext(void 0);function lR(){let $=ZW.useContext(iL);if($===void 0)throw Error(F1(34));return $}var iR=z2.memo(z2.forwardRef(function(J,Q){let{render:Z,className:q,value:X,defaultValue:Y,onValueChange:z,disabled:K=!1,style:W,"aria-labelledby":H,...B}=J,[U,_]=z2.useState(void 0),[L,F]=kQ({controlled:X,default:Y,name:"MenuRadioGroup"}),V=g0((O,I)=>{if(z?.(O,I),I.isCanceled)return;F(O)}),D=o0("div",J,{state:{disabled:K},ref:Q,props:{role:"group","aria-labelledby":H??U,"aria-disabled":K||void 0,...B}}),N=z2.useMemo(()=>({value:L,setValue:V,disabled:K}),[L,V,K]);return G(JX.Provider,{value:_,children:G(iL.Provider,{value:N,children:D})})}));var XW=R(v(),1);var qW=R(v(),1),rL=qW.createContext(void 0);function rR(){let $=qW.useContext(rL);if($===void 0)throw Error(F1(35));return $}var sR=XW.forwardRef(function(J,Q){let{render:Z,className:q,id:X,label:Y,nativeButton:z=!1,disabled:K=!1,closeOnClick:W=!1,value:H,style:B,...U}=J,_=D9({label:Y}),L=r8(!0),F=x5(X),{store:V}=Y5(),M=V.useState("isActive",_.index),D=V.useState("itemProps"),{value:N,setValue:O,disabled:I}=lR(),A=I||K,b=N===H,{getItemProps:k,itemRef:w}=q2({closeOnClick:W,disabled:A,highlighted:M,id:F,store:V,nativeButton:z,nodeId:L?.context.nodeId,itemMetadata:TQ}),C=XW.useMemo(()=>({disabled:A,highlighted:M,checked:b}),[A,M,b]);function y(j){let P=p0(T0.itemPress,j.nativeEvent,void 0,{preventUnmountOnClose(){}});O(H,P)}let f=o0("div",J,{state:C,stateAttributesMapping:X2,props:[D,{role:"menuitemradio","aria-checked":b,onClick:y},U,k],ref:[w,Q,_.ref]});return G(rL.Provider,{value:C,children:f})});var YW=R(v(),1);var oR=YW.forwardRef(function(J,Q){let{render:Z,className:q,style:X,keepMounted:Y=!1,...z}=J,K=rR(),W=YW.useRef(null),{transitionStatus:H,setMounted:B}=BQ(K.checked);L4({open:K.checked,ref:W,onComplete(){if(!K.checked)B(!1)}});let U={checked:K.checked,disabled:K.disabled,highlighted:K.highlighted,transitionStatus:H};return o0("span",J,{state:U,stateAttributesMapping:X2,ref:[Q,W],props:{"aria-hidden":!0,...z},enabled:Y||K.checked})});var u5=R(v(),1);var zW=R(v(),1),Oa=zW.createContext(null);function KW($){let J=zW.useContext(Oa);if(J===null&&!$)throw Error(F1(5));return J}var QX=R(v(),1);var Aa={..._G,disabled:$1(($)=>$.parent.type==="menubar"?$.parent.context.disabled||$.disabled:$.disabled),modal:$1(($)=>($.parent.type===void 0||$.parent.type==="context-menu")&&($.modal??!0)),openMethod:$1(($)=>$.openMethod),allowMouseEnter:$1(($)=>$.allowMouseEnter),highlightItemOnHover:$1(($)=>$.highlightItemOnHover),stickIfOpen:$1(($)=>$.stickIfOpen),parent:$1(($)=>$.parent),rootId:$1(($)=>{if($.parent.type==="menu")return $.parent.store.select("rootId");return $.parent.type!==void 0?$.parent.context.rootId:$.rootId}),activeIndex:$1(($)=>$.activeIndex),isActive:$1(($,J)=>$.activeIndex===J),hoverEnabled:$1(($)=>$.hoverEnabled),instantType:$1(($)=>$.instantType),lastOpenChangeReason:$1(($)=>$.openChangeReason),floatingTreeRoot:$1(($)=>{if($.parent.type==="menu")return $.parent.store.select("floatingTreeRoot");return $.floatingTreeRoot}),floatingNodeId:$1(($)=>$.floatingNodeId),floatingParentNodeId:$1(($)=>$.floatingParentNodeId),itemProps:$1(($)=>$.itemProps),closeDelay:$1(($)=>$.closeDelay),hasViewport:$1(($)=>$.hasViewport),keyboardEventRelay:$1(($)=>{if($.keyboardEventRelay)return $.keyboardEventRelay;if($.parent.type==="menu")return $.parent.store.select("keyboardEventRelay");return})};class jQ extends A${constructor($){super({...wa(),...$},{positionerRef:QX.createRef(),popupRef:QX.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:QX.createRef(),beforeContentFocusGuardRef:QX.createRef(),onOpenChangeComplete:void 0,triggerElements:new Z7},Aa);this.unsubscribeParentListener=this.observe("parent",(J)=>{if(this.unsubscribeParentListener?.(),J.type==="menu"){let Q=J.store.select("rootId"),Z=J.store.select("floatingTreeRoot"),q=J.store.select("keyboardEventRelay");this.unsubscribeParentListener=J.store.subscribe(()=>{let X=J.store.select("rootId"),Y=J.store.select("floatingTreeRoot"),z=J.store.select("keyboardEventRelay");if(Q===X&&Z===Y&&q===z)return;Q=X,Z=Y,q=z,this.notifyAll()}),this.context.allowMouseUpTriggerRef=J.store.context.allowMouseUpTriggerRef;return}if(J.type!==void 0)this.context.allowMouseUpTriggerRef=J.context.allowMouseUpTriggerRef;this.unsubscribeParentListener=null})}setOpen($,J){this.state.floatingRootContext.context.events.emit("setOpen",{open:$,eventDetails:J})}static useStore($,J){let Q=W5(()=>{return new jQ(J)}).current;return $??Q}unsubscribeParentListener=null}function wa(){return{...UG(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new M$,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:T1,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}var GW=R(v(),1),sL=GW.createContext(void 0);function WW(){return GW.useContext(sL)}var HW=LL(function(J){let{children:Q,open:Z,onOpenChange:q,onOpenChangeComplete:X,defaultOpen:Y=!1,disabled:z=!1,modal:K,loopFocus:W=!0,orientation:H="vertical",actionsRef:B,closeParentOnEsc:U=!1,handle:_,triggerId:L,defaultTriggerId:F=null,highlightItemOnHover:V=!0}=J,M=V4(!0),D=Y5(!0),N=KW(!0),O=WW(),I=u5.useMemo(()=>{if(O&&D)return{type:"menu",store:D.store};if(N)return{type:"menubar",context:N};if(M&&!D)return{type:"context-menu",context:M};return{type:void 0}},[M,D,N,O]),A=jQ.useStore(_?.store,{open:Y,openProp:Z,activeTriggerId:F,triggerIdProp:L,parent:I});KG(A,Z,Y,F),A.useControlledProp("openProp",Z),A.useControlledProp("triggerIdProp",L),A.useContextCallback("onOpenChangeComplete",X);let b=x6(),k=x6(),w=A.useState("floatingTreeRoot"),C=D$(w),y=x8(),f=A.useState("open"),j=A.useState("activeTriggerElement"),P=A.useState("positionerElement"),x=A.useState("hoverEnabled"),p=A.useState("disabled"),t=A.useState("lastOpenChangeReason"),h=A.useState("parent"),r=A.useState("activeIndex"),$0=A.useState("payload"),Y0=A.useState("floatingParentNodeId"),e=u5.useRef(null),H0=u5.useRef(h.type!=="context-menu"),K0=U5(),E=u5.useRef(!0),m=U5(),c=Y0!=null,{openMethod:i,triggerProps:u}=SP(f);A.useSyncedValues({disabled:z,highlightItemOnHover:V,modal:h.type===void 0?K:void 0,openMethod:i,rootId:b}),WG(A);let{forceUnmount:d}=HG(f,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0})});y0(()=>{if(M&&!D)A.update({parent:{type:"context-menu",context:M},floatingNodeId:C,floatingParentNodeId:y});else if(D)A.update({floatingNodeId:C,floatingParentNodeId:y})},[M,D,C,y,A]),u5.useEffect(()=>{if(!f)e.current=null;if(h.type!=="context-menu")return;if(!f){K0.clear(),H0.current=!1;return}K0.start(500,()=>{H0.current=!0})},[K0,f,h.type]),y0(()=>{if(!f&&!x)A.set("hoverEnabled",!0)},[f,x,A]);let o=g0((F0,u0)=>{let P0=u0.reason;if(f===F0&&u0.trigger===j&&t===P0)return;let n0=zG(u0);if(!F0&&u0.trigger==null)u0.trigger=j??void 0;if(q?.(F0,u0),u0.isCanceled)return;A.state.floatingRootContext.dispatchOpenChange(F0,u0);let R0=u0.event;if(F0===!1&&R0?.type==="click"&&R0.pointerType==="touch"&&!E.current)return;if(F0&&P0===T0.triggerFocus)E.current=!1,m.start(300,()=>{E.current=!0});else E.current=!0,m.clear();let Y1=(P0===T0.triggerPress||P0===T0.itemPress)&&R0.detail===0&&R0?.isTrusted,z1=!F0&&(P0===T0.escapeKey||P0==null),a0={open:F0,openChangeReason:P0};if(e.current=u0.event??null,YG(a0,F0,u0.trigger,n0()),A.update(a0),h.type==="menubar"&&(P0===T0.triggerFocus||P0===T0.focusOut||P0===T0.triggerHover||P0===T0.listNavigation||P0===T0.siblingOpen))A.set("instantType","group");else if(Y1||z1)A.set("instantType",Y1?"click":"dismiss");else A.set("instantType",void 0)}),S=rq({popupStore:A,floatingId:k,nested:y!=null,onOpenChange:o}),s=S.context.events;u5.useEffect(()=>{let F0=({open:u0,eventDetails:P0})=>o(u0,P0);return s.on("setOpen",F0),()=>{s?.off("setOpen",F0)}},[s,o]);let G0=u5.useCallback(()=>{A.setOpen(!1,p0(T0.imperativeAction))},[A]);u5.useImperativeHandle(B,()=>({unmount:d,close:G0}),[d,G0]);let l;if(h.type==="context-menu")l=h.context;u5.useImperativeHandle(l?.positionerRef,()=>P,[P]),u5.useImperativeHandle(l?.actionsRef,()=>({setOpen:o}),[o]);let Q0=iq(S,{enabled:!p,bubbles:{escapeKey:U&&h.type==="menu"},outsidePress(){if(h.type!=="context-menu"||e.current?.type==="contextmenu")return!0;return H0.current},externalTree:c?w:void 0}),J0=J2(),B0=u5.useCallback((F0)=>{if(A.select("activeIndex")===F0)return;A.set("activeIndex",F0)},[A]),W0=jL(S,{enabled:!p,listRef:A.context.itemDomElements,activeIndex:r,nested:h.type!==void 0,loopFocus:W,orientation:H,parentOrientation:h.type==="menubar"?h.context.orientation:void 0,rtl:J0==="rtl",disabledIndices:B$,onNavigate:B0,openOnArrowKeyDown:h.type!=="context-menu",externalTree:c?w:void 0,focusItemOnHover:V}),L0=u5.useCallback((F0)=>{A.context.typingRef.current=F0},[A]),_0=EL(S,{enabled:!p,listRef:A.context.itemLabels,elementsRef:A.context.itemDomElements,activeIndex:r,resetMs:ly,onMatch:(F0)=>{if(f&&F0!==r)A.set("activeIndex",F0)},onTyping:L0}),D0=u5.useMemo(()=>{let F0=h8(_0.reference,W0.reference,Q0.reference,{onMouseMove(){A.set("allowMouseEnter",!0)}},u);return F0["aria-haspopup"]="menu",F0["aria-expanded"]=f,F0},[A,_0.reference,W0.reference,Q0.reference,u,f]),c0=u5.useMemo(()=>{let F0=h8(W0.trigger,Q0.trigger,u);return F0["aria-haspopup"]="menu",F0["aria-expanded"]=!1,F0},[W0.trigger,Q0.trigger,u]),g=u5.useMemo(()=>h8(_Q,{id:k,role:"menu","aria-labelledby":j?.id,onMouseMove(){if(A.set("allowMouseEnter",!0),h.type==="menu")A.set("hoverEnabled",!1)},onClick(){if(A.select("hoverEnabled"))A.set("hoverEnabled",!1)},onKeyDown(F0){let u0=A.select("keyboardEventRelay");if(u0&&!F0.isPropagationStopped())u0(F0)}},_0.floating,W0.floating,Q0.floating),[j,k,h.type,A,_0.floating,W0.floating,Q0.floating]),a=W0.item??T1;BG(A,{floatingRootContext:S,activeTriggerProps:D0,inactiveTriggerProps:c0,popupProps:g,itemProps:a});let I0=u5.useMemo(()=>({store:A,parent:I}),[A,I]),A0=G(mL.Provider,{value:I0,children:typeof Q==="function"?Q({payload:$0}):Q});if(h.type===void 0||h.type==="context-menu")return G(dq,{externalTree:w,children:A0});return A0});var nR=R(v(),1);function aR($){let J=Y5().store,Q=nR.useMemo(()=>({parentMenu:J}),[J]);return G(sL.Provider,{value:Q,children:G(HW,{...$})})}var s8=R(v(),1);function tR($){let J=$.getBoundingClientRect(),Q=h1($);if(p1.env.jsdom)return J;let Z=Q.getComputedStyle($,"::before"),q=Q.getComputedStyle($,"::after");if(!(Z.content!=="none"||q.content!=="none"))return J;let Y=parseFloat(Z.width)||0,z=parseFloat(Z.height)||0,K=parseFloat(q.width)||0,W=parseFloat(q.height)||0,H=Math.max(J.width,Y,K),B=Math.max(J.height,z,W),U=H-J.width,_=B-J.height;return{left:J.left-U/2,right:J.right+U/2,top:J.top-_/2,bottom:J.bottom+_/2}}var eR=R(v(),1);function $C($={}){let{highlightItemOnHover:J,highlightedIndex:Q,onHighlightedIndexChange:Z}=VQ(),{ref:q,index:X}=D9($),Y=Q===X,z=eR.useRef(null),K=L9(q,z);return{compositeProps:{tabIndex:Y?0:-1,onFocus(){Z(X)},onMouseMove(){let H=z.current;if(!J||!H)return;let B=H.hasAttribute("disabled")||H.ariaDisabled==="true";if(!Y&&!B)H.focus()}},compositeRef:K,index:X}}function JC($){let{render:J,className:Q,style:Z,state:q=T1,props:X=B$,refs:Y=B$,metadata:z,stateAttributesMapping:K,tag:W="div",...H}=$,{compositeProps:B,compositeRef:U}=$C({metadata:z});return o0(W,$,{state:q,ref:[...Y,U],props:[B,...X,H],stateAttributesMapping:K})}function oL($){if(P1($)&&$.hasAttribute("data-rootownerid"))return $.getAttribute("data-rootownerid")??void 0;if(E6($))return;return oL(j6($))}var BW=R(v(),1);function QC($){let{enabled:J=!0,mouseDownAction:Q,open:Z}=$,q=BW.useRef(!1);return BW.useMemo(()=>{if(!J)return T1;return{onMouseDown:(X)=>{if(Q==="open"&&!Z||Q==="close"&&Z)q.current=!0,X1(X.currentTarget).addEventListener("click",()=>{q.current=!1},{once:!0})},onClick:(X)=>{if(q.current)q.current=!1,X.preventBaseUIHandler()}}},[J,Q,Z])}var UW=2,ZC=KP(function(J,Q){let{render:Z,className:q,style:X,disabled:Y=!1,nativeButton:z=!0,id:K,openOnHover:W,delay:H=100,closeDelay:B=0,handle:U,payload:_,...L}=J,F=Y5(!0),V=U?.store??F?.store;if(!V)throw Error(F1(85));let M=x5(K),D=V.useState("isTriggerActive",M),N=V.useState("floatingRootContext"),O=V.useState("isOpenedByTrigger",M),I=V.useState("triggerPopupId",M),A=s8.useRef(null),b=Ia(),k=VQ(!0),w=d8(),C=s8.useMemo(()=>{return w??new M$},[w]),y=D$(C),f=x8(),{registerTrigger:j,isMountedByThisTrigger:P}=GG(M,A,V,{payload:_,closeDelay:B,parent:b,floatingTreeRoot:C,floatingNodeId:y,floatingParentNodeId:f,keyboardEventRelay:k?.relayKeyboardEvent}),x=b.type==="menubar",p=V.useState("disabled"),t=Y||p||x&&b.context.disabled,{getButtonProps:h,buttonRef:r}=f6({disabled:t,native:z});s8.useEffect(()=>{if(!O&&b.type===void 0)V.context.allowMouseUpTriggerRef.current=!1},[V,O,b.type]);let $0=s8.useRef(null),Y0=U5(),e=g0((W0)=>{if(!$0.current)return;Y0.clear(),V.context.allowMouseUpTriggerRef.current=!1;let L0=W0.target;if(e0($0.current,L0)||e0(V.select("positionerElement"),L0)||L0===$0.current)return;if(L0!=null&&oL(L0)===V.select("rootId"))return;let _0=tR($0.current);if(W0.clientX>=_0.left-UW&&W0.clientX<=_0.right+UW&&W0.clientY>=_0.top-UW&&W0.clientY<=_0.bottom+UW)return;C.events.emit("close",{domEvent:W0,reason:T0.cancelOpen})});s8.useEffect(()=>{if(O&&V.select("lastOpenChangeReason")===T0.triggerHover)X1($0.current).addEventListener("mouseup",e,{once:!0})},[O,e,V]);let H0=x&&b.context.hasSubmenuOpen,E=k$(N,{enabled:(W??H0)&&!t&&b.type!=="context-menu"&&(!x||H0&&!P),handleClose:T$({blockPointerEvents:!x}),mouseOnly:!0,move:!1,restMs:b.type===void 0?H:void 0,delay:{close:B},triggerElementRef:A,externalTree:C,isActiveTrigger:D,isClosing:()=>V.select("transitionStatus")==="ending"}),m=ka(O,V.select("lastOpenChangeReason")),c=N$(N,{enabled:!t&&b.type!=="context-menu",event:O&&x?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:b.type===void 0?m:!1}),i=wL(N,{enabled:!t&&H0}),u=QC({open:O,enabled:x,mouseDownAction:"open"}),d=s8.useMemo(()=>h8(i.reference,c.reference),[i.reference,c.reference]),o=V.useState("triggerProps",P),{preFocusGuardRef:S,handlePreFocusGuardFocus:s,handleFocusTargetFocus:G0}=bG(V,A),l={disabled:t,open:O},Q0=[$0,Q,r,j,A],J0=[d,E??T1,o,{"aria-haspopup":"menu","aria-controls":I,id:M,onMouseDown:(W0)=>{if(V.select("open"))return;Y0.start(200,()=>{V.context.allowMouseUpTriggerRef.current=!0}),X1(W0.currentTarget).addEventListener("mouseup",e,{once:!0})}},x?{role:"menuitem"}:{},u,L,h],B0=o0("button",J,{enabled:!x,stateAttributesMapping:aq,state:l,ref:Q0,props:J0});if(x)return G(JC,{tag:"button",render:Z,className:q,style:X,state:l,refs:Q0,props:J0,stateAttributesMapping:aq});if(O)return T(s8.Fragment,{children:[G(V9,{ref:S,onFocus:s},`${M}-pre-focus-guard`),G(s8.Fragment,{children:B0},M),G(V9,{ref:V.context.triggerFocusTargetRef,onFocus:G0},`${M}-post-focus-guard`)]});return G(s8.Fragment,{children:B0},M)});function ka($,J){let Q=U5(),[Z,q]=s8.useState(!1);return y0(()=>{if($&&J==="trigger-hover")q(!0),Q.start($G,()=>{q(!1)});else if(!$)Q.clear(),q(!1)},[$,J,Q]),Z}function Ia(){let $=V4(!0),J=Y5(!0),Q=KW(!0);return s8.useMemo(()=>{if(Q)return{type:"menubar",context:Q};if($&&!J)return{type:"context-menu",context:$};return{type:void 0}},[$,J,Q])}var XC=R(v(),1);var qC=function($){return $.popupWidth="--popup-width",$.popupHeight="--popup-height",$}({});var Ta={activationDirection:($)=>$?{"data-activation-direction":$}:null},YC=XC.forwardRef(function(J,Q){let{render:Z,className:q,style:X,children:Y,...z}=J,{store:K}=Y5(),{side:W}=r8(),H=K.useState("instantType"),{children:B,state:U}=dG({store:K,side:W,cssVars:qC,children:Y}),_={activationDirection:U.activationDirection,transitioning:U.transitioning,instant:H};return o0("div",J,{state:_,ref:Q,props:[z,{children:B}],stateAttributesMapping:Ta})});var zC=R(v(),1);var KC=zC.forwardRef(function(J,Q){let{className:Z,render:q,orientation:X="horizontal",style:Y,...z}=J;return o0("div",J,{state:{orientation:X},ref:Q,props:[{role:"separator","aria-orientation":X},z]})});var X7=R(v(),1);var GC=X7.forwardRef(function(J,Q){let{render:Z,className:q,style:X,label:Y,id:z,nativeButton:K=!1,openOnHover:W=!0,delay:H=100,closeDelay:B=0,disabled:U=!1,..._}=J,L=D9({label:Y}),F=r8(),{store:V}=Y5(),M=x5(z),D=V.useState("open"),N=V.useState("floatingRootContext"),O=V.useState("floatingTreeRoot"),I=V.useState("triggerPopupId",M),A=DL(M,V),b=X7.useCallback((c)=>{let i=A(c);if(c!==null&&V.select("open")&&V.select("activeTriggerId")==null)V.update({activeTriggerId:M,activeTriggerElement:c,closeDelay:B});return i},[A,B,V,M]),k=X7.useRef(null),w=X7.useCallback((c)=>{k.current=c,V.set("activeTriggerElement",c)},[V]),C=WW();if(!C?.parentMenu)throw Error(F1(37));V.useSyncedValue("closeDelay",B);let y=C.parentMenu,f=V.useState("disabled"),j=y.useState("disabled"),P=U||f||j,x=y.useState("itemProps"),p=y.useState("isActive",L.index),t=X7.useMemo(()=>({type:"submenu-trigger",setActive(){if(y.select("highlightItemOnHover"))y.set("activeIndex",L.index)}}),[y,L.index]),{getItemProps:h,itemRef:r}=q2({closeOnClick:!1,disabled:P,highlighted:p,id:M,store:V,typingRef:y.context.typingRef,nativeButton:K,itemMetadata:t,nodeId:F?.context.nodeId}),$0=V.useState("hoverEnabled"),Y0=k$(N,{enabled:$0&&W&&!P,handleClose:T$({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:H,delay:{open:H,close:B},shouldOpen:H>0?()=>y.select("allowMouseEnter"):void 0,triggerElementRef:k,externalTree:O,isClosing:()=>V.select("transitionStatus")==="ending"}),H0=N$(N,{enabled:!P,event:"mousedown",toggle:!W,ignoreMouse:W,stickIfOpen:!1}).reference??T1,K0=V.useState("triggerProps",!0);return delete K0.id,o0("div",J,{state:{disabled:P,highlighted:p,open:D},stateAttributesMapping:TG,props:[H0,Y0,K0,x,{"aria-controls":I,tabIndex:D||p?0:-1,onBlur(){if(p)y.set("activeIndex",null)}},_,h],ref:[Q,L.ref,r,b,w]})});class _W{constructor(){this.store=new jQ}open($){let J=$?this.store.context.triggerElements.getById($):void 0;if($&&!J)throw Error(F1(83,$));this.store.setOpen(!0,p0("imperative-action",void 0,J))}close(){this.store.setOpen(!1,p0("imperative-action",void 0,void 0))}get isOpen(){return this.store.select("open")}}function WC(){return new _W}var P$={};e4(P$,{ScrubAreaCursor:()=>JS,ScrubArea:()=>eC,Root:()=>RC,Input:()=>sC,Increment:()=>dC,Group:()=>SC,Decrement:()=>lC});var o8=R(v(),1);var LW=R(v(),1),nL=LW.createContext(void 0);function N4(){let $=LW.useContext(nL);if($===void 0)throw Error(F1(43));return $}var FW=R(v(),1);var aL=function($){return $.disabled="data-disabled",$.valid="data-valid",$.invalid="data-invalid",$.touched="data-touched",$.dirty="data-dirty",$.filled="data-filled",$.focused="data-focused",$}({});var HC={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},EQ={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},BC={disabled:!1,...EQ},UC={valid($){if($===null)return null;if($)return{[aL.valid]:""};return{[aL.invalid]:""}}};var ba={invalid:void 0,name:void 0,validityData:{state:HC,errors:[],error:"",value:"",initialValue:null},setValidityData:d1,disabled:void 0,touched:EQ.touched,setTouched:d1,dirty:EQ.dirty,setDirty:d1,filled:EQ.filled,setFilled:d1,focused:EQ.focused,setFocused:d1,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:BC,markedDirtyRef:{current:!1},registerFieldControl:d1,validation:{getValidationProps:($,J=T1)=>J,inputRef:{current:null},registerInput:d1,commit:async()=>{},change:d1}},ja=FW.createContext(ba);function yQ($=!0){let J=FW.useContext(ja);if(J.setValidityData===d1&&!$)throw Error(F1(28));return J}var VW=R(v(),1);var Ea=VW.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:d1,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function MW(){return VW.useContext(Ea)}var ZX=R(v(),1);var DW=R(v(),1);var ya=DW.createContext({controlId:void 0,registerControlId:d1,labelId:void 0,setLabelId:d1,messageIds:[],setMessageIds:d1,getDescriptionProps:($)=>$});function NW(){return DW.useContext(ya)}function _C($={}){let{id:J,implicit:Q=!1,controlRef:Z}=$,{controlId:q,registerControlId:X}=NW(),Y=x5(J),z=Q?q:void 0,K=W5(()=>Symbol("labelable-control")),W=ZX.useRef(!1),H=ZX.useRef(J!=null),B=g0(()=>{if(!W.current||X===d1)return;W.current=!1,X(K.current,void 0)});return y0(()=>{if(X===d1)return;let U;if(Q){let _=Z?.current;if(L1(_)&&_.closest("label")!=null)U=J??null;else U=z??Y}else if(J!=null)H.current=!0,U=J;else if(H.current)U=Y;else{B();return}if(U===void 0){B();return}W.current=!0,X(K.current,U);return},[J,Z,z,X,Q,Y,K,B]),ZX.useEffect(()=>{return B},[B]),q??Y}var N9={inputValue:()=>null,value:()=>null,...UC};function tL($){if(Array.isArray($))return $.map((J)=>tL(J)).join(",");if($==null)return"";return String($)}var LC=new Map;function E$($,J){let Q=JSON.stringify({locale:tL($),options:J}),Z=LC.get(Q);if(Z)return Z;let q=new Intl.NumberFormat($,J);return LC.set(Q,q),q}function PQ($,J,Q){if($==null)return"";return E$(J,Q).format($)}var VC=["零","〇","一","二","三","四","五","六","七","八","九"],Pa={零:"0",〇:"0",一:"1",二:"2",三:"3",四:"4",五:"5",六:"6",七:"7",八:"8",九:"9"},eL=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],$F=["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"],JF=["0","1","2","3","4","5","6","7","8","9"],QF=["%","٪","%","﹪"],ZF=["‰","؉"],MC=["−","-","‒","–","—","﹣"],DC=["+","﹢"],Ra=".",Ca=",",Sa=new RegExp(`[${eL.join("")}]`,"g"),ha=new RegExp(`[${$F.join("")}]`,"g"),xa=new RegExp(`[${JF.join("")}]`,"g"),fa=new RegExp(`[${VC.join("")}]`,"g"),NC=new RegExp(`[${QF.join("")}]`),OC=new RegExp(`[${ZF.join("")}]`),va=new RegExp(NC.source,"g"),ga=new RegExp(OC.source,"g"),AC=new RegExp(`[${eL.join("")}]`),wC=new RegExp(`[${$F.join("")}]`),kC=new RegExp(`[${VC.join("")}]`),ua=new RegExp(`[${JF.join("")}]`);function qF($){return $>="0"&&$<="9"||AC.test($)||wC.test($)||kC.test($)||ua.test($)}var IC=[".",",",Ra,Ca,"٫","٬"],XF=/\p{Zs}/u,TC=["+",...DC],bC=["-",...MC],qX=($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ma=($)=>$.replace(/[-\\\]^]/g,(J)=>`\\${J}`);function FC($,J){let[Q,Z="0"]=String($).split("e");return Number(`${Q}e${Number(Z)+J}`)}var jC=($)=>`[${$.map(ma).join("")}]`,EC=jC(["-"].concat(MC)),yC=jC(["+"].concat(DC)),YF=new RegExp(EC,"gu"),zF=new RegExp(yC,"gu"),OW=new RegExp(EC),KF=new RegExp(yC);function XX($,J){let Q=E$($,J).formatToParts(11111.1),Z={};return Q.forEach((q)=>{Z[q.type]=q.value}),E$($).formatToParts(0.1).forEach((q)=>{if(q.type==="decimal")Z[q.type]=q.value}),Z}function Y7($,J,Q){if($==null)return null;let Z=String($).replace(/\p{Cf}/gu,"").trim();Z=Z.replace(YF,"-").replace(zF,"+");let q=!1,X=Z.match(/([+-])\s*$/);if(X){if(X[1]==="-")q=!0;Z=Z.replace(/([+-])\s*$/,"")}let Y=Z.match(/^\s*([+-])/);if(Y){if(Y[1]==="-")q=!0;Z=Z.replace(/^\s*[+-]/,"")}let z=J;if(z===void 0){if(AC.test(Z)||wC.test(Z))z="ar";else if(kC.test(Z))z="zh"}let{group:K,decimal:W,currency:H,exponentSeparator:B}=XX(z,Q),U=E$(z,Q).formatToParts(1).filter((k)=>k.type==="unit").map((k)=>qX(k.value)),_=U.length?new RegExp(U.join("|"),"g"):null,L=null;if(K){let k=/\p{Zs}/u.test(K),w=K==="'"||K==="’";if(k)L=/\p{Zs}/gu;else if(w)L=/['’]/g;else L=new RegExp(qX(K),"g")}let V=[{regex:L,replacement:""},{regex:W?new RegExp(qX(W),"g"):null,replacement:"."},{regex:/./g,replacement:"."},{regex:/,/g,replacement:""},{regex:/٫/g,replacement:"."},{regex:/٬/g,replacement:""},{regex:H?new RegExp(qX(H),"g"):null,replacement:""},{regex:_,replacement:""},{regex:va,replacement:""},{regex:ga,replacement:""},{regex:B?new RegExp(qX(B),"g"):null,replacement:"e"},{regex:Sa,replacement:(k)=>String(eL.indexOf(k))},{regex:ha,replacement:(k)=>String($F.indexOf(k))},{regex:xa,replacement:(k)=>String(JF.indexOf(k))},{regex:fa,replacement:(k)=>Pa[k]}].reduce((k,{regex:w,replacement:C})=>{return w?k.replace(w,C):k},Z),M=V.lastIndexOf(".");if(M!==-1)V=`${V.slice(0,M).replace(/\./g,"")}.${V.slice(M+1).replace(/\./g,"")}`;if(/^[-+]?Infinity$/i.test(Z)||Z.includes("∞"))return null;let D=(q?"-":"")+V,N=parseFloat(D),O=Q?.style,I=O==="unit"&&Q?.unit==="percent",A=NC.test($)||O==="percent";if(OC.test($))N=FC(N,-3);else if(!I&&A)N=FC(N,-2);if(!Number.isFinite(N))return null;return N}function GF($,J=Number.MIN_SAFE_INTEGER,Q=Number.MAX_SAFE_INTEGER){return Math.max(J,Math.min($,Q))}var ca=0.0000000001,da=0.0000000001;function AW($){return $?.maximumFractionDigits!=null||$?.minimumFractionDigits!=null||$?.maximumSignificantDigits!=null||$?.minimumSignificantDigits!=null||$?.roundingIncrement!=null||$?.roundingMode!=null||$?.roundingPriority!=null}function WF($,J){if(!Number.isFinite($))return $;if(!AW(J)){let X=parseFloat($.toPrecision(15)),Y=Math.abs(X-$),z=Math.min(Number.EPSILON*Math.max(1,Math.abs($)),da);return Y<=z?X:$}let Q=E$("en-US",{...J,signDisplay:"auto",currencySign:"standard",notation:J.notation==="compact"?"standard":J.notation,useGrouping:!1}),Z=Q.format($),q=Y7(Z,"en-US",J);if(q===null)return $;return Q.format(q)===Z?q:$}function pa($,J,Q,Z="directional"){let q=Math.abs(Q),X=Math.sign(Q),Y=q*ca*X,z=$-J+Y;if(Z==="nearest")return J+Math.round(z/Q)*Q;let K=X>0?Math.floor(z/q):Math.ceil(z/q);return J+K*q}function PC($,{step:J,minWithDefault:Q,maxWithDefault:Z,minWithZeroDefault:q,format:X,snapOnStep:Y,small:z,clamp:K}){if($===null)return $;let W=$;if(J!=null&&Y&&J!==0){let B=z||Q===Number.MIN_SAFE_INTEGER?q:Q;W=pa(W,B,J,z?"nearest":"directional")}if(K)W=GF(W,Q,Z);if(J==null&&!AW(X))return W;let H=WF(W,X);return K?GF(H,Q,Z):H}var RC=o8.forwardRef(function(J,Q){let{id:Z,min:q,max:X,smallStep:Y=0.1,step:z=1,largeStep:K=10,required:W=!1,disabled:H=!1,readOnly:B=!1,form:U,name:_,defaultValue:L,value:F,onValueChange:V,onValueCommitted:M,allowWheelScrub:D=!1,snapOnStep:N=!1,allowOutOfRange:O=!1,format:I,locale:A,render:b,className:k,inputRef:w,style:C,...y}=J,{setDirty:f,validityData:j,disabled:P,setFilled:x,invalid:p,name:t,state:h,validation:r}=yQ(),{clearErrors:$0}=MW(),Y0=P||H,e=t??_,H0=z==="any"?1:z,[K0,E]=o8.useState(!1),m=q??Number.MIN_SAFE_INTEGER,c=X??Number.MAX_SAFE_INTEGER,i=q??0,u=I?.style,d=o8.useRef(null),o=L9(w,r.inputRef),S=_C({id:Z}),[s,G0]=kQ({controlled:F,default:L,name:"NumberField",state:"value"}),l=s??null,Q0=F5(l);y0(()=>{x(l!==null)},[x,l]);let J0=WP(),B0=F5(I),W0=o8.useRef(!1),L0=g0((z1,a0)=>{W0.current=!1,M?.(z1,a0)}),_0=o8.useRef(!0),D0=o8.useRef(null),[c0,g]=o8.useState(()=>PQ(l,A,I)),[a,I0]=o8.useState("numeric"),A0=g0(()=>{let{decimal:z1,group:a0,currency:C1,literal:g1}=XX(A,I),b1=new Set;if(IC.forEach((w0)=>b1.add(w0)),z1)b1.add(z1);if(a0){if(b1.add(a0),XF.test(a0))b1.add(" ")}let n=u==="percent"||u==="unit"&&I?.unit==="percent",N0=u==="percent"||u==="unit"&&I?.unit==="permille";if(n)QF.forEach((w0)=>b1.add(w0));if(N0)ZF.forEach((w0)=>b1.add(w0));if(u==="currency"&&C1)b1.add(C1);if(g1){if(Array.from(g1).forEach((w0)=>b1.add(w0)),XF.test(g1))b1.add(" ")}if(TC.forEach((w0)=>b1.add(w0)),m<0||O)bC.forEach((w0)=>b1.add(w0));return b1}),F0=g0((z1)=>{if(z1?.altKey)return Y;if(z1?.shiftKey)return K;return H0}),u0=g0((z1,a0)=>{let{event:C1,direction:g1}=a0,b1=a0.reason===T0.inputChange||a0.reason===T0.inputClear||a0.reason===T0.inputBlur||a0.reason===T0.inputPaste||a0.reason===T0.none,n=!O||!b1,N0=PC(z1,{step:g1?F0(C1)*g1:void 0,format:B0.current,minWithDefault:m,maxWithDefault:c,minWithZeroDefault:i,snapOnStep:N,small:C1?.altKey??!1,clamp:n}),w0=N0!==l||b1&&(z1!==l||_0.current===!1);if(w0){if(V?.(N0,a0),a0.isCanceled)return!1;G0(N0),f(N0!==j.initialValue),W0.current=!0}if(D0.current=N0,_0.current)g(PQ(N0,A,I));return J0(),w0}),P0=g0((z1,{direction:a0,currentValue:C1,event:g1,reason:b1})=>{let n=C1==null?Q0.current:C1,N0=g1;if(typeof n!=="number")return u0(0,p0(b1,N0));return u0(n+z1*a0,p0(b1,N0,void 0,{direction:a0}))});y0(function(){if(!_0.current)return;let a0=PQ(l,A,I);if(a0!==c0)g(a0)}),y0(function(){if(!p1.os.ios)return;let a0="text";if(m>=0)a0="decimal";I0(a0)},[m]),o8.useEffect(function(){let a0=d.current;if(Y0||B||!D||!a0)return;function C1(g1){if(g1.ctrlKey||g5(X1(d.current))!==d.current)return;g1.preventDefault(),_0.current=!0;let b1=F0(g1);if(P0(b1,{direction:g1.deltaY>0?-1:1,event:g1,reason:"wheel"}))L0(D0.current??Q0.current,f9(T0.wheel,g1))}return U1(a0,"wheel",C1)},[D,P0,Y0,B,F0,L0,D0,Q0]);let n0=o8.useMemo(()=>({...h,disabled:Y0,readOnly:B,required:W,value:l,inputValue:c0,scrubbing:K0}),[h,Y0,B,W,l,c0,K0]),R0=o8.useMemo(()=>({inputRef:d,inputValue:c0,value:l,minWithDefault:m,maxWithDefault:c,disabled:Y0,readOnly:B,id:S,setValue:u0,incrementValue:P0,getStepAmount:F0,allowInputSyncRef:_0,formatOptionsRef:B0,valueRef:Q0,lastChangedValueRef:D0,hasPendingCommitRef:W0,name:e,nameProp:_,required:W,invalid:p,inputMode:a,getAllowedNonNumericKeys:A0,min:q,max:X,setInputValue:g,locale:A,isScrubbing:K0,setIsScrubbing:E,state:n0,onValueCommitted:L0}),[d,c0,l,m,c,Y0,B,S,u0,P0,F0,B0,Q0,e,_,W,p,a,A0,q,X,g,A,K0,n0,L0]),Y1=o0("div",J,{ref:Q,state:n0,props:y,stateAttributesMapping:N9});return T(nL.Provider,{value:R0,children:[Y1,G("input",{...r.getValidationProps(Y0,{onFocus(){d.current?.focus()},onChange(z1){if(z1.nativeEvent.defaultPrevented||Y0||B)return;let a0=z1.currentTarget.valueAsNumber,C1=Number.isNaN(a0)?null:a0,g1=p0(T0.none,z1.nativeEvent);u0(C1,g1),$0(e),r.change(D0.current??C1)}}),ref:o,type:"number",form:U,name:e,value:l??"",min:q,max:X,step:z,disabled:Y0,readOnly:B,required:W,"aria-hidden":!0,tabIndex:-1,style:e?By:cK,suppressHydrationWarning:!0})]})});var CC=R(v(),1);var SC=CC.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{state:z}=N4();return o0("div",J,{ref:Q,state:z,props:[{role:"group"},Y],stateAttributesMapping:N9})});var cC=R(v(),1);var u9=R(v(),1);var hC=0;class HF extends b8{static create(){return new HF}start($,J){this.clear(),this.currentId=setInterval(()=>{J()},$)}clear=()=>{if(this.currentId!==hC)clearInterval(this.currentId),this.currentId=hC}}function xC(){let $=W5(HF.create).current;return l7($.disposeEffect),$}var la=60,ia=400,ra=8,sa=50,oa=3;function y$($){return $==="touch"||$==="pen"}function fC($){let{disabled:J,readOnly:Q=!1,tick:Z,onStop:q,tickDelay:X=la,startDelay:Y=ia,scrollDistance:z=ra,elementRef:K}=$,W=U5(),H=xC(),B=U5(),U=u9.useRef(!1),_=u9.useRef(0),L=u9.useRef({x:0,y:0}),F=u9.useRef(!1),V=u9.useRef(!1),M=u9.useRef(""),D=u9.useRef(d1),N=u9.useRef(d1),O=g0(()=>{B.clear(),W.clear(),H.clear(),D.current(),_.current=0});function I(k){O();let w=K.current;if(!w)return;let C=h1(w);function y(f){f.preventDefault()}if(D.current=U1(C,"contextmenu",y),N.current(),N.current=U1(C,"pointerup",(f)=>{U.current=!1,O(),q?.(f)},{once:!0}),!Z(k)){O();return}W.start(Y,()=>{H.start(X,()=>{if(!Z(k))O()})})}u9.useEffect(()=>()=>{O(),N.current()},[O]);let A={onTouchStart(){F.current=!0},onTouchEnd(){F.current=!1},onPointerDown(k){let w=!k.button||k.button===0;if(k.defaultPrevented||!w||J||Q)return;if(M.current=k.pointerType,V.current=!1,U.current=!0,L.current={x:k.clientX,y:k.clientY},!y$(k.pointerType))k.preventDefault(),I(k.nativeEvent);else B.start(sa,()=>{let y=_.current;if(_.current=0,U.current&&y<oa)I(k.nativeEvent),V.current=!0;else V.current=!1,O()})},onPointerUp(k){if(y$(k.pointerType))U.current=!1},onPointerMove(k){if(J||Q||!y$(k.pointerType)||!U.current)return;if(_.current!=null)_.current+=1;let{x:w,y:C}=L.current,y=w-k.clientX,f=C-k.clientY;if(y**2+f**2>z**2)O()},onMouseEnter(k){if(k.defaultPrevented||J||Q||!U.current||F.current||y$(M.current))return;I(k.nativeEvent)},onMouseLeave(){if(F.current)return;O()},onMouseUp(){if(F.current)return;O()}},b=g0((k)=>{if(k.defaultPrevented)return!0;if(y$(M.current))return V.current;return k.detail!==0});return{pointerHandlers:A,shouldSkipClick:b}}var vC=60,gC=400,uC=8;var na={WebkitUserSelect:"none",userSelect:"none"};function mC($){let{allowInputSyncRef:J,disabled:Q,formatOptionsRef:Z,getStepAmount:q,id:X,incrementValue:Y,inputRef:z,inputValue:K,isIncrement:W,locale:H,readOnly:B,setValue:U,valueRef:_,lastChangedValueRef:L,onValueCommitted:F}=$,V=W?T0.incrementPress:T0.decrementPress;function M(I){let A=!J.current;if(J.current=!0,!A){L.current=_.current;return}let b=Y7(K,H,Z.current);if(b!==null){let k=p0(V,I);if(U(b,k),!k.isCanceled)_.current=b}}let{pointerHandlers:D,shouldSkipClick:N}=fC({disabled:Q||B,elementRef:z,tickDelay:vC,startDelay:gC,scrollDistance:uC,tick(I){let A=q(I);return Y(A,{direction:W?1:-1,event:I,reason:V})},onStop(I){let A=L.current??_.current;F(A,f9(V,I))}});return{disabled:Q,"aria-label":W?"Increase":"Decrease","aria-controls":X,tabIndex:-1,style:na,...D,onClick(I){let A=Q||B;if(I.defaultPrevented||A||N(I))return;M(I.nativeEvent);let b=q(I),k=_.current;Y(b,{direction:W?1:-1,event:I.nativeEvent,reason:V});let w=L.current??_.current;if(w!==k)F(w,f9(V,I.nativeEvent))},onPointerDown(I){let A=!I.button||I.button===0;if(I.defaultPrevented||B||!A||Q)return;if(M(I.nativeEvent),L.current=null,!y$(I.pointerType))z.current?.focus();D.onPointerDown(I)}}}function wW($,J,Q){let{render:Z,className:q,disabled:X=!1,nativeButton:Y=!0,style:z,...K}=$,{allowInputSyncRef:W,disabled:H,formatOptionsRef:B,getStepAmount:U,id:_,incrementValue:L,inputRef:F,inputValue:V,maxWithDefault:M,minWithDefault:D,readOnly:N,setValue:O,state:I,value:A,valueRef:b,locale:k,lastChangedValueRef:w,onValueCommitted:C}=N4(),y=A!=null&&(Q?A>=M:A<=D),f=X||H||y,j=mC({isIncrement:Q,inputRef:F,inputValue:V,disabled:f,readOnly:N,id:_,setValue:O,getStepAmount:U,incrementValue:L,allowInputSyncRef:W,formatOptionsRef:B,valueRef:b,locale:k,lastChangedValueRef:w,onValueCommitted:C}),{getButtonProps:P,buttonRef:x}=f6({disabled:f||N,native:Y,focusableWhenDisabled:!0}),p={...I,disabled:f};return o0("button",$,{ref:[J,x],state:p,props:[j,K,P],stateAttributesMapping:N9})}var dC=cC.forwardRef(function(J,Q){return wW(J,Q,!0)});var pC=R(v(),1);var lC=pC.forwardRef(function(J,Q){return wW(J,Q,!1)});var RQ=R(v(),1);var iC=R(v(),1);function rC($,J,Q,Z,q=!0,X){let{registerFieldControl:Y}=yQ(),z=iC.useRef(null);if(!z.current)z.current=Symbol();y0(()=>{let K=z.current;if(!K||!q)return;return Y(K,{controlRef:$,getValue:Z,id:J,name:X,value:Q}),()=>{Y(K,void 0)}},[$,q,Z,J,X,Y,Q])}var aa=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"]),sC=RQ.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{allowInputSyncRef:z,disabled:K,formatOptionsRef:W,getAllowedNonNumericKeys:H,getStepAmount:B,id:U,incrementValue:_,inputMode:L,inputValue:F,max:V,min:M,name:D,nameProp:N,readOnly:O,required:I,setValue:A,state:b,setInputValue:k,locale:w,inputRef:C,value:y,onValueCommitted:f,lastChangedValueRef:j,hasPendingCommitRef:P,valueRef:x}=N4(),{clearErrors:p}=MW(),{validationMode:t,setTouched:h,setFocused:r,invalid:$0,shouldValidateOnChange:Y0,validation:e}=yQ(),{labelId:H0}=NW(),K0=RQ.useRef(!1),E=RQ.useRef(!1),m=RQ.useRef(null);return rC(C,U,y,void 0,!K,N),y0(()=>{if(m.current!=null){let u=m.current;m.current=null,C.current?.setSelectionRange(u,u)}}),jG(y,()=>{if(p(D),E.current&&!Y0()){E.current=!1;return}e.change(y)}),o0("input",J,{ref:[Q,C],state:b,props:[{id:U,required:I,disabled:K,readOnly:O,inputMode:L,value:F,type:"text",autoComplete:"off",autoCorrect:"off",spellCheck:"false","aria-roledescription":"Number field","aria-invalid":!K&&$0?!0:void 0,"aria-labelledby":H0,suppressHydrationWarning:!0,onFocus(u){if(u.defaultPrevented||K)return;if(r(!0),K0.current)return;K0.current=!0;let d=u.currentTarget,o=d.value.length;d.setSelectionRange(o,o)},onBlur(u){if(u.defaultPrevented||K)return;if(h(!0),r(!1),O)return;let d=!z.current,o=P.current;if(z.current=!0,F.trim()===""){let _0=p0(T0.inputClear,u.nativeEvent);if(A(null,_0),_0.isCanceled)return;if(t==="onBlur")e.commit(null);if(d||o||y!==null)f(null,f9(T0.inputClear,u.nativeEvent));return}let S=W.current,s=Y7(F,w,S);if(s===null)return;let G0=AW(S),l;if(!d&&!G0)l=y;else if(G0)l=WF(s,S);else l=s;let Q0=f9(T0.inputBlur,u.nativeEvent),J0=y!==l,B0=d||J0||o,W0=l;if(J0){let _0=p0(T0.inputBlur,u.nativeEvent);if(E.current=!0,A(l,_0),_0.isCanceled){E.current=!1;return}if(W0=j.current??l,W0===y)E.current=!1}if(t==="onBlur")e.commit(W0);if(B0)f(W0,Q0);let L0=PQ(W0,w,S);if(F!==L0)k(L0)},onChange(u){if(u.nativeEvent.defaultPrevented)return;z.current=!1;let d=u.currentTarget.value;if(d.trim()===""){k(d),A(null,p0(T0.inputClear,u.nativeEvent));return}let o=H();if(!Array.from(d).every((G0)=>qF(G0)||OW.test(G0)||o.has(G0)))return;let s=Y7(d,w,W.current);if(k(d),s!==null)A(s,p0(T0.inputChange,u.nativeEvent))},onKeyDown(u){if(u.defaultPrevented||O||K)return;let d=u.nativeEvent,o=!z.current,S=H(),s=S.has(u.key),{decimal:G0,currency:l,percentSign:Q0}=XX(w,W.current),J0=u.currentTarget.selectionStart,B0=u.currentTarget.selectionEnd,W0=J0===0&&B0===F.length,L0=(P0)=>J0!=null&&B0!=null&&P0>=J0&&P0<B0;[[OW,YF],[KF,zF]].forEach(([P0,n0])=>{if(P0.test(u.key)&&Array.from(S).some((R0)=>P0.test(R0))){let R0=F.search(n0),Y1=R0!==-1&&L0(R0);s=!(OW.test(F)||KF.test(F))||W0||Y1}}),[G0,l,Q0].forEach((P0)=>{if(u.key===P0){let n0=F.indexOf(P0),R0=L0(n0);s=!F.includes(P0)||W0||R0}});let D0=aa.has(u.key),c0=u.key==="ArrowUp"||u.key==="ArrowDown";if(u.which===229||u.altKey&&!c0||u.ctrlKey||u.metaKey||s||qF(u.key)||D0)return;let g=u.key==="Home"&&M!=null,a=u.key==="End"&&V!=null;if(u.key.length>1&&!c0&&!g&&!a)return;let I0=o?Y7(F,w,W.current):null,A0=B(u);q6(u);let F0=f9(T0.keyboard,d),u0=!1;if(u.key==="ArrowUp"||u.key==="ArrowDown"){if(z.current=!0,!o)j.current=x.current;u0=_(A0,{direction:u.key==="ArrowUp"?1:-1,currentValue:I0,event:d,reason:T0.keyboard})}else if(g)z.current=!0,u0=A(M,p0(T0.keyboard,d));else if(a)z.current=!0,u0=A(V,p0(T0.keyboard,d));if(u0)f(j.current??x.current,F0)},onPaste(u){if(u.defaultPrevented||O||K)return;let d="";try{d=u.clipboardData?.getData("text/plain")??""}catch{return}u.preventDefault();let o=u.currentTarget,S=o.selectionStart??F.length,s=o.selectionEnd??F.length,G0=F.slice(0,S)+d+F.slice(s),l=Y7(G0,w,W.current);if(l!==null)z.current=!1,m.current=S+d.length,A(l,p0(T0.inputPaste,u.nativeEvent)),k(G0)}},Y,(u)=>e.getValidationProps(K,u)],stateAttributesMapping:N9})});var m5=R(v(),1),tC=R(J5(),1);var kW=R(v(),1),BF=kW.createContext(void 0);function oC(){let $=kW.useContext(BF);if($===void 0)throw Error(F1(44));return $}function nC($,J){let Q=h1(J);if($!=null){let q=J.getBoundingClientRect();return{left:q.left-$/2,top:q.top-$/2,right:q.right+$/2,bottom:q.bottom+$/2}}let Z=Q.visualViewport;if(Z)return{left:Z.offsetLeft,top:Z.offsetTop,right:Z.offsetLeft+Z.width,bottom:Z.offsetTop+Z.height};return{left:0,top:0,right:Q.document.documentElement.clientWidth,bottom:Q.document.documentElement.clientHeight}}function aC($,J){let Q=h1($).visualViewport;if(!Q)return()=>{};function Z(){if(Q)J.current=Q.scale}return Z(),U1(Q,"resize",Z)}var ta={touchAction:"none",WebkitUserSelect:"none",userSelect:"none"},eC=m5.forwardRef(function(J,Q){let{render:Z,className:q,direction:X="horizontal",pixelSensitivity:Y=2,teleportDistance:z,style:K,...W}=J,{state:H,setIsScrubbing:B,disabled:U,readOnly:_,inputRef:L,incrementValue:F,allowInputSyncRef:V,getStepAmount:M,onValueCommitted:D,lastChangedValueRef:N,valueRef:O}=N4(),I=m5.useRef(null),A=m5.useRef(!1),b=m5.useRef(!1),k=m5.useRef(null),w=m5.useRef(null),C=m5.useRef({x:0,y:0}),y=m5.useRef(1),f=U5(),[j,P]=m5.useState(!1),[x,p]=m5.useState(!1),[t,h]=m5.useState(!1);m5.useEffect(()=>{if(!t||!w.current)return;return aC(w.current,y)},[t]);function r(E,m){if(w.current)w.current.style.transform=`translate3d(${E}px,${m}px,0) scale(${1/y.current})`}let $0=g0(({movementX:E,movementY:m})=>{let c=w.current,i=I.current;if(!c||!i)return;let u=nC(z,i),d=C.current,o={x:Math.round(d.x+E),y:Math.round(d.y+m)},S=c.offsetWidth,s=c.offsetHeight;if(o.x+S/2<u.left)o.x=u.right-S/2;else if(o.x+S/2>u.right)o.x=u.left-S/2;if(o.y+s/2<u.top)o.y=u.bottom-s/2;else if(o.y+s/2>u.bottom)o.y=u.top-s/2;C.current=o,r(o.x,o.y)}),Y0=g0((E,{clientX:m,clientY:c})=>{tC.flushSync(()=>{h(E),B(E)});let i=w.current;if(!i||!E)return;let u={x:m-i.offsetWidth/2,y:c-i.offsetHeight/2};C.current=u,r(u.x,u.y)});m5.useEffect(function(){if(!L.current||U||_||!t)return;let m=0;function c(o){function S(){try{X1(I.current).exitPointerLock()}catch{}finally{A.current=!1,Y0(!1,o),D(N.current??O.current,f9(T0.scrub,o));let s=k.current,G0=L.current;if(!b.current&&s!=null&&G0)s.dispatchEvent(new(h1(G0)).MouseEvent("click",{bubbles:!0,cancelable:!0}));b.current=!1,k.current=null}}if(p1.engine.gecko)f.start(20,S);else S()}function i(o){if(!A.current)return;o.preventDefault(),$0(o);let{movementX:S,movementY:s}=o;if(m+=X==="vertical"?s:S,Math.abs(m)>=Y){m=0,b.current=!0;let G0=X==="vertical"?-s:S,l=M(o),Q0=G0*l;if(Q0!==0)V.current=!0,F(Math.abs(Q0),{direction:Q0>=0?1:-1,event:o,reason:T0.scrub})}}let u=h1(L.current),d=T8(U1(u,"pointerup",c,!0),U1(u,"pointermove",i,!0));return()=>{f.clear(),d()}},[U,_,V,F,t,M,L,Y0,$0,X,Y,N,D,O,f]),m5.useEffect(()=>()=>{if(A.current){A.current=!1,B(!1);try{X1(I.current).exitPointerLock()}catch{}}},[B]),m5.useEffect(function(){let m=I.current;if(!m||U||_)return;function c(i){if(i.touches.length===1)i.preventDefault()}return U1(m,"touchstart",c)},[U,_]);let H0=o0("span",J,{ref:[Q,I],state:H,props:[{role:"presentation",style:ta,async onPointerDown(E){let m=!E.button||E.button===0;if(E.defaultPrevented||_||!m||U)return;let c=E.pointerType==="touch";if(P(c),E.pointerType==="mouse")E.preventDefault(),L.current?.focus();if(A.current=!0,b.current=!1,k.current=k5(E.nativeEvent),Y0(!0,E.nativeEvent),!c&&!p1.engine.webkit)try{await X1(I.current).body.requestPointerLock(),p(!1)}catch(i){p(!0)}finally{if(A.current)Y0(!0,E.nativeEvent)}}},W],stateAttributesMapping:N9}),K0=m5.useMemo(()=>({isScrubbing:t,isTouchInput:j,isPointerLockDenied:x,scrubAreaCursorRef:w}),[t,j,x]);return G(BF.Provider,{value:K0,children:H0})});var IW=R(v(),1),$S=R(J5(),1);var ea={position:"fixed",top:0,left:0,pointerEvents:"none"},JS=IW.forwardRef(function(J,Q){let{render:Z,className:q,style:X,...Y}=J,{state:z}=N4(),{isScrubbing:K,isTouchInput:W,isPointerLockDenied:H,scrubAreaCursorRef:B}=oC(),[U,_]=IW.useState(null),L=K&&!p1.engine.webkit&&!W&&!H,F=o0("span",J,{enabled:L,ref:[Q,B,_],state:z,props:[{role:"presentation",style:ea},Y],stateAttributesMapping:N9});return F&&$S.createPortal(F,X1(U).body)});var YX={fast:{type:"spring",duration:0.08,bounce:0,exit:{duration:0.06}},moderate:{type:"spring",duration:0.16,bounce:0.08,exit:{duration:0.12}},settle:{type:"spring",duration:0.16,bounce:0,exit:{duration:0.12}},slow:{type:"spring",duration:0.24,bounce:0.12,exit:{duration:0.16}}};var R$={normal:"'wght' 400, 'opsz' 14",medium:"'wght' 450, 'opsz' 15",semibold:"'wght' 550, 'opsz' 20",bold:"'wght' 700, 'opsz' 25"};var z7=R(v(),1);var UF={pill:{item:"rounded-[20px]",bg:"rounded-[20px]",focusRing:"rounded-[22px]",mergedBg:"rounded-2xl",container:"rounded-3xl",button:"rounded-[20px]",input:"rounded-[20px]",bgRadius:20,mergedRadius:16},rounded:{item:"rounded-lg",bg:"rounded-lg",focusRing:"rounded-[10px]",mergedBg:"rounded-lg",container:"rounded-xl",button:"rounded-lg",input:"rounded-lg",bgRadius:8,mergedRadius:8}},$t=z7.createContext(null);function m9(){let $=z7.useContext($t);if(!$)return UF.pill;return $.classes}var qS=s0.createContext(null);function Jt({value:$,children:J}){return G(qS.Provider,{value:$,children:J})}function V8($){return Math.max(0,Math.min(1,$))}function g6($){return Math.max(0,Math.min(255,$))}function MF($,J,Q){let Z=Q*J,q=($%360+360)%360/60,X=Z*(1-Math.abs(q%2-1)),Y=0,z=0,K=0;if(q<1)Y=Z,z=X,K=0;else if(q<2)Y=X,z=Z,K=0;else if(q<3)Y=0,z=Z,K=X;else if(q<4)Y=0,z=X,K=Z;else if(q<5)Y=X,z=0,K=Z;else Y=Z,z=0,K=X;let W=Q-Z;return{r:(Y+W)*255,g:(z+W)*255,b:(K+W)*255}}function CQ($,J,Q){$/=255,J/=255,Q/=255;let Z=Math.max($,J,Q),q=Math.min($,J,Q),X=Z,Y=Z-q,z=Z===0?0:Y/Z,K=0;if(Y>0){if(Z===$)K=(J-Q)/Y%6;else if(Z===J)K=(Q-$)/Y+2;else K=($-J)/Y+4;if(K*=60,K<0)K+=360}return{h:K,s:z,v:X}}function DF($,J,Q){$/=255,J/=255,Q/=255;let Z=Math.max($,J,Q),q=Math.min($,J,Q),X=(Z+q)/2,Y=Z-q,z=0,K=0;if(Y>0){if(K=X>0.5?Y/(2-Z-q):Y/(Z+q),Z===$)z=(J-Q)/Y%6;else if(Z===J)z=(Q-$)/Y+2;else z=($-J)/Y+4;if(z*=60,z<0)z+=360}return{h:z,s:K,l:X}}function XS($,J,Q){let Z=(1-Math.abs(2*Q-1))*J,q=($%360+360)%360/60,X=Z*(1-Math.abs(q%2-1)),Y=0,z=0,K=0;if(q<1)Y=Z,z=X;else if(q<2)Y=X,z=Z;else if(q<3)z=Z,K=X;else if(q<4)z=X,K=Z;else if(q<5)Y=X,K=Z;else Y=Z,K=X;let W=Q-Z/2;return{r:(Y+W)*255,g:(z+W)*255,b:(K+W)*255}}function _F($){return $=$/255,$<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function LF($){let J=$<=0.0031308?12.92*$:1.055*Math.pow($,0.4166666666666667)-0.055;return V8(J)*255}function Qt($,J,Q){let Z=0.4122214708*$+0.5363325363*J+0.0514459929*Q,q=0.2119034982*$+0.6806995451*J+0.1073969566*Q,X=0.0883024619*$+0.2817188376*J+0.6299787005*Q,Y=Math.cbrt(Z),z=Math.cbrt(q),K=Math.cbrt(X);return{L:0.2104542553*Y+0.793617785*z-0.0040720468*K,a:1.9779984951*Y-2.428592205*z+0.4505937099*K,b:0.0259040371*Y+0.7827717662*z-0.808675766*K}}function Zt($,J,Q){let Z=$+0.3963377774*J+0.2158037573*Q,q=$-0.1055613458*J-0.0638541728*Q,X=$-0.0894841775*J-1.291485548*Q,Y=Z*Z*Z,z=q*q*q,K=X*X*X;return{r:4.0767416621*Y-3.3077115913*z+0.2309699292*K,g:-1.2684380046*Y+2.6097574011*z-0.3413193965*K,b:-0.0041960863*Y-0.7034186147*z+1.707614701*K}}function NF($,J,Q){let Z=_F($),q=_F(J),X=_F(Q),Y=Qt(Z,q,X),z=Math.sqrt(Y.a*Y.a+Y.b*Y.b),K=Math.atan2(Y.b,Y.a)*180/Math.PI;if(K<0)K+=360;return{L:Y.L,C:z,H:K}}function YS($,J,Q){let Z=J*Math.cos(Q*Math.PI/180),q=J*Math.sin(Q*Math.PI/180),X=Zt($,Z,q);return{r:g6(LF(X.r)),g:g6(LF(X.g)),b:g6(LF(X.b))}}function C$($){return Math.round(g6($)).toString(16).padStart(2,"0")}function SQ($,J,Q,Z){if(Z>=1)return`#${C$($)}${C$(J)}${C$(Q)}`;return`#${C$($)}${C$(J)}${C$(Q)}${C$(Z*255)}`}function qt($){if($.length===3)return $.split("").map((J)=>J+J).join("");if($.length===4)return $.split("").map((J)=>J+J).join("");return $}function Xt($){let J=$.trim().match(/^#?([0-9a-fA-F]{3,8})$/);if(!J)return null;let Q=J[1];if(Q.length===3||Q.length===4)Q=qt(Q);if(Q.length===6)return{r:parseInt(Q.slice(0,2),16),g:parseInt(Q.slice(2,4),16),b:parseInt(Q.slice(4,6),16),a:1};if(Q.length===8)return{r:parseInt(Q.slice(0,2),16),g:parseInt(Q.slice(2,4),16),b:parseInt(Q.slice(4,6),16),a:parseInt(Q.slice(6,8),16)/255};return null}function K2($){let J=$.trim();if(!J)return null;if(J.startsWith("#")||/^[0-9a-fA-F]{3,8}$/.test(J))return Xt(J);let Q=J.match(/^rgba?\(\s*([^)]+)\)$/i);if(Q){let X=Q[1].split(/[\s,/]+/).filter(Boolean);if(X.length<3)return null;let Y=parseFloat(X[0]),z=parseFloat(X[1]),K=parseFloat(X[2]),W=1;if(X[3]!==void 0)W=X[3].endsWith("%")?parseFloat(X[3])/100:parseFloat(X[3]);if([Y,z,K,W].some(Number.isNaN))return null;return{r:g6(Y),g:g6(z),b:g6(K),a:V8(W)}}let Z=J.match(/^hsla?\(\s*([^)]+)\)$/i);if(Z){let X=Z[1].split(/[\s,/]+/).filter(Boolean);if(X.length<3)return null;let Y=parseFloat(X[0]),z=X[1].endsWith("%")?parseFloat(X[1])/100:parseFloat(X[1]),K=X[2].endsWith("%")?parseFloat(X[2])/100:parseFloat(X[2]),W=1;if(X[3]!==void 0)W=X[3].endsWith("%")?parseFloat(X[3])/100:parseFloat(X[3]);if([Y,z,K,W].some(Number.isNaN))return null;let H=XS(Y,V8(z),V8(K));return{r:g6(H.r),g:g6(H.g),b:g6(H.b),a:V8(W)}}let q=J.match(/^oklch\(\s*([^)]+)\)$/i);if(q){let X=q[1].split(/[\s,/]+/).filter(Boolean);if(X.length<3)return null;let Y=X[0].endsWith("%")?parseFloat(X[0])/100:parseFloat(X[0]),z=parseFloat(X[1]),K=parseFloat(X[2]),W=1;if(X[3]!==void 0)W=X[3].endsWith("%")?parseFloat(X[3])/100:parseFloat(X[3]);if([Y,z,K,W].some(Number.isNaN))return null;let H=YS(V8(Y),Math.max(0,z),K);return{r:g6(H.r),g:g6(H.g),b:g6(H.b),a:V8(W)}}return null}var TW=null;function zS($){let J=K2($);if(J)return J;let Q=$.trim();if(!Q||typeof document>"u")return null;if(!TW){if(TW=document.createElement("canvas").getContext("2d"),!TW)return null}let Z=TW;Z.fillStyle="#000000",Z.fillStyle=Q;let q=String(Z.fillStyle);Z.fillStyle="#ffffff",Z.fillStyle=Q;let X=String(Z.fillStyle);if(q!==X)return null;return K2(q)}function FF($,J,Q,Z){let{r:q,g:X,b:Y}=MF($,J,Q),z=DF(q,X,Y),K=NF(q,X,Y),W=SQ(q,X,Y,Z),H=Z>=1?`rgb(${Math.round(q)}, ${Math.round(X)}, ${Math.round(Y)})`:`rgba(${Math.round(q)}, ${Math.round(X)}, ${Math.round(Y)}, ${Number(Z.toFixed(3))})`,B=Z>=1?`hsl(${Math.round(z.h)}, ${Math.round(z.s*100)}%, ${Math.round(z.l*100)}%)`:`hsla(${Math.round(z.h)}, ${Math.round(z.s*100)}%, ${Math.round(z.l*100)}%, ${Number(Z.toFixed(3))})`,U=Z>=1?`oklch(${(K.L*100).toFixed(1)}% ${K.C.toFixed(3)} ${K.H.toFixed(1)})`:`oklch(${(K.L*100).toFixed(1)}% ${K.C.toFixed(3)} ${K.H.toFixed(1)} / ${Number(Z.toFixed(3))})`;return{h:$,s:J,v:Q,a:Z,r:Math.round(q),g:Math.round(X),b:Math.round(Y),hex:W,rgb:H,hsl:B,oklch:U}}function VF($,J){switch(J){case"hex":return $.hex;case"rgb":return $.rgb;case"hsl":return $.hsl;case"oklch":return $.oklch}}var Yt=280,zt=156,KS={backgroundImage:"conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0)",backgroundSize:"8px 8px"};function Kt({h:$,s:J,v:Q,onChange:Z}){let q=s0.useRef(null),[X,Y]=s0.useState(!1),z=s0.useRef(!1),[K,W]=s0.useState(!1),[H,B]=s0.useState(!1),[U,_]=s0.useState(null),L=m9(),F=s0.useCallback((w,C)=>{let y=q.current?.getBoundingClientRect();if(!y)return;let f=V8((w-y.left)/y.width),j=V8((C-y.top)/y.height);Z(f,1-j)},[Z]),V=s0.useCallback((w,C)=>{let y=q.current?.getBoundingClientRect();if(!y)return;_({x:V8((w-y.left)/y.width)*100,y:V8((C-y.top)/y.height)*100})},[]),M=s0.useCallback((w)=>{if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),Y(!0),z.current=!1,w.currentTarget.setPointerCapture(w.pointerId),F(w.clientX,w.clientY)},[F]),D=s0.useCallback((w)=>{if(V(w.clientX,w.clientY),!X)return;z.current=!0,F(w.clientX,w.clientY)},[X,F,V]),N=s0.useCallback(()=>{Y(!1),z.current=!1},[]),O=s0.useCallback((w)=>{let C=w.shiftKey?0.1:0.01,y=J,f=Q,j=!0;if(w.key==="ArrowLeft")y=V8(J-C);else if(w.key==="ArrowRight")y=V8(J+C);else if(w.key==="ArrowUp")f=V8(Q+C);else if(w.key==="ArrowDown")f=V8(Q-C);else j=!1;if(j)w.preventDefault(),Z(y,f)},[Z,J,Q]),{r:I,g:A,b}=MF($,J,Q),k=`rgb(${Math.round(I)}, ${Math.round(A)}, ${Math.round(b)})`;return T("div",{ref:q,role:"application","aria-label":"Saturation and brightness",tabIndex:0,onFocus:(w)=>{if(w.currentTarget.matches(":focus-visible"))W(!0)},onBlur:()=>W(!1),onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),_(null)},onPointerDown:M,onPointerMove:D,onPointerUp:N,onKeyDown:O,className:b0("relative w-full select-none touch-none cursor-none outline-none",L.bg),style:{height:zt,boxShadow:K?"0 0 0 2px var(--focus-ring, #6B97FF)":void 0},children:[G("div",{className:b0("absolute inset-0 overflow-hidden",L.bg==="rounded-[20px]"?"rounded-2xl":L.bg),style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${$}, 100%, 50%))`}}),G(Eq.div,{className:"absolute pointer-events-none rounded-full",initial:!1,animate:{left:`${J*100}%`,top:`${(1-Q)*100}%`,width:18,height:18},transition:{duration:0},style:{transform:"translate(-50%, -50%)",border:"1px solid white",boxShadow:"0 0 0 1px rgba(0,0,0,1)",backgroundColor:k}}),H&&!X&&U&&G("div",{className:"absolute pointer-events-none rounded-full",style:{left:`${U.x}%`,top:`${U.y}%`,width:18,height:18,transform:"translate(-50%, -50%)",border:"2px solid rgba(255, 255, 255, 0.55)",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.2)"}})]})}function GS({value:$,onChange:J,min:Q,max:Z,step:q,trackStyle:X,thumbColor:Y,thumbBorderColor:z,className:K,...W}){return T($Z,{className:b0("relative flex h-8 w-full touch-none select-none items-center",K),value:[$],min:Q,max:Z,step:q,onValueChange:(H)=>J(H[0]??$),...W,children:[G(nX,{className:"relative h-4 w-full grow overflow-hidden rounded-full border border-border bg-muted",style:X,children:G(aX,{className:"absolute h-full bg-transparent"})}),G(tX,{className:"block h-5 w-5 rounded-full border-2 bg-background shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",style:{backgroundColor:Y,borderColor:z}})]})}function Gt({h:$,onChange:J}){let Q=`hsl(${$}, 100%, 50%)`;return G(GS,{value:$,onChange:J,min:0,max:360,step:1,thumbColor:Q,thumbBorderColor:"rgba(255,255,255,0.9)",trackStyle:{background:"linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))",borderColor:"transparent"},"aria-label":"Hue"})}function Wt({a:$,solidColor:J,solidR:Q,solidG:Z,solidB:q,onChange:X}){let Y=`rgba(${Q}, ${Z}, ${q}, 0)`;return G(GS,{value:Math.round($*100),onChange:(z)=>X(z/100),min:0,max:100,step:1,thumbColor:J,thumbBorderColor:"rgba(255,255,255,0.9)",trackStyle:{backgroundImage:`linear-gradient(to right, ${Y} 0%, ${J} 98%), conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0)`,backgroundSize:"100% 100%, 8px 8px",borderWidth:0},"aria-label":"Alpha"})}var QS={hex:"HEX",rgb:"RGB",hsl:"HSL",oklch:"OKLCH"},Ht=["hex","rgb","hsl","oklch"],Bt=UF.rounded;function Ut({value:$,label:J,checked:Q}){let Z=m9();return G(D4.RadioItem,{value:$,label:J,closeOnClick:!0,render:G("div",{className:b0("relative z-10 flex items-center px-3 py-2 text-[13px] cursor-pointer outline-none",Z.item)}),children:G("span",{className:b0("transition-colors duration-80",Q?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:Q?R$.semibold:R$.normal},children:J})})}function _t({value:$,onChange:J,open:Q,defaultOpen:Z=!1}){let[q,X]=s0.useState(Z),Y=Q!==void 0,z=Y?Q:q,K=s0.useRef(null),W=m9(),H=s0.useContext(qS),B=j4;return T(D4.Root,{open:z,onOpenChange:(U)=>{if(!Y)X(U)},actionsRef:K,modal:!1,children:[T(D4.Trigger,{className:b0("flex items-center justify-between gap-2 h-9 px-3 text-[13px] bg-transparent hover:bg-hover hover:text-foreground transition-colors duration-80 outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] cursor-pointer border border-border",z?"bg-active text-foreground":"text-muted-foreground active:bg-active",W.input),style:{fontVariationSettings:R$.medium},children:[G("span",{children:QS[$]}),G(B,{size:14,strokeWidth:1.5,className:b0("text-muted-foreground transition-transform duration-150",z&&"rotate-180")})]}),G(D4.Portal,{container:H??void 0,children:G(D4.Positioner,{side:"bottom",align:"start",sideOffset:6,className:"z-[60] outline-none",children:G(Eq.div,{initial:{opacity:0,y:-4,scaleY:0.96},animate:z?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:0.96},transition:z?YX.fast:YX.fast.exit,style:{transformOrigin:"top center"},onAnimationComplete:()=>{if(!z)K.current?.unmount()},children:G(D4.Popup,{className:b0(`relative flex flex-col gap-0.5 min-w-[var(--anchor-width)] bg-popover ${Bt.container} p-1 select-none outline-none`),children:G(D4.RadioGroup,{value:$,onValueChange:(U)=>J(U),className:"contents",children:Ht.map((U)=>G(Ut,{value:U,label:QS[U],checked:$===U},U))})})})})})]})}var WS=s0.forwardRef(({value:$,onCommit:J,ariaLabel:Q,width:Z,className:q,inputClassName:X,align:Y="left",prefix:z,inputMode:K="text",nudgeStep:W,nudgeShiftStep:H,hasPercent:B=!1,decimals:U,min:_,max:L,wrap:F=!1},V)=>{let[M,D]=s0.useState($),N=s0.useRef(!1),O=m9();s0.useEffect(()=>{if(!N.current)D($)},[$]);let I=(k)=>U!=null?k.toFixed(U):String(Math.round(k)),A=(k)=>{let w=k;if(F&&_!=null&&L!=null){let f=L-_;w=((w-_)%f+f)%f+_}else{if(_!=null)w=Math.max(_,w);if(L!=null)w=Math.min(L,w)}let C=I(w),y=B?`${C}%`:C;D(y),J(y)},b=(k,w)=>{let C=w?H??10:W??1,y=parseFloat(M.replace("%",""));if(Number.isNaN(y))return;A(y+k*C)};return T("div",{className:b0("flex items-center h-9 px-2 bg-transparent hover:bg-hover active:bg-active transition-colors duration-80 focus-within:ring-1 focus-within:ring-[color:var(--highlight,#6B97FF)] select-none border border-border",O.input,q),style:{width:Z},children:[z&&G("span",{className:"text-[12px] text-muted-foreground mr-1 select-none",children:z}),G("input",{ref:V,value:M,onChange:(k)=>D(k.target.value),onFocus:(k)=>{N.current=!0,k.currentTarget.select()},onBlur:()=>{if(N.current=!1,M!==$){let k=parseFloat(M.replace("%",""));if(!Number.isNaN(k)&&(_!=null||L!=null))A(k);else J(M)}else D($)},onKeyDown:(k)=>{if(k.key==="Enter")k.currentTarget.blur();else if(k.key==="Escape")D($),k.currentTarget.blur();else if((W!=null||H!=null)&&(k.key==="ArrowUp"||k.key==="ArrowDown"))k.preventDefault(),b(k.key==="ArrowUp"?1:-1,k.shiftKey)},inputMode:K,"aria-label":Q,className:b0("flex-1 min-w-0 bg-transparent text-foreground text-[13px] outline-none tabular-nums",Y==="center"&&"text-center",Y==="right"&&"text-right",X),style:{fontVariationSettings:R$.medium}})]})});WS.displayName="TextColorInput";var HS=s0.forwardRef(({value:$,onCommit:J,ariaLabel:Q,width:Z,className:q,inputClassName:X,align:Y="left",prefix:z,inputMode:K="numeric",nudgeStep:W,nudgeShiftStep:H,hasPercent:B=!1,decimals:U,min:_,max:L,wrap:F=!1},V)=>{let M=m9(),D=s0.useRef(null),[N,O]=s0.useState(!1),I=s0.useRef(!1),A=parseFloat(String($).replace("%","")),b=Number.isNaN(A)?null:A,k=s0.useMemo(()=>{let y={useGrouping:!1};if(U!=null)y.minimumFractionDigits=U,y.maximumFractionDigits=U;else y.maximumFractionDigits=0;if(B)y.style="unit",y.unit="percent";return y},[U,B]),w=s0.useCallback((y)=>{if(D.current=y,typeof V==="function")V(y);else if(V)V.current=y},[V]),C=s0.useCallback((y)=>{let f=y;if(F&&_!=null&&L!=null){if(f<_||f>L){let P=L-_;f=((f-_)%P+P)%P+_}}else{if(_!=null)f=Math.max(_,f);if(L!=null)f=Math.min(L,f)}let j=U!=null?f.toFixed(U):String(Math.round(f));J(B?`${j}%`:j)},[F,_,L,U,B,J]);return G(P$.Root,{value:b,onValueChange:(y,f)=>{if(y==null)return;let j=f.reason;if(j==="input-change"||j==="input-paste"||j==="input-clear")return;C(y)},onValueCommitted:(y,f)=>{if(f.reason==="scrub")I.current=!1,D.current?.blur()},min:F?void 0:_,max:F?void 0:L,step:W??1,largeStep:H??10,format:k,className:b0("flex items-center h-9 bg-transparent hover:bg-hover active:bg-active transition-colors duration-80 focus-within:ring-1 focus-within:ring-[color:var(--highlight,#6B97FF)] select-none border border-border",M.input,q),style:{width:Z},children:T(P$.ScrubArea,{direction:"horizontal",pixelSensitivity:1,onPointerDownCapture:()=>{I.current=!0},onClick:()=>{I.current=!1,O(!0),D.current?.focus(),D.current?.select()},className:b0("flex flex-1 min-w-0 items-center self-stretch px-2",!N&&"cursor-ew-resize"),children:[G(P$.ScrubAreaCursor,{className:"drop-shadow-[0_1px_1px_rgba(0,0,0,0.4)]",children:G("svg",{width:24,height:14,viewBox:"0 0 24 14",fill:"#000",stroke:"#fff",strokeWidth:1,"aria-hidden":"true",children:G("path",{d:"M0.5 7l5-5v3.5h13V2l5 5-5 5V8.5h-13V12l-5-5z"})})}),z&&G("span",{className:"text-[12px] text-muted-foreground mr-1 select-none",children:z}),G(P$.Input,{ref:w,"aria-label":Q,inputMode:K,onPointerDown:(y)=>{if(N)y.stopPropagation()},onFocus:(y)=>{if(I.current)return;O(!0),y.currentTarget.select()},onBlur:()=>{O(!1)},onKeyDown:(y)=>{if(y.key==="Enter")y.currentTarget.blur();else if(y.key==="Escape"){let f=y.currentTarget,j=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;if(j&&b!=null){let P=U!=null?b.toFixed(U):String(Math.round(b));j.call(f,B?`${P}%`:P),f.dispatchEvent(new Event("input",{bubbles:!0}))}f.blur()}},className:b0("flex-1 min-w-0 bg-transparent text-foreground text-[13px] outline-none tabular-nums",Y==="center"&&"text-center",Y==="right"&&"text-right",!N&&"pointer-events-none",X),style:{fontVariationSettings:R$.medium}})]})})});HS.displayName="ScrubColorInput";var O9=s0.forwardRef(({scrubbable:$=!1,...J},Q)=>$?G(HS,{ref:Q,...J}):G(WS,{ref:Q,...J}));O9.displayName="ColorInput";function Lt({onPick:$}){let[J,Q]=s0.useState(!1),Z=m9(),q=ZS;if(s0.useEffect(()=>{Q(typeof window<"u"&&"EyeDropper"in window)},[]),!J)return null;return G("button",{type:"button",onClick:async()=>{try{let K=await new window.EyeDropper().open();$(K.sRGBHex)}catch{}},"aria-label":"Pick color from screen",className:b0("flex items-center justify-center h-9 px-3 text-muted-foreground bg-transparent hover:bg-hover hover:text-foreground active:bg-active transition-colors duration-80 outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] cursor-pointer border border-border",Z.input),children:G(q,{size:16,strokeWidth:1.5})})}function Ft({color:$,size:J=24,className:Q,style:Z}){let q=m9();return G("span",{className:b0("inline-block relative shrink-0 overflow-hidden",q.bg,Q),style:{width:J,height:J,...KS,boxShadow:"inset 0 0 0 1px rgba(127,127,127,0.25)",...Z},children:G("span",{className:"absolute inset-0",style:{backgroundColor:$}})})}var BS=s0.forwardRef(({color:$,size:J=28,selected:Q,className:Z,onMouseEnter:q,onMouseLeave:X,...Y},z)=>{let K=m9(),[W,H]=s0.useState(!1),B=Q?"inset 0 0 0 1px rgba(127,127,127,0.25), 0 0 0 2px var(--background), 0 0 0 4px #6B97FF":W?"inset 0 0 0 1px rgba(127,127,127,0.25), 0 0 0 2px var(--background), 0 0 0 4px rgba(127,127,127,0.4)":"inset 0 0 0 1px rgba(127,127,127,0.25)";return G("button",{ref:z,type:"button","aria-label":`Select color ${$}`,className:b0("relative shrink-0 overflow-hidden cursor-pointer outline-none transition-shadow duration-100",K.bg,Z),style:{width:J,height:J,...KS,boxShadow:B},onMouseEnter:(U)=>{H(!0),q?.(U)},onMouseLeave:(U)=>{H(!1),X?.(U)},...Y,children:G("span",{className:"absolute inset-0",style:{backgroundColor:$}})})});BS.displayName="ColorSwatch";function Vt({swatches:$,current:J,onPick:Q}){let Z=s0.useMemo(()=>{let Y=K2(J);return Y?SQ(Y.r,Y.g,Y.b,Y.a).toLowerCase():""},[J]),[q,X]=s0.useState({});return s0.useEffect(()=>{let Y={};for(let z of $)if(!K2(z)){let K=zS(z);if(K)Y[z]=SQ(K.r,K.g,K.b,K.a).toLowerCase()}X(Y)},[$]),G("div",{className:"flex flex-wrap gap-2",children:$.map((Y,z)=>{let K=K2(Y),H=(K?SQ(K.r,K.g,K.b,K.a).toLowerCase():q[Y]??Y.toLowerCase())===Z;return G(BS,{color:Y,size:28,selected:H,onClick:()=>Q(Y)},`${Y}-${z}`)})})}var US=s0.forwardRef(({value:$,defaultValue:J="#6B97FF",onValueChange:Q,format:Z,defaultFormat:q="hex",onFormatChange:X,swatches:Y,hideEyedropper:z,formatOpen:K,defaultFormatOpen:W,className:H,...B},U)=>{let _=$!==void 0,[L,F]=s0.useState($??J),V=_?$:L,M=Z!==void 0,[D,N]=s0.useState(q),O=M?Z:D,I=s0.useMemo(()=>{let e=K2(V);if(!e)return{h:0,s:1,v:1,a:1};let H0=CQ(e.r,e.g,e.b);return{h:H0.s===0?0:H0.h,s:H0.s,v:H0.v,a:e.a}},[]),[A,b]=s0.useState(I),k=s0.useRef(null),w=s0.useRef("");s0.useEffect(()=>{if(!_)return;let e=w.current,H0=$;if(H0===e)return;let K0=K2(H0);if(!K0)return;k.current=null;let E=CQ(K0.r,K0.g,K0.b);b((m)=>({h:E.s===0?m.h:E.h,s:E.s,v:E.v,a:K0.a}))},[$,_]);let C=s0.useMemo(()=>FF(A.h,A.s,A.v,A.a),[A]),y=s0.useCallback((e)=>{let H0={...A,...e};b(H0);let K0=FF(H0.h,H0.s,H0.v,H0.a),E=VF(K0,O);if(w.current=E,!_)F(E);Q?.(E,K0)},[A,O,_,Q]),f=s0.useCallback((e)=>{if(!M)N(e);X?.(e);let H0=VF(C,e);if(w.current=H0,!_)F(H0);Q?.(H0,C)},[M,_,X,Q,C]),j=s0.useCallback((e)=>{let H0=zS(e);if(!H0)return;k.current=null;let K0=CQ(H0.r,H0.g,H0.b),E={h:K0.s===0?A.h:K0.h,s:K0.s,v:K0.v,a:H0.a};b(E);let m=FF(E.h,E.s,E.v,E.a),c=VF(m,O);if(w.current=c,!_)F(c);Q?.(c,m)},[A.h,O,_,Q]),P=s0.useCallback((e)=>{j(e)},[j]),x=s0.useCallback((e)=>{j(e)},[j]),p=s0.useMemo(()=>MF(A.h,A.s,A.v),[A.h,A.s,A.v]),t=Math.round(p.r),h=Math.round(p.g),r=Math.round(p.b),$0=`rgb(${t}, ${h}, ${r})`,Y0=m9();return T("div",{ref:U,className:b0("flex flex-col gap-2 p-3",Y0.container,H),style:{width:Yt},...B,children:[G(Kt,{h:A.h,s:A.s,v:A.v,onChange:(e,H0)=>y({s:e,v:H0})}),T("div",{className:"flex flex-col [&>*]:mb-0 [&>*+*]:-mt-px",children:[G(Gt,{h:A.h,onChange:(e)=>{k.current=null,y({h:e})}}),G(Wt,{a:A.a,solidColor:$0,solidR:t,solidG:h,solidB:r,onChange:(e)=>y({a:e})})]}),T("div",{className:"grid grid-cols-2 gap-2",children:[G(_t,{value:O,onChange:f,open:K,defaultOpen:W}),!z&&G(Lt,{onPick:x})]}),G(Mt,{parsed:C,format:O,oklchHue:k.current,onChannelChange:(e,H0)=>{let K0={...C};switch(e){case"hex":j(H0);return;case"r":case"g":case"b":{k.current=null;let E=e==="r"?Number(H0):K0.r,m=e==="g"?Number(H0):K0.g,c=e==="b"?Number(H0):K0.b,i=CQ(E,m,c);y({h:i.s===0?A.h:i.h,s:i.s,v:i.v});return}case"hSL":case"sSL":case"lSL":{if(e==="hSL")k.current=null;let E=DF(K0.r,K0.g,K0.b),m=e==="hSL"?Number(H0):E.h,c=e==="sSL"?Number(H0)/100:E.s,i=e==="lSL"?Number(H0)/100:E.l,u=XS(m,V8(c),V8(i)),d=CQ(u.r,u.g,u.b);y({h:d.s===0?m:d.h,s:d.s,v:d.v});return}case"L":case"C":case"H":{let E=NF(K0.r,K0.g,K0.b),m=k.current??E.H,c=e==="L"?Number(H0)/100:E.L,i=e==="C"?Number(H0):E.C,u=e==="H"?Number(H0):m;k.current=u;let d=YS(V8(c),Math.max(0,i),u),o=CQ(d.r,d.g,d.b);y({h:o.s===0?A.h:o.h,s:o.s,v:o.v});return}case"alphaPercent":{let E=V8(Number(H0)/100);y({a:E});return}}}}),Y&&Y.length>0&&G(Vt,{swatches:Y,current:C.hex,onPick:P})]})});US.displayName="ColorPicker";function Mt({parsed:$,format:J,oklchHue:Q,onChannelChange:Z}){let q=Math.round($.a*100);if(J==="hex"){let z=$.hex.replace(/^#/,"").toUpperCase();return T("div",{className:"grid grid-cols-2 gap-2",children:[G(c9,{label:"Hex",children:G(O9,{value:z,onCommit:(K)=>Z("hex",K.startsWith("#")?K:`#${K}`),ariaLabel:"Hex value",prefix:"#"})}),G(bW,{value:q,onCommit:(K)=>Z("alphaPercent",String(K))})]})}if(J==="rgb")return T("div",{className:"grid grid-cols-4 gap-1",children:[G(c9,{label:"Red",children:G(O9,{value:String($.r),onCommit:(z)=>Z("r",z),ariaLabel:"Red",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:255})}),G(c9,{label:"Green",children:G(O9,{value:String($.g),onCommit:(z)=>Z("g",z),ariaLabel:"Green",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:255})}),G(c9,{label:"Blue",children:G(O9,{value:String($.b),onCommit:(z)=>Z("b",z),ariaLabel:"Blue",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:255})}),G(bW,{value:q,onCommit:(z)=>Z("alphaPercent",String(z))})]});if(J==="hsl"){let z=DF($.r,$.g,$.b);return T("div",{className:"grid grid-cols-4 gap-1",children:[G(c9,{label:"Hue",children:G(O9,{value:String(Math.round(z.h)),onCommit:(K)=>Z("hSL",K),ariaLabel:"Hue",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:360,wrap:!0})}),G(c9,{label:"Saturation",children:G(O9,{value:String(Math.round(z.s*100)),onCommit:(K)=>Z("sSL",K),ariaLabel:"Saturation",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:100})}),G(c9,{label:"Lightness",children:G(O9,{value:String(Math.round(z.l*100)),onCommit:(K)=>Z("lSL",K),ariaLabel:"Lightness",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:100})}),G(bW,{value:q,onCommit:(K)=>Z("alphaPercent",String(K))})]})}let X=NF($.r,$.g,$.b),Y=Q??X.H;return T("div",{className:"grid grid-cols-4 gap-1",children:[G(c9,{label:"Lightness",children:G(O9,{value:(X.L*100).toFixed(0),onCommit:(z)=>Z("L",z),ariaLabel:"Lightness",align:"center",inputMode:"decimal",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:100})}),G(c9,{label:"Chroma",children:G(O9,{value:X.C.toFixed(2),onCommit:(z)=>Z("C",z),ariaLabel:"Chroma",align:"center",inputMode:"decimal",nudgeStep:0.01,nudgeShiftStep:0.1,decimals:2,scrubbable:!0,min:0,max:0.4})}),G(c9,{label:"Hue",children:G(O9,{value:Y.toFixed(0),onCommit:(z)=>Z("H",z),ariaLabel:"Hue",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,scrubbable:!0,min:0,max:360,wrap:!0})}),G(bW,{value:q,onCommit:(z)=>Z("alphaPercent",String(z))})]})}function c9({label:$,children:J}){return T(H1,{delayDuration:300,children:[G(B1,{asChild:!0,children:G("span",{className:"contents",children:J})}),G(W1,{children:$})]})}function bW({value:$,onCommit:J}){return G(c9,{label:"Alpha",children:G(O9,{value:`${$}%`,onCommit:(Q)=>{let Z=parseFloat(Q.replace("%",""));if(Number.isNaN(Z))return;J(Math.max(0,Math.min(100,Math.round(Z))))},ariaLabel:"Alpha",align:"center",inputMode:"numeric",nudgeStep:1,nudgeShiftStep:10,hasPercent:!0,scrubbable:!0,min:0,max:100})})}var OF=s0.forwardRef(({triggerAriaLabel:$,triggerLabel:J,triggerLabelPosition:Q="left",triggerShowValue:Z=!0,triggerShowRemove:q=!1,onTriggerRemove:X,triggerClassName:Y,side:z="bottom",align:K="start",sideOffset:W=6,alignOffset:H=0,open:B,defaultOpen:U=!1,onOpenChange:_,...L},F)=>{let V=B!==void 0,[M,D]=s0.useState(U),N=V?B:M,O=s0.useRef(null),[I,A]=s0.useState(null),b=m9(),k=s0.useCallback((h)=>{if(!V)D(h);_?.(h)},[V,_]),w=L.value!==void 0,[C,y]=s0.useState(L.value??L.defaultValue??"#6B97FF"),f=w?L.value:C,j=s0.useCallback((h,r)=>{if(!w)y(h);L.onValueChange?.(h,r)},[w,L]);s0.useEffect(()=>{if(N)return;let h=setTimeout(()=>O.current?.unmount(),150);return()=>clearTimeout(h)},[N]);let P=a9,x=s0.useMemo(()=>K2(f),[f]),p=x?SQ(x.r,x.g,x.b,x.a):f,t=x?SQ(x.r,x.g,x.b,x.a).toUpperCase():f;return G(Z2.Root,{open:N,onOpenChange:k,actionsRef:O,modal:!1,children:T("div",{ref:F,className:"inline-flex",children:[T(Z2.Trigger,{"aria-label":$,className:b0("flex items-center gap-2 h-9 px-2 border border-border bg-transparent hover:bg-hover transition-colors duration-80 outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] cursor-pointer",b.input,Y),style:{fontVariationSettings:R$.medium},children:[J&&Q==="left"&&G("span",{className:"text-[13px] text-muted-foreground px-1 select-none",children:J}),G(Ft,{color:p,size:20}),Z&&G("span",{className:"text-[13px] text-foreground tabular-nums",children:t}),J&&Q==="right"&&G("span",{className:"text-[13px] text-muted-foreground px-1 select-none",children:J}),q&&G("span",{role:"button","aria-label":"Remove color",tabIndex:0,onClick:(h)=>{h.stopPropagation(),X?.()},onKeyDown:(h)=>{if(h.key==="Enter"||h.key===" ")h.stopPropagation(),h.preventDefault(),X?.()},className:"ml-1 text-muted-foreground hover:text-foreground cursor-pointer flex items-center",children:G(P,{size:14,strokeWidth:1.5})})]}),G(Z2.Portal,{children:G("div",{className:D8,children:G(Z2.Positioner,{side:z,align:K,sideOffset:W,alignOffset:H,className:"z-[10000] outline-none",children:G(Eq.div,{initial:{opacity:0,y:-4,scaleY:0.96},animate:N?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:0.96},transition:N?YX.moderate:YX.moderate.exit,style:{transformOrigin:"top left"},onAnimationComplete:()=>{if(!N)O.current?.unmount()},children:G(Z2.Popup,{render:G("div",{ref:A}),className:"outline-none",children:G(Jt,{value:I,children:G(US,{...L,value:f,onValueChange:j,className:b0("bg-popover",L.className)})})})})})})})]})})});OF.displayName="ColorPickerPopover";var Dt=[{id:"no-outline",label:"No outline",style:{color:"#ffffff",outline_color:"transparent",background_color:"transparent"}},{id:"white-outline",label:"White",style:{color:"#ffffff",outline_color:"#000000",background_color:"transparent"}},{id:"yellow-outline",label:"Yellow",style:{color:"#ffd60a",outline_color:"#000000",background_color:"transparent"}},{id:"black-card",label:"Black",style:{color:"#ffffff",outline_color:"transparent",background_color:"#000000"}},{id:"white-card",label:"White card",style:{color:"#000000",outline_color:"transparent",background_color:"#ffffff"}},{id:"accent-card",label:"Accent",style:{color:"#ffffff",outline_color:"transparent",background_color:"#b65764"}},{id:"green-outline",label:"Green",style:{color:"#50f0a0",outline_color:"#000000",background_color:"transparent"}},{id:"blue-shadow",label:"Blue",style:{color:"#ffffff",outline_color:"#2f8cff",background_color:"transparent"}},{id:"pink-shadow",label:"Pink",style:{color:"#ffffff",outline_color:"#ff5ba7",background_color:"transparent"}},{id:"cream-card",label:"Cream",style:{color:"#251f1a",outline_color:"transparent",background_color:"#f4e8b7"}},{id:"red-outline",label:"Red",style:{color:"#ff334e",outline_color:"#ffffff",background_color:"transparent"}},{id:"teal-card",label:"Teal",style:{color:"#ffffff",outline_color:"transparent",background_color:"#0f766e"}},{id:"rose-card",label:"Rose",style:{color:"#fff1f4",outline_color:"transparent",background_color:"#be4f60"}}];function VS($,J){if(!$)return J;if($.trim().toLowerCase()==="transparent")return"rgba(0, 0, 0, 0)";return $}function S$($){let J=VS($,"rgba(0, 0, 0, 0)").replaceAll(" ","").toLowerCase();if(J==="rgba(0,0,0,0)")return"transparent";return J}function Nt($,J){return S$($.color)===S$(J.style.color)&&S$($.outline_color)===S$(J.style.outline_color)&&S$($.background_color)===S$(J.style.background_color)}function jW($){return Math.round($*100)}function zX($){return Math.max(0,Math.min(1,$/100))}function _S($){return Number($.toFixed(1))}function Ot($){return S$($)!=="transparent"}function MS({text:$,style:J,onTextChange:Q,onStyleChange:Z,speechSettings:q,onSpeechSettingsChange:X,onGenerateSpeech:Y}){let z=Z1(),[K,W]=d9.useState(jZ),H=q??K,[B,U]=d9.useState(!1),[_,L]=d9.useState(!1),F=d9.useRef(null),[V,M]=d9.useState(!1),D=J.background_opacity??0.7,N=jW(D),O=!Ot(J.background_color),I=d9.useMemo(()=>{if(!H.referenceAudio)return null;if(/^https?:\/\//i.test(H.referenceAudio))return H.referenceAudio;let w=H.referenceAudioSourceType??"input";return Z5({source_type:w,file_path:w==="input"||w==="output"?H.referenceAudio:void 0,local_path:w==="local"?H.referenceAudio:void 0})},[H.referenceAudio,H.referenceAudioSourceType]);d9.useEffect(()=>{let w=F.current;if(L(!1),w){w.pause();try{w.currentTime=0}catch(C){console.error("[SubtitleSettingsPanel] failed to reset reference audio preview:",C)}}return()=>{w?.pause()}},[I]);function A(w){let C={...H,...w};if(q){X?.(C);return}W(C)}async function b(){if(!Y||V)return;M(!0);try{await Y(H)}finally{M(!1)}}async function k(){let w=F.current;if(!w||!I)return;if(_){w.pause(),L(!1);return}if(w.ended)try{w.currentTime=0}catch(C){console.error("[SubtitleSettingsPanel] failed to restart reference audio preview:",C)}L(!0);try{await w.play()}catch(C){L(!1),console.error("[SubtitleSettingsPanel] failed to play reference audio preview:",C)}}return T("aside",{"data-testid":"subtitle-settings-panel","data-capture-wheel":"true",className:"flex h-full min-h-0 w-[35%] min-w-72 shrink-0 flex-col overflow-hidden border-l border-border bg-muted/30 text-card-foreground shadow-lg","aria-label":z("multitrack.subtitleTextSettings"),children:[I?G("audio",{ref:F,"data-testid":"reference-audio-preview",src:I,preload:"metadata",className:"hidden",onEnded:()=>L(!1)}):null,T(c4,{defaultValue:"text",className:"flex min-h-0 flex-1 flex-col",children:[G("div",{className:"border-b border-border p-1",children:T(o9,{className:"h-8 bg-card border-0 cursor-pointer",children:[T(H8,{value:"text",className:"gap-1 text-[10px]",children:[G(FS,{className:"h-3 w-3"}),z("multitrack.text")]}),T(H8,{value:"speech",className:"gap-1 text-[10px]",children:[G(AF,{className:"h-3 w-3"}),z("multitrack.speech")]})]})}),G(P9,{value:"text",className:"mt-0 min-h-0 flex-1 overflow-y-auto p-3",children:T("div",{className:"grid gap-4",children:[G("label",{className:"grid gap-1.5 text-xs font-medium text-foreground",children:G(p4,{"aria-label":z("multitrack.subtitleText"),className:"min-h-20 resize-none bg-card text-xs",value:$,onChange:(w)=>Q(w.currentTarget.value)})}),T("div",{className:"grid grid-cols-[3rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.fontSize")}),T("div",{className:"flex min-w-0 items-center gap-2",children:[G("div",{className:"flex-1 w-full",children:G(O8,{"aria-label":z("multitrack.fontSize"),value:[J.font_size],min:8,max:66,step:1,onValueChange:(w)=>Z({font_size:w[0]??J.font_size})})}),G(e8,{"aria-label":z("multitrack.fontSize"),className:"h-7 w-16 shrink-0",min:8,max:96,step:1,value:J.font_size,onChange:(w)=>Z({font_size:w})})]})]}),T("div",{className:"grid grid-cols-[3rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.backgroundOpacity")}),T("div",{className:"flex min-w-0 items-center gap-2",children:[G("div",{className:"flex-1 w-full",children:G(O8,{"aria-label":z("multitrack.backgroundOpacity"),value:[N],min:0,max:100,step:1,disabled:O,onValueChange:(w)=>Z({background_opacity:zX(w[0]??N)})})}),G(e8,{"aria-label":z("multitrack.backgroundOpacityPercent"),className:"h-7 w-16 shrink-0",min:0,max:100,step:1,disabled:O,value:N,onChange:(w)=>Z({background_opacity:zX(w)})})]})]}),T("div",{className:"grid grid-cols-[3rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.textColor")}),G(OF,{value:VS(J.color,"#ffffff"),defaultFormat:"hex",triggerAriaLabel:z("multitrack.textColor"),triggerClassName:"w-full justify-start h-6 text-[10px]",side:"left",align:"start",sideOffset:10,onValueChange:(w)=>Z({color:w})})]}),T("div",{className:"grid gap-2",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.presetStyle")}),G("div",{className:"grid grid-cols-7 gap-1.5",children:Dt.map((w)=>{let C=Nt(J,w);return G(k0,{type:"button",variant:"ghost","aria-pressed":C,className:b0("flex aspect-square h-auto min-h-0 w-full items-center justify-center rounded-md border bg-muted p-0 text-base font-bold transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",C?"border-primary ring-2 ring-primary":"border-border"),"aria-label":z("multitrack.applyPresetStyle",{name:w.label}),onClick:()=>Z(w.style),children:w.id==="no-outline"?G(LS,{className:"h-4 w-4 text-muted-foreground"}):G("span",{className:"rounded px-1 leading-none",style:{color:w.style.color,backgroundColor:w.style.background_color,textShadow:`1px 0 0 ${w.style.outline_color}, -1px 0 0 ${w.style.outline_color}, 0 1px 0 ${w.style.outline_color}, 0 -1px 0 ${w.style.outline_color}`},children:"T"})},w.id)})})]}),T("div",{className:"grid grid-cols-[3rem_repeat(3,minmax(0,1fr))] items-center gap-2",children:[T("span",{className:"text-[11px] font-medium text-foreground",children:[z("multitrack.position"),"%"]}),T("label",{className:"flex min-w-0 items-center gap-1",children:[G("span",{className:"text-[10px] font-medium text-muted-foreground",children:z("multitrack.positionX")}),G(e8,{"aria-label":z("multitrack.positionXPercent"),className:"h-7 min-w-0 flex-1",min:0,max:100,step:1,value:jW(J.x),onChange:(w)=>Z({x:zX(w)})})]}),T("label",{className:"flex min-w-0 items-center gap-1",children:[G("span",{className:"text-[10px] font-medium text-muted-foreground",children:z("multitrack.positionY")}),G(e8,{"aria-label":z("multitrack.positionYPercent"),className:"h-7 min-w-0 flex-1",min:0,max:95,step:1,value:jW(J.y),onChange:(w)=>Z({y:Math.min(0.95,zX(w))})})]}),T("label",{className:"flex min-w-0 items-center gap-1",children:[G("span",{className:"text-[10px] font-medium text-muted-foreground",children:z("multitrack.subtitleWidthShort")}),G(e8,{"aria-label":z("multitrack.subtitleWidthPercent"),className:"h-7 min-w-0 flex-1",min:10,max:100,step:1,value:jW(J.width),onChange:(w)=>Z({width:Math.max(0.1,zX(w))})})]})]})]})}),T(P9,{value:"speech",className:"mt-0 flex min-h-0 flex-1 flex-col overflow-hidden p-0",children:[G("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 pb-4",children:T("div",{className:"grid gap-4",children:[T("div",{className:"grid grid-cols-[4.25rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.speechModel")}),T(y8,{value:H.model,onValueChange:(w)=>A({model:w}),children:[G(P8,{"aria-label":z("multitrack.speechModel"),className:"h-8 w-full bg-card text-xs",children:G(W6,{})}),G(R8,{children:G(i5,{value:"VoxCPM2",children:"VoxCPM2"})})]})]}),G("label",{className:"grid gap-1.5",children:G(p4,{"aria-label":z("multitrack.speechPrompt"),className:"min-h-20 resize-none bg-card text-xs",value:H.prompt,placeholder:z("multitrack.speechPromptPlaceholder"),onChange:(w)=>A({prompt:w.currentTarget.value})})}),T("div",{className:"grid grid-cols-[4.25rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.speechCfg")}),T("div",{className:"flex min-w-0 items-center gap-2",children:[G("div",{className:"flex-1 w-full",children:G(O8,{"aria-label":z("multitrack.speechCfg"),value:[H.cfg],min:0.1,max:5,step:0.1,onValueChange:(w)=>A({cfg:_S(w[0]??H.cfg)})})}),G(e8,{"aria-label":z("multitrack.speechCfg"),className:"h-7 w-16 shrink-0",min:0.1,max:5,step:0.1,value:H.cfg,formatValue:(w)=>w.toFixed(1),onChange:(w)=>A({cfg:_S(w)})})]})]}),T("div",{className:"grid grid-cols-[4.25rem_minmax(0,1fr)] items-center gap-3",children:[G("span",{className:"text-[11px] font-medium text-foreground",children:z("multitrack.speechSteps")}),T("div",{className:"flex min-w-0 items-center gap-2",children:[G("div",{className:"flex-1 w-full",children:G(O8,{"aria-label":z("multitrack.speechSteps"),value:[H.steps],min:1,max:50,step:1,onValueChange:(w)=>A({steps:w[0]??H.steps})})}),G(e8,{"aria-label":z("multitrack.speechSteps"),className:"h-7 w-16 shrink-0",min:1,max:50,step:1,value:H.steps,onChange:(w)=>A({steps:w})})]})]}),T("div",{className:"grid grid-cols-[4.25rem_minmax(0,1fr)] items-start gap-3",children:[G("span",{className:"pt-1.5 text-[11px] font-medium text-foreground",children:z("multitrack.referenceAudio")}),G("div",{className:"min-w-0",children:H.referenceAudio?T("div",{className:"flex min-w-0 items-center gap-1",children:[T(t1,{open:B,onOpenChange:U,children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"secondary",className:"h-8 min-w-0 flex-1 cursor-pointer justify-start bg-card px-1 text-xs","aria-label":z("multitrack.reselectReferenceAudio"),children:[G(FJ,{className:"h-3.5 w-3.5 shrink-0 text-highlight"}),G("span",{className:"truncate",children:H.referenceAudio})]})}),G(o1,{className:"w-auto p-0",align:"end",children:G(M5,{value:H.referenceAudio,mediaType:"audio",defaultTab:"inputs",onChange:(w,C)=>{A({referenceAudio:w,referenceAudioSourceType:C??"input"}),U(!1)}})})]}),I?G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 cursor-pointer","aria-label":z(_?"multitrack.pauseReferenceAudio":"multitrack.playReferenceAudio"),onClick:()=>void k(),children:_?G(O7,{className:"h-3.5 w-3.5"}):G(P4,{className:"h-3.5 w-3.5"})}):null,G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 cursor-pointer text-destructive","aria-label":z("multitrack.clearReferenceAudio"),onClick:()=>A({referenceAudio:""}),children:G(N5,{className:"h-3.5 w-3.5"})})]}):T(t1,{open:B,onOpenChange:U,children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"secondary",className:"h-8 w-full cursor-pointer justify-start bg-card text-xs",children:[G(K5,{className:"h-3.5 w-3.5"}),z("multitrack.addReferenceAudio")]})}),G(o1,{className:"w-auto p-0",align:"end",children:G(M5,{value:"",mediaType:"audio",defaultTab:"inputs",onChange:(w,C)=>{A({referenceAudio:w,referenceAudioSourceType:C??"input"}),U(!1)}})})]})})]})]})}),G("div",{className:"sticky bottom-0 flex shrink-0 justify-end border-t border-border bg-muted/80 p-2 backdrop-blur",children:T(k0,{type:"button",disabled:!Y||V,className:"h-7 cursor-pointer bg-highlight px-3 text-[11px] text-background shadow hover:bg-highlight/90",onClick:b,children:[V?G(X6,{className:"h-3 w-3 animate-spin"}):G(AF,{className:"h-3 w-3"}),z("multitrack.speech")]})})]})]})]})}var At="calc(max(35%, 18rem) + 12px)";function wt($,J,Q){let Z=$.findIndex((z)=>z.id===J),q=$.findIndex((z)=>z.id===Q);if(Z<0||q<0||Z===q)return $;let X=[...$],[Y]=X.splice(Z,1);return X.splice(q,0,Y),X}function kt($,J){let Q=CW($,J);for(let Z of $.tracks){if(Z.type!=="task")continue;let q=Z.segments.findIndex((K)=>Q>=K.start_frame&&Q<K.end_frame);if(q<0)continue;let X=Z.segments[q],Y=Oz(X.content.images),z=Y.map((K)=>{let W=Z5({source_type:K.source_type??"input",file_path:K.file_path,local_path:K.local_path,url:K.url,slot_name:K.slot_name});return{image:K,url:W??void 0}});return{index:q,segmentId:X.id,allImages:Y,images:z}}return null}function It($,J){let Q=CW($,J);for(let Z of $.tracks){if(Z.type!=="task")continue;let q=Z.segments.findIndex((z)=>Q>=z.start_frame&&Q<z.end_frame);if(q<0)continue;let X=Z.segments[q],Y=fZ(X.content);return{index:q,segmentId:X.id,prompt:Y,taskMode:X.content.task_mode??"default",content:X.content}}return null}function Tt($,J){let Q=CW($,J);return $.tracks.flatMap((Z)=>{if(Z.type!=="subtitle"||Z.visible===!1)return[];return Z.segments.filter((q)=>Q>=q.start_frame&&Q<q.end_frame)})}function EW($){let J=Math.max(0.1,Math.min(1,$.width)),Q=Math.max(0,Math.min(1-J,$.x));return{...$,font_size:Math.max(8,Math.min(96,$.font_size)),outline_color:$.outline_color||"#000000",background_opacity:Math.max(0,Math.min(1,$.background_opacity??0.7)),x:Q,y:Math.max(0,Math.min(0.95,$.y)),width:J}}function IS($){let J=$.trim().toLowerCase();return J==="transparent"||J==="rgba(0, 0, 0, 0)"||J==="rgba(0,0,0,0)"}function bt($,J){if(IS($))return"transparent";let Q=Math.max(0,Math.min(1,J)),Z=$.trim().match(/^#?([0-9a-fA-F]{6})$/);if(Z){let X=Z[1],Y=Number.parseInt(X.slice(0,2),16),z=Number.parseInt(X.slice(2,4),16),K=Number.parseInt(X.slice(4,6),16);return`rgba(${Y}, ${z}, ${K}, ${Q})`}let q=$.trim().match(/^rgba?\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)(?:\s*,\s*[0-9.]+)?\s*\)$/);if(q)return`rgba(${q[1]}, ${q[2]}, ${q[3]}, ${Q})`;return $}function DS($){return[`1px 0 0 ${$}`,`-1px 0 0 ${$}`,`0 1px 0 ${$}`,`0 -1px 0 ${$}`,`1px 1px 0 ${$}`,`-1px 1px 0 ${$}`,`1px -1px 0 ${$}`,`-1px -1px 0 ${$}`].join(", ")}function TS({data:$,currentTime:J,selectedSegment:Q,isPlaying:Z,playbackNonce:q=0,node:X,app:Y,editingSubtitleSegmentId:z,onSubtitleEditRequestHandled:K,onSelectSegment:W,onGlobalSettingsChange:H,onSelectedSegmentContentChange:B,taskSegments:U,selectedTaskSegments:_,onTrackSegmentsContentChange:L,onTaskTrackSegmentsChange:F,onSelectedSegmentDurationChange:V,onGenerateSubtitleSpeech:M}){let D=Z1(),N=I5.useRef(null),[O,I]=I5.useState(null),A=Xz(O?`${O.segmentId}:${O.imageId}`:null,()=>I(null)),[b,k]=I5.useState(null),[w,C]=I5.useState("balanced"),[y,f]=I5.useState(!1),[j,P]=I5.useState(!1),[x,p]=I5.useState(null),[t,h]=I5.useState(null),[r,$0]=I5.useState(null),Y0=aY(X),e=I5.useMemo(()=>K9(X,Y,"image"),[X,Y,y]),H0=I5.useMemo(()=>$.tracks.filter((z0)=>z0.type==="video").flatMap((z0)=>z0.segments),[$.tracks]),K0=I5.useMemo(()=>$.tracks.some((z0)=>z0.segments.length>0),[$.tracks]),E=I5.useMemo(()=>{let z0=H0.find((C0)=>C0.content.media_type==="video");if(!z0)return null;return Z5({source_type:z0.content.source_type??"input",file_path:z0.content.file_path,local_path:z0.content.local_path,url:z0.content.url,slot_name:z0.content.slot_name})},[H0]),m=Q?.trackType==="audio"?null:Q,c=m?.trackType==="task"?null:AS($,J,m?.trackType==="video"?m.segment.id:null),i=wS($,J,m),u=m===null?kt($,J):null,d=m===null?It($,J):null,o=I5.useMemo(()=>{if(m?.trackType==="task")return[];let z0=Tt($,J);if(m?.trackType!=="subtitle")return z0;let C0=m.segment,h0=z0.findIndex((l0)=>l0.id===C0.id);if(h0<0)return[...z0,C0];return z0.map((l0,j0)=>j0===h0?C0:l0)},[J,$,m]),S=kS(Y0,r),s=Q?.trackType==="video"||Q?.trackType==="audio"?p2(mJ(Q.segment),$.frame_rate):null,G0=Q?.trackType==="subtitle"?EW({...h2,...Q.segment.content.subtitle_style}):null,l=Q?.trackType==="subtitle"?{...jZ,...Q.segment.content.subtitle_speech}:jZ,Q0=Q?.trackType==="task"?Q.segment.content.images??[]:[],J0=O?.source==="selected"?Q0.find((z0)=>z0.id===O.imageId)??null:O?.source==="active"?u?.allImages.find((z0)=>z0.id===O.imageId)??null:null,B0=u?.images.find(({image:z0})=>z0.id===b)??u?.images[0]??null,W0=Boolean(u&&!c),L0=w==="image-large"?"w-32 flex-[0_0_8rem]":"w-20 flex-[0_0_5rem]",_0=w==="image-large"?"h-full flex-none":"h-full flex-none",D0=G0?"mx-auto flex h-full min-h-24 w-full max-w-full items-stretch justify-center gap-0":W0?"mx-auto flex h-full min-h-24 w-full max-w-full items-center justify-center gap-3":"mx-auto flex h-full min-h-24 w-fit max-w-full items-center justify-center gap-3";I5.useEffect(()=>{I(null)},[Q?.segment.id]),I5.useEffect(()=>{if(!z)return;let z0=o.find((C0)=>C0.id===z);if(!z0)return;h({segmentId:z0.id,text:z0.content.text??""}),K?.()},[o,z,K]),I5.useEffect(()=>{if(!u){k(null);return}if(u.images.some(({image:z0})=>z0.id===b))return;k(u.images[0]?.image.id??null)},[u,b]),I5.useEffect(()=>{if(!d){p(null);return}let z0=d.content.user_prompt_variant==="b"?"b":"a";if(x?.segmentId===d.segmentId&&x.variant===z0)return;p(null)},[d,x?.segmentId,x?.variant]),I5.useEffect(()=>{if(O?.source==="active"&&O.segmentId!==u?.segmentId)I(null)},[O,u?.segmentId]),I5.useEffect(()=>{if(!E){$0(null);return}let z0=!1;return EZ(E).then((C0)=>{if(!z0)$0({width:C0.width,height:C0.height})}).catch((C0)=>{if(console.error("[PreviewArea] failed to read first video metadata:",C0),!z0)$0(null)}),()=>{z0=!0}},[E]);function c0(z0){if(!u)return;let C0=N.current;if(N.current=null,!C0)return;L?.([{segmentId:u.segmentId,patch:{images:wt(u.allImages,C0,z0)}}])}function g(z0){if(!u)return;let C0=u.allImages.find((h0)=>h0.id===z0);if(C0?.shared_reference===!0){let h0=U&&U.length>0?U:$.tracks.filter((j0)=>j0.type==="task").flatMap((j0)=>j0.segments),l0=b7(C0);L?.(j7(h0,C0,!1).map((j0)=>({segmentId:j0.segmentId,patch:{images:j0.segmentId===u.segmentId?j0.images.filter((V1)=>b7(V1)!==l0):j0.images}})));return}L?.([{segmentId:u.segmentId,patch:{images:u.allImages.filter((h0)=>h0.id!==z0)}}])}function a(z0,C0){let h0=U&&U.length>0?U:u?$.tracks.filter((l0)=>l0.type==="task").flatMap((l0)=>l0.segments):[];if(h0.length===0||C0&&!fJ(h0,z0))return;L?.(j7(h0,z0,C0).map((l0)=>({segmentId:l0.segmentId,patch:{images:l0.images}})))}function I0(z0,C0){if(!u)return;L?.([{segmentId:u.segmentId,patch:{images:u.allImages.map((h0)=>h0.id===z0?{...h0,muted:C0}:h0)}}])}function A0(z0){if(Array.from(z0.files).some((h0)=>h0.type.startsWith("image/")))return!0;return Array.from(z0.items??[]).some((h0)=>h0.kind==="file"&&h0.type.startsWith("image/"))}function F0(z0){if(!z0.dataTransfer||!A0(z0.dataTransfer))return;z0.preventDefault(),P(!0)}function u0(z0){if(!z0.dataTransfer||!A0(z0.dataTransfer))return;z0.preventDefault(),P(!0)}function P0(z0){let C0=z0.relatedTarget;if(C0 instanceof Node&&z0.currentTarget.contains(C0))return;P(!1)}async function n0(z0){if(z0.preventDefault(),P(!1),!z0.dataTransfer||!u)return;let C0=X4-u.allImages.length;if(C0<=0)return;let h0=Array.from(z0.dataTransfer.files).filter((V1)=>V1.type.startsWith("image/")).slice(0,C0);if(h0.length===0)return;let j0=(await Promise.allSettled(h0.map((V1)=>y7(V1)))).flatMap((V1)=>{if(V1.status==="fulfilled")return[V1.value];return console.error("[PreviewArea] failed to upload active task image:",V1.reason),[]});if(j0.length===0)return;C5("inputs"),L?.([{segmentId:u.segmentId,patch:{images:[...u.allImages,...j0]}}])}function R0(z0,C0){if(!u)return;let h0=X4-u.allImages.length;if(h0<=0)return;let l0=uJ(z0).slice(0,h0),j0=C0??(z0.startsWith("http://")||z0.startsWith("https://")?"url":"input"),V1=l0.map((r1)=>gJ(r1,j0));if(V1.length===0)return;L?.([{segmentId:u.segmentId,patch:{images:[...u.allImages,...V1]}}]),f(!1)}function Y1(z0){if(!x||!d)return;p({...x,text:z0}),L?.([{segmentId:x.segmentId,patch:vZ(d.content,z0)}])}function z1(){p(null)}function a0(z0,C0){L?.([{segmentId:z0,patch:{task_mode:C0}}])}function C1(z0,C0){L?.([{segmentId:z0,patch:{continuity_mode:C0}}])}function g1(z0,C0){L?.([{segmentId:z0,patch:{ref_image_size:C0}}])}function b1(){if(!t)return;if(Q?.trackType==="subtitle"&&Q.segment.id===t.segmentId)B({text:t.text});else L?.([{segmentId:t.segmentId,patch:{text:t.text}}]);h(null)}function n(z0,C0,h0,l0,j0){if(!C0)return G("div",{"data-testid":`task-preview-slot-image-${z0.id}`,className:`${j0} flex items-center justify-center bg-muted/30 px-2 text-center text-[9px] text-muted-foreground`,children:z0.source_type==="slot"?D("mediaSelector.slotImage",{n:Az(z0,l0)}):h0});return z0.panorama_view?G(Gz,{imageId:z0.id,imageUrl:C0,alt:h0,view:z0.panorama_view,className:j0}):G("img",{className:j0,src:C0,alt:h0,draggable:!1})}function N0(z0="h-10 w-10 aspect-square",C0=!1){if(!u||u.allImages.length>=X4)return null;return T(t1,{open:y,onOpenChange:f,children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"outline","data-testid":u.images.length===0?"task-preview-empty-add-image":"task-preview-add-image",className:`cursor-pointer shrink-0 border-dashed bg-background/70 text-muted-foreground transition-colors hover:bg-background/90 ${j?"border-primary bg-accent/20 text-foreground":"border-border"} ${C0?"flex-col gap-1":""} ${z0}`,"aria-label":D("multitrack.addImage"),onClick:(h0)=>{h0.stopPropagation(),f(!0)},onDragEnter:F0,onDragOver:u0,onDragLeave:P0,onDrop:n0,children:[G(K5,{className:"h-5 w-5"}),C0?G("span",{className:"text-[10px] font-semibold",children:D("multitrack.addImage")}):null]})}),G(o1,{className:"w-auto p-0",align:"end",children:G(M5,{value:"",mediaType:"image",allowMultipleSelection:!0,maxSelectionCount:X4-u.allImages.length,slotItems:e,onChange:R0})})]})}function w0(z0,C0,h0,l0,j0="aspect-square w-full",V1=!0,r1="thumbnail"){if(!u)return null;let w1=z0.file_name??z0.file_path??z0.local_path??z0.url??z0.slot_name??z0.id,e1=z0.shared_reference?z0.muted===!0?"border-highlight opacity-50":"border-highlight":l0?"border-primary":"border-border";return T("div",{"data-testid":`task-preview-image-${z0.id}`,className:`group/task-image relative shrink-0 cursor-pointer overflow-hidden rounded-sm border bg-black ${e1} ${j0}`,draggable:!0,onDragStart:()=>{N.current=z0.id},onDragEnd:()=>{N.current=null},onDragOver:(D5)=>D5.preventDefault(),onDrop:()=>c0(z0.id),children:[G(k0,{type:"button",variant:"ghost",className:r1==="flow"&&C0?"h-full w-auto max-w-full rounded-none p-0 hover:bg-transparent":"h-full w-full rounded-none p-0 hover:bg-transparent","aria-label":w1,onClick:()=>k(z0.id),children:n(z0,C0,w1,h0,r1==="flow"&&C0?`h-full w-auto max-w-full object-contain transition-opacity ${z0.muted===!0?"opacity-40":""}`:`h-full w-full object-contain transition-opacity ${z0.muted===!0?"opacity-40":""}`)}),V1?r0(z0,w1,r1==="flow"?"flow":"split",Boolean(C0)):null]},z0.id)}function v0(z0){let C0=Q?.segment.id===z0.id&&Q.trackType==="subtitle",h0=EW({...h2,...z0.content.subtitle_style}),l0=t?.segmentId===z0.id?t:null,j0=bt(h0.background_color,h0.background_opacity),V1=!IS(j0),r1=(X0)=>{if(!C0)return;B({subtitle_style:EW({...h0,...X0})})};function w1(X0){if(l0){X0.stopPropagation();return}if(X0.preventDefault(),X0.stopPropagation(),!C0){W?.(z0.id);return}let O0=X0.currentTarget.closest("[data-multitrack-preview-area]")?.getBoundingClientRect();if(!O0)return;let{width:x0,height:J1}=O0,u1=X0.clientX,S1=X0.clientY,Z0=h0;function f0(M1){r1({x:Z0.x+(M1.clientX-u1)/x0,y:Z0.y+(M1.clientY-S1)/J1})}function i0(){globalThis.removeEventListener("mousemove",f0),globalThis.removeEventListener("mouseup",i0)}globalThis.addEventListener("mousemove",f0),globalThis.addEventListener("mouseup",i0)}function e1(X0){X0.preventDefault(),X0.stopPropagation(),W?.(z0.id),h({segmentId:z0.id,text:z0.content.text??""})}function D5(X0,O0){if(!C0)return;O0.preventDefault(),O0.stopPropagation();let x0=O0.currentTarget.closest("[data-multitrack-preview-area]")?.getBoundingClientRect();if(!x0)return;let J1=x0.width,u1=O0.clientX,S1=h0;function Z0(i0){let M1=(i0.clientX-u1)/J1;if(X0==="left"){let N1=S1.x+M1;r1({x:N1,width:S1.width-M1});return}r1({width:S1.width+M1})}function f0(){globalThis.removeEventListener("mousemove",Z0),globalThis.removeEventListener("mouseup",f0)}globalThis.addEventListener("mousemove",Z0),globalThis.addEventListener("mouseup",f0)}return T("div",{"data-testid":"subtitle-preview-overlay",className:`absolute z-10 text-center leading-snug ${C0?"ring-1 ring-primary cursor-move":"cursor-pointer"}`,style:{left:`${(h0.x+h0.width/2)*100}%`,top:`${h0.y*100}%`,width:"max-content",maxWidth:`${h0.width*100}%`,transform:"translateX(-50%)",color:h0.color,fontSize:h0.font_size,textShadow:DS(h0.outline_color||"#000000")},onMouseDown:w1,onDoubleClick:e1,children:[l0?G($6,{"data-testid":"subtitle-preview-editor",autoFocus:!0,"aria-label":D("multitrack.editSubtitle"),value:l0.text,className:`inline-block h-auto max-w-full rounded-sm border-primary px-3 py-1.5 text-center leading-snug text-inherit shadow-none focus-visible:ring-1 ${V1?"shadow-sm":""}`,style:{width:`${Math.max(l0.text.length+2,5)}em`,backgroundColor:j0,color:h0.color,fontSize:h0.font_size,textShadow:DS(h0.outline_color||"#000000")},onMouseDown:(X0)=>X0.stopPropagation(),onClick:(X0)=>X0.stopPropagation(),onDoubleClick:(X0)=>X0.stopPropagation(),onChange:(X0)=>h({...l0,text:X0.currentTarget.value}),onBlur:b1,onKeyDown:(X0)=>{if(X0.key==="Enter")X0.preventDefault(),b1();if(X0.key==="Escape")X0.preventDefault(),h(null)}}):G("span",{"data-testid":"subtitle-preview-text",className:`inline-block max-w-full whitespace-pre-wrap break-words rounded-sm px-2 py-1 ${V1?"shadow-sm":""}`,style:{backgroundColor:j0},children:z0.content.text}),C0?T(G1,{children:[G("span",{className:"absolute left-0 top-0 h-full w-1 cursor-ew-resize bg-primary",onMouseDown:(X0)=>D5("left",X0)}),G("span",{className:"absolute right-0 top-0 h-full w-1 cursor-ew-resize bg-primary",onMouseDown:(X0)=>D5("right",X0)})]}):null]})}function r0(z0,C0,h0,l0=!0){if(!u)return null;let j0=h0==="flow"?"absolute right-0 top-1 flex gap-1 opacity-0 transition-opacity group-hover/task-image:opacity-100 group-focus-within/task-image:opacity-100":"absolute right-0 top-0 flex gap-0.5 opacity-0 transition-opacity group-hover/task-image:opacity-100 group-focus-within/task-image:opacity-100",V1="h-auto w-auto",r1="[&_svg]:!size-4",w1=z0.shared_reference?16:18,e1=U&&U.length>0?U:$.tracks.filter((X0)=>X0.type==="task").flatMap((X0)=>X0.segments),D5=z0.shared_reference===!0||fJ(e1,z0);return T("div",{className:j0,children:[G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:z0.shared_reference===!0?"secondary":"ghost",className:`${V1} cursor-pointer rounded-none bg-background/70 hover:bg-background/90 ${r1} ${z0.shared_reference===!0?"text-highlight":"text-muted-foreground"}`,style:{width:w1,height:w1},"aria-label":z0.shared_reference===!0?D("multitrack.disableSharedReference"):D("multitrack.enableSharedReference"),"aria-pressed":z0.shared_reference===!0,disabled:!D5,onClick:(X0)=>{X0.stopPropagation(),a(z0,z0.shared_reference!==!0)},children:G(vJ,{})})}),G(W1,{side:"bottom",className:"max-w-64",children:D5?D("multitrack.sharedImageReferenceTooltip"):D("multitrack.sharedImageLimitTooltip")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:z0.muted===!0?"secondary":"ghost","data-testid":`task-preview-image-muted-${z0.id}`,className:`${V1} cursor-pointer bg-background/70 text-[14px] font-bold hover:bg-background/90 ${z0.muted===!0?"text-destructive hover:text-destructive":"text-muted-foreground"}`,style:{width:w1,height:w1},"aria-label":z0.muted===!0?D("multitrack.includeImage"):D("multitrack.bypassImage"),"aria-pressed":z0.muted===!0,onClick:(X0)=>{X0.stopPropagation(),I0(z0.id,z0.muted!==!0)},children:"M"})}),G(W1,{side:"bottom",children:z0.muted===!0?D("multitrack.includeImageTooltip"):D("multitrack.bypassImageTooltip")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:`${V1} cursor-pointer bg-background/70 font-bold text-muted-foreground hover:bg-background/90 ${r1}`,style:{width:w1,height:w1},"aria-label":D("multitrack.previewImage"),disabled:!l0,onClick:(X0)=>{X0.stopPropagation(),I({imageId:z0.id,segmentId:u.segmentId,source:"active"})},children:G(E7,{})})}),G(W1,{side:"bottom",children:D("multitrack.previewImage")})]})}),G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:`${V1} cursor-pointer rounded-none bg-background/70 text-destructive hover:bg-background/90 hover:text-destructive ${r1}`,style:{width:w1,height:w1},"aria-label":`${D("multitrack.deleteImage")} ${C0}`,onClick:(X0)=>{X0.stopPropagation(),g(z0.id)},children:G(a9,{})})}),G(W1,{side:"bottom",children:D("multitrack.deleteImage")})]})})]})}function K1(){if(!d)return null;let z0=x?.segmentId===d.segmentId?x:null,h0=(z0?.text??d.prompt).trim().length>0,l0=w==="image-large"?D("multitrack.previewLayoutBalanced"):D("multitrack.previewLayoutImageLarge");return T("div",{"data-testid":"task-prompt-overlay",className:`flex w-full editing ${z0?"items-end":"items-center"} bg-background/70 px-2 text-primary-foreground`,children:[!W0?G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 cursor-pointer rounded-none text-primary [&_svg]:!size-3","aria-label":l0,onClick:(j0)=>{j0.stopPropagation(),C((V1)=>V1==="balanced"?"image-large":"balanced")},children:w==="image-large"?G(OS,{}):G(NS,{})})}),G(W1,{side:"top",children:l0})]})}):null,z0?G(p4,{"data-testid":"task-prompt-editor",autoFocus:!0,"aria-label":D("multitrack.userPrompt"),placeholder:D("multitrack.promptPlaceholder"),className:"min-h-24 flex-1 resize-none border-none bg-transparent px-1 py-0 text-[9px] leading-4 text-primary shadow-none focus-visible:ring-0",value:z0.text,onMouseDown:(j0)=>j0.stopPropagation(),onClick:(j0)=>j0.stopPropagation(),onDoubleClick:(j0)=>j0.stopPropagation(),onChange:(j0)=>Y1(j0.currentTarget.value),onBlur:z1,onKeyDown:(j0)=>{if(j0.key==="Escape")j0.preventDefault(),p(null);if((j0.metaKey||j0.ctrlKey)&&j0.key==="Enter")j0.preventDefault(),z1()}}):G("div",{"data-testid":"task-prompt-text",className:`min-w-0 flex-1 truncate px-1 text-[9px] leading-4 ${h0?"text-primary":"text-muted-foreground"}`,title:h0?d.prompt:D("multitrack.promptPlaceholder"),onDoubleClick:(j0)=>{j0.preventDefault(),j0.stopPropagation(),p({segmentId:d.segmentId,variant:d.content.user_prompt_variant==="b"?"b":"a",text:d.prompt})},children:h0?d.prompt:D("multitrack.promptPlaceholder")}),G("span",{className:"shrink-0 px-1 text-[9px] leading-4 text-secondary",children:"|"}),r4(Y0.format)&&d.index>0&&T(G1,{children:[T(y8,{value:d.content.continuity_mode??xZ,disabled:!L,onValueChange:(j0)=>C1(d.segmentId,j0),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"data-testid":"task-continuity-mode-select","aria-label":D("multitrack.continuityMode"),className:"h-5 min-h-0 w-24 shrink-0 cursor-pointer border-none bg-transparent px-1 text-[9px] leading-4 text-primary shadow-none focus-visible:ring-1 focus-visible:ring-ring [&_svg]:size-3",onClick:(j0)=>j0.stopPropagation(),onDoubleClick:(j0)=>j0.stopPropagation(),children:G(W6,{})})}),G(W1,{side:"top",children:D("multitrack.continuityModeTooltip")})]})}),G(R8,{children:kz.map((j0)=>G(i5,{value:j0,children:G("span",{className:"text-[10px]",children:D(`multitrackContinuityModes.${j0}`)})},j0))})]}),G("span",{className:"shrink-0 px-1 text-[9px] leading-4 text-secondary",children:"|"})]}),r4(Y0.format)&&["ref","edit"].includes(d.taskMode)&&T(G1,{children:[T(y8,{value:d.content.ref_image_size??Tz,disabled:!L,onValueChange:(j0)=>g1(d.segmentId,j0),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"data-testid":"task-ref-image-size-select","aria-label":D("multitrack.refImageSize"),className:"h-5 min-h-0 w-16 shrink-0 cursor-pointer border-none bg-transparent px-1 text-[9px] leading-4 text-primary shadow-none focus-visible:ring-1 focus-visible:ring-ring [&_svg]:size-3",onClick:(j0)=>j0.stopPropagation(),onDoubleClick:(j0)=>j0.stopPropagation(),children:G(W6,{})})}),G(W1,{side:"top",children:D("multitrack.refImageSizeTooltip")})]})}),G(R8,{children:Iz.map((j0)=>G(i5,{value:j0,children:G("span",{className:"text-[10px]",children:D(`multitrackRefImageSizes.${j0}`)})},j0))})]}),G("span",{className:"shrink-0 px-1 text-[9px] leading-4 text-secondary",children:"|"})]}),T(y8,{value:d.taskMode,disabled:!L,onValueChange:(j0)=>a0(d.segmentId,j0),children:[G(a1,{delayDuration:300,children:T(H1,{children:[G(B1,{asChild:!0,children:G(P8,{"data-testid":"task-mode-select","aria-label":D("multitrack.taskMode"),className:"h-5 min-h-0 w-12 shrink-0 cursor-pointer border-none bg-transparent px-1 text-[9px] leading-4 text-primary shadow-none focus-visible:ring-1 focus-visible:ring-ring [&_svg]:size-3",onClick:(j0)=>j0.stopPropagation(),onDoubleClick:(j0)=>j0.stopPropagation(),children:G(W6,{})})}),G(W1,{side:"top",children:D("multitrack.taskModeTooltip")})]})}),G(R8,{children:wz.map((j0)=>G(i5,{value:j0,children:G("span",{className:"text-[10px]",children:RW(j0,D)})},j0))})]})]})}function x1(){let z0=[[PW,"multitrack.emptyTaskTrack","multitrack.emptyTaskTrackPurpose"],[q4,"multitrack.emptyVideoTrack","multitrack.emptyVideoTrackPurpose"],[$4,"multitrack.emptyAudioTrack","multitrack.emptyAudioTrackPurpose"],[h$,"multitrack.emptySubtitleTrack","multitrack.emptySubtitleTrackPurpose"]],C0=[[TJ,"multitrack.emptyTaskMarkers","multitrack.emptyTaskMarkersPurpose"],[Qz,"multitrack.emptyTaskOverview","multitrack.emptyTaskOverviewPurpose"]];return T("div",{"data-testid":"multitrack-empty-preview",className:"flex h-full w-full flex-col items-center justify-center px-6 py-5 text-center",children:[G(q4,{className:"mb-2 h-9 w-9 text-muted-foreground","aria-hidden":"true"}),G("h3",{className:"text-sm font-semibold text-foreground",children:D("multitrack.emptyPreviewTitle")}),G("p",{className:"mt-1 text-xs text-muted-foreground",children:D("multitrack.emptyPreviewDescription")}),G("dl",{className:"mt-4 grid max-w-xl grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-left text-[11px] leading-4",children:z0.map(([h0,l0,j0])=>T("div",{className:"contents",children:[T("dt",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[G(h0,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),G("span",{children:D(l0)})]}),G("dd",{className:"text-muted-foreground",children:D(j0)})]},l0))}),G("div",{"data-testid":"multitrack-empty-preview-features",className:"mt-4 flex max-w-2xl items-start justify-center gap-5 border-t border-border pt-3 text-left",children:C0.map(([h0,l0,j0])=>T("div",{className:"flex max-w-xs items-start gap-2",children:[G(h0,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),T("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[G("span",{className:"font-medium text-foreground",children:D(l0)}),G("span",{className:"block",children:D(j0)})]})]},l0))})]})}function s1(z0){let C0=Z5({source_type:z0.source_type??"input",file_path:z0.file_path,local_path:z0.local_path,url:z0.url,slot_name:z0.slot_name});if(!C0)return null;let h0=z0.file_name??z0.file_path??z0.local_path??z0.url??z0.id;return T("div",{"data-testid":"task-image-expanded-preview","data-zoom":A.zoom.toFixed(2),className:"absolute inset-0 z-30 flex items-center justify-center overflow-hidden bg-black p-3 pt-12",onWheel:A.onWheel,children:[T(k0,{type:"button",variant:"secondary",className:"absolute left-2 top-2 z-20 h-8 cursor-pointer gap-1.5 px-2.5 text-xs","aria-label":D("multitrack.backToPreview"),onClick:()=>I(null),children:[G(yW,{className:"h-4 w-4"}),G("span",{children:D("multitrack.backToPreview")})]}),T("span",{className:"pointer-events-none absolute right-2 top-2 z-20 rounded bg-background/70 px-2 py-1 text-[10px] tabular-nums text-foreground",children:[Math.round(A.zoom*100),"%"]}),G("img",{ref:A.imageRef,src:C0,alt:h0,className:"max-h-full max-w-full object-contain transition-transform duration-100 ease-out",style:{transform:`scale(${A.zoom})`,transformOrigin:`${A.origin.x}% ${A.origin.y}%`},draggable:!1})]})}if(Q?.trackType==="task")return G("div",{"data-multitrack-preview-area":!0,className:"relative flex min-h-24 w-full min-w-0 max-w-full flex-1 overflow-hidden rounded-sm bg-background",onClick:(z0)=>z0.stopPropagation(),children:J0?s1(J0):G(gT,{segment:Q.segment,node:X,app:Y,trackSegments:U,selectedSegments:_,videoSegments:H0,mediaTracks:$.tracks.filter((z0)=>z0.type==="audio"||z0.type==="video"),frameRate:$.frame_rate,totalFrames:$.total_length,imageIndexOffset:r4(Y0.format)?1:0,format:Y0.format,onContentChange:B,onTrackSegmentsContentChange:L,onTrackSegmentsChange:F,onDurationChange:V,onOpenImagePreview:(z0)=>I({imageId:z0,segmentId:Q.segment.id,source:"selected"})})});return T("div",{"data-multitrack-preview-area":!0,className:"relative flex min-h-24 w-full min-w-0 max-w-full flex-1 items-center justify-center overflow-hidden rounded-sm text-xs text-muted-foreground bg-background",onClick:(z0)=>z0.stopPropagation(),children:[J0&&O?.source==="active"?s1(J0):null,Q===null&&S.mode==="megapixels"?T(bJ,{"data-testid":"multitrack-preview-resolution-badge",variant:"outline",className:"pointer-events-none absolute right-2 top-2 z-30 flex items-baseline gap-1.5 border-border bg-background/90 px-2 py-1 text-foreground shadow-sm backdrop-blur",children:[G("span",{className:"text-[9px] font-normal text-muted-foreground",children:D("multitrack.currentResolution")}),T("span",{className:"text-[11px] font-semibold tabular-nums",children:[S.width," × ",S.height]})]}):null,T("div",{className:"flex h-full min-h-24 w-full flex-col items-center justify-center gap-0.5",children:[!K0?x1():null,T("div",{className:!K0?"hidden":`min-w-0 ${D0}`,children:[W0&&u?T(G1,{children:[T("div",{"data-testid":"task-preview-images","data-layout":"flow",className:"flex h-full min-h-0 w-full flex-wrap content-center items-center justify-center gap-2 overflow-y-auto p-2",children:[u.images.map(({image:z0,url:C0},h0)=>w0(z0,C0,h0,z0.id===B0?.image.id,z0.source_type==="slot"&&!C0?"h-40 w-40 aspect-square":"h-40 w-fit max-w-full",!0,"flow")),N0("h-40 w-40 aspect-square",!0)]}),o.map((z0)=>G("div",{children:v0(z0)},z0.id))]}):u&&T("div",{"data-testid":"task-preview-images",className:`flex max-h-full shrink-0 flex-col gap-2 overflow-hidden transition-all duration-300 ease-in-out ${L0}`,children:[G("div",{className:"shrink-0 text-center text-[10px] font-medium text-foreground pt-2",children:D("multitrack.previewTaskLabel",{n:u.index})}),T("div",{className:"flex min-h-0 flex-col gap-2 overflow-y-auto pb-2",children:[u.images.map(({image:z0,url:C0},h0)=>{return w0(z0,C0,h0,z0.id===B0?.image.id)}),N0("aspect-square h-auto w-full")]})]}),!W0?G("div",{className:G0?"relative flex h-auto min-h-0 min-w-0 max-h-full flex-1 self-center flex-col items-center justify-center overflow-hidden":`min-w-0 transition-all duration-300 ease-in-out ${u?_0:"h-full flex-[1_1_100%]"}`,style:G0?{aspectRatio:`${S.width} / ${S.height}`}:void 0,children:G(cT,{activeVideo:c,resolution:S,isPlaying:Z,playbackNonce:q,muted:!0,volume:0,frameRate:$.frame_rate,className:G0?"absolute inset-0 h-full w-full":void 0,children:o.map((z0)=>G("div",{children:v0(z0)},z0.id))})}):null,Q?.trackType==="subtitle"&&G0?G(MS,{text:Q.segment.content.text??"",style:G0,onTextChange:(z0)=>B({text:z0}),onStyleChange:(z0)=>{B({subtitle_style:EW({...G0,...z0})})},speechSettings:l,onSpeechSettingsChange:(z0)=>B({subtitle_speech:z0}),onGenerateSpeech:(z0)=>M?.(Q.segment,z0)??Promise.resolve()}):null]}),K0?K1():null]}),G(xI,{sources:i,isPlaying:Z,playbackNonce:q}),G(hI,{globalMuted:$.muted===!0,globalVolumeDb:$.volume_db??0,frameRate:$.frame_rate,selectedMediaVolumeDb:Q?.trackType==="video"||Q?.trackType==="audio"?Q.segment.content.volume_db??0:null,selectedMediaMuted:Q?.trackType==="video"||Q?.trackType==="audio"?Q.segment.content.muted===!0:!1,selectedMediaDuration:s,rightInset:G0?At:12,onGlobalSettingsChange:H,onSelectedSegmentContentChange:B,onSelectedSegmentDurationChange:V})]})}var hQ=R(v(),1);var bS=5;function ES({segment:$,frameRate:J,open:Q,onOpenChange:Z,onConfirm:q}){let X=Z1(),[Y,z]=hQ.useState(bS),K=$?mJ($):0,W=Math.max(1,Math.round(J));hQ.useEffect(()=>{if(!Q||!$)return;z(bS)},[Q,$?.id]);let H=hQ.useMemo(()=>{return C9(Y,W)},[W,Y]),B=H>0&&H<K?Math.max(2,Math.ceil(K/H)):0,U=Boolean($)&&H>=1&&H<K&&B>=2,_=p2(K,W),L=Math.max(1,Math.floor(p2(Math.max(1,K-1),W)));function F(M){z(Math.max(1,Math.round(M)))}function V(M){if(M.preventDefault(),!$||!U)return;q($.id,H),Z(!1)}return G(AJ,{open:Q,onOpenChange:Z,children:T(y2,{className:"max-w-xs",children:[T(kZ,{children:[G(P2,{children:X("multitrack.splitTaskSegment")}),G(TZ,{children:X("multitrack.splitTaskSegmentDescription",{frames:K,seconds:_.toFixed(2)})})]}),T("form",{className:"space-y-4",onSubmit:V,children:[T("div",{className:"flex w-full items-center gap-2",children:[G(e8,{min:1,max:L,step:1,value:Y,className:"h-9 min-w-0 flex-1","aria-label":X("multitrack.splitTaskSegmentSeconds"),onChange:F}),G("span",{className:"flex h-9 shrink-0 items-center rounded-md border border-border bg-muted px-3 text-sm text-muted-foreground",children:X("multitrack.splitTaskSegmentSecondsUnit")})]}),G("p",{className:`text-xs leading-5 ${U?"text-muted-foreground":"text-destructive"}`,children:U?X("multitrack.splitTaskSegmentPreview",{count:B}):X("multitrack.splitTaskSegmentInvalid")}),T(IZ,{children:[G(k0,{type:"button",variant:"outline",onClick:()=>Z(!1),children:X("common.cancel")}),T(k0,{type:"submit",disabled:!U,children:[G(jS,{className:"h-4 w-4"}),X("multitrack.splitTaskSegmentConfirm")]})]})]})]})})}var I6=R(v(),1);var k6=R(v(),1);var jt=8,Et=12,yt=8,Pt=4;function Rt($,J,Q){let Z=Math.max(J,1),q=$.start_frame/Z*Q,X=$.end_frame/Z*Q;return{left:q,width:Math.max(2,X-q)}}function G2({trackType:$,segmentIndex:J,segment:Q,totalLength:Z,frameRate:q,areaWidth:X,canvasScale:Y,selected:z,onSelect:K,onDelete:W,onDistribute:H,onClone:B,onMerge:U,onSplitTask:_,onSmartSplit:L,onSmartSplitTasks:F,onRecognizeSubtitles:V,cutMode:M=!1,onCut:D,onResize:N,onResizePreview:O,onMove:I,onDragPreviewChange:A,getDragPreviewStart:b,onDragPreviewEnd:k,onDoubleClick:w,dimmed:C=!1,showTaskIndex:y=!0,taskOverview:f=!1,audioLocked:j=!1,audioLockEnabled:P=!1,onAudioLockToggle:x,sharedReference:p=!1,onSharedReferenceToggle:t}){let h=Z1(),r=k6.useRef(!1),$0=k6.useRef(null),Y0=k6.useRef(null),e=k6.useRef(!1),[H0,K0]=k6.useState(!1),[E,m]=k6.useState(!1),[c,i]=k6.useState(null),[u,d]=k6.useState(null),[o,S]=k6.useState(null),{left:s,width:G0}=Rt(Q,Z,X),l=Z5({source_type:Q.content.source_type??"input",file_path:Q.content.file_path,local_path:Q.content.local_path,url:Q.content.url}),Q0=Math.max(0,Q.end_frame-Q.start_frame),J0=Q.content.duration&&Q.content.duration>0?Q.content.duration*Math.max(q,1):null,B0=Q.origin_start_frame??Q.start_frame,W0=J0?Math.max(0,Math.min(1,(Q.start_frame-B0)/J0)):0,L0=J0?Math.max(W0,Math.min(1,(Q.end_frame-B0)/J0)):1,_0=Math.max(0,(Q.start_frame-B0)/Math.max(q,1)),D0=RW(Q.content.task_mode??"default",h),c0=$==="task"?y?h("multitrackSegment.taskLabel",{n:J+1,mode:D0}):D0:$==="subtitle"?Q.content.text??h("multitrack.subtitle"):Q.content.file_name??Q.id,g=M6(Q0,{frameRate:q,showFrames:!0}),a=Q.content.user_prompt?.trim()??"",I0=gZ(Q.content.images).flatMap((n)=>{let N0=Z5({source_type:n.source_type??"input",file_path:n.file_path,local_path:n.local_path,url:n.url,slot_name:n.slot_name});return N0?[N0]:[]}),A0=Array.from({length:24},(n,N0)=>I0.map((w0,v0)=>({key:`${N0}-${v0}`,url:w0}))).flat(),F0=Z4($),u0=$==="video"?h("multitrack.cloneVideoSegment"):$==="audio"?h("multitrack.cloneAudioSegment"):h("multitrack.cloneTaskSegment"),P0=H0?"var(--warning)":z?F0.borderColor:F0.backgroundColorStrong,n0={left:c?0:s,top:c?c.y:void 0,bottom:c?void 0:void 0,width:c?c.width:G0,height:c?c.height:void 0,position:"absolute",transform:c?`translate3d(${c.x}px, 0, 0)`:void 0,backgroundColor:F0.backgroundColor,color:F0.textColor,border:`1px solid ${P0}`,"--multitrack-waveform":F0.waveformColor??void 0,cursor:M?"text":o??"grab",zIndex:E?9999:z?30:1,boxShadow:E?"0 8px 24px rgb(0 0 0 / 0.35)":void 0,pointerEvents:c?"none":void 0};function R0(n){if($0.current=n,Y0.current!==null)return;Y0.current=requestAnimationFrame(()=>{if(Y0.current=null,i($0.current),$0.current)A?.(Q.id,$0.current.nextStartTime,$0.current.clientY)})}k6.useEffect(()=>{if(!F0.showThumbnail||!l){d(null);return}let n=!1,N0=null;return AI(l,_0).then((w0)=>{if(n){URL.revokeObjectURL(w0);return}N0=w0,d(w0)}).catch((w0)=>{if(console.error("[MultiTrackSegmentBlock] failed to capture video poster:",w0),!n)d(null)}),()=>{if(n=!0,N0)URL.revokeObjectURL(N0)}},[l,F0.showThumbnail,_0]),k6.useEffect(()=>{return()=>{if(Y0.current!==null)cancelAnimationFrame(Y0.current)}},[]);function Y1(){return z?Et:jt}function z1(n){let N0=n/Math.max(G0,1);return Number.isFinite(N0)&&N0>0.01?N0:Math.max(Y,0.01)}function a0(n,N0,w0){return(n-N0)/w0/Math.max(X,1)*Math.max(Z,1)}function C1(){return Math.max(1,Math.round(yt/Math.max(X,1)*Math.max(Z,1)))}function g1(n){if(M)return;let N0=n.currentTarget.getBoundingClientRect(),w0=z1(N0.width),v0=(n.clientX-N0.left)/w0,r0=Y1();S(v0<=r0||v0>=N0.width/w0-r0?"ew-resize":"grab")}function b1(n){if(n.button!==0)return;if(n.preventDefault(),n.stopPropagation(),M)return;r.current=!1,e.current=!1,K(Q.id,n.metaKey||n.ctrlKey?"toggle":n.shiftKey||z?"add":"replace");let N0=n.currentTarget.getBoundingClientRect(),w0=z1(N0.width),v0=(n.clientX-N0.left)/w0,r0=N0.width/w0,K1=Y1(),x1=v0<=K1?"start":v0>=r0-K1?"end":null,s1=n.clientX,z0=n.clientY;if(!x1){let S1=function(f0){let i0=a0(f0.clientX,s1,w0);if(Math.hypot(f0.clientX-s1,f0.clientY-z0)<Pt)return;if(!X0)return;if(r.current=!0,!e.current)e.current=!0,m(!0);let N1=w1+i0,_5=b?.(Q.id,N1,f0.clientY)??N1,O1=_5/Math.max(Z,1)*X,A1=(f0.clientY-X0.top)/O0-x0;R0({x:O1,y:A1,width:J1,height:u1,nextStartTime:_5,clientY:f0.clientY})},Z0=function(){if(Y0.current!==null)cancelAnimationFrame(Y0.current),Y0.current=null;e.current=!1,m(!1);let f0=$0.current;if(r.current&&f0)I(Q.id,f0.nextStartTime,f0.clientY);$0.current=null,i(null),k?.(),globalThis.removeEventListener("mousemove",S1),globalThis.removeEventListener("mouseup",Z0)},w1=Q.start_frame,e1=n.currentTarget.getBoundingClientRect(),X0=n.currentTarget.offsetParent?.getBoundingClientRect(),O0=w0,x0=(n.clientY-e1.top)/O0,J1=e1.width/O0,u1=e1.height/O0;globalThis.addEventListener("mousemove",S1),globalThis.addEventListener("mouseup",Z0);return}let C0=x1,h0=C0==="start"?Q.start_frame:Q.end_frame,l0=C0==="start"?N0.left:N0.right,j0=C1();K0(!0);function V1(w1){let e1=a0(w1.clientX,l0,w0);if(Math.abs(e1)>0)r.current=!0;O(Q.id,C0,h0+e1,j0)}function r1(w1){let e1=a0(w1.clientX,l0,w0);if(r.current)N(Q.id,C0,h0+e1,j0);K0(!1),globalThis.removeEventListener("mousemove",V1),globalThis.removeEventListener("mouseup",r1)}globalThis.addEventListener("mousemove",V1),globalThis.addEventListener("mouseup",r1)}return G(G1,{children:T(a6,{children:[G(t6,{asChild:!0,children:T("div",{role:"button","data-multitrack-segment":"",tabIndex:0,className:`absolute top-1 bottom-1 flex items-center rounded select-none active:opacity-70 ${$==="audio"?"overflow-visible":"overflow-hidden"} ${C?"opacity-50":""}`,style:n0,onMouseDown:b1,onMouseMove:g1,onMouseLeave:()=>S(null),onClick:(n)=>{if(n.stopPropagation(),M&&D){let N0=n.currentTarget.getBoundingClientRect(),w0=N0.width/Math.max(Y,0.01),v0=(n.clientX-N0.left)/Math.max(Y,0.01),r0=Math.max(0,Math.min(1,v0/Math.max(w0,1))),K1=Math.round(Q.start_frame+r0*(Q.end_frame-Q.start_frame));D(Q.id,K1);return}if(!r.current)n.preventDefault()},onContextMenu:(n)=>{n.stopPropagation(),K(Q.id,z?"add":"replace")},onDoubleClick:(n)=>{if(n.preventDefault(),n.stopPropagation(),M)return;w?.(Q.id,n)},onKeyDown:(n)=>{if(n.key==="Enter")K(Q.id,n.metaKey||n.ctrlKey?"toggle":n.shiftKey?"add":"replace");if(n.key==="Delete"||n.key==="Backspace")W(Q.id)},children:[G("div",{className:"pointer-events-none relative flex h-full min-w-0 flex-1 flex-col gap-0.5 overflow-hidden rounded-sm",children:$==="task"&&f?T(G1,{children:[A0.length>0?G("div",{className:"absolute inset-0 overflow-hidden bg-black",children:G("div",{className:"flex h-full w-max",children:A0.map(({key:n,url:N0})=>G("img",{src:N0,alt:"",className:"h-full w-auto max-w-none shrink-0 object-contain",draggable:!1,onError:(w0)=>{w0.currentTarget.style.display="none"}},n))})}):null,G("div",{className:A0.length>0?"absolute inset-x-0 bottom-0 z-10 flex items-center bg-black px-1 py-0.5 text-white":"absolute inset-0 flex items-center justify-center px-1 text-center",children:G("span",{className:`min-w-0 text-[9px] leading-tight ${A0.length>0?"truncate":"line-clamp-3"}`,children:a||c0})})]}):T(G1,{children:[T("div",{className:`flex h-3.5 min-w-0 items-center gap-1 leading-none ${F0.textClassName}`,style:{backgroundColor:F0.titleBackgroundColor??void 0},children:[G("span",{className:"truncate rounded-sm px-1 font-medium",children:c0}),G("span",{className:"shrink-0 rounded-sm px-1 tabular-nums",children:g})]}),F0.showThumbnail?G("div",{className:"h-8 overflow-hidden bg-black",style:{backgroundImage:u?`url(${JSON.stringify(u)})`:void 0,backgroundPosition:"left center",backgroundRepeat:"repeat-x",backgroundSize:"auto 32px"}}):null,F0.showWaveform?T("div",{className:$==="audio"?"relative min-h-0 flex-1 overflow-hidden rounded-sm":"relative h-2.5 overflow-hidden rounded-sm",style:{backgroundColor:F0.backgroundColorStrong},children:[G("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 bg-warning"}),G(dY,{content:{source_type:Q.content.source_type??"input",file_path:Q.content.file_path,local_path:Q.content.local_path,url:Q.content.url,slot_name:Q.content.slot_name},startRatio:W0,endRatio:L0,className:"h-full w-full",color:F0.waveformColor??void 0})]}):$!=="audio"?G("div",{className:"min-h-0 flex-1"}):null]})}),G("span",{className:"absolute left-0 top-0 h-full w-0.5 cursor-ew-resize",style:{background:H0||z?P0:"transparent"}}),G("span",{className:"absolute right-0 top-0 h-full w-0.5 cursor-ew-resize",style:{background:H0||z?P0:"transparent"}}),$==="audio"||$==="video"?G(a1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:p?"secondary":"ghost","data-testid":`${$}-shared-reference`,"aria-label":p?h("multitrack.disableSharedReference"):h("multitrack.enableSharedReference"),"aria-pressed":p,className:`absolute ${P?"right-8":"right-2"} top-0.5 z-20 h-5 w-5 cursor-pointer bg-background/80 shadow-sm [&_svg]:!size-3 ${p?"text-highlight":"text-muted-foreground"}`,onMouseDown:(n)=>{n.preventDefault(),n.stopPropagation()},onClick:(n)=>{n.preventDefault(),n.stopPropagation(),t?.(!p)},children:G(vJ,{})})}),G(W1,{side:"bottom",className:"max-w-72",children:h("multitrack.sharedReferenceTooltip")})]})}):null,($==="audio"||$==="video")&&P?G(G1,{children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",size:"icon",variant:j?"secondary":"ghost","data-testid":$==="audio"?"audio-segment-lock":"video-segment-audio-lock","aria-label":j?h("multitrack.unlockAudio"):h("multitrack.lockAudio"),"aria-pressed":j,className:`absolute right-2 top-0.5 z-20 h-5 w-5 cursor-pointer bg-background/80 shadow-sm [&_svg]:!size-3 ${j?"text-highlight":"text-muted-foreground"}`,onMouseDown:(n)=>{n.preventDefault(),n.stopPropagation()},onClick:(n)=>{n.preventDefault(),n.stopPropagation(),x?.(!j)},children:j?G(PS,{}):G(yS,{})})}),G(W1,{side:"bottom",className:"max-w-72",children:h($==="video"?"multitrack.videoAudioLockTooltip":"multitrack.audioLockTooltip")})]})}):null]})}),T(y6,{children:[$==="video"&&L?G(Q5,{onClick:()=>L(Q.id),children:h("multitrack.smartSplit")}):null,$==="video"&&F?G(Q5,{onClick:()=>F(Q.id),children:h("multitrack.smartSplitTasksOnly")}):null,($==="video"||$==="audio")&&V?T(EA,{children:[G(S3,{children:h("multitrack.recognizeSubtitles")}),T(h3,{children:[G(Q5,{onClick:()=>V(Q.id,"whisper-large-v3"),children:h("multitrack.recognizeSubtitlesWhisper")}),G(Q5,{onClick:()=>V(Q.id,"qwen3-asr"),children:h("multitrack.recognizeSubtitlesQwen3")})]})]}):null,$==="task"&&H?G(Q5,{onClick:H,children:h("multitrack.distributeTaskSegments")}):null,B?G(Q5,{onClick:()=>B(Q.id),children:u0}):null,$==="task"&&U?G(Q5,{onClick:U,children:h("multitrack.mergeTaskSegments")}):null,$==="task"&&_?G(Q5,{onClick:()=>_(Q.id),children:h("multitrack.splitTaskSegment")}):null,G(Q5,{onClick:()=>W(Q.id),children:h("multitrack.deleteSegment")})]})]})})}var x$=R(v(),1);function SW({track:$,icon:J,preserveSelection:Q=!1,onChange:Z}){let q=Z1();return T("div",{className:"flex h-full flex-col items-center justify-center gap-0.5",children:[J,T("div",{className:"flex gap-px mt-1",children:[T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"outline",size:"icon",className:`h-3 w-3 cursor-pointer rounded-sm bg-card p-0 text-[8px] ${$.muted?"text-destructive":"text-muted-foreground"}`,"aria-label":q("multitrack.muteTrack",{name:$.name}),"aria-pressed":$.muted,onClick:(X)=>{if(Q)X.stopPropagation();Z({muted:!$.muted})},children:q("multitrack.muteShort")})}),G(W1,{children:q("multitrack.muteTrack",{name:$.name})})]}),T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"outline",size:"icon",className:`h-3 w-3 cursor-pointer rounded-sm bg-card p-0 text-[8px] ${$.solo?"text-highlight":"text-muted-foreground"}`,"aria-label":q("multitrack.soloTrack",{name:$.name}),"aria-pressed":$.solo===!0,onClick:(X)=>{if(Q)X.stopPropagation();Z({solo:!$.solo})},children:q("multitrack.soloShort")})}),G(W1,{children:q("multitrack.soloTrack",{name:$.name})})]})]})]})}var RS=R(v(),1);function W2($){let J=[...$].sort((q,X)=>q.start_frame-X.start_frame);if(J.length===0)return[];let Q=J[0].start_frame>0?[{startFrame:0,endFrame:J[0].start_frame}]:[],Z=J[0].end_frame;for(let q of J.slice(1)){if(q.start_frame>Z)Q.push({startFrame:Z,endFrame:q.start_frame});Z=Math.max(Z,q.end_frame)}return Q}var H2=RS.forwardRef(function({gap:J,totalLength:Q,width:Z,ariaLabel:q,onClick:X,className:Y,style:z,...K},W){let B=(J.startFrame+(J.endFrame-J.startFrame)/2)/Math.max(Q,1)*Z;return G(k0,{...K,ref:W,type:"button",variant:"secondary",size:"icon","data-testid":`track-gap-add-${J.startFrame}-${J.endFrame}`,className:b0("absolute top-1/2 z-10 h-5 w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer",Y),style:{...z,left:B},"aria-label":q,onClick:(U)=>{U.stopPropagation(),X?.(U)},children:G(K5,{className:"h-2.5 w-2.5"})})});function xQ({track:$,children:J}){let Q=Z1();return G(k0,{type:"button",variant:"ghost",size:"icon",draggable:!0,className:"h-5 w-5 cursor-grab p-0 active:cursor-grabbing","aria-label":Q("multitrack.reorderTrack",{name:$.name}),"data-multitrack-track-drag-handle":$.id,children:J})}function Ct($){if($==="output")return"outputs";if($==="local")return"local";if($==="url")return"url";if($==="slot")return"slot";return"inputs"}function CS({track:$,totalLength:J,frameRate:Q,width:Z,canvasScale:q,selectedSegmentIds:X,node:Y,app:z,onAddAudio:K,onReplaceAudio:W,onSelectSegment:H,onDeleteSegment:B,onCloneSegment:U,onDeleteTrack:_,onTrackAudioSettingsChange:L,onSharedReferenceChange:F=()=>{},onResizeSegment:V,onResizeSegmentPreview:M,onMoveSegment:D,onDragPreviewChange:N,getDragPreviewStart:O,onDragPreviewEnd:I,onRecognizeSubtitles:A=()=>{},cutMode:b,onCutSegment:k,audioLockEnabled:w=!1}){let C=Z1(),y=x$.useRef(null),[f,j]=x$.useState(!1),[P,x]=x$.useState(null),p=x$.useMemo(()=>K9(Y,z,"audio"),[Y,z,f,P]),t=$.segments.reduce((e,H0)=>Math.max(e,H0.end_frame),0),h=$.segments.length===0?6:t/Math.max(J,1)*Z+6,r=W2($.segments),$0=P?$.segments.find((e)=>e.id===P.segmentId):void 0,Y0=$0?.content.file_path??$0?.content.local_path??$0?.content.url??($0?.content.slot_name?`__slot__:${$0.content.slot_name}`:"");return T("div",{className:"relative flex h-16 border-b border-border","data-multitrack-track-id":$.id,children:[G("div",{className:"shrink-0 border-r border-border",style:{width:q5},children:G(SW,{track:$,icon:G(xQ,{track:$,children:G(wJ,{className:"h-3.5 w-3.5 text-muted-foreground"})}),preserveSelection:$.segments.some((e)=>X.has(e.id)),onChange:(e)=>L($.id,e)})}),T("div",{ref:y,className:"relative min-w-0 flex-1",children:[$.segments.map((e,H0)=>G(G2,{trackType:"audio",segmentIndex:H0,segment:e,totalLength:J,frameRate:Q,areaWidth:Z,canvasScale:q,selected:X.has(e.id),onSelect:H,onDelete:B,onClone:U,onResize:V,onResizePreview:M,onMove:D,onDragPreviewChange:N,getDragPreviewStart:O,onDragPreviewEnd:I,onRecognizeSubtitles:A,cutMode:b,onCut:k,audioLocked:w&&$.audio_locked===!0,audioLockEnabled:w,onAudioLockToggle:(K0)=>{L($.id,{audio_locked:K0})},sharedReference:e.content.shared_reference===!0,onSharedReferenceToggle:(K0)=>{F($.id,e.id,K0)},onDoubleClick:(K0,E)=>{let m=y.current?.getBoundingClientRect();if(!m)return;x({segmentId:K0,x:(E.clientX-m.left)/Math.max(q,0.01),y:(E.clientY-m.top)/Math.max(q,0.01)})}},e.id)),r.map((e)=>T(t1,{children:[G(b5,{asChild:!0,children:G(H2,{gap:e,totalLength:J,width:Z,ariaLabel:C("multitrack.addAudioSegment")})}),G(o1,{className:"w-auto p-0",align:"center",children:G(M5,{value:"",mediaType:"audio",defaultTab:"inputs",slotItems:p,onChange:(H0,K0="input")=>{let E=p.find((c)=>c.value===H0)?.audio_name,m=E?z9(E,"input"):void 0;K($.id,H0,K0,m,e.startFrame,e.endFrame)}})})]},`${e.startFrame}-${e.endFrame}`)),T("div",{className:"absolute top-1/2 flex -translate-y-1/2 gap-1",style:{left:h},children:[T(t1,{open:f,onOpenChange:j,children:[G(b5,{asChild:!0,children:G(k0,{type:"button",variant:"secondary",size:"icon",className:"h-5 w-5 cursor-pointer","aria-label":C("multitrack.addAudioSegment"),children:G(K5,{className:"h-2.5 w-2.5"})})}),G(o1,{className:"w-auto p-0",align:"start",children:G(M5,{value:"",mediaType:"audio",defaultTab:"inputs",slotItems:p,onChange:(e,H0="input")=>{let K0=p.find((m)=>m.value===e)?.audio_name,E=K0?z9(K0,"input"):void 0;K($.id,e,H0,E),j(!1)}})})]}),$.segments.length===0?T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer text-destructive","aria-label":C("multitrack.deleteTrack",{name:$.name}),onClick:()=>_($.id),children:G(N5,{className:"h-2.5 w-2.5"})})}),G(W1,{children:C("multitrack.deleteTrack",{name:$.name})})]}):null]}),T(t1,{open:P!==null,onOpenChange:(e)=>{if(!e)x(null)},children:[P?G(_6,{asChild:!0,children:G("div",{className:"absolute h-px w-px",style:{left:P.x,top:P.y}})}):null,G(o1,{className:"w-auto p-0",align:"start",children:G(M5,{value:Y0,mediaType:"audio",defaultTab:Ct($0?.content.source_type),slotItems:p,onChange:(e,H0="input")=>{if(!P)return;let K0=p.find((m)=>m.value===e)?.audio_name,E=K0?z9(K0,"input"):void 0;W($.id,P.segmentId,e,H0,E),x(null)}})})]})]})]})}var f$=R(v(),1);function St($){if($==="output")return"outputs";if($==="local")return"local";if($==="url")return"url";if($==="slot")return"slot";return"inputs"}function wF($,J){let Q=J.find((Z)=>Z.value===$)?.video_name;return Q?z9(Q,"input"):void 0}function SS({track:$,totalLength:J,frameRate:Q,width:Z,canvasScale:q,selectedSegmentIds:X,node:Y,app:z,onAddVideo:K,onSelectSegment:W,onDeleteSegment:H,onCloneSegment:B,canDeleteTrack:U,onDeleteTrack:_,onTrackAudioSettingsChange:L,onSharedReferenceChange:F=()=>{},onResizeSegment:V,onResizeSegmentPreview:M,onMoveSegment:D,onDragPreviewChange:N,getDragPreviewStart:O,onDragPreviewEnd:I,onReplaceVideo:A,onSmartSplit:b,onSmartSplitTasks:k,onRecognizeSubtitles:w=()=>{},cutMode:C,onCutSegment:y,audioLockEnabled:f=!1}){let j=Z1(),P=f$.useRef(null),[x,p]=f$.useState(!1),[t,h]=f$.useState(null),r=f$.useMemo(()=>K9(Y,z,"video"),[Y,z,x,t]),$0=t?$.segments.find((E)=>E.id===t.segmentId):void 0,Y0=$0?.content.source_type==="slot"&&$0.content.slot_name?`__slot__:${$0.content.slot_name}`:$0?.content.file_path??$0?.content.local_path??$0?.content.url??"",H0=$.segments.reduce((E,m)=>Math.max(E,m.end_frame),0)/Math.max(J,1)*Z,K0=W2($.segments);return T("div",{className:"relative flex h-16 border-b border-border","data-multitrack-track-id":$.id,children:[G("div",{className:"shrink-0 border-r border-border",style:{width:q5},children:G(SW,{track:$,icon:G(xQ,{track:$,children:G(q4,{className:"h-3.5 w-3.5 text-muted-foreground"})}),preserveSelection:$.segments.some((E)=>X.has(E.id)),onChange:(E)=>L($.id,E)})}),T("div",{ref:P,className:"relative min-w-0 flex-1",children:[$.segments.map((E,m)=>G(G2,{trackType:$.type,segmentIndex:m,segment:E,totalLength:J,frameRate:Q,areaWidth:Z,canvasScale:q,selected:X.has(E.id),onSelect:W,onDelete:H,onClone:B,onSmartSplit:b,onSmartSplitTasks:k,onRecognizeSubtitles:w,cutMode:C,onCut:y,onResize:V,onResizePreview:M,onMove:D,onDragPreviewChange:N,getDragPreviewStart:O,onDragPreviewEnd:I,audioLocked:f&&$.audio_locked===!0,audioLockEnabled:f,onAudioLockToggle:(c)=>{L($.id,{audio_locked:c})},sharedReference:E.content.shared_reference===!0,onSharedReferenceToggle:(c)=>{F($.id,E.id,c)},onDoubleClick:(c,i)=>{let u=P.current?.getBoundingClientRect();if(!u)return;h({segmentId:c,x:(i.clientX-u.left)/Math.max(q,0.01),y:(i.clientY-u.top)/Math.max(q,0.01)})}},E.id)),K0.map((E)=>T(t1,{children:[G(b5,{asChild:!0,children:G(H2,{gap:E,totalLength:J,width:Z,ariaLabel:j("multitrack.addVideo")})}),G(o1,{className:"w-auto p-0",align:"center",children:G(M5,{value:"",mediaType:"video",defaultTab:"inputs",slotItems:r,onChange:(m,c="input")=>{K($.id,m,c,E.startFrame,E.endFrame,wF(m,r))}})})]},`${E.startFrame}-${E.endFrame}`)),T("div",{className:"absolute top-1/2 flex -translate-y-1/2 flex-col gap-1",style:{left:$.segments.length===0?6:H0+6},children:[T(t1,{open:x,onOpenChange:p,children:[G(b5,{asChild:!0,children:G(k0,{type:"button",variant:"secondary",size:"icon",className:"h-5 w-5 cursor-pointer","aria-label":j("multitrack.addVideo"),children:G(K5,{className:"h-2.5 w-2.5"})})}),G(o1,{className:"w-auto p-0",align:"start",children:G(M5,{value:"",mediaType:"video",defaultTab:"inputs",slotItems:r,onChange:(E,m="input")=>{K($.id,E,m,void 0,void 0,wF(E,r)),p(!1)}})})]}),U?T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer text-destructive","aria-label":j("multitrack.deleteTrack",{name:$.name}),onClick:()=>_($.id),children:G(N5,{className:"h-2.5 w-2.5"})})}),G(W1,{children:j("multitrack.deleteTrack",{name:$.name})})]}):null]}),T(t1,{open:t!==null,onOpenChange:(E)=>{if(!E)h(null)},children:[t?G(_6,{asChild:!0,children:G("div",{className:"absolute h-px w-px",style:{left:t.x,top:t.y}})}):null,G(o1,{className:"w-auto p-0",align:"start",children:G(M5,{value:Y0,mediaType:"video",defaultTab:St($0?.content.source_type),slotItems:r,onChange:(E,m="input")=>{if(!t)return;A($.id,t.segmentId,E,m,wF(E,r)),h(null)}})})]})]})]})}function xS({track:$,totalLength:J,frameRate:Q,width:Z,canvasScale:q,selectedSegmentIds:X,onSelectSegment:Y,onAddSubtitleSegment:z,onDeleteSegment:K,onCloneSegment:W,onDeleteTrack:H,onTrackVisibilityChange:B=()=>{},onEditSubtitleSegment:U,onResizeSegment:_,onResizeSegmentPreview:L,onMoveSegment:F,onDragPreviewChange:V,getDragPreviewStart:M,onDragPreviewEnd:D}){let N=Z1(),O=$.segments.reduce((k,w)=>Math.max(k,w.end_frame),0),I=$.segments.length===0?6:O/Math.max(J,1)*Z+6,A=W2($.segments),b=$.visible!==!1;return T("div",{className:"relative flex h-[30px] border-b border-border","data-multitrack-track-id":$.id,children:[G("div",{className:"flex shrink-0 items-center justify-center border-r border-border",style:{width:q5},children:G(xQ,{track:$,children:G(h$,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),T("div",{className:"relative min-w-0 flex-1",children:[$.segments.map((k,w)=>G(G2,{trackType:"subtitle",segmentIndex:w,segment:k,totalLength:J,frameRate:Q,areaWidth:Z,canvasScale:q,selected:X.has(k.id),onSelect:Y,onDelete:K,onClone:W,onResize:_,onResizePreview:L,onMove:F,onDragPreviewChange:V,getDragPreviewStart:M,onDragPreviewEnd:D,dimmed:!b,onDoubleClick:()=>{Y(k.id),U(k.id)}},k.id)),A.map((k)=>G(H2,{gap:k,totalLength:J,width:Z,ariaLabel:N("multitrack.addSubtitleSegment"),onClick:()=>z($.id,k.startFrame,k.endFrame)},`${k.startFrame}-${k.endFrame}`)),T("div",{className:"absolute top-1/2 flex -translate-y-1/2 flex-row gap-1",style:{left:I},children:[T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"secondary",size:"icon",className:"h-5 w-5 cursor-pointer","aria-label":N("multitrack.addSubtitleSegment"),onClick:(k)=>{k.stopPropagation(),z($.id)},children:G(K5,{className:"h-2.5 w-2.5"})})}),G(W1,{children:N("multitrack.addSubtitleSegment")})]}),$.segments.length===0?T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer text-destructive","aria-label":N("multitrack.deleteTrack",{name:$.name}),onClick:()=>H($.id),children:G(N5,{className:"h-2.5 w-2.5"})})}),G(W1,{children:N("multitrack.deleteTrack",{name:$.name})})]}):null,T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:b?"ghost":"outline",size:"icon",className:`h-5 w-5 cursor-pointer ${b?"text-muted-foreground":"text-foreground"}`,"aria-label":b?N("multitrack.hideSubtitleTrack",{name:$.name}):N("multitrack.showSubtitleTrack",{name:$.name}),"aria-pressed":!b,onClick:(k)=>{k.stopPropagation(),B($.id,!b)},children:b?G(hS,{className:"h-2.5 w-2.5"}):G(E7,{className:"h-2.5 w-2.5"})})}),G(W1,{children:b?N("multitrack.hideSubtitleTrack",{name:$.name}):N("multitrack.showSubtitleTrack",{name:$.name})})]})]})]})]})}function ht({type:$}){return G($==="video"?q4:$==="audio"?$4:$==="subtitle"?h$:$==="task"?PW:uS,{className:"h-3.5 w-3.5 text-muted-foreground"})}function fS($,J){if($===J)return!0;if(!$||!J)return!1;return $.segmentId===J.segmentId&&$.targetTrackId===J.targetTrackId&&$.insertIndex===J.insertIndex&&$.start_frame===J.start_frame&&$.end_frame===J.end_frame}var xt=new Set(["mp3","wav","flac","ogg","m4a","aac","opus","wma"]),ft=new Set(["mp4","webm","mov","mkv","avi","m4v"]),vt=new Set(["png","jpg","jpeg","webp","gif","bmp","tif","tiff","avif"]);function pS($){let J=$.name.split(".").pop()?.toLowerCase()??"";if(J==="srt")return"subtitle";if($.type.startsWith("audio/"))return"audio";if($.type.startsWith("video/"))return"video";if($.type.startsWith("image/"))return"image";if(xt.has(J))return"audio";if(ft.has(J))return"video";if(vt.has(J))return"image";return null}function gt($){let J=lS($);if(J)return pS(J);for(let Q of Array.from($.items)){if(Q.kind!=="file")continue;if(Q.type==="application/x-subrip")return"subtitle";if(Q.type.startsWith("audio/"))return"audio";if(Q.type.startsWith("video/"))return"video";if(Q.type.startsWith("image/"))return"image"}return null}function vS($){return Array.from($.types).includes("Files")||$.files.length>0||Array.from($.items).some((J)=>J.kind==="file")}function lS($){let J=Array.from($.files)[0];if(J)return J;for(let Q of Array.from($.items)){if(Q.kind!=="file")continue;let Z=Q.getAsFile();if(Z)return Z}return null}function iS({data:$,node:J,app:Q,width:Z,currentTime:q,snapEnabled:X,canvasScale:Y,selectedSegmentIds:z,taskOverview:K=!1,onAddVideo:W,onAddAudio:H,onReplaceAudio:B,onAddTrack:U,onAddSubtitleSegment:_,onImportSubtitles:L=()=>{},onReplaceVideo:F,onAddTaskSegment:V,onSelectSegment:M,onSelectSegments:D,onClearSelection:N,onDeleteSegment:O,onDeleteTrack:I,onReorderTrack:A=()=>{},onTrackVisibilityChange:b=()=>{},onTrackAudioSettingsChange:k,onSharedReferenceChange:w=()=>{},onDistributeTaskSegments:C,onCloneTaskSegment:y,canMergeSelectedTaskSegments:f=!1,onMergeSelectedTaskSegments:j,onSplitTaskSegment:P=()=>{},onResizeSegment:x,onResizeSegmentPreview:p,onMoveSegment:t,onSmartSplit:h,onSmartSplitTasks:r,onRecognizeSubtitles:$0=()=>{},onEditSubtitleSegment:Y0=()=>{},cutMode:e,onCutSegment:H0,format:K0}){let E=Z1(),m=I6.useRef(null),c=I6.useRef(null),i=I6.useRef(null),u=I6.useRef(!1),d=I6.useRef(!1),o=I6.useRef(null),[S,s]=I6.useState(null),[G0,l]=I6.useState(null),[Q0,J0]=I6.useState(null),[B0,W0]=I6.useState(null),L0=Math.max($.total_length,1),_0=Math.max(1,Z-q5),D0=Math.max(1,_0-x2),c0=q5+q/L0*D0,g=q5+D0,a=24,I0=$.tracks.reduce((X0,O0)=>X0+vQ(O0.type,K),0),A0=I0+24,F0=$.tracks.find((X0)=>X0.type==="video")?.id,u0=$.tracks.filter((X0)=>X0.type==="video").length>=fQ,P0=$.tracks.filter((X0)=>X0.type==="audio").length>=fQ,n0=$.tracks.filter((X0)=>X0.type==="subtitle").length>=fQ,R0=$.tracks.reduce((X0,O0)=>{let x0=X0.at(-1)?.bottom??0;return X0.push({id:O0.id,top:x0,bottom:x0+vQ(O0.type,K)}),X0},[]);I6.useEffect(()=>{return()=>{o.current?.()}},[]);function Y1(X0){let O0=m.current?.getBoundingClientRect();if(!O0)return null;let x0=(X0-O0.top)/Math.max(Y,0.01);return R0.find((J1)=>x0>=J1.top&&x0<J1.bottom)?.id??null}function z1(X0,O0){let x0=m.current?.getBoundingClientRect();if(!x0)return null;let J1=Math.max(Y,0.01);return{x:(X0-x0.left)/J1,y:(O0-x0.top)/J1}}function a0(X0,O0){let x0=z1(X0,O0);if(!x0)return null;return{x:Math.max(0,Math.min(Z,x0.x)),y:Math.max(0,Math.min(A0,x0.y))}}function C1(X0,O0){return{left:Math.min(X0.x,O0.x),top:Math.min(X0.y,O0.y),width:Math.abs(O0.x-X0.x),height:Math.abs(O0.y-X0.y)}}function g1(X0,O0,x0){let J1=R0.find((N1)=>N1.id===X0);if(!J1)return!1;let u1=q5+O0.start_frame/L0*D0,S1=q5+O0.end_frame/L0*D0,Z0=J1.top+4,f0=J1.bottom-4,i0=x0.left+x0.width,M1=x0.top+x0.height;return u1<i0&&S1>x0.left&&Z0<M1&&f0>x0.top}function b1(X0){return $.tracks.flatMap((O0)=>O0.segments.filter((x0)=>g1(O0.id,x0,X0)).map((x0)=>x0.id))}function n(X0){if(X0.button!==0||e)return!1;let O0=X0.target;return!O0.closest("[data-multitrack-segment]")&&!O0.closest("button")&&!O0.closest('[role="button"]')&&!O0.closest("[data-radix-popper-content-wrapper]")}function N0(){o.current?.();let X0=null,O0=(J1)=>{J1.preventDefault(),J1.stopPropagation(),J1.stopImmediatePropagation(),x0()};function x0(){if(globalThis.removeEventListener("click",O0,!0),X0!==null)globalThis.clearTimeout(X0);if(o.current===x0)o.current=null}o.current=x0,globalThis.addEventListener("click",O0,!0),X0=globalThis.setTimeout(x0,0)}function w0(X0){if(!n(X0))return;let O0=z1(X0.clientX,X0.clientY);if(!O0||O0.y>A0)return;X0.preventDefault(),X0.stopPropagation(),c.current=O0,u.current=!1;function x0(u1){let S1=c.current,Z0=a0(u1.clientX,u1.clientY);if(!S1||!Z0)return;let f0=C1(S1,Z0);if(f0.width>3||f0.height>3)u.current=!0;W0(f0)}function J1(u1){let S1=c.current,Z0=a0(u1.clientX,u1.clientY);if(c.current=null,W0(null),globalThis.removeEventListener("mousemove",x0),globalThis.removeEventListener("mouseup",J1),!S1||!Z0)return;if(!u.current){N();return}d.current=!0,N0();let f0=b1(C1(S1,Z0));D(f0)}globalThis.addEventListener("mousemove",x0),globalThis.addEventListener("mouseup",J1)}function v0(X0,O0,x0){let J1=m.current?.getBoundingClientRect(),u1=Y1(O0),S1=$.tracks.find((O1)=>O1.id===u1),Z0=x0==="image"?S1?.type==="task":x0===S1?.type;if(!J1||!S1||!Z0)return null;let f0=(X0-J1.left)/Math.max(Y,0.01)-q5,i0=Math.round(Math.max(0,Math.min(D0,f0))/D0*L0),M1=[...S1.segments].sort((O1,A1)=>O1.start_frame-A1.start_frame),N1=M1.filter((O1)=>O1.start_frame+(O1.end_frame-O1.start_frame)/2<i0).length,_5=M1[N1-1]?.end_frame??0;return{trackId:S1.id,frame:x0==="subtitle"?i0:Math.max(i0,_5)}}function r0(X0){if(!vS(X0.dataTransfer))return;X0.preventDefault(),X0.stopPropagation(),X0.dataTransfer.dropEffect="copy";let O0=v0(X0.clientX,X0.clientY,gt(X0.dataTransfer));l(O0)}function K1(X0){if(!(X0 instanceof Element))return;let O0=X0.closest("[data-multitrack-track-id]");return $.tracks.find((x0)=>x0.id===O0?.dataset.multitrackTrackId)}function x1(X0){if(!(X0.target instanceof Element))return;let O0=X0.target.closest("[data-multitrack-track-drag-handle]"),x0=$.tracks.find((J1)=>J1.id===O0?.dataset.multitrackTrackDragHandle);if(!x0||x0.type==="task")return;i.current=x0.id,X0.dataTransfer.effectAllowed="move",X0.dataTransfer.setData("application/x-easy-media-track",x0.id)}function s1(X0){let O0=i.current,x0=K1(X0.target);if(!O0||!x0||x0.type==="task"||x0.id===O0)return;X0.preventDefault(),X0.stopPropagation(),X0.dataTransfer.dropEffect="move"}function z0(X0){let O0=i.current,x0=K1(X0.target);if(i.current=null,!O0||!x0||x0.type==="task"||x0.id===O0)return;X0.preventDefault(),X0.stopPropagation(),A(O0,x0.id)}async function C0(X0){if(!vS(X0.dataTransfer))return;X0.preventDefault(),X0.stopPropagation();let O0=lS(X0.dataTransfer),x0=O0?pS(O0):null,J1=v0(X0.clientX,X0.clientY,x0);if(l(null),!O0||!J1)return;J0({...J1,fileName:O0.name});try{if(x0==="subtitle"){L(J1.trackId,await O0.text(),J1.frame);return}if(x0==="image"){let S1=await y7(O0);C5("inputs"),V(J1.trackId,J1.frame,void 0,[S1]);return}let u1=await MZ(O0);if(C5("inputs"),x0==="video")W(J1.trackId,u1,"input",J1.frame);else H(J1.trackId,u1,"input",void 0,J1.frame)}catch(u1){console.error("[TrackArea] failed to process dropped media:",u1)}finally{J0(null)}}function h0(X0){let O0=R0.find((u1)=>u1.id===X0.targetTrackId);if(!O0)return null;let x0=q5+X0.start_frame/L0*D0,J1=q5+X0.end_frame/L0*D0;return{left:x0,top:O0.top+4,width:Math.max(2,J1-x0),height:Math.max(2,O0.bottom-O0.top-8)}}function l0(){return Math.max(1,Math.round(8/D0*L0))}function j0(X0,O0){return X?mS($,X0,O0,l0(),q):j8(O0,$.frame_rate)}function V1(X0,O0,x0){let J1=Y1(x0);if(!J1){s((S1)=>fS(S1,null)?S1:null);return}let u1=cS($.tracks,X0,J1,j0(X0,O0),$.frame_rate);s((S1)=>fS(S1,u1)?S1:u1)}function r1(X0,O0,x0,J1){let u1=Y1(J1);if(s(null),!u1)return;t(X0,u1??O0,j0(X0,x0))}let w1=S?h0(S):null,e1=S?dS($.tracks,S,$.frame_rate):null;function D5(X0){if(!S||X0.id===S.segmentId)return X0;return e1?.find((O0)=>O0.id===X0.id)??X0}return T("div",{ref:m,className:"relative shrink-0",style:{width:Z,height:A0},"data-multitrack-track-area":!0,onDragOverCapture:r0,onDragLeave:(X0)=>{let O0=X0.relatedTarget;if(!(O0 instanceof Node)||!X0.currentTarget.contains(O0))l(null)},onDropCapture:C0,onDragStart:x1,onDragOver:s1,onDrop:z0,onDragEnd:()=>{i.current=null},onMouseDown:w0,onClick:(X0)=>{if(X0.stopPropagation(),d.current){d.current=!1;return}let O0=X0.target;if(!O0.closest("[data-multitrack-segment]")&&!O0.closest("button")&&!O0.closest('[role="button"]'))N()},children:[G("div",{className:"pointer-events-none absolute top-0 z-10 bg-black/30",style:{left:g,width:x2,height:I0}}),G("div",{className:"absolute top-0 z-20 w-px bg-destructive",style:{left:c0,height:I0}}),$.tracks.map((X0)=>{if(X0.type==="video")return G(SS,{track:{...X0,segments:X0.segments.map((O0)=>D5(O0))},totalLength:$.total_length,frameRate:$.frame_rate,width:D0,canvasScale:Y,selectedSegmentIds:z,node:J,app:Q,onAddVideo:W,onReplaceVideo:F,onSelectSegment:M,onDeleteSegment:O,onCloneSegment:(O0)=>y(X0.id,O0),onSmartSplit:h,onSmartSplitTasks:r,onRecognizeSubtitles:$0,cutMode:e,onCutSegment:H0,canDeleteTrack:X0.id!==F0,onDeleteTrack:I,onTrackAudioSettingsChange:k,onSharedReferenceChange:w,onResizeSegment:x,onResizeSegmentPreview:p,onMoveSegment:(O0,x0,J1)=>{r1(O0,X0.id,x0,J1)},onDragPreviewChange:V1,getDragPreviewStart:j0,onDragPreviewEnd:()=>s(null),audioLockEnabled:r4(K0)},X0.id);if(X0.type==="audio")return G(CS,{track:{...X0,segments:X0.segments.map((O0)=>D5(O0))},totalLength:$.total_length,frameRate:$.frame_rate,width:D0,canvasScale:Y,selectedSegmentIds:z,node:J,app:Q,onAddAudio:H,onReplaceAudio:B,onSelectSegment:M,onDeleteSegment:O,onCloneSegment:(O0)=>y(X0.id,O0),onDeleteTrack:I,onTrackAudioSettingsChange:k,onSharedReferenceChange:w,onResizeSegment:x,onResizeSegmentPreview:p,onMoveSegment:(O0,x0,J1)=>r1(O0,X0.id,x0,J1),onDragPreviewChange:V1,getDragPreviewStart:j0,onDragPreviewEnd:()=>s(null),onRecognizeSubtitles:$0,cutMode:e,onCutSegment:H0,audioLockEnabled:r4(K0)},X0.id);if(X0.type==="subtitle")return G(xS,{track:{...X0,segments:X0.segments.map((O0)=>D5(O0))},totalLength:$.total_length,frameRate:$.frame_rate,width:D0,canvasScale:Y,selectedSegmentIds:z,onSelectSegment:M,onAddSubtitleSegment:_,onDeleteSegment:O,onCloneSegment:(O0)=>y(X0.id,O0),onDeleteTrack:I,onTrackVisibilityChange:b,onEditSubtitleSegment:Y0,onResizeSegment:x,onResizeSegmentPreview:p,onMoveSegment:(O0,x0,J1)=>r1(O0,X0.id,x0,J1),onDragPreviewChange:V1,getDragPreviewStart:j0,onDragPreviewEnd:()=>s(null)},X0.id);return T("div",{"data-testid":`track-row-${X0.id}`,"data-multitrack-track-id":X0.id,className:"relative flex border-b border-border",style:{height:vQ(X0.type,K)},children:[G("div",{className:"flex shrink-0 items-center justify-center border-r border-border",style:{width:q5},children:G(ht,{type:X0.type})}),T("div",{className:"relative min-w-0 flex-1",children:[X0.segments.map((O0,x0)=>G(G2,{trackType:X0.type,segmentIndex:x0,segment:D5(O0),totalLength:$.total_length,frameRate:$.frame_rate,areaWidth:D0,canvasScale:Y,selected:z.has(O0.id),showTaskIndex:($.task_markers??[]).length===0,taskOverview:X0.type==="task"&&K,onSelect:M,onDelete:O,onDistribute:X0.type==="task"?()=>C(X0.id):void 0,onClone:X0.type==="task"?(J1)=>y(X0.id,J1):void 0,onMerge:X0.type==="task"&&z.has(O0.id)&&f?j:void 0,onSplitTask:X0.type==="task"?P:void 0,cutMode:e,onCut:H0,onResize:x,onResizePreview:p,onMove:(J1,u1,S1)=>{r1(J1,X0.id,u1,S1)},onDragPreviewChange:V1,getDragPreviewStart:j0,onDragPreviewEnd:()=>s(null)},O0.id)),X0.type==="task"?T(G1,{children:[W2(X0.segments).map((O0)=>G(H2,{gap:O0,totalLength:$.total_length,width:D0,ariaLabel:E("multitrack.addTaskSegment"),onClick:()=>V(X0.id,O0.startFrame,O0.endFrame)},`${O0.startFrame}-${O0.endFrame}`)),G(k0,{type:"button",variant:"secondary",size:"icon",className:"absolute top-1/2 h-5 w-5 cursor-pointer",style:{left:X0.segments.length===0?6:X0.segments.reduce((O0,x0)=>Math.max(O0,x0.end_frame),0)/L0*D0+6,transform:"translateY(-50%)"},"aria-label":E("multitrack.addTaskSegment"),onClick:(O0)=>{O0.stopPropagation(),V(X0.id)},children:G(K5,{className:"h-2.5 w-2.5"})})]}):T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"absolute top-1/2 h-5 w-5 -translate-y-1/2 cursor-pointer text-destructive",style:{left:X0.segments.length===0?6:X0.segments.reduce((O0,x0)=>Math.max(O0,x0.end_frame),0)/L0*D0+6},"aria-label":E("multitrack.deleteTrack",{name:X0.name}),onClick:()=>I(X0.id),children:G(N5,{className:"h-2.5 w-2.5"})})}),G(W1,{children:E("multitrack.deleteTrack",{name:X0.name})})]})]})]},X0.id)}),T("div",{className:"flex items-center justify-center gap-1 border-b border-border text-[10px] text-muted-foreground",style:{height:24},children:[G("span",{children:E("multitrack.addTrack")}),T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer disabled:cursor-not-allowed",disabled:u0,"aria-label":E("multitrack.addVideoTrack"),onClick:()=>U("video"),children:G(gS,{className:"h-3.5 w-3.5"})})}),G(W1,{children:E("multitrack.addVideoTrack")})]}),T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer disabled:cursor-not-allowed",disabled:P0,"aria-label":E("multitrack.addAudioTrack"),onClick:()=>U("audio"),children:G(wJ,{className:"h-3.5 w-3.5"})})}),G(W1,{children:E("multitrack.addAudioTrack")})]}),T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer disabled:cursor-not-allowed",disabled:n0,"aria-label":E("multitrack.addSubtitleTrack"),onClick:()=>U("subtitle"),children:G(h$,{className:"h-3.5 w-3.5"})})}),G(W1,{children:E("multitrack.addSubtitleTrack")})]})]}),w1?G("div",{className:"pointer-events-none absolute z-10 rounded border border-border bg-muted/60",style:w1}):null,B0?G("div",{className:"pointer-events-none absolute z-40 rounded border border-primary bg-primary/10",style:B0}):null,G0?(()=>{let X0=R0.find((O0)=>O0.id===G0.trackId);if(!X0)return null;return G("div",{"data-testid":"external-media-drop-slot",className:"pointer-events-none absolute z-30 w-1 rounded bg-primary",style:{left:q5+G0.frame/L0*D0,top:X0.top+4,height:X0.bottom-X0.top-8}})})():null,Q0?(()=>{let X0=R0.find((O0)=>O0.id===Q0.trackId);if(!X0)return null;return T("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute z-40 flex max-w-48 items-center gap-1.5 rounded border border-border bg-background/95 px-2 py-1 text-[10px] text-foreground shadow-sm",style:{left:q5+Q0.frame/L0*D0,top:X0.top+(X0.bottom-X0.top)/2,transform:"translate(-50%, -50%)"},children:[G(X6,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}),G("span",{className:"truncate",children:E("multitrack.externalMediaUploading",{name:Q0.fileName})})]})})():null]})}function ut($){if($&&typeof $==="object"&&!Array.isArray($)){if(Array.isArray($.tracks))return EF($)}return Lh()}function hW($,J){let Q=[...$].sort((B,U)=>B.start_frame-U.start_frame),Z=Q.filter((B)=>B.start_frame+(B.end_frame-B.start_frame)/2<J.start_frame).length,q=Q.slice(0,Z),X=q.at(-1)?.end_frame??0,Y=J.end_frame-J.start_frame,z=Math.max(J.start_frame,X),K={...J,start_frame:z,end_frame:z+Y},W=K.end_frame,H=Q.slice(Z).map((B)=>{let U=B.end_frame-B.start_frame,_=Math.max(B.start_frame,W);return W=_+U,{...B,start_frame:_,end_frame:W}});return[...q,K,...H]}function rS($){let J=$.task_overview===!0;return $.tracks.reduce((Q,Z)=>Q+vQ(Z.type,J),0)}function mt({value:$,onChange:J,app:Q,node:Z}){let q=ut($),X=JSON.stringify(q),[Y,z]=i1.useState(null),K=Y??q,W=K.task_overview===!0,H=i1.useRef(q);H.current=q;let[B,U]=i1.useState(0),[_,L]=i1.useState(!1),[F,V]=i1.useState(1),[M,D]=i1.useState(!0),[N,O]=i1.useState(!1),[I,A]=i1.useState(null),[b,k]=i1.useState(null),[w,C]=i1.useState(()=>new Set),[y,f]=i1.useState(null),[j,P]=i1.useState(null),[x,p]=i1.useState(!1),[t,h]=i1.useState(!1),[r,$0]=i1.useState(0),[Y0,e]=i1.useState(null),[H0,K0]=i1.useState(!1),[E,m]=i1.useState(null),c=i1.useRef(null),i=i1.useRef(null),u=i1.useRef(0),d=i1.useRef(0),o=i1.useRef(0),s=Math.max(1,kJ(i))*F,G0=t9(Q),l=aY(Z),Q0=w.size<=1?jF(K,b):null,J0=w.size>1?K.tracks.flatMap((q0)=>q0.type==="task"?q0.segments.filter((V0)=>w.has(V0.id)):[]):[],B0=J0.length===w.size&&J0.length>1,W0=bF(K.tracks,w)!==null,L0=Q0??(B0?jF(K,b):null),_0=L0?.trackType==="task"?K.tracks.find((q0)=>q0.id===L0.trackId&&q0.type==="task")?.segments??[L0.segment]:void 0,D0=j?K.tracks.find((q0)=>q0.type==="task"&&q0.segments.some((V0)=>V0.id===j))?.segments.find((q0)=>q0.id===j)??null:null,c0=i1.useCallback((q0)=>{let V0=rS(q0)-rS(H.current);sS(Z,V0),H.current=q0,J(q0)},[Z,J]),{canUndo:g,canRedo:a,commitChange:I0,undo:A0,redo:F0}=GI(q,c0),u0=Q?.ui?.settings?.settingsValues?.["Comfy.Locale"],P0=(q0,V0)=>fW(u0,q0,V0),n0=Y0?.directory.split(/[\\/]/).filter(Boolean).at(-1)??"";function R0(q0){I0(EF(q0))}function Y1(q0){k(q0),C(q0?new Set([q0]):new Set)}function z1(q0){let V0=j8(q0,K.frame_rate);o.current=V0,U(V0)}function a0(q0,V0="replace"){let U0=K.tracks.find((M0)=>M0.type==="task"&&M0.segments.some((S0)=>S0.id===q0))?.segments.find((M0)=>M0.id===q0);if(U0&&(o.current<U0.start_frame||o.current>=U0.end_frame))z1(U0.start_frame);A(null),C((M0)=>{if(V0==="replace")return k(q0),new Set([q0]);let S0=new Set(M0);if(V0==="toggle"&&S0.has(q0))return S0.delete(q0),k((E0)=>E0===q0?S0.values().next().value??null:E0),S0;return S0.add(q0),k(q0),S0})}function C1(q0){A(null);let V0=new Set(q0);C(V0),k(q0.at(-1)??null)}function g1(){Y1(null),A(null)}i1.useEffect(()=>{z(null);let q0=new Set(q.tracks.flatMap((V0)=>V0.segments.map((U0)=>U0.id)));C((V0)=>{let U0=new Set([...V0].filter((M0)=>q0.has(M0)));return k((M0)=>M0&&!q0.has(M0)?U0.values().next().value??null:M0),U0}),A((V0)=>V0&&q.task_markers?.some((U0)=>U0.id===V0)?V0:null)},[X]);function b1(){let q0=j8(B,K.frame_rate);return q0>0&&q0<=K.total_length&&!(K.task_markers??[]).some((V0)=>V0.frame===q0)}function n(){let q0=j8(B,K.frame_rate);if(!b1())return;let V0={id:f1(),frame:q0};R0({...K,task_markers:[...K.task_markers??[],V0]}),Y1(null),A(V0.id)}function N0(q0){if(!(K.task_markers??[]).some((V0)=>V0.id===q0))return;R0({...K,task_markers:(K.task_markers??[]).filter((V0)=>V0.id!==q0)}),A((V0)=>V0===q0?null:V0)}function w0(q0,V0){let U0=j8(V0,K.frame_rate),M0=K.task_markers??[],S0=M0.find((E0)=>E0.id===q0);if(!S0||S0.frame===U0)return;if(U0<=0||U0>K.total_length)return;if(M0.some((E0)=>E0.id!==q0&&E0.frame===U0))return;R0({...K,task_markers:M0.map((E0)=>E0.id===q0?{...E0,frame:U0}:E0)})}function v0(q0){R0({...q,task_overview:q0})}i1.useEffect(()=>{o.current=B},[B]),i1.useEffect(()=>{if(!b||w.size!==1)return;let q0=K.tracks.find((M0)=>M0.type==="task"&&M0.segments.some((S0)=>S0.id===b)),V0=q0?.segments.find((M0)=>M0.id===b);if(!q0||!V0)return;if(B>=V0.start_frame&&B<V0.end_frame)return;let U0=q0.segments.find((M0)=>B>=M0.start_frame&&B<M0.end_frame);if(!U0||U0.id===b)return;Y1(U0.id)},[B,K.tracks,b,w]),i1.useEffect(()=>{let q0=Z;return q0.__easyMediaSyncPlay=()=>{if(c.current!==null)cancelAnimationFrame(c.current);c.current=null,o.current=0,d.current=0,u.current=performance.now(),U(0),L(!0),$0((V0)=>V0+1)},()=>{if(q0.__easyMediaSyncPlay)delete q0.__easyMediaSyncPlay}},[Z]),i1.useEffect(()=>{let q0=Q.api;if(!q0?.addCustomEventListener||!q0.removeCustomEventListener)return;let V0=(U0)=>{let M0=tY(U0.detail);if(!M0)return;e(M0),m(null),K0(!1)};return q0.addCustomEventListener(TB,V0),()=>q0.removeCustomEventListener?.(TB,V0)},[Q]),i1.useEffect(()=>{if(!_){if(c.current!==null)cancelAnimationFrame(c.current);c.current=null;return}u.current=performance.now(),d.current=o.current;function q0(V0){let U0=(V0-u.current)/1000,M0=j8(d.current+C9(U0,K.frame_rate),K.frame_rate);if(M0>=K.total_length){o.current=0,d.current=0,u.current=V0,U(0),$0((S0)=>S0+1),c.current=requestAnimationFrame(q0);return}o.current=M0,U(M0),c.current=requestAnimationFrame(q0)}return c.current=requestAnimationFrame(q0),()=>{if(c.current!==null)cancelAnimationFrame(c.current)}},[_,r,K.frame_rate,K.total_length]);async function r0(q0,V0,U0,M0,S0,E0){let t0=IF(V0,U0);if(E0)t0.url=E0;let Q1=Z5(t0),l1;if(Q1)try{let c5=await EZ(Q1);if(Number.isFinite(c5.duration)&&c5.duration>0)l1=c5.duration}catch(c5){console.error("[MultiTrackWidget] failed to read video metadata:",c5)}let y1=H.current,$5={added:!1,startFrame:0,endFrame:0},m1=y1.tracks.map((c5)=>{if(c5.id!==q0)return c5;let G7=M0===void 0?j8(c5.segments.reduce((p9,gQ)=>Math.max(p9,gQ.end_frame),0),y1.frame_rate):Math.max(0,Math.round(M0)),_X=S0===void 0?G7+Math.max(1,xW(l1??kF,y1.frame_rate)):Math.max(G7+1,Math.round(S0));return $5.added=!0,$5.startFrame=G7,$5.endFrame=_X,{...c5,segments:(()=>{let p9={id:f1(),start_frame:G7,end_frame:_X,color:c5.color,content:{...t0,...l1===void 0?{}:{duration:l1}}};if(M0===void 0)return[...c5.segments,p9];return hW(c5.segments,p9)})()}}),b6=M0===void 0?m1:$h(y1.tracks,m1),U2=$5.added?Jh(b6,$5.startFrame,$5.endFrame):b6;R0({...y1,tracks:U2,total_length:_8(U2,y1.frame_rate)})}async function K1(q0,V0,U0,M0,S0,E0){let t0=TF(V0,U0);if(M0)t0.url=M0;let Q1=Z5(t0),l1;if(Q1)try{l1=(await PB(Q1)).duration}catch(m1){console.error("[MultiTrackWidget] failed to read audio metadata:",m1)}let y1=H.current,$5=y1.tracks.map((m1)=>{if(m1.id!==q0||m1.type!=="audio")return m1;let b6=S0===void 0?m1.segments.reduce((c5,G7)=>Math.max(c5,G7.end_frame),0):Math.max(0,Math.round(S0)),U2=E0===void 0?b6+Math.max(1,xW(l1??kF,y1.frame_rate)):Math.max(b6+1,Math.round(E0));return{...m1,segments:(()=>{let c5={id:f1(),start_frame:b6,end_frame:U2,color:m1.color,content:{...t0,...l1===void 0?{}:{duration:l1}}};if(S0===void 0)return[...m1.segments,c5];return hW(m1.segments,c5)})()}});R0({...y1,tracks:$5,total_length:_8($5,y1.frame_rate)})}async function x1(q0,V0,U0,M0,S0){let E0=TF(U0,M0);if(S0)E0.url=S0;let t0=Z5(E0),Q1=null;if(t0)try{Q1=(await PB(t0)).duration}catch($5){console.error("[MultiTrackWidget] failed to read replacement audio metadata:",$5)}let l1=H.current,y1=l1.tracks.map(($5)=>{if($5.id!==q0||$5.type!=="audio")return $5;return{...$5,segments:$5.segments.map((m1)=>{if(m1.id!==V0)return m1;return{...m1,end_frame:Q1===null?m1.end_frame:nS(m1,Q1,l1.frame_rate),origin_start_frame:m1.start_frame,content:{...E0,...Q1===null?{}:{duration:Q1},muted:m1.content.muted??E0.muted,volume_db:m1.content.volume_db??E0.volume_db,shared_reference:m1.content.shared_reference===!0}}})}});R0({...l1,tracks:y1,total_length:_8(y1,l1.frame_rate)})}function s1(q0){if(q0!=="video"&&q0!=="audio"&&q0!=="subtitle")return;let V0=K.tracks.filter((S0)=>S0.type===q0).length;if(V0>=fQ)return;let U0=q0==="video"||q0==="audio",M0={id:f1(),name:`${q0==="video"?"Video":q0==="audio"?"Audio":"Subtitle"} ${V0}`,type:q0,color:q0==="subtitle"?C2:bZ[q0],muted:!1,solo:U0?!1:void 0,volume_db:U0?S2:void 0,locked:!1,segments:[]};R0({...K,tracks:[...K.tracks,M0]})}function z0(q0){let V0=K.tracks.find((E0)=>E0.id===q0),U0=K.tracks.find((E0)=>E0.type==="video")?.id;if(!V0||V0.type==="task"||V0.id===U0)return;let M0=new Set(V0.segments.map((E0)=>E0.id)),S0=K.tracks.filter((E0)=>E0.id!==q0);R0({...K,tracks:S0,total_length:_8(S0,K.frame_rate)}),C((E0)=>{let t0=new Set([...E0].filter((Q1)=>!M0.has(Q1)));return k((Q1)=>Q1&&M0.has(Q1)?t0.values().next().value??null:Q1),t0})}function C0(q0,V0){let U0=K.tracks.findIndex((Q1)=>Q1.id===q0),M0=K.tracks.findIndex((Q1)=>Q1.id===V0),S0=K.tracks[U0],E0=K.tracks[M0];if(U0<0||M0<0||U0===M0||S0?.type==="task"||E0?.type==="task")return;let t0=[...K.tracks];t0[U0]=E0,t0[M0]=S0,R0({...K,tracks:t0})}function h0(q0,V0){if("audio_locked"in V0){R0(_h(K,q0,V0.audio_locked===!0));return}if("solo"in V0){let U0=K.tracks.find((E0)=>E0.id===q0);if(!U0||U0.type!=="video"&&U0.type!=="audio")return;let M0=V0.solo===!0,S0=K.tracks.map((E0)=>{if(E0.type!=="video"&&E0.type!=="audio")return E0;if(E0.id===q0)return{...E0,...V0,solo:M0,muted:M0?!1:E0.muted};return{...E0,solo:!1,muted:M0?!0:!1}});R0({...K,tracks:S0});return}R0({...K,tracks:K.tracks.map((U0)=>U0.id===q0?{...U0,...V0}:U0)})}function l0(q0,V0){R0({...K,tracks:K.tracks.map((U0)=>U0.id===q0&&U0.type==="subtitle"?{...U0,visible:V0}:U0)})}function j0(q0,V0,U0){R0({...K,tracks:K.tracks.map((M0)=>{if(M0.id!==q0||M0.type!=="audio"&&M0.type!=="video")return M0;return{...M0,segments:M0.segments.map((S0)=>({...S0,content:{...S0.content,shared_reference:U0&&S0.id===V0,speaker_reference:void 0}}))}})})}async function V1(q0,V0,U0,M0,S0){let E0=IF(U0,M0);if(S0)E0.url=S0;let t0=Z5(E0),Q1;if(t0)try{let y1=await EZ(t0);if(Number.isFinite(y1.duration)&&y1.duration>0)Q1=y1.duration}catch(y1){console.error("[MultiTrackWidget] failed to read replacement video metadata:",y1)}let l1=K.tracks.map((y1)=>{if(y1.id!==q0)return y1;return{...y1,segments:y1.segments.map(($5)=>$5.id===V0?{...$5,content:{...E0,...Q1===void 0?{}:{duration:Q1},shared_reference:$5.content.shared_reference===!0}}:$5)}});R0({...K,tracks:l1,total_length:_8(l1,K.frame_rate)})}function r1(q0,V0,U0,M0){let S0=K.tracks.map((E0)=>{if(E0.id!==q0||E0.type!=="task")return E0;let t0=V0===void 0?j8(E0.segments.reduce((y1,$5)=>Math.max(y1,$5.end_frame),0),K.frame_rate):Math.max(0,Math.round(V0)),Q1=U0===void 0?t0+Math.max(1,C9(5,K.frame_rate)):Math.max(t0+1,Math.round(U0)),l1={id:f1(),start_frame:t0,end_frame:Q1,color:E0.color,content:{media_type:"none",...eS(E0.segments,t0,E0.task_mode??"default"),images:M0??[]}};return{...E0,segments:V0===void 0?[...E0.segments,l1]:hW(E0.segments,l1)}});R0({...K,tracks:S0,total_length:_8(S0,K.frame_rate)})}function w1(q0,V0,U0){let M0=K.tracks.map((S0)=>{if(S0.id!==q0||S0.type!=="subtitle")return S0;let E0=V0===void 0?j8(S0.segments.reduce((y1,$5)=>Math.max(y1,$5.end_frame),0),K.frame_rate):Math.max(0,Math.round(V0)),t0=U0===void 0?E0+Math.max(1,C9(5,K.frame_rate)):Math.max(E0+1,Math.round(U0)),Q1=S0.segments.find((y1)=>y1.content.subtitle_style)?.content.subtitle_style,l1={id:f1(),start_frame:E0,end_frame:t0,color:S0.color||C2,content:{media_type:"subtitle",text:"默认文字",subtitle_style:{...Q1??h2}}};return{...S0,segments:V0===void 0?[...S0.segments,l1]:hW(S0.segments,l1)}});R0({...K,tracks:M0,total_length:_8(M0,K.frame_rate)})}function e1(q0,V0,U0){let M0=H.current,S0=M0.tracks.map((E0)=>{if(E0.id!==q0||E0.type!=="subtitle")return E0;let t0=E0.segments.find((m1)=>m1.content.subtitle_style)?.content.subtitle_style,Q1=NI(V0,{color:E0.color||C2,createId:()=>f1(),frameRate:M0.frame_rate,startFrame:Math.max(0,Math.round(U0)),subtitleStyle:t0??h2}),l1=Q1.reduce((m1,b6)=>Math.min(m1,b6.start_frame),Q1[0].start_frame),y1=Q1.reduce((m1,b6)=>Math.max(m1,b6.end_frame),Q1[0].end_frame),$5=E0.segments.filter((m1)=>m1.end_frame<=l1||m1.start_frame>=y1);return{...E0,segments:[...$5,...Q1].sort((m1,b6)=>m1.start_frame-b6.start_frame)}});R0({...M0,tracks:S0,total_length:_8(S0,M0.frame_rate)})}function D5(q0){let V0=w.has(q0)?w:new Set([q0]),U0=V0.size>1?Yh(K.tracks,V0,K.frame_rate):Xh(K.tracks,q0,K.frame_rate),M0=_8(U0,K.frame_rate);R0({...K,tracks:U0,total_length:M0}),g1(),U((S0)=>Math.min(S0,M0))}function X0(q0){let V0=K.tracks.map((U0)=>U0.id===q0&&U0.type==="task"?{...U0,segments:Qh(U0.segments,K.total_length)}:U0);R0({...K,tracks:V0})}function O0(q0,V0){let U0=null,M0=0,S0=K.tracks.map((E0)=>{if(E0.id!==q0)return E0;let t0=qh(E0.segments,V0);if(!t0)return E0;return U0=t0.clonedSegmentId,M0=t0.segments.reduce((Q1,l1)=>Math.max(Q1,l1.end_frame),0),{...E0,segments:t0.segments}});if(!U0)return;R0({...K,tracks:S0,total_length:Math.max(K.total_length,M0)}),Y1(U0)}function x0(){let q0=bF(K.tracks,w);if(!q0)return;R0({...K,tracks:q0.tracks,total_length:_8(q0.tracks,K.frame_rate)}),Y1(q0.mergedSegmentId)}function J1(q0,V0){let U0=[],M0=K.tracks.map((S0)=>{if(S0.type!=="task"||!S0.segments.some((t0)=>t0.id===q0))return S0;let E0=Zh(S0.segments,q0,V0);if(!E0)return S0;return U0=E0.splitSegmentIds,{...S0,segments:E0.segments}});if(U0.length===0)return;R0({...K,tracks:M0,total_length:_8(M0,K.frame_rate)}),C(new Set(U0)),k(U0[0]??null)}function u1(q0,V0,U0,M0){let S0=q0.tracks.map((t0)=>{if(t0.type==="task"&&U0==="end"&&t0.segments.some((Q1)=>Q1.id===V0))return{...t0,segments:Hh(t0.segments,V0,j8(M0,q0.frame_rate))};return{...t0,segments:t0.segments.map((Q1)=>{if(Q1.id!==V0)return Q1;let l1=[...t0.segments].sort((p9,gQ)=>p9.start_frame-gQ.start_frame),y1=l1.findIndex((p9)=>p9.id===V0),$5=y1>0?l1[y1-1]:null,m1=y1>=0&&y1<l1.length-1?l1[y1+1]:null,U2=(Q1.content.source_type!=="slot"||Boolean(Q1.content.url))&&Q1.content.duration&&Q1.content.duration>0?Math.max(1,xW(Q1.content.duration,q0.frame_rate)):Number.POSITIVE_INFINITY;if(U0==="start"){let p9=j8(M0,q0.frame_rate),gQ=Math.max(0,$5?.end_frame??0,Q1.end_frame-U2),ph=Q1.end_frame-1,cF=Math.max(gQ,Math.min(p9,ph));return{...Q1,start_frame:cF,...cF!==Q1.start_frame&&(t0.type==="video"||t0.type==="audio")?{origin_start_frame:Q1.origin_start_frame??Q1.start_frame}:{}}}let c5=j8(M0,q0.frame_rate),G7=Q1.start_frame+1,_X=Math.min(m1?.start_frame??Number.POSITIVE_INFINITY,Q1.start_frame+U2);return{...Q1,end_frame:Math.max(G7,Math.min(c5,_X))}}).sort((Q1,l1)=>Q1.start_frame-l1.start_frame)}}),E0=Wh(q0.tracks,S0,V0);return{...q0,tracks:E0,total_length:_8(E0,q0.frame_rate)}}function S1(q0,V0,U0,M0){return M?aS(q,q0,V0,U0,M0,o.current):j8(U0,q.frame_rate)}function Z0(q0,V0,U0,M0=0){z(u1(q,q0,V0,S1(q0,V0,U0,M0)))}function f0(q0,V0,U0,M0=0){z(null),R0(u1(q,q0,V0,S1(q0,V0,U0,M0)))}function i0(q0,V0,U0){let M0=w.has(q0)?Kh(K.tracks,w,q0,V0,U0,K.frame_rate):zh(K.tracks,q0,V0,U0,K.frame_rate);R0({...K,tracks:M0,total_length:_8(M0,K.frame_rate)})}function M1(q0){let V0=q0.frame_rate;if(typeof V0==="number"&&V0>0&&V0!==K.frame_rate){let U0=Uh(K,V0),M0=tS(o.current,K.frame_rate,U0.frame_rate);o.current=M0,U(M0),R0({...U0,...q0,frame_rate:U0.frame_rate});return}R0({...K,...q0,frame_rate:K.frame_rate})}function N1(q0){if(!b)return;if(Q0?.trackType==="subtitle"&&q0.subtitle_style){let{subtitle_style:V0,...U0}=q0,M0=Object.keys(U0).length>0,S0=K.tracks.map((E0)=>{if(E0.id!==Q0.trackId||E0.type!=="subtitle")return E0;return{...E0,segments:E0.segments.map((t0)=>({...t0,content:{...t0.content,...M0&&t0.id===b?U0:{},subtitle_style:V0}}))}});R0({...K,tracks:S0});return}R0(Gh(K,b,q0))}function _5(q0){let V0=new Map(q0.map((M0)=>[M0.segmentId,M0.patch])),U0=K.tracks.map((M0)=>({...M0,segments:M0.segments.map((S0)=>{let E0=V0.get(S0.id);if(!E0)return S0;return{...S0,content:{...S0.content,...E0}}})}));R0({...K,tracks:U0})}function O1(q0){if(Q0?.trackType!=="task")return;let V0=K.tracks.map((U0)=>U0.id===Q0.trackId?{...U0,segments:q0}:U0);R0({...K,tracks:V0,total_length:_8(V0,K.frame_rate)})}function A1(q0){if(!b)return;R0(Bh(K,b,q0,K.frame_rate))}async function T6(q0){let V0=K.tracks.find((U0)=>U0.type==="video"&&U0.segments.some((M0)=>M0.id===q0))?.segments.find((U0)=>U0.id===q0);if(!V0||x)return;L(!1),p(!0);try{let U0=await bB(V0,K.frame_rate);R0(UI(K,q0,U0))}catch(U0){if(U0 instanceof R2){e(U0.model),m(null);return}console.error("[MultiTrackWidget] smart split failed:",U0);let M0=U0 instanceof Error?U0.message:String(U0);try{Q.extensionManager.toast.add({severity:"error",summary:P0("multitrack.smartSplitFailed"),detail:M0,life:5000})}catch(S0){console.error("[MultiTrackWidget] failed to show smart split error:",S0)}}finally{p(!1)}}async function u6(q0){let V0=K.tracks.find((U0)=>U0.type==="video"&&U0.segments.some((M0)=>M0.id===q0))?.segments.find((U0)=>U0.id===q0);if(!V0||x)return;if(!BI(K,q0)){try{Q.extensionManager.toast.add({severity:"warn",summary:P0("multitrack.smartSplitTasksOnly"),detail:P0("multitrack.noMatchingTaskSegment"),life:4000})}catch(U0){console.error("[MultiTrackWidget] failed to show task split warning:",U0)}return}L(!1),p(!0);try{let U0=await bB(V0,K.frame_rate);R0(_I(K,q0,U0))}catch(U0){if(U0 instanceof R2){e(U0.model),m(null);return}console.error("[MultiTrackWidget] task-only smart split failed:",U0);let M0=U0 instanceof Error?U0.message:String(U0);try{Q.extensionManager.toast.add({severity:"error",summary:P0("multitrack.smartSplitFailed"),detail:M0,life:5000})}catch(S0){console.error("[MultiTrackWidget] failed to show smart split error:",S0)}}finally{p(!1)}}async function Y6(q0,V0){let U0=K.tracks.find((M0)=>(M0.type==="video"||M0.type==="audio")&&M0.segments.some((S0)=>S0.id===q0))?.segments.find((M0)=>M0.id===q0);if(!U0||t)return;L(!1),h(!0);try{let M0=await LI(U0,K.frame_rate,V0);R0(FI(K,q0,M0))}catch(M0){if(M0 instanceof R2){e(M0.model),m(null);return}console.error("[MultiTrackWidget] subtitle recognition failed:",M0);let S0=M0 instanceof Error?M0.message:String(M0);try{Q.extensionManager?.toast?.add({severity:"error",summary:P0("multitrack.subtitleRecognitionFailed"),detail:S0,life:5000})}catch(E0){console.error("[MultiTrackWidget] failed to show subtitle recognition error:",E0)}}finally{h(!1)}}async function rW(q0,V0){if(q0.content.media_type!=="subtitle")return;L(!1);try{let U0=await VI({...V0,text:q0.content.text??""});C5("outputs");let M0=H.current;R0(MI(M0,{subtitleSegmentId:q0.id,startFrame:q0.start_frame,endFrame:q0.end_frame,filePath:U0.filePath,duration:U0.duration}));try{Q.extensionManager?.toast?.add({severity:"success",summary:P0("multitrack.subtitleSpeechComplete"),detail:U0.message||P0("multitrack.subtitleSpeechSaved",{path:U0.absolutePath||U0.filePath}),life:5000})}catch(S0){console.error("[MultiTrackWidget] failed to show subtitle speech success:",S0)}}catch(U0){if(U0 instanceof R2){e(U0.model),m(null);return}console.error("[MultiTrackWidget] subtitle speech generation failed:",U0);let M0=U0 instanceof Error?U0.message:String(U0);try{Q.extensionManager?.toast?.add({severity:"error",summary:P0("multitrack.subtitleSpeechFailed"),detail:M0,life:5000})}catch(S0){console.error("[MultiTrackWidget] failed to show subtitle speech error:",S0)}}}function uh(q0,V0){R0(EB(K,q0,V0))}function mh(){let q0=j8(B,K.frame_rate),V0=w.size>0?Array.from(w):K.tracks.flatMap((E0)=>E0.segments.filter((t0)=>q0>t0.start_frame&&q0<t0.end_frame).map((t0)=>t0.id));if(V0.length===0)return;let U0=K.tracks.reduce((E0,t0)=>E0+t0.segments.length,0),M0=V0.reduce((E0,t0)=>EB(E0,t0,q0),K);if(M0.tracks.reduce((E0,t0)=>E0+t0.segments.length,0)===U0)return;R0(M0)}function uF(q0){let V0=w.size>0?w:new Set(K.tracks.flatMap((U0)=>U0.segments.map((M0)=>M0.id)));return K.tracks.flatMap((U0)=>U0.segments.filter((M0)=>V0.has(M0.id)&&q0>M0.start_frame&&q0<M0.end_frame).map((M0)=>M0.id))}function sW(){let q0=j8(B,K.frame_rate);return uF(q0).length>0}function mF(q0){let V0=j8(B,K.frame_rate),U0=uF(V0);if(U0.length===0)return;let M0=U0.reduce((S0,E0)=>u1(S0,E0,q0,V0),K);R0(M0)}async function ch(){if(!Y0||H0)return;K0(!0),m(null);try{let q0=await WI(Y0.name);e(null);try{Q.extensionManager?.toast?.add({severity:"success",summary:P0("modelDownload.downloadComplete"),detail:P0("modelDownload.downloadCompleteDetail",{name:q0.display_name}),life:5000})}catch(V0){console.error("[MultiTrackWidget] failed to show model download success:",V0)}}catch(q0){let V0=q0 instanceof Error?q0.message:String(q0);m(V0)}finally{K0(!1)}}function dh(){if(!Y0)return;for(let q0 of Y0.urls??[Y0.url])globalThis.open(q0,"_blank","noopener,noreferrer")}return G(P6.Provider,{value:u0,children:G(a1,{children:T("div",{className:"relative flex h-full w-full min-w-0 max-w-full flex-col overflow-hidden rounded text-foreground font-sans text-xs select-none","aria-busy":x||t,children:[G(TS,{data:K,currentTime:B,selectedSegment:L0,isPlaying:_,playbackNonce:r,node:Z,app:Q,editingSubtitleSegmentId:y,onSubtitleEditRequestHandled:()=>f(null),onSelectSegment:(q0)=>a0(q0),onGlobalSettingsChange:M1,onSelectedSegmentContentChange:N1,taskSegments:_0,selectedTaskSegments:B0?J0:void 0,onTrackSegmentsContentChange:_5,onTaskTrackSegmentsChange:O1,onSelectedSegmentDurationChange:A1,onGenerateSubtitleSpeech:rW}),G(yI,{currentTime:B,totalLength:K.total_length,frameRate:K.frame_rate,isPlaying:_,zoom:F,snapEnabled:M,taskOverview:W,timelineCollapsed:N,onPlayPause:()=>L((q0)=>!q0),onZoomChange:V,onSnapEnabledChange:D,canAddTaskMarker:b1(),onAddTaskMarker:n,onTaskOverviewChange:v0,onToggleTimeline:()=>O((q0)=>!q0),canDelete:w.size>0,onDeleteSelected:()=>{if(b)D5(b)},onCutAtCurrentTime:mh,canTrimCenter:sW(),canTrimLeft:sW(),canTrimRight:sW(),onTrimLeftAtCurrentTime:()=>mF("start"),onTrimRightAtCurrentTime:()=>mF("end"),canUndo:g,canRedo:a,onUndo:A0,onRedo:F0}),G("div",{"data-testid":"multitrack-timeline-panel","aria-hidden":N,className:`grid shrink-0 transition-[grid-template-rows] duration-300 ease-in-out ${N?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:G("div",{className:"min-h-0 shrink-0 overflow-hidden",children:G("div",{ref:i,className:"no-scrollbar shrink-0 overflow-x-auto overflow-y-hidden",children:T("div",{className:"min-h-full",style:{width:s,minWidth:"100%"},children:[G(Jz,{totalLength:K.total_length,frameRate:K.frame_rate,width:s,canvasScale:G0,currentTime:B,taskMarkers:K.task_markers??[],selectedTaskMarkerId:I,onSeek:z1,onSelectTaskMarker:(q0)=>{Y1(null),A(q0)},onMoveTaskMarker:w0,onDeleteTaskMarker:N0}),G(iS,{data:K,node:Z,app:Q,width:s,currentTime:B,snapEnabled:M,canvasScale:G0,selectedSegmentIds:w,taskOverview:W,onAddVideo:r0,onAddAudio:K1,onReplaceAudio:x1,onAddTrack:s1,onAddSubtitleSegment:w1,onImportSubtitles:e1,onReplaceVideo:V1,onAddTaskSegment:r1,onSelectSegment:a0,onSelectSegments:C1,onClearSelection:g1,onDeleteSegment:D5,onDeleteTrack:z0,onReorderTrack:C0,onTrackVisibilityChange:l0,onTrackAudioSettingsChange:h0,onSharedReferenceChange:j0,onDistributeTaskSegments:X0,onCloneTaskSegment:O0,canMergeSelectedTaskSegments:W0,onMergeSelectedTaskSegments:x0,onSplitTaskSegment:P,onResizeSegment:f0,onResizeSegmentPreview:Z0,onMoveSegment:i0,onSmartSplit:T6,onSmartSplitTasks:u6,onRecognizeSubtitles:Y6,onEditSubtitleSegment:f,cutMode:!1,onCutSegment:uh,format:l.format})]})})})}),x?G("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80","data-testid":"smart-split-overlay",role:"status","aria-live":"polite",children:T("div",{className:"flex items-center gap-2 rounded border border-border bg-background px-3 py-2 text-foreground shadow-sm",children:[G(X6,{className:"h-4 w-4 animate-spin"}),G("span",{children:P0("multitrack.smartSplitting")})]})}):null,t?G("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80","data-testid":"subtitle-recognition-overlay",role:"status","aria-live":"polite",children:T("div",{className:"flex items-center gap-2 rounded border border-border bg-background px-3 py-2 text-foreground shadow-sm",children:[G(X6,{className:"h-4 w-4 animate-spin"}),G("span",{children:P0("multitrack.recognizingSubtitles")})]})}):null,G(ES,{segment:D0,frameRate:K.frame_rate,open:Boolean(j),onOpenChange:(q0)=>{if(!q0)P(null)},onConfirm:J1}),Y0?G("div",{className:"absolute inset-0 z-[60] flex items-center justify-center bg-background/90 p-4","data-testid":"missing-model-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"missing-model-title",children:T("div",{className:"w-full max-w-md rounded border border-border bg-background p-4 text-foreground shadow-sm",children:[T("div",{className:"flex items-start justify-between gap-3",children:[T("div",{className:"min-w-0",children:[G("h3",{id:"missing-model-title",className:"text-sm font-semibold",children:P0("modelDownload.title",{name:Y0.display_name})}),G("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:P0("modelDownload.description",{name:Y0.display_name,directory:n0})})]}),G(k0,{type:"button",variant:"ghost",size:"icon",onClick:()=>e(null),"aria-label":P0("modelDownload.close"),disabled:H0,children:G(a9,{className:"h-4 w-4"})})]}),G("div",{className:"mt-3 rounded border border-border bg-muted px-2 py-1.5 font-mono text-[8px] leading-4 text-foreground break-all",children:Y0.path}),E?G("p",{className:"mt-3 text-xs leading-5 text-destructive",children:E}):null,T("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[T(k0,{type:"button",variant:"outline",size:"sm",onClick:dh,disabled:H0,children:[G(oS,{className:"h-4 w-4"}),P0("modelDownload.manual")]}),T(k0,{type:"button",size:"sm",onClick:ch,disabled:H0,children:[H0?G(X6,{className:"h-4 w-4 animate-spin"}):G(vW,{className:"h-4 w-4"}),H0?P0("modelDownload.downloading"):P0("modelDownload.auto")]})]})]})}):null]})})})}var g$=R(v(),1);var v$=25;function ct($){if($?.source_type==="output")return"outputs";if($?.source_type==="local")return"local";if($?.source_type==="url")return"url";return"inputs"}function dt($,J){if(J)return J;return/^https?:\/\//i.test($)?"url":"input"}function pt({value:$,onChange:J,app:Q}){let Z=Q?.ui?.settings?.settingsValues?.["Comfy.Locale"],X=($&&Array.isArray($.images)?$:{images:[]}).images.slice(0,v$),[Y,z]=g$.useState(!1),[K,W]=g$.useState(null),[H,B]=g$.useState(null),[U,_]=g$.useState(!1),L=g$.useRef(null),F=t9(Q),V=Boolean(Q?.ui?.settings?.settingsValues?.["Comfy.VueNodes.Enabled"]),M=X.find((b)=>b.id===K),D=Math.min(5,Math.max(1,Math.ceil(Math.sqrt(X.length+(X.length<v$?1:0))))),N=Math.min(32,Math.max(22,26/Math.max(F,0.5)));function O(b){J({images:b.slice(0,v$)})}function I(b,k){let w=uJ(b).slice(0,K?1:v$-X.length);if(!w.length)return;let C=w.map((y)=>gJ(y,dt(y,k)));O(K?X.map((y)=>y.id===K?{...C[0],id:K}:y):[...X,...C]),W(null),z(!1)}async function A(b){if(!b?.length)return;let k=Array.from(b).filter((y)=>y.type.startsWith("image/")).slice(0,v$-X.length),w=await Promise.allSettled(k.map(y7)),C=[];for(let y of w)if(y.status==="fulfilled")C.push(y.value);else console.error("[MultiImagesLoaderWidget] image upload failed:",y.reason);if(C.length)C5("inputs"),O([...X,...C])}return G(P6.Provider,{value:Z,children:G(lt,{images:X,columns:D,controlSize:N,isNodeV2:V,selectorOpen:Y,setSelectorOpen:z,replaceId:K,setReplaceId:W,activeImage:M,preview:H,setPreview:B,dragOver:U,setDragOver:_,dragId:L,commit:O,select:I,dropFiles:A})})}function lt($){let J=Z1(),{images:Q,columns:Z,controlSize:q}=$,X=$.preview&&Z5({...$.preview,source_type:$.preview.source_type??"input"}),Y=Xz($.preview?.id??null,()=>$.setPreview(null));return T("div",{className:`relative flex h-full min-h-0 w-full flex-col overflow-hidden rounded-md bg-muted/20 text-foreground ${$.isNodeV2?"nodeNew":""}`,onDragOver:(z)=>{z.preventDefault(),$.setDragOver(!0)},onDragLeave:(z)=>{if(!z.currentTarget.contains(z.relatedTarget))$.setDragOver(!1)},onDrop:(z)=>{z.preventDefault(),$.setDragOver(!1),$.dropFiles(z.dataTransfer.files)},children:[T(t1,{open:$.selectorOpen,onOpenChange:(z)=>{if($.setSelectorOpen(z),!z)$.setReplaceId(null)},children:[Q.length===0?T("div",{className:`task-image-picker-empty relative flex h-full min-h-0 w-full flex-1 flex-col items-center justify-center gap-2 rounded-md px-4 py-2 text-foreground shadow-sm ${$.dragOver?"border border-primary bg-accent/20":"bg-muted/20"}`,children:[G(Nz,{className:"size-12 shrink-0"}),G("span",{className:"mt-1 text-base font-semibold",children:J("multitrack.selectImage")}),G("span",{className:"max-w-full whitespace-normal text-center text-sm text-muted-foreground",children:J("multitrack.imageDropHint")}),G(b5,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",className:"absolute inset-0 h-full w-full cursor-pointer rounded-md p-0 hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":J("multitrack.selectImage"),onClick:()=>$.setReplaceId(null)})})]}):G(_6,{asChild:!0,children:T("div",{className:`task-image-grid grid h-full min-h-0 w-full flex-1 auto-rows-max content-start gap-2 overflow-y-auto rounded-md p-3 transition-colors ${$.dragOver?"border border-primary bg-accent/20":"bg-muted/20"}`,style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:[Q.map((z,K)=>{let W=Z5({...z,source_type:z.source_type??"input"}),H=z.file_name??z.file_path??z.local_path??z.url??String(K+1);return T("div",{className:"group relative aspect-square min-w-0 w-full self-start overflow-hidden rounded-md border border-border bg-black",draggable:!0,onDragStart:()=>{$.dragId.current=z.id},onDragEnd:()=>{$.dragId.current=null},onDrop:(B)=>{if(B.dataTransfer.files.length>0||!$.dragId.current)return;B.preventDefault(),B.stopPropagation(),$.setDragOver(!1);let U=$.dragId.current;if(U===z.id)return;let _=[...Q],L=_.findIndex((M)=>M.id===U);if(L<0)return;let F=_.findIndex((M)=>M.id===z.id),[V]=_.splice(L,1);_.splice(F,0,V),$.commit(_)},children:[G(k0,{variant:"ghost",className:"absolute inset-0 h-full w-full rounded-none p-0","aria-label":J("multiImagesLoader.replace",{n:K+1}),onClick:()=>{$.setReplaceId(z.id),$.setSelectorOpen(!0)},children:W?G("img",{src:W,alt:H,className:"h-full w-full object-contain",draggable:!1}):G("span",{className:"px-1 text-xs text-image-tile-foreground",children:H})}),G("span",{className:"pointer-events-none absolute bottom-0 left-0 bg-black/50 px-1.5 text-[10px] text-image-tile-foreground",children:K+1}),T("div",{className:"absolute right-1 top-1 flex gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",children:[G(k0,{variant:"secondary",size:"icon",style:{width:q,height:q},"aria-label":J("multiImagesLoader.preview"),onClick:()=>$.setPreview(z),children:G(E7,{})}),G(k0,{variant:"destructive",size:"icon",style:{width:q,height:q},"aria-label":J("multiImagesLoader.delete"),onClick:()=>$.commit(Q.filter((B)=>B.id!==z.id)),children:G(N5,{})})]})]},z.id)}),Q.length<v$&&G(k0,{variant:"outline",className:"task-image-grid-add aspect-square h-auto w-full self-start border-dashed text-muted-foreground","aria-label":J("multiImagesLoader.add"),onClick:()=>{$.setReplaceId(null),$.setSelectorOpen(!0)},children:G(K5,{})})]})}),G(o1,{className:"w-auto p-0",align:"start",children:G(M5,{value:$.activeImage?.file_path??$.activeImage?.local_path??$.activeImage?.url??"",mediaType:"image",defaultTab:ct($.activeImage),allowMultipleSelection:!$.replaceId,maxSelectionCount:$.replaceId?1:v$-Q.length,onChange:$.select},$.replaceId??"add")})]}),Q.length>0&&T("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-t border-border bg-background/60 px-3 text-xs",children:[G("span",{className:"text-muted-foreground",children:J("multiImagesLoader.imageCount",{n:Q.length})}),T(k0,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>{$.setSelectorOpen(!1),$.setReplaceId(null),$.setPreview(null),$.commit([])},children:[G(N5,{className:"size-3.5"}),J("multiImagesLoader.clearAll")]})]}),X&&T("div",{"data-testid":"multi-images-expanded-preview","data-zoom":Y.zoom.toFixed(2),className:"absolute inset-0 z-30 flex items-center justify-center overflow-hidden bg-black p-3 pt-12",onWheel:Y.onWheel,children:[T(k0,{type:"button",variant:"secondary",className:"absolute left-2 top-2 z-20 h-8 cursor-pointer gap-1.5 px-2.5 text-xs","aria-label":J("multitrack.backToPreview"),onClick:()=>$.setPreview(null),children:[G(yW,{className:"h-4 w-4"}),G("span",{children:J("multitrack.backToPreview")})]}),T("span",{className:"pointer-events-none absolute right-2 top-2 z-20 rounded bg-background/70 px-2 py-1 text-[10px] tabular-nums text-foreground",children:[Math.round(Y.zoom*100),"%"]}),G("img",{ref:Y.imageRef,src:X,alt:$.preview?.file_name??$.preview?.file_path??$.preview?.url??"",className:"max-h-full max-w-full object-contain transition-transform duration-100 ease-out",style:{transform:`scale(${Y.zoom})`,transformOrigin:`${Y.origin.x}% ${Y.origin.y}%`},draggable:!1})]})]})}var E1=R(v(),1);var KX=R(v(),1);function Fh($,J,Q,Z,q,X){let Y=$?Math.max($.startTime,Math.min($.endTime,$.currentTime)):void 0,z=$?.isPlaying,K=KX.useCallback((W)=>{if(!W||Y===void 0)return;let H=Number.isFinite(W.duration)?Math.min(Y,W.duration):Y;try{if(!z||Math.abs(W.currentTime-H)>0.12)W.currentTime=H;if(z&&Number.isFinite(W.duration)&&Y>=W.duration)W.pause();else if(z&&W.paused)W.play()?.catch((B)=>{console.error("[CompareVideoWidget] failed to resume parent playback:",B),X()})}catch(B){console.error("[CompareVideoWidget] failed to follow parent playback:",B)}},[X,z,Y]);return KX.useEffect(()=>{if(Y===void 0)return;Z(Y),K(J.current),K(Q.current)},[Q,Z,J,K,Y]),KX.useEffect(()=>{if(z===void 0)return;if(z)q();else X()},[X,q,z]),K}var PF={save_output:!1,filename_prefix:"ComfyUI",watch_output_history:!1,compare_mode:"compare",source:null,output:null},it=50,rt=new Set([".mp4",".webm",".mov",".avi",".mkv",".flv",".wmv",".m4v"]);function Vh($){if(!$?.filename)return null;let J=$.type??"temp",Q=$.subfolder??"";return`/view?filename=${encodeURIComponent($.filename)}&type=${encodeURIComponent(J)}&subfolder=${encodeURIComponent(Q)}`}function Mh($){if(!$||typeof $!=="object")return null;let J=$,Q=J.source_type??J.type,Z=Q==="input"||Q==="output"||Q==="temp"||Q==="url"?Q:void 0,q=typeof J.file_path==="string"?J.file_path:typeof J.path==="string"?J.path:void 0,Y=(typeof J.url==="string"?J.url:void 0)??q??"";if(!Y.trim())return null;if(Z==="url"||/^https?:\/\//i.test(Y))return{source_type:"url",url:Y};if(!Z||!q)return null;return{source_type:Z,file_path:q}}function gW($){if(!$)return null;let{source_type:J,file_path:Q,url:Z}=$;if(J==="url"||/^https?:\/\//i.test(Z??Q??""))return Z??Q??null;if((J==="input"||J==="output"||J==="temp")&&Q)return z9(Q,J);return null}function bh($){if(!$)return"";return $.file_path??$.url??""}function st($,J){if($?.source_type==="url")return"url";if($?.source_type==="output")return"outputs";return J==="output"?"outputs":"inputs"}function RF($){let J=bh($);return J.split(/[\\/]/).pop()||J}function CF($){return $.path?`${$.source_type}:${$.path}`:null}function ot($,J){if(!$||typeof $!=="object")return null;let Q=$,Z=typeof Q.filename==="string"?Q.filename:"",q=Q.type==="output"||Q.type==="temp"?Q.type:void 0;if(!Z||!q)return null;if(Z.toLowerCase().includes("easy_compare"))return null;let X=Z.lastIndexOf(".");if(X<=0)return null;let Y=Z.slice(X).toLowerCase();if(!rt.has(Y))return null;let z=typeof Q.subfolder==="string"?Q.subfolder.replaceAll("\\","/"):"",K=z?`${z}/${Z}`:Z;return{type:"file",name:Z,path:K,url:z9(K,q),size:0,mtime:J,source_type:q}}function nt($){if(!$||typeof $!=="object")return[];let J=$.output;if(!J||typeof J!=="object")return[];let Q=J,Z=[],q=new Set,X=Date.now();for(let Y of["video","images"]){let z=Q[Y];if(!Array.isArray(z))continue;for(let K of z){let W=ot(K,X);if(!W)continue;let H=CF(W);if(!H||q.has(H))continue;q.add(H),Z.push(W),X+=1}}return Z}function at($){return{source_type:"output",file_path:$}}function tt($){return{source_type:"temp",file_path:$}}function Dh($,J){if(!$&&!J)return!0;if(!$||!J)return!1;return $.source_type===J.source_type&&$.file_path===J.file_path&&$.url===J.url}function GX($){if(!$)return null;let J=$.file_path??$.url??"";return J?`${$.source_type}:${J}`:null}function et($){return $.source_type==="temp"?tt($.path):at($.path)}function $e($,J,Q=new Set){let Z=[],q=new Set;for(let W of J){let H=et(W),B=GX(H);if(!B||q.has(B))continue;q.add(B),Z.push(H)}let X=Q.has("source")&&$.source!=null,Y=Q.has("output")&&$.output!=null,z=X?$.source??null:Y?Z.find((W)=>GX(W)!==GX($.output))??null:Z.length>=2?Z[1]:null,K=Y?$.output??null:X?Z.find((W)=>GX(W)!==GX(z))??null:Z.length>=1?Z[0]:null;return{source:z,output:K}}function uW($){if(Array.isArray($)){for(let J of $){let Q=uW(J);if(Q)return Q}return null}if(!$||typeof $!=="object")return null;return $}function Je($){if(!$||typeof $!=="object")return{...PF};let J=$,Q=J.compare_mode,Z=Q==="source"||Q==="compare"||Q==="side-by-side"||Q==="output"?Q:"compare";return{save_output:J.save_output===!0,filename_prefix:typeof J.filename_prefix==="string"?J.filename_prefix:PF.filename_prefix,watch_output_history:J.watch_output_history===!0,compare_mode:Z,source:Mh(J.source),output:Mh(J.output)}}function Qe($){if(!$||typeof $!=="object")return null;let J=$,Q=uW(J.compare_videos);if(Q)return Q;let Z=J.output;if(Z&&typeof Z==="object"){let X=uW(Z.compare_videos);if(X)return X}let q=J.ui;if(q&&typeof q==="object"){let X=uW(q.compare_videos);if(X)return X}return null}function Ze($,J){if(!$||typeof $!=="object")return!0;let Q=$.node;if(Q===void 0||Q===null||J.id===void 0||J.id===null)return!0;return String(Q)===String(J.id)}function Nh($){if(!Number.isFinite($)||$<0)return"0:00";let J=Math.floor($/60),Q=Math.floor($%60);return`${J}:${Q.toString().padStart(2,"0")}`}function yF($,J){if(!$||!Number.isFinite(J))return;try{$.currentTime=J}catch(Q){console.error("[CompareVideoWidget] failed to seek video:",Q)}}function qe({app:$,node:J,value:Q,onChange:Z}){let q=$?.ui?.settings?.settingsValues?.["Comfy.Locale"],X=J,Y=Je(Q);return G(P6.Provider,{value:q,children:G(Eh,{app:$,node:X,settings:Y,onSettingsChange:Z})})}var jh=E1.memo(function({app:J,sourceUrl:Q,outputUrl:Z,pausePlaybackNonce:q,parentPlayback:X}){let Y=J?.ui?.settings?.settingsValues?.["Comfy.Locale"],[z,K]=E1.useState("side-by-side"),W=E1.useMemo(()=>({...PF,compare_mode:z,source:{source_type:"url",url:Q},output:{source_type:"url",url:Z}}),[z,Z,Q]);return G(P6.Provider,{value:Y,children:G(Eh,{app:J,node:{},settings:W,onSettingsChange:(H)=>K(H.compare_mode??"side-by-side"),allowMediaSelection:!1,bindNodeEvents:!1,pausePlaybackNonce:q,parentPlayback:X})})});function Oh({settings:$,onSettingsChange:J}){let Q=Z1();return T("div",{className:"flex w-64 flex-col gap-3",children:[T("div",{className:"flex items-center gap-2",children:[T(k0,{type:"button",variant:"ghost",role:"checkbox","aria-checked":$.save_output,disabled:$.watch_output_history,className:b0("h-auto flex-1 cursor-pointer justify-start gap-2 px-0 py-1 hover:bg-transparent",$.watch_output_history&&"cursor-not-allowed opacity-50"),onClick:()=>J({...$,save_output:!$.save_output}),children:[G("span",{className:b0("flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-border",$.save_output&&"border-primary bg-primary text-primary-foreground"),children:$.save_output?G(j9,{className:"h-3 w-3"}):null}),G("span",{className:"text-left",children:Q("compareVideo.saveOutput")})]}),T(k0,{type:"button",variant:"ghost",role:"checkbox","aria-checked":$.watch_output_history,className:"h-auto flex-1 cursor-pointer justify-start gap-2 px-0 py-1 hover:bg-transparent",onClick:()=>{let Z=!$.watch_output_history;J({...$,watch_output_history:Z,source:Z?null:$.source,output:Z?null:$.output,save_output:Z?!1:$.save_output})},children:[G("span",{className:b0("flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-border",$.watch_output_history&&"border-primary bg-primary text-primary-foreground"),children:$.watch_output_history?G(j9,{className:"h-3 w-3"}):null}),G(Ih,{className:"h-3.5 w-3.5 text-muted-foreground"}),G("span",{className:"text-left",children:Q("compareVideo.watchOutputHistory")})]})]}),T("label",{className:"flex flex-col gap-1.5 text-xs text-muted-foreground",children:[G("span",{children:Q("compareVideo.filenamePrefix")}),G($6,{value:$.filename_prefix,disabled:$.watch_output_history,placeholder:"ComfyUI","aria-label":Q("compareVideo.filenamePrefix"),onChange:(Z)=>J({...$,filename_prefix:Z.currentTarget.value})})]})]})}function Ah({slot:$,selection:J,disabled:Q=!1,watchHistory:Z=!1,onSelect:q,onClear:X}){let Y=Z1(),[z,K]=E1.useState(!1),W=RF(J),H=$==="source"?Y("compareVideo.source"):Y("compareVideo.output"),B=$==="source"?Y("compareVideo.selectSource"):Y("compareVideo.selectOutput"),U=$==="source"?Y("compareVideo.clearSource"):Y("compareVideo.clearOutput");return T("div",{className:"flex items-center gap-1",children:[T(t1,{open:z,onOpenChange:(_)=>{if(Q)return;K(_)},children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"secondary",size:"sm",disabled:Q,className:b0("h-7 gap-1.5 border-border/50 bg-muted/60 px-2 text-foreground shadow",Q?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-muted/90"),"aria-label":W?`${H}: ${W}`:B,children:[G(kh,{className:"h-3.5 w-3.5"}),G("span",{className:"max-w-36 truncate text-[11px]",children:W||B})]})}),G(o1,{className:"w-auto p-0",align:$==="source"?"start":"end",children:G(M5,{value:bh(J),mediaType:"video",defaultTab:Z?"history":st(J,$),historySource:"combined",historyOnly:Z,onChange:(_,L)=>{if(L===void 0)q(_,L),K(!1)},onSourceChange:(_)=>{q(_.filePath,_.sourceType),K(!1)}},`${$}-${W||"empty"}`)})]}),J?G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 cursor-pointer bg-muted/60 text-foreground shadow hover:bg-muted/90","aria-label":U,disabled:Q,onClick:X,children:G(a9,{className:"h-3.5 w-3.5"})}):null]})}function Eh({app:$,node:J,settings:Q,onSettingsChange:Z,allowMediaSelection:q=!0,bindNodeEvents:X=!0,pausePlaybackNonce:Y,parentPlayback:z}){let K=Z1(),W=t9($),H=E1.useRef(null),B=E1.useRef(null),U=E1.useRef(null),[_,L]=E1.useState(()=>J.__easyMediaCompareVideos??null),[F,V]=E1.useState(Q.compare_mode??"compare"),[M,D]=E1.useState(50),[N,O]=E1.useState(!1),[I,A]=E1.useState(!1),[b,k]=E1.useState(!1),w=b||z?.muted===!0,[C,y]=E1.useState(0.75),[f,j]=E1.useState(0),[P,x]=E1.useState(0),p=E1.useRef(Q),t=E1.useRef(z);t.current=z;let h=E1.useRef(Z),r=E1.useRef(new Set),$0=E1.useRef(Q.watch_output_history);p.current=Q,h.current=Z;let Y0=E1.useMemo(()=>gW(Q.source)??(Q.watch_output_history?null:Vh(_?.source)),[_,Q.source,Q.watch_output_history]),e=E1.useMemo(()=>gW(Q.output)??(Q.watch_output_history?null:Vh(_?.output)),[_,Q.output,Q.watch_output_history]),H0=Boolean(Y0),K0=Boolean(e),E=H0||K0,m=H0&&K0,c=z?.isPlaying?z.endTime:K0?P:Math.max(_?.duration??0,P,0),i=m?F:H0?"source":"output",u=m&&i==="side-by-side",d=i==="source"?100:i==="output"?0:u?50:M,o=i!=="compare"||!N;E1.useEffect(()=>{if(!X)return;function g(u0){let P0=Qe(u0);if(!P0)return;J.__easyMediaCompareVideos=P0,L(P0),j(0),A(!1),x(0)}let a=J.onExecuted,I0=function(P0){a?.call(this,P0),g(P0)};J.onExecuted=I0;let A0=$.api,F0=(u0)=>{if(!Ze(u0.detail,J))return;g(u0.detail)};return A0?.addEventListener?.("executed",F0),A0?.addCustomEventListener?.("executed",F0),()=>{if(J.onExecuted===I0)J.onExecuted=a;A0?.removeEventListener?.("executed",F0),A0?.removeCustomEventListener?.("executed",F0)}},[$.api,X,J]),E1.useEffect(()=>{if(H.current)H.current.muted=w||K0,H.current.volume=C;if(B.current)B.current.muted=w,B.current.volume=C},[K0,w,C]),E1.useEffect(()=>{if(m)V(Q.compare_mode??"compare");else if(H0)V("source");else if(K0)V("output")},[m,K0,H0,Q.compare_mode]),E1.useEffect(()=>{let g=$0.current;if($0.current=Q.watch_output_history,Q.watch_output_history&&!g)r.current.clear();else if(!Q.watch_output_history&&g)J.__easyMediaCompareVideos=null,L(null),j(0),x(0)},[J,Q.watch_output_history]),E1.useEffect(()=>{if(!Q.watch_output_history)return;let g=[],a=[],I0=new Set;function A0(){let R0=p.current;if(!R0.watch_output_history)return;let{source:Y1,output:z1}=$e(R0,g,r.current);if(Dh(R0.source,Y1)&&Dh(R0.output,z1))return;h.current({...R0,source:Y1,output:z1}),j(0),x(0),A(!1)}function F0(R0){let Y1=nt(R0.detail);if(Y1.length===0)return;for(let z1 of Y1){let a0=CF(z1);if(!a0||I0.has(a0))continue;I0.add(a0),a.push(z1)}}function u0(){a=[],I0=new Set}function P0(){let R0=[...a].reverse(),Y1=[],z1=new Set;for(let a0 of[...R0,...g]){let C1=CF(a0);if(!C1||z1.has(C1))continue;z1.add(C1),Y1.push(a0)}g.splice(0,g.length,...Y1.slice(0,it)),a=[],I0=new Set,A0()}let n0=$.api;return n0?.addEventListener?.("execution_start",u0),n0?.addEventListener?.("executed",F0),n0?.addEventListener?.("execution_success",P0),n0?.addCustomEventListener?.("execution_start",u0),n0?.addCustomEventListener?.("executed",F0),n0?.addCustomEventListener?.("execution_success",P0),()=>{n0?.removeEventListener?.("execution_start",u0),n0?.removeEventListener?.("executed",F0),n0?.removeEventListener?.("execution_success",P0),n0?.removeCustomEventListener?.("execution_start",u0),n0?.removeCustomEventListener?.("executed",F0),n0?.removeCustomEventListener?.("execution_success",P0)}},[$.api,Q.watch_output_history]);let S=E1.useCallback((g)=>{yF(H.current,g),yF(B.current,g)},[]),s=E1.useCallback(()=>{A(!0);for(let g of[H.current,B.current]){if(!g)continue;let a=t.current;if(a?.isPlaying&&Number.isFinite(g.duration)&&a.currentTime>=g.duration)continue;if(!g.paused)continue;let I0=g.play();if(I0)I0.catch((A0)=>{console.error("[CompareVideoWidget] failed to play video:",A0),A(!1)})}},[]),G0=E1.useCallback(()=>{A(!1),H.current?.pause(),B.current?.pause()},[]);E1.useEffect(()=>{if(Y===void 0)return;G0()},[Y,G0]);let l=Fh(z,H,B,j,s,G0);E1.useEffect(()=>{let g=H.current,a=B.current;return()=>{g?.pause(),a?.pause()}},[Y0,e]),E1.useEffect(()=>{if(!X)return;return J.__easyMediaSyncPlay=()=>{S(0),j(0),s()},()=>{if(J.__easyMediaSyncPlay)delete J.__easyMediaSyncPlay}},[X,J,s,S]);function Q0(g){if(!m||i!=="compare")return;let a=U.current?.getBoundingClientRect();if(!a)return;let I0=W>0?W:1,A0=(g.clientX-a.left)/I0,F0=a.width/I0,u0=F0>0?A0/F0*100:50;D(Math.max(0,Math.min(100,u0)))}function J0(g){if(z?.isPlaying)return;let a=g.currentTarget,I0=B.current??H.current;if(a!==I0)return;j(a.currentTime);let A0=a===H.current?B.current:H.current;if(A0&&Math.abs(A0.currentTime-a.currentTime)>0.08)yF(A0,a.currentTime)}function B0(g){if(z?.isPlaying){g.currentTarget.pause();return}if(S(0),j(0),I)s()}function W0(g){let a=g[0]??0;if(z?.isPlaying){z.onSeek(Math.max(z.startTime,Math.min(z.endTime,a)));return}j(a),S(a)}function L0(){V((g)=>{let a="compare";if(g==="compare")a="side-by-side";else if(g==="side-by-side")a="source";else if(g==="source")a="output";return Z({...Q,compare_mode:a}),a})}function _0(g,a,I0){let A0=/^https?:\/\//i.test(a),F0=I0==="output"?"output":I0==="temp"?"temp":I0==="input"?"input":A0?"url":"input",u0=F0==="url"?{source_type:"url",url:a}:{source_type:F0,file_path:a},P0={...Q,[g]:u0},n0=g==="source"?P0.output:P0.source;if(Q.watch_output_history)r.current.add(g);if(Z(P0),j(0),x(0),A(!1),gW(u0)&&gW(n0))V(P0.compare_mode??"compare")}function D0(g){if(Q.watch_output_history)r.current.delete(g);Z({...Q,[g]:null}),j(0),x(0),A(!1)}function c0(){let g=Q.watch_output_history?RF(Q.output):_?.output?.filename??RF(Q.output);if(!e||!g)return;try{let a=document.createElement("a");a.href=e,a.download=g,a.rel="noopener",document.body.appendChild(a),a.click(),a.remove()}catch(a){console.error("[CompareVideoWidget] failed to download output video:",a)}}return G(a1,{children:T("div",{className:"group relative h-full min-h-[320px] w-full overflow-hidden rounded border border-border bg-background text-foreground",children:[T("div",{ref:U,className:"relative h-full min-h-[320px] overflow-hidden bg-black",onPointerEnter:()=>O(!0),onPointerMove:(g)=>{Q0(g)},onPointerLeave:()=>{if(O(!1),i==="compare")D(50)},onPointerCancel:()=>{if(O(!1),i==="compare")D(50)},children:[Y0?G("video",{ref:H,className:b0("absolute inset-0 h-full w-full object-contain",!H0&&"invisible",u&&"right-auto w-1/2"),"data-compare-video-panel":u?"source":void 0,src:Y0,loop:!z?.isPlaying,muted:w||K0,playsInline:!0,preload:"auto",onLoadedMetadata:(g)=>{let a=g.currentTarget.duration||0;if(!K0)x(a);l(g.currentTarget)},onTimeUpdate:J0,onEnded:B0}):null,e?G("video",{ref:B,className:b0("absolute inset-0 h-full w-full object-contain",!K0&&"invisible",u&&"left-1/2 w-1/2"),style:{clipPath:u?void 0:`inset(0 0 0 ${d}%)`,transition:!u&&o?"clip-path 260ms ease":void 0},"data-compare-video-panel":u?"output":void 0,src:e,loop:!z?.isPlaying,muted:w,playsInline:!0,preload:"auto",onLoadedMetadata:(g)=>{let a=g.currentTarget.duration||0;x(a),l(g.currentTarget)},onTimeUpdate:J0,onEnded:B0}):null,!E?T("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-4 bg-background p-4 pt-12",children:[G(Oh,{settings:Q,onSettingsChange:Z}),G("p",{className:"text-xs text-muted-foreground mt-2",children:K("compareVideo.empty")})]}):null,q?T(G1,{children:[G("div",{className:"absolute left-3 top-2 z-30",children:G(Ah,{slot:"source",selection:Q.source,watchHistory:Q.watch_output_history,onSelect:(g,a)=>_0("source",g,a),onClear:()=>D0("source")})}),G("div",{className:"absolute right-3 top-2 z-30",children:G(Ah,{slot:"output",selection:Q.output,watchHistory:Q.watch_output_history,onSelect:(g,a)=>_0("output",g,a),onClear:()=>D0("output")})})]}):null,m&&(i==="compare"||u)?G("div",{className:"pointer-events-none absolute inset-y-0 w-px bg-white shadow",style:{left:`${d}%`,transition:o?"left 260ms ease":void 0}}):null,m?T(k0,{type:"button",className:"absolute left-1/2 top-2 z-30 -translate-x-1/2 cursor-pointer bg-muted/60 text-foreground shadow hover:bg-muted/90",onClick:L0,onPointerDown:(g)=>g.stopPropagation(),size:"sm",variant:"secondary",children:[i==="source"||i==="output"?G(VJ,{className:"h-4 w-4"}):G(wh,{className:"h-4 w-4"}),i==="source"?K("compareVideo.sourceOnly"):i==="output"?K("compareVideo.outputOnly"):i==="side-by-side"?K("compareVideo.sideBySide"):K("compareVideo.compare")]}):null]}),T("div",{"data-compare-video-toolbar":!0,className:"@container/compare-video-controls pointer-events-none absolute inset-x-0 bottom-0 z-10 grid translate-y-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-t border-border bg-background/90 px-1 opacity-0 shadow-sm backdrop-blur-sm transition-[opacity,transform] duration-300 ease-out @max-[420px]/compare-video-controls:grid-cols-[minmax(0,1fr)_auto] @max-[420px]/compare-video-controls:gap-x-1 @max-[420px]/compare-video-controls:gap-y-0 @max-[420px]/compare-video-controls:px-2 @max-[420px]/compare-video-controls:py-1 group-hover:pointer-events-auto group-hover:translate-y-0 group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:translate-y-0 group-focus-within:opacity-100",children:[G("div",{"data-compare-video-playback":!0,className:"@max-[420px]/compare-video-controls:col-start-1 @max-[420px]/compare-video-controls:row-start-2",children:T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"cursor-pointer",onClick:()=>{if(I){if(G0(),z?.isPlaying)z.onPause()}else s()},"aria-label":I?K("compareVideo.pause"):K("compareVideo.play"),children:I?G(O7,{className:"h-4 w-4"}):G(P4,{className:"h-4 w-4"})})}),G(W1,{children:I?K("compareVideo.pause"):K("compareVideo.play")})]})}),T("div",{"data-compare-video-seek":!0,className:"grid min-w-0 grid-cols-[auto_minmax(4rem,1fr)_auto] items-center gap-2 @max-[420px]/compare-video-controls:col-span-2 @max-[420px]/compare-video-controls:col-start-1 @max-[420px]/compare-video-controls:row-start-1 @max-[420px]/compare-video-controls:w-full @max-[420px]/compare-video-controls:px-1 @max-[420px]/compare-video-controls:py-1",children:[G("span",{className:"w-10 text-right text-[11px] tabular-nums text-muted-foreground",children:Nh(f)}),G("div",{className:"min-w-0",children:G(O8,{className:"w-full",value:[Math.min(f,c||f)],min:z?.isPlaying?z.startTime:0,max:Math.max(c,f,0.01),step:0.01,onValueChange:W0,"aria-label":K("compareVideo.seek")})}),G("span",{className:"w-10 text-[11px] tabular-nums text-muted-foreground",children:Nh(c)})]}),T("div",{"data-compare-video-actions":!0,className:"flex items-center gap-2 @max-[420px]/compare-video-controls:col-start-2 @max-[420px]/compare-video-controls:row-start-2 @max-[420px]/compare-video-controls:gap-1",children:[T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"cursor-pointer",onClick:()=>k((g)=>!g),"aria-label":b?K("compareVideo.unmute"):K("compareVideo.mute"),children:b?G(EJ,{className:"h-4 w-4"}):G($4,{className:"h-4 w-4"})})}),G(W1,{children:b?K("compareVideo.unmute"):K("compareVideo.mute")})]}),G("div",{"data-compare-video-volume":!0,children:G(O8,{className:"w-20",value:[C],min:0,max:1,step:0.01,onValueChange:(g)=>y(g[0]??0),"aria-label":K("compareVideo.volume")})}),q?T(t1,{children:[G(b5,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"cursor-pointer","aria-label":K("compareVideo.settings"),children:G(Th,{className:"h-4 w-4"})})}),G(o1,{align:"end",className:"w-auto",children:G(Oh,{settings:Q,onSettingsChange:Z})})]}):null,q&&K0?T(H1,{children:[G(B1,{asChild:!0,children:G(k0,{type:"button",variant:"ghost",size:"icon",className:"cursor-pointer","aria-label":K("compareVideo.downloadOutput"),onClick:c0,children:G(vW,{className:"h-4 w-4"})})}),G(W1,{children:K("compareVideo.downloadOutput")})]}):null]})]})]})})}var K7=R(v(),1);var B2={minimax:"h3-context-ir (海螺官方)",volcengine:"doubao-seed-2-0-pro-260215 (火山引擎)",zhipu:"glm-5v-turbo (智谱)",runningHubDoubao:"bytedance/doubao-seed-2.0-pro (RunningHub)",runningHubGlm:"glm-5v-turbo (RunningHub)",local:"llama.cpp (本地)"},mW=new Map;function Xe($){if(!$||typeof $!=="object")throw Error("RunningHub returned an invalid account response.");let J=$;if(typeof J.error==="string")throw Error(J.error);let Q=Number(J.amount);if(!Number.isFinite(Q))throw Error("RunningHub account response did not contain a valid balance.");return{amount:Q,currency:typeof J.currency==="string"?J.currency:"CNY"}}var yh=[{id:"minimax",modelNames:[B2.minimax],balancePageUrl:"https://platform.minimaxi.com/console/recharge-records",apiKeyPageUrl:"https://platform.minimaxi.com/console/access?tab=api-keys"},{id:"volcengine",modelNames:[B2.volcengine],balancePageUrl:"https://console.volcengine.com/finance/",apiKeyPageUrl:"https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey"},{id:"zhipu",modelNames:[B2.zhipu],balancePageUrl:"https://open.bigmodel.cn/usercenter/financial/balance",apiKeyPageUrl:"https://open.bigmodel.cn/usercenter/apikeys"},{id:"runninghub",modelNames:[B2.runningHubDoubao,B2.runningHubGlm],balancePageUrl:"https://www.runninghub.cn/call-api/bill-task?tab=llmLogs&inviteCode=rh-v1623",apiKeyPageUrl:"https://www.runninghub.cn/zh-cn/enterprise-api/sharedApi?inviteCode=rh-v1623",balanceRequest:{url:"/easy-media/prompt-enhancer/runninghub-balance",refreshIntervalMs:30000,createInit:($)=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:$})}),readBalance:Xe}},{id:"local",modelNames:[B2.local]}];function SF($){return yh.find((J)=>J.modelNames.includes($))??yh[0]}async function Ph($,J){let Q=$.balanceRequest;if(!Q)throw Error("The selected provider does not expose a balance API.");let Z=`${$.id}:${J}`,q=mW.get(Z);if(q?.request)return q.request;if(q?.completedAt!==void 0&&Date.now()-q.completedAt<Q.refreshIntervalMs){if(q.balance)return q.balance;if(q.error!==void 0)throw q.error}let X=(async()=>{let Y=await fetch(Q.url,Q.createInit(J));if(!Y.ok)throw Error(`Balance request failed with status ${Y.status}.`);let z=await Y.json();return Q.readBalance(z)})();mW.set(Z,{request:X});try{let Y=await X;return mW.set(Z,{balance:Y,completedAt:Date.now()}),Y}catch(Y){throw mW.set(Z,{error:Y,completedAt:Date.now()}),Y}}function cW($){let J=$;while(Array.isArray(J)&&J.length===1)J=J[0];return J}function Rh($,J){let Q=cW($);if(!Q||typeof Q!=="object")return"";let Z=cW(Q[J]);return typeof Z==="string"?Z:""}function dW($){let J=$.widgets??[],Q=J.find((X)=>X.name==="model")?.value,Z=cW(J.find((X)=>X.name==="model.model")?.value??Q),q=cW(J.find((X)=>X.name==="model.apikey")?.value??J.find((X)=>X.name==="apikey")?.value);return{modelName:typeof Z==="string"?Z:Rh(Q,"model")||B2.minimax,apiKey:typeof q==="string"?q:Rh(Q,"apikey")}}function hF($){globalThis.open($,"_blank","noopener,noreferrer")}function Ch($,J){try{return new Intl.NumberFormat(J||void 0,{style:"currency",currency:$.currency,minimumFractionDigits:2,maximumFractionDigits:2}).format($.amount)}catch(Q){return console.error("[PromptEnhancerAccountBar] failed to format balance:",Q),`${$.amount.toFixed(2)} ${$.currency}`}}function Ye({apiKey:$,locale:J,modelName:Q,refreshToken:Z=0}){let q=Z1(),X=SF(Q),[Y,z]=K7.useState(null),[K,W]=K7.useState(!1),[H,B]=K7.useState(!1);if(K7.useEffect(()=>{let _=X.balanceRequest,L=$.trim();if(z(null),W(!1),B(Boolean(_)),!_)return;let F=!1;return(async()=>{try{let M=await Ph(X,L);if(!F)z(M)}catch(M){if(F)return;console.error("[PromptEnhancerAccountBar] failed to load balance:",M),W(!0)}finally{if(!F)B(!1)}})(),()=>{F=!0}},[$,X,Z]),X.id==="local")return G("div",{className:"flex h-[30px] items-center border-t border-border px-2 text-[10px] text-muted-foreground",children:q("promptEnhancerAccount.localModel")});return T("div",{className:"flex h-[30px] min-w-0 items-center justify-between gap-2",children:[G("div",{className:"min-w-0",children:(()=>{if(!X.balanceRequest)return G(k0,{className:"h-6 px-1.5 text-[10px] cursor-pointer",onClick:()=>X.balancePageUrl&&hF(X.balancePageUrl),size:"sm",type:"button",variant:"link",children:q("promptEnhancerAccount.viewBalance")});if(H)return T(bJ,{className:"h-5 gap-1 px-1.5 text-[10px]",variant:"outline",children:[G(X6,{className:"size-3 animate-spin"}),q("promptEnhancerAccount.loadingBalance")]});if(Y)return G(bJ,{className:"h-5 max-w-full truncate px-1.5 text-[10px] cursor-pointer",title:Ch(Y,J),variant:"secondary",onClick:()=>X.balancePageUrl&&hF(X.balancePageUrl),children:q("promptEnhancerAccount.balance",{amount:Ch(Y,J)})});let _=K?q("promptEnhancerAccount.balanceUnavailable"):q("promptEnhancerAccount.apiKeyRequired");return G(bJ,{className:"h-5 px-1.5 text-[10px]",title:_,variant:"outline",children:q("promptEnhancerAccount.balanceEmpty")})})()}),X.apiKeyPageUrl?T(k0,{className:"h-6 shrink-0 px-1.5 text-[10px] cursor-pointer",onClick:()=>X.apiKeyPageUrl&&hF(X.apiKeyPageUrl),size:"sm",type:"button",variant:"outline",children:[G(Sh,{className:"size-1"}),q("promptEnhancerAccount.apiKey")]}):null]})}function ze($){return G(P6.Provider,{value:$.locale,children:G(Ye,{...$})})}function Ke({app:$,node:J}){let Q=J,[Z,q]=K7.useState(()=>dW(Q)),[X,Y]=K7.useState(0);return K7.useEffect(()=>{let z=!0,K=Q.onConfigure,W=Q.onExecuted,H=Q.onWidgetChanged,B=()=>{queueMicrotask(()=>{if(!z)return;let F=dW(Q);q((V)=>V.modelName===F.modelName&&V.apiKey===F.apiKey?V:F)})},U=function(F){K?.call(this,F),B()},_=function(F){W?.call(this,F);let V=dW(Q);if(SF(V.modelName).id==="runninghub")Y((M)=>M+1)},L=function(F,V,M,D){if(H?.call(this,F,V,M,D),F==="model"||F==="model.model"||F==="model.apikey"||F==="apikey")B()};return Q.onConfigure=U,Q.onExecuted=_,Q.onWidgetChanged=L,B(),()=>{if(z=!1,Q.onConfigure===U)Q.onConfigure=K;if(Q.onExecuted===_)Q.onExecuted=W;if(Q.onWidgetChanged===L)Q.onWidgetChanged=H}},[Q]),G(ze,{apiKey:Z.apiKey,locale:$?.ui?.settings?.settingsValues?.["Comfy.Locale"],modelName:Z.modelName,refreshToken:X})}var D1=R(v(),1);var pW=R(v(),1);function hh($){let J=pW.useRef($);J.current=$,pW.useEffect(()=>{function Q(){if(document.visibilityState==="hidden")J.current()}function Z(){J.current()}return document.addEventListener("visibilitychange",Q),window.addEventListener("pagehide",Z),()=>{document.removeEventListener("visibilitychange",Q),window.removeEventListener("pagehide",Z)}},[])}var gh=1,Ge=100,xF="h-6 w-6 shrink-0 [&_svg]:size-3.5",lW=Symbol("drop-prompt-input");function fF($){if(!$||typeof $!=="object"||Array.isArray($))return UX;let J=$;return{project_name:typeof J.project_name==="string"?J.project_name:"default",width:Number.isFinite(J.width)?Math.max(0,Number(J.width)):0,height:Number.isFinite(J.height)?Math.max(0,Number(J.height)):0,frame_rate:Number.isFinite(J.frame_rate)&&Number(J.frame_rate)>0?Number(J.frame_rate):24,clips:Array.isArray(J.clips)?J.clips:[],auto_combine:J.auto_combine!==!1,updated_at:J.updated_at}}function We($){let J=$.graph?.links;if(!J)return[];if(Array.isArray(J))return J.filter(Boolean);if(J instanceof Map)return[...J.values()].filter(Boolean);return Object.values(J).filter(Boolean)}function He($,J,Q){let Z=new Set(Object.keys(Q));for(let q of $.graph?._nodes??[])if(q.id!=null)Z.add(String(q.id));if(J&&typeof J==="object"&&"nodes"in J&&Array.isArray(J.nodes)){for(let q of J.nodes)if(q&&typeof q==="object"&&"id"in q&&q.id!=null)Z.add(String(q.id))}return Z}function vF($,J,Q){if(Array.isArray($)&&$.length===2&&(typeof $[0]==="string"||typeof $[0]==="number")&&typeof $[1]==="number"&&Q.has(String($[0])))return J.has(String($[0]))?$:lW;if(Array.isArray($))return $.flatMap((Z)=>{let q=vF(Z,J,Q);return q===lW?[]:[q]});if($&&typeof $==="object")return Object.fromEntries(Object.entries($).flatMap(([Z,q])=>{let X=vF(q,J,Q);return X===lW?[]:[[Z,X]]}));return $}function Be($){let J=String($.id??""),Q=new Set(J?[J]:[]),Z=J?[J]:[],q=We($);while(Z.length>0){let X=Z.shift();for(let Y of q){if(String(Y.origin_id??"")!==X||Y.target_id==null)continue;let z=String(Y.target_id);if(Q.has(z))continue;Q.add(z),Z.push(z)}}return Q}function iW($){return Math.max(gh,$.source_end_frame-$.source_start_frame)}function xh($){return $.filter((J)=>J.enabled!==!1).reduce((J,Q)=>J+iW(Q),0)}function WX($,J){let Q=0;for(let Z of $){if(Z.enabled===!1)continue;let q=Q+iW(Z);if(J<q)return{clip:Z,start:Q};Q=q}return null}function Ue($,J){let Q=0;for(let Z of $){if(Z.enabled===!1)continue;if(Z.id===J)return Q;Q+=iW(Z)}return 0}function HX($,J){if($&&typeof $==="object"&&"error"in $&&typeof $.error==="string")return $.error;return J}function fh($){let J=Z5({source_type:"output",file_path:$.file_path});return J?gF(J,$.media_revision):null}function _e($){let J=Z5({source_type:"output",file_path:$.file_path});return J?gF(J,$.media_revision):null}function BX($){let J=$.video_files?.length?$.video_files:[{file_path:$.file_path,file_name:$.file_name,media_revision:$.media_revision,source_frame_count:$.source_frame_count}];return J.some((Q)=>Q.file_path===$.file_path)?J:[{file_path:$.file_path,file_name:$.file_name,media_revision:$.media_revision,source_frame_count:$.source_frame_count},...J]}function vh($,J){let Q=Math.max(gh,J.source_frame_count),Z=Math.min($.source_start_frame,Q-1);return{...$,file_path:J.file_path,file_name:J.file_name,media_revision:J.media_revision,source_start_frame:Z,source_end_frame:Math.max(Z+1,Math.min($.source_end_frame,Q)),source_frame_count:Q,continuity_mode:J.continuity_mode??$.continuity_mode}}function Le({value:$,onChange:J,app:Q,node:Z}){let q=fF($),X=Q?.ui?.settings?.settingsValues?.["Comfy.Locale"],Y=D1.useCallback((n,N0)=>fW(X,n,N0),[X]),[z,K]=D1.useState(0),[W,H]=D1.useState(!1),[B,U]=D1.useState(!1),[_,L]=D1.useState(1),[F,V]=D1.useState(!1),[M,D]=D1.useState(!1),[N,O]=D1.useState(!1),[I,A]=D1.useState(null),[b,k]=D1.useState(!1),[w,C]=D1.useState(["default"]),[y,f]=D1.useState(null),[j,P]=D1.useState({}),[x,p]=D1.useState(0),[t,h]=D1.useState(0),r=D1.useRef(new Map),$0=D1.useRef(0),Y0=D1.useRef(0),e=D1.useRef(0),H0=D1.useRef(0),K0=D1.useRef(null),E=D1.useRef(null),m=D1.useRef(0),c=D1.useRef(!1),i=D1.useRef(q);i.current=q;let u=t9(Q),o=Math.max(1,kJ(E))*_,S=xh(q.clips),s=WX(q.clips,Math.min(z,Math.max(0,S-1))),G0=s?fh(s.clip):null,l=q.clips.filter((n)=>n.enabled!==!1),Q0=s?l.findIndex((n)=>n.id===s.clip.id):-1,J0=Q0>=0&&l.length>1?l[(Q0+1)%l.length]:void 0,B0=J0?fh(J0):null,W0=w.includes(q.project_name)||!q.project_name?w:[...w,q.project_name];function L0(n){let N0=new Set(BX(n).map((v0)=>v0.file_path));if(N0.size===1)return[...N0];let w0=[...new Set(j[n.id]??[])].filter((v0)=>N0.has(v0)).slice(0,2);return w0.includes(n.file_path)?w0:[n.file_path]}let _0=s?L0(s.clip).map((n)=>BX(s.clip).find((N0)=>N0.file_path===n)).filter((n)=>Boolean(n)):[],D0=_0.length===2?_0.map(_e):[],c0=D0.length===2&&D0.every(Boolean);function g(n){Y1(Ue(q.clips,n.id))}function a(n,N0){let w0=n.video_files?.find((v0)=>v0.file_path===N0);if(!w0)return;J({...q,clips:q.clips.map((v0)=>v0.id===n.id?vh(v0,w0):v0)}),I0(n,w0)}async function I0(n,N0){let w0=q.project_name||"default";try{let v0=await Q.api.fetchApi("/easy-media/project/video",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_name:w0,segment_index:n.index,file_path:N0.file_path})}),r0;try{r0=await v0.json()}catch(K1){if(!(K1 instanceof SyntaxError))throw K1;throw Error(Y("projectVideoCombine.selectClipFileFailed"))}if(!v0.ok)throw Error(HX(r0,Y("projectVideoCombine.selectClipFileFailed")))}catch(v0){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.selectClipFileFailed"),detail:v0 instanceof Error?v0.message:String(v0),life:5000}),F0(w0,!1)}}function A0(n,N0){let w0=L0(n),v0=w0.includes(N0);if(v0&&w0.length===1)return;if(!v0&&w0.length>=2)return;let r0=v0?w0.filter((K1)=>K1!==N0):[...w0,N0];if(P((K1)=>({...K1,[n.id]:r0})),g(n),r0[0]!==n.file_path)a(n,r0[0])}let F0=D1.useCallback(async(n,N0=!0)=>{if(!n||c.current)return;let w0=++m.current;if(D(!0),n!==q.project_name)H(!1),K(0),f(null),P({}),J({...UX,project_name:n,auto_combine:q.auto_combine});try{let r0=await Q.api.fetchApi(`/easy-media/project?project_name=${encodeURIComponent(n)}`),K1=await r0.json();if(!r0.ok&&r0.status===404&&n==="default"){if(w0!==m.current)return;J({...UX,project_name:"default",auto_combine:q.auto_combine});return}if(!r0.ok)throw Error(HX(K1,Y("projectVideoCombine.refreshFailed")));if(w0!==m.current)return;J({...fF(K1),auto_combine:q.auto_combine})}catch(r0){if(N0&&w0===m.current)Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.refreshFailed"),detail:r0 instanceof Error?r0.message:String(r0),life:5000})}finally{if(w0===m.current)D(!1)}},[Q,q.auto_combine,q.project_name,J,Y]),u0=D1.useCallback(async()=>{try{let n=await Q.api.fetchApi("/easy-media/projects"),N0=await n.json();if(!n.ok)throw Error(HX(N0,Y("projectVideoCombine.projectListFailed")));let w0=N0&&typeof N0==="object"&&"projects"in N0&&Array.isArray(N0.projects)?N0.projects.filter((v0)=>typeof v0==="string"&&v0.length>0):[];C(w0.includes("default")?w0:["default",...w0])}catch(n){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.projectListFailed"),detail:n instanceof Error?n.message:String(n),life:5000})}},[Q,Y]);async function P0(n,N0){if(c.current)return;c.current=!0,A(N0.file_path);let w0=q.project_name||"default";try{if(!await Q.extensionManager.dialog.confirm({title:Y("projectVideoCombine.deleteClipFileTitle"),message:Y("projectVideoCombine.deleteClipFileConfirm",{file:N0.file_name})}))return;++m.current,D(!1);let r0=await Q.api.fetchApi("/easy-media/project/video",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_name:w0,segment_index:n.index,file_path:N0.file_path})}),K1;try{K1=await r0.json()}catch(l0){if(!(l0 instanceof SyntaxError))throw l0;if(r0.status===404||r0.status===405)throw Error(Y("projectVideoCombine.deleteClipFileUnavailable"));throw Error(Y("projectVideoCombine.deleteClipFileInvalidResponse",{status:r0.status}))}if(!r0.ok)throw Error(HX(K1,Y("projectVideoCombine.deleteClipFileFailed")));if(!K1||typeof K1!=="object"||!("project_name"in K1)||K1.project_name!==w0||!("clips"in K1)||!Array.isArray(K1.clips))throw Error(Y("projectVideoCombine.deleteClipFileInvalidResponse",{status:r0.status}));let x1=i.current;if((x1.project_name||"default")!==w0)return;let s1=fF(K1),z0=s1.clips.find((l0)=>l0.id===n.id),C0={...x1,updated_at:s1.updated_at,clips:x1.clips.flatMap((l0)=>{if(l0.id!==n.id)return[l0];if(!z0)return[];let j0=BX(z0),r1=[l0.file_path,...j[l0.id]??[]].map((w1)=>j0.find((e1)=>e1.file_path===w1)).find((w1)=>w1!==void 0)??j0.find((w1)=>w1.file_path===z0.file_path);return[vh({...l0,video_files:j0},r1)]})};P((l0)=>{let j0={...l0},V1=C0.clips.find((e1)=>e1.id===n.id);if(!V1)return delete j0[n.id],j0;let r1=new Set(BX(V1).map((e1)=>e1.file_path)),w1=[...new Set(l0[n.id]??[])].filter((e1)=>r1.has(e1));return j0[n.id]=r1.size>1&&w1.length===2&&w1.includes(V1.file_path)?w1:[V1.file_path],j0}),H(!1),h((l0)=>l0+1),p((l0)=>l0+1);let h0=Math.min($0.current,Math.max(0,xh(C0.clips)-1));$0.current=h0,K(h0),f(WX(C0.clips,h0)?.clip.id??null),J(C0)}catch(v0){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.deleteClipFileFailed"),detail:v0 instanceof Error?v0.message:String(v0),life:5000})}finally{c.current=!1,A(null)}}async function n0(){let n=q.project_name||"default",N0=!1;try{N0=await Q.extensionManager.dialog.confirm({title:Y("projectVideoCombine.deleteProjectTitle"),message:Y(n==="default"?"projectVideoCombine.deleteDefaultProjectConfirm":"projectVideoCombine.deleteProjectConfirm",{project:n})})}catch(w0){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.deleteProjectFailed"),detail:w0 instanceof Error?w0.message:String(w0),life:5000});return}if(!N0)return;O(!0),D(!1),++m.current;try{let w0=await Q.api.fetchApi(`/easy-media/project?project_name=${encodeURIComponent(n)}`,{method:"DELETE"}),v0=await w0.json();if(!w0.ok)throw Error(HX(v0,Y("projectVideoCombine.deleteProjectFailed")));H(!1),K(0),f(null),P({}),C((r0)=>n==="default"?r0:r0.filter((K1)=>K1!==n)),J({...UX,project_name:"default",auto_combine:q.auto_combine}),Q.extensionManager.toast.add({severity:"success",summary:Y("projectVideoCombine.deleteProjectSuccess"),detail:Y("projectVideoCombine.deleteProjectSuccessDetail",{project:n}),life:4000})}catch(w0){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.deleteProjectFailed"),detail:w0 instanceof Error?w0.message:String(w0),life:5000})}finally{O(!1)}}D1.useEffect(()=>{if(q.clips.length===0)F0(q.project_name||"default",!1)},[]),D1.useEffect(()=>{let n=()=>void F0(q.project_name||"default",!1);return Q.api.addEventListener("execution_success",n),()=>Q.api.removeEventListener("execution_success",n)},[Q.api,q.project_name,F0]),D1.useEffect(()=>{let n=(N0)=>{let w0=N0.detail,v0=w0&&typeof w0==="object"&&"project_name"in w0?String(w0.project_name):"",r0=q.project_name||"default";F0(v0||r0,!1)};return Q.api.addCustomEventListener("easy_multitrack_project_refresh",n),()=>Q.api.removeCustomEventListener("easy_multitrack_project_refresh",n)},[Q.api,q.project_name,F0]),D1.useEffect(()=>{let n=(N0)=>{let w0=N0.detail;if(!w0||typeof w0!=="object")return;let v0="node_id"in w0?String(w0.node_id):"";if(v0&&v0!==String(Z.id??""))return;let r0="project_name"in w0?String(w0.project_name):"";if(r0)F0(r0,!1)};return Q.api.addCustomEventListener("easy-media.project.selected",n),()=>Q.api.removeCustomEventListener("easy-media.project.selected",n)},[Q.api,Z,F0]),D1.useEffect(()=>{let n=Z;return n.__easyMediaSyncPlay=(N0,w0)=>{if(typeof w0==="boolean")U(w0);$0.current=0,K(0),f(WX(q.clips,0)?.clip.id??null),p((v0)=>v0+1),H(!0)},()=>{delete n.__easyMediaSyncPlay}},[q.clips,Z]),D1.useEffect(()=>{$0.current=z},[z]);let R0=D1.useCallback(()=>{if(K0.current!==null)cancelAnimationFrame(K0.current),K0.current=null;for(let n of r.current.values())n.pause()},[]);hh(()=>{R0(),K($0.current),H(!1),h((n)=>n+1)}),D1.useEffect(()=>()=>R0(),[R0]),D1.useEffect(()=>{let n=Q.extensionManager.workflow,N0=n.activeWorkflow?.key??null;return n.$subscribe((w0,v0)=>{let r0=v0.activeWorkflow?.key??null;if(N0!==null&&r0!==null&&r0!==N0)R0(),K($0.current),H(!1),h((K1)=>K1+1);N0=r0})},[Q.extensionManager.workflow,R0]),D1.useEffect(()=>{if(!W||S<=0){if(K0.current!==null)cancelAnimationFrame(K0.current);K0.current=null;return}e.current=performance.now(),H0.current=e.current,Y0.current=$0.current>=S?0:$0.current;function n(N0){let w0=Math.floor((N0-e.current)/1000*q.frame_rate),v0=Y0.current+w0;if(v0>=S)$0.current=0,Y0.current=0,e.current=N0,K(0),f(WX(q.clips,0)?.clip.id??null),p((r0)=>r0+1);else if(v0!==$0.current){if($0.current=v0,N0-H0.current>=Ge)H0.current=N0,K(v0)}K0.current=requestAnimationFrame(n)}return K0.current=requestAnimationFrame(n),()=>{if(K0.current!==null)cancelAnimationFrame(K0.current);K0.current=null}},[q.clips,q.frame_rate,W,S]),D1.useEffect(()=>{let n=s?r.current.get(s.clip.id):void 0;if(!n||!s)return;let N0=(s.clip.source_start_frame+Math.max(0,$0.current-s.start))/q.frame_rate;try{if(Math.abs(n.currentTime-N0)>0.001)n.currentTime=N0}catch(w0){console.error("[ProjectVideoCombineWidget] failed to seek preview video:",w0)}},[s?.clip.id,G0,q.frame_rate,c0,x]),D1.useEffect(()=>{if(W)return;let n=s?r.current.get(s.clip.id):void 0;if(!n||!s)return;let N0=(s.clip.source_start_frame+Math.max(0,z-s.start))/q.frame_rate;try{if(Math.abs(n.currentTime-N0)>0.001)n.currentTime=N0}catch(w0){console.error("[ProjectVideoCombineWidget] failed to seek paused preview video:",w0)}},[s?.clip.id,G0,z,q.frame_rate,c0,W]),D1.useEffect(()=>{let n=J0?r.current.get(J0.id):void 0;if(!n||!J0)return;let N0=J0.source_start_frame/q.frame_rate;try{if(Math.abs(n.currentTime-N0)>0.001)n.currentTime=N0}catch(w0){console.error("[ProjectVideoCombineWidget] failed to preload the next preview video:",w0)}},[q.frame_rate,J0?.id,B0]),D1.useEffect(()=>{let n=s?r.current.get(s.clip.id):void 0;if(!n||!s)return;for(let[N0,w0]of r.current)if(N0!==s.clip.id)w0.pause();if(W)n.play().catch((N0)=>{console.error("[ProjectVideoCombineWidget] failed to play preview video:",N0),H(!1)});else n.pause()},[s?.clip.id,G0,c0,W,x]);function Y1(n){let N0=Math.max(0,Math.min(S,Math.round(n)));if($0.current=N0,W)Y0.current=N0>=S?0:N0,e.current=performance.now();K(N0);let w0=WX(q.clips,Math.min(N0,Math.max(0,S-1)));f(w0?.clip.id??null)}function z1(){H((n)=>{if(n)K($0.current);return!n})}async function a0(){let n=q.project_name||"default";try{let N0=await Q.api.getQueue();if(N0.Running.length>0||N0.Pending.length>0)throw Error(Y("projectVideoCombine.queueBusy"));k(!0);let w0=await Q.graphToPrompt(),v0=Be(Z),r0=w0.output,K1=He(Z,w0.workflow,r0),x1=Object.fromEntries(Object.entries(r0).filter(([s1])=>v0.has(s1)).map(([s1,z0])=>{let C0=vF(z0.inputs??{},v0,K1),h0=C0===lW?{}:C0;if(s1===String(Z.id??""))h0.project_name=n,h0.project_data=JSON.stringify({...q,auto_combine:!0});return[s1,{...z0,inputs:h0}]}));if(Object.keys(x1).length<2)throw Error(Y("projectVideoCombine.connectSaveNode"));await Q.api.queuePrompt(0,{...w0,output:x1}),Q.extensionManager.toast.add({severity:"info",summary:Y("projectVideoCombine.combineQueued"),detail:Y("projectVideoCombine.combineQueuedDetail",{project:n}),life:4000})}catch(N0){Q.extensionManager.toast.add({severity:"error",summary:Y("projectVideoCombine.combineFailed"),detail:N0 instanceof Error?N0.message:String(N0),life:6000})}finally{k(!1)}}function C1(n,N0){return T(H1,{children:[G(B1,{asChild:!0,children:G("span",{className:"inline-flex shrink-0",children:N0})}),G(W1,{children:n})]})}let g1=Math.max(1,o-q5-x2),b1=q5+Math.min(z,S)/Math.max(S,1)*g1;return G(P6.Provider,{value:X,children:G(a1,{children:T("div",{className:"flex h-full min-h-[520px] w-full flex-col overflow-hidden rounded-md border border-border bg-background text-foreground",children:[T("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-border px-2",children:[T("div",{className:"flex items-center gap-1",children:[T(y8,{disabled:I!==null,value:q.project_name||"default",onOpenChange:(n)=>{if(n)u0()},onValueChange:(n)=>void F0(n),children:[G(P8,{className:"h-7 w-32 text-xs","aria-label":Y("projectVideoCombine.selectProject"),children:G(W6,{})}),G(R8,{children:W0.map((n)=>G(i5,{value:n,children:n},n))})]}),C1(Y("projectVideoCombine.deleteProject"),G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:N||M||I!==null,"aria-label":Y("projectVideoCombine.deleteProject"),onClick:()=>void n0(),children:N?G(X6,{className:"size-3.5 animate-spin"}):G(N5,{className:"size-3.5"})}))]}),T("div",{className:"flex items-center gap-2",children:[C1(Y("projectVideoCombine.refresh"),G(k0,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",disabled:M||I!==null,"aria-label":Y("projectVideoCombine.refresh"),onClick:()=>void F0(q.project_name||"default"),children:M?G(X6,{className:"size-3.5 animate-spin"}):G(SY,{className:"size-3.5"})})),T("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[G(UJ,{checked:q.auto_combine,onCheckedChange:(n)=>J({...q,auto_combine:n===!0})}),Y("projectVideoCombine.autoCombine")]}),T(k0,{type:"button",size:"sm",className:"h-7 gap-1.5 text-xs",disabled:b||I!==null||q.clips.length===0,onClick:()=>void a0(),children:[b?G(X6,{className:"size-3.5 animate-spin"}):G(P4,{className:"size-3.5"}),Y("projectVideoCombine.combine")]})]})]}),G("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-black p-3",children:c0?G(jh,{app:Q,sourceUrl:D0[0],outputUrl:D0[1],pausePlaybackNonce:t,parentPlayback:{isPlaying:W,currentTime:(s.clip.source_start_frame+z-s.start)/q.frame_rate,startTime:s.clip.source_start_frame/q.frame_rate,endTime:s.clip.source_end_frame/q.frame_rate,muted:B,onPause:()=>{K($0.current),H(!1)},onSeek:(n)=>Y1(s.start+n*q.frame_rate-s.clip.source_start_frame)}},`${s.clip.id}:${D0.join("|")}`):G0?[{clip:s.clip,url:G0,visible:!0},...J0&&B0?[{clip:J0,url:B0,visible:!1}]:[]].map(({clip:n,url:N0,visible:w0})=>G("video",{ref:(v0)=>{if(v0)r.current.set(n.id,v0);else r.current.delete(n.id)},src:N0,preload:"auto",playsInline:!0,muted:!w0||B,"aria-hidden":!w0,className:w0?"h-full max-h-full w-full object-contain":"pointer-events-none absolute left-0 top-0 h-px w-px opacity-0"},n.id)):G("div",{className:"text-xs text-muted-foreground",children:Y("projectVideoCombine.emptyPreview")})}),T("div",{className:"grid h-9 shrink-0 grid-cols-[1fr_auto_1fr] items-center border-y border-border px-1 text-[10px]",children:[G("div",{className:"flex items-center",children:C1(B?Y("projectVideoCombine.unmutePreview"):Y("projectVideoCombine.mutePreview"),G(k0,{type:"button",variant:"ghost",size:"icon",className:xF,"aria-label":B?Y("projectVideoCombine.unmutePreview"):Y("projectVideoCombine.mutePreview"),"aria-pressed":B,onClick:()=>U((n)=>!n),children:B?G(EJ,{}):G($4,{})}))}),T("div",{className:"flex items-center gap-2 text-muted-foreground",children:[G("span",{className:"w-16 text-right tabular-nums text-gradient",children:M6(z,{frameRate:q.frame_rate,showFrames:!0})}),G(k0,{type:"button",variant:"secondary",size:"icon",className:`${xF} rounded-full`,disabled:S===0,"aria-label":W?Y("multitrack.pause"):Y("multitrack.play"),onClick:z1,children:W?G(O7,{}):G(P4,{})}),G("span",{className:"w-16 tabular-nums",children:M6(S,{frameRate:q.frame_rate,showFrames:!0})})]}),T("div",{className:"ml-auto flex items-center gap-1",children:[C1(F?Y("multitrack.showTimeline"):Y("multitrack.hideTimeline"),G(k0,{type:"button",variant:"ghost",size:"icon",className:xF,"aria-label":F?Y("multitrack.showTimeline"):Y("multitrack.hideTimeline"),onClick:()=>V((n)=>!n),children:F?G(Zz,{}):G(qz,{})})),G(JJ,{className:"size-3.5 text-muted-foreground"}),G(O8,{min:1,max:6,step:0.25,value:[_],onValueChange:([n])=>L(n),className:"h-3 w-12","aria-label":Y("multitrack.timelineZoom")})]})]}),G("div",{ref:E,className:`no-scrollbar h-[104px] shrink-0 overflow-x-auto overflow-y-hidden bg-muted/20 ${F?"hidden":""}`,"aria-hidden":F,children:T("div",{style:{width:o,minWidth:"100%"},children:[G(Jz,{totalLength:S,frameRate:q.frame_rate,width:o,canvasScale:u,currentTime:z,taskMarkers:[],selectedTaskMarkerId:null,onSeek:Y1,onSelectTaskMarker:()=>{},onMoveTaskMarker:()=>{},onDeleteTaskMarker:()=>{}}),T("div",{className:"relative h-20",style:{width:o},children:[G("div",{className:"absolute top-2 flex h-14 overflow-hidden rounded-sm border border-border bg-muted/40",style:{left:q5,width:g1},children:q.clips.filter((n)=>n.enabled!==!1).map((n)=>{let w0=`h-full min-w-0 shrink-0 rounded-none border-r border-border px-2 ${y===n.id?"bg-primary/20 ring-1 ring-inset ring-primary":"bg-secondary/40 hover:bg-secondary/60"}`,v0={width:`${iW(n)/Math.max(S,1)*100}%`},r0=T("div",{className:"flex min-w-0 flex-col items-center leading-tight",children:[G("span",{className:"truncate text-[11px] font-medium",children:Y("projectVideoCombine.clipLabel",{number:n.index+1})}),G("span",{className:"truncate text-[9px] text-muted-foreground",children:Y("projectVideoCombine.clipContinuity",{mode:Y(n.continuity_mode==="shot"?"projectVideoCombine.continuityShot":n.continuity_mode==="context_swap"?"projectVideoCombine.continuityContextSwap":"projectVideoCombine.continuityContext")})})]}),K1=L0(n);return T(t1,{onOpenChange:(x1)=>{if(x1)g(n)},children:[G(b5,{asChild:!0,children:T(k0,{type:"button",variant:"ghost",className:`${w0} relative justify-center`,style:v0,"aria-label":Y("projectVideoCombine.selectClipFiles",{number:n.index+1}),children:[r0,T("span",{className:"absolute right-2 flex items-center gap-0.5 text-[9px] text-muted-foreground",children:[K1.length>1?K1.length:null,G(j4,{className:"size-3"})]})]})}),T(o1,{className:"w-64 p-1",align:"center",children:[G("div",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:Y("projectVideoCombine.selectClipFilesHint")}),BX(n).map((x1)=>{let s1=K1.includes(x1.file_path),z0=I!==null||!s1&&K1.length>=2;return T("div",{className:"flex items-center gap-1",children:[T(k0,{type:"button",variant:"ghost",role:"checkbox","aria-checked":s1,disabled:z0,className:b0("h-8 min-w-0 flex-1 justify-start gap-2 px-2 text-xs",z0&&"opacity-50"),onClick:()=>A0(n,x1.file_path),children:[G("span",{className:b0("flex size-4 shrink-0 items-center justify-center rounded-sm border border-border",s1&&"border-primary bg-primary text-primary-foreground"),children:s1?G(j9,{className:"size-3"}):null}),G("span",{className:"truncate",children:x1.file_name})]}),G(k0,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-destructive hover:text-destructive",disabled:I!==null||N||M,"aria-label":Y("projectVideoCombine.deleteClipFile",{file:x1.file_name}),title:Y("projectVideoCombine.deleteClipFile",{file:x1.file_name}),onPointerDown:(C0)=>C0.stopPropagation(),onKeyDown:(C0)=>C0.stopPropagation(),onClick:(C0)=>{C0.preventDefault(),C0.stopPropagation(),P0(n,x1)},children:I===x1.file_path?G(X6,{className:"size-3.5 animate-spin"}):G(N5,{className:"size-3.5"})})]},x1.file_path)})]})]},n.id)})}),G("div",{className:"pointer-events-none absolute top-0 h-20 w-px bg-destructive",style:{left:b1}})]})]})})]})})})}export{Mp as TimelineWidget,Fe as SamplingPreviewWidget,Ke as PromptEnhancerAccountWidget,Le as ProjectVideoCombineWidget,mt as MultiTrackWidget,pt as MultiImagesLoaderWidget,qe as CompareVideoWidget};
|