@arcteninc/core 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/citation-button.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +31 -20
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"citation-button.d.ts","sourceRoot":"","sources":["../../src/components/citation-button.tsx"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,mBAAmB;IAC3B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"citation-button.d.ts","sourceRoot":"","sources":["../../src/components/citation-button.tsx"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,mBAAmB;IAC3B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,mBAAmB,kDA6EzF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ua=Object.create;var yi=Object.defineProperty;var _a=Object.getOwnPropertyDescriptor;var Wa=Object.getOwnPropertyNames;var Ka=Object.getPrototypeOf,Ha=Object.prototype.hasOwnProperty;var Ga=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Wa(e))!Ha.call(t,i)&&i!==n&&yi(t,i,{get:()=>e[i],enumerable:!(s=_a(e,i))||s.enumerable});return t};var Xa=(t,e,n)=>(n=t!=null?Ua(Ka(t)):{},Ga(e||!t||!t.__esModule?yi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),et=require("lucide-react"),Lr=require("@ai-sdk/react"),An=require("ai"),Or=require("@radix-ui/react-slot"),Fr=require("class-variance-authority"),qa=require("clsx"),Ya=require("tailwind-merge"),Ja=require("@radix-ui/react-tooltip"),xi=require("@radix-ui/react-use-controllable-state"),Za=require("@radix-ui/react-collapsible"),Qa=require("react-dom"),tc=require("./server.cjs");function js(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Ct=js(m),Pe=js(Ja),Ms=js(Za);function nt(...t){return Ya.twMerge(qa.clsx(t))}const oe=Fr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Cn=Ct.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Or.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:nt(oe({variant:e,size:n,className:t})),...i})});Cn.displayName="Button";const ec=Fr.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function zn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Or.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:nt(ec({variant:e}),t),...s})}const nc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Ct.useState(!0);Ct.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Br=Ct.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Ct.useRef(null),[c,u]=Ct.useState("");return nc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Ct.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:nt("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Br.displayName="AutosizeTextarea";function sc({delayDuration:t=0,...e}){return h.jsx(Pe.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Wt({...t}){return h.jsx(sc,{children:h.jsx(Pe.Root,{"data-slot":"tooltip",...t})})}function Kt({...t}){return h.jsx(Pe.Trigger,{"data-slot":"tooltip-trigger",...t})}function Ht({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Pe.Portal,{children:h.jsxs(Pe.Content,{"data-slot":"tooltip-content",sideOffset:e,className:nt("bg-foreground text-background 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Pe.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function vi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:nt("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Es=m.createContext({});function ks(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ds=typeof window<"u",$r=Ds?m.useLayoutEffect:m.useEffect,Dn=m.createContext(null);function Vs(t,e){t.indexOf(e)===-1&&t.push(e)}function Ns(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Ot=(t,e,n)=>n>e?e:n<t?t:n;function is(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ft=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(is(e,n))},Ft=(t,e,n)=>{if(!t)throw new Error(is(e,n))});const Bt={},zr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Ur(t){return typeof t=="object"&&t!==null}const _r=t=>/^0[^.\s]+$/u.test(t);function Rs(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,ic=(t,e)=>n=>e(t(n)),nn=(...t)=>t.reduce(ic),Ye=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Is{constructor(){this.subscriptions=[]}add(e){return Vs(this.subscriptions,e),()=>Ns(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Pt=t=>t*1e3,bt=t=>t/1e3;function Wr(t,e){return e?t*(1e3/e):0}const bi=new Set;function Ls(t,e,n){t||bi.has(e)||(console.warn(is(e,n)),bi.add(e))}const Kr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,rc=1e-7,oc=12;function ac(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Kr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>rc&&++a<oc);return r}function sn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>ac(o,0,1,t,n);return o=>o===0||o===1?o:Kr(i(o),e,s)}const Hr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Gr=t=>e=>1-t(1-e),Xr=sn(.33,1.53,.69,.99),Os=Gr(Xr),qr=Hr(Os),Yr=t=>(t*=2)<1?.5*Os(t):.5*(2-Math.pow(2,-10*(t-1))),Fs=t=>1-Math.sin(Math.acos(t)),Jr=Gr(Fs),Zr=Hr(Fs),cc=sn(.42,0,1,1),lc=sn(0,0,.58,1),Qr=sn(.42,0,.58,1),uc=t=>Array.isArray(t)&&typeof t[0]!="number",to=t=>Array.isArray(t)&&typeof t[0]=="number",wi={linear:wt,easeIn:cc,easeInOut:Qr,easeOut:lc,circIn:Fs,circInOut:Zr,circOut:Jr,backIn:Os,backInOut:qr,backOut:Xr,anticipate:Yr},dc=t=>typeof t=="string",Ti=t=>{if(to(t)){Ft(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return sn(e,n,s,i)}else if(dc(t))return Ft(wi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),wi[t];return t},mn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function hc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&r.add(l),y.has(l)||y.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const fc=40;function eo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=mn.reduce((T,V)=>(T[V]=hc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:y}=r,v=()=>{const T=Bt.useManualTiming?i.timestamp:performance.now();n=!1,Bt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,fc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:mn.reduce((T,V)=>{const k=r[V];return T[V]=(C,L=!1,M=!1)=>(n||A(),k.schedule(C,L,M)),T},{}),cancel:T=>{for(let V=0;V<mn.length;V++)r[mn[V]].cancel(T)},state:i,steps:r}}const{schedule:X,cancel:Xt,state:it,steps:Un}=eo(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let vn;function mc(){vn=void 0}const mt={now:()=>(vn===void 0&&mt.set(it.isProcessing||Bt.useManualTiming?it.timestamp:performance.now()),vn),set:t=>{vn=t,queueMicrotask(mc)}},no=t=>e=>typeof e=="string"&&e.startsWith(t),Bs=no("--"),pc=no("var(--"),$s=t=>pc(t)?gc.test(t.split("/*")[0].trim()):!1,gc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Je={...De,transform:t=>Ot(0,1,t)},pn={...De,default:1},We=t=>Math.round(t*1e5)/1e5,zs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function yc(t){return t==null}const xc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Us=(t,e)=>n=>!!(typeof n=="string"&&xc.test(n)&&n.startsWith(t)||e&&!yc(n)&&Object.prototype.hasOwnProperty.call(n,e)),so=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(zs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},vc=t=>Ot(0,255,t),_n={...De,transform:t=>Math.round(vc(t))},ce={test:Us("rgb","red"),parse:so("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+_n.transform(t)+", "+_n.transform(e)+", "+_n.transform(n)+", "+We(Je.transform(s))+")"};function bc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const rs={test:Us("#"),parse:bc,transform:ce.transform},rn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Gt=rn("deg"),Vt=rn("%"),I=rn("px"),wc=rn("vh"),Tc=rn("vw"),Si={...Vt,parse:t=>Vt.parse(t)/100,transform:t=>Vt.transform(t*100)},be={test:Us("hsl","hue"),parse:so("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Vt.transform(We(e))+", "+Vt.transform(We(n))+", "+We(Je.transform(s))+")"},tt={test:t=>ce.test(t)||rs.test(t)||be.test(t),parse:t=>ce.test(t)?ce.parse(t):be.test(t)?be.parse(t):rs.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ce.transform(t):be.transform(t),getAnimatableNone:t=>{const e=tt.parse(t);return e.alpha=0,tt.transform(e)}},Sc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ac(t){return isNaN(t)&&typeof t=="string"&&(t.match(zs)?.length||0)+(t.match(Sc)?.length||0)>0}const io="number",ro="color",Cc="var",Pc="var(",Ai="${}",jc=/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 Ze(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(jc,c=>(tt.test(c)?(s.color.push(o),i.push(ro),n.push(tt.parse(c))):c.startsWith(Pc)?(s.var.push(o),i.push(Cc),n.push(c)):(s.number.push(o),i.push(io),n.push(parseFloat(c))),++o,Ai)).split(Ai);return{values:n,split:a,indexes:s,types:i}}function oo(t){return Ze(t).values}function ao(t){const{split:e,types:n}=Ze(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===io?o+=We(i[r]):a===ro?o+=tt.transform(i[r]):o+=i[r]}return o}}const Mc=t=>typeof t=="number"?0:tt.test(t)?tt.getAnimatableNone(t):t;function Ec(t){const e=oo(t);return ao(t)(e.map(Mc))}const qt={test:Ac,parse:oo,createTransformer:ao,getAnimatableNone:Ec};function Wn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function kc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Wn(c,a,t+1/3),o=Wn(c,a,t),r=Wn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Pn(t,e){return n=>n>0?e:t}const Y=(t,e,n)=>t+(e-t)*n,Kn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Dc=[rs,ce,be],Vc=t=>Dc.find(e=>e.test(t));function Ci(t){const e=Vc(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=kc(n)),n}const Pi=(t,e)=>{const n=Ci(t),s=Ci(e);if(!n||!s)return Pn(t,e);const i={...n};return o=>(i.red=Kn(n.red,s.red,o),i.green=Kn(n.green,s.green,o),i.blue=Kn(n.blue,s.blue,o),i.alpha=Y(n.alpha,s.alpha,o),ce.transform(i))},os=new Set(["none","hidden"]);function Nc(t,e){return os.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Rc(t,e){return n=>Y(t,e,n)}function _s(t){return typeof t=="number"?Rc:typeof t=="string"?$s(t)?Pn:tt.test(t)?Pi:Oc:Array.isArray(t)?co:typeof t=="object"?tt.test(t)?Pi:Ic:Pn}function co(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>_s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Ic(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=_s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Lc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Oc=(t,e)=>{const n=qt.createTransformer(e),s=Ze(t),i=Ze(e);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?os.has(t)&&!i.values.length||os.has(e)&&!s.values.length?Nc(t,e):nn(co(Lc(s,i),i.values),n):(ke(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Pn(t,e))};function lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Y(t,e,n):_s(t)(t,e)}const Fc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>X.update(e,n),stop:()=>Xt(e),now:()=>it.isProcessing?it.timestamp:mt.now()}},uo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},jn=2e4;function Ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<jn;)e+=n,s=t.next(e);return e>=jn?1/0:e}function Bc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ws(s),jn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const $c=5;function ho(t,e,n){const s=Math.max(e-$c,0);return Wr(n-t(s),e-s)}const q={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},Hn=.001;function zc({duration:t=q.duration,bounce:e=q.bounce,velocity:n=q.velocity,mass:s=q.mass}){let i,o;ke(t<=Pt(q.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Ot(q.minDamping,q.maxDamping,r),t=Ot(q.minDuration,q.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=as(u,r),y=Math.exp(-d);return Hn-f/g*y},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=as(Math.pow(u,2),r);return(-i(u)+Hn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Hn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=_c(i,o,a);if(t=Pt(t),isNaN(c))return{stiffness:q.stiffness,damping:q.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Uc=12;function _c(t,e,n){let s=n;for(let i=1;i<Uc;i++)s=s-t(s)/e(s);return s}function as(t,e){return t*Math.sqrt(1-e*e)}const Wc=["duration","bounce"],Kc=["stiffness","damping","mass"];function ji(t,e){return e.some(n=>t[n]!==void 0)}function Hc(t){let e={velocity:q.velocity,stiffness:q.stiffness,damping:q.damping,mass:q.mass,isResolvedFromDuration:!1,...t};if(!ji(t,Kc)&&ji(t,Wc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Ot(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:q.mass,stiffness:i,damping:o}}else{const n=zc(t);e={...e,...n,mass:q.mass},e.isResolvedFromDuration=!0}return e}function Mn(t=q.visualDuration,e=q.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Hc({...n,velocity:-bt(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,x=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?q.restSpeed.granular:q.restSpeed.default),i||(i=w?q.restDelta.granular:q.restDelta.default);let T;if(v<1){const k=as(x,v);T=C=>{const L=Math.exp(-v*x*C);return r-L*((y+v*x*A)/k*Math.sin(k*C)+A*Math.cos(k*C))}}else if(v===1)T=k=>r-Math.exp(-x*k)*(A+(y+x*A)*k);else{const k=x*Math.sqrt(v*v-1);T=C=>{const L=Math.exp(-v*x*C),M=Math.min(k*C,300);return r-L*((y+v*x*A)*Math.sinh(M)+k*A*Math.cosh(M))/k}}const V={calculatedDuration:g&&d||null,next:k=>{const C=T(k);if(g)a.done=k>=d;else{let L=k===0?y:0;v<1&&(L=k===0?Pt(y):ho(T,k,C));const M=Math.abs(L)<=s,F=Math.abs(r-C)<=i;a.done=M&&F}return a.value=a.done?r:C,a},toString:()=>{const k=Math.min(Ws(V),jn),C=uo(L=>V.next(k*L).value,k,30);return k+"ms "+C},toTransition:()=>{}};return V}Mn.applyToOptions=t=>{const e=Bc(t,100,Mn);return t.ease=e.ease,t.duration=Pt(e.duration),t.type="keyframes",t};function cs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=M=>a!==void 0&&M<a||c!==void 0&&M>c,y=M=>a===void 0?c:c===void 0||Math.abs(a-M)<Math.abs(c-M)?a:c;let v=n*e;const A=d+v,x=r===void 0?A:r(A);x!==A&&(v=x-d);const w=M=>-v*Math.exp(-M/s),T=M=>x+w(M),V=M=>{const F=w(M),z=T(M);f.done=Math.abs(F)<=u,f.value=f.done?x:z};let k,C;const L=M=>{g(f.value)&&(k=M,C=Mn({keyframes:[f.value,y(f.value)],velocity:ho(T,M,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return L(0),{calculatedDuration:null,next:M=>{let F=!1;return!C&&k===void 0&&(F=!0,V(M),L(M)),k!==void 0&&M>=k?C.next(M-k):(!F&&V(M),f)}}}function Gc(t,e,n){const s=[],i=n||Bt.mix||lo,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=nn(c,a)}s.push(a)}return s}function Xc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ft(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Gc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ye(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Ot(t[0],t[o-1],l)):u}function qc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ye(0,e,s);t.push(Y(n,1,i))}}function Yc(t){const e=[0];return qc(e,t.length-1),e}function Jc(t,e){return t.map(n=>n*e)}function Zc(t,e){return t.map(()=>e||Qr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=uc(s)?s.map(Ti):Ti(s),o={done:!1,value:e[0]},r=Jc(n&&n.length===e.length?n:Yc(e),t),a=Xc(r,e,{ease:Array.isArray(i)?i:Zc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Qc=t=>t!==null;function Ks(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Qc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const tl={decay:cs,inertia:cs,tween:we,keyframes:we,spring:Mn};function fo(t){typeof t.type=="string"&&(t.type=tl[t.type])}class Hs{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const el=t=>t/100;class Gs extends Hs{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;fo(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ft(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=nn(el,lo(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ws(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,V=s;if(d){const M=Math.min(this.currentTime,i)/a;let F=Math.floor(M),z=M%1;!z&&M>=1&&(z=1),z===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(f==="reverse"?(z=1-z,g&&(z-=g/a)):f==="mirror"&&(V=r)),T=Ot(0,1,z)*a}const k=w?{done:!1,value:l[0]}:V.next(T);o&&(k.value=o(k.value));let{done:C}=k;!w&&c!==null&&(C=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const L=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return L&&y!==cs&&(k.value=Ks(l,this.options,A,this.speed)),v&&v(k.value),L&&this.finish(),k}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Pt(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Fc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();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(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function nl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const le=t=>t*180/Math.PI,ls=t=>{const e=le(Math.atan2(t[1],t[0]));return us(e)},sl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ls,rotateZ:ls,skewX:t=>le(Math.atan(t[1])),skewY:t=>le(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},us=t=>(t=t%360,t<0&&(t+=360),t),Mi=ls,Ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ki=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),il={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ei,scaleY:ki,scale:t=>(Ei(t)+ki(t))/2,rotateX:t=>us(le(Math.atan2(t[6],t[5]))),rotateY:t=>us(le(Math.atan2(-t[2],t[0]))),rotateZ:Mi,rotate:Mi,skewX:t=>le(Math.atan(t[4])),skewY:t=>le(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ds(t){return t.includes("scale")?1:0}function hs(t,e){if(!t||t==="none")return ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=il,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=sl,i=a}if(!i)return ds(e);const o=s[e],r=i[1].split(",").map(ol);return typeof o=="function"?o(r):r[o]}const rl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return hs(n,e)};function ol(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ne=new Set(Ve),Di=t=>t===De||t===I,al=new Set(["x","y","z"]),cl=Ve.filter(t=>!al.has(t));function ll(t){const e=[];return cl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ue={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>hs(e,"x"),y:(t,{transform:e})=>hs(e,"y")};ue.translateX=ue.x;ue.translateY=ue.y;const de=new Set;let fs=!1,ms=!1,ps=!1;function mo(){if(ms){const t=Array.from(de).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ms=!1,fs=!1,de.forEach(t=>t.complete(ps)),de.clear()}function po(){de.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ms=!0)})}function ul(){ps=!0,po(),mo(),ps=!1}class Xs{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(de.add(this),fs||(fs=!0,X.read(po),X.resolveKeyframes(mo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}nl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),de.delete(this)}cancel(){this.state==="scheduled"&&(de.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const dl=t=>t.startsWith("--");function hl(t,e,n){dl(e)?t.style.setProperty(e,n):t.style[e]=n}const fl=Rs(()=>window.ScrollTimeline!==void 0),ml={};function pl(t,e){const n=Rs(t);return()=>ml[e]??n()}const go=pl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Vi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_e([0,.65,.55,1]),circOut:_e([.55,0,1,.45]),backIn:_e([.31,.01,.66,-.59]),backOut:_e([.33,1.53,.69,.99])};function yo(t,e){if(t)return typeof t=="function"?go()?uo(t,e):"ease-out":to(t)?_e(t):Array.isArray(t)?t.map(n=>yo(n,e)||Vi.easeOut):Vi[t]}function gl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=yo(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function xo(t){return typeof t=="function"&&"applyToOptions"in t}function yl({type:t,...e}){return xo(t)&&go()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class xl extends Hs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ft(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=yl(e);this.animation=gl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Ks(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):hl(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Pt(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&fl()?(this.animation.timeline=e,wt):n(this)}}const vo={anticipate:Yr,backInOut:qr,circInOut:Zr};function vl(t){return t in vo}function bl(t){typeof t.ease=="string"&&vl(t.ease)&&(t.ease=vo[t.ease])}const Ni=10;class wl extends xl{constructor(e){bl(e),fo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Gs({...r,autoplay:!1}),c=Pt(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ni).value,a.sample(c).value,Ni),a.stop()}}const Ri=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(qt.test(t)||t==="0")&&!t.startsWith("url("));function Tl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Sl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ri(i,e),a=Ri(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:Tl(t)||(n==="spring"||xo(n))&&s}function gs(t){t.duration=0,t.type="keyframes"}const Al=new Set(["opacity","clipPath","filter","transform"]),Cl=Rs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Cl()&&n&&Al.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const jl=40;class Ml extends Hs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Xs;this.keyframeResolver=new g(a,(y,v,A)=>this.onKeyframesResolved(y,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),Sl(e,o,r,a)||((Bt.instantAnimations||!c)&&l?.(Ks(e,s,n)),e[0]=e[e.length-1],gs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>jl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Pl(f)?new wl({...f,element:f.motionValue.owner.current}):new Gs(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),ul()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const El=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function kl(t){const e=El.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const Dl=4;function bo(t,e,n=1){Ft(n<=Dl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=kl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return zr(r)?parseFloat(r):r}return $s(i)?bo(i,e,n+1):i}function qs(t,e){return t?.[e]??t?.default??t}const wo=new Set(["width","height","top","left","right","bottom",...Ve]),Vl={test:t=>t==="auto",parse:t=>t},To=t=>e=>e.test(t),So=[De,I,Vt,Gt,Tc,wc,Vl],Ii=t=>So.find(To(t));function Nl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_r(t):!0}const Rl=new Set(["brightness","contrast","saturate","opacity"]);function Il(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(zs)||[];if(!s)return t;const i=n.replace(s,"");let o=Rl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Ll=/\b([a-z-]*)\(.*?\)/gu,ys={...qt,getAnimatableNone:t=>{const e=t.match(Ll);return e?e.map(Il).join(" "):t}},Li={...De,transform:Math.round},Ol={rotate:Gt,rotateX:Gt,rotateY:Gt,rotateZ:Gt,scale:pn,scaleX:pn,scaleY:pn,scaleZ:pn,skew:Gt,skewX:Gt,skewY:Gt,distance:I,translateX:I,translateY:I,translateZ:I,x:I,y:I,z:I,perspective:I,transformPerspective:I,opacity:Je,originX:Si,originY:Si,originZ:I},Ys={borderWidth:I,borderTopWidth:I,borderRightWidth:I,borderBottomWidth:I,borderLeftWidth:I,borderRadius:I,radius:I,borderTopLeftRadius:I,borderTopRightRadius:I,borderBottomRightRadius:I,borderBottomLeftRadius:I,width:I,maxWidth:I,height:I,maxHeight:I,top:I,right:I,bottom:I,left:I,padding:I,paddingTop:I,paddingRight:I,paddingBottom:I,paddingLeft:I,margin:I,marginTop:I,marginRight:I,marginBottom:I,marginLeft:I,backgroundPositionX:I,backgroundPositionY:I,...Ol,zIndex:Li,fillOpacity:Je,strokeOpacity:Je,numOctaves:Li},Fl={...Ys,color:tt,backgroundColor:tt,outlineColor:tt,fill:tt,stroke:tt,borderColor:tt,borderTopColor:tt,borderRightColor:tt,borderBottomColor:tt,borderLeftColor:tt,filter:ys,WebkitFilter:ys},Ao=t=>Fl[t];function Co(t,e){let n=Ao(t);return n!==ys&&(n=qt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Bl=new Set(["auto","none","0"]);function $l(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Bl.has(o)&&Ze(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Co(n,i)}class zl extends Xs{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),$s(u))){const l=bo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!wo.has(s)||e.length!==2)return;const[i,o]=e,r=Ii(i),a=Ii(o);if(r!==a)if(Di(r)&&Di(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ue[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Nl(e[i]))&&s.push(i);s.length&&$l(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ue[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ue[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Ul(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function jo(t){return Ur(t)&&"offsetHeight"in t}const Oi=30,_l=t=>!isNaN(parseFloat(t));class Wl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Ls(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Is);const s=this.events[e].add(n);return e==="change"?()=>{s(),X.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Oi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Oi);return Wr(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(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(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Me(t,e){return new Wl(t,e)}const{schedule:Js}=eo(queueMicrotask,!1),At={x:!1,y:!1};function Mo(){return At.x||At.y}function Kl(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function Eo(t,e){const n=Ul(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Fi(t){return!(t.pointerType==="touch"||Mo())}function Hl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{if(!Fi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Fi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const ko=(t,e)=>e?t===e?!0:ko(t,e.parentElement):!1,Zs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Gl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Xl(t){return Gl.has(t.tagName)||t.tabIndex!==-1}const bn=new WeakSet;function Bi(t){return e=>{e.key==="Enter"&&t(e)}}function Gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const ql=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Bi(()=>{if(bn.has(n))return;Gn(n,"down");const i=Bi(()=>{Gn(n,"up")}),o=()=>Gn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function $i(t){return Zs(t)&&!Mo()}function Yl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{const c=a.currentTarget;if(!$i(a))return;bn.add(c);const u=e(c,a),l=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),bn.has(c)&&bn.delete(c),$i(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||ko(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),jo(a)&&(a.addEventListener("focus",u=>ql(u,i)),!Xl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Do(t){return Ur(t)&&"ownerSVGElement"in t}function Jl(t){return Do(t)&&t.tagName==="svg"}const at=t=>!!(t&&t.getVelocity),Zl=[...So,tt,qt],Ql=t=>Zl.find(To(t)),Qs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function tu(...t){return e=>{let n=!1;const s=t.map(i=>{const o=zi(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():zi(t[i],null)}}}}function eu(...t){return Ct.useCallback(tu(...t),t)}class nu extends Ct.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=jo(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 su({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Qs),c=eu(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var Ua=Object.create;var yi=Object.defineProperty;var _a=Object.getOwnPropertyDescriptor;var Wa=Object.getOwnPropertyNames;var Ka=Object.getPrototypeOf,Ha=Object.prototype.hasOwnProperty;var Xa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Wa(e))!Ha.call(t,i)&&i!==n&&yi(t,i,{get:()=>e[i],enumerable:!(s=_a(e,i))||s.enumerable});return t};var Ga=(t,e,n)=>(n=t!=null?Ua(Ka(t)):{},Xa(e||!t||!t.__esModule?yi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),et=require("lucide-react"),Lr=require("@ai-sdk/react"),An=require("ai"),Or=require("@radix-ui/react-slot"),Fr=require("class-variance-authority"),qa=require("clsx"),Ya=require("tailwind-merge"),Ja=require("@radix-ui/react-tooltip"),xi=require("@radix-ui/react-use-controllable-state"),Za=require("@radix-ui/react-collapsible"),Qa=require("react-dom"),tc=require("./server.cjs");function js(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Ct=js(m),Pe=js(Ja),Ms=js(Za);function nt(...t){return Ya.twMerge(qa.clsx(t))}const oe=Fr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Cn=Ct.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Or.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:nt(oe({variant:e,size:n,className:t})),...i})});Cn.displayName="Button";const ec=Fr.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function zn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Or.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:nt(ec({variant:e}),t),...s})}const nc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Ct.useState(!0);Ct.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Br=Ct.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Ct.useRef(null),[c,u]=Ct.useState("");return nc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Ct.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:nt("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Br.displayName="AutosizeTextarea";function sc({delayDuration:t=0,...e}){return h.jsx(Pe.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Wt({...t}){return h.jsx(sc,{children:h.jsx(Pe.Root,{"data-slot":"tooltip",...t})})}function Kt({...t}){return h.jsx(Pe.Trigger,{"data-slot":"tooltip-trigger",...t})}function Ht({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Pe.Portal,{children:h.jsxs(Pe.Content,{"data-slot":"tooltip-content",sideOffset:e,className:nt("bg-foreground text-background 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Pe.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function vi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:nt("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Es=m.createContext({});function ks(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ds=typeof window<"u",$r=Ds?m.useLayoutEffect:m.useEffect,Dn=m.createContext(null);function Vs(t,e){t.indexOf(e)===-1&&t.push(e)}function Ns(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Ot=(t,e,n)=>n>e?e:n<t?t:n;function is(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ft=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(is(e,n))},Ft=(t,e,n)=>{if(!t)throw new Error(is(e,n))});const Bt={},zr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Ur(t){return typeof t=="object"&&t!==null}const _r=t=>/^0[^.\s]+$/u.test(t);function Rs(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,ic=(t,e)=>n=>e(t(n)),nn=(...t)=>t.reduce(ic),Ye=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Is{constructor(){this.subscriptions=[]}add(e){return Vs(this.subscriptions,e),()=>Ns(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Pt=t=>t*1e3,bt=t=>t/1e3;function Wr(t,e){return e?t*(1e3/e):0}const bi=new Set;function Ls(t,e,n){t||bi.has(e)||(console.warn(is(e,n)),bi.add(e))}const Kr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,rc=1e-7,oc=12;function ac(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Kr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>rc&&++a<oc);return r}function sn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>ac(o,0,1,t,n);return o=>o===0||o===1?o:Kr(i(o),e,s)}const Hr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Xr=t=>e=>1-t(1-e),Gr=sn(.33,1.53,.69,.99),Os=Xr(Gr),qr=Hr(Os),Yr=t=>(t*=2)<1?.5*Os(t):.5*(2-Math.pow(2,-10*(t-1))),Fs=t=>1-Math.sin(Math.acos(t)),Jr=Xr(Fs),Zr=Hr(Fs),cc=sn(.42,0,1,1),lc=sn(0,0,.58,1),Qr=sn(.42,0,.58,1),uc=t=>Array.isArray(t)&&typeof t[0]!="number",to=t=>Array.isArray(t)&&typeof t[0]=="number",wi={linear:wt,easeIn:cc,easeInOut:Qr,easeOut:lc,circIn:Fs,circInOut:Zr,circOut:Jr,backIn:Os,backInOut:qr,backOut:Gr,anticipate:Yr},dc=t=>typeof t=="string",Ti=t=>{if(to(t)){Ft(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return sn(e,n,s,i)}else if(dc(t))return Ft(wi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),wi[t];return t},mn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function hc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&r.add(l),y.has(l)||y.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const fc=40;function eo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=mn.reduce((T,V)=>(T[V]=hc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:y}=r,v=()=>{const T=Bt.useManualTiming?i.timestamp:performance.now();n=!1,Bt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,fc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:mn.reduce((T,V)=>{const k=r[V];return T[V]=(C,L=!1,M=!1)=>(n||A(),k.schedule(C,L,M)),T},{}),cancel:T=>{for(let V=0;V<mn.length;V++)r[mn[V]].cancel(T)},state:i,steps:r}}const{schedule:G,cancel:Gt,state:it,steps:Un}=eo(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let vn;function mc(){vn=void 0}const mt={now:()=>(vn===void 0&&mt.set(it.isProcessing||Bt.useManualTiming?it.timestamp:performance.now()),vn),set:t=>{vn=t,queueMicrotask(mc)}},no=t=>e=>typeof e=="string"&&e.startsWith(t),Bs=no("--"),pc=no("var(--"),$s=t=>pc(t)?gc.test(t.split("/*")[0].trim()):!1,gc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Je={...De,transform:t=>Ot(0,1,t)},pn={...De,default:1},We=t=>Math.round(t*1e5)/1e5,zs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function yc(t){return t==null}const xc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Us=(t,e)=>n=>!!(typeof n=="string"&&xc.test(n)&&n.startsWith(t)||e&&!yc(n)&&Object.prototype.hasOwnProperty.call(n,e)),so=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(zs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},vc=t=>Ot(0,255,t),_n={...De,transform:t=>Math.round(vc(t))},ce={test:Us("rgb","red"),parse:so("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+_n.transform(t)+", "+_n.transform(e)+", "+_n.transform(n)+", "+We(Je.transform(s))+")"};function bc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const rs={test:Us("#"),parse:bc,transform:ce.transform},rn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Xt=rn("deg"),Vt=rn("%"),I=rn("px"),wc=rn("vh"),Tc=rn("vw"),Si={...Vt,parse:t=>Vt.parse(t)/100,transform:t=>Vt.transform(t*100)},be={test:Us("hsl","hue"),parse:so("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Vt.transform(We(e))+", "+Vt.transform(We(n))+", "+We(Je.transform(s))+")"},tt={test:t=>ce.test(t)||rs.test(t)||be.test(t),parse:t=>ce.test(t)?ce.parse(t):be.test(t)?be.parse(t):rs.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ce.transform(t):be.transform(t),getAnimatableNone:t=>{const e=tt.parse(t);return e.alpha=0,tt.transform(e)}},Sc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ac(t){return isNaN(t)&&typeof t=="string"&&(t.match(zs)?.length||0)+(t.match(Sc)?.length||0)>0}const io="number",ro="color",Cc="var",Pc="var(",Ai="${}",jc=/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 Ze(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(jc,c=>(tt.test(c)?(s.color.push(o),i.push(ro),n.push(tt.parse(c))):c.startsWith(Pc)?(s.var.push(o),i.push(Cc),n.push(c)):(s.number.push(o),i.push(io),n.push(parseFloat(c))),++o,Ai)).split(Ai);return{values:n,split:a,indexes:s,types:i}}function oo(t){return Ze(t).values}function ao(t){const{split:e,types:n}=Ze(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===io?o+=We(i[r]):a===ro?o+=tt.transform(i[r]):o+=i[r]}return o}}const Mc=t=>typeof t=="number"?0:tt.test(t)?tt.getAnimatableNone(t):t;function Ec(t){const e=oo(t);return ao(t)(e.map(Mc))}const qt={test:Ac,parse:oo,createTransformer:ao,getAnimatableNone:Ec};function Wn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function kc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Wn(c,a,t+1/3),o=Wn(c,a,t),r=Wn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Pn(t,e){return n=>n>0?e:t}const Y=(t,e,n)=>t+(e-t)*n,Kn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Dc=[rs,ce,be],Vc=t=>Dc.find(e=>e.test(t));function Ci(t){const e=Vc(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=kc(n)),n}const Pi=(t,e)=>{const n=Ci(t),s=Ci(e);if(!n||!s)return Pn(t,e);const i={...n};return o=>(i.red=Kn(n.red,s.red,o),i.green=Kn(n.green,s.green,o),i.blue=Kn(n.blue,s.blue,o),i.alpha=Y(n.alpha,s.alpha,o),ce.transform(i))},os=new Set(["none","hidden"]);function Nc(t,e){return os.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Rc(t,e){return n=>Y(t,e,n)}function _s(t){return typeof t=="number"?Rc:typeof t=="string"?$s(t)?Pn:tt.test(t)?Pi:Oc:Array.isArray(t)?co:typeof t=="object"?tt.test(t)?Pi:Ic:Pn}function co(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>_s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Ic(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=_s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Lc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Oc=(t,e)=>{const n=qt.createTransformer(e),s=Ze(t),i=Ze(e);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?os.has(t)&&!i.values.length||os.has(e)&&!s.values.length?Nc(t,e):nn(co(Lc(s,i),i.values),n):(ke(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Pn(t,e))};function lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Y(t,e,n):_s(t)(t,e)}const Fc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>G.update(e,n),stop:()=>Gt(e),now:()=>it.isProcessing?it.timestamp:mt.now()}},uo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},jn=2e4;function Ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<jn;)e+=n,s=t.next(e);return e>=jn?1/0:e}function Bc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ws(s),jn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const $c=5;function ho(t,e,n){const s=Math.max(e-$c,0);return Wr(n-t(s),e-s)}const q={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},Hn=.001;function zc({duration:t=q.duration,bounce:e=q.bounce,velocity:n=q.velocity,mass:s=q.mass}){let i,o;ke(t<=Pt(q.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Ot(q.minDamping,q.maxDamping,r),t=Ot(q.minDuration,q.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=as(u,r),y=Math.exp(-d);return Hn-f/g*y},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=as(Math.pow(u,2),r);return(-i(u)+Hn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Hn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=_c(i,o,a);if(t=Pt(t),isNaN(c))return{stiffness:q.stiffness,damping:q.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Uc=12;function _c(t,e,n){let s=n;for(let i=1;i<Uc;i++)s=s-t(s)/e(s);return s}function as(t,e){return t*Math.sqrt(1-e*e)}const Wc=["duration","bounce"],Kc=["stiffness","damping","mass"];function ji(t,e){return e.some(n=>t[n]!==void 0)}function Hc(t){let e={velocity:q.velocity,stiffness:q.stiffness,damping:q.damping,mass:q.mass,isResolvedFromDuration:!1,...t};if(!ji(t,Kc)&&ji(t,Wc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Ot(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:q.mass,stiffness:i,damping:o}}else{const n=zc(t);e={...e,...n,mass:q.mass},e.isResolvedFromDuration=!0}return e}function Mn(t=q.visualDuration,e=q.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Hc({...n,velocity:-bt(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,x=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?q.restSpeed.granular:q.restSpeed.default),i||(i=w?q.restDelta.granular:q.restDelta.default);let T;if(v<1){const k=as(x,v);T=C=>{const L=Math.exp(-v*x*C);return r-L*((y+v*x*A)/k*Math.sin(k*C)+A*Math.cos(k*C))}}else if(v===1)T=k=>r-Math.exp(-x*k)*(A+(y+x*A)*k);else{const k=x*Math.sqrt(v*v-1);T=C=>{const L=Math.exp(-v*x*C),M=Math.min(k*C,300);return r-L*((y+v*x*A)*Math.sinh(M)+k*A*Math.cosh(M))/k}}const V={calculatedDuration:g&&d||null,next:k=>{const C=T(k);if(g)a.done=k>=d;else{let L=k===0?y:0;v<1&&(L=k===0?Pt(y):ho(T,k,C));const M=Math.abs(L)<=s,F=Math.abs(r-C)<=i;a.done=M&&F}return a.value=a.done?r:C,a},toString:()=>{const k=Math.min(Ws(V),jn),C=uo(L=>V.next(k*L).value,k,30);return k+"ms "+C},toTransition:()=>{}};return V}Mn.applyToOptions=t=>{const e=Bc(t,100,Mn);return t.ease=e.ease,t.duration=Pt(e.duration),t.type="keyframes",t};function cs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=M=>a!==void 0&&M<a||c!==void 0&&M>c,y=M=>a===void 0?c:c===void 0||Math.abs(a-M)<Math.abs(c-M)?a:c;let v=n*e;const A=d+v,x=r===void 0?A:r(A);x!==A&&(v=x-d);const w=M=>-v*Math.exp(-M/s),T=M=>x+w(M),V=M=>{const F=w(M),z=T(M);f.done=Math.abs(F)<=u,f.value=f.done?x:z};let k,C;const L=M=>{g(f.value)&&(k=M,C=Mn({keyframes:[f.value,y(f.value)],velocity:ho(T,M,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return L(0),{calculatedDuration:null,next:M=>{let F=!1;return!C&&k===void 0&&(F=!0,V(M),L(M)),k!==void 0&&M>=k?C.next(M-k):(!F&&V(M),f)}}}function Xc(t,e,n){const s=[],i=n||Bt.mix||lo,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=nn(c,a)}s.push(a)}return s}function Gc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ft(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Xc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ye(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Ot(t[0],t[o-1],l)):u}function qc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ye(0,e,s);t.push(Y(n,1,i))}}function Yc(t){const e=[0];return qc(e,t.length-1),e}function Jc(t,e){return t.map(n=>n*e)}function Zc(t,e){return t.map(()=>e||Qr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=uc(s)?s.map(Ti):Ti(s),o={done:!1,value:e[0]},r=Jc(n&&n.length===e.length?n:Yc(e),t),a=Gc(r,e,{ease:Array.isArray(i)?i:Zc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Qc=t=>t!==null;function Ks(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Qc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const tl={decay:cs,inertia:cs,tween:we,keyframes:we,spring:Mn};function fo(t){typeof t.type=="string"&&(t.type=tl[t.type])}class Hs{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const el=t=>t/100;class Xs extends Hs{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;fo(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ft(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=nn(el,lo(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ws(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,V=s;if(d){const M=Math.min(this.currentTime,i)/a;let F=Math.floor(M),z=M%1;!z&&M>=1&&(z=1),z===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(f==="reverse"?(z=1-z,g&&(z-=g/a)):f==="mirror"&&(V=r)),T=Ot(0,1,z)*a}const k=w?{done:!1,value:l[0]}:V.next(T);o&&(k.value=o(k.value));let{done:C}=k;!w&&c!==null&&(C=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const L=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return L&&y!==cs&&(k.value=Ks(l,this.options,A,this.speed)),v&&v(k.value),L&&this.finish(),k}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Pt(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Fc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();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(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function nl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const le=t=>t*180/Math.PI,ls=t=>{const e=le(Math.atan2(t[1],t[0]));return us(e)},sl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ls,rotateZ:ls,skewX:t=>le(Math.atan(t[1])),skewY:t=>le(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},us=t=>(t=t%360,t<0&&(t+=360),t),Mi=ls,Ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ki=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),il={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ei,scaleY:ki,scale:t=>(Ei(t)+ki(t))/2,rotateX:t=>us(le(Math.atan2(t[6],t[5]))),rotateY:t=>us(le(Math.atan2(-t[2],t[0]))),rotateZ:Mi,rotate:Mi,skewX:t=>le(Math.atan(t[4])),skewY:t=>le(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ds(t){return t.includes("scale")?1:0}function hs(t,e){if(!t||t==="none")return ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=il,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=sl,i=a}if(!i)return ds(e);const o=s[e],r=i[1].split(",").map(ol);return typeof o=="function"?o(r):r[o]}const rl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return hs(n,e)};function ol(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ne=new Set(Ve),Di=t=>t===De||t===I,al=new Set(["x","y","z"]),cl=Ve.filter(t=>!al.has(t));function ll(t){const e=[];return cl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ue={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>hs(e,"x"),y:(t,{transform:e})=>hs(e,"y")};ue.translateX=ue.x;ue.translateY=ue.y;const de=new Set;let fs=!1,ms=!1,ps=!1;function mo(){if(ms){const t=Array.from(de).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ms=!1,fs=!1,de.forEach(t=>t.complete(ps)),de.clear()}function po(){de.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ms=!0)})}function ul(){ps=!0,po(),mo(),ps=!1}class Gs{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(de.add(this),fs||(fs=!0,G.read(po),G.resolveKeyframes(mo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}nl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),de.delete(this)}cancel(){this.state==="scheduled"&&(de.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const dl=t=>t.startsWith("--");function hl(t,e,n){dl(e)?t.style.setProperty(e,n):t.style[e]=n}const fl=Rs(()=>window.ScrollTimeline!==void 0),ml={};function pl(t,e){const n=Rs(t);return()=>ml[e]??n()}const go=pl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Vi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_e([0,.65,.55,1]),circOut:_e([.55,0,1,.45]),backIn:_e([.31,.01,.66,-.59]),backOut:_e([.33,1.53,.69,.99])};function yo(t,e){if(t)return typeof t=="function"?go()?uo(t,e):"ease-out":to(t)?_e(t):Array.isArray(t)?t.map(n=>yo(n,e)||Vi.easeOut):Vi[t]}function gl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=yo(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function xo(t){return typeof t=="function"&&"applyToOptions"in t}function yl({type:t,...e}){return xo(t)&&go()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class xl extends Hs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ft(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=yl(e);this.animation=gl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Ks(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):hl(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Pt(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&fl()?(this.animation.timeline=e,wt):n(this)}}const vo={anticipate:Yr,backInOut:qr,circInOut:Zr};function vl(t){return t in vo}function bl(t){typeof t.ease=="string"&&vl(t.ease)&&(t.ease=vo[t.ease])}const Ni=10;class wl extends xl{constructor(e){bl(e),fo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Xs({...r,autoplay:!1}),c=Pt(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ni).value,a.sample(c).value,Ni),a.stop()}}const Ri=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(qt.test(t)||t==="0")&&!t.startsWith("url("));function Tl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Sl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ri(i,e),a=Ri(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:Tl(t)||(n==="spring"||xo(n))&&s}function gs(t){t.duration=0,t.type="keyframes"}const Al=new Set(["opacity","clipPath","filter","transform"]),Cl=Rs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Cl()&&n&&Al.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const jl=40;class Ml extends Hs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Gs;this.keyframeResolver=new g(a,(y,v,A)=>this.onKeyframesResolved(y,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),Sl(e,o,r,a)||((Bt.instantAnimations||!c)&&l?.(Ks(e,s,n)),e[0]=e[e.length-1],gs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>jl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Pl(f)?new wl({...f,element:f.motionValue.owner.current}):new Xs(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),ul()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const El=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function kl(t){const e=El.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const Dl=4;function bo(t,e,n=1){Ft(n<=Dl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=kl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return zr(r)?parseFloat(r):r}return $s(i)?bo(i,e,n+1):i}function qs(t,e){return t?.[e]??t?.default??t}const wo=new Set(["width","height","top","left","right","bottom",...Ve]),Vl={test:t=>t==="auto",parse:t=>t},To=t=>e=>e.test(t),So=[De,I,Vt,Xt,Tc,wc,Vl],Ii=t=>So.find(To(t));function Nl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_r(t):!0}const Rl=new Set(["brightness","contrast","saturate","opacity"]);function Il(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(zs)||[];if(!s)return t;const i=n.replace(s,"");let o=Rl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Ll=/\b([a-z-]*)\(.*?\)/gu,ys={...qt,getAnimatableNone:t=>{const e=t.match(Ll);return e?e.map(Il).join(" "):t}},Li={...De,transform:Math.round},Ol={rotate:Xt,rotateX:Xt,rotateY:Xt,rotateZ:Xt,scale:pn,scaleX:pn,scaleY:pn,scaleZ:pn,skew:Xt,skewX:Xt,skewY:Xt,distance:I,translateX:I,translateY:I,translateZ:I,x:I,y:I,z:I,perspective:I,transformPerspective:I,opacity:Je,originX:Si,originY:Si,originZ:I},Ys={borderWidth:I,borderTopWidth:I,borderRightWidth:I,borderBottomWidth:I,borderLeftWidth:I,borderRadius:I,radius:I,borderTopLeftRadius:I,borderTopRightRadius:I,borderBottomRightRadius:I,borderBottomLeftRadius:I,width:I,maxWidth:I,height:I,maxHeight:I,top:I,right:I,bottom:I,left:I,padding:I,paddingTop:I,paddingRight:I,paddingBottom:I,paddingLeft:I,margin:I,marginTop:I,marginRight:I,marginBottom:I,marginLeft:I,backgroundPositionX:I,backgroundPositionY:I,...Ol,zIndex:Li,fillOpacity:Je,strokeOpacity:Je,numOctaves:Li},Fl={...Ys,color:tt,backgroundColor:tt,outlineColor:tt,fill:tt,stroke:tt,borderColor:tt,borderTopColor:tt,borderRightColor:tt,borderBottomColor:tt,borderLeftColor:tt,filter:ys,WebkitFilter:ys},Ao=t=>Fl[t];function Co(t,e){let n=Ao(t);return n!==ys&&(n=qt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Bl=new Set(["auto","none","0"]);function $l(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Bl.has(o)&&Ze(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Co(n,i)}class zl extends Gs{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),$s(u))){const l=bo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!wo.has(s)||e.length!==2)return;const[i,o]=e,r=Ii(i),a=Ii(o);if(r!==a)if(Di(r)&&Di(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ue[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Nl(e[i]))&&s.push(i);s.length&&$l(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ue[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ue[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Ul(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function jo(t){return Ur(t)&&"offsetHeight"in t}const Oi=30,_l=t=>!isNaN(parseFloat(t));class Wl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Ls(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Is);const s=this.events[e].add(n);return e==="change"?()=>{s(),G.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Oi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Oi);return Wr(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(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(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Me(t,e){return new Wl(t,e)}const{schedule:Js}=eo(queueMicrotask,!1),At={x:!1,y:!1};function Mo(){return At.x||At.y}function Kl(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function Eo(t,e){const n=Ul(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Fi(t){return!(t.pointerType==="touch"||Mo())}function Hl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{if(!Fi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Fi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const ko=(t,e)=>e?t===e?!0:ko(t,e.parentElement):!1,Zs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Xl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Gl(t){return Xl.has(t.tagName)||t.tabIndex!==-1}const bn=new WeakSet;function Bi(t){return e=>{e.key==="Enter"&&t(e)}}function Xn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const ql=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Bi(()=>{if(bn.has(n))return;Xn(n,"down");const i=Bi(()=>{Xn(n,"up")}),o=()=>Xn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function $i(t){return Zs(t)&&!Mo()}function Yl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{const c=a.currentTarget;if(!$i(a))return;bn.add(c);const u=e(c,a),l=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),bn.has(c)&&bn.delete(c),$i(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||ko(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),jo(a)&&(a.addEventListener("focus",u=>ql(u,i)),!Gl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Do(t){return Ur(t)&&"ownerSVGElement"in t}function Jl(t){return Do(t)&&t.tagName==="svg"}const at=t=>!!(t&&t.getVelocity),Zl=[...So,tt,qt],Ql=t=>Zl.find(To(t)),Qs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function tu(...t){return e=>{let n=!1;const s=t.map(i=>{const o=zi(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():zi(t[i],null)}}}}function eu(...t){return Ct.useCallback(tu(...t),t)}class nu extends Ct.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=jo(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 su({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Qs),c=eu(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${u}px !important;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
${y}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(nu,{isPresent:e,childRef:o,sizeRef:r,children:Ct.cloneElement(t,{ref:c})})}const iu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=ks(ru),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),Ct.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(su,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Dn.Provider,{value:f,children:t})};function ru(){return new Map}function Vo(t=!0){const e=m.useContext(Dn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const gn=t=>t.key||"";function Ui(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const ou=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Vo(r),d=m.useMemo(()=>Ui(t),[t]),f=r&&!u?[]:d.map(gn),g=m.useRef(!0),y=m.useRef(d),v=ks(()=>new Map),[A,x]=m.useState(d),[w,T]=m.useState(d);$r(()=>{g.current=!1,y.current=d;for(let C=0;C<w.length;C++){const L=gn(w[C]);f.includes(L)?v.delete(L):v.get(L)!==!0&&v.set(L,!1)}},[w,f.length,f.join("-")]);const V=[];if(d!==A){let C=[...d];for(let L=0;L<w.length;L++){const M=w[L],F=gn(M);f.includes(F)||(C.splice(L,0,M),V.push(M))}return o==="wait"&&V.length&&(C=V),T(Ui(C)),x(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:k}=m.useContext(Es);return h.jsx(h.Fragment,{children:w.map(C=>{const L=gn(C),M=r&&!u?!1:d===w||f.includes(L),F=()=>{if(v.has(L))v.set(L,!0);else return;let z=!0;v.forEach(W=>{W||(z=!1)}),z&&(k?.(),T(y.current),r&&l?.(),s&&s())};return h.jsx(iu,{isPresent:M,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:M?void 0:F,anchorX:a,children:C},L)})})},ti=m.createContext({strict:!1}),_i={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"]},Ee={};for(const t in _i)Ee[t]={isEnabled:e=>_i[t].some(n=>!!e[n])};function xs(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function au({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Xn(e)),i=m.useRef(void 0);if(!Xn(e)){const{renderer:o,...r}=e;i.current=o,xs(r)}return m.useEffect(()=>{Xn(e)&&e().then(({renderer:o,...r})=>{xs(r),i.current=o,s(!0)})},[]),h.jsx(ti.Provider,{value:{renderer:i.current,strict:n},children:t})}function Xn(t){return typeof t=="function"}const cu=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 En(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cu.has(t)}let No=t=>!En(t);function lu(t){typeof t=="function"&&(No=e=>e.startsWith("on")?!En(e):t(e))}try{lu(require("@emotion/is-prop-valid").default)}catch{}function uu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(No(i)||n===!0&&En(i)||!e&&!En(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Vn=m.createContext({});function Nn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qe(t){return typeof t=="string"||Array.isArray(t)}const ei=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ni=["initial",...ei];function Rn(t){return Nn(t.animate)||ni.some(e=>Qe(t[e]))}function Ro(t){return!!(Rn(t)||t.variants)}function du(t,e){if(Rn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Qe(n)?n:void 0,animate:Qe(s)?s:void 0}}return t.inherit!==!1?e:{}}function hu(t){const{initial:e,animate:n}=du(t,m.useContext(Vn));return m.useMemo(()=>({initial:e,animate:n}),[Wi(e),Wi(n)])}function Wi(t){return Array.isArray(t)?t.join(" "):t}const tn={};function fu(t){for(const e in t)tn[e]=t[e],Bs(e)&&(tn[e].isCSSVariable=!0)}function Io(t,{layout:e,layoutId:n}){return Ne.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!tn[t]||t==="opacity")}const mu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pu=Ve.length;function gu(t,e,n){let s="",i=!0;for(let o=0;o<pu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Ys[r]);if(!c){i=!1;const l=mu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function si(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Ne.has(c)){r=!0;continue}else if(Bs(c)){i[c]=u;continue}else{const l=Po(u,Ys[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=gu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ii=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Lo(t,e,n){for(const s in e)!at(e[s])&&!Io(s,n)&&(t[s]=e[s])}function yu({transformTemplate:t},e){return m.useMemo(()=>{const n=ii();return si(n,e,t),Object.assign({},n.vars,n.style)},[e])}function xu(t,e){const n=t.style||{},s={};return Lo(s,n,t),Object.assign(s,yu(t,e)),s}function vu(t,e){const n={},s=xu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const bu={offset:"stroke-dashoffset",array:"stroke-dasharray"},wu={offset:"strokeDashoffset",array:"strokeDasharray"};function Tu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?bu:wu;t[o.offset]=I.transform(-s);const r=I.transform(e),a=I.transform(n);t[o.array]=`${r} ${a}`}function Oo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(si(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Tu(d,i,o,r,!1)}const Fo=()=>({...ii(),attrs:{}}),Bo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Su(t,e,n,s){const i=m.useMemo(()=>{const o=Fo();return Oo(o,e,Bo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Lo(o,t.style,t),i.style={...o,...i.style}}return i}const Au=["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 ri(t){return typeof t!="string"||t.includes("-")?!1:!!(Au.indexOf(t)>-1||/[A-Z]/u.test(t))}function Cu(t,e,n,{latestValues:s},i,o=!1){const a=(ri(t)?Su:vu)(e,s,i,t),c=uu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>at(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Ki(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function oi(t,e,n,s){if(typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function wn(t){return at(t)?t.get():t}function Pu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:ju(n,s,i,t),renderState:e()}}function ju(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=wn(o[f]);let{initial:r,animate:a}=t;const c=Rn(t),u=Ro(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Nn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=oi(t,f[g]);if(y){const{transitionEnd:v,transition:A,...x}=y;for(const w in x){let T=x[w];if(Array.isArray(T)){const V=l?T.length-1:0;T=T[V]}T!==null&&(i[w]=T)}for(const w in v)i[w]=v[w]}}}return i}const $o=t=>(e,n)=>{const s=m.useContext(Vn),i=m.useContext(Dn),o=()=>Pu(t,e,s,i);return n?o():ks(o)};function ai(t,e,n){const{style:s}=t,i={};for(const o in s)(at(s[o])||e.style&&at(e.style[o])||Io(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Mu=$o({scrapeMotionValuesFromProps:ai,createRenderState:ii});function zo(t,e,n){const s=ai(t,e,n);for(const i in t)if(at(t[i])||at(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Eu=$o({scrapeMotionValuesFromProps:zo,createRenderState:Fo}),ku=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Du(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ci=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Vu="framerAppearId",Uo="data-"+ci(Vu),_o=m.createContext({});function Nu(t,e,n,s,i){const{visualElement:o}=m.useContext(Vn),r=m.useContext(ti),a=m.useContext(Dn),c=m.useContext(Qs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(_o);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Ru(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[Uo],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return $r(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),y.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!y.current&&l.animationState&&l.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),l.enteringChildren=void 0)}),l}function Ru(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Wo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Wo(t){if(t)return t.options.allowProjection!==!1?t.projection:Wo(t.parent)}function Tn(t,{forwardMotionProps:e=!1}={},n,s){n&&xs(n);const i=ri(t)?Eu:Mu;function o(a,c){let u;const l={...m.useContext(Qs),...a,layoutId:Iu(a)},{isStatic:d}=l,f=hu(a),g=i(a,d);if(!d&&Ds){Lu(l,n);const y=Ou(l);u=y.MeasureLayout,f.visualElement=Nu(t,g,l,s,y.ProjectionNode)}return h.jsxs(Vn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Cu(t,a,Du(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ku]=t,r}function Iu({layoutId:t}){const e=m.useContext(Es).id;return e&&t!==void 0?e+"-"+t:t}function Lu(t,e){const n=m.useContext(ti).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ft(!1,s,"lazy-strict-mode")}}function Ou(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Fu(t,e){if(typeof Proxy>"u")return Tn;const n=new Map,s=(o,r)=>Tn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Ls(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Tn(r,void 0,t,e)),n.get(r))})}function Ko({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Bu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function $u(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function qn(t){return t===void 0||t===1}function vs({scale:t,scaleX:e,scaleY:n}){return!qn(t)||!qn(e)||!qn(n)}function ae(t){return vs(t)||Ho(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ho(t){return Hi(t.x)||Hi(t.y)}function Hi(t){return t&&t!=="0%"}function kn(t,e,n){const s=t-n,i=e*s;return n+i}function Gi(t,e,n,s,i){return i!==void 0&&(t=kn(t,i,s)),kn(t,n,s)+e}function bs(t,e=0,n=1,s,i){t.min=Gi(t.min,e,n,s,i),t.max=Gi(t.max,e,n,s,i)}function Go(t,{x:e,y:n}){bs(t.x,e.translate,e.scale,e.originPoint),bs(t.y,n.translate,n.scale,n.originPoint)}const Xi=.999999999999,qi=1.0000000000001;function zu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],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&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Go(t,r)),s&&ae(o.latestValues)&&Ae(t,o.latestValues))}e.x<qi&&e.x>Xi&&(e.x=1),e.y<qi&&e.y>Xi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function Yi(t,e,n,s,i=.5){const o=Y(t.min,t.max,i);bs(t,e,n,o,s)}function Ae(t,e){Yi(t.x,e.x,e.scaleX,e.scale,e.originX),Yi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Xo(t,e){return Ko($u(t.getBoundingClientRect(),e))}function Uu(t,e,n){const s=Xo(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Ji=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ce=()=>({x:Ji(),y:Ji()}),Zi=()=>({min:0,max:0}),J=()=>({x:Zi(),y:Zi()}),ws={current:null},qo={current:!1};function _u(){if(qo.current=!0,!!Ds)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ws.current=t.matches;t.addEventListener("change",e),e()}else ws.current=!1}const Wu=new WeakMap;function Ku(t,e,n){for(const s in e){const i=e[s],o=n[s];if(at(i))t.addValue(s,i);else if(at(o))t.addValue(s,Me(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,Me(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Qi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Hu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Xs,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 f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,X.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Rn(n),this.isVariantNode=Ro(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&at(g)&&g.set(c[f])}}mount(e){this.current=e,Wu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),qo.current||_u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ws.current,process.env.NODE_ENV!=="production"&&Ls(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Xt(this.notifyUpdate),Xt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Ne.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&X.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];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):J()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Qi.length;s++){const i=Qi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Ku(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]: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(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=Me(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(zr(s)||_r(s))?s=parseFloat(s):!Ql(s)&&qt.test(n)&&(s=Co(e,n)),this.setBaseTarget(e,at(s)?s.get():s)),at(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=oi(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!at(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Js.render(this.render)}}class Yo extends Hu{constructor(){super(...arguments),this.KeyframeResolver=zl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;at(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Jo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Gu(t){return window.getComputedStyle(t)}class Xu extends Yo{constructor(){super(...arguments),this.type="html",this.renderInstance=Jo}readValueFromInstance(e,n){if(Ne.has(n))return this.projection?.isProjecting?ds(n):rl(e,n);{const s=Gu(e),i=(Bs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Xo(e,n)}build(e,n,s){si(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ai(e,n,s)}}const Zo=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 qu(t,e,n,s){Jo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Zo.has(i)?i:ci(i),e.attrs[i])}class Yu extends Yo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=J}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Ne.has(n)){const s=Ao(n);return s&&s.default||0}return n=Zo.has(n)?n:ci(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return zo(e,n,s)}build(e,n,s){Oo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){qu(e,n,s,i)}mount(e){this.isSVGTag=Bo(e.tagName),super.mount(e)}}const Qo=(t,e)=>ri(t)?new Yu(e):new Xu(e,{allowProjection:t!==m.Fragment});function je(t,e,n){const s=t.getProps();return oi(s,e,n!==void 0?n:s.custom,t)}const Ts=t=>Array.isArray(t);function Ju(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Me(n))}function Zu(t){return Ts(t)?t[t.length-1]||0:t}function Qu(t,e){const n=je(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Zu(o[r]);Ju(t,r,a)}}function td(t){return!!(at(t)&&t.add)}function Ss(t,e){const n=t.getValue("willChange");if(td(n))return n.add(e);if(!n&&Bt.WillChange){const s=new Bt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function ta(t){return t.props[Uo]}const ed=t=>t!==null;function nd(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ed),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const sd={type:"spring",stiffness:500,damping:25,restSpeed:10},id=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),rd={type:"keyframes",duration:.8},od={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ad=(t,{keyframes:e})=>e.length>2?rd:Ne.has(t)?t.startsWith("scale")?id(e[1]):sd:od;function cd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const li=(t,e,n,s={},i,o)=>r=>{const a=qs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Pt(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};cd(a)||Object.assign(l,ad(t,l)),l.duration&&(l.duration=Pt(l.duration)),l.repeatDelay&&(l.repeatDelay=Pt(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(gs(l),l.delay===0&&(d=!0)),(Bt.instantAnimations||Bt.skipAnimations)&&(d=!0,gs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=nd(l.keyframes,a);if(f!==void 0){X.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Gs(l):new Ml(l)};function ld({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ea(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ld(u,l))continue;const g={delay:n,...qs(o||{},l)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=ta(t);if(x){const w=window.MotionHandoffAnimation(x,l,X);w!==null&&(g.startTime=w,v=!0)}}Ss(t,l),d.start(li(l,d,f,t.shouldReduceMotion&&wo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{X.update(()=>{r&&Qu(t,r)})}),c}function na(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function As(t,e,n={}){const s=je(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ea(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ud(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function ud(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(As(c,e,{...r,delay:n+(typeof s=="function"?0:s)+na(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function dd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>As(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=As(t,e,n);else{const i=typeof e=="function"?je(t,e,n.custom):e;s=Promise.all(ea(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function sa(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const hd=ni.length;function ia(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?ia(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<hd;n++){const s=ni[n],i=t.props[s];(Qe(i)||i===!1)&&(e[s]=i)}return e}const fd=[...ei].reverse(),md=ei.length;function pd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>dd(t,n,s)))}function gd(t){let e=pd(t),n=tr(),s=!0;const i=c=>(u,l)=>{const d=je(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=ia(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let A=0;A<md;A++){const x=fd[A],w=n[x],T=u[x]!==void 0?u[x]:l[x],V=Qe(T),k=x===c?w.isActive:null;k===!1&&(y=A);let C=T===l[x]&&T!==u[x]&&V;if(C&&s&&t.manuallyAnimateOnMount&&(C=!1),w.protectedKeys={...g},!w.isActive&&k===null||!T&&!w.prevProp||Nn(T)||typeof T=="boolean")continue;const L=yd(w.prevProp,T);let M=L||x===c&&w.isActive&&!C&&V||A>y&&V,F=!1;const z=Array.isArray(T)?T:[T];let W=z.reduce(i(x),{});k===!1&&(W={});const{prevResolvedValues:B={}}=w,jt={...B,...W},Tt=U=>{M=!0,f.has(U)&&(F=!0,f.delete(U)),w.needsAnimating[U]=!0;const ct=t.getValue(U);ct&&(ct.liveStyle=!1)};for(const U in jt){const ct=W[U],lt=B[U];if(g.hasOwnProperty(U))continue;let ut=!1;Ts(ct)&&Ts(lt)?ut=!sa(ct,lt):ut=ct!==lt,ut?ct!=null?Tt(U):f.add(U):ct!==void 0&&f.has(U)?Tt(U):w.protectedKeys[U]=!0}w.prevProp=T,w.prevResolvedValues=W,w.isActive&&(g={...g,...W}),s&&t.blockInitialAnimation&&(M=!1);const rt=C&&L;M&&(!rt||F)&&d.push(...z.map(U=>{const ct={type:x};if(typeof U=="string"&&s&&!rt&&t.manuallyAnimateOnMount&&t.parent){const{parent:lt}=t,ut=je(lt,U);if(lt.enteringChildren&&ut){const{delayChildren:dt}=ut.transition||{};ct.delay=na(lt.enteringChildren,t,dt)}}return{animation:U,options:ct}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const x=je(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(A.transition=x.transition)}f.forEach(x=>{const w=t.getBaseTarget(x),T=t.getValue(x);T&&(T.liveStyle=!0),A[x]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tr()}}}function yd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!sa(e,t):!1}function re(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tr(){return{animate:re(!0),whileInView:re(),whileHover:re(),whileTap:re(),whileDrag:re(),whileFocus:re(),exit:re()}}class Yt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class xd extends Yt{constructor(e){super(e),e.animationState||(e.animationState=gd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Nn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let vd=0;class bd extends Yt{constructor(){super(...arguments),this.id=vd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const ra={animation:{Feature:xd},exit:{Feature:bd}};function en(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function on(t){return{point:{x:t.pageX,y:t.pageY}}}const wd=t=>e=>Zs(e)&&t(e,on(e));function Ke(t,e,n,s){return en(t,e,wd(n),s)}const oa=1e-4,Td=1-oa,Sd=1+oa,aa=.01,Ad=0-aa,Cd=0+aa;function ft(t){return t.max-t.min}function Pd(t,e,n){return Math.abs(t-e)<=n}function er(t,e,n,s=.5){t.origin=s,t.originPoint=Y(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=Y(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Td&&t.scale<=Sd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ad&&t.translate<=Cd||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,s){er(t.x,e.x,n.x,s?s.originX:void 0),er(t.y,e.y,n.y,s?s.originY:void 0)}function nr(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function jd(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function sr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function Ge(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const ca=({current:t})=>t?t.ownerDocument.defaultView:null,ir=(t,e)=>Math.abs(t-e);function Md(t,e){const n=ir(t.x,e.x),s=ir(t.y,e.y);return Math.sqrt(n**2+s**2)}class la{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=Md(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:A}=it;this.history.push({...v,timestamp:A});const{onStart:x,onMove:w}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Yn(g,this.transformPagePoint),X.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Jn(f.type==="pointercancel"?this.lastMoveEventInfo:Yn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Zs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=on(e),c=Yn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=it;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Jn(c,this.history)),this.removeListeners=nn(Ke(this.contextWindow,"pointermove",this.handlePointerMove),Ke(this.contextWindow,"pointerup",this.handlePointerUp),Ke(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Xt(this.updatePoint)}}function Yn(t,e){return e?{point:e(t.point)}:t}function rr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Jn({point:t},e){return{point:t,delta:rr(t,ua(e)),offset:rr(t,Ed(e)),velocity:kd(e,.1)}}function Ed(t){return t[0]}function ua(t){return t[t.length-1]}function kd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ua(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Pt(e)));)n--;if(!s)return{x:0,y:0};const o=bt(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 Dd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?Y(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?Y(n,t,s.max):Math.min(t,n)),t}function or(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Vd(t,{top:e,left:n,bottom:s,right:i}){return{x:or(t.x,n,i),y:or(t.y,e,s)}}function ar(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function Nd(t,e){return{x:ar(t.x,e.x),y:ar(t.y,e.y)}}function Rd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ye(e.min,e.max-s,t.min):s>i&&(n=Ye(t.min,t.max-i,e.min)),Ot(0,1,n)}function Id(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Cs=.35;function Ld(t=Cs){return t===!1?t=0:t===!0&&(t=Cs),{x:cr(t,"left","right"),y:cr(t,"top","bottom")}}function cr(t,e,n){return{min:lr(t,e),max:lr(t,n)}}function lr(t,e){return typeof t=="number"?t:t[e]||0}const Od=new WeakMap;class Fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=J(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(on(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Kl(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(x=>{let w=this.getAxisMotionValue(x).get()||0;if(Vt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const V=T.layout.layoutBox[x];V&&(w=ft(V)*(parseFloat(w)/100))}}this.originPoint[x]=w}),v&&X.postRender(()=>v(d,f)),Ss(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=Bd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new la(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:ca(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&X.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.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(e,n,s){const{drag:i}=this.getProps();if(!s||!yn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Dd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Vd(s.layoutBox,e):this.constraints=!1,this.elastic=Ld(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Id(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ft(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Uu(s,i.root,this.visualElement.getTransformPagePoint());let r=Nd(i.layout.layoutBox,o);if(n){const a=n(Bu(r));this.hasMutatedConstraints=!!a,a&&(r=Ko(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!yn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Ss(this.visualElement,e),s.start(li(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!yn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-Y(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Rd({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(),vt(r=>{if(!yn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(Y(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Od.set(this.visualElement,this);const e=this.visualElement.current,n=Ke(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(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()),X.read(s);const r=en(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Cs,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Bd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $d extends Yt{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ur=t=>(e,n)=>{t&&X.postRender(()=>t(e,n))};class zd extends Yt{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new la(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ca(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:ur(e),onStart:ur(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&X.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ke(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Sn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ue={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(I.test(t))t=parseFloat(t);else return t;const n=dr(t,e.target.x),s=dr(t,e.target.y);return`${n}% ${s}%`}},Ud={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=qt.parse(t);if(i.length>5)return s;const o=qt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=Y(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Zn=!1;class _d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;fu(Wd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Zn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Sn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Zn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||X.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Zn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function da(t){const[e,n]=Vo(),s=m.useContext(Es);return h.jsx(_d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(_o),isPresent:e,safeToRemove:n})}const Wd={borderRadius:{...Ue,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ue,borderTopRightRadius:Ue,borderBottomLeftRadius:Ue,borderBottomRightRadius:Ue,boxShadow:Ud};function Kd(t,e,n){const s=at(t)?t:Me(t);return s.start(li("",s,e,n)),s.animation}const Hd=(t,e)=>t.depth-e.depth;class Gd{constructor(){this.children=[],this.isDirty=!1}add(e){Vs(this.children,e),this.isDirty=!0}remove(e){Ns(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Hd),this.isDirty=!1,this.children.forEach(e)}}function Xd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Xt(s),t(o-e))};return X.setup(s,!0),()=>Xt(s)}const ha=["TopLeft","TopRight","BottomLeft","BottomRight"],qd=ha.length,hr=t=>typeof t=="string"?parseFloat(t):t,fr=t=>typeof t=="number"||I.test(t);function Yd(t,e,n,s,i,o){i?(t.opacity=Y(0,n.opacity??1,Jd(s)),t.opacityExit=Y(e.opacity??1,0,Zd(s))):o&&(t.opacity=Y(e.opacity??1,n.opacity??1,s));for(let r=0;r<qd;r++){const a=`border${ha[r]}Radius`;let c=mr(e,a),u=mr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||fr(c)===fr(u)?(t[a]=Math.max(Y(hr(c),hr(u),s),0),(Vt.test(u)||Vt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=Y(e.rotate||0,n.rotate||0,s))}function mr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Jd=fa(0,.5,Jr),Zd=fa(.5,.95,wt);function fa(t,e,n){return s=>s<t?0:s>e?1:n(Ye(t,e,s))}function pr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){pr(t.x,e.x),pr(t.y,e.y)}function gr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yr(t,e,n,s,i){return t-=e,t=kn(t,1/n,s),i!==void 0&&(t=kn(t,1/i,s)),t}function Qd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Vt.test(e)&&(e=parseFloat(e),e=Y(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=Y(o.min,o.max,s);t===o&&(a-=e),t.min=yr(t.min,e,n,a,i),t.max=yr(t.max,e,n,a,i)}function xr(t,e,[n,s,i],o,r){Qd(t,e[n],e[s],e[i],e.scale,o,r)}const th=["x","scaleX","originX"],eh=["y","scaleY","originY"];function vr(t,e,n,s){xr(t.x,e,th,n?n.x:void 0,s?s.x:void 0),xr(t.y,e,eh,n?n.y:void 0,s?s.y:void 0)}function br(t){return t.translate===0&&t.scale===1}function ma(t){return br(t.x)&&br(t.y)}function wr(t,e){return t.min===e.min&&t.max===e.max}function nh(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function pa(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t){return ft(t.x)/ft(t.y)}function Ar(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class sh{constructor(){this.members=[]}add(e){Vs(this.members,e),e.scheduleRender()}remove(e){if(Ns(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===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(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function ih(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Qn=["","X","Y","Z"],rh=1e3;let oh=0;function ts(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ga(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=ta(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",X,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ga(s)}function ya({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=oh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.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(lh),this.nodes.forEach(fh),this.nodes.forEach(mh),this.nodes.forEach(uh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Gd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Is),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Do(r)&&!Jl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;X.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Xd(f,250),Sn.hasAnimatedSinceResize&&(Sn.hasAnimatedSinceResize=!1,this.nodes.forEach(jr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||vh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),x=!this.targetLayout||!pa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...qs(y,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,w)}else d||jr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}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(),Xt(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(ph),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&&ga(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Cr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Pr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(hh),this.nodes.forEach(ah),this.nodes.forEach(ch)):this.nodes.forEach(Pr),this.clearAllSnapshots();const a=mt.now();it.delta=Ot(0,1e3/60,a-it.timestamp),it.timestamp=a,it.isProcessing=!0,Un.update.process(it),Un.preRender.process(it),Un.render.process(it),it.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(dh),this.sharedNodes.forEach(gh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,X.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){X.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(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=J(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&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,a=this.projectionDelta&&!ma(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||ae(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),bh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return J();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(wh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=J();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=J();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ae(l.latestValues)&&Ae(c,l.latestValues)}return ae(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=J();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ae(u.latestValues))continue;vs(u.latestValues)&&u.updateSnapshot();const l=J(),d=u.measurePageBox();xt(l,d),vr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ae(this.latestValues)&&vr(a,this.latestValues),a}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!==it.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=it.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),Ge(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=J(),this.targetWithTransforms=J()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),jd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Go(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),Ge(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||vs(this.parent.latestValues)||Ho(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===it.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;zu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=J());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gr(this.prevProjectionDelta.x,this.projectionDelta.x),gr(this.prevProjectionDelta.y,this.projectionDelta.y)),He(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ar(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ar(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ce(),this.projectionDelta=Ce(),this.projectionDeltaWithTransform=Ce()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Ce();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=J(),g=c?c.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,A=this.getStack(),x=!A||A.members.length<=1,w=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(xh));this.animationProgress=0;let T;this.mixTargetDelta=V=>{const k=V/1e3;Mr(d.x,r.x,k),Mr(d.y,r.y,k),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ge(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),yh(this.relativeTarget,this.relativeTargetOrigin,f,k),T&&nh(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=J()),xt(T,this.relativeTarget)),v&&(this.animationValues=l,Yd(l,u,this.latestValues,k,w,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Xt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=X.update(()=>{Sn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Me(0)),this.currentAnimation=Kd(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},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(rh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&xa(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||J();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),He(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new sh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&ts("z",r,u,this.animationValues);for(let l=0;l<Qn.length;l++)ts(`rotate${Qn[l]}`,r,u,this.animationValues),ts(`skew${Qn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=wn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=wn(a?.pointerEvents)||""),this.hasProjected&&!ae(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=ih(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const y in tn){if(l[y]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:x}=tn[y],w=d==="none"?l[y]:v(l[y],u);if(A){const T=A.length;for(let V=0;V<T;V++)r[A[V]]=w}else x?this.options.visualElement.renderState.vars[y]=w:r[y]=w}this.options.layoutId&&(r.pointerEvents=u===this?wn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Cr),this.root.sharedNodes.clear()}}}function ah(t){t.updateLayout()}function ch(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):xa(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Ce();He(r,n,e.layoutBox);const a=Ce();o?He(a,t.applyTransform(s,!0),e.measuredBox):He(a,n,e.layoutBox);const c=!ma(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=J();Ge(g,e.layoutBox,d.layoutBox);const y=J();Ge(y,n,f.layoutBox),pa(g,y)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function lh(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function uh(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function dh(t){t.clearSnapshot()}function Cr(t){t.clearMeasurements()}function Pr(t){t.isLayoutDirty=!1}function hh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function jr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function fh(t){t.resolveTargetDelta()}function mh(t){t.calcProjection()}function ph(t){t.resetSkewAndRotation()}function gh(t){t.removeLeadSnapshot()}function Mr(t,e,n){t.translate=Y(e.translate,0,n),t.scale=Y(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Er(t,e,n,s){t.min=Y(e.min,n.min,s),t.max=Y(e.max,n.max,s)}function yh(t,e,n,s){Er(t.x,e.x,n.x,s),Er(t.y,e.y,n.y,s)}function xh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const vh={duration:.45,ease:[.4,0,.1,1]},kr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dr=kr("applewebkit/")&&!kr("chrome/")?Math.round:wt;function Vr(t){t.min=Dr(t.min),t.max=Dr(t.max)}function bh(t){Vr(t.x),Vr(t.y)}function xa(t,e,n){return t==="position"||t==="preserve-aspect"&&!Pd(Sr(e),Sr(n),.2)}function wh(t){return t!==t.root&&t.scroll?.wasRoot}const Th=ya({attachResizeListener:(t,e)=>en(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),es={current:void 0},va=ya({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!es.current){const t=new Th({});t.mount(window),t.setOptions({layoutScroll:!0}),es.current=t}return es.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Sh={pan:{Feature:zd},drag:{Feature:$d,ProjectionNode:va,MeasureLayout:da}};function Nr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&X.postRender(()=>o(e,on(e)))}class Ah extends Yt{mount(){const{current:e}=this.node;e&&(this.unmount=Hl(e,(n,s)=>(Nr(this.node,s,"Start"),i=>Nr(this.node,i,"End"))))}unmount(){}}class Ch extends Yt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=nn(en(this.node.current,"focus",()=>this.onFocus()),en(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Rr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&X.postRender(()=>o(e,on(e)))}class Ph extends Yt{mount(){const{current:e}=this.node;e&&(this.unmount=Yl(e,(n,s)=>(Rr(this.node,s,"Start"),(i,{success:o})=>Rr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ps=new WeakMap,ns=new WeakMap,jh=t=>{const e=Ps.get(t.target);e&&e(t)},Mh=t=>{t.forEach(jh)};function Eh({root:t,...e}){const n=t||document;ns.has(n)||ns.set(n,{});const s=ns.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Mh,{root:t,...e})),s[i]}function kh(t,e,n){const s=Eh(e);return Ps.set(t,n),s.observe(t),()=>{Ps.delete(t),s.unobserve(t)}}const Dh={some:0,all:1};class Vh extends Yt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Dh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return kh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Nh(e,n))&&this.startObserver()}unmount(){}}function Nh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ba={inView:{Feature:Vh},tap:{Feature:Ph},focus:{Feature:Ch},hover:{Feature:Ah}},Rh={layout:{ProjectionNode:va,MeasureLayout:da}},Ih={...ra,...ba,...Sh,...Rh},Lh=Fu(Ih,Qo),Oh={renderer:Qo,...ra,...ba};function wa(t,e){return Tn(t,e)}const xn=wa("div"),Fh=wa("p"),Dt=Symbol.for("@arcteninc/core:originalName");function Bh(t,e){return t[Dt]=e,t}function $h(t,e,n,s){if(typeof t!="function")return null;const i=t[Dt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[Dt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[Dt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[Dt]=r.name,{fn:t,meta:r};return null}function Ta(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
|
|
9
|
+
`),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(nu,{isPresent:e,childRef:o,sizeRef:r,children:Ct.cloneElement(t,{ref:c})})}const iu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=ks(ru),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),Ct.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(su,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Dn.Provider,{value:f,children:t})};function ru(){return new Map}function Vo(t=!0){const e=m.useContext(Dn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const gn=t=>t.key||"";function Ui(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const ou=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Vo(r),d=m.useMemo(()=>Ui(t),[t]),f=r&&!u?[]:d.map(gn),g=m.useRef(!0),y=m.useRef(d),v=ks(()=>new Map),[A,x]=m.useState(d),[w,T]=m.useState(d);$r(()=>{g.current=!1,y.current=d;for(let C=0;C<w.length;C++){const L=gn(w[C]);f.includes(L)?v.delete(L):v.get(L)!==!0&&v.set(L,!1)}},[w,f.length,f.join("-")]);const V=[];if(d!==A){let C=[...d];for(let L=0;L<w.length;L++){const M=w[L],F=gn(M);f.includes(F)||(C.splice(L,0,M),V.push(M))}return o==="wait"&&V.length&&(C=V),T(Ui(C)),x(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:k}=m.useContext(Es);return h.jsx(h.Fragment,{children:w.map(C=>{const L=gn(C),M=r&&!u?!1:d===w||f.includes(L),F=()=>{if(v.has(L))v.set(L,!0);else return;let z=!0;v.forEach(W=>{W||(z=!1)}),z&&(k?.(),T(y.current),r&&l?.(),s&&s())};return h.jsx(iu,{isPresent:M,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:M?void 0:F,anchorX:a,children:C},L)})})},ti=m.createContext({strict:!1}),_i={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"]},Ee={};for(const t in _i)Ee[t]={isEnabled:e=>_i[t].some(n=>!!e[n])};function xs(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function au({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Gn(e)),i=m.useRef(void 0);if(!Gn(e)){const{renderer:o,...r}=e;i.current=o,xs(r)}return m.useEffect(()=>{Gn(e)&&e().then(({renderer:o,...r})=>{xs(r),i.current=o,s(!0)})},[]),h.jsx(ti.Provider,{value:{renderer:i.current,strict:n},children:t})}function Gn(t){return typeof t=="function"}const cu=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 En(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cu.has(t)}let No=t=>!En(t);function lu(t){typeof t=="function"&&(No=e=>e.startsWith("on")?!En(e):t(e))}try{lu(require("@emotion/is-prop-valid").default)}catch{}function uu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(No(i)||n===!0&&En(i)||!e&&!En(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Vn=m.createContext({});function Nn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qe(t){return typeof t=="string"||Array.isArray(t)}const ei=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ni=["initial",...ei];function Rn(t){return Nn(t.animate)||ni.some(e=>Qe(t[e]))}function Ro(t){return!!(Rn(t)||t.variants)}function du(t,e){if(Rn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Qe(n)?n:void 0,animate:Qe(s)?s:void 0}}return t.inherit!==!1?e:{}}function hu(t){const{initial:e,animate:n}=du(t,m.useContext(Vn));return m.useMemo(()=>({initial:e,animate:n}),[Wi(e),Wi(n)])}function Wi(t){return Array.isArray(t)?t.join(" "):t}const tn={};function fu(t){for(const e in t)tn[e]=t[e],Bs(e)&&(tn[e].isCSSVariable=!0)}function Io(t,{layout:e,layoutId:n}){return Ne.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!tn[t]||t==="opacity")}const mu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pu=Ve.length;function gu(t,e,n){let s="",i=!0;for(let o=0;o<pu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Ys[r]);if(!c){i=!1;const l=mu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function si(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Ne.has(c)){r=!0;continue}else if(Bs(c)){i[c]=u;continue}else{const l=Po(u,Ys[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=gu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ii=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Lo(t,e,n){for(const s in e)!at(e[s])&&!Io(s,n)&&(t[s]=e[s])}function yu({transformTemplate:t},e){return m.useMemo(()=>{const n=ii();return si(n,e,t),Object.assign({},n.vars,n.style)},[e])}function xu(t,e){const n=t.style||{},s={};return Lo(s,n,t),Object.assign(s,yu(t,e)),s}function vu(t,e){const n={},s=xu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const bu={offset:"stroke-dashoffset",array:"stroke-dasharray"},wu={offset:"strokeDashoffset",array:"strokeDasharray"};function Tu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?bu:wu;t[o.offset]=I.transform(-s);const r=I.transform(e),a=I.transform(n);t[o.array]=`${r} ${a}`}function Oo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(si(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Tu(d,i,o,r,!1)}const Fo=()=>({...ii(),attrs:{}}),Bo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Su(t,e,n,s){const i=m.useMemo(()=>{const o=Fo();return Oo(o,e,Bo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Lo(o,t.style,t),i.style={...o,...i.style}}return i}const Au=["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 ri(t){return typeof t!="string"||t.includes("-")?!1:!!(Au.indexOf(t)>-1||/[A-Z]/u.test(t))}function Cu(t,e,n,{latestValues:s},i,o=!1){const a=(ri(t)?Su:vu)(e,s,i,t),c=uu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>at(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Ki(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function oi(t,e,n,s){if(typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function wn(t){return at(t)?t.get():t}function Pu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:ju(n,s,i,t),renderState:e()}}function ju(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=wn(o[f]);let{initial:r,animate:a}=t;const c=Rn(t),u=Ro(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Nn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=oi(t,f[g]);if(y){const{transitionEnd:v,transition:A,...x}=y;for(const w in x){let T=x[w];if(Array.isArray(T)){const V=l?T.length-1:0;T=T[V]}T!==null&&(i[w]=T)}for(const w in v)i[w]=v[w]}}}return i}const $o=t=>(e,n)=>{const s=m.useContext(Vn),i=m.useContext(Dn),o=()=>Pu(t,e,s,i);return n?o():ks(o)};function ai(t,e,n){const{style:s}=t,i={};for(const o in s)(at(s[o])||e.style&&at(e.style[o])||Io(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Mu=$o({scrapeMotionValuesFromProps:ai,createRenderState:ii});function zo(t,e,n){const s=ai(t,e,n);for(const i in t)if(at(t[i])||at(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Eu=$o({scrapeMotionValuesFromProps:zo,createRenderState:Fo}),ku=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Du(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ci=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Vu="framerAppearId",Uo="data-"+ci(Vu),_o=m.createContext({});function Nu(t,e,n,s,i){const{visualElement:o}=m.useContext(Vn),r=m.useContext(ti),a=m.useContext(Dn),c=m.useContext(Qs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(_o);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Ru(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[Uo],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return $r(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),y.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!y.current&&l.animationState&&l.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),l.enteringChildren=void 0)}),l}function Ru(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Wo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Wo(t){if(t)return t.options.allowProjection!==!1?t.projection:Wo(t.parent)}function Tn(t,{forwardMotionProps:e=!1}={},n,s){n&&xs(n);const i=ri(t)?Eu:Mu;function o(a,c){let u;const l={...m.useContext(Qs),...a,layoutId:Iu(a)},{isStatic:d}=l,f=hu(a),g=i(a,d);if(!d&&Ds){Lu(l,n);const y=Ou(l);u=y.MeasureLayout,f.visualElement=Nu(t,g,l,s,y.ProjectionNode)}return h.jsxs(Vn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Cu(t,a,Du(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ku]=t,r}function Iu({layoutId:t}){const e=m.useContext(Es).id;return e&&t!==void 0?e+"-"+t:t}function Lu(t,e){const n=m.useContext(ti).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ft(!1,s,"lazy-strict-mode")}}function Ou(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Fu(t,e){if(typeof Proxy>"u")return Tn;const n=new Map,s=(o,r)=>Tn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Ls(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Tn(r,void 0,t,e)),n.get(r))})}function Ko({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Bu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function $u(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function qn(t){return t===void 0||t===1}function vs({scale:t,scaleX:e,scaleY:n}){return!qn(t)||!qn(e)||!qn(n)}function ae(t){return vs(t)||Ho(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ho(t){return Hi(t.x)||Hi(t.y)}function Hi(t){return t&&t!=="0%"}function kn(t,e,n){const s=t-n,i=e*s;return n+i}function Xi(t,e,n,s,i){return i!==void 0&&(t=kn(t,i,s)),kn(t,n,s)+e}function bs(t,e=0,n=1,s,i){t.min=Xi(t.min,e,n,s,i),t.max=Xi(t.max,e,n,s,i)}function Xo(t,{x:e,y:n}){bs(t.x,e.translate,e.scale,e.originPoint),bs(t.y,n.translate,n.scale,n.originPoint)}const Gi=.999999999999,qi=1.0000000000001;function zu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],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&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Xo(t,r)),s&&ae(o.latestValues)&&Ae(t,o.latestValues))}e.x<qi&&e.x>Gi&&(e.x=1),e.y<qi&&e.y>Gi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function Yi(t,e,n,s,i=.5){const o=Y(t.min,t.max,i);bs(t,e,n,o,s)}function Ae(t,e){Yi(t.x,e.x,e.scaleX,e.scale,e.originX),Yi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Go(t,e){return Ko($u(t.getBoundingClientRect(),e))}function Uu(t,e,n){const s=Go(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Ji=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ce=()=>({x:Ji(),y:Ji()}),Zi=()=>({min:0,max:0}),J=()=>({x:Zi(),y:Zi()}),ws={current:null},qo={current:!1};function _u(){if(qo.current=!0,!!Ds)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ws.current=t.matches;t.addEventListener("change",e),e()}else ws.current=!1}const Wu=new WeakMap;function Ku(t,e,n){for(const s in e){const i=e[s],o=n[s];if(at(i))t.addValue(s,i);else if(at(o))t.addValue(s,Me(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,Me(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Qi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Hu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Gs,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 f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,G.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Rn(n),this.isVariantNode=Ro(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&at(g)&&g.set(c[f])}}mount(e){this.current=e,Wu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),qo.current||_u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ws.current,process.env.NODE_ENV!=="production"&&Ls(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Gt(this.notifyUpdate),Gt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Ne.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&G.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];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):J()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Qi.length;s++){const i=Qi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Ku(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]: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(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=Me(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(zr(s)||_r(s))?s=parseFloat(s):!Ql(s)&&qt.test(n)&&(s=Co(e,n)),this.setBaseTarget(e,at(s)?s.get():s)),at(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=oi(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!at(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Js.render(this.render)}}class Yo extends Hu{constructor(){super(...arguments),this.KeyframeResolver=zl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;at(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Jo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Xu(t){return window.getComputedStyle(t)}class Gu extends Yo{constructor(){super(...arguments),this.type="html",this.renderInstance=Jo}readValueFromInstance(e,n){if(Ne.has(n))return this.projection?.isProjecting?ds(n):rl(e,n);{const s=Xu(e),i=(Bs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Go(e,n)}build(e,n,s){si(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ai(e,n,s)}}const Zo=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 qu(t,e,n,s){Jo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Zo.has(i)?i:ci(i),e.attrs[i])}class Yu extends Yo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=J}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Ne.has(n)){const s=Ao(n);return s&&s.default||0}return n=Zo.has(n)?n:ci(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return zo(e,n,s)}build(e,n,s){Oo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){qu(e,n,s,i)}mount(e){this.isSVGTag=Bo(e.tagName),super.mount(e)}}const Qo=(t,e)=>ri(t)?new Yu(e):new Gu(e,{allowProjection:t!==m.Fragment});function je(t,e,n){const s=t.getProps();return oi(s,e,n!==void 0?n:s.custom,t)}const Ts=t=>Array.isArray(t);function Ju(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Me(n))}function Zu(t){return Ts(t)?t[t.length-1]||0:t}function Qu(t,e){const n=je(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Zu(o[r]);Ju(t,r,a)}}function td(t){return!!(at(t)&&t.add)}function Ss(t,e){const n=t.getValue("willChange");if(td(n))return n.add(e);if(!n&&Bt.WillChange){const s=new Bt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function ta(t){return t.props[Uo]}const ed=t=>t!==null;function nd(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ed),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const sd={type:"spring",stiffness:500,damping:25,restSpeed:10},id=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),rd={type:"keyframes",duration:.8},od={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ad=(t,{keyframes:e})=>e.length>2?rd:Ne.has(t)?t.startsWith("scale")?id(e[1]):sd:od;function cd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const li=(t,e,n,s={},i,o)=>r=>{const a=qs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Pt(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};cd(a)||Object.assign(l,ad(t,l)),l.duration&&(l.duration=Pt(l.duration)),l.repeatDelay&&(l.repeatDelay=Pt(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(gs(l),l.delay===0&&(d=!0)),(Bt.instantAnimations||Bt.skipAnimations)&&(d=!0,gs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=nd(l.keyframes,a);if(f!==void 0){G.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Xs(l):new Ml(l)};function ld({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ea(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ld(u,l))continue;const g={delay:n,...qs(o||{},l)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=ta(t);if(x){const w=window.MotionHandoffAnimation(x,l,G);w!==null&&(g.startTime=w,v=!0)}}Ss(t,l),d.start(li(l,d,f,t.shouldReduceMotion&&wo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{G.update(()=>{r&&Qu(t,r)})}),c}function na(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function As(t,e,n={}){const s=je(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ea(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ud(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function ud(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(As(c,e,{...r,delay:n+(typeof s=="function"?0:s)+na(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function dd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>As(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=As(t,e,n);else{const i=typeof e=="function"?je(t,e,n.custom):e;s=Promise.all(ea(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function sa(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const hd=ni.length;function ia(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?ia(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<hd;n++){const s=ni[n],i=t.props[s];(Qe(i)||i===!1)&&(e[s]=i)}return e}const fd=[...ei].reverse(),md=ei.length;function pd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>dd(t,n,s)))}function gd(t){let e=pd(t),n=tr(),s=!0;const i=c=>(u,l)=>{const d=je(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=ia(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let A=0;A<md;A++){const x=fd[A],w=n[x],T=u[x]!==void 0?u[x]:l[x],V=Qe(T),k=x===c?w.isActive:null;k===!1&&(y=A);let C=T===l[x]&&T!==u[x]&&V;if(C&&s&&t.manuallyAnimateOnMount&&(C=!1),w.protectedKeys={...g},!w.isActive&&k===null||!T&&!w.prevProp||Nn(T)||typeof T=="boolean")continue;const L=yd(w.prevProp,T);let M=L||x===c&&w.isActive&&!C&&V||A>y&&V,F=!1;const z=Array.isArray(T)?T:[T];let W=z.reduce(i(x),{});k===!1&&(W={});const{prevResolvedValues:B={}}=w,jt={...B,...W},Tt=U=>{M=!0,f.has(U)&&(F=!0,f.delete(U)),w.needsAnimating[U]=!0;const ct=t.getValue(U);ct&&(ct.liveStyle=!1)};for(const U in jt){const ct=W[U],lt=B[U];if(g.hasOwnProperty(U))continue;let ut=!1;Ts(ct)&&Ts(lt)?ut=!sa(ct,lt):ut=ct!==lt,ut?ct!=null?Tt(U):f.add(U):ct!==void 0&&f.has(U)?Tt(U):w.protectedKeys[U]=!0}w.prevProp=T,w.prevResolvedValues=W,w.isActive&&(g={...g,...W}),s&&t.blockInitialAnimation&&(M=!1);const rt=C&&L;M&&(!rt||F)&&d.push(...z.map(U=>{const ct={type:x};if(typeof U=="string"&&s&&!rt&&t.manuallyAnimateOnMount&&t.parent){const{parent:lt}=t,ut=je(lt,U);if(lt.enteringChildren&&ut){const{delayChildren:dt}=ut.transition||{};ct.delay=na(lt.enteringChildren,t,dt)}}return{animation:U,options:ct}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const x=je(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(A.transition=x.transition)}f.forEach(x=>{const w=t.getBaseTarget(x),T=t.getValue(x);T&&(T.liveStyle=!0),A[x]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tr()}}}function yd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!sa(e,t):!1}function re(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tr(){return{animate:re(!0),whileInView:re(),whileHover:re(),whileTap:re(),whileDrag:re(),whileFocus:re(),exit:re()}}class Yt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class xd extends Yt{constructor(e){super(e),e.animationState||(e.animationState=gd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Nn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let vd=0;class bd extends Yt{constructor(){super(...arguments),this.id=vd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const ra={animation:{Feature:xd},exit:{Feature:bd}};function en(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function on(t){return{point:{x:t.pageX,y:t.pageY}}}const wd=t=>e=>Zs(e)&&t(e,on(e));function Ke(t,e,n,s){return en(t,e,wd(n),s)}const oa=1e-4,Td=1-oa,Sd=1+oa,aa=.01,Ad=0-aa,Cd=0+aa;function ft(t){return t.max-t.min}function Pd(t,e,n){return Math.abs(t-e)<=n}function er(t,e,n,s=.5){t.origin=s,t.originPoint=Y(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=Y(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Td&&t.scale<=Sd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ad&&t.translate<=Cd||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,s){er(t.x,e.x,n.x,s?s.originX:void 0),er(t.y,e.y,n.y,s?s.originY:void 0)}function nr(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function jd(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function sr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function Xe(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const ca=({current:t})=>t?t.ownerDocument.defaultView:null,ir=(t,e)=>Math.abs(t-e);function Md(t,e){const n=ir(t.x,e.x),s=ir(t.y,e.y);return Math.sqrt(n**2+s**2)}class la{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=Md(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:A}=it;this.history.push({...v,timestamp:A});const{onStart:x,onMove:w}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Yn(g,this.transformPagePoint),G.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Jn(f.type==="pointercancel"?this.lastMoveEventInfo:Yn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Zs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=on(e),c=Yn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=it;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Jn(c,this.history)),this.removeListeners=nn(Ke(this.contextWindow,"pointermove",this.handlePointerMove),Ke(this.contextWindow,"pointerup",this.handlePointerUp),Ke(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Gt(this.updatePoint)}}function Yn(t,e){return e?{point:e(t.point)}:t}function rr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Jn({point:t},e){return{point:t,delta:rr(t,ua(e)),offset:rr(t,Ed(e)),velocity:kd(e,.1)}}function Ed(t){return t[0]}function ua(t){return t[t.length-1]}function kd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ua(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Pt(e)));)n--;if(!s)return{x:0,y:0};const o=bt(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 Dd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?Y(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?Y(n,t,s.max):Math.min(t,n)),t}function or(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Vd(t,{top:e,left:n,bottom:s,right:i}){return{x:or(t.x,n,i),y:or(t.y,e,s)}}function ar(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function Nd(t,e){return{x:ar(t.x,e.x),y:ar(t.y,e.y)}}function Rd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ye(e.min,e.max-s,t.min):s>i&&(n=Ye(t.min,t.max-i,e.min)),Ot(0,1,n)}function Id(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Cs=.35;function Ld(t=Cs){return t===!1?t=0:t===!0&&(t=Cs),{x:cr(t,"left","right"),y:cr(t,"top","bottom")}}function cr(t,e,n){return{min:lr(t,e),max:lr(t,n)}}function lr(t,e){return typeof t=="number"?t:t[e]||0}const Od=new WeakMap;class Fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=J(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(on(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Kl(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(x=>{let w=this.getAxisMotionValue(x).get()||0;if(Vt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const V=T.layout.layoutBox[x];V&&(w=ft(V)*(parseFloat(w)/100))}}this.originPoint[x]=w}),v&&G.postRender(()=>v(d,f)),Ss(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=Bd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new la(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:ca(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&G.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.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(e,n,s){const{drag:i}=this.getProps();if(!s||!yn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Dd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Vd(s.layoutBox,e):this.constraints=!1,this.elastic=Ld(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Id(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ft(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Uu(s,i.root,this.visualElement.getTransformPagePoint());let r=Nd(i.layout.layoutBox,o);if(n){const a=n(Bu(r));this.hasMutatedConstraints=!!a,a&&(r=Ko(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!yn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Ss(this.visualElement,e),s.start(li(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!yn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-Y(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Rd({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(),vt(r=>{if(!yn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(Y(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Od.set(this.visualElement,this);const e=this.visualElement.current,n=Ke(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(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()),G.read(s);const r=en(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Cs,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Bd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $d extends Yt{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ur=t=>(e,n)=>{t&&G.postRender(()=>t(e,n))};class zd extends Yt{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new la(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ca(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:ur(e),onStart:ur(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&G.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ke(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Sn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ue={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(I.test(t))t=parseFloat(t);else return t;const n=dr(t,e.target.x),s=dr(t,e.target.y);return`${n}% ${s}%`}},Ud={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=qt.parse(t);if(i.length>5)return s;const o=qt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=Y(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Zn=!1;class _d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;fu(Wd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Zn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Sn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Zn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||G.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Zn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function da(t){const[e,n]=Vo(),s=m.useContext(Es);return h.jsx(_d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(_o),isPresent:e,safeToRemove:n})}const Wd={borderRadius:{...Ue,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ue,borderTopRightRadius:Ue,borderBottomLeftRadius:Ue,borderBottomRightRadius:Ue,boxShadow:Ud};function Kd(t,e,n){const s=at(t)?t:Me(t);return s.start(li("",s,e,n)),s.animation}const Hd=(t,e)=>t.depth-e.depth;class Xd{constructor(){this.children=[],this.isDirty=!1}add(e){Vs(this.children,e),this.isDirty=!0}remove(e){Ns(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Hd),this.isDirty=!1,this.children.forEach(e)}}function Gd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Gt(s),t(o-e))};return G.setup(s,!0),()=>Gt(s)}const ha=["TopLeft","TopRight","BottomLeft","BottomRight"],qd=ha.length,hr=t=>typeof t=="string"?parseFloat(t):t,fr=t=>typeof t=="number"||I.test(t);function Yd(t,e,n,s,i,o){i?(t.opacity=Y(0,n.opacity??1,Jd(s)),t.opacityExit=Y(e.opacity??1,0,Zd(s))):o&&(t.opacity=Y(e.opacity??1,n.opacity??1,s));for(let r=0;r<qd;r++){const a=`border${ha[r]}Radius`;let c=mr(e,a),u=mr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||fr(c)===fr(u)?(t[a]=Math.max(Y(hr(c),hr(u),s),0),(Vt.test(u)||Vt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=Y(e.rotate||0,n.rotate||0,s))}function mr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Jd=fa(0,.5,Jr),Zd=fa(.5,.95,wt);function fa(t,e,n){return s=>s<t?0:s>e?1:n(Ye(t,e,s))}function pr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){pr(t.x,e.x),pr(t.y,e.y)}function gr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yr(t,e,n,s,i){return t-=e,t=kn(t,1/n,s),i!==void 0&&(t=kn(t,1/i,s)),t}function Qd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Vt.test(e)&&(e=parseFloat(e),e=Y(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=Y(o.min,o.max,s);t===o&&(a-=e),t.min=yr(t.min,e,n,a,i),t.max=yr(t.max,e,n,a,i)}function xr(t,e,[n,s,i],o,r){Qd(t,e[n],e[s],e[i],e.scale,o,r)}const th=["x","scaleX","originX"],eh=["y","scaleY","originY"];function vr(t,e,n,s){xr(t.x,e,th,n?n.x:void 0,s?s.x:void 0),xr(t.y,e,eh,n?n.y:void 0,s?s.y:void 0)}function br(t){return t.translate===0&&t.scale===1}function ma(t){return br(t.x)&&br(t.y)}function wr(t,e){return t.min===e.min&&t.max===e.max}function nh(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function pa(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t){return ft(t.x)/ft(t.y)}function Ar(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class sh{constructor(){this.members=[]}add(e){Vs(this.members,e),e.scheduleRender()}remove(e){if(Ns(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===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(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function ih(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Qn=["","X","Y","Z"],rh=1e3;let oh=0;function ts(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ga(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=ta(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",G,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ga(s)}function ya({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=oh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.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(lh),this.nodes.forEach(fh),this.nodes.forEach(mh),this.nodes.forEach(uh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Xd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Is),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Do(r)&&!Jl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;G.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Gd(f,250),Sn.hasAnimatedSinceResize&&(Sn.hasAnimatedSinceResize=!1,this.nodes.forEach(jr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||vh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),x=!this.targetLayout||!pa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...qs(y,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,w)}else d||jr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}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(),Gt(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(ph),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&&ga(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Cr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Pr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(hh),this.nodes.forEach(ah),this.nodes.forEach(ch)):this.nodes.forEach(Pr),this.clearAllSnapshots();const a=mt.now();it.delta=Ot(0,1e3/60,a-it.timestamp),it.timestamp=a,it.isProcessing=!0,Un.update.process(it),Un.preRender.process(it),Un.render.process(it),it.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(dh),this.sharedNodes.forEach(gh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,G.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){G.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(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=J(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&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,a=this.projectionDelta&&!ma(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||ae(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),bh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return J();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(wh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=J();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=J();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ae(l.latestValues)&&Ae(c,l.latestValues)}return ae(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=J();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ae(u.latestValues))continue;vs(u.latestValues)&&u.updateSnapshot();const l=J(),d=u.measurePageBox();xt(l,d),vr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ae(this.latestValues)&&vr(a,this.latestValues),a}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!==it.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=it.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),Xe(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=J(),this.targetWithTransforms=J()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),jd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Xo(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),Xe(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||vs(this.parent.latestValues)||Ho(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===it.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;zu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=J());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gr(this.prevProjectionDelta.x,this.projectionDelta.x),gr(this.prevProjectionDelta.y,this.projectionDelta.y)),He(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ar(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ar(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ce(),this.projectionDelta=Ce(),this.projectionDeltaWithTransform=Ce()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Ce();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=J(),g=c?c.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,A=this.getStack(),x=!A||A.members.length<=1,w=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(xh));this.animationProgress=0;let T;this.mixTargetDelta=V=>{const k=V/1e3;Mr(d.x,r.x,k),Mr(d.y,r.y,k),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Xe(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),yh(this.relativeTarget,this.relativeTargetOrigin,f,k),T&&nh(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=J()),xt(T,this.relativeTarget)),v&&(this.animationValues=l,Yd(l,u,this.latestValues,k,w,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Gt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=G.update(()=>{Sn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Me(0)),this.currentAnimation=Kd(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},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(rh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&xa(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||J();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),He(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new sh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&ts("z",r,u,this.animationValues);for(let l=0;l<Qn.length;l++)ts(`rotate${Qn[l]}`,r,u,this.animationValues),ts(`skew${Qn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=wn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=wn(a?.pointerEvents)||""),this.hasProjected&&!ae(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=ih(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const y in tn){if(l[y]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:x}=tn[y],w=d==="none"?l[y]:v(l[y],u);if(A){const T=A.length;for(let V=0;V<T;V++)r[A[V]]=w}else x?this.options.visualElement.renderState.vars[y]=w:r[y]=w}this.options.layoutId&&(r.pointerEvents=u===this?wn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Cr),this.root.sharedNodes.clear()}}}function ah(t){t.updateLayout()}function ch(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):xa(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Ce();He(r,n,e.layoutBox);const a=Ce();o?He(a,t.applyTransform(s,!0),e.measuredBox):He(a,n,e.layoutBox);const c=!ma(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=J();Xe(g,e.layoutBox,d.layoutBox);const y=J();Xe(y,n,f.layoutBox),pa(g,y)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function lh(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function uh(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function dh(t){t.clearSnapshot()}function Cr(t){t.clearMeasurements()}function Pr(t){t.isLayoutDirty=!1}function hh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function jr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function fh(t){t.resolveTargetDelta()}function mh(t){t.calcProjection()}function ph(t){t.resetSkewAndRotation()}function gh(t){t.removeLeadSnapshot()}function Mr(t,e,n){t.translate=Y(e.translate,0,n),t.scale=Y(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Er(t,e,n,s){t.min=Y(e.min,n.min,s),t.max=Y(e.max,n.max,s)}function yh(t,e,n,s){Er(t.x,e.x,n.x,s),Er(t.y,e.y,n.y,s)}function xh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const vh={duration:.45,ease:[.4,0,.1,1]},kr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dr=kr("applewebkit/")&&!kr("chrome/")?Math.round:wt;function Vr(t){t.min=Dr(t.min),t.max=Dr(t.max)}function bh(t){Vr(t.x),Vr(t.y)}function xa(t,e,n){return t==="position"||t==="preserve-aspect"&&!Pd(Sr(e),Sr(n),.2)}function wh(t){return t!==t.root&&t.scroll?.wasRoot}const Th=ya({attachResizeListener:(t,e)=>en(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),es={current:void 0},va=ya({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!es.current){const t=new Th({});t.mount(window),t.setOptions({layoutScroll:!0}),es.current=t}return es.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Sh={pan:{Feature:zd},drag:{Feature:$d,ProjectionNode:va,MeasureLayout:da}};function Nr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&G.postRender(()=>o(e,on(e)))}class Ah extends Yt{mount(){const{current:e}=this.node;e&&(this.unmount=Hl(e,(n,s)=>(Nr(this.node,s,"Start"),i=>Nr(this.node,i,"End"))))}unmount(){}}class Ch extends Yt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=nn(en(this.node.current,"focus",()=>this.onFocus()),en(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Rr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&G.postRender(()=>o(e,on(e)))}class Ph extends Yt{mount(){const{current:e}=this.node;e&&(this.unmount=Yl(e,(n,s)=>(Rr(this.node,s,"Start"),(i,{success:o})=>Rr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ps=new WeakMap,ns=new WeakMap,jh=t=>{const e=Ps.get(t.target);e&&e(t)},Mh=t=>{t.forEach(jh)};function Eh({root:t,...e}){const n=t||document;ns.has(n)||ns.set(n,{});const s=ns.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Mh,{root:t,...e})),s[i]}function kh(t,e,n){const s=Eh(e);return Ps.set(t,n),s.observe(t),()=>{Ps.delete(t),s.unobserve(t)}}const Dh={some:0,all:1};class Vh extends Yt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Dh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return kh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Nh(e,n))&&this.startObserver()}unmount(){}}function Nh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ba={inView:{Feature:Vh},tap:{Feature:Ph},focus:{Feature:Ch},hover:{Feature:Ah}},Rh={layout:{ProjectionNode:va,MeasureLayout:da}},Ih={...ra,...ba,...Sh,...Rh},Lh=Fu(Ih,Qo),Oh={renderer:Qo,...ra,...ba};function wa(t,e){return Tn(t,e)}const xn=wa("div"),Fh=wa("p"),Dt=Symbol.for("@arcteninc/core:originalName");function Bh(t,e){return t[Dt]=e,t}function $h(t,e,n,s){if(typeof t!="function")return null;const i=t[Dt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[Dt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[Dt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[Dt]=r.name,{fn:t,meta:r};return null}function Ta(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
|
|
10
10
|
|
|
11
11
|
Please:
|
|
12
12
|
1. Run "arcten-extract-types ." before build (add to package.json scripts)
|
|
@@ -16,9 +16,9 @@ Please:
|
|
|
16
16
|
useAgent({ tools: [...], toolMetadata: toolMetadata })
|
|
17
17
|
(Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
|
|
18
18
|
`);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=$h(o,n,i,s);if(!r){const a=o.name,u=o[Dt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
|
|
19
|
-
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function zh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Cn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(et.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Cn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(et.X,{className:"h-3 w-3"})})]})]})})}function Uh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(et.ChevronDown,{className:"h-3 w-3"}):h.jsx(et.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(et.X,{className:"h-3 w-3"}):s?h.jsx(et.Zap,{className:"h-3 w-3"}):h.jsx(et.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function _h({...t}){return h.jsx(Ms.Root,{"data-slot":"collapsible",...t})}function Wh({...t}){return h.jsx(Ms.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Kh({...t}){return h.jsx(Ms.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Hh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ui=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Hh,{className:nt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ui.displayName="Response";const Gh=Object.freeze(Object.defineProperty({__proto__:null,Response:ui},Symbol.toStringTag,{value:"Module"})),Xh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Lh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:nt("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},qh=m.memo(Xh),Sa=m.createContext(null),Yh=()=>{const t=m.useContext(Sa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Jh=1e3,Zh=1e3,Aa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=xi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=xi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Zh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Jh);return()=>clearTimeout(x)}},[e,c,s,u,f]);const A=x=>{u(x)};return h.jsx(Sa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(_h,{className:nt("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Qh=(t,e)=>t||e===0?h.jsx(qh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Ca=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Yh();return h.jsx(Wh,{className:nt("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(et.BrainIcon,{className:"size-4"}),Qh(s,o),h.jsx(et.ChevronDownIcon,{className:nt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(Kh,{className:nt("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ui,{className:"grid gap-2",children:e})}));Aa.displayName="Reasoning";Ca.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Ir(t){const e=t.toLowerCase();return e.includes("youtube")?{icon:"▶",color:"#FF0000"}:e.includes("ted")?{icon:"TED",color:"#E62B1E"}:e.includes("github")?{icon:"GitHub",color:"#181717"}:e.includes("twitter")||e.includes("x.com")?{icon:"𝕏",color:"#000000"}:{icon:t.split(".")[0]||t}}function tf({sources:t,citationNumber:e,className:n}){const s=t.find(r=>r.number===e);if(!s)return null;const i=Ir(s.domain),o=t.map(r=>({...r,iconInfo:Ir(r.domain)}));return h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsxs("button",{className:nt("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:r=>{r.preventDefault(),r.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[h.jsx("span",{className:"leading-none",children:i.icon}),h.jsx("span",{className:"leading-none",children:s.domain})]})}),h.jsx(Ht,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",o.length]}),o.map(r=>h.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:nt("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[h.jsx("span",{className:"text-xs font-medium min-w-[24px] flex items-center justify-center",style:r.iconInfo.color?{color:r.iconInfo.color}:void 0,children:r.iconInfo.icon}),h.jsx("span",{className:"text-xs flex-1 truncate",children:r.domain})]},r.number))]})})]})}function ef({text:t,citations:e,citationMap:n,referencesText:s,ResponseComponent:i,className:o}){const r=m.useRef(null),[a,c]=m.useState([]);m.useEffect(()=>{if(!r.current||e.length===0||n.size===0){n.size===0&&c([]);return}const l=r.current;let d,f=!1;const g=new WeakSet,y=()=>{if(!r.current||f)return;f=!0;const A=r.current,x=/\[(\d+)\]/g,w=document.createTreeWalker(A,NodeFilter.SHOW_TEXT,null),T=[];let V;for(;V=w.nextNode();)if(V.nodeType===Node.TEXT_NODE&&!g.has(V)){const C=V,L=C.textContent||"";let M=C.parentElement,F=!1;for(;M&&M!==A;){if(M.tagName==="A"||M.tagName==="CODE"||M.tagName==="PRE"){F=!0;break}M=M.parentElement}if(!F){const W=Array.from(L.matchAll(x)).filter(B=>{if(!B[1])return!1;const jt=parseInt(B[1],10);return n.has(jt)});W.length>0&&T.push({node:C,matches:W})}}if(T.length===0){f=!1;return}const k=[];T.forEach(({node:C,matches:L})=>{g.add(C);const M=C.textContent||"",F=document.createDocumentFragment();let z=0;L.forEach(W=>{if(!W[1])return;W.index!==void 0&&W.index>z&&F.appendChild(document.createTextNode(M.slice(z,W.index)));const B=document.createElement("span");B.className="inline-flex items-center citation-button-container";const jt=parseInt(W[1],10);B.setAttribute("data-citation",W[1]),F.appendChild(B),k.push({element:B,citationNum:jt}),z=(W.index||0)+W[0].length}),z<M.length&&F.appendChild(document.createTextNode(M.slice(z))),C.parentNode&&C.parentNode.replaceChild(F,C)}),k.length>0&&c(C=>{const L=new Set(C.map(z=>z.element)),M=C.filter(z=>z.element.isConnected),F=k.filter(z=>!L.has(z.element));return[...M,...F]}),f=!1},v=new MutationObserver(()=>{clearTimeout(d),d=setTimeout(y,100)});return v.observe(l,{childList:!0,subtree:!0,characterData:!0}),d=setTimeout(y,200),()=>{v.disconnect(),clearTimeout(d)}},[t,e,n]);const u=s?h.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[h.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-2",children:"References"}),h.jsx("div",{className:"text-xs text-stone-600 dark:text-stone-400 space-y-1",children:Array.from(n.entries()).sort(([l],[d])=>l-d).map(([l,d])=>h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("span",{className:"font-medium",children:["[",l,"]"]}),h.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline break-all",children:d})]},l))})]}):null;return h.jsxs("div",{className:o,children:[h.jsx("div",{ref:r,children:h.jsx(i,{children:t})}),a.filter(({element:l})=>l.isConnected).map(({element:l,citationNum:d},f)=>e.find(y=>y.number===d)?Qa.createPortal(h.jsx(tf,{sources:e.map(y=>({number:y.number,url:y.url,domain:nf(y.url)})),citationNumber:d},`citation-${d}-${l}`),l,`citation-${d}-${f}`):null),u]})}function nf(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function sf(t){let e=t.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=e.match(n),i=new Map,o=[];if(s&&s[1]){const g=s[1],y=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let v;for(;(v=y.exec(g))!==null;)if(v[1]&&v[2]){const A=parseInt(v[1],10),x=v[2].replace(/[.,;:!?]+$/,"");i.set(A,x),o.push({number:A,url:x})}}let r,a=e;s&&s[0]&&(r=s[0],a=e.replace(n,""));const c=[];let u=0;const l=/```[\s\S]*?```|`[^`]+`/g;let d;for(;(d=l.exec(a))!==null;)d.index>u&&c.push({type:"text",content:a.slice(u,d.index),start:u,end:d.index}),c.push({type:"code",content:d[0],start:d.index,end:d.index+d[0].length}),u=d.index+d[0].length;return u<a.length&&c.push({type:"text",content:a.slice(u),start:u,end:a.length}),{processedText:c.map(g=>{if(g.type==="code")return g.content;let y=g.content;return y=y.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(A,x,w)=>{const T=parseInt(x,10);return i.has(T)||(i.set(T,w),o.push({number:T,url:w})),`[${T}]`}),y}).join(""),citations:o.sort((g,y)=>g.number-y.number),citationMap:i,referencesText:r}}function Xe(t){if(typeof t=="string")try{const e=JSON.parse(t);return Xe(e)}catch{return t}if(Array.isArray(t))return t.map(Xe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Xe(s);return e}return t}function ss(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Xe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Xe(t):{}}function rf({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:x,onStateChange:w,allowStateEdits:T=!0}){const[V,k]=m.useState(null),C=m.useRef(null),[L,M]=m.useState(null),[F,z]=m.useState(null),W=m.useRef(null),B=x!==void 0,[jt,Tt]=m.useState({}),rt=m.useRef({});B&&x?rt.current=x:B||(rt.current=jt);const[$t,U]=m.useState(!1),[ct,lt]=m.useState(null),ut=m.useRef(!1),[dt,Nt]=m.useState(u),[yt,he]=m.useState(r),[Jt,Zt]=m.useState(600),[Mt,Rt]=m.useState(!1),[H,fe]=m.useState(!1),[pt,Qt]=m.useState(!1),[gt,me]=m.useState({x:100,y:100}),[St,Re]=m.useState(!1),[te,pe]=m.useState({x:0,y:0}),[In,ge]=m.useState(!1),ee=m.useRef(null),ye=m.useRef(null),[xe,Ie]=m.useState(""),[Le,Ln]=m.useState(null),[On,Fn]=m.useState("Thinking..."),[Oe,P]=m.useState(new Set),[j,N]=m.useState(""),[O,K]=m.useState([]),[_,st]=m.useState(!1),[It,ne]=m.useState([]),[Et,Fe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,an]=m.useState(!1),[cf,cn]=m.useState(!1),[lf,ln]=m.useState([]),di=m.useCallback(async(p,b=3)=>{if(!Et||!C.current)return;const E=async()=>{const D=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Et,updates:p},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const Z=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${Z}`)}};for(let S=0;S<b;S++)try{await E(),lt(null);return}catch(D){if(S===b-1){const Z=D instanceof Error?D:new Error(String(D));throw lt(Z),console.error("Failed to sync state to Convex after retries:",D),Z}await new Promise(Z=>setTimeout(Z,Math.pow(2,S)*100))}},[Et,v,C]),Be=m.useMemo(()=>function(){return rt.current},[]),$e=m.useMemo(()=>async function(b){const E={...rt.current,...b};rt.current=E,B||Tt(E),w&&w(E);try{await di(b)}catch(S){throw S}},[di,w,B]);m.useEffect(()=>{B&&x&&(rt.current=x)},[B,x]);const se=m.useMemo(()=>{const p=[...l,...d,Be];return(!B||T)&&p.push($e),p},[l,d,Be,$e,B,T]),Bn=m.useMemo(()=>Ta(se,f),[se,f]),Lt=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!B||T)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Bn,...p]},[Bn,B,T]),hi=m.useMemo(()=>new Set(Lt.map(p=>p.name)),[Lt]),un=m.useMemo(()=>Lt.filter(p=>p.name==="getState"?!0:p.name==="setState"?!B||T:hi.has(p.name)),[Lt,hi,B,T]),dn=m.useMemo(()=>{const p=new Map,b=new Map(Bn.map(E=>[E.name,E]));return p.set("getState",Be),(!B||T)&&p.set("setState",$e),se.forEach(E=>{if(E===Be||E===$e)return;const S=E[Dt];if(S){const R=b.get(S);if(R){p.set(R.name,E);return}}const D=Lt.find(R=>R.name===E.name);D&&p.set(D.name,E)}),p},[se,Lt,Be,$e,B,T]),ze=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(Lt.map(E=>[E.name,E]));return d.forEach(E=>{const S=E[Dt];if(S&&b.has(S))p.add(S);else{const D=Lt.find(R=>R.name===E.name);D&&p.add(D.name)}}),p},[d,Lt]),fi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Nt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&he(parseInt(b));const E=localStorage.getItem("arcten-sidebar-height");E&&Zt(parseInt(E));const S=localStorage.getItem("arcten-sidebar-detached");S&&fe(JSON.parse(S));const D=localStorage.getItem("arcten-sidebar-position");if(D){const Z=JSON.parse(D),$=50,Q=Math.max($-r,Math.min(Z.x,window.innerWidth-$)),G=Math.max(0,Math.min(Z.y,window.innerHeight-$));me({x:Q,y:G})}const R=localStorage.getItem("arcten-sidebar-minimized");R&&Qt(JSON.parse(R)),ge(!0)}},[]);const zt=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:zt})});if(!b.ok)throw new Error("Failed to fetch token");const E=await b.json();k(E.clientToken),C.current=E.clientToken,z(E.expiresAt),M(null)}catch(b){M(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{W.current&&clearTimeout(W.current)}),[y,zt]),m.useEffect(()=>{if(!F)return;W.current&&clearTimeout(W.current);const p=Math.floor(Date.now()/1e3),b=F-p,S=Math.max(0,b-5);return W.current=setTimeout(async()=>{try{const D=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:zt})});if(!D.ok)throw new Error("Failed to refresh token");const R=await D.json();k(R.clientToken),C.current=R.clientToken,z(R.expiresAt),M(null)}catch(D){console.error("Token refresh failed:",D),M(D instanceof Error?D.message:"Failed to refresh token")}},S*1e3),()=>{W.current&&clearTimeout(W.current)}},[F,y,zt]),m.useEffect(()=>{(async()=>{if(se.length!==0)try{const b=se.map(S=>({name:S.name,code:S.toString()})),E=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(E.ok){const S=await E.json();K(S.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[se]),m.useEffect(()=>{Promise.resolve().then(()=>Gh).then(p=>{Ln(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{N(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const $n=m.useCallback(async()=>{if(!(!zt?.id||!V)){cn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${V}`}})).json();ne(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{cn(!1)}}},[zt?.id,V,v]);m.useEffect(()=>{zt?.id&&V&&$n()},[zt?.id,V,$n]);function ja(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ma(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1);const b=B?x||{}:{};rt.current=b,B||Tt(b),w&&w(b),ut.current=!1}async function Ea(p){if(V)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${V}`}}),ne(It.filter(b=>b._id!==p)),p===Et&&Ma()}catch(b){console.error("Failed to delete conversation:",b)}}async function ka(p){Fe(p.chatId),an(!1),cn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${C.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];fn(S),ln(S)}catch(b){console.error("Failed to load conversation messages:",b);const E=p.messages||[];fn(E),ln(E)}finally{cn(!1)}}const Da=async(p,b={})=>{const E=b.headers?new Headers(b.headers):new Headers;return E.delete("user-agent"),E.delete("User-Agent"),fetch(p,{...b,headers:E})},{messages:Ut,sendMessage:Va,status:kt,error:mi,stop:hn,addToolResult:ie,setMessages:fn}=Lr.useChat({id:Et||void 0,transport:new An.DefaultChatTransport({api:`${v}/chat`,fetch:Da,headers:()=>{const p={};return C.current&&(p.Authorization=`Bearer ${C.current}`),p},body:()=>({tools:un.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:j,state:rt.current})}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=Ut[Ut.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(E=>E.type?.startsWith("tool-")&&E.state==="input-available"&&typeof E.toolCallId=="string"&&E.input!==void 0)||[];for(const E of b){const S=E,D=S.type?.replace("tool-","")||"",R=S.toolCallId;if(ze.has(D)){if(Oe.has(R))continue;P($=>$.has(R)?$:new Set($).add(R)),(async()=>{try{const $=dn.get(D);if(!$){console.warn(`[ArctenAgent] Tool ${D} not found in toolsMap. Available tools:`,Array.from(dn.keys())),ie({toolCallId:R,tool:D,output:`Error: Tool ${D} not found`}),P(ot=>{const _t=new Set(ot);return _t.delete(R),_t});return}const Q=ss(S.input),G=un.find(ot=>ot.name===D);let ht;if(G&&G.jsonSchema?.properties){const _t=Object.keys(G.jsonSchema.properties).map(za=>Q[za]);console.log(`[ArctenAgent] Executing safe tool ${D} with args:`,_t),ht=await $(..._t)}else if(D==="getState")ht=$();else if(D==="setState"){const ot=Q.updates||Q;ht=await $(ot)}else ht=await $(...Object.values(Q));console.log(`[ArctenAgent] Tool ${D} completed, result:`,ht),ie({toolCallId:R,tool:D,output:ht}),P(ot=>{const _t=new Set(ot);return _t.delete(R),_t})}catch($){console.error(`[ArctenAgent] Error executing safe tool ${D}:`,$),ie({toolCallId:R,tool:D,output:`Error: ${$ instanceof Error?$.message:String($)}`}),P(Q=>{const G=new Set(Q);return G.delete(R),G})}})()}}},[Ut,ze,dn,un,ie]),m.useEffect(()=>{if(!Et||!C.current)return;(async()=>{U(!0),lt(null);try{const E=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:Et},format:"json"})});if(!S.ok){if(S.status===404||S.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${S.status}), using empty state`);const G=B?x||{}:{};rt.current=G,B||Tt(G),w&&w(G),ut.current=!0,U(!1);return}const Q=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${S.status} ${Q}`)}const R=(await S.json())?.value||{},Z=!ut.current;let $;Z?($={...B?x||{}:{},...R},ut.current=!0):$=R,rt.current=$,B||Tt($),w&&w($)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const S=b instanceof Error?b:new Error(String(b));if(lt(S),!ut.current){const D=B?x||{}:{};rt.current=D,B||Tt(D),w&&w(D),ut.current=!0}}finally{U(!1)}})()},[Et,v,B,x,w]),m.useEffect(()=>{dt&&ye.current&&ye.current.focus()},[dt,Ut]);function Na(){Nt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ra(){Nt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[dt]),m.useEffect(()=>{ee.current&&ee.current.scrollIntoView({behavior:"smooth"})},[Ut]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(kt==="streaming"||kt==="submitted")&&(b.preventDefault(),hn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[kt,hn]);function Ia(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1)}function pi(p){if(p.preventDefault(),!xe.trim())return;(kt==="streaming"||kt==="submitted")&&hn();const b=fi[Math.floor(Math.random()*fi.length)]||"Thinking...";Fn(b),Va({text:xe}),Ie("")}function La(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(E){if(H){const S=E.clientX-gt.x,D=E.clientY-gt.y;S>=a&&S<=c&&he(S),D>=400&&D<=1e3&&Zt(D)}else{const S=window.innerWidth-E.clientX;S>=a&&S<=c&&he(S)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Jt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Jt,H,gt,a,c]);function Oa(p){p.preventDefault(),Rt(!0)}function Fa(){fe(!0),Qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ba(){fe(!1),Qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function gi(){Qt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function $a(p){H&&(Re(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!H)return;function p(){me(b=>{const S=window.innerWidth-50,D=window.innerHeight-50,R=50-yt,Z=0,$=Math.max(R,Math.min(b.x,S)),Q=Math.max(Z,Math.min(b.y,D));if($!==b.x||Q!==b.y){const G={x:$,y:Q};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(G)),G}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[H,yt]),m.useEffect(()=>{if(!St)return;function p(E){const S=E.clientX-te.x,D=E.clientY-te.y,R=50,Z=window.innerWidth-R,$=window.innerHeight-R,Q=R-yt,G=0,ht=Math.max(Q,Math.min(S,Z)),ot=Math.max(G,Math.min(D,$));me({x:ht,y:ot})}function b(){Re(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,te,gt,yt]),In?L?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",L]})}):V?h.jsx(au,{features:Oh,children:h.jsx(xn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:H?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:H?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
19
|
+
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function zh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Cn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(et.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Cn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(et.X,{className:"h-3 w-3"})})]})]})})}function Uh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(et.ChevronDown,{className:"h-3 w-3"}):h.jsx(et.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(et.X,{className:"h-3 w-3"}):s?h.jsx(et.Zap,{className:"h-3 w-3"}):h.jsx(et.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function _h({...t}){return h.jsx(Ms.Root,{"data-slot":"collapsible",...t})}function Wh({...t}){return h.jsx(Ms.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Kh({...t}){return h.jsx(Ms.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Hh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ui=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Hh,{className:nt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ui.displayName="Response";const Xh=Object.freeze(Object.defineProperty({__proto__:null,Response:ui},Symbol.toStringTag,{value:"Module"})),Gh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Lh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:nt("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},qh=m.memo(Gh),Sa=m.createContext(null),Yh=()=>{const t=m.useContext(Sa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Jh=1e3,Zh=1e3,Aa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=xi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=xi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Zh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Jh);return()=>clearTimeout(x)}},[e,c,s,u,f]);const A=x=>{u(x)};return h.jsx(Sa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(_h,{className:nt("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Qh=(t,e)=>t||e===0?h.jsx(qh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Ca=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Yh();return h.jsx(Wh,{className:nt("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(et.BrainIcon,{className:"size-4"}),Qh(s,o),h.jsx(et.ChevronDownIcon,{className:nt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(Kh,{className:nt("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ui,{className:"grid gap-2",children:e})}));Aa.displayName="Reasoning";Ca.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Ir(t){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(t)}&sz=16`}function tf({sources:t,citationNumber:e,className:n}){const s=t.find(o=>o.number===e);if(!s)return null;const i=Ir(s.domain);return h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsxs("button",{className:nt("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[h.jsx("img",{src:i,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const r=o.target;r.style.display="none"}}),h.jsx("span",{className:"leading-none",children:s.domain})]})}),h.jsx(Ht,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",t.length]}),t.map(o=>h.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:nt("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:r=>r.stopPropagation(),children:[h.jsx("img",{src:Ir(o.domain),alt:"",className:"w-4 h-4 flex-shrink-0",onError:r=>{const a=r.target;a.style.display="none"}}),h.jsx("span",{className:"text-xs flex-1 truncate",children:o.domain})]},o.number))]})})]})}function ef({text:t,citations:e,citationMap:n,referencesText:s,ResponseComponent:i,className:o}){const r=m.useRef(null),[a,c]=m.useState([]);m.useEffect(()=>{if(!r.current||e.length===0||n.size===0){n.size===0&&c([]);return}const l=r.current;let d,f=!1;const g=new WeakSet,y=()=>{if(!r.current||f)return;f=!0;const A=r.current,x=/\[(\d+)\]/g,w=document.createTreeWalker(A,NodeFilter.SHOW_TEXT,null),T=[];let V;for(;V=w.nextNode();)if(V.nodeType===Node.TEXT_NODE&&!g.has(V)){const C=V,L=C.textContent||"";let M=C.parentElement,F=!1;for(;M&&M!==A;){if(M.tagName==="A"||M.tagName==="CODE"||M.tagName==="PRE"){F=!0;break}M=M.parentElement}if(!F){const W=Array.from(L.matchAll(x)).filter(B=>{if(!B[1])return!1;const jt=parseInt(B[1],10);return n.has(jt)});W.length>0&&T.push({node:C,matches:W})}}if(T.length===0){f=!1;return}const k=[];T.forEach(({node:C,matches:L})=>{g.add(C);const M=C.textContent||"",F=document.createDocumentFragment();let z=0;L.forEach(W=>{if(!W[1])return;W.index!==void 0&&W.index>z&&F.appendChild(document.createTextNode(M.slice(z,W.index)));const B=document.createElement("span");B.className="inline-flex items-center citation-button-container";const jt=parseInt(W[1],10);B.setAttribute("data-citation",W[1]),F.appendChild(B),k.push({element:B,citationNum:jt}),z=(W.index||0)+W[0].length}),z<M.length&&F.appendChild(document.createTextNode(M.slice(z))),C.parentNode&&C.parentNode.replaceChild(F,C)}),k.length>0&&c(C=>{const L=new Set(C.map(z=>z.element)),M=C.filter(z=>z.element.isConnected),F=k.filter(z=>!L.has(z.element));return[...M,...F]}),f=!1},v=new MutationObserver(()=>{clearTimeout(d),d=setTimeout(y,100)});return v.observe(l,{childList:!0,subtree:!0,characterData:!0}),d=setTimeout(y,200),()=>{v.disconnect(),clearTimeout(d)}},[t,e,n]);const u=s?h.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[h.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-2",children:"References"}),h.jsx("div",{className:"text-xs text-stone-600 dark:text-stone-400 space-y-1",children:Array.from(n.entries()).sort(([l],[d])=>l-d).map(([l,d])=>h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("span",{className:"font-medium",children:["[",l,"]"]}),h.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline break-all",children:d})]},l))})]}):null;return h.jsxs("div",{className:o,children:[h.jsx("div",{ref:r,children:h.jsx(i,{children:t})}),a.filter(({element:l})=>l.isConnected).map(({element:l,citationNum:d},f)=>e.find(y=>y.number===d)?Qa.createPortal(h.jsx(tf,{sources:e.map(y=>({number:y.number,url:y.url,domain:nf(y.url)})),citationNumber:d},`citation-${d}-${l}`),l,`citation-${d}-${f}`):null),u]})}function nf(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function sf(t){let e=t.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=e.match(n),i=new Map,o=[];if(s&&s[1]){const g=s[1],y=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let v;for(;(v=y.exec(g))!==null;)if(v[1]&&v[2]){const A=parseInt(v[1],10),x=v[2].replace(/[.,;:!?]+$/,"");i.set(A,x),o.push({number:A,url:x})}}let r,a=e;s&&s[0]&&(r=s[0],a=e.replace(n,""));const c=[];let u=0;const l=/```[\s\S]*?```|`[^`]+`/g;let d;for(;(d=l.exec(a))!==null;)d.index>u&&c.push({type:"text",content:a.slice(u,d.index),start:u,end:d.index}),c.push({type:"code",content:d[0],start:d.index,end:d.index+d[0].length}),u=d.index+d[0].length;return u<a.length&&c.push({type:"text",content:a.slice(u),start:u,end:a.length}),{processedText:c.map(g=>{if(g.type==="code")return g.content;let y=g.content;return y=y.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(A,x,w)=>{const T=parseInt(x,10);return i.has(T)||(i.set(T,w),o.push({number:T,url:w})),`[${T}]`}),y}).join(""),citations:o.sort((g,y)=>g.number-y.number),citationMap:i,referencesText:r}}function Ge(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ge(e)}catch{return t}if(Array.isArray(t))return t.map(Ge);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ge(s);return e}return t}function ss(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ge(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ge(t):{}}function rf({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:x,onStateChange:w,allowStateEdits:T=!0}){const[V,k]=m.useState(null),C=m.useRef(null),[L,M]=m.useState(null),[F,z]=m.useState(null),W=m.useRef(null),B=x!==void 0,[jt,Tt]=m.useState({}),rt=m.useRef({});B&&x?rt.current=x:B||(rt.current=jt);const[$t,U]=m.useState(!1),[ct,lt]=m.useState(null),ut=m.useRef(!1),[dt,Nt]=m.useState(u),[yt,he]=m.useState(r),[Jt,Zt]=m.useState(600),[Mt,Rt]=m.useState(!1),[H,fe]=m.useState(!1),[pt,Qt]=m.useState(!1),[gt,me]=m.useState({x:100,y:100}),[St,Re]=m.useState(!1),[te,pe]=m.useState({x:0,y:0}),[In,ge]=m.useState(!1),ee=m.useRef(null),ye=m.useRef(null),[xe,Ie]=m.useState(""),[Le,Ln]=m.useState(null),[On,Fn]=m.useState("Thinking..."),[Oe,P]=m.useState(new Set),[j,N]=m.useState(""),[O,K]=m.useState([]),[_,st]=m.useState(!1),[It,ne]=m.useState([]),[Et,Fe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,an]=m.useState(!1),[cf,cn]=m.useState(!1),[lf,ln]=m.useState([]),di=m.useCallback(async(p,b=3)=>{if(!Et||!C.current)return;const E=async()=>{const D=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Et,updates:p},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const Z=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${Z}`)}};for(let S=0;S<b;S++)try{await E(),lt(null);return}catch(D){if(S===b-1){const Z=D instanceof Error?D:new Error(String(D));throw lt(Z),console.error("Failed to sync state to Convex after retries:",D),Z}await new Promise(Z=>setTimeout(Z,Math.pow(2,S)*100))}},[Et,v,C]),Be=m.useMemo(()=>function(){return rt.current},[]),$e=m.useMemo(()=>async function(b){const E={...rt.current,...b};rt.current=E,B||Tt(E),w&&w(E);try{await di(b)}catch(S){throw S}},[di,w,B]);m.useEffect(()=>{B&&x&&(rt.current=x)},[B,x]);const se=m.useMemo(()=>{const p=[...l,...d,Be];return(!B||T)&&p.push($e),p},[l,d,Be,$e,B,T]),Bn=m.useMemo(()=>Ta(se,f),[se,f]),Lt=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!B||T)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Bn,...p]},[Bn,B,T]),hi=m.useMemo(()=>new Set(Lt.map(p=>p.name)),[Lt]),un=m.useMemo(()=>Lt.filter(p=>p.name==="getState"?!0:p.name==="setState"?!B||T:hi.has(p.name)),[Lt,hi,B,T]),dn=m.useMemo(()=>{const p=new Map,b=new Map(Bn.map(E=>[E.name,E]));return p.set("getState",Be),(!B||T)&&p.set("setState",$e),se.forEach(E=>{if(E===Be||E===$e)return;const S=E[Dt];if(S){const R=b.get(S);if(R){p.set(R.name,E);return}}const D=Lt.find(R=>R.name===E.name);D&&p.set(D.name,E)}),p},[se,Lt,Be,$e,B,T]),ze=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(Lt.map(E=>[E.name,E]));return d.forEach(E=>{const S=E[Dt];if(S&&b.has(S))p.add(S);else{const D=Lt.find(R=>R.name===E.name);D&&p.add(D.name)}}),p},[d,Lt]),fi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Nt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&he(parseInt(b));const E=localStorage.getItem("arcten-sidebar-height");E&&Zt(parseInt(E));const S=localStorage.getItem("arcten-sidebar-detached");S&&fe(JSON.parse(S));const D=localStorage.getItem("arcten-sidebar-position");if(D){const Z=JSON.parse(D),$=50,Q=Math.max($-r,Math.min(Z.x,window.innerWidth-$)),X=Math.max(0,Math.min(Z.y,window.innerHeight-$));me({x:Q,y:X})}const R=localStorage.getItem("arcten-sidebar-minimized");R&&Qt(JSON.parse(R)),ge(!0)}},[]);const zt=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:zt})});if(!b.ok)throw new Error("Failed to fetch token");const E=await b.json();k(E.clientToken),C.current=E.clientToken,z(E.expiresAt),M(null)}catch(b){M(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{W.current&&clearTimeout(W.current)}),[y,zt]),m.useEffect(()=>{if(!F)return;W.current&&clearTimeout(W.current);const p=Math.floor(Date.now()/1e3),b=F-p,S=Math.max(0,b-5);return W.current=setTimeout(async()=>{try{const D=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:zt})});if(!D.ok)throw new Error("Failed to refresh token");const R=await D.json();k(R.clientToken),C.current=R.clientToken,z(R.expiresAt),M(null)}catch(D){console.error("Token refresh failed:",D),M(D instanceof Error?D.message:"Failed to refresh token")}},S*1e3),()=>{W.current&&clearTimeout(W.current)}},[F,y,zt]),m.useEffect(()=>{(async()=>{if(se.length!==0)try{const b=se.map(S=>({name:S.name,code:S.toString()})),E=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(E.ok){const S=await E.json();K(S.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[se]),m.useEffect(()=>{Promise.resolve().then(()=>Xh).then(p=>{Ln(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{N(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const $n=m.useCallback(async()=>{if(!(!zt?.id||!V)){cn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${V}`}})).json();ne(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{cn(!1)}}},[zt?.id,V,v]);m.useEffect(()=>{zt?.id&&V&&$n()},[zt?.id,V,$n]);function ja(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ma(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1);const b=B?x||{}:{};rt.current=b,B||Tt(b),w&&w(b),ut.current=!1}async function Ea(p){if(V)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${V}`}}),ne(It.filter(b=>b._id!==p)),p===Et&&Ma()}catch(b){console.error("Failed to delete conversation:",b)}}async function ka(p){Fe(p.chatId),an(!1),cn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${C.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];fn(S),ln(S)}catch(b){console.error("Failed to load conversation messages:",b);const E=p.messages||[];fn(E),ln(E)}finally{cn(!1)}}const Da=async(p,b={})=>{const E=b.headers?new Headers(b.headers):new Headers;return E.delete("user-agent"),E.delete("User-Agent"),fetch(p,{...b,headers:E})},{messages:Ut,sendMessage:Va,status:kt,error:mi,stop:hn,addToolResult:ie,setMessages:fn}=Lr.useChat({id:Et||void 0,transport:new An.DefaultChatTransport({api:`${v}/chat`,fetch:Da,headers:()=>{const p={};return C.current&&(p.Authorization=`Bearer ${C.current}`),p},body:()=>({tools:un.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:j,state:rt.current})}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=Ut[Ut.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(E=>E.type?.startsWith("tool-")&&E.state==="input-available"&&typeof E.toolCallId=="string"&&E.input!==void 0)||[];for(const E of b){const S=E,D=S.type?.replace("tool-","")||"",R=S.toolCallId;if(ze.has(D)){if(Oe.has(R))continue;P($=>$.has(R)?$:new Set($).add(R)),(async()=>{try{const $=dn.get(D);if(!$){console.warn(`[ArctenAgent] Tool ${D} not found in toolsMap. Available tools:`,Array.from(dn.keys())),ie({toolCallId:R,tool:D,output:`Error: Tool ${D} not found`}),P(ot=>{const _t=new Set(ot);return _t.delete(R),_t});return}const Q=ss(S.input),X=un.find(ot=>ot.name===D);let ht;if(X&&X.jsonSchema?.properties){const _t=Object.keys(X.jsonSchema.properties).map(za=>Q[za]);console.log(`[ArctenAgent] Executing safe tool ${D} with args:`,_t),ht=await $(..._t)}else if(D==="getState")ht=$();else if(D==="setState"){const ot=Q.updates||Q;ht=await $(ot)}else ht=await $(...Object.values(Q));console.log(`[ArctenAgent] Tool ${D} completed, result:`,ht),ie({toolCallId:R,tool:D,output:ht}),P(ot=>{const _t=new Set(ot);return _t.delete(R),_t})}catch($){console.error(`[ArctenAgent] Error executing safe tool ${D}:`,$),ie({toolCallId:R,tool:D,output:`Error: ${$ instanceof Error?$.message:String($)}`}),P(Q=>{const X=new Set(Q);return X.delete(R),X})}})()}}},[Ut,ze,dn,un,ie]),m.useEffect(()=>{if(!Et||!C.current)return;(async()=>{U(!0),lt(null);try{const E=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:Et},format:"json"})});if(!S.ok){if(S.status===404||S.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${S.status}), using empty state`);const X=B?x||{}:{};rt.current=X,B||Tt(X),w&&w(X),ut.current=!0,U(!1);return}const Q=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${S.status} ${Q}`)}const R=(await S.json())?.value||{},Z=!ut.current;let $;Z?($={...B?x||{}:{},...R},ut.current=!0):$=R,rt.current=$,B||Tt($),w&&w($)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const S=b instanceof Error?b:new Error(String(b));if(lt(S),!ut.current){const D=B?x||{}:{};rt.current=D,B||Tt(D),w&&w(D),ut.current=!0}}finally{U(!1)}})()},[Et,v,B,x,w]),m.useEffect(()=>{dt&&ye.current&&ye.current.focus()},[dt,Ut]);function Na(){Nt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ra(){Nt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[dt]),m.useEffect(()=>{ee.current&&ee.current.scrollIntoView({behavior:"smooth"})},[Ut]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(kt==="streaming"||kt==="submitted")&&(b.preventDefault(),hn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[kt,hn]);function Ia(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1)}function pi(p){if(p.preventDefault(),!xe.trim())return;(kt==="streaming"||kt==="submitted")&&hn();const b=fi[Math.floor(Math.random()*fi.length)]||"Thinking...";Fn(b),Va({text:xe}),Ie("")}function La(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(E){if(H){const S=E.clientX-gt.x,D=E.clientY-gt.y;S>=a&&S<=c&&he(S),D>=400&&D<=1e3&&Zt(D)}else{const S=window.innerWidth-E.clientX;S>=a&&S<=c&&he(S)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Jt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Jt,H,gt,a,c]);function Oa(p){p.preventDefault(),Rt(!0)}function Fa(){fe(!0),Qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ba(){fe(!1),Qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function gi(){Qt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function $a(p){H&&(Re(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!H)return;function p(){me(b=>{const S=window.innerWidth-50,D=window.innerHeight-50,R=50-yt,Z=0,$=Math.max(R,Math.min(b.x,S)),Q=Math.max(Z,Math.min(b.y,D));if($!==b.x||Q!==b.y){const X={x:$,y:Q};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(X)),X}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[H,yt]),m.useEffect(()=>{if(!St)return;function p(E){const S=E.clientX-te.x,D=E.clientY-te.y,R=50,Z=window.innerWidth-R,$=window.innerHeight-R,Q=R-yt,X=0,ht=Math.max(Q,Math.min(S,Z)),ot=Math.max(X,Math.min(D,$));me({x:ht,y:ot})}function b(){Re(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,te,gt,yt]),In?L?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",L]})}):V?h.jsx(au,{features:Oh,children:h.jsx(xn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:H?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:H?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
20
|
${H?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
21
21
|
${dt?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
22
22
|
${H?"border border-border":"border-l border-border"}
|
|
23
23
|
${dt?"":"w-[30px]"}
|
|
24
|
-
`,style:dt?H?{width:`${yt}px`,height:pt?"auto":`${Jt}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:dt?void 0:Na,children:dt?h.jsxs(h.Fragment,{children:[!H&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Oa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),H&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Re(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${H?"cursor-move":""}`,onMouseDown:H?$a:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${H&&pt?"cursor-pointer":""}`,onClick:H&&pt?p=>{p.stopPropagation(),gi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ia,"aria-label":"New chat",children:h.jsx(et.Plus,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:"Start a new conversation"})]}),h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:H?Ba:Fa,"aria-label":H?"Dock sidebar":"Float sidebar",children:H?h.jsx(et.Dock,{className:"h-4 w-4"}):h.jsx(et.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:H?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:H?gi:Ra,"aria-label":H?pt?"Maximize":"Minimize":"Close sidebar",children:H?pt?h.jsx(et.Maximize2,{className:"h-4 w-4"}):h.jsx(et.Minimize2,{className:"h-4 w-4"}):h.jsx(et.X,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:H?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&It.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Cn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||$n(),an(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:It.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:nt(oe({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ka(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ja(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),Ea(p._id)},"aria-label":"Delete conversation",children:h.jsx(et.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:Ut.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),O.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(_?O:O.slice(0,10)).map(p=>h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ye.current?.focus()},children:p.friendlyName})}),h.jsx(Ht,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),O.length>10&&!_&&h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsxs(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>st(!0),children:["+",O.length-10," more"]})}),h.jsx(Ht,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:O.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),_&&O.length>10&&h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>st(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[Ut.map(p=>{const E=p.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Fh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:E}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,D)=>{if(S.type?.startsWith("tool-")){const R=S.type?.replace("tool-","")||"",Z=un.find(G=>G.name===R),$=S.state==="input-available",Q=S.state==="output-available";if($&&ze.has(R),$){if(ze.has(R))return null;const G=ss(S.input);return h.jsx(xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(zh,{toolName:R,description:Z?.description||"",args:G,onApprove:async()=>{if(Oe.has(S.toolCallId))return;P(ot=>new Set(ot).add(S.toolCallId));const ht=dn.get(R);if(ht)try{const ot=await ht(...Object.values(G));ie({toolCallId:S.toolCallId,tool:R,output:ot})}catch(ot){ie({toolCallId:S.toolCallId,tool:R,output:`Error: ${ot}`})}},onDeny:async()=>{Oe.has(S.toolCallId)||(P(ht=>new Set(ht).add(S.toolCallId)),ie({toolCallId:S.toolCallId,tool:R,output:"User denied tool execution"}))}})},`${S.toolCallId}-${D}`)}else if(Q){const G=S.output==="User denied tool execution",ht=ss(S.input);return h.jsx(Uh,{toolName:R,args:ht,isDenied:G,isSafe:ze.has(R)},`${S.toolCallId}-${D}`)}return null}if(S.type==="text"&&S.text&&Le){const{processedText:R,citations:Z,citationMap:$,referencesText:Q}=sf(S.text);return h.jsx(ef,{text:R,citations:Z,citationMap:$,referencesText:Q,ResponseComponent:Le,className:"text-sm prose prose-sm dark:prose-invert max-w-none"},`${p.id}-${D}`)}return S.type==="reasoning"&&S.text?h.jsxs(Aa,{className:"w-full",isStreaming:kt==="streaming"&&D===p.parts.length-1&&p.id===Ut.at(-1)?.id,children:[h.jsx(Ca,{}),h.jsx(Pa,{children:S.text})]},`${p.id}-${D}`):null})})})},p.id)}),h.jsx("div",{ref:ee})]})}),mi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",mi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(ou,{mode:"wait",children:(kt==="streaming"||kt==="submitted")&&h.jsxs(xn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(xn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:On})]})}),h.jsxs("form",{onSubmit:pi,className:"relative",children:[h.jsx(Br,{ref:ye,value:xe,onChange:La,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),pi(p))}}),kt==="streaming"||kt==="submitted"?h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:hn,children:h.jsx(et.Square,{className:"h-4 w-4"})})}),h.jsxs(Ht,{children:[h.jsx(vi,{children:"Escape"})," to stop"]})]}):h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"submit",className:nt(oe({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xe.trim(),children:h.jsx(et.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Ht,{children:[h.jsx(vi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(et.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function qe(t){if(typeof t=="string")try{const e=JSON.parse(t);return qe(e)}catch{return t}if(Array.isArray(t))return t.map(qe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=qe(s);return e}return t}function of(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return qe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?qe(t):{}}function af({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:y}={}){const[v,A]=m.useState(n||null),x=m.useRef(n||null),[w,T]=m.useState(null),[V,k]=m.useState(null),C=m.useRef(null),[L,M]=m.useState([]),[F,z]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[W,B]=m.useState(!1),[jt,Tt]=m.useState(new Set),[rt,$t]=m.useState(d),U=m.useRef(d),[ct,lt]=m.useState(!1),[ut,dt]=m.useState(null),Nt=m.useRef(!1),yt=m.useCallback(async(P,j=3)=>{if(!F||!x.current)return;const N=async()=>{const K=`${t.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,_=await fetch(K,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:F,updates:P},format:"json"})});if(!_.ok){if(_.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const st=await _.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${_.status} ${st}`)}};for(let O=0;O<j;O++)try{await N(),dt(null);return}catch(K){if(O===j-1){const st=K instanceof Error?K:new Error(String(K));throw dt(st),console.error("Failed to sync state to Convex after retries:",K),st}await new Promise(st=>setTimeout(st,Math.pow(2,O)*100))}},[F,t,x]),he=m.useMemo(()=>function(){return U.current},[]),Jt=m.useMemo(()=>async function(j){const N={...U.current,...j};U.current=N,$t(N);try{await yt(j)}catch(O){throw O}},[yt]),Zt=m.useMemo(()=>[...o,...r,he,Jt],[o,r,he,Jt]),Mt=m.useMemo(()=>Ta(Zt,a),[Zt,a]),Rt=m.useMemo(()=>{const P=new Map,j=new Map(Mt.map(N=>[N.name,N]));return Zt.forEach(N=>{const O=N[Dt];if(O){const _=j.get(O);if(_){P.set(_.name,N);return}}const K=Mt.find(_=>_.name===N.name);K&&P.set(K.name,N)}),P},[Zt,Mt]),H=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),fe=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>fe.filter(P=>P.name==="getState"||P.name==="setState"?!0:H.has(P.name)),[fe,H]),Qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(j=>{for(const[N,O]of Rt.entries())if(O===j){P.add(N);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const j=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!j.ok)throw new Error("Failed to fetch token");const N=await j.json();A(N.clientToken),x.current=N.clientToken,k(N.expiresAt),T(null)}catch(j){console.error("[useAgent] Token fetch failed:",j),T(j instanceof Error?j.message:"Failed to fetch token")}})(),()=>{C.current&&clearTimeout(C.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!V||s||n)return;C.current&&clearTimeout(C.current);const P=Math.floor(Date.now()/1e3),j=V-P,O=Math.max(0,j-5);return C.current=setTimeout(async()=>{try{const K=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!K.ok)throw new Error("Failed to refresh token");const _=await K.json();A(_.clientToken),x.current=_.clientToken,k(_.expiresAt),T(null)}catch(K){console.error("[useAgent] Token refresh failed:",K),T(K instanceof Error?K.message:"Failed to refresh token")}},O*1e3),()=>{C.current&&clearTimeout(C.current)}},[V,e,JSON.stringify(i),s,n]);const gt=async(P,j={})=>{const N=j.headers?new Headers(j.headers):new Headers;N.delete("user-agent"),N.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",j.method||"GET"),console.log("[useAgent] Has Authorization header:",N.has("Authorization")),console.log("[useAgent] Client token available:",!!x.current);try{const O=await fetch(P,{...j,headers:N});if(!O.ok){console.error("[useAgent] Request failed:",O.status,O.statusText);const K=await O.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",K)}return O}catch(O){throw console.error("[useAgent] Fetch error:",O),O}},me=`${t}/chat`;console.log("[useAgent] Chat API URL:",me);const{messages:St,sendMessage:Re,status:te,error:pe,stop:In,addToolResult:ge,setMessages:ee}=Lr.useChat({id:F||void 0,messages:u,transport:new An.DefaultChatTransport({api:me,fetch:gt,headers:()=>{const P={};return x.current?(P.Authorization=`Bearer ${x.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(N=>({name:N.name,description:N.description,inputSchema:N.jsonSchema})),j=P.filter(N=>N.name==="getState"||N.name==="setState").map(N=>N.name);return j.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",j),{tools:P,systemPrompt:c,state:U.current,...y&&{ragFilters:y}}}}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(j=>{if(!j.type?.startsWith("tool-")||j.state!=="input-available")return;const N=j.type.replace("tool-",""),O=j.toolCallId;if(jt.has(O))return;Tt(_=>new Set(_).add(O));const K=of(j.input);if(Qt.has(N)){const _=Rt.get(N);_?(async()=>{try{const st=pt.find(ne=>ne.name===N);let It;if(st&&st.jsonSchema?.properties){const Et=Object.keys(st.jsonSchema.properties).map(Fe=>K[Fe]);It=await _(...Et)}else if(N==="getState")It=_();else if(N==="setState"){const ne=K.updates||K;It=await _(ne)}else It=await _(...Object.values(K));ge({toolCallId:O,tool:N,output:It})}catch(st){console.error(`[useAgent] Error executing tool ${N}:`,st),ge({toolCallId:O,tool:N,output:`Error: ${st}`})}})():console.warn(`[useAgent] Tool ${N} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:O,toolName:N,args:K}})})})},[St,Qt,Rt,f,ge,jt,Jt,pt]),m.useEffect(()=>{if(te==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!pe})}},[te,St,pe,g]);async function ye(){if(!(!i?.id||!v)){B(!0);try{const j=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();M(j.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{B(!1)}}}m.useEffect(()=>{i?.id&&v&&ye()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!F||!x.current)return;(async()=>{lt(!0),dt(null);try{const j=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:F},format:"json"})});if(!j.ok){const st=await j.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${j.status} ${st}`)}const O=(await j.json())?.value||{},K=!Nt.current;let _;K?(_={...d,...O},Nt.current=!0):_=O,U.current=_,$t(_)}catch(j){console.error("Failed to fetch state:",j);const N=j instanceof Error?j:new Error(String(j));dt(N),Nt.current||(U.current=d,$t(d),Nt.current=!0)}finally{lt(!1)}})()},[F,t]);async function xe(P){z(P),B(!0);try{const j=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${x.current}`}});if(!j.ok)throw new Error(`Failed to fetch messages: ${j.statusText}`);const O=(await j.json()).messages||[];ee(O)}catch(j){console.error("Failed to load conversation messages:",j)}finally{B(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),M(L.filter(j=>j._id!==P)),P===F&&Le()}catch(j){console.error("Failed to delete conversation:",j)}}function Le(){const P=crypto.randomUUID();z(P),ee([]),Tt(new Set),U.current=d,$t(d),Nt.current=!1}function Ln(P){ge(P)}async function On(P){const j={...U.current,...P};U.current=j,$t(j);try{await yt(P)}catch(N){throw N}}async function Fn(){if(!i?.id||!x.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:U.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(j){throw console.error("Failed to share state:",j),j}}async function Oe(P){if(!x.current)throw new Error("Authentication required to import state");try{const j=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!j.ok)throw new Error("Failed to fetch shared state");const O=(await j.json())?.value||{};U.current=O,$t(O)}catch(j){throw console.error("Failed to import state:",j),j}}return{id:F,messages:St,status:te,error:pe,sendMessage:Re,stop:In,addToolOutput:Ln,setMessages:ee,conversations:L,loadConversation:xe,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:W,clientToken:v,tokenError:w,state:rt,setState:On,shareState:Fn,importState:Oe,isStateLoading:ct,stateError:ut}}exports.verifyToken=tc.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Dt;exports.ArctenAgent=rf;exports.preserveToolName=Bh;exports.useAgent=af;
|
|
24
|
+
`,style:dt?H?{width:`${yt}px`,height:pt?"auto":`${Jt}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:dt?void 0:Na,children:dt?h.jsxs(h.Fragment,{children:[!H&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Oa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),H&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Re(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${H?"cursor-move":""}`,onMouseDown:H?$a:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${H&&pt?"cursor-pointer":""}`,onClick:H&&pt?p=>{p.stopPropagation(),gi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ia,"aria-label":"New chat",children:h.jsx(et.Plus,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:"Start a new conversation"})]}),h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:H?Ba:Fa,"aria-label":H?"Dock sidebar":"Float sidebar",children:H?h.jsx(et.Dock,{className:"h-4 w-4"}):h.jsx(et.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:H?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:H?gi:Ra,"aria-label":H?pt?"Maximize":"Minimize":"Close sidebar",children:H?pt?h.jsx(et.Maximize2,{className:"h-4 w-4"}):h.jsx(et.Minimize2,{className:"h-4 w-4"}):h.jsx(et.X,{className:"h-4 w-4"})})}),h.jsx(Ht,{children:H?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&It.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Cn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||$n(),an(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:It.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:nt(oe({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ka(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ja(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),Ea(p._id)},"aria-label":"Delete conversation",children:h.jsx(et.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:Ut.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),O.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(_?O:O.slice(0,10)).map(p=>h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ye.current?.focus()},children:p.friendlyName})}),h.jsx(Ht,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),O.length>10&&!_&&h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsxs(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>st(!0),children:["+",O.length-10," more"]})}),h.jsx(Ht,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:O.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),_&&O.length>10&&h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>st(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[Ut.map(p=>{const E=p.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Fh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:E}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,D)=>{if(S.type?.startsWith("tool-")){const R=S.type?.replace("tool-","")||"",Z=un.find(X=>X.name===R),$=S.state==="input-available",Q=S.state==="output-available";if($&&ze.has(R),$){if(ze.has(R))return null;const X=ss(S.input);return h.jsx(xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(zh,{toolName:R,description:Z?.description||"",args:X,onApprove:async()=>{if(Oe.has(S.toolCallId))return;P(ot=>new Set(ot).add(S.toolCallId));const ht=dn.get(R);if(ht)try{const ot=await ht(...Object.values(X));ie({toolCallId:S.toolCallId,tool:R,output:ot})}catch(ot){ie({toolCallId:S.toolCallId,tool:R,output:`Error: ${ot}`})}},onDeny:async()=>{Oe.has(S.toolCallId)||(P(ht=>new Set(ht).add(S.toolCallId)),ie({toolCallId:S.toolCallId,tool:R,output:"User denied tool execution"}))}})},`${S.toolCallId}-${D}`)}else if(Q){const X=S.output==="User denied tool execution",ht=ss(S.input);return h.jsx(Uh,{toolName:R,args:ht,isDenied:X,isSafe:ze.has(R)},`${S.toolCallId}-${D}`)}return null}if(S.type==="text"&&S.text&&Le){const{processedText:R,citations:Z,citationMap:$,referencesText:Q}=sf(S.text);return h.jsx(ef,{text:R,citations:Z,citationMap:$,referencesText:Q,ResponseComponent:Le,className:"text-sm prose prose-sm dark:prose-invert max-w-none"},`${p.id}-${D}`)}return S.type==="reasoning"&&S.text?h.jsxs(Aa,{className:"w-full",isStreaming:kt==="streaming"&&D===p.parts.length-1&&p.id===Ut.at(-1)?.id,children:[h.jsx(Ca,{}),h.jsx(Pa,{children:S.text})]},`${p.id}-${D}`):null})})})},p.id)}),h.jsx("div",{ref:ee})]})}),mi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",mi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(ou,{mode:"wait",children:(kt==="streaming"||kt==="submitted")&&h.jsxs(xn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(xn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:On})]})}),h.jsxs("form",{onSubmit:pi,className:"relative",children:[h.jsx(Br,{ref:ye,value:xe,onChange:La,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),pi(p))}}),kt==="streaming"||kt==="submitted"?h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"button",className:nt(oe({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:hn,children:h.jsx(et.Square,{className:"h-4 w-4"})})}),h.jsxs(Ht,{children:[h.jsx(vi,{children:"Escape"})," to stop"]})]}):h.jsxs(Wt,{children:[h.jsx(Kt,{asChild:!0,children:h.jsx("button",{type:"submit",className:nt(oe({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xe.trim(),children:h.jsx(et.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Ht,{children:[h.jsx(vi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(et.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function qe(t){if(typeof t=="string")try{const e=JSON.parse(t);return qe(e)}catch{return t}if(Array.isArray(t))return t.map(qe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=qe(s);return e}return t}function of(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return qe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?qe(t):{}}function af({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:y}={}){const[v,A]=m.useState(n||null),x=m.useRef(n||null),[w,T]=m.useState(null),[V,k]=m.useState(null),C=m.useRef(null),[L,M]=m.useState([]),[F,z]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[W,B]=m.useState(!1),[jt,Tt]=m.useState(new Set),[rt,$t]=m.useState(d),U=m.useRef(d),[ct,lt]=m.useState(!1),[ut,dt]=m.useState(null),Nt=m.useRef(!1),yt=m.useCallback(async(P,j=3)=>{if(!F||!x.current)return;const N=async()=>{const K=`${t.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,_=await fetch(K,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:F,updates:P},format:"json"})});if(!_.ok){if(_.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const st=await _.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${_.status} ${st}`)}};for(let O=0;O<j;O++)try{await N(),dt(null);return}catch(K){if(O===j-1){const st=K instanceof Error?K:new Error(String(K));throw dt(st),console.error("Failed to sync state to Convex after retries:",K),st}await new Promise(st=>setTimeout(st,Math.pow(2,O)*100))}},[F,t,x]),he=m.useMemo(()=>function(){return U.current},[]),Jt=m.useMemo(()=>async function(j){const N={...U.current,...j};U.current=N,$t(N);try{await yt(j)}catch(O){throw O}},[yt]),Zt=m.useMemo(()=>[...o,...r,he,Jt],[o,r,he,Jt]),Mt=m.useMemo(()=>Ta(Zt,a),[Zt,a]),Rt=m.useMemo(()=>{const P=new Map,j=new Map(Mt.map(N=>[N.name,N]));return Zt.forEach(N=>{const O=N[Dt];if(O){const _=j.get(O);if(_){P.set(_.name,N);return}}const K=Mt.find(_=>_.name===N.name);K&&P.set(K.name,N)}),P},[Zt,Mt]),H=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),fe=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>fe.filter(P=>P.name==="getState"||P.name==="setState"?!0:H.has(P.name)),[fe,H]),Qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(j=>{for(const[N,O]of Rt.entries())if(O===j){P.add(N);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const j=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!j.ok)throw new Error("Failed to fetch token");const N=await j.json();A(N.clientToken),x.current=N.clientToken,k(N.expiresAt),T(null)}catch(j){console.error("[useAgent] Token fetch failed:",j),T(j instanceof Error?j.message:"Failed to fetch token")}})(),()=>{C.current&&clearTimeout(C.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!V||s||n)return;C.current&&clearTimeout(C.current);const P=Math.floor(Date.now()/1e3),j=V-P,O=Math.max(0,j-5);return C.current=setTimeout(async()=>{try{const K=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!K.ok)throw new Error("Failed to refresh token");const _=await K.json();A(_.clientToken),x.current=_.clientToken,k(_.expiresAt),T(null)}catch(K){console.error("[useAgent] Token refresh failed:",K),T(K instanceof Error?K.message:"Failed to refresh token")}},O*1e3),()=>{C.current&&clearTimeout(C.current)}},[V,e,JSON.stringify(i),s,n]);const gt=async(P,j={})=>{const N=j.headers?new Headers(j.headers):new Headers;N.delete("user-agent"),N.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",j.method||"GET"),console.log("[useAgent] Has Authorization header:",N.has("Authorization")),console.log("[useAgent] Client token available:",!!x.current);try{const O=await fetch(P,{...j,headers:N});if(!O.ok){console.error("[useAgent] Request failed:",O.status,O.statusText);const K=await O.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",K)}return O}catch(O){throw console.error("[useAgent] Fetch error:",O),O}},me=`${t}/chat`;console.log("[useAgent] Chat API URL:",me);const{messages:St,sendMessage:Re,status:te,error:pe,stop:In,addToolResult:ge,setMessages:ee}=Lr.useChat({id:F||void 0,messages:u,transport:new An.DefaultChatTransport({api:me,fetch:gt,headers:()=>{const P={};return x.current?(P.Authorization=`Bearer ${x.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(N=>({name:N.name,description:N.description,inputSchema:N.jsonSchema})),j=P.filter(N=>N.name==="getState"||N.name==="setState").map(N=>N.name);return j.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",j),{tools:P,systemPrompt:c,state:U.current,...y&&{ragFilters:y}}}}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(j=>{if(!j.type?.startsWith("tool-")||j.state!=="input-available")return;const N=j.type.replace("tool-",""),O=j.toolCallId;if(jt.has(O))return;Tt(_=>new Set(_).add(O));const K=of(j.input);if(Qt.has(N)){const _=Rt.get(N);_?(async()=>{try{const st=pt.find(ne=>ne.name===N);let It;if(st&&st.jsonSchema?.properties){const Et=Object.keys(st.jsonSchema.properties).map(Fe=>K[Fe]);It=await _(...Et)}else if(N==="getState")It=_();else if(N==="setState"){const ne=K.updates||K;It=await _(ne)}else It=await _(...Object.values(K));ge({toolCallId:O,tool:N,output:It})}catch(st){console.error(`[useAgent] Error executing tool ${N}:`,st),ge({toolCallId:O,tool:N,output:`Error: ${st}`})}})():console.warn(`[useAgent] Tool ${N} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:O,toolName:N,args:K}})})})},[St,Qt,Rt,f,ge,jt,Jt,pt]),m.useEffect(()=>{if(te==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!pe})}},[te,St,pe,g]);async function ye(){if(!(!i?.id||!v)){B(!0);try{const j=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();M(j.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{B(!1)}}}m.useEffect(()=>{i?.id&&v&&ye()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!F||!x.current)return;(async()=>{lt(!0),dt(null);try{const j=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:F},format:"json"})});if(!j.ok){const st=await j.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${j.status} ${st}`)}const O=(await j.json())?.value||{},K=!Nt.current;let _;K?(_={...d,...O},Nt.current=!0):_=O,U.current=_,$t(_)}catch(j){console.error("Failed to fetch state:",j);const N=j instanceof Error?j:new Error(String(j));dt(N),Nt.current||(U.current=d,$t(d),Nt.current=!0)}finally{lt(!1)}})()},[F,t]);async function xe(P){z(P),B(!0);try{const j=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${x.current}`}});if(!j.ok)throw new Error(`Failed to fetch messages: ${j.statusText}`);const O=(await j.json()).messages||[];ee(O)}catch(j){console.error("Failed to load conversation messages:",j)}finally{B(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),M(L.filter(j=>j._id!==P)),P===F&&Le()}catch(j){console.error("Failed to delete conversation:",j)}}function Le(){const P=crypto.randomUUID();z(P),ee([]),Tt(new Set),U.current=d,$t(d),Nt.current=!1}function Ln(P){ge(P)}async function On(P){const j={...U.current,...P};U.current=j,$t(j);try{await yt(P)}catch(N){throw N}}async function Fn(){if(!i?.id||!x.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:U.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(j){throw console.error("Failed to share state:",j),j}}async function Oe(P){if(!x.current)throw new Error("Authentication required to import state");try{const j=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!j.ok)throw new Error("Failed to fetch shared state");const O=(await j.json())?.value||{};U.current=O,$t(O)}catch(j){throw console.error("Failed to import state:",j),j}}return{id:F,messages:St,status:te,error:pe,sendMessage:Re,stop:In,addToolOutput:Ln,setMessages:ee,conversations:L,loadConversation:xe,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:W,clientToken:v,tokenError:w,state:rt,setState:On,shareState:Fn,importState:Oe,isStateLoading:ct,stateError:ut}}exports.verifyToken=tc.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Dt;exports.ArctenAgent=rf;exports.preserveToolName=Bh;exports.useAgent=af;
|
package/dist/index.mjs
CHANGED
|
@@ -5347,16 +5347,12 @@ Oa.displayName = "Reasoning";
|
|
|
5347
5347
|
ja.displayName = "ReasoningTrigger";
|
|
5348
5348
|
Fa.displayName = "ReasoningContent";
|
|
5349
5349
|
function Ur(t) {
|
|
5350
|
-
|
|
5351
|
-
return e.includes("youtube") ? { icon: "▶", color: "#FF0000" } : e.includes("ted") ? { icon: "TED", color: "#E62B1E" } : e.includes("github") ? { icon: "GitHub", color: "#181717" } : e.includes("twitter") || e.includes("x.com") ? { icon: "𝕏", color: "#000000" } : { icon: t.split(".")[0] || t };
|
|
5350
|
+
return `https://www.google.com/s2/favicons?domain=${encodeURIComponent(t)}&sz=16`;
|
|
5352
5351
|
}
|
|
5353
5352
|
function Af({ sources: t, citationNumber: e, className: n }) {
|
|
5354
|
-
const s = t.find((
|
|
5353
|
+
const s = t.find((o) => o.number === e);
|
|
5355
5354
|
if (!s) return null;
|
|
5356
|
-
const i = Ur(s.domain)
|
|
5357
|
-
...r,
|
|
5358
|
-
iconInfo: Ur(r.domain)
|
|
5359
|
-
}));
|
|
5355
|
+
const i = Ur(s.domain);
|
|
5360
5356
|
return /* @__PURE__ */ k(Xt, { children: [
|
|
5361
5357
|
/* @__PURE__ */ f(Yt, { asChild: !0, children: /* @__PURE__ */ k(
|
|
5362
5358
|
"button",
|
|
@@ -5371,11 +5367,22 @@ function Af({ sources: t, citationNumber: e, className: n }) {
|
|
|
5371
5367
|
"leading-tight",
|
|
5372
5368
|
n
|
|
5373
5369
|
),
|
|
5374
|
-
onClick: (
|
|
5375
|
-
|
|
5370
|
+
onClick: (o) => {
|
|
5371
|
+
o.preventDefault(), o.stopPropagation(), window.open(s.url, "_blank", "noopener,noreferrer");
|
|
5376
5372
|
},
|
|
5377
5373
|
children: [
|
|
5378
|
-
/* @__PURE__ */ f(
|
|
5374
|
+
/* @__PURE__ */ f(
|
|
5375
|
+
"img",
|
|
5376
|
+
{
|
|
5377
|
+
src: i,
|
|
5378
|
+
alt: "",
|
|
5379
|
+
className: "w-3 h-3 leading-none",
|
|
5380
|
+
onError: (o) => {
|
|
5381
|
+
const r = o.target;
|
|
5382
|
+
r.style.display = "none";
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
),
|
|
5379
5386
|
/* @__PURE__ */ f("span", { className: "leading-none", children: s.domain })
|
|
5380
5387
|
]
|
|
5381
5388
|
}
|
|
@@ -5388,32 +5395,36 @@ function Af({ sources: t, citationNumber: e, className: n }) {
|
|
|
5388
5395
|
children: /* @__PURE__ */ k("div", { className: "space-y-1.5", children: [
|
|
5389
5396
|
/* @__PURE__ */ k("div", { className: "text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600", children: [
|
|
5390
5397
|
"Sources • ",
|
|
5391
|
-
|
|
5398
|
+
t.length
|
|
5392
5399
|
] }),
|
|
5393
|
-
|
|
5400
|
+
t.map((o) => /* @__PURE__ */ k(
|
|
5394
5401
|
"a",
|
|
5395
5402
|
{
|
|
5396
|
-
href:
|
|
5403
|
+
href: o.url,
|
|
5397
5404
|
target: "_blank",
|
|
5398
5405
|
rel: "noopener noreferrer",
|
|
5399
5406
|
className: rt(
|
|
5400
5407
|
"flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors",
|
|
5401
5408
|
"text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"
|
|
5402
5409
|
),
|
|
5403
|
-
onClick: (
|
|
5410
|
+
onClick: (r) => r.stopPropagation(),
|
|
5404
5411
|
children: [
|
|
5405
5412
|
/* @__PURE__ */ f(
|
|
5406
|
-
"
|
|
5413
|
+
"img",
|
|
5407
5414
|
{
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5415
|
+
src: Ur(o.domain),
|
|
5416
|
+
alt: "",
|
|
5417
|
+
className: "w-4 h-4 flex-shrink-0",
|
|
5418
|
+
onError: (r) => {
|
|
5419
|
+
const a = r.target;
|
|
5420
|
+
a.style.display = "none";
|
|
5421
|
+
}
|
|
5411
5422
|
}
|
|
5412
5423
|
),
|
|
5413
|
-
/* @__PURE__ */ f("span", { className: "text-xs flex-1 truncate", children:
|
|
5424
|
+
/* @__PURE__ */ f("span", { className: "text-xs flex-1 truncate", children: o.domain })
|
|
5414
5425
|
]
|
|
5415
5426
|
},
|
|
5416
|
-
|
|
5427
|
+
o.number
|
|
5417
5428
|
))
|
|
5418
5429
|
] })
|
|
5419
5430
|
}
|