import{r as f,j as a,c as ue,a as ee,u as je,D as X,d as _t,L as pl,g as nn,b as ml,e as Ut,s as gl,f as Q,h as yl,i as xl,B as be,k as vl,l as bl,m as Sl,n as wl}from"./index-Daq5M5bC.js";import{c as Oe,P as G,a as O,b as Qe,u as Je,d as Tl,D as or,e as jl}from"./index-B33Yn3RC.js";import{c as $t,R as ar,I as lr,u as Yn,a as Xn,L,b as Zn,d as Qn,C as Cl,e as zt,f as cr,g as ur,A as Jn,h as dr,i as Pl,j as Al,k as Rl,F as Nl,l as El,t as kl,S as Ml,m as Dl,n as Vl,o as $s,T as Il,p as Ll,U as Ol,s as sn}from"./user-status-C4MB9Ruf.js";import{z as Fl,T as Bl}from"./index-CTnVPfHU.js";import{S as _l,Z as hr,A as ot,a as at,u as fr,b as Ul,B as $l,f as zl,c as Kl,P as Gl,C as ql,T as Wl}from"./usage-format-CNuTCnK-.js";import{C as ke,a as Me,b as De,c as We,d as Ve,S as Hl,L as Yl}from"./logo-NAd285bv.js";import{S as se,a as ie,b as re,c as oe,d as $,G as Xl,e as pr,C as vn,f as mr,g as Zl,B as Ql}from"./SubtitleDisplay-ChT0YnnH.js";import{R as Jl}from"./index-ChHm2POI.js";import{s as ec}from"./orchestrator-BOSZpYE8.js";var Kt="Tabs",[tc,eg]=Oe(Kt,[$t]),gr=$t(),[nc,es]=tc(Kt),yr=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:i,defaultValue:o,orientation:r="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=Yn(l),[h,p]=Je({prop:s,onChange:i,defaultProp:o??"",caller:Kt});return a.jsx(nc,{scope:n,baseId:Xn(),value:h,onValueChange:p,orientation:r,dir:u,activationMode:c,children:a.jsx(G.div,{dir:u,"data-orientation":r,...d,ref:t})})});yr.displayName=Kt;var xr="TabsList",vr=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...i}=e,o=es(xr,n),r=gr(n);return a.jsx(ar,{asChild:!0,...r,orientation:o.orientation,dir:o.dir,loop:s,children:a.jsx(G.div,{role:"tablist","aria-orientation":o.orientation,...i,ref:t})})});vr.displayName=xr;var br="TabsTrigger",Sr=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:i=!1,...o}=e,r=es(br,n),l=gr(n),c=jr(r.baseId,s),d=Cr(r.baseId,s),u=s===r.value;return a.jsx(lr,{asChild:!0,...l,focusable:!i,active:u,children:a.jsx(G.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...o,ref:t,onMouseDown:O(e.onMouseDown,h=>{!i&&h.button===0&&h.ctrlKey===!1?r.onValueChange(s):h.preventDefault()}),onKeyDown:O(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&r.onValueChange(s)}),onFocus:O(e.onFocus,()=>{const h=r.activationMode!=="manual";!u&&!i&&h&&r.onValueChange(s)})})})});Sr.displayName=br;var wr="TabsContent",Tr=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:i,children:o,...r}=e,l=es(wr,n),c=jr(l.baseId,s),d=Cr(l.baseId,s),u=s===l.value,h=f.useRef(u);return f.useEffect(()=>{const p=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(p)},[]),a.jsx(Qe,{present:i||u,children:({present:p})=>a.jsx(G.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:d,tabIndex:0,...r,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:p&&o})})});Tr.displayName=wr;function jr(e,t){return`${e}-trigger-${t}`}function Cr(e,t){return`${e}-content-${t}`}var sc=yr,Pr=vr,Ar=Sr,Rr=Tr;const ic=sc,Nr=f.forwardRef(({className:e,...t},n)=>a.jsx(Pr,{ref:n,className:ue("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Nr.displayName=Pr.displayName;const _e=f.forwardRef(({className:e,...t},n)=>a.jsx(Ar,{ref:n,className:ue("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 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-sm",e),...t}));_e.displayName=Ar.displayName;const Ue=f.forwardRef(({className:e,...t},n)=>a.jsx(Rr,{ref:n,className:ue("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ue.displayName=Rr.displayName;/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rc=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],zs=ee("bot",rc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oc=[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]],ac=ee("captions",oc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],cc=ee("circle-plus",lc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const uc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],dc=ee("globe",uc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const hc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],fc=ee("info",hc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pc=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Ks=ee("languages",pc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mc=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],gc=ee("lock",mc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const yc=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],bn=ee("palette",yc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xc=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],vc=ee("server",xc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const bc=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Sc=ee("trash-2",bc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wc=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Er=ee("triangle-alert",wc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Tc=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],jc=ee("type",Tc);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Cc=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Pc=ee("volume-2",Cc),rn=pl,Ac=ml;function Rc(){const{t:e,i18n:t}=je(),[n,s]=f.useState(X.general.appLanguage),[i,o]=f.useState(X.general.nativeLanguage),[r,l]=f.useState(X.general.learnLanguage),[c,d]=f.useState(X.general.languageLevel),[u,h]=f.useState(X.general.autoPlayWordAudio),[p,m]=f.useState(!1),[v,g]=f.useState(!1),x=f.useCallback(_t(b=>{m(!0),gl(b).then(()=>{console.debug("Save General Settings success:",b)}).catch(j=>{console.error("Failed to save settings:",j)}).finally(()=>{m(!1)})},1e3),[]);f.useEffect(()=>{(async()=>{try{const j=await Ut();s(j.general.appLanguage),o(j.general.nativeLanguage),l(j.general.learnLanguage),d(j.general.languageLevel),h(j.general.autoPlayWordAudio),g(!0)}catch(j){console.error("Failed to load general settings:",j),g(!0)}})()},[]),f.useEffect(()=>{v?x({appLanguage:n,nativeLanguage:i,learnLanguage:r,languageLevel:c,autoPlayWordAudio:u}):console.debug("Skip auto save - not initialized")},[n,i,r,c,u,x,v]);const y=b=>{s(b);const j=b.toLowerCase(),N=j==="zh-cn"||j==="zh"?"zh-CN":j==="zh-tw"?"zh-TW":j;t.changeLanguage(N).catch(()=>{})},w=b=>{o(b)},S=b=>{l(b)},C=b=>{d(b)};return a.jsxs(ke,{className:"border-2 border-primary/10 gradient-border card-glow",children:[a.jsxs(Me,{children:[a.jsxs(De,{className:"flex items-center gap-2",children:[a.jsx(dc,{className:"h-5 w-5 text-primary"}),a.jsx("span",{className:"gradient-text",children:e("options.general")})]}),a.jsx(We,{children:e("options.customizeTip")})]}),a.jsxs(Ve,{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"app-language",children:e("general.appLanguage")}),a.jsxs(se,{value:n,onValueChange:y,children:[a.jsx(ie,{id:"app-language",className:"w-full relative z-10",children:a.jsx(re,{placeholder:e("general.selectAppLanguage")})}),a.jsx(oe,{className:"z-[999]",children:rn.map(b=>a.jsxs($,{value:b.value,children:[a.jsx("span",{className:"mr-2",children:nn(b.value)}),b.label]},b.value))})]})]}),a.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:"native-language",className:"flex items-center gap-2",children:[a.jsx(Ks,{className:"h-4 w-4 text-primary"}),e("general.nativeLanguage")]}),a.jsxs(se,{value:i,onValueChange:w,children:[a.jsx(ie,{id:"native-language",className:"relative z-10",children:a.jsx(re,{placeholder:e("general.selectNativeLanguage")})}),a.jsx(oe,{className:"z-[999]",children:rn.map(b=>a.jsxs($,{value:b.value,children:[a.jsx("span",{className:"mr-2",children:nn(b.value)}),b.label]},b.value))})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:"learn-language",className:"flex items-center gap-2",children:[a.jsx(Ks,{className:"h-4 w-4 text-primary"}),e("general.learningLanguage")]}),a.jsxs(se,{value:r,onValueChange:S,children:[a.jsx(ie,{id:"learn-language",className:"relative z-10",children:a.jsx(re,{placeholder:e("general.selectLearningLanguage")})}),a.jsx(oe,{className:"z-[999]",children:rn.map(b=>a.jsxs($,{value:b.value,children:[a.jsx("span",{className:"mr-2",children:nn(b.value)}),b.label]},b.value))})]})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xl,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("general.languageProficiency")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"language-level",className:"flex items-center gap-2",children:e("general.currentLevel")}),a.jsxs(se,{value:c,onValueChange:C,children:[a.jsx(ie,{id:"language-level",className:"relative z-10",children:a.jsx(re,{placeholder:e("general.selectCurrentLevel")})}),a.jsx(oe,{className:"z-[999]",children:Ac.map(b=>a.jsx($,{value:b.value,children:b.label},b.value))})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("general.selectCurrentLevel")})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Pc,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("general.pronunciation","Pronunciation")})]}),a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(L,{htmlFor:"auto-play-word-audio",children:e("general.autoPlayWordAudio","Auto-play pronunciation")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("general.autoPlayWordAudioDesc","Automatically play pronunciation audio when opening the word panel (if available).")})]}),a.jsx(_l,{id:"auto-play-word-audio",checked:u,onCheckedChange:h})]})]}),p&&a.jsx("div",{className:"text-xs text-muted-foreground text-right animate-pulse",children:e("general.saving")})]})]})}var kr=["PageUp","PageDown"],Mr=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Dr={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},et="Slider",[Sn,Nc,Ec]=Tl(et),[Vr,tg]=Oe(et,[Ec]),[kc,Gt]=Vr(et),Ir=f.forwardRef((e,t)=>{const{name:n,min:s=0,max:i=100,step:o=1,orientation:r="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[s],value:u,onValueChange:h=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:v,...g}=e,x=f.useRef(new Set),y=f.useRef(0),S=r==="horizontal"?Mc:Dc,[C=[],b]=Je({prop:u,defaultProp:d,onChange:M=>{var Y;(Y=[...x.current][y.current])==null||Y.focus(),h(M)}}),j=f.useRef(C);function N(M){const W=Fc(C,M);E(M,W)}function P(M){E(M,y.current)}function D(){const M=j.current[y.current];C[y.current]!==M&&p(C)}function E(M,W,{commit:Y}={commit:!1}){const ye=$c(o),Fe=zc(Math.round((M-s)/o)*o+s,ye),le=pr(Fe,[s,i]);b((V=[])=>{const K=Lc(V,le,W);if(Uc(K,c*o)){y.current=K.indexOf(le);const T=String(K)!==String(V);return T&&Y&&p(K),T?K:V}else return V})}return a.jsx(kc,{scope:e.__scopeSlider,name:n,disabled:l,min:s,max:i,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:r,form:v,children:a.jsx(Sn.Provider,{scope:e.__scopeSlider,children:a.jsx(Sn.Slot,{scope:e.__scopeSlider,children:a.jsx(S,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:t,onPointerDown:O(g.onPointerDown,()=>{l||(j.current=C)}),min:s,max:i,inverted:m,onSlideStart:l?void 0:N,onSlideMove:l?void 0:P,onSlideEnd:l?void 0:D,onHomeKeyDown:()=>!l&&E(s,0,{commit:!0}),onEndKeyDown:()=>!l&&E(i,C.length-1,{commit:!0}),onStepKeyDown:({event:M,direction:W})=>{if(!l){const Fe=kr.includes(M.key)||M.shiftKey&&Mr.includes(M.key)?10:1,le=y.current,V=C[le],K=o*Fe*W;E(V+K,le,{commit:!0})}}})})})})});Ir.displayName=et;var[Lr,Or]=Vr(et,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Mc=f.forwardRef((e,t)=>{const{min:n,max:s,dir:i,inverted:o,onSlideStart:r,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,p]=f.useState(null),m=Q(t,S=>p(S)),v=f.useRef(void 0),g=Yn(i),x=g==="ltr",y=x&&!o||!x&&o;function w(S){const C=v.current||h.getBoundingClientRect(),b=[0,C.width],N=ts(b,y?[n,s]:[s,n]);return v.current=C,N(S-C.left)}return a.jsx(Lr,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:a.jsx(Fr,{dir:g,"data-orientation":"horizontal",...u,ref:m,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:S=>{const C=w(S.clientX);r==null||r(C)},onSlideMove:S=>{const C=w(S.clientX);l==null||l(C)},onSlideEnd:()=>{v.current=void 0,c==null||c()},onStepKeyDown:S=>{const b=Dr[y?"from-left":"from-right"].includes(S.key);d==null||d({event:S,direction:b?-1:1})}})})}),Dc=f.forwardRef((e,t)=>{const{min:n,max:s,inverted:i,onSlideStart:o,onSlideMove:r,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=f.useRef(null),h=Q(t,u),p=f.useRef(void 0),m=!i;function v(g){const x=p.current||u.current.getBoundingClientRect(),y=[0,x.height],S=ts(y,m?[s,n]:[n,s]);return p.current=x,S(g-x.top)}return a.jsx(Lr,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:a.jsx(Fr,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const x=v(g.clientY);o==null||o(x)},onSlideMove:g=>{const x=v(g.clientY);r==null||r(x)},onSlideEnd:()=>{p.current=void 0,l==null||l()},onStepKeyDown:g=>{const y=Dr[m?"from-bottom":"from-top"].includes(g.key);c==null||c({event:g,direction:y?-1:1})}})})}),Fr=f.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:i,onSlideEnd:o,onHomeKeyDown:r,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=Gt(et,n);return a.jsx(G.span,{...d,ref:t,onKeyDown:O(e.onKeyDown,h=>{h.key==="Home"?(r(h),h.preventDefault()):h.key==="End"?(l(h),h.preventDefault()):kr.concat(Mr).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:O(e.onPointerDown,h=>{const p=h.target;p.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(p)?p.focus():s(h)}),onPointerMove:O(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&i(h)}),onPointerUp:O(e.onPointerUp,h=>{const p=h.target;p.hasPointerCapture(h.pointerId)&&(p.releasePointerCapture(h.pointerId),o(h))})})}),Br="SliderTrack",_r=f.forwardRef((e,t)=>{const{__scopeSlider:n,...s}=e,i=Gt(Br,n);return a.jsx(G.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...s,ref:t})});_r.displayName=Br;var wn="SliderRange",Ur=f.forwardRef((e,t)=>{const{__scopeSlider:n,...s}=e,i=Gt(wn,n),o=Or(wn,n),r=f.useRef(null),l=Q(t,r),c=i.values.length,d=i.values.map(p=>Kr(p,i.min,i.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return a.jsx(G.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...s,ref:l,style:{...e.style,[o.startEdge]:u+"%",[o.endEdge]:h+"%"}})});Ur.displayName=wn;var Tn="SliderThumb",$r=f.forwardRef((e,t)=>{const n=Nc(e.__scopeSlider),[s,i]=f.useState(null),o=Q(t,l=>i(l)),r=f.useMemo(()=>s?n().findIndex(l=>l.ref.current===s):-1,[n,s]);return a.jsx(Vc,{...e,ref:o,index:r})}),Vc=f.forwardRef((e,t)=>{const{__scopeSlider:n,index:s,name:i,...o}=e,r=Gt(Tn,n),l=Or(Tn,n),[c,d]=f.useState(null),u=Q(t,w=>d(w)),h=c?r.form||!!c.closest("form"):!0,p=Zn(c),m=r.values[s],v=m===void 0?0:Kr(m,r.min,r.max),g=Oc(s,r.values.length),x=p==null?void 0:p[l.size],y=x?Bc(x,v,l.direction):0;return f.useEffect(()=>{if(c)return r.thumbs.add(c),()=>{r.thumbs.delete(c)}},[c,r.thumbs]),a.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${v}% + ${y}px)`},children:[a.jsx(Sn.ItemSlot,{scope:e.__scopeSlider,children:a.jsx(G.span,{role:"slider","aria-label":e["aria-label"]||g,"aria-valuemin":r.min,"aria-valuenow":m,"aria-valuemax":r.max,"aria-orientation":r.orientation,"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,tabIndex:r.disabled?void 0:0,...o,ref:u,style:m===void 0?{display:"none"}:e.style,onFocus:O(e.onFocus,()=>{r.valueIndexToChangeRef.current=s})})}),h&&a.jsx(zr,{name:i??(r.name?r.name+(r.values.length>1?"[]":""):void 0),form:r.form,value:m},s)]})});$r.displayName=Tn;var Ic="RadioBubbleInput",zr=f.forwardRef(({__scopeSlider:e,value:t,...n},s)=>{const i=f.useRef(null),o=Q(i,s),r=Qn(t);return f.useEffect(()=>{const l=i.current;if(!l)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(r!==t&&u){const h=new Event("input",{bubbles:!0});u.call(l,t),l.dispatchEvent(h)}},[r,t]),a.jsx(G.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});zr.displayName=Ic;function Lc(e=[],t,n){const s=[...e];return s[n]=t,s.sort((i,o)=>i-o)}function Kr(e,t,n){const o=100/(n-t)*(e-t);return pr(o,[0,100])}function Oc(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Fc(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),s=Math.min(...n);return n.indexOf(s)}function Bc(e,t,n){const s=e/2,o=ts([0,50],[0,s]);return(s-o(t)*n)*n}function _c(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Uc(e,t){if(t>0){const n=_c(e);return Math.min(...n)>=t}return!0}function ts(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function $c(e){return(String(e).split(".")[1]||"").length}function zc(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Gr=Ir,Kc=_r,Gc=Ur,qc=$r;const jn=f.forwardRef(({className:e,...t},n)=>a.jsxs(Gr,{ref:n,className:ue("relative flex w-full touch-none select-none items-center",e),...t,children:[a.jsx(Kc,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:a.jsx(Gc,{className:"absolute h-full bg-primary"})}),a.jsx(qc,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));jn.displayName=Gr.displayName;var ns="Radio",[Wc,qr]=Oe(ns),[Hc,Yc]=Wc(ns),Wr=f.forwardRef((e,t)=>{const{__scopeRadio:n,name:s,checked:i=!1,required:o,disabled:r,value:l="on",onCheck:c,form:d,...u}=e,[h,p]=f.useState(null),m=Q(t,x=>p(x)),v=f.useRef(!1),g=h?d||!!h.closest("form"):!0;return a.jsxs(Hc,{scope:n,checked:i,disabled:r,children:[a.jsx(G.button,{type:"button",role:"radio","aria-checked":i,"data-state":Zr(i),"data-disabled":r?"":void 0,disabled:r,value:l,...u,ref:m,onClick:O(e.onClick,x=>{i||c==null||c(),g&&(v.current=x.isPropagationStopped(),v.current||x.stopPropagation())})}),g&&a.jsx(Xr,{control:h,bubbles:!v.current,name:s,value:l,checked:i,required:o,disabled:r,form:d,style:{transform:"translateX(-100%)"}})]})});Wr.displayName=ns;var Hr="RadioIndicator",Yr=f.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:s,...i}=e,o=Yc(Hr,n);return a.jsx(Qe,{present:s||o.checked,children:a.jsx(G.span,{"data-state":Zr(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t})})});Yr.displayName=Hr;var Xc="RadioBubbleInput",Xr=f.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:s=!0,...i},o)=>{const r=f.useRef(null),l=Q(r,o),c=Qn(n),d=Zn(t);return f.useEffect(()=>{const u=r.current;if(!u)return;const h=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==n&&m){const v=new Event("click",{bubbles:s});m.call(u,n),u.dispatchEvent(v)}},[c,n,s]),a.jsx(G.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:l,style:{...i.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Xr.displayName=Xc;function Zr(e){return e?"checked":"unchecked"}var Zc=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],qt="RadioGroup",[Qc,ng]=Oe(qt,[$t,qr]),Qr=$t(),Jr=qr(),[Jc,eu]=Qc(qt),eo=f.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:s,defaultValue:i,value:o,required:r=!1,disabled:l=!1,orientation:c,dir:d,loop:u=!0,onValueChange:h,...p}=e,m=Qr(n),v=Yn(d),[g,x]=Je({prop:o,defaultProp:i??null,onChange:h,caller:qt});return a.jsx(Jc,{scope:n,name:s,required:r,disabled:l,value:g,onValueChange:x,children:a.jsx(ar,{asChild:!0,...m,orientation:c,dir:v,loop:u,children:a.jsx(G.div,{role:"radiogroup","aria-required":r,"aria-orientation":c,"data-disabled":l?"":void 0,dir:v,...p,ref:t})})})});eo.displayName=qt;var to="RadioGroupItem",no=f.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:s,...i}=e,o=eu(to,n),r=o.disabled||s,l=Qr(n),c=Jr(n),d=f.useRef(null),u=Q(t,d),h=o.value===i.value,p=f.useRef(!1);return f.useEffect(()=>{const m=g=>{Zc.includes(g.key)&&(p.current=!0)},v=()=>p.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",v)}},[]),a.jsx(lr,{asChild:!0,...l,focusable:!r,active:h,children:a.jsx(Wr,{disabled:r,required:o.required,checked:h,...c,...i,name:o.name,ref:u,onCheck:()=>o.onValueChange(i.value),onKeyDown:O(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:O(i.onFocus,()=>{var m;p.current&&((m=d.current)==null||m.click())})})})});no.displayName=to;var tu="RadioGroupIndicator",so=f.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...s}=e,i=Jr(n);return a.jsx(Yr,{...i,...s,ref:t})});so.displayName=tu;var io=eo,ro=no,nu=so;const oo=f.forwardRef(({className:e,...t},n)=>a.jsx(io,{className:ue("grid gap-2",e),...t,ref:n}));oo.displayName=io.displayName;const Cn=f.forwardRef(({className:e,...t},n)=>a.jsx(ro,{ref:n,className:ue("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:a.jsx(nu,{className:"flex items-center justify-center",children:a.jsx(Cl,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Cn.displayName=ro.displayName;var su=Symbol("radix.slottable");function iu(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=su,t}var[Wt,sg]=Oe("Tooltip",[zt]),Ht=zt(),ao="TooltipProvider",ru=700,Pn="tooltip.open",[ou,ss]=Wt(ao),lo=e=>{const{__scopeTooltip:t,delayDuration:n=ru,skipDelayDuration:s=300,disableHoverableContent:i=!1,children:o}=e,r=f.useRef(!0),l=f.useRef(!1),c=f.useRef(0);return f.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),a.jsx(ou,{scope:t,isOpenDelayedRef:r,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(c.current),r.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>r.current=!0,s)},[s]),isPointerInTransitRef:l,onPointerInTransitChange:f.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:o})};lo.displayName=ao;var ft="Tooltip",[au,Yt]=Wt(ft),co=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:i,onOpenChange:o,disableHoverableContent:r,delayDuration:l}=e,c=ss(ft,e.__scopeTooltip),d=Ht(t),[u,h]=f.useState(null),p=Xn(),m=f.useRef(0),v=r??c.disableHoverableContent,g=l??c.delayDuration,x=f.useRef(!1),[y,w]=Je({prop:s,defaultProp:i??!1,onChange:N=>{N?(c.onOpen(),document.dispatchEvent(new CustomEvent(Pn))):c.onClose(),o==null||o(N)},caller:ft}),S=f.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),C=f.useCallback(()=>{window.clearTimeout(m.current),m.current=0,x.current=!1,w(!0)},[w]),b=f.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),j=f.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{x.current=!0,w(!0),m.current=0},g)},[g,w]);return f.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),a.jsx(ur,{...d,children:a.jsx(au,{scope:t,contentId:p,open:y,stateAttribute:S,trigger:u,onTriggerChange:h,onTriggerEnter:f.useCallback(()=>{c.isOpenDelayedRef.current?j():C()},[c.isOpenDelayedRef,j,C]),onTriggerLeave:f.useCallback(()=>{v?b():(window.clearTimeout(m.current),m.current=0)},[b,v]),onOpen:C,onClose:b,disableHoverableContent:v,children:n})})};co.displayName=ft;var An="TooltipTrigger",uo=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,i=Yt(An,n),o=ss(An,n),r=Ht(n),l=f.useRef(null),c=Q(t,l,i.onTriggerChange),d=f.useRef(!1),u=f.useRef(!1),h=f.useCallback(()=>d.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),a.jsx(Jn,{asChild:!0,...r,children:a.jsx(G.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...s,ref:c,onPointerMove:O(e.onPointerMove,p=>{p.pointerType!=="touch"&&!u.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:O(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:O(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:O(e.onBlur,i.onClose),onClick:O(e.onClick,i.onClose)})})});uo.displayName=An;var lu="TooltipPortal",[ig,cu]=Wt(lu,{forceMount:void 0}),He="TooltipContent",ho=f.forwardRef((e,t)=>{const n=cu(He,e.__scopeTooltip),{forceMount:s=n.forceMount,side:i="top",...o}=e,r=Yt(He,e.__scopeTooltip);return a.jsx(Qe,{present:s||r.open,children:r.disableHoverableContent?a.jsx(fo,{side:i,...o,ref:t}):a.jsx(uu,{side:i,...o,ref:t})})}),uu=f.forwardRef((e,t)=>{const n=Yt(He,e.__scopeTooltip),s=ss(He,e.__scopeTooltip),i=f.useRef(null),o=Q(t,i),[r,l]=f.useState(null),{trigger:c,onClose:d}=n,u=i.current,{onPointerInTransitChange:h}=s,p=f.useCallback(()=>{l(null),h(!1)},[h]),m=f.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=mu(y,x.getBoundingClientRect()),S=gu(y,w),C=yu(g.getBoundingClientRect()),b=vu([...S,...C]);l(b),h(!0)},[h]);return f.useEffect(()=>()=>p(),[p]),f.useEffect(()=>{if(c&&u){const v=x=>m(x,u),g=x=>m(x,c);return c.addEventListener("pointerleave",v),u.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",g)}}},[c,u,m,p]),f.useEffect(()=>{if(r){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(c==null?void 0:c.contains(x))||(u==null?void 0:u.contains(x)),S=!xu(y,r);w?p():S&&(p(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,u,r,d,p]),a.jsx(fo,{...e,ref:o})}),[du,hu]=Wt(ft,{isInside:!1}),fu=iu("TooltipContent"),fo=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:r,...l}=e,c=Yt(He,n),d=Ht(n),{onClose:u}=c;return f.useEffect(()=>(document.addEventListener(Pn,u),()=>document.removeEventListener(Pn,u)),[u]),f.useEffect(()=>{if(c.trigger){const h=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&u()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,u]),a.jsx(or,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:h=>h.preventDefault(),onDismiss:u,children:a.jsxs(cr,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.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:[a.jsx(fu,{children:s}),a.jsx(du,{scope:n,isInside:!0,children:a.jsx(Jl,{id:c.contentId,role:"tooltip",children:i||s})})]})})});ho.displayName=He;var po="TooltipArrow",pu=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,i=Ht(n);return hu(po,n).isInside?null:a.jsx(dr,{...i,...s,ref:t})});pu.displayName=po;function mu(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,s,i,o)){case o:return"left";case i:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function gu(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function yu(e){const{top:t,right:n,bottom:s,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:s},{x:i,y:s}]}function xu(e,t){const{x:n,y:s}=e;let i=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){const l=t[o],c=t[r],d=l.x,u=l.y,h=c.x,p=c.y;u>s!=p>s&&n<(h-d)*(s-u)/(p-u)+d&&(i=!i)}return i}function vu(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),bu(t)}function bu(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(;t.length>=2;){const o=t[t.length-1],r=t[t.length-2];if((o.x-r.x)*(i.y-r.y)>=(o.y-r.y)*(i.x-r.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const i=e[s];for(;n.length>=2;){const o=n[n.length-1],r=n[n.length-2];if((o.x-r.x)*(i.y-r.y)>=(o.y-r.y)*(i.x-r.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Su=lo,wu=co,Tu=uo,mo=ho;const ju=Su,Cu=wu,Pu=Tu,go=f.forwardRef(({className:e,sideOffset:t=4,...n},s)=>a.jsx(mo,{ref:s,sideOffset:t,className:ue("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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",e),...n}));go.displayName=mo.displayName;const ve=f.forwardRef(({className:e,type:t,...n},s)=>a.jsx("input",{type:t,className:ue("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background 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-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...n}));ve.displayName="Input";function Au(e){const t=Ru(e),n=f.forwardRef((s,i)=>{const{children:o,...r}=s,l=f.Children.toArray(o),c=l.find(Eu);if(c){const d=c.props.children,u=l.map(h=>h===c?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:h);return a.jsx(t,{...r,ref:i,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return a.jsx(t,{...r,ref:i,children:o})});return n.displayName=`${e}.Slot`,n}function Ru(e){const t=f.forwardRef((n,s)=>{const{children:i,...o}=n;if(f.isValidElement(i)){const r=Mu(i),l=ku(o,i.props);return i.type!==f.Fragment&&(l.ref=s?yl(s,r):r),f.cloneElement(i,l)}return f.Children.count(i)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Nu=Symbol("radix.slottable");function Eu(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nu}function ku(e,t){const n={...t};for(const s in t){const i=e[s],o=t[s];/^on[A-Z]/.test(s)?i&&o?n[s]=(...l)=>{const c=o(...l);return i(...l),c}:i&&(n[s]=i):s==="style"?n[s]={...i,...o}:s==="className"&&(n[s]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function Mu(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xt="Popover",[yo,rg]=Oe(Xt,[zt]),St=zt(),[Du,Ce]=yo(Xt),xo=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:i,onOpenChange:o,modal:r=!1}=e,l=St(t),c=f.useRef(null),[d,u]=f.useState(!1),[h,p]=Je({prop:s,defaultProp:i??!1,onChange:o,caller:Xt});return a.jsx(ur,{...l,children:a.jsx(Du,{scope:t,contentId:Xn(),triggerRef:c,open:h,onOpenChange:p,onOpenToggle:f.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:d,onCustomAnchorAdd:f.useCallback(()=>u(!0),[]),onCustomAnchorRemove:f.useCallback(()=>u(!1),[]),modal:r,children:n})})};xo.displayName=Xt;var vo="PopoverAnchor",Vu=f.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=Ce(vo,n),o=St(n),{onCustomAnchorAdd:r,onCustomAnchorRemove:l}=i;return f.useEffect(()=>(r(),()=>l()),[r,l]),a.jsx(Jn,{...o,...s,ref:t})});Vu.displayName=vo;var bo="PopoverTrigger",So=f.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=Ce(bo,n),o=St(n),r=Q(t,i.triggerRef),l=a.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Po(i.open),...s,ref:r,onClick:O(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:a.jsx(Jn,{asChild:!0,...o,children:l})});So.displayName=bo;var is="PopoverPortal",[Iu,Lu]=yo(is,{forceMount:void 0}),wo=e=>{const{__scopePopover:t,forceMount:n,children:s,container:i}=e,o=Ce(is,t);return a.jsx(Iu,{scope:t,forceMount:n,children:a.jsx(Qe,{present:n||o.open,children:a.jsx(jl,{asChild:!0,container:i,children:s})})})};wo.displayName=is;var Ye="PopoverContent",To=f.forwardRef((e,t)=>{const n=Lu(Ye,e.__scopePopover),{forceMount:s=n.forceMount,...i}=e,o=Ce(Ye,e.__scopePopover);return a.jsx(Qe,{present:s||o.open,children:o.modal?a.jsx(Fu,{...i,ref:t}):a.jsx(Bu,{...i,ref:t})})});To.displayName=Ye;var Ou=Au("PopoverContent.RemoveScroll"),Fu=f.forwardRef((e,t)=>{const n=Ce(Ye,e.__scopePopover),s=f.useRef(null),i=Q(t,s),o=f.useRef(!1);return f.useEffect(()=>{const r=s.current;if(r)return Pl(r)},[]),a.jsx(Al,{as:Ou,allowPinchZoom:!0,children:a.jsx(jo,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,r=>{var l;r.preventDefault(),o.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,r=>{const l=r.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;o.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:O(e.onFocusOutside,r=>r.preventDefault(),{checkForDefaultPrevented:!1})})})}),Bu=f.forwardRef((e,t)=>{const n=Ce(Ye,e.__scopePopover),s=f.useRef(!1),i=f.useRef(!1);return a.jsx(jo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var r,l;(r=e.onCloseAutoFocus)==null||r.call(e,o),o.defaultPrevented||(s.current||(l=n.triggerRef.current)==null||l.focus(),o.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:o=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const r=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(r))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),jo=f.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:r,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...h}=e,p=Ce(Ye,n),m=St(n);return Rl(),a.jsx(Nl,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:o,children:a.jsx(or,{asChild:!0,disableOutsidePointerEvents:r,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>p.onOpenChange(!1),children:a.jsx(cr,{"data-state":Po(p.open),role:"dialog",id:p.contentId,...m,...h,ref:t,style:{...h.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)"}})})})}),Co="PopoverClose",_u=f.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=Ce(Co,n);return a.jsx(G.button,{type:"button",...s,ref:t,onClick:O(e.onClick,()=>i.onOpenChange(!1))})});_u.displayName=Co;var Uu="PopoverArrow",$u=f.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=St(n);return a.jsx(dr,{...i,...s,ref:t})});$u.displayName=Uu;function Po(e){return e?"open":"closed"}var zu=xo,Ku=So,Gu=wo,Ao=To;const qu=zu,Wu=Ku,Ro=f.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},i)=>a.jsx(Gu,{children:a.jsx(Ao,{ref:i,align:t,sideOffset:n,className:ue("z-50 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",e),...s})}));Ro.displayName=Ao.displayName;function Gs({color:e,onChange:t}){const[n,s]=f.useState(!1),i=r=>{const l=r.target.value;(/^#[0-9A-Fa-f]{0,6}$/.test(l)||l==="")&&t(l.startsWith("#")?l:`#${l}`)},o=["#ffffff","#000000","#ff0000","#00ff00","#0000ff","#ffff00","#00ffff","#ff00ff","#f5f5f5","#808080"];return a.jsx("div",{className:"space-y-2",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-8 w-8 rounded-md border cursor-pointer relative z-10",style:{backgroundColor:e},onClick:()=>s(!0)}),a.jsx(ve,{value:e,onChange:i,className:"w-28 font-mono",maxLength:7}),a.jsxs(qu,{open:n,onOpenChange:s,children:[a.jsx(Wu,{asChild:!0,children:a.jsx("button",{className:"rounded-md p-2 hover:bg-muted relative z-10",children:a.jsx(bn,{className:"h-4 w-4"})})}),a.jsx(Ro,{className:"w-64 z-50",children:a.jsx("div",{className:"grid grid-cols-5 gap-2",children:o.map(r=>a.jsx("div",{className:"h-8 w-8 cursor-pointer rounded-md border transition-transform hover:scale-110",style:{backgroundColor:r},onClick:()=>{t(r),s(!1)}},r))})})]})]})})}function Hu(){const{t:e}=je(),[t,n]=f.useState(X.subtitle.showNativeSubtitles),[s,i]=f.useState(X.subtitle.showLearningSubtitles),[o,r]=f.useState(X.subtitle.fontSize),[l,c]=f.useState(X.subtitle.position),[d,u]=f.useState(X.subtitle.textColor),[h,p]=f.useState(X.subtitle.backgroundColor),[m,v]=f.useState(X.subtitle.opacity),[g,x]=f.useState(X.subtitle.karaokeStyle),[y,w]=f.useState(X.subtitle.translationSource),[S,C]=f.useState(!1),[b,j]=f.useState(!1),N=()=>t&&s?"bilingual":s&&!t?"main":!s&&t?"translation":"bilingual",P=E=>{E==="main"?(n(!1),i(!0)):E==="translation"?(n(!0),i(!1)):(n(!0),i(!0))},D=f.useCallback(_t(E=>{C(!0),xl(E).then(()=>{console.debug("Subtitle settings saved automatically")}).catch(M=>{console.error("Failed to save subtitle settings:",M)}).finally(()=>{C(!1)})},1e3),[]);return f.useEffect(()=>{(async()=>{try{const M=await Ut();n(M.subtitle.showNativeSubtitles),i(M.subtitle.showLearningSubtitles),r(M.subtitle.fontSize),c(M.subtitle.position),u(M.subtitle.textColor),p(M.subtitle.backgroundColor),v(M.subtitle.opacity),x(M.subtitle.karaokeStyle),w(M.subtitle.translationSource),j(!0)}catch(M){console.error("Failed to load subtitle settings:",M)}})()},[]),f.useEffect(()=>{b&&D({showNativeSubtitles:t,showLearningSubtitles:s,fontSize:o,position:l,textColor:d,backgroundColor:h,opacity:m,karaokeStyle:g,translationSource:y})},[t,s,o,l,d,h,m,g,y,D,b]),a.jsxs(ke,{className:"border-2 border-primary/10 gradient-border card-glow",children:[a.jsxs(Me,{children:[a.jsxs(De,{className:"flex items-center gap-2",children:[a.jsx(ac,{className:"h-5 w-5 text-primary"}),a.jsx("span",{className:"gradient-text",children:e("subtitle.title","Subtitle Settings")})]}),a.jsx(We,{children:e("subtitle.desc","Customize how subtitles appear in your videos")})]}),a.jsxs(Ve,{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.display","Subtitle Display")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{children:e("subtitle.mode.title","Subtitle Mode")}),a.jsxs(se,{value:N(),onValueChange:P,children:[a.jsx(ie,{children:a.jsx(re,{})}),a.jsxs(oe,{children:[a.jsx($,{value:"bilingual",children:e("subtitle.mode.bilingual","Bilingual subtitles")}),a.jsx($,{value:"main",children:e("subtitle.mode.main","Main subtitles")}),a.jsx($,{value:"translation",children:e("subtitle.mode.translation","Translation subtitles")})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{children:e("subtitle.translationSource.title","Translation Source")}),a.jsxs(se,{value:y,onValueChange:E=>w(E),children:[a.jsx(ie,{children:a.jsx(re,{})}),a.jsxs(oe,{children:[a.jsx($,{value:"auto",children:e("subtitle.translationSource.auto","Auto (recommended)")}),a.jsx($,{value:"ai",children:e("subtitle.translationSource.ai","AI Translation")}),a.jsx($,{value:"native",children:e("subtitle.translationSource.youtube","YouTube Translation")})]})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("subtitle.translationSource.desc","Auto uses AI when signed in, YouTube translation otherwise.")})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jc,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.size","Subtitle Size")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"flex justify-between",children:a.jsx(L,{htmlFor:"subtitle-size",children:e("subtitle.sizeLabel",{defaultValue:"Size: {{px}}px",px:o})})}),a.jsx(jn,{id:"subtitle-size",min:12,max:48,step:1,value:[o],onValueChange:E=>r(E[0]),className:"w-full",color:"primary"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(vn,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.position","Subtitle Position")})]}),a.jsxs(oo,{value:l,onValueChange:E=>c(E),className:"flex gap-4",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Cn,{value:"top",id:"position-top"}),a.jsxs(L,{htmlFor:"position-top",className:"flex items-center gap-1",children:[a.jsx(mr,{className:"h-4 w-4"})," ",e("common.top","Top")]})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Cn,{value:"bottom",id:"position-bottom"}),a.jsxs(L,{htmlFor:"position-bottom",className:"flex items-center gap-1",children:[a.jsx(vn,{className:"h-4 w-4"})," ",e("common.bottom","Bottom")]})]})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(hr,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.karaokeStyle","Shadow Reading Style")}),a.jsx(ju,{delayDuration:0,children:a.jsxs(Cu,{children:[a.jsx(Pu,{asChild:!0,children:a.jsxs("button",{type:"button",className:"cursor-help focus:outline-none",onClick:E=>{E.preventDefault()},children:[a.jsx(fc,{className:"h-4 w-4 text-muted-foreground hover:text-foreground transition-colors"}),a.jsx("span",{className:"sr-only",children:"Info"})]})}),a.jsx(go,{side:"right",className:"duration-75",children:a.jsx("p",{className:"max-w-xs",children:e("subtitle.karaokeStyleInfo","Style is applied when word timestamps are available.")})})]})})]}),a.jsx("div",{className:"w-full max-w-xs",children:a.jsxs(se,{value:g,onValueChange:E=>x(E),children:[a.jsx(ie,{children:a.jsx(re,{placeholder:"Select style"})}),a.jsxs(oe,{children:[a.jsx($,{value:"neon",children:e("subtitle.style.neon","Neon Highlight")}),a.jsx($,{value:"underline",children:e("subtitle.style.underline","Water Flow")}),a.jsx($,{value:"highlight",children:e("subtitle.style.highlight","Marker Pen")}),a.jsx($,{value:"off",children:e("subtitle.style.off","Off")})]})]})})]}),a.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bn,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.color","Subtitle Color")})]}),a.jsx(Gs,{color:d,onChange:u})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bn,{className:"h-4 w-4 text-primary"}),a.jsx("h3",{className:"text-lg font-medium gradient-text",children:e("subtitle.bgColor","Background Color")})]}),a.jsx(Gs,{color:h,onChange:p}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"flex justify-between",children:a.jsx(L,{htmlFor:"bg-opacity",children:e("subtitle.opacityLabel",{defaultValue:"Opacity: {{percent}}%",percent:Math.round(m*100)})})}),a.jsx(jn,{id:"bg-opacity",min:0,max:1,step:.01,value:[m],onValueChange:E=>v(E[0]),className:"w-full",color:"primary"})]})]})]}),a.jsxs("div",{className:"mt-6 rounded-lg border p-4 card-glow",children:[a.jsx("h4",{className:"mb-2 font-medium gradient-text",children:e("subtitle.preview","Preview")}),a.jsx("div",{className:"relative h-24 w-full rounded-md bg-gray-800 flex items-center justify-center",children:a.jsx(Zl,{texts:["Hello, how are you today?","你好，今天怎么样？"],settings:{fontSize:o,textColor:d,backgroundColor:h,opacity:m,karaokeStyle:g,showNativeSubtitles:!0,showLearningSubtitles:!0}})})]}),S&&a.jsx("div",{className:"text-xs text-muted-foreground text-right animate-pulse",children:e("general.saving")})]})]})}var Zt="Checkbox",[Yu,og]=Oe(Zt),[Xu,rs]=Yu(Zt);function Zu(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:i,disabled:o,form:r,name:l,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:h}=e,[p,m]=Je({prop:n,defaultProp:i??!1,onChange:c,caller:Zt}),[v,g]=f.useState(null),[x,y]=f.useState(null),w=f.useRef(!1),S=v?!!r||!!v.closest("form"):!0,C={checked:p,disabled:o,setChecked:m,control:v,setControl:g,name:l,form:r,value:u,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:Se(i)?!1:i,isFormControl:S,bubbleInput:x,setBubbleInput:y};return a.jsx(Xu,{scope:t,...C,children:Qu(h)?h(C):s})}var No="CheckboxTrigger",Eo=f.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},i)=>{const{control:o,value:r,disabled:l,checked:c,required:d,setControl:u,setChecked:h,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:v}=rs(No,e),g=Q(i,u),x=f.useRef(c);return f.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>h(x.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,h]),a.jsx(G.button,{type:"button",role:"checkbox","aria-checked":Se(c)?"mixed":c,"aria-required":d,"data-state":Io(c),"data-disabled":l?"":void 0,disabled:l,value:r,...s,ref:g,onKeyDown:O(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:O(n,y=>{h(w=>Se(w)?!0:!w),v&&m&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})});Eo.displayName=No;var os=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:i,defaultChecked:o,required:r,disabled:l,value:c,onCheckedChange:d,form:u,...h}=e;return a.jsx(Zu,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:l,required:r,onCheckedChange:d,name:s,form:u,value:c,internal_do_not_use_render:({isFormControl:p})=>a.jsxs(a.Fragment,{children:[a.jsx(Eo,{...h,ref:t,__scopeCheckbox:n}),p&&a.jsx(Vo,{__scopeCheckbox:n})]})})});os.displayName=Zt;var ko="CheckboxIndicator",Mo=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...i}=e,o=rs(ko,n);return a.jsx(Qe,{present:s||Se(o.checked)||o.checked===!0,children:a.jsx(G.span,{"data-state":Io(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});Mo.displayName=ko;var Do="CheckboxBubbleInput",Vo=f.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:r,required:l,disabled:c,name:d,value:u,form:h,bubbleInput:p,setBubbleInput:m}=rs(Do,e),v=Q(n,m),g=Qn(o),x=Zn(s);f.useEffect(()=>{const w=p;if(!w)return;const S=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(S,"checked").set,j=!i.current;if(g!==o&&b){const N=new Event("click",{bubbles:j});w.indeterminate=Se(o),b.call(w,Se(o)?!1:o),w.dispatchEvent(N)}},[p,g,o,i]);const y=f.useRef(Se(o)?!1:o);return a.jsx(G.input,{type:"checkbox","aria-hidden":!0,defaultChecked:r??y.current,required:l,disabled:c,name:d,value:u,form:h,...t,tabIndex:-1,ref:v,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Vo.displayName=Do;function Qu(e){return typeof e=="function"}function Se(e){return e==="indeterminate"}function Io(e){return Se(e)?"indeterminate":e?"checked":"unchecked"}const Rn=f.forwardRef(({className:e,...t},n)=>a.jsx(os,{ref:n,className:ue("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(Mo,{className:ue("flex items-center justify-center text-current"),children:a.jsx(El,{className:"h-4 w-4"})})}));Rn.displayName=os.displayName;function Lo(e){switch(e){case"openai":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your OpenAI API key"},organization:{name:"Organization ID",type:"string",required:!1,description:"Your OpenAI organization ID (optional)"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Custom base URL for API calls"},project:{name:"Project",type:"string",required:!1,description:"OpenAI project"}};case"anthropic":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your Anthropic API key"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Custom base URL for API calls (default: https://api.anthropic.com/v1)"},thinking:{name:"Thinking",type:"object",required:!1,description:"Thinking configuration for Anthropic models",properties:{type:{name:"Type",type:"enum",required:!0,description:"Type of thinking",options:["enabled","disabled"]},budgetTokens:{name:"Budget Tokens",type:"number",required:!1,description:"Token budget for thinking"}}}};case"google":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your Google AI API key"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Custom base URL for API calls (default: https://generativelanguage.googleapis.com/v1beta)"},responseModalities:{name:"Response Modalities",type:"array",required:!1,description:"Types of content the model can generate",itemType:"enum",options:["TEXT","IMAGE"]},thinkingConfig:{name:"Thinking Config",type:"object",required:!1,description:"Configuration for model thinking",properties:{thinkingBudget:{name:"Thinking Budget",type:"number",required:!1,description:"Token budget for thinking"}}}};case"deepseek":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your DeepSeek API key"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Base URL for API calls"}};case"azure":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your Azure OpenAI API key"},resourceName:{name:"Resource Name",type:"string",required:!1,description:"Name of your Azure OpenAI resource"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Base URL for API calls (overrides resourceName if provided)"},apiVersion:{name:"API Version",type:"string",required:!1,description:"Azure OpenAI API version",default:"2024-10-01-preview"}};case"qwen":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Your Qwen API key from Alibaba Cloud DashScope console"},baseURL:{name:"Base URL",type:"string",required:!1,description:"Custom base URL for API calls (default: https://dashscope.aliyuncs.com/compatible-mode/v1 for China, https://dashscope-intl.aliyuncs.com/compatible-mode/v1 for International)"}};case"openai-compatible":return{apiKey:{name:"API Key",type:"string",required:!0,description:"Provider API key for authenticating requests"},baseURL:{name:"Base URL",type:"string",required:!0,description:"Base URL for API calls (e.g., https://api.provider.com/v1)"},options:{name:"Advanced Options",type:"object",required:!1,description:"Advanced provider-specific options",properties:{queryParams:{name:"Query Parameters",type:"object",required:!1,description:"Custom URL query parameters (e.g., api-version for Azure AI services)"}}}};default:return{}}}function Oo(e,t){const n=[];(!e.name||e.name.trim()==="")&&n.push(t("ai.required",{defaultValue:"{{name}} is required",name:t("ai.form.serverName","Server Name")}));const s=Lo(e.provider),i=e.settings||{};return Object.entries(s).forEach(([o,r])=>{r.required&&(!i[o]||i[o]==="")&&n.push(t("ai.required",{defaultValue:"{{name}} is required",name:r.name})),r.type==="object"&&r.properties&&Object.entries(r.properties).forEach(([l,c])=>{var d,u;c.required&&(!((d=i[o])!=null&&d[l])||((u=i[o])==null?void 0:u[l])==="")&&n.push(t("ai.required",{defaultValue:"{{name}} is required",name:c.name}))})}),n}const qs={openai:["gpt-4o","gpt-4o-mini","gpt-4-turbo","gpt-4","gpt-3.5-turbo","gpt-3.5-turbo-16k","text-embedding-3-small","text-embedding-3-large","dall-e-3","dall-e-2","tts-1","tts-1-hd","whisper-1"],anthropic:["claude-3-opus-20240229","claude-3-sonnet-20240229","claude-3-haiku-20240307","claude-2.1","claude-2.0","claude-instant-1.2"],google:["gemini-1.5-pro","gemini-1.5-flash","gemini-1.0-pro","gemini-1.0-ultra","text-embedding-004","text-embedding-gecko"],deepseek:["deepseek-coder","deepseek-chat"],azure:["gpt-4","gpt-4-32k","gpt-4-vision","gpt-4-turbo","gpt-35-turbo","text-embedding-ada-002"],qwen:["qwen-plus","qwen-max","qwen-turbo","qwen-long","qwen-long-latest","qwen2.5-72b-instruct","qwen2.5-14b-instruct-1m","qwen-vl-max","qwen2.5-vl-72b-instruct"],"openai-compatible":[]};function Ju({server:e,onUpdate:t,onSetDefault:n}){const{t:s}=je(),i=qs[e.provider]||[],o=i.length===0||!!e.model&&!i.includes(e.model),[r,l]=f.useState(e.name),[c,d]=f.useState(e.provider),[u,h]=f.useState(e.model),[p,m]=f.useState(e.settings||{}),[v,g]=f.useState(o?e.model:""),[x,y]=f.useState(o),[w,S]=f.useState([]),[C,b]=f.useState(!1),[j,N]=f.useState(null),[P,D]=f.useState("china"),E=f.useRef(e.provider),M=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google AI"},{value:"deepseek",label:"DeepSeek"},{value:"azure",label:"Azure OpenAI"},{value:"qwen",label:"Qwen"},{value:"openai-compatible",label:"OpenAI Compatible"}],W=Lo(c),Y=qs[c]||[],ye=f.useRef(!0);f.useEffect(()=>{if(ye.current){ye.current=!1;return}const T={id:e.id,name:r,provider:c,model:x?v:u,settings:p,isDefault:e.isDefault};t(T)},[r,c,u,v,x,p]),f.useEffect(()=>{const T={};Object.keys(W).forEach(R=>{W[R].type==="object"&&W[R].properties?(T[R]={},Object.keys(W[R].properties).forEach(k=>{var I;T[R][k]=((I=p[R])==null?void 0:I[k])||""})):T[R]=p[R]||""}),c==="qwen"&&(T.baseURL||(T.baseURL=P==="china"?"https://dashscope.aliyuncs.com/compatible-mode/v1":"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"),T.baseURL&&(T.baseURL.includes("dashscope.aliyuncs.com")?D("china"):T.baseURL.includes("dashscope-intl.aliyuncs.com")&&D("international"))),m(T),E.current!==c&&(Y.length>0?(h(Y[0]),y(!1)):(y(!0),g("")),E.current=c)},[c]),f.useEffect(()=>{if(c==="qwen"){const T=P==="china"?"https://dashscope.aliyuncs.com/compatible-mode/v1":"https://dashscope-intl.aliyuncs.com/compatible-mode/v1";m(R=>({...R,baseURL:T}))}},[P,c]);const Fe=async()=>{const T={id:"test-server",name:r,provider:c,model:x?v:u,settings:p,isDefault:!1},R=Oo(T,s);if(R.length>0){S(R);return}S([]),N(null),b(!0);try{const k=new Ql(T);if(k.validateConnection)await k.validateConnection(),N({success:!0,message:s("ai.testSuccess",{defaultValue:"Successfully connected to {{provider}} API!",provider:c})});else throw new Error("Service does not support connection validation")}catch(k){console.error("Test connection failed:",k);let I=k.message||"Unknown error";I.includes("401")&&(I=s("ai.errInvalidKey",{defaultValue:"Invalid API key"})),N({success:!1,message:s("ai.testFailed",{defaultValue:"Failed to connect: {{error}}",error:I})})}finally{b(!1)}},le=(T,R)=>{m(k=>({...k,[T]:R}))},V=(T,R,k)=>{m(I=>({...I,[T]:{...I[T],[R]:k}}))},K=(T,R)=>R.type==="string"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:T,className:"flex items-center gap-2",children:[R.name,R.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx(ve,{id:T,type:T.toLowerCase().includes("key")?"password":"text",value:p[T]||"",onChange:k=>le(T,k.target.value),placeholder:R.description})]},T):R.type==="number"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:T,className:"flex items-center gap-2",children:[R.name,R.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx(ve,{id:T,type:"number",value:p[T]||"",onChange:k=>le(T,Number(k.target.value)),placeholder:R.description})]},T):R.type==="enum"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:T,className:"flex items-center gap-2",children:[R.name,R.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsxs(se,{value:p[T]||"",onValueChange:k=>le(T,k),children:[a.jsx(ie,{id:T,children:a.jsx(re,{placeholder:R.description})}),a.jsx(oe,{children:R.options.map(k=>a.jsx($,{value:k,children:k},k))})]})]},T):R.type==="array"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{className:"flex items-center gap-2",children:[R.name,R.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx("div",{className:"space-y-2",children:R.options.map(k=>a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Rn,{id:`${T}-${k}`,checked:(p[T]||[]).includes(k),onCheckedChange:I=>{const Be=p[T]||[],Pt=I?[...Be,k]:Be.filter(de=>de!==k);le(T,Pt)}}),a.jsx(L,{htmlFor:`${T}-${k}`,children:k})]},k))})]},T):R.type==="object"&&R.properties?a.jsxs("div",{className:"space-y-4 rounded-lg border p-4 card-glow",children:[a.jsx("h3",{className:"font-medium gradient-text",children:R.name}),Object.entries(R.properties).map(([k,I])=>{var Be,Pt;return I.type==="string"||I.type==="number"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:`${T}-${k}`,className:"flex items-center gap-2",children:[I.name,I.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx(ve,{id:`${T}-${k}`,type:I.type==="number"?"number":"text",value:((Be=p[T])==null?void 0:Be[k])||"",onChange:de=>V(T,k,I.type==="number"?Number(de.target.value):de.target.value),placeholder:I.description})]},k):I.type==="enum"?a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:`${T}-${k}`,className:"flex items-center gap-2",children:[I.name,I.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsxs(se,{value:((Pt=p[T])==null?void 0:Pt[k])||"",onValueChange:de=>V(T,k,de),children:[a.jsx(ie,{id:`${T}-${k}`,children:a.jsx(re,{placeholder:I.description})}),a.jsx(oe,{children:I.options.map(de=>a.jsx($,{value:de,children:de},de))})]})]},k):null})]},T):null;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:"server-name",children:[s("ai.form.serverName","Server Name"),a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx(ve,{id:"server-name",value:r,onChange:T=>{l(T.target.value)},placeholder:s("ai.form.serverNamePh","Enter a name for this AI server")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"provider",children:s("ai.form.provider","AI Provider")}),a.jsxs(se,{value:c,onValueChange:T=>{d(T)},children:[a.jsx(ie,{id:"provider",children:a.jsx(re,{placeholder:s("ai.form.providerPh","Select AI provider")})}),a.jsx(oe,{children:M.map(T=>a.jsx($,{value:T.value,children:T.label},T.value))})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Rn,{id:"custom-model",checked:x,onCheckedChange:T=>{y(T===!0)},disabled:Y.length===0}),a.jsx(L,{htmlFor:"custom-model",children:s("ai.form.useCustomModel","Use custom model name")})]}),x?a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"custom-model-name",children:s("ai.form.customModelName","Custom Model Name")}),a.jsx(ve,{id:"custom-model-name",value:v,onChange:T=>{g(T.target.value)},placeholder:s("ai.form.customModelNamePh","Enter custom model name")})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"model",children:s("ai.form.model","Model")}),a.jsxs(se,{value:u,onValueChange:T=>{h(T)},disabled:Y.length===0,children:[a.jsx(ie,{id:"model",children:a.jsx(re,{placeholder:Y.length===0?s("ai.form.noModels","No models available"):s("ai.form.selectModel","Select model")})}),a.jsx(oe,{children:Y.map(T=>a.jsx($,{value:T,children:T},T))})]})]})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsx("h3",{className:"font-medium gradient-text",children:s("ai.form.providerSettings","Provider Settings")}),c==="qwen"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(L,{htmlFor:"qwen-region",children:s("ai.form.region","Region")}),a.jsxs(se,{value:P,onValueChange:T=>{D(T)},children:[a.jsx(ie,{id:"qwen-region",children:a.jsx(re,{placeholder:s("ai.form.regionPh","Select region")})}),a.jsxs(oe,{children:[a.jsx($,{value:"china",children:s("ai.form.regionChina","China (中国区)")}),a.jsx($,{value:"international",children:s("ai.form.regionIntl","International (国际区)")})]})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:P==="china"?s("ai.form.cnEndpoint","Default endpoint: dashscope.aliyuncs.com (You can customize Base URL below)"):s("ai.form.intlEndpoint","Default endpoint: dashscope-intl.aliyuncs.com (You can customize Base URL below)")})]}),Object.entries(W).map(([T,R])=>K(T,R))]}),a.jsxs("div",{className:"space-y-4",children:[w.length>0&&a.jsxs("div",{className:"bg-destructive/10 text-destructive px-4 py-2 rounded-md",children:[a.jsx("p",{className:"font-medium mb-1",children:s("ai.form.fixErrors","Please fix the following errors:")}),a.jsx("ul",{className:"list-disc pl-5 text-sm",children:w.map((T,R)=>a.jsx("li",{children:T},R))})]}),j&&a.jsx("div",{className:`px-4 py-2 rounded-md ${j.success?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-destructive/10 text-destructive"}`,children:a.jsx("p",{children:j.message})}),a.jsxs("div",{className:"flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-3 sm:justify-end",children:[a.jsx(be,{onClick:Fe,disabled:C,variant:"outline",className:"min-w-[140px] relative btn-bounce",children:C?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("ai.form.testing","Testing...")]}):a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(hr,{className:"h-4 w-4"}),s("ai.form.testConnection","Test Connection")]})}),a.jsx(be,{onClick:n,disabled:e.isDefault,className:"min-w-[140px] relative btn-bounce enhanced-button",variant:e.isDefault?"secondary":"default",children:e.isDefault?s("ai.default","Default"):s("ai.setDefault","Set as Default")})]})]})]})}const as=f.createContext({});function ls(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const cs=typeof window<"u",Fo=cs?f.useLayoutEffect:f.useEffect,Qt=f.createContext(null);function us(e,t){e.indexOf(t)===-1&&e.push(t)}function ds(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const me=(e,t,n)=>n>t?t:n<e?e:n;let hs=()=>{};const ge={},Bo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function _o(e){return typeof e=="object"&&e!==null}const Uo=e=>/^0[^.\s]+$/u.test(e);function fs(e){let t;return()=>(t===void 0&&(t=e()),t)}const ae=e=>e,ed=(e,t)=>n=>t(e(n)),wt=(...e)=>e.reduce(ed),pt=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class ps{constructor(){this.subscriptions=[]}add(t){return us(this.subscriptions,t),()=>ds(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const he=e=>e*1e3,fe=e=>e/1e3;function $o(e,t){return t?e*(1e3/t):0}const zo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,td=1e-7,nd=12;function sd(e,t,n,s,i){let o,r,l=0;do r=t+(n-t)/2,o=zo(r,s,i)-e,o>0?n=r:t=r;while(Math.abs(o)>td&&++l<nd);return r}function Tt(e,t,n,s){if(e===t&&n===s)return ae;const i=o=>sd(o,0,1,e,n);return o=>o===0||o===1?o:zo(i(o),t,s)}const Ko=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Go=e=>t=>1-e(1-t),qo=Tt(.33,1.53,.69,.99),ms=Go(qo),Wo=Ko(ms),Ho=e=>(e*=2)<1?.5*ms(e):.5*(2-Math.pow(2,-10*(e-1))),gs=e=>1-Math.sin(Math.acos(e)),Yo=Go(gs),Xo=Ko(gs),id=Tt(.42,0,1,1),rd=Tt(0,0,.58,1),Zo=Tt(.42,0,.58,1),od=e=>Array.isArray(e)&&typeof e[0]!="number",Qo=e=>Array.isArray(e)&&typeof e[0]=="number",ad={linear:ae,easeIn:id,easeInOut:Zo,easeOut:rd,circIn:gs,circInOut:Xo,circOut:Yo,backIn:ms,backInOut:Wo,backOut:qo,anticipate:Ho},ld=e=>typeof e=="string",Ws=e=>{if(Qo(e)){hs(e.length===4);const[t,n,s,i]=e;return Tt(t,n,s,i)}else if(ld(e))return ad[e];return e},At=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],Hs={value:null};function cd(e,t){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let l={delta:0,timestamp:0,isProcessing:!1},c=0;function d(h){r.has(h)&&(u.schedule(h),e()),c++,h(l)}const u={schedule:(h,p=!1,m=!1)=>{const g=m&&i?n:s;return p&&r.add(h),g.has(h)||g.add(h),h},cancel:h=>{s.delete(h),r.delete(h)},process:h=>{if(l=h,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(d),t&&Hs.value&&Hs.value.frameloop[t].push(c),c=0,n.clear(),i=!1,o&&(o=!1,u.process(h))}};return u}const ud=40;function Jo(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=At.reduce((S,C)=>(S[C]=cd(o,t?C:void 0),S),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:u,update:h,preRender:p,render:m,postRender:v}=r,g=()=>{const S=ge.useManualTiming?i.timestamp:performance.now();n=!1,ge.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,ud),1)),i.timestamp=S,i.isProcessing=!0,l.process(i),c.process(i),d.process(i),u.process(i),h.process(i),p.process(i),m.process(i),v.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(g))},x=()=>{n=!0,s=!0,i.isProcessing||e(g)};return{schedule:At.reduce((S,C)=>{const b=r[C];return S[C]=(j,N=!1,P=!1)=>(n||x(),b.schedule(j,N,P)),S},{}),cancel:S=>{for(let C=0;C<At.length;C++)r[At[C]].cancel(S)},state:i,steps:r}}const{schedule:B,cancel:we,state:q,steps:on}=Jo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ae,!0);let kt;function dd(){kt=void 0}const J={now:()=>(kt===void 0&&J.set(q.isProcessing||ge.useManualTiming?q.timestamp:performance.now()),kt),set:e=>{kt=e,queueMicrotask(dd)}},ea=e=>t=>typeof t=="string"&&t.startsWith(e),ys=ea("--"),hd=ea("var(--"),xs=e=>hd(e)?fd.test(e.split("/*")[0].trim()):!1,fd=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,tt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},mt={...tt,transform:e=>me(0,1,e)},Rt={...tt,default:1},lt=e=>Math.round(e*1e5)/1e5,vs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pd(e){return e==null}const md=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,bs=(e,t)=>n=>!!(typeof n=="string"&&md.test(n)&&n.startsWith(e)||t&&!pd(n)&&Object.prototype.hasOwnProperty.call(n,t)),ta=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,l]=s.match(vs);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(r),alpha:l!==void 0?parseFloat(l):1}},gd=e=>me(0,255,e),an={...tt,transform:e=>Math.round(gd(e))},Ne={test:bs("rgb","red"),parse:ta("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+an.transform(e)+", "+an.transform(t)+", "+an.transform(n)+", "+lt(mt.transform(s))+")"};function yd(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const Nn={test:bs("#"),parse:yd,transform:Ne.transform},jt=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),xe=jt("deg"),pe=jt("%"),A=jt("px"),xd=jt("vh"),vd=jt("vw"),Ys={...pe,parse:e=>pe.parse(e)/100,transform:e=>pe.transform(e*100)},$e={test:bs("hsl","hue"),parse:ta("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+pe.transform(lt(t))+", "+pe.transform(lt(n))+", "+lt(mt.transform(s))+")"},z={test:e=>Ne.test(e)||Nn.test(e)||$e.test(e),parse:e=>Ne.test(e)?Ne.parse(e):$e.test(e)?$e.parse(e):Nn.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Ne.transform(e):$e.transform(e),getAnimatableNone:e=>{const t=z.parse(e);return t.alpha=0,z.transform(t)}},bd=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Sd(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(vs))==null?void 0:t.length)||0)+(((n=e.match(bd))==null?void 0:n.length)||0)>0}const na="number",sa="color",wd="var",Td="var(",Xs="${}",jd=/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 gt(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const l=t.replace(jd,c=>(z.test(c)?(s.color.push(o),i.push(sa),n.push(z.parse(c))):c.startsWith(Td)?(s.var.push(o),i.push(wd),n.push(c)):(s.number.push(o),i.push(na),n.push(parseFloat(c))),++o,Xs)).split(Xs);return{values:n,split:l,indexes:s,types:i}}function ia(e){return gt(e).values}function ra(e){const{split:t,types:n}=gt(e),s=t.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=t[r],i[r]!==void 0){const l=n[r];l===na?o+=lt(i[r]):l===sa?o+=z.transform(i[r]):o+=i[r]}return o}}const Cd=e=>typeof e=="number"?0:z.test(e)?z.getAnimatableNone(e):e;function Pd(e){const t=ia(e);return ra(e)(t.map(Cd))}const Te={test:Sd,parse:ia,createTransformer:ra,getAnimatableNone:Pd};function ln(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ad({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,o=0,r=0;if(!t)i=o=r=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;i=ln(c,l,e+1/3),o=ln(c,l,e),r=ln(c,l,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function It(e,t){return n=>n>0?t:e}const F=(e,t,n)=>e+(t-e)*n,cn=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},Rd=[Nn,Ne,$e],Nd=e=>Rd.find(t=>t.test(e));function Zs(e){const t=Nd(e);if(!t)return!1;let n=t.parse(e);return t===$e&&(n=Ad(n)),n}const Qs=(e,t)=>{const n=Zs(e),s=Zs(t);if(!n||!s)return It(e,t);const i={...n};return o=>(i.red=cn(n.red,s.red,o),i.green=cn(n.green,s.green,o),i.blue=cn(n.blue,s.blue,o),i.alpha=F(n.alpha,s.alpha,o),Ne.transform(i))},En=new Set(["none","hidden"]);function Ed(e,t){return En.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function kd(e,t){return n=>F(e,t,n)}function Ss(e){return typeof e=="number"?kd:typeof e=="string"?xs(e)?It:z.test(e)?Qs:Vd:Array.isArray(e)?oa:typeof e=="object"?z.test(e)?Qs:Md:It}function oa(e,t){const n=[...e],s=n.length,i=e.map((o,r)=>Ss(o)(o,t[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Md(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=Ss(e[i])(e[i],t[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Dd(e,t){const n=[],s={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],r=e.indexes[o][s[o]],l=e.values[r]??0;n[i]=l,s[o]++}return n}const Vd=(e,t)=>{const n=Te.createTransformer(t),s=gt(e),i=gt(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?En.has(e)&&!i.values.length||En.has(t)&&!s.values.length?Ed(e,t):wt(oa(Dd(s,i),i.values),n):It(e,t)};function aa(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?F(e,t,n):Ss(e)(e,t)}const Id=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>B.update(t,n),stop:()=>we(t),now:()=>q.isProcessing?q.timestamp:J.now()}},la=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let o=0;o<i;o++)s+=Math.round(e(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Lt=2e4;function ws(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Lt;)t+=n,s=e.next(t);return t>=Lt?1/0:t}function Ld(e,t=100,n){const s=n({...e,keyframes:[0,t]}),i=Math.min(ws(s),Lt);return{type:"keyframes",ease:o=>s.next(i*o).value/t,duration:fe(i)}}const Od=5;function ca(e,t,n){const s=Math.max(t-Od,0);return $o(n-e(s),t-s)}const _={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},un=.001;function Fd({duration:e=_.duration,bounce:t=_.bounce,velocity:n=_.velocity,mass:s=_.mass}){let i,o,r=1-t;r=me(_.minDamping,_.maxDamping,r),e=me(_.minDuration,_.maxDuration,fe(e)),r<1?(i=d=>{const u=d*r,h=u*e,p=u-n,m=kn(d,r),v=Math.exp(-h);return un-p/m*v},o=d=>{const h=d*r*e,p=h*n+n,m=Math.pow(r,2)*Math.pow(d,2)*e,v=Math.exp(-h),g=kn(Math.pow(d,2),r);return(-i(d)+un>0?-1:1)*((p-m)*v)/g}):(i=d=>{const u=Math.exp(-d*e),h=(d-n)*e+1;return-un+u*h},o=d=>{const u=Math.exp(-d*e),h=(n-d)*(e*e);return u*h});const l=5/e,c=_d(i,o,l);if(e=he(e),isNaN(c))return{stiffness:_.stiffness,damping:_.damping,duration:e};{const d=Math.pow(c,2)*s;return{stiffness:d,damping:r*2*Math.sqrt(s*d),duration:e}}}const Bd=12;function _d(e,t,n){let s=n;for(let i=1;i<Bd;i++)s=s-e(s)/t(s);return s}function kn(e,t){return e*Math.sqrt(1-t*t)}const Ud=["duration","bounce"],$d=["stiffness","damping","mass"];function Js(e,t){return t.some(n=>e[n]!==void 0)}function zd(e){let t={velocity:_.velocity,stiffness:_.stiffness,damping:_.damping,mass:_.mass,isResolvedFromDuration:!1,...e};if(!Js(e,$d)&&Js(e,Ud))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*me(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:_.mass,stiffness:i,damping:o}}else{const n=Fd(e);t={...t,...n,mass:_.mass},t.isResolvedFromDuration=!0}return t}function Ot(e=_.visualDuration,t=_.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],l={done:!1,value:o},{stiffness:c,damping:d,mass:u,duration:h,velocity:p,isResolvedFromDuration:m}=zd({...n,velocity:-fe(n.velocity||0)}),v=p||0,g=d/(2*Math.sqrt(c*u)),x=r-o,y=fe(Math.sqrt(c/u)),w=Math.abs(x)<5;s||(s=w?_.restSpeed.granular:_.restSpeed.default),i||(i=w?_.restDelta.granular:_.restDelta.default);let S;if(g<1){const b=kn(y,g);S=j=>{const N=Math.exp(-g*y*j);return r-N*((v+g*y*x)/b*Math.sin(b*j)+x*Math.cos(b*j))}}else if(g===1)S=b=>r-Math.exp(-y*b)*(x+(v+y*x)*b);else{const b=y*Math.sqrt(g*g-1);S=j=>{const N=Math.exp(-g*y*j),P=Math.min(b*j,300);return r-N*((v+g*y*x)*Math.sinh(P)+b*x*Math.cosh(P))/b}}const C={calculatedDuration:m&&h||null,next:b=>{const j=S(b);if(m)l.done=b>=h;else{let N=b===0?v:0;g<1&&(N=b===0?he(v):ca(S,b,j));const P=Math.abs(N)<=s,D=Math.abs(r-j)<=i;l.done=P&&D}return l.value=l.done?r:j,l},toString:()=>{const b=Math.min(ws(C),Lt),j=la(N=>C.next(b*N).value,b,30);return b+"ms "+j},toTransition:()=>{}};return C}Ot.applyToOptions=e=>{const t=Ld(e,100,Ot);return e.ease=t.ease,e.duration=he(t.duration),e.type="keyframes",e};function Mn({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:l,max:c,restDelta:d=.5,restSpeed:u}){const h=e[0],p={done:!1,value:h},m=P=>l!==void 0&&P<l||c!==void 0&&P>c,v=P=>l===void 0?c:c===void 0||Math.abs(l-P)<Math.abs(c-P)?l:c;let g=n*t;const x=h+g,y=r===void 0?x:r(x);y!==x&&(g=y-h);const w=P=>-g*Math.exp(-P/s),S=P=>y+w(P),C=P=>{const D=w(P),E=S(P);p.done=Math.abs(D)<=d,p.value=p.done?y:E};let b,j;const N=P=>{m(p.value)&&(b=P,j=Ot({keyframes:[p.value,v(p.value)],velocity:ca(S,P,p.value),damping:i,stiffness:o,restDelta:d,restSpeed:u}))};return N(0),{calculatedDuration:null,next:P=>{let D=!1;return!j&&b===void 0&&(D=!0,C(P),N(P)),b!==void 0&&P>=b?j.next(P-b):(!D&&C(P),p)}}}function Kd(e,t,n){const s=[],i=n||ge.mix||aa,o=e.length-1;for(let r=0;r<o;r++){let l=i(e[r],e[r+1]);if(t){const c=Array.isArray(t)?t[r]||ae:t;l=wt(c,l)}s.push(l)}return s}function Gd(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const o=e.length;if(hs(o===t.length),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const r=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=Kd(t,s,i),c=l.length,d=u=>{if(r&&u<e[0])return t[0];let h=0;if(c>1)for(;h<e.length-2&&!(u<e[h+1]);h++);const p=pt(e[h],e[h+1],u);return l[h](p)};return n?u=>d(me(e[0],e[o-1],u)):d}function qd(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=pt(0,t,s);e.push(F(n,1,i))}}function Wd(e){const t=[0];return qd(t,e.length-1),t}function Hd(e,t){return e.map(n=>n*t)}function Yd(e,t){return e.map(()=>t||Zo).splice(0,e.length-1)}function ct({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=od(s)?s.map(Ws):Ws(s),o={done:!1,value:t[0]},r=Hd(n&&n.length===t.length?n:Wd(t),e),l=Gd(r,t,{ease:Array.isArray(i)?i:Yd(t,i)});return{calculatedDuration:e,next:c=>(o.value=l(c),o.done=c>=e,o)}}const Xd=e=>e!==null;function Ts(e,{repeat:t,repeatType:n="loop"},s,i=1){const o=e.filter(Xd),l=i<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!l||s===void 0?o[l]:s}const Zd={decay:Mn,inertia:Mn,tween:ct,keyframes:ct,spring:Ot};function ua(e){typeof e.type=="string"&&(e.type=Zd[e.type])}class js{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Qd=e=>e/100;class Cs extends js{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var s,i;const{motionValue:n}=this.options;n&&n.updatedAt!==J.now()&&this.tick(J.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(s=this.options).onStop)==null||i.call(s))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;ua(t);const{type:n=ct,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=t;let{keyframes:l}=t;const c=n||ct;c!==ct&&typeof l[0]!="number"&&(this.mixKeyframes=wt(Qd,aa(l[0],l[1])),l=[0,100]);const d=c({...t,keyframes:l});o==="mirror"&&(this.mirroredGenerator=c({...t,keyframes:[...l].reverse(),velocity:-r})),d.calculatedDuration===null&&(d.calculatedDuration=ws(d));const{calculatedDuration:u}=d;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=d}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:l,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:d=0,keyframes:u,repeat:h,repeatType:p,repeatDelay:m,type:v,onUpdate:g,finalKeyframe:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-d*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,C=s;if(h){const P=Math.min(this.currentTime,i)/l;let D=Math.floor(P),E=P%1;!E&&P>=1&&(E=1),E===1&&D--,D=Math.min(D,h+1),!!(D%2)&&(p==="reverse"?(E=1-E,m&&(E-=m/l)):p==="mirror"&&(C=r)),S=me(0,1,E)*l}const b=w?{done:!1,value:u[0]}:C.next(S);o&&(b.value=o(b.value));let{done:j}=b;!w&&c!==null&&(j=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return N&&v!==Mn&&(b.value=Ts(u,this.options,x,this.speed)),g&&g(b.value),N&&this.finish(),b}then(t,n){return this.finished.then(t,n)}get duration(){return fe(this.calculatedDuration)}get time(){return fe(this.currentTime)}set time(t){var n;t=he(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(J.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=fe(this.currentTime))}play(){var i,o;if(this.isStopped)return;const{driver:t=Id,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),(o=(i=this.options).onPlay)==null||o.call(i);const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(J.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Jd(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Ee=e=>e*180/Math.PI,Dn=e=>{const t=Ee(Math.atan2(e[1],e[0]));return Vn(t)},eh={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Dn,rotateZ:Dn,skewX:e=>Ee(Math.atan(e[1])),skewY:e=>Ee(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Vn=e=>(e=e%360,e<0&&(e+=360),e),ei=Dn,ti=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ni=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),th={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ti,scaleY:ni,scale:e=>(ti(e)+ni(e))/2,rotateX:e=>Vn(Ee(Math.atan2(e[6],e[5]))),rotateY:e=>Vn(Ee(Math.atan2(-e[2],e[0]))),rotateZ:ei,rotate:ei,skewX:e=>Ee(Math.atan(e[4])),skewY:e=>Ee(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function In(e){return e.includes("scale")?1:0}function Ln(e,t){if(!e||e==="none")return In(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=th,i=n;else{const l=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=eh,i=l}if(!i)return In(t);const o=s[t],r=i[1].split(",").map(sh);return typeof o=="function"?o(r):r[o]}const nh=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ln(n,t)};function sh(e){return parseFloat(e.trim())}const nt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],st=new Set(nt),si=e=>e===tt||e===A,ih=new Set(["x","y","z"]),rh=nt.filter(e=>!ih.has(e));function oh(e){const t=[];return rh.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Ie={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ln(t,"x"),y:(e,{transform:t})=>Ln(t,"y")};Ie.translateX=Ie.x;Ie.translateY=Ie.y;const Le=new Set;let On=!1,Fn=!1,Bn=!1;function da(){if(Fn){const e=Array.from(Le).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=oh(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{var l;(l=s.getValue(o))==null||l.set(r)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Fn=!1,On=!1,Le.forEach(e=>e.complete(Bn)),Le.clear()}function ha(){Le.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fn=!0)})}function ah(){Bn=!0,ha(),da(),Bn=!1}class Ps{constructor(t,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(Le.add(this),On||(On=!0,B.read(ha),B.resolveKeyframes(da))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;if(t[0]===null){const o=i==null?void 0:i.get(),r=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const l=s.readValue(n,r);l!=null&&(t[0]=l)}t[0]===void 0&&(t[0]=r),i&&o===void 0&&i.set(t[0])}Jd(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Le.delete(this)}cancel(){this.state==="scheduled"&&(Le.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const lh=e=>e.startsWith("--");function ch(e,t,n){lh(t)?e.style.setProperty(t,n):e.style[t]=n}const uh=fs(()=>window.ScrollTimeline!==void 0),dh={};function hh(e,t){const n=fs(e);return()=>dh[t]??n()}const fa=hh(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),rt=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,ii={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:rt([0,.65,.55,1]),circOut:rt([.55,0,1,.45]),backIn:rt([.31,.01,.66,-.59]),backOut:rt([.33,1.53,.69,.99])};function pa(e,t){if(e)return typeof e=="function"?fa()?la(e,t):"ease-out":Qo(e)?rt(e):Array.isArray(e)?e.map(n=>pa(n,t)||ii.easeOut):ii[e]}function fh(e,t,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:l="easeOut",times:c}={},d=void 0){const u={[t]:n};c&&(u.offset=c);const h=pa(l,i);Array.isArray(h)&&(u.easing=h);const p={delay:s,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return d&&(p.pseudoElement=d),e.animate(u,p)}function ma(e){return typeof e=="function"&&"applyToOptions"in e}function ph({type:e,...t}){return ma(e)&&fa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class mh extends js{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:l,onComplete:c}=t;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=t,hs(typeof t.type!="string");const d=ph(t);this.animation=fh(n,s,i,d,o),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const u=Ts(i,this.options,l,this.speed);this.updateMotionValue?this.updateMotionValue(u):ch(n,s,u),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var t,n;this.isPseudoElement||(n=(t=this.animation).commitStyles)==null||n.call(t)}get duration(){var n,s;const t=((s=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:s.call(n).duration)||0;return fe(Number(t))}get time(){return fe(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=he(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){var s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&uh()?(this.animation.timeline=t,ae):n(this)}}const ga={anticipate:Ho,backInOut:Wo,circInOut:Xo};function gh(e){return e in ga}function yh(e){typeof e.ease=="string"&&gh(e.ease)&&(e.ease=ga[e.ease])}const ri=10;class xh extends mh{constructor(t){yh(t),ua(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const l=new Cs({...r,autoplay:!1}),c=he(this.finishedTime??this.time);n.setWithVelocity(l.sample(c-ri).value,l.sample(c).value,ri),l.stop()}}const oi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Te.test(e)||e==="0")&&!e.startsWith("url("));function vh(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function bh(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],r=oi(i,t),l=oi(o,t);return!r||!l?!1:vh(e)||(n==="spring"||ma(n))&&s}function As(e){return _o(e)&&"offsetHeight"in e}const Sh=new Set(["opacity","clipPath","filter","transform"]),wh=fs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Th(e){var d;const{motionValue:t,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=e;if(!As((d=t==null?void 0:t.owner)==null?void 0:d.current))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return wh()&&n&&Sh.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const jh=40;class Ch extends js{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:l,name:c,motionValue:d,element:u,...h}){var v;super(),this.stop=()=>{var g,x;this._animation&&(this._animation.stop(),(g=this.stopTimeline)==null||g.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=J.now();const p={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:d,element:u,...h},m=(u==null?void 0:u.KeyframeResolver)||Ps;this.keyframeResolver=new m(l,(g,x,y)=>this.onKeyframesResolved(g,x,p,!y),c,d,u),(v=this.keyframeResolver)==null||v.scheduleResolve()}onKeyframesResolved(t,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:l,delay:c,isHandoff:d,onUpdate:u}=s;this.resolvedAt=J.now(),bh(t,o,r,l)||((ge.instantAnimations||!c)&&(u==null||u(Ts(t,s,n))),t[0]=t[t.length-1],s.duration=0,s.repeat=0);const p={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>jh?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},m=!d&&Th(p)?new xh({...p,element:p.motionValue.owner.current}):new Cs(p);m.finished.then(()=>this.notifyFinished()).catch(ae),this.pendingTimeline&&(this.stopTimeline=m.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),ah()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}const Ph=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ah(e){const t=Ph.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}function ya(e,t,n=1){const[s,i]=Ah(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const r=o.trim();return Bo(r)?parseFloat(r):r}return xs(i)?ya(i,t,n+1):i}function Rs(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const xa=new Set(["width","height","top","left","right","bottom",...nt]),Rh={test:e=>e==="auto",parse:e=>e},va=e=>t=>t.test(e),ba=[tt,A,pe,xe,vd,xd,Rh],ai=e=>ba.find(va(e));function Nh(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Uo(e):!0}const Eh=new Set(["brightness","contrast","saturate","opacity"]);function kh(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(vs)||[];if(!s)return e;const i=n.replace(s,"");let o=Eh.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+i+")"}const Mh=/\b([a-z-]*)\(.*?\)/gu,_n={...Te,getAnimatableNone:e=>{const t=e.match(Mh);return t?t.map(kh).join(" "):e}},li={...tt,transform:Math.round},Dh={rotate:xe,rotateX:xe,rotateY:xe,rotateZ:xe,scale:Rt,scaleX:Rt,scaleY:Rt,scaleZ:Rt,skew:xe,skewX:xe,skewY:xe,distance:A,translateX:A,translateY:A,translateZ:A,x:A,y:A,z:A,perspective:A,transformPerspective:A,opacity:mt,originX:Ys,originY:Ys,originZ:A},Ns={borderWidth:A,borderTopWidth:A,borderRightWidth:A,borderBottomWidth:A,borderLeftWidth:A,borderRadius:A,radius:A,borderTopLeftRadius:A,borderTopRightRadius:A,borderBottomRightRadius:A,borderBottomLeftRadius:A,width:A,maxWidth:A,height:A,maxHeight:A,top:A,right:A,bottom:A,left:A,padding:A,paddingTop:A,paddingRight:A,paddingBottom:A,paddingLeft:A,margin:A,marginTop:A,marginRight:A,marginBottom:A,marginLeft:A,backgroundPositionX:A,backgroundPositionY:A,...Dh,zIndex:li,fillOpacity:mt,strokeOpacity:mt,numOctaves:li},Vh={...Ns,color:z,backgroundColor:z,outlineColor:z,fill:z,stroke:z,borderColor:z,borderTopColor:z,borderRightColor:z,borderBottomColor:z,borderLeftColor:z,filter:_n,WebkitFilter:_n},Sa=e=>Vh[e];function wa(e,t){let n=Sa(e);return n!==_n&&(n=Te),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ih=new Set(["auto","none","0"]);function Lh(e,t,n){let s=0,i;for(;s<e.length&&!i;){const o=e[s];typeof o=="string"&&!Ih.has(o)&&gt(o).values.length&&(i=e[s]),s++}if(i&&n)for(const o of t)e[o]=wa(n,i)}class Oh extends Ps{constructor(t,n,s,i,o){super(t,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let d=t[c];if(typeof d=="string"&&(d=d.trim(),xs(d))){const u=ya(d,n.current);u!==void 0&&(t[c]=u),c===t.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!xa.has(s)||t.length!==2)return;const[i,o]=t,r=ai(i),l=ai(o);if(r!==l)if(si(r)&&si(l))for(let c=0;c<t.length;c++){const d=t[c];typeof d=="string"&&(t[c]=parseFloat(d))}else Ie[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)(t[i]===null||Nh(t[i]))&&s.push(i);s.length&&Lh(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ie[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){var l;const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=Ie[n](t.measureViewportBox(),window.getComputedStyle(t.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),(l=this.removedTransforms)!=null&&l.length&&this.removedTransforms.forEach(([c,d])=>{t.getValue(c).set(d)}),this.resolveNoneKeyframes()}}function Fh(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const i=(n==null?void 0:n[e])??s.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}const Ta=(e,t)=>t&&typeof e=="number"?t.transform(e):e,ci=30,Bh=e=>!isNaN(parseFloat(e));class _h{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(s,i=!0)=>{var r,l;const o=J.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const c of this.dependents)c.dirty();i&&((l=this.events.renderRequest)==null||l.notify(this.current))},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=J.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Bh(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new ps);const s=this.events[t].add(n);return t==="change"?()=>{s(),B.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=J.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>ci)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ci);return $o(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Xe(e,t){return new _h(e,t)}const{schedule:Es}=Jo(queueMicrotask,!1),ce={x:!1,y:!1};function ja(){return ce.x||ce.y}function Uh(e){return e==="x"||e==="y"?ce[e]?null:(ce[e]=!0,()=>{ce[e]=!1}):ce.x||ce.y?null:(ce.x=ce.y=!0,()=>{ce.x=ce.y=!1})}function Ca(e,t){const n=Fh(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function ui(e){return!(e.pointerType==="touch"||ja())}function $h(e,t,n={}){const[s,i,o]=Ca(e,n),r=l=>{if(!ui(l))return;const{target:c}=l,d=t(c,l);if(typeof d!="function"||!c)return;const u=h=>{ui(h)&&(d(h),c.removeEventListener("pointerleave",u))};c.addEventListener("pointerleave",u,i)};return s.forEach(l=>{l.addEventListener("pointerenter",r,i)}),o}const Pa=(e,t)=>t?e===t?!0:Pa(e,t.parentElement):!1,ks=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,zh=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Kh(e){return zh.has(e.tagName)||e.tabIndex!==-1}const Mt=new WeakSet;function di(e){return t=>{t.key==="Enter"&&e(t)}}function dn(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Gh=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=di(()=>{if(Mt.has(n))return;dn(n,"down");const i=di(()=>{dn(n,"up")}),o=()=>dn(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function hi(e){return ks(e)&&!ja()}function qh(e,t,n={}){const[s,i,o]=Ca(e,n),r=l=>{const c=l.currentTarget;if(!hi(l))return;Mt.add(c);const d=t(c,l),u=(m,v)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",p),Mt.has(c)&&Mt.delete(c),hi(m)&&typeof d=="function"&&d(m,{success:v})},h=m=>{u(m,c===window||c===document||n.useGlobalTarget||Pa(c,m.target))},p=m=>{u(m,!1)};window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",p,i)};return s.forEach(l=>{(n.useGlobalTarget?window:l).addEventListener("pointerdown",r,i),As(l)&&(l.addEventListener("focus",d=>Gh(d,i)),!Kh(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),o}function Aa(e){return _o(e)&&"ownerSVGElement"in e}function Wh(e){return Aa(e)&&e.tagName==="svg"}const H=e=>!!(e&&e.getVelocity),Hh=[...ba,z,Te],Yh=e=>Hh.find(va(e)),Ms=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Xh extends f.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=As(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Zh({children:e,isPresent:t,anchorX:n}){const s=f.useId(),i=f.useRef(null),o=f.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:r}=f.useContext(Ms);return f.useInsertionEffect(()=>{const{width:l,height:c,top:d,left:u,right:h}=o.current;if(t||!i.current||!l||!c)return;const p=n==="left"?`left: ${u}`:`right: ${h}`;i.current.dataset.motionPopId=s;const m=document.createElement("style");return r&&(m.nonce=r),document.head.appendChild(m),m.sheet&&m.sheet.insertRule(`
          [data-motion-pop-id="${s}"] {
            position: absolute !important;
            width: ${l}px !important;
            height: ${c}px !important;
            ${p}px !important;
            top: ${d}px !important;
          }
        `),()=>{document.head.contains(m)&&document.head.removeChild(m)}},[t]),a.jsx(Xh,{isPresent:t,childRef:i,sizeRef:o,children:f.cloneElement(e,{ref:i})})}const Qh=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:l})=>{const c=ls(Jh),d=f.useId();let u=!0,h=f.useMemo(()=>(u=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:p=>{c.set(p,!0);for(const m of c.values())if(!m)return;s&&s()},register:p=>(c.set(p,!1),()=>c.delete(p))}),[n,c,s]);return o&&u&&(h={...h}),f.useMemo(()=>{c.forEach((p,m)=>c.set(m,!1))},[n]),f.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),r==="popLayout"&&(e=a.jsx(Zh,{isPresent:n,anchorX:l,children:e})),a.jsx(Qt.Provider,{value:h,children:e})};function Jh(){return new Map}function Ra(e=!0){const t=f.useContext(Qt);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,o=f.useId();f.useEffect(()=>{if(e)return i(o)},[e]);const r=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,r]:[!0]}const Nt=e=>e.key||"";function fi(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const ef=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:l="left"})=>{const[c,d]=Ra(r),u=f.useMemo(()=>fi(e),[e]),h=r&&!c?[]:u.map(Nt),p=f.useRef(!0),m=f.useRef(u),v=ls(()=>new Map),[g,x]=f.useState(u),[y,w]=f.useState(u);Fo(()=>{p.current=!1,m.current=u;for(let b=0;b<y.length;b++){const j=Nt(y[b]);h.includes(j)?v.delete(j):v.get(j)!==!0&&v.set(j,!1)}},[y,h.length,h.join("-")]);const S=[];if(u!==g){let b=[...u];for(let j=0;j<y.length;j++){const N=y[j],P=Nt(N);h.includes(P)||(b.splice(j,0,N),S.push(N))}return o==="wait"&&S.length&&(b=S),w(fi(b)),x(u),null}const{forceRender:C}=f.useContext(as);return a.jsx(a.Fragment,{children:y.map(b=>{const j=Nt(b),N=r&&!c?!1:u===y||h.includes(j),P=()=>{if(v.has(j))v.set(j,!0);else return;let D=!0;v.forEach(E=>{E||(D=!1)}),D&&(C==null||C(),w(m.current),r&&(d==null||d()),s&&s())};return a.jsx(Qh,{isPresent:N,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,onExitComplete:N?void 0:P,anchorX:l,children:b},j)})})},Na=f.createContext({strict:!1}),pi={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"]},Ze={};for(const e in pi)Ze[e]={isEnabled:t=>pi[e].some(n=>!!t[n])};function tf(e){for(const t in e)Ze[t]={...Ze[t],...e[t]}}const nf=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","ignoreStrict","viewport"]);function Ft(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||nf.has(e)}let Ea=e=>!Ft(e);function sf(e){typeof e=="function"&&(Ea=t=>t.startsWith("on")?!Ft(t):e(t))}try{sf(require("@emotion/is-prop-valid").default)}catch{}function rf(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(Ea(i)||n===!0&&Ft(i)||!t&&!Ft(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}function of(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...s)=>e(...s);return new Proxy(n,{get:(s,i)=>i==="create"?e:(t.has(i)||t.set(i,e(i)),t.get(i))})}const Jt=f.createContext({});function en(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function yt(e){return typeof e=="string"||Array.isArray(e)}const Ds=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Vs=["initial",...Ds];function tn(e){return en(e.animate)||Vs.some(t=>yt(e[t]))}function ka(e){return!!(tn(e)||e.variants)}function af(e,t){if(tn(e)){const{initial:n,animate:s}=e;return{initial:n===!1||yt(n)?n:void 0,animate:yt(s)?s:void 0}}return e.inherit!==!1?t:{}}function lf(e){const{initial:t,animate:n}=af(e,f.useContext(Jt));return f.useMemo(()=>({initial:t,animate:n}),[mi(t),mi(n)])}function mi(e){return Array.isArray(e)?e.join(" "):e}const cf=Symbol.for("motionComponentSymbol");function ze(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function uf(e,t,n){return f.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):ze(n)&&(n.current=s))},[t])}const Is=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),df="framerAppearId",Ma="data-"+Is(df),Da=f.createContext({});function hf(e,t,n,s,i){var g,x;const{visualElement:o}=f.useContext(Jt),r=f.useContext(Na),l=f.useContext(Qt),c=f.useContext(Ms).reducedMotion,d=f.useRef(null);s=s||r.renderer,!d.current&&s&&(d.current=s(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c}));const u=d.current,h=f.useContext(Da);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&ff(d.current,n,i,h);const p=f.useRef(!1);f.useInsertionEffect(()=>{u&&p.current&&u.update(n,l)});const m=n[Ma],v=f.useRef(!!m&&!((g=window.MotionHandoffIsComplete)!=null&&g.call(window,m))&&((x=window.MotionHasOptimisedAnimation)==null?void 0:x.call(window,m)));return Fo(()=>{u&&(p.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),Es.render(u.render),v.current&&u.animationState&&u.animationState.animateChanges())}),f.useEffect(()=>{u&&(!v.current&&u.animationState&&u.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,m)}),v.current=!1))}),u}function ff(e,t,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutCrossfade:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Va(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||l&&ze(l),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:c,layoutRoot:d})}function Va(e){if(e)return e.options.allowProjection!==!1?e.projection:Va(e.parent)}function pf({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:s,Component:i}){e&&tf(e);function o(l,c){let d;const u={...f.useContext(Ms),...l,layoutId:mf(l)},{isStatic:h}=u,p=lf(l),m=s(l,h);if(!h&&cs){gf();const v=yf(u);d=v.MeasureLayout,p.visualElement=hf(i,m,u,t,v.ProjectionNode)}return a.jsxs(Jt.Provider,{value:p,children:[d&&p.visualElement?a.jsx(d,{visualElement:p.visualElement,...u}):null,n(i,l,uf(m,p.visualElement,c),m,h,p.visualElement)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const r=f.forwardRef(o);return r[cf]=i,r}function mf({layoutId:e}){const t=f.useContext(as).id;return t&&e!==void 0?t+"-"+e:e}function gf(e,t){f.useContext(Na).strict}function yf(e){const{drag:t,layout:n}=Ze;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}const xt={};function xf(e){for(const t in e)xt[t]=e[t],ys(t)&&(xt[t].isCSSVariable=!0)}function Ia(e,{layout:t,layoutId:n}){return st.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!xt[e]||e==="opacity")}const vf={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},bf=nt.length;function Sf(e,t,n){let s="",i=!0;for(let o=0;o<bf;o++){const r=nt[o],l=e[r];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(r.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const d=Ta(l,Ns[r]);if(!c){i=!1;const u=vf[r]||r;s+=`${u}(${d}) `}n&&(t[r]=d)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ls(e,t,n){const{style:s,vars:i,transformOrigin:o}=e;let r=!1,l=!1;for(const c in t){const d=t[c];if(st.has(c)){r=!0;continue}else if(ys(c)){i[c]=d;continue}else{const u=Ta(d,Ns[c]);c.startsWith("origin")?(l=!0,o[c]=u):s[c]=u}}if(t.transform||(r||n?s.transform=Sf(t,e.transform,n):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:u=0}=o;s.transformOrigin=`${c} ${d} ${u}`}}const Os=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function La(e,t,n){for(const s in t)!H(t[s])&&!Ia(s,n)&&(e[s]=t[s])}function wf({transformTemplate:e},t){return f.useMemo(()=>{const n=Os();return Ls(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Tf(e,t){const n=e.style||{},s={};return La(s,n,e),Object.assign(s,wf(e,t)),s}function jf(e,t){const n={},s=Tf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Cf={offset:"stroke-dashoffset",array:"stroke-dasharray"},Pf={offset:"strokeDashoffset",array:"strokeDasharray"};function Af(e,t,n=1,s=0,i=!0){e.pathLength=1;const o=i?Cf:Pf;e[o.offset]=A.transform(-s);const r=A.transform(t),l=A.transform(n);e[o.array]=`${r} ${l}`}function Oa(e,{attrX:t,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...l},c,d,u){if(Ls(e,l,d),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:p}=e;h.transform&&(p.transform=h.transform,delete h.transform),(p.transform||h.transformOrigin)&&(p.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),p.transform&&(p.transformBox=(u==null?void 0:u.transformBox)??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),i!==void 0&&Af(h,i,o,r,!1)}const Fa=()=>({...Os(),attrs:{}}),Ba=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Rf(e,t,n,s){const i=f.useMemo(()=>{const o=Fa();return Oa(o,t,Ba(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};La(o,e.style,e),i.style={...o,...i.style}}return i}const Nf=["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 Fs(e){return typeof e!="string"||e.includes("-")?!1:!!(Nf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Ef(e=!1){return(n,s,i,{latestValues:o},r)=>{const c=(Fs(n)?Rf:jf)(s,o,r,n),d=rf(s,typeof n=="string",e),u=n!==f.Fragment?{...d,...c,ref:i}:{},{children:h}=s,p=f.useMemo(()=>H(h)?h.get():h,[h]);return f.createElement(n,{...u,children:p})}}function gi(e){const t=[{},{}];return e==null||e.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Bs(e,t,n,s){if(typeof t=="function"){const[i,o]=gi(s);t=t(n!==void 0?n:e.custom,i,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,o]=gi(s);t=t(n!==void 0?n:e.custom,i,o)}return t}function Dt(e){return H(e)?e.get():e}function kf({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:Mf(n,s,i,e),renderState:t()}}const _a=e=>(t,n)=>{const s=f.useContext(Jt),i=f.useContext(Qt),o=()=>kf(e,t,s,i);return n?o():ls(o)};function Mf(e,t,n,s){const i={},o=s(e,{});for(const p in o)i[p]=Dt(o[p]);let{initial:r,animate:l}=e;const c=tn(e),d=ka(e);t&&d&&!c&&e.inherit!==!1&&(r===void 0&&(r=t.initial),l===void 0&&(l=t.animate));let u=n?n.initial===!1:!1;u=u||r===!1;const h=u?l:r;if(h&&typeof h!="boolean"&&!en(h)){const p=Array.isArray(h)?h:[h];for(let m=0;m<p.length;m++){const v=Bs(e,p[m]);if(v){const{transitionEnd:g,transition:x,...y}=v;for(const w in y){let S=y[w];if(Array.isArray(S)){const C=u?S.length-1:0;S=S[C]}S!==null&&(i[w]=S)}for(const w in g)i[w]=g[w]}}}return i}function _s(e,t,n){var o;const{style:s}=e,i={};for(const r in s)(H(s[r])||t.style&&H(t.style[r])||Ia(r,e)||((o=n==null?void 0:n.getValue(r))==null?void 0:o.liveStyle)!==void 0)&&(i[r]=s[r]);return i}const Df={useVisualState:_a({scrapeMotionValuesFromProps:_s,createRenderState:Os})};function Ua(e,t,n){const s=_s(e,t,n);for(const i in e)if(H(e[i])||H(t[i])){const o=nt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=e[i]}return s}const Vf={useVisualState:_a({scrapeMotionValuesFromProps:Ua,createRenderState:Fa})};function If(e,t){return function(s,{forwardMotionProps:i}={forwardMotionProps:!1}){const r={...Fs(s)?Vf:Df,preloadedFeatures:e,useRender:Ef(i),createVisualElement:t,Component:s};return pf(r)}}function vt(e,t,n){const s=e.getProps();return Bs(s,t,n!==void 0?n:s.custom,e)}const Un=e=>Array.isArray(e);function Lf(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Xe(n))}function Of(e){return Un(e)?e[e.length-1]||0:e}function Ff(e,t){const n=vt(e,t);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const l=Of(o[r]);Lf(e,r,l)}}function Bf(e){return!!(H(e)&&e.add)}function $n(e,t){const n=e.getValue("willChange");if(Bf(n))return n.add(t);if(!n&&ge.WillChange){const s=new ge.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function $a(e){return e.props[Ma]}const _f=e=>e!==null;function Uf(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(_f),o=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[o]}const $f={type:"spring",stiffness:500,damping:25,restSpeed:10},zf=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Kf={type:"keyframes",duration:.8},Gf={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},qf=(e,{keyframes:t})=>t.length>2?Kf:st.has(e)?e.startsWith("scale")?zf(t[1]):$f:Gf;function Wf({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:l,from:c,elapsed:d,...u}){return!!Object.keys(u).length}const Us=(e,t,n,s={},i,o)=>r=>{const l=Rs(s,e)||{},c=l.delay||s.delay||0;let{elapsed:d=0}=s;d=d-he(c);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:p=>{t.set(p),l.onUpdate&&l.onUpdate(p)},onComplete:()=>{r(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:o?void 0:i};Wf(l)||Object.assign(u,qf(e,u)),u.duration&&(u.duration=he(u.duration)),u.repeatDelay&&(u.repeatDelay=he(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(u.duration=0,u.delay===0&&(h=!0)),(ge.instantAnimations||ge.skipAnimations)&&(h=!0,u.duration=0,u.delay=0),u.allowFlatten=!l.type&&!l.ease,h&&!o&&t.get()!==void 0){const p=Uf(u.keyframes,l);if(p!==void 0){B.update(()=>{u.onUpdate(p),u.onComplete()});return}}return l.isSync?new Cs(u):new Ch(u)};function Hf({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function za(e,t,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:r,...l}=t;s&&(o=s);const c=[],d=i&&e.animationState&&e.animationState.getState()[i];for(const u in l){const h=e.getValue(u,e.latestValues[u]??null),p=l[u];if(p===void 0||d&&Hf(d,u))continue;const m={delay:n,...Rs(o||{},u)},v=h.get();if(v!==void 0&&!h.isAnimating&&!Array.isArray(p)&&p===v&&!m.velocity)continue;let g=!1;if(window.MotionHandoffAnimation){const y=$a(e);if(y){const w=window.MotionHandoffAnimation(y,u,B);w!==null&&(m.startTime=w,g=!0)}}$n(e,u),h.start(Us(u,h,p,e.shouldReduceMotion&&xa.has(u)?{type:!1}:m,e,g));const x=h.animation;x&&c.push(x)}return r&&Promise.all(c).then(()=>{B.update(()=>{r&&Ff(e,r)})}),c}function zn(e,t,n={}){var c;const s=vt(e,t,n.type==="exit"?(c=e.presenceContext)==null?void 0:c.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(za(e,s,n)):()=>Promise.resolve(),r=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:u=0,staggerChildren:h,staggerDirection:p}=i;return Yf(e,t,u+d,h,p,n)}:()=>Promise.resolve(),{when:l}=i;if(l){const[d,u]=l==="beforeChildren"?[o,r]:[r,o];return d().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function Yf(e,t,n=0,s=0,i=1,o){const r=[],l=(e.variantChildren.size-1)*s,c=i===1?(d=0)=>d*s:(d=0)=>l-d*s;return Array.from(e.variantChildren).sort(Xf).forEach((d,u)=>{d.notify("AnimationStart",t),r.push(zn(d,t,{...o,delay:n+c(u)}).then(()=>d.notify("AnimationComplete",t)))}),Promise.all(r)}function Xf(e,t){return e.sortNodePosition(t)}function Zf(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(o=>zn(e,o,n));s=Promise.all(i)}else if(typeof t=="string")s=zn(e,t,n);else{const i=typeof t=="function"?vt(e,t,n.custom):t;s=Promise.all(za(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function Ka(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const Qf=Vs.length;function Ga(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Ga(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Qf;n++){const s=Vs[n],i=e.props[s];(yt(i)||i===!1)&&(t[s]=i)}return t}const Jf=[...Ds].reverse(),ep=Ds.length;function tp(e){return t=>Promise.all(t.map(({animation:n,options:s})=>Zf(e,n,s)))}function np(e){let t=tp(e),n=yi(),s=!0;const i=c=>(d,u)=>{var p;const h=vt(e,u,c==="exit"?(p=e.presenceContext)==null?void 0:p.custom:void 0);if(h){const{transition:m,transitionEnd:v,...g}=h;d={...d,...g,...v}}return d};function o(c){t=c(e)}function r(c){const{props:d}=e,u=Ga(e.parent)||{},h=[],p=new Set;let m={},v=1/0;for(let x=0;x<ep;x++){const y=Jf[x],w=n[y],S=d[y]!==void 0?d[y]:u[y],C=yt(S),b=y===c?w.isActive:null;b===!1&&(v=x);let j=S===u[y]&&S!==d[y]&&C;if(j&&s&&e.manuallyAnimateOnMount&&(j=!1),w.protectedKeys={...m},!w.isActive&&b===null||!S&&!w.prevProp||en(S)||typeof S=="boolean")continue;const N=sp(w.prevProp,S);let P=N||y===c&&w.isActive&&!j&&C||x>v&&C,D=!1;const E=Array.isArray(S)?S:[S];let M=E.reduce(i(y),{});b===!1&&(M={});const{prevResolvedValues:W={}}=w,Y={...W,...M},ye=V=>{P=!0,p.has(V)&&(D=!0,p.delete(V)),w.needsAnimating[V]=!0;const K=e.getValue(V);K&&(K.liveStyle=!1)};for(const V in Y){const K=M[V],T=W[V];if(m.hasOwnProperty(V))continue;let R=!1;Un(K)&&Un(T)?R=!Ka(K,T):R=K!==T,R?K!=null?ye(V):p.add(V):K!==void 0&&p.has(V)?ye(V):w.protectedKeys[V]=!0}w.prevProp=S,w.prevResolvedValues=M,w.isActive&&(m={...m,...M}),s&&e.blockInitialAnimation&&(P=!1),P&&(!(j&&N)||D)&&h.push(...E.map(V=>({animation:V,options:{type:y}})))}if(p.size){const x={};if(typeof d.initial!="boolean"){const y=vt(e,Array.isArray(d.initial)?d.initial[0]:d.initial);y&&y.transition&&(x.transition=y.transition)}p.forEach(y=>{const w=e.getBaseTarget(y),S=e.getValue(y);S&&(S.liveStyle=!0),x[y]=w??null}),h.push({animation:x})}let g=!!h.length;return s&&(d.initial===!1||d.initial===d.animate)&&!e.manuallyAnimateOnMount&&(g=!1),s=!1,g?t(h):Promise.resolve()}function l(c,d){var h;if(n[c].isActive===d)return Promise.resolve();(h=e.variantChildren)==null||h.forEach(p=>{var m;return(m=p.animationState)==null?void 0:m.setActive(c,d)}),n[c].isActive=d;const u=r(c);for(const p in n)n[p].protectedKeys={};return u}return{animateChanges:r,setActive:l,setAnimateFunction:o,getState:()=>n,reset:()=>{n=yi(),s=!0}}}function sp(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Ka(t,e):!1}function Ae(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function yi(){return{animate:Ae(!0),whileInView:Ae(),whileHover:Ae(),whileTap:Ae(),whileDrag:Ae(),whileFocus:Ae(),exit:Ae()}}class Pe{constructor(t){this.isMounted=!1,this.node=t}update(){}}class ip extends Pe{constructor(t){super(t),t.animationState||(t.animationState=np(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();en(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let rp=0;class op extends Pe{constructor(){super(...arguments),this.id=rp++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const ap={animation:{Feature:ip},exit:{Feature:op}};function bt(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Ct(e){return{point:{x:e.pageX,y:e.pageY}}}const lp=e=>t=>ks(t)&&e(t,Ct(t));function ut(e,t,n,s){return bt(e,t,lp(n),s)}function qa({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function cp({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function up(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}const Wa=1e-4,dp=1-Wa,hp=1+Wa,Ha=.01,fp=0-Ha,pp=0+Ha;function Z(e){return e.max-e.min}function mp(e,t,n){return Math.abs(e-t)<=n}function xi(e,t,n,s=.5){e.origin=s,e.originPoint=F(t.min,t.max,e.origin),e.scale=Z(n)/Z(t),e.translate=F(n.min,n.max,e.origin)-e.originPoint,(e.scale>=dp&&e.scale<=hp||isNaN(e.scale))&&(e.scale=1),(e.translate>=fp&&e.translate<=pp||isNaN(e.translate))&&(e.translate=0)}function dt(e,t,n,s){xi(e.x,t.x,n.x,s?s.originX:void 0),xi(e.y,t.y,n.y,s?s.originY:void 0)}function vi(e,t,n){e.min=n.min+t.min,e.max=e.min+Z(t)}function gp(e,t,n){vi(e.x,t.x,n.x),vi(e.y,t.y,n.y)}function bi(e,t,n){e.min=t.min-n.min,e.max=e.min+Z(t)}function ht(e,t,n){bi(e.x,t.x,n.x),bi(e.y,t.y,n.y)}const Si=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ke=()=>({x:Si(),y:Si()}),wi=()=>({min:0,max:0}),U=()=>({x:wi(),y:wi()});function ne(e){return[e("x"),e("y")]}function hn(e){return e===void 0||e===1}function Kn({scale:e,scaleX:t,scaleY:n}){return!hn(e)||!hn(t)||!hn(n)}function Re(e){return Kn(e)||Ya(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ya(e){return Ti(e.x)||Ti(e.y)}function Ti(e){return e&&e!=="0%"}function Bt(e,t,n){const s=e-n,i=t*s;return n+i}function ji(e,t,n,s,i){return i!==void 0&&(e=Bt(e,i,s)),Bt(e,n,s)+t}function Gn(e,t=0,n=1,s,i){e.min=ji(e.min,t,n,s,i),e.max=ji(e.max,t,n,s,i)}function Xa(e,{x:t,y:n}){Gn(e.x,t.translate,t.scale,t.originPoint),Gn(e.y,n.translate,n.scale,n.originPoint)}const Ci=.999999999999,Pi=1.0000000000001;function yp(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let o,r;for(let l=0;l<i;l++){o=n[l],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&qe(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(t.x*=r.x.scale,t.y*=r.y.scale,Xa(e,r)),s&&Re(o.latestValues)&&qe(e,o.latestValues))}t.x<Pi&&t.x>Ci&&(t.x=1),t.y<Pi&&t.y>Ci&&(t.y=1)}function Ge(e,t){e.min=e.min+t,e.max=e.max+t}function Ai(e,t,n,s,i=.5){const o=F(e.min,e.max,i);Gn(e,t,n,o,s)}function qe(e,t){Ai(e.x,t.x,t.scaleX,t.scale,t.originX),Ai(e.y,t.y,t.scaleY,t.scale,t.originY)}function Za(e,t){return qa(up(e.getBoundingClientRect(),t))}function xp(e,t,n){const s=Za(e,n),{scroll:i}=t;return i&&(Ge(s.x,i.offset.x),Ge(s.y,i.offset.y)),s}const Qa=({current:e})=>e?e.ownerDocument.defaultView:null,Ri=(e,t)=>Math.abs(e-t);function vp(e,t){const n=Ri(e.x,t.x),s=Ri(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ja{constructor(t,n,{transformPagePoint:s,contextWindow:i,dragSnapToOrigin:o=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const h=pn(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,m=vp(h.offset,{x:0,y:0})>=3;if(!p&&!m)return;const{point:v}=h,{timestamp:g}=q;this.history.push({...v,timestamp:g});const{onStart:x,onMove:y}=this.handlers;p||(x&&x(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,h)},this.handlePointerMove=(h,p)=>{this.lastMoveEvent=h,this.lastMoveEventInfo=fn(p,this.transformPagePoint),B.update(this.updatePoint,!0)},this.handlePointerUp=(h,p)=>{this.end();const{onEnd:m,onSessionEnd:v,resumeAnimation:g}=this.handlers;if(this.dragSnapToOrigin&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=pn(h.type==="pointercancel"?this.lastMoveEventInfo:fn(p,this.transformPagePoint),this.history);this.startEvent&&m&&m(h,x),v&&v(h,x)},!ks(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.contextWindow=i||window;const r=Ct(t),l=fn(r,this.transformPagePoint),{point:c}=l,{timestamp:d}=q;this.history=[{...c,timestamp:d}];const{onSessionStart:u}=n;u&&u(t,pn(l,this.history)),this.removeListeners=wt(ut(this.contextWindow,"pointermove",this.handlePointerMove),ut(this.contextWindow,"pointerup",this.handlePointerUp),ut(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),we(this.updatePoint)}}function fn(e,t){return t?{point:t(e.point)}:e}function Ni(e,t){return{x:e.x-t.x,y:e.y-t.y}}function pn({point:e},t){return{point:e,delta:Ni(e,el(t)),offset:Ni(e,bp(t)),velocity:Sp(t,.1)}}function bp(e){return e[0]}function el(e){return e[e.length-1]}function Sp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=el(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>he(t)));)n--;if(!s)return{x:0,y:0};const o=fe(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function wp(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?F(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?F(n,e,s.max):Math.min(e,n)),e}function Ei(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Tp(e,{top:t,left:n,bottom:s,right:i}){return{x:Ei(e.x,n,i),y:Ei(e.y,t,s)}}function ki(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function jp(e,t){return{x:ki(e.x,t.x),y:ki(e.y,t.y)}}function Cp(e,t){let n=.5;const s=Z(e),i=Z(t);return i>s?n=pt(t.min,t.max-s,e.min):s>i&&(n=pt(e.min,e.max-i,t.min)),me(0,1,n)}function Pp(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const qn=.35;function Ap(e=qn){return e===!1?e=0:e===!0&&(e=qn),{x:Mi(e,"left","right"),y:Mi(e,"top","bottom")}}function Mi(e,t,n){return{min:Di(e,t),max:Di(e,n)}}function Di(e,t){return typeof e=="number"?e:e[t]||0}const Rp=new WeakMap;class Np{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=U(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=u=>{const{dragSnapToOrigin:h}=this.getProps();h?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ct(u).point)},o=(u,h)=>{const{drag:p,dragPropagation:m,onDragStart:v}=this.getProps();if(p&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Uh(p),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ne(x=>{let y=this.getAxisMotionValue(x).get()||0;if(pe.test(y)){const{projection:w}=this.visualElement;if(w&&w.layout){const S=w.layout.layoutBox[x];S&&(y=Z(S)*(parseFloat(y)/100))}}this.originPoint[x]=y}),v&&B.postRender(()=>v(u,h)),$n(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},r=(u,h)=>{const{dragPropagation:p,dragDirectionLock:m,onDirectionLock:v,onDrag:g}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:x}=h;if(m&&this.currentDirection===null){this.currentDirection=Ep(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",h.point,x),this.updateAxis("y",h.point,x),this.visualElement.render(),g&&g(u,h)},l=(u,h)=>this.stop(u,h),c=()=>ne(u=>{var h;return this.getAnimationState(u)==="paused"&&((h=this.getAxisMotionValue(u).animation)==null?void 0:h.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ja(t,{onSessionStart:i,onStart:o,onMove:r,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,contextWindow:Qa(this.visualElement)})}stop(t,n){const s=this.isDragging;if(this.cancel(),!s)return;const{velocity:i}=n;this.startAnimation(i);const{onDragEnd:o}=this.getProps();o&&B.postRender(()=>o(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!Et(t,i,this.currentDirection))return;const o=this.getAxisMotionValue(t);let r=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(r=wp(r,this.constraints[t],this.elastic[t])),o.set(r)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,i=this.constraints;t&&ze(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Tp(s.layoutBox,t):this.constraints=!1,this.elastic=Ap(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&ne(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=Pp(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!ze(t))return!1;const s=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=xp(s,i.root,this.visualElement.getTransformPagePoint());let r=jp(i.layout.layoutBox,o);if(n){const l=n(cp(r));this.hasMutatedConstraints=!!l,l&&(r=qa(l))}return r}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=ne(u=>{if(!Et(u,n,this.currentDirection))return;let h=c&&c[u]||{};r&&(h={min:0,max:0});const p=i?200:1e6,m=i?40:1e7,v={type:"inertia",velocity:s?t[u]:0,bounceStiffness:p,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(u,v)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return $n(this.visualElement,t),s.start(Us(t,s,0,n,this.visualElement,!1))}stopAnimation(){ne(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){ne(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){ne(n=>{const{drag:s}=this.getProps();if(!Et(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:l}=i.layout.layoutBox[n];o.set(t[n]-F(r,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!ze(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ne(r=>{const l=this.getAxisMotionValue(r);if(l&&this.constraints!==!1){const c=l.get();i[r]=Cp({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),ne(r=>{if(!Et(r,t,null))return;const l=this.getAxisMotionValue(r),{min:c,max:d}=this.constraints[r];l.set(F(c,d,i[r]))})}addListeners(){if(!this.visualElement.current)return;Rp.set(this.visualElement,this);const t=this.visualElement.current,n=ut(t,"pointerdown",c=>{const{drag:d,dragListener:u=!0}=this.getProps();d&&u&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();ze(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),B.read(s);const r=bt(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d})=>{this.isDragging&&d&&(ne(u=>{const h=this.getAxisMotionValue(u);h&&(this.originPoint[u]+=c[u].translate,h.set(h.get()+c[u].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=qn,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:l}}}function Et(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ep(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class kp extends Pe{constructor(t){super(t),this.removeGroupControls=ae,this.removeListeners=ae,this.controls=new Np(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ae}unmount(){this.removeGroupControls(),this.removeListeners()}}const Vi=e=>(t,n)=>{e&&B.postRender(()=>e(t,n))};class Mp extends Pe{constructor(){super(...arguments),this.removePointerDownListener=ae}onPointerDown(t){this.session=new Ja(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Qa(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Vi(t),onStart:Vi(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&B.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=ut(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Vt={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Ii(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const it={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(A.test(e))e=parseFloat(e);else return e;const n=Ii(e,t.target.x),s=Ii(e,t.target.y);return`${n}% ${s}%`}},Dp={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Te.parse(e);if(i.length>5)return s;const o=Te.createTransformer(e),r=typeof i[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;i[0+r]/=l,i[1+r]/=c;const d=F(l,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=d),typeof i[3+r]=="number"&&(i[3+r]/=d),o(i)}};class Vp extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=t;xf(Ip),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Vt.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,i||t.layoutDependency!==n||n===void 0||t.isPresent!==o?r.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?r.promote():r.relegate()||B.postRender(()=>{const l=r.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Es.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function tl(e){const[t,n]=Ra(),s=f.useContext(as);return a.jsx(Vp,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Da),isPresent:t,safeToRemove:n})}const Ip={borderRadius:{...it,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:it,borderTopRightRadius:it,borderBottomLeftRadius:it,borderBottomRightRadius:it,boxShadow:Dp};function Lp(e,t,n){const s=H(e)?e:Xe(e);return s.start(Us("",s,t,n)),s.animation}const Op=(e,t)=>e.depth-t.depth;class Fp{constructor(){this.children=[],this.isDirty=!1}add(t){us(this.children,t),this.isDirty=!0}remove(t){ds(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Op),this.isDirty=!1,this.children.forEach(t)}}function Bp(e,t){const n=J.now(),s=({timestamp:i})=>{const o=i-n;o>=t&&(we(s),e(o-t))};return B.setup(s,!0),()=>we(s)}const nl=["TopLeft","TopRight","BottomLeft","BottomRight"],_p=nl.length,Li=e=>typeof e=="string"?parseFloat(e):e,Oi=e=>typeof e=="number"||A.test(e);function Up(e,t,n,s,i,o){i?(e.opacity=F(0,n.opacity??1,$p(s)),e.opacityExit=F(t.opacity??1,0,zp(s))):o&&(e.opacity=F(t.opacity??1,n.opacity??1,s));for(let r=0;r<_p;r++){const l=`border${nl[r]}Radius`;let c=Fi(t,l),d=Fi(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||Oi(c)===Oi(d)?(e[l]=Math.max(F(Li(c),Li(d),s),0),(pe.test(d)||pe.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=F(t.rotate||0,n.rotate||0,s))}function Fi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const $p=sl(0,.5,Yo),zp=sl(.5,.95,ae);function sl(e,t,n){return s=>s<e?0:s>t?1:n(pt(e,t,s))}function Bi(e,t){e.min=t.min,e.max=t.max}function te(e,t){Bi(e.x,t.x),Bi(e.y,t.y)}function _i(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Ui(e,t,n,s,i){return e-=t,e=Bt(e,1/n,s),i!==void 0&&(e=Bt(e,1/i,s)),e}function Kp(e,t=0,n=1,s=.5,i,o=e,r=e){if(pe.test(t)&&(t=parseFloat(t),t=F(r.min,r.max,t/100)-r.min),typeof t!="number")return;let l=F(o.min,o.max,s);e===o&&(l-=t),e.min=Ui(e.min,t,n,l,i),e.max=Ui(e.max,t,n,l,i)}function $i(e,t,[n,s,i],o,r){Kp(e,t[n],t[s],t[i],t.scale,o,r)}const Gp=["x","scaleX","originX"],qp=["y","scaleY","originY"];function zi(e,t,n,s){$i(e.x,t,Gp,n?n.x:void 0,s?s.x:void 0),$i(e.y,t,qp,n?n.y:void 0,s?s.y:void 0)}function Ki(e){return e.translate===0&&e.scale===1}function il(e){return Ki(e.x)&&Ki(e.y)}function Gi(e,t){return e.min===t.min&&e.max===t.max}function Wp(e,t){return Gi(e.x,t.x)&&Gi(e.y,t.y)}function qi(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function rl(e,t){return qi(e.x,t.x)&&qi(e.y,t.y)}function Wi(e){return Z(e.x)/Z(e.y)}function Hi(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Hp{constructor(){this.members=[]}add(t){us(this.members,t),t.scheduleRender()}remove(t){if(ds(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Yp(e,t,n){let s="";const i=e.x.translate/t.x,o=e.y.translate/t.y,r=(n==null?void 0:n.z)||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:u,rotateX:h,rotateY:p,skewX:m,skewY:v}=n;d&&(s=`perspective(${d}px) ${s}`),u&&(s+=`rotate(${u}deg) `),h&&(s+=`rotateX(${h}deg) `),p&&(s+=`rotateY(${p}deg) `),m&&(s+=`skewX(${m}deg) `),v&&(s+=`skewY(${v}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const mn=["","X","Y","Z"],Xp={visibility:"hidden"},Zp=1e3;let Qp=0;function gn(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function ol(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=$a(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",B,!(i||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&ol(s)}function al({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},l=t==null?void 0:t()){this.id=Qp++,this.animationId=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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(tm),this.nodes.forEach(om),this.nodes.forEach(am),this.nodes.forEach(nm)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Fp)}addEventListener(r,l){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new ps),this.eventHandlers.get(r).add(l)}notifyListeners(r,...l){const c=this.eventHandlers.get(r);c&&c.notify(...l)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Aa(r)&&!Wh(r),this.instance=r;const{layoutId:l,layout:c,visualElement:d}=this.options;if(d&&!d.current&&d.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||l)&&(this.isLayoutDirty=!0),e){let u;const h=()=>this.root.updateBlockedByResize=!1;e(r,()=>{this.root.updateBlockedByResize=!0,u&&u(),u=Bp(h,250),Vt.hasAnimatedSinceResize&&(Vt.hasAnimatedSinceResize=!1,this.nodes.forEach(Xi))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||c)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h,hasRelativeLayoutChanged:p,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const v=this.options.transition||d.getDefaultTransition()||hm,{onLayoutAnimationStart:g,onLayoutAnimationComplete:x}=d.getProps(),y=!this.targetLayout||!rl(this.targetLayout,m),w=!h&&p;if(this.options.layoutRoot||this.resumeFrom||w||h&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Rs(v,"layout"),onPlay:g,onComplete:x};(d.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(u,w)}else h||Xi(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),we(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(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(lm),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ol(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const h=this.path[u];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Yi);return}this.isUpdating||this.nodes.forEach(im),this.isUpdating=!1,this.nodes.forEach(rm),this.nodes.forEach(Jp),this.nodes.forEach(em),this.clearAllSnapshots();const l=J.now();q.delta=me(0,1e3/60,l-q.timestamp),q.timestamp=l,q.isProcessing=!0,on.update.process(q),on.preRender.process(q),on.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Es.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(sm),this.sharedNodes.forEach(cm)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,B.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){B.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Z(this.snapshot.measuredBox.x)&&!Z(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=U(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(l=!1),l&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!il(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,u=d!==this.prevTransformTemplateValue;r&&this.instance&&(l||Re(this.latestValues)||u)&&(i(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return r&&(c=this.removeTransform(c)),fm(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:r}=this.options;if(!r)return U();const l=r.measureViewportBox();if(!(((d=this.scroll)==null?void 0:d.wasRoot)||this.path.some(pm))){const{scroll:u}=this.root;u&&(Ge(l.x,u.offset.x),Ge(l.y,u.offset.y))}return l}removeElementScroll(r){var c;const l=U();if(te(l,r),(c=this.scroll)!=null&&c.wasRoot)return l;for(let d=0;d<this.path.length;d++){const u=this.path[d],{scroll:h,options:p}=u;u!==this.root&&h&&p.layoutScroll&&(h.wasRoot&&te(l,r),Ge(l.x,h.offset.x),Ge(l.y,h.offset.y))}return l}applyTransform(r,l=!1){const c=U();te(c,r);for(let d=0;d<this.path.length;d++){const u=this.path[d];!l&&u.options.layoutScroll&&u.scroll&&u!==u.root&&qe(c,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),Re(u.latestValues)&&qe(c,u.latestValues)}return Re(this.latestValues)&&qe(c,this.latestValues),c}removeTransform(r){const l=U();te(l,r);for(let c=0;c<this.path.length;c++){const d=this.path[c];if(!d.instance||!Re(d.latestValues))continue;Kn(d.latestValues)&&d.updateSnapshot();const u=U(),h=d.measurePageBox();te(u,h),zi(l,d.latestValues,d.snapshot?d.snapshot.layoutBox:void 0,u)}return Re(this.latestValues)&&zi(l,this.latestValues),l}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.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(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){var p;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(p=this.parent)!=null&&p.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:h}=this.options;if(!(!this.layout||!(u||h))){if(this.resolvedRelativeTargetAt=q.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=U(),this.relativeTargetOrigin=U(),ht(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),te(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=U(),this.targetWithTransforms=U()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gp(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):te(this.target,this.layout.layoutBox),Xa(this.target,this.targetDelta)):te(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=U(),this.relativeTargetOrigin=U(),ht(this.relativeTargetOrigin,this.target,m.target),te(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Kn(this.parent.latestValues)||Ya(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var v;const r=this.getLead(),l=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||(v=this.parent)!=null&&v.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===q.timestamp&&(c=!1),c)return;const{layout:d,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||u))return;te(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,p=this.treeScale.y;yp(this.layoutCorrected,this.treeScale,this.path,l),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=U());const{target:m}=r;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(_i(this.prevProjectionDelta.x,this.projectionDelta.x),_i(this.prevProjectionDelta.y,this.projectionDelta.y)),dt(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==p||!Hi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Hi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){var l;if((l=this.options.visualElement)==null||l.scheduleRender(),r){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ke(),this.projectionDelta=Ke(),this.projectionDeltaWithTransform=Ke()}setAnimationOrigin(r,l=!1){const c=this.snapshot,d=c?c.latestValues:{},u={...this.latestValues},h=Ke();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const p=U(),m=c?c.source:void 0,v=this.layout?this.layout.source:void 0,g=m!==v,x=this.getStack(),y=!x||x.members.length<=1,w=!!(g&&!y&&this.options.crossfade===!0&&!this.path.some(dm));this.animationProgress=0;let S;this.mixTargetDelta=C=>{const b=C/1e3;Zi(h.x,r.x,b),Zi(h.y,r.y,b),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ht(p,this.layout.layoutBox,this.relativeParent.layout.layoutBox),um(this.relativeTarget,this.relativeTargetOrigin,p,b),S&&Wp(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=U()),te(S,this.relativeTarget)),g&&(this.animationValues=u,Up(u,d,this.latestValues,b,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=b},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){var l,c,d;this.notifyListeners("animationStart"),(l=this.currentAnimation)==null||l.stop(),(d=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||d.stop(),this.pendingAnimation&&(we(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=B.update(()=>{Vt.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Xe(0)),this.currentAnimation=Lp(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),r.onUpdate&&r.onUpdate(u)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Zp),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:u}=r;if(!(!l||!c||!d)){if(this!==r&&this.layout&&d&&ll(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||U();const h=Z(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+h;const p=Z(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+p}te(l,c),qe(l,u),dt(this.projectionDeltaWithTransform,this.layoutCorrected,l,u)}}registerSharedNode(r,l){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Hp),this.sharedNodes.get(r).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){var l;const{layoutId:r}=this.options;return r?((l=this.getStack())==null?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:r}=this.options;return r?(l=this.getStack())==null?void 0:l.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let l=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&gn("z",r,d,this.animationValues);for(let u=0;u<mn.length;u++)gn(`rotate${mn[u]}`,r,d,this.animationValues),gn(`skew${mn[u]}`,r,d,this.animationValues);r.render();for(const u in d)r.setStaticValue(u,d[u]),this.animationValues&&(this.animationValues[u]=d[u]);r.scheduleRender()}getProjectionStyles(r){if(!this.instance||this.isSVG)return;if(!this.isVisible)return Xp;const l={visibility:""},c=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,l.opacity="",l.pointerEvents=Dt(r==null?void 0:r.pointerEvents)||"",l.transform=c?c(this.latestValues,""):"none",l;const d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){const m={};return this.options.layoutId&&(m.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,m.pointerEvents=Dt(r==null?void 0:r.pointerEvents)||""),this.hasProjected&&!Re(this.latestValues)&&(m.transform=c?c({},""):"none",this.hasProjected=!1),m}const u=d.animationValues||d.latestValues;this.applyTransformsToTarget(),l.transform=Yp(this.projectionDeltaWithTransform,this.treeScale,u),c&&(l.transform=c(u,l.transform));const{x:h,y:p}=this.projectionDelta;l.transformOrigin=`${h.origin*100}% ${p.origin*100}% 0`,d.animationValues?l.opacity=d===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:l.opacity=d===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const m in xt){if(u[m]===void 0)continue;const{correct:v,applyTo:g,isCSSVariable:x}=xt[m],y=l.transform==="none"?u[m]:v(u[m],d);if(g){const w=g.length;for(let S=0;S<w;S++)l[g[S]]=y}else x?this.options.visualElement.renderState.vars[m]=y:l[m]=y}return this.options.layoutId&&(l.pointerEvents=d===this?Dt(r==null?void 0:r.pointerEvents)||"":"none"),l}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>{var l;return(l=r.currentAnimation)==null?void 0:l.stop()}),this.root.nodes.forEach(Yi),this.root.sharedNodes.clear()}}}function Jp(e){e.updateLayout()}function em(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:i}=e.layout,{animationType:o}=e.options,r=t.source!==e.layout.source;o==="size"?ne(h=>{const p=r?t.measuredBox[h]:t.layoutBox[h],m=Z(p);p.min=s[h].min,p.max=p.min+m}):ll(o,t.layoutBox,s)&&ne(h=>{const p=r?t.measuredBox[h]:t.layoutBox[h],m=Z(s[h]);p.max=p.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[h].max=e.relativeTarget[h].min+m)});const l=Ke();dt(l,s,t.layoutBox);const c=Ke();r?dt(c,e.applyTransform(i,!0),t.measuredBox):dt(c,s,t.layoutBox);const d=!il(l);let u=!1;if(!e.resumeFrom){const h=e.getClosestProjectingParent();if(h&&!h.resumeFrom){const{snapshot:p,layout:m}=h;if(p&&m){const v=U();ht(v,t.layoutBox,p.layoutBox);const g=U();ht(g,s,m.layoutBox),rl(v,g)||(u=!0),h.options.layoutRoot&&(e.relativeTarget=g,e.relativeTargetOrigin=v,e.relativeParent=h)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:t,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:s}=e.options;s&&s()}e.options.transition=void 0}function tm(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function nm(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function sm(e){e.clearSnapshot()}function Yi(e){e.clearMeasurements()}function im(e){e.isLayoutDirty=!1}function rm(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Xi(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function om(e){e.resolveTargetDelta()}function am(e){e.calcProjection()}function lm(e){e.resetSkewAndRotation()}function cm(e){e.removeLeadSnapshot()}function Zi(e,t,n){e.translate=F(t.translate,0,n),e.scale=F(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Qi(e,t,n,s){e.min=F(t.min,n.min,s),e.max=F(t.max,n.max,s)}function um(e,t,n,s){Qi(e.x,t.x,n.x,s),Qi(e.y,t.y,n.y,s)}function dm(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const hm={duration:.45,ease:[.4,0,.1,1]},Ji=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),er=Ji("applewebkit/")&&!Ji("chrome/")?Math.round:ae;function tr(e){e.min=er(e.min),e.max=er(e.max)}function fm(e){tr(e.x),tr(e.y)}function ll(e,t,n){return e==="position"||e==="preserve-aspect"&&!mp(Wi(t),Wi(n),.2)}function pm(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const mm=al({attachResizeListener:(e,t)=>bt(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),yn={current:void 0},cl=al({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!yn.current){const e=new mm({});e.mount(window),e.setOptions({layoutScroll:!0}),yn.current=e}return yn.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),gm={pan:{Feature:Mp},drag:{Feature:kp,ProjectionNode:cl,MeasureLayout:tl}};function nr(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&B.postRender(()=>o(t,Ct(t)))}class ym extends Pe{mount(){const{current:t}=this.node;t&&(this.unmount=$h(t,(n,s)=>(nr(this.node,s,"Start"),i=>nr(this.node,i,"End"))))}unmount(){}}class xm extends Pe{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=wt(bt(this.node.current,"focus",()=>this.onFocus()),bt(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function sr(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&B.postRender(()=>o(t,Ct(t)))}class vm extends Pe{mount(){const{current:t}=this.node;t&&(this.unmount=qh(t,(n,s)=>(sr(this.node,s,"Start"),(i,{success:o})=>sr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Wn=new WeakMap,xn=new WeakMap,bm=e=>{const t=Wn.get(e.target);t&&t(e)},Sm=e=>{e.forEach(bm)};function wm({root:e,...t}){const n=e||document;xn.has(n)||xn.set(n,{});const s=xn.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Sm,{root:e,...t})),s[i]}function Tm(e,t,n){const s=wm(t);return Wn.set(e,n),s.observe(e),()=>{Wn.delete(e),s.unobserve(e)}}const jm={some:0,all:1};class Cm extends Pe{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=t,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:jm[i]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,o&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:u,onViewportLeave:h}=this.node.getProps(),p=d?u:h;p&&p(c)};return Tm(this.node.current,r,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Pm(t,n))&&this.startObserver()}unmount(){}}function Pm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Am={inView:{Feature:Cm},tap:{Feature:vm},focus:{Feature:xm},hover:{Feature:ym}},Rm={layout:{ProjectionNode:cl,MeasureLayout:tl}},Hn={current:null},ul={current:!1};function Nm(){if(ul.current=!0,!!cs)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Hn.current=e.matches;e.addListener(t),t()}else Hn.current=!1}const Em=new WeakMap;function km(e,t,n){for(const s in t){const i=t[s],o=n[s];if(H(i))e.addValue(s,i);else if(H(o))e.addValue(s,Xe(i,{owner:e}));else if(o!==i)if(e.hasValue(s)){const r=e.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=e.getStaticValue(s);e.addValue(s,Xe(r!==void 0?r:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const ir=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Mm{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ps,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=J.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,B.render(this.render,!1,!0))};const{latestValues:c,renderState:d}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=d,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=l,this.blockInitialAnimation=!!o,this.isControllingVariants=tn(n),this.isVariantNode=ka(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in h){const m=h[p];c[p]!==void 0&&H(m)&&m.set(c[p],!1)}}mount(t){this.current=t,Em.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),ul.current||Nm(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Hn.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),we(this.notifyUpdate),we(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=st.has(t);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&B.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0)}),o=n.on("renderRequest",this.scheduleRender);let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),o(),r&&r(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Ze){const n=Ze[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):U()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<ir.length;s++){const i=ir[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=t[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=km(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Xe(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(Bo(s)||Uo(s))?s=parseFloat(s):!Yh(s)&&Te.test(n)&&(s=wa(t,n)),this.setBaseTarget(t,H(s)?s.get():s)),H(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=Bs(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);r&&(s=r[t])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!H(i)?i:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new ps),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class dl extends Mm{constructor(){super(...arguments),this.KeyframeResolver=Oh}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;H(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function hl(e,{style:t,vars:n},s,i){Object.assign(e.style,t,i&&i.getProjectionStyles(s));for(const o in n)e.style.setProperty(o,n[o])}function Dm(e){return window.getComputedStyle(e)}class Vm extends dl{constructor(){super(...arguments),this.type="html",this.renderInstance=hl}readValueFromInstance(t,n){var s;if(st.has(n))return(s=this.projection)!=null&&s.isProjecting?In(n):nh(t,n);{const i=Dm(t),o=(ys(n)?i.getPropertyValue(n):i[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Za(t,n)}build(t,n,s){Ls(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return _s(t,n,s)}}const fl=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"]);function Im(e,t,n,s){hl(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(fl.has(i)?i:Is(i),t.attrs[i])}class Lm extends dl{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=U}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(st.has(n)){const s=Sa(n);return s&&s.default||0}return n=fl.has(n)?n:Is(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Ua(t,n,s)}build(t,n,s){Oa(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,i){Im(t,n,s,i)}mount(t){this.isSVGTag=Ba(t.tagName),super.mount(t)}}const Om=(e,t)=>Fs(e)?new Lm(t):new Vm(t,{allowProjection:e!==f.Fragment}),Fm=If({...ap,...Am,...gm,...Rm},Om),rr=of(Fm);function Bm(){const{t:e}=je(),[t,n]=f.useState(X.aiServers),[s,i]=f.useState(null),[o,r]=f.useState(!1),[l,c]=f.useState(!1),d=f.useCallback(_t(g=>{r(!0),vl(g).then(()=>{console.debug("Save %s AI Servers success",g.length)}).catch(x=>{console.error("Failed to save AI servers:",x)}).finally(()=>{r(!1)})},1e3),[]);f.useEffect(()=>{(async()=>{try{const x=await Ut();n(x.aiServers),c(!0)}catch(x){console.error("Failed to load AI server settings:",x),c(!0)}})()},[]),f.useEffect(()=>{l&&d(t)},[t,d,l]);const u=()=>{const g={id:`server-${Date.now()}`,name:`AI Server ${t.length+1}`,provider:"openai",model:"gpt-4o",settings:{apiKey:""},isDefault:!1};n(x=>[...x,g]),i(g.id)},h=g=>{n(x=>{const y=x.find(S=>S.id===g),w=x.filter(S=>S.id!==g);return w.length===0?[]:y!=null&&y.isDefault?w.map((S,C)=>({...S,isDefault:C===0})):w}),s===g&&i(null)},p=g=>{n(x=>x.map(y=>y.id===g.id?g:y))},m=g=>{i(x=>x===g?null:g)},v=g=>{const x=t.find(y=>y.id===g);if(x&&!x.isBuiltin){const y=Oo(x,e);if(y.length>0){i(g),kl.error(e("ai.fixErrors","Please fix the following errors:"),{description:a.jsx("ul",{className:"list-disc pl-5 text-sm mt-2",children:y.map((w,S)=>a.jsx("li",{children:w},S))}),duration:5e3});return}}n(y=>y.map(w=>({...w,isDefault:w.id===g})))};return a.jsxs(ke,{className:"border-2 border-primary/10 gradient-border card-glow",children:[a.jsxs(Me,{children:[a.jsxs(De,{className:"flex items-center gap-2",children:[a.jsx(vc,{className:"h-5 w-5 text-primary"}),a.jsx("span",{className:"gradient-text",children:e("ai.title","AI Server Settings")})]}),a.jsx(We,{children:e("ai.desc","Configure your AI providers and models for language learning")})]}),a.jsxs(Ve,{className:"space-y-6",children:[a.jsx(ot,{className:"border-primary/20",children:a.jsx(at,{children:e("ai.banner","Subtitle translation is now batch and context-aware, requiring a more capable model. For better results, use a larger model, or subscribe to built-in DeepAcquire AI (recommended).")})}),t.length===0?a.jsxs("div",{className:"text-center py-8 space-y-4",children:[a.jsx("div",{className:"mx-auto w-16 h-16 bg-muted/50 rounded-full flex items-center justify-center",children:a.jsx(zs,{className:"h-8 w-8 text-muted-foreground"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h3",{className:"text-lg font-medium",children:e("ai.emptyTitle","No AI Servers Configured")}),a.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:e("ai.emptyDesc","Add an AI server to enable contextual word analysis and enhanced learning features. Popular options include OpenAI, Anthropic, and DeepSeek.")})]})]}):a.jsx("div",{className:"space-y-4",children:t.map(g=>a.jsxs(rr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,height:0,overflow:"hidden"},transition:{duration:.3},className:"rounded-lg border shadow-sm hover:shadow-md transition-shadow card-glow",children:[a.jsxs("div",{className:`flex items-center justify-between p-4 ${g.isBuiltin?"cursor-default":"cursor-pointer"} relative`,onClick:()=>{g.isBuiltin||m(g.id)},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zs,{className:"h-5 w-5 text-primary"}),a.jsx("div",{className:"font-medium",children:g.name}),!g.isBuiltin&&a.jsx("div",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary",children:g.provider}),!g.isBuiltin&&a.jsx("div",{className:"rounded-full bg-muted px-2 py-0.5 text-xs",children:g.model}),g.isDefault&&a.jsx("div",{className:"rounded-full bg-secondary/20 px-2 py-0.5 text-xs text-secondary-foreground font-medium",children:e("ai.default","Default")}),g.isBuiltin&&a.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs",children:[a.jsx(gc,{className:"h-3.5 w-3.5"})," ",e("ai.builtin","Built-in")]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!g.isDefault&&a.jsx(be,{variant:"outline",size:"sm",onClick:x=>{x.stopPropagation(),v(g.id)},className:"text-xs h-8 btn-bounce",children:e("ai.setDefault","Set as Default")}),!g.isBuiltin&&a.jsx(be,{variant:"ghost",size:"icon",onClick:x=>{x.stopPropagation(),h(g.id)},className:"btn-bounce",children:a.jsx(Sc,{className:"h-4 w-4 text-destructive"})}),!g.isBuiltin&&(s===g.id?a.jsx(mr,{className:"h-4 w-4"}):a.jsx(vn,{className:"h-4 w-4"}))]})]}),a.jsx(ef,{children:!g.isBuiltin&&s===g.id&&a.jsx(rr.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3},className:"overflow-hidden",children:a.jsx("div",{className:"border-t p-4",children:a.jsx(Ju,{server:g,onUpdate:p,onSetDefault:()=>v(g.id)})})})})]},g.id))}),o&&a.jsx("div",{className:"text-xs text-muted-foreground text-right animate-pulse",children:e("general.saving")}),a.jsxs(be,{variant:"default",className:"w-full py-6 btn-bounce group enhanced-button bg-gradient-to-r from-primary/80 to-secondary/80",onClick:u,children:[a.jsx(cc,{className:"mr-2 h-5 w-5 group-hover:scale-110 transition-transform"}),t.length===0?e("ai.addFirst","Add Your First AI Server"):e("ai.add","Add AI Server")]})]})]})}function _m({label:e,icon:t,info:n,unit:s,formatFn:i}){const{t:o}=je();if(!n)return null;const r=n.limit===-1,l=r?0:Math.min(n.used/n.limit*100,100),c=l>=80,d=Kl(n,s,o("subscription.unlimited","Unlimited"),i);return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t,a.jsx("span",{children:e})]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:d})]}),!r&&a.jsx(Gl,{value:l,className:`h-2 ${c?"[&>div]:bg-amber-500":""}`}),n.resetAt&&a.jsx("p",{className:"text-xs text-muted-foreground",children:o("subscription.resetAt",{date:new Date(n.resetAt).toLocaleDateString()})})]})}function Um({auth:e,sendMessage:t}){const{t:n}=je(),{user:s}=e,{plan:i,isLoading:o,cancelAtPeriodEnd:r,currentPeriodEnd:l}=fr(!!s,t),{usage:c,isLoading:d}=Ul(!!s,t),u=o||d,h=i==="pro"||i==="premium",p=()=>{t("ACQUIRE_LANGUAGE:OPEN_WEBSITE",{returnTo:$s.pricing},"background").catch(()=>{})},m=()=>{t("ACQUIRE_LANGUAGE:OPEN_WEBSITE",{returnTo:$s.account},"background").catch(()=>{})};return s?a.jsxs("div",{className:"space-y-6",children:[a.jsxs(ke,{children:[a.jsx(Me,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx(De,{className:"text-lg",children:n("subscription.currentPlan","Current Plan")}),a.jsx(We,{children:n("subscription.desc")})]}),a.jsx($l,{className:i==="premium"?"bg-amber-500 hover:bg-amber-600 text-white":i==="pro"?"bg-blue-500 hover:bg-blue-600 text-white":"",variant:i==="free"?"secondary":"default",children:n(`subscription.${i}`,i)})]})}),a.jsxs(Ve,{className:"space-y-4",children:[!h&&a.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-dashed border-primary/30 bg-primary/5",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium",children:n("subscription.upgradeToPro","Upgrade to Pro")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:n("subscription.upgradeCta")})]}),a.jsxs(be,{size:"sm",onClick:p,children:[a.jsx(Dl,{className:"h-4 w-4 mr-1"}),n("subscription.upgrade","Upgrade")]})]}),h&&a.jsxs(be,{variant:"outline",onClick:m,children:[a.jsx(Vl,{className:"h-4 w-4 mr-2"}),n("subscription.manageBilling","Manage Subscription")]})]})]}),!u&&c&&a.jsxs(ke,{children:[a.jsx(Me,{children:a.jsx(De,{className:"text-lg",children:n("subscription.usage","Usage")})}),a.jsx(Ve,{className:"space-y-6",children:a.jsx(_m,{label:n("subscription.aiUsage","AI Usage"),icon:a.jsx(Hl,{className:"h-4 w-4 text-blue-500"}),info:c.shared,unit:"credits",formatFn:zl})})]}),r&&a.jsxs(ot,{className:"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950",children:[a.jsx(Er,{className:"h-4 w-4 text-amber-600"}),a.jsx(at,{className:"text-sm text-amber-800 dark:text-amber-200",children:n("subscription.cancelNotice",{date:l?new Date(l).toLocaleDateString():""})})]})]}):a.jsxs(ke,{children:[a.jsxs(Me,{children:[a.jsx(De,{children:n("subscription.title","Subscription")}),a.jsx(We,{children:n("subscription.desc")})]}),a.jsxs(Ve,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:n("auth.signInPrompt","Sign in to manage your subscription.")}),a.jsx(Ml,{onSignIn:()=>e.signIn(),isSigningIn:e.isSigningIn,text:n("auth.signIn","Sign In")})]})]})}function $m(){var y,w,S,C;const{t:e}=je(),[t,n]=f.useState(""),[s,i]=f.useState(!1),[o,r]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(null),[h,p]=f.useState(null),m=((w=(y=globalThis.browser)==null?void 0:y.runtime)==null?void 0:w.getURL)??((C=(S=globalThis.chrome)==null?void 0:S.runtime)==null?void 0:C.getURL),v=typeof m=="function"?m("icon/eudic.png"):"/icon/eudic.png",g=f.useCallback(_t(b=>{i(!0),bl({integrations:{eudic:{token:b}}}).catch(j=>console.error("Failed to save Eudic token:",j)).finally(()=>i(!1))},600),[]);f.useEffect(()=>{(async()=>{var b,j;try{const N=await Ut();n(((j=(b=N.integrations)==null?void 0:b.eudic)==null?void 0:j.token)||"")}finally{r(!0)}})()},[]),f.useEffect(()=>{o&&g(t)},[t,o,g]);const x=async()=>{u(null),p(null),c(!0);try{const b=await ec({dryRun:!0});u(e("integrations.validateOk",{defaultValue:"Token valid ✓"}))}catch(b){p((b==null?void 0:b.message)||String(b))}finally{c(!1)}};return a.jsxs(ke,{className:"border-2 border-primary/10 gradient-border card-glow",children:[a.jsxs(Me,{children:[a.jsx(De,{className:"gradient-text",children:e("integrations.title","Integrations")}),a.jsx(We,{children:e("integrations.desc","Connect external services. Currently supports Eudic token.")})]}),a.jsxs(Ve,{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs(L,{htmlFor:"eudic-token",className:"flex items-center gap-2",children:[a.jsx("img",{src:v,alt:"Eudic",className:"w-4 h-4 rounded-sm"}),e("integrations.eudicToken","Eudic Token")]}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[e("integrations.getTokenHint",{defaultValue:"Get a token here:"})," ",a.jsx("a",{href:"https://my.eudic.net/OpenAPI/Authorization",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:e("integrations.getTokenLinkText",{defaultValue:"Eudic OpenAPI Authorization"})})]}),a.jsx(ve,{id:"eudic-token",type:"password",placeholder:"NIS xxx...",value:t,onChange:b=>n(b.target.value)}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("integrations.tokenNote","Your token is stored locally (sync storage when available).")})]}),a.jsx("div",{className:"flex justify-end",children:a.jsx(be,{onClick:x,disabled:l||!t,children:l?e("integrations.validating","Validating..."):e("integrations.validate","Validate Token")})}),d&&a.jsx(ot,{className:"border-green-500/30",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ql,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),a.jsx(at,{children:d})]})}),h&&a.jsx(ot,{className:"border-destructive/40",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Er,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),a.jsx(at,{children:h})]})}),s&&a.jsx(ot,{className:"border-primary/20",children:a.jsx(at,{children:e("general.saving","Saving...")})})]})]})}const zm=({...e})=>{const{theme:t="system"}=Fl();return a.jsx(Il,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};function Km(){const[e,t]=f.useState("general"),{t:n}=je(),s=Ll(sn),{user:i}=s,{plan:o}=fr(!!i,sn);return f.useEffect(()=>{const l=new URLSearchParams(window.location.search).get("tab");l&&["general","subtitle","ai","integrations","subscription"].includes(l)&&t(l)},[]),a.jsxs(Bl,{children:[a.jsx(zm,{}),a.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/20 pb-8 relative",children:[a.jsx("div",{className:"scanline absolute inset-0 pointer-events-none z-0"}),a.jsx("header",{className:"sticky top-0 z-20 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:a.jsxs("div",{className:"container flex h-16 items-center justify-between py-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yl,{}),a.jsx("h1",{className:"text-xl font-bold tracking-tight gradient-text tech-glow",children:n("common.appName","DeepAcquire")})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Ol,{auth:s,plan:o,variant:"compact"}),a.jsx(Wl,{})]})]})}),a.jsx("main",{className:"container py-6 relative z-10",children:a.jsxs("div",{className:"mx-auto max-w-5xl space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight text-primary tech-glow",children:n("options.settings")}),a.jsx("p",{className:"text-muted-foreground",children:n("options.customizeTip")})]}),a.jsxs(ic,{value:e,onValueChange:t,className:"w-full",children:[a.jsxs(Nr,{className:"grid w-full grid-cols-5 relative z-10",children:[a.jsx(_e,{value:"general",className:"gradient-text",children:n("options.general")}),a.jsx(_e,{value:"subtitle",className:"gradient-text",children:n("options.subtitle")}),a.jsx(_e,{value:"ai",className:"gradient-text",children:n("options.aiServers")}),a.jsx(_e,{value:"integrations",className:"gradient-text",children:n("options.integrations","Integrations")}),a.jsx(_e,{value:"subscription",className:"gradient-text",children:n("options.subscription","Subscription")})]}),a.jsx(Ue,{value:"general",className:"mt-6 relative z-10",children:a.jsx(Rc,{})}),a.jsx(Ue,{value:"subtitle",className:"mt-6 relative z-10",children:a.jsx(Hu,{})}),a.jsx(Ue,{value:"ai",className:"mt-6 relative z-10",children:a.jsx(Bm,{})}),a.jsx(Ue,{value:"integrations",className:"mt-6 relative z-10",children:a.jsx($m,{})}),a.jsx(Ue,{value:"subscription",className:"mt-6 relative z-10",children:a.jsx(Um,{auth:s,sendMessage:sn})})]})]})})]})]})}Sl().finally(()=>{wl.createRoot(document.getElementById("root")).render(a.jsx(f.StrictMode,{children:a.jsx(Km,{})}))});
